From 1036bc3f4a069c1abb3afbc00cd05441adb5dad9 Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Mon, 2 Dec 2024 20:28:14 +0800 Subject: [PATCH 1/7] :art: Support HarmonyOS NEXT system --- kernel/harmony/build-win.sh | 2 ++ kernel/harmony/build.sh | 2 ++ 2 files changed, 4 insertions(+) diff --git a/kernel/harmony/build-win.sh b/kernel/harmony/build-win.sh index 329b66bffbb..9f58d38501f 100755 --- a/kernel/harmony/build-win.sh +++ b/kernel/harmony/build-win.sh @@ -5,4 +5,6 @@ export CGO_ENABLED=1 export GOOS=android export GOARCH=amd64 export CC=/mnt/f/ohos-sdk-windows_linux-public/linux/native/llvm/bin/x86_64-unknown-linux-ohos-clang +export CGO_FLAGS = "-I/mnt/f/log-adaptor/include" +export CGO_LDFLAGS = "-L/mnt/f/log-adaptor//dist/x86_64" go build --tags fts5 -ldflags "-s -w" -buildmode=c-shared -v -o libkernel.so . diff --git a/kernel/harmony/build.sh b/kernel/harmony/build.sh index 5b229fa1c40..20a8622d300 100755 --- a/kernel/harmony/build.sh +++ b/kernel/harmony/build.sh @@ -5,4 +5,6 @@ export CGO_ENABLED=1 export GOOS=android export GOARCH=arm64 export CC=/mnt/f/ohos-sdk-windows_linux-public/linux/native/llvm/bin/aarch64-unknown-linux-ohos-clang +export CGO_FLAGS = "-I/mnt/f/log-adaptor/include" +export CGO_LDFLAGS = "-L/mnt/f/log-adaptor//dist/arm64-v8a" go build --tags fts5 -ldflags "-s -w" -buildmode=c-shared -v -o libkernel.so . From df19d66101a163b81abfc055ddb923bfab297f71 Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Mon, 2 Dec 2024 20:44:58 +0800 Subject: [PATCH 2/7] :art: Support HarmonyOS NEXT system --- kernel/harmony/build-win.sh | 4 ++-- kernel/harmony/build.sh | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/kernel/harmony/build-win.sh b/kernel/harmony/build-win.sh index 9f58d38501f..1624420a9c0 100755 --- a/kernel/harmony/build-win.sh +++ b/kernel/harmony/build-win.sh @@ -5,6 +5,6 @@ export CGO_ENABLED=1 export GOOS=android export GOARCH=amd64 export CC=/mnt/f/ohos-sdk-windows_linux-public/linux/native/llvm/bin/x86_64-unknown-linux-ohos-clang -export CGO_FLAGS = "-I/mnt/f/log-adaptor/include" -export CGO_LDFLAGS = "-L/mnt/f/log-adaptor//dist/x86_64" +export CGO_FLAGS="-I/mnt/f/log-adaptor/include" +export CGO_LDFLAGS="-L/mnt/f/log-adaptor//dist/x86_64" go build --tags fts5 -ldflags "-s -w" -buildmode=c-shared -v -o libkernel.so . diff --git a/kernel/harmony/build.sh b/kernel/harmony/build.sh index 20a8622d300..d1026565fab 100755 --- a/kernel/harmony/build.sh +++ b/kernel/harmony/build.sh @@ -5,6 +5,6 @@ export CGO_ENABLED=1 export GOOS=android export GOARCH=arm64 export CC=/mnt/f/ohos-sdk-windows_linux-public/linux/native/llvm/bin/aarch64-unknown-linux-ohos-clang -export CGO_FLAGS = "-I/mnt/f/log-adaptor/include" -export CGO_LDFLAGS = "-L/mnt/f/log-adaptor//dist/arm64-v8a" +export CGO_FLAGS="-I/mnt/f/log-adaptor/include" +export CGO_LDFLAGS="-L/mnt/f/log-adaptor//dist/arm64-v8a" go build --tags fts5 -ldflags "-s -w" -buildmode=c-shared -v -o libkernel.so . From 160143c275966a59b7d28512f84734cf5c9c95b3 Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Mon, 2 Dec 2024 21:12:21 +0800 Subject: [PATCH 3/7] :art: Support HarmonyOS NEXT system --- kernel/harmony/build-win.sh | 2 +- kernel/harmony/build.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/harmony/build-win.sh b/kernel/harmony/build-win.sh index 1624420a9c0..496c485996c 100755 --- a/kernel/harmony/build-win.sh +++ b/kernel/harmony/build-win.sh @@ -5,6 +5,6 @@ export CGO_ENABLED=1 export GOOS=android export GOARCH=amd64 export CC=/mnt/f/ohos-sdk-windows_linux-public/linux/native/llvm/bin/x86_64-unknown-linux-ohos-clang -export CGO_FLAGS="-I/mnt/f/log-adaptor/include" +export CGO_CFLAGS="-I/mnt/f/log-adaptor/include" export CGO_LDFLAGS="-L/mnt/f/log-adaptor//dist/x86_64" go build --tags fts5 -ldflags "-s -w" -buildmode=c-shared -v -o libkernel.so . diff --git a/kernel/harmony/build.sh b/kernel/harmony/build.sh index d1026565fab..5ac8c9f247a 100755 --- a/kernel/harmony/build.sh +++ b/kernel/harmony/build.sh @@ -5,6 +5,6 @@ export CGO_ENABLED=1 export GOOS=android export GOARCH=arm64 export CC=/mnt/f/ohos-sdk-windows_linux-public/linux/native/llvm/bin/aarch64-unknown-linux-ohos-clang -export CGO_FLAGS="-I/mnt/f/log-adaptor/include" +export CGO_CFLAGS="-I/mnt/f/log-adaptor/include" export CGO_LDFLAGS="-L/mnt/f/log-adaptor//dist/arm64-v8a" go build --tags fts5 -ldflags "-s -w" -buildmode=c-shared -v -o libkernel.so . From 204f2fd1db032b21876a6b800c3d233ac5290edd Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Mon, 2 Dec 2024 21:40:26 +0800 Subject: [PATCH 4/7] :art: Support HarmonyOS NEXT system --- kernel/harmony/build-win.sh | 23 ++++++++++++++++++++--- kernel/harmony/build.sh | 23 ++++++++++++++++++++--- 2 files changed, 40 insertions(+), 6 deletions(-) diff --git a/kernel/harmony/build-win.sh b/kernel/harmony/build-win.sh index 496c485996c..4e347f769bb 100755 --- a/kernel/harmony/build-win.sh +++ b/kernel/harmony/build-win.sh @@ -1,10 +1,27 @@ #!/bin/bash +export OHOS_NDK_HOME=/mnt/f/ohos-sdk-windows_linux-public/linux/ +export LOG_ADAPTOR_HOME=/mnt/f/log-adaptor + +export CC=$OHOS_NDK_HOME/native/llvm/bin/clang +export CXX=$OHOS_NDK_HOME/native/llvm/bin/clang++ +export AR=$OHOS_NDK_HOME/native/llvm/bin/llvm-ar +export AS=$OHOS_NDK_HOME/native/llvm/bin/llvm-as +export LD=$OHOS_NDK_HOME/native/llvm/bin/ld.lld +export STRIP=$OHOS_NDK_HOME/native/llvm/bin/llvm-strip +export RANLIB=$OHOS_NDK_HOME/native/llvm/bin/llvm-ranlib +export OBJDUMP=$OHOS_NDK_HOME/native/llvm/bin/llvm-objdump +export OBJCOPY=$OHOS_NDK_HOME/native/llvm/bin/llvm-objcopy +export NM=$OHOS_NDK_HOME/native/llvm/bin/llvm-nm +export CFLAGS="-target x86_64-linux-ohos --sysroot=${OHOS_NDK_HOME}/native/sysroot -D__MUSL__" +export CXXFLAGS="-target x86_64-linux-ohos --sysroot=${OHOS_NDK_HOME}/native/sysroot -D__MUSL__" +export LLVMCONFIG=$OHOS_NDK_HOME/native/llvm/bin/llvm-config + export GOPROXY=https://mirrors.aliyun.com/goproxy/ export CGO_ENABLED=1 export GOOS=android export GOARCH=amd64 -export CC=/mnt/f/ohos-sdk-windows_linux-public/linux/native/llvm/bin/x86_64-unknown-linux-ohos-clang -export CGO_CFLAGS="-I/mnt/f/log-adaptor/include" -export CGO_LDFLAGS="-L/mnt/f/log-adaptor//dist/x86_64" +export CGO_CFLAGS="-I${LOG_ADAPTOR_HOME}/include -g -O2 `$LLVMCONFIG --cflags` --target=x86_64-linux-ohos --sysroot=$OHOS_NDK_HOME/native/sysroot" +export CGO_LDFLAGS="--target=x86_64-linux-ohos -fuse-ld=lld -L${LOG_ADAPTOR_HOME}/dist/x86_64" + go build --tags fts5 -ldflags "-s -w" -buildmode=c-shared -v -o libkernel.so . diff --git a/kernel/harmony/build.sh b/kernel/harmony/build.sh index 5ac8c9f247a..3f84fdf59b8 100755 --- a/kernel/harmony/build.sh +++ b/kernel/harmony/build.sh @@ -1,10 +1,27 @@ #!/bin/bash +export OHOS_NDK_HOME=/mnt/f/ohos-sdk-windows_linux-public/linux/ +export LOG_ADAPTOR_HOME=/mnt/f/log-adaptor + +export CC=$OHOS_NDK_HOME/native/llvm/bin/clang +export CXX=$OHOS_NDK_HOME/native/llvm/bin/clang++ +export AR=$OHOS_NDK_HOME/native/llvm/bin/llvm-ar +export AS=$OHOS_NDK_HOME/native/llvm/bin/llvm-as +export LD=$OHOS_NDK_HOME/native/llvm/bin/ld.lld +export STRIP=$OHOS_NDK_HOME/native/llvm/bin/llvm-strip +export RANLIB=$OHOS_NDK_HOME/native/llvm/bin/llvm-ranlib +export OBJDUMP=$OHOS_NDK_HOME/native/llvm/bin/llvm-objdump +export OBJCOPY=$OHOS_NDK_HOME/native/llvm/bin/llvm-objcopy +export NM=$OHOS_NDK_HOME/native/llvm/bin/llvm-nm +export CFLAGS="-target aarch64-linux-ohos --sysroot=${OHOS_NDK_HOME}/native/sysroot -D__MUSL__" +export CXXFLAGS="-target aarch64-linux-ohos --sysroot=${OHOS_NDK_HOME}/native/sysroot -D__MUSL__" +export LLVMCONFIG=$OHOS_NDK_HOME/native/llvm/bin/llvm-config + export GOPROXY=https://mirrors.aliyun.com/goproxy/ export CGO_ENABLED=1 export GOOS=android export GOARCH=arm64 -export CC=/mnt/f/ohos-sdk-windows_linux-public/linux/native/llvm/bin/aarch64-unknown-linux-ohos-clang -export CGO_CFLAGS="-I/mnt/f/log-adaptor/include" -export CGO_LDFLAGS="-L/mnt/f/log-adaptor//dist/arm64-v8a" +export CGO_CFLAGS="-I${LOG_ADAPTOR_HOME}/include -g -O2 `$LLVMCONFIG --cflags` --target=aarch64-linux-ohos --sysroot=$OHOS_NDK_HOME/native/sysroot" +export CGO_LDFLAGS="--target=aarch64-linux-ohos -fuse-ld=lld -L${LOG_ADAPTOR_HOME}/dist/arm64-v8a" + go build --tags fts5 -ldflags "-s -w" -buildmode=c-shared -v -o libkernel.so . From f54195c7b4f118786024519b597887eb708133f4 Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Tue, 3 Dec 2024 00:08:46 +0800 Subject: [PATCH 5/7] :art: Support HarmonyOS NEXT system --- kernel/go.mod | 2 +- kernel/go.sum | 4 ++-- kernel/util/path.go | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/kernel/go.mod b/kernel/go.mod index 214309e8eb2..016fea61536 100644 --- a/kernel/go.mod +++ b/kernel/go.mod @@ -60,7 +60,7 @@ require ( github.com/siyuan-note/dejavu v0.0.0-20241124021155-df73bbaf4338 github.com/siyuan-note/encryption v0.0.0-20231219001248-1e028a4d13b4 github.com/siyuan-note/eventbus v0.0.0-20240627125516-396fdb0f0f97 - github.com/siyuan-note/filelock v0.0.0-20241121021809-1cf0626a7d64 + github.com/siyuan-note/filelock v0.0.0-20241202160444-1a99015900ff github.com/siyuan-note/httpclient v0.0.0-20241113084556-839baaab03f6 github.com/siyuan-note/logging v0.0.0-20240505035402-6430d57006a2 github.com/siyuan-note/riff v0.0.0-20241201090115-1c20f539f7ab diff --git a/kernel/go.sum b/kernel/go.sum index c3c6b5b7714..daf7033ab1b 100644 --- a/kernel/go.sum +++ b/kernel/go.sum @@ -347,8 +347,8 @@ github.com/siyuan-note/encryption v0.0.0-20231219001248-1e028a4d13b4 h1:kJaw5L/e github.com/siyuan-note/encryption v0.0.0-20231219001248-1e028a4d13b4/go.mod h1:UYcCCY+0wh+GmUoDOaO63j1sV5lgy7laLAk1XhEiUis= github.com/siyuan-note/eventbus v0.0.0-20240627125516-396fdb0f0f97 h1:lM5v8BfNtbOL5jYwhCdMYBcYtr06IYBKjjSLAPMKTM8= github.com/siyuan-note/eventbus v0.0.0-20240627125516-396fdb0f0f97/go.mod h1:1/nGgthl89FPA7GzAcEWKl6zRRnfgyTjzLZj9bW7kuw= -github.com/siyuan-note/filelock v0.0.0-20241121021809-1cf0626a7d64 h1:w4i1AumKqsUgMcuNKw5FkJjAWK8jXVKpvW1BkAJvB+0= -github.com/siyuan-note/filelock v0.0.0-20241121021809-1cf0626a7d64/go.mod h1:QUxfb/zE/lMrpiGBV9MBT5c5NKQanGvpdBXtMwWjTD0= +github.com/siyuan-note/filelock v0.0.0-20241202160444-1a99015900ff h1:Ec6Q5dI/q2uSiFxSkbHajLQgqQQ3mFYXwZKiOSldmE4= +github.com/siyuan-note/filelock v0.0.0-20241202160444-1a99015900ff/go.mod h1:QUxfb/zE/lMrpiGBV9MBT5c5NKQanGvpdBXtMwWjTD0= github.com/siyuan-note/httpclient v0.0.0-20241113084556-839baaab03f6 h1:IzvOUPUc6YbtLgQuj3rVVIdbn1HzDOGMsTLLb9yN0Wo= github.com/siyuan-note/httpclient v0.0.0-20241113084556-839baaab03f6/go.mod h1:cMXV74/pjFOvH3zIwQW/SyH3gZw8YzTBbqt7dxof69k= github.com/siyuan-note/logging v0.0.0-20240505035402-6430d57006a2 h1:/2+tlOThVB86RxSLeW0JFw2ISUrH2ZFRg15ULGAUGAE= diff --git a/kernel/util/path.go b/kernel/util/path.go index b8cf52d5e42..fc73895d00a 100644 --- a/kernel/util/path.go +++ b/kernel/util/path.go @@ -53,7 +53,7 @@ func ShortPathForBootingDisplay(p string) string { var LocalIPs []string func GetLocalIPs() (ret []string) { - if ContainerAndroid == Container { + if ContainerAndroid == Container || ContainerHarmony == Container { // Android 上用不了 net.InterfaceAddrs() https://github.com/golang/go/issues/40569,所以前面使用启动内核传入的参数 localIPs LocalIPs = append(LocalIPs, LocalHost) LocalIPs = gulu.Str.RemoveDuplicatedElem(LocalIPs) From 4cbe4684b80de66ad1a9bcf319f03f1308814287 Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Tue, 3 Dec 2024 00:15:50 +0800 Subject: [PATCH 6/7] :art: Support HarmonyOS NEXT system --- kernel/harmony/kernel.go | 1 + 1 file changed, 1 insertion(+) diff --git a/kernel/harmony/kernel.go b/kernel/harmony/kernel.go index fc9828997f7..7527d4ac473 100644 --- a/kernel/harmony/kernel.go +++ b/kernel/harmony/kernel.go @@ -45,6 +45,7 @@ func StartKernel(container, appDir, workspaceBaseDir, timezoneID, localIPs, lang util.Mode = "prod" util.MobileOSVer = C.GoString(osVer) util.LocalIPs = strings.Split(C.GoString(localIPs), ",") + filelock.Container = util.ContainerHarmony util.BootMobile(C.GoString(container), C.GoString(appDir), C.GoString(workspaceBaseDir), C.GoString(lang)) model.InitConf() From dcf77055524d414825e10a74816fb3eb1ecbe310 Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Tue, 3 Dec 2024 00:18:03 +0800 Subject: [PATCH 7/7] :art: Support HarmonyOS NEXT system --- kernel/harmony/kernel.go | 1 - kernel/util/working_mobile.go | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/kernel/harmony/kernel.go b/kernel/harmony/kernel.go index 7527d4ac473..fc9828997f7 100644 --- a/kernel/harmony/kernel.go +++ b/kernel/harmony/kernel.go @@ -45,7 +45,6 @@ func StartKernel(container, appDir, workspaceBaseDir, timezoneID, localIPs, lang util.Mode = "prod" util.MobileOSVer = C.GoString(osVer) util.LocalIPs = strings.Split(C.GoString(localIPs), ",") - filelock.Container = util.ContainerHarmony util.BootMobile(C.GoString(container), C.GoString(appDir), C.GoString(workspaceBaseDir), C.GoString(lang)) model.InitConf() diff --git a/kernel/util/working_mobile.go b/kernel/util/working_mobile.go index e54a29abd25..541b3d055d9 100644 --- a/kernel/util/working_mobile.go +++ b/kernel/util/working_mobile.go @@ -25,6 +25,7 @@ import ( "github.com/88250/gulu" figure "github.com/common-nighthawk/go-figure" + "github.com/siyuan-note/filelock" "github.com/siyuan-note/httpclient" "github.com/siyuan-note/logging" ) @@ -36,6 +37,7 @@ func BootMobile(container, appDir, workspaceBaseDir, lang string) { initHttpClient() ServerPort = FixedPort Container = container + filelock.Container = Container UserAgent = UserAgent + " " + Container + "/" + runtime.GOOS httpclient.SetUserAgent(UserAgent) Lang = lang