summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam James <sam@gentoo.org>2024-11-25 21:48:03 +0000
committerSam James <sam@gentoo.org>2024-11-25 21:48:23 +0000
commit83040182130d06ae074b30752e7e709c364602d4 (patch)
treed82958329a7527a064e99e13d362594676bf2911 /dev-util
parentmedia-video/mplayer: Stabilize 1.5_p20241125 arm, #944961 (diff)
downloadgentoo-83040182130d06ae074b30752e7e709c364602d4.tar.gz
gentoo-83040182130d06ae074b30752e7e709c364602d4.tar.bz2
gentoo-83040182130d06ae074b30752e7e709c364602d4.zip
dev-util/clang-extract: new package, add 0_pre20241002, 9999
Signed-off-by: Sam James <sam@gentoo.org>
Diffstat (limited to 'dev-util')
-rw-r--r--dev-util/clang-extract/Manifest1
-rw-r--r--dev-util/clang-extract/clang-extract-0_pre20241002.ebuild114
-rw-r--r--dev-util/clang-extract/clang-extract-9999.ebuild114
-rw-r--r--dev-util/clang-extract/files/clang-extract-meson.patch54
-rw-r--r--dev-util/clang-extract/metadata.xml11
5 files changed, 294 insertions, 0 deletions
diff --git a/dev-util/clang-extract/Manifest b/dev-util/clang-extract/Manifest
new file mode 100644
index 000000000000..5fdcd6bc5cee
--- /dev/null
+++ b/dev-util/clang-extract/Manifest
@@ -0,0 +1 @@
+DIST clang-extract-0_pre20241002.gh.tar.gz 129679 BLAKE2B 98d55d96fddcaf97e3ba12c4f5cc64a226ca8cb01328bfbe29e0526e48ba3304fdba0f4ee0f07972e488dd9339326011116359401fed047031c49806ee175245 SHA512 c05a8c2aa9a3fd0050d23b35991b8169e185e6186b2c583b364e78fef448030d44be4d14f175148fde5389a1463d4db61d52621dc2b410764336cca12ce3e5b3
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..d99ec316f176
--- /dev/null
+++ b/dev-util/clang-extract/clang-extract-0_pre20241002.ebuild
@@ -0,0 +1,114 @@
+# 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
+ 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..892787e428de
--- /dev/null
+++ b/dev-util/clang-extract/clang-extract-9999.ebuild
@@ -0,0 +1,114 @@
+# 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="
+ $(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>