diff --git a/attachment/repos/bootstrap/Makefile b/attachment/repos/bootstrap/Makefile deleted file mode 100755 index 3d34580ac8f49e397831d549968d0fb6f87c4ef9..0000000000000000000000000000000000000000 --- a/attachment/repos/bootstrap/Makefile +++ /dev/null @@ -1,30 +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. - - -ifeq ($(OS),Windows_NT) - ohos=".\ohos.bat" - clean=".\clean.bat" -else - ohos="./ohos.sh" - clean="./clean.sh" -endif - -$(info ${clean_command}) -default: ohos -ohos: - ${ohos} -clean: - ${clean} - - diff --git a/attachment/repos/bootstrap/ohos.py b/attachment/repos/bootstrap/ohos.py index 8eebfcdb8281f0576856347cd293f259a73b0b52..03373f1b16ff67adb76d90b85d1069143f58169c 100644 --- a/attachment/repos/bootstrap/ohos.py +++ b/attachment/repos/bootstrap/ohos.py @@ -48,6 +48,7 @@ def safeGetPath(filePath, isDirectory=True): return os.path.abspath(filePath) +TIME_STR = datetime.now().strftime("%H%M") DIR_OUTPUTS = safeGetPath( "%s/outputs/%s" % (DIR_ROOT, datetime.now().strftime("%Y%m%d")) ) @@ -266,7 +267,7 @@ def zipFiles(buildInfo): fileIn = os.path.abspath("%s/src/out/%s" % (DIR_ROOT, outputName)) fileName = "%s-%s-%s-%s" % ( outputName, - datetime.now().strftime("%H%M"), + TIME_STR, OS_NAME, platform.machine(), ) @@ -275,20 +276,6 @@ def zipFiles(buildInfo): zipFileDir(fileIn, fileName, prefixInZip, excludeDir=dirArray) -def stashChanges(): - dir_root = "src/flutter/attachment" - config_file = "%s/scripts/config.json" % dir_root - cache = [] - with open(config_file) as json_file: - data = json.load(json_file) - for task in data: - dir = os.path.join(task["target"]) - if task["type"] == "patch" and not dir in cache: - cache.append(dir) - runCommand("git -C %s add -A" % dir) - runCommand("git -C %s stash save 'Auto stash save'" % dir) - - def addParseParam(parser): parser.add_argument( "-n", @@ -316,20 +303,18 @@ def addParseParam(parser): "--gn-extra-param", nargs="?", default="", - help="Extra param to src/flutter/tools/gn. Such as: -g \"\\--enable-unittests\"", + help='Extra param to src/flutter/tools/gn. Such as: -g "\\--enable-unittests"', ) def updateCode(args): if args.branch: - stashChanges() dir = os.path.join("src", "flutter") runCommand("git -C %s add -A" % dir) runCommand("git -C %s stash save 'Auto stash save.'" % dir) runCommand("git -C %s checkout %s" % (dir, args.branch)) runCommand("git -C %s pull --rebase" % dir, checkCode=False) - runCommand("git -C %s stash pop" % dir) - runCommand("gclient sync --force") + runCommand("python3 src/flutter/attachment/scripts/ohos_setup.py") def checkEnvironment(): diff --git a/attachment/scripts/ohos_setup.py b/attachment/scripts/ohos_setup.py index a129b955e73a3a1a0a031123af6aebae565ed0fb..b6e1b531019b0a0b54d07159fcb1856acf969263 100644 --- a/attachment/scripts/ohos_setup.py +++ b/attachment/scripts/ohos_setup.py @@ -43,6 +43,19 @@ def apply_patch(task, log=False): print("Apply failed. file path:" + file_path + " Error:" + str(stderr)) pass + +def stashChanges(task, log): + if task['type'] != 'patch': + return + target_path = task['target'] + sub_process_with_timeout.excuteArr([ + 'git', 'add', '-A' + ], target_path, log) + sub_process_with_timeout.excuteArr([ + 'git', 'stash', 'save', 'Auto stash by ohos_setup.py' + ], target_path, log) + + def apply_check(task, log=False): file_path = task['file_path'] target_path = task['target'] @@ -79,6 +92,8 @@ def parse_config(config_file="{}/scripts/config.json".format(ROOT)): log = True with open(config_file) as json_file: data = json.load(json_file) + for task in data: + stashChanges(task, log) for task in data: doTask(task, log)