Skip to content

Commit

Permalink
add build preset / bundle configurations for wallaby and devnet-wasm.
Browse files Browse the repository at this point in the history
QoL finishing touches:
- The 1:N network/features mapping in runtime/build.rs wasn't cutting it any longer.
  I expanded this data structure to M:N.
- Added docs to runtime/build.rs.
  • Loading branch information
raulk committed Jul 28, 2022
1 parent fea998e commit 80411ce
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
CACHE_SKIP_SAVE: ${{ matrix.push == '' || matrix.push == 'false' }}
strategy:
matrix:
network: [ 'mainnet', 'caterpillarnet', 'butterflynet', 'calibrationnet', 'devnet', 'testing', 'testing-fake-proofs' ]
network: [ 'mainnet', 'caterpillarnet', 'butterflynet', 'calibrationnet', 'devnet', 'testing', 'testing-fake-proofs', 'wallaby', 'devnet-wasm' ]
steps:
- name: Checking out
uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ target
*.wasm
.idea/
**/.DS_Store
output/builtin-actors.car
output/*.car
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,11 @@ bundle-calibrationnet: deps-build
bundle-devnet: deps-build
BUILD_FIL_NETWORK=devnet cargo run -- -o output/builtin-actors-devnet.car

bundle-devnet-m2-native: deps-build
BUILD_FIL_NETWORK=devnet-m2-native cargo run -- -o output/builtin-actors-devnet-m2-native.car
bundle-wallaby: deps-build
BUILD_FIL_NETWORK=wallaby cargo run -- -o output/builtin-actors-wallaby.car

bundle-devnet-wasm: deps-build
BUILD_FIL_NETWORK=devnet-wasm cargo run -- -o output/builtin-actors-devnet-wasm.car

bundle-testing: deps-build
BUILD_FIL_NETWORK=testing cargo run -- -o output/builtin-actors-testing.car
Expand Down
4 changes: 2 additions & 2 deletions actors/init/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ keywords = ["filecoin", "web3", "wasm"]
crate-type = ["cdylib", "lib"]

[dependencies]
fil_actors_runtime = { version = "9.0.0-alpha.1", path = "../../runtime", features = ["fil-actor"] }
fil_actors_runtime = { version = "9.0.0-alpha.1", path = "../../runtime" }
fvm_shared = { version = "0.8.0", default-features = false }
fvm_ipld_hamt = "0.5.1"
serde = { version = "1.0.136", features = ["derive"] }
Expand All @@ -30,5 +30,5 @@ fvm_ipld_encoding = "0.2.2"
fil_actors_runtime = { version = "9.0.0-alpha.1", path = "../../runtime", features = ["test_utils", "sector-default"] }

[features]
fil-actor = []
fil-actor = ["fil_actors_runtime/fil-actor"]
m2-native = ["fil_actors_runtime/m2-native"]
8 changes: 6 additions & 2 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ const DEFAULT_CARGO_FEATURES: &[&str] = &["fil-actor"];

/// Extra Cargo-level features to enable per network.
const EXTRA_CARGO_FEATURES: &[(&str, &[&str])] = &[
("devnet-wasm", &["m2-native"]),
/*("devnet-evm", &["m2-fevm"]),*/
("wallaby", &["m2-native"]),
];

Expand All @@ -51,8 +53,10 @@ fn network_name() -> String {
Some("calibrationnet")
} else if cfg!(feature = "devnet") {
Some("devnet")
} else if cfg!(feature = "devnet-m2-native") {
Some("devnet-m2-native")
} else if cfg!(feature = "devnet-wasm") {
Some("devnet-wasm")
}else if cfg!(feature = "wallaby") {
Some("wallaby")
} else if cfg!(feature = "testing") {
Some("testing")
} else if cfg!(feature = "testing-fake-proofs") {
Expand Down
32 changes: 19 additions & 13 deletions runtime/build.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
static NETWORKS: &[(&str, &[&str])] = &[
("mainnet", &["sector-32g", "sector-64g"]),
static NETWORKS: &[(&[&str], &[&str])] = &[
(&["mainnet"], &["sector-32g", "sector-64g"]),
(
"caterpillarnet",
&["caterpillarnet"],
&[
"sector-512m",
"sector-32g",
Expand All @@ -11,15 +11,11 @@ static NETWORKS: &[(&str, &[&str])] = &[
"min-power-2k",
],
),
("butterflynet", &["sector-512m", "sector-32g", "sector-64g", "min-power-2g"]),
("calibrationnet", &["sector-32g", "sector-64g", "min-power-32g"]),
("devnet", &["sector-2k", "sector-8m", "small-deals", "short-precommit", "min-power-2k"]),
(&["butterflynet", "wallaby"], &["sector-512m", "sector-32g", "sector-64g", "min-power-2g"]),
(&["calibrationnet"], &["sector-32g", "sector-64g", "min-power-32g"]),
(&["devnet", "devnet-wasm", /*devnet-fevm*/], &["sector-2k", "sector-8m", "small-deals", "short-precommit", "min-power-2k"]),
(
"devnet-m2-native",
&["sector-2k", "sector-8m", "small-deals", "short-precommit", "min-power-2k", "m2-native"],
),
(
"testing",
&["testing"],
&[
"sector-2k",
"sector-8m",
Expand All @@ -33,7 +29,7 @@ static NETWORKS: &[(&str, &[&str])] = &[
],
),
(
"testing-fake-proofs",
&["testing-fake-proofs"],
&[
"sector-2k",
"sector-8m",
Expand All @@ -50,12 +46,22 @@ static NETWORKS: &[(&str, &[&str])] = &[
];
const NETWORK_ENV: &str = "BUILD_FIL_NETWORK";

/// This build script enables _local_ compile features. These features do not
/// affect the dependency graph (they are not processed by Cargo). They are only
/// in effect for conditional compilation _in this crate_.
///
/// The reason we can't set these features as Cargo features from the root build
/// is that this crate is only ever used as a _transitive_ dependency from actor
/// crates.
///
/// So the only two options are: (a) actors crates set the features when
/// importing us as a dependency (super repetitive), or (b) this.
fn main() {
let network = std::env::var(NETWORK_ENV).ok();
println!("cargo:rerun-if-env-changed={}", NETWORK_ENV);

let network = network.as_deref().unwrap_or("mainnet");
let features = NETWORKS.iter().find(|(k, _)| k == &network).expect("unknown network").1;
let features = NETWORKS.iter().find(|(k, _)| k.contains(&network)).expect("unknown network").1;
for feature in features {
println!("cargo:rustc-cfg=feature=\"{}\"", feature);
}
Expand Down

0 comments on commit 80411ce

Please sign in to comment.