-
-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added ability to import a crate containing lib and bin targets with t…
…he same name.
- Loading branch information
Showing
10 changed files
with
161 additions
and
71 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
corrosion_tests_add_test(one_package_bin_and_lib "my_program") | ||
|
||
set_tests_properties("one_package_bin_and_lib_run_my_program" PROPERTIES PASS_REGULAR_EXPRESSION | ||
"^Ok\r?\n$" | ||
) | ||
|
16 changes: 16 additions & 0 deletions
16
test/one_package_bin_and_lib/one_package_bin_and_lib/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
cmake_minimum_required(VERSION 3.15) | ||
project(test_project VERSION 0.1.0) | ||
include(../../test_header.cmake) | ||
|
||
corrosion_import_crate( | ||
MANIFEST_PATH ${CMAKE_CURRENT_SOURCE_DIR}/Cargo.toml | ||
BIN_NAMESPACE bin LIB_NAMESPACE lib | ||
) | ||
|
||
if(NOT TARGET bin::mycrate) | ||
message(FATAL_ERROR "Unable to import bin::mycrate.") | ||
endif() | ||
|
||
add_executable(my_program main.cpp) | ||
target_link_libraries(my_program PUBLIC lib::mycrate) | ||
|
7 changes: 7 additions & 0 deletions
7
test/one_package_bin_and_lib/one_package_bin_and_lib/Cargo.lock
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
9 changes: 9 additions & 0 deletions
9
test/one_package_bin_and_lib/one_package_bin_and_lib/Cargo.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[package] | ||
name = "mycrate" | ||
version = "0.1.0" | ||
edition = "2018" | ||
description = "descr;\"hello\\" | ||
|
||
[lib] | ||
crate-type = ["staticlib", "rlib"] | ||
name = "mycrate" |
4 changes: 4 additions & 0 deletions
4
test/one_package_bin_and_lib/one_package_bin_and_lib/main.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#include <iostream> | ||
int main() { | ||
std::cout << "Ok"; | ||
} |
3 changes: 3 additions & 0 deletions
3
test/one_package_bin_and_lib/one_package_bin_and_lib/src/lib.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
pub fn hello() { | ||
println!("Hello world"); | ||
} |
5 changes: 5 additions & 0 deletions
5
test/one_package_bin_and_lib/one_package_bin_and_lib/src/main.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
use mycrate::hello; | ||
|
||
fn main() { | ||
hello(); | ||
} |