diff options
-rw-r--r-- | .github/workflows/CI.yml | 28 | ||||
-rw-r--r-- | README.md | 87 | ||||
-rwxr-xr-x | ci/run_tests.bat | 28 | ||||
-rwxr-xr-x | ci/run_tests.sh | 35 | ||||
-rw-r--r-- | fpm/fpm.toml | 4 | ||||
-rw-r--r-- | fpm/src/fpm_command_line.f90 | 2 | ||||
-rw-r--r-- | fpm/src/fpm_strings.f90 | 2 |
7 files changed, 107 insertions, 79 deletions
diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 8165ded..f42d8ff 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -27,33 +27,39 @@ jobs: - os: ubuntu-latest STACK_CACHE: "/home/runner/.stack/" STACK_CACHE_VERSION: "" + TEST_SCRIPT: ci/run_tests.sh GET_VERSION_CMD: echo ${{ github.ref }} | cut -dv -f2 CHECK_VERSION_CMD: grep $(cat fpm_version) - RELEASE_CMD: "fpm run --flag --static --flag -g --flag -fbacktrace --flag -O3 --runner cp -- fpm-v$(cat fpm_version)-linux-x86_64" + RELEASE_CMD: "cp -- fpm-v$(cat fpm_version)-linux-x86_64" BOOTSTRAP_RELEASE_CMD: cp /home/runner/.local/bin/fpm fpm-bootstrap-v$(cat fpm_version)-linux-x86_64 HASH_CMD: ls fpm-*|xargs -i{} sh -c 'sha256sum $1 > $1.sha256' -- {} + RELEASE_FLAGS: --flag --static --flag -g --flag -fbacktrace --flag -O3 - os: macos-latest STACK_CACHE: | /Users/runner/.stack/snapshots /Users/runner/.stack/setup-exe-src STACK_CACHE_VERSION: "v2" + TEST_SCRIPT: ci/run_tests.sh GET_VERSION_CMD: echo ${{ github.ref }} | cut -dv -f2 CHECK_VERSION_CMD: grep $(cat fpm_version) - RELEASE_CMD: "fpm run --flag -g --flag -fbacktrace --flag -O3 --runner cp -- fpm-v$(cat fpm_version)-macos-x86_64" + RELEASE_CMD: "cp -- fpm-v$(cat fpm_version)-macos-x86_64" BOOTSTRAP_RELEASE_CMD: cp /Users/runner/.local/bin/fpm fpm-bootstrap-v$(cat fpm_version)-macos-x86_64 HASH_CMD: ls fpm-*|xargs -I{} sh -c 'shasum -a 256 $1 > $1.sha256' -- {} + RELEASE_FLAGS: --flag -g --flag -fbacktrace --flag -O3 - os: windows-latest STACK_CACHE: | C:\Users\runneradmin\AppData\Roaming\stack C:\Users\runneradmin\AppData\Local\Programs\stack STACK_CACHE_VERSION: "v2" + TEST_SCRIPT: ci\run_tests.bat GET_VERSION_CMD: ("${{ github.ref }}" -Split "v")[1] CHECK_VERSION_CMD: Select-String -Pattern Version | Where-Object { if ($_ -like -join("*",(Get-Content fpm_version),"*")) {echo $_} else {Throw} } - RELEASE_CMD: fpm run --flag --static --flag -g --flag -fbacktrace --flag -O3 --runner copy -- (-join("fpm-v",(Get-Content fpm_version),"-windows-x86_64.exe")) + RELEASE_CMD: copy -- (-join("fpm-v",(Get-Content fpm_version),"-windows-x86_64.exe")) BOOTSTRAP_RELEASE_CMD: copy C:\Users\runneradmin\AppData\Roaming\local\bin\fpm.exe (-join("fpm-bootstrap-v",(Get-Content fpm_version),"-windows-x86_64.exe")) HASH_CMD: Get-ChildItem -File -Filter "fpm-*" | Foreach-Object {echo (Get-FileHash -Algorithm SHA256 $PSItem | Select-Object hash | Format-Table -HideTableHeaders | Out-String) > (-join($PSItem,".sha256"))} + RELEASE_FLAGS: --flag --static --flag -g --flag -fbacktrace --flag -O3 env: FC: gfortran @@ -116,15 +122,11 @@ jobs: cd bootstrap stack test - - name: Build and run Fortran fpm (Linux / macOS) - if: contains(matrix.os, 'ubuntu') || contains(matrix.os, 'macos') - run: | - ci/run_tests.sh + - name: Build and test Fortran fpm + run: ${{ matrix.TEST_SCRIPT }} - - name: Build and run Fortran fpm (Windows) - if: contains(matrix.os, 'windows') - run: | - ci\run_tests.bat + - name: Build and test Fortran fpm (release version) + run: ${{ matrix.TEST_SCRIPT }} ${{ matrix.RELEASE_FLAGS }} # ----- Upload binaries if creating a release ----- - name: Check that fpm --version matches release tag @@ -138,7 +140,7 @@ jobs: if: github.event_name == 'release' run: | cd fpm - ${{ matrix.RELEASE_CMD }} + fpm run ${{ matrix.RELEASE_FLAGS }} --runner ${{ matrix.RELEASE_CMD }} ${{ matrix.BOOTSTRAP_RELEASE_CMD }} ${{ matrix.HASH_CMD }} @@ -150,4 +152,4 @@ jobs: file: fpm/fpm-* file_glob: true tag: ${{ github.ref }} - overwrite: true
\ No newline at end of file + overwrite: true @@ -24,45 +24,7 @@ __Note:__ On Linux and MacOS, you will need to enable executable permission befo _e.g._ `$ chmod u+x fpm-v0.1.0-linux-x86_64` -### Build from source - -#### Install Haskell - -To install **Haskell Stack**, follow these -[instructions](https://docs.haskellstack.org/en/stable/install_and_upgrade/), -users without superuser (admin) permissions should follow the -[manual installation](https://docs.haskellstack.org/en/stable/install_and_upgrade/#manual-download_2) -procedure. - -#### Download this repository - -```bash -$ git clone https://github.com/fortran-lang/fpm -$ cd fpm/ -``` - -#### Build and test fpm - -Bootstrap *fpm* using: - -```bash -$ cd bootstrap/ -$ stack build -``` - -To test: - -```bash -$ stack test -``` - -To install: - -```bash -$ stack install -``` - -On Linux, the above command installs `fpm` to `${HOME}/.local/bin/`. +For other platforms and architectures have a look at the [bootstrapping instructions](#bootstrapping-instructions). ### Creating a new project @@ -88,7 +50,52 @@ with the following contents and initialized as a git repository. The command `fpm run` can optionally accept the name of the specific executable to run, as can `fpm test`; like `fpm run specific_executable`. Command line arguments can also be passed to the executable(s) or test(s) with the option -`--args "some arguments"`. +`-- some arguments`. See additional instructions in the [Packaging guide](PACKAGING.md) or the [manifest reference](manifest-reference.md). + + +### Bootstrapping instructions + +This guide explains the process of building *fpm* on a platform for the first time. +If your platform and architecture are already supported, download the binary from the [release page](https://github.com/fortran-lang/fpm/releases) instead. + +#### Download this repository + +```bash +$ git clone https://github.com/fortran-lang/fpm +$ cd fpm/ +``` + +#### Build a bootstrap version of fpm + +You can use the install script to perform the build of the Haskell version of *fpm* with: + +```bash +$ ./install.sh +``` + +On Linux, the above command installs `fpm` to `${HOME}/.local/bin/`. + +Now you can build the Fortran *fpm* version with + +```bash +$ cd fpm/ +$ fpm build +``` + +Test that everything is working as expected + +```bash +$ fpm test +``` + +Finally, install the Fortran *fpm* version with + +```bash +$ fpm run --runner cp -- ~/.local/bin +``` + +Or choose another location if you do not want to overwrite the bootstrapping version. +From now on you can rebuild *fpm* with your Fortran *fpm* version. diff --git a/ci/run_tests.bat b/ci/run_tests.bat index 44f6e5c..533590d 100755 --- a/ci/run_tests.bat +++ b/ci/run_tests.bat @@ -3,18 +3,25 @@ cd fpm if errorlevel 1 exit 1 -fpm build +fpm build %* if errorlevel 1 exit 1 -fpm run +fpm run %* +if errorlevel 1 exit 1 + +fpm run %* -- --help +if errorlevel 1 exit 1 + +fpm run %* -- --version if errorlevel 1 exit 1 rmdir fpm_scratch_* /s /q -fpm test +fpm test %* if errorlevel 1 exit 1 rmdir fpm_scratch_* /s /q -for /f %%i in ('where /r build fpm.exe') do set fpm_path=%%i +for /f %%i in ('fpm run %* --runner echo') do set fpm_path=%%i +echo %fpm_path% %fpm_path% if errorlevel 1 exit 1 @@ -22,6 +29,7 @@ if errorlevel 1 exit 1 cd ..\example_packages\hello_world if errorlevel 1 exit 1 +del /q /f build %fpm_path% build if errorlevel 1 exit 1 @@ -32,6 +40,7 @@ if errorlevel 1 exit 1 cd ..\hello_fpm if errorlevel 1 exit 1 +del /q /f build %fpm_path% build if errorlevel 1 exit 1 @@ -42,6 +51,7 @@ if errorlevel 1 exit 1 cd ..\circular_test if errorlevel 1 exit 1 +del /q /f build %fpm_path% build if errorlevel 1 exit 1 @@ -49,6 +59,7 @@ if errorlevel 1 exit 1 cd ..\circular_example if errorlevel 1 exit 1 +del /q /f build %fpm_path% build if errorlevel 1 exit 1 @@ -56,6 +67,7 @@ if errorlevel 1 exit 1 cd ..\hello_complex if errorlevel 1 exit 1 +del /q /f build %fpm_path% build if errorlevel 1 exit 1 @@ -75,6 +87,7 @@ if errorlevel 1 exit 1 cd ..\hello_complex_2 if errorlevel 1 exit 1 +del /q /f build %fpm_path% build if errorlevel 1 exit 1 @@ -93,6 +106,7 @@ if errorlevel 1 exit 1 cd ..\auto_discovery_off if errorlevel 1 exit 1 +del /q /f build %fpm_path% build if errorlevel 1 exit 1 @@ -110,6 +124,7 @@ if exist .\build\gfortran_debug\test\unused_test exit /B 1 cd ..\with_c if errorlevel 1 exit 1 +del /q /f build %fpm_path% build if errorlevel 1 exit 1 @@ -120,6 +135,7 @@ if errorlevel 1 exit 1 cd ..\submodules if errorlevel 1 exit 1 +del /q /f build %fpm_path% build if errorlevel 1 exit 1 @@ -127,6 +143,7 @@ if errorlevel 1 exit 1 cd ..\program_with_module if errorlevel 1 exit 1 +del /q /f build %fpm_path% build if errorlevel 1 exit 1 @@ -137,8 +154,11 @@ if errorlevel 1 exit 1 cd ..\link_executable if errorlevel 1 exit 1 +del /q /f build %fpm_path% build if errorlevel 1 exit 1 .\build\gfortran_debug\app\gomp_test if errorlevel 1 exit 1 + +cd ..\..
\ No newline at end of file diff --git a/ci/run_tests.sh b/ci/run_tests.sh index 894b1f0..3588012 100755 --- a/ci/run_tests.sh +++ b/ci/run_tests.sh @@ -1,30 +1,26 @@ #!/bin/bash +set -ex -get_abs_filename() { - # $1 : relative filename - filename=$1 - parentdir=$(dirname "${filename}") +cd $(dirname $0)/../fpm - if [ -d "${filename}" ]; then - echo "$(cd "${filename}" && pwd)" - elif [ -d "${parentdir}" ]; then - echo "$(cd "${parentdir}" && pwd)/$(basename "${filename}")" - fi -} +fpm build $@ -set -ex +# Run fpm executable +fpm run $@ +fpm run $@ -- --version +fpm run $@ -- --help -cd fpm -fpm build -fpm run +# Run tests rm -rf fpm_scratch_*/ -fpm test +fpm test $@ rm -rf fpm_scratch_*/ -f_fpm_path="$(get_abs_filename $(find build -regex 'build/.*/app/fpm'))" -"${f_fpm_path}" +# Build example packages +f_fpm_path="$(fpm run $@ --runner echo)" +cd ../example_packages/ +rm -rf ./*/build -cd ../example_packages/hello_world +cd hello_world "${f_fpm_path}" build ./build/gfortran_debug/app/hello_world @@ -77,3 +73,6 @@ cd ../link_external cd ../link_executable "${f_fpm_path}" build ./build/gfortran_debug/app/gomp_test + +# Cleanup +rm -rf ./*/build
\ No newline at end of file diff --git a/fpm/fpm.toml b/fpm/fpm.toml index 7afc0a0..c30c9b4 100644 --- a/fpm/fpm.toml +++ b/fpm/fpm.toml @@ -1,5 +1,5 @@ name = "fpm" -version = "0.1.0" +version = "0.1.1" license = "MIT" author = "fpm maintainers" maintainer = "" @@ -12,7 +12,7 @@ tag = "v0.2.1" [dependencies.M_CLI2] git = "https://github.com/urbanjost/M_CLI2.git" -rev = "893cac0ce374bf07a70ffb9556439c7390e58131" +rev = "e59fb2bfcf36199f1af506f937b3849180454a0f" [[test]] name = "cli-test" diff --git a/fpm/src/fpm_command_line.f90 b/fpm/src/fpm_command_line.f90 index 50a7d25..03daf6f 100644 --- a/fpm/src/fpm_command_line.f90 +++ b/fpm/src/fpm_command_line.f90 @@ -83,7 +83,7 @@ contains case default ; os_type = "OS Type: UNKNOWN" end select version_text = [character(len=80) :: & - & 'Version: 0.1.0, Pre-alpha', & + & 'Version: 0.1.1, alpha', & & 'Program: fpm(1)', & & 'Description: A Fortran package manager and build system', & & 'Home Page: https://github.com/fortran-lang/fpm', & diff --git a/fpm/src/fpm_strings.f90 b/fpm/src/fpm_strings.f90 index a6511c9..d1f5150 100644 --- a/fpm/src/fpm_strings.f90 +++ b/fpm/src/fpm_strings.f90 @@ -155,7 +155,7 @@ subroutine split(input_line,array,delimiters,order,nulls) select case (ilen) - case (:0) ! command was totally blank + case (0) ! command was totally blank case default ! there is at least one non-delimiter in INPUT_LINE if get here icol=1 ! initialize pointer into input line |