Skip to content

Commit

Permalink
enh: add zeromq build integration
Browse files Browse the repository at this point in the history
add zeromq build support to uberenv
add conduit cmake setup for zeromq
add smoke conduit tpl test for zeromq
  • Loading branch information
cyrush committed Nov 14, 2016
1 parent b41cb99 commit cffa30e
Show file tree
Hide file tree
Showing 7 changed files with 279 additions and 0 deletions.
52 changes: 52 additions & 0 deletions scripts/uberenv/packages/libsodium/package.py
@@ -0,0 +1,52 @@
##############################################################################
# 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 LICENSE file 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
##############################################################################
from spack import *


class Libsodium(Package):
"""Sodium is a modern, easy-to-use software library for encryption,
decryption, signatures, password hashing and more."""
homepage = "https://download.libsodium.org/doc/"
url = "https://download.libsodium.org/libsodium/releases/libsodium-1.0.11.tar.gz"

version('1.0.11', 'b58928d035064b2a46fb564937b83540')
version('1.0.10', 'ea89dcbbda0b2b6ff6a1c476231870dd')
version('1.0.3', 'b3bcc98e34d3250f55ae196822307fab')
version('1.0.2', 'dc40eb23e293448c6fc908757738003f')
version('1.0.1', '9a221b49fba7281ceaaf5e278d0f4430')
version('1.0.0', '3093dabe4e038d09f0d150cef064b2f7')
version('0.7.1', 'c224fe3923d1dcfe418c65c8a7246316')

def url_for_version(self, version):
url = 'https://download.libsodium.org/libsodium/releases/'
if version < Version('1.0.4'):
url += 'old/'
return url + 'libsodium-{0}.tar.gz'.format(version)

def install(self, spec, prefix):
configure("--prefix=%s" % prefix)

make()
make("install")
9 changes: 9 additions & 0 deletions scripts/uberenv/packages/uberenv-conduit/package.py
Expand Up @@ -68,6 +68,7 @@ class UberenvConduit(Package):
variant("python",default=True,description="build python 2")
variant("python3",default=True,description="build python 3")
variant("mpich",default=False,description="build mpich as MPI lib for Conduit")
variant("zeromq",default=True,description="build third party dependencies for Conduit ZeroMQ support")


###########################
Expand Down Expand Up @@ -108,6 +109,7 @@ class UberenvConduit(Package):
#######################
# i/o packages
#######################
depends_on("zeromq",when="+zeromq")
depends_on("hdf5",when="+hdf5")
depends_on("silo",when="+silo")

Expand Down Expand Up @@ -243,6 +245,13 @@ def install(self, spec, prefix):
if not mpiexec is None:
cfg.write(cmake_cache_entry("MPIEXEC", mpiexec.command))

#######################
# zeromq
#######################
if "+zeromq" in spec:
cfg.write("# zeromq from uberenv\n")
cfg.write(cmake_cache_entry("ZEROMQ_DIR",spec['zeromq'].prefix))

#######################
#######################
# i/o packages
Expand Down
51 changes: 51 additions & 0 deletions scripts/uberenv/packages/zeromq/package.py
@@ -0,0 +1,51 @@
##############################################################################
# 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 LICENSE file 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
##############################################################################
from spack import *


class Zeromq(Package):
""" The ZMQ networking/concurrency library and core API """
homepage = "http://zguide.zeromq.org/"
url = "http://download.zeromq.org/zeromq-4.1.2.tar.gz"

# versions newer than 4.0.7 fail on osx due to missing pkg cfg
# https://github.com/zeromq/libzmq/issues/1642
#version('4.1.4', 'a611ecc93fffeb6d058c0e6edf4ad4fb')
#version('4.1.2', '159c0c56a895472f02668e692d122685')
#version('4.1.1', '0a4b44aa085644f25c177f79dc13f253')


version('4.0.7', '9b46f7e7b0704b83638ef0d461fd59ab')
version('4.0.6', 'd47dd09ed7ae6e7fd6f9a816d7f5fdf6')
version('4.0.5', '73c39f5eb01b9d7eaf74a5d899f1d03d')

depends_on("libsodium")
#depends_on("libsodium@:1.0.3", when='@:4.1.2')

def install(self, spec, prefix):
configure("--with-libsodium", "--prefix=%s" % prefix)

make()
make("install")
13 changes: 13 additions & 0 deletions src/CMake/Setup3rdParty.cmake
Expand Up @@ -148,6 +148,19 @@ if(ENABLE_MPI)
endif()


################################
# Setup ZeroMQ if available
################################
# Search for ZeroMQ.
if(ZEROMQ_DIR)
include(CMake/thirdparty/SetupZeroMQ.cmake)
include_directories(${ZEROMQ_INCLUDE_DIRS})
# if we don't find ZeroMQ, throw a fatal error
if(NOT ZEROMQ_FOUND)
message(FATAL_ERROR "ZEROMQ_DIR is set, but ZeroMQ wasn't found.")
endif()
endif()

################################
# Setup HDF5 if available
################################
Expand Down
77 changes: 77 additions & 0 deletions src/CMake/thirdparty/SetupZeroMQ.cmake
@@ -0,0 +1,77 @@
###############################################################################
# Copyright (c) 2014-2016, Lawrence Livermore National Security, LLC.
#
# Produced at the Lawrence Livermore National Laboratory
#
# LLNL-CODE-666778
#
# All rights reserved.
#
# This file is part of Conduit.
#
# For details, see: http://software.llnl.gov/conduit/.
#
# Please also read conduit/LICENSE
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the disclaimer below.
#
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the disclaimer (as noted below) in the
# documentation and/or other materials provided with the distribution.
#
# * Neither the name of the LLNS/LLNL nor the names of its contributors may
# be used to endorse or promote products derived from this software without
# specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL SECURITY,
# LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
# IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
###############################################################################
#
# Setup ZeroMQ
# This file defines:
# ZEROMQ_FOUND - If ZeroMQ was found
# ZEROMQ_INCLUDE_DIRS - The ZeroMQ include directories
# ZEROMQ_LIBRARIES - The libraries needed to use ZeroMQ


if(NOT ZEROMQ_DIR)
MESSAGE(FATAL_ERROR "ZeroMQ support needs explicit ZEROMQ_DIR")
endif()

find_path(ZEROMQ_INCLUDE_DIRS zmq.h
PATHS ${ZEROMQ_DIR}/include
NO_DEFAULT_PATH
NO_CMAKE_ENVIRONMENT_PATH
NO_CMAKE_PATH
NO_SYSTEM_ENVIRONMENT_PATH
NO_CMAKE_SYSTEM_PATH)

find_library(ZEROMQ_LIBRARIES NAMES zmq
PATHS ${ZEROMQ_DIR}/lib
NO_DEFAULT_PATH
NO_CMAKE_ENVIRONMENT_PATH
NO_CMAKE_PATH
NO_SYSTEM_ENVIRONMENT_PATH
NO_CMAKE_SYSTEM_PATH)

include(FindPackageHandleStandardArgs)
# handle the QUIETLY and REQUIRED arguments and set SILO_FOUND to TRUE
# if all listed variables are TRUE
find_package_handle_standard_args(ZeroMQ DEFAULT_MSG
ZEROMQ_LIBRARIES ZEROMQ_INCLUDE_DIRS)

11 changes: 11 additions & 0 deletions src/tests/thirdparty/CMakeLists.txt
Expand Up @@ -60,6 +60,7 @@ set(CIVET_TPL_TEST t_civetweb_smoke)
################################
set(PYTHON_TESTS t_numpy_smoke)
set(MPI_TESTS t_mpi_smoke)
set(ZEROMQ_TESTS t_zeromq_smoke)
set(HDF5_TESTS t_hdf5_smoke)
set(SILO_TESTS t_silo_smoke)

Expand Down Expand Up @@ -110,6 +111,16 @@ else()
endif()


if(ZEROMQ_FOUND)
message(STATUS "ZeroMQ enabled: Adding related unit tests")
foreach(TEST ${ZEROMQ_TESTS})
add_cpp_test(TEST ${TEST})
target_link_libraries(${TEST} ${ZEROMQ_LIBRARIES})
endforeach()
else()
message(STATUS "ZeroMQ disabled: Skipping related tests")
endif()

if(MPI_FOUND)
message(STATUS "MPI enabled: Adding related unit tests")
foreach(TEST ${MPI_TESTS})
Expand Down
66 changes: 66 additions & 0 deletions src/tests/thirdparty/t_zeromq_smoke.cpp
@@ -0,0 +1,66 @@
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// Copyright (c) 2014-2016, Lawrence Livermore National Security, LLC.
//
// Produced at the Lawrence Livermore National Laboratory
//
// LLNL-CODE-666778
//
// All rights reserved.
//
// This file is part of Conduit.
//
// For details, see: http://software.llnl.gov/conduit/.
//
// Please also read conduit/LICENSE
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the disclaimer below.
//
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the disclaimer (as noted below) in the
// documentation and/or other materials provided with the distribution.
//
// * Neither the name of the LLNS/LLNL nor the names of its contributors may
// be used to endorse or promote products derived from this software without
// specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL SECURITY,
// LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS BE LIABLE FOR ANY
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
// OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
// IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//

//-----------------------------------------------------------------------------
///
/// file: t_zeromq_smoke.cpp
///
//-----------------------------------------------------------------------------

#include "gtest/gtest.h"
#include <zmq.h>

//-----------------------------------------------------------------------------
TEST(zeromq_smoke, create_and_destroy_context)
{
// test compiling and linking with zeromq
void *context = zmq_ctx_new();
EXPECT_TRUE(context != NULL);
void *socket = zmq_socket(context, ZMQ_REP);
EXPECT_TRUE(socket != NULL);
EXPECT_EQ(zmq_close(socket),0);
EXPECT_EQ(zmq_ctx_destroy(context),0);
}


0 comments on commit cffa30e

Please sign in to comment.