From c41c39e36cc1e10699a47d5eca6da396f0173a64 Mon Sep 17 00:00:00 2001 From: LKedward Date: Sun, 7 Mar 2021 11:48:49 +0000 Subject: Add: example packages for include directories --- ci/run_tests.bat | 24 ++++++++++++++++++++++ ci/run_tests.sh | 9 ++++++++ example_packages/README.md | 3 +++ example_packages/c_header_only/.gitignore | 1 + example_packages/c_header_only/fpm.toml | 1 + example_packages/c_header_only/include/c_header.h | 1 + example_packages/c_includes/.gitignore | 1 + example_packages/c_includes/fpm.toml | 4 ++++ example_packages/c_includes/include/lib.h | 4 ++++ example_packages/c_includes/src/lib.c | 7 +++++++ example_packages/fortran_includes/.gitignore | 1 + example_packages/fortran_includes/fpm.toml | 4 ++++ .../fortran_includes/inc/parameters.f90 | 1 + example_packages/fortran_includes/src/lib.f90 | 14 +++++++++++++ example_packages/link_executable/include/test.f90 | 1 + 15 files changed, 76 insertions(+) create mode 100644 example_packages/c_header_only/.gitignore create mode 100644 example_packages/c_header_only/fpm.toml create mode 100644 example_packages/c_header_only/include/c_header.h create mode 100644 example_packages/c_includes/.gitignore create mode 100644 example_packages/c_includes/fpm.toml create mode 100644 example_packages/c_includes/include/lib.h create mode 100644 example_packages/c_includes/src/lib.c create mode 100644 example_packages/fortran_includes/.gitignore create mode 100644 example_packages/fortran_includes/fpm.toml create mode 100644 example_packages/fortran_includes/inc/parameters.f90 create mode 100644 example_packages/fortran_includes/src/lib.f90 create mode 100644 example_packages/link_executable/include/test.f90 diff --git a/ci/run_tests.bat b/ci/run_tests.bat index ae57da6..811baa4 100755 --- a/ci/run_tests.bat +++ b/ci/run_tests.bat @@ -187,4 +187,28 @@ if errorlevel 1 exit 1 .\build\gfortran_debug\app\gomp_test if errorlevel 1 exit 1 + +cd ..\fortran_includes +if errorlevel 1 exit 1 + +del /q /f build +%fpm_path% build +if errorlevel 1 exit 1 + + +cd ..\c_includes +if errorlevel 1 exit 1 + +del /q /f build +%fpm_path% build +if errorlevel 1 exit 1 + + +cd ..\c_header_only +if errorlevel 1 exit 1 + +del /q /f build +%fpm_path% build +if errorlevel 1 exit 1 + cd ..\.. diff --git a/ci/run_tests.sh b/ci/run_tests.sh index f1c4dff..b1f9a7f 100755 --- a/ci/run_tests.sh +++ b/ci/run_tests.sh @@ -89,5 +89,14 @@ cd ../link_executable "${f_fpm_path}" build ./build/gfortran_debug/app/gomp_test +cd ../fortran_includes +"${f_fpm_path}" build + +cd ../c_includes +"${f_fpm_path}" build + +cd ../c_header_only +"${f_fpm_path}" build + # Cleanup rm -rf ./*/build diff --git a/example_packages/README.md b/example_packages/README.md index 667b9a3..b556dcb 100644 --- a/example_packages/README.md +++ b/example_packages/README.md @@ -7,8 +7,11 @@ the features demonstrated in each package and which versions of fpm are supporte | Name | Features | Bootstrap (Haskell) fpm | fpm | |---------------------|---------------------------------------------------------------|:-----------------------:|:---:| | auto_discovery_off | Default layout with auto-discovery disabled | N | Y | +| c_header_only | C header-only library | N | Y | +| c_includes | C library with c include directory and dependency includes | N | Y | | circular_example | Local path dependency; circular dependency | Y | Y | | circular_test | Local path dependency; circular dependency | Y | Y | +| fortran_includes | Fortran library with explicit include directory | Y | N | | hello_complex | Non-standard directory layout; multiple tests and executables | Y | Y | | hello_complex_2 | Auto-discovery of tests and executables with modules | N | Y | | hello_fpm | App-only; local path dependency | Y | Y | diff --git a/example_packages/c_header_only/.gitignore b/example_packages/c_header_only/.gitignore new file mode 100644 index 0000000..a007fea --- /dev/null +++ b/example_packages/c_header_only/.gitignore @@ -0,0 +1 @@ +build/* diff --git a/example_packages/c_header_only/fpm.toml b/example_packages/c_header_only/fpm.toml new file mode 100644 index 0000000..372fe0e --- /dev/null +++ b/example_packages/c_header_only/fpm.toml @@ -0,0 +1 @@ +name = "c_header_only" diff --git a/example_packages/c_header_only/include/c_header.h b/example_packages/c_header_only/include/c_header.h new file mode 100644 index 0000000..ec88a4b --- /dev/null +++ b/example_packages/c_header_only/include/c_header.h @@ -0,0 +1 @@ +int printf ( const char * format, ... ); diff --git a/example_packages/c_includes/.gitignore b/example_packages/c_includes/.gitignore new file mode 100644 index 0000000..a007fea --- /dev/null +++ b/example_packages/c_includes/.gitignore @@ -0,0 +1 @@ +build/* diff --git a/example_packages/c_includes/fpm.toml b/example_packages/c_includes/fpm.toml new file mode 100644 index 0000000..46918d6 --- /dev/null +++ b/example_packages/c_includes/fpm.toml @@ -0,0 +1,4 @@ +name = "c_includes" + +[dependencies] +c_header_only = { path = "../c_header_only"} diff --git a/example_packages/c_includes/include/lib.h b/example_packages/c_includes/include/lib.h new file mode 100644 index 0000000..4f29282 --- /dev/null +++ b/example_packages/c_includes/include/lib.h @@ -0,0 +1,4 @@ +// Include from "c_header_only" dependency +#include "c_header.h" + +int test(const int a); diff --git a/example_packages/c_includes/src/lib.c b/example_packages/c_includes/src/lib.c new file mode 100644 index 0000000..2339822 --- /dev/null +++ b/example_packages/c_includes/src/lib.c @@ -0,0 +1,7 @@ +#include "lib.h" + +int test(const int a){ + + return printf("input: %d\n", a); + +} \ No newline at end of file diff --git a/example_packages/fortran_includes/.gitignore b/example_packages/fortran_includes/.gitignore new file mode 100644 index 0000000..a007fea --- /dev/null +++ b/example_packages/fortran_includes/.gitignore @@ -0,0 +1 @@ +build/* diff --git a/example_packages/fortran_includes/fpm.toml b/example_packages/fortran_includes/fpm.toml new file mode 100644 index 0000000..8557b72 --- /dev/null +++ b/example_packages/fortran_includes/fpm.toml @@ -0,0 +1,4 @@ +name = "fortran_includes" + +[library] +include-dir = "inc" diff --git a/example_packages/fortran_includes/inc/parameters.f90 b/example_packages/fortran_includes/inc/parameters.f90 new file mode 100644 index 0000000..e9e1af5 --- /dev/null +++ b/example_packages/fortran_includes/inc/parameters.f90 @@ -0,0 +1 @@ +integer, parameter :: dp = kind(0.d0) \ No newline at end of file diff --git a/example_packages/fortran_includes/src/lib.f90 b/example_packages/fortran_includes/src/lib.f90 new file mode 100644 index 0000000..a27a001 --- /dev/null +++ b/example_packages/fortran_includes/src/lib.f90 @@ -0,0 +1,14 @@ +module test_mod + implicit none + + include "parameters.f90" + + contains + + subroutine test_sub(a) + real(dp), intent(in) :: a + + write(*,*) 'a: ', a + end subroutine test_sub + +end module test_mod \ No newline at end of file diff --git a/example_packages/link_executable/include/test.f90 b/example_packages/link_executable/include/test.f90 new file mode 100644 index 0000000..5413cbc --- /dev/null +++ b/example_packages/link_executable/include/test.f90 @@ -0,0 +1 @@ +real, parameter :: a = 2.0 -- cgit v1.2.3