aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOndřej Čertík <ondrej@certik.us>2020-07-21 16:56:44 -0600
committerGitHub <noreply@github.com>2020-07-21 16:56:44 -0600
commit66e46f578b209eee42b9420a12550a8de0ca3e10 (patch)
treed85fc31f6f3a48c64205b33473c8fd55eb916de2
parent661d30f4cc8b8bf4b702c3a8d71b6add86915e16 (diff)
parent3bd6db28fbd1392c2c883b48e7beb783114d0d06 (diff)
downloadfpm-66e46f578b209eee42b9420a12550a8de0ca3e10.tar.gz
fpm-66e46f578b209eee42b9420a12550a8de0ca3e10.zip
Merge pull request #140 from certik/ex
Build hello_world
-rw-r--r--.github/workflows/CI.yml13
-rwxr-xr-xci/run_tests.bat22
-rwxr-xr-xci/run_tests.sh11
-rw-r--r--fpm/src/fpm.f9017
4 files changed, 56 insertions, 7 deletions
diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml
index 0de8b3e..4666022 100644
--- a/.github/workflows/CI.yml
+++ b/.github/workflows/CI.yml
@@ -82,9 +82,12 @@ jobs:
cd bootstrap
stack test
- - name: Build and run Fortran fpm
+ - name: Build and run Fortran fpm (Linux / macOS)
+ if: contains(matrix.os, 'ubuntu') || contains(matrix.os, 'macos')
run: |
- cd fpm
- fpm build
- fpm run
- fpm run --args build
+ ci/run_tests.sh
+
+ - name: Build and run Fortran fpm (Windows)
+ if: contains(matrix.os, 'windows')
+ run: |
+ ci\run_tests.bat
diff --git a/ci/run_tests.bat b/ci/run_tests.bat
new file mode 100755
index 0000000..dcc9a8a
--- /dev/null
+++ b/ci/run_tests.bat
@@ -0,0 +1,22 @@
+@echo on
+
+cd fpm
+if errorlevel 1 exit 1
+
+fpm build
+if errorlevel 1 exit 1
+
+fpm run
+if errorlevel 1 exit 1
+
+fpm run --args build
+if errorlevel 1 exit 1
+
+cd ..\test\example_packages\hello_world
+if errorlevel 1 exit 1
+
+..\..\..\fpm\fpm build
+if errorlevel 1 exit 1
+
+.\hello_world
+if errorlevel 1 exit 1
diff --git a/ci/run_tests.sh b/ci/run_tests.sh
new file mode 100755
index 0000000..8f99a2c
--- /dev/null
+++ b/ci/run_tests.sh
@@ -0,0 +1,11 @@
+#!/bin/bash
+
+set -ex
+
+cd fpm
+fpm build
+fpm run
+fpm run --args build
+cd ../test/example_packages/hello_world
+../../../fpm/fpm build
+./hello_world
diff --git a/fpm/src/fpm.f90 b/fpm/src/fpm.f90
index e1e52e9..85597c0 100644
--- a/fpm/src/fpm.f90
+++ b/fpm/src/fpm.f90
@@ -20,11 +20,24 @@ if (stat /= 0) then
end if
end subroutine
+logical function exists(filename) result(r)
+character(len=*), intent(in) :: filename
+inquire(file=filename, exist=r)
+end function
+
subroutine cmd_build()
+logical :: src
print *, "# Building project"
-call run("gfortran -c src/fpm.f90 -o fpm.o")
+src = exists("src/fpm.f90")
+if (src) then
+ call run("gfortran -c src/fpm.f90 -o fpm.o")
+end if
call run("gfortran -c app/main.f90 -o main.o")
-call run("gfortran main.o fpm.o -o fpm")
+if (src) then
+ call run("gfortran main.o fpm.o -o fpm")
+else
+ call run("gfortran main.o -o hello_world")
+end if
end subroutine
end module fpm