Add new package for rhash, a cmake dependency (#5120)

* Add new package for rhash, a cmake dependency

* Add missing libuv dependency to cmake
This commit is contained in:
Adam J. Stewart 2017-08-17 08:17:45 -05:00 committed by GitHub
parent 3bb7767839
commit 187f4420e2
2 changed files with 120 additions and 40 deletions

View File

@ -64,72 +64,74 @@ class Cmake(Package):
depends_on('bzip2', when='~ownlibs')
depends_on('xz', when='~ownlibs')
depends_on('libarchive', when='~ownlibs')
depends_on('libuv@1.0.0:', when='~ownlibs')
depends_on('rhash', when='@3.8.0:~ownlibs')
depends_on('qt', when='+qt')
depends_on('python@2.7.11:', when='+doc', type='build')
depends_on('py-sphinx', when='+doc', type='build')
depends_on("openssl", when='+openssl')
depends_on("openssl@:1.0.99", when='@:3.6.9+openssl')
depends_on('openssl', when='+openssl')
depends_on('openssl@:1.0.99', when='@:3.6.9+openssl')
depends_on('ncurses', when='+ncurses')
# Cannot build with Intel, should be fixed in 3.6.2
# https://gitlab.kitware.com/cmake/cmake/issues/16226
patch('intel-c-gnu11.patch', when='@3.6.0:3.6.1')
conflicts('+qt', when='^qt@5.4.0') # qt-5.4.0 has broken CMake modules
phases = ['bootstrap', 'build', 'install']
def url_for_version(self, version):
"""Handle CMake's version-based custom URLs."""
return 'https://cmake.org/files/v%s/cmake-%s.tar.gz' % (
version.up_to(2), version)
url = 'https://cmake.org/files/v{0}/cmake-{1}.tar.gz'
return url.format(version.up_to(2), version)
def validate(self, spec):
"""
Checks if incompatible versions of qt were specified
:param spec: spec of the package
:raises RuntimeError: in case of inconsistencies
"""
if '+qt' in spec and spec.satisfies('^qt@5.4.0'):
msg = 'qt-5.4.0 has broken CMake modules.'
raise RuntimeError(msg)
def install(self, spec, prefix):
# Consistency check
self.validate(spec)
options = [
'--prefix={0}'.format(prefix),
'--parallel={0}'.format(make_jobs)]
if spec.satisfies("@3.2:"):
options.append(
# jsoncpp requires CMake to build
# use CMake-provided library to avoid circular dependency
'--no-system-jsoncpp'
)
def bootstrap_args(self):
spec = self.spec
args = [
'--prefix={0}'.format(self.prefix),
'--parallel={0}'.format(make_jobs)
]
if '+ownlibs' in spec:
# Build and link to the CMake-provided third-party libraries
options.append('--no-system-libs')
args.append('--no-system-libs')
else:
# Build and link to the Spack-installed third-party libraries
options.append('--system-libs')
args.append('--system-libs')
if spec.satisfies('@3.2:'):
# jsoncpp requires CMake to build
# use CMake-provided library to avoid circular dependency
args.append('--no-system-jsoncpp')
if '+qt' in spec:
options.append('--qt-gui')
args.append('--qt-gui')
else:
options.append('--no-qt-gui')
args.append('--no-qt-gui')
if '+doc' in spec:
options.append('--sphinx-html')
options.append('--sphinx-man')
args.append('--sphinx-html')
args.append('--sphinx-man')
if '+openssl' in spec:
options.append('--')
options.append('-DCMAKE_USE_OPENSSL=ON')
args.append('--')
args.append('-DCMAKE_USE_OPENSSL=ON')
return args
def bootstrap(self, spec, prefix):
bootstrap = Executable('./bootstrap')
bootstrap(*options)
bootstrap(*self.bootstrap_args())
def build(self, spec, prefix):
make()
if self.run_tests:
make('test') # some tests fail, takes forever
@run_after('build')
@on_package_attributes(run_tests=True)
def test(self):
# Some tests fail, takes forever
make('test')
def install(self, spec, prefix):
make('install')

View File

@ -0,0 +1,78 @@
##############################################################################
# Copyright (c) 2013-2016, Lawrence Livermore National Security, LLC.
# Produced at the Lawrence Livermore National Laboratory.
#
# This file is part of Spack.
# Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved.
# LLNL-CODE-647188
#
# For details, see https://github.com/llnl/spack
# Please also see the NOTICE and LICENSE files for our notice and the LGPL.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License (as
# published by the Free Software Foundation) version 2.1, February 1999.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms and
# conditions of the GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
##############################################################################
import glob
from spack import *
class Rhash(MakefilePackage):
"""RHash is a console utility for computing and verifying hash sums of
files. It supports CRC32, MD4, MD5, SHA1, SHA256, SHA512, SHA3, Tiger,
TTH, Torrent BTIH, AICH, ED2K, GOST R 34.11-94, RIPEMD-160, HAS-160,
EDON-R 256/512, WHIRLPOOL and SNEFRU hash sums."""
homepage = "https://sourceforge.net/projects/rhash/"
url = "https://github.com/rhash/RHash/archive/v1.3.5.tar.gz"
version('1.3.5', 'f586644019c10c83c6b6835de4b99e74')
# For macOS build instructions, see:
# https://github.com/Homebrew/homebrew-core/blob/master/Formula/rhash.rb
def build(self, spec, prefix):
# Doesn't build shared libraries by default
make()
if spec.satisfies('platform=darwin'):
make('-C', 'librhash', 'dylib')
else:
make('lib-shared')
def check(self):
# Makefile has both `test` and `check` targets:
#
# * `test` - used to test that the build is working properly
# * `check` - used to check that the tarball is ready for upload
#
# Default implmentation is to run both `make test` and `make check`.
# `test` passes, but `check` fails, so only run `test`.
make('test')
make('test-static-lib')
if not self.spec.satisfies('platform=darwin'):
make('test-shared')
make('test-shared-lib')
def install(self, spec, prefix):
# Some things are installed to $(DESTDIR)$(PREFIX) while other things
# are installed to $DESTDIR/etc.
make('install', 'DESTDIR={0}'.format(prefix), 'PREFIX=')
make('install-lib-static', 'DESTDIR={0}'.format(prefix), 'PREFIX=')
if spec.satisfies('platform=darwin'):
libs = glob.glob('librhash/*.dylib')
for lib in libs:
install(lib, prefix.lib)
else:
make('install-lib-shared', 'DESTDIR={0}'.format(prefix), 'PREFIX=')