-
-
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.
Add test for installing an executable
Tests installing an executable to the default location
- Loading branch information
Showing
8 changed files
with
66 additions
and
1 deletion.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -2,7 +2,6 @@ | |
**/target/ | ||
**/*.rs.bk | ||
build*/ | ||
install*/ | ||
.vscode | ||
.idea | ||
cmake-build-* | ||
|
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(install_rust_bin "generated_from_installed_bin") | ||
|
||
set_tests_properties("install_rust_bin_run_generated_from_installed_bin" | ||
PROPERTIES PASS_REGULAR_EXPRESSION | ||
"Hello World! I'm generated code" | ||
) |
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,30 @@ | ||
cmake_minimum_required(VERSION 3.22) | ||
project(test_project VERSION 0.1.0) | ||
|
||
# Note: Corrosion supports `hostbuild`, so building a Rust binary in a subproject | ||
# like this doesn't offer any benefit over using the hostbuild option. | ||
# However, this is a reasonable way to test that installing Rust binaries via | ||
# corrosion_install works as expected. | ||
include(ExternalProject) | ||
|
||
set(bin_suffix "") | ||
if(CMAKE_HOST_WIN32) | ||
set(bin_suffix ".exe") | ||
endif() | ||
set(generator_bin_path "${CMAKE_CURRENT_BINARY_DIR}/rust_bin/bin/my_rust_bin${bin_suffix}") | ||
|
||
ExternalProject_Add( | ||
rust_bin | ||
PREFIX "${CMAKE_CURRENT_BINARY_DIR}/rust_bin" | ||
SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/rust_bin" | ||
CMAKE_ARGS "-DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/rust_bin" | ||
INSTALL_BYPRODUCTS "${generator_bin_path}" | ||
) | ||
|
||
add_custom_command( | ||
OUTPUT generated_main.cpp | ||
COMMAND "${generator_bin_path}" > "${CMAKE_CURRENT_BINARY_DIR}/generated_main.cpp" | ||
DEPENDS "${generator_bin_path}" | ||
) | ||
|
||
add_executable(generated_from_installed_bin ${CMAKE_CURRENT_BINARY_DIR}/generated_main.cpp) |
6 changes: 6 additions & 0 deletions
6
test/corrosion_install/install_rust_bin/rust_bin/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,6 @@ | ||
cmake_minimum_required(VERSION 3.22) | ||
project(test_rust_bin VERSION 0.1.0) | ||
include(../../../test_header.cmake) | ||
|
||
corrosion_import_crate(MANIFEST_PATH Cargo.toml) | ||
corrosion_install(TARGETS my_rust_bin) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[package] | ||
name = "my_rust_bin" | ||
version = "0.1.0" | ||
edition = "2018" | ||
license = "MIT" | ||
|
||
[dependencies] |
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 @@ | ||
fn main() { | ||
println!( | ||
"#include <iostream> | ||
int main() {{ | ||
std::cout << \"Hello World! I'm generated code\"; | ||
return 0; | ||
}}" | ||
); | ||
} |