Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How would I pass a variable from a bitbake recipe to a makefile?

I'm trying to pass a variable from my bitbake (.bb) recipe to a Makefile that I have it calling.

In my recipe I have:

export FOO="bar"

When it runs the do_compile() method I have it calling a Makefile I generated. In the Makefile I tested the variable was set correctly via:

ifeq ($(FOO), "bar")
    echo $(FOO) >> ./test.txt
else
    echo "Didn't work" >> ./test.txt
endif

When I bake the recipe I just see "Didn't work" in the log. I thought this was very strange because if I had FOO="bar" in my Makefile and just ran make, then I would see "bar" printed in the test file. So why didn't it "pass" correctly?

I ran one more test to verify, in my Makefile I only put this line:

echo $(FOO) >> ./always_print.txt

And then after baking the recipe I see bar printed in my "always_print.txt" file yet I see "Didn't work" printed in test.txt...

Does anyone have a clue what I'm doing wrong here?

like image 698
Mike Avatar asked Dec 26 '22 07:12

Mike


1 Answers

Before defining your do_compile method, you have to define the variable EXTRA_OEMAKE which this content:

EXTRA_OEMAKE = "FOO=bar"

After that, in your do_compile method you must call 'oe_runmake'. That call invokes the command 'make', and all contents defined in EXTRA_OEMAKE variable are passed as argument to the 'make' command. Hope this helps!

like image 52
criptobadia Avatar answered Jan 13 '23 16:01

criptobadia