@@ -3,6 +3,7 @@ Wrappers and helpers around `rules_pkg` to build codeql packs.
33"""
44
55load ("@bazel_skylib//lib:paths.bzl" , "paths" )
6+ load ("@bazel_skylib//rules:native_binary.bzl" , "native_test" )
67load ("@rules_pkg//pkg:install.bzl" , "pkg_install" )
78load ("@rules_pkg//pkg:mappings.bzl" , "pkg_attributes" , "pkg_filegroup" , "pkg_files" , _strip_prefix = "strip_prefix" )
89load ("@rules_pkg//pkg:pkg.bzl" , "pkg_zip" )
@@ -351,25 +352,42 @@ def _codeql_pack_install(name, srcs, install_dest = None, build_file_label = Non
351352 visibility = ["//visibility:private" ],
352353 )
353354 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+ )
355369 py_binary (
356370 name = name ,
357371 srcs = [Label ("//misc/bazel/internal:install.py" )],
358372 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 []),
364373 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" ,
373391 )
374392
375393def codeql_pack_group (name , srcs , visibility = None , skip_installer = False , prefix = "" , install_dest = None , build_file_label = None , compression_level = 6 ):
0 commit comments