Skip to content

Commit

Permalink
Update for 'eccodes'. (spack#5899)
Browse files Browse the repository at this point in the history
  • Loading branch information
skosukhin authored and tgamblin committed Oct 25, 2017
1 parent 5d3a774 commit ce8a698
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 20 deletions.
26 changes: 26 additions & 0 deletions var/spack/repos/builtin/packages/eccodes/enable_only_jasper.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index bf4d78b..ea2f3e9 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -162,8 +162,6 @@ if( ENABLE_JPG )
set(CMAKE_PREFIX_PATH ${_CMAKE_PREFIX_PATH}) # Restore CMAKE_PREFIX_PATH
set(CMAKE_WARN_DEPRECATED ON) # Remove suppression

- find_package( OpenJPEG )
-
if( JASPER_FOUND )
list( APPEND ECCODES_TPLS Jasper )
set( HAVE_JPEG 1 )
@@ -172,12 +170,6 @@ if( ENABLE_JPG )
string(REGEX REPLACE "^([0-9]+)\\.[0-9]+\\.[0-9]+.*" "\\1" JASPER_VERSION_MAJOR "${JASPER_VERSION_STRING}")
endif()

- if( OPENJPEG_FOUND )
- list( APPEND ECCODES_TPLS OpenJPEG )
- set( HAVE_JPEG 1 )
- set( HAVE_LIBOPENJPEG 1 )
- endif()
-
endif()


Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index bf4d78b..3ae50ba 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -151,27 +151,8 @@ set( HAVE_LIBOPENJPEG 0 )

if( ENABLE_JPG )

- # Note: This is a deprecated feature but we need it to find Jasper at ECMWF.
- # ecbuild_add_extra_search_paths modifies CMAKE_PREFIX_PATH
- # which can affect future package discovery if not undone by the caller.
- # The current CMAKE_PREFIX_PATH is backed up as _CMAKE_PREFIX_PATH
- #
- set(CMAKE_WARN_DEPRECATED OFF) # Suppress deprecation message
- ecbuild_add_extra_search_paths( jasper )
- find_package( Jasper )
- set(CMAKE_PREFIX_PATH ${_CMAKE_PREFIX_PATH}) # Restore CMAKE_PREFIX_PATH
- set(CMAKE_WARN_DEPRECATED ON) # Remove suppression
-
find_package( OpenJPEG )

- if( JASPER_FOUND )
- list( APPEND ECCODES_TPLS Jasper )
- set( HAVE_JPEG 1 )
- set( HAVE_LIBJASPER 1 )
- # Extract Jasper's major version number to enable conditional code. See ECC-396
- string(REGEX REPLACE "^([0-9]+)\\.[0-9]+\\.[0-9]+.*" "\\1" JASPER_VERSION_MAJOR "${JASPER_VERSION_STRING}")
- endif()
-
if( OPENJPEG_FOUND )
list( APPEND ECCODES_TPLS OpenJPEG )
set( HAVE_JPEG 1 )
64 changes: 44 additions & 20 deletions var/spack/repos/builtin/packages/eccodes/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,37 +34,61 @@ class Eccodes(CMakePackage):
url = "https://software.ecmwf.int/wiki/download/attachments/45757960/eccodes-2.2.0-Source.tar.gz?api=v2"
list_url = "https://software.ecmwf.int/wiki/display/ECC/Releases"

version('2.5.0', '5a7e92c58418d855082fa573efd352aa')
version('2.2.0', 'b27e6f0a3eea5b92dac37372e4c45a62')

variant('netcdf', default=True,
description="Support GRIB to NetCDF conversion")
variant('jpeg', default=True,
description="Support JPEG2000 encoding/decoding")
variant('png', default=True,
description="Support PNG encoding/decoding")
variant('python', default=False,
description="Build the eccodes Python interface")
variant('netcdf', default=False,
description='Enable GRIB to NetCDF conversion tool')
variant('jp2k', default='openjpeg', values=('openjpeg', 'jasper', 'none'),
description='Specify JPEG2000 decoding/encoding backend')
variant('png', default=False,
description='Enable PNG support for decoding/encoding')
variant('aec', default=False,
description='Enable Adaptive Entropy Coding for decoding/encoding')
variant('pthreads', default=False,
description="Enable POSIX threads")
description='Enable POSIX threads')
variant('openmp', default=False,
description="Enable OpenMP threads")
description='Enable OpenMP threads')
variant('memfs', default=False,
description="Memory based access to definitions/samples")
description='Enable memory based access to definitions/samples')
variant('python', default=False,
description='Enable the Python interface')
variant('fortran', default=True, description='Enable the Fortran support')
variant('build_type', default='RelWithDebInfo',
description='The build type to build',
values=('Debug', 'Release', 'RelWithDebInfo', 'Production'))

depends_on('netcdf', when='+netcdf')
depends_on('openjpeg', when='+jpeg')
depends_on('openjpeg', when='jp2k=openjpeg')
depends_on('jasper', when='jp2k=jasper')
depends_on('libpng', when='+png')
depends_on('py-numpy', when='+python')
depends_on('libaec', when='+aec')
depends_on('python@:2', when='+python')
depends_on('py-numpy', when='+python', type=('build', 'run'))
extends('python', when='+python')

conflicts('+openmp', when='+pthreads',
msg='Cannot enable both POSIX threads and OMP')

# The following enforces linking against the specified JPEG2000 backend.
patch('enable_only_openjpeg.patch', when='jp2k=openjpeg')
patch('enable_only_jasper.patch', when='jp2k=jasper')

def cmake_args(self):
variants = ['+netcdf', '+jpeg', '+png', '+python',
'+pthreads', '+openmp', '+memfs']
options = ['NETCDF', 'JPG', 'PNG', 'PYTHON',
'ECCODES_THREADS', 'ECCODES_OMP_THREADS', 'MEMFS']
return map(lambda variant, option: "-DENABLE_%s=%s" %
(option, 'YES' if variant in self.spec else 'NO'),
variants, options)
variants = ['+netcdf', '+png', '+aec', '+pthreads',
'+openmp', '+memfs', '+python', '+fortran']
options = ['NETCDF', 'PNG', 'AEC', 'ECCODES_THREADS',
'ECCODES_OMP_THREADS', 'MEMFS', 'PYTHON', 'FORTRAN']

args = map(lambda var, opt:
"-DENABLE_%s=%s" %
(opt, 'ON' if var in self.spec else 'OFF'),
variants,
options)

if self.spec.variants['jp2k'].value == 'none':
args.append('-DENABLE_JPG=OFF')
else:
args.append('-DENABLE_JPG=ON')

return args

0 comments on commit ce8a698

Please sign in to comment.