Merge updates from master

This commit is contained in:
Repository mirror & CI
2024-08-06 09:07:34 +00:00
9 changed files with 200 additions and 146 deletions

View File

@@ -1,94 +0,0 @@
# Copyright 1999-2023 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
JAVA_PKG_IUSE="doc source test"
inherit java-pkg-2 java-pkg-simple toolchain-funcs java-ant-2
JAVA_TESTING_FRAMEWORKS="junit-4"
DESCRIPTION="A wrapper that makes it possible to install a Java Application as daemon"
HOMEPAGE="https://wrapper.tanukisoftware.com"
SRC_URI="https://download.tanukisoftware.com/wrapper/${PV}/wrapper_${PV}_src.tar.gz"
LICENSE="tanuki-community"
SLOT="0"
KEYWORDS="amd64 ~arm ~arm64 x86"
RESTRICT="!test? ( test )"
RDEPEND=">=virtual/jre-1.8:*"
DEPEND="
>=virtual/jdk-1.8:*
test? (
dev-java/junit:4
dev-util/cunit
)
"
BDEPEND="virtual/jdk"
S="${WORKDIR}/wrapper_${PV}_src"
JAVA_SRC_DIR="src/java/"
JAVA_JAR_FILENAME="wrapper.jar"
JAVA_TEST_SRC_DIR="src/test"
JAVA_TEST_GENTOO_CLASSPATH="junit-4"
PATCHES=(
"${FILESDIR}"/java-service-wrapper-3.5.25-gentoo-wrapper-defaults.patch
)
src_prepare() {
default
# replaces as-needed.patch
sed -i \
-e 's/gcc -O3/$(CC)/g' \
-e 's/ -pthread/ $(CFLAGS) $(LDFLAGS) -pthread/g' \
-e 's/ -shared/ $(LDFLAGS) -shared/g' \
-e 's/$(TEST)\/testsuite/testsuite/g' \
src/c/Makefile-*.make || die
cp "${S}/src/c/Makefile-linux-armel-32.make" "${S}/src/c/Makefile-linux-arm-32.make"
java-pkg-2_src_prepare
# disable tests by default (they are only enabled by default on amd64)
sed -e "s/\(all: init wrapper libwrapper.so\) testsuite/\1/g" \
-i src/c/Makefile-linux-x86-64.make || die
# re-enable tests on all platforms if requested
if use test; then
grep "testsuite_SOURCE" "src/c/Makefile-linux-x86-64.make" | tee -a src/c/Makefile-*.make
assert
echo 'all: testsuite' | tee -a src/c/Makefile-*.make
assert
fi
}
src_compile() {
tc-export CC
pushd "${T}" || die
echo 'public class GetArchDataModel{public static void main(String[] args){System.out.println(System.getProperty("sun.arch.data.model"));}}' \
> GetArchDataModel.java || die
ejavac GetArchDataModel.java
local BITS
BITS="$(java GetArchDataModel)" || die "Failed to identify sun.arch.data.model property"
popd || die
eant -Dbits="${BITS}" compile-c
java-pkg-simple_src_compile
}
src_test() {
src/c/testsuite --basic || die
java-pkg-simple_src_test
}
src_install() {
java-pkg-simple_src_install
java-pkg_doso lib/libwrapper.so
dobin bin/wrapper
dodoc README*.txt
dodoc doc/revisions.txt
}

View File

@@ -109,7 +109,7 @@ ECARGO_VENDOR="${ECARGO_HOME}/gentoo"
#
# If you enable CARGO_OPTIONAL, you have to set BDEPEND on virtual/rust
# for your package and call at least cargo_gen_config manually before using
# other src_functions of this eclass.
# other src_functions or cargo_env of this eclass.
# Note that cargo_gen_config is automatically called by cargo_src_unpack.
# @ECLASS_VARIABLE: myfeatures
@@ -248,7 +248,7 @@ cargo_crate_uris() {
# @FUNCTION: cargo_gen_config
# @DESCRIPTION:
# Generate the $CARGO_HOME/config necessary to use our local registry and settings.
# Generate the $CARGO_HOME/config.toml necessary to use our local registry and settings.
# Cargo can also be configured through environment variables in addition to the TOML syntax below.
# For each configuration key below of the form foo.bar the environment variable CARGO_FOO_BAR
# can also be used to define the value.
@@ -259,9 +259,22 @@ cargo_crate_uris() {
cargo_gen_config() {
debug-print-function ${FUNCNAME} "$@"
# The default linker is "cc" so override by setting linker to CC in the
# RUSTFLAGS. The given linker cannot include any arguments, so split these
# into link-args along with LDFLAGS. Also include external RUSTFLAGS.
# Note that as of Rust 1.80, the build host RUSTFLAGS are ignored when
# cross-compiling unless you use the unstable host-config feature available
# with USE=nightly. There is no simple way around this.
tc-export_build_env
local LD_A=( $(tc-getBUILD_CC) ${BUILD_LDFLAGS} )
local MY_BUILD_RUSTFLAGS="-C strip=none -C linker=${LD_A[0]}"
[[ ${#LD_A[@]} -gt 1 ]] && MY_BUILD_RUSTFLAGS+="$(printf -- ' -C link-arg=%s' "${LD_A[@]:1}")"
MY_BUILD_RUSTFLAGS+=" ${RUSTFLAGS} ${BUILD_RUSTFLAGS}"
tc-is-cross-compiler || MY_BUILD_RUSTFLAGS+=" ${TARGET_RUSTFLAGS}"
mkdir -p "${ECARGO_HOME}" || die
cat > "${ECARGO_HOME}/config" <<- _EOF_ || die "Failed to create cargo config"
cat > "${ECARGO_HOME}/config.toml" <<- _EOF_ || die "Failed to create cargo config"
[source.gentoo]
directory = "${ECARGO_VENDOR}"
@@ -273,6 +286,7 @@ cargo_gen_config() {
offline = true
[build]
rustflags = "${MY_BUILD_RUSTFLAGS}"
jobs = $(makeopts_jobs)
incremental = false
@@ -523,36 +537,65 @@ cargo_src_configure() {
[[ ${ECARGO_ARGS[@]} ]] && einfo "Configured with: ${ECARGO_ARGS[@]}"
}
# @FUNCTION: cargo_env
# @USAGE: Command with its arguments
# @DESCRIPTION:
# Run the given command under an environment needed for performing tasks with
# Cargo such as building. RUSTFLAGS is used for both the build and target host.
# BUILD_RUSTFLAGS and TARGET_RUSTFLAGS are used for just the build host and
# target host respectively. Ensure these are set consistently between Cargo
# invocations, otherwise rebuilds will occur.
cargo_env() {
[[ ${_CARGO_GEN_CONFIG_HAS_RUN} ]] || \
die "FATAL: please call cargo_gen_config before using ${FUNCNAME}"
# Shadow flag variables so that filtering below remains local.
local flag
for flag in $(all-flag-vars); do
local -x "${flag}=${!flag}"
done
# Rust extensions are incompatible with C/C++ LTO compiler see e.g.
# https://bugs.gentoo.org/910220
filter-lto
tc-export AR CC CXX PKG_CONFIG
# Set vars for cc-rs crate.
local -x \
HOST_AR=$(tc-getBUILD_AR)
HOST_CC=$(tc-getBUILD_CC)
HOST_CXX=$(tc-getBUILD_CXX)
HOST_CFLAGS=${BUILD_CFLAGS}
HOST_CXXFLAGS=${BUILD_CXXFLAGS}
if tc-is-cross-compiler; then
local -x CARGO_BUILD_TARGET=$(rust_abi)
local TRIPLE=${CARGO_BUILD_TARGET//-/_}
local TRIPLE=${TRIPLE^^} LD_A=( $(tc-getCC) ${LDFLAGS} )
local -x CARGO_TARGET_"${TRIPLE}"_RUSTFLAGS="-C strip=none -C linker=${LD_A[0]}"
[[ ${#LD_A[@]} -gt 1 ]] && local CARGO_TARGET_"${TRIPLE}"_RUSTFLAGS+="$(printf -- ' -C link-arg=%s' "${LD_A[@]:1}")"
local CARGO_TARGET_"${TRIPLE}"_RUSTFLAGS+=" ${RUSTFLAGS} ${TARGET_RUSTFLAGS}"
fi
(
# These variables will override the above, even if empty, so unset them
# locally. Do this in a subshell so that they remain set afterwards.
unset CARGO_BUILD_RUSTFLAGS CARGO_ENCODED_RUSTFLAGS RUSTFLAGS
"${@}"
)
}
# @FUNCTION: cargo_src_compile
# @DESCRIPTION:
# Build the package using cargo build.
cargo_src_compile() {
debug-print-function ${FUNCNAME} "$@"
[[ ${_CARGO_GEN_CONFIG_HAS_RUN} ]] || \
die "FATAL: please call cargo_gen_config before using ${FUNCNAME}"
filter-lto
tc-export AR CC CXX PKG_CONFIG
if tc-is-cross-compiler; then
export CARGO_BUILD_TARGET=$(rust_abi)
local TRIPLE=${CARGO_BUILD_TARGET//-/_}
export CARGO_TARGET_"${TRIPLE^^}"_LINKER=$(tc-getCC)
# Set vars for cc-rs crate.
tc-export_build_env
export \
HOST_AR=$(tc-getBUILD_AR)
HOST_CC=$(tc-getBUILD_CC)
HOST_CXX=$(tc-getBUILD_CXX)
HOST_CFLAGS=${BUILD_CFLAGS}
HOST_CXXFLAGS=${BUILD_CXXFLAGS}
fi
set -- cargo build $(usex debug "" --release) ${ECARGO_ARGS[@]} "$@"
einfo "${@}"
"${@}" || die "cargo build failed"
cargo_env "${@}" || die "cargo build failed"
}
# @FUNCTION: cargo_src_install
@@ -564,16 +607,13 @@ cargo_src_compile() {
cargo_src_install() {
debug-print-function ${FUNCNAME} "$@"
[[ ${_CARGO_GEN_CONFIG_HAS_RUN} ]] || \
die "FATAL: please call cargo_gen_config before using ${FUNCNAME}"
set -- cargo install $(has --path ${@} || echo --path ./) \
--root "${ED}/usr" \
${GIT_CRATES[@]:+--frozen} \
$(usex debug --debug "") \
${ECARGO_ARGS[@]} "$@"
einfo "${@}"
"${@}" || die "cargo install failed"
cargo_env "${@}" || die "cargo install failed"
rm -f "${ED}/usr/.crates.toml" || die
rm -f "${ED}/usr/.crates2.json" || die
@@ -585,12 +625,9 @@ cargo_src_install() {
cargo_src_test() {
debug-print-function ${FUNCNAME} "$@"
[[ ${_CARGO_GEN_CONFIG_HAS_RUN} ]] || \
die "FATAL: please call cargo_gen_config before using ${FUNCNAME}"
set -- cargo test $(usex debug "" --release) ${ECARGO_ARGS[@]} "$@"
einfo "${@}"
"${@}" || die "cargo test failed"
cargo_env "${@}" || die "cargo test failed"
}
fi

View File

@@ -204,7 +204,7 @@ esac
# This is an optimization that can avoid the overhead of calling into
# the build system in pure Python packages and packages using the stable
# Python ABI.
DISTUTILS_ALLOW_WHEEL_REUSE=1
: ${DISTUTILS_ALLOW_WHEEL_REUSE=1}
# @ECLASS_VARIABLE: BUILD_DIR
# @OUTPUT_VARIABLE
@@ -936,6 +936,7 @@ _distutils-r1_print_package_versions() {
# distutils patches and/or quirks.
distutils-r1_python_prepare_all() {
debug-print-function ${FUNCNAME} "${@}"
_python_sanity_checks
_distutils-r1_check_all_phase_mismatch
if [[ ! ${DISTUTILS_OPTIONAL} ]]; then
@@ -1251,7 +1252,9 @@ distutils_pep517_install() {
die "mydistutilsargs are banned in PEP517 mode (use DISTUTILS_ARGS)"
fi
local config_settings=
local cmd=() config_settings=
has cargo ${INHERITED} && cmd+=( cargo_env )
case ${DISTUTILS_USE_PEP517} in
maturin)
# `maturin pep517 build-wheel --help` for options
@@ -1388,9 +1391,14 @@ distutils_pep517_install() {
;;
esac
# https://pyo3.rs/latest/building-and-distribution.html#cross-compiling
if tc-is-cross-compiler; then
local -x PYO3_CROSS_LIB_DIR=${SYSROOT}/$(python_get_stdlib)
fi
local build_backend=$(_distutils-r1_get_backend)
einfo " Building the wheel for ${PWD#${WORKDIR}/} via ${build_backend}"
local cmd=(
cmd+=(
"${EPYTHON}" -m gpep517 build-wheel
--prefix="${EPREFIX}/usr"
--backend "${build_backend}"
@@ -1792,16 +1800,6 @@ distutils-r1_run_phase() {
# bug fixes from Cython (this works only when setup.py is using
# cythonize() but it's better than nothing)
local -x CYTHON_FORCE_REGEN=1
# Rust extensions are incompatible with C/C++ LTO compiler
# see e.g. https://bugs.gentoo.org/910220
if has cargo ${INHERITED}; then
local x
for x in $(all-flag-vars); do
local -x "${x}=${!x}"
done
filter-lto
fi
fi
# silence warnings when pydevd is loaded on Python 3.11+

View File

@@ -1,4 +1,4 @@
# Copyright 1999-2023 Gentoo Authors
# Copyright 1999-2024 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
# @ECLASS: python-any-r1.eclass
@@ -272,6 +272,7 @@ python_gen_any_dep() {
# This function will call python_check_deps() if defined.
python_setup() {
debug-print-function ${FUNCNAME} "${@}"
_python_sanity_checks
# support developer override
if [[ ${PYTHON_COMPAT_OVERRIDE} ]]; then

View File

@@ -617,6 +617,7 @@ _python_multibuild_wrapper() {
# locally, and the former two are exported to the command environment.
python_foreach_impl() {
debug-print-function ${FUNCNAME} "${@}"
_python_sanity_checks
if [[ ${_DISTUTILS_R1_ECLASS} ]]; then
if has "${EBUILD_PHASE}" prepare configure compile test install &&
@@ -708,6 +709,7 @@ python_foreach_impl() {
# @CODE
python_setup() {
debug-print-function ${FUNCNAME} "${@}"
_python_sanity_checks
local has_check_deps
declare -f python_check_deps >/dev/null && has_check_deps=1

View File

@@ -1,4 +1,4 @@
# Copyright 1999-2022 Gentoo Authors
# Copyright 1999-2024 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
# @ECLASS: python-single-r1.eclass
@@ -393,6 +393,7 @@ python_gen_impl_dep() {
# the Python build environment up for it.
python_setup() {
debug-print-function ${FUNCNAME} "${@}"
_python_sanity_checks
unset EPYTHON

View File

@@ -332,6 +332,17 @@ _python_export() {
export PYTHON=${BROOT-${EPREFIX}}/usr/bin/${impl}
debug-print "${FUNCNAME}: PYTHON = ${PYTHON}"
;;
PYTHON_STDLIB)
[[ -n ${PYTHON} ]] || die "PYTHON needs to be set for ${var} to be exported, or requested before it"
PYTHON_STDLIB=$(
"${PYTHON}" - "${EPREFIX}/usr" <<-EOF || die
import sys, sysconfig
print(sysconfig.get_path("stdlib", vars={"installed_base": sys.argv[1]}))
EOF
)
export PYTHON_STDLIB
debug-print "${FUNCNAME}: PYTHON_STDLIB = ${PYTHON_STDLIB}"
;;
PYTHON_SITEDIR)
[[ -n ${PYTHON} ]] || die "PYTHON needs to be set for ${var} to be exported, or requested before it"
PYTHON_SITEDIR=$(
@@ -466,6 +477,18 @@ _python_export() {
done
}
# @FUNCTION: python_get_stdlib
# @USAGE: [<impl>]
# @DESCRIPTION:
# Obtain and print the 'stdlib' path for the given implementation. If no
# implementation is provided, ${EPYTHON} will be used.
python_get_stdlib() {
debug-print-function ${FUNCNAME} "${@}"
_python_export "${@}" PYTHON_STDLIB
echo "${PYTHON_STDLIB}"
}
# @FUNCTION: python_get_sitedir
# @USAGE: [<impl>]
# @DESCRIPTION:
@@ -1544,4 +1567,38 @@ python_has_version() {
return 0
}
# @FUNCTION: _python_sanity_checks
# @INTERNAL
# @DESCRIPTION:
# Perform additional environment sanity checks.
_python_sanity_checks() {
debug-print-function ${FUNCNAME} "${@}"
[[ ${_PYTHON_SANITY_CHECKED} ]] && return
if [[ -v PYTHONPATH ]]; then
local x paths=()
mapfile -d ':' -t paths <<<${PYTHONPATH}
for x in "${paths[@]}"; do
if [[ ${x} != /* ]]; then
eerror "Relative path found in PYTHONPATH:"
eerror
eerror " PYTHONPATH=${PYTHONPATH@Q}"
eerror
eerror "This is guaranteed to cause random breakage. Please make sure that"
eerror "your PYTHONPATH contains absolute paths only (and only if necessary)."
eerror "Note that empty values (including ':' at either end and an empty"
eerror "PYTHONPATH) count as the current directory. If no PYTHONPATH"
eerror "is intended, it needs to be unset instead."
die "Relative paths in PYTHONPATH are forbidden: ${x@Q}"
fi
done
elog "PYTHONPATH=${PYTHONPATH@Q}"
fi
_PYTHON_SANITY_CHECKED=1
}
fi

View File

@@ -210,6 +210,36 @@ if type -P gcc &>/dev/null; then
tbegin "tc-get-c-rtlib (gcc)"
[[ $(CC=gcc tc-get-c-rtlib) == libgcc ]]
tend $?
tbegin "tc-is-lto (gcc, -fno-lto)"
CC=gcc CFLAGS=-fno-lto tc-is-lto
[[ $? -eq 1 ]]
tend $?
tbegin "tc-is-lto (gcc, -flto)"
CC=gcc CFLAGS=-flto tc-is-lto
[[ $? -eq 0 ]]
tend $?
case $(gcc -dumpmachine) in
i*86*-gnu*|arm*-gnu*|powerpc-*-gnu)
tbegin "tc-has-64bit-time_t (_TIME_BITS=32)"
CC=gcc CFLAGS="-U_TIME_BITS -D_TIME_BITS=32" tc-has-64bit-time_t
[[ $? -eq 1 ]]
tend $?
tbegin "tc-has-64bit-time_t (_TIME_BITS=64)"
CC=gcc CFLAGS="-U_FILE_OFFSET_BITS -U_TIME_BITS -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64" tc-has-64bit-time_t
[[ $? -eq 0 ]]
tend $?
;;
*)
tbegin "tc-has-64bit-time_t"
CC=gcc tc-has-64bit-time_t
[[ $? -eq 0 ]]
tend $?
;;
esac
fi
if type -P clang &>/dev/null; then
@@ -232,6 +262,16 @@ if type -P clang &>/dev/null; then
[[ $(CC=clang CFLAGS="--rtlib=${rtlib}" tc-get-c-rtlib) == ${rtlib} ]]
tend $?
done
tbegin "tc-is-lto (clang, -fno-lto)"
CC=clang CFLAGS=-fno-lto tc-is-lto
[[ $? -eq 1 ]]
tend $?
tbegin "tc-is-lto (clang, -flto)"
CC=clang CFLAGS=-flto tc-is-lto
[[ $? -eq 0 ]]
tend $?
fi
texit

View File

@@ -1,4 +1,4 @@
# Copyright 2002-2023 Gentoo Authors
# Copyright 2002-2024 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
# @ECLASS: toolchain-funcs.eclass
@@ -1234,6 +1234,7 @@ tc-get-build-ptr-size() {
# @RETURN: Shell true if we are using LTO, shell false otherwise
tc-is-lto() {
local f="${T}/test-lto.o"
local ret=1
case $(tc-get-compiler-type) in
clang)
@@ -1241,14 +1242,25 @@ tc-is-lto() {
# If LTO is used, clang will output bytecode and llvm-bcanalyzer
# will run successfully. Otherwise, it will output plain object
# file and llvm-bcanalyzer will exit with error.
llvm-bcanalyzer "${f}" &>/dev/null && return 0
llvm-bcanalyzer "${f}" &>/dev/null && ret=0
;;
gcc)
$(tc-getCC) ${CFLAGS} -c -o "${f}" -x c - <<<"" || die
[[ $($(tc-getREADELF) -S "${f}") == *.gnu.lto* ]] && return 0
[[ $($(tc-getREADELF) -S "${f}") == *.gnu.lto* ]] && ret=0
;;
esac
return 1
rm -f "${f}" || die
return "${ret}"
}
# @FUNCTION: tc-has-64bit-time_t
# @RETURN: Shell true if time_t is at least 64 bits long, false otherwise
tc-has-64bit-time_t() {
$(tc-getCC) ${CFLAGS} ${CPPFLAGS} -c -x c - -o /dev/null <<-EOF &>/dev/null
#include <sys/types.h>
int test[sizeof(time_t) >= 8 ? 1 : -1];
EOF
return $?
}
fi