Skip to content

Commit

Permalink
[Package] Normalize install options (#65)
Browse files Browse the repository at this point in the history
* refactor: update packagePath to path in GoBuildOptions interface

Signed-off-by: jaudiger <jeremy.audiger@ioterop.com>

* feat: add support for setting environment variables in CargoBuildOptions

Signed-off-by: jaudiger <jeremy.audiger@ioterop.com>

---------

Signed-off-by: jaudiger <jeremy.audiger@ioterop.com>
  • Loading branch information
jaudiger authored Jul 14, 2024
1 parent 92ad6bd commit 63be501
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion packages/carapace/project.bri
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default () => {
generate: true,
ldflags: ["-s", "-w", `-X main.version=${project.version}`],
},
packagePath: "./cmd/carapace",
path: "./cmd/carapace",
runnable: "bin/carapace",
});
};
8 changes: 4 additions & 4 deletions packages/go/project.bri
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ interface GoBuildOptions {
goModule: std.AsyncRecipe<std.Directory>;
env?: Record<string, std.ProcessTemplateLike>;
buildParams?: GoBuildParameters;
packagePath?: string;
path?: string;
runnable?: string;
}

Expand All @@ -76,7 +76,7 @@ interface GoBuildOptions {
* - `trimpath`: Set the `-trimpath` flag.
* - `mod`: Set the `-mod` flag to one of `"readonly"`, `"vendor"`, or `"mod"`.
* - `env`: Optionally set environment variables for the build.
* - `packagePath`: Optionally set the package path to build (e.g. `./cmd/foo`).
* - `path`: Optionally set the package path to build (e.g. `./cmd/foo`).
* - `runnable`: Optionally set a path to the binary to run
* by default (e.g. `bin/foo`).
*
Expand All @@ -100,7 +100,7 @@ interface GoBuildOptions {
* "-w"
* ],
* },
* packagePath: "./cmd/hello",
* path: "./cmd/hello",
* runnable: "bin/hello",
* });
* };
Expand Down Expand Up @@ -142,7 +142,7 @@ export async function goInstall(
ldflags: ldflagsWrapper(options.buildParams?.ldflags ?? []),
trimpath: options.buildParams?.trimpath ?? false ? "true" : "false",
mod: options.buildParams?.mod ?? "",
package_path: options.packagePath ?? ".",
package_path: options.path ?? ".",
...options.env,
})
.toDirectory();
Expand Down
2 changes: 1 addition & 1 deletion packages/opentofu/project.bri
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const goModule = std
export default () => {
return goInstall({
goModule,
packagePath: "./cmd/tofu",
path: "./cmd/tofu",
buildParams: {
ldflags: ["-s", "-w", `-X github.com/opentofu/opentofu/version.dev=no`],
mod: "readonly",
Expand Down
6 changes: 6 additions & 0 deletions packages/rust/project.bri
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ export interface CargoBuildOptions {
path?: string;
runnable?: string;
dependencies?: std.AsyncRecipe<std.Directory>[];
env?: Record<string, std.ProcessTemplateLike>;
}

/**
Expand All @@ -131,6 +132,7 @@ export interface CargoBuildOptions {
* - `runnable`: Optionally set a path to the binary to run
* by default (e.g. `bin/foo`).
* - `dependencies`: Optionally add additional dependencies to the build.
* - `env`: Optionally set environment variables for the build.
*
* ## Example
*
Expand All @@ -143,6 +145,9 @@ export interface CargoBuildOptions {
* crate: Brioche.glob("src", "Cargo.*"),
* runnable: "bin/hello",
* dependencies: [openssl()],
* env: {
* CARGO_LOG: "debug",
* },
* });
* };
* ```
Expand Down Expand Up @@ -197,6 +202,7 @@ export function cargoBuild(options: CargoBuildOptions) {
CARGO_INSTALL_ROOT: std.outputPath,
PATH: std.tpl`${std.outputPath}/bin`,
crate_path: options.path ?? ".",
...options.env,
})
.workDir(crate)
.toDirectory();
Expand Down

0 comments on commit 63be501

Please sign in to comment.