Open EMCP opened 5 months ago
I had to hard-code the include path
let include_path = "/home/emcp/.conan/data/twsapi/10.25.01/stonks/prod/package/2a448472971d7718b4207a1ee198ae4f78f2995d/include";
from my conan-rs installed library.. but is there a better more elegant way to get this wired together with CXX?
use std::path::{Path, PathBuf}; use cxx_build::CFG; use conan::*; fn main() { // requires : sudo apt install libintelrdfpmath-dev println!("cargo:rustc-link-lib=bidgcc000"); let default_conan_profile = "default"; let command: InstallCommand = InstallCommandBuilder::new() .with_profile(&default_conan_profile) .build_policy(BuildPolicy::Missing) .recipe_path(Path::new("conanfile.txt")) .build(); if let Some(build_info) = command.generate() { println!("using conan build info"); build_info.cargo_emit(); let twsapi:&BuildDependency = build_info.get_dependency("twsapi").unwrap(); let twsapi_inc_dir:Vec<&str> = twsapi.get_include_dirs(); for dir in &twsapi_inc_dir { let twsapi_inc_dir_path = Path::new(dir); // Add TWSAPI Conan Pkg to Includes CFG.exported_header_dirs.extend([twsapi_inc_dir_path]); } } let build_command = BuildCommandBuilder::new() .with_recipe_path(PathBuf::from("../../../conanfile.py")) .with_build_path(PathBuf::from("../../../build/")) .build(); if let Some(exit_status) = build_command.run() { println!("conan build exited with {}", exit_status); } let include_path = "/home/emcp/.conan/data/twsapi/10.25.01/stonks/prod/package/2a448472971d7718b4207a1ee198ae4f78f2995d/include"; cxx_build::bridge("src/main.rs") .file("src/gettingstarted.cc") .include(include_path) .flag_if_supported("-std=c++17") .compile("twsapi_helloworld"); println!("cargo:rerun-if-changed=src/main.rs"); println!("cargo:rerun-if-changed=src/gettingstarted.cc"); println!("cargo:rerun-if-changed=include/gettingstarted.h"); }
I had to hard-code the include path
from my conan-rs installed library.. but is there a better more elegant way to get this wired together with CXX?
build.rs