Skip to contentSkip to conversation

pkg-waf: add support for <pkg>_SUBDIR

PATCH New Lionel Orry 2 participants 6 messages Oct 11, 2018 Arm/Amlogic Meson SoC support

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/4 pkg-waf: add support for <pkg>_SUBDIR

In the Buildroot manual, it is specified that the Waf-based infrastructure supports the <pkg>_SUBDIR variable, which was not true.

This patch:
* makes use of this variable by changing to the given sub-directory before executing waf commands,
* documents the usage of <pkg>_SUBDIR in the waf-specific section of the manual.

---
Changes v1 -> v2:
- remove redundant definition of <pkg>_SRCDIR definition in pkg-waf.mk
- adds <pkg>_SUBDIR documentation in the waf section of the manual

---
 docs/manual/adding-packages-waf.txt | 6 ++++++
 package/pkg-waf.mk                  | 8 ++++----
 2 files changed, 10 insertions(+), 4 deletions(-)
docs/manual/adding-packages-waf.txt +6 -0
index 43b557c070..208dacc63d 100644
@@ -60,6 +60,12 @@ the generic infrastructure also exist in the Waf infrastructure:
 An additional variable, specific to the Waf infrastructure, can
 also be defined.
 
+* +LIBFOO_SUBDIR+ may contain the name of a subdirectory inside the
+  package that contains the main wscript file. This is useful,
+  if for example, the main wscript file is not at the root of
+  the tree extracted by the tarball. If +HOST_LIBFOO_SUBDIR+ is not
+  specified, it defaults to +LIBFOO_SUBDIR+.
+
 * +LIBFOO_NEEDS_EXTERNAL_WAF+ can be set to +YES+ or +NO+ to tell
   Buildroot to use the bundled +waf+ executable. If set to +NO+, the
   default, then Buildroot will use the waf executable provided in the
package/pkg-waf.mk +4 -4
index 3288dd63a0..a32d5dab33 100644
@@ -60,7 +60,7 @@ $(2)_WAF_OPTS				?=
 #
 ifndef $(2)_CONFIGURE_CMDS
 define $(2)_CONFIGURE_CMDS
-	cd $$(@D) && \
+	cd $$($$(PKG)_SRCDIR) && \
 	$$(TARGET_CONFIGURE_OPTS) \
 	$$($(2)_CONF_ENV) \
 	$$(HOST_DIR)/bin/python2 $$($(2)_WAF) configure \
@@ -77,7 +77,7 @@ endif
 #
 ifndef $(2)_BUILD_CMDS
 define $(2)_BUILD_CMDS
-	cd $$(@D) && \
+	cd $$($$(PKG)_SRCDIR) && \
 	$$(TARGET_MAKE_ENV) $$(HOST_DIR)/bin/python2 $$($(2)_WAF) \
 		build -j $$(PARALLEL_JOBS) $$($(2)_BUILD_OPTS) \
 		$$($(2)_WAF_OPTS)
@@ -90,7 +90,7 @@ endif
 #
 ifndef $(2)_INSTALL_STAGING_CMDS
 define $(2)_INSTALL_STAGING_CMDS
-	cd $$(@D) && \
+	cd $$($$(PKG)_SRCDIR) && \
 	$$(TARGET_MAKE_ENV) $$(HOST_DIR)/bin/python2 $$($(2)_WAF) \
 		install --destdir=$$(STAGING_DIR) \
 		$$($(2)_INSTALL_STAGING_OPTS) \
@@ -104,7 +104,7 @@ endif
 #
 ifndef $(2)_INSTALL_TARGET_CMDS
 define $(2)_INSTALL_TARGET_CMDS
-	cd $$(@D) && \
+	cd $$($$(PKG)_SRCDIR) && \
 	$$(TARGET_MAKE_ENV) $$(HOST_DIR)/bin/python2 $$($(2)_WAF) \
 		install --destdir=$$(TARGET_DIR) \
 		$$($(2)_INSTALL_TARGET_OPTS) \
Signature · 1 line
2.19.1
#1 lore raw

PATCH v2 2/4 pkg-meson: <pkg>_SUBDIR cleanup

No functional change is brought by this modification.

This patch:
* removes a redundant <pkg>_SRCDIR declaration (already defined in pkg-generic.mk)
* documents the usage of <pkg>_SUBDIR in the meson-specific section of the manual.

---
 docs/manual/adding-packages-meson.txt | 6 ++++++
 package/pkg-meson.mk                  | 1 -
 2 files changed, 6 insertions(+), 1 deletion(-)
docs/manual/adding-packages-meson.txt +6 -0
index c52fe10506..a0f64ba09e 100644
@@ -85,6 +85,12 @@ A few additional variables, specific to the Meson infrastructure, can also be
 defined. Many of them are only useful in very specific cases, typical packages
 will therefore only use a few of them.
 
+* +FOO_SUBDIR+ may contain the name of a subdirectory inside the
+  package that contains the main meson.build file. This is useful,
+  if for example, the main meson.build file is not at the root of
+  the tree extracted by the tarball. If +HOST_FOO_SUBDIR+ is not
+  specified, it defaults to +FOO_SUBDIR+.
+
 * +FOO_CONF_ENV+, to specify additional environment variables to pass to
   +meson+ for the configuration step. By default, empty.
 
package/pkg-meson.mk +0 -1
index 507e686068..5f2955b460 100644
@@ -48,7 +48,6 @@ define inner-meson-package
 $(2)_CONF_ENV		?=
 $(2)_CONF_OPTS		?=
 $(2)_NINJA_ENV		?=
-$(2)_SRCDIR		= $$($(2)_DIR)/$$($(2)_SUBDIR)
 
 #
 # Configure step. Only define it if not already defined by the package
Signature · 1 line
2.19.1
#2 lore raw

PATCH v2 3/4 pkg-python: <pkg>_SUBDIR cleanup

In reply to Lionel Orry

No functional change is brought by this modification.

This patch:
* removes redundant <pkg>_SRCDIR and <pkg>_BUILDDIR declarations (already defined in pkg-generic.mk)
* documents the usage of <pkg>_SUBDIR in the python-specific section of the manual.

---
 docs/manual/adding-packages-python.txt | 6 ++++++
 package/pkg-python.mk                  | 3 ---
 2 files changed, 6 insertions(+), 3 deletions(-)
docs/manual/adding-packages-python.txt +6 -0
index 5eb6ba51b1..15137cfd6d 100644
@@ -113,6 +113,12 @@ optionally be defined, depending on the package's needs. Many of them
 are only useful in very specific cases, typical packages will
 therefore only use a few of them, or none.
 
+* +PYTHON_FOO_SUBDIR+ may contain the name of a subdirectory inside the
+  package that contains the main +setup.py+ file. This is useful,
+  if for example, the main +setup.py+ file is not at the root of
+  the tree extracted by the tarball. If +HOST_PYTHON_FOO_SUBDIR+ is not
+  specified, it defaults to +PYTHON_FOO_SUBDIR+.
+
 * +PYTHON_FOO_ENV+, to specify additional environment variables to
   pass to the Python +setup.py+ script (for both the build and install
   steps). Note that the infrastructure is automatically passing
package/pkg-python.mk +0 -3
index f57e486dad..831bcacfad 100644
@@ -101,9 +101,6 @@ HOST_PKG_PYTHON_SETUPTOOLS_INSTALL_OPTS = \
 
 define inner-python-package
 
-$(2)_SRCDIR	= $$($(2)_DIR)/$$($(2)_SUBDIR)
-$(2)_BUILDDIR	= $$($(2)_SRCDIR)
-
 $(2)_ENV         ?=
 $(2)_BUILD_OPTS   ?=
 $(2)_INSTALL_OPTS ?=
Signature · 1 line
2.19.1
#3 lore raw

PATCH v2 4/4 pkg-cmake: <pkg>_SUBDIR cleanup

In reply to Lionel Orry

No functional change is brought by this modification.

This patch removes redundant <pkg>_SRCDIR declaration
(already defined in pkg-generic.mk)

---
 package/pkg-cmake.mk | 2 --
 1 file changed, 2 deletions(-)
package/pkg-cmake.mk +0 -2
index 51a1929ebb..b9ce8ff622 100644
@@ -60,8 +60,6 @@ $(2)_INSTALL_OPTS		?= install
 $(2)_INSTALL_STAGING_OPTS	?= DESTDIR=$$(STAGING_DIR) install/fast
 $(2)_INSTALL_TARGET_OPTS		?= DESTDIR=$$(TARGET_DIR) install/fast
 
-$(2)_SRCDIR			= $$($(2)_DIR)/$$($(2)_SUBDIR)
-
 $(3)_SUPPORTS_IN_SOURCE_BUILD ?= YES
 
 
Signature · 1 line
2.19.1
#4 lore raw

PATCH v2 1/4 pkg-waf: add support for <pkg>_SUBDIR

In reply to Lionel Orry

package/pkg-waf.mk $(2)_WAF_OPTS ?= · line 63

Quoted 10 lines · Lionel Orry
package/pkg-waf.mk +1 -1
index 3288dd63a0..a32d5dab33 100644
@@ -60,7 +60,7 @@ $(2)_WAF_OPTS				?=
 #
 ifndef $(2)_CONFIGURE_CMDS
 define $(2)_CONFIGURE_CMDS
-	cd $$(@D) && \
+	cd $$($$(PKG)_SRCDIR) && \

A little mistake on Thomas's part: this should be $$($$(PKG)_BUILDDIR), not
$$($$(PKG)_SRCDIR). They are currently the same, but the idea is to introduce the possibility to do out-of-tree builds and to reuse the same source directory for host and target, and also for packages that share their source trees.

Regards,
Arnout

Quoted 3 lines
package/pkg-waf.mk +0 -0
 	$$(TARGET_CONFIGURE_OPTS) \
 	$$($(2)_CONF_ENV) \
 	$$(HOST_DIR)/bin/python2 $$($(2)_WAF) configure \
Signature · 6 lines
Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF
#5 lore raw

PATCH v2 1/4 pkg-waf: add support for <pkg>_SUBDIR

Hi Arnout,

Quoted 4 lines · Arnout Vandecappelle

On 11/10/18 11:57, Lionel Orry wrote:

Quoted 15 lines

package/pkg-waf.mk $(2)_WAF_OPTS ?= · line 63

Quoted 10 lines
package/pkg-waf.mk +1 -1
index 3288dd63a0..a32d5dab33 100644
@@ -60,7 +60,7 @@ $(2)_WAF_OPTS                               ?=
 #
 ifndef $(2)_CONFIGURE_CMDS
 define $(2)_CONFIGURE_CMDS
-     cd $$(@D) && \
+     cd $$($$(PKG)_SRCDIR) && \

A little mistake on Thomas's part: this should be $$($$(PKG)_BUILDDIR), not
$$($$(PKG)_SRCDIR). They are currently the same, but the idea is to introduce the possibility to do out-of-tree builds and to reuse the same source directory for host and target, and also for packages that share their source trees.

Actually in the case of waf, one needs to change to the directory where the 'wscript' file is located, not in the directory where the build output files are going to be generated.
By default, waf generates its output in a 'build/' subfolder relative to the wscript, but this can be overriden in the wscript file and using a command-line option as well.
So I believe we really want to change into $$($$(PKG)_SRCDIR). Do you agree?

Quoted 16 lines

Regards,
Arnout

package/pkg-waf.mk $(2)_WAF_OPTS ?= · line 66

Quoted 3 lines
package/pkg-waf.mk +0 -0
      $$(TARGET_CONFIGURE_OPTS) \
      $$($(2)_CONF_ENV) \
      $$(HOST_DIR)/bin/python2 $$($(2)_WAF) configure \

--

Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF