mirror of
https://github.com/gitui-org/gitui
synced 2026-05-23 08:58:21 +00:00
Merge 621ff5b4bf into 8619c07f3f
This commit is contained in:
commit
0857b59bae
4 changed files with 99 additions and 21 deletions
|
|
@ -22,5 +22,39 @@ good first issue, you can take a look at [issues labelled with
|
|||
too much context so that people not familiar with the codebase yet can still
|
||||
make a contribution.
|
||||
|
||||
## Cross-compiling for OpenHarmony
|
||||
|
||||
GitUI can be built for OpenHarmony (target `aarch64-unknown-linux-ohos`). This requires the OpenHarmony SDK native toolchain.
|
||||
|
||||
Download the SDK command-line tools from [HarmonyOS Developer](https://developer.huawei.com/consumer/cn/download/command-line-tools-for-hmos). After installation, the default SDK path is typically:
|
||||
|
||||
- Linux: `~/command-line-tools/sdk/default/openharmony`
|
||||
- macOS: `~/Library/command-line-tools/sdk/default/openharmony`
|
||||
|
||||
First, install the `aarch64-unknown-linux-ohos` Rust target:
|
||||
|
||||
```sh
|
||||
rustup target add aarch64-unknown-linux-ohos
|
||||
```
|
||||
|
||||
Set the following environment variables (adjust paths to your OHOS SDK location):
|
||||
|
||||
```sh
|
||||
export OHOS_SDK=/path/to/ohos-sdk
|
||||
export CC_aarch64_unknown_linux_ohos="$OHOS_SDK/native/llvm/bin/clang"
|
||||
export CXX_aarch64_unknown_linux_ohos="$OHOS_SDK/native/llvm/bin/clang++"
|
||||
export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_OHOS_LINKER="$OHOS_SDK/native/llvm/bin/clang"
|
||||
export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_OHOS_AR="$OHOS_SDK/native/llvm/bin/llvm-ar"
|
||||
export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_OHOS_RUSTFLAGS="-C link-arg=--sysroot=$OHOS_SDK/native/sysroot -C link-arg=-L$OHOS_SDK/native/sysroot/usr/lib/aarch64-linux-ohos -C link-arg=-Wl,--allow-multiple-definition -C link-arg=-Wl,--undefined-version -C link-arg=-Wl,--defsym=__xpg_strerror_r=0"
|
||||
```
|
||||
|
||||
Then build:
|
||||
|
||||
```sh
|
||||
cargo build --target aarch64-unknown-linux-ohos --release
|
||||
```
|
||||
|
||||
> **Note:** On OpenHarmony the user/process model is sandbox-based. GitUI automatically disables libgit2's owner validation on OHOS targets to avoid spurious "not owned by current user" errors.
|
||||
|
||||
[discord-server]: https://discord.gg/rZv4uxSQx3
|
||||
[good-first-issues]: https://github.com/gitui-org/gitui/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22
|
||||
|
|
|
|||
|
|
@ -1,11 +1,12 @@
|
|||
use crate::{
|
||||
error::Result,
|
||||
sync::{
|
||||
gix_repo, repo, CommitId, LogWalker, LogWalkerWithoutFilter,
|
||||
RepoPath, SharedCommitFilterFn,
|
||||
repo, CommitId, LogWalker, RepoPath, SharedCommitFilterFn,
|
||||
},
|
||||
AsyncGitNotification, Error,
|
||||
};
|
||||
#[cfg(not(target_env = "ohos"))]
|
||||
use crate::sync::{gix_repo, LogWalkerWithoutFilter};
|
||||
use crossbeam_channel::Sender;
|
||||
use scopetime::scope_time;
|
||||
use std::{
|
||||
|
|
@ -200,25 +201,45 @@ impl AsyncLog {
|
|||
sender: &Sender<AsyncGitNotification>,
|
||||
filter: Option<SharedCommitFilterFn>,
|
||||
) -> Result<()> {
|
||||
filter.map_or_else(
|
||||
|| {
|
||||
Self::fetch_helper_without_filter(
|
||||
repo_path,
|
||||
arc_current,
|
||||
arc_background,
|
||||
sender,
|
||||
)
|
||||
},
|
||||
|filter| {
|
||||
Self::fetch_helper_with_filter(
|
||||
repo_path,
|
||||
arc_current,
|
||||
arc_background,
|
||||
sender,
|
||||
filter,
|
||||
)
|
||||
},
|
||||
)
|
||||
#[cfg(target_env = "ohos")]
|
||||
{
|
||||
Self::fetch_helper_with_filter(
|
||||
repo_path,
|
||||
arc_current,
|
||||
arc_background,
|
||||
sender,
|
||||
filter.unwrap_or_else(|| {
|
||||
Arc::new(Box::new(
|
||||
|_: &git2::Repository, _: &CommitId| {
|
||||
Ok(true)
|
||||
},
|
||||
))
|
||||
}),
|
||||
)
|
||||
}
|
||||
|
||||
#[cfg(not(target_env = "ohos"))]
|
||||
{
|
||||
filter.map_or_else(
|
||||
|| {
|
||||
Self::fetch_helper_without_filter(
|
||||
repo_path,
|
||||
arc_current,
|
||||
arc_background,
|
||||
sender,
|
||||
)
|
||||
},
|
||||
|filter| {
|
||||
Self::fetch_helper_with_filter(
|
||||
repo_path,
|
||||
arc_current,
|
||||
arc_background,
|
||||
sender,
|
||||
filter,
|
||||
)
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fn fetch_helper_with_filter(
|
||||
|
|
@ -265,6 +286,7 @@ impl AsyncLog {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(not(target_env = "ohos"))]
|
||||
fn fetch_helper_without_filter(
|
||||
repo_path: &RepoPath,
|
||||
arc_current: &Arc<Mutex<AsyncLogResult>>,
|
||||
|
|
|
|||
|
|
@ -7,6 +7,22 @@ use git2::{Repository, RepositoryOpenFlags};
|
|||
|
||||
use crate::error::Result;
|
||||
|
||||
#[cfg(target_env = "ohos")]
|
||||
use std::sync::Once;
|
||||
|
||||
#[cfg(target_env = "ohos")]
|
||||
static INIT_OHOS: Once = Once::new();
|
||||
|
||||
#[cfg(target_env = "ohos")]
|
||||
pub(crate) fn init_ohos_owner_validation() {
|
||||
INIT_OHOS.call_once(|| {
|
||||
#[allow(unsafe_code)]
|
||||
unsafe {
|
||||
git2::opts::set_verify_owner_validation(false).ok();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
///
|
||||
pub type RepoPathRef = RefCell<RepoPath>;
|
||||
|
||||
|
|
@ -55,6 +71,9 @@ impl From<&str> for RepoPath {
|
|||
}
|
||||
|
||||
pub fn repo(repo_path: &RepoPath) -> Result<Repository> {
|
||||
#[cfg(target_env = "ohos")]
|
||||
init_ohos_owner_validation();
|
||||
|
||||
let repo = Repository::open_ext(
|
||||
repo_path.gitpath(),
|
||||
RepositoryOpenFlags::FROM_ENV,
|
||||
|
|
|
|||
|
|
@ -26,6 +26,9 @@ pub struct Head {
|
|||
|
||||
///
|
||||
pub fn repo_open_error(repo_path: &RepoPath) -> Option<String> {
|
||||
#[cfg(target_env = "ohos")]
|
||||
super::repository::init_ohos_owner_validation();
|
||||
|
||||
if let Err(e) = Repository::open_ext(
|
||||
repo_path.gitpath(),
|
||||
RepositoryOpenFlags::FROM_ENV,
|
||||
|
|
|
|||
Loading…
Reference in a new issue