diff --git a/packages/autobuild/autotools/tangram.ts b/packages/autobuild/autotools/tangram.ts index 230c3c41..23194e2c 100644 --- a/packages/autobuild/autotools/tangram.ts +++ b/packages/autobuild/autotools/tangram.ts @@ -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; diff --git a/packages/autobuild/tangram.ts b/packages/autobuild/tangram.ts index aeaf7de1..f36cebf6 100644 --- a/packages/autobuild/tangram.ts +++ b/packages/autobuild/tangram.ts @@ -256,9 +256,8 @@ const testParamaters = (): Record => { }; const testDirs = async (): Promise> => { - const preparedAutotoolsTest = await prepareAutotoolsTestDistributionBundle(); return { - "cc-autotools": preparedAutotoolsTest, + "cc-autotools": ccAutotoolsTest, cmake: cmakeTest, go: goTest, "js-node": jsNodeTest, @@ -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); -});