HMDemo/cppLib/build.bat

50 lines
1.3 KiB
Batchfile
Raw Normal View History

2024-04-23 11:02:19 +08:00
@echo off
chcp 65001 > nul
2024-06-25 15:00:04 +08:00
set "native_path=C:\Program Files\Huawei\DevEco Studio5\sdk\HarmonyOS-NEXT-DB1\openharmony\native\"
:: IF NOT "%~2" == "" (
:: set "native_path=%~2"
:: )
echo native_path: "%native_path%"
2024-04-23 11:02:19 +08:00
2024-06-25 15:00:04 +08:00
set "toolchain=%native_path%build\cmake\ohos.toolchain.cmake"
echo toolchain: "%toolchain%"
2024-06-25 15:00:04 +08:00
set "cmake_root=%native_path%build-tools\cmake\"
echo cmake_root: "%cmake_root%"
2024-06-25 15:00:04 +08:00
set "cmake_path=%cmake_root%bin\cmake.exe"
echo cmake_path: "%cmake_path%"
2024-06-25 15:00:04 +08:00
set "ninja_path=%cmake_root%bin\ninja.exe"
echo ninja_path: "%ninja_path%"
2024-06-25 15:00:04 +08:00
set "make_path=C:\MinGW\msys\1.0\bin\make.exe"
echo make_path: %make_path%
2024-06-25 15:00:04 +08:00
set "arch=arm64-v8a"
2024-06-25 20:46:40 +08:00
IF NOT "%~1" == "" (
set "arch=%~1"
)
echo arch: "%arch%"
2024-06-25 15:00:04 +08:00
2024-04-23 11:02:19 +08:00
if exist build (
del /q /s build
) else (
mkdir build
)
if exist dist (
2024-05-28 20:05:06 +08:00
cd dist
if exist "%arch%" (
del /q /s ""%arch%"
)
2024-05-28 20:06:18 +08:00
cd ../
2024-04-23 11:02:19 +08:00
)
cd build
:: 使用 make 构建
2024-06-25 20:46:40 +08:00
:: "%cmake_path%" -G "Unix Makefiles" -DCMAKE_MAKE_PROGRAM="%make_path%" -DOHOS_STL=c++_static -DOHOS_ARCH="%arch%" -DOHOS_PLATFORM=OHOS -DCMAKE_TOOLCHAIN_FILE="%toolchain%" ..
2024-04-23 11:02:19 +08:00
:: %make_path%
:: 使用 ninja 构建
2024-06-25 20:46:40 +08:00
"%cmake_path%" -G "Ninja" -D CMAKE_MAKE_PROGRAM="%ninja_path%" -D OHOS_STL=c++_static -D OHOS_ARCH="%arch%" -D OHOS_PLATFORM=OHOS -D CMAKE_TOOLCHAIN_FILE="%toolchain%" ..
2024-06-25 15:00:04 +08:00
"%ninja_path%"
2024-04-23 11:02:19 +08:00
cd ../