Skip to contentSkip to conversation

meson: implement nativesdk support

PATCH In review Martin Kelly 3 participants 13 messages Jun 4, 2018 – Jun 5, 2018 Arm/Amlogic Meson SoC support

lore
Share & tools
lore
#0 lore raw

v3 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

v3:
- Implement review feedback from Joshua Watt (thanks!).
v2:
- Switch to new version of patches to fix exe wrappers, as upstream tweaked the previous patch.

Martin Kelly (6):
toolchain-scripts: retab file
toolchain-scripts: allow non-sh post-relocate
toolchain-scripts: print post-relocate error
toolchain-scripts: pass env to post-relocate
meson: handle exe wrappers
meson: enable nativesdk

 meta/classes/toolchain-scripts.bbclass             |  48 +-
 meta/recipes-core/meta/meta-environment.bb         |   2 +-
 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 ++
 9 files changed, 1247 insertions(+), 34 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 v3 1/6 toolchain-scripts: retab file

Two functions is uses a mix of spaces and tabs. The rest of the file uses tabs, so switch to tabs uniformly.

---
 meta/classes/toolchain-scripts.bbclass | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)
meta/classes/toolchain-scripts.bbclass +10 -10
index 71da5e5409..a72436167c 100644
@@ -122,7 +122,7 @@ toolchain_create_post_relocate_script() {
 	rm -f $script
 	touch $script
 
-    cat >> $script <<EOF
+	cat >> $script <<EOF
 if [ -d "${SDKPATHNATIVE}/post-relocate-setup.d/" ]; then
     for s in ${SDKPATHNATIVE}/post-relocate-setup.d/*.sh; do
         \$s "\$1"
@@ -166,13 +166,13 @@ toolchain_create_sdk_siteconfig () {
 toolchain_create_sdk_siteconfig[vardepsexclude] = "TOOLCHAIN_CONFIGSITE_SYSROOTCACHE"
 
 python __anonymous () {
-    import oe.classextend
-    deps = ""
-    for dep in (d.getVar('TOOLCHAIN_NEED_CONFIGSITE_CACHE') or "").split():
-        deps += " %s:do_populate_sysroot" % dep
-        for variant in (d.getVar('MULTILIB_VARIANTS') or "").split():
-            clsextend = oe.classextend.ClassExtender(variant, d)
-            newdep = clsextend.extend_name(dep)
-            deps += " %s:do_populate_sysroot" % newdep
-    d.appendVarFlag('do_configure', 'depends', deps)
+	import oe.classextend
+	deps = ""
+	for dep in (d.getVar('TOOLCHAIN_NEED_CONFIGSITE_CACHE') or "").split():
+		deps += " %s:do_populate_sysroot" % dep
+		for variant in (d.getVar('MULTILIB_VARIANTS') or "").split():
+			clsextend = oe.classextend.ClassExtender(variant, d)
+			newdep = clsextend.extend_name(dep)
+			deps += " %s:do_populate_sysroot" % newdep
+	d.appendVarFlag('do_configure', 'depends', deps)
 }
Signature · 1 line
2.11.0
#2 lore raw

Re: [PATCH v3 1/6] toolchain-scripts: retab file

Quoted 21 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Martin Kelly
Sent: den 5 juni 2018 01:06
To: [email protected]
Subject: [OE-core] [PATCH v3 1/6] toolchain-scripts: retab file

Two functions is uses a mix of spaces and tabs. The rest of the file uses tabs, so switch to tabs uniformly.

---
 meta/classes/toolchain-scripts.bbclass | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)
meta/classes/toolchain-scripts.bbclass +0 -0
index 71da5e5409..a72436167c 100644

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

Quoted 8 lines
meta/classes/toolchain-scripts.bbclass +1 -1
@@ -122,7 +122,7 @@ toolchain_create_post_relocate_script() {
 	rm -f $script
 	touch $script
 
-    cat >> $script <<EOF
+	cat >> $script <<EOF
 if [ -d "${SDKPATHNATIVE}/post-relocate-setup.d/" ]; then
     for s in ${SDKPATHNATIVE}/post-relocate-setup.d/*.sh; do
         \$s "\$1"

This part should be indented using tabs as well.

Quoted 12 lines
meta/classes/toolchain-scripts.bbclass +0 -8
@@ -166,13 +166,13 @@ toolchain_create_sdk_siteconfig () {
 toolchain_create_sdk_siteconfig[vardepsexclude] = "TOOLCHAIN_CONFIGSITE_SYSROOTCACHE"
 
 python __anonymous () {
-    import oe.classextend
-    deps = ""
-    for dep in (d.getVar('TOOLCHAIN_NEED_CONFIGSITE_CACHE') or "").split():
-        deps += " %s:do_populate_sysroot" % dep
-        for variant in (d.getVar('MULTILIB_VARIANTS') or "").split():
-            clsextend = oe.classextend.ClassExtender(variant, d)
-            newdep = clsextend.extend_name(dep)
-            deps += " %s:do_populate_sysroot" % newdep

meta/classes/toolchain-scripts.bbclass toolchain_create_sdk_siteconfig () { · line 177

Quoted 10 lines
meta/classes/toolchain-scripts.bbclass +9 -1
-    d.appendVarFlag('do_configure', 'depends', deps)
+	import oe.classextend
+	deps = ""
+	for dep in (d.getVar('TOOLCHAIN_NEED_CONFIGSITE_CACHE') or "").split():
+		deps += " %s:do_populate_sysroot" % dep
+		for variant in (d.getVar('MULTILIB_VARIANTS') or "").split():
+			clsextend = oe.classextend.ClassExtender(variant, d)
+			newdep = clsextend.extend_name(dep)
+			deps += " %s:do_populate_sysroot" % newdep
+	d.appendVarFlag('do_configure', 'depends', deps)

This is Python code. I believe the OE-Core standard is for Python code to be indented using four spaces (whereas shell code should be indented using tabs).

Quoted 3 lines
meta/classes/toolchain-scripts.bbclass +0 -1
 }
--

2.11.0

//Peter

#3 lore raw

Re: [PATCH v3 1/6] toolchain-scripts: retab file

Quoted 61 lines · Peter Kjellerstedt
Quoted 24 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of
Martin Kelly
Sent: den 5 juni 2018 01:06
To: [email protected]
Subject: [OE-core] [PATCH v3 1/6] toolchain-scripts: retab file

Two functions is uses a mix of spaces and tabs. The rest of the file
uses tabs, so switch to tabs uniformly.

---
 meta/classes/toolchain-scripts.bbclass | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)
meta/classes/toolchain-scripts.bbclass +0 -0
index 71da5e5409..a72436167c 100644

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

Quoted 8 lines
meta/classes/toolchain-scripts.bbclass +1 -1
@@ -122,7 +122,7 @@ toolchain_create_post_relocate_script() {
 	rm -f $script
 	touch $script
 
-    cat >> $script <<EOF
+	cat >> $script <<EOF
 if [ -d "${SDKPATHNATIVE}/post-relocate-setup.d/" ]; then
     for s in ${SDKPATHNATIVE}/post-relocate-setup.d/*.sh; do
         \$s "\$1"

This part should be indented using tabs as well.

Quoted 26 lines
meta/classes/toolchain-scripts.bbclass +0 -0
@@ -166,13 +166,13 @@ toolchain_create_sdk_siteconfig () {
 toolchain_create_sdk_siteconfig[vardepsexclude] =

"TOOLCHAIN_CONFIGSITE_SYSROOTCACHE"

python __anonymous () {

meta/classes/toolchain-scripts.bbclass +0 -3
-    import oe.classextend
-    deps = ""
-    for dep in (d.getVar('TOOLCHAIN_NEED_CONFIGSITE_CACHE') or

"").split():

meta/classes/toolchain-scripts.bbclass +0 -2
-        deps += " %s:do_populate_sysroot" % dep
-        for variant in (d.getVar('MULTILIB_VARIANTS') or

"").split():

meta/classes/toolchain-scripts.bbclass +3 -4
-            clsextend = oe.classextend.ClassExtender(variant, d)
-            newdep = clsextend.extend_name(dep)
-            deps += " %s:do_populate_sysroot" % newdep
-    d.appendVarFlag('do_configure', 'depends', deps)
+	import oe.classextend
+	deps = ""
+	for dep in (d.getVar('TOOLCHAIN_NEED_CONFIGSITE_CACHE') or

"").split():

meta/classes/toolchain-scripts.bbclass +2 -0
+		deps += " %s:do_populate_sysroot" % dep
+		for variant in (d.getVar('MULTILIB_VARIANTS') or

"").split():

meta/classes/toolchain-scripts.bbclass +1 -0
+			clsextend =

oe.classextend.ClassExtender(variant, d)

meta/classes/toolchain-scripts.bbclass +1 -0
+			newdep = clsextend.extend_name(dep)
Quoted 8 lines

meta/classes/toolchain-scripts.bbclass toolchain_create_sdk_siteconfig () { · line 177

Quoted 2 lines
meta/classes/toolchain-scripts.bbclass +2 -0
+			deps += " %s:do_populate_sysroot" % newdep
+	d.appendVarFlag('do_configure', 'depends', deps)

This is Python code. I believe the OE-Core standard is for Python code
to be indented using four spaces (whereas shell code should be indented
using tabs).

I noticed this last bit and simply dropped that patch hunk.

Cheers,

Richard

#4 lore raw

Re: [PATCH v3 1/6] toolchain-scripts: retab file

Quoted 79 lines

-----Original Message-----
From: Richard Purdie [mailto:[email protected]]
Sent: den 5 juni 2018 12:37
To: Peter Kjellerstedt <[email protected]>; Martin Kelly <[email protected]>; [email protected]
Subject: Re: [OE-core] [PATCH v3 1/6] toolchain-scripts: retab file

Quoted 54 lines · Peter Kjellerstedt
Quoted 24 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of
Martin Kelly
Sent: den 5 juni 2018 01:06
To: [email protected]
Subject: [OE-core] [PATCH v3 1/6] toolchain-scripts: retab file

Two functions is uses a mix of spaces and tabs. The rest of the file
uses tabs, so switch to tabs uniformly.

---
 meta/classes/toolchain-scripts.bbclass | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)
meta/classes/toolchain-scripts.bbclass +0 -0
index 71da5e5409..a72436167c 100644

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

Quoted 8 lines
meta/classes/toolchain-scripts.bbclass +1 -1
@@ -122,7 +122,7 @@ toolchain_create_post_relocate_script() {
 	rm -f $script
 	touch $script
 
-    cat >> $script <<EOF
+	cat >> $script <<EOF
 if [ -d "${SDKPATHNATIVE}/post-relocate-setup.d/" ]; then
     for s in ${SDKPATHNATIVE}/post-relocate-setup.d/*.sh; do
         \$s "\$1"

This part should be indented using tabs as well.

Quoted 19 lines
meta/classes/toolchain-scripts.bbclass +0 -0
@@ -166,13 +166,13 @@ toolchain_create_sdk_siteconfig () {
 toolchain_create_sdk_siteconfig[vardepsexclude] =

"TOOLCHAIN_CONFIGSITE_SYSROOTCACHE"

python __anonymous () {

meta/classes/toolchain-scripts.bbclass +0 -3
-    import oe.classextend
-    deps = ""
-    for dep in (d.getVar('TOOLCHAIN_NEED_CONFIGSITE_CACHE') or

"").split():

meta/classes/toolchain-scripts.bbclass +0 -2
-        deps += " %s:do_populate_sysroot" % dep
-        for variant in (d.getVar('MULTILIB_VARIANTS') or

"").split():

meta/classes/toolchain-scripts.bbclass +3 -4
-            clsextend = oe.classextend.ClassExtender(variant, d)
-            newdep = clsextend.extend_name(dep)
-            deps += " %s:do_populate_sysroot" % newdep
-    d.appendVarFlag('do_configure', 'depends', deps)
+	import oe.classextend
+	deps = ""
+	for dep in (d.getVar('TOOLCHAIN_NEED_CONFIGSITE_CACHE') or
Quoted 8 lines

meta/classes/toolchain-scripts.bbclass

Quoted 8 lines

"").split():

meta/classes/toolchain-scripts.bbclass +2 -0
+		deps += " %s:do_populate_sysroot" % dep
+		for variant in (d.getVar('MULTILIB_VARIANTS') or

"").split():

meta/classes/toolchain-scripts.bbclass +1 -0
+			clsextend =

oe.classextend.ClassExtender(variant, d)

meta/classes/toolchain-scripts.bbclass +2 -0
+			newdep = clsextend.extend_name(dep)
+			deps += " %s:do_populate_sysroot" %

newdep

Quoted 7 lines

meta/classes/toolchain-scripts.bbclass toolchain_create_sdk_siteconfig () { · line 177

Quoted 1 line
meta/classes/toolchain-scripts.bbclass +1 -0
+	d.appendVarFlag('do_configure', 'depends', deps)

This is Python code. I believe the OE-Core standard is for Python code
to be indented using four spaces (whereas shell code should be indented
using tabs).

Quoted 5 lines

I noticed this last bit and simply dropped that patch hunk.

Cheers,

Richard

You might want to update the commit message then as well, as it refers to the two functions that are modified, which is no longer the case.

//Peter

#5 lore raw

Re: [PATCH v3 1/6] toolchain-scripts: retab file

Quoted 81 lines · Peter Kjellerstedt
Quoted 81 lines

-----Original Message-----
From: Richard Purdie [mailto:[email protected]]
Sent: den 5 juni 2018 12:37
To: Peter Kjellerstedt <[email protected]>; Martin Kelly <[email protected]>; [email protected]
Subject: Re: [OE-core] [PATCH v3 1/6] toolchain-scripts: retab file

Quoted 54 lines · Peter Kjellerstedt
Quoted 24 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of
Martin Kelly
Sent: den 5 juni 2018 01:06
To: [email protected]
Subject: [OE-core] [PATCH v3 1/6] toolchain-scripts: retab file

Two functions is uses a mix of spaces and tabs. The rest of the file
uses tabs, so switch to tabs uniformly.

---
  meta/classes/toolchain-scripts.bbclass | 20 ++++++++++----------
  1 file changed, 10 insertions(+), 10 deletions(-)
meta/classes/toolchain-scripts.bbclass +0 -0
index 71da5e5409..a72436167c 100644

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

Quoted 8 lines
meta/classes/toolchain-scripts.bbclass +1 -1
@@ -122,7 +122,7 @@ toolchain_create_post_relocate_script() {
  	rm -f $script
  	touch $script
 
-    cat >> $script <<EOF
+	cat >> $script <<EOF
  if [ -d "${SDKPATHNATIVE}/post-relocate-setup.d/" ]; then
      for s in ${SDKPATHNATIVE}/post-relocate-setup.d/*.sh; do
          \$s "\$1"

This part should be indented using tabs as well.

Quoted 19 lines
meta/classes/toolchain-scripts.bbclass +0 -0
@@ -166,13 +166,13 @@ toolchain_create_sdk_siteconfig () {
  toolchain_create_sdk_siteconfig[vardepsexclude] =

"TOOLCHAIN_CONFIGSITE_SYSROOTCACHE"

  python __anonymous () {
meta/classes/toolchain-scripts.bbclass +0 -3
-    import oe.classextend
-    deps = ""
-    for dep in (d.getVar('TOOLCHAIN_NEED_CONFIGSITE_CACHE') or

"").split():

meta/classes/toolchain-scripts.bbclass +0 -2
-        deps += " %s:do_populate_sysroot" % dep
-        for variant in (d.getVar('MULTILIB_VARIANTS') or

"").split():

meta/classes/toolchain-scripts.bbclass +3 -4
-            clsextend = oe.classextend.ClassExtender(variant, d)
-            newdep = clsextend.extend_name(dep)
-            deps += " %s:do_populate_sysroot" % newdep
-    d.appendVarFlag('do_configure', 'depends', deps)
+	import oe.classextend
+	deps = ""
+	for dep in (d.getVar('TOOLCHAIN_NEED_CONFIGSITE_CACHE') or
Quoted 8 lines

meta/classes/toolchain-scripts.bbclass

Quoted 8 lines

"").split():

meta/classes/toolchain-scripts.bbclass +2 -0
+		deps += " %s:do_populate_sysroot" % dep
+		for variant in (d.getVar('MULTILIB_VARIANTS') or

"").split():

meta/classes/toolchain-scripts.bbclass +1 -0
+			clsextend =

oe.classextend.ClassExtender(variant, d)

meta/classes/toolchain-scripts.bbclass +2 -0
+			newdep = clsextend.extend_name(dep)
+			deps += " %s:do_populate_sysroot" %

newdep

Quoted 7 lines

meta/classes/toolchain-scripts.bbclass toolchain_create_sdk_siteconfig () { · line 177

Quoted 1 line
meta/classes/toolchain-scripts.bbclass +1 -0
+	d.appendVarFlag('do_configure', 'depends', deps)

This is Python code. I believe the OE-Core standard is for Python code
to be indented using four spaces (whereas shell code should be indented
using tabs).

I noticed this last bit and simply dropped that patch hunk.

Quoted 9 lines
Quoted 3 lines

Cheers,

Richard

You might want to update the commit message then as well, as it refers to the two functions that are modified, which is no longer the case.

//Peter

Thanks all; good point about Python and the commit message. I thought about using the one-line || version, but like Richard, I find the explicit if statement more readable, and more consistent with what the rest of the function does.

#6 lore raw

PATCH v3 2/6 toolchain-scripts: 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.

---
v3:
- Test for executability prior to running each script.

 meta/classes/toolchain-scripts.bbclass | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
meta/classes/toolchain-scripts.bbclass +4 -1
index a72436167c..da8a57f24b 100644
@@ -124,7 +124,10 @@ 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
+        if [ ! -x \$s ]; then
+            continue
+        fi
         \$s "\$1"
     done
     rm -rf "${SDKPATHNATIVE}/post-relocate-setup.d"
Signature · 1 line
2.11.0
#7 lore raw

Re: [PATCH v3 2/6] toolchain-scripts: allow non-sh post-relocate

Quoted 27 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Martin Kelly
Sent: den 5 juni 2018 01:06
To: [email protected]
Subject: [OE-core] [PATCH v3 2/6] toolchain-scripts: allow non-sh post- relocate

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.

---
v3:
- Test for executability prior to running each script.

 meta/classes/toolchain-scripts.bbclass | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
meta/classes/toolchain-scripts.bbclass +0 -0
index a72436167c..da8a57f24b 100644

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

Quoted 8 lines
meta/classes/toolchain-scripts.bbclass +4 -1
@@ -124,7 +124,10 @@ 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
+        if [ ! -x \$s ]; then
+            continue
+        fi

That can be written as:

         [ -x \$s ] || continue

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

Quoted 1 line
meta/classes/toolchain-scripts.bbclass +0 -0
         \$s "\$1"

Or you can replace all of it with:

         [ ! -x \$s ] || \$s "\$1"

You should not invert the test and replace the || with && though (even if it may seem more logical) due to the return status of the [ command in case $s is not executable.

Quoted 10 lines
meta/classes/toolchain-scripts.bbclass +0 -1
     done
     rm -rf "${SDKPATHNATIVE}/post-relocate-setup.d"
--

2.11.0

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

#8 lore raw

Re: [PATCH v3 2/6] toolchain-scripts: allow non-sh post-relocate

Quoted 46 lines · Peter Kjellerstedt
Quoted 31 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of
Martin Kelly
Sent: den 5 juni 2018 01:06
To: [email protected]
Subject: [OE-core] [PATCH v3 2/6] toolchain-scripts: allow non-sh post-
relocate

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.

---
v3:
- Test for executability prior to running each script.

 meta/classes/toolchain-scripts.bbclass | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
meta/classes/toolchain-scripts.bbclass +0 -0
index a72436167c..da8a57f24b 100644

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

Quoted 8 lines
meta/classes/toolchain-scripts.bbclass +4 -1
@@ -124,7 +124,10 @@ 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
+        if [ ! -x \$s ]; then
+            continue
+        fi

That can be written as:

         [ -x \$s ] || continue

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

Quoted 1 line
meta/classes/toolchain-scripts.bbclass +0 -0
         \$s "\$1"
Quoted 7 lines

Or you can replace all of it with:

         [ ! -x \$s ] || \$s "\$1"

You should not invert the test and replace the || with && though (even if it may seem more logical) due to the return status of the [ command in case $s is not executable.

FWIW personally I prefer the original patch version as being more readable...

Cheers,

Richard

#9 lore raw

PATCH v3 3/6 toolchain-scripts: 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 da8a57f24b..ef190a69ec 100644
@@ -129,6 +129,11 @@ if [ -d "${SDKPATHNATIVE}/post-relocate-setup.d/" ]; then
             continue
         fi
         \$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
#10 lore raw

PATCH v3 4/6 toolchain-scripts: 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.

---
v3:
- Source all top-level env setup scripts instead of just one.

 meta/classes/toolchain-scripts.bbclass     | 20 ++++++++++++++++----
 meta/recipes-core/meta/meta-environment.bb |  2 +-
 2 files changed, 17 insertions(+), 5 deletions(-)
meta/classes/toolchain-scripts.bbclass +16 -4
index ef190a69ec..727bdab4a0 100644
@@ -118,11 +118,23 @@ EOF
 }
 
 toolchain_create_post_relocate_script() {
-	script=$1
-	rm -f $script
-	touch $script
+	relocate_script=$1
+	env_dir=$2
+	rm -f $relocate_script
+	touch $relocate_script
+
+	cat >> $relocate_script <<EOF
+# Source top-level SDK env scripts in case they are needed for the relocate
+# scripts.
+for env_setup_script in ${env_dir}/environment-setup-*; do
+    . \$env_setup_script
+    status=\$?
+    if [ \$status != 0 ]; then
+        echo "\$0: Failed to source \$env_setup_script with status \$status"
+        exit \$status
+    fi
+done
 
-	cat >> $script <<EOF
 if [ -d "${SDKPATHNATIVE}/post-relocate-setup.d/" ]; then
     for s in ${SDKPATHNATIVE}/post-relocate-setup.d/*; do
         if [ ! -x \$s ]; then
meta/recipes-core/meta/meta-environment.bb +1 -1
index 09f757a087..da1230bead 100644
@@ -56,7 +56,7 @@ create_sdk_files() {
 	# 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 ${SDKPATH}
 }
 
 do_install() {
Signature · 1 line
2.11.0
#11 lore raw

PATCH v3 5/6 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
#12 lore raw

PATCH v3 6/6 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