From 48326945549f3fb40c8534688b0e188520310f81 Mon Sep 17 00:00:00 2001 From: xuchang Date: Tue, 10 Oct 2023 03:45:43 -0700 Subject: [PATCH] =?UTF-8?q?IssueNo:=20#I86Y89=20engine=E5=85=BC=E5=AE=B9ma?= =?UTF-8?q?c=E7=8E=AF=E5=A2=83=E7=BC=96=E8=AF=91=20Description:=20engine?= =?UTF-8?q?=E5=85=BC=E5=AE=B9mac=E7=8E=AF=E5=A2=83=E7=BC=96=E8=AF=91=20Sig?= =?UTF-8?q?:=20OpenHarmony-SIG/flutter-engine=20Feature=20or=20Bugfix:=20F?= =?UTF-8?q?eature=20Binary=20Source:=20No?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: xuchang --- OAT.xml | 1 + attachment/repos/bootstrap/ohos.sh | 9 ++- attachment/repos/build3.bin | 112 +++++++++++++++++++++++++++++ attachment/repos/dart.patch | 39 +++++++++- attachment/scripts/config.json | 8 ++- 5 files changed, 165 insertions(+), 4 deletions(-) create mode 100644 attachment/repos/build3.bin diff --git a/OAT.xml b/OAT.xml index 4d0f4aafc4..553069e858 100644 --- a/OAT.xml +++ b/OAT.xml @@ -94,6 +94,7 @@ used to filter file path. + diff --git a/attachment/repos/bootstrap/ohos.sh b/attachment/repos/bootstrap/ohos.sh index e58a59e113..7d623708a0 100755 --- a/attachment/repos/bootstrap/ohos.sh +++ b/attachment/repos/bootstrap/ohos.sh @@ -1,3 +1,4 @@ +#! /bin/bash # Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -10,12 +11,18 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -#! /bin/bash # #编译依赖 #sudo apt install g++-multilib git python3 curl +if [[ `uname` =~ 'Darwin' ]]; then +HOST_OS=mac +elif [[ `uname` =~ 'Linux' ]];then HOST_OS=linux +else +HOST_OS=linux +fi + NDK_HOME=`pwd`/ndk/$HOST_OS/4.0/native NDK_TOOLCHAIN_CMAKE=$NDK_HOME/build/cmake/ohos.toolchain.cmake NDK_SDK_CMAKE=$NDK_HOME/build/cmake/sdk_native_platforms.cmake diff --git a/attachment/repos/build3.bin b/attachment/repos/build3.bin new file mode 100644 index 0000000000..e28c91ec35 --- /dev/null +++ b/attachment/repos/build3.bin @@ -0,0 +1,112 @@ +diff --git a/build/config/BUILDCONFIG.gn b/build/config/BUILDCONFIG.gn +index 301b014..bd3476a 100644 +--- a/build/config/BUILDCONFIG.gn ++++ b/build/config/BUILDCONFIG.gn +@@ -34,11 +34,8 @@ + # When writing build files, to do something only for the host: + # if (current_toolchain == host_toolchain) { ... + +-print("11target_os:"+target_os) +-print("11target_cpu:"+target_cpu) + + if (target_os == "") { +- #target_os = host_os + target_os = "ohos" + } + +@@ -60,16 +57,14 @@ if (current_cpu == "") { + if (current_os == "") { + if (host_os == "win") { + current_os = "win" ++ } else if (host_os == "mac" && (target_os == "ohos" || target_os == "linux")) { ++ current_os = "ohos" + } else { + #current_os = target_os + current_os = host_os + } + } + +-print("current_os:"+current_os) +-print("current_cpu:"+current_cpu) +-print("target_os:"+target_os) +-print("target_cpu:"+target_cpu) + # ============================================================================= + # BUILD FLAGS + # ============================================================================= +@@ -279,6 +274,19 @@ if (current_os == "win") { + is_posix = true + is_win = false + is_wasm = false ++} else if ((current_os == "ohos" || current_os == "linux") && host_os == "mac") { ++ target_os="linux" ++ is_android = false ++ is_chromeos = false ++ is_fuchsia = false ++ is_fuchsia_host = false ++ is_ios = false ++ is_linux = true ++ is_ohos = true ++ is_mac = false ++ is_posix = true ++ is_win = false ++ is_wasm = false + } else if (current_os == "linux") { + is_android = false + is_chromeos = false +@@ -394,7 +402,7 @@ if (is_posix) { + ] + } + +-if( is_ohos){ ++if(is_ohos || (is_linux && host_os == "mac")){ + _native_compiler_configs += [ "//build/config/ohos:sdk" ] + }else if (is_linux) { + _native_compiler_configs += [ "//build/config/linux:sdk" ] +@@ -541,8 +549,18 @@ shlib_toolchain = false + if (custom_toolchain != "") { + assert(custom_sysroot != "") + assert(custom_target_triple != "") +- host_toolchain = "//build/toolchain/linux:clang_$host_cpu" + set_default_toolchain("//build/toolchain/custom") ++ if (host_os == "linux") { ++ if (is_clang) { ++ host_toolchain = "//build/toolchain/linux:clang_$host_cpu" ++ } else { ++ host_toolchain = "//build/toolchain/linux:$host_cpu" ++ } ++ } else if (host_os == "mac") { ++ host_toolchain = "//build/toolchain/mac:clang_$host_cpu" ++ } else { ++ assert(false, "Unknown host for ohos cross compile") ++ } + } else if (is_win) { + if (is_clang) { + host_toolchain = "//build/toolchain/win:clang_$host_cpu" +@@ -576,15 +594,19 @@ if (custom_toolchain != "") { + set_default_toolchain("//build/toolchain/android:$current_cpu") + } + } else if (is_ohos) { +- if (is_clang) { +- host_toolchain = "//build/toolchain/linux:clang_$host_cpu" +- set_default_toolchain("//build/toolchain/linux:clang_$current_cpu") ++ if (host_os == "linux") { ++ if (is_clang) { ++ host_toolchain = "//build/toolchain/linux:clang_$host_cpu" ++ set_default_toolchain("//build/toolchain/linux:clang_$current_cpu") ++ } else { ++ host_toolchain = "//build/toolchain/linux:$host_cpu" ++ set_default_toolchain("//build/toolchain/linux:$current_cpu") ++ } ++ } else if (host_os == "mac") { ++ host_toolchain = "//build/toolchain/mac:clang_$host_cpu" ++ set_default_toolchain("//build/toolchain/ohos:clang_$current_cpu") + } else { +- host_toolchain = "//build/toolchain/linux:$host_cpu" +- set_default_toolchain("//build/toolchain/linux:$current_cpu") +- } +- if (is_chromeos && cros_use_custom_toolchain) { +- set_default_toolchain("//build/toolchain/cros:target") ++ assert(false, "Unknown host for ohos cross compile") + } + } else if (is_linux) { + if (is_clang) { diff --git a/attachment/repos/dart.patch b/attachment/repos/dart.patch index 708f9c78a0..840d6495d5 100644 --- a/attachment/repos/dart.patch +++ b/attachment/repos/dart.patch @@ -112,7 +112,7 @@ index 33be98fc0aa..eda146a0580 100644 String? _authCode; diff --git a/runtime/BUILD.gn b/runtime/BUILD.gn -index 13bfd0a724b..65227b4be20 100644 +index 13bfd0a724b..28ea7c79797 100644 --- a/runtime/BUILD.gn +++ b/runtime/BUILD.gn @@ -88,6 +88,7 @@ config("dart_precompiler_config") { @@ -146,8 +146,16 @@ index 13bfd0a724b..65227b4be20 100644 } # We need to build gen_snapshot targeting Fuchsia during a build of the SDK +@@ -221,6 +231,7 @@ config("dart_config") { + "-ggdb3", + "-fno-rtti", + "-fno-exceptions", ++ "-Wno-sign-compare" + ] + if (is_clang) { + cflags += [ diff --git a/runtime/bin/BUILD.gn b/runtime/bin/BUILD.gn -index f597fa5b0c3..2bb3bd42adc 100644 +index f597fa5b0c3..fa98edfee62 100644 --- a/runtime/bin/BUILD.gn +++ b/runtime/bin/BUILD.gn @@ -32,6 +32,11 @@ config("libdart_builtin_config") { @@ -162,6 +170,33 @@ index f597fa5b0c3..2bb3bd42adc 100644 } template("build_libdart_builtin") { +@@ -452,7 +457,7 @@ template("dart_io") { + ] + } + +- if (is_linux || is_win || is_fuchsia) { ++ if (is_linux || is_win || is_fuchsia || is_ohos) { + if (dart_use_fallback_root_certificates) { + sources += [ "//third_party/root_certificates/root_certificates.cc" ] + } else { +@@ -1036,7 +1041,7 @@ shared_library("entrypoints_verification_test") { + # The only effect of DART_SHARED_LIB is to export the Dart API. + "DART_SHARED_LIB", + ] +- if (is_linux || is_android) { ++ if (is_linux || is_android || is_ohos) { + cflags = [ "-fPIC" ] + } + if (is_win) { +@@ -1091,7 +1096,7 @@ shared_library("ffi_test_functions") { + # The only effect of DART_SHARED_LIB is to export the Dart API. + "DART_SHARED_LIB", + ] +- if (is_linux || is_android) { ++ if (is_linux || is_android || is_ohos) { + cflags = [ "-fPIC" ] + } + if (is_win) { diff --git a/runtime/bin/builtin_natives.cc b/runtime/bin/builtin_natives.cc index 14762ed7e63..74ea2336efc 100644 --- a/runtime/bin/builtin_natives.cc diff --git a/attachment/scripts/config.json b/attachment/scripts/config.json index 7150038643..d15251e003 100644 --- a/attachment/scripts/config.json +++ b/attachment/scripts/config.json @@ -51,5 +51,11 @@ "target": "./src/build", "type": "patch", "file_path": "../flutter/attachment/repos/build2.bin" + }, + { + "name": "build3", + "target": "./src/build", + "type": "patch", + "file_path": "../flutter/attachment/repos/build3.bin" } -] \ No newline at end of file +] -- Gitee