浏览代码

delete useless scripts and fix some errors

/zgh-build_scripts
guanghuispark 4 年前
当前提交
43ae65ff
共有 10 个文件被更改,包括 41 次插入922 次删除
  1. 85
      engine/Build.bee.cs
  2. 3
      engine/Scripts/lib_build.py
  3. 7
      engine/Scripts/patches/android/rsp.patch
  4. 44
      engine/Scripts/full_build.sh
  5. 162
      engine/Scripts/lib_build_mac.sh
  6. 186
      engine/Scripts/lib_build_ios.sh
  7. 61
      engine/Scripts/prelink.py
  8. 186
      engine/Scripts/lib_build_android.sh
  9. 214
      engine/Scripts/lib_build_win.py
  10. 15
      engine/Scripts/rsppatch.py

85
engine/Build.bee.cs


//bee.exe win
static void DeployWindows()
{
var libUIWidgets = SetupLibUIWidgets(UIWidgetsBuildTargetPlatform.windows, out var dependencies_d, out var dependencies_r);
var libUIWidgets = SetupLibUIWidgets(UIWidgetsBuildTargetPlatform.windows, out var dependencies_debug, out var dependencies_release);
var builder = new VisualStudioNativeProjectFileBuilder(libUIWidgets);
builder = libUIWidgets.SetupConfigurations.Aggregate(

Backend.Current.AddAliasDependency("ProjectFiles", sln.Setup());
Backend.Current.AddAliasDependency("win_debug", deployed.Path);
foreach (var dep in dependencies_d)
foreach (var dep in dependencies_debug)
foreach (var dep in dependencies_r)
foreach (var dep in dependencies_release)
{
Backend.Current.AddAliasDependency("win_release", dep);
}

static void DeployAndroid()
{
var libUIWidgets = SetupLibUIWidgets(UIWidgetsBuildTargetPlatform.android, out var dependencies_d, out var dependencies_r);
var libUIWidgets = SetupLibUIWidgets(UIWidgetsBuildTargetPlatform.android, out var dependencies_debug, out var dependencies_release);
foreach (var dep in dependencies_d)
foreach (var dep in dependencies_debug)
foreach (var dep in dependencies_r)
foreach (var dep in dependencies_release)
{
Backend.Current.AddAliasDependency("android_release", dep);
}

{
var libUIWidgets = SetupLibUIWidgets(UIWidgetsBuildTargetPlatform.mac, out var dependencies_d, out var dependencies_r);
var libUIWidgets = SetupLibUIWidgets(UIWidgetsBuildTargetPlatform.mac, out var dependencies_debug, out var dependencies_release);
var nativePrograms = new List<NativeProgram>();
nativePrograms.Add(libUIWidgets);

foreach (var dep in dependencies_d)
foreach (var dep in dependencies_debug)
foreach (var dep in dependencies_r)
foreach (var dep in dependencies_release)
{
Backend.Current.AddAliasDependency("mac_release", dep);
}

static void DeployIOS()
{
var libUIWidgets = SetupLibUIWidgets(UIWidgetsBuildTargetPlatform.ios, out var dependencies_d, out var dependencies_r);
var libUIWidgets = SetupLibUIWidgets(UIWidgetsBuildTargetPlatform.ios, out var dependencies_debug, out var dependencies_release);
foreach(var dep in dependencies_d) {
foreach(var dep in dependencies_debug) {
foreach(var dep in dependencies_r) {
foreach(var dep in dependencies_release) {
Backend.Current.AddAliasDependency("ios_release", dep);
}
}

try
{
using (StreamReader sr = new StreamReader("Scripts/bitcode.conf"))
if(File.Exists("Scripts/bitcode.conf"))
string line;
if ((line = sr.ReadLine()) != null)
using (StreamReader sr = new StreamReader("Scripts/bitcode.conf"))
if(line.Trim() == "true")
string line;
if ((line = sr.ReadLine()) != null)
ios_bitcode_enabled = true;
}
else
{
ios_bitcode_enabled = false;
if(line.Trim() == "true")
{
ios_bitcode_enabled = true;
}
else
{
ios_bitcode_enabled = false;
}
}
else
{
ios_bitcode_enabled = false;
}
}
catch (Exception e)

//refer to the readme file for the details
private static bool ios_bitcode_enabled = false;
static NativeProgram SetupLibUIWidgets(UIWidgetsBuildTargetPlatform platform, out List<NPath> dependencies_d, out List<NPath> dependencies_r)
static NativeProgram SetupLibUIWidgets(UIWidgetsBuildTargetPlatform platform, out List<NPath> dependencies_debug, out List<NPath> dependencies_release)
{
var np = new NativeProgram("libUIWidgets")
{

//SetupSkia(np);
//SetupTxt(np);
var codegens = new[] { CodeGen.Debug, CodeGen.Release };
dependencies_d = new List<NPath>();
dependencies_r = new List<NPath>();
dependencies_debug = new List<NPath>();
dependencies_release = new List<NPath>();
if (platform == UIWidgetsBuildTargetPlatform.windows)
{
var toolchain = ToolChain.Store.Windows().VS2019().Sdk_17134().x64();

{
var builtNP = np.SetupSpecificConfiguration(config, toolchain.DynamicLibraryFormat)
.DeployTo("build_debug");
dependencies_d.Add(builtNP.Path);
// builtNP.DeployTo("../com.unity.uiwidgets/Runtime/Plugins/x86_64");
dependencies_debug.Add(builtNP.Path);
dependencies_r.Add(builtNP.Path);
// builtNP.DeployTo("../com.unity.uiwidgets/Runtime/Plugins/x86_64");
dependencies_release.Add(builtNP.Path);
}
}

if(codegen == CodeGen.Debug)
{
var buildNP = np.SetupSpecificConfiguration(config, androidToolchain.DynamicLibraryFormat).DeployTo("build_debug");
// var deoployNp = buildNP.DeployTo("../com.unity.uiwidgets/Runtime/Plugins/Android");
dependencies_d.Add(buildNP.Path);
// dependencies_d.Add(deoployNp.Path);
dependencies_debug.Add(buildNP.Path);
// var deoployNp = buildNP.DeployTo("../com.unity.uiwidgets/Runtime/Plugins/Android");
dependencies_r.Add(buildNP.Path);
// dependencies_r.Add(deoployNp.Path);
dependencies_release.Add(buildNP.Path);
}
}

if(codegen == CodeGen.Debug)
{
var buildNp = buildProgram.DeployTo("build_debug");
// var deployNp = buildProgram.DeployTo("../com.unity.uiwidgets/Runtime/Plugins/osx");
dependencies_d.Add(buildNp.Path);
// dependencies_d.Add(deployNp.Path);
dependencies_debug.Add(buildNp.Path);
// var deployNp = buildProgram.DeployTo("../com.unity.uiwidgets/Runtime/Plugins/osx");
dependencies_r.Add(buildNp.Path);
// dependencies_r.Add(deployNp.Path);
dependencies_release.Add(buildNp.Path);
}
}
np.ValidConfigurations = validConfigurations;

if(codegen == CodeGen.Debug)
{
var builtNP = buildProgram.DeployTo("build_debug");
// var deployNP = buildProgram.DeployTo("../com.unity.uiwidgets/Runtime/Plugins/iOS/");
dependencies_d.Add(builtNP.Path);
// dependencies_d.Add(deployNP.Path);
dependencies_debug.Add(builtNP.Path);
// var deployNP = buildProgram.DeployTo("../com.unity.uiwidgets/Runtime/Plugins/iOS/");
dependencies_r.Add(builtNP.Path);
// dependencies_r.Add(deployNP.Path);
dependencies_release.Add(builtNP.Path);
}
}

3
engine/Scripts/lib_build.py


tundra_file=Path(work_path + "/../artifacts/tundra.dag.json")
prelinkfiles(tundra_file, runtime_mode, output_path, work_path, bitcode)
elif runtime_mode == "debug":
shutil.rmtree(Path(work_path + "/../build_debug"))
if os.path.exists(Path(work_path + "/../build_debug")):
shutil.rmtree(Path(work_path + "/../build_debug"))
if platform == "windows":
os.system("bee.exe win_debug")
else:

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

44
engine/Scripts/full_build.sh


engine_path=
platform=
runtime_mode=
gn_params=""
ninja_params=""
bitcode=""
while getopts ":r:p:m:v:e" 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)
platform=$OPTARG
;;
m)
runtime_mode=$OPTARG
;;
e)
bitcode="-e" # enable-bitcode switch
;;
v)
# do nothing here
;;
?)
echo "unknown param"
exit 1;;
esac
done
case $platform in
"android") ./lib_build_android.sh -r $engine_path -p android -m $runtime_mode
;;
"ios") ./lib_build_ios.sh -r $engine_path -p ios -m $runtime_mode $bitcode
;;
"mac") ./lib_build_mac.sh -m $runtime_mode -r $engine_path
;;
"windows") echo "Please run lib_build_win.py with params directly"
;;
*) echo "unknown platform, only support \"android\",\"ios\",\"mac\",\"windows\""
;;
esac

162
engine/Scripts/lib_build_mac.sh


work_path=$(pwd)
engine_path=
platform=
gn_params=""
optimize=""
ninja_params=""
runtime_mode=
echo "setting environment variable and other params..."
while getopts ":r:m:" opt
do
case $opt in
r)
engine_path=$OPTARG # set engine_path, depot_tools and flutter engine folder will be put into this path
;;
m)
runtime_mode=$OPTARG
gn_params="$gn_params --runtime-mode=$runtime_mode" # set runtime mode release/debug
;;
?)
echo "unknown param"
exit 1;;
esac
done
if [ ! -d $engine_path ];
then
mkdir $engine_path
fi
if [ "$runtime_mode" == "release" ];
then
optimize=""
output_path="host_release"
ninja_params="-C out/host_release flutter/third_party/txt:txt_lib"
elif [ "$runtime_mode" == "debug" ];
then
optimize="--unoptimized"
output_path="host_debug_unopt"
ninja_params=" -C out/$output_path 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 an 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
echo "solutions = [
{
\"managed\": False,
\"name\": \"src/flutter\",
\"url\": \"git@github.com:flutter/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/BUILD.gn.patch BUILD.gn.patch
patch < BUILD.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
echo "icu_use_data_file=false" >> out/$output_path/args.gn
ninja $ninja_params
echo "\nStarting build engine..."
cd $work_path/../
if [ -d '../com.unity.uiwidgets/Runtime/Plugins/osx' ];
then
echo "osx folder already exist, skip create folder"
else
mkdir ../com.unity.uiwidgets/Runtime/Plugins/osx
fi
if [ "$runtime_mode" == "release" ];
then
rm -rf build_release/*
mono bee.exe mac_release
cp -r build_release/. ../com.unity.uiwidgets/Runtime/Plugins/osx
elif [ "$runtime_mode" == "debug" ];
then
rm -rf build_debug/*
mono bee.exe mac_debug
cp -r build_debug/. ../com.unity.uiwidgets/Runtime/Plugins/osx
fi
echo "\nRevert patches..."
cd $FLUTTER_ROOT_PATH/flutter/third_party/txt
patch -R < BUILD.gn.patch
cd $FLUTTER_ROOT_PATH/build/mac
patch -R < find_sdk.patch

186
engine/Scripts/lib_build_ios.sh


work_path=$(pwd)
engine_path=
platform=
gn_params=""
optimize=""
ninja_params=""
runtime_mode=
bitcode=""
output_path=
echo "setting environment variable and other params..."
while getopts ":r:p:m:e" 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)
bitcode="-bitcode_bundle -bitcode_verify"
gn_params="$gn_params --bitcode" # enable-bitcode switch
;;
?)
echo "unknown param"
exit 1;;
esac
done
if [ ! -d $engine_path ];
then
mkdir $engine_path
fi
if [ "$bitcode" == "-bitcode_bundle -bitcode_verify" ];
then
echo "true" > bitcode.conf
else
echo "false" > bitcode.conf
fi
if [ "$runtime_mode" == "release" ];
then
optimize=""
output_path="ios_release"
ninja_params="-C out/$output_path flutter/third_party/txt:txt_lib"
elif [ "$runtime_mode" == "debug" ];
then
optimize="--unoptimized"
output_path="ios_debug_unopt"
ninja_params=" -C out/$output_path 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
echo "solutions = [
{
\"managed\": False,
\"name\": \"src/flutter\",
\"url\": \"git@github.com:flutter/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/BUILD.gn.patch BUILD.gn.patch
patch < BUILD.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
echo "icu_use_data_file=false" >> out/$output_path/args.gn
ninja $ninja_params
echo "\nStarting build engine..."
cd $work_path/../
if [ -d '../com.unity.uiwidgets/Runtime/Plugins/ios' ];
then
echo "ios folder already exist, skip create folder"
else
mkdir ../com.unity.uiwidgets/Runtime/Plugins/ios
fi
if [ "$runtime_mode" == "release" ];
then
rm -rf build_release/*
mono bee.exe ios_release
cp -r build_release/. ../com.unity.uiwidgets/Runtime/Plugins/ios
echo "\nStarting prlink library..."
cd Scripts/../
tundra_file="$work_path/../artifacts/tundra.dag.json"
python3 Scripts/prelink.py $tundra_file $runtime_mode $output_path $work_path $bitcode
elif [ "$runtime_mode" == "debug" ];
then
rm -rf build_debug/*
mono bee.exe ios_debug
cp -r build_debug/. ../com.unity.uiwidgets/Runtime/Plugins/ios
fi
if [ "$runtime_mode" == "debug" ];
then
echo "\nRevert patches..."
cd $FLUTTER_ROOT_PATH/flutter/third_party/txt
patch -R < BUILD.gn.patch
cd $FLUTTER_ROOT_PATH/build/mac
patch -R < find_sdk.patch
fi

61
engine/Scripts/prelink.py


# coding=utf-8
import os
import sys
import json
def get_xcode_path():
res = os.popen('xcode-select -p')
return res.read()
def get_target_files(tundra_file, runtime_mode):
if not os.path.exists(tundra_file):
print('tundra.dag.json file not found')
return None
with open(tundra_file, 'r') as f:
temp = json.loads(f.read())
json_list = temp['Nodes']
target_files=''
for item in json_list:
if item['Annotation'].startswith('Lib_iOS_arm64') and item['Annotation'].find(runtime_mode) != -1:
action = item['Action']
o_file_list = action.split("\"")
for o in o_file_list:
if o.endswith('.o'):
target_files += ' '+o
return target_files
def prelinkfiles(tundra_file, runtime_mode, output_path, work_path, bitcode):
target_files = get_target_files(tundra_file, runtime_mode)
if not target_files:
print("get prelink xxx.o files failed")
else:
flutter_root_path = os.environ['FLUTTER_ROOT_PATH']
os.system('nm -j ' + flutter_root_path + '/out/' + output_path + '/obj/flutter/third_party/txt/libtxt_lib.a > third.symbol')
xcode_path = get_xcode_path().strip()
os.system('\"' + xcode_path + '/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld" -r -arch arm64 ' + bitcode + ' -syslibroot ' + xcode_path + '/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk -unexported_symbols_list third.symbol ' + target_files + ' ' + flutter_root_path + '/out/' + output_path + '/obj/flutter/third_party/txt/libtxt_lib.a -o "libUIWidgets.o"')
os.system('\"' + xcode_path + '/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool" -arch_only arm64 -static "libUIWidgets.o" -o "libUIWidgets.a"')
os.system('\"' + xcode_path + '/Toolchains/XcodeDefault.xctoolchain/usr/bin/strip" -x "libUIWidgets.a"')
os.system('cp -r libUIWidgets.a ' + '../com.unity.uiwidgets/Runtime/Plugins/ios/libUIWidgets.a')
def revert_patches(work_path):
print("\nRevert patches...")
flutter_root_path = os.environ['FLUTTER_ROOT_PATH']
os.chdir(flutter_root_path + "/flutter/third_party/txt")
os.system("patch -R < BUILD.gn.patch")
os.chdir(flutter_root_path + "/build/mac")
os.system("patch -R < find_sdk.patch")
os.chdir(work_path)
if os.path.exists(work_path + "/bitcode.conf"):
os.remove("bitcode.conf")
if __name__ == "__main__":
work_path = sys.argv[4]
if len(sys.argv) > 5:
prelinkfiles(sys.argv[1], sys.argv[2], sys.argv[3], work_path, sys.argv[5])
else:
prelinkfiles(sys.argv[1], sys.argv[2], sys.argv[3], work_path, "")
revert_patches(work_path)

186
engine/Scripts/lib_build_android.sh


work_path=$(pwd)
engine_path=
platform=
gn_params=""
optimize=""
ninja_params=""
runtime_mode=
echo "setting environment variable and other params..."
while getopts ":r:p:m:" 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
;;
?)
echo "unknown param"
exit 1;;
esac
done
if [ "$runtime_mode" == "release" ];
then
optimize=""
output_path="android_release"
ninja_params="-C out/android_release flutter/third_party/txt:txt_lib"
elif [ "$runtime_mode" == "debug" ];
then
optimize="--unoptimized"
output_path="android_debug_unopt"
ninja_params=" -C out/android_debug_unopt flutter/third_party/txt:txt_lib"
elif [ "$runtime_mode" == "profile" ];
then
echo "not support profile build"
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
echo "solutions = [
{
\"managed\": False,
\"name\": \"src/flutter\",
\"url\": \"git@github.com:flutter/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
mkdir $work_path/../artifacts/rsp/backup
cp -f $work_path/../artifacts/rsp/14590475716575637239.rsp $work_path/../artifacts/rsp/backup/14590475716575637239.rsp
cd $work_path
python -c 'import rsppatch; print rsppatch.rsp_patch()'
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
elif [ "$runtime_mode" == "debug" ];
then
mono bee.exe android_debug
rm -rf ../com.unity.uiwidgets/Runtime/Plugins/android/libUIWidgets.so
cp -r build_debug/. ../com.unity.uiwidgets/Runtime/Plugins/android
fi
echo "\nRevert patches..."
cd $FLUTTER_ROOT_PATH/flutter/third_party/txt
patch -R < BUILD.gn.patch
cd $FLUTTER_ROOT_PATH/build/secondary/third_party/libcxxabi
patch -R < BUILD_2.gn.patch
cd $FLUTTER_ROOT_PATH/build/mac
patch -R < find_sdk.patch
if [ "$runtime_mode" == "release" ];
then
rm -rf $work_path/../artifacts/rsp/14590475716575637239.rsp
cp -f $work_path/../artifacts/rsp/backup/14590475716575637239.rsp $work_path/../artifacts/rsp/14590475716575637239.rsp
rm -rf $work_path/../artifacts/rsp/backup
echo "rsp reverted"
fi

214
engine/Scripts/lib_build_win.py


from genericpath import exists
import os
import sys
import getopt
work_path=os.getcwd()
engine_path=""
platform=""
gn_params=""
optimize=""
ninja_params1=""
ninja_params2=""
ninja_params3=""
runtime_mode=""
bitcode=""
flutter_root_path=""
visual_studio_path=""
def get_opts():
# get intput agrs
global engine_path
global gn_params
global runtime_mode
global bitcode
global visual_studio_path
options, args = getopt.getopt(sys.argv[1:], 'r:p:m:v:')
for opt, arg in options:
if opt == '-r':
engine_path = arg # set engine_path, depot_tools and flutter engine folder will be put into this path
elif opt == '-p':
gn_params += gn_params + " --" + arg # set the target platform android/ios
elif opt == '-m':
runtime_mode = arg
gn_params += gn_params + " --runtime-mode=" + runtime_mode # set runtime mode release/debug
elif opt == '-v':
visual_studio_path = arg
def engine_path_check():
global engine_path
if not os.path.exists(engine_path):
os.makedirs(engine_path)
def set_params():
global output_path
global ninja_params1
global ninja_params2
global ninja_params3
global gn_params
global visual_studio_path
print("setting environment variable and other params...")
visual_studio_path_env = os.getenv('GYP_MSVS_OVERRIDE_PATH', 'null')
if visual_studio_path == "":
if visual_studio_path_env == 'null':
assert False, "In func set_params(), visual_studio_path is not exist, please set the path by using \"-v\" param to set a engine path."
else:
os.environ["GYP_MSVS_OVERRIDE_PATH"] = visual_studio_path
if runtime_mode == "release":
optimize=""
output_path="host_release"
elif runtime_mode == "debug":
optimize="--unoptimized"
output_path="host_debug_unopt"
else:
assert False, "In func set_params(), unknown param"
ninja_params1="-C out/" +output_path + " flutter/third_party/txt:txt_lib"
ninja_params2="-C out/" +output_path + " third_party/angle:angle_lib"
ninja_params3="-C out/" +output_path + " third_party/angle:libEGL_static"
gn_params=gn_params + " " + optimize
def set_env_verb():
global flutter_root_path
flutter_root_path = os.getenv('FLUTTER_ROOT_PATH', 'null')
if flutter_root_path == 'null':
os.environ["FLUTTER_ROOT_PATH"] = engine_path + "/engine/src"
flutter_root_path = os.getenv('FLUTTER_ROOT_PATH')
else:
print("This environment variable has been set, skip")
env_path = os.getenv('Path')
path_strings = env_path.split(';')
for path in path_strings:
if path.startswith(engine_path):
print("This environment variable has been set, skip")
return
os.environ["Path"] = engine_path + "/depot_tools;" + os.environ["Path"]
def get_depot_tools():
print("\nGetting Depot Tools...")
if not os.path.exists(engine_path):
assert False,"Flutter engine path is not exist, please set the path by using \"-r\" param to set a engine path."
if os.path.exists(engine_path + "/depot_tools") and os.path.exists(engine_path + "/depot_tools/.git"):
print("depot_tools already installed, skip")
else:
os.chdir(engine_path)
os.system("git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git")
os.system("gclient")
def get_flutter_engine():
global engine_path
global flutter_root_path
print("\nGetting flutter engine...")
if os.path.exists(engine_path + "/engine"):
print("engine folder already exist, skip")
else:
os.makedirs(engine_path + "/engine")
content = '''
solutions = [
{
"managed": False,
"name": "src/flutter",
"url": "git@github.com:flutter/engine.git",
"custom_deps": {},
"deps_file": "DEPS",
"safesync_url": "",
},
]
'''
f = open(engine_path + "/engine/.gclient", "w")
f.write(content)
f.close()
os.chdir(engine_path + "/engine")
os.system("gclient sync")
os.chdir(flutter_root_path + "/flutter")
os.system("git checkout flutter-1.17-candidate.5")
os.system("gclient sync -D")
def compile_engine():
global flutter_root_path
global work_path
global gn_params
global output_path
global ninja_params1
global ninja_params2
global ninja_params3
print("\nSCompiling engine...")
os.chdir(flutter_root_path + "/flutter/third_party/txt")
os.system("cp -f " + work_path + "/patches/BUILD.gn.patch BUILD.gn.patch")
os.system("patch < BUILD.gn.patch -N")
os.chdir(flutter_root_path + "/third_party/angle")
os.system("cp -f " + work_path + "/patches/windows/BUILD.gn.patch BUILD.gn.patch")
os.system("patch < BUILD.gn.patch -N")
os.chdir(flutter_root_path + "/third_party/angle/src/libANGLE/renderer/d3d/d3d11/")
os.system("cp -f " + work_path + "/patches/windows/cpp.patch cpp.patch")
os.system("patch < cpp.patch -N")
os.chdir(flutter_root_path + "/third_party/skia/")
os.system("cp -f " + work_path + "/patches/windows/BUILD_2.gn.patch BUILD_2.gn.patch")
os.system("patch < BUILD_2.gn.patch -N")
os.chdir(flutter_root_path)
os.system("python ./flutter/tools/gn " + gn_params)
print(gn_params)
f = open(flutter_root_path + "/out/" + output_path + "/args.gn", 'a')
f.write("skia_use_angle = true\nskia_use_egl = true")
f.close()
os.system("ninja " + ninja_params1)
os.system("ninja " + ninja_params2)
os.system("ninja " + ninja_params3)
os.chdir(flutter_root_path + "/third_party/icu/flutter/")
os.system("ld -r -b binary -o icudtl.o icudtl.dat")
def build_engine():
global work_path
global runtime_mode
print("\nStarting build engine...")
if not os.path.exists(work_path + "/../../com.unity.uiwidgets/Runtime/Plugins/x86_64"):
os.makedirs(work_path + "/../../com.unity.uiwidgets/Runtime/Plugins/x86_64")
os.chdir(work_path + "/../")
if runtime_mode == "release":
os.system("rm -rf build_release/*")
os.system("bee.exe win_release")
os.system("cp -r build_release/. ../com.unity.uiwidgets/Runtime/Plugins/x86_64")
if runtime_mode == "debug":
os.system("rm -rf build_debug/*")
os.system("bee.exe win_debug")
os.system("cp -r build_debug/. ../com.unity.uiwidgets/Runtime/Plugins/x86_64")
def revert_patches():
print("\nRevert patches...")
os.chdir(flutter_root_path + "/flutter/third_party/txt")
os.system("patch -R < BUILD.gn.patch")
os.chdir(flutter_root_path + "/third_party/angle")
os.system("patch -R < BUILD.gn.patch")
os.chdir(flutter_root_path + "/third_party/angle/src/libANGLE/renderer/d3d/d3d11/")
os.system("patch -R < cpp.patch")
os.chdir(flutter_root_path + "/third_party/skia/")
os.system("patch -R < BUILD_2.gn.patch")
def main():
get_opts()
engine_path_check()
set_params()
set_env_verb()
get_depot_tools()
get_flutter_engine()
compile_engine()
build_engine()
revert_patches()
if __name__=="__main__":
main()

15
engine/Scripts/rsppatch.py


import os
import sys
def rsp_patch():
file_data = ""
file = "../artifacts/rsp/14590475716575637239.rsp"
old_str = ',--icf-iterations=5'
with open(file, "r") as f:
for line in f:
if old_str in line:
line = line.replace(old_str,'')
file_data += line
with open(file,"w") as f:
f.write(file_data)
return "rsp modified"
正在加载...
取消
保存