Skip to content

Commit

Permalink
fix(autobuild): typecheck
Browse files Browse the repository at this point in the history
  • Loading branch information
deciduously committed Jan 16, 2025
1 parent 59e5573 commit 3c98097
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 26 deletions.
6 changes: 3 additions & 3 deletions packages/autobuild/autotools/tangram.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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_);
});

Expand Down
7 changes: 4 additions & 3 deletions packages/autobuild/cmake/tangram.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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_);
});
Expand Down
6 changes: 3 additions & 3 deletions packages/autobuild/go/tangram.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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_);
});

Expand Down
20 changes: 12 additions & 8 deletions packages/autobuild/python/tangram.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 } };
}
}

Expand All @@ -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,
},
Expand All @@ -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_);
});

Expand Down
6 changes: 4 additions & 2 deletions packages/autobuild/ruby/tangram.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
13 changes: 7 additions & 6 deletions packages/autobuild/rust/tangram.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,22 @@ 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_);
});

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_);
});
Expand Down
6 changes: 5 additions & 1 deletion packages/python/tangram.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -361,6 +364,7 @@ export const build = tg.target(async (...args: std.Args<BuildArg>) => {
);
const {
build: buildTriple_,
env,
host: host_,
python: pythonArg,
pyprojectToml: pyprojectToml_,
Expand All @@ -387,7 +391,7 @@ export const build = tg.target(async (...args: std.Args<BuildArg>) => {

// 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}`),
Expand Down

0 comments on commit 3c98097

Please sign in to comment.