From 96181b040406cf99dc7d7caaf0fd3278a82f1e1d Mon Sep 17 00:00:00 2001 From: zmf <279822581@qq.com> Date: Thu, 23 Nov 2023 20:30:58 +0800 Subject: [PATCH 01/10] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zmf <279822581@qq.com> --- README.en.md | 2 ++ README.md | 2 ++ update_engine.sh | 17 +++++++++++++++++ 3 files changed, 21 insertions(+) create mode 100644 update_engine.sh diff --git a/README.en.md b/README.en.md index 672d61668a..f47abe6cc1 100644 --- a/README.en.md +++ b/README.en.md @@ -57,6 +57,8 @@ This warehouse is based on the extension of Flutter's official engine warehouse (For mac environment, please download mac-sdk-full or mac-sdk-m1-full, and the placement directory is ndk/mac/4.0;No need to download OpenHarmony SDK in Windows environment) 5. Start building: engine directory, execute `make` to start building the flutter engine that supports ohos devices. + +6. Update project: execute update_engine.sh under linux/mac ## Embedding layer code construction guide diff --git a/README.md b/README.md index 2de040c7c2..e5c9053ef2 100644 --- a/README.md +++ b/README.md @@ -59,6 +59,8 @@ Flutter Engine 5. 开始构建:engine目录,执行`make`,即可开始构建支持ohos设备的flutter engine。 + +6. 更新代码:linux/mac下执行update_engine.sh ## embedding层代码构建指导 diff --git a/update_engine.sh b/update_engine.sh new file mode 100644 index 0000000000..60ce2a25d4 --- /dev/null +++ b/update_engine.sh @@ -0,0 +1,17 @@ +# 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. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# 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 + +python3 ./src/flutter/attachment/scripts/ohos_reverse_patch.py +git -C ./src/flutter pull +python3 ./src/flutter/attachment/scripts/ohos_setup.py -- Gitee From 2df861fcdac3fdf324c88c657e4193b0c01524f2 Mon Sep 17 00:00:00 2001 From: zmf <279822581@qq.com> Date: Fri, 24 Nov 2023 19:00:21 +0800 Subject: [PATCH 02/10] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zmf <279822581@qq.com> --- README.en.md | 2 +- README.md | 2 +- attachment/repos/bootstrap/update_engine.bat | 19 ++++++++++++ attachment/repos/bootstrap/update_engine.sh | 17 +++++++++++ attachment/scripts/excute_util.py | 31 +++++--------------- attachment/scripts/file_util.py | 15 ++++++---- attachment/scripts/ohos_reverse_patch.py | 23 +++++++++++---- attachment/scripts/ohos_setup.py | 27 ++++++++++------- 8 files changed, 88 insertions(+), 48 deletions(-) create mode 100644 attachment/repos/bootstrap/update_engine.bat create mode 100644 attachment/repos/bootstrap/update_engine.sh diff --git a/README.en.md b/README.en.md index f47abe6cc1..5f7cb601bb 100644 --- a/README.en.md +++ b/README.en.md @@ -58,7 +58,7 @@ This warehouse is based on the extension of Flutter's official engine warehouse 5. Start building: engine directory, execute `make` to start building the flutter engine that supports ohos devices. -6. Update project: execute update_engine.sh under linux/mac +6. Update project: execute `./update_engine.sh` under Linux/Mac;execute `update_engine.bat` under Windows ## Embedding layer code construction guide diff --git a/README.md b/README.md index e5c9053ef2..0447be69ea 100644 --- a/README.md +++ b/README.md @@ -60,7 +60,7 @@ Flutter Engine 5. 开始构建:engine目录,执行`make`,即可开始构建支持ohos设备的flutter engine。 -6. 更新代码:linux/mac下执行update_engine.sh +6. 更新代码:Linux/Mac下在engine目录执行`./update_engine.sh`; Windows下执行`update_engine.bat` ## embedding层代码构建指导 diff --git a/attachment/repos/bootstrap/update_engine.bat b/attachment/repos/bootstrap/update_engine.bat new file mode 100644 index 0000000000..0ea95be367 --- /dev/null +++ b/attachment/repos/bootstrap/update_engine.bat @@ -0,0 +1,19 @@ +@rem Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem http://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. + +@echo off +py -3 .\src\flutter\attachment\scripts\ohos_reverse_patch.py %1 +call git -C .\src\flutter pull +py -3 .\src\flutter\attachment\scripts\ohos_setup.py %1 +echo %1 +pause \ No newline at end of file diff --git a/attachment/repos/bootstrap/update_engine.sh b/attachment/repos/bootstrap/update_engine.sh new file mode 100644 index 0000000000..a95c146943 --- /dev/null +++ b/attachment/repos/bootstrap/update_engine.sh @@ -0,0 +1,17 @@ +# 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. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# 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 + +python3 ./src/flutter/attachment/scripts/ohos_reverse_patch.py $1 +git -C ./src/flutter pull +python3 ./src/flutter/attachment/scripts/ohos_setup.py $1 diff --git a/attachment/scripts/excute_util.py b/attachment/scripts/excute_util.py index dc233031d9..17e7f28c7c 100644 --- a/attachment/scripts/excute_util.py +++ b/attachment/scripts/excute_util.py @@ -29,26 +29,12 @@ def excute(cmdStr, path=".", log=True): try: proc = subprocess.Popen(cmdStr, cwd=path, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - # 逐行读取输出结果 - for line in proc.stdout: - if line == b'' and proc.poll() is not None: - break - data = line.strip() - if log: - print(data) - result += data - error_output = proc.stderr.read().strip() - if error_output: - if log: - print("错误输出:", error_output) - err = True - if err: + out, err = proc.communicate() + if proc.returncode != 0: result = '-1' - if log: - print("执行失败", proc.returncode) - else: - if log: - print("执行成功") + if (log): + print("Executing: %s failed. Exit code: %s" % (cmdStr, proc.returncode)) + except subprocess.CalledProcessError as e: if log: print("命令执行错误:", str(e)) @@ -66,12 +52,9 @@ def excute(cmdStr, path=".", log=True): return result # 执行数组命令 - - -def excuteArr(cmdArr, path="."): +def excuteArr(cmdArr, path=".", log = True): str = ' '.join(cmdArr) - return excute(str, path) - + return excute(str, path, log) def getDateStr(date): hour = date.hour diff --git a/attachment/scripts/file_util.py b/attachment/scripts/file_util.py index 32ec08bd67..28d779a692 100644 --- a/attachment/scripts/file_util.py +++ b/attachment/scripts/file_util.py @@ -35,16 +35,18 @@ def copytree(src, dst, symlinks=False, ignore=None): copy_file(s, d) -def copy_file(sourceFile, targetFile): - print("拷贝文件,从{}到{}".format(sourceFile, targetFile)) +def copy_file(sourceFile, targetFile, log=False): + if log: + print("拷贝文件,从{}到{}".format(sourceFile, targetFile)) if os.path.exists(targetFile): os.remove(targetFile) shutil.copy2(sourceFile, targetFile) # 拷贝文件夹 -def copy_dir(sourceFiles, targetFiles): - print("拷贝文件夹,从{}到{}".format(sourceFiles, targetFiles)) +def copy_dir(sourceFiles, targetFiles, log=False): + if log: + print("拷贝文件夹,从{}到{}".format(sourceFiles, targetFiles)) if os.path.exists(targetFiles): print("目标文件夹已存在,退出") pass @@ -54,8 +56,9 @@ def copy_dir(sourceFiles, targetFiles): # 拷贝文件夹中所有文件到目标目录(必须存在),不拷贝文件夹本身 -def copy_files(source_folder, destination_folder): - print("拷贝文件夹内所有文件,从{}到{}".format(source_folder, destination_folder)) +def copy_files(source_folder, destination_folder, log=False): + if log: + print("拷贝文件夹内所有文件,从{}到{}".format(source_folder, destination_folder)) # 获取源文件夹中的所有文件 files = os.listdir(source_folder) diff --git a/attachment/scripts/ohos_reverse_patch.py b/attachment/scripts/ohos_reverse_patch.py index 2930711e75..cd8a8dec9f 100644 --- a/attachment/scripts/ohos_reverse_patch.py +++ b/attachment/scripts/ohos_reverse_patch.py @@ -12,6 +12,7 @@ # limitations under the License. #!/usr/bin/python +import sys import json import excute_util from operator import itemgetter @@ -24,22 +25,34 @@ from operator import itemgetter """ ROOT = './src/flutter/attachment' -def apply_reverse_patch(task): +def apply_reverse_patch(task, log=False): file_path = task['file_path'] target_path = task['target'] - excute_util.excuteArr(['git', 'apply', '-R', file_path], target_path) + excute_util.excuteArr(['git', 'apply', '-R', '--ignore-whitespace', file_path], target_path, log) pass -def doTask(task): +def apply_reverse_check(task, log=False): + file_path = task['file_path'] + target_path = task['target'] + result = excute_util.excuteArr( + ['git', 'apply', '-R', '--check', '--ignore-whitespace', file_path], target_path, log) + return result != '-1' and 'error' not in result + +def doTask(task, log=False): if (task['type'] == 'patch'): - apply_reverse_patch(task) + if (apply_reverse_check(task, False)): + apply_reverse_patch(task, log) def parse_config(config_file="{}/scripts/config.json".format(ROOT)): + log = False + if (len(sys.argv) > 1): + if(sys.argv[1] == '-v'): + log = True with open(config_file) as json_file: data = json.load(json_file) data = sorted(data, key=itemgetter('name'), reverse=True) for task in data: - doTask(task) + doTask(task, log) if __name__ == "__main__": parse_config() diff --git a/attachment/scripts/ohos_setup.py b/attachment/scripts/ohos_setup.py index 99ca997854..d8f63fd786 100644 --- a/attachment/scripts/ohos_setup.py +++ b/attachment/scripts/ohos_setup.py @@ -12,6 +12,7 @@ # limitations under the License. #!/usr/bin/python +import sys import json import file_util import excute_util @@ -29,40 +30,44 @@ ROOT = './src/flutter/attachment' REPOS_ROOT = ROOT + '/repos' -def apply_patch(task): +def apply_patch(task, log=False): file_path = task['file_path'] target_path = task['target'] - excute_util.excuteArr(['git', 'apply', file_path], target_path) + excute_util.excuteArr(['git', 'apply', file_path], target_path, log) pass -def apply_check(task): +def apply_check(task, log=False): file_path = task['file_path'] target_path = task['target'] result = excute_util.excuteArr( - ['git', 'apply', '--check', file_path], target_path) + ['git', 'apply', '--check', file_path], target_path, log) return result != '-1' and 'error' not in result -def doTask(task): +def doTask(task, log=False): sourceFile = "{}/repos/{}".format(ROOT, task['name']) targetFile = task['target'] if (task['type'] == 'dir'): - file_util.copy_dir(sourceFile, targetFile) + file_util.copy_dir(sourceFile, targetFile, log) elif (task['type'] == 'files'): - file_util.copy_files(sourceFile, targetFile) + file_util.copy_files(sourceFile, targetFile, log) elif (task['type'] == 'file'): - file_util.copy_file(sourceFile, targetFile) + file_util.copy_file(sourceFile, targetFile, log) elif (task['type'] == 'patch'): - if apply_check(task): - apply_patch(task) + if apply_check(task, False): + apply_patch(task, log) def parse_config(config_file="{}/scripts/config.json".format(ROOT)): + log = False + if (len(sys.argv) > 1): + if(sys.argv[1] == '-v'): + log = True with open(config_file) as json_file: data = json.load(json_file) for task in data: - doTask(task) + doTask(task, log) if __name__ == "__main__": -- Gitee From ec197058d090920a9254807cb2537d56a72aedb6 Mon Sep 17 00:00:00 2001 From: zmf <279822581@qq.com> Date: Fri, 24 Nov 2023 21:13:58 +0800 Subject: [PATCH 03/10] =?UTF-8?q?=E7=A7=BB=E9=99=A4=E6=97=A0=E7=94=A8?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zmf <279822581@qq.com> --- attachment/repos/bootstrap/update_engine.bat | 1 - 1 file changed, 1 deletion(-) diff --git a/attachment/repos/bootstrap/update_engine.bat b/attachment/repos/bootstrap/update_engine.bat index 0ea95be367..252a48d3d0 100644 --- a/attachment/repos/bootstrap/update_engine.bat +++ b/attachment/repos/bootstrap/update_engine.bat @@ -15,5 +15,4 @@ py -3 .\src\flutter\attachment\scripts\ohos_reverse_patch.py %1 call git -C .\src\flutter pull py -3 .\src\flutter\attachment\scripts\ohos_setup.py %1 -echo %1 pause \ No newline at end of file -- Gitee From c0e934fd8d52e6656649767331d2286dc132df43 Mon Sep 17 00:00:00 2001 From: zmf <279822581@qq.com> Date: Sat, 25 Nov 2023 18:17:08 +0800 Subject: [PATCH 04/10] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dmac=E5=B9=B3=E5=8F=B0?= =?UTF-8?q?=E5=88=A4=E6=96=AD=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zmf <279822581@qq.com> --- attachment/repos/dart.patch1 | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/attachment/repos/dart.patch1 b/attachment/repos/dart.patch1 index 9daa97ba76..7c90194787 100644 --- a/attachment/repos/dart.patch1 +++ b/attachment/repos/dart.patch1 @@ -154,6 +154,22 @@ index e9f8c7a55cd..b1df3aef772 100644 # TODO(GYP): Figure out which of these work and are needed on other platforms. copy("copy_llvm_symbolizer") { if (is_win) { +diff --git a/runtime/BUILD.gn b/runtime/BUILD.gn +index 042b6a45f7e..7f89f9fcd06 100644 +--- a/runtime/BUILD.gn ++++ b/runtime/BUILD.gn +@@ -87,8 +87,10 @@ config("dart_precompiler_config") { + + config("dart_os_config") { + defines = [] +- if (target_os == "linux") { ++ if (target_os == "linux" && !is_mac) { + target_os = "ohos" ++ } else if (is_mac){ ++ target_os = "mac" + } + print("DART TARGET OS: "+target_os ) + if (target_os == "android") { diff --git a/runtime/bin/BUILD.gn b/runtime/bin/BUILD.gn index 5eecfb63c08..14548125acb 100644 --- a/runtime/bin/BUILD.gn @@ -561,14 +577,14 @@ index e04c881411e..fb5f9dd1993 100644 #else return DynamicLibrary::New(kWindowsDynamicLibraryProcessPtr); diff --git a/runtime/platform/globals.h b/runtime/platform/globals.h -index 7122f9f7d08..373e958a322 100644 +index 7122f9f7d08..f8a861e6c54 100644 --- a/runtime/platform/globals.h +++ b/runtime/platform/globals.h @@ -108,6 +108,10 @@ // Check for Android first, to determine its difference from Linux. #define DART_HOST_OS_ANDROID 1 -+#elif defined(DART_TARGET_OS_OHOS) && !defined(__APPLE__) && !defined(_WIN32) ++#elif defined(DART_TARGET_OS_OHOS) && !defined(_WIN32) + +#define DART_HOST_OS_OHOS 1 + -- Gitee From 065c7950174fbdbadb480066888c40feb651c873 Mon Sep 17 00:00:00 2001 From: zmf <279822581@qq.com> Date: Mon, 27 Nov 2023 11:16:37 +0800 Subject: [PATCH 05/10] =?UTF-8?q?=E4=BD=BF=E7=94=A8=E8=B6=85=E6=97=B6?= =?UTF-8?q?=E6=9C=BA=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zmf <279822581@qq.com> --- attachment/scripts/ohos_reverse_patch.py | 24 ++++-- attachment/scripts/ohos_setup.py | 30 +++++--- .../scripts/sub_process_with_timeout.py | 76 +++++++++++++++++++ 3 files changed, 116 insertions(+), 14 deletions(-) create mode 100644 attachment/scripts/sub_process_with_timeout.py diff --git a/attachment/scripts/ohos_reverse_patch.py b/attachment/scripts/ohos_reverse_patch.py index cd8a8dec9f..c430135038 100644 --- a/attachment/scripts/ohos_reverse_patch.py +++ b/attachment/scripts/ohos_reverse_patch.py @@ -14,7 +14,7 @@ #!/usr/bin/python import sys import json -import excute_util +import sub_process_with_timeout from operator import itemgetter """ @@ -28,15 +28,29 @@ ROOT = './src/flutter/attachment' def apply_reverse_patch(task, log=False): file_path = task['file_path'] target_path = task['target'] - excute_util.excuteArr(['git', 'apply', '-R', '--ignore-whitespace', file_path], target_path, log) + retcode,stdout,stderr = sub_process_with_timeout.excuteArr( + ['git', 'apply', '-R', '--ignore-whitespace','--whitespace=nowarn', file_path], target_path, log, timeout=20) + if retcode == 0 and log: + print("Apply reverse succeded. file path:" + file_path) + if log: + print(str(stdout)) + print(str(stderr)) + if retcode != 0 and log: + print("Apply reverse failed. file path:" + file_path + " Error:" + str(stderr)) pass def apply_reverse_check(task, log=False): file_path = task['file_path'] target_path = task['target'] - result = excute_util.excuteArr( - ['git', 'apply', '-R', '--check', '--ignore-whitespace', file_path], target_path, log) - return result != '-1' and 'error' not in result + retcode,stdout,stderr = sub_process_with_timeout.excuteArr( + ['git', 'apply', '-R', '--check', '--ignore-whitespace', file_path], target_path, log, timeout=20) + if log: + print("retcode:" + str(retcode)) + print(str(stdout)) + print(str(stderr)) + if retcode != 0 and log: + print("Apply reverse check failed. file path:" + file_path + " Error:" + str(stderr)) + return retcode != '-1' and 'error' not in str(stderr) def doTask(task, log=False): if (task['type'] == 'patch'): diff --git a/attachment/scripts/ohos_setup.py b/attachment/scripts/ohos_setup.py index d8f63fd786..a129b955e7 100644 --- a/attachment/scripts/ohos_setup.py +++ b/attachment/scripts/ohos_setup.py @@ -15,7 +15,7 @@ import sys import json import file_util -import excute_util +import sub_process_with_timeout import os """ @@ -29,20 +29,32 @@ import os ROOT = './src/flutter/attachment' REPOS_ROOT = ROOT + '/repos' - def apply_patch(task, log=False): file_path = task['file_path'] target_path = task['target'] - excute_util.excuteArr(['git', 'apply', file_path], target_path, log) + retcode,stdout,stderr = sub_process_with_timeout.excuteArr( + ['git', 'apply', '--ignore-whitespace', '--whitespace=nowarn', file_path], target_path, log, timeout=20) + if retcode == 0 and log: + print("Apply succeded. file path:" + file_path) + if log: + print(str(stdout)) + print(str(stderr)) + if retcode != 0: + print("Apply failed. file path:" + file_path + " Error:" + str(stderr)) pass - def apply_check(task, log=False): file_path = task['file_path'] target_path = task['target'] - result = excute_util.excuteArr( - ['git', 'apply', '--check', file_path], target_path, log) - return result != '-1' and 'error' not in result + retcode,stdout,stderr = sub_process_with_timeout.excuteArr( + ['git', 'apply', '--check', '--ignore-whitespace', file_path], target_path, log, timeout=20) + if log: + print("retcode:" + str(retcode)) + print(str(stdout)) + print(str(stderr)) + if retcode != 0: + print("Apply check failed. file path:" + file_path + " Error:" + str(stderr)) + return retcode != -1 and 'error' not in str(stderr) def doTask(task, log=False): @@ -55,8 +67,9 @@ def doTask(task, log=False): elif (task['type'] == 'file'): file_util.copy_file(sourceFile, targetFile, log) elif (task['type'] == 'patch'): - if apply_check(task, False): + if apply_check(task, log): apply_patch(task, log) + pass def parse_config(config_file="{}/scripts/config.json".format(ROOT)): @@ -69,6 +82,5 @@ def parse_config(config_file="{}/scripts/config.json".format(ROOT)): for task in data: doTask(task, log) - if __name__ == "__main__": parse_config() diff --git a/attachment/scripts/sub_process_with_timeout.py b/attachment/scripts/sub_process_with_timeout.py new file mode 100644 index 0000000000..87873a776b --- /dev/null +++ b/attachment/scripts/sub_process_with_timeout.py @@ -0,0 +1,76 @@ +import subprocess +import threading +import time +import os +import signal +import inspect +import ctypes +import tempfile + + +class TimeoutError(Exception): + pass + +class SubProcess(threading.Thread): + + def __init__(self, cmd, path, timeout=5, log = False): + super(SubProcess,self).__init__() + self.cmd = cmd + self.event = threading.Event() + self.stdout = "" + self.stderr = "" + self.retcode = None + self.timeout = timeout + self.path = path + self.log = log + self.sub = None + + def run(self): + try: + start_time = time.time() + read_flag = end_flag = False + PIPE = subprocess.PIPE + self.sub = subprocess.Popen(self.cmd, cwd=self.path, shell=True, stderr=PIPE, stdout=PIPE, text=True) + while not self.event.is_set() and self.sub.poll() is None: + self.stdout += self.sub.stdout.read() + time.sleep(0.05) + self.stderr +=self.sub.stderr.read() + if (time.time()-start_time) > self.timeout: + self.retcode = -2 + self.sub.stderr = TimeoutError('执行超时:' + self.cmd) + return + self.sub.stdout.close() + self.sub.stderr.close() + self.retcode = self.sub.returncode + except Exception as ex: + self.retcode = -1 + self.stderr = ex + self.event.set() + self.sub.stdout.close() + self.sub.stderr.close() + + def stop(self): + self.event.set() + +# 执行数组命令 +def excuteArr(cmdArr, path=".", log = True, timeout=5): + str = ' '.join(cmdArr) + return execCommandEx(str, path, log, timeout) + +def execCommandEx(cmd, path = ".", log = False, timeout=1): + start_time = end_time = time.time() + sub = SubProcess(cmd, path, 10, log) + sub.daemon = True + sub.start() + while True: + # print("执行中000:" + cmd + " is_set:" + str(sub.event.is_set()) + " is_alive:" + str(sub.is_alive()) + " name:" + sub.name + " time:" + str(time.time()) + " start:" + str(start_time) + " t:" + str(int(time.time() - start_time)) + " tout:" + str(timeout)) + if int(time.time() - start_time) > int(timeout): + # print("执行中:" + cmd + " time:" + str(time.time()) + " start:" + str(start_time) + " t:" + str(int(time.time() - start_time)) + " tout:" + str(timeout)) + sub.retcode = -1 + sub.stderr = TimeoutError('执行超时:' + cmd) + sub.stop() + if not sub.is_alive() or sub.event.is_set(): + break + time.sleep(0.1) + end_time = time.time() + return sub.retcode,sub.stdout,sub.stderr -- Gitee From a512ce5f5d3f71170bb07837262c832ba86c787e Mon Sep 17 00:00:00 2001 From: zmf <279822581@qq.com> Date: Mon, 27 Nov 2023 11:20:15 +0800 Subject: [PATCH 06/10] =?UTF-8?q?=E6=B7=BB=E5=8A=A0windows=E8=84=9A?= =?UTF-8?q?=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zmf <279822581@qq.com> --- attachment/repos/bootstrap/update_engine.bat | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/attachment/repos/bootstrap/update_engine.bat b/attachment/repos/bootstrap/update_engine.bat index 252a48d3d0..8131a4e437 100644 --- a/attachment/repos/bootstrap/update_engine.bat +++ b/attachment/repos/bootstrap/update_engine.bat @@ -14,5 +14,4 @@ @echo off py -3 .\src\flutter\attachment\scripts\ohos_reverse_patch.py %1 call git -C .\src\flutter pull -py -3 .\src\flutter\attachment\scripts\ohos_setup.py %1 -pause \ No newline at end of file +py -3 .\src\flutter\attachment\scripts\ohos_setup.py %1 \ No newline at end of file -- Gitee From bbd0f63271b6d87acddea74329641f6278362917 Mon Sep 17 00:00:00 2001 From: zmf <279822581@qq.com> Date: Mon, 27 Nov 2023 11:27:02 +0800 Subject: [PATCH 07/10] =?UTF-8?q?=E4=BF=AE=E6=AD=A3readme=E8=AF=B4?= =?UTF-8?q?=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zmf <279822581@qq.com> --- README.en.md | 4 ++-- README.md | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.en.md b/README.en.md index 5f7cb601bb..7e9ebe46f2 100644 --- a/README.en.md +++ b/README.en.md @@ -56,9 +56,9 @@ This warehouse is based on the extension of Flutter's official engine warehouse 4. Download sdk: Download ohos-sdk-full in [the daily build](http://ci.openharmony.cn/workbench/cicd/dailybuild/dailylist), create a new folder ndk/linux/4.0 in the engine root directory, unzip the native folder in ohos-sdk-full and place it in ndk/linux/4.0 in folder; (For mac environment, please download mac-sdk-full or mac-sdk-m1-full, and the placement directory is ndk/mac/4.0;No need to download OpenHarmony SDK in Windows environment) -5. Start building: engine directory, execute `make` to start building the flutter engine that supports ohos devices. +5. Start building: In the engine directory, execute `make` to start building the flutter engine that supports ohos devices. -6. Update project: execute `./update_engine.sh` under Linux/Mac;execute `update_engine.bat` under Windows +6. Update project: In the engine directory, execute `./update_engine.sh` (Linux/Mac platform) or `update_engine.bat` (Windows platform) ## Embedding layer code construction guide diff --git a/README.md b/README.md index 0447be69ea..e02286dfc4 100644 --- a/README.md +++ b/README.md @@ -58,9 +58,9 @@ Flutter Engine (mac环境,请下载mac-sdk-full或者mac-sdk-m1-full,放置目录为ndk/mac/4.0;Windows环境无需下载鸿蒙sdk,请参考《构建基础环境》配置Windows环境) -5. 开始构建:engine目录,执行`make`,即可开始构建支持ohos设备的flutter engine。 +5. 开始构建:在engine目录,执行`make`,即可开始构建支持ohos设备的flutter engine。 -6. 更新代码:Linux/Mac下在engine目录执行`./update_engine.sh`; Windows下执行`update_engine.bat` +6. 更新代码:在engine目录,执行`./update_engine.sh`(Linux/Mac平台)或`update_engine.bat`(Windows平台) ## embedding层代码构建指导 -- Gitee From 95e6a1fbb4c76636bb334a88dac6ed932c6bf3e0 Mon Sep 17 00:00:00 2001 From: zmf <279822581@qq.com> Date: Mon, 27 Nov 2023 11:29:10 +0800 Subject: [PATCH 08/10] =?UTF-8?q?=E7=A7=BB=E9=99=A4=E5=A4=9A=E4=BD=99?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E5=92=8C=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zmf <279822581@qq.com> --- attachment/scripts/sub_process_with_timeout.py | 2 -- update_engine.sh | 17 ----------------- 2 files changed, 19 deletions(-) delete mode 100644 update_engine.sh diff --git a/attachment/scripts/sub_process_with_timeout.py b/attachment/scripts/sub_process_with_timeout.py index 87873a776b..3245c97ee7 100644 --- a/attachment/scripts/sub_process_with_timeout.py +++ b/attachment/scripts/sub_process_with_timeout.py @@ -63,9 +63,7 @@ def execCommandEx(cmd, path = ".", log = False, timeout=1): sub.daemon = True sub.start() while True: - # print("执行中000:" + cmd + " is_set:" + str(sub.event.is_set()) + " is_alive:" + str(sub.is_alive()) + " name:" + sub.name + " time:" + str(time.time()) + " start:" + str(start_time) + " t:" + str(int(time.time() - start_time)) + " tout:" + str(timeout)) if int(time.time() - start_time) > int(timeout): - # print("执行中:" + cmd + " time:" + str(time.time()) + " start:" + str(start_time) + " t:" + str(int(time.time() - start_time)) + " tout:" + str(timeout)) sub.retcode = -1 sub.stderr = TimeoutError('执行超时:' + cmd) sub.stop() diff --git a/update_engine.sh b/update_engine.sh deleted file mode 100644 index 60ce2a25d4..0000000000 --- a/update_engine.sh +++ /dev/null @@ -1,17 +0,0 @@ -# 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# 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 - -python3 ./src/flutter/attachment/scripts/ohos_reverse_patch.py -git -C ./src/flutter pull -python3 ./src/flutter/attachment/scripts/ohos_setup.py -- Gitee From 5560a01158733eaf12ff998dbc37d97fd1cfb74b Mon Sep 17 00:00:00 2001 From: zmf <279822581@qq.com> Date: Mon, 27 Nov 2023 12:12:25 +0800 Subject: [PATCH 09/10] =?UTF-8?q?=E4=BF=AE=E5=A4=8Ddart=20apply=E5=90=8E?= =?UTF-8?q?=E7=BC=96=E8=AF=91=E6=89=BE=E4=B8=8D=E5=88=B0=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E9=97=AE=E9=A2=98=EF=BC=9B=E4=BF=AE=E5=A4=8Dpull=E8=AF=AD?= =?UTF-8?q?=E5=8F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zmf <279822581@qq.com> --- attachment/repos/bootstrap/update_engine.bat | 2 +- attachment/repos/bootstrap/update_engine.sh | 2 +- attachment/repos/dart.patch1 | 9 +++++++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/attachment/repos/bootstrap/update_engine.bat b/attachment/repos/bootstrap/update_engine.bat index 8131a4e437..de3d208a60 100644 --- a/attachment/repos/bootstrap/update_engine.bat +++ b/attachment/repos/bootstrap/update_engine.bat @@ -13,5 +13,5 @@ @echo off py -3 .\src\flutter\attachment\scripts\ohos_reverse_patch.py %1 -call git -C .\src\flutter pull +call git -C .\src\flutter checkout master && git -C .\src\flutter pull origin master py -3 .\src\flutter\attachment\scripts\ohos_setup.py %1 \ No newline at end of file diff --git a/attachment/repos/bootstrap/update_engine.sh b/attachment/repos/bootstrap/update_engine.sh index a95c146943..be214136b7 100644 --- a/attachment/repos/bootstrap/update_engine.sh +++ b/attachment/repos/bootstrap/update_engine.sh @@ -13,5 +13,5 @@ #! /bin/bash python3 ./src/flutter/attachment/scripts/ohos_reverse_patch.py $1 -git -C ./src/flutter pull +git -C ./src/flutter checkout master && git -C ./src/flutter pull origin master python3 ./src/flutter/attachment/scripts/ohos_setup.py $1 diff --git a/attachment/repos/dart.patch1 b/attachment/repos/dart.patch1 index 7c90194787..8ca8517164 100644 --- a/attachment/repos/dart.patch1 +++ b/attachment/repos/dart.patch1 @@ -102,6 +102,15 @@ index 36c7e9f4fb4..00a1cb64be8 100644 default_warning_flags += [ "-Wno-type-limits" ] } +diff --git a/build/config/gclient_args.gni b/build/config/gclient_args.gni +new file mode 100755 +index 00000000000..69d89776479 +--- /dev/null ++++ b/build/config/gclient_args.gni +@@ -0,0 +1,2 @@ ++# Generated from 'DEPS' ++checkout_llvm = false +\ No newline at end of file diff --git a/build/config/sanitizers/sanitizers.gni b/build/config/sanitizers/sanitizers.gni index c7da74b09fe..8c11b3401dc 100644 --- a/build/config/sanitizers/sanitizers.gni -- Gitee From c00953fb4ca88f6b3a639bbdd62d784bdd412c62 Mon Sep 17 00:00:00 2001 From: zmf <279822581@qq.com> Date: Mon, 27 Nov 2023 20:30:22 +0800 Subject: [PATCH 10/10] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dwindows=E8=84=9A?= =?UTF-8?q?=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zmf <279822581@qq.com> --- attachment/repos/bootstrap/ohos.bat | 21 ++----------------- .../scripts/sub_process_with_timeout.py | 4 ++-- 2 files changed, 4 insertions(+), 21 deletions(-) diff --git a/attachment/repos/bootstrap/ohos.bat b/attachment/repos/bootstrap/ohos.bat index a52ff9e297..11f503836a 100644 --- a/attachment/repos/bootstrap/ohos.bat +++ b/attachment/repos/bootstrap/ohos.bat @@ -14,25 +14,8 @@ @echo off setlocal EnableDelayedExpansion -:config_debug_env call python .\src\flutter\tools\gn --unoptimized --runtime-mode=debug --ohos --ohos-cpu=arm64 -EXIT /B 0 - - - -:config_release_env call python .\src\flutter\tools\gn --runtime-mode=release --ohos --unoptimized --ohos-cpu=arm64 -EXIT /B 0 - -:config_host_debug_env -src/flutter/tools/gn "!HOST_OPT!" "--runtime-mode" "!RT_MODE!" "--no-dart-version-git-info" "--full-dart-sdk" "--no-build-web-sdk" "--disable-desktop-embeddings" "--no-build-embedder-examples" "--verbose" "--trace-gn" -EXIT /B 0 - -:config -CALL :config_debug_env -@REM CALL :config_release_env -EXIT /B 0 +ninja -C .\src\out\ohos_debug_unopt_arm64 +ninja -C .\src\out\ohos_release_arm64 -:compile -REM UNKNOWN: {"type":"Pipeline","commands":[{"type":"Command","name":{"text":"find","type":"Word"},"suffix":[{"text":"src/out","type":"Word"},{"text":"-mindepth","type":"Word"},{"text":"1","type":"Word"},{"text":"-maxdepth","type":"Word"},{"text":"1","type":"Word"},{"text":"-type","type":"Word"},{"text":"d","type":"Word"}]},{"type":"Command","name":{"text":"xargs","type":"Word"},"suffix":[{"text":"-n","type":"Word"},{"text":"1","type":"Word"},{"text":"sh","type":"Word"},{"text":"-c","type":"Word"},{"text":"ninja -C $0 || exit 255","type":"Word"}]}]} -EXIT /B 0 diff --git a/attachment/scripts/sub_process_with_timeout.py b/attachment/scripts/sub_process_with_timeout.py index 3245c97ee7..36ab5b0bb0 100644 --- a/attachment/scripts/sub_process_with_timeout.py +++ b/attachment/scripts/sub_process_with_timeout.py @@ -53,11 +53,11 @@ class SubProcess(threading.Thread): self.event.set() # 执行数组命令 -def excuteArr(cmdArr, path=".", log = True, timeout=5): +def excuteArr(cmdArr, path=".", log = True, timeout=10): str = ' '.join(cmdArr) return execCommandEx(str, path, log, timeout) -def execCommandEx(cmd, path = ".", log = False, timeout=1): +def execCommandEx(cmd, path = ".", log = False, timeout=10): start_time = end_time = time.time() sub = SubProcess(cmd, path, 10, log) sub.daemon = True -- Gitee