3
3
load ("@bazel_skylib//lib:paths.bzl" , "paths" )
4
4
load ("@bazel_tools//tools/build_defs/repo:utils.bzl" , "patch" )
5
5
load ("@bazel_tools//tools/cpp:lib_cc_configure.bzl" , "get_cpu_value" )
6
- load ("@rules_cc//cc:find_cc_toolchain.bzl" , "CC_TOOLCHAIN_TYPE" )
7
6
load ("@rules_sh//sh:posix.bzl" , "sh_posix_configure" )
8
- load ("//haskell:ghc.bzl" , "DEFAULT_GHC_VERSION" )
9
- load (":private/bazel_platforms.bzl" , "bazel_platforms" )
7
+ load ("@rules_cc//cc:find_cc_toolchain.bzl" , "CC_TOOLCHAIN_TYPE" )
10
8
load (
11
9
":private/pkgdb_to_bzl.bzl" ,
12
10
"pkgdb_to_bzl" ,
19
17
"find_python" ,
20
18
"resolve_labels" ,
21
19
)
20
+ load ("//haskell:ghc.bzl" , "DEFAULT_GHC_VERSION" )
21
+ load (":private/bazel_platforms.bzl" , "bazel_platforms" )
22
22
23
23
_GHC_DEFAULT_VERSION = DEFAULT_GHC_VERSION
24
24
@@ -87,7 +87,7 @@ def _ghc_bindist_impl(ctx):
87
87
if GHC_BINDIST_STRIP_PREFIX .get (version ) != None and GHC_BINDIST_STRIP_PREFIX [version ].get (target ) != None :
88
88
stripPrefix = GHC_BINDIST_STRIP_PREFIX [version ][target ]
89
89
else :
90
- arch_suffix = {"amd64 " : "x86_64 " , "arm64 " : "aarch64 " }.get (arch )
90
+ arch_suffix = {"arm64 " : "aarch64 " , "amd64 " : "x86_64 " }.get (arch )
91
91
92
92
if os == "windows" and version_tuple >= (9 , 0 , 1 ):
93
93
stripPrefix += "-{}-unknown-mingw32" .format (arch_suffix )
@@ -263,10 +263,10 @@ rm -f
263
263
"BUILD" ,
264
264
filepaths ["@rules_haskell//haskell:ghc.BUILD.tpl" ],
265
265
substitutions = {
266
- "%{docdir}" : docdir ,
267
- "%{is_clang}" : str (is_clang ),
268
266
"%{toolchain_libraries}" : toolchain_libraries ,
269
267
"%{toolchain}" : toolchain ,
268
+ "%{docdir}" : docdir ,
269
+ "%{is_clang}" : str (is_clang ),
270
270
},
271
271
executable = False ,
272
272
)
@@ -275,11 +275,24 @@ _ghc_bindist = repository_rule(
275
275
_ghc_bindist_impl ,
276
276
local = False ,
277
277
attrs = {
278
- "cabalopts" : attr .string_list (),
278
+ "version" : attr .string (
279
+ default = _GHC_DEFAULT_VERSION ,
280
+ doc = "The desired GHC version" ,
281
+ ),
282
+ "target" : attr .string (),
279
283
"ghcopts" : attr .string_list (),
280
284
"haddock_flags" : attr .string_list (),
281
- "locale" : attr .string (
282
- mandatory = False ,
285
+ "repl_ghci_args" : attr .string_list (),
286
+ "cabalopts" : attr .string_list (),
287
+ "patches" : attr .label_list (
288
+ default = [],
289
+ doc =
290
+ "A list of files that are to be applied as patches afer " +
291
+ "extracting the archive." ,
292
+ ),
293
+ "patch_tool" : attr .string (
294
+ default = "patch" ,
295
+ doc = "The patch(1) utility to use." ,
283
296
),
284
297
"patch_args" : attr .string_list (
285
298
default = ["-p0" ],
@@ -289,21 +302,8 @@ _ghc_bindist = repository_rule(
289
302
default = [],
290
303
doc = "Sequence of commands to be applied after patches are applied." ,
291
304
),
292
- "patch_tool" : attr .string (
293
- default = "patch" ,
294
- doc = "The patch(1) utility to use." ,
295
- ),
296
- "patches" : attr .label_list (
297
- default = [],
298
- doc =
299
- "A list of files that are to be applied as patches afer " +
300
- "extracting the archive." ,
301
- ),
302
- "repl_ghci_args" : attr .string_list (),
303
- "target" : attr .string (),
304
- "version" : attr .string (
305
- default = _GHC_DEFAULT_VERSION ,
306
- doc = "The desired GHC version" ,
305
+ "locale" : attr .string (
306
+ mandatory = False ,
307
307
),
308
308
"_relpath_script" : attr .label (
309
309
allow_single_file = True ,
@@ -475,7 +475,7 @@ def ghc_bindist(
475
475
"9.2.1" : ["@rules_haskell//haskell:assets/ghc_9_2_1_mac.patch" ],
476
476
}.get (version )
477
477
478
- extra_attrs = {"patch_args" : ["-p0" ], "patches" : patches } if patches else {}
478
+ extra_attrs = {"patches" : patches , " patch_args" : ["-p0" ]} if patches else {}
479
479
480
480
# We want the toolchain definition to be tucked away in a separate
481
481
# repository, that way `bazel build //...` will not match it (and
@@ -611,6 +611,7 @@ toolchain(
611
611
stub_shebang = stub_shebang ,
612
612
))
613
613
614
+
614
615
_config_python3_toolchain = repository_rule (
615
616
_configure_python3_toolchain_impl ,
616
617
configure = True ,
0 commit comments