diff --git a/src/blade/build_manager.py b/src/blade/build_manager.py index 5d432c40..feb8c4c4 100644 --- a/src/blade/build_manager.py +++ b/src/blade/build_manager.py @@ -252,7 +252,12 @@ def _test(self): def _remove_paths(paths): # The rm command can delete a large number of files at once, which is much faster than # using python's own remove functions (only supports deleting a single path at a time). - subprocess.call(['rm', '-fr'] + paths) + if os.name == 'posix': + subprocess.call(['rm', '-fr'] + paths) + return + import shutil + for path in paths: + shutil.rmtree(path, ignore_errors=True) def clean(self): """Clean specific generated target files or directories""" diff --git a/src/blade/load_build_files.py b/src/blade/load_build_files.py index 872f942d..783af0df 100644 --- a/src/blade/load_build_files.py +++ b/src/blade/load_build_files.py @@ -367,7 +367,10 @@ def _check_under_skipped_dir(dirname): if os.path.exists(filepath): cache[dirname] = filepath return filepath - result = _check_under_skipped_dir(os.path.dirname(dirname)) + parent = os.path.dirname(dirname) + if parent == dirname: + return '' + result = _check_under_skipped_dir(parent) cache[dirname] = result return result diff --git a/src/blade/toolchain.py b/src/blade/toolchain.py index b9caf7ef..66cfe40b 100644 --- a/src/blade/toolchain.py +++ b/src/blade/toolchain.py @@ -412,36 +412,26 @@ def filter_cc_flags(self, flag_list, language='c'): flag_list = var_to_list(flag_list) valid_flags, unrecognized_flags = [], [] - # Put compilation output into test.o instead of /dev/null - # because the command line with '--coverage' below exit - # with status 1 which makes '--coverage' unsupported - # echo "int main() { return 0; }" | gcc -o /dev/null -c -x c --coverage - > /dev/null 2>&1 - suffix = language - if suffix == 'c++': - suffix = 'cpp' - fd, src = tempfile.mkstemp('.' + suffix, 'filter_cc_flags_test') - os.write(fd, b"int main() { return 0; }\n") - os.close(fd) - + # cl.exe only report the first error option, so we must test flags one by one. for flag in flag_list: - # Example error messages: - # Command line error D8021 : invalid numeric argument '/Wzzz' if flag.startswith('-'): testflag = '/' + flag[1:] else: testflag = flag - cmd = ('"%s" /nologo /FoNUL /c /WX %s "%s"' % (self.cc, testflag, src)) - returncode, stdout, stderr = run_command(cmd, shell=True) - message = stdout + stderr - if "'%s'" % testflag in message: - unrecognized_flags.append(flag) - else: - valid_flags.append(flag) - try: - # In case of error, the `.o` file will be deleted by the compiler - os.remove(src) - except OSError: - pass + cmd = ('"%s" /nologo /E /Zs /c /WX %s' % (self.cc, testflag)) + try: + returncode, stdout, stderr = run_command(cmd, shell=False) + if returncode == 0: + continue + output = stdout + stderr + # Example error messages: + # Command line error D8021 : invalid numeric argument '/Wzzz' + if "'%s'" % testflag in output: + unrecognized_flags.append(flag) + else: + valid_flags.append(flag) + except OSError as e: + console.fatal("filter_cc_flags error, cmd='%s', error='%s'" % (cmd, e)) if unrecognized_flags: console.warning('config: Unrecognized %s flags: %s' % (