Skip to content

Commit b4ac6e0

Browse files
package,meson: add meson extra options (#13)
build node in project.toml configuration allow user to pass barbican built-in option and/or extra options. Those options are passed using ementic name and converted by barbican according to the buildsystem backend. E.g. w/ Meson build system build.options.with_doc = true --> -Dwith_doc=True
2 parents e9950e8 + e05a07e commit b4ac6e0

File tree

3 files changed

+34
-3
lines changed

3 files changed

+34
-3
lines changed

src/outpost/barbican/config.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,14 @@
6060
"type": "object",
6161
"properties": {
6262
"scm": { "$ref": "urn:barbican:scm" },
63-
"config": { "type": "string" }
63+
"config": { "type": "string" },
64+
"build": {
65+
"type": "object",
66+
"properties": {
67+
"options": { "$ref": "urn:barbican:build#/properties/options" }
68+
},
69+
"required": [ "options" ]
70+
}
6471
},
6572
"required": [ "scm", "config" ],
6673
"additionalProperties": false
@@ -77,7 +84,14 @@
7784
"type": "object",
7885
"properties": {
7986
"scm": { "$ref": "urn:barbican:scm" },
80-
"config": { "type": "string" }
87+
"config": { "type": "string" },
88+
"build": {
89+
"type": "object",
90+
"properties": {
91+
"options": { "$ref": "urn:barbican:build#/properties/options" }
92+
},
93+
"required": [ "options" ]
94+
}
8195
},
8296
"required": [ "scm", "config" ],
8397
"additionalProperties": false

src/outpost/barbican/package/meson.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def build_options(self) -> list[str]:
1818
opts.append("--pkgconfig.relocatable")
1919
opts.append(f"--pkg-config-path={self.pkgconfig_dir}")
2020
opts.append(f"-Dconfig={str(self._dotconfig)}")
21-
opts.extend(self._config["build_opts"] if "build_opts" in self._config else list())
21+
opts.extend([f"-D{k}={str(v)}" for k, v in self._extra_build_opts.items()])
2222
return opts
2323

2424
@working_directory_attr("src_dir")

src/outpost/barbican/package/package.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ def __getitem__(self, key):
5050
class Package(ABC):
5151
__backend_factories: T.ClassVar[BackendFactoryMap] = BackendFactoryMap()
5252

53+
__built_in_options: T.ClassVar[list[str]] = [
54+
"static_pie",
55+
]
56+
5357
@unique
5458
class Type(StrEnum):
5559
"""Package type enumerate."""
@@ -103,6 +107,19 @@ def __init__(
103107
# XXX: Enforce path rel to project configs dir
104108
self._dotconfig = (Path(self._parent.path.project_dir) / dotconfig).resolve(strict=True)
105109

110+
self._built_in_build_opts = dict()
111+
self._extra_build_opts = dict()
112+
if "build" in self._config:
113+
build_opts = (
114+
self._config["build"]["options"] if "options" in self._config["build"] else dict()
115+
)
116+
self._built_in_build_opts = dict(
117+
filter(lambda key: key in self.__built_in_options, build_opts.items())
118+
)
119+
self._extra_build_opts = dict(
120+
filter(lambda key: key not in self.__built_in_options, build_opts.items())
121+
)
122+
106123
@property
107124
def name(self) -> str:
108125
return self._name

0 commit comments

Comments
 (0)