Skip to contentSkip to conversation

how to load cmake args from git?

DISCUSSION Adam Trhon 2 participants 6 messages Jun 22, 2017 – Jul 5, 2017

lore
Share & tools
lore

Adam Trhon

author
#0 lore raw

I have a recipe that is configured by cmake. The cmake arguments are hardcoded in the recipe and set using the EXTRA_OECMAKE variable. For various reasons, I would like to have the arguments in a file in the project's upstream repository (it's mine as well) and load them.

I came up with this:

do_configure_prepend() {
    PACKAGECONFIG_CONFARGS =" ${PACKAGECONFIG_CONFARGS} $(cat ${S}/oe_arguments.txt) "
}

but I am not very happy about using PACKAGECONFIG_CONFARGS - it feels hacky, the arguments are not shown in cmake fail log and it cannot handle argumetns containing spaces. Is there a cleaner way to achieve this?

Thank you
Adam

Signature · 4 lines
Ing. Adam Trhoň, Software Engineer
Touchless Biometric Systems s.r.o. | 
Palackého třída 180/44 | 61200 Brno | CZECH REPUBLIC | 
Mobile: +42(0) 721 565 113 | tbs-biometrics.cz
#1 lore raw
Quoted 6 lines · Adam Trhon

but I am not very happy about using PACKAGECONFIG_CONFARGS - it feels hacky, the
arguments are not shown in cmake fail log and it cannot handle argumetns containing
spaces. Is there a cleaner way to achieve this?

Definitely don't use PACKAGECONFIG_CONFARGS: that has a well defined meaning and use, and that isn't it.

I don't see why as you control the repository why can't you just set the arguments in cmakelists, or the recipe itself? Either they're useful everywhere (cmakelists) or in OE builds (recipe).

Anyway, you could do something like this:

python() {
d.appendVar("EXTRA_OECMAKE", " " +
open(d.expand("${S}/oe_arguments.txt")).read()
}

Ross

author
#2 lore raw
Quoted 9 lines · Ross
Quoted 6 lines · Adam Trhon

but I am not very happy about using PACKAGECONFIG_CONFARGS - it feels hacky, the
arguments are not shown in cmake fail log and it cannot handle argumetns containing
spaces. Is there a cleaner way to achieve this?

Quoted 6 lines

Definitely don't use PACKAGECONFIG_CONFARGS: that has a well defined meaning and use, and that isn't it.

I don't see why as you control the repository why can't you just set the arguments in cmakelists, or the recipe itself? Either they're useful everywhere (cmakelists) or in OE builds (recipe).

The CMake options are maintained and used by upstream project developers (I am one of them). Sometimes they change the options between revisions, so it is difficult to maintain the argument list in the recipe.

I also want to let the upstream project developers change some arguments without touching the recipe (for automated builds).

Quoted 7 lines

Anyway, you could do something like this:

python() {
d.appendVar("EXTRA_OECMAKE", " " +
open(d.expand("${S}/oe_arguments.txt")).read()
}

According to documentation, this is expanded during recipe parsing. At that time ${S}/oe_arguments.txt does not yet exits (it exists only after do_unpack). I tried it and the build failed with python Exception:
FileNotFound.

I tried

python do_setup_extra_oecmake() {                  
    d.appendVar("EXTRA_OECMAKE", " " + open(d.expand("${S}/oe_arguments.txt")).read())
    print("adding "+d.expand("${S}/oe_arguments.txt"))
}   

addtask do_setup_extra_oecmake after do_unpack before do_configure

but it did not work as well. The "adding.... " line is printed correctly in log.do_setup_extra_oecmake, the file exists, but the arguments in it are not used (I checked run.do_configure).

Thank you
Adam

Quoted 2 lines

Ross

Signature · 4 lines
Ing. Adam Trhoň, Software Engineer
Touchless Biometric Systems s.r.o. | 
Palackého třída 180/44 | 61200 Brno | CZECH REPUBLIC | 
Mobile: +42(0) 721 565 113 | tbs-biometrics.cz
#3 lore raw
Quoted 5 lines · Adam Trhon

According to documentation, this is expanded during recipe parsing. At that time ${S}/oe_arguments.txt does not yet exits (it exists only after do_unpack). I tried it and the build failed with python Exception:
FileNotFound.

Yes, good point. In m defence it was late. :)

Quoted 8 lines

I tried

python do_setup_extra_oecmake() {
    d.appendVar("EXTRA_OECMAKE", " " + open(d.expand("${S}/oe_
arguments.txt")).read())
    print("adding "+d.expand("${S}/oe_arguments.txt"))
}
Quoted 6 lines

addtask do_setup_extra_oecmake after do_unpack before do_configure

but it did not work as well. The "adding.... " line is printed correctly in log.do_setup_extra_oecmake, the file exists, but the arguments in it are not used (I checked run.do_configure).

Have a look at log.do_configure and verify what options are being passed. I'm also assuming that you're using the cmake class here.

Ross

author
#4 lore raw
Quoted 19 lines · Ross
Quoted 5 lines · Adam Trhon

According to documentation, this is expanded during recipe parsing. At that time ${S}/oe_arguments.txt does not yet exits (it exists only after do_unpack). I tried it and the build failed with python Exception:
FileNotFound.

Yes, good point. In m defence it was late. :)

Quoted 8 lines

I tried

python do_setup_extra_oecmake() {
    d.appendVar("EXTRA_OECMAKE", " " + open(d.expand("${S}/oe_
arguments.txt")).read())
    print("adding "+d.expand("${S}/oe_arguments.txt"))
}
Quoted 8 lines
Quoted 6 lines

addtask do_setup_extra_oecmake after do_unpack before do_configure

but it did not work as well. The "adding.... " line is printed correctly in log.do_setup_extra_oecmake, the file exists, but the arguments in it are not used (I checked run.do_configure).

Have a look at log.do_configure and verify what options are being passed.

I still have EXTRA_OECMAKE="..." in the recipe, the arguments from here are being passed. But the arguments from oe_arguments.txt are not.

Quoted 1 line

I'm also assuming that you're using the cmake class here.

To be precise, I inherit cmake_qt5 class, which inherits cmake class.

Adam

Quoted 2 lines

Ross

Signature · 4 lines
Ing. Adam Trhoň, Software Engineer
Touchless Biometric Systems s.r.o. | 
Palackého třída 180/44 | 61200 Brno | CZECH REPUBLIC | 
Mobile: +42(0) 721 565 113 | tbs-biometrics.cz
author
#5 lore raw

Finally we figured it out. When chaning EXTRA_OECMAKE with python function, the function must not be registered like this:

addtask do_setup_extra_oecmake after do_patch before do_configure

but like this:

do_configure[prefuncs] += "do_setup_extra_oecmake"

I assume that as bitbake controls build task environment:

https://www.yoctoproject.org/docs/2.3/bitbake-user-manual/bitbake-user-manual.html#passing-information-into-the-build-task-environment

the changes of EXTRA_OECMAKE made in do_setup_extra_oecmake were not propagated to do_configure.

Just for the completeness, how am I supposed to globally modify a datastore variable from a python task?

Thank you
Adam

Signature · 4 lines
Ing. Adam Trhoň, Software Engineer
Touchless Biometric Systems s.r.o. | 
Palackého třída 180/44 | 61200 Brno | CZECH REPUBLIC | 
Mobile: +42(0) 721 565 113 | tbs-biometrics.cz