From b93e4754e08e3b0473dc395c4883809767b79d5b Mon Sep 17 00:00:00 2001 From: chen3feng Date: Wed, 28 Feb 2024 18:40:26 +0800 Subject: [PATCH] Fix hdrs command error and deps format parsing error --- src/blade/target.py | 6 ++++-- src/blade/toolchain.py | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/blade/target.py b/src/blade/target.py index 3a90c67f..f9649919 100644 --- a/src/blade/target.py +++ b/src/blade/target.py @@ -90,7 +90,7 @@ def _parse_target(dep): result = ('', '', msgs) else: if path: - path = os.path.normpath(path) + path = os.path.normpath(path).replace('\\', '/') # windows result = (path, name, None) _parse_target.cache[dep] = result return result @@ -440,6 +440,7 @@ def _add_location_reference_target(self, m): def _unify_dep(self, dep): """Unify dep to key.""" (path, name, msgs) = _parse_target(dep) + console.warning(f'uni: dep={dep}, path={path}') if msgs: for msg in msgs: @@ -463,7 +464,7 @@ def _unify_dep(self, dep): else: # Depend on library in current directory path = self.path - + console.warning(f'_unify_dep: dep={dep}, path={path}') return '%s:%s' % (path, name) def _init_target_deps(self, deps): @@ -480,6 +481,7 @@ def _init_target_deps(self, deps): """ for d in deps: dkey = self._unify_dep(d) + console.warning(f'deps={deps}, dkey={dkey}') if dkey and dkey not in self.deps: self.deps.append(dkey) diff --git a/src/blade/toolchain.py b/src/blade/toolchain.py index 4c2ef971..ffd7d137 100644 --- a/src/blade/toolchain.py +++ b/src/blade/toolchain.py @@ -506,8 +506,10 @@ def _hdrs_command(self, flags, cppflags, includes): Command to generate cc inclusion information file for header file to check dependency missing. See https://learn.microsoft.com/en-us/cpp/build/reference/showincludes-list-include-files for details. """ + # If there is not #include in the file, findstr will fail, use "|| ver>nul" to ignore the error. + # https://stackoverflow.com/questions/22046780/whats-the-windows-command-shell-equivalent-of-bashs-true-command cmd = ('cmd.exe /c %s /nologo /c /E /Zs /TP /showIncludes %s %s /w ${cppflags} %s ${includes} ${in} 2>&1 >nul |' - ' findstr "Note: including file" >${out} && type ${out}'% ( + ' findstr "Note: including file" >${out} || ver>nul'% ( self.cc, ' '.join(flags), ' '.join(cppflags), includes)) # If the first cpp command fails, the second cpp command will be executed.