aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOndřej Čertík <ondrej@certik.us>2020-01-12 15:18:04 -0700
committerOndřej Čertík <ondrej@certik.us>2020-01-12 15:18:04 -0700
commit434213681dc74d8d6fae62e34917dfe4c9efb086 (patch)
tree51bce302f5a412f3ab9759d4a23ddc087d5fd6a5
parent66971b3a4b0d06925aee05a772bb61233e54ac2f (diff)
downloadfpm-434213681dc74d8d6fae62e34917dfe4c9efb086.tar.gz
fpm-434213681dc74d8d6fae62e34917dfe4c9efb086.zip
Run CMake as part of "build", implement "run"
-rw-r--r--.gitlab-ci.yml5
-rwxr-xr-xrun_tests.sh1
-rw-r--r--src/main.rs49
3 files changed, 53 insertions, 2 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 042dff0..845df00 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -5,10 +5,11 @@ rust-latest:
stage: build
image: rust:latest
script:
+ - apt-get update
+ - apt-get -yq --no-install-recommends install cmake make gfortran
- cargo build --verbose
- cargo test --verbose
- - touch a.f90 b.f90 c.f90
- - cargo run -- build
+ - cargo run -- --help
- ./run_tests.sh
rust-nightly:
diff --git a/run_tests.sh b/run_tests.sh
index 123acb2..d47133b 100755
--- a/run_tests.sh
+++ b/run_tests.sh
@@ -6,3 +6,4 @@ fpm=$(pwd)/target/debug/fpm
cd tests/1
${fpm} build
+${fpm} run
diff --git a/src/main.rs b/src/main.rs
index 85ba64a..ddcb335 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -30,6 +30,51 @@ fn build() {
println!("File: {}", file.to_str().unwrap());
}
println!("Files: {:?}", files);
+ let s = "\
+cmake_minimum_required(VERSION 3.5.0 FATAL_ERROR)
+
+enable_language(Fortran)
+
+project(p1)
+
+set(SRC
+ a.f90
+ b.f90
+)
+
+add_executable(p1 main.f90 ${SRC})
+";
+ std::fs::write("CMakeLists.txt", s).unwrap();
+ let output = std::process::Command::new("cmake")
+ .args(&["-B", "build", "."])
+ .output().unwrap();
+ println!("status: {}", output.status);
+ println!("stdout: {}", String::from_utf8_lossy(&output.stdout));
+ println!("stderr: {}", String::from_utf8_lossy(&output.stderr));
+ if !output.status.success() {
+ panic!("Command failed.")
+ }
+
+ let output = std::process::Command::new("cmake")
+ .args(&["--build", "build"])
+ .output().unwrap();
+ println!("status: {}", output.status);
+ println!("stdout: {}", String::from_utf8_lossy(&output.stdout));
+ println!("stderr: {}", String::from_utf8_lossy(&output.stderr));
+ if !output.status.success() {
+ panic!("Command failed.")
+ }
+}
+
+fn run() {
+ let output = std::process::Command::new("build/p1")
+ .output().unwrap();
+ println!("status: {}", output.status);
+ println!("stdout: {}", String::from_utf8_lossy(&output.stdout));
+ println!("stderr: {}", String::from_utf8_lossy(&output.stderr));
+ if !output.status.success() {
+ panic!("Command failed.")
+ }
}
fn main() {
@@ -38,6 +83,10 @@ fn main() {
if args.command == "build" {
println!("Command: build");
build();
+ } else if args.command == "run" {
+ println!("Command: run");
+ build();
+ run();
} else {
panic!("Unknown command");
}