Skip to content

Commit

Permalink
Build dependency (#78)
Browse files Browse the repository at this point in the history
* Added build placeholder replace.
* Enabled tests on development version of Odra
  • Loading branch information
kubaplas authored Feb 27, 2024
1 parent 99c4d7e commit d47387e
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 26 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci-cargo-odra.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
- run: just prepare
- run: just check-lint
- run: just install
# - run: just test-project-generation-on-future-odra
# - run: just test-workspace-generation-on-future-odra
- run: just test-project-generation-on-future-odra
- run: just test-workspace-generation-on-future-odra
- run: just test-project-generation-on-stable-odra
- run: just test-workspace-generation-on-stable-odra
2 changes: 1 addition & 1 deletion justfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
DEVELOPMENT_ODRA_BRANCH := "release/0.8.0"
DEVELOPMENT_ODRA_BRANCH := "release/0.9.0"
BINARYEN_VERSION := "version_116"
BINARYEN_CHECKSUM := "c55b74f3109cdae97490faf089b0286d3bba926bb6ea5ed00c8c784fc53718fd"

Expand Down
60 changes: 37 additions & 23 deletions src/actions/init.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Module responsible for initializing an Odra project.
use std::path::PathBuf;
use std::path::{Path, PathBuf};

use cargo_generate::{GenerateArgs, TemplatePath, Vcs};
use cargo_toml::{Dependency, DependencyDetail};
Expand Down Expand Up @@ -104,31 +104,48 @@ impl InitAction {
}
};

replace_in_file(
cargo_toml_path.clone(),
Self::replace_package_placeholder(
init,
&odra_location,
&cargo_toml_path,
"#odra_dependency",
format!(
"odra = {{ {} }}",
toml::to_string(&Self::odra_project_dependency(
odra_location.clone(),
"odra",
init
))
.unwrap()
.trim_end()
.replace('\n', ", ")
)
.as_str(),
"odra",
);
Self::replace_package_placeholder(
init,
&odra_location,
&cargo_toml_path,
"#odra_test_dependency",
"odra-test",
);
Self::replace_package_placeholder(
init,
&odra_location,
&cargo_toml_path,
"#odra_build_dependency",
"odra-build",
);

rename_file(cargo_toml_path, "Cargo.toml");
log::info("Done!");
}

fn replace_package_placeholder(
init: bool,
odra_location: &OdraLocation,
cargo_toml_path: &Path,
placeholder: &str,
crate_name: &str,
) {
replace_in_file(
cargo_toml_path.clone(),
"#odra_test_dependency",
cargo_toml_path.to_path_buf(),
placeholder,
format!(
"odra-test = {{ {} }}",
"{} = {{ {} }}",
crate_name,
toml::to_string(&Self::odra_project_dependency(
odra_location,
"odra-test",
odra_location.clone(),
crate_name,
init
))
.unwrap()
Expand All @@ -137,9 +154,6 @@ impl InitAction {
)
.as_str(),
);

rename_file(cargo_toml_path, "Cargo.toml");
log::info("Done!");
}
fn assert_dir_is_empty(dir: PathBuf) {
if dir.read_dir().unwrap().next().is_some() {
Expand Down

0 comments on commit d47387e

Please sign in to comment.