| @@ -321,7 +321,7 @@ jobs: | |||
| if: runner.os == 'Linux' | |||
| run: | | |||
| # Test C template Project | |||
| dora new test_c_project --lang c | |||
| dora new test_c_project --lang c --internal-create-with-path-dependencies | |||
| cd test_c_project | |||
| dora up | |||
| dora list | |||
| @@ -340,7 +340,7 @@ jobs: | |||
| if: runner.os == 'Linux' | |||
| run: | | |||
| # Test C++ template Project | |||
| dora new test_cxx_project --lang c++ | |||
| dora new test_cxx_project --lang cxx --internal-create-with-path-dependencies | |||
| cd test_cxx_project | |||
| dora up | |||
| dora list | |||
| @@ -4,34 +4,60 @@ project(cxx-dataflow LANGUAGES C) | |||
| set(CMAKE_CXX_STANDARD 17) | |||
| set(CMAKE_CXX_FLAGS "-fPIC") | |||
| set(DORA_ROOT_DIR "__DORA_PATH__" CACHE FILEPATH "Path to the root of dora") | |||
| set(dora_c_include_dir "${CMAKE_CURRENT_BINARY_DIR}/include/c") | |||
| if(DORA_ROOT_DIR) | |||
| include(ExternalProject) | |||
| ExternalProject_Add(Dora | |||
| SOURCE_DIR ${DORA_ROOT_DIR} | |||
| BUILD_IN_SOURCE True | |||
| CONFIGURE_COMMAND "" | |||
| BUILD_COMMAND | |||
| cargo build | |||
| --package dora-node-api-c | |||
| INSTALL_COMMAND "" | |||
| ) | |||
| add_custom_command(OUTPUT ${dora_c_include_dir} | |||
| WORKING_DIRECTORY ${DORA_ROOT_DIR} | |||
| DEPENDS Dora | |||
| COMMAND | |||
| mkdir ${CMAKE_CURRENT_BINARY_DIR}/include/c -p | |||
| && | |||
| cp apis/c/node ${CMAKE_CURRENT_BINARY_DIR}/include/c -r | |||
| ) | |||
| add_custom_target(Dora_c DEPENDS ${dora_c_include_dir}) | |||
| set(dora_link_dirs ${DORA_ROOT_DIR}/target/debug) | |||
| else() | |||
| include(ExternalProject) | |||
| ExternalProject_Add(Dora | |||
| PREFIX ${CMAKE_CURRENT_BINARY_DIR}/dora | |||
| GIT_REPOSITORY https://github.com/dora-rs/dora.git | |||
| GIT_TAG main | |||
| BUILD_IN_SOURCE True | |||
| CONFIGURE_COMMAND "" | |||
| BUILD_COMMAND | |||
| cargo build | |||
| --package dora-node-api-c | |||
| --target-dir ${CMAKE_CURRENT_BINARY_DIR}/dora/src/Dora/target | |||
| INSTALL_COMMAND "" | |||
| ) | |||
| add_custom_command(OUTPUT ${dora_c_include_dir} | |||
| WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/dora/src/Dora/target | |||
| DEPENDS Dora | |||
| COMMAND | |||
| mkdir ${CMAKE_CURRENT_BINARY_DIR}/include/c -p | |||
| && | |||
| cp ../apis/c/node ${CMAKE_CURRENT_BINARY_DIR}/include/c -r | |||
| ) | |||
| set(dora_link_dirs ${CMAKE_CURRENT_BINARY_DIR}/dora/src/Dora/target/debug) | |||
| include(ExternalProject) | |||
| ExternalProject_Add(Dora | |||
| PREFIX ${CMAKE_CURRENT_BINARY_DIR}/dora | |||
| GIT_REPOSITORY https://github.com/dora-rs/dora.git | |||
| GIT_TAG main | |||
| BUILD_IN_SOURCE True | |||
| CONFIGURE_COMMAND "" | |||
| BUILD_COMMAND | |||
| cargo build | |||
| --package dora-node-api-c | |||
| --target-dir ${CMAKE_CURRENT_BINARY_DIR}/dora/src/Dora/target | |||
| INSTALL_COMMAND "" | |||
| ) | |||
| add_custom_command(OUTPUT ${dora_c_include_dir} | |||
| WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/dora/src/Dora/target | |||
| DEPENDS Dora | |||
| COMMAND | |||
| mkdir ${CMAKE_CURRENT_BINARY_DIR}/include/c -p | |||
| && | |||
| cp ../apis/c/node ${CMAKE_CURRENT_BINARY_DIR}/include/c -r | |||
| ) | |||
| set(dora_link_dirs ${CMAKE_CURRENT_BINARY_DIR}/dora/src/Dora/target/debug) | |||
| add_custom_target(Dora_c DEPENDS ${dora_c_include_dir}) | |||
| add_custom_target(Dora_c DEPENDS ${dora_c_include_dir}) | |||
| endif() | |||
| link_directories(${dora_link_dirs}) | |||
| @@ -10,7 +10,7 @@ const NODE: &str = include_str!("node/node-template.c"); | |||
| const TALKER: &str = include_str!("talker/talker-template.c"); | |||
| const LISTENER: &str = include_str!("listener/listener-template.c"); | |||
| pub fn create(args: crate::CommandNew) -> eyre::Result<()> { | |||
| pub fn create(args: crate::CommandNew, use_path_deps: bool) -> eyre::Result<()> { | |||
| let crate::CommandNew { | |||
| kind, | |||
| lang: _, | |||
| @@ -23,11 +23,15 @@ pub fn create(args: crate::CommandNew) -> eyre::Result<()> { | |||
| bail!("Operators are going to be depreciated, please don't use it") | |||
| } | |||
| crate::Kind::CustomNode => create_custom_node(name, path, NODE), | |||
| crate::Kind::Dataflow => create_dataflow(name, path), | |||
| crate::Kind::Dataflow => create_dataflow(name, path, use_path_deps), | |||
| } | |||
| } | |||
| fn create_dataflow(name: String, path: Option<PathBuf>) -> Result<(), eyre::ErrReport> { | |||
| fn create_dataflow( | |||
| name: String, | |||
| path: Option<PathBuf>, | |||
| use_path_deps: bool, | |||
| ) -> Result<(), eyre::ErrReport> { | |||
| const DATAFLOW_YML: &str = include_str!("dataflow-template.yml"); | |||
| if name.contains('/') { | |||
| @@ -50,7 +54,7 @@ fn create_dataflow(name: String, path: Option<PathBuf>) -> Result<(), eyre::ErrR | |||
| create_custom_node("talker_1".into(), Some(root.join("talker_1")), TALKER)?; | |||
| create_custom_node("talker_2".into(), Some(root.join("talker_2")), TALKER)?; | |||
| create_custom_node("listener_1".into(), Some(root.join("listener_1")), LISTENER)?; | |||
| create_cmakefile(root.to_path_buf())?; | |||
| create_cmakefile(root.to_path_buf(), use_path_deps)?; | |||
| println!( | |||
| "Created new C dataflow at `{name}` at {}", | |||
| @@ -100,11 +104,19 @@ fn create_operator(name: String, path: Option<PathBuf>) -> Result<(), eyre::ErrR | |||
| Ok(()) | |||
| } | |||
| fn create_cmakefile(root: PathBuf) -> Result<(), eyre::ErrReport> { | |||
| fn create_cmakefile(root: PathBuf, use_path_deps: bool) -> Result<(), eyre::ErrReport> { | |||
| const CMAKEFILE: &str = include_str!("cmake-template.txt"); | |||
| let cmake_file = if use_path_deps { | |||
| let manifest_dir = Path::new(env!("CARGO_MANIFEST_DIR")); | |||
| let workspace_dir = manifest_dir.parent().unwrap().parent().unwrap(); | |||
| CMAKEFILE.replace("__DORA_PATH__", workspace_dir.to_str().unwrap()) | |||
| } else { | |||
| CMAKEFILE.replace("__DORA_PATH__", "") | |||
| }; | |||
| let cmake_path = root.join("CMakeLists.txt"); | |||
| fs::write(&cmake_path, CMAKEFILE) | |||
| fs::write(&cmake_path, cmake_file) | |||
| .with_context(|| format!("failed to write `{}`", cmake_path.display()))?; | |||
| println!("Created new CMakeLists.txt at {}", cmake_path.display()); | |||
| @@ -4,37 +4,66 @@ project(cxx-dataflow LANGUAGES CXX) | |||
| set(CMAKE_CXX_STANDARD 17) | |||
| set(CMAKE_CXX_FLAGS "-fPIC") | |||
| set(DORA_ROOT_DIR "__DORA_PATH__" CACHE FILEPATH "Path to the root of dora") | |||
| set(dora_cxx_include_dir "${CMAKE_CURRENT_BINARY_DIR}/include/cxx") | |||
| set(node_bridge "${CMAKE_CURRENT_BINARY_DIR}/node_bridge.cc") | |||
| include(ExternalProject) | |||
| ExternalProject_Add(Dora | |||
| PREFIX ${CMAKE_CURRENT_BINARY_DIR}/dora | |||
| GIT_REPOSITORY https://github.com/dora-rs/dora.git | |||
| GIT_TAG main | |||
| BUILD_IN_SOURCE True | |||
| CONFIGURE_COMMAND "" | |||
| BUILD_COMMAND | |||
| cargo build | |||
| --package dora-node-api-cxx | |||
| --target-dir ${CMAKE_CURRENT_BINARY_DIR}/dora/src/Dora/target | |||
| INSTALL_COMMAND "" | |||
| ) | |||
| add_custom_command(OUTPUT ${node_bridge} ${dora_cxx_include_dir} | |||
| WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/dora/src/Dora/target | |||
| DEPENDS Dora | |||
| COMMAND | |||
| mkdir ${dora_cxx_include_dir} -p | |||
| && | |||
| cp cxxbridge/dora-node-api-cxx/src/lib.rs.cc ${node_bridge} | |||
| && | |||
| cp cxxbridge/dora-node-api-cxx/src/lib.rs.h ${dora_cxx_include_dir}/dora-node-api.h | |||
| ) | |||
| set(dora_link_dirs ${CMAKE_CURRENT_BINARY_DIR}/dora/src/Dora/target/debug) | |||
| add_custom_target(Dora_cxx DEPENDS ${node_bridge} ${dora_cxx_include_dir}) | |||
| if(DORA_ROOT_DIR) | |||
| include(ExternalProject) | |||
| ExternalProject_Add(Dora | |||
| SOURCE_DIR ${DORA_ROOT_DIR} | |||
| BUILD_IN_SOURCE True | |||
| CONFIGURE_COMMAND "" | |||
| BUILD_COMMAND | |||
| cargo build | |||
| --package dora-node-api-cxx | |||
| INSTALL_COMMAND "" | |||
| ) | |||
| add_custom_command(OUTPUT ${node_bridge} ${dora_cxx_include_dir} ${operator_bridge} ${dora_c_include_dir} | |||
| WORKING_DIRECTORY ${DORA_ROOT_DIR} | |||
| DEPENDS Dora | |||
| COMMAND | |||
| mkdir ${dora_cxx_include_dir} -p | |||
| && | |||
| cp target/cxxbridge/dora-node-api-cxx/src/lib.rs.cc ${node_bridge} | |||
| && | |||
| cp target/cxxbridge/dora-node-api-cxx/src/lib.rs.h ${dora_cxx_include_dir}/dora-node-api.h | |||
| ) | |||
| add_custom_target(Dora_cxx DEPENDS ${node_bridge} ${dora_cxx_include_dir}) | |||
| set(dora_link_dirs ${DORA_ROOT_DIR}/target/debug) | |||
| else() | |||
| include(ExternalProject) | |||
| ExternalProject_Add(Dora | |||
| PREFIX ${CMAKE_CURRENT_BINARY_DIR}/dora | |||
| GIT_REPOSITORY https://github.com/dora-rs/dora.git | |||
| GIT_TAG main | |||
| BUILD_IN_SOURCE True | |||
| CONFIGURE_COMMAND "" | |||
| BUILD_COMMAND | |||
| cargo build | |||
| --package dora-node-api-cxx | |||
| --target-dir ${CMAKE_CURRENT_BINARY_DIR}/dora/src/Dora/target | |||
| INSTALL_COMMAND "" | |||
| ) | |||
| add_custom_command(OUTPUT ${node_bridge} ${dora_cxx_include_dir} | |||
| WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/dora/src/Dora/target | |||
| DEPENDS Dora | |||
| COMMAND | |||
| mkdir ${dora_cxx_include_dir} -p | |||
| && | |||
| cp cxxbridge/dora-node-api-cxx/src/lib.rs.cc ${node_bridge} | |||
| && | |||
| cp cxxbridge/dora-node-api-cxx/src/lib.rs.h ${dora_cxx_include_dir}/dora-node-api.h | |||
| ) | |||
| set(dora_link_dirs ${CMAKE_CURRENT_BINARY_DIR}/dora/src/Dora/target/debug) | |||
| add_custom_target(Dora_cxx DEPENDS ${node_bridge} ${dora_cxx_include_dir}) | |||
| endif() | |||
| link_directories(${dora_link_dirs}) | |||
| @@ -8,7 +8,7 @@ const NODE: &str = include_str!("node-template.cc"); | |||
| const TALKER: &str = include_str!("talker-template.cc"); | |||
| const LISTENER: &str = include_str!("listener-template.cc"); | |||
| pub fn create(args: crate::CommandNew) -> eyre::Result<()> { | |||
| pub fn create(args: crate::CommandNew, use_path_deps: bool) -> eyre::Result<()> { | |||
| let crate::CommandNew { | |||
| kind, | |||
| lang: _, | |||
| @@ -21,11 +21,15 @@ pub fn create(args: crate::CommandNew) -> eyre::Result<()> { | |||
| bail!("Operators are going to be depreciated, please don't use it") | |||
| } | |||
| crate::Kind::CustomNode => create_custom_node(name, path, NODE), | |||
| crate::Kind::Dataflow => create_dataflow(name, path), | |||
| crate::Kind::Dataflow => create_dataflow(name, path, use_path_deps), | |||
| } | |||
| } | |||
| fn create_dataflow(name: String, path: Option<PathBuf>) -> Result<(), eyre::ErrReport> { | |||
| fn create_dataflow( | |||
| name: String, | |||
| path: Option<PathBuf>, | |||
| use_path_deps: bool, | |||
| ) -> Result<(), eyre::ErrReport> { | |||
| const DATAFLOW_YML: &str = include_str!("dataflow-template.yml"); | |||
| if name.contains('/') { | |||
| @@ -48,7 +52,7 @@ fn create_dataflow(name: String, path: Option<PathBuf>) -> Result<(), eyre::ErrR | |||
| create_custom_node("talker_1".into(), Some(root.join("talker_1")), TALKER)?; | |||
| create_custom_node("talker_2".into(), Some(root.join("talker_2")), TALKER)?; | |||
| create_custom_node("listener_1".into(), Some(root.join("listener_1")), LISTENER)?; | |||
| create_cmakefile(root.to_path_buf())?; | |||
| create_cmakefile(root.to_path_buf(), use_path_deps)?; | |||
| println!( | |||
| "Created new C++ dataflow at `{name}` at {}", | |||
| @@ -58,11 +62,19 @@ fn create_dataflow(name: String, path: Option<PathBuf>) -> Result<(), eyre::ErrR | |||
| Ok(()) | |||
| } | |||
| fn create_cmakefile(root: PathBuf) -> Result<(), eyre::ErrReport> { | |||
| fn create_cmakefile(root: PathBuf, use_path_deps: bool) -> Result<(), eyre::ErrReport> { | |||
| const CMAKEFILE: &str = include_str!("cmake-template.txt"); | |||
| let cmake_file = if use_path_deps { | |||
| let manifest_dir = Path::new(env!("CARGO_MANIFEST_DIR")); | |||
| let workspace_dir = manifest_dir.parent().unwrap().parent().unwrap(); | |||
| CMAKEFILE.replace("__DORA_PATH__", workspace_dir.to_str().unwrap()) | |||
| } else { | |||
| CMAKEFILE.replace("__DORA_PATH__", "") | |||
| }; | |||
| let cmake_path = root.join("CMakeLists.txt"); | |||
| fs::write(&cmake_path, CMAKEFILE) | |||
| fs::write(&cmake_path, cmake_file) | |||
| .with_context(|| format!("failed to write `{}`", cmake_path.display()))?; | |||
| println!("Created new CMakeLists.txt at {}", cmake_path.display()); | |||
| @@ -7,7 +7,7 @@ pub fn create(args: crate::CommandNew, use_path_deps: bool) -> eyre::Result<()> | |||
| match args.lang { | |||
| crate::Lang::Rust => rust::create(args, use_path_deps), | |||
| crate::Lang::Python => python::create(args), | |||
| crate::Lang::C => c::create(args), | |||
| crate::Lang::Cxx => cxx::create(args), | |||
| crate::Lang::C => c::create(args, use_path_deps), | |||
| crate::Lang::Cxx => cxx::create(args, use_path_deps), | |||
| } | |||
| } | |||