diff --git a/packages/autobuild/autotools/tangram.ts b/packages/autobuild/autotools/tangram.ts index b07bc281..230c3c41 100644 --- a/packages/autobuild/autotools/tangram.ts +++ b/packages/autobuild/autotools/tangram.ts @@ -16,10 +16,10 @@ export type Arg = { }; export const build = tg.target(async (arg: Arg) => { - const { build, env: envArg, host, source } = arg ?? {}; + const { env: envArg, ...rest } = arg ?? {}; - const env_ = envArg ?? env({ build, host }); - const arg_ = { build, env: env_, host, source }; + const env_ = envArg ?? env({ build: arg.build, host: arg.host }); + const arg_ = { ...rest, env: env_ }; return std.autotools.build(arg_); }); diff --git a/packages/autobuild/cmake/tangram.ts b/packages/autobuild/cmake/tangram.ts index 2c5e228d..dfbe8000 100644 --- a/packages/autobuild/cmake/tangram.ts +++ b/packages/autobuild/cmake/tangram.ts @@ -9,10 +9,11 @@ export type Arg = { }; export const build = tg.target(async (arg: Arg) => { - const { build, env: envArg, host, source } = arg ?? {}; + const { env: envArg, ...rest } = arg ?? {}; - const env_ = envArg ?? std.env.arg(env({ build, host }), envArg); - const arg_ = { build, env: env_, host, source }; + const env_ = + envArg ?? std.env.arg(env({ build: arg.build, host: arg.host }), envArg); + const arg_ = { ...rest, env: env_ }; return cmake.build(arg_); }); diff --git a/packages/autobuild/go/tangram.ts b/packages/autobuild/go/tangram.ts index 0f46a168..6a04720a 100644 --- a/packages/autobuild/go/tangram.ts +++ b/packages/autobuild/go/tangram.ts @@ -9,10 +9,10 @@ export type Arg = { }; export const build = tg.target(async (arg: Arg) => { - const { build, env: envArg, host, source } = arg ?? {}; + const { env: envArg, ...rest } = arg ?? {}; - const env_ = envArg ?? env({ build, host }); - const arg_ = { build, env: env_, host, source }; + const env_ = envArg ?? env({ build: arg.build, host: arg.host }); + const arg_ = { ...rest, env: env_ }; return go.build(arg_); }); diff --git a/packages/autobuild/python/tangram.ts b/packages/autobuild/python/tangram.ts index 2517ccda..017a883d 100644 --- a/packages/autobuild/python/tangram.ts +++ b/packages/autobuild/python/tangram.ts @@ -11,15 +11,17 @@ export type Arg = { }; export const build = tg.target(async (arg: Arg) => { - const { build, env: envArg, host, source } = arg ?? {}; + const { env: envArg, source, ...rest } = arg ?? {}; - const env_ = envArg ?? std.env.arg(env({ build, host }), envArg); - let arg_: python.BuildArg = { build, env: env_, host, source }; + const env_ = + envArg ?? + (await std.env.arg(env({ build: arg.build, host: arg.host }), envArg)); + let arg_: python.BuildArg = { ...rest, env: env_, source }; const maybeRequirements = source.tryGet("requirements.txt"); if (maybeRequirements) { if (maybeRequirements instanceof tg.File) { - arg_ = { ...arg_, requirements: maybeRequirements }; + arg_ = { ...arg_, python: { requirements: maybeRequirements } }; } } @@ -38,7 +40,7 @@ export const plain = tg.target(async (arg: Arg) => { directory: source, extension: ".py", interpreter, - env: std.env.arg( + env: await std.env.arg( { PYTHONPATH: toolchain, }, @@ -56,11 +58,13 @@ export const plain = tg.target(async (arg: Arg) => { // }); export const pyproject = tg.target(async (arg: Arg) => { - const { build, env: envArg, host, source } = arg ?? {}; + const { env: envArg, source, ...rest } = arg ?? {}; - const env_ = envArg ?? std.env.arg(env({ build, host }), envArg); + const env_ = + envArg ?? + (await std.env.arg(env({ build: arg.build, host: arg.host }), envArg)); const pyprojectToml = await source.get("pyproject.toml").then(tg.File.expect); - const arg_ = { build, env: env_, host, pyprojectToml, source }; + const arg_ = { ...rest, env: env_, pyprojectToml, source }; return python.build(arg_); }); diff --git a/packages/autobuild/ruby/tangram.ts b/packages/autobuild/ruby/tangram.ts index 8dee17e2..f6cadcba 100644 --- a/packages/autobuild/ruby/tangram.ts +++ b/packages/autobuild/ruby/tangram.ts @@ -10,9 +10,11 @@ export type Arg = { }; export const plain = tg.target(async (arg: Arg) => { - const { build, env: envArg, host, source } = arg ?? {}; + const { env: envArg, source } = arg ?? {}; - const env_ = envArg ?? std.env.arg(env({ build, host }), envArg); + const env_ = + envArg ?? + (await std.env.arg(env({ build: arg.build, host: arg.host }), envArg)); const toolchain = await ruby.toolchain(); const interpreter = await toolchain.get("bin/ruby").then(tg.File.expect); return wrapScripts({ diff --git a/packages/autobuild/rust/tangram.ts b/packages/autobuild/rust/tangram.ts index 9d4d921c..ba1d910b 100644 --- a/packages/autobuild/rust/tangram.ts +++ b/packages/autobuild/rust/tangram.ts @@ -11,10 +11,11 @@ export type Arg = { }; export const cargo = tg.target(async (arg: Arg) => { - const { build, env: envArg, host, source } = arg ?? {}; + const { env: envArg, ...rest } = arg ?? {}; - const env_ = envArg ?? std.env.arg(env({ build, host }), envArg); - const arg_ = { build, env: env_, host, source }; + const env_ = + envArg ?? std.env.arg(env({ build: arg.build, host: arg.host }), envArg); + const arg_ = { ...rest, env: env_ }; return await rust.cargo.build(arg_); }); @@ -22,10 +23,10 @@ export const cargo = tg.target(async (arg: Arg) => { export default cargo; export const plain = tg.target(async (arg: Arg) => { - const { build, env: envArg, host, source } = arg ?? {}; + const { env: envArg, ...rest } = arg ?? {}; - const env_ = envArg ?? env({ build, host }); - const arg_ = { build, env: env_, host, source }; + const env_ = envArg ?? env({ build: arg.build, host: arg.host }); + const arg_ = { ...rest, env: env_ }; return await rust.build.build(arg_); }); diff --git a/packages/python/tangram.ts b/packages/python/tangram.ts index b6fd0714..7020ee43 100644 --- a/packages/python/tangram.ts +++ b/packages/python/tangram.ts @@ -342,6 +342,9 @@ export type BuildArg = { /** The machine this package will build on. */ build?: string; + /** Additi8onal environment to include. */ + env?: std.env.Arg; + /** The machine this package produces binaries for. */ host?: string; @@ -361,6 +364,7 @@ export const build = tg.target(async (...args: std.Args) => { ); const { build: buildTriple_, + env, host: host_, python: pythonArg, pyprojectToml: pyprojectToml_, @@ -387,7 +391,7 @@ export const build = tg.target(async (...args: std.Args) => { // Construct the python environment. const pythonArtifact = await tg.directory( - toolchain({ ...pythonArg, build: buildTriple, host }), + toolchain({ ...pythonArg, build: buildTriple, env, host }), { ["lib/python3/site-packages"]: { [name]: tg.symlink(tg`${source}/src/${name}`),