diff --git a/attachment/scripts/artifacts_files.json b/attachment/scripts/artifacts_files.json new file mode 100644 index 0000000000000000000000000000000000000000..31a2e2e42ab5cdcfc9fc851e9db75333e6516625 --- /dev/null +++ b/attachment/scripts/artifacts_files.json @@ -0,0 +1,55 @@ +{ + "darwin-arm64": { + "src/out/host_release/gen/frontend_server.dart.snapshot": "frontend_server.dart.snapshot", + "src/out/host_release/gen_snapshot": "gen_snapshot", + "src/out/host_release/icudtl.dat": "icudtl.dat", + "src/out/host_release/impellerc": "impellerc", + "src/out/host_debug_unopt/gen/flutter/lib/snapshot/isolate_snapshot.bin": "isolate_snapshot.bin", + "src/out/host_release/libpath_ops.dylib": "libpath_ops.dylib", + "src/out/host_release/libtessellator.dylib": "libtessellator.dylib", + "src/out/host_release/shader_lib/": "shader_lib", + "src/out/host_debug_unopt/gen/flutter/lib/snapshot/vm_isolate_snapshot.bin": "vm_isolate_snapshot.bin", + "src/out/host_release/gen/const_finder.dart.snapshot": "const_finder.dart.snapshot" + + }, + "darwin-x64": { + "src/out/host_release/flutter_tester": "flutter_tester", + "src/out/host_release/gen/frontend_server.dart.snapshot": "frontend_server.dart.snapshot", + "src/out/host_release/gen_snapshot": "gen_snapshot", + "src/out/host_release/icudtl.dat": "icudtl.dat", + "src/out/host_release/impellerc": "impellerc", + "src/out/host_debug_unopt/gen/flutter/lib/snapshot/isolate_snapshot.bin": "isolate_snapshot.bin", + "src/out/host_release/libpath_ops.dylib": "libpath_ops.dylib", + "src/out/host_release/libtessellator.dylib": "libtessellator.dylib", + "src/out/host_release/shader_lib/": "shader_lib", + "src/out/host_debug_unopt/gen/flutter/lib/snapshot/vm_isolate_snapshot.bin": "vm_isolate_snapshot.bin", + "src/out/host_release/gen/const_finder.dart.snapshot": "const_finder.dart.snapshot" + }, + "windows-x64": { + "src/out/host_release/flutter_tester.exe": "flutter_tester.exe", + "src/out/host_release/gen/frontend_server.dart.snapshot": "frontend_server.dart.snapshot", + "src/out/host_release/gen_snapshot.exe": "gen_snapshot.exe", + "src/out/host_release/icudtl.dat": "icudtl.dat", + "src/out/host_release/impellerc.exe": "impellerc.exe", + "src/out/host_debug_unopt/gen/flutter/lib/snapshot/isolate_snapshot.bin": "isolate_snapshot.bin", + "src/out/host_release/path_ops.dll": "path_ops.dll", + "src/out/host_release/libtessellator.dll": "libtessellator.dll", + "src/out/host_release/shader_lib/": "shader_lib", + "src/out/host_debug_unopt/gen/flutter/lib/snapshot/vm_isolate_snapshot.bin": "vm_isolate_snapshot.bin", + "src/out/host_release/gen/const_finder.dart.snapshot": "const_finder.dart.snapshot" + }, + "linux-x64": { + "src/out/host_release/flutter_tester": "flutter_tester", + "src/out/host_release/gen/frontend_server.dart.snapshot": "frontend_server.dart.snapshot", + "src/out/host_release/gen_snapshot": "gen_snapshot", + "src/out/host_release/icudtl.dat": "icudtl.dat", + "src/out/host_release/impellerc": "impellerc", + "src/out/host_debug_unopt/gen/flutter/lib/snapshot/isolate_snapshot.bin": "isolate_snapshot.bin", + "src/out/host_release/libpath_ops.so": "libpath_ops.so", + "src/out/host_release/libtessellator.so": "libtessellator.so", + "src/out/host_release/shader_lib/": "shader_lib", + "src/out/host_debug_unopt/gen/flutter/lib/snapshot/vm_isolate_snapshot.bin": "vm_isolate_snapshot.bin", + "src/out/host_release/gen/const_finder.dart.snapshot": "const_finder.dart.snapshot" + } +} + diff --git a/attachment/scripts/auto_compile.py b/attachment/scripts/auto_compile.py index 3dab798b0f7fceefc7e225ddecf1d4d678966014..124b912ae8feff4368219deb39cb242f44842a63 100644 --- a/attachment/scripts/auto_compile.py +++ b/attachment/scripts/auto_compile.py @@ -20,6 +20,8 @@ import subprocess import sys import traceback import zipfile +import argparse +from pathlib import Path from obs import ObsClient, PutObjectHeader # 使用华为obs @@ -28,14 +30,16 @@ from obs import ObsClient, PutObjectHeader OS_NAME = platform.system().lower() IS_WINDOWS = OS_NAME.startswith("win") IS_MAC = OS_NAME.startswith("darwin") -FLUTTER_ENGINE_PATH = os.path.join(os.getcwd(), 'src', 'flutter') -OHOS_ENGINE_TYPE_OUT = {'ohos-arm64' : 'ohos_debug_unopt_arm64', - 'ohos-arm64-profile' : 'ohos_profile_arm64', - 'ohos-arm64-release' : 'ohos_release_arm64', - 'ohos-x64' : 'ohos_debug_unopt_x64', - 'ohos-x64-profile' : 'ohos_profile_x64', - 'ohos-x64-release' : 'ohos_release_x64', - } +engine_project_root_dir = Path(os.path.realpath(__file__)).parents[4] +FLUTTER_ENGINE_PATH = os.path.join(engine_project_root_dir.__str__(), 'src', 'flutter') +OHOS_ENGINE_TYPE_OUT = { + 'ohos-arm64': 'ohos_debug_unopt_arm64', + 'ohos-arm64-profile': 'ohos_profile_arm64', + 'ohos-arm64-release': 'ohos_release_arm64', + 'ohos-x64': 'ohos_debug_unopt_x64', + 'ohos-x64-profile': 'ohos_profile_x64', + 'ohos-x64-release': 'ohos_release_x64', +} UPLOAD_TEMPLATE = "upload_template.json" @@ -46,189 +50,213 @@ SECRET_KEY = os.getenv("SecretAccessKey") # 服务器地址 华南-广州 SERVER = "https://obs.cn-south-1.myhuaweicloud.com" -# OBS桶 +# OBS桶 FLUTTER_OHOS = 'flutter-ohos' + def log(msg): - print(f'================{msg}============') + print(f'================{msg}============') + def runGitCommand(command): - result = subprocess.run(command, capture_output=True, text=True, shell=True) - if result.returncode != 0: - raise Exception(f"Git command failed: {result.stderr}") - return result.stdout.strip() + result = subprocess.run(command, capture_output=True, text=True, shell=True) + if result.returncode != 0: + raise Exception(f"Git command failed: {result.stderr}") + return result.stdout.strip() + def runPyCommand(command): - if IS_WINDOWS: - proc = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) - else: - proc = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=False) + if IS_WINDOWS: + proc = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) + else: + proc = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=False) - # 获取实时输出 - for line in iter(proc.stdout.readline, b''): - print(line.decode('utf-8').strip()) + # 获取实时输出 + for line in iter(proc.stdout.readline, b''): + print(line.decode('utf-8').strip()) + + # 等待命令执行完成 + proc.wait() - # 等待命令执行完成 - proc.wait() def getRemoteTags(repoPath, remoteName='origin'): - # 获取远程仓库的所有标签 - tagsOutput = runGitCommand(f'git -C {repoPath} ls-remote --tags {remoteName}') + # 获取远程仓库的所有标签 + tagsOutput = runGitCommand(f'git -C {repoPath} ls-remote --tags {remoteName}') + + # 分割输出,每一行都是一个tag + tags = tagsOutput.split('\n') - # 分割输出,每一行都是一个tag - tags = tagsOutput.split('\n') + # 去除空行和解析tag信息 + parsedTags = [line.split()[0] for line in tags if line] - # 去除空行和解析tag信息 - parsedTags = [line.split()[0] for line in tags if line] + return parsedTags - return parsedTags # 在指定目录及其子目录中查找指定的文件 def findFile(directory, filename): - for root, dirs, files in os.walk(directory): - if filename in files: - return (os.path.join(root, filename)) + for root, dirs, files in os.walk(directory): + if filename in files: + return (os.path.join(root, filename)) + # 获取上传对象的进度 def uploadCallback(transferredAmount, totalAmount, totalSeconds): - # 获取上传平均速率(KB/S) - speed = int(transferredAmount / totalSeconds / 1024) - # 获取上传进度百分比 - progress = int(transferredAmount * 100.0 / totalAmount) - print("\r", end="") - print("Speed: {} KB/S progress: {}%: ".format(speed, progress), "▓" * (progress // 2), end="") - sys.stdout.flush() - if progress == 100: - print("") + # 获取上传平均速率(KB/S) + speed = int(transferredAmount / totalSeconds / 1024) + # 获取上传进度百分比 + progress = int(transferredAmount * 100.0 / totalAmount) + print("\r", end="") + print("Speed: {} KB/S progress: {}%: ".format(speed, progress), "▓" * (progress // 2), end="") + sys.stdout.flush() + if progress == 100: + print("") + # 检查TAG版本 def checkRemoteTagsUpdates(): - # 获取远程TAG的最新提交哈希 - remoteTags = getRemoteTags(FLUTTER_ENGINE_PATH) - remoteLatestTag = remoteTags[-1] + # 获取远程TAG的最新提交哈希 + remoteTags = getRemoteTags(FLUTTER_ENGINE_PATH) + remoteLatestTag = remoteTags[-1] - # 获取本地分支的最新提交哈希 - localLatestCommit = runGitCommand(f'git -C {FLUTTER_ENGINE_PATH} rev-parse HEAD') + # 获取本地分支的最新提交哈希 + localLatestCommit = runGitCommand(f'git -C {FLUTTER_ENGINE_PATH} rev-parse HEAD') + + if remoteLatestTag != localLatestCommit: + log("Remote repository has updates.") + return True + else: + log("Local repository is up to date.") + return False - if remoteLatestTag != localLatestCommit: - log("Remote repository has updates.") - return True - else: - log("Local repository is up to date.") - return False # 检查分支更新 def checkRemoteBranchUpdates(repoPath, remoteName='origin', branch='dev'): - # 切换到你的Git仓库目录 - os.chdir(repoPath) + # 切换到你的Git仓库目录 + os.chdir(repoPath) - # 获取远程分支的最新提交哈希 - remoteLatestCommit = runGitCommand(f'git -C {repoPath} rev-parse {remoteName}/{branch}') + # 获取远程分支的最新提交哈希 + remoteLatestCommit = runGitCommand(f'git -C {repoPath} rev-parse {remoteName}/{branch}') - # 获取本地分支的最新提交哈希 - localLatestCommit = runGitCommand(f'git -C {repoPath} rev-parse HEAD') + # 获取本地分支的最新提交哈希 + localLatestCommit = runGitCommand(f'git -C {repoPath} rev-parse HEAD') - if remoteLatestCommit != localLatestCommit: - log("Remote repository has updates.") - return True - else: - log("Local repository is up to date.") - return False + if remoteLatestCommit != localLatestCommit: + log("Remote repository has updates.") + return True + else: + log("Local repository is up to date.") + return False # 获取编译产物 def getCompileFiles(buildType): - zipfiles = ['artifacts.zip','linux-x64.zip','windows-x64.zip','darwin-x64.zip','symbols.zip'] + zipfiles = ['artifacts.zip', 'linux-x64.zip', 'windows-x64.zip', 'darwin-x64.zip', 'symbols.zip'] + + files = [] + for fileName in zipfiles: + if IS_WINDOWS and fileName != 'windows-x64.zip': + continue + if IS_MAC and fileName != 'darwin-x64.zip': + continue - files = [] - for fileName in zipfiles: - if IS_WINDOWS and fileName != 'windows-x64.zip': - continue - if IS_MAC and fileName != 'darwin-x64.zip': - continue + files.append( + findFile( + os.path.join(engine_project_root_dir.__str__(), 'src', 'out', buildType), fileName + ) + ) - files.append(findFile(os.path.join(os.getcwd(), 'src', 'out', buildType), fileName)) + return files - return files def uploadExtraFiles(localVersion): - log("uploadExtraFiles ") - if not os.path.exists(UPLOAD_TEMPLATE): - log(f"File not exist: {UPLOAD_TEMPLATE}") - return - with open(UPLOAD_TEMPLATE, 'r') as jsonFile: - jsonData = json.load(jsonFile) - tag = jsonData["tag"] - if not tag: - tag = localVersion; - log(f"tag = {tag}") - uploadFiles = jsonData["files"] - for key in uploadFiles: - value = uploadFiles[key] - if os.path.exists(value): - uploadServer(tag, key, value) - else: - log(f"Not exist file: {value}") + log("uploadExtraFiles ") + if not os.path.exists(UPLOAD_TEMPLATE): + log(f"File not exist: {UPLOAD_TEMPLATE}") + return + with open(UPLOAD_TEMPLATE, 'r') as jsonFile: + jsonData = json.load(jsonFile) + tag = jsonData["tag"] + if not tag: + tag = localVersion + log(f"tag = {tag}") + uploadFiles = jsonData["files"] + for key in uploadFiles: + value = uploadFiles[key] + if os.path.exists(value): + uploadServer(tag, key, value) + else: + log(f"Not exist file: {value}") + # 上传服务器 def uploadServer(version, buildType, filePath): - try: - log(f'upload: {filePath}') - - bucketName = FLUTTER_OHOS - obsClient = ObsClient(access_key_id=ACCESS_KEY, secret_access_key=SECRET_KEY, server=SERVER) - - # 上传对象的附加头域 - headers = PutObjectHeader() - # 【可选】待上传对象的MIME类型 - headers.contentType = 'text/plain' - - # https://storage.flutter-io.cn/flutter_infra_release/flutter/cececddab019a56da828c41d55cb54484278e880/ohos-arm64-profile/linux-x64.zip - fileName = os.path.basename(filePath) - objectKey = f'flutter_infra_release/flutter/{version}/{buildType}/{fileName}' - log(f'objectKey: {objectKey}') - - # 待上传文件/文件夹的完整路径,如aa/bb.txt,或aa/ - file_path = filePath - - # 文件上传 - resp = obsClient.putFile(bucketName, objectKey, file_path, headers=headers, progressCallback=uploadCallback) - # 返回码为2xx时,接口调用成功,否则接口调用失败 - if resp.status < 300: - print('Put Content Succeeded') - print('requestId:', resp.requestId) - print('etag:', resp.body.etag) - else: - print('Put Content Failed') - print('requestId:', resp.requestId) - print('errorCode:', resp.errorCode) - print('errorMessage:', resp.errorMessage) - - except: - log('Put Content Failed') - log(traceback.format_exc()) + try: + log(f'upload: {filePath}') + + bucketName = FLUTTER_OHOS + obsClient = ObsClient(access_key_id=ACCESS_KEY, secret_access_key=SECRET_KEY, server=SERVER) + + # 上传对象的附加头域 + headers = PutObjectHeader() + # 【可选】待上传对象的MIME类型 + headers.contentType = 'text/plain' + + # https://storage.flutter-io.cn/flutter_infra_release/flutter/cececddab019a56da828c41d55cb54484278e880/ohos-arm64-profile/linux-x64.zip + fileName = os.path.basename(filePath) + objectKey = f'flutter_infra_release/flutter/{version}/{buildType}/{fileName}' + log(f'objectKey: {objectKey}') + + # 待上传文件/文件夹的完整路径,如aa/bb.txt,或aa/ + file_path = filePath + + # 文件上传 + resp = obsClient.putFile( + bucketName, objectKey, file_path, headers=headers, progressCallback=uploadCallback + ) + # 返回码为2xx时,接口调用成功,否则接口调用失败 + if resp.status < 300: + print('Put Content Succeeded') + print('requestId:', resp.requestId) + print('etag:', resp.body.etag) + else: + print('Put Content Failed') + print('requestId:', resp.requestId) + print('errorCode:', resp.errorCode) + print('errorMessage:', resp.errorMessage) + + except: + log('Put Content Failed') + log(traceback.format_exc()) def main(): - if checkRemoteTagsUpdates() : - localVersion = runGitCommand(f'git -C {FLUTTER_ENGINE_PATH} rev-parse HEAD') - log(localVersion) + if checkRemoteTagsUpdates(): + parser = argparse.ArgumentParser( + prog='auto_compile', description='upload artifacts', epilog='upload artifacts' + ) + parser.add_argument('-t', '--tag') + args = parser.parse_args() + if args.tag: + version = args.tag + else: + version = runGitCommand(f'git -C {FLUTTER_ENGINE_PATH} rev-parse HEAD') + log(version) + # 获取编译产物 + for buildType in OHOS_ENGINE_TYPE_OUT: + zipfiles = getCompileFiles(OHOS_ENGINE_TYPE_OUT[buildType]) + for filePath in zipfiles: + if not filePath or not os.path.exists(filePath): + continue + uploadServer(version, buildType, filePath) - # 获取编译产物 - for buildType in OHOS_ENGINE_TYPE_OUT: - zipfiles = getCompileFiles(OHOS_ENGINE_TYPE_OUT[buildType]) - for filePath in zipfiles: - if not filePath or not os.path.exists(filePath): - continue - uploadServer(localVersion, buildType, filePath) + uploadExtraFiles(version) + log('上传完成') - uploadExtraFiles(localVersion) - log('上传完成') + else: + log("本地代码已经是最新") - else : - log("本地代码已经是最新") if __name__ == "__main__": - exit(main()) + exit(main()) diff --git a/attachment/scripts/ohos.py b/attachment/scripts/ohos.py index acf42ab53f248de834f88d40052467505f9b7baa..cf53065a5cdb6d0850d4205fc114727cb419cacc 100644 --- a/attachment/scripts/ohos.py +++ b/attachment/scripts/ohos.py @@ -26,7 +26,7 @@ import sys import zipfile from datetime import datetime -SUPPORT_BUILD_NAMES = ("clean", "config", "har", "compile", "zip", "zip2", "upload") +SUPPORT_BUILD_NAMES = ("clean", "config", "har", "compile", "zip", "zip2", "upload", "host") SUPPORT_BUILD_TYPES = ("debug", "profile", "release") SUPPORT_ABIS = { "x86": "x86", @@ -198,6 +198,7 @@ def engineConfig(buildInfo, args): + unixCommand + "--no-goma " + "--no-prebuilt-dart-sdk " + + "--full-dart-sdk " + "--embedder-for-target " + "--disable-desktop-embeddings " + "--no-build-embedder-examples " @@ -340,6 +341,9 @@ def addParseParam(parser): parser.add_argument( "--ohos-cpu", type=str, choices=['x64', 'x86', 'arm64', 'arm'], default="arm64" ) + parser.add_argument( + "--host-cpu", type=str, choices=['x64', 'arm64'], default="x64" + ) def updateCode(args): @@ -362,6 +366,32 @@ def checkEnvironment(): exit(1) +def buildLocalEngine(buildType, args): + OPT = "--unoptimized --no-lto " if buildType == "debug" else "" + extraParam = args.gn_extra_param + osName = platform.system().lower() + hostAppend = f"--mac-cpu {args.host_cpu}" if osName == "darwin" else "" + runCommand( + "%s " % os.path.join("src", "flutter", "tools", "gn") + + "--runtime-mode %s " % buildType + + OPT + + "--no-goma " + + "--no-prebuilt-dart-sdk " + + "--full-dart-sdk " + + "--disable-desktop-embeddings " + + "--no-build-embedder-examples " + + "--verbose " + + hostAppend + + extraParam.replace("\\", ""), + checkCode=False, + timeout=600, + ) + append1 = "_unopt" if buildType == "debug" else "" + append2 = "_arm64" if args.host_cpu == "arm64" else "" + outputName = f"host_{buildType}{append1}{append2}" + runCommand(f"ninja -C src/out/{outputName}") + + def uploadFiles(): runCommand("python3 src/flutter/attachment/scripts/auto_compile.py") @@ -388,6 +418,8 @@ def buildByNameAndType(args): zipFiles(buildInfo, False, args) elif "zip2" == buildName: zipFiles(buildInfo, True, args) + elif "host" == buildName: + buildLocalEngine(buildType, args) else: logging.warning("Other name=%s" % buildName) diff --git a/attachment/scripts/upload_dart_sdk.py b/attachment/scripts/upload_dart_sdk.py new file mode 100644 index 0000000000000000000000000000000000000000..ae65cacb346bbfdd7c03dd474a7e407af5949308 --- /dev/null +++ b/attachment/scripts/upload_dart_sdk.py @@ -0,0 +1,56 @@ +#!/usr/bin/env python3 +# coding=utf-8 +# +# Copyright (c) 2021-2024 Huawei Device 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. + +import os +import logging +import argparse +import platform +from pathlib import Path +from utils import getArch, getEnginePath, runGitCommand, upload + +engine_path = getEnginePath() + +logging.basicConfig() +log = logging.getLogger() +log.setLevel(logging.INFO) + + +def main(): + parser = argparse.ArgumentParser( + prog='upload_dart_sdk', description='upload dart sdk', epilog='upload dart sdk' + ) + parser.add_argument('-t', '--tag') + parser.add_argument('-f', '--file') + parser.add_argument('--arch', type=str, choices=['x64', 'arm64'], default="x64") + args = parser.parse_args() + osArch = args.arch + osName = platform.system().lower() + file_name = f'dart-sdk-{osName}-{osArch}.zip' + if args.file: + file_path = args.file + else: + file_path = Path(engine_path).joinpath(file_name).__str__() + flutter_path = Path(engine_path).joinpath('src/flutter').__str__() + if args.tag: + version = args.tag + else: + version = runGitCommand(f'git -C {flutter_path} rev-parse HEAD') + log.info(version) + upload(version, file_path) + + +if __name__ == "__main__": + exit(main()) diff --git a/attachment/scripts/upload_flutter_patched_sdk.py b/attachment/scripts/upload_flutter_patched_sdk.py new file mode 100644 index 0000000000000000000000000000000000000000..6a3fc95736d4a1dd634454deac183dcea5753481 --- /dev/null +++ b/attachment/scripts/upload_flutter_patched_sdk.py @@ -0,0 +1,59 @@ +#!/usr/bin/env python3 +# coding=utf-8 +# +# Copyright (c) 2021-2024 Huawei Device 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. + +import logging +import argparse +from pathlib import Path +from utils import getEnginePath, runGitCommand +from utils import upload + +engine_path = getEnginePath() + +logging.basicConfig() +log = logging.getLogger() +log.setLevel(logging.INFO) + + +def main(): + parser = argparse.ArgumentParser( + prog='upload flutter patched sdk', + description='upload flutter_patched_sdk', + epilog='upload flutter_patched_sdk' + ) + parser.add_argument('-t', '--tag') + parser.add_argument('-d', '--patched_sdk') + parser.add_argument('-p', '--patched_sdk_product') + args = parser.parse_args() + patched_sdk = 'flutter_patched_sdk.zip' + patched_sdk_product = 'flutter_patched_sdk_product.zip' + if args.patched_sdk and args.patched_sdk_product: + patched_sdk_path = args.patched_sdk + patched_sdk_product_path = args.patched_sdk_product + else: + patched_sdk_path = Path(engine_path).joinpath(patched_sdk).__str__() + patched_sdk_product_path = Path(engine_path).joinpath(patched_sdk_product).__str__() + if args.tag: + version = args.tag + else: + flutter_path = Path(engine_path).joinpath('src/flutter').__str__() + version = runGitCommand(f'git -C {flutter_path} rev-parse HEAD') + log.info(version) + upload(version, patched_sdk_path) + upload(version, patched_sdk_product_path) + + +if __name__ == "__main__": + exit(main()) diff --git a/attachment/scripts/upload_sky_engine.py b/attachment/scripts/upload_sky_engine.py new file mode 100644 index 0000000000000000000000000000000000000000..4a7555c81a009bade8ea8f6fd45f8cca0425a611 --- /dev/null +++ b/attachment/scripts/upload_sky_engine.py @@ -0,0 +1,52 @@ +#!/usr/bin/env python3 +# coding=utf-8 +# +# Copyright (c) 2021-2024 Huawei Device 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. + +import logging +import argparse +from pathlib import Path +from utils import getEnginePath, runGitCommand +from utils import upload + +engine_path = getEnginePath() + +logging.basicConfig() +log = logging.getLogger() +log.setLevel(logging.INFO) + + +def main(): + parser = argparse.ArgumentParser( + prog='upload sky_engine', description='upload sky_engine', epilog='upload sky_engine' + ) + parser.add_argument('-t', '--tag') + parser.add_argument('-f', '--file') + args = parser.parse_args() + file_name = 'sky_engine.zip' + if args.file: + file_path = args.file + else: + file_path = Path(engine_path).joinpath(file_name).__str__() + if args.tag: + version = args.tag + else: + flutter_path = Path(engine_path).joinpath('src/flutter').__str__() + version = runGitCommand(f'git -C {flutter_path} rev-parse HEAD') + log.info(version) + upload(version, file_path) + + +if __name__ == "__main__": + exit(main()) diff --git a/attachment/scripts/utils.py b/attachment/scripts/utils.py new file mode 100644 index 0000000000000000000000000000000000000000..f9520ef1bf68333646b10ed71889f0ace6bb9490 --- /dev/null +++ b/attachment/scripts/utils.py @@ -0,0 +1,94 @@ +#!/usr/bin/env python3 +# coding=utf-8 +# +# Copyright (c) 2021-2024 Huawei Device 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. + +import logging +import platform +import os +import subprocess +from pathlib import Path +import sys +from obs import ObsClient, PutObjectHeader + +log = logging.getLogger(__name__) + +FLUTTER_OHOS = 'flutter-ohos' + +# OBS 环境变量配置key信息 +ACCESS_KEY = os.getenv("AccessKeyID") +SECRET_KEY = os.getenv("SecretAccessKey") + +# 服务器地址 华南-广州 +SERVER = "https://obs.cn-south-1.myhuaweicloud.com" + + +def upload(version, file_path): + bucketName = FLUTTER_OHOS + obsClient = ObsClient(access_key_id=ACCESS_KEY, secret_access_key=SECRET_KEY, server=SERVER) + headers = PutObjectHeader() + headers.contentType = 'text/plain' + file_name = os.path.basename(file_path) + objectKey = f'flutter_infra_release/flutter/{version}/{file_name}' + print(f'objectKey: {objectKey}') + resp = obsClient.putFile( + bucketName, objectKey, file_path, headers=headers, progressCallback=uploadCallback + ) + if resp.status < 300: + print('Put Content Succeeded') + print('requestId:', resp.requestId) + print('etag:', resp.body.etag) + else: + print('Put Content Failed') + print('requestId:', resp.requestId) + print('errorCode:', resp.errorCode) + print('errorMessage:', resp.errorMessage) + + +def getEnginePath(): + return Path(os.path.realpath(__file__)).parents[4] + + +def getArch(): + os = platform.system().lower() + cpu_arch = platform.machine() + if cpu_arch == 'arm64': + return f'{os}-{cpu_arch}' + elif cpu_arch == 'x86_64': + return f'{os}-x64' + elif cpu_arch == 'AMD64': + return f'{os}-x64' + else: + log.error(f"Error: {os}-{cpu_arch} unsupported arch") + exit(1) + + +def runGitCommand(command): + result = subprocess.run(command, capture_output=True, text=True, shell=True) + if result.returncode != 0: + raise Exception(f"Git command failed: {result.stderr}") + return result.stdout.strip() + + +# 获取上传对象的进度 +def uploadCallback(transferredAmount, totalAmount, totalSeconds): + # 获取上传平均速率(KB/S) + speed = int(transferredAmount / totalSeconds / 1024) + # 获取上传进度百分比 + progress = int(transferredAmount * 100.0 / totalAmount) + print("\r", end="") + print("Speed: {} KB/S progress: {}%: ".format(speed, progress), "▓" * (progress // 2), end="") + sys.stdout.flush() + if progress == 100: + print("") diff --git a/attachment/scripts/zip_artifacts.py b/attachment/scripts/zip_artifacts.py new file mode 100644 index 0000000000000000000000000000000000000000..46e41a2e20dd2a80ee1da39bc37c5d4a9e2764f5 --- /dev/null +++ b/attachment/scripts/zip_artifacts.py @@ -0,0 +1,122 @@ +#!/usr/bin/env python3 +# coding=utf-8 +# +# Copyright (c) 2021-2024 Huawei Device 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. + +import json +import os +import zipfile +import logging +from utils import getArch +from pathlib import PurePath +from pathlib import Path + +log = logging.getLogger(__name__) + +artifact_json = "artifacts_files.json" + + +def getFileMap(): + script_path = os.path.realpath(__file__) + script_dir = PurePath(script_path).parent + zip_artifact_json = script_dir.joinpath(artifact_json).__str__() + with open(zip_artifact_json, 'r') as jsonFile: + jsonData = json.load(jsonFile) + return jsonData + + +# BUILD.gn file does not exist in out/host_release/shader_lib. +# However, Google's flutter artifacts.zip contains it, so I add it manually here +# See. https://storage.flutter-io.cn/flutter_infra_release/flutter/edd8546116457bdf1c5bdfb13ecb9463d2bb5ed4/darwin-arm64/artifacts.zip + +shader_flutter_build = '''# Copyright 2013 The Flutter Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +copy("flutter") { + sources = [ "runtime_effect.glsl" ] + outputs = [ "$root_out_dir/shader_lib/flutter/{{source_file_part}}" ] +} +''' + +shader_impeller_build = '''# Copyright 2013 The Flutter Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +copy("impeller") { + sources = [ + "blending.glsl", + "branching.glsl", + "color.glsl", + "constants.glsl", + "conversions.glsl", + "dithering.glsl", + "external_texture_oes.glsl", + "gaussian.glsl", + "gradient.glsl", + "path.glsl", + "texture.glsl", + "tile_mode.glsl", + "transform.glsl", + "types.glsl", + ] + outputs = [ "$root_out_dir/shader_lib/impeller/{{source_file_part}}" ] +} +''' + +shader_gn_build = '''# Copyright 2013 The Flutter Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +group("shader_lib") { + deps = [ + "./flutter", + "./impeller", + ] +} +''' + + +def genZipFile(): + engine_project_root_dir = Path(os.path.realpath(__file__)).parents[4] + files_map = getFileMap()[getArch()] + with zipfile.ZipFile(engine_project_root_dir.joinpath('artifacts.zip'), 'w', + zipfile.ZIP_DEFLATED) as zipf: + for file_to_zip in files_map: + path = engine_project_root_dir.joinpath(file_to_zip) + if not path.exists(): + log.error(f"Error: file {path} does not exist") + exit(2) + else: + if path.is_file(): + log.info('Compressing:' + path.__str__()) + zipf.write(path, files_map[file_to_zip]) + elif Path(path).is_dir(): + dir_name_in_zip = files_map[file_to_zip] + for entry in path.rglob("*"): + log.info( + 'Compressing:' + Path(dir_name_in_zip).joinpath(entry.relative_to(path)).__str__() + ) + zipf.write(entry, Path(dir_name_in_zip).joinpath(entry.relative_to(path))) + zipf.writestr('shader_lib/flutter/BUILD.gn', shader_flutter_build) + zipf.writestr('shader_lib/impeller/BUILD.gn', shader_impeller_build) + zipf.writestr('shader_lib/BUILD.gn', shader_gn_build) + + +def main(): + genZipFile() + + +if __name__ == "__main__": + exit(main()) diff --git a/attachment/scripts/zip_dart_sdk.py b/attachment/scripts/zip_dart_sdk.py new file mode 100644 index 0000000000000000000000000000000000000000..8bc426ca32b847e02fdf88e3ad9e2f3bd1e0f4d5 --- /dev/null +++ b/attachment/scripts/zip_dart_sdk.py @@ -0,0 +1,54 @@ +#!/usr/bin/env python3 +# coding=utf-8 +# +# Copyright (c) 2021-2024 Huawei Device 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. + +import argparse +import os +import zipfile +import platform +import logging +from pathlib import Path + +log = logging.getLogger(__name__) + + +def genZipFile(): + parser = argparse.ArgumentParser() + parser.add_argument('--arch', type=str, choices=['x64', 'arm64'], default="x64") + args = parser.parse_args() + osArch = args.arch + osName = platform.system().lower() + suffix = "_arm64" if osArch == "arm64" else "" + engine_project_root_dir = Path(os.path.realpath(__file__)).parents[4] + dart_sdk_path = engine_project_root_dir.joinpath(f"src/out/host_release{suffix}/dart-sdk") + host_release_path = engine_project_root_dir.joinpath(f"src/out/host_release{suffix}/") + + print(dart_sdk_path) + with zipfile.ZipFile(engine_project_root_dir.joinpath(f'dart-sdk-{osName}-{osArch}.zip'), 'w', + zipfile.ZIP_DEFLATED) as zipf: + for entry in dart_sdk_path.rglob("*"): + if (entry.is_dir()): + continue + else: + print(entry.relative_to(host_release_path)) + zipf.write(entry, entry.relative_to(host_release_path)) + + +def main(): + genZipFile() + + +if __name__ == "__main__": + exit(main()) diff --git a/attachment/scripts/zip_flutter_patched_sdk.py b/attachment/scripts/zip_flutter_patched_sdk.py new file mode 100644 index 0000000000000000000000000000000000000000..136f568e803a19aa952a50d1b1cad6ca934ec5a9 --- /dev/null +++ b/attachment/scripts/zip_flutter_patched_sdk.py @@ -0,0 +1,55 @@ +#!/usr/bin/env python3 +# coding=utf-8 +# +# Copyright (c) 2021-2024 Huawei Device 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. + +import os +import zipfile +import logging +from pathlib import Path + +log = logging.getLogger(__name__) + + +def genZipFile(is_product): + if is_product: + product_suffix = '_product' + sdk_rel_path = 'src/out/ohos_release_arm64/flutter_patched_sdk/' + zip_file_name = 'flutter_patched_sdk_product.zip' + else: + product_suffix = '' + sdk_rel_path = 'src/out/ohos_debug_unopt_arm64/flutter_patched_sdk/' + zip_file_name = 'flutter_patched_sdk.zip' + print(f'zipping {zip_file_name}...') + engine_project_root_path = Path(os.path.realpath(__file__)).parents[4] + patched_sdk_path = engine_project_root_path.joinpath(sdk_rel_path) + zip_file_prefix = Path('flutter_patched_sdk' + product_suffix) + with zipfile.ZipFile(engine_project_root_path.joinpath(zip_file_name), 'w', + zipfile.ZIP_DEFLATED) as zipf: + for entry in patched_sdk_path.rglob("*.dill"): + if (entry.is_dir()): + continue + else: + zip_path = zip_file_prefix.joinpath(entry.relative_to(patched_sdk_path)) + print(zip_path) + zipf.write(entry, zip_path) + + +def main(): + genZipFile(True) + genZipFile(False) + + +if __name__ == "__main__": + exit(main()) diff --git a/attachment/scripts/zip_sky_engine.py b/attachment/scripts/zip_sky_engine.py new file mode 100644 index 0000000000000000000000000000000000000000..9d5f76dfb6ebc8be16c123f15d9b08cd96b5f64a --- /dev/null +++ b/attachment/scripts/zip_sky_engine.py @@ -0,0 +1,51 @@ +#!/usr/bin/env python3 +# coding=utf-8 +# +# Copyright (c) 2021-2024 Huawei Device 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. + +import os +import zipfile +import logging +from pathlib import Path +from utils import getArch + +log = logging.getLogger(__name__) + + +def genZipFile(): + engine_project_root_dir = Path(os.path.realpath(__file__)).parents[4] + sky_engine_path = engine_project_root_dir.joinpath("src/out/host_release/gen/dart-pkg/sky_engine") + host_release_path = engine_project_root_dir.joinpath("src/out/host_release/gen/dart-pkg") + arch = getArch() + with zipfile.ZipFile(engine_project_root_dir.joinpath('sky_engine.zip'), 'w', + zipfile.ZIP_DEFLATED) as zipf: + for entry in sky_engine_path.rglob("*"): + if (entry.is_dir()): + continue + elif (entry.is_symlink()): + link = str(entry) + real = str(entry.readlink()) + print(f'found sym_link: {link} -> {real}') + zipf.write(real, entry.relative_to(host_release_path)) + else: + print(entry.relative_to(host_release_path)) + zipf.write(entry, entry.relative_to(host_release_path)) + + +def main(): + genZipFile() + + +if __name__ == "__main__": + exit(main()) diff --git a/fml/BUILD.gn b/fml/BUILD.gn index bc70dd0f79a47a5b4df373ce29a00f62158a833d..c4e3708b376d7125afb6837fd71442b8160db534 100644 --- a/fml/BUILD.gn +++ b/fml/BUILD.gn @@ -364,11 +364,16 @@ if (enable_unittests) { "time/time_delta_unittest.cc", "time/time_point_unittest.cc", "time/time_unittest.cc", - "platform/ohos/timerfd_unittests.cpp", - "platform/ohos/paths_ohos_unittests.cpp", - "platform/ohos/napi_util_unittests.cpp", ] + if (is_ohos) { + sources += [ + "platform/ohos/timerfd_unittests.cpp", + "platform/ohos/paths_ohos_unittests.cpp", + "platform/ohos/napi_util_unittests.cpp", + ] + } + if (is_mac) { sources += [ "platform/darwin/cf_utils_unittests.mm", diff --git a/third_party/accessibility/ax/ax_table_info.h b/third_party/accessibility/ax/ax_table_info.h index 53086c42693c18501c3786bff29804464e01f2f3..ef9266f2e5c4145824c451d14c3075f8daf22310 100644 --- a/third_party/accessibility/ax/ax_table_info.h +++ b/third_party/accessibility/ax/ax_table_info.h @@ -7,6 +7,7 @@ #include #include +#include #include #include