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

Feature: eng 465 update all the codegens #686

Merged
3 changes: 2 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

77 changes: 44 additions & 33 deletions cargo-shuttle/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,7 @@ impl Shuttle {
"Building".bold().green(),
working_directory.display()
);

let runtime = build_crate(working_directory, false, tx).await?;

trace!("loading secrets");
Expand All @@ -403,7 +404,7 @@ impl Shuttle {

let service_name = self.ctx.project_name().to_string();

let (is_wasm, so_path) = match runtime {
let (is_wasm, bin_path) = match runtime {
Runtime::Next(path) => (true, path),
Runtime::Legacy(path) => (false, path),
};
Expand All @@ -414,52 +415,62 @@ impl Shuttle {
run_args.port + 1,
));

let get_runtime_executable = || {
let runtime_path = home::cargo_home()
.expect("failed to find cargo home dir")
.join("bin/shuttle-runtime");

if cfg!(debug_assertions) {
// Canonicalized path to shuttle-runtime for dev to work on windows
let path = std::fs::canonicalize(format!("{MANIFEST_DIR}/../runtime"))
.expect("path to shuttle-runtime does not exist or is invalid");

std::process::Command::new("cargo")
.arg("install")
.arg("shuttle-runtime")
.arg("--path")
.arg(path)
.output()
.expect("failed to install the shuttle runtime");
} else {
// If the version of cargo-shuttle is different from shuttle-runtime,
// or it isn't installed, try to install shuttle-runtime from the production
// branch.
if let Err(err) = check_version(&runtime_path) {
trace!("{}", err);
let runtime_path = || {
if is_wasm {
let runtime_path = home::cargo_home()
.expect("failed to find cargo home dir")
.join("bin/shuttle-next");

if cfg!(debug_assertions) {
// Canonicalized path to shuttle-runtime for dev to work on windows
let path = std::fs::canonicalize(format!("{MANIFEST_DIR}/../runtime"))
.expect("path to shuttle-runtime does not exist or is invalid");

trace!("installing shuttle-runtime");
// TODO: Add --features next here when https://github.com/shuttle-hq/shuttle/pull/688 is merged
std::process::Command::new("cargo")
.arg("install")
.arg("shuttle-runtime")
.arg("--git")
.arg("https://github.com/shuttle-hq/shuttle")
.arg("--branch")
.arg("production")
.arg("--path")
.arg(path)
.arg("--bin")
.arg("shuttle-next")
.output()
.expect("failed to install the shuttle runtime");
} else {
// If the version of cargo-shuttle is different from shuttle-runtime,
// or it isn't installed, try to install shuttle-runtime from the production
// branch.
if let Err(err) = check_version(&runtime_path) {
trace!("{}", err);

trace!("installing shuttle-runtime");
// TODO: Add --features next here when https://github.com/shuttle-hq/shuttle/pull/688 is merged
std::process::Command::new("cargo")
.arg("install")
.arg("shuttle-runtime")
.arg("--bin")
.arg("shuttle-next")
.arg("--git")
.arg("https://github.com/shuttle-hq/shuttle")
.arg("--branch")
.arg("production")
.output()
.expect("failed to install the shuttle runtime");
};
};
};

runtime_path
runtime_path
} else {
bin_path.clone()
}
};

let (mut runtime, mut runtime_client) = runtime::start(
is_wasm,
runtime::StorageManagerType::WorkingDir(working_directory.to_path_buf()),
&format!("http://localhost:{}", run_args.port + 1),
run_args.port + 2,
get_runtime_executable,
runtime_path,
)
.await
.map_err(|err| {
Expand All @@ -469,7 +480,7 @@ impl Shuttle {
})?;

let load_request = tonic::Request::new(LoadRequest {
path: so_path
path: bin_path
.into_os_string()
.into_string()
.expect("to convert path to string"),
Expand Down
Loading