Skip to content

Commit

Permalink
fix: Set target input to default value in build-crates-standalone a…
Browse files Browse the repository at this point in the history
…ction (#73)
  • Loading branch information
fuzzypixelz authored Mar 27, 2024
1 parent cf7aade commit 6ae1c50
Show file tree
Hide file tree
Showing 10 changed files with 7 additions and 12 deletions.
1 change: 0 additions & 1 deletion dist/build-crates-debian-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -128404,7 +128404,6 @@ async function installBinaryCached(name) {
async function build(path, target) {
const crossContents = await fs.readFile(join(path, "Cross.toml"), "utf-8");
const crossManifest = toml.parse(crossContents);
target ??= hostTarget();
sh(`rustup target add ${target}`, { cwd: path });
const command = target in crossManifest ? ["cross"] : ["cargo"];
command.push("build", "--release", "--bins", "--lib", "--target", target);
Expand Down
2 changes: 1 addition & 1 deletion dist/build-crates-standalone-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -128403,7 +128403,6 @@ async function installBinaryCached(name) {
async function build(path, target) {
const crossContents = await promises_.readFile((0,external_path_.join)(path, "Cross.toml"), "utf-8");
const crossManifest = parse(crossContents);
target ??= hostTarget();
command_sh(`rustup target add ${target}`, { cwd: path });
const command = target in crossManifest ? ["cross"] : ["cargo"];
command.push("build", "--release", "--bins", "--lib", "--target", target);
Expand Down Expand Up @@ -128497,6 +128496,7 @@ async function main(input) {
const repo = input.repo.split("/")[1];
cloneFromGitHub(input.repo, { branch: input.branch, token: input.githubToken });
input.version ??= describe(repo);
input.target ??= hostTarget();
await build(repo, input.target);
const output = artifactName(repo, input.version, input.target);
await fromDirectory(output, external_path_.join(repo, "target", input.target, "release"), input.artifactRegExp);
Expand Down
1 change: 0 additions & 1 deletion dist/bump-crates-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -82262,7 +82262,6 @@ async function installBinaryCached(name) {
async function build(path, target) {
const crossContents = await fs.readFile(join(path, "Cross.toml"), "utf-8");
const crossManifest = toml.parse(crossContents);
target ??= hostTarget();
sh(`rustup target add ${target}`, { cwd: path });
const command = target in crossManifest ? ["cross"] : ["cargo"];
command.push("build", "--release", "--bins", "--lib", "--target", target);
Expand Down
1 change: 0 additions & 1 deletion dist/publish-crates-cargo-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -82262,7 +82262,6 @@ async function installBinaryCached(name) {
async function build(path, target) {
const crossContents = await fs.readFile(join(path, "Cross.toml"), "utf-8");
const crossManifest = toml.parse(crossContents);
target ??= hostTarget();
sh(`rustup target add ${target}`, { cwd: path });
const command = target in crossManifest ? ["cross"] : ["cargo"];
command.push("build", "--release", "--bins", "--lib", "--target", target);
Expand Down
1 change: 0 additions & 1 deletion dist/publish-crates-debian-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -128426,7 +128426,6 @@ async function installBinaryCached(name) {
async function build(path, target) {
const crossContents = await fs.readFile(join(path, "Cross.toml"), "utf-8");
const crossManifest = toml.parse(crossContents);
target ??= hostTarget();
sh(`rustup target add ${target}`, { cwd: path });
const command = target in crossManifest ? ["cross"] : ["cargo"];
command.push("build", "--release", "--bins", "--lib", "--target", target);
Expand Down
2 changes: 1 addition & 1 deletion dist/publish-crates-eclipse-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -128423,7 +128423,6 @@ async function installBinaryCached(name) {
async function build(path, target) {
const crossContents = await fs.readFile(join(path, "Cross.toml"), "utf-8");
const crossManifest = toml.parse(crossContents);
target ??= hostTarget();
sh(`rustup target add ${target}`, { cwd: path });
const command = target in crossManifest ? ["cross"] : ["cargo"];
command.push("build", "--release", "--bins", "--lib", "--target", target);
Expand Down Expand Up @@ -128517,6 +128516,7 @@ async function main(input) {
const repo = input.repo.split("/")[1];
git.cloneFromGitHub(input.repo, { branch: input.branch, token: input.githubToken });
input.version ??= git.describe(repo);
input.target ??= cargo.hostTarget();
await cargo.build(repo, input.target);
const output = artifactName(repo, input.version, input.target);
await zip.fromDirectory(output, path.join(repo, "target", input.target, "release"), input.artifactRegExp);
Expand Down
2 changes: 1 addition & 1 deletion dist/publish-crates-github-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -128404,7 +128404,6 @@ async function installBinaryCached(name) {
async function build(path, target) {
const crossContents = await fs.readFile(join(path, "Cross.toml"), "utf-8");
const crossManifest = toml.parse(crossContents);
target ??= hostTarget();
sh(`rustup target add ${target}`, { cwd: path });
const command = target in crossManifest ? ["cross"] : ["cargo"];
command.push("build", "--release", "--bins", "--lib", "--target", target);
Expand Down Expand Up @@ -128574,6 +128573,7 @@ async function build_crates_standalone_main(input) {
const repo = input.repo.split("/")[1];
git.cloneFromGitHub(input.repo, { branch: input.branch, token: input.githubToken });
input.version ??= git.describe(repo);
input.target ??= cargo.hostTarget();
await cargo.build(repo, input.target);
const output = build_crates_standalone_artifactName(repo, input.version, input.target);
await zip.fromDirectory(output, path.join(repo, "target", input.target, "release"), input.artifactRegExp);
Expand Down
2 changes: 1 addition & 1 deletion dist/publish-crates-homebrew-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -128425,7 +128425,6 @@ async function installBinaryCached(name) {
async function build(path, target) {
const crossContents = await fs.readFile(join(path, "Cross.toml"), "utf-8");
const crossManifest = toml.parse(crossContents);
target ??= hostTarget();
sh(`rustup target add ${target}`, { cwd: path });
const command = target in crossManifest ? ["cross"] : ["cargo"];
command.push("build", "--release", "--bins", "--lib", "--target", target);
Expand Down Expand Up @@ -128519,6 +128518,7 @@ async function main(input) {
const repo = input.repo.split("/")[1];
git.cloneFromGitHub(input.repo, { branch: input.branch, token: input.githubToken });
input.version ??= git.describe(repo);
input.target ??= cargo.hostTarget();
await cargo.build(repo, input.target);
const output = artifactName(repo, input.version, input.target);
await zip.fromDirectory(output, path.join(repo, "target", input.target, "release"), input.artifactRegExp);
Expand Down
1 change: 1 addition & 0 deletions src/build-crates-standalone.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export async function main(input: Input) {
git.cloneFromGitHub(input.repo, { branch: input.branch, token: input.githubToken });

input.version ??= git.describe(repo);
input.target ??= cargo.hostTarget();

await cargo.build(repo, input.target);

Expand Down
6 changes: 2 additions & 4 deletions src/cargo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -304,20 +304,18 @@ type CrossManifest = {
target: { [target: string]: { image: string } };
};

export async function build(path: string, target?: string) {
export async function build(path: string, target: string) {
const crossContents = await fs.readFile(join(path, "Cross.toml"), "utf-8");
const crossManifest = toml.parse(crossContents) as CrossManifest;

target ??= hostTarget();

sh(`rustup target add ${target}`, { cwd: path });

const command = target in crossManifest ? ["cross"] : ["cargo"];
command.push("build", "--release", "--bins", "--lib", "--target", target);
sh(command.join(" "), { cwd: path });
}

function hostTarget(): string {
export function hostTarget(): string {
return sh("rustc --version --verbose").match(/host: (?<target>.*)/).groups["target"];
}

Expand Down

0 comments on commit 6ae1c50

Please sign in to comment.