1- # libacl
1+ """ libacl"""
22
33load("@@//bazel/rules:so_symlink.bzl", "so_symlink")
44load("@@//compliance/rules:ship_source_offer.bzl", "ship_source_offer")
5- load("@bazel_skylib//rules:copy_file.bzl", "copy_file")
65load("@bazel_skylib//rules:expand_template.bzl", "expand_template")
76load("@package_metadata//rules:package_metadata.bzl", "package_metadata")
87load("@rules_cc//cc:defs.bzl", "cc_library", "cc_shared_library")
98load("@rules_license//rules:license.bzl", "license")
109load("@rules_pkg//pkg:install.bzl", "pkg_install")
11- load("@rules_pkg//pkg:mappings.bzl", "pkg_files")
10+ load("@rules_pkg//pkg:mappings.bzl", "pkg_filegroup", " pkg_files", "strip_prefix ")
1211
1312package(default_package_metadata = [":package_metadata", ":ship_source_offer"])
1413
15- _VERSION = "2.3.1"
14+ VERSION = "2.3.1"
1615
17- # This is going to change in the future. Debate the syntax in https://github.com/bazel-contrib/supply-chain/issues/124
18- PURL = "pkg:https/download.savannah.nongnu.org/acl@{version}?url=https://download.savannah.nongnu.org/releases/acl/attr-%{version}.tar.xz".format(
19- version = _VERSION,
16+ PURL = "pkg:generic/acl@{version}?download_url=https://download.savannah.nongnu.org/releases/acl/acl-{version}.tar.xz".format(
17+ version = VERSION,
2018)
2119
2220package_metadata(
@@ -39,33 +37,39 @@ license(
3937
4038# TODO: We will have to adjust this when we put a dependency on it.
4139# It is possible that some of the other files in include are public.
42- _PUBLIC_HEADERS = [
43- ":include/sys/acl.h",
44- ":include/acl/libacl.h",
40+ PUBLIC_HEADERS = [
41+ ":fixed/ include/sys/acl.h",
42+ ":fixed/ include/acl/libacl.h",
4543]
4644
47- # The code sometimes includes "include/acl.h" as <sys/acl.h>
48- copy_file(
49- name = "sys_acl_h",
50- src = "include/acl.h",
51- out = "include/sys/acl.h",
52- )
45+ # There are two things going on here
46+ # 1. The public headers in the source are not in their installed locations.
47+ # src = "include/acl.h" => "include/sys/acl.h"
48+ # src = "include/libacl.h", => "include/acl/libacl.h"
49+ # 2. In the (internal) source headers, external methods are marked EXPORT.
50+ # However, the public version should use extern instead. Configure/make
51+ # did the rename while copying, so we do the same.
5352
54- # There is both a libacl/libacl.h and an include/libacl.h
55- # libacl/libacl.h is internal to the library build.
56- # include/libacl.h is the public one, which they self refernce as
57- # <sys/libacl.h>
58- copy_file(
59- name = "sys_libacl_h",
60- src = "include/libacl.h",
61- out = "include/acl/libacl.h",
53+ genrule(
54+ name = "fixed_headers",
55+ srcs = [
56+ ":include/acl.h",
57+ ":include/libacl.h",
58+ ],
59+ outs = [
60+ "fixed/include/sys/acl.h",
61+ "fixed/include/acl/libacl.h",
62+ ],
63+ cmd = ";".join([
64+ "sed 's/EXPORT/extern/g' $(location :include/acl.h) > $(location fixed/include/sys/acl.h)",
65+ "sed 's/EXPORT/extern/g' $(location :include/libacl.h) > $(location fixed/include/acl/libacl.h)",
66+ ]),
6267)
6368
6469cc_library(
6570 name = "libacl",
6671 srcs = [
67- ":sys_acl_h",
68- ":sys_libacl_h",
72+ ":fixed_headers",
6973 "include/acl_ea.h",
7074 "include/acl.h",
7175 "include/config.h",
@@ -133,14 +137,15 @@ cc_library(
133137 "libmisc/unquote.c",
134138 "libmisc/walk_tree.c",
135139 ],
136- hdrs = _PUBLIC_HEADERS ,
140+ hdrs = PUBLIC_HEADERS ,
137141 includes = [
138142 "include",
143+ "fixed/include",
139144 ],
140145 copts = [
141146 "-fPIC",
142- # TODO: Does this need speed or size?
143- # "-O2 ",
147+ "-O2",
148+ "-g ",
144149 "-Ilibacl",
145150 ],
146151 local_defines = [
@@ -173,12 +178,14 @@ so_symlink(
173178 src = ":acl",
174179 libname = "libacl",
175180 version = "1.1.2301",
181+ prefix = "embedded",
176182)
177183
178184pkg_files(
179185 name = "hdr_files",
180- srcs = _PUBLIC_HEADERS,
181- prefix = "include/acl/",
186+ srcs = [":fixed_headers"],
187+ strip_prefix = strip_prefix.from_pkg("fixed"),
188+ prefix = "embedded",
182189)
183190
184191expand_template(
@@ -190,22 +197,29 @@ expand_template(
190197 "@exec_prefix@": "${prefix}",
191198 "@libdir@": "${prefix}/lib",
192199 "@includedir@": "${prefix}/include",
193- "@PACKAGE_VERSION@": _VERSION ,
200+ "@PACKAGE_VERSION@": VERSION ,
194201 },
195202 template = "libacl.pc.in",
196203)
197204
198205pkg_files(
199206 name = "pc_file",
200207 srcs = [":gen_pkgconfig"],
201- prefix = "lib/pkgconfig",
208+ prefix = "embedded/ lib/pkgconfig",
202209)
203210
204- pkg_install (
205- name = "install ",
211+ pkg_filegroup (
212+ name = "all_files ",
206213 srcs = [
207214 ":hdr_files",
208215 ":lib_files",
209216 ":pc_file",
210217 ],
211218)
219+
220+ pkg_install(
221+ name = "install",
222+ srcs = [
223+ ":all_files",
224+ ],
225+ )
0 commit comments