diff --git a/interactive_engine/executor/gaia_runtime/Cargo.toml b/interactive_engine/executor/gaia_runtime/Cargo.toml index 3f817bbf01ab..94347ef17656 100644 --- a/interactive_engine/executor/gaia_runtime/Cargo.toml +++ b/interactive_engine/executor/gaia_runtime/Cargo.toml @@ -24,7 +24,7 @@ log4rs = "0.8.0" maxgraph-common = { path = "../../rust-common" } maxgraph-store = { path = "../store" } maxgraph-server = { path = "../server" } -maxgraph-runtime = { path = "../runtime" } +maxgraph-runtime = { path = "../runtime", features = ["with_native"] } protobuf = { version = "~2.0", features = ["with-bytes"] } rand = "0.7.3" regex = "1" @@ -43,10 +43,11 @@ gaia_pegasus = { path = "../../../research/engine/pegasus/pegasus", package = "p pegasus_network = { path = "../../../research/engine/pegasus/network" } pegasus_server = { path = "../../../research/engine/pegasus/server" } runtime_integration = { path = "../../../research/query_service/ir/integrated" } -v6d_ffi = { path = "../../../research/query_service/ir/v6d_ffi" } +v6d_ffi = { path = "../../../research/query_service/ir/v6d_ffi", features = ["with_v6d"] } [dev-dependencies] env_logger = "0.6" [build-dependencies] cmake = "0.1" + diff --git a/interactive_engine/executor/runtime/Cargo.toml b/interactive_engine/executor/runtime/Cargo.toml index e23dfcc37602..e09a6d0e39f9 100644 --- a/interactive_engine/executor/runtime/Cargo.toml +++ b/interactive_engine/executor/runtime/Cargo.toml @@ -42,3 +42,7 @@ env_logger = "0.6" [build-dependencies] cmake = "0.1" + +[features] +default = [] +with_native = [] diff --git a/interactive_engine/executor/runtime/build.rs b/interactive_engine/executor/runtime/build.rs index 94b2f2798077..2b2e03eed348 100644 --- a/interactive_engine/executor/runtime/build.rs +++ b/interactive_engine/executor/runtime/build.rs @@ -1,12 +1,12 @@ // //! Copyright 2020 Alibaba Group Holding Limited. -//! +//! //! Licensed under the Apache License, Version 2.0 (the "License"); //! you may not use this file except in compliance with the License. //! You may obtain a copy of the License at -//! +//! //! http://www.apache.org/licenses/LICENSE-2.0 -//! +//! //! Unless required by applicable law or agreed to in writing, software //! distributed under the License is distributed on an "AS IS" BASIS, //! WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -15,14 +15,21 @@ extern crate cmake; +use std::env; use std::path::Path; + use cmake::Config; -use std::env; -fn main() { - let dst = Config::new("native") - .build_target("native_store") - .build(); +fn main() -> Result<(), Box> { + codegen_inplace() +} + +#[cfg(feature = "with_native")] +const NATIVE_DIR: &'static str = "native"; + +#[cfg(feature = "with_native")] +fn codegen_inplace() -> Result<(), Box> { + let dst = Config::new(NATIVE_DIR).build_target("native_store").build(); println!("cargo:rustc-link-search=/usr/local/lib"); println!("cargo:rustc-link-search=/usr/local/lib64"); @@ -32,7 +39,7 @@ fn main() { println!("cargo:rustc-link-search={}/lib", val); println!("cargo:rustc-link-search={}/lib64", val); } - Err(_) => () + Err(_) => (), } println!("cargo:rustc-link-search={}/build", dst.display()); println!("cargo:rustc-link-lib=native_store"); @@ -50,7 +57,15 @@ fn main() { if Path::new("/usr/ali/alicpp/built/gcc-4.9.2").exists() { println!("cargo:cfg=tunnel"); } - } else if cfg!(target_os = "macos") {} else { + } else if cfg!(target_os = "macos") { + } else { unimplemented!() } + + Ok(()) +} + +#[cfg(not(feature = "with_native"))] +fn codegen_inplace() -> Result<(), Box> { + Ok(()) } diff --git a/research/query_service/ir/integrated/build.rs b/research/query_service/ir/integrated/build.rs new file mode 100644 index 000000000000..64b94e9c354a --- /dev/null +++ b/research/query_service/ir/integrated/build.rs @@ -0,0 +1,26 @@ +// +//! Copyright 2020-2022 Alibaba Group Holding Limited. +//! +//! Licensed under the Apache License, Version 2.0 (the "License"); +//! you may not use this file except in compliance with the License. +//! You may obtain a copy of the License at +//! +//! http://www.apache.org/licenses/LICENSE-2.0 +//! +//! Unless required by applicable law or agreed to in writing, software +//! distributed under the License is distributed on an "AS IS" BASIS, +//! WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +//! See the License for the specific language governing permissions and +//! limitations under the License. + +fn main() -> Result<(), Box> { + if cfg!(target_os = "linux") { + println!("cargo:rustc-link-arg=-Wl,--unresolved-symbols=ignore-all"); + } else if cfg!(target_os = "macos") { + println!("cargo:rustc-link-arg=-Wl,-undefined"); + println!("cargo:rustc-link-arg=-Wl,dynamic_lookup"); + } else { + unimplemented!() + } + Ok(()) +} diff --git a/research/query_service/ir/v6d_ffi/Cargo.toml b/research/query_service/ir/v6d_ffi/Cargo.toml index 5ba127fbdca2..7f022afc9d74 100644 --- a/research/query_service/ir/v6d_ffi/Cargo.toml +++ b/research/query_service/ir/v6d_ffi/Cargo.toml @@ -17,3 +17,7 @@ maxgraph-runtime = {path = "../../../../interactive_engine/executor/runtime"} [build-dependencies] cmake = "0.1" + +[features] +default = [] +with_v6d = [] diff --git a/research/query_service/ir/v6d_ffi/build.rs b/research/query_service/ir/v6d_ffi/build.rs index 39df053f728b..19507bcea219 100644 --- a/research/query_service/ir/v6d_ffi/build.rs +++ b/research/query_service/ir/v6d_ffi/build.rs @@ -20,8 +20,16 @@ use std::path::Path; use cmake::Config; -fn main() { - let dst = Config::new("src/native") +fn main() -> Result<(), Box> { + codegen_inplace() +} + +#[cfg(feature = "with_v6d")] +const NATIVE_DIR: &'static str = "src/native"; + +#[cfg(feature = "with_v6d")] +fn codegen_inplace() -> Result<(), Box> { + let dst = Config::new(NATIVE_DIR) .build_target("v6d_native_store") .build(); @@ -55,4 +63,11 @@ fn main() { } else { unimplemented!() } + + Ok(()) +} + +#[cfg(not(feature = "with_v6d"))] +fn codegen_inplace() -> Result<(), Box> { + Ok(()) }