From 82e15dbaf91dedeb57e419ddd2d06d51558a94a0 Mon Sep 17 00:00:00 2001 From: Leonardo Uieda Date: Wed, 19 Jun 2019 18:22:30 -1000 Subject: [PATCH 01/12] Separate out the libgmt loading tests --- pygmt/clib/loading.py | 2 +- pygmt/tests/test_clib.py | 51 ---------------------------- pygmt/tests/test_clib_loading.py | 58 ++++++++++++++++++++++++++++++++ 3 files changed, 59 insertions(+), 52 deletions(-) create mode 100644 pygmt/tests/test_clib_loading.py diff --git a/pygmt/clib/loading.py b/pygmt/clib/loading.py index 2de978534f3..bb13a3682ad 100644 --- a/pygmt/clib/loading.py +++ b/pygmt/clib/loading.py @@ -52,7 +52,7 @@ def load_libgmt(env=None): return libgmt -def get_clib_path(env): +def get_clib_path(env=None): """ Get the path to the libgmt shared library. diff --git a/pygmt/tests/test_clib.py b/pygmt/tests/test_clib.py index 2014ae70917..4a6c3cbcf38 100644 --- a/pygmt/tests/test_clib.py +++ b/pygmt/tests/test_clib.py @@ -14,12 +14,9 @@ from .. import clib from ..clib.session import FAMILIES, VIAS -from ..clib.loading import clib_name, load_libgmt, check_libgmt, get_clib_path from ..clib.conversion import dataarray_to_matrix from ..exceptions import ( GMTCLibError, - GMTOSError, - GMTCLibNotFoundError, GMTCLibNoSessionError, GMTInvalidInput, GMTVersionError, @@ -70,54 +67,6 @@ def mock_get_libgmt_func(name, argtypes=None, restype=None): setattr(session, "get_libgmt_func", get_libgmt_func) -def test_load_libgmt(): - "Test that loading libgmt works and doesn't crash." - load_libgmt() - - -def test_load_libgmt_fail(): - "Test that loading fails when given a bad library path." - env = {"GMT_LIBRARY_PATH": "not/a/real/path"} - with pytest.raises(GMTCLibNotFoundError): - load_libgmt(env=env) - - -def test_get_clib_path(): - "Test that the correct path is found when setting GMT_LIBRARY_PATH." - # Get the real path to the library first - with clib.Session() as lib: - libpath = lib.info["library path"] - libdir = os.path.dirname(libpath) - # Assign it to the environment variable but keep a backup value to restore - # later - env = {"GMT_LIBRARY_PATH": libdir} - - # Check that the path is determined correctly - path_used = get_clib_path(env=env) - assert os.path.samefile(path_used, libpath) - assert os.path.dirname(path_used) == libdir - - # Check that loading libgmt works - load_libgmt(env=env) - - -def test_check_libgmt(): - "Make sure check_libgmt fails when given a bogus library" - with pytest.raises(GMTCLibError): - check_libgmt(dict()) - - -def test_clib_name(): - "Make sure we get the correct library name for different OS names" - for linux in ["linux", "linux2", "linux3"]: - assert clib_name(linux) == "libgmt.so" - assert clib_name("darwin") == "libgmt.dylib" - assert clib_name("win32", is_64bit=True) == "gmt_w64.dll" - assert clib_name("win32", is_64bit=False) == "gmt_w32.dll" - with pytest.raises(GMTOSError): - clib_name("meh") - - def test_getitem(): "Test that I can get correct constants from the C lib" ses = clib.Session() diff --git a/pygmt/tests/test_clib_loading.py b/pygmt/tests/test_clib_loading.py new file mode 100644 index 00000000000..a62c1d69e6c --- /dev/null +++ b/pygmt/tests/test_clib_loading.py @@ -0,0 +1,58 @@ +""" +Test the functions that load libgmt +""" +import os + +import pytest + +from ..clib.loading import clib_name, load_libgmt, check_libgmt, get_clib_path +from .. import clib +from ..exceptions import GMTCLibError, GMTOSError, GMTCLibNotFoundError + + +def test_load_libgmt(): + "Test that loading libgmt works and doesn't crash." + load_libgmt() + + +def test_load_libgmt_fail(): + "Test that loading fails when given a bad library path." + env = {"GMT_LIBRARY_PATH": "not/a/real/path"} + with pytest.raises(GMTCLibNotFoundError): + load_libgmt(env=env) + + +def test_get_clib_path(): + "Test that the correct path is found when setting GMT_LIBRARY_PATH." + # Get the real path to the library first + with clib.Session() as lib: + libpath = lib.info["library path"] + libdir = os.path.dirname(libpath) + # Assign it to the environment variable but keep a backup value to restore + # later + env = {"GMT_LIBRARY_PATH": libdir} + + # Check that the path is determined correctly + path_used = get_clib_path(env=env) + assert os.path.samefile(path_used, libpath) + assert os.path.dirname(path_used) == libdir + + # Check that loading libgmt works + load_libgmt(env=env) + + +def test_check_libgmt(): + "Make sure check_libgmt fails when given a bogus library" + with pytest.raises(GMTCLibError): + check_libgmt(dict()) + + +def test_clib_name(): + "Make sure we get the correct library name for different OS names" + for linux in ["linux", "linux2", "linux3"]: + assert clib_name(linux) == "libgmt.so" + assert clib_name("darwin") == "libgmt.dylib" + assert clib_name("win32", is_64bit=True) == "gmt_w64.dll" + assert clib_name("win32", is_64bit=False) == "gmt_w32.dll" + with pytest.raises(GMTOSError): + clib_name("meh") From fb04b6d07d07c5fd89bb4cab7944cc31f1165fc7 Mon Sep 17 00:00:00 2001 From: Leonardo Uieda Date: Wed, 19 Jun 2019 18:43:40 -1000 Subject: [PATCH 02/12] Try to find the Windows library --- pygmt/clib/loading.py | 83 +++++++++----------------------- pygmt/tests/test_clib_loading.py | 45 +++++------------ 2 files changed, 33 insertions(+), 95 deletions(-) diff --git a/pygmt/clib/loading.py b/pygmt/clib/loading.py index bb13a3682ad..4050cdbadeb 100644 --- a/pygmt/clib/loading.py +++ b/pygmt/clib/loading.py @@ -37,85 +37,46 @@ def load_libgmt(env=None): couldn't access the functions). """ - libpath = get_clib_path(env) - try: - libgmt = ctypes.CDLL(libpath) - check_libgmt(libgmt) - except OSError as err: - msg = "\n".join( - [ - "Error loading the GMT shared library '{}':".format(libpath), - "{}".format(str(err)), - ] - ) - raise GMTCLibNotFoundError(msg) - return libgmt - - -def get_clib_path(env=None): - """ - Get the path to the libgmt shared library. - - Determine the file name and extension and append to the path set by - ``GMT_LIBRARY_PATH``, if any. - - Parameters - ---------- - env : dict or None - A dictionary containing the environment variables. If ``None``, will - default to ``os.environ``. - - Returns - ------- - libpath : str - The path to the libgmt shared library. - - """ - libname = clib_name() if env is None: env = os.environ - if "GMT_LIBRARY_PATH" in env: - libpath = os.path.join(env["GMT_LIBRARY_PATH"], libname) - else: - libpath = libname - return libpath + libnames = clib_name(os_name=sys.platform) + libpath = env.get("GMT_LIBRARY_PATH", "") + error = False + for libname in libnames: + try: + libgmt = ctypes.CDLL(os.path.join(libpath, libname)) + check_libgmt(libgmt) + except OSError as err: + error = err + if error: + raise GMTCLibNotFoundError( + "Error loading the GMT shared library '{}':".format(libname) + ) + return libgmt -def clib_name(os_name=None, is_64bit=None): +def clib_name(os_name): """ Return the name of GMT's shared library for the current OS. Parameters ---------- - os_name : str or None - The operating system name as given by ``sys.platform`` - (the default if None). - is_64bit : bool or None - Whether or not the OS is 64bit. Only used if the OS is ``win32``. If None, will - determine automatically. + os_name : str + The operating system name as given by ``sys.platform``. Returns ------- - libname : str - The name of GMT's shared library. + libname : list of str + List of possible names of GMT's shared library. """ - if os_name is None: - os_name = sys.platform - - if is_64bit is None: - is_64bit = sys.maxsize > 2 ** 32 - if os_name.startswith("linux"): - libname = "libgmt.so" + libname = ["libgmt.so"] elif os_name == "darwin": # Darwin is macOS - libname = "libgmt.dylib" + libname = ["libgmt.dylib"] elif os_name == "win32": - if is_64bit: - libname = "gmt_w64.dll" - else: - libname = "gmt_w32.dll" + libname = ["gmt.lib", "gmt_w64.dll", "gmt_w32.dll"] else: raise GMTOSError('Operating system "{}" not supported.'.format(sys.platform)) return libname diff --git a/pygmt/tests/test_clib_loading.py b/pygmt/tests/test_clib_loading.py index a62c1d69e6c..a3c4f1140ce 100644 --- a/pygmt/tests/test_clib_loading.py +++ b/pygmt/tests/test_clib_loading.py @@ -1,18 +1,21 @@ """ Test the functions that load libgmt """ -import os - import pytest -from ..clib.loading import clib_name, load_libgmt, check_libgmt, get_clib_path -from .. import clib +from ..clib.loading import clib_name, load_libgmt, check_libgmt from ..exceptions import GMTCLibError, GMTOSError, GMTCLibNotFoundError +def test_check_libgmt(): + "Make sure check_libgmt fails when given a bogus library" + with pytest.raises(GMTCLibError): + check_libgmt(dict()) + + def test_load_libgmt(): "Test that loading libgmt works and doesn't crash." - load_libgmt() + check_libgmt(load_libgmt()) def test_load_libgmt_fail(): @@ -22,37 +25,11 @@ def test_load_libgmt_fail(): load_libgmt(env=env) -def test_get_clib_path(): - "Test that the correct path is found when setting GMT_LIBRARY_PATH." - # Get the real path to the library first - with clib.Session() as lib: - libpath = lib.info["library path"] - libdir = os.path.dirname(libpath) - # Assign it to the environment variable but keep a backup value to restore - # later - env = {"GMT_LIBRARY_PATH": libdir} - - # Check that the path is determined correctly - path_used = get_clib_path(env=env) - assert os.path.samefile(path_used, libpath) - assert os.path.dirname(path_used) == libdir - - # Check that loading libgmt works - load_libgmt(env=env) - - -def test_check_libgmt(): - "Make sure check_libgmt fails when given a bogus library" - with pytest.raises(GMTCLibError): - check_libgmt(dict()) - - def test_clib_name(): "Make sure we get the correct library name for different OS names" for linux in ["linux", "linux2", "linux3"]: - assert clib_name(linux) == "libgmt.so" - assert clib_name("darwin") == "libgmt.dylib" - assert clib_name("win32", is_64bit=True) == "gmt_w64.dll" - assert clib_name("win32", is_64bit=False) == "gmt_w32.dll" + assert clib_name(linux) == ["libgmt.so"] + assert clib_name("darwin") == ["libgmt.dylib"] + assert clib_name("win32") == ["gmt.lib", "gmt_w64.dll", "gmt_w32.dll"] with pytest.raises(GMTOSError): clib_name("meh") From c93734bf51b28d7abdb0fead37477cf93080f657 Mon Sep 17 00:00:00 2001 From: Leonardo Uieda Date: Wed, 19 Jun 2019 19:02:07 -1000 Subject: [PATCH 03/12] Use .dll instead of .lib --- pygmt/clib/loading.py | 2 +- pygmt/tests/test_clib_loading.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pygmt/clib/loading.py b/pygmt/clib/loading.py index 4050cdbadeb..c77d8c3f6a2 100644 --- a/pygmt/clib/loading.py +++ b/pygmt/clib/loading.py @@ -76,7 +76,7 @@ def clib_name(os_name): # Darwin is macOS libname = ["libgmt.dylib"] elif os_name == "win32": - libname = ["gmt.lib", "gmt_w64.dll", "gmt_w32.dll"] + libname = ["gmt.dll", "gmt_w64.dll", "gmt_w32.dll"] else: raise GMTOSError('Operating system "{}" not supported.'.format(sys.platform)) return libname diff --git a/pygmt/tests/test_clib_loading.py b/pygmt/tests/test_clib_loading.py index a3c4f1140ce..1cc6dc4f4df 100644 --- a/pygmt/tests/test_clib_loading.py +++ b/pygmt/tests/test_clib_loading.py @@ -30,6 +30,6 @@ def test_clib_name(): for linux in ["linux", "linux2", "linux3"]: assert clib_name(linux) == ["libgmt.so"] assert clib_name("darwin") == ["libgmt.dylib"] - assert clib_name("win32") == ["gmt.lib", "gmt_w64.dll", "gmt_w32.dll"] + assert clib_name("win32") == ["gmt.dll", "gmt_w64.dll", "gmt_w32.dll"] with pytest.raises(GMTOSError): clib_name("meh") From aa70177563de48377d7da992d0957ee14a5cc06f Mon Sep 17 00:00:00 2001 From: Leonardo Uieda Date: Wed, 19 Jun 2019 19:22:23 -1000 Subject: [PATCH 04/12] Set GMT_LIBRARY_PATH --- .azure-pipelines.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.azure-pipelines.yml b/.azure-pipelines.yml index 68b8ace0a83..19662890dfc 100644 --- a/.azure-pipelines.yml +++ b/.azure-pipelines.yml @@ -156,6 +156,7 @@ jobs: CONDA_REQUIREMENTS_DEV: requirements-dev.txt CONDA_INSTALL_EXTRA: "codecov" CONDA_EXTRA_CHANNEL: "conda-forge/label/dev" + GMT_LIBRARY_PATH: "C:\Miniconda\envs\testing\lib" strategy: matrix: From b21f424d864eef5cb9604c642a0fb94ba447c2cf Mon Sep 17 00:00:00 2001 From: Leonardo Uieda Date: Thu, 20 Jun 2019 09:39:14 -1000 Subject: [PATCH 05/12] Update pygmt/clib/loading.py Co-Authored-By: Dongdong Tian --- pygmt/clib/loading.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pygmt/clib/loading.py b/pygmt/clib/loading.py index c77d8c3f6a2..dd5212cd057 100644 --- a/pygmt/clib/loading.py +++ b/pygmt/clib/loading.py @@ -46,6 +46,7 @@ def load_libgmt(env=None): try: libgmt = ctypes.CDLL(os.path.join(libpath, libname)) check_libgmt(libgmt) + break except OSError as err: error = err if error: From dfd34e64c8dcc3fd75f4d4242289fb093fde1332 Mon Sep 17 00:00:00 2001 From: Leonardo Uieda Date: Thu, 20 Jun 2019 09:42:56 -1000 Subject: [PATCH 06/12] Remove the GMT_LIBRARY_PATH definition --- .azure-pipelines.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.azure-pipelines.yml b/.azure-pipelines.yml index 19662890dfc..68b8ace0a83 100644 --- a/.azure-pipelines.yml +++ b/.azure-pipelines.yml @@ -156,7 +156,6 @@ jobs: CONDA_REQUIREMENTS_DEV: requirements-dev.txt CONDA_INSTALL_EXTRA: "codecov" CONDA_EXTRA_CHANNEL: "conda-forge/label/dev" - GMT_LIBRARY_PATH: "C:\Miniconda\envs\testing\lib" strategy: matrix: From efbd6ab4b0446f6791690d99aad44e20aa16a16c Mon Sep 17 00:00:00 2001 From: Leonardo Uieda Date: Thu, 20 Jun 2019 10:11:36 -1000 Subject: [PATCH 07/12] Temporarily disable clib info printing --- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 072b8ccdb50..4ff43f1cfcc 100644 --- a/Makefile +++ b/Makefile @@ -23,9 +23,9 @@ install: test: # Run a tmp folder to make sure the tests are run on the installed version mkdir -p $(TESTDIR) - @echo "" - @cd $(TESTDIR); python -c "import $(PROJECT); $(PROJECT).print_clib_info()" - @echo "" + #@echo "" + #@cd $(TESTDIR); python -c "import $(PROJECT); $(PROJECT).print_clib_info()" + #@echo "" cd $(TESTDIR); pytest $(PYTEST_ARGS) $(PROJECT) cp $(TESTDIR)/.coverage* . rm -r $(TESTDIR) From 611e5739044c6a420718f40b0cdb0919405664c8 Mon Sep 17 00:00:00 2001 From: Leonardo Uieda Date: Wed, 3 Jul 2019 13:16:02 -1000 Subject: [PATCH 08/12] Update to RC2 --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 7fa49cc889a..eb0b582614c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ # Requirements for installing with conda -gmt=6.0.0rc1 +gmt==6.0.0rc2 numpy pandas xarray From ce7d12a4c8a46f814c185cd9303496f0ccea46ef Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Tue, 6 Aug 2019 22:09:52 -0400 Subject: [PATCH 09/12] Update to GMT6.0.0rc3 --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index eb0b582614c..60d79300899 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ # Requirements for installing with conda -gmt==6.0.0rc2 +gmt==6.0.0rc3 numpy pandas xarray From 197ebb8ede5cf3d652427d6c00b58a9824b2bca3 Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Thu, 22 Aug 2019 01:29:10 -0400 Subject: [PATCH 10/12] Re-enable Windows CI in current PR --- .azure-pipelines.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.azure-pipelines.yml b/.azure-pipelines.yml index fd8d655c161..68b8ace0a83 100644 --- a/.azure-pipelines.yml +++ b/.azure-pipelines.yml @@ -147,7 +147,6 @@ jobs: ######################################################################################## - job: displayName: 'Windows' - condition: False pool: vmImage: 'vs2017-win2016' From 22fd4b010d22685a1302e5271a86aac66ed25059 Mon Sep 17 00:00:00 2001 From: Leonardo Uieda Date: Thu, 28 Nov 2019 17:27:24 +0000 Subject: [PATCH 11/12] Try compiling GMT on Windows builds --- .azure-pipelines.yml | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/.azure-pipelines.yml b/.azure-pipelines.yml index d8ca1163e2a..116a0fef61c 100644 --- a/.azure-pipelines.yml +++ b/.azure-pipelines.yml @@ -166,18 +166,12 @@ jobs: Python37: python.version: '3.7' PYTHON: '3.7' - Python36: - python.version: '3.6' - PYTHON: '3.6' + #Python36: + #python.version: '3.6' + #PYTHON: '3.6' steps: - # Install ghostscript separately since there is no Windows conda-forge package for it. - - bash: | - set -x -e - choco install ghostscript - displayName: Install ghostscript via chocolatey - - powershell: Write-Host "##vso[task.prependpath]$env:CONDA\Scripts" displayName: Add conda to PATH @@ -196,6 +190,13 @@ jobs: conda list displayName: List installed packages + # Download latest GMT + - script: git clone --branch=master --depth=1 https://github.com/GenericMappingTools/gmt.git + displayName: Download GMT + + # Build GMT + - template: gmt/ci/azure-pipelines-windows.yml + # Install the package that we want to test - bash: | set -x -e From 27afcdea290aa15fc0da97c676ba60a1aecf9cc7 Mon Sep 17 00:00:00 2001 From: Leonardo Uieda Date: Thu, 28 Nov 2019 17:40:36 +0000 Subject: [PATCH 12/12] Copy over Azure template from GMT It doesn't seem to like loading from a clone. It parses the templates before actually running anything. --- .azure-pipelines.yml | 2 +- ci/azure-pipelines-windows.yml | 88 ++++++++++++++++++++++++++++++++++ ci/config-gmt-windows.sh | 41 ++++++++++++++++ ci/download-coastlines.sh | 55 +++++++++++++++++++++ 4 files changed, 185 insertions(+), 1 deletion(-) create mode 100644 ci/azure-pipelines-windows.yml create mode 100755 ci/config-gmt-windows.sh create mode 100755 ci/download-coastlines.sh diff --git a/.azure-pipelines.yml b/.azure-pipelines.yml index 116a0fef61c..58616537366 100644 --- a/.azure-pipelines.yml +++ b/.azure-pipelines.yml @@ -195,7 +195,7 @@ jobs: displayName: Download GMT # Build GMT - - template: gmt/ci/azure-pipelines-windows.yml + - template: ci/azure-pipelines-windows.yml # Install the package that we want to test - bash: | diff --git a/ci/azure-pipelines-windows.yml b/ci/azure-pipelines-windows.yml new file mode 100644 index 00000000000..f3ab4ae8117 --- /dev/null +++ b/ci/azure-pipelines-windows.yml @@ -0,0 +1,88 @@ +# Template for Windows steps in Azure Pipelines + +steps: + +# Cache vcpkg installed libraries +# Currently, caches are immutable and can't be updated. +# To rebuild the cache, you have to change the date in the key list +- task: CacheBeta@0 + inputs: + key: $(Agent.OS) | vcpkg | 20190802 + path: $(VCPKG_INSTALLATION_ROOT)/installed/ + cacheHitVar: CACHE_VCPKG_RESTORED + displayName: Cache vcpkg libraries + +- bash: | + set -x -e + # By default, vcpkg builds both release and debug configurations. + # Set VCPKG_BUILD_TYPE to build release only to save half time + echo 'set (VCPKG_BUILD_TYPE release)' >> ${VCPKG_INSTALLATION_ROOT}/triplets/${WIN_PLATFORM}.cmake + cat ${VCPKG_INSTALLATION_ROOT}/triplets/${WIN_PLATFORM}.cmake + # install libraries + #vcpkg install netcdf-c gdal pcre fftw3 clapack openblas --triplet ${WIN_PLATFORM} + vcpkg install netcdf-c gdal pcre fftw3 --triplet ${WIN_PLATFORM} + displayName: Install dependencies via vcpkg + env: + WIN_PLATFORM: "x64-windows" + condition: ne(variables['CACHE_VCPKG_RESTORED'], true) + +- bash: | + # hook up user-wide integration + vcpkg integrate install + # list installed libraries + vcpkg list + # Executable files search for DLL files in the directories listed in the PATH environment variable. + echo "##vso[task.prependpath]${VCPKG_INSTALLATION_ROOT}/installed/${WIN_PLATFORM}/bin" + # Tools like gdal_translate, ogr2ogr are located in tools/gdal + echo "##vso[task.prependpath]${VCPKG_INSTALLATION_ROOT}/installed/${WIN_PLATFORM}/tools/gdal" + displayName: Configure vcpkg + env: + WIN_PLATFORM: "x64-windows" + +- bash: | + set -x -e + choco install ninja + choco install ghostscript --version 9.26 # gs 9.27 is buggy + displayName: Install dependencies via chocolatey + +- bash: | + echo "##vso[task.setvariable variable=INSTALLDIR]$BUILD_SOURCESDIRECTORY/gmt-install-dir" + echo "##vso[task.setvariable variable=COASTLINEDIR]$BUILD_SOURCESDIRECTORY/coastline" + displayName: Set install location and coastline location + +- bash: echo "##vso[task.prependpath]$INSTALLDIR/bin" + displayName: Set PATH + +- task: CacheBeta@0 + inputs: + key: coastline + path: $(COASTLINEDIR) + cacheHitVar: CACHE_COASTLINE_RESTORED + displayName: Cache GSHHG and DCW data + +- bash: ci/download-coastlines.sh + displayName: Download coastlines + condition: ne(variables['CACHE_COASTLINE_RESTORED'], true) + +- bash: ci/config-gmt-windows.sh + displayName: Configure GMT + +# Azure Pipelines cannot find Visual Studio correctly if Ninja is used. +# Here, we need +# 1. call the vcvars64.bat script +# 2. define CMAKE_C_COMPILER +- script: | + mkdir build + cd build + call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Auxiliary\Build\vcvars64.bat" + cmake .. -G "Ninja" -DCMAKE_TOOLCHAIN_FILE=%VCPKG_INSTALLATION_ROOT%\scripts\buildsystems\vcpkg.cmake -DCMAKE_C_COMPILER=cl.exe -DCMAKE_BUILD_TYPE=Release + cmake --build . + cmake --build . --target install + displayName: Compile GMT + +- script: | + gmt --version + gmt defaults -Vd + gmt pscoast -R0/10/0/10 -JM6i -Ba -Ggray -ENG+p1p,blue -P -Vd > test.ps + gmt begin && gmt coast -R0/10/0/10 -JM6i -Ba -Ggray -ENG+p1p,blue -Vd && gmt end + displayName: Check a few simple commands diff --git a/ci/config-gmt-windows.sh b/ci/config-gmt-windows.sh new file mode 100755 index 00000000000..ce1d7eeda46 --- /dev/null +++ b/ci/config-gmt-windows.sh @@ -0,0 +1,41 @@ +#!/usr/bin/env bash +# Build and install GMT + +# To return a failure if any commands inside fail +set -e + +cat > cmake/ConfigUser.cmake << 'EOF' +set (CMAKE_INSTALL_PREFIX "$ENV{INSTALLDIR}") +set (GSHHG_ROOT "$ENV{COASTLINEDIR}/gshhg") +set (DCW_ROOT "$ENV{COASTLINEDIR}/dcw") +set (COPY_GSHHG TRUE) +set (COPY_DCW TRUE) +set (GMT_INSTALL_MODULE_LINKS FALSE) +set (CMAKE_C_FLAGS "/D_CRT_SECURE_NO_WARNINGS /D_CRT_SECURE_NO_DEPRECATE ${CMAKE_C_FLAGS}") +set (CMAKE_C_FLAGS "/D_CRT_NONSTDC_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE ${CMAKE_C_FLAGS}") +EOF + +if [[ "$TEST" == "true" ]]; then + cat >> cmake/ConfigUser.cmake << 'EOF' +enable_testing() +set (DO_EXAMPLES TRUE) +set (DO_TESTS TRUE) +set (DO_API_TESTS ON) +set (SUPPORT_EXEC_IN_BINARY_DIR TRUE) +EOF +fi + +if [[ "$BUILD_DOCS" == "true" ]]; then + cat >> cmake/ConfigUser.cmake << 'EOF' +set (DO_ANIMATIONS TRUE) +set (CMAKE_VERBOSE_MAKEFILE ON CACHE BOOL "ON") +EOF +fi + +echo "" +echo "Using the following cmake configuration:" +cat cmake/ConfigUser.cmake +echo "" + +# Turn off exit on failure. +set +e diff --git a/ci/download-coastlines.sh b/ci/download-coastlines.sh new file mode 100755 index 00000000000..6033b9ec291 --- /dev/null +++ b/ci/download-coastlines.sh @@ -0,0 +1,55 @@ +#!/usr/bin/env bash +# Download and install the coastlines and boundaries datasets + +# General settings: +EXT="tar.gz" +GSHHG="gshhg-gmt-2.3.7" +DCW="dcw-gmt-1.1.4" +MD5_GSHHG=8ee2653f9daf84d49fefbf990bbfa1e7 +MD5_DCW=4f30857a8b12af0f910222fceb591538 + +# Used for checking the downloaded files: +check_md5 () +{ + md5_ref=$1 + file=$2 + + test -f "$file" || return 1 + md5=$(openssl dgst -md5 $file | cut -d ' ' -f 2) + test "$md5" = "$md5_ref" +} + +# To return a failure if any commands inside fail +set -e + +# Create the directory for coastline data +mkdir -p $COASTLINEDIR + +# GSHHG and DCW tarballs are cached here: +test -d $HOME/cache-gshhg-dcw || mkdir $HOME/cache-gshhg-dcw +cd $HOME/cache-gshhg-dcw + +# GSHHG (coastlines, rivers, and political boundaries): +echo "" +echo "Downloading and unpacking GSHHG" +echo "================================================================================" +# download when md5sums don't match: +check_md5 $MD5_GSHHG $GSHHG.$EXT || curl -L -O --retry 10 "https://mirrors.ustc.edu.cn/gmt/$GSHHG.$EXT" +check_md5 $MD5_GSHHG $GSHHG.$EXT +tar xzf $GSHHG.$EXT +mv $GSHHG $COASTLINEDIR/gshhg + +# DCW (country polygons): +echo "" +echo "Downloading and unpacking DCW" +echo "================================================================================" +# download when md5sums don't match: +check_md5 $MD5_DCW $DCW.$EXT || curl -L -O --retry 10 "https://mirrors.ustc.edu.cn/gmt/$DCW.$EXT" +check_md5 $MD5_DCW $DCW.$EXT +tar xzf $DCW.$EXT +mv $DCW $COASTLINEDIR/dcw + +ls $COASTLINEDIR/gshhg $COASTLINEDIR/dcw + +# Turn off exit on failure. +set +e