浏览代码

android arm64

/main
siyao 3 年前
当前提交
c709280a
共有 3 个文件被更改,包括 59 次插入21 次删除
  1. 44
      engine/Build.bee.cs
  2. 23
      engine/Scripts/lib_build.py
  3. 13
      engine/Scripts/lib_build_android.sh

44
engine/Build.bee.cs


}
skiaRoot = flutterRoot + "/third_party/skia";
buildArchitexture = Environment.GetEnvironmentVariable("BUILD_ARCHITECTURE");
try
{
if(File.Exists("Scripts/bitcode.conf"))

private static string skiaRoot;
private static string flutterRoot;
private static string buildArchitexture;
//this setting is disabled by default, don't change it unless you know what you are doing
//it must be set the same as the settings we choose to build the flutter txt library

"-I"+ flutterRoot+"/flutter/third_party/txt/src",
"-I" + flutterRoot + "/third_party/harfbuzz/src",
"-I" + skiaRoot + "/third_party/externals/icu/source/common",
//"-I/Users/siyao/Documents/GitHub/com.unity.uiwidgets/engine/artifacts/Stevedore/android-ndk-mac/sources/cxx-stl/llvm-libc++/include/memory",
// "-Igen",
"-I"+ flutterRoot+"/third_party/libcxx/include",

"-Wno-deprecated-declarations",
"-fno-strict-aliasing",
"-march=armv7-a",
// "-march=armv7-a",
"-mtune=generic-armv7-a",
//"-mtune=generic-armv7-a",
"-mthumb",
"-fPIC",
"-pipe",

"-fno-short-enums",
"-nostdinc++",
"--target=arm-linux-androideabi",
// "--target=arm-linux-androideabi",
"--target=aarch64-linux-android",
"-mfpu=neon",
"-Wall",
"-Wextra",

// "-Wno-non-c-typedef-for-linkage",
"-isystem"+ flutterRoot+"/third_party/android_tools/ndk/sources/android/support/include",
"-isystem"+ flutterRoot +
"/third_party/android_tools/ndk/sysroot/usr/include/arm-linux-androideabi",
//"/third_party/android_tools/ndk/sysroot/usr/include/arm-linux-androideabi",
"/third_party/android_tools/ndk/sysroot/usr/include/aarch64-linux-android",
//"-D__ANDROID_API__=16",
// "-fvisibility=hidden",
"--sysroot="+ flutterRoot+"/third_party/android_tools/ndk/sysroot",

np.LinkerSettings().Add(c => {
return IsWindows(c) && c.CodeGen == CodeGen.Debug;
}, l => l.WithCustomFlags_workaround(new[] { "/DEBUG:FULL" }));
Console.WriteLine("???????" + "-L" + flutterRoot + "/third_party/android_tools/ndk/toolchains/aarch64-linux-android-4.9/prebuilt/darwin-x86_64");
np.LinkerSettings().Add(c => IsAndroid(c), l => l.WithCustomFlags_workaround(new[] {
"-Wl,--fatal-warnings",

"-Wl,-z,relro",
"-Wl,-z,defs",
"--gcc-toolchain="+ flutterRoot +
"/third_party/android_tools/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64",
//"/third_party/android_tools/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64",
"/third_party/android_tools/ndk/toolchains/aarch64-linux-android-4.9/prebuilt/darwin-x86_64",
"--target=arm-linux-androideabi",
//"--target=arm-linux-androideabi",
"--sysroot="+ flutterRoot+"/third_party/android_tools/ndk/platforms/android-16/arch-arm",
"-L"+ flutterRoot + "/third_party/android_tools/ndk/sources/cxx-stl/llvm-libc++/libs/armeabi-v7a",
//"--sysroot="+ flutterRoot+"/third_party/android_tools/ndk/platforms/android-16/arch-arm",
"--sysroot="+ flutterRoot+"/third_party/android_tools/ndk/platforms/android-22/arch-arm64",
//"-L"+ flutterRoot + "/third_party/android_tools/ndk/sources/cxx-stl/llvm-libc++/libs/armeabi-v7a",
"-L"+ flutterRoot + "/third_party/android_tools/ndk/sources/cxx-stl/llvm-libc++/libs/arm64-v8a",
"-L/Users/siyao/Documents/GitHub/com.unity.uiwidgets/engine/Scripts/engine/src/third_party/android_tools/ndk/toolchains/aarch64-linux-android-4.9/prebuilt/darwin-x86_64/lib/gcc/aarch64-linux-android/4.9.x",
"-Wl,--build-id=sha1",
"-g",
"-Wl,-soname=libUIWidgets.so",

}
else if (platform == UIWidgetsBuildTargetPlatform.android)
{
var androidToolchain = ToolChain.Store.Android().r19().Armv7();
//var androidToolchain = ToolChain.Store.Android().r19().Armv7();
var androidToolchain = ToolChain.Store.Android().r19().Arm64();
var validConfigurations = new List<NativeProgramConfiguration>();

{
if(c.CodeGen == CodeGen.Debug){
return new PrecompiledLibrary[]{
new StaticLibrary(flutterRoot+"/out/android_debug_unopt/obj/flutter/third_party/txt/libtxt_lib.a"),
new StaticLibrary(flutterRoot+"/out/android_debug_unopt_arm64/obj/flutter/third_party/txt/libtxt_lib.a"),
};
} else {
return new PrecompiledLibrary[]{

// icudtl
new StaticLibrary("icudtl.o"),
new StaticLibrary(flutterRoot+"/third_party/android_tools/ndk/platforms/android-16/arch-arm/usr/lib/crtbegin_so.o"),
new StaticLibrary(flutterRoot+"/third_party/android_tools/ndk/platforms/android-16/arch-arm/usr/lib/crtend_so.o"),
//new StaticLibrary(flutterRoot+"/third_party/android_tools/ndk/platforms/android-16/arch-arm/usr/lib/crtbegin_so.o"),
new StaticLibrary(flutterRoot+"/third_party/android_tools/ndk/platforms/android-22/arch-arm64/usr/lib/crtbegin_so.o"),
//new StaticLibrary(flutterRoot+"/third_party/android_tools/ndk/platforms/android-16/arch-arm/usr/lib/crtend_so.o"),
new StaticLibrary(flutterRoot+"/third_party/android_tools/ndk/platforms/android-22/arch-arm64/usr/lib/crtbegin_so.o"),
new SystemLibrary("android_support"),
new SystemLibrary("unwind"),
// new SystemLibrary("android_support"),
// new SystemLibrary("unwind"),
new SystemLibrary("gcc"),
new SystemLibrary("c"),
new SystemLibrary("dl"),

23
engine/Scripts/lib_build.py


bitcode=""
flutter_root_path=""
visual_studio_path=""
architecture=""
def get_opts():
# get intput agrs

global bitcode
global visual_studio_path
global platform
global architecture
options, args = getopt.getopt(sys.argv[1:], 'r:p:m:v:eh',["help"])
options, args = getopt.getopt(sys.argv[1:], 'r:p:m:v:eh',["arm64","help"])
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

visual_studio_path = arg
elif opt == '-e':
bitcode="-bitcode_bundle -bitcode_verify"
elif opt == '--arm64':
architecture = "arm64"
if platform == "android":
gn_params += " --android-cpu=arm64"
elif opt in ("-h","--help"):
show_help()
sys.exit()

output_path="android_release"
elif runtime_mode == "debug" and platform == "android":
optimize="--unoptimized"
output_path="android_debug_unopt"
if architecture == "arm64":
output_path="android_debug_unopt_arm64"
else:
output_path="android_debug_unopt"
elif runtime_mode == "release" and platform == "ios":
optimize=""
output_path="ios_release"

elif platform == "android":
dest_folder = "android"
os.chdir(work_path + "/../")
os.system("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 architecture == "arm64":
os.system("python " + flutter_root_path + "/flutter/sky/tools/objcopy.py --objcopy " + flutter_root_path + "/third_party/android_tools/ndk/toolchains/aarch64-linux-android-4.9/prebuilt/darwin-x86_64/bin/aarch64-linux-android-objcopy --input " + flutter_root_path + "/third_party/icu/flutter/icudtl.dat --output icudtl.o --arch aarch64")
else:
os.system("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")
elif platform == "ios":
dest_folder = "ios"
if not os.path.exists(Path(work_path + "/../../com.unity.uiwidgets/Runtime/Plugins/" + dest_folder)):

os.chdir(Path(work_path + "/../"))
os.system("artifacts/Stevedore/android-ndk-mac/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang++ " + "@\"" + rsp + "\"")
os.system(flutter_root_path + "/buildtools/mac-x64/clang/bin/clang++ " + "@\"" + rsp + "\"")
copy_file(Path(work_path + "/../artifacts/libUIWidgets/release_Android_arm32/libUIWidgets.so"), Path(work_path + "/../../com.unity.uiwidgets/Runtime/Plugins/Android"))
if architecture == "arm64":
copy_file(Path(work_path + "/../artifacts/libUIWidgets/release_Android_arm64/libUIWidgets.so"), Path(work_path + "/../../com.unity.uiwidgets/Runtime/Plugins/Android"))
else:
copy_file(Path(work_path + "/../artifacts/libUIWidgets/release_Android_arm32/libUIWidgets.so"), Path(work_path + "/../../com.unity.uiwidgets/Runtime/Plugins/Android"))
elif platform == "ios":
print("\nStarting prlink library...")
os.chdir(Path(work_path + "/../"))

13
engine/Scripts/lib_build_android.sh


engine_path=$(pwd)
runtime_mode=release
while getopts ":r:m:" opt
architecture=false
while getopts ":r:m:a:" opt
do
case $opt in
r)

runtime_mode=$OPTARG
;;
a)
architecture=true
;;
?)
echo "unknown param"

python3 lib_build.py -r $engine_path -p android -m $runtime_mode
if [ $architecture ]; then
python3 lib_build.py -r $engine_path -p android -m $runtime_mode --arm64
else
python3 lib_build.py -r $engine_path -p android -m $runtime_mode
fi
正在加载...
取消
保存