Skip to contentSkip to conversation

package/swig: also create a swig4.0 symlink

PATCH Applied Yegor Yefremov via buildroot 1 participant 3 messages Sep 24 – Oct 10

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 package/swig: also create a swig4.0 symlink

FindSWIG in CMake searches for swig4.0, swig3.0 and swig2.0 before it tries plain swig, and it searches the whole PATH for one name before moving on to the next. We only create swig3.0 and swig$(SWIG_VERSION_MAJOR) (swig4.5) symlinks in $(HOST_DIR)/bin, so a swig4.0 installed on the build machine, as Ubuntu 22.04 does with its swig4.0 package, takes precedence over our host-swig for every CMake package that does not pass SWIG_EXECUTABLE explicitly. With CMake 3.22.1, libftdi1 with Python bindings ends up with

-- Found SWIG: /usr/bin/swig4.0 (found suitable version "4.0.2", ...)

Also create a swig4.0 symlink, and update the comment accordingly.

Assisted-by Claude:claude-opus-5
---
 package/swig/swig.mk | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)
package/swig/swig.mk +8 -7
index e277f5049a..4dac64dadc 100644
@@ -30,18 +30,19 @@ endef
 
 HOST_SWIG_POST_INSTALL_HOOKS += HOST_SWIG_INSTALL_WRAPPER
 
-# CMake looks first at swig3.0, then swig2.0 and then swig. However,
-# when doing the search, it will look into the PATH for swig2.0 first,
-# and then for swig.
+# CMake looks first for swig4.0, then swig3.0 and swig2.0, and only
+# then for swig. However, it searches the whole PATH for one name before
+# trying the next one.
 # While the PATH contains first our $(HOST_DIR)/bin, it also contains
 # /usr/bin and other system directories. Therefore, if there is an
-# installed swig3.0 on the system, it will get the preference over the
-# swig installed in $(HOST_DIR)/bin, which isn't nice. To prevent
-# this from happening we create a symbolic link swig3.0 -> swig, so that
-# our swig always gets used.
+# installed swig4.0 or swig3.0 on the system, it will get the preference
+# over the swig installed in $(HOST_DIR)/bin, which isn't nice. To prevent
+# this from happening we create swig4.0 and swig3.0 symbolic links to
+# swig, so that our swig always gets used.
 
 define HOST_SWIG_INSTALL_SYMLINK
 	ln -fs swig $(HOST_DIR)/bin/swig$(SWIG_VERSION_MAJOR)
+	ln -fs swig $(HOST_DIR)/bin/swig4.0
 	ln -fs swig $(HOST_DIR)/bin/swig3.0
 endef
 
Signature · 6 lines
2.34.1

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#1 lore raw
Quoted 9 lines · Yegor Yefremov via buildroot

FindSWIG in CMake searches for swig4.0, swig3.0 and swig2.0 before it tries plain swig, and it searches the whole PATH for one name before moving on to the next. We only create swig3.0 and swig$(SWIG_VERSION_MAJOR) (swig4.5) symlinks in $(HOST_DIR)/bin, so a swig4.0 installed on the build machine, as Ubuntu 22.04 does with its swig4.0 package, takes precedence over our host-swig for every CMake package that does not pass SWIG_EXECUTABLE explicitly. With CMake 3.22.1, libftdi1 with Python bindings ends up with

Quoted 6 lines

-- Found SWIG: /usr/bin/swig4.0 (found suitable version "4.0.2", ...)

Also create a swig4.0 symlink, and update the comment accordingly.

Assisted-by Claude:claude-opus-5

Applied to master, thanks!

Best regards,

Thomas Petazzoni

Signature · 7 lines
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#2 lore raw
In reply to Yegor Yefremov via buildroot

In reply of:

Quoted 9 lines

FindSWIG in CMake searches for swig4.0, swig3.0 and swig2.0 before it tries plain swig, and it searches the whole PATH for one name before moving on to the next. We only create swig3.0 and swig$(SWIG_VERSION_MAJOR) (swig4.5) symlinks in $(HOST_DIR)/bin, so a swig4.0 installed on the build machine, as Ubuntu 22.04 does with its swig4.0 package, takes precedence over our host-swig for every CMake package that does not pass SWIG_EXECUTABLE explicitly. With CMake 3.22.1, libftdi1 with Python bindings ends up with

Quoted 6 lines

-- Found SWIG: /usr/bin/swig4.0 (found suitable version "4.0.2", ...)

Also create a swig4.0 symlink, and update the comment accordingly.

Assisted-by Claude:claude-opus-5

Applied to 2025.02.x & 2026.08.x. Thanks

Quoted 42 lines
---
 package/swig/swig.mk | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)
package/swig/swig.mk +8 -7
index e277f5049a..4dac64dadc 100644
@@ -30,18 +30,19 @@ endef
 
 HOST_SWIG_POST_INSTALL_HOOKS += HOST_SWIG_INSTALL_WRAPPER
 
-# CMake looks first at swig3.0, then swig2.0 and then swig. However,
-# when doing the search, it will look into the PATH for swig2.0 first,
-# and then for swig.
+# CMake looks first for swig4.0, then swig3.0 and swig2.0, and only
+# then for swig. However, it searches the whole PATH for one name before
+# trying the next one.
 # While the PATH contains first our $(HOST_DIR)/bin, it also contains
 # /usr/bin and other system directories. Therefore, if there is an
-# installed swig3.0 on the system, it will get the preference over the
-# swig installed in $(HOST_DIR)/bin, which isn't nice. To prevent
-# this from happening we create a symbolic link swig3.0 -> swig, so that
-# our swig always gets used.
+# installed swig4.0 or swig3.0 on the system, it will get the preference
+# over the swig installed in $(HOST_DIR)/bin, which isn't nice. To prevent
+# this from happening we create swig4.0 and swig3.0 symbolic links to
+# swig, so that our swig always gets used.
 
 define HOST_SWIG_INSTALL_SYMLINK
 	ln -fs swig $(HOST_DIR)/bin/swig$(SWIG_VERSION_MAJOR)
+	ln -fs swig $(HOST_DIR)/bin/swig4.0
 	ln -fs swig $(HOST_DIR)/bin/swig3.0
 endef
 
Signature · 6 lines
2.34.1

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot