Skip to content

Commit

Permalink
[unity]qjs backend compile
Browse files Browse the repository at this point in the history
  • Loading branch information
chexiongsheng committed Dec 16, 2020
1 parent 336bb84 commit 417068a
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
26 changes: 26 additions & 0 deletions unity/native_src/make_android_qjs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
if [ -n "$ANDROID_NDK" ]; then
export NDK=${ANDROID_NDK}
elif [ -n "$ANDROID_NDK_HOME" ]; then
export NDK=${ANDROID_NDK_HOME}
else
export NDK=~/android-ndk-r21b
fi

if [ ! -d "$NDK" ]; then
echo "Please set ANDROID_NDK environment to the root of NDK."
exit 1
fi

function build() {
API=$1
ABI=$2
TOOLCHAIN_ANME=$3
BUILD_PATH=build.qjs.Android.${ABI}
cmake -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON -DJS_ENGINE=quickjs -DANDROID_ABI=${ABI} -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON -H. -B${BUILD_PATH} -DCMAKE_TOOLCHAIN_FILE=${NDK}/build/cmake/android.toolchain.cmake -DANDROID_NATIVE_API_LEVEL=${API} -DANDROID_TOOLCHAIN=clang -DANDROID_TOOLCHAIN_NAME=${TOOLCHAIN_ANME}
cmake --build ${BUILD_PATH} --config Release
mkdir -p ../Assets/Plugins/Android/libs/${ABI}/
cp ${BUILD_PATH}/libpuerts.so ../Assets/Plugins/Android/libs/${ABI}/libpuerts.so
}

build android-18 armeabi-v7a arm-linux-androideabi-4.9
build android-18 arm64-v8a arm-linux-androideabi-clang
8 changes: 8 additions & 0 deletions unity/native_src/make_ios_qjs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
mkdir -p build_ios_qjs && cd build_ios_qjs
cmake -DJS_ENGINE=quickjs -DCMAKE_TOOLCHAIN_FILE=../cmake/ios.toolchain.cmake -DPLATFORM=OS64 -GXcode ../
cd ..
cmake --build build_ios_qjs --config Release
mkdir -p ../Assets/Plugins/iOS/
cp build_ios_qjs/Release-iphoneos/libpuerts.a ../Assets/Plugins/iOS/
cp quickjs/Lib/iOS/arm64/*.a ../Assets/Plugins/iOS/

7 changes: 7 additions & 0 deletions unity/native_src/make_osx_qjs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
mkdir -p build_osx_qjs && cd build_osx_qjs
cmake -DJS_ENGINE=quickjs -GXcode ../
cd ..
cmake --build build_osx_qjs --config Release
mkdir -p ../Assets/Plugins/
cp -r build_osx_qjs/Release/puerts.bundle ../Assets/Plugins/

0 comments on commit 417068a

Please sign in to comment.