@@ -86,7 +86,7 @@ def _validate_cpu_architecture(arch, expected_archs):
8686 expected_archs ,
8787 ))
8888
89- def get_host_triple (repository_ctx , abi = None ):
89+ def get_host_triple (repository_ctx , abi = {} ):
9090 """Query host information for the appropriate triple to use with load_arbitrary_tool or the crate_universe resolver
9191
9292 Example:
@@ -110,8 +110,9 @@ def get_host_triple(repository_ctx, abi = None):
110110
111111 Args:
112112 repository_ctx (repository_ctx): The repository_rule's context object
113- abi (str): Since there's no consistent way to check for ABI, this info
114- may be explicitly provided
113+ abi (dict): A mapping of platform triple prefixes to desired abi. This
114+ is useful since there's no consistent way to check for ABI, this info
115+ may be explicitly provided.
115116
116117 Returns:
117118 struct: A triple struct; see the `triple` function in this module
@@ -134,9 +135,10 @@ def get_host_triple(repository_ctx, abi = None):
134135
135136 if "linux" in repository_ctx .os .name :
136137 _validate_cpu_architecture (arch , supported_architectures ["linux" ])
137- return triple ("{}-unknown-linux-{}" .format (
138- arch ,
139- abi or "gnu" ,
138+ prefix = "{}-unknown-linux" .format (arch )
139+ return triple ("{}-{}" .format (
140+ prefix ,
141+ abi .get (prefix , "gnu" ),
140142 ))
141143
142144 if "mac" in repository_ctx .os .name :
@@ -145,9 +147,10 @@ def get_host_triple(repository_ctx, abi = None):
145147
146148 if "win" in repository_ctx .os .name :
147149 _validate_cpu_architecture (arch , supported_architectures ["windows" ])
148- return triple ("{}-pc-windows-{}" .format (
149- arch ,
150- abi or "msvc" ,
150+ prefix = "{}-pc-windows" .format (arch )
151+ return triple ("{}-{}" .format (
152+ prefix ,
153+ abi .get (prefix , "msvc" ),
151154 ))
152155
153156 fail ("Unhandled host os: {}" , repository_ctx .os .name )
0 commit comments