浏览代码

add android build scripts

/zgh-build_scripts
guanghuispark 3 年前
当前提交
1f851690
共有 6 个文件被更改,包括 223 次插入1 次删除
  1. 2
      engine/Scripts/full_build.sh
  2. 182
      engine/Scripts/lib_build_android.sh
  3. 23
      engine/Scripts/patches/android/BUILD.gn.patch
  4. 10
      engine/Scripts/patches/android/BUILD_2.gn.patch
  5. 7
      engine/Scripts/patches/android/rsp.patch

2
engine/Scripts/full_build.sh


done
case $platform in
"andorid") echo 'You select android'
"android") ./lib_build_android.sh -r $engine_path $optimize -p android -m $runtime_mode
;;
"ios") ./lib_build_ios.sh -r $engine_path $optimize -p ios -m $runtime_mode $bitcode
;;

182
engine/Scripts/lib_build_android.sh


work_path=$(pwd)
engine_path=
platform=
gn_params=""
optimize="--unoptimized"
ninja_params=""
runtime_mode=
echo "setting environment variable and other params..."
while getopts ":r:p:m:eo" opt
do
case $opt in
r)
engine_path=$OPTARG # set engine_path, depot_tools and flutter engine folder will be put into this path
;;
p)
gn_params="$gn_params --$OPTARG" # set the target platform android/ios
;;
m)
runtime_mode=$OPTARG
gn_params="$gn_params --runtime-mode=$runtime_mode" # set runtime mode release/debug
;;
e)
gn_params="$gn_params --bitcode" # enable-bitcode switch
;;
o)
optimize="" # optimize code switch
;;
?)
echo "unknown param"
exit 1;;
esac
done
if [ "$runtime_mode" == "release" ] && [ "$optimize" == "--unoptimized" ];
then
output_path="android_release_unopt"
ninja_params=" -C out/android_release_unopt flutter/third_party/txt:txt_lib"
elif [ "$runtime_mode" == "release" ] && [ "$optimize" == "" ];
then
output_path="android_release"
ninja_params="-C out/android_release flutter/third_party/txt:txt_lib"
elif [ "$runtime_mode" == "debug" ] && [ "$optimize" == "--unoptimized" ];
then
output_path="android_debug_unopt"
ninja_params=" -C out/android_debug_unopt flutter/third_party/txt:txt_lib"
elif [ "$runtime_mode" == "debug" ] && [ "$optimize" == "" ];
then
output_path="android_debug"
ninja_params=" -C out/android_debug flutter/third_party/txt:txt_lib"
elif [ "$runtime_mode" == "profile" ];
then
echo "not support profile build yet"
exit 1
fi
gn_params="$gn_params $optimize"
#set environment variable
function isexist()
{
source_str=$1
test_str=$2
strings=$(echo $source_str | sed 's/:/ /g')
for str in $strings
do
if [ $test_str = $str ]; then
return 0
fi
done
return 1
}
if [ ! $FLUTTER_ROOT_PATH ];then
echo "export FLUTTER_ROOT_PATH=$engine_path/engine/src" >> ~/.bash_profile
else
echo "This environment variable has been set, skip"
fi
if isexist $PATH $engine_path/depot_tools; then
echo "This environment variable has been set, skip"
else
echo "export PATH=$engine_path/depot_tools:\$PATH" >> ~/.bash_profile
fi
source ~/.bash_profile
echo "\nGetting Depot Tools..."
if [ ! -n "$engine_path" ]; then
echo "Flutter engine path is not exist, please set the path by using \"-r\" param to set a engine path."
exit 1
fi
cd $engine_path
if [ -d 'depot_tools' ] && [ -d "depot_tools/.git" ];
then
echo "depot_tools already installed, skip"
else
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
gclient
fi
echo "\nGetting flutter engine..."
if [ -d 'engine' ];
then
echo "engine folder already exist, skip"
else
mkdir engine
fi
cd engine
#git@github.com:guanghuispark/engine.git is a temp repo, replace it later
echo "solutions = [
{
\"managed\": False,
\"name\": \"src/flutter\",
\"url\": \"git@github.com:guanghuispark/engine.git\",
\"custom_deps\": {},
\"deps_file\": \"DEPS\",
\"safesync_url\": \"\",
},
]" > .gclient
gclient sync
cd $FLUTTER_ROOT_PATH/flutter
git checkout flutter-1.17-candidate.5
gclient sync -D
echo "\nSCompiling engine..."
#apply patch to Build.gn
cd $FLUTTER_ROOT_PATH/flutter/third_party/txt
cp -f $work_path/patches/android/BUILD.gn.patch BUILD.gn.patch
patch < BUILD.gn.patch -N
cd $FLUTTER_ROOT_PATH/build/secondary/third_party/libcxxabi
cp -f $work_path/patches/android/BUILD_2.gn.patch BUILD_2.gn.patch
patch < BUILD_2.gn.patch -N
cd $FLUTTER_ROOT_PATH/build/mac
cp -f $work_path/patches/find_sdk.patch find_sdk.patch
patch < find_sdk.patch -N
cd $FLUTTER_ROOT_PATH
./flutter/tools/gn $gn_params
ninja $ninja_params
echo "\nStarting build engine..."
cd $work_path/../
python $FLUTTER_ROOT_PATH/flutter/sky/tools/objcopy.py --objcopy $FLUTTER_ROOT_PATH/third_party/android_tools/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-objcopy --input $FLUTTER_ROOT_PATH/third_party/icu/flutter/icudtl.dat --output icudtl.o --arch arm
if [ -d '../com.unity.uiwidgets/Runtime/Plugins/android' ];
then
echo "android folder already exist, skip create folder"
else
mkdir ../com.unity.uiwidgets/Runtime/Plugins/android
fi
if [ "$runtime_mode" == "release" ];
then
mono bee.exe android_release
rm -rf ../com.unity.uiwidgets/Runtime/Plugins/android/libUIWidgets.so
cp -r build_release/. ../com.unity.uiwidgets/Runtime/Plugins/android
elif [ "$runtime_mode" == "debug" ];
then
mono bee.exe android_debug
rm -rf ../com.unity.uiwidgets/Runtime/Plugins/android/libUIWidgets.so
cp -r build_release/. ../com.unity.uiwidgets/Runtime/Plugins/android
fi
cd $work_path/../artifacts/rsp
cp -f $work_path/patches/android/rsp.patch rsp.patch
patch < rsp.patch -N
cd $work_path/../
"artifacts/Stevedore/android-ndk-mac/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang++" @"artifacts/rsp/14590475716575637239.rsp"
$FLUTTER_ROOT_PATH/buildtools/mac-x64/clang/bin/clang++ @"artifacts/rsp/14590475716575637239.rsp"
cp artifacts/libUIWidgets/release_Android_arm32/libUIWidgets.so ../com.unity.uiwidgets/Runtime/Plugins/Android/libUIWidgets.so

23
engine/Scripts/patches/android/BUILD.gn.patch


--- /Users/unity/Documents/GitHub/EngineBuildTool/engine/src/flutter/third_party/txt/BUILD.gn 2021-05-19 11:45:24.000000000 +0800
+++ /Users/unity/Documents/GitHub/EngineBuildTool/engine/src/flutter/third_party/txt/modify/BUILD.gn 2021-05-19 11:44:06.000000000 +0800
@@ -141,6 +141,9 @@
"//third_party/harfbuzz",
"//third_party/icu",
"//third_party/skia",
+ "//third_party/skia/modules/skottie",
+ "//third_party/libcxx",
+ "//third_party/libcxxabi",
]
deps = [
@@ -339,3 +342,10 @@
deps += [ "//third_party/skia/modules/skparagraph" ]
}
}
+
+static_library("txt_lib") {
+ complete_static_lib = true
+ deps = [
+ ":txt",
+ ]
+}

10
engine/Scripts/patches/android/BUILD_2.gn.patch


--- /Users/unity/Documents/GitHub/EngineBuildTool/engine/src/build/secondary/third_party/libcxxabi/BUILD.gn 2021-05-19 10:57:31.000000000 +0800
+++ /Users/unity/Documents/GitHub/EngineBuildTool/engine/src/build/secondary/third_party/libcxxabi/modify/BUILD.gn 2021-05-19 11:53:06.000000000 +0800
@@ -7,7 +7,6 @@
}
source_set("libcxxabi") {
- visibility = [ "../libcxx:*" ]
sources = [
"src/abort_message.cpp",

7
engine/Scripts/patches/android/rsp.patch
文件差异内容过多而无法显示
查看文件

正在加载...
取消
保存