This commit is contained in:
siyao 2021-08-04 15:24:39 +08:00
Родитель d3e024f996
Коммит 6562531959
3 изменённых файлов: 196 добавлений и 115 удалений

Просмотреть файл

@ -17,6 +17,8 @@ using Bee.Toolchain.GNU;
using Bee.Toolchain.IOS; using Bee.Toolchain.IOS;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
using Bee.Toolchain.Android;
enum UIWidgetsBuildTargetPlatform enum UIWidgetsBuildTargetPlatform
{ {
windows, windows,
@ -690,74 +692,93 @@ class Build
//"SKIA_VERSION=\"0.0\"", //"SKIA_VERSION=\"0.0\"",
"XML_STATIC", "XML_STATIC",
}); });
np.CompilerSettings().Add(c => IsAndroid(c), c => c.WithCustomFlags(new[] { np.CompilerSettings().Add(c => IsAndroid(c), c =>
"-MD", {
"-MF", var flags = new List<string>{
"-MD",
"-MF",
"-I.", "-I.",
"-Ithird_party", "-Ithird_party",
"-Isrc", "-Isrc",
"-I"+ flutterRoot, "-I" + flutterRoot,
"-I"+ flutterRoot+"/third_party/rapidjson/include", "-I" + flutterRoot + "/third_party/rapidjson/include",
"-I"+ skiaRoot, "-I" + skiaRoot,
"-I"+ skiaRoot + "/include/third_party/vulkan", "-I" + skiaRoot + "/include/third_party/vulkan",
"-I"+ flutterRoot+"/flutter/third_party/txt/src", "-I" + flutterRoot + "/flutter/third_party/txt/src",
"-I" + flutterRoot + "/third_party/harfbuzz/src", "-I" + flutterRoot + "/third_party/harfbuzz/src",
"-I" + skiaRoot + "/third_party/externals/icu/source/common", "-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", // "-Igen",
"-I"+ flutterRoot+"/third_party/libcxx/include", "-I" + flutterRoot + "/third_party/libcxx/include",
"-I"+ flutterRoot+"/third_party/libcxxabi/include", "-I" + flutterRoot + "/third_party/libcxxabi/include",
"-I"+ flutterRoot+"/third_party/icu/source/common", "-I" + flutterRoot + "/third_party/icu/source/common",
"-I"+ flutterRoot+"/third_party/icu/source/i18n", "-I" + flutterRoot + "/third_party/icu/source/i18n",
// ignore deprecated code // ignore deprecated code
"-Wno-deprecated-declarations", "-Wno-deprecated-declarations",
"-fno-strict-aliasing", "-fno-strict-aliasing",
// "-march=armv7-a", "-mfloat-abi=softfp",
"-mfloat-abi=softfp", "-mthumb",
//"-mtune=generic-armv7-a", "-fPIC",
"-mthumb", "-pipe",
"-fPIC", "-fcolor-diagnostics",
"-pipe", "-ffunction-sections",
"-fcolor-diagnostics", "-funwind-tables",
"-ffunction-sections", "-fno-short-enums",
"-funwind-tables", "-nostdinc++",
"-fno-short-enums", "-mfpu=neon",
"-nostdinc++", "-Wall",
// "--target=arm-linux-androideabi", "-Wextra",
"--target=aarch64-linux-android", "-Wendif-labels",
"-mfpu=neon", "-Werror",
"-Wall", "-Wno-missing-field-initializers",
"-Wextra", "-Wno-unused-parameter",
"-Wendif-labels", "-Wno-unused-variable",
"-Werror", "-Wno-unused-command-line-argument",
"-Wno-missing-field-initializers", "-Wno-unused-function",
"-Wno-unused-parameter", // "-Wno-non-c-typedef-for-linkage",
"-Wno-unused-variable", "-isystem" + flutterRoot + "/third_party/android_tools/ndk/sources/android/support/include",
"-Wno-unused-command-line-argument", // "-isystem" + flutterRoot +
"-Wno-unused-function", //"-D__ANDROID_API__=16",
// "-Wno-non-c-typedef-for-linkage", // "-fvisibility=hidden",
"-isystem"+ flutterRoot+"/third_party/android_tools/ndk/sources/android/support/include", "--sysroot=" + flutterRoot + "/third_party/android_tools/ndk/sysroot",
"-isystem"+ flutterRoot + "-Wstring-conversion",
//"/third_party/android_tools/ndk/sysroot/usr/include/arm-linux-androideabi", // supress new line error
"/third_party/android_tools/ndk/sysroot/usr/include/aarch64-linux-android", // "-Wnewline-eof",
//"-D__ANDROID_API__=16", "-O0",
// "-fvisibility=hidden", "-g2",
"--sysroot="+ flutterRoot+"/third_party/android_tools/ndk/sysroot", "-fvisibility-inlines-hidden",
"-Wstring-conversion", "-std=c++17",
// supress new line error "-fno-rtti",
// "-Wnewline-eof", "-fno-exceptions",
"-O0", "-nostdlib"
"-g2", };
"-fvisibility-inlines-hidden", if (buildArchitexture!= null && buildArchitexture.Equals("arm64"))
"-std=c++17", {
"-fno-rtti", flags.Add(new []
"-fno-exceptions", {
"-nostdlib" "--target=aarch64-linux-android",
})); "-isystem"+ flutterRoot +
"/third_party/android_tools/ndk/sysroot/usr/include/aarch64-linux-android",
});
}
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("third_party");
np.IncludeDirectories.Add("src"); np.IncludeDirectories.Add("src");
@ -774,36 +795,54 @@ class Build
np.LinkerSettings().Add(c => { np.LinkerSettings().Add(c => {
return IsWindows(c) && c.CodeGen == CodeGen.Debug; return IsWindows(c) && c.CodeGen == CodeGen.Debug;
}, l => l.WithCustomFlags_workaround(new[] { "/DEBUG:FULL" })); }, 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[] { np.LinkerSettings().Add(c => IsAndroid(c), l =>
"-Wl,--fatal-warnings", {
"-fPIC", var flags = new List<string>()
"-Wl,-z,noexecstack", {
"-Wl,-z,now", "-Wl,--fatal-warnings",
"-Wl,-z,relro", "-fPIC",
"-Wl,-z,defs", "-Wl,-z,noexecstack",
"--gcc-toolchain="+ flutterRoot + "-Wl,-z,now",
//"/third_party/android_tools/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64", "-Wl,-z,relro",
"/third_party/android_tools/ndk/toolchains/aarch64-linux-android-4.9/prebuilt/darwin-x86_64", "-Wl,-z,defs",
"-Wl,--no-undefined", "-Wl,--no-undefined",
"-Wl,--exclude-libs,ALL", "-Wl,--exclude-libs,ALL",
"-fuse-ld=lld", "-fuse-ld=lld",
"-Wl,--icf=all", "-Wl,--icf=all",
//"--target=arm-linux-androideabi", "-nostdlib++",
"-nostdlib++", "-Wl,--warn-shared-textrel",
"-Wl,--warn-shared-textrel", "-nostdlib",
"-nostdlib", "-Wl,--build-id=sha1",
//"--sysroot="+ flutterRoot+"/third_party/android_tools/ndk/platforms/android-16/arch-arm", "-g",
"--sysroot="+ flutterRoot+"/third_party/android_tools/ndk/platforms/android-22/arch-arm64", "-Wl,-soname=libUIWidgets.so",
//"-L"+ flutterRoot + "/third_party/android_tools/ndk/sources/cxx-stl/llvm-libc++/libs/armeabi-v7a", "-Wl,--whole-archive",
"-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", if (buildArchitexture!= null && buildArchitexture.Equals("arm64"))
"-g", {
"-Wl,-soname=libUIWidgets.so", flags.Add(new []
"-Wl,--whole-archive", {
})); "--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); SetupDependency(np);
//SetupFml(np); //SetupFml(np);
@ -838,8 +877,15 @@ class Build
} }
else if (platform == UIWidgetsBuildTargetPlatform.android) else if (platform == UIWidgetsBuildTargetPlatform.android)
{ {
//var androidToolchain = ToolChain.Store.Android().r19().Armv7(); AndroidNdkToolchain androidToolchain = null;
var androidToolchain = ToolChain.Store.Android().r19().Arm64(); if (buildArchitexture != null && buildArchitexture.Equals("arm64"))
{
androidToolchain = ToolChain.Store.Android().r19().Arm64();
}
else
{
androidToolchain = ToolChain.Store.Android().r19().Armv7();
}
var validConfigurations = new List<NativeProgramConfiguration>(); var validConfigurations = new List<NativeProgramConfiguration>();
@ -1289,13 +1335,30 @@ class Build
np.Libraries.Add(IsAndroid, c => np.Libraries.Add(IsAndroid, c =>
{ {
if(c.CodeGen == CodeGen.Debug){ if (c.CodeGen == CodeGen.Debug)
return new PrecompiledLibrary[]{ {
new StaticLibrary(flutterRoot+"/out/android_debug_unopt_arm64/obj/flutter/third_party/txt/libtxt_lib.a"), if (buildArchitexture != null && buildArchitexture == "arm64")
}; {
} else { return new PrecompiledLibrary[]
return new PrecompiledLibrary[]{ {
new StaticLibrary(flutterRoot+"/out/android_release/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[]
{
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"),
}; };
} }
}); });
@ -1303,20 +1366,11 @@ class Build
np.Libraries.Add(IsAndroid, c => np.Libraries.Add(IsAndroid, c =>
{ {
var basePath = skiaRoot + "/out/arm"; var basePath = skiaRoot + "/out/arm";
return new PrecompiledLibrary[] var libraries = new List<PrecompiledLibrary>
{ {
// icudtl // icudtl
new StaticLibrary("icudtl.o"), 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-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("gcc"), new SystemLibrary("gcc"),
new SystemLibrary("c"), new SystemLibrary("c"),
new SystemLibrary("dl"), new SystemLibrary("dl"),
@ -1326,6 +1380,30 @@ class Build
new SystemLibrary("GLESv2"), new SystemLibrary("GLESv2"),
new SystemLibrary("log"), new SystemLibrary("log"),
}; };
if (buildArchitexture != null && buildArchitexture == "arm64")
{
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;
}); });
} }

Просмотреть файл

@ -263,7 +263,7 @@ If the compilation fails because "no available Mac SDK is found" (in flutter-1.1
### build icu ### build icu
``` ```
cd <uiwidigets_dir>\engine 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 ### build uiwidgets
``` ```

Просмотреть файл

@ -140,6 +140,8 @@ def set_env_verb():
flutter_root_path = os.getenv('FLUTTER_ROOT_PATH') flutter_root_path = os.getenv('FLUTTER_ROOT_PATH')
else: else:
print("This environment variable has been set, skip") print("This environment variable has been set, skip")
if architecture == "arm64":
os.environ["BUILD_ARCHITECTURE"]="arm64";
env_path = os.getenv('PATH') env_path = os.getenv('PATH')
path_strings = re.split("[;:]", env_path) path_strings = re.split("[;:]", env_path)
for path in path_strings: for path in path_strings:
@ -294,7 +296,8 @@ def build_engine():
dest_folder = "android" dest_folder = "android"
os.chdir(work_path + "/../") os.chdir(work_path + "/../")
if architecture == "arm64": 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") 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: 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") 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": elif platform == "ios":
@ -323,7 +326,7 @@ def build_engine():
os.system("artifacts/Stevedore/android-ndk-mac/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang++ " + "@\"" + rsp + "\"") 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 + "\"") os.system(flutter_root_path + "/buildtools/mac-x64/clang/bin/clang++ " + "@\"" + rsp + "\"")
if architecture == "arm64": if architecture == "arm64":
copy_file(Path(work_path + "/../artifacts/libUIWidgets/release_Android_arm64/libUIWidgets.so"), Path(work_path + "/../../com.unity.uiwidgets/Runtime/Plugins/Android")) copy_file(Path(work_path + "/../artifacts/libUIWidgets/release_Android_arm64/libUIWidgets.so"), Path(work_path + "/../../com.unity.uiwidgets/Runtime/Plugins/Android/arm64"))
else: else:
copy_file(Path(work_path + "/../artifacts/libUIWidgets/release_Android_arm32/libUIWidgets.so"), Path(work_path + "/../../com.unity.uiwidgets/Runtime/Plugins/Android")) copy_file(Path(work_path + "/../artifacts/libUIWidgets/release_Android_arm32/libUIWidgets.so"), Path(work_path + "/../../com.unity.uiwidgets/Runtime/Plugins/Android"))
elif platform == "ios": elif platform == "ios":