Skip to content

Commit 7a36a54

Browse files
committed
fix: fix build
Signed-off-by: Paolo Insogna <paolo@cowtech.it>
1 parent 328f10f commit 7a36a54

File tree

2 files changed

+25
-8
lines changed

2 files changed

+25
-8
lines changed

deps/libffi/libffi.gyp

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@
175175
'action_name': 'preprocess_win64_arm_asm_with_cl',
176176
'process_outputs_as_sources': 1,
177177
'inputs': [
178+
'preprocess_asm.py',
178179
'include/ffi_cfi.h',
179180
'src/aarch64/internal.h',
180181
'src/aarch64/win64_armasm.S',
@@ -185,11 +186,20 @@
185186
'<(INTERMEDIATE_DIR)/win64_armasm.asm',
186187
],
187188
'action': [
188-
'cmd.exe',
189-
'/d',
190-
'/s',
191-
'/c',
192-
'"cl.exe /nologo /EP /TC /Iinclude /Isrc\\aarch64 /I<(INTERMEDIATE_DIR) /DFFI_STATIC_BUILD src\\aarch64\\win64_armasm.S > <(INTERMEDIATE_DIR)\\win64_armasm.asm"',
189+
'<(python)',
190+
'preprocess_asm.py',
191+
'--compiler',
192+
'cl.exe',
193+
'--input',
194+
'src/aarch64/win64_armasm.S',
195+
'--output',
196+
'<@(_outputs)',
197+
'--include-dir',
198+
'include',
199+
'--include-dir',
200+
'src/aarch64',
201+
'--define',
202+
'FFI_STATIC_BUILD',
193203
],
194204
},
195205
],

deps/libffi/preprocess_asm.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,12 @@ def split_command(value):
1818
return shlex.split(value, posix=(os.name != 'nt'))
1919

2020

21-
def find_compiler():
21+
def find_compiler(preferred=None):
22+
if preferred:
23+
command = split_command(preferred)
24+
if command and shutil.which(command[0]):
25+
return command
26+
2227
for var in ('CC', 'CXX'):
2328
command = split_command(os.environ.get(var))
2429
if command and shutil.which(command[0]):
@@ -48,7 +53,7 @@ def unique_paths(paths):
4853

4954

5055
def preprocess(args):
51-
compiler = find_compiler()
56+
compiler = find_compiler(args.compiler)
5257
input_path = normalize_path(args.input)
5358
output = Path(normalize_path(args.output))
5459
include_dirs = [normalize_path(include_dir) for include_dir in args.include_dir]
@@ -74,7 +79,8 @@ def preprocess(args):
7479

7580
processed_lines = []
7681
for line in result.stdout.splitlines(keepends=True):
77-
if line.lstrip().startswith('#'):
82+
normalized = line.lstrip('\ufeff\x00 \t\r\n')
83+
if normalized.startswith('#'):
7884
continue
7985
processed_lines.append(line)
8086

@@ -87,6 +93,7 @@ def main(argv=None):
8793
parser.add_argument('--output', required=True)
8894
parser.add_argument('--include-dir', action='append', default=[])
8995
parser.add_argument('--define', action='append', default=[])
96+
parser.add_argument('--compiler', default=None)
9097
args = parser.parse_args(argv)
9198

9299
preprocess(args)

0 commit comments

Comments
 (0)