From 4b1903e923f5958d892c60dd344dc89cd9e9f026 Mon Sep 17 00:00:00 2001 From: Bartek Kryza Date: Sat, 11 Jun 2022 23:54:46 +0200 Subject: [PATCH] Added conda packaging script --- .gitignore | 2 ++ packaging/Makefile | 17 +++++++++++++- packaging/conda/build.sh | 23 ++++++++++++++++++ packaging/conda/meta.yaml.in | 45 ++++++++++++++++++++++++++++++++++++ 4 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 packaging/conda/build.sh create mode 100644 packaging/conda/meta.yaml.in diff --git a/.gitignore b/.gitignore index c615ae18..26a06f93 100644 --- a/.gitignore +++ b/.gitignore @@ -21,7 +21,9 @@ bin/ docs/diagrams coverage*.info + packaging/_BUILD +packaging/conda/meta.yaml # CLion diff --git a/packaging/Makefile b/packaging/Makefile index 3902c77b..a400e67d 100644 --- a/packaging/Makefile +++ b/packaging/Makefile @@ -17,7 +17,7 @@ SHELL := /bin/bash .ONESHELL: -.PHONY: download deb clean +.PHONY: download deb clean conda NAME ?= clang-uml REBUILD ?= 1 @@ -31,6 +31,8 @@ TAR_EXT ?= gz build_dir = _BUILD/$(NAME)/$(OS)/$(DIST) VERSION ?= $(shell git describe --tags --always --abbrev=7) +COMMIT ?= $(shell git rev-parse HEAD) +BRANCH ?= $(shell git rev-parse --abbrev-ref HEAD) # # Replace mustache template variable in all files in directory recursively, @@ -41,6 +43,9 @@ define subst_template_dir find $(3) -type f -exec sed -i "s/{{$(1)}}/$(2)/g" {} \; endef +define subst_conda_meta_yaml + find $(3) -name meta.yaml -exec sed -i "s/{{$(1)}}/$(2)/g" {} \; +endef deb: rm -rf $(build_dir) @@ -67,3 +72,13 @@ deb: debuild -S -sa -us -d -k$(GPG_KEY) #--source-option=--include-binaries --source-option=--include-removal --source-option=-isession # BUILD LOCALLY BINARY PACKAGE #debuild -us -uc #--source-option=--include-binaries --source-option=--include-removal --source-option=-isession + +conda: + mkdir -p _BUILD/conda + git-archive-all --prefix=clang-uml-$(VERSION)/ _BUILD/conda/clang-uml-$(VERSION).tar.$(TAR_EXT) + cp conda/meta.yaml.in conda/meta.yaml + $(call subst_conda_meta_yaml,PKG_VERSION,${VERSION},conda) + $(call subst_conda_meta_yaml,PKG_SOURCE,..\/_BUILD\/conda\/clang-uml-$(VERSION).tar.$(TAR_EXT),conda) + $(call subst_conda_meta_yaml,GIT_COMMIT,${COMMIT},conda) + $(call subst_conda_meta_yaml,GIT_BRANCH,${BRANCH},conda) + conda build conda diff --git a/packaging/conda/build.sh b/packaging/conda/build.sh new file mode 100644 index 00000000..3819ba95 --- /dev/null +++ b/packaging/conda/build.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +mkdir build && cd build + +export PKG_CONFIG_PATH="$BUILD_PREFIX/lib/pkgconfig:$PKG_CONFIG_PATH" + +export CLANGUML_GIT_TOPLEVEL_DIR=${SRC_DIR} + +cmake -DCMAKE_BUILD_TYPE=Release \ + -DGIT_VERSION=${GIT_VERSION} \ + -DCODE_COVERAGE=OFF \ + -DWITH_TESTS=ON \ + -DLLVM_CONFIG_PATH=${BUILD_PREFIX}/bin/llvm-config \ + -DCONDA_BUILD_PREFIX=${BUILD_PREFIX} \ + -DCMAKE_INSTALL_PREFIX=${PREFIX} \ + -DCMAKE_EXE_LINKER_FLAGS="-lyaml-cpp" \ + .. + +CTEST_OUTPUT_ON_FAILURE=1 make -j${CPU_COUNT} + +CTEST_OUTPUT_ON_FAILURE=1 ctest -j${CPU_COUNT} + +make install \ No newline at end of file diff --git a/packaging/conda/meta.yaml.in b/packaging/conda/meta.yaml.in new file mode 100644 index 00000000..ed65b924 --- /dev/null +++ b/packaging/conda/meta.yaml.in @@ -0,0 +1,45 @@ +{% set name = "clang-uml" %} +{% set version = "{{PKG_VERSION}}" %} + +package: + name: {{ name|lower }} + version: {{ version|replace('-', '.') }} + +source: + url: "{{PKG_SOURCE}}" + +build: + binary_relocation: true + script_env: + - PKG_VERSION + - CLANGUML_GIT_REVISION={{PKG_VERSION}} + - CLANGUML_GIT_BRANCH={{GIT_BRANCH}} + - CLANGUML_GIT_COMMIT={{GIT_COMMIT}} + +requirements: + build: + - {{ compiler('c') }} + - {{ compiler('cxx') }} + - conda-forge::pkg-config + - conda-forge::yaml-cpp 0.7.0 + - conda-forge::clangdev 14.0.4 + - conda-forge::libclang 14.0.4 + - conda-forge::cmake + - conda-forge::git + - conda-forge::make # [unix] + run: + - conda-forge::yaml-cpp 0.7.0 + - conda-forge::libclang 14.0.4 + +test: + commands: + - $PREFIX/bin/clang-uml --version + +about: + home: https://github.com/bkryza/clang-uml + license: Apache 2.0 + summary: clang-uml is an automatic C++ UML diagram generator based on Clang. + +extra: + recipe-maintainers: + - bkryza \ No newline at end of file