Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run cargo update before attempting to build Rust compute packages #179

Merged
merged 1 commit into from
Dec 17, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions pkg/compute/rust.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,18 @@ func (r Rust) Initialize(out io.Writer) error { return nil }
// Build implements the Toolchain interface and attempts to compile the package
// Rust source to a Wasm binary.
func (r Rust) Build(out io.Writer, verbose bool) error {
args := []string{"update"}
if verbose {
args = append(args, "--verbose")
}
// Execute `cargo update` command, to ensure we are using latest version
// of fastly-sys transient dependency and avoid misleading/confusing
// compiler error messages.
cmd := common.NewStreamingExec("cargo", args, os.Environ(), verbose, out)
if err := cmd.Exec(); err != nil {
return err
}

// Get binary name from Cargo.toml.
var m CargoManifest
if err := m.Read("Cargo.toml"); err != nil {
Expand All @@ -276,7 +288,7 @@ func (r Rust) Build(out io.Writer, verbose bool) error {
// Specify the toolchain using the `cargo +<version>` syntax.
toolchain := fmt.Sprintf("+%s", RustToolchainVersion)

args := []string{
args = []string{
toolchain,
"build",
"--bin",
Expand All @@ -296,7 +308,7 @@ func (r Rust) Build(out io.Writer, verbose bool) error {

// Execute the `cargo build` commands with the Wasm WASI target, release
// flags and env vars.
cmd := common.NewStreamingExec("cargo", args, env, verbose, out)
cmd = common.NewStreamingExec("cargo", args, env, verbose, out)
if err := cmd.Exec(); err != nil {
return err
}
Expand Down