|
25 | 25 | import os
|
26 | 26 | import re
|
27 | 27 | import subprocess
|
| 28 | +import sys |
28 | 29 | import gyp
|
29 | 30 | import gyp.common
|
30 | 31 | import gyp.xcode_emulation
|
@@ -378,7 +379,7 @@ def CalculateGeneratorInputInfo(params):
|
378 | 379 | CXXFLAGS.target ?= $(CPPFLAGS) $(CXXFLAGS)
|
379 | 380 | LINK.target ?= %(LINK.target)s
|
380 | 381 | LDFLAGS.target ?= $(LDFLAGS)
|
381 |
| -AR.target ?= $(AR) |
| 382 | +AR.target ?= %(AR.target)s |
382 | 383 | PLI.target ?= %(PLI.target)s
|
383 | 384 |
|
384 | 385 | # C++ apps need to be linked with g++.
|
@@ -442,13 +443,21 @@ def CalculateGeneratorInputInfo(params):
|
442 | 443 | define fixup_dep
|
443 | 444 | # The depfile may not exist if the input file didn't have any #includes.
|
444 | 445 | touch $(depfile).raw
|
445 |
| -# Fixup path as in (1). |
446 |
| -sed -e "s|^$(notdir $@)|$@|" $(depfile).raw >> $(depfile) |
| 446 | +# Fixup path as in (1).""" + |
| 447 | + (r""" |
| 448 | +sed -e "s|^$(notdir $@)|$@|" -re 's/\\\\([^$$])/\/\1/g' $(depfile).raw >> $(depfile)""" |
| 449 | + if sys.platform == 'win32' else r""" |
| 450 | +sed -e "s|^$(notdir $@)|$@|" $(depfile).raw >> $(depfile)""") + |
| 451 | + r""" |
447 | 452 | # Add extra rules as in (2).
|
448 | 453 | # We remove slashes and replace spaces with new lines;
|
449 | 454 | # remove blank lines;
|
450 |
| -# delete the first line and append a colon to the remaining lines. |
451 |
| -sed -e 's|\\||' -e 'y| |\n|' $(depfile).raw |\ |
| 455 | +# delete the first line and append a colon to the remaining lines.""" + |
| 456 | + (""" |
| 457 | +sed -e 's/\\\\\\\\$$//' -e 's/\\\\\\\\/\\//g' -e 'y| |\\n|' $(depfile).raw |\\""" |
| 458 | + if sys.platform == 'win32' else """ |
| 459 | +sed -e 's|\\\\||' -e 'y| |\\n|' $(depfile).raw |\\""") + |
| 460 | + r""" |
452 | 461 | grep -v '^$$' |\
|
453 | 462 | sed -e 1d -e 's|$$|:|' \
|
454 | 463 | >> $(depfile)
|
@@ -724,6 +733,10 @@ def QuoteIfNecessary(string):
|
724 | 733 | string = '"' + string.replace('"', '\\"') + '"'
|
725 | 734 | return string
|
726 | 735 |
|
| 736 | +def replace_sep(string): |
| 737 | + if sys.platform == 'win32': |
| 738 | + string = string.replace('\\\\', '/').replace('\\', '/') |
| 739 | + return string |
727 | 740 |
|
728 | 741 | def StringToMakefileVariable(string):
|
729 | 742 | """Convert a string to a value that is acceptable as a make variable name."""
|
@@ -859,7 +872,7 @@ def Write(
|
859 | 872 | self.output = self.ComputeMacBundleOutput(spec)
|
860 | 873 | self.output_binary = self.ComputeMacBundleBinaryOutput(spec)
|
861 | 874 | else:
|
862 |
| - self.output = self.output_binary = self.ComputeOutput(spec) |
| 875 | + self.output = self.output_binary = replace_sep(self.ComputeOutput(spec)) |
863 | 876 |
|
864 | 877 | self.is_standalone_static_library = bool(
|
865 | 878 | spec.get("standalone_static_library", 0)
|
@@ -985,7 +998,7 @@ def WriteSubMake(self, output_filename, makefile_path, targets, build_dir):
|
985 | 998 | # sub-project dir (see test/subdirectory/gyptest-subdir-all.py).
|
986 | 999 | self.WriteLn(
|
987 | 1000 | "export builddir_name ?= %s"
|
988 |
| - % os.path.join(os.path.dirname(output_filename), build_dir) |
| 1001 | + % replace_sep(os.path.join(os.path.dirname(output_filename), build_dir)) |
989 | 1002 | )
|
990 | 1003 | self.WriteLn(".PHONY: all")
|
991 | 1004 | self.WriteLn("all:")
|
@@ -2063,7 +2076,7 @@ def WriteList(self, value_list, variable=None, prefix="", quoter=QuoteIfNecessar
|
2063 | 2076 | """
|
2064 | 2077 | values = ""
|
2065 | 2078 | if value_list:
|
2066 |
| - value_list = [quoter(prefix + value) for value in value_list] |
| 2079 | + value_list = [replace_sep(quoter(prefix + value)) for value in value_list] |
2067 | 2080 | values = " \\\n\t" + " \\\n\t".join(value_list)
|
2068 | 2081 | self.fp.write(f"{variable} :={values}\n\n")
|
2069 | 2082 |
|
@@ -2369,10 +2382,12 @@ def WriteAutoRegenerationRule(params, root_makefile, makefile_name, build_files)
|
2369 | 2382 | "\t$(call do_cmd,regen_makefile)\n\n"
|
2370 | 2383 | % {
|
2371 | 2384 | "makefile_name": makefile_name,
|
2372 |
| - "deps": " ".join(SourceifyAndQuoteSpaces(bf) for bf in build_files), |
2373 |
| - "cmd": gyp.common.EncodePOSIXShellList( |
2374 |
| - [gyp_binary, "-fmake"] + gyp.RegenerateFlags(options) + build_files_args |
| 2385 | + "deps": replace_sep( |
| 2386 | + " ".join(SourceifyAndQuoteSpaces(bf) for bf in build_files) |
2375 | 2387 | ),
|
| 2388 | + "cmd": replace_sep(gyp.common.EncodePOSIXShellList( |
| 2389 | + [gyp_binary, "-fmake"] + gyp.RegenerateFlags(options) + build_files_args |
| 2390 | + )), |
2376 | 2391 | }
|
2377 | 2392 | )
|
2378 | 2393 |
|
@@ -2435,33 +2450,52 @@ def CalculateMakefilePath(build_file, base_name):
|
2435 | 2450 | makefile_path = os.path.join(
|
2436 | 2451 | options.toplevel_dir, options.generator_output, makefile_name
|
2437 | 2452 | )
|
2438 |
| - srcdir = gyp.common.RelativePath(srcdir, options.generator_output) |
| 2453 | + srcdir = replace_sep(gyp.common.RelativePath(srcdir, options.generator_output)) |
2439 | 2454 | srcdir_prefix = "$(srcdir)/"
|
2440 | 2455 |
|
2441 | 2456 | flock_command = "flock"
|
2442 | 2457 | copy_archive_arguments = "-af"
|
2443 | 2458 | makedep_arguments = "-MMD"
|
| 2459 | + |
| 2460 | + # wasm-ld doesn't support --start-group/--end-group |
| 2461 | + link_commands = LINK_COMMANDS_LINUX |
| 2462 | + if flavor in ["wasi", "wasm"]: |
| 2463 | + link_commands = link_commands.replace(' -Wl,--start-group', '').replace( |
| 2464 | + ' -Wl,--end-group', '' |
| 2465 | + ) |
| 2466 | + |
| 2467 | + CC_target = replace_sep(GetEnvironFallback(("CC_target", "CC"), "$(CC)")) |
| 2468 | + AR_target = replace_sep(GetEnvironFallback(("AR_target", "AR"), "$(AR)")) |
| 2469 | + CXX_target = replace_sep(GetEnvironFallback(("CXX_target", "CXX"), "$(CXX)")) |
| 2470 | + LINK_target = replace_sep(GetEnvironFallback(("LINK_target", "LINK"), "$(LINK)")) |
| 2471 | + PLI_target = replace_sep(GetEnvironFallback(("PLI_target", "PLI"), "pli")) |
| 2472 | + CC_host = replace_sep(GetEnvironFallback(("CC_host", "CC"), "gcc")) |
| 2473 | + AR_host = replace_sep(GetEnvironFallback(("AR_host", "AR"), "ar")) |
| 2474 | + CXX_host = replace_sep(GetEnvironFallback(("CXX_host", "CXX"), "g++")) |
| 2475 | + LINK_host = replace_sep(GetEnvironFallback(("LINK_host", "LINK"), "$(CXX.host)")) |
| 2476 | + PLI_host = replace_sep(GetEnvironFallback(("PLI_host", "PLI"), "pli")) |
| 2477 | + |
2444 | 2478 | header_params = {
|
2445 | 2479 | "default_target": default_target,
|
2446 | 2480 | "builddir": builddir_name,
|
2447 | 2481 | "default_configuration": default_configuration,
|
2448 | 2482 | "flock": flock_command,
|
2449 | 2483 | "flock_index": 1,
|
2450 |
| - "link_commands": LINK_COMMANDS_LINUX, |
| 2484 | + "link_commands": link_commands, |
2451 | 2485 | "extra_commands": "",
|
2452 | 2486 | "srcdir": srcdir,
|
2453 | 2487 | "copy_archive_args": copy_archive_arguments,
|
2454 | 2488 | "makedep_args": makedep_arguments,
|
2455 |
| - "CC.target": GetEnvironFallback(("CC_target", "CC"), "$(CC)"), |
2456 |
| - "AR.target": GetEnvironFallback(("AR_target", "AR"), "$(AR)"), |
2457 |
| - "CXX.target": GetEnvironFallback(("CXX_target", "CXX"), "$(CXX)"), |
2458 |
| - "LINK.target": GetEnvironFallback(("LINK_target", "LINK"), "$(LINK)"), |
2459 |
| - "PLI.target": GetEnvironFallback(("PLI_target", "PLI"), "pli"), |
2460 |
| - "CC.host": GetEnvironFallback(("CC_host", "CC"), "gcc"), |
2461 |
| - "AR.host": GetEnvironFallback(("AR_host", "AR"), "ar"), |
2462 |
| - "CXX.host": GetEnvironFallback(("CXX_host", "CXX"), "g++"), |
2463 |
| - "LINK.host": GetEnvironFallback(("LINK_host", "LINK"), "$(CXX.host)"), |
2464 |
| - "PLI.host": GetEnvironFallback(("PLI_host", "PLI"), "pli"), |
| 2489 | + "CC.target": CC_target, |
| 2490 | + "AR.target": AR_target, |
| 2491 | + "CXX.target": CXX_target, |
| 2492 | + "LINK.target": LINK_target, |
| 2493 | + "PLI.target": PLI_target, |
| 2494 | + "CC.host": CC_host, |
| 2495 | + "AR.host": AR_host, |
| 2496 | + "CXX.host": CXX_host, |
| 2497 | + "LINK.host": LINK_host, |
| 2498 | + "PLI.host": PLI_host, |
2465 | 2499 | }
|
2466 | 2500 | if flavor == "mac":
|
2467 | 2501 | flock_command = "./gyp-mac-tool flock"
|
|
0 commit comments