blob: 2b2f42241c15147b80a23ef3d7ed1b452772137a [file] [log] [blame]
Tim Windelschmidtbed76d92025-02-18 03:04:14 +01001load("//osbase/build/fsspec:def.bzl", "FSSpecInfo", "fsspec_core_impl")
2
3def _erofs_image_impl(ctx):
4 fs_name = ctx.label.name + ".img"
5 fs_out = ctx.actions.declare_file(fs_name)
6
7 fsspec_core_impl(ctx, ctx.executable._mkerofs, fs_out)
8
9 return [DefaultInfo(files = depset([fs_out]))]
10
11erofs_image = rule(
12 implementation = _erofs_image_impl,
13 doc = """
Jan Schär0fd36f42025-04-29 10:26:03 +000014 Build an EROFS. All files specified in files and all specified symlinks will be contained.
Tim Windelschmidtbed76d92025-02-18 03:04:14 +010015 Executable files will have their permissions set to 0555, non-executable files will have
16 their permissions set to 0444. All parent directories will be created with 0555 permissions.
17 """,
18 attrs = {
19 "files": attr.string_keyed_label_dict(
20 mandatory = True,
21 allow_files = True,
22 doc = """
23 Dictionary of Labels to String, placing a given Label's output file in the EROFS at the location
24 specified by the String value. The specified labels must only have a single output.
25 """,
Tim Windelschmidtbed76d92025-02-18 03:04:14 +010026 ),
27 "symlinks": attr.string_dict(
28 default = {},
29 doc = """
Jan Schär0fd36f42025-04-29 10:26:03 +000030 Symbolic links to create. Similar format as in `files`, so the key is the location of the
Tim Windelschmidtad4d9542025-03-24 20:20:13 +010031 symlink itself and the value of it is target of the symlink. Only raw strings are allowed as targets,
Jan Schär0fd36f42025-04-29 10:26:03 +000032 labels are not permitted. Include the file using `files`, then symlink to its location.
Tim Windelschmidtad4d9542025-03-24 20:20:13 +010033 """,
Tim Windelschmidtbed76d92025-02-18 03:04:14 +010034 ),
35 "fsspecs": attr.label_list(
36 default = [],
37 doc = """
38 List of file system specs (osbase.build.fsspec.FSSpec) to also include in the resulting image.
39 These will be merged with all other given attributes.
40 """,
41 providers = [FSSpecInfo],
42 allow_files = True,
43 ),
44
45 # Tools, implicit dependencies.
46 "_mkerofs": attr.label(
47 default = Label("//osbase/build/mkerofs"),
48 executable = True,
49 cfg = "exec",
50 ),
51 },
52)