Skip to content

Commit

Permalink
Fix nightly ci by specify different flags for debug and release build…
Browse files Browse the repository at this point in the history
…s. (#93)

* Fix nightly ci by specify different flags for debug and release builds.

* Fix build failure

(cherry picked from commit fff163c)
  • Loading branch information
MeirShpilraien committed Jan 16, 2024
1 parent 20fb7f5 commit 7520d3e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
13 changes: 11 additions & 2 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,10 @@ lazy_static::lazy_static! {
static ref V8_FORCE_MONOLITH_DOWNLOAD: bool = env::var("V8_FORCE_DOWNLOAD_V8_MONOLITH").map(|v| v == "yes").unwrap_or(false);
}

fn run_cmd(cmd: &str, args: &[&str]) {
fn run_cmd_with_env(cmd: &str, args: &[&str], env: &[(&str, &str)]) {
let failure_message = format!("Failed running command: {} {}", cmd, args.join(" "));
if !Command::new(cmd)
.envs(env.iter().map(|v| v.clone()))
.args(args)
.status()
.expect(&failure_message)
Expand All @@ -51,6 +52,10 @@ fn run_cmd(cmd: &str, args: &[&str]) {
}
}

fn run_cmd(cmd: &str, args: &[&str]) {
run_cmd_with_env(cmd, args, &[])
}

fn main() {
println!("cargo:rerun-if-changed=v8_c_api/src/v8_c_api.h");
println!("cargo:rerun-if-changed=v8_c_api/src/v8_c_api.cpp");
Expand All @@ -69,7 +74,11 @@ fn main() {
run_cmd("unzip", &[&V8_HEADERS_PATH, "-d", *V8_HEADERS_DIRECTORY]);
}

run_cmd("make", &["-C", "v8_c_api/"]);
if PROFILE.as_str() == "debug" {
run_cmd_with_env("make", &["-C", "v8_c_api/"], &[("DEBUG", "1")]);
} else {
run_cmd("make", &["-C", "v8_c_api/"]);
}

let output_dir = env::var("OUT_DIR").expect("Can not find out directory");

Expand Down
11 changes: 9 additions & 2 deletions v8_c_api/src/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
GCC_FLAGS=-std=c++17 -DV8_COMPRESS_POINTERS -DV8_ENABLE_SANDBOX
ifeq ($(DEBUG),1)
GCC_FLAGS+=-O0 -DV8_ENABLE_CHECKS
else
GCC_FLAGS+=-O2
endif

build:
g++ -I./v8include -fPIC -c -o2 -g v8_c_api.cpp -o c8_c_api.o -std=c++17 -DV8_COMPRESS_POINTERS -DV8_ENABLE_SANDBOX
g++ -I./v8include -fPIC -c -g v8_c_api.cpp -o c8_c_api.o $(GCC_FLAGS)
ar r libv8.a c8_c_api.o

clean:
rm -rf *.o *.a
rm -rf *.o *.a

0 comments on commit 7520d3e

Please sign in to comment.