浏览代码

Merge pull request #221 from Unity-Technologies/siyaoH/1.17/androidArm64

Siyao h/1.17/android arm64
/main
GitHub 3 年前
当前提交
d22933d9
共有 10 个文件被更改,包括 350 次插入118 次删除
  1. 3
      com.unity.uiwidgets/Runtime/Plugins/Android/libUIWidgets.so.meta
  2. 307
      engine/Build.bee.cs
  3. 2
      engine/README.md
  4. 52
      engine/Scripts/lib_build.py
  5. 15
      engine/Scripts/lib_build_android.sh
  6. 8
      com.unity.uiwidgets/Runtime/Plugins/Android/arm64.meta
  7. 81
      com.unity.uiwidgets/Runtime/Plugins/Android/arm64/libUIWidgets.so.meta

3
com.unity.uiwidgets/Runtime/Plugins/Android/libUIWidgets.so.meta


fileFormatVersion: 2
guid: 983c1f57f6a4847638f514f55f79c8b4
guid: 44a73cced101346fcadd6be5304e117d
PluginImporter:
externalObjects: {}
serializedVersion: 2

Exclude Editor: 1
Exclude Linux64: 1
Exclude OSXUniversal: 1
Exclude WebGL: 1
Exclude Win: 1
Exclude Win64: 1
Exclude iOS: 1

307
engine/Build.bee.cs


using Bee.Toolchain.IOS;
using System.Diagnostics;
using System.IO;
using Bee.Toolchain.Android;
enum UIWidgetsBuildTargetPlatform
{
windows,

}
//bee.exe mac
static void DeployAndroid()
static void DeployAndroid(bool isArm64 = false)
buildArm64 = isArm64;
Backend.Current.AddAliasDependency("android_debug", dep);
Backend.Current.AddAliasDependency(isArm64 ? "android_debug_arm64" : "android_debug", dep);
Backend.Current.AddAliasDependency("android_release", dep);
Backend.Current.AddAliasDependency(isArm64 ? "android_release_arm64" : "android_release", dep);
}
}

{
DeployMac();
DeployAndroid();
DeployAndroid(true);
DeployIOS();
}
}

private static bool buildArm64;
//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

//"SKIA_VERSION=\"0.0\"",
"XML_STATIC",
});
np.CompilerSettings().Add(c => IsAndroid(c), c => c.WithCustomFlags(new[] {
"-MD",
"-MF",
np.CompilerSettings().Add(c => IsAndroid(c), c =>
{
var flags = new List<string>{
"-MD",
"-MF",
"-I.",
"-Ithird_party",
"-Isrc",
"-I"+ flutterRoot,
"-I"+ flutterRoot+"/third_party/rapidjson/include",
"-I"+ skiaRoot,
"-I"+ skiaRoot + "/include/third_party/vulkan",
"-I"+ flutterRoot+"/flutter/third_party/txt/src",
"-I" + flutterRoot + "/third_party/harfbuzz/src",
"-I" + skiaRoot + "/third_party/externals/icu/source/common",
"-I.",
"-Ithird_party",
"-Isrc",
"-I" + flutterRoot,
"-I" + flutterRoot + "/third_party/rapidjson/include",
"-I" + skiaRoot,
"-I" + skiaRoot + "/include/third_party/vulkan",
"-I" + flutterRoot + "/flutter/third_party/txt/src",
"-I" + flutterRoot + "/third_party/harfbuzz/src",
"-I" + skiaRoot + "/third_party/externals/icu/source/common",
// "-Igen",
"-I"+ flutterRoot+"/third_party/libcxx/include",
"-I"+ flutterRoot+"/third_party/libcxxabi/include",
"-I"+ flutterRoot+"/third_party/icu/source/common",
"-I"+ flutterRoot+"/third_party/icu/source/i18n",
// "-Igen",
"-I" + flutterRoot + "/third_party/libcxx/include",
"-I" + flutterRoot + "/third_party/libcxxabi/include",
"-I" + flutterRoot + "/third_party/icu/source/common",
"-I" + flutterRoot + "/third_party/icu/source/i18n",
// ignore deprecated code
"-Wno-deprecated-declarations",
// ignore deprecated code
"-Wno-deprecated-declarations",
"-fno-strict-aliasing",
"-mfloat-abi=softfp",
"-mthumb",
"-fPIC",
"-pipe",
"-fcolor-diagnostics",
"-ffunction-sections",
"-funwind-tables",
"-fno-short-enums",
"-nostdinc++",
"-mfpu=neon",
"-Wall",
"-Wextra",
"-Wendif-labels",
"-Werror",
"-Wno-missing-field-initializers",
"-Wno-unused-parameter",
"-Wno-unused-variable",
"-Wno-unused-command-line-argument",
"-Wno-unused-function",
// "-Wno-non-c-typedef-for-linkage",
"-isystem" + flutterRoot + "/third_party/android_tools/ndk/sources/android/support/include",
// "-isystem" + flutterRoot +
//"-D__ANDROID_API__=16",
// "-fvisibility=hidden",
"--sysroot=" + flutterRoot + "/third_party/android_tools/ndk/sysroot",
"-Wstring-conversion",
// supress new line error
// "-Wnewline-eof",
"-O0",
"-g2",
"-fvisibility-inlines-hidden",
"-std=c++17",
"-fno-rtti",
"-fno-exceptions",
"-nostdlib"
};
if (buildArm64)
{
flags.Add(new []
{
"--target=aarch64-linux-android",
"-isystem"+ flutterRoot +
"/third_party/android_tools/ndk/sysroot/usr/include/aarch64-linux-android",
"-fno-strict-aliasing",
"-march=armv7-a",
"-mfloat-abi=softfp",
"-mtune=generic-armv7-a",
"-mthumb",
"-fPIC",
"-pipe",
"-fcolor-diagnostics",
"-ffunction-sections",
"-funwind-tables",
"-fno-short-enums",
"-nostdinc++",
"--target=arm-linux-androideabi",
"-mfpu=neon",
"-Wall",
"-Wextra",
"-Wendif-labels",
"-Werror",
"-Wno-missing-field-initializers",
"-Wno-unused-parameter",
"-Wno-unused-variable",
"-Wno-unused-command-line-argument",
"-Wno-unused-function",
// "-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",
//"-D__ANDROID_API__=16",
// "-fvisibility=hidden",
"--sysroot="+ flutterRoot+"/third_party/android_tools/ndk/sysroot",
"-Wstring-conversion",
// supress new line error
// "-Wnewline-eof",
"-O0",
"-g2",
"-fvisibility-inlines-hidden",
"-std=c++17",
"-fno-rtti",
"-fno-exceptions",
"-nostdlib"
}));
});
}
else
{
flags.Add(new []
{
"-march=armv7-a",
"-mtune=generic-armv7-a",
"--target=arm-linux-androideabi",
"-isystem"+ flutterRoot +
"/third_party/android_tools/ndk/sysroot/usr/include/arm-linux-androideabi",
});
}
return c.WithCustomFlags(flags.ToArray());
}
);
np.IncludeDirectories.Add("third_party");
np.IncludeDirectories.Add("src");

return IsWindows(c) && c.CodeGen == CodeGen.Debug;
}, l => l.WithCustomFlags_workaround(new[] { "/DEBUG:FULL" }));
np.LinkerSettings().Add(c => IsAndroid(c), l => l.WithCustomFlags_workaround(new[] {
"-Wl,--fatal-warnings",
"-fPIC",
"-Wl,-z,noexecstack",
"-Wl,-z,now",
"-Wl,-z,relro",
"-Wl,-z,defs",
"--gcc-toolchain="+ flutterRoot +
"/third_party/android_tools/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64",
"-Wl,--no-undefined",
"-Wl,--exclude-libs,ALL",
"-fuse-ld=lld",
"-Wl,--icf=all",
"--target=arm-linux-androideabi",
"-nostdlib++",
"-Wl,--warn-shared-textrel",
"-nostdlib",
"--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",
"-Wl,--build-id=sha1",
"-g",
"-Wl,-soname=libUIWidgets.so",
"-Wl,--whole-archive",
}));
np.LinkerSettings().Add(c => IsAndroid(c), l =>
{
var flags = new List<string>()
{
"-Wl,--fatal-warnings",
"-fPIC",
"-Wl,-z,noexecstack",
"-Wl,-z,now",
"-Wl,-z,relro",
"-Wl,-z,defs",
"-Wl,--no-undefined",
"-Wl,--exclude-libs,ALL",
"-fuse-ld=lld",
"-Wl,--icf=all",
"-nostdlib++",
"-Wl,--warn-shared-textrel",
"-nostdlib",
"-Wl,--build-id=sha1",
"-g",
"-Wl,-soname=libUIWidgets.so",
"-Wl,--whole-archive",
};
if (buildArm64)
{
flags.Add(new []
{
"--gcc-toolchain="+ flutterRoot +
"/third_party/android_tools/ndk/toolchains/aarch64-linux-android-4.9/prebuilt/darwin-x86_64",
"--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/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",
});
}
else
{
flags.Add(new []
{
"--gcc-toolchain="+ flutterRoot +
"/third_party/android_tools/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64",
"--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",
});
}
return l.WithCustomFlags_workaround(flags.ToArray());
});
SetupDependency(np);
//SetupFml(np);

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

if(codegen == CodeGen.Debug)
{
var buildNP = np.SetupSpecificConfiguration(config, androidToolchain.DynamicLibraryFormat).DeployTo("build_debug");
var buildNP = np.SetupSpecificConfiguration(config, androidToolchain.DynamicLibraryFormat)
.DeployTo(buildArm64 ? "build_debug_arm64" : "build_debug");
var buildNP = np.SetupSpecificConfiguration(config, androidToolchain.DynamicLibraryFormat).DeployTo("build_release");
var buildNP = np.SetupSpecificConfiguration(config, androidToolchain.DynamicLibraryFormat)
.DeployTo(buildArm64 ? "build_release_64" : "build_release");
dependencies_release.Add(buildNP.Path);
}

np.Libraries.Add(IsAndroid, c =>
{
if(c.CodeGen == CodeGen.Debug){
return new PrecompiledLibrary[]{
new StaticLibrary(flutterRoot+"/out/android_debug_unopt/obj/flutter/third_party/txt/libtxt_lib.a"),
};
} else {
return new PrecompiledLibrary[]{
new StaticLibrary(flutterRoot+"/out/android_release/obj/flutter/third_party/txt/libtxt_lib.a"),
if (c.CodeGen == CodeGen.Debug)
{
if (buildArm64)
{
return new PrecompiledLibrary[]
{
new StaticLibrary(flutterRoot +
"/out/android_debug_unopt_arm64/obj/flutter/third_party/txt/libtxt_lib.a"),
};
}
else
{
return new PrecompiledLibrary[]
{
new StaticLibrary(flutterRoot +
"/out/android_debug_unopt/obj/flutter/third_party/txt/libtxt_lib.a"),
};
}
}
else
{
return new PrecompiledLibrary[]
{
new StaticLibrary(buildArm64 ?
flutterRoot + "/out/android_release_arm64/obj/flutter/third_party/txt/libtxt_lib.a"
:flutterRoot + "/out/android_release/obj/flutter/third_party/txt/libtxt_lib.a"
),
};
}
});

var basePath = skiaRoot + "/out/arm";
return new PrecompiledLibrary[]
var libraries = new List<PrecompiledLibrary>
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 SystemLibrary("android_support"),
new SystemLibrary("unwind"),
new SystemLibrary("gcc"),
new SystemLibrary("c"),
new SystemLibrary("dl"),

new SystemLibrary("GLESv2"),
new SystemLibrary("log"),
};
if (buildArm64)
{
libraries.Add(new PrecompiledLibrary[]
{
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-22/arch-arm64/usr/lib/crtbegin_so.o"),
});
}
else
{
libraries.Add(new PrecompiledLibrary[]
{
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 SystemLibrary("android_support"),
new SystemLibrary("unwind"),
});
}
return libraries;
});
}

2
engine/README.md


### build icu
```
cd <uiwidigets_dir>\engine
python $FLUTTER_ROOT/flutter/sky/tools/objcopy.py --objcopy $FLUTTER_ROOT/third_party/android_tools/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-objcopy --input $FLUTTER_ROOT/third_party/icu/flutter/icudtl.dat --output icudtl.o --arch arm
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
```
### build uiwidgets
```

52
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()

ninja_params3=" -C out/" +output_path + " third_party/angle:libEGL_static"
elif runtime_mode == "release" and platform == "android":
optimize=""
output_path="android_release"
if architecture == "arm64":
output_path="android_release_arm64"
else:
output_path="android_release"
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 arm64")
dest_folder = os.path.join(dest_folder, "arm64")
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)):

if os.path.exists(Path(work_path + "/../build_release")):
shutil.rmtree(Path(work_path + "/../build_release"))
if os.path.exists(Path(work_path + "/../build_release_arm64")):
shutil.rmtree(Path(work_path + "/../build_release_arm64"))
os.system("mono bee.exe " + platform +"_release")
copy_file(Path(work_path + "/../build_release/"), Path(work_path + "/../../com.unity.uiwidgets/Runtime/Plugins/" + dest_folder))
if platform == "android" and architecture == "arm64":
os.system("mono bee.exe " + platform +"_release_arm64")
else:
os.system("mono bee.exe " + platform +"_release")
if architecture == "arm64":
copy_file(Path(work_path + "/../build_release_arm64/"), Path(work_path + "/../../com.unity.uiwidgets/Runtime/Plugins/" + dest_folder))
else:
copy_file(Path(work_path + "/../build_release/"), Path(work_path + "/../../com.unity.uiwidgets/Runtime/Plugins/" + dest_folder))
if platform == "android":
tundra_file=Path(work_path + "/../artifacts/tundra.dag.json")
rsp = get_rsp(tundra_file, runtime_mode)

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/arm64"))
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 + "/../"))

if os.path.exists(Path(work_path + "/../build_debug_arm64")):
shutil.rmtree(Path(work_path + "/../build_debug_arm64"))
elif platform == "android" and architecture == "arm64":
os.system("mono bee.exe " + platform +"_debug_arm64")
copy_file(Path(work_path + "/../build_debug/"), Path(work_path + "/../../com.unity.uiwidgets/Runtime/Plugins/" + dest_folder))
if architecture == "arm64":
copy_file(Path(work_path + "/../build_debug_arm64/"), Path(work_path + "/../../com.unity.uiwidgets/Runtime/Plugins/" + dest_folder))
else:
copy_file(Path(work_path + "/../build_debug/"), Path(work_path + "/../../com.unity.uiwidgets/Runtime/Plugins/" + dest_folder))
if platform == "ios":
print("\nStarting prlink library...")
os.chdir(Path(work_path + "/../"))

json_list = temp['Nodes']
target_files=''
for item in json_list:
if item['Annotation'].startswith('Link_Android_arm32') and item['Annotation'].find(runtime_mode) != -1:
if item['Annotation'].startswith('Link_Android_arm64' if architecture == "arm64" else 'Link_Android_arm32') and item['Annotation'].find(runtime_mode) != -1:
action_list = item['Inputs']
for o in action_list:
if o.endswith('.rsp'):

15
engine/Scripts/lib_build_android.sh


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

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

python3 lib_build.py -r $engine_path -p android -m $runtime_mode
if [ $architecture = "arm64" ]; then
python3 lib_build.py -r $engine_path -p android -m $runtime_mode --arm64
elif [ ! $architecture ] || [ $architecture = "arm32" ]; then
python3 lib_build.py -r $engine_path -p android -m $runtime_mode
else
echo "If you want to build android arm64, please enter '-a arm64'. \Without entering this, it will build android arm32 by default"
fi

8
com.unity.uiwidgets/Runtime/Plugins/Android/arm64.meta


fileFormatVersion: 2
guid: 50c2cf1b23d954ecfb07bb4ccbd9fd74
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

81
com.unity.uiwidgets/Runtime/Plugins/Android/arm64/libUIWidgets.so.meta


fileFormatVersion: 2
guid: 01e6709a425804d4d8c0f92544b01ce0
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 1
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
: Any
second:
enabled: 0
settings:
Exclude Android: 0
Exclude Editor: 1
Exclude Linux64: 1
Exclude OSXUniversal: 1
Exclude WebGL: 1
Exclude Win: 1
Exclude Win64: 1
Exclude iOS: 1
- first:
Android: Android
second:
enabled: 1
settings:
CPU: ARM64
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
CPU: AnyCPU
DefaultValueInitialized: true
OS: AnyOS
- first:
Standalone: Linux64
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: OSXUniversal
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Win
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Win64
second:
enabled: 0
settings:
CPU: None
- first:
iPhone: iOS
second:
enabled: 0
settings:
AddToEmbeddedBinaries: false
CPU: AnyCPU
CompileFlags:
FrameworkDependencies:
userData:
assetBundleName:
assetBundleVariant:

部分文件因为文件数量过多而无法显示

正在加载...
取消
保存