Skip to content

Commit

Permalink
refactor(autobuild): run autoreconf if needed
Browse files Browse the repository at this point in the history
  • Loading branch information
deciduously committed Jan 20, 2025
1 parent c1b70d3 commit 7ae3525
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 16 deletions.
25 changes: 23 additions & 2 deletions packages/autobuild/autotools/tangram.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,35 @@ export type Arg = {

export const build = tg.target(async (arg: Arg) => {
const { env: envArg, ...rest } = arg ?? {};

const env_ = envArg ?? env({ build: arg.build, host: arg.host });
const arg_ = { ...rest, env: env_ };

let source = arg.source;
if (needsReconf(source)) {
source = await reconfigure(source);
}

const arg_ = { ...rest, env: env_, source };
return std.autotools.build(arg_);
});

export default build;

export const needsReconf = async (source: tg.Directory): boolean => {
const entries = await source.entries();
const hasFile = (name: string) =>
entries.hasOwnProperty(name) && entries[name] instanceof tg.File;
return hasFile("configure.ac") && !hasFile("configure");
}

export const reconfigure = async (source: tg.Directory) => {
return $`cp -R ${source} $OUTPUT
chmod -R u+w $OUTPUT
cd $OUTPUT
autoreconf --install --verbose`
.env(autoconf(), automake())
.then(tg.Directory.expect);
}

export type EnvArg = {
build?: string | undefined;
host?: string | undefined;
Expand Down
15 changes: 1 addition & 14 deletions packages/autobuild/tangram.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,9 +256,8 @@ const testParamaters = (): Record<Kind, TestFnArg> => {
};

const testDirs = async (): Promise<Record<Kind, tg.Directory>> => {
const preparedAutotoolsTest = await prepareAutotoolsTestDistributionBundle();
return {
"cc-autotools": preparedAutotoolsTest,
"cc-autotools": ccAutotoolsTest,
cmake: cmakeTest,
go: goTest,
"js-node": jsNodeTest,
Expand Down Expand Up @@ -299,15 +298,3 @@ export const testKind = tg.target(async (kind: Kind) => {
await testStdout(testParamaters()[kind]);
return true;
});

/** We need to generate the distribution bundle for the `cc-autotools` test package, generating the configure scripts and intermediate makefile templates. */
export const prepareAutotoolsTestDistributionBundle = tg.target(async () => {
const originalSource = ccAutotoolsTest;
return $`set -eux
cp -R ${originalSource} $OUTPUT
chmod -R u+w $OUTPUT
cd $OUTPUT
autoreconf --install --verbose`
.env(autoconf(), automake())
.then(tg.Directory.expect);
});

0 comments on commit 7ae3525

Please sign in to comment.