bazel-contrib / bazel-contrib/rules_foreign_cc

How to call `autoheader`?

Open
#1,081 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Starlark
Stars
737
Forks
270
PR merge metrics
No merged PRs in 30d

Description

I'm using `configure_make` to build [SAMtools](https://github.com/samtools/samtools#building-samtools), a popular bioinformatics library.

The installation instructions request that the user run `autoheader` *before* `autoconf`.

I can obviously just check in the `config.h.in` file that `autoheader` generates, but this will introduce the requirement that I carefully ensure the (6+) environments I build in have identical libraries (and I am not a large enough operation to realistically vendor all of these upstream dependencies).

I tried playing some tricks like:
```
autogen = 1,
autogen_command = "autoheader",
```
but that produces a `build_script.sh` like:
```
NOCONFIGURE="1" "$BUILD_TMPDIR/autoheader"
```
which is not quite right.

I've patched this repo to get the behavior I want for now, but was wondering if there is a "better" way to do this?

```diff
❯ git diff HEAD~1 HEAD
diff --git a/foreign_cc/configure.bzl b/foreign_cc/configure.bzl
index 781f3ab..bc5c15b 100644
--- a/foreign_cc/configure.bzl
+++ b/foreign_cc/configure.bzl
@@ -111,6 +111,7 @@ def _create_configure_script(configureParameters):
autogen = ctx.attr.autogen,
autogen_command = ctx.attr.autogen_command,
autogen_options = ctx.attr.autogen_options,
+ autoheader = ctx.attr.autoheader,
make_commands = make_commands,
make_path = attrs.make_path,
)
@@ -159,6 +160,14 @@ def _attrs():
"autogen_options": attr.string_list(
doc = "Any options to be put in the 'autogen.sh' command line.",
),
+ "autoheader": attr.bool(
+ doc = (
+ "Set to True if we should run 'autoheader' before 'autoconf', " +
+ "currently requires `configure_in_place` to be True."
+ ),
+ mandatory = False,
+ default = False,
+ ),
"autoreconf": attr.bool(
doc = (
"Set to True if 'autoreconf' should be invoked before 'configure.', " +
diff --git a/foreign_cc/private/configure_script.bzl b/foreign_cc/private/configure_script.bzl
index dce885a..aa8836f 100644
--- a/foreign_cc/private/configure_script.bzl
+++ b/foreign_cc/private/configure_script.bzl
@@ -24,6 +24,7 @@ def create_configure_script(
autogen,
autogen_command,
autogen_options,
+ autoheader,
make_path,
make_commands):
ext_build_dirs = inputs.ext_build_dirs
@@ -40,6 +41,9 @@ def create_configure_script(
script.append("##export_var## MAKE {}".format(make_path))
script.append("##enable_tracing##")

+ if autoheader:
+ script.append("autoheader")
+
if autogen:
# NOCONFIGURE is pseudo standard and tells the script to not invoke configure.
# We explicitly invoke configure later.
```

Contributor guide

Open the contributing guide

Research direction

Start in foreign_cc/configure.bzl and private/configure_script.bzl, following create_configure_script and the generated build_script.sh shown in the issue. Verify how configure_make assembles autogen commands, then confirm that the requested autoheader invocation appears before autoconf without breaking existing generation behavior.

Written by the indexing model from the issue text.

Assessment

Domain
build-system
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.