From 595616877dff93524e2234f5113f86ee210ab7a6 Mon Sep 17 00:00:00 2001 From: chengxuya Date: Fri, 8 Dec 2023 12:49:17 +0800 Subject: [PATCH] [*] fix parse config bug --- build.py | 3 ++- core/main.py | 13 ++++++++++++- core/ninja.py | 5 ++++- core/util/parse_cmd.py | 5 +++++ 4 files changed, 23 insertions(+), 3 deletions(-) diff --git a/build.py b/build.py index 83defa4..aa8d2c5 100755 --- a/build.py +++ b/build.py @@ -21,4 +21,5 @@ from core.util.env import getEnv from core.util.log_util import LogUtil LogUtil.success("host platform " + sys.platform) -subprocess.run("python build/core/main.py", shell=True, env=getEnv()); +cmd = ["python", "build/core/main.py"] + sys.argv[1:] +subprocess.run(cmd, env=getEnv()); diff --git a/core/main.py b/core/main.py index ccb2778..f650536 100644 --- a/core/main.py +++ b/core/main.py @@ -1,5 +1,16 @@ +# Copyright (c) 2023 DoubleByte. +# This is licensed under Mulan PSL v2. +# You can use this software according to the terms and conditions of the Mulan PSL v2. +# You may obtain a copy of Mulan PSL v2 at: +# +# http://license.coscl.org.cn/MulanPSL2 +# +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, +# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, +# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +# See the Mulan PSL v2 for more details. + import sys -import subprocess from util.parse_cmd import Parser from util.log_util import LogUtil diff --git a/core/ninja.py b/core/ninja.py index 49b7f7c..1b85676 100644 --- a/core/ninja.py +++ b/core/ninja.py @@ -3,6 +3,7 @@ import subprocess from exceptions.status import throw_exception from exceptions.build_exception import BuildException from util.env import getEnv +from util.path import ROOT_PATH from util.log_util import LogUtil class Ninja: @@ -10,9 +11,11 @@ class Ninja: def __init__(self): pass +# communicate @throw_exception def run(self): - process = subprocess.Popen("ninja -C out", stdout=subprocess.PIPE, stderr=subprocess.STDOUT, + cmd = "export CCACHE_DIR=\"" + ROOT_PATH + "/.ccache\" && ninja -C out" + process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, encoding="utf-8", errors="ignore", shell=True, env=getEnv()) for line in iter(process.stdout.readline, ""): LogUtil.info(line) diff --git a/core/util/parse_cmd.py b/core/util/parse_cmd.py index d4117b6..547b61e 100644 --- a/core/util/parse_cmd.py +++ b/core/util/parse_cmd.py @@ -42,6 +42,11 @@ class Parser: self.parser.add_argument('--ide', dest='ide', choices=['', 'qtcreator', 'xcode'], default='', type=str) self.parse_args = self.parser.parse_args() + self.target_os_ = self.parse_args.target_os + self.target_cpu = self.parse_args.target_cpu + self.build_mode_ = self.parse_args.build_mode + self.build_target_ = self.parse_args.build_target + def set_compiler(self): # set compiler if ('linux' == self.host_os_): -- Gitee