Skip to content

Commit

Permalink
Use commandline tools for macOS to build for HarmonyOS
Browse files Browse the repository at this point in the history
  • Loading branch information
csukuangfj committed Nov 22, 2024
1 parent e424cc9 commit 2db62a8
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 60 deletions.
45 changes: 25 additions & 20 deletions build-ohos-arm64-v8a.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ cd $dir
# rm commandline-tools-linux-x64-5.0.5.200.zip
if [ -z $OHOS_SDK_NATIVE_DIR ]; then
OHOS_SDK_NATIVE_DIR=/star-fj/fangjun/software/huawei/command-line-tools/sdk/default/openharmony/native/
export PATH=$OHOS_SDK_NATIVE_DIR/build-tools/cmake/bin:$PATH
# You can find the following content inside OHOS_SDK_NATIVE_DIR
# ls -lh /star-fj/fangjun/software/huawei/command-line-tools/sdk/default/openharmony/native/
# total 524K
Expand All @@ -35,32 +34,39 @@ if [ -z $OHOS_SDK_NATIVE_DIR ]; then
# drwxr-xr-x 3 kuangfangjun root 0 Nov 6 22:36 sysroot
fi

# If you don't want to install commandline tools, you can install the SDK
# using DevEco Studio. The following uses API version 10 as an example and
# it has installed the SDK to
# /Users/fangjun/software/huawei/OpenHarmony/Sdk/10/native
#
# Remember to select ``native`` when you install the SDK
if [ ! -d $OHOS_SDK_NATIVE_DIR ]; then
OHOS_SDK_NATIVE_DIR=/Users/fangjun/software/huawei/OpenHarmony/Sdk/10/native
# export PATH=$OHOS_SDK_NATIVE_DIR/build-tools/cmake/bin:$PATH
# ls -lh /Users/fangjun/software/huawei/OpenHarmony/Sdk/10/native/
# total 1560
# -rw-r--r-- 1 fangjun staff 764K Jan 1 2001 NOTICE.txt
# drwxr-xr-x 3 fangjun staff 96B Nov 19 22:42 build
# drwxr-xr-x 3 fangjun staff 96B Nov 19 22:42 build-tools
# drwxr-xr-x 10 fangjun staff 320B Nov 19 22:42 llvm
# -rw-r--r-- 1 fangjun staff 4.0K Jan 1 2001 nativeapi_syscap_config.json
# -rw-r--r-- 1 fangjun staff 1.9K Jan 1 2001 ndk_system_capability.json
# -rw-r--r-- 1 fangjun staff 169B Jan 1 2001 oh-uni-package.json
# drwxr-xr-x 3 fangjun staff 96B Nov 19 22:42 sysroot
OHOS_SDK_NATIVE_DIR=/Users/fangjun/software/command-line-tools/sdk/default/openharmony/native
# (py38) fangjuns-MacBook-Pro:software fangjun$ ls -lh command-line-tools/sdk/default/openharmony/native/
# total 752
# -rw-r--r-- 1 fangjun staff 341K Jan 1 2001 NOTICE.txt
# drwxr-xr-x 3 fangjun staff 96B Nov 6 21:17 build
# drwxr-xr-x 3 fangjun staff 96B Nov 6 21:18 build-tools
# -rw-r--r-- 1 fangjun staff 371B Jan 1 2001 compatible_config.json
# drwxr-xr-x 10 fangjun staff 320B Nov 6 21:18 llvm
# -rw-r--r-- 1 fangjun staff 16K Jan 1 2001 nativeapi_syscap_config.json
# -rw-r--r-- 1 fangjun staff 5.9K Jan 1 2001 ndk_system_capability.json
# -rw-r--r-- 1 fangjun staff 167B Jan 1 2001 oh-uni-package.json
# drwxr-xr-x 3 fangjun staff 96B Nov 6 21:17 sysroot
fi

if [ ! -d $OHOS_SDK_NATIVE_DIR ]; then
echo "Please first download Command Line Tools for HarmonyOS"
echo "See https://developer.huawei.com/consumer/cn/download/"
echo "or"
echo "https://hf-mirror.com/csukuangfj/harmonyos-commandline-tools/tree/main"
exit 1
fi

if [ ! -f $OHOS_SDK_NATIVE_DIR/llvm/bin/aarch64-unknown-linux-ohos-clang ]; then
echo "$OHOS_SDK_NATIVE_DIR/llvm/bin/aarch64-unknown-linux-ohos-clang does not exist"
echo "Please first download Command Line Tools for HarmonyOS"
echo "See https://developer.huawei.com/consumer/cn/download/"
echo "or"
echo "https://hf-mirror.com/csukuangfj/harmonyos-commandline-tools/tree/main"
exit 1
fi

export PATH=$OHOS_SDK_NATIVE_DIR/build-tools/cmake/bin:$PATH
export PATH=$OHOS_SDK_NATIVE_DIR/llvm/bin:$PATH

OHOS_TOOLCHAIN_FILE=$OHOS_SDK_NATIVE_DIR/build/cmake/ohos.toolchain.cmake
Expand All @@ -71,7 +77,6 @@ if [ ! -f $OHOS_TOOLCHAIN_FILE ]; then
exit 1
fi


sleep 1
onnxruntime_version=1.16.3
onnxruntime_dir=onnxruntime-ohos-arm64-v8a-$onnxruntime_version
Expand Down
31 changes: 11 additions & 20 deletions build-ohos-armeabi-v7a.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,32 +35,24 @@ if [ -z $OHOS_SDK_NATIVE_DIR ]; then
# drwxr-xr-x 3 kuangfangjun root 0 Nov 6 22:36 sysroot
fi

# If you don't want to install commandline tools, you can install the SDK
# using DevEco Studio. The following uses API version 10 as an example and
# it has installed the SDK to
# /Users/fangjun/software/huawei/OpenHarmony/Sdk/10/native
#
# Remember to select ``native`` when you install the SDK
if [ ! -d $OHOS_SDK_NATIVE_DIR ]; then
OHOS_SDK_NATIVE_DIR=/Users/fangjun/software/huawei/OpenHarmony/Sdk/10/native
# export PATH=$OHOS_SDK_NATIVE_DIR/build-tools/cmake/bin:$PATH
# ls -lh /Users/fangjun/software/huawei/OpenHarmony/Sdk/10/native/
# total 1560
# -rw-r--r-- 1 fangjun staff 764K Jan 1 2001 NOTICE.txt
# drwxr-xr-x 3 fangjun staff 96B Nov 19 22:42 build
# drwxr-xr-x 3 fangjun staff 96B Nov 19 22:42 build-tools
# drwxr-xr-x 10 fangjun staff 320B Nov 19 22:42 llvm
# -rw-r--r-- 1 fangjun staff 4.0K Jan 1 2001 nativeapi_syscap_config.json
# -rw-r--r-- 1 fangjun staff 1.9K Jan 1 2001 ndk_system_capability.json
# -rw-r--r-- 1 fangjun staff 169B Jan 1 2001 oh-uni-package.json
# drwxr-xr-x 3 fangjun staff 96B Nov 19 22:42 sysroot
echo "Please first download Command Line Tools for HarmonyOS"
echo "See https://developer.huawei.com/consumer/cn/download/"
echo "or"
echo "https://hf-mirror.com/csukuangfj/harmonyos-commandline-tools/tree/main"
exit 1
fi

if [ ! -d $OHOS_SDK_NATIVE_DIR ]; then
if [ ! -f $OHOS_SDK_NATIVE_DIR/llvm/bin/armv7-unknown-linux-ohos-clang ]; then
echo "$OHOS_SDK_NATIVE_DIR/llvm/bin/armv7-unknown-linux-ohos-clang does not exist"
echo "Please first download Command Line Tools for HarmonyOS"
echo "See https://developer.huawei.com/consumer/cn/download/"
echo "or"
echo "https://hf-mirror.com/csukuangfj/harmonyos-commandline-tools/tree/main"
exit 1
fi

export PATH=$OHOS_SDK_NATIVE_DIR/build-tools/cmake/bin:$PATH
export PATH=$OHOS_SDK_NATIVE_DIR/llvm/bin:$PATH

OHOS_TOOLCHAIN_FILE=$OHOS_SDK_NATIVE_DIR/build/cmake/ohos.toolchain.cmake
Expand All @@ -71,7 +63,6 @@ if [ ! -f $OHOS_TOOLCHAIN_FILE ]; then
exit 1
fi


sleep 1
onnxruntime_version=1.16.3
onnxruntime_dir=onnxruntime-ohos-armeabi-v7a-$onnxruntime_version
Expand Down
45 changes: 25 additions & 20 deletions build-ohos-x86-64.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ cd $dir
# rm commandline-tools-linux-x64-5.0.5.200.zip
if [ -z $OHOS_SDK_NATIVE_DIR ]; then
OHOS_SDK_NATIVE_DIR=/star-fj/fangjun/software/huawei/command-line-tools/sdk/default/openharmony/native/
export PATH=$OHOS_SDK_NATIVE_DIR/build-tools/cmake/bin:$PATH
# You can find the following content inside OHOS_SDK_NATIVE_DIR
# ls -lh /star-fj/fangjun/software/huawei/command-line-tools/sdk/default/openharmony/native/
# total 524K
Expand All @@ -35,32 +34,39 @@ if [ -z $OHOS_SDK_NATIVE_DIR ]; then
# drwxr-xr-x 3 kuangfangjun root 0 Nov 6 22:36 sysroot
fi

# If you don't want to install commandline tools, you can install the SDK
# using DevEco Studio. The following uses API version 10 as an example and
# it has installed the SDK to
# /Users/fangjun/software/huawei/OpenHarmony/Sdk/10/native
#
# Remember to select ``native`` when you install the SDK
if [ ! -d $OHOS_SDK_NATIVE_DIR ]; then
OHOS_SDK_NATIVE_DIR=/Users/fangjun/software/huawei/OpenHarmony/Sdk/10/native
# export PATH=$OHOS_SDK_NATIVE_DIR/build-tools/cmake/bin:$PATH
# ls -lh /Users/fangjun/software/huawei/OpenHarmony/Sdk/10/native/
# total 1560
# -rw-r--r-- 1 fangjun staff 764K Jan 1 2001 NOTICE.txt
# drwxr-xr-x 3 fangjun staff 96B Nov 19 22:42 build
# drwxr-xr-x 3 fangjun staff 96B Nov 19 22:42 build-tools
# drwxr-xr-x 10 fangjun staff 320B Nov 19 22:42 llvm
# -rw-r--r-- 1 fangjun staff 4.0K Jan 1 2001 nativeapi_syscap_config.json
# -rw-r--r-- 1 fangjun staff 1.9K Jan 1 2001 ndk_system_capability.json
# -rw-r--r-- 1 fangjun staff 169B Jan 1 2001 oh-uni-package.json
# drwxr-xr-x 3 fangjun staff 96B Nov 19 22:42 sysroot
OHOS_SDK_NATIVE_DIR=/Users/fangjun/software/command-line-tools/sdk/default/openharmony/native
# (py38) fangjuns-MacBook-Pro:software fangjun$ ls -lh command-line-tools/sdk/default/openharmony/native/
# total 752
# -rw-r--r-- 1 fangjun staff 341K Jan 1 2001 NOTICE.txt
# drwxr-xr-x 3 fangjun staff 96B Nov 6 21:17 build
# drwxr-xr-x 3 fangjun staff 96B Nov 6 21:18 build-tools
# -rw-r--r-- 1 fangjun staff 371B Jan 1 2001 compatible_config.json
# drwxr-xr-x 10 fangjun staff 320B Nov 6 21:18 llvm
# -rw-r--r-- 1 fangjun staff 16K Jan 1 2001 nativeapi_syscap_config.json
# -rw-r--r-- 1 fangjun staff 5.9K Jan 1 2001 ndk_system_capability.json
# -rw-r--r-- 1 fangjun staff 167B Jan 1 2001 oh-uni-package.json
# drwxr-xr-x 3 fangjun staff 96B Nov 6 21:17 sysroot
fi

if [ ! -d $OHOS_SDK_NATIVE_DIR ]; then
echo "Please first download Command Line Tools for HarmonyOS"
echo "See https://developer.huawei.com/consumer/cn/download/"
echo "or"
echo "https://hf-mirror.com/csukuangfj/harmonyos-commandline-tools/tree/main"
exit 1
fi

if [ ! -f $OHOS_SDK_NATIVE_DIR/llvm/bin/x86_64-unknown-linux-ohos-clang ]; then
echo "$OHOS_SDK_NATIVE_DIR/llvm/bin/x86_64-unknown-linux-ohos-clang does not exist"
echo "Please first download Command Line Tools for HarmonyOS"
echo "See https://developer.huawei.com/consumer/cn/download/"
echo "or"
echo "https://hf-mirror.com/csukuangfj/harmonyos-commandline-tools/tree/main"
exit 1
fi

export PATH=$OHOS_SDK_NATIVE_DIR/build-tools/cmake/bin:$PATH
export PATH=$OHOS_SDK_NATIVE_DIR/llvm/bin:$PATH

OHOS_TOOLCHAIN_FILE=$OHOS_SDK_NATIVE_DIR/build/cmake/ohos.toolchain.cmake
Expand All @@ -71,7 +77,6 @@ if [ ! -f $OHOS_TOOLCHAIN_FILE ]; then
exit 1
fi


sleep 1
onnxruntime_version=1.16.3
onnxruntime_dir=onnxruntime-ohos-x86_64-$onnxruntime_version
Expand Down

0 comments on commit 2db62a8

Please sign in to comment.