Commit 840ee5bb authored by Wez Furlong's avatar Wez Furlong Committed by Facebook Github Bot

fbcode_builder: getdeps: add AutoconfBuilder

Summary:
the autoconf builder performs an out-of-source build using
the autoconf suite to configure the build rules.

The `autoconf.args` section from the manifest is passed to the `./configure`
command line.

If an `autogen.sh` script is present then it will be used to regenerate
a missing `configure` script, otherwise we'll try `autoreconf`.

Reviewed By: simpkins

Differential Revision: D14691002

fbshipit-source-id: ab8cceafb833dab513d5a50c65f4c895a4f40047
parent 06b37c9d
......@@ -11,7 +11,7 @@ from __future__ import absolute_import, division, print_function, unicode_litera
import glob
import os
from .envfuncs import Env
from .envfuncs import Env, add_path_entry
from .runcmd import run_cmd
......@@ -103,3 +103,42 @@ class MakeBuilder(BuilderBase):
install_cmd = ["make", "install", "PREFIX=" + self.inst_dir]
self._run_cmd(install_cmd)
class AutoconfBuilder(BuilderBase):
def __init__(self, build_opts, ctx, manifest, src_dir, build_dir, inst_dir, args):
super(AutoconfBuilder, self).__init__(
build_opts, ctx, manifest, src_dir, build_dir, inst_dir
)
self.args = args or []
def _build(self, install_dirs, reconfigure):
configure_path = os.path.join(self.src_dir, "configure")
autogen_path = os.path.join(self.src_dir, "autogen.sh")
env = self.env.copy()
for d in install_dirs:
add_path_entry(env, "PKG_CONFIG_PATH", "%s/lib/pkgconfig" % d)
bindir = os.path.join(d, "bin")
add_path_entry(env, "PATH", bindir, append=False)
if not os.path.exists(configure_path):
print("%s doesn't exist, so reconfiguring" % configure_path)
# This libtoolize call is a bit gross; the issue is that
# `autoreconf` as invoked by libsodium's `autogen.sh` doesn't
# seem to realize that it should invoke libtoolize and then
# error out when the configure script references a libtool
# related symbol.
self._run_cmd(["libtoolize"], cwd=self.src_dir, env=env)
# We generally prefer to call the `autogen.sh` script provided
# by the project on the basis that it may know more than plain
# autoreconf does.
if os.path.exists(autogen_path):
self._run_cmd([autogen_path], cwd=self.src_dir, env=env)
else:
self._run_cmd(["autoreconf", "-ivf"], cwd=self.src_dir, env=env)
configure_cmd = [configure_path, "--prefix=" + self.inst_dir] + self.args
self._run_cmd(configure_cmd, env=env)
self._run_cmd(["make", "-j%s" % self.build_opts.num_jobs], env=env)
self._run_cmd(["make", "install"], env=env)
......@@ -10,7 +10,7 @@ from __future__ import absolute_import, division, print_function, unicode_litera
import io
from .builder import MakeBuilder
from .builder import AutoconfBuilder, MakeBuilder
from .expr import parse_expr
from .fetcher import (
ArchiveFetcher,
......@@ -306,4 +306,10 @@ class ManifestParser(object):
args = self.get_section_as_args("make.args", ctx)
return MakeBuilder(build_options, ctx, self, src_dir, None, inst_dir, args)
if builder == "autoconf":
args = self.get_section_as_args("autoconf.args", ctx)
return AutoconfBuilder(
build_options, ctx, self, src_dir, build_dir, inst_dir, args
)
raise KeyError("project %s has no known builder" % (self.name))
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment