Skip to content

Commit

Permalink
refactor: build on LC_PROGRAM_AUTOBUILD=1
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Chataigner <[email protected]>
  • Loading branch information
tchataigner committed Jun 24, 2024
1 parent 7f213e4 commit e145300
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion aptos/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ generated in two ways:

- Automated: There is a build script located at `./aptos-programs/build.rs` that
will compile all the programs and place them in the `./aptos-programs/artifacts`
folder.
folder. To enable this feature, it is needed to set the environment variable `LC_PROGRAM_AUTOBUILD=1`.
- Manual: You can also compile the programs manually using `make` by running the following
command in the `./aptos-programs` folder:
```shell
Expand Down
8 changes: 8 additions & 0 deletions aptos/aptos-programs/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ const PROGRAM_PATTERNS: [&str; 2] = ["../programs/*", "../programs/benchmarks/*"
const TARGET_DIR: [&str; 2] = ["./artifacts", "./artifacts/benchmarks"];

fn main() {
// Get `LC_PROGRAM_AUTOBUILD` env variable, default to 0
let should_build: bool =
std::env::var("LC_PROGRAM_AUTOBUILD").unwrap_or_else(|_| "0".into()) == "1";

if !should_build {
return;
}

// Re-run if the core library changes
let core_dir = std::path::Path::new("../core");
println!("cargo:rerun-if-changed={}", core_dir.display());
Expand Down

0 comments on commit e145300

Please sign in to comment.