Skip to content

Commit 604907a

Browse files
committed
unix: simplify code for setting target triple
There was a lot of lazy copy pasting that got us to this sad state. I feel ashasmed.
1 parent 625db2a commit 604907a

File tree

1 file changed

+6
-19
lines changed

1 file changed

+6
-19
lines changed

cpython-unix/build.py

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -103,28 +103,15 @@ def add_target_env(env, build_platform, target_triple, build_env):
103103
if build_platform == "linux64":
104104
env["BUILD_TRIPLE"] = "x86_64-unknown-linux-gnu"
105105

106-
if target_triple == "aarch64-unknown-linux-gnu":
107-
env["TARGET_TRIPLE"] = "aarch64-unknown-linux-gnu"
108-
elif target_triple == "armv7-unknown-linux-gnueabi":
109-
env["TARGET_TRIPLE"] = "armv7-unknown-linux-gnueabi"
110-
elif target_triple == "armv7-unknown-linux-gnueabihf":
111-
env["TARGET_TRIPLE"] = "armv7-unknown-linux-gnueabihf"
112-
elif target_triple == "mips-unknown-linux-gnu":
113-
env["TARGET_TRIPLE"] = "mips-unknown-linux-gnu"
114-
elif target_triple == "mipsel-unknown-linux-gnu":
115-
env["TARGET_TRIPLE"] = "mipsel-unknown-linux-gnu"
116-
elif target_triple == "mips64el-unknown-linux-gnuabi64":
117-
env["TARGET_TRIPLE"] = "mips64el-unknown-linux-gnuabi64"
118-
elif target_triple == "s390x-unknown-linux-gnu":
119-
env["TARGET_TRIPLE"] = "s390x-unknown-linux-gnu"
120-
elif target_triple in ("x86_64-unknown-linux-gnu", "x86_64-unknown-linux-musl"):
106+
# TODO should the musl target be normalized?
107+
if target_triple == "x86_64-unknown-linux-musl":
121108
env["TARGET_TRIPLE"] = "x86_64-unknown-linux-gnu"
122-
elif target_triple == "i686-unknown-linux-gnu":
123-
env["TARGET_TRIPLE"] = "i686-unknown-linux-gnu"
109+
else:
110+
env["TARGET_TRIPLE"] = target_triple
111+
112+
if target_triple == "i686-unknown-linux-gnu":
124113
extra_target_cflags.append("-m32")
125114
extra_target_ldflags.append("-m32")
126-
else:
127-
raise Exception("unhandled target triple: %s" % target_triple)
128115

129116
if build_platform == "macos":
130117
machine = platform.machine()

0 commit comments

Comments
 (0)