@@ -3,6 +3,7 @@ Wrappers and helpers around `rules_pkg` to build codeql packs.
3
3
"""
4
4
5
5
load ("@bazel_skylib//lib:paths.bzl" , "paths" )
6
+ load ("@bazel_skylib//rules:native_binary.bzl" , "native_test" )
6
7
load ("@rules_pkg//pkg:install.bzl" , "pkg_install" )
7
8
load ("@rules_pkg//pkg:mappings.bzl" , "pkg_attributes" , "pkg_filegroup" , "pkg_files" , _strip_prefix = "strip_prefix" )
8
9
load ("@rules_pkg//pkg:pkg.bzl" , "pkg_zip" )
@@ -351,25 +352,42 @@ def _codeql_pack_install(name, srcs, install_dest = None, build_file_label = Non
351
352
visibility = ["//visibility:private" ],
352
353
)
353
354
build_file_label = internal ("build-file" )
354
-
355
+ data = [
356
+ internal ("script" ),
357
+ internal ("zip-manifest" ),
358
+ Label ("//misc/ripunzip" ),
359
+ ] + ([build_file_label ] if build_file_label else [])
360
+ args = [
361
+ "--pkg-install-script=$(rlocationpath %s)" % internal ("script" ),
362
+ "--ripunzip=$(rlocationpath %s)" % Label ("//misc/ripunzip" ),
363
+ "--zip-manifest=$(rlocationpath %s)" % internal ("zip-manifest" ),
364
+ ] + ([
365
+ "--build-file=$(rlocationpath %s)" % build_file_label ,
366
+ ] if build_file_label else []) + (
367
+ ["--destdir" , "\" %s\" " % install_dest ] if install_dest else []
368
+ )
355
369
py_binary (
356
370
name = name ,
357
371
srcs = [Label ("//misc/bazel/internal:install.py" )],
358
372
main = Label ("//misc/bazel/internal:install.py" ),
359
- data = [
360
- internal ("script" ),
361
- internal ("zip-manifest" ),
362
- Label ("//misc/ripunzip" ),
363
- ] + ([build_file_label ] if build_file_label else []),
364
373
deps = ["@rules_python//python/runfiles" ],
365
- args = [
366
- "--pkg-install-script=$(rlocationpath %s)" % internal ("script" ),
367
- "--ripunzip=$(rlocationpath %s)" % Label ("//misc/ripunzip" ),
368
- "--zip-manifest=$(rlocationpath %s)" % internal ("zip-manifest" ),
369
- ] + ([
370
- "--build-file=$(rlocationpath %s)" % build_file_label ,
371
- ] if build_file_label else []) +
372
- (["--destdir" , "\" %s\" " % install_dest ] if install_dest else []),
374
+ data = data ,
375
+ args = args ,
376
+ )
377
+
378
+ # this hack is meant to be an optimization when using install for tests, where
379
+ # the install step is skipped if nothing changed. If the installation directory
380
+ # is somehow messed up, `bazel run` can be used to force install
381
+ native_test (
382
+ name = internal ("as" , "test" ),
383
+ src = name ,
384
+ tags = [
385
+ "manual" , # avoid having this picked up by `...`, `:all` or `:*`
386
+ "local" , # make sure installation does not run sandboxed
387
+ ],
388
+ data = data ,
389
+ args = args ,
390
+ size = "small" ,
373
391
)
374
392
375
393
def codeql_pack_group (name , srcs , visibility = None , skip_installer = False , prefix = "" , install_dest = None , build_file_label = None , compression_level = 6 ):
0 commit comments