summaryrefslogtreecommitdiff
path: root/modules/squashfs-tools/4.6.1/patches/add_build_file.patch
blob: 0103220dac62bf71f5654785c47deff3b4dce8b8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
--- /dev/null
+++ BUILD
@@ -0,0 +1,82 @@
+load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library")
+
+_COPTS = [
+    "-O2",  # squashfs-tools/Makefile#L219
+    "-std=gnu17",  # GNU extensions are at play
+    "-pthread",
+    "--no-warnings",  # We don't care about third-party warnings
+]
+
+_LINKOPTS = [
+    "-lpthread",
+]
+
+_DEFINES = [
+    'COMP_DEFAULT=\\"gzip\\"',
+    'DATE=\\"redacted\\"',
+    'VERSION=\\"redacted\\"',
+    'YEAR=\\"redacted\\"',
+    "_FILE_OFFSET_BITS=64",
+    "_GNU_SOURCE",
+    "_LARGEFILE_SOURCE",
+    "REPRODUCIBLE_DEFAULT",
+    "XATTR_DEFAULT",
+    "XATTR_SUPPORT",
+] + [
+    "GZIP_SUPPORT",
+    "LZ4_SUPPORT",
+    "ZSTD_SUPPORT",
+    # "LZO_SUPPORT",  # Not available on BCR yet
+    # "XZ_SUPPORT",  # Not available on BCR yet
+]
+
+cc_library(
+    name = "common",
+    srcs = glob(
+        [
+            "*.c",
+            "*.h",
+        ],
+        exclude = [
+            "mksquashfs.c",
+            "unsquash*",
+            "lzma*",
+            "lzo*",
+            "xz*",
+        ],
+    ),
+    hdrs = ["squashfs_fs.h"],
+    copts = _COPTS,
+    linkopts = _LINKOPTS,
+    local_defines = _DEFINES,
+    deps = [
+        "@lz4",
+        "@lz4//:lz4_hc",
+        "@zlib",
+        "@zstd",
+    ],
+)
+
+cc_binary(
+    name = "mksquashfs",
+    srcs = [
+        "mksquashfs.c",
+        "mksquashfs.h",
+        "mksquashfs_error.h",
+    ],
+    copts = _COPTS,
+    linkopts = _LINKOPTS,
+    local_defines = _DEFINES,
+    visibility = ["//visibility:public"],
+    deps = [":common"],
+)
+
+cc_binary(
+    name = "unsquashfs",
+    srcs = glob(["unsquash*"]),
+    copts = _COPTS,
+    linkopts = _LINKOPTS,
+    local_defines = _DEFINES,
+    visibility = ["//visibility:public"],
+    deps = [":common"],
+)