commit:     788804b6b5175f0513f970a1e7bb1ab9e7897f5a
Author:     Katalin Rebhan <me <AT> dblsaiko <DOT> net>
AuthorDate: Sat Jul  5 17:32:31 2025 +0000
Commit:     Marco Rebhan <me <AT> dblsaiko <DOT> net>
CommitDate: Sat Jul  5 17:44:18 2025 +0000
URL:        https://gitweb.gentoo.org/repo/proj/guru.git/commit/?id=788804b6

dev-lang/swift: Correctly merge extra build flags

The build script complains when the same option occurs multiple
times in the same preset, but merges them when they occur in separate
presets. Therefore restore the code that creates a stack of presets
with one for each subsequent argument, instead of packing them all
into a single preset.

Signed-off-by: Katalin Rebhan <me <AT> dblsaiko.net>

 dev-lang/swift/swift-6.0.3-r2.ebuild | 26 ++++++++++++++++----------
 dev-lang/swift/swift-6.1.1.ebuild    | 26 ++++++++++++++++----------
 dev-lang/swift/swift-6.1.2-r1.ebuild | 26 ++++++++++++++++----------
 dev-lang/swift/swift-6.1.ebuild      | 26 ++++++++++++++++----------
 4 files changed, 64 insertions(+), 40 deletions(-)

diff --git a/dev-lang/swift/swift-6.0.3-r2.ebuild 
b/dev-lang/swift/swift-6.0.3-r2.ebuild
index 838810f56c..3bfb618be6 100644
--- a/dev-lang/swift/swift-6.0.3-r2.ebuild
+++ b/dev-lang/swift/swift-6.0.3-r2.ebuild
@@ -214,16 +214,22 @@ src_configure() {
 
        extra_build_flags+=(${SWIFT_EXTRA_BUILD_FLAGS})
 
-       if [[ ${#extra_build_flags[@]} -gt 0 ]]; then
-               SWIFT_BUILD_PRESET='gentoo,custom'
-               {
-                       echo "[preset: gentoo,custom]"
-                       echo "mixin-preset=gentoo"
-                       for flag in "${extra_build_flags[@]}"; do
-                               echo "${flag#--}"
-                       done
-               } >> "${SWIFT_BUILD_PRESETS_INI_PATH}"
-       fi
+       local orig_preset="${SWIFT_BUILD_PRESET}"
+       local preset="${orig_preset}"
+       local n=1
+
+       {
+               for arg in "${extra_build_flags[@]}"; do
+                       local next="${orig_preset},${n}"
+                       printf '[preset: %s]\n' "${next}"
+                       printf 'mixin-preset=%s\n' "${preset}"
+                       echo "${arg#--}"
+                       preset="${next}"
+                       n="$((n + 1))"
+               done
+       } >> "${SWIFT_BUILD_PRESETS_INI_PATH}"
+
+       SWIFT_BUILD_PRESET="${preset}"
 }
 
 src_compile() {

diff --git a/dev-lang/swift/swift-6.1.1.ebuild 
b/dev-lang/swift/swift-6.1.1.ebuild
index 5567d0b1f0..864a87fbae 100644
--- a/dev-lang/swift/swift-6.1.1.ebuild
+++ b/dev-lang/swift/swift-6.1.1.ebuild
@@ -215,16 +215,22 @@ src_configure() {
 
        extra_build_flags+=(${SWIFT_EXTRA_BUILD_FLAGS})
 
-       if [[ ${#extra_build_flags[@]} -gt 0 ]]; then
-               SWIFT_BUILD_PRESET='gentoo,custom'
-               {
-                       echo "[preset: gentoo,custom]"
-                       echo "mixin-preset=gentoo"
-                       for flag in "${extra_build_flags[@]}"; do
-                               echo "${flag#--}"
-                       done
-               } >> "${SWIFT_BUILD_PRESETS_INI_PATH}"
-       fi
+       local orig_preset="${SWIFT_BUILD_PRESET}"
+       local preset="${orig_preset}"
+       local n=1
+
+       {
+               for arg in "${extra_build_flags[@]}"; do
+                       local next="${orig_preset},${n}"
+                       printf '[preset: %s]\n' "${next}"
+                       printf 'mixin-preset=%s\n' "${preset}"
+                       echo "${arg#--}"
+                       preset="${next}"
+                       n="$((n + 1))"
+               done
+       } >> "${SWIFT_BUILD_PRESETS_INI_PATH}"
+
+       SWIFT_BUILD_PRESET="${preset}"
 }
 
 src_compile() {

diff --git a/dev-lang/swift/swift-6.1.2-r1.ebuild 
b/dev-lang/swift/swift-6.1.2-r1.ebuild
index 52b3f0ee15..7908e1dc60 100644
--- a/dev-lang/swift/swift-6.1.2-r1.ebuild
+++ b/dev-lang/swift/swift-6.1.2-r1.ebuild
@@ -215,16 +215,22 @@ src_configure() {
 
        extra_build_flags+=(${SWIFT_EXTRA_BUILD_FLAGS})
 
-       if [[ ${#extra_build_flags[@]} -gt 0 ]]; then
-               SWIFT_BUILD_PRESET='gentoo,custom'
-               {
-                       echo "[preset: gentoo,custom]"
-                       echo "mixin-preset=gentoo"
-                       for flag in "${extra_build_flags[@]}"; do
-                               echo "${flag#--}"
-                       done
-               } >> "${SWIFT_BUILD_PRESETS_INI_PATH}"
-       fi
+       local orig_preset="${SWIFT_BUILD_PRESET}"
+       local preset="${orig_preset}"
+       local n=1
+
+       {
+               for arg in "${extra_build_flags[@]}"; do
+                       local next="${orig_preset},${n}"
+                       printf '[preset: %s]\n' "${next}"
+                       printf 'mixin-preset=%s\n' "${preset}"
+                       echo "${arg#--}"
+                       preset="${next}"
+                       n="$((n + 1))"
+               done
+       } >> "${SWIFT_BUILD_PRESETS_INI_PATH}"
+
+       SWIFT_BUILD_PRESET="${preset}"
 }
 
 src_compile() {

diff --git a/dev-lang/swift/swift-6.1.ebuild b/dev-lang/swift/swift-6.1.ebuild
index 5567d0b1f0..864a87fbae 100644
--- a/dev-lang/swift/swift-6.1.ebuild
+++ b/dev-lang/swift/swift-6.1.ebuild
@@ -215,16 +215,22 @@ src_configure() {
 
        extra_build_flags+=(${SWIFT_EXTRA_BUILD_FLAGS})
 
-       if [[ ${#extra_build_flags[@]} -gt 0 ]]; then
-               SWIFT_BUILD_PRESET='gentoo,custom'
-               {
-                       echo "[preset: gentoo,custom]"
-                       echo "mixin-preset=gentoo"
-                       for flag in "${extra_build_flags[@]}"; do
-                               echo "${flag#--}"
-                       done
-               } >> "${SWIFT_BUILD_PRESETS_INI_PATH}"
-       fi
+       local orig_preset="${SWIFT_BUILD_PRESET}"
+       local preset="${orig_preset}"
+       local n=1
+
+       {
+               for arg in "${extra_build_flags[@]}"; do
+                       local next="${orig_preset},${n}"
+                       printf '[preset: %s]\n' "${next}"
+                       printf 'mixin-preset=%s\n' "${preset}"
+                       echo "${arg#--}"
+                       preset="${next}"
+                       n="$((n + 1))"
+               done
+       } >> "${SWIFT_BUILD_PRESETS_INI_PATH}"
+
+       SWIFT_BUILD_PRESET="${preset}"
 }
 
 src_compile() {

Reply via email to