Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
135 changes: 6 additions & 129 deletions .github/workflows/build_osgeo4w.sh
Original file line number Diff line number Diff line change
@@ -1,145 +1,22 @@
#!/bin/sh
#
# Usage: build_osgeo4w.sh [-p] [path]
# Usage: build_osgeo4w.sh [path]
#
# By default, the script will look for the source code in the current directory
# and create bin.x86_64-w64-mingw32\grass$ver.bat (run this batch file to start
# GRASS GIS) and dist.x86_64-w64-mingw32\etc\env.bat.
#
# -p optionally install GRASS GIS to C:\OSGeo4W64\opt\grass (run
# C:\OSGeo4W64\opt\grass\grass$ver.bat) and create an unzippable package
# grass$ver-x86_64-w64-mingw32-osgeo4w64-$date.zip
#
# path specify a path to the source code
#

# stop on errors
set -e

if [ "$1" = "-p" ]; then
package=1
shift
else
package=0
fi

test -d "$1" && cd "$1"

osgeo4w_path=/c/OSGeo4W64
arch=x86_64-w64-mingw32
src=$(pwd)

# compile

export PATH=/mingw64/bin:/c/OSGeo4W64/bin:/usr/bin
export PROJ_LIB=$osgeo4w_path/share/proj

OSGEO4W_ROOT_MSYS=$osgeo4w_path \
./configure \
--host=$arch \
--with-includes=$osgeo4w_path/include \
--with-libs="$osgeo4w_path/lib $osgeo4w_path/bin" \
--with-nls \
--with-freetype-includes=$osgeo4w_path/include/freetype2 \
--with-bzlib \
--with-geos=$src/mswindows/osgeo4w/geos-config \
--with-netcdf=$osgeo4w_path/bin/nc-config \
--with-gdal=$src/mswindows/osgeo4w/gdal-config \
--with-liblas=$src/mswindows/osgeo4w/liblas-config \
--with-opengl=windows

make

# install

bin=bin.$arch
dist=dist.$arch
ver=$(sed -n '/^INST_DIR[ \t]*=/{s/^.*grass//; p}' include/Make/Platform.make)

rm -f $dist/grass$ver.tmp $dist/etc/fontcap

# create batch files

src_esc=$(echo $src | sed 's#^/\([a-z]\)#\1:#; s#/#\\\\\\\\#g')
dist_esc="$src_esc\\\\$dist"

(
sed 's/^\(set GISBASE=\).*/\1'$dist_esc'/' \
mswindows/osgeo4w/env.bat.tmpl
cat <<EOT

set PATH=C:\\msys64\\mingw64\\bin;%OSGEO4W_ROOT%\\apps\\msys\\bin;%PATH%

if not exist %GISBASE%\etc\fontcap (
pushd .
%~d0
cd %GISBASE%\lib
set GISRC=dummy
%GISBASE%\bin\g.mkfontcap.exe
popd
)
EOT
) >$dist/etc/env.bat
unix2dos $dist/etc/env.bat

(
sed -e 's/^\(call "\)%~dp0\(.*\)$/\1C:\\OSGeo4W64\\bin\2/' \
-e 's/^\(call "\).*\(\\etc\\env\.bat"\)$/\1'$dist_esc'\2/' \
-e 's/^\(.* "\)%GISBASE%\\etc\(\\grass.*\)$/\1%GISBASE%\\..\\'$bin'\2/' \
-e 's/@POSTFIX@/'$ver'/g' \
mswindows/osgeo4w/grass.bat.tmpl
) >$bin/grass$ver.bat
unix2dos $bin/grass$ver.bat

test $package -eq 0 && exit

# package

opt_path=$osgeo4w_path/opt
grass_path=$opt_path/grass

mkdir -p $opt_path
cp -a $dist $grass_path
# have a versionless and versioned startup script
cp -a $bin/grass.py $bin/grass$ver.py
cp -a $bin/grass$ver.py $grass_path/etc
cp -a $(ldd $dist/lib/*.dll | awk '/mingw64/{print $3}' |
sort -u | grep -v 'lib\(crypto\|ssl\)') $grass_path/lib

(
sed -e 's/^\(set GISBASE=\).*/\1%OSGEO4W_ROOT%\\opt\\grass/' \
mswindows/osgeo4w/env.bat.tmpl
cat <<EOT

set PATH=%OSGEO4W_ROOT%\\apps\\msys\\bin;%PATH%

if not exist %GISBASE%\etc\fontcap (
pushd .
%~d0
cd %GISBASE%\lib
set GISRC=dummy
%GISBASE%\bin\g.mkfontcap.exe
popd
)
EOT
) >$grass_path/etc/env.bat
unix2dos $grass_path/etc/env.bat

(
sed -e 's/^\(call "%~dp0\)\(.*\)$/\1\\..\\..\\bin\2/' \
-e 's/^\(call "%OSGEO4W_ROOT%\\\).*\(\\etc\\env\.bat"\)$/\1opt\\grass\2/' \
-e 's/@POSTFIX@/'$ver'/g' \
mswindows/osgeo4w/grass.bat.tmpl
) >$grass_path/grass$ver.bat
unix2dos $grass_path/grass$ver.bat

exit

# don't package for GitHub workflow; unnecessary

osgeo4w_basename=$(basename $osgeo4w_path)
date=$(date +%Y%m%d)
zip=$src/grass$ver-$arch-osgeo4w64-$date.zip
export OSGEO4W_ROOT_MSYS=/c/OSGeo4W
export SRC=$(pwd)
export UNITTEST=1

cd $osgeo4w_path/..
zip -r $zip $osgeo4w_basename -x "$osgeo4w_basename/var/*" "*/__pycache__/*"
# Build according to OSGeo4W recipe
${SRC}/mswindows/osgeo4w/build_osgeo4W.sh
22 changes: 15 additions & 7 deletions .github/workflows/osgeo4w.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,25 @@ jobs:
git config --global core.autocrlf false
git config --global core.eol lf
- uses: actions/checkout@v2

- name: Install OSGeo4W
run: |
$exe = 'osgeo4w-setup-x86_64-v1.exe'
$url = 'http://download.osgeo.org/osgeo4w/' + $exe
$exe = 'osgeo4w-setup.exe'
$url = 'http://download.osgeo.org/osgeo4w/v2/' + $exe
(New-Object System.Net.WebClient).DownloadFile($url, $exe)
Start-Process ('.\'+$exe) -ArgumentList '-A -g -k -q -s http://download.osgeo.org/x86_64 -P cairo,fftw,freetype-devel,gdal-ecw,gdal-mrsid,liblas-devel,libxdr,msys,pdcurses,python3-numpy,python3-pywin32,python3-wx,regex-devel,wxpython,zstd-devel' -Wait
Start-Process ('.\'+$exe) -ArgumentList '-A -g -k -q -s http://download.osgeo.org/x86_64 -P proj-devel,gdal-devel,geos-devel,libtiff-devel,libpng-devel,pdal-devel,netcdf-devel,cairo-devel,fftw,freetype-devel,gdal-ecw,gdal-mrsid,liblas-devel,libxdr,libpq-devel,pdcurses,python3-matplotlib,python3-numpy,python3-ply,python3-pywin32,python3-six,python3-wxpython,regex-devel,wxwidgets-devel,zstd-devel' -Wait

- name: Install MSYS2 packages
run: C:\msys64\usr\bin\pacman.exe --noconfirm -S tar libintl make bison diffutils git dos2unix zip mingw-w64-x86_64-toolchain mingw-w64-x86_64-cairo mingw-w64-x86_64-python3-six
run: C:\msys64\usr\bin\pacman.exe --noconfirm -S tar libintl make bison flex diffutils git dos2unix zip mingw-w64-x86_64-toolchain mingw-w64-x86_64-cairo mingw-w64-x86_64-fftw mingw-w64-x86_64-lapack mingw-w64-x86_64-pkg-config mingw-w64-x86_64-gcc mingw-w64-x86_64-ccache mingw-w64-x86_64-zlib mingw-w64-x86_64-libiconv mingw-w64-x86_64-bzip2 mingw-w64-x86_64-gettext mingw-w64-x86_64-libsystre mingw-w64-x86_64-libtre-git mingw-w64-x86_64-libwinpthread-git mingw-w64-x86_64-libpng mingw-w64-x86_64-pcre mingw-w64-x86_64-python3-six

- name: Compile GRASS GIS
run: C:\msys64\usr\bin\bash.exe -l (''+(Get-Location)+'\.github\workflows\build_osgeo4w.sh') -p (Get-Location)
run: C:\msys64\usr\bin\bash.exe -l (''+(Get-Location)+'\.github\workflows\build_osgeo4w.sh') (Get-Location)

- name: Test executing of the grass command
run: .github/workflows/test_simple.bat 'C:\OSGeo4W64\opt\grass\grass80.bat'
run: .github/workflows/test_simple.bat 'C:\OSGeo4W\opt\grass\grass80.bat'

- name: Test executing of the grass command in bash
run: C:\msys64\usr\bin\bash.exe .github/workflows/test_simple.sh

- name: Run tests
run: .github/workflows/test_thorough.bat 'C:\OSGeo4W64\opt\grass\grass80.bat'
run: .github/workflows/test_thorough.bat 'C:\OSGeo4W\opt\grass\grass80.bat' 'C:\OSGeo4W\bin\python3'
5 changes: 5 additions & 0 deletions .github/workflows/test_simple.bat
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
set grass=%1

rem Test execution of binary command
call %grass% --tmp-location EPSG:4326 --exec g.region res=0.1 -p
rem Test if batch-wrapper-scripts without extension are found
call %grass% --tmp-location EPSG:4326 --exec C:/Windows/System32/where.exe t.create
rem Test if python-scripts can be called
call %grass% --tmp-location EPSG:4326 --exec t.create --help
5 changes: 5 additions & 0 deletions .github/workflows/test_simple.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,9 @@
# fail on non-zero return code from a subprocess
set -e

# Test execution of binary command
grass --tmp-location EPSG:4326 --exec g.region res=0.1 -p
# Test if python modules without extension are found
grass --tmp-location EPSG:4326 --exec which t.create
# Test if python modules can be called
grass --tmp-location EPSG:4326 --exec t.create --help
2 changes: 1 addition & 1 deletion .github/workflows/test_thorough.bat
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
set grass=%1
set python=C:\OSGeo4W64\bin\python3
set python=%2

call %grass% --tmp-location XY --exec g.download.location url=https://grass.osgeo.org/sampledata/north_carolina/nc_spm_full_v2alpha2.tar.gz path=%USERPROFILE%
call %grass% --tmp-location XY --exec %python% -m grass.gunittest.main --grassdata %USERPROFILE% --location nc_spm_full_v2alpha2 --location-type nc --min-success 60
Loading