summaryrefslogtreecommitdiff
path: root/dev-util/clang-extract
diff options
context:
space:
mode:
authorV3n3RiX <venerix@koprulu.sector>2024-11-26 02:00:48 +0000
committerV3n3RiX <venerix@koprulu.sector>2024-11-26 02:00:48 +0000
commit403335d7014372971e9e9267493a808d08bab48e (patch)
treeffd28ddc69e6fe6543b018a00c9fad058bdda027 /dev-util/clang-extract
parent7f0b7329b3aa78ea82792fdf68ab48415fe4cc35 (diff)
gentoo auto-resync : 26:11:2024 - 02:00:48
Diffstat (limited to 'dev-util/clang-extract')
-rw-r--r--dev-util/clang-extract/Manifest5
-rw-r--r--dev-util/clang-extract/clang-extract-0_pre20241002.ebuild115
-rw-r--r--dev-util/clang-extract/clang-extract-9999.ebuild115
-rw-r--r--dev-util/clang-extract/files/clang-extract-meson.patch54
-rw-r--r--dev-util/clang-extract/metadata.xml11
5 files changed, 300 insertions, 0 deletions
diff --git a/dev-util/clang-extract/Manifest b/dev-util/clang-extract/Manifest
new file mode 100644
index 000000000000..6e447b592e2f
--- /dev/null
+++ b/dev-util/clang-extract/Manifest
@@ -0,0 +1,5 @@
+AUX clang-extract-meson.patch 2308 BLAKE2B 179088a6c843d295f99744944eef645b73c851da6fa2378a8b6e23c645e0b945b42c1182dedeb2c14b8656f065c3a4e6b0a4288f14670b61e6a4adfe03a06c96 SHA512 8019d1c9a08f6ddfd63ebc7874a2296255176dcd24eeac69e28556122fbac0c74b5978c5df5dbcb09d87f657ffc4a403ab3793f02d5f556489985f7b686e705c
+DIST clang-extract-0_pre20241002.gh.tar.gz 129679 BLAKE2B 98d55d96fddcaf97e3ba12c4f5cc64a226ca8cb01328bfbe29e0526e48ba3304fdba0f4ee0f07972e488dd9339326011116359401fed047031c49806ee175245 SHA512 c05a8c2aa9a3fd0050d23b35991b8169e185e6186b2c583b364e78fef448030d44be4d14f175148fde5389a1463d4db61d52621dc2b410764336cca12ce3e5b3
+EBUILD clang-extract-0_pre20241002.ebuild 3076 BLAKE2B 47ecf0219aa2bac9abf09fccdf9eb2282e32560c014d7042cc5e6ca2ff79111661e4c7dafb25d4c637375e3bc48053f56407d3b4815135c4b0f4419e98f43204 SHA512 184193c76f068ff241919eef29a7f741451c563e4feb57f9581683ba86de4e2ea36d999c826afd7788f70e4e07242df0f6537476a3b6cbf01206ebc34454b462
+EBUILD clang-extract-9999.ebuild 3076 BLAKE2B 47ecf0219aa2bac9abf09fccdf9eb2282e32560c014d7042cc5e6ca2ff79111661e4c7dafb25d4c637375e3bc48053f56407d3b4815135c4b0f4419e98f43204 SHA512 184193c76f068ff241919eef29a7f741451c563e4feb57f9581683ba86de4e2ea36d999c826afd7788f70e4e07242df0f6537476a3b6cbf01206ebc34454b462
+MISC metadata.xml 323 BLAKE2B fe3cebcb47898e93e18a41041e641980b9d53d292f77f06eb9c3316be67a5a8fab79d9d0b436401e3eed9b3476e7ef12f9e682e7e967067603103459ba46e999 SHA512 f31bd9d5c30efcca54ee10b22379c7698200e1f57b552f287eba863dedce75a20179b2b4670dfc90726c6c51e3db7decc72b181c8b768272d0f900897e4659e4
diff --git a/dev-util/clang-extract/clang-extract-0_pre20241002.ebuild b/dev-util/clang-extract/clang-extract-0_pre20241002.ebuild
new file mode 100644
index 000000000000..6dfe117dea9e
--- /dev/null
+++ b/dev-util/clang-extract/clang-extract-0_pre20241002.ebuild
@@ -0,0 +1,115 @@
+# Copyright 2024 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+LLVM_COMPAT=( {16..18} )
+PYTHON_COMPAT=( python3_{10..13} )
+inherit flag-o-matic llvm-r1 meson python-any-r1
+
+DESCRIPTION="Tool to extract code content from source files"
+HOMEPAGE="https://github.com/SUSE/clang-extract"
+
+if [[ ${PV} == 9999 ]] ; then
+ EGIT_REPO_URI="https://github.com/SUSE/clang-extract.git"
+ inherit git-r3
+else
+ CLANG_EXTRACT_COMMIT="ec46efd739f15ee49f99834ba56c019cbf69e4ed"
+ SRC_URI="
+ https://github.com/SUSE/clang-extract/archive/${CLANG_EXTRACT_COMMIT}.tar.gz -> ${P}.gh.tar.gz
+ "
+ S="${WORKDIR}"/${PN}-${CLANG_EXTRACT_COMMIT}
+
+ KEYWORDS="~amd64"
+fi
+
+LICENSE="UoI-NCSA"
+SLOT="0"
+IUSE="test"
+RESTRICT="!test? ( test )"
+
+DEPEND="
+ app-arch/zstd:=
+ sys-libs/zlib
+ virtual/libelf
+ $(llvm_gen_dep '
+ sys-devel/clang:${LLVM_SLOT}
+ sys-devel/llvm:${LLVM_SLOT}
+ ')
+"
+RDEPEND="${DEPEND}"
+BDEPEND="
+ $(llvm_gen_dep '
+ sys-devel/clang:${LLVM_SLOT}
+ ')
+ test? ( ${PYTHON_DEPS} )
+"
+
+PATCHES=(
+ "${FILESDIR}"/${PN}-meson.patch
+)
+
+pkg_setup() {
+ use test && python-any-r1_pkg_setup
+ llvm-r1_pkg_setup
+}
+
+src_prepare() {
+ default
+
+ # There's no need to manually add --gcc-install-dir to Clang invocations;
+ # we already have this setup properly via our Clang config files in
+ # /etc/clang.
+ sed -i -e '/add_project_argument.*gcc-install-dir/d' meson.build || die
+
+ # Testsuite makes some (bad) assumptions about layout
+ BUILD_DIR="${S}"/build
+}
+
+src_configure() {
+ # Use whatever CC/CXX llvm-r1 found for us, as meson.build
+ # asserts on GCC being used.
+ export CC=clang
+ export CXX=clang++
+ export PKG_CONFIG_PATH="$(get_llvm_prefix)/$(get_libdir)/pkgconfig:${PKG_CONFIG_PATH}"
+ # User flags may be expecting GCC
+ strip-unsupported-flags
+
+ meson_src_configure
+}
+
+src_test() {
+ # These hacks are inspired by dev-util/clazy.
+ #
+ # clang-extract wants to be installed in the directory of the clang binary,
+ # so it can find the llvm/clang via relative paths.
+ #
+ # Setup the directories and symlink the system include dir for that.
+ local -x LLVM_ROOT="$(get_llvm_prefix)"
+ local -x CLANG_ROOT="${LLVM_ROOT//llvm/clang}"
+
+ mkdir -p "${BUILD_DIR}${CLANG_ROOT}" || die
+ ln -s "${CLANG_ROOT}/include" "${BUILD_DIR}${CLANG_ROOT}/include" || die
+ mkdir -p "${BUILD_DIR}${LLVM_ROOT}/bin" || die
+ ln -s "${BUILD_DIR}"/clang-extract "${BUILD_DIR}${LLVM_ROOT}/bin" || die
+ ln -s "${BUILD_DIR}"/ce-inline "${BUILD_DIR}${LLVM_ROOT}/bin" || die
+
+ # Wrap runtest.py so we always pass -bin-path.
+ #
+ # This is gnarly but we already have to make sure it uses the
+ # right Python, so it was quicker to just do the bash wrapper.
+ mv testsuite/lib/runtest.py{,.real} || die
+ cat <<-EOF > testsuite/lib/runtest.py || die
+ #!/bin/bash
+ export CLANG_NO_DEFAULT_CONFIG=1
+ ${EPYTHON} "${S}"/testsuite/lib/runtest.py.real \
+ -bin-path "${BUILD_DIR}${LLVM_ROOT}/bin/" \
+ "\$@"
+ EOF
+ chmod +x testsuite/lib/runtest.py || die
+
+ local -x PATH="${BUILD_DIR}/${LLVM_ROOT}/bin:${BUILD_DIR}/bin:${PATH}"
+ local -x LD_LIBRARY_PATH="${BUILD_DIR}/lib:${LD_LIBRARY_PATH}"
+
+ meson_src_test
+}
diff --git a/dev-util/clang-extract/clang-extract-9999.ebuild b/dev-util/clang-extract/clang-extract-9999.ebuild
new file mode 100644
index 000000000000..6dfe117dea9e
--- /dev/null
+++ b/dev-util/clang-extract/clang-extract-9999.ebuild
@@ -0,0 +1,115 @@
+# Copyright 2024 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+LLVM_COMPAT=( {16..18} )
+PYTHON_COMPAT=( python3_{10..13} )
+inherit flag-o-matic llvm-r1 meson python-any-r1
+
+DESCRIPTION="Tool to extract code content from source files"
+HOMEPAGE="https://github.com/SUSE/clang-extract"
+
+if [[ ${PV} == 9999 ]] ; then
+ EGIT_REPO_URI="https://github.com/SUSE/clang-extract.git"
+ inherit git-r3
+else
+ CLANG_EXTRACT_COMMIT="ec46efd739f15ee49f99834ba56c019cbf69e4ed"
+ SRC_URI="
+ https://github.com/SUSE/clang-extract/archive/${CLANG_EXTRACT_COMMIT}.tar.gz -> ${P}.gh.tar.gz
+ "
+ S="${WORKDIR}"/${PN}-${CLANG_EXTRACT_COMMIT}
+
+ KEYWORDS="~amd64"
+fi
+
+LICENSE="UoI-NCSA"
+SLOT="0"
+IUSE="test"
+RESTRICT="!test? ( test )"
+
+DEPEND="
+ app-arch/zstd:=
+ sys-libs/zlib
+ virtual/libelf
+ $(llvm_gen_dep '
+ sys-devel/clang:${LLVM_SLOT}
+ sys-devel/llvm:${LLVM_SLOT}
+ ')
+"
+RDEPEND="${DEPEND}"
+BDEPEND="
+ $(llvm_gen_dep '
+ sys-devel/clang:${LLVM_SLOT}
+ ')
+ test? ( ${PYTHON_DEPS} )
+"
+
+PATCHES=(
+ "${FILESDIR}"/${PN}-meson.patch
+)
+
+pkg_setup() {
+ use test && python-any-r1_pkg_setup
+ llvm-r1_pkg_setup
+}
+
+src_prepare() {
+ default
+
+ # There's no need to manually add --gcc-install-dir to Clang invocations;
+ # we already have this setup properly via our Clang config files in
+ # /etc/clang.
+ sed -i -e '/add_project_argument.*gcc-install-dir/d' meson.build || die
+
+ # Testsuite makes some (bad) assumptions about layout
+ BUILD_DIR="${S}"/build
+}
+
+src_configure() {
+ # Use whatever CC/CXX llvm-r1 found for us, as meson.build
+ # asserts on GCC being used.
+ export CC=clang
+ export CXX=clang++
+ export PKG_CONFIG_PATH="$(get_llvm_prefix)/$(get_libdir)/pkgconfig:${PKG_CONFIG_PATH}"
+ # User flags may be expecting GCC
+ strip-unsupported-flags
+
+ meson_src_configure
+}
+
+src_test() {
+ # These hacks are inspired by dev-util/clazy.
+ #
+ # clang-extract wants to be installed in the directory of the clang binary,
+ # so it can find the llvm/clang via relative paths.
+ #
+ # Setup the directories and symlink the system include dir for that.
+ local -x LLVM_ROOT="$(get_llvm_prefix)"
+ local -x CLANG_ROOT="${LLVM_ROOT//llvm/clang}"
+
+ mkdir -p "${BUILD_DIR}${CLANG_ROOT}" || die
+ ln -s "${CLANG_ROOT}/include" "${BUILD_DIR}${CLANG_ROOT}/include" || die
+ mkdir -p "${BUILD_DIR}${LLVM_ROOT}/bin" || die
+ ln -s "${BUILD_DIR}"/clang-extract "${BUILD_DIR}${LLVM_ROOT}/bin" || die
+ ln -s "${BUILD_DIR}"/ce-inline "${BUILD_DIR}${LLVM_ROOT}/bin" || die
+
+ # Wrap runtest.py so we always pass -bin-path.
+ #
+ # This is gnarly but we already have to make sure it uses the
+ # right Python, so it was quicker to just do the bash wrapper.
+ mv testsuite/lib/runtest.py{,.real} || die
+ cat <<-EOF > testsuite/lib/runtest.py || die
+ #!/bin/bash
+ export CLANG_NO_DEFAULT_CONFIG=1
+ ${EPYTHON} "${S}"/testsuite/lib/runtest.py.real \
+ -bin-path "${BUILD_DIR}${LLVM_ROOT}/bin/" \
+ "\$@"
+ EOF
+ chmod +x testsuite/lib/runtest.py || die
+
+ local -x PATH="${BUILD_DIR}/${LLVM_ROOT}/bin:${BUILD_DIR}/bin:${PATH}"
+ local -x LD_LIBRARY_PATH="${BUILD_DIR}/lib:${LD_LIBRARY_PATH}"
+
+ meson_src_test
+}
diff --git a/dev-util/clang-extract/files/clang-extract-meson.patch b/dev-util/clang-extract/files/clang-extract-meson.patch
new file mode 100644
index 000000000000..7e25d81dd3d7
--- /dev/null
+++ b/dev-util/clang-extract/files/clang-extract-meson.patch
@@ -0,0 +1,54 @@
+TODO: Upstream the LLVM includedir parts.
+NOTE: The add_languages part is commented out as it interferes with
+ which LLVM we choose in the ebuild. Might be:
+ https://github.com/mesonbuild/meson/issues/13906.
+--- a/libcextract/meson.build
++++ b/libcextract/meson.build
+@@ -37,4 +37,4 @@ libcextract_sources = [
+ 'ASTUnitHack.cpp'
+ ]
+
+-libcextract_static = static_library('cextract', libcextract_sources)
++libcextract_static = static_library('cextract', libcextract_sources, include_directories: llvm_incdir)
+--- a/meson.build
++++ b/meson.build
+@@ -61,11 +61,16 @@ foreach line : gcc_output
+ endforeach
+
+ # Check if we got the gcc installation dir and add it to the project arguments.
+-assert(gcc_install_dir != '', 'GCC headers dir not found. Check \'gcc -v\'')
+-add_project_arguments('--gcc-install-dir=' + gcc_install_dir, language: 'cpp')
++#assert(gcc_install_dir != '', 'GCC headers dir not found. Check \'gcc -v\'')
++#add_project_arguments('--gcc-install-dir=' + gcc_install_dir, language: 'cpp')
+
+ ########## Dependency: clang libraries ################
+-llvm_libdir = dependency('llvm', version : '>=16').get_variable(cmake : 'LLVM_LIBRARY_DIR', configtool: 'libdir')
++# This is needed to lookup LLVM via CMake, per a Meson warning.
++#add_languages('c', native : false)
++llvm_dep = dependency('llvm', version : '>=16')
++llvm_bindir = llvm_dep.get_variable(cmake : 'LLVM_BINARY_DIR', configtool : 'bindir')
++llvm_incdir = llvm_dep.get_variable(cmake : 'LLVM_MAIN_INCLUDE_DIR', configtool : 'includedir')
++llvm_libdir = llvm_dep.get_variable(cmake : 'LLVM_LIBRARY_DIR', configtool : 'libdir')
+
+ clang_dep = []
+ clang_dep += cpp.find_library('clang-cpp', dirs : llvm_libdir)
+@@ -80,15 +85,17 @@ subdir('libcextract')
+ incdir = include_directories('libcextract')
+
+ executable('ce-inline', 'Inline.cpp',
+- include_directories : incdir,
++ include_directories : [llvm_incdir, incdir],
+ install : true,
++ install_dir : llvm_bindir,
+ link_with : libcextract_static,
+ dependencies : [elf_dep, zlib_dep, zstd_dep]
+ )
+
+ executable('clang-extract', 'Main.cpp',
+- include_directories : incdir,
++ include_directories : [llvm_incdir, incdir],
+ install : true,
++ install_dir : llvm_bindir,
+ link_with : libcextract_static,
+ dependencies : [elf_dep, clang_dep, zlib_dep, zstd_dep]
+ )
diff --git a/dev-util/clang-extract/metadata.xml b/dev-util/clang-extract/metadata.xml
new file mode 100644
index 000000000000..3c186aedec04
--- /dev/null
+++ b/dev-util/clang-extract/metadata.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "https://www.gentoo.org/dtd/metadata.dtd">
+<pkgmetadata>
+ <maintainer type="person">
+ <email>sam@gentoo.org</email>
+ <name>Sam James</name>
+ </maintainer>
+ <upstream>
+ <remote-id type="github">SUSE/clang-extract</remote-id>
+ </upstream>
+</pkgmetadata>