From 949f39236a63842d4b311ab9623e008ee6f4e38e Mon Sep 17 00:00:00 2001 From: Pat Riehecky Date: Jun 24 2021 21:04:15 +0000 Subject: Initial build --- diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2e17bdf --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/jsonnet-0.17.0.tar.gz diff --git a/0001-Dynamic-link-to-libjsonnet-rather-than-static.patch b/0001-Dynamic-link-to-libjsonnet-rather-than-static.patch new file mode 100644 index 0000000..d112f90 --- /dev/null +++ b/0001-Dynamic-link-to-libjsonnet-rather-than-static.patch @@ -0,0 +1,34 @@ +From d904d586ad312b31acf5d1f011f21e40c985028c Mon Sep 17 00:00:00 2001 +From: Pat Riehecky +Date: Wed, 23 Jun 2021 08:28:33 -0500 +Subject: [PATCH] Dynamic link to libjsonnet rather than static + +--- + setup.py | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/setup.py b/setup.py +index 8cc5ce4..b4cf2ae 100644 +--- a/setup.py ++++ b/setup.py +@@ -60,7 +60,7 @@ def get_version(): + + class BuildJsonnetExt(BuildExt): + def run(self): +- p = Popen(['make'] + LIB_OBJECTS, cwd=DIR) ++ p = Popen(['make', 'libs'] , cwd=DIR) + p.wait() + if p.returncode != 0: + raise Exception('Could not build %s' % (', '.join(LIB_OBJECTS))) +@@ -69,7 +69,7 @@ class BuildJsonnetExt(BuildExt): + jsonnet_ext = Extension( + '_jsonnet', + sources=MODULE_SOURCES, +- extra_objects=LIB_OBJECTS, ++ extra_objects=['libjsonnet.so.0', ], + include_dirs = ['include', 'third_party/md5', 'third_party/json'], + language='c++' + ) +-- +2.31.1 + diff --git a/0002-jsonnet-0.17.0-do-not-override-compiler-flags.patch b/0002-jsonnet-0.17.0-do-not-override-compiler-flags.patch new file mode 100644 index 0000000..397f01e --- /dev/null +++ b/0002-jsonnet-0.17.0-do-not-override-compiler-flags.patch @@ -0,0 +1,36 @@ +From 052efc6196c602db6b72f95d09f838cde6070127 Mon Sep 17 00:00:00 2001 +From: Ben Beasley +Date: Wed, 23 Jun 2021 13:20:22 -0500 +Subject: [PATCH] patch CMakeLists.txt to stop overriding build flags + +--- + CMakeLists.txt | 8 +++----- + 1 file changed, 3 insertions(+), 5 deletions(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 5df20ca..1d6eb73 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -35,16 +35,14 @@ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${GLOBAL_OUTPUT_PATH}) + # Compiler flags. + if (${CMAKE_CXX_COMPILER_ID} MATCHES "Clang" OR + ${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") +- set(OPT "-O3") +- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -Wall -Wextra -pedantic -std=c99 -O3 ${OPT}") +- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -Wall -Wextra -Woverloaded-virtual -pedantic -std=c++11 -fPIC ${OPT}") ++ set(OPT "") ++ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -Wall -Wextra -pedantic ${OPT}") ++ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -Wall -Wextra -Woverloaded-virtual -pedantic -fPIC ${OPT}") + else() + # TODO: Windows support. + message(FATAL_ERROR "Compiler ${CMAKE_CXX_COMPILER_ID} not supported") + endif() + +-set(CMAKE_CXX_STANDARD 11) +- + + # Include external googletest project. This runs a CMake sub-script + # (CMakeLists.txt.in) that downloads googletest source. It's then built as part +-- +2.31.1 + diff --git a/jsonnet.spec b/jsonnet.spec new file mode 100644 index 0000000..19046c4 --- /dev/null +++ b/jsonnet.spec @@ -0,0 +1,151 @@ +%global so_version 0 + +Name: jsonnet +Version: 0.17.0 +Release: 1%{?dist} +Summary: Diff JSON and JSON-like structures + +# The bundled MD5 library is RSA licenced +License: ASL 2.0 and RSA + +URL: https://github.com/google/jsonnet +Source0: %{url}/archive/v%{version}/%{name}-%{version}.tar.gz + +# Upstream wants to build single source wheels +# these benefit from static linking, +# but we want to link to libjsonnet here so we are sharing the lib +Patch0001: 0001-Dynamic-link-to-libjsonnet-rather-than-static.patch +Patch0002: 0002-jsonnet-0.17.0-do-not-override-compiler-flags.patch + + +# Bundled MD5 C++ class with very permissive license (RSA) +# rpmlint must be notified of the unversioned provides +Provides: bundled(md5-thilo) + +BuildRequires: python3-devel +BuildRequires: python3-setuptools + +BuildRequires: bash cmake gcc gcc-c++ gtest-devel make + +# json is header only, so note the static lib for tracking +BuildRequires: json-devel json-static + +# Set our toplevel runtime requirements +Requires: %{name}-libs%{?_isa} = %{version}-%{release} + +%global _description %{expand: +A data templating language for app and tool developers based on JSON} + +%description %{_description} + + +%package -n python3-%{name} +Summary: %{name} Bindings for Python +Requires: %{name}-libs%{?_isa} = %{version}-%{release} + +%description -n python3-%{name} %{_description} + + +%package libs +Summary: Shared Libraries for %{name} + +%description libs %{_description} + + +%package devel +Summary: Development Headers for %{name} +Requires: %{name}-libs%{?_isa} = %{version}-%{release} + +%description devel %{_description} + + +%package doc +Summary: Documentation for %{name} +License: CC-BY +BuildArch: noarch + +%description doc %{_description} + + +%prep +%autosetup + +# use system json lib instead +rm -rfv third_party/json/* + +# don't bundel rapidyaml +rm -rfv third_party/rapidyaml/* + +# don't bundle thirdparty doc resources +# this leaves the doc "unbuilt" but still sorta useful +rm -rf doc/third_party +rm -rf doc/.gitignore + + +%build + +%if 0%{?rhel} == 8 +# required macro drop for EL8 +%undefine __cmake_in_source_build +%endif + + +# FIXME: +# For reasons I'm not following, json-devel isn't added to include by cmake +# +# explicitly set -fPIC so python can pick it up later on +export CXXFLAGS="%{optflags} -fPIC -I%{_includedir}/nlohmann" + +# setup our build environment +%cmake -DBUILD_SHARED_BINARIES:BOOL=ON -DBUILD_STATIC_LIBS:BOOL=OFF -DUSE_SYSTEM_JSON:BOOL=ON -DUSE_SYSTEM_GTEST:BOOL=ON + +# make tools and headers +%cmake_build + +# make python binding +%{py3_build} + + +%install +%{cmake_install} + +# install python binding +%{py3_install} + + +%check +%ctest + + +%files +%{_bindir}/jsonnet +%{_bindir}/jsonnetfmt + +%files libs +%license LICENSE +%doc README.md +%{_libdir}/lib%{name}*.so.%{so_version} +%{_libdir}/lib%{name}*.so.%{version} + +%files devel +%{_includedir}/lib%{name}* +%{_libdir}/lib%{name}*.so + +%files -n python3-%{name} +# rpmlint must be notified this is not versioned on purpose +%{python3_sitearch}/_%{name}*.so +%{python3_sitearch}/%{name}-%{version}-py%{python3_version}.egg-info + +%files doc +%license LICENSE +%doc README.md +%doc CONTRIBUTING +%doc doc +%doc examples +# don't package up the self-check script +%exclude %{_docdir}/%{name}-doc/examples/*.sh + + +%changelog +* Thu Jun 17 2021 Pat Riehecky - 0.17.0-1 +- Initial package. diff --git a/sources b/sources new file mode 100644 index 0000000..637aa51 --- /dev/null +++ b/sources @@ -0,0 +1 @@ +SHA512 (jsonnet-0.17.0.tar.gz) = d3ee6947163d8abced504ff37ecf365c0311164cbf243d4c635d34944f0831ca9fce2470acf00eb9a218f82a2e553b3f885db9bd21bb9dcefbd707fa0202925d