Skip to content

Commit

Permalink
Fix hdrs command error and deps format parsing error
Browse files Browse the repository at this point in the history
  • Loading branch information
chen3feng committed Feb 28, 2024
1 parent f2525de commit b93e475
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/blade/target.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -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):
Expand All @@ -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)

Expand Down
4 changes: 3 additions & 1 deletion src/blade/toolchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit b93e475

Please sign in to comment.