diff --git a/build/fbcode_builder/getdeps/builder.py b/build/fbcode_builder/getdeps/builder.py index 65bca2692..10bd2a62a 100644 --- a/build/fbcode_builder/getdeps/builder.py +++ b/build/fbcode_builder/getdeps/builder.py @@ -487,6 +487,61 @@ def _build(self, reconfigure) -> None: self._run_cmd(install_cmd, env=env) +class SystemdBuilder(BuilderBase): + # SystemdBuilder assumes that meson build tool has already been installed on + # the machine. + def __init__( + self, + loader, + dep_manifests, + build_opts, + ctx, + manifest, + src_dir, + build_dir, + inst_dir, + ) -> None: + super(SystemdBuilder, self).__init__( + loader, + dep_manifests, + build_opts, + ctx, + manifest, + src_dir, + build_dir, + inst_dir, + ) + + def _build(self, reconfigure) -> None: + env = self._compute_env() + meson = path_search(env, "meson") + if meson is None: + raise Exception("Failed to find Meson") + + # Meson builds typically require setup, compile, and install steps. + # During this setup step we ensure that the static library is built and + # the prefix is empty. + self._run_cmd( + [ + meson, + "setup", + "-Dstatic-libsystemd=true", + "-Dprefix=/", + self.build_dir, + self.src_dir, + ] + ) + + # Compile step needs to satisfy the build directory that was previously + # prepared during setup. + self._run_cmd([meson, "compile", "-C", self.build_dir]) + + # Install step + self._run_cmd( + [meson, "install", "-C", self.build_dir, "--destdir", self.inst_dir] + ) + + class CMakeBuilder(BuilderBase): MANUAL_BUILD_SCRIPT = """\ #!{sys.executable} diff --git a/build/fbcode_builder/getdeps/manifest.py b/build/fbcode_builder/getdeps/manifest.py index d02cfe83f..e329da1ee 100644 --- a/build/fbcode_builder/getdeps/manifest.py +++ b/build/fbcode_builder/getdeps/manifest.py @@ -22,6 +22,7 @@ NopBuilder, OpenSSLBuilder, SqliteBuilder, + SystemdBuilder, ) from .cargo import CargoBuilder from .expr import parse_expr @@ -661,6 +662,18 @@ def create_builder( # noqa:C901 inst_dir, ) + if builder == "systemd": + return SystemdBuilder( + loader, + dep_manifests, + build_options, + ctx, + self, + src_dir, + build_dir, + inst_dir, + ) + if builder == "cargo": return self.create_cargo_builder( loader, diff --git a/build/fbcode_builder/manifests/systemd b/build/fbcode_builder/manifests/systemd index 40564970d..0fb2a6f5a 100644 --- a/build/fbcode_builder/manifests/systemd +++ b/build/fbcode_builder/manifests/systemd @@ -4,3 +4,12 @@ name = systemd [rpms] systemd systemd-devel + +[download] +url = https://github.com/systemd/systemd/archive/refs/tags/v256.7.tar.gz +sha256 = 896d76ff65c88f5fd9e42f90d152b0579049158a163431dd77cdc57748b1d7b0 + + +[build] +builder = systemd +subdir = systemd-256.7