Skip to content

Commit 3699f7f

Browse files
authored
Feature: eng 465 update all the codegens (#686)
* feat: initial commit of codegen rewrite * refactor: wrapper to loader * tests: update the unit tests * fix: don't unwrap return type * feat: setup tracing in loader codegen * fix: pass inn logger to loader * feat: mvp of shuttle-next local run * refactor: move logger to runtime * refactor: move storagemanager export to runtime
1 parent a93ba51 commit 3699f7f

File tree

13 files changed

+210
-323
lines changed

13 files changed

+210
-323
lines changed

Cargo.lock

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cargo-shuttle/src/lib.rs

Lines changed: 44 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,7 @@ impl Shuttle {
383383
"Building".bold().green(),
384384
working_directory.display()
385385
);
386+
386387
let runtime = build_crate(working_directory, false, tx).await?;
387388

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

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

406-
let (is_wasm, so_path) = match runtime {
407+
let (is_wasm, bin_path) = match runtime {
407408
Runtime::Next(path) => (true, path),
408409
Runtime::Legacy(path) => (false, path),
409410
};
@@ -414,52 +415,62 @@ impl Shuttle {
414415
run_args.port + 1,
415416
));
416417

417-
let get_runtime_executable = || {
418-
let runtime_path = home::cargo_home()
419-
.expect("failed to find cargo home dir")
420-
.join("bin/shuttle-runtime");
421-
422-
if cfg!(debug_assertions) {
423-
// Canonicalized path to shuttle-runtime for dev to work on windows
424-
let path = std::fs::canonicalize(format!("{MANIFEST_DIR}/../runtime"))
425-
.expect("path to shuttle-runtime does not exist or is invalid");
426-
427-
std::process::Command::new("cargo")
428-
.arg("install")
429-
.arg("shuttle-runtime")
430-
.arg("--path")
431-
.arg(path)
432-
.output()
433-
.expect("failed to install the shuttle runtime");
434-
} else {
435-
// If the version of cargo-shuttle is different from shuttle-runtime,
436-
// or it isn't installed, try to install shuttle-runtime from the production
437-
// branch.
438-
if let Err(err) = check_version(&runtime_path) {
439-
trace!("{}", err);
418+
let runtime_path = || {
419+
if is_wasm {
420+
let runtime_path = home::cargo_home()
421+
.expect("failed to find cargo home dir")
422+
.join("bin/shuttle-next");
423+
424+
if cfg!(debug_assertions) {
425+
// Canonicalized path to shuttle-runtime for dev to work on windows
426+
let path = std::fs::canonicalize(format!("{MANIFEST_DIR}/../runtime"))
427+
.expect("path to shuttle-runtime does not exist or is invalid");
440428

441-
trace!("installing shuttle-runtime");
429+
// TODO: Add --features next here when https://github.com/shuttle-hq/shuttle/pull/688 is merged
442430
std::process::Command::new("cargo")
443431
.arg("install")
444432
.arg("shuttle-runtime")
445-
.arg("--git")
446-
.arg("https://github.com/shuttle-hq/shuttle")
447-
.arg("--branch")
448-
.arg("production")
433+
.arg("--path")
434+
.arg(path)
435+
.arg("--bin")
436+
.arg("shuttle-next")
449437
.output()
450438
.expect("failed to install the shuttle runtime");
439+
} else {
440+
// If the version of cargo-shuttle is different from shuttle-runtime,
441+
// or it isn't installed, try to install shuttle-runtime from the production
442+
// branch.
443+
if let Err(err) = check_version(&runtime_path) {
444+
trace!("{}", err);
445+
446+
trace!("installing shuttle-runtime");
447+
// TODO: Add --features next here when https://github.com/shuttle-hq/shuttle/pull/688 is merged
448+
std::process::Command::new("cargo")
449+
.arg("install")
450+
.arg("shuttle-runtime")
451+
.arg("--bin")
452+
.arg("shuttle-next")
453+
.arg("--git")
454+
.arg("https://github.com/shuttle-hq/shuttle")
455+
.arg("--branch")
456+
.arg("production")
457+
.output()
458+
.expect("failed to install the shuttle runtime");
459+
};
451460
};
452-
};
453461

454-
runtime_path
462+
runtime_path
463+
} else {
464+
bin_path.clone()
465+
}
455466
};
456467

457468
let (mut runtime, mut runtime_client) = runtime::start(
458469
is_wasm,
459470
runtime::StorageManagerType::WorkingDir(working_directory.to_path_buf()),
460471
&format!("http://localhost:{}", run_args.port + 1),
461472
run_args.port + 2,
462-
get_runtime_executable,
473+
runtime_path,
463474
)
464475
.await
465476
.map_err(|err| {
@@ -469,7 +480,7 @@ impl Shuttle {
469480
})?;
470481

471482
let load_request = tonic::Request::new(LoadRequest {
472-
path: so_path
483+
path: bin_path
473484
.into_os_string()
474485
.into_string()
475486
.expect("to convert path to string"),

0 commit comments

Comments
 (0)