Skip to contentSkip to conversation

meson: implement nativesdk support

PATCH Superseded Martin Kelly 3 participants 22 messages Jun 1, 2018 – Jan 8, 2019 Arm/Amlogic Meson SoC support

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover meson: implement nativesdk support

This patch series implements nativesdk support fer meson. In order to do so, it adds a few features to the toolchain-shar-extract functionality, which enables a script to run prior to the SDK being extracted. This is important because the meson.cross file (which meson uses to find its cross toolchain) allows for only absolute paths. Thus, it is important to customize those paths to point to the SDK at SDK extraction time. For comparison, cmake did not need this functionality because it supports referencing environment variables in the toolchain file, so we can just reference the SDK root environment variables. The meson maintainers did not want to take that approach, so this seemed like the best option.

If curious, see the following threads for more background information:
http://lists.openembedded.org/pipermail/openembedded-core/2018-January/146210.html
http://lists.openembedded.org/pipermail/openembedded-core/2018-January/146225.html
http://lists.openembedded.org/pipermail/openembedded-core/2018-January/146236.html
http://lists.openembedded.org/pipermail/openembedded-core/2018-January/146241.html
http://lists.openembedded.org/pipermail/openembedded-core/2018-January/146261.html
http://lists.openembedded.org/pipermail/openembedded-core/2018-January/146262.html

v2:
- Switch to new version of patches to fix exe wrappers, as upstream tweaked the previous patch.

Martin Kelly (7):
meson.bbclass: refactor native override nativesdk-python*: suppress user site dirs
toolchain-shar-extract: allow non-sh post-relocate
toolchain-shar-extract: print post-relocate error
toolchain-shar-extract: pass env to post-relocate
meson: handle exe wrappers
meson: enable nativesdk

 meta/classes/meson.bbclass                         |  17 +-
 meta/classes/toolchain-scripts.bbclass             |  24 +-
 meta/recipes-core/meta/meta-environment.bb         |   5 +-
 meta/recipes-devtools/meson/meson.inc              |  22 +
 ...0004-Prettifying-some-output-with-pathlib.patch | 188 +++++
 ...on-command-to-use-when-we-know-what-it-is.patch | 851 +++++++++++++++++++++
 meta/recipes-devtools/meson/meson/meson-setup.py   |  62 ++
 meta/recipes-devtools/meson/meson/meson-wrapper    |  14 +
 meta/recipes-devtools/meson/meson_0.46.1.bb        |  20 +-
 .../meson/nativesdk-meson_0.46.1.bb                |  74 ++
 .../python/python-scons-native_3.0.1.bb            |   2 +-
 meta/recipes-devtools/python/python3_3.5.5.bb      |   2 +-
 meta/recipes-devtools/python/python_2.7.14.bb      |   2 +-
 13 files changed, 1244 insertions(+), 39 deletions(-)
 create mode 100644 meta/recipes-devtools/meson/meson.inc
 create mode 100644 meta/recipes-devtools/meson/meson/0004-Prettifying-some-output-with-pathlib.patch
 create mode 100644 meta/recipes-devtools/meson/meson/0005-Set-the-meson-command-to-use-when-we-know-what-it-is.patch
 create mode 100755 meta/recipes-devtools/meson/meson/meson-setup.py
 create mode 100755 meta/recipes-devtools/meson/meson/meson-wrapper
 create mode 100644 meta/recipes-devtools/meson/nativesdk-meson_0.46.1.bb
Signature · 1 line
2.11.0
#1 lore raw

PATCH v2 1/7 meson.bbclass: refactor native override

The native override is specified in two different places, so let's move it into a function to reduce code duplication.

---
 meta/classes/meson.bbclass | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)
meta/classes/meson.bbclass +7 -10
index 2d7ee4fffc..5881765abb 100644
@@ -90,7 +90,7 @@ meson_do_configure() {
     fi
 }
 
-meson_do_configure_prepend_class-target() {
+override_native_tools() {
     # Set these so that meson uses the native tools for its build sanity tests,
     # which require executables to be runnable. The cross file will still
     # override these for the target build. Note that we do *not* set CFLAGS,
@@ -100,18 +100,15 @@ meson_do_configure_prepend_class-target() {
     export CXX="${BUILD_CXX}"
     export LD="${BUILD_LD}"
     export AR="${BUILD_AR}"
+
+}
+
+meson_do_configure_prepend_class-target() {
+    override_native_tools
 }
 
 meson_do_configure_prepend_class-nativesdk() {
-    # Set these so that meson uses the native tools for its build sanity tests,
-    # which require executables to be runnable. The cross file will still
-    # override these for the nativesdk build. Note that we do *not* set CFLAGS,
-    # LDFLAGS, etc. as they will be slurped in by meson and applied to the
-    # nativesdk build, causing errors.
-    export CC="${BUILD_CC}"
-    export CXX="${BUILD_CXX}"
-    export LD="${BUILD_LD}"
-    export AR="${BUILD_AR}"
+    override_native_tools
 }
 
 meson_do_configure_prepend_class-native() {
Signature · 1 line
2.11.0
#2 lore raw

PATCH v2 2/7 nativesdk-python*: suppress user site dirs

In reply to Martin Kelly

Currently, $HOME/.local is being added into sys.path in the Python SDK causing subtle host contamination. Suppress this by exporting PYTHONNOUSERSITE = "1" as documented in PEP 370.

This issue occurred in the past for python*-native and was fixed similarly in OE-core commit 8fe9fb4d5a61dcbcb3fc5b9ee0234cc135af873f ("python*native.bbclass: suppress user site dirs").

---
 meta/recipes-devtools/python/python-scons-native_3.0.1.bb | 2 +-
 meta/recipes-devtools/python/python3_3.5.5.bb             | 2 +-
 meta/recipes-devtools/python/python_2.7.14.bb             | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
meta/recipes-devtools/python/python-scons-native_3.0.1.bb +1 -1
index dae89ab5d2..68b63c9357 100644
@@ -4,5 +4,5 @@ DEPENDS = "python-native"
 RDEPENDS_${PN} = ""
 
 do_install_append() {
-    create_wrapper ${D}${bindir}/scons SCONS_LIB_DIR='${STAGING_DIR_HOST}/${PYTHON_SITEPACKAGES_DIR}'
+    create_wrapper ${D}${bindir}/scons SCONS_LIB_DIR='${STAGING_DIR_HOST}/${PYTHON_SITEPACKAGES_DIR}' PYTHONNOUSERSITE='1'
 }
meta/recipes-devtools/python/python3_3.5.5.bb +1 -1
index f893b846ad..4dae4fa4c6 100644
@@ -176,7 +176,7 @@ do_install() {
 }
 
 do_install_append_class-nativesdk () {
-	create_wrapper ${D}${bindir}/python${PYTHON_MAJMIN} TERMINFO_DIRS='${sysconfdir}/terminfo:/etc/terminfo:/usr/share/terminfo:/usr/share/misc/terminfo:/lib/terminfo'
+	create_wrapper ${D}${bindir}/python${PYTHON_MAJMIN} TERMINFO_DIRS='${sysconfdir}/terminfo:/etc/terminfo:/usr/share/terminfo:/usr/share/misc/terminfo:/lib/terminfo' PYTHONNOUSERSITE='1'
 }
 
 SSTATE_SCAN_FILES += "Makefile"
meta/recipes-devtools/python/python_2.7.14.bb +1 -1
index 41a8609b15..b923b9237b 100644
@@ -130,7 +130,7 @@ do_install() {
 }
 
 do_install_append_class-nativesdk () {
-	create_wrapper ${D}${bindir}/python2.7 PYTHONHOME='${prefix}' TERMINFO_DIRS='${sysconfdir}/terminfo:/etc/terminfo:/usr/share/terminfo:/usr/share/misc/terminfo:/lib/terminfo'
+	create_wrapper ${D}${bindir}/python2.7 PYTHONHOME='${prefix}' TERMINFO_DIRS='${sysconfdir}/terminfo:/etc/terminfo:/usr/share/terminfo:/usr/share/misc/terminfo:/lib/terminfo' PYTHONNOUSERSITE='1'
 }
 
 SSTATE_SCAN_FILES += "Makefile"
Signature · 1 line
2.11.0
#3 lore raw

PATCH v2 3/7 toolchain-shar-extract: allow non-sh post-relocate

In reply to Martin Kelly

Currently, we look only for scripts matching *.sh, which means we can't write post-relocate scripts in other languages.

Expand this to allow any type of script.

---
 meta/classes/toolchain-scripts.bbclass | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta/classes/toolchain-scripts.bbclass +1 -1
index 71da5e5409..cbba07838a 100644
@@ -124,7 +124,7 @@ toolchain_create_post_relocate_script() {
 
     cat >> $script <<EOF
 if [ -d "${SDKPATHNATIVE}/post-relocate-setup.d/" ]; then
-    for s in ${SDKPATHNATIVE}/post-relocate-setup.d/*.sh; do
+    for s in ${SDKPATHNATIVE}/post-relocate-setup.d/*; do
         \$s "\$1"
     done
     rm -rf "${SDKPATHNATIVE}/post-relocate-setup.d"
Signature · 1 line
2.11.0
#4 lore raw

PATCH v2 4/7 toolchain-shar-extract: print post-relocate error

In reply to Martin Kelly

Currently, if a post-relocate script fails, it fails silently. We should be louder about this, as it likely indicates a broken SDK.

Print a message if a post-relocate script fails.

---
 meta/classes/toolchain-scripts.bbclass | 5 +++++
 1 file changed, 5 insertions(+)
meta/classes/toolchain-scripts.bbclass +5 -0
index cbba07838a..ae7bbef034 100644
@@ -126,6 +126,11 @@ toolchain_create_post_relocate_script() {
 if [ -d "${SDKPATHNATIVE}/post-relocate-setup.d/" ]; then
     for s in ${SDKPATHNATIVE}/post-relocate-setup.d/*; do
         \$s "\$1"
+        status=\$?
+        if [ \$status != 0 ]; then
+            echo "post-relocate command \"\$s \$1\" failed with status \$status" >&2
+            exit \$status
+        fi
     done
     rm -rf "${SDKPATHNATIVE}/post-relocate-setup.d"
 fi
Signature · 1 line
2.11.0
#5 lore raw

Re: [PATCH v2 4/7] toolchain-shar-extract: print post-relocate error

Quoted 17 lines · Martin Kelly

Currently, if a post-relocate script fails, it fails silently. We should
be louder about this, as it likely indicates a broken SDK.

Print a message if a post-relocate script fails.

---
 meta/classes/toolchain-scripts.bbclass | 5 +++++
 1 file changed, 5 insertions(+)
meta/classes/toolchain-scripts.bbclass +0 -0
index cbba07838a..ae7bbef034 100644

meta/classes/toolchain-scripts.bbclass toolchain_create_post_relocate_script() { · line 127

Quoted 2 lines
meta/classes/toolchain-scripts.bbclass +0 -0
@@ -126,6 +126,11 @@ toolchain_create_post_relocate_script() {
 if [ -d "${SDKPATHNATIVE}/post-relocate-setup.d/" ]; then
     for s in ${SDKPATHNATIVE}/post-relocate-setup.d/*; do

Perhaps worth adding:

[ -x \$s ] || continue

?

Quoted 10 lines
meta/classes/toolchain-scripts.bbclass +3 -0
         \$s "\$1"
+        status=\$?
+        if [ \$status != 0 ]; then
+            echo "post-relocate command \"\$s \$1\" failed with

status \$status" >&2

meta/classes/toolchain-scripts.bbclass +2 -0
+            exit \$status
+        fi
     done
     rm -rf "${SDKPATHNATIVE}/post-relocate-setup.d"
 fi
#6 lore raw

Re: [PATCH v2 4/7] toolchain-shar-extract: print post-relocate error

Quoted 23 lines · Joshua Watt
Quoted 17 lines · Martin Kelly

Currently, if a post-relocate script fails, it fails silently. We should
be louder about this, as it likely indicates a broken SDK.

Print a message if a post-relocate script fails.

---
  meta/classes/toolchain-scripts.bbclass | 5 +++++
  1 file changed, 5 insertions(+)
meta/classes/toolchain-scripts.bbclass +0 -0
index cbba07838a..ae7bbef034 100644

meta/classes/toolchain-scripts.bbclass toolchain_create_post_relocate_script() { · line 127

Quoted 2 lines
meta/classes/toolchain-scripts.bbclass +0 -0
@@ -126,6 +126,11 @@ toolchain_create_post_relocate_script() {
  if [ -d "${SDKPATHNATIVE}/post-relocate-setup.d/" ]; then
      for s in ${SDKPATHNATIVE}/post-relocate-setup.d/*; do

Perhaps worth adding:

Quoted 4 lines
  [ -x \$s ] || continue

?

Yes, good idea. I will add it in the next revision, after I wait a day or two more for other reviews.

Quoted 10 lines
Quoted 10 lines
meta/classes/toolchain-scripts.bbclass +3 -0
          \$s "\$1"
+        status=\$?
+        if [ \$status != 0 ]; then
+            echo "post-relocate command \"\$s \$1\" failed with

status \$status" >&2

meta/classes/toolchain-scripts.bbclass +2 -0
+            exit \$status
+        fi
      done
      rm -rf "${SDKPATHNATIVE}/post-relocate-setup.d"
  fi
#7 lore raw

PATCH v2 5/7 toolchain-shar-extract: pass env to post-relocate

In reply to Martin Kelly

It's useful for the post-relocate scripts to be able to see the SDK environment, for example to see the values of CC, CXX etc. in order to dynamically generate toolchain files.

To enable this, source the SDK environment script prior to calling the relocate scripts.

---
 meta/classes/toolchain-scripts.bbclass     | 17 +++++++++++++----
 meta/recipes-core/meta/meta-environment.bb |  5 +++--
 2 files changed, 16 insertions(+), 6 deletions(-)
meta/classes/toolchain-scripts.bbclass +13 -4
index ae7bbef034..5f99fd8c03 100644
@@ -118,11 +118,20 @@ EOF
 }
 
 toolchain_create_post_relocate_script() {
-	script=$1
-	rm -f $script
-	touch $script
+	relocate_script=$1
+	sdk_script=$2
+	rm -f $relocate_script
+	touch $relocate_script
+
+    cat >> $relocate_script <<EOF
+# Source the SDK env script in case it is needed for the relocate scripts.
+. $sdk_script
+status=\$?
+if [ \$status != 0 ]; then
+    echo "\$0: Failed to source $sdk_script with status \$status"
+    exit \$status
+fi
 
-    cat >> $script <<EOF
 if [ -d "${SDKPATHNATIVE}/post-relocate-setup.d/" ]; then
     for s in ${SDKPATHNATIVE}/post-relocate-setup.d/*; do
         \$s "\$1"
meta/recipes-core/meta/meta-environment.bb +3 -2
index 09f757a087..74c0600c3d 100644
@@ -51,12 +51,13 @@ create_sdk_files() {
 	# Setup site file for external use
 	toolchain_create_sdk_siteconfig ${SDK_OUTPUT}/${SDKPATH}/site-config-${REAL_MULTIMACH_TARGET_SYS}
 
-	toolchain_create_sdk_env_script ${SDK_OUTPUT}/${SDKPATH}/environment-setup-${REAL_MULTIMACH_TARGET_SYS}
+	sdk_script="${SDKPATH}/environment-setup-${REAL_MULTIMACH_TARGET_SYS}"
+	toolchain_create_sdk_env_script ${SDK_OUTPUT}/${sdk_script}
 
 	# Add version information
 	toolchain_create_sdk_version ${SDK_OUTPUT}/${SDKPATH}/version-${REAL_MULTIMACH_TARGET_SYS}
 
-	toolchain_create_post_relocate_script ${SDK_OUTPUT}/${SDKPATH}/post-relocate-setup.sh
+	toolchain_create_post_relocate_script ${SDK_OUTPUT}/${SDKPATH}/post-relocate-setup.sh ${sdk_script}
 }
 
 do_install() {
Signature · 1 line
2.11.0
#8 lore raw

Re: [PATCH v2 5/7] toolchain-shar-extract: pass env to post-relocate

Quoted 34 lines · Martin Kelly

It's useful for the post-relocate scripts to be able to see the SDK environment, for example to see the values of CC, CXX etc. in order to
dynamically generate toolchain files.

To enable this, source the SDK environment script prior to calling the
relocate scripts.

---
 meta/classes/toolchain-scripts.bbclass     | 17 +++++++++++++----
 meta/recipes-core/meta/meta-environment.bb |  5 +++--
 2 files changed, 16 insertions(+), 6 deletions(-)
meta/classes/toolchain-scripts.bbclass +7 -3
index ae7bbef034..5f99fd8c03 100644
@@ -118,11 +118,20 @@ EOF
 }
 
 toolchain_create_post_relocate_script() {
-	script=$1
-	rm -f $script
-	touch $script
+	relocate_script=$1
+	sdk_script=$2
+	rm -f $relocate_script
+	touch $relocate_script
+
+    cat >> $relocate_script <<EOF
+# Source the SDK env script in case it is needed for the relocate
Quoted 2 lines

scripts.
+. $sdk_script

I had originally done something similar to this when I added support for the post-relocate scripts with icecream. However, it is insufficent because there can be multiple SDK environment scripts that need to be sourced. In order to get a fully correct environment, I had to do:

# Setup environment
for env_setup_script in ls $1/environment-setup-*; do
. $env_setup_script
done

see meta/recipes-devtools/icecc-toolchain/icecc-toolchain/icecc- setup.sh

Quoted 38 lines
meta/classes/toolchain-scripts.bbclass +5 -1
+status=\$?
+if [ \$status != 0 ]; then
+    echo "\$0: Failed to source $sdk_script with status \$status"
+    exit \$status
+fi
 
-    cat >> $script <<EOF
 if [ -d "${SDKPATHNATIVE}/post-relocate-setup.d/" ]; then
     for s in ${SDKPATHNATIVE}/post-relocate-setup.d/*; do
         \$s "\$1"
meta/recipes-core/meta/meta-environment.bb +0 -1
index 09f757a087..74c0600c3d 100644
@@ -51,12 +51,13 @@ create_sdk_files() {
 	# Setup site file for external use
 	toolchain_create_sdk_siteconfig
 ${SDK_OUTPUT}/${SDKPATH}/site-config-${REAL_MULTIMACH_TARGET_SYS}
 
-	toolchain_create_sdk_env_script

${SDK_OUTPUT}/${SDKPATH}/environment-setup-
${REAL_MULTIMACH_TARGET_SYS}

meta/recipes-core/meta/meta-environment.bb +1 -0
+	sdk_script="${SDKPATH}/environment-setup-

${REAL_MULTIMACH_TARGET_SYS}"

meta/recipes-core/meta/meta-environment.bb +1 -0
+	toolchain_create_sdk_env_script ${SDK_OUTPUT}/${sdk_script}
 
 	# Add version information
 	toolchain_create_sdk_version

${SDK_OUTPUT}/${SDKPATH}/version-${REAL_MULTIMACH_TARGET_SYS}

meta/recipes-core/meta/meta-environment.bb +0 -1
-	toolchain_create_post_relocate_script

${SDK_OUTPUT}/${SDKPATH}/post-relocate-setup.sh

meta/recipes-core/meta/meta-environment.bb +1 -0
+	toolchain_create_post_relocate_script

${SDK_OUTPUT}/${SDKPATH}/post-relocate-setup.sh ${sdk_script}
}

do_install() {

#9 lore raw

Re: [PATCH v2 5/7] toolchain-shar-extract: pass env to post-relocate

Quoted 43 lines · Joshua Watt
Quoted 34 lines · Martin Kelly

It's useful for the post-relocate scripts to be able to see the SDK environment, for example to see the values of CC, CXX etc. in order to
dynamically generate toolchain files.

To enable this, source the SDK environment script prior to calling the
relocate scripts.

---
  meta/classes/toolchain-scripts.bbclass     | 17 +++++++++++++----
  meta/recipes-core/meta/meta-environment.bb |  5 +++--
  2 files changed, 16 insertions(+), 6 deletions(-)
meta/classes/toolchain-scripts.bbclass +7 -3
index ae7bbef034..5f99fd8c03 100644
@@ -118,11 +118,20 @@ EOF
  }
 
  toolchain_create_post_relocate_script() {
-	script=$1
-	rm -f $script
-	touch $script
+	relocate_script=$1
+	sdk_script=$2
+	rm -f $relocate_script
+	touch $relocate_script
+
+    cat >> $relocate_script <<EOF
+# Source the SDK env script in case it is needed for the relocate
Quoted 2 lines

scripts.
+. $sdk_script

I had originally done something similar to this when I added support for the post-relocate scripts with icecream. However, it is insufficent because there can be multiple SDK environment scripts that need to be sourced. In order to get a fully correct environment, I had to do:

Quoted 9 lines

# Setup environment
for env_setup_script in ls $1/environment-setup-*; do
. $env_setup_script
done

see meta/recipes-devtools/icecc-toolchain/icecc-toolchain/icecc- setup.sh

There's one overall "SDK environment" script (the one you source as a user to enter the SDK environment), and also customizable ones installed by nativesdk-* packages (e.g. one that cmake uses). In this patch, I had not intended that post-relocate scripts should be able to see the environment scripts for every project but instead just for the global SDK enivorment (to get at variables like OECORE_NATIVE_SYSROOT).

Let me know if I have missed something and not including the other environments could cause breakage.

Here's what I mean from an example extracted SDK:

martin@columbia:~$ ls /opt/xos/nanopi-neo-plus2/*environment*
/opt/xos/nanopi-neo-plus2/environment-setup-aarch64-poky-linux
martin@columbia:~$ ls /opt/xos/nanopi-neo-plus2/sysroots/x86_64-xevo-linux/environment-setup.d/
cmake.sh

In the above example, we are currently sourcing only /opt/xos/nanopi-neo-plus2/environment-setup-aarch64-poky-linux and not cmake.sh.

#10 lore raw

Re: [PATCH v2 5/7] toolchain-shar-extract: pass env to post-relocate

Quoted 62 lines · Martin Kelly
Quoted 51 lines · Joshua Watt
Quoted 38 lines · Martin Kelly

It's useful for the post-relocate scripts to be able to see the SDK
environment, for example to see the values of CC, CXX etc. in order
to
dynamically generate toolchain files.

To enable this, source the SDK environment script prior to calling
the
relocate scripts.

---
  meta/classes/toolchain-scripts.bbclass     | 17 +++++++++++++
----
  meta/recipes-core/meta/meta-environment.bb |  5 +++--
  2 files changed, 16 insertions(+), 6 deletions(-)
meta/classes/toolchain-scripts.bbclass +7 -3
index ae7bbef034..5f99fd8c03 100644
@@ -118,11 +118,20 @@ EOF
  }
 
  toolchain_create_post_relocate_script() {
-	script=$1
-	rm -f $script
-	touch $script
+	relocate_script=$1
+	sdk_script=$2
+	rm -f $relocate_script
+	touch $relocate_script
+
+    cat >> $relocate_script <<EOF
+# Source the SDK env script in case it is needed for the
Quoted 3 lines

relocate
scripts.
+. $sdk_script

I had originally done something similar to this when I added support
for the post-relocate scripts with icecream. However, it is insufficent
because there can be multiple SDK environment scripts that need to be
sourced. In order to get a fully correct environment, I had to do:

Quoted 9 lines

# Setup environment
for env_setup_script in ls $1/environment-setup-*; do
. $env_setup_script
done

see meta/recipes-devtools/icecc-toolchain/icecc-toolchain/icecc- setup.sh

Quoted 10 lines

There's one overall "SDK environment" script (the one you source as a
user to enter the SDK environment), and also customizable ones installed
by nativesdk-* packages (e.g. one that cmake uses). In this patch, I had
not intended that post-relocate scripts should be able to see the environment scripts for every project but instead just for the global
SDK enivorment (to get at variables like OECORE_NATIVE_SYSROOT).

(Almost) All of the code I can find that deals with the SDK environment supports multiple top level environment-setup-* files. If you happen to have more than one, the relocation script will relocate all of them (meta/files/toolchain-shar-relocate.sh), and the extraction script will give you instructions to source them all (meta/files/toolchain-shar- extract.sh).

It's possible this is some left over anachronism and it has no actual use, but we should either fix it everywhere else or be consistent here.

Quoted 14 lines

Let me know if I have missed something and not including the other environments could cause breakage.

Here's what I mean from an example extracted SDK:

martin@columbia:~$ ls /opt/xos/nanopi-neo-plus2/*environment*
/opt/xos/nanopi-neo-plus2/environment-setup-aarch64-poky-linux
martin@columbia:~$ ls 
/opt/xos/nanopi-neo-plus2/sysroots/x86_64-xevo-linux/environment-
setup.d/
cmake.sh
Quoted 4 lines

In the above example, we are currently sourcing only /opt/xos/nanopi-neo-plus2/environment-setup-aarch64-poky-linux and not
cmake.sh.

Sort of.... environment-setup-aarch64-poky-linux is going to implicitly source the cmake.sh script (see the for loop at the end of the script)

#11 lore raw

Re: [PATCH v2 5/7] toolchain-shar-extract: pass env to post-relocate

Quoted 81 lines · Joshua Watt
Quoted 62 lines · Martin Kelly
Quoted 51 lines · Joshua Watt
Quoted 38 lines · Martin Kelly

It's useful for the post-relocate scripts to be able to see the SDK
environment, for example to see the values of CC, CXX etc. in order
to
dynamically generate toolchain files.

To enable this, source the SDK environment script prior to calling
the
relocate scripts.

---
   meta/classes/toolchain-scripts.bbclass     | 17 +++++++++++++
----
   meta/recipes-core/meta/meta-environment.bb |  5 +++--
   2 files changed, 16 insertions(+), 6 deletions(-)
meta/classes/toolchain-scripts.bbclass +7 -3
index ae7bbef034..5f99fd8c03 100644
@@ -118,11 +118,20 @@ EOF
   }
 
   toolchain_create_post_relocate_script() {
-	script=$1
-	rm -f $script
-	touch $script
+	relocate_script=$1
+	sdk_script=$2
+	rm -f $relocate_script
+	touch $relocate_script
+
+    cat >> $relocate_script <<EOF
+# Source the SDK env script in case it is needed for the
Quoted 3 lines

relocate
scripts.
+. $sdk_script

I had originally done something similar to this when I added support
for the post-relocate scripts with icecream. However, it is insufficent
because there can be multiple SDK environment scripts that need to be
sourced. In order to get a fully correct environment, I had to do:

Quoted 9 lines

# Setup environment
for env_setup_script in ls $1/environment-setup-*; do
. $env_setup_script
done

see meta/recipes-devtools/icecc-toolchain/icecc-toolchain/icecc- setup.sh

Quoted 10 lines

There's one overall "SDK environment" script (the one you source as a
user to enter the SDK environment), and also customizable ones installed
by nativesdk-* packages (e.g. one that cmake uses). In this patch, I had
not intended that post-relocate scripts should be able to see the environment scripts for every project but instead just for the global
SDK enivorment (to get at variables like OECORE_NATIVE_SYSROOT).

(Almost) All of the code I can find that deals with the SDK environment supports multiple top level environment-setup-* files. If you happen to have more than one, the relocation script will relocate all of them (meta/files/toolchain-shar-relocate.sh), and the extraction script will give you instructions to source them all (meta/files/toolchain-shar- extract.sh).

Quoted 3 lines

It's possible this is some left over anachronism and it has no actual use, but we should either fix it everywhere else or be consistent here.

OK, that's good to know.

Quoted 14 lines
Quoted 14 lines

Let me know if I have missed something and not including the other environments could cause breakage.

Here's what I mean from an example extracted SDK:

martin@columbia:~$ ls /opt/xos/nanopi-neo-plus2/*environment*
/opt/xos/nanopi-neo-plus2/environment-setup-aarch64-poky-linux
martin@columbia:~$ ls
/opt/xos/nanopi-neo-plus2/sysroots/x86_64-xevo-linux/environment-
setup.d/
cmake.sh
Quoted 8 lines
Quoted 4 lines

In the above example, we are currently sourcing only /opt/xos/nanopi-neo-plus2/environment-setup-aarch64-poky-linux and not
cmake.sh.

Sort of.... environment-setup-aarch64-poky-linux is going to implicitly source the cmake.sh script (see the for loop at the end of the script)

Yes, I see that now. Given that the top-level environment-setup script implicitly sources the individual project sh scripts, isn't it correct to source only the top-level one? In that way, if the path to the individual sh scripts changes, this code won't break, and it leaves the top-level script to the single source of truth with regard to environment setup scripts.

#12 lore raw

Re: [PATCH v2 5/7] toolchain-shar-extract: pass env to post-relocate

Quoted 128 lines · Martin Kelly
Quoted 92 lines · Joshua Watt
Quoted 67 lines · Martin Kelly
Quoted 55 lines · Joshua Watt
Quoted 40 lines · Martin Kelly

It's useful for the post-relocate scripts to be able to see the
SDK
environment, for example to see the values of CC, CXX etc. in order
to
dynamically generate toolchain files.

To enable this, source the SDK environment script prior to calling
the
relocate scripts.

---
   meta/classes/toolchain-scripts.bbclass     | 17
+++++++++++++
----
   meta/recipes-core/meta/meta-environment.bb |  5 +++--
   2 files changed, 16 insertions(+), 6 deletions(-)
meta/classes/toolchain-scripts.bbclass +7 -3
index ae7bbef034..5f99fd8c03 100644
@@ -118,11 +118,20 @@ EOF
   }
 
   toolchain_create_post_relocate_script() {
-	script=$1
-	rm -f $script
-	touch $script
+	relocate_script=$1
+	sdk_script=$2
+	rm -f $relocate_script
+	touch $relocate_script
+
+    cat >> $relocate_script <<EOF
+# Source the SDK env script in case it is needed for the
Quoted 3 lines

relocate
scripts.
+. $sdk_script

I had originally done something similar to this when I added support
for the post-relocate scripts with icecream. However, it is insufficent
because there can be multiple SDK environment scripts that need to
be
sourced. In order to get a fully correct environment, I had to do:

Quoted 10 lines

# Setup environment
for env_setup_script in ls $1/environment-setup-*; do
. $env_setup_script
done

see meta/recipes-devtools/icecc-toolchain/icecc-
toolchain/icecc-
setup.sh

Quoted 12 lines

There's one overall "SDK environment" script (the one you source as
a
user to enter the SDK environment), and also customizable ones installed
by nativesdk-* packages (e.g. one that cmake uses). In this patch, I
had
not intended that post-relocate scripts should be able to see the environment scripts for every project but instead just for the global
SDK enivorment (to get at variables like OECORE_NATIVE_SYSROOT).

(Almost) All of the code I can find that deals with the SDK environment
supports multiple top level environment-setup-* files. If you happen to
have more than one, the relocation script will relocate all of them (meta/files/toolchain-shar-relocate.sh), and the extraction script will
give you instructions to source them all (meta/files/toolchain- shar-
extract.sh).

Quoted 5 lines

It's possible this is some left over anachronism and it has no actual
use, but we should either fix it everywhere else or be consistent here.

OK, that's good to know.

Quoted 21 lines
Quoted 15 lines

Let me know if I have missed something and not including the other
environments could cause breakage.

Here's what I mean from an example extracted SDK:

martin@columbia:~$ ls /opt/xos/nanopi-neo-plus2/*environment*
/opt/xos/nanopi-neo-plus2/environment-setup-aarch64-poky-linux
martin@columbia:~$ ls
/opt/xos/nanopi-neo-plus2/sysroots/x86_64-xevo-linux/environment-
setup.d/
cmake.sh
Quoted 5 lines

In the above example, we are currently sourcing only /opt/xos/nanopi-neo-plus2/environment-setup-aarch64-poky-linux and
not
cmake.sh.

Quoted 5 lines

Sort of.... environment-setup-aarch64-poky-linux is going to implicitly
source the cmake.sh script (see the for loop at the end of the script)

Quoted 9 lines

Yes, I see that now. Given that the top-level environment-setup script
implicitly sources the individual project sh scripts, isn't it correct
to source only the top-level one? In that way, if the path to the individual sh scripts changes, this code won't break, and it leaves the
top-level script to the single source of truth with regard to environment setup scripts.

Yes I agree. I think there was some miscommunication, I wasn't suggesting that we should be sourcing those manually. I just wanted to handle the top level environment-setup-* scripts in a consistent manner to the rest of the code (i.e. make sure we source all of them).

#13 lore raw

Re: [PATCH v2 5/7] toolchain-shar-extract: pass env to post-relocate

Quoted 139 lines · Joshua Watt
Quoted 128 lines · Martin Kelly
Quoted 92 lines · Joshua Watt
Quoted 67 lines · Martin Kelly
Quoted 55 lines · Joshua Watt
Quoted 40 lines · Martin Kelly

It's useful for the post-relocate scripts to be able to see the
SDK
environment, for example to see the values of CC, CXX etc. in order
to
dynamically generate toolchain files.

To enable this, source the SDK environment script prior to calling
the
relocate scripts.

---
    meta/classes/toolchain-scripts.bbclass     | 17
+++++++++++++
----
    meta/recipes-core/meta/meta-environment.bb |  5 +++--
    2 files changed, 16 insertions(+), 6 deletions(-)
meta/classes/toolchain-scripts.bbclass +7 -3
index ae7bbef034..5f99fd8c03 100644
@@ -118,11 +118,20 @@ EOF
    }
 
    toolchain_create_post_relocate_script() {
-	script=$1
-	rm -f $script
-	touch $script
+	relocate_script=$1
+	sdk_script=$2
+	rm -f $relocate_script
+	touch $relocate_script
+
+    cat >> $relocate_script <<EOF
+# Source the SDK env script in case it is needed for the
Quoted 3 lines

relocate
scripts.
+. $sdk_script

I had originally done something similar to this when I added support
for the post-relocate scripts with icecream. However, it is insufficent
because there can be multiple SDK environment scripts that need to
be
sourced. In order to get a fully correct environment, I had to do:

Quoted 10 lines

# Setup environment
for env_setup_script in ls $1/environment-setup-*; do
. $env_setup_script
done

see meta/recipes-devtools/icecc-toolchain/icecc-
toolchain/icecc-
setup.sh

Quoted 12 lines

There's one overall "SDK environment" script (the one you source as
a
user to enter the SDK environment), and also customizable ones installed
by nativesdk-* packages (e.g. one that cmake uses). In this patch, I
had
not intended that post-relocate scripts should be able to see the environment scripts for every project but instead just for the global
SDK enivorment (to get at variables like OECORE_NATIVE_SYSROOT).

(Almost) All of the code I can find that deals with the SDK environment
supports multiple top level environment-setup-* files. If you happen to
have more than one, the relocation script will relocate all of them (meta/files/toolchain-shar-relocate.sh), and the extraction script will
give you instructions to source them all (meta/files/toolchain- shar-
extract.sh).

Quoted 5 lines

It's possible this is some left over anachronism and it has no actual
use, but we should either fix it everywhere else or be consistent here.

OK, that's good to know.

Quoted 21 lines
Quoted 15 lines

Let me know if I have missed something and not including the other
environments could cause breakage.

Here's what I mean from an example extracted SDK:

martin@columbia:~$ ls /opt/xos/nanopi-neo-plus2/*environment*
/opt/xos/nanopi-neo-plus2/environment-setup-aarch64-poky-linux
martin@columbia:~$ ls
/opt/xos/nanopi-neo-plus2/sysroots/x86_64-xevo-linux/environment-
setup.d/
cmake.sh
Quoted 5 lines

In the above example, we are currently sourcing only /opt/xos/nanopi-neo-plus2/environment-setup-aarch64-poky-linux and
not
cmake.sh.

Quoted 5 lines

Sort of.... environment-setup-aarch64-poky-linux is going to implicitly
source the cmake.sh script (see the for loop at the end of the script)

Quoted 9 lines

Yes, I see that now. Given that the top-level environment-setup script
implicitly sources the individual project sh scripts, isn't it correct
to source only the top-level one? In that way, if the path to the individual sh scripts changes, this code won't break, and it leaves the
top-level script to the single source of truth with regard to environment setup scripts.

Quoted 5 lines

Yes I agree. I think there was some miscommunication, I wasn't suggesting that we should be sourcing those manually. I just wanted to handle the top level environment-setup-* scripts in a consistent manner to the rest of the code (i.e. make sure we source all of them).

OK, before I move to the next revision, let me make sure I understand you correctly:

- There may be multiple top-level environment setup scripts.

- The environment setup script that is always created (environment-setup-aarch64-poky-linux in our example) sources all the project-specific files.

- Thus, we should source all top-level environment scripts, but not any project-specific ones, as they will be pulled in implicitly.

Is that correct?

#14 lore raw

Re: [PATCH v2 5/7] toolchain-shar-extract: pass env to post-relocate

Quoted 177 lines · Martin Kelly
Quoted 157 lines · Joshua Watt
Quoted 145 lines · Martin Kelly
Quoted 105 lines · Joshua Watt
Quoted 82 lines · Martin Kelly
Quoted 61 lines · Joshua Watt
Quoted 43 lines · Martin Kelly

It's useful for the post-relocate scripts to be able to see
the
SDK
environment, for example to see the values of CC, CXX etc. in
order
to
dynamically generate toolchain files.

To enable this, source the SDK environment script prior to
calling
the
relocate scripts.

---
    meta/classes/toolchain-scripts.bbclass     | 17
+++++++++++++
----
    meta/recipes-core/meta/meta-environment.bb |  5 +++--
    2 files changed, 16 insertions(+), 6 deletions(-)
meta/classes/toolchain-scripts.bbclass +7 -3
index ae7bbef034..5f99fd8c03 100644
@@ -118,11 +118,20 @@ EOF
    }
 
    toolchain_create_post_relocate_script() {
-	script=$1
-	rm -f $script
-	touch $script
+	relocate_script=$1
+	sdk_script=$2
+	rm -f $relocate_script
+	touch $relocate_script
+
+    cat >> $relocate_script <<EOF
+# Source the SDK env script in case it is needed for the
Quoted 3 lines

relocate
scripts.
+. $sdk_script

I had originally done something similar to this when I added
support
for the post-relocate scripts with icecream. However, it is insufficent
because there can be multiple SDK environment scripts that need
to
be
sourced. In order to get a fully correct environment, I had to
do:

Quoted 10 lines

# Setup environment
for env_setup_script in ls $1/environment-setup-*; do
. $env_setup_script
done

see meta/recipes-devtools/icecc-toolchain/icecc-
toolchain/icecc-
setup.sh

There's one overall "SDK environment" script (the one you source
as
a
user to enter the SDK environment), and also customizable ones
installed
by nativesdk-* packages (e.g. one that cmake uses). In this patch, I

Quoted 8 lines

had
not intended that post-relocate scripts should be able to see the
environment scripts for every project but instead just for the
global
SDK enivorment (to get at variables like OECORE_NATIVE_SYSROOT).

(Almost) All of the code I can find that deals with the SDK environment
supports multiple top level environment-setup-* files. If you happen to
have more than one, the relocation script will relocate all of them
(meta/files/toolchain-shar-relocate.sh), and the extraction script
will
give you instructions to source them all (meta/files/toolchain- shar-
extract.sh).

Quoted 6 lines

It's possible this is some left over anachronism and it has no actual
use, but we should either fix it everywhere else or be consistent
here.

OK, that's good to know.

Quoted 24 lines
Quoted 17 lines

Let me know if I have missed something and not including the other
environments could cause breakage.

Here's what I mean from an example extracted SDK:

martin@columbia:~$ ls /opt/xos/nanopi-neo-plus2/*environment*
/opt/xos/nanopi-neo-plus2/environment-setup-aarch64-poky-
linux
martin@columbia:~$ ls
/opt/xos/nanopi-neo-plus2/sysroots/x86_64-xevo-
linux/environment-
setup.d/
cmake.sh
Quoted 6 lines

In the above example, we are currently sourcing only /opt/xos/nanopi-neo-plus2/environment-setup-aarch64-poky- linux
and
not
cmake.sh.

Quoted 5 lines

Sort of.... environment-setup-aarch64-poky-linux is going to implicitly
source the cmake.sh script (see the for loop at the end of the script)

Quoted 10 lines

Yes, I see that now. Given that the top-level environment-setup script
implicitly sources the individual project sh scripts, isn't it correct
to source only the top-level one? In that way, if the path to the individual sh scripts changes, this code won't break, and it leaves
the
top-level script to the single source of truth with regard to environment setup scripts.

Quoted 7 lines

Yes I agree. I think there was some miscommunication, I wasn't suggesting that we should be sourcing those manually. I just wanted to
handle the top level environment-setup-* scripts in a consistent manner
to the rest of the code (i.e. make sure we source all of them).

OK, before I move to the next revision, let me make sure I understand
you correctly:

- There may be multiple top-level environment setup scripts.

- The environment setup script that is always created (environment-setup-aarch64-poky-linux in our example) sources all the
project-specific files.

Quoted 5 lines

- Thus, we should source all top-level environment scripts, but not any
project-specific ones, as they will be pulled in implicitly.

Is that correct?

That sounds correct

#15 lore raw

Re: [PATCH v2 5/7] toolchain-shar-extract: pass env to post-relocate

Quoted 178 lines · Joshua Watt
Quoted 177 lines · Martin Kelly
Quoted 157 lines · Joshua Watt
Quoted 145 lines · Martin Kelly
Quoted 105 lines · Joshua Watt
Quoted 82 lines · Martin Kelly
Quoted 61 lines · Joshua Watt
Quoted 43 lines · Martin Kelly

It's useful for the post-relocate scripts to be able to see
the
SDK
environment, for example to see the values of CC, CXX etc. in
order
to
dynamically generate toolchain files.

To enable this, source the SDK environment script prior to
calling
the
relocate scripts.

---
     meta/classes/toolchain-scripts.bbclass     | 17
+++++++++++++
----
     meta/recipes-core/meta/meta-environment.bb |  5 +++--
     2 files changed, 16 insertions(+), 6 deletions(-)
meta/classes/toolchain-scripts.bbclass +7 -3
index ae7bbef034..5f99fd8c03 100644
@@ -118,11 +118,20 @@ EOF
     }
 
     toolchain_create_post_relocate_script() {
-	script=$1
-	rm -f $script
-	touch $script
+	relocate_script=$1
+	sdk_script=$2
+	rm -f $relocate_script
+	touch $relocate_script
+
+    cat >> $relocate_script <<EOF
+# Source the SDK env script in case it is needed for the
Quoted 3 lines

relocate
scripts.
+. $sdk_script

I had originally done something similar to this when I added
support
for the post-relocate scripts with icecream. However, it is insufficent
because there can be multiple SDK environment scripts that need
to
be
sourced. In order to get a fully correct environment, I had to
do:

Quoted 10 lines

# Setup environment
for env_setup_script in ls $1/environment-setup-*; do
. $env_setup_script
done

see meta/recipes-devtools/icecc-toolchain/icecc-
toolchain/icecc-
setup.sh

There's one overall "SDK environment" script (the one you source
as
a
user to enter the SDK environment), and also customizable ones
installed
by nativesdk-* packages (e.g. one that cmake uses). In this patch, I

Quoted 8 lines

had
not intended that post-relocate scripts should be able to see the
environment scripts for every project but instead just for the
global
SDK enivorment (to get at variables like OECORE_NATIVE_SYSROOT).

(Almost) All of the code I can find that deals with the SDK environment
supports multiple top level environment-setup-* files. If you happen to
have more than one, the relocation script will relocate all of them
(meta/files/toolchain-shar-relocate.sh), and the extraction script
will
give you instructions to source them all (meta/files/toolchain- shar-
extract.sh).

Quoted 6 lines

It's possible this is some left over anachronism and it has no actual
use, but we should either fix it everywhere else or be consistent
here.

OK, that's good to know.

Quoted 24 lines
Quoted 17 lines

Let me know if I have missed something and not including the other
environments could cause breakage.

Here's what I mean from an example extracted SDK:

martin@columbia:~$ ls /opt/xos/nanopi-neo-plus2/*environment*
/opt/xos/nanopi-neo-plus2/environment-setup-aarch64-poky-
linux
martin@columbia:~$ ls
/opt/xos/nanopi-neo-plus2/sysroots/x86_64-xevo-
linux/environment-
setup.d/
cmake.sh
Quoted 6 lines

In the above example, we are currently sourcing only /opt/xos/nanopi-neo-plus2/environment-setup-aarch64-poky- linux
and
not
cmake.sh.

Quoted 5 lines

Sort of.... environment-setup-aarch64-poky-linux is going to implicitly
source the cmake.sh script (see the for loop at the end of the script)

Quoted 10 lines

Yes, I see that now. Given that the top-level environment-setup script
implicitly sources the individual project sh scripts, isn't it correct
to source only the top-level one? In that way, if the path to the individual sh scripts changes, this code won't break, and it leaves
the
top-level script to the single source of truth with regard to environment setup scripts.

Quoted 7 lines

Yes I agree. I think there was some miscommunication, I wasn't suggesting that we should be sourcing those manually. I just wanted to
handle the top level environment-setup-* scripts in a consistent manner
to the rest of the code (i.e. make sure we source all of them).

OK, before I move to the next revision, let me make sure I understand
you correctly:

- There may be multiple top-level environment setup scripts.

- The environment setup script that is always created (environment-setup-aarch64-poky-linux in our example) sources all the
project-specific files.

Quoted 8 lines
Quoted 5 lines

- Thus, we should source all top-level environment scripts, but not any
project-specific ones, as they will be pulled in implicitly.

Is that correct?

That sounds correct

OK, I'll send a v3 soon.

#16 lore raw

PATCH v2 6/7 meson: handle exe wrappers

In reply to Martin Kelly

Add patches to enable meson to handle being wrapped with a shell script. This will enable us to do so for supporting the SDK, which requires us to setup env vars and point to a meson.cross file inside the SDK.

These patches are all merged upstream, so we can drop them soon.

---
v2:
- Switch to new version of patches to fix exe wrappers, as upstream tweaked the previous patch.

 ...0004-Prettifying-some-output-with-pathlib.patch | 188 +++++
 ...on-command-to-use-when-we-know-what-it-is.patch | 851 +++++++++++++++++++++
 meta/recipes-devtools/meson/meson_0.46.1.bb        |   2 +
 3 files changed, 1041 insertions(+)
 create mode 100644 meta/recipes-devtools/meson/meson/0004-Prettifying-some-output-with-pathlib.patch
 create mode 100644 meta/recipes-devtools/meson/meson/0005-Set-the-meson-command-to-use-when-we-know-what-it-is.patch
meta/recipes-devtools/meson/meson/0004-Prettifying-some-output-with-pathlib.patch new file +188 -0
new file mode 100644
index 0000000000..e75633beb9
@@ -0,0 +1,188 @@
+From 253ab5bf6d6d925abcf625b72f5fcacf99be13bd Mon Sep 17 00:00:00 2001
+From: Niklas Claesson <[email protected]>
+Date: Wed, 18 Apr 2018 15:25:03 +0200
+Subject: [PATCH] Prettifying some output with pathlib
+
+This is a backport required in order to make
+0005-Set-the-meson-command-to-use-when-we-know-what-it-is.patch apply.
+
+Upstream-Status: Accepted [https://github.com/mesonbuild/meson/pull/3423]
+Should be in the 0.47.0 release.
+
+Signed-off-by: Martin Kelly <[email protected]>
+---
+ run_cross_test.py    |  6 ++++--
+ run_project_tests.py | 51 +++++++++++++++++++++++++++++----------------------
+ 2 files changed, 33 insertions(+), 24 deletions(-)
+
+diff --git a/run_cross_test.py b/run_cross_test.py
+index e285e218..71914028 100755
+--- a/run_cross_test.py
++++ b/run_cross_test.py
+@@ -22,13 +22,15 @@ Not part of the main test suite because of two reasons:
+ 
+ Eventually migrate to something fancier.'''
+ 
+-import sys, os
++import sys
++import os
++from pathlib import Path
+ 
+ from run_project_tests import gather_tests, run_tests, StopException, setup_commands
+ from run_project_tests import failing_logs
+ 
+ def runtests(cross_file):
+-    commontests = [('common', gather_tests('test cases/common'), False)]
++    commontests = [('common', gather_tests(Path('test cases', 'common')), False)]
+     try:
+         (passing_tests, failing_tests, skipped_tests) = run_tests(commontests, 'meson-cross-test-run', ['--cross', cross_file])
+     except StopException:
+diff --git a/run_project_tests.py b/run_project_tests.py
+index 8c02a9ee..3c516240 100755
+--- a/run_project_tests.py
++++ b/run_project_tests.py
+@@ -14,14 +14,22 @@
+ # See the License for the specific language governing permissions and
+ # limitations under the License.
+ 
+-from glob import glob
+ import itertools
+-import os, subprocess, shutil, sys, signal
++import os
++import subprocess
++import shutil
++import sys
++import signal
+ from io import StringIO
+ from ast import literal_eval
+ from enum import Enum
+ import tempfile
+-from mesonbuild import build, environment, mesonlib, mlog, mtest
++from pathlib import Path, PurePath
++from mesonbuild import build
++from mesonbuild import environment
++from mesonbuild import mesonlib
++from mesonbuild import mlog
++from mesonbuild import mtest
+ from mesonbuild.mesonlib import stringlistify, Popen_safe
+ from mesonbuild.coredata import backendlist
+ import argparse
+@@ -198,7 +206,7 @@ def validate_install(srcdir, installdir, compiler, env):
+ 
+ def log_text_file(logfile, testdir, stdo, stde):
+     global stop, executor, futures
+-    logfile.write('%s\nstdout\n\n---\n' % testdir)
++    logfile.write('%s\nstdout\n\n---\n' % testdir.as_posix())
+     logfile.write(stdo)
+     logfile.write('\n\n---\n\nstderr\n\n---\n')
+     logfile.write(stde)
+@@ -245,11 +253,11 @@ def run_test_inprocess(testdir):
+     sys.stderr = mystderr = StringIO()
+     old_cwd = os.getcwd()
+     os.chdir(testdir)
+-    test_log_fname = 'meson-logs/testlog.txt'
++    test_log_fname = Path('meson-logs', 'testlog.txt')
+     try:
+         returncode_test = mtest.run(['--no-rebuild'])
+-        if os.path.exists(test_log_fname):
+-            test_log = open(test_log_fname, errors='ignore').read()
++        if test_log_fname.exists():
++            test_log = test_log_fname.open(errors='ignore').read()
+         else:
+             test_log = ''
+         returncode_benchmark = mtest.run(['--no-rebuild', '--benchmark', '--logbase', 'benchmarklog'])
+@@ -318,9 +326,8 @@ def _run_test(testdir, test_build_dir, install_dir, extra_args, compiler, backen
+     gen_args += [testdir, test_build_dir] + flags + test_args + extra_args
+     (returncode, stdo, stde) = run_configure(meson_command, gen_args)
+     try:
+-        logfile = os.path.join(test_build_dir, 'meson-logs/meson-log.txt')
+-        with open(logfile, encoding='utf-8', errors='ignore') as f:
+-            mesonlog = f.read()
++        logfile = Path(test_build_dir, 'meson-logs', 'meson-log.txt')
++        mesonlog = logfile.open(errors='ignore', encoding='utf-8').read()
+     except Exception:
+         mesonlog = no_meson_log_msg
+     gen_time = time.time() - gen_start
+@@ -390,11 +397,11 @@ def _run_test(testdir, test_build_dir, install_dir, extra_args, compiler, backen
+     return TestResult(validate_install(testdir, install_dir, compiler, builddata.environment),
+                       BuildStep.validate, stdo, stde, mesonlog, gen_time, build_time, test_time)
+ 
+-def gather_tests(testdir):
+-    tests = [t.replace('\\', '/').split('/', 2)[2] for t in glob(testdir + '/*')]
++def gather_tests(testdir: Path):
++    tests = [t.name for t in testdir.glob('*')]
+     testlist = [(int(t.split()[0]), t) for t in tests]
+     testlist.sort()
+-    tests = [os.path.join(testdir, t[1]) for t in testlist]
++    tests = [testdir / t[1] for t in testlist]
+     return tests
+ 
+ def have_d_compiler():
+@@ -517,7 +524,7 @@ def detect_tests_to_run():
+         ('fpga', 'fpga', shutil.which('yosys') is None),
+         ('frameworks', 'frameworks', False),
+     ]
+-    gathered_tests = [(name, gather_tests('test cases/' + subdir), skip) for name, subdir, skip in all_tests]
++    gathered_tests = [(name, gather_tests(Path('test cases', subdir)), skip) for name, subdir, skip in all_tests]
+     return gathered_tests
+ 
+ def run_tests(all_tests, log_name_base, extra_args):
+@@ -566,18 +573,18 @@ def _run_tests(all_tests, log_name_base, extra_args):
+         for t in test_cases:
+             # Jenkins screws us over by automatically sorting test cases by name
+             # and getting it wrong by not doing logical number sorting.
+-            (testnum, testbase) = os.path.split(t)[-1].split(' ', 1)
++            (testnum, testbase) = t.name.split(' ', 1)
+             testname = '%.3d %s' % (int(testnum), testbase)
+             should_fail = False
+             if name.startswith('failing'):
+                 should_fail = name.split('failing-')[1]
+-            result = executor.submit(run_test, skipped, t, extra_args, system_compiler, backend, backend_flags, commands, should_fail)
++            result = executor.submit(run_test, skipped, t.as_posix(), extra_args, system_compiler, backend, backend_flags, commands, should_fail)
+             futures.append((testname, t, result))
+         for (testname, t, result) in futures:
+             sys.stdout.flush()
+             result = result.result()
+-            if (result is None) or (('MESON_SKIP_TEST' in result.stdo) and (skippable(name, t))):
+-                print(yellow('Skipping:'), t)
++            if (result is None) or (('MESON_SKIP_TEST' in result.stdo) and (skippable(name, t.as_posix()))):
++                print(yellow('Skipping:'), t.as_posix())
+                 current_test = ET.SubElement(current_suite, 'testcase', {'name': testname,
+                                                                          'classname': name})
+                 ET.SubElement(current_test, 'skipped', {})
+@@ -585,7 +592,7 @@ def _run_tests(all_tests, log_name_base, extra_args):
+             else:
+                 without_install = "" if len(install_commands) > 0 else " (without install)"
+                 if result.msg != '':
+-                    print(red('Failed test{} during {}: {!r}'.format(without_install, result.step.name, t)))
++                    print(red('Failed test{} during {}: {!r}'.format(without_install, result.step.name, t.as_posix())))
+                     print('Reason:', result.msg)
+                     failing_tests += 1
+                     if result.step == BuildStep.configure and result.mlog != no_meson_log_msg:
+@@ -597,7 +604,7 @@ def _run_tests(all_tests, log_name_base, extra_args):
+                         failing_logs.append(result.stdo)
+                     failing_logs.append(result.stde)
+                 else:
+-                    print('Succeeded test%s: %s' % (without_install, t))
++                    print('Succeeded test%s: %s' % (without_install, t.as_posix()))
+                     passing_tests += 1
+                 conf_time += result.conftime
+                 build_time += result.buildtime
+@@ -641,7 +648,7 @@ def check_format():
+ 
+ def check_meson_commands_work():
+     global backend, meson_command, compile_commands, test_commands, install_commands
+-    testdir = 'test cases/common/1 trivial'
++    testdir = PurePath('test cases', 'common', '1 trivial').as_posix()
+     with AutoDeletedDir(tempfile.mkdtemp(prefix='b ', dir='.')) as build_dir:
+         print('Checking that configuring works...')
+         gen_cmd = mesonlib.meson_command + [testdir, build_dir] + backend_flags
+@@ -706,7 +713,7 @@ if __name__ == '__main__':
+             except UnicodeError:
+                 print(l.encode('ascii', errors='replace').decode(), '\n')
+     for name, dirs, skip in all_tests:
+-        dirs = (os.path.basename(x) for x in dirs)
++        dirs = (x.name for x in dirs)
+         for k, g in itertools.groupby(dirs, key=lambda x: x.split()[0]):
+             tests = list(g)
+             if len(tests) != 1:
meta/recipes-devtools/meson/meson/0005-Set-the-meson-command-to-use-when-we-know-what-it-is.patch new file +851 -0

851 lines not on this page · raw message

meta/recipes-devtools/meson/meson_0.46.1.bb +2 -0
index a18cab81f4..77f6416cc2 100644
@@ -9,6 +9,8 @@ SRC_URI = "https://github.com/mesonbuild/meson/releases/download/${PV}/${BP}.tar
            file://0002-gobject-introspection-determine-g-ir-scanner-and-g-i.patch \
            file://0001-Linker-rules-move-cross_args-in-front-of-output_args.patch \
            file://0003-native_bindir.patch \
+           file://0004-Prettifying-some-output-with-pathlib.patch \
+           file://0005-Set-the-meson-command-to-use-when-we-know-what-it-is.patch \
            "
 SRC_URI[md5sum] = "1698f6526574839de5dcdc45e3f7d582"
 SRC_URI[sha256sum] = "19497a03e7e5b303d8d11f98789a79aba59b5ad4a81bd00f4d099be0212cee78"
Signature · 1 line
2.11.0
#17 lore raw

PATCH v2 7/7 meson: enable nativesdk

In reply to Martin Kelly

Currently, we can't build meson into SDKs because we don't autogenerate the required meson.cross file.

Enable this by using the post-relocate hooks and generating a meson.cross file based on the SDK environment passed into the post-relocate hook.

---
 meta/recipes-devtools/meson/meson.inc              | 22 +++++++
 meta/recipes-devtools/meson/meson/meson-setup.py   | 62 ++++++++++++++++++
 meta/recipes-devtools/meson/meson/meson-wrapper    | 14 ++++
 meta/recipes-devtools/meson/meson_0.46.1.bb        | 22 +------
 .../meson/nativesdk-meson_0.46.1.bb                | 74 ++++++++++++++++++++++
 5 files changed, 173 insertions(+), 21 deletions(-)
 create mode 100644 meta/recipes-devtools/meson/meson.inc
 create mode 100755 meta/recipes-devtools/meson/meson/meson-setup.py
 create mode 100755 meta/recipes-devtools/meson/meson/meson-wrapper
 create mode 100644 meta/recipes-devtools/meson/nativesdk-meson_0.46.1.bb
meta/recipes-devtools/meson/meson.inc new file +22 -0
new file mode 100644
index 0000000000..4c113dcaf7
@@ -0,0 +1,22 @@
+HOMEPAGE = "http://mesonbuild.com"
+SUMMARY = "A high performance build system"
+
+LICENSE = "Apache-2.0"
+LIC_FILES_CHKSUM = "file://COPYING;md5=3b83ef96387f14655fc854ddc3c6bd57"
+
+SRC_URI = "https://github.com/mesonbuild/meson/releases/download/${PV}/meson-${PV}.tar.gz \
+           file://0001-gtkdoc-fix-issues-that-arise-when-cross-compiling.patch \
+           file://0002-gobject-introspection-determine-g-ir-scanner-and-g-i.patch \
+           file://0001-Linker-rules-move-cross_args-in-front-of-output_args.patch \
+           file://0003-native_bindir.patch \
+           file://0004-Prettifying-some-output-with-pathlib.patch \
+           file://0005-Set-the-meson-command-to-use-when-we-know-what-it-is.patch \
+           "
+
+SRC_URI[md5sum] = "1698f6526574839de5dcdc45e3f7d582"
+SRC_URI[sha256sum] = "19497a03e7e5b303d8d11f98789a79aba59b5ad4a81bd00f4d099be0212cee78"
+UPSTREAM_CHECK_URI = "https://github.com/mesonbuild/meson/releases"
+
+inherit setuptools3
+
+RDEPENDS_${PN} = "ninja python3-core python3-modules"
meta/recipes-devtools/meson/meson/meson-setup.py new file +62 -0

62 lines not on this page · raw message

meta/recipes-devtools/meson/meson/meson-wrapper new file +14 -0
new file mode 100755
index 0000000000..b2e00da513
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+if [ -z "$OECORE_NATIVE_SYSROOT" ]; then
+    echo "OECORE_NATIVE_SYSROOT not set; are you in a Yocto SDK environment?" >&2
+fi
+
+# If these are set to a cross-compile path, meson will get confused and try to
+# use them as native tools. Unset them to prevent this, as all the cross-compile
+# config is already in meson.cross.
+unset CC CXX CPP LD AR NM STRIP
+
+exec "$OECORE_NATIVE_SYSROOT/usr/bin/meson.real" \
+     --cross-file "$OECORE_NATIVE_SYSROOT/usr/share/meson/meson.cross" \
+     "$@"
meta/recipes-devtools/meson/meson_0.46.1.bb +1 -21
index 77f6416cc2..897fa148d9 100644
@@ -1,23 +1,3 @@
-HOMEPAGE = "http://mesonbuild.com"
-SUMMARY = "A high performance build system"
-
-LICENSE = "Apache-2.0"
-LIC_FILES_CHKSUM = "file://COPYING;md5=3b83ef96387f14655fc854ddc3c6bd57"
-
-SRC_URI = "https://github.com/mesonbuild/meson/releases/download/${PV}/${BP}.tar.gz \
-           file://0001-gtkdoc-fix-issues-that-arise-when-cross-compiling.patch \
-           file://0002-gobject-introspection-determine-g-ir-scanner-and-g-i.patch \
-           file://0001-Linker-rules-move-cross_args-in-front-of-output_args.patch \
-           file://0003-native_bindir.patch \
-           file://0004-Prettifying-some-output-with-pathlib.patch \
-           file://0005-Set-the-meson-command-to-use-when-we-know-what-it-is.patch \
-           "
-SRC_URI[md5sum] = "1698f6526574839de5dcdc45e3f7d582"
-SRC_URI[sha256sum] = "19497a03e7e5b303d8d11f98789a79aba59b5ad4a81bd00f4d099be0212cee78"
-UPSTREAM_CHECK_URI = "https://github.com/mesonbuild/meson/releases"
-
-inherit setuptools3
-
-RDEPENDS_${PN} = "ninja python3-core python3-modules"
+include meson.inc
 
 BBCLASSEXTEND = "native"
meta/recipes-devtools/meson/nativesdk-meson_0.46.1.bb new file +74 -0

74 lines not on this page · raw message

Signature · 1 line
2.11.0
#18 lore raw

Re: [PATCH v2 7/7] meson: enable nativesdk

I added a test case to actually build something with Meson on the autobuilder, and this breaks for multilib SDKs. These ship multiple environment files, so the cross generation can't happen at relocate time.

Ross

Quoted 254 lines · Martin Kelly

Currently, we can't build meson into SDKs because we don't autogenerate the required meson.cross file.

Enable this by using the post-relocate hooks and generating a meson.cross file based on the SDK environment passed into the post-relocate hook.

---
 meta/recipes-devtools/meson/meson.inc              | 22 +++++++
 meta/recipes-devtools/meson/meson/meson-setup.py   | 62 ++++++++++++++++++
 meta/recipes-devtools/meson/meson/meson-wrapper    | 14 ++++
 meta/recipes-devtools/meson/meson_0.46.1.bb        | 22 +------
 .../meson/nativesdk-meson_0.46.1.bb                | 74 ++++++++++++++++++++++
 5 files changed, 173 insertions(+), 21 deletions(-)
 create mode 100644 meta/recipes-devtools/meson/meson.inc
 create mode 100755 meta/recipes-devtools/meson/meson/meson-setup.py
 create mode 100755 meta/recipes-devtools/meson/meson/meson-wrapper
 create mode 100644 meta/recipes-devtools/meson/nativesdk-meson_0.46.1.bb
meta/recipes-devtools/meson/meson.inc new file +22 -0
new file mode 100644
index 0000000000..4c113dcaf7
@@ -0,0 +1,22 @@
+HOMEPAGE = "http://mesonbuild.com"
+SUMMARY = "A high performance build system"
+
+LICENSE = "Apache-2.0"
+LIC_FILES_CHKSUM = "file://COPYING;md5=3b83ef96387f14655fc854ddc3c6bd57"
+
+SRC_URI = "https://github.com/mesonbuild/meson/releases/download/${PV}/meson-${PV}.tar.gz \
+           file://0001-gtkdoc-fix-issues-that-arise-when-cross-compiling.patch \
+           file://0002-gobject-introspection-determine-g-ir-scanner-and-g-i.patch \
+           file://0001-Linker-rules-move-cross_args-in-front-of-output_args.patch \
+           file://0003-native_bindir.patch \
+           file://0004-Prettifying-some-output-with-pathlib.patch \
+           file://0005-Set-the-meson-command-to-use-when-we-know-what-it-is.patch \
+           "
+
+SRC_URI[md5sum] = "1698f6526574839de5dcdc45e3f7d582"
+SRC_URI[sha256sum] = "19497a03e7e5b303d8d11f98789a79aba59b5ad4a81bd00f4d099be0212cee78"
+UPSTREAM_CHECK_URI = "https://github.com/mesonbuild/meson/releases"
+
+inherit setuptools3
+
+RDEPENDS_${PN} = "ninja python3-core python3-modules"
meta/recipes-devtools/meson/meson/meson-setup.py new file +62 -0
new file mode 100755
index 0000000000..a9749eae9d
@@ -0,0 +1,62 @@
+#!/usr/bin/env python3
+
+import os
+import sys
+
+def bail(msg):
+    print(msg, file=sys.stderr)
+    sys.exit(1)
+
+_MARKER = '@@'
+def transform_line(line):
+    # Substitute any special markers of this form:
+    # @@ENV@@
+    # with the value of ENV, split into meson array syntax.
+    start = line.find(_MARKER)
+    if start == -1:
+        return line
+
+    end = line.rfind(_MARKER)
+    if end == start:
+        return line
+
+    # Lookup value of the env var.
+    var = line[start+len(_MARKER):end]
+    try:
+        val = os.environ[var]
+    except KeyError:
+        bail('cannot generate meson.cross; env var %s not set' % var)
+
+    # Transform into meson array.
+    val = ["'%s'" % x for x in val.split()]
+    val = ', '.join(val)
+    val = '[%s]' % val
+
+    before = line[:start]
+    after = line[end+len(_MARKER):]
+
+    return '%s%s%s' % (before, val, after)
+
+# Make sure this is really an SDK extraction environment.
+try:
+    sysroot = os.environ['OECORE_NATIVE_SYSROOT']
+except KeyError:
+    bail('OECORE_NATIVE_SYSROOT env var must be set')
+
+cross_file = os.path.join(sysroot, 'usr/share/meson/meson.cross')
+tmp_cross_file = '%s.tmp' % cross_file
+
+# Read through and transform the current meson.cross.
+lines = []
+with open(cross_file, 'r') as f:
+    for line in f:
+        lines.append(transform_line(line))
+
+# Write the transformed result to a tmp file and atomically rename it. In case
+# we crash during the file write, we don't want an invalid meson.cross file.
+with open(tmp_cross_file, 'w') as f:
+    for line in lines:
+        f.write(line)
+    f.flush()
+    os.fdatasync(f.fileno())
+os.rename(tmp_cross_file, cross_file)
meta/recipes-devtools/meson/meson/meson-wrapper new file +14 -0
new file mode 100755
index 0000000000..b2e00da513
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+if [ -z "$OECORE_NATIVE_SYSROOT" ]; then
+    echo "OECORE_NATIVE_SYSROOT not set; are you in a Yocto SDK environment?" >&2
+fi
+
+# If these are set to a cross-compile path, meson will get confused and try to
+# use them as native tools. Unset them to prevent this, as all the cross-compile
+# config is already in meson.cross.
+unset CC CXX CPP LD AR NM STRIP
+
+exec "$OECORE_NATIVE_SYSROOT/usr/bin/meson.real" \
+     --cross-file "$OECORE_NATIVE_SYSROOT/usr/share/meson/meson.cross" \
+     "$@"
meta/recipes-devtools/meson/meson_0.46.1.bb +1 -21
index 77f6416cc2..897fa148d9 100644
@@ -1,23 +1,3 @@
-HOMEPAGE = "http://mesonbuild.com"
-SUMMARY = "A high performance build system"
-
-LICENSE = "Apache-2.0"
-LIC_FILES_CHKSUM = "file://COPYING;md5=3b83ef96387f14655fc854ddc3c6bd57"
-
-SRC_URI = "https://github.com/mesonbuild/meson/releases/download/${PV}/${BP}.tar.gz \
-           file://0001-gtkdoc-fix-issues-that-arise-when-cross-compiling.patch \
-           file://0002-gobject-introspection-determine-g-ir-scanner-and-g-i.patch \
-           file://0001-Linker-rules-move-cross_args-in-front-of-output_args.patch \
-           file://0003-native_bindir.patch \
-           file://0004-Prettifying-some-output-with-pathlib.patch \
-           file://0005-Set-the-meson-command-to-use-when-we-know-what-it-is.patch \
-           "
-SRC_URI[md5sum] = "1698f6526574839de5dcdc45e3f7d582"
-SRC_URI[sha256sum] = "19497a03e7e5b303d8d11f98789a79aba59b5ad4a81bd00f4d099be0212cee78"
-UPSTREAM_CHECK_URI = "https://github.com/mesonbuild/meson/releases"
-
-inherit setuptools3
-
-RDEPENDS_${PN} = "ninja python3-core python3-modules"
+include meson.inc
 
 BBCLASSEXTEND = "native"
meta/recipes-devtools/meson/nativesdk-meson_0.46.1.bb new file +74 -1
new file mode 100644
index 0000000000..53503aa998
@@ -0,0 +1,74 @@
+include meson.inc
+
+inherit nativesdk
+
+SRC_URI += "file://meson-setup.py \
+            file://meson-wrapper"
+
+def meson_array(var, d):
+    return "', '".join(d.getVar(var).split()).join(("'", "'"))
+
+# both are required but not used by meson
+MESON_SDK_ENDIAN = "bogus-endian"
+MESON_TARGET_ENDIAN = "bogus-endian"
+
+MESON_TOOLCHAIN_ARGS = "${BUILDSDK_CC_ARCH}${TOOLCHAIN_OPTIONS}"
+MESON_C_ARGS = "${MESON_TOOLCHAIN_ARGS} ${BUILDSDK_CFLAGS}"
+MESON_CPP_ARGS = "${MESON_TOOLCHAIN_ARGS} ${BUILDSDK_CXXFLAGS}"
+MESON_LINK_ARGS = "${MESON_TOOLCHAIN_ARGS} ${BUILDSDK_LDFLAGS}"
+
+# This logic is similar but not identical to that in meson.bbclass, since it's
+# generating for an SDK rather than a cross-compile. Important differences are:
+# - We can't set vars like CC, CXX, etc. yet because they will be filled in with
+#   real paths by meson-setup.sh when the SDK is extracted.
+# - Some overrides aren't needed, since the SDK injects paths that take care of
+#   them.
+addtask write_config before do_install
+do_write_config[vardeps] += "MESON_C_ARGS MESON_CPP_ARGS MESON_LINK_ARGS CC CXX LD AR NM STRIP READELF"
+do_write_config() {
+    # This needs to be Py to split the args into single-element lists
+    cat >${WORKDIR}/meson.cross <<EOF
+[binaries]
+c = @@CC@@
+cpp = @@CXX@@
+ar = @@AR@@
+nm = @@NM@@
+ld = @@LD@@
+strip = @@STRIP@@
+pkgconfig = 'pkg-config'
+
+[properties]
+needs_exe_wrapper = true
+c_args = @@CFLAGS@@
+c_link_args = @@LDFLAGS@@
+cpp_args = @@CPPFLAGS@@
+cpp_link_args = @@LDFLAGS@@
+
+[host_machine]
+system = '${SDK_OS}'
+cpu_family = '${SDK_ARCH}'
+cpu = '${SDK_ARCH}'
+endian = '${MESON_SDK_ENDIAN}'
+EOF
+}
+
+do_install_append() {
+    install -d ${D}${datadir}/meson
+    install -m 0644 ${WORKDIR}/meson.cross ${D}${datadir}/meson/
+
+    install -d ${D}${SDKPATHNATIVE}/post-relocate-setup.d
+    install -m 0755 ${WORKDIR}/meson-setup.py ${D}${SDKPATHNATIVE}/post-relocate-setup.d/
+
+    # We need to wrap the real meson with a thin env setup wrapper.
+    mv ${D}${bindir}/meson ${D}${bindir}/meson.real
+    install -m 0755 ${WORKDIR}/meson-wrapper ${D}${bindir}/meson
+}
+
+RDEPENDS_${PN} += "\
+    nativesdk-ninja \
+    nativesdk-python3-core \
+    nativesdk-python3-misc \
+    nativesdk-python3-modules \
+    "
+
+FILES_${PN} += "${datadir}/meson ${SDKPATHNATIVE}"
--

2.11.0

--
_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core

#19 lore raw

Re: [PATCH v2 7/7] meson: enable nativesdk

Quoted 7 lines · Ross

I added a test case to actually build something with Meson on the autobuilder, and this breaks for multilib SDKs. These ship multiple environment files, so the cross generation can't happen at relocate time.

Ross

Could you elaborate on exactly what is breaking, or do you have a link to the autobuilder breakage?

To give a bit of background, cmake handles this by putting env vars directly into the wrapper script. However, meson does not support env vars in its cross toolchain file (and upstream is resistant to adding it), so we are left with generating paths at relocate time.

Quoted 255 lines · Martin Kelly
Quoted 254 lines

Currently, we can't build meson into SDKs because we don't autogenerate the required meson.cross file.

Enable this by using the post-relocate hooks and generating a meson.cross file based on the SDK environment passed into the post-relocate hook.

---
  meta/recipes-devtools/meson/meson.inc              | 22 +++++++
  meta/recipes-devtools/meson/meson/meson-setup.py   | 62 ++++++++++++++++++
  meta/recipes-devtools/meson/meson/meson-wrapper    | 14 ++++
  meta/recipes-devtools/meson/meson_0.46.1.bb        | 22 +------
  .../meson/nativesdk-meson_0.46.1.bb                | 74 ++++++++++++++++++++++
  5 files changed, 173 insertions(+), 21 deletions(-)

create mode 100644 meta/recipes-devtools/meson/meson.inc create mode 100755 meta/recipes-devtools/meson/meson/meson-setup.py create mode 100755 meta/recipes-devtools/meson/meson/meson-wrapper create mode 100644 meta/recipes-devtools/meson/nativesdk-meson_0.46.1.bb

meta/recipes-devtools/meson/meson.inc new file +22 -0
new file mode 100644
index 0000000000..4c113dcaf7
@@ -0,0 +1,22 @@
+HOMEPAGE = "http://mesonbuild.com"
+SUMMARY = "A high performance build system"
+
+LICENSE = "Apache-2.0"
+LIC_FILES_CHKSUM = "file://COPYING;md5=3b83ef96387f14655fc854ddc3c6bd57"
+
+SRC_URI = "https://github.com/mesonbuild/meson/releases/download/${PV}/meson-${PV}.tar.gz \
+           file://0001-gtkdoc-fix-issues-that-arise-when-cross-compiling.patch \
+           file://0002-gobject-introspection-determine-g-ir-scanner-and-g-i.patch \
+           file://0001-Linker-rules-move-cross_args-in-front-of-output_args.patch \
+           file://0003-native_bindir.patch \
+           file://0004-Prettifying-some-output-with-pathlib.patch \
+           file://0005-Set-the-meson-command-to-use-when-we-know-what-it-is.patch \
+           "
+
+SRC_URI[md5sum] = "1698f6526574839de5dcdc45e3f7d582"
+SRC_URI[sha256sum] = "19497a03e7e5b303d8d11f98789a79aba59b5ad4a81bd00f4d099be0212cee78"
+UPSTREAM_CHECK_URI = "https://github.com/mesonbuild/meson/releases"
+
+inherit setuptools3
+
+RDEPENDS_${PN} = "ninja python3-core python3-modules"
meta/recipes-devtools/meson/meson/meson-setup.py new file +62 -0
new file mode 100755
index 0000000000..a9749eae9d
@@ -0,0 +1,62 @@
+#!/usr/bin/env python3
+
+import os
+import sys
+
+def bail(msg):
+    print(msg, file=sys.stderr)
+    sys.exit(1)
+
+_MARKER = '@@'
+def transform_line(line):
+    # Substitute any special markers of this form:
+    # @@ENV@@
+    # with the value of ENV, split into meson array syntax.
+    start = line.find(_MARKER)
+    if start == -1:
+        return line
+
+    end = line.rfind(_MARKER)
+    if end == start:
+        return line
+
+    # Lookup value of the env var.
+    var = line[start+len(_MARKER):end]
+    try:
+        val = os.environ[var]
+    except KeyError:
+        bail('cannot generate meson.cross; env var %s not set' % var)
+
+    # Transform into meson array.
+    val = ["'%s'" % x for x in val.split()]
+    val = ', '.join(val)
+    val = '[%s]' % val
+
+    before = line[:start]
+    after = line[end+len(_MARKER):]
+
+    return '%s%s%s' % (before, val, after)
+
+# Make sure this is really an SDK extraction environment.
+try:
+    sysroot = os.environ['OECORE_NATIVE_SYSROOT']
+except KeyError:
+    bail('OECORE_NATIVE_SYSROOT env var must be set')
+
+cross_file = os.path.join(sysroot, 'usr/share/meson/meson.cross')
+tmp_cross_file = '%s.tmp' % cross_file
+
+# Read through and transform the current meson.cross.
+lines = []
+with open(cross_file, 'r') as f:
+    for line in f:
+        lines.append(transform_line(line))
+
+# Write the transformed result to a tmp file and atomically rename it. In case
+# we crash during the file write, we don't want an invalid meson.cross file.
+with open(tmp_cross_file, 'w') as f:
+    for line in lines:
+        f.write(line)
+    f.flush()
+    os.fdatasync(f.fileno())
+os.rename(tmp_cross_file, cross_file)
meta/recipes-devtools/meson/meson/meson-wrapper new file +14 -0
new file mode 100755
index 0000000000..b2e00da513
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+if [ -z "$OECORE_NATIVE_SYSROOT" ]; then
+    echo "OECORE_NATIVE_SYSROOT not set; are you in a Yocto SDK environment?" >&2
+fi
+
+# If these are set to a cross-compile path, meson will get confused and try to
+# use them as native tools. Unset them to prevent this, as all the cross-compile
+# config is already in meson.cross.
+unset CC CXX CPP LD AR NM STRIP
+
+exec "$OECORE_NATIVE_SYSROOT/usr/bin/meson.real" \
+     --cross-file "$OECORE_NATIVE_SYSROOT/usr/share/meson/meson.cross" \
+     "$@"
meta/recipes-devtools/meson/meson_0.46.1.bb +1 -21
index 77f6416cc2..897fa148d9 100644
@@ -1,23 +1,3 @@
-HOMEPAGE = "http://mesonbuild.com"
-SUMMARY = "A high performance build system"
-
-LICENSE = "Apache-2.0"
-LIC_FILES_CHKSUM = "file://COPYING;md5=3b83ef96387f14655fc854ddc3c6bd57"
-
-SRC_URI = "https://github.com/mesonbuild/meson/releases/download/${PV}/${BP}.tar.gz \
-           file://0001-gtkdoc-fix-issues-that-arise-when-cross-compiling.patch \
-           file://0002-gobject-introspection-determine-g-ir-scanner-and-g-i.patch \
-           file://0001-Linker-rules-move-cross_args-in-front-of-output_args.patch \
-           file://0003-native_bindir.patch \
-           file://0004-Prettifying-some-output-with-pathlib.patch \
-           file://0005-Set-the-meson-command-to-use-when-we-know-what-it-is.patch \
-           "
-SRC_URI[md5sum] = "1698f6526574839de5dcdc45e3f7d582"
-SRC_URI[sha256sum] = "19497a03e7e5b303d8d11f98789a79aba59b5ad4a81bd00f4d099be0212cee78"
-UPSTREAM_CHECK_URI = "https://github.com/mesonbuild/meson/releases"
-
-inherit setuptools3
-
-RDEPENDS_${PN} = "ninja python3-core python3-modules"
+include meson.inc
 
  BBCLASSEXTEND = "native"
meta/recipes-devtools/meson/nativesdk-meson_0.46.1.bb new file +74 -1
new file mode 100644
index 0000000000..53503aa998
@@ -0,0 +1,74 @@
+include meson.inc
+
+inherit nativesdk
+
+SRC_URI += "file://meson-setup.py \
+            file://meson-wrapper"
+
+def meson_array(var, d):
+    return "', '".join(d.getVar(var).split()).join(("'", "'"))
+
+# both are required but not used by meson
+MESON_SDK_ENDIAN = "bogus-endian"
+MESON_TARGET_ENDIAN = "bogus-endian"
+
+MESON_TOOLCHAIN_ARGS = "${BUILDSDK_CC_ARCH}${TOOLCHAIN_OPTIONS}"
+MESON_C_ARGS = "${MESON_TOOLCHAIN_ARGS} ${BUILDSDK_CFLAGS}"
+MESON_CPP_ARGS = "${MESON_TOOLCHAIN_ARGS} ${BUILDSDK_CXXFLAGS}"
+MESON_LINK_ARGS = "${MESON_TOOLCHAIN_ARGS} ${BUILDSDK_LDFLAGS}"
+
+# This logic is similar but not identical to that in meson.bbclass, since it's
+# generating for an SDK rather than a cross-compile. Important differences are:
+# - We can't set vars like CC, CXX, etc. yet because they will be filled in with
+#   real paths by meson-setup.sh when the SDK is extracted.
+# - Some overrides aren't needed, since the SDK injects paths that take care of
+#   them.
+addtask write_config before do_install
+do_write_config[vardeps] += "MESON_C_ARGS MESON_CPP_ARGS MESON_LINK_ARGS CC CXX LD AR NM STRIP READELF"
+do_write_config() {
+    # This needs to be Py to split the args into single-element lists
+    cat >${WORKDIR}/meson.cross <<EOF
+[binaries]
+c = @@CC@@
+cpp = @@CXX@@
+ar = @@AR@@
+nm = @@NM@@
+ld = @@LD@@
+strip = @@STRIP@@
+pkgconfig = 'pkg-config'
+
+[properties]
+needs_exe_wrapper = true
+c_args = @@CFLAGS@@
+c_link_args = @@LDFLAGS@@
+cpp_args = @@CPPFLAGS@@
+cpp_link_args = @@LDFLAGS@@
+
+[host_machine]
+system = '${SDK_OS}'
+cpu_family = '${SDK_ARCH}'
+cpu = '${SDK_ARCH}'
+endian = '${MESON_SDK_ENDIAN}'
+EOF
+}
+
+do_install_append() {
+    install -d ${D}${datadir}/meson
+    install -m 0644 ${WORKDIR}/meson.cross ${D}${datadir}/meson/
+
+    install -d ${D}${SDKPATHNATIVE}/post-relocate-setup.d
+    install -m 0755 ${WORKDIR}/meson-setup.py ${D}${SDKPATHNATIVE}/post-relocate-setup.d/
+
+    # We need to wrap the real meson with a thin env setup wrapper.
+    mv ${D}${bindir}/meson ${D}${bindir}/meson.real
+    install -m 0755 ${WORKDIR}/meson-wrapper ${D}${bindir}/meson
+}
+
+RDEPENDS_${PN} += "\
+    nativesdk-ninja \
+    nativesdk-python3-core \
+    nativesdk-python3-misc \
+    nativesdk-python3-modules \
+    "
+
+FILES_${PN} += "${datadir}/meson ${SDKPATHNATIVE}"
--

2.11.0

--
_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core

#20 lore raw

Re: [PATCH v2 7/7] meson: enable nativesdk

Quoted 7 lines · Martin Kelly

Could you elaborate on exactly what is breaking, or do you have a link to the autobuilder breakage?

To give a bit of background, cmake handles this by putting env vars directly into the wrapper script. However, meson does not support env vars in its cross toolchain file (and upstream is resistant to adding it), so we are left with generating paths at relocate time.

A multilib SDK has multiple environment scripts, and its only the environment scripts that differs. By the time I'd figured out what the problem was I was close to solving it, so there's patches on the list to solve this problem.

Ross

#21 lore raw

Re: [PATCH v2 7/7] meson: enable nativesdk

Quoted 9 lines · Ross
Quoted 7 lines · Martin Kelly

Could you elaborate on exactly what is breaking, or do you have a link to the autobuilder breakage?

To give a bit of background, cmake handles this by putting env vars directly into the wrapper script. However, meson does not support env vars in its cross toolchain file (and upstream is resistant to adding it), so we are left with generating paths at relocate time.

Quoted 7 lines

A multilib SDK has multiple environment scripts, and its only the environment scripts that differs. By the time I'd figured out what the problem was I was close to solving it, so there's patches on the list to solve this problem.

Ross

Got it, thanks!