Skip to content

Commit 3037b21

Browse files
committed
[swift_build_support] Change shell env to be a mapping.
- This is consistent with the `subprocess` API, which this module is otherwise closely related to, so I think this makes more sense than taking a list of key-value pairs.
1 parent b3a9656 commit 3037b21

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

utils/swift_build_support/swift_build_support/products/ninja.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,15 @@ def do_build(self):
4444
sysroot = xcrun.sdk_path("macosx")
4545
osx_version_min = self.args.darwin_deployment_version_osx
4646
assert sysroot is not None
47-
env = [
48-
("CXX", self.toolchain.cxx),
49-
("CFLAGS", (
47+
env = {
48+
"CXX": self.toolchain.cxx,
49+
"CFLAGS": (
5050
"-isysroot {sysroot} -mmacosx-version-min={osx_version}"
51-
).format(sysroot=sysroot, osx_version=osx_version_min)),
52-
("LDFLAGS", (
51+
).format(sysroot=sysroot, osx_version=osx_version_min),
52+
"LDFLAGS": (
5353
"-mmacosx-version-min={osx_version}"
54-
).format(osx_version=osx_version_min)),
55-
]
54+
).format(osx_version=osx_version_min),
55+
}
5656

5757
# Ninja can only be built in-tree. Copy the source tree to the build
5858
# directory.

utils/swift_build_support/swift_build_support/shell.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ def _coerce_dry_run(dry_run_override):
5353
def _echo_command(dry_run, command, env=None, prompt="+ "):
5454
output = []
5555
if env is not None:
56-
output += ['env'] + [_quote("%s=%s" % (k, v)) for k, v in env]
56+
output += ['env'] + [_quote("%s=%s" % (k, v))
57+
for (k, v) in sorted(env.items())]
5758
output += [_quote(arg) for arg in command]
5859
file = sys.stderr
5960
if dry_run:

utils/swift_build_support/tests/products/test_ninja.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ def test_do_build(self):
9292
if platform.system() == "Darwin":
9393
expect_env = (
9494
"env "
95-
"CXX={cxx} "
9695
"'CFLAGS=-isysroot {sysroot} -mmacosx-version-min=10.9' "
96+
"CXX={cxx} "
9797
"LDFLAGS=-mmacosx-version-min=10.9 "
9898
).format(
9999
cxx=self.toolchain.cxx,

0 commit comments

Comments
 (0)