Build Flag for prerequisites


Richard Peters <mail@...>
 

Hi Community,

I use these flags to link jerryscript against zephyr in my project makefile:

ALL_LIBS += jerry-core
export ALL_LIBS
LDFLAGS_zephyr += "-L $(JERRYOUT)/lib"
export LDFLAGS_zephyr

1. This works, but is this the way it should be done?
2. is there a build variable for zephyr to make targets automatically
built, before zephyr, which i can use in my Makefile?
I think about something like:
DEPS+=jerryscript


Paul Sokolovsky
 

Hello Richard,

On Tue, 14 Feb 2017 18:36:31 +0100
Richard Peters <mail@richardpeters.de> wrote:

Hi Community,

I use these flags to link jerryscript against zephyr in my project
makefile:
This mail crosses its way with one you sent me privately, about doing
the same thing with MicroPython, so let me try to answer both here,
with a perspective.


ALL_LIBS += jerry-core
export ALL_LIBS
LDFLAGS_zephyr += "-L $(JERRYOUT)/lib"
export LDFLAGS_zephyr

1. This works, but is this the way it should be done?
2. is there a build variable for zephyr to make targets automatically
built, before zephyr, which i can use in my Makefile?
I think about something like:
DEPS+=jerryscript
So, the first paradigmatic question is what's the center of the world
here. For you above, it's Zephyr, all centered around it, and it wants
to make other things built. Unsurprisingly, that's also point of view of
Anas Nashif, a lead Zephyr developer, so you can look how he recommends
to do it (or recommended some time ago):
https://github.com/nashif/zephyr_modules


However, the point of view that Zephyr is the center of the universe is
unhelpful for projects like JerryScript or MicroPython. For them,
Zephyr is just yet another, of many, platforms to be ported to (from
baremetal vendor SDKs and BSPs thru RTOSes to big OSes). There's one
thing common in build systems for all these platforms, that being that
they all are absolutely different. It's highly impractical for portable
projects to try to integrate "into" foreign build system, or integrate
foreign platform build "into" them (deeply, I mean). What they call for
is loosely coupled integration, and there's a bit of evolution of how
that was achieved re: Zephyr:

1. It started with JerryScript port. It simply tried to duplicate
effort of mapping BOARD value to CC and CFLAGS, i.e. did it on ts own,
in parallel to what Zephyr did. That worked for subset of targets, and
as Zephyr evolved, started to breakdown even for what worked before.

2. When I started MicroPython port, I was set to investigate ways to do
it better, the idea was that to integrate 2 build systems to get a
complete binary, following is needed:

a) Make Zephyr build its stuff.
b) As a cross-product of that, there should be available: i) all the
compilation flags (Makefile vars); ii) Zephyr config options (a header
file).
c) Then we build our project using the information above.
d) Then we call Zephyr build system again to do the final link.

I did that, but it took some quite dirty hacks to persuade Zephyr
build system to do its job in the stages above, and give out needed
information.

3. At this point, other good folks joined the effort, culminating in
the documented way of 3rd party vs Zephyr build system
integration:
https://www.zephyrproject.org/doc/1.6.0/application/apps_structure.html#support-for-building-third-party-library-code
It became also clear that the process above can be optimize a bit to:

a) Call Zephyr to give out Makefile and header settings.
b) Build application using the info above.
c) Call Zephyr to do its compilation and the final link.

4. JerryScript was updated to the process in p.3, MicroPython was
updated, but not fully, it still has artifacts from the previous
approach (it call Zephyr to link with non-existing library, that causes
Zephyr to build its stuff, but fail, when MicroPython code is built and
Zephyr make is called again, this time to success).

5. As a new twist of the story,
https://gerrit.zephyrproject.org/r/#/c/9387/ removed the docs section
linked above (for 1.7 docs), I'm raising the alarm:
https://jira.zephyrproject.org/browse/ZEP-1733



--
Best Regards,
Paul

Linaro.org | Open source software for ARM SoCs
Follow Linaro: http://www.facebook.com/pages/Linaro
http://twitter.com/#!/linaroorg - http://www.linaro.org/linaro-blog


Richard Peters <mail@...>
 

Hi Paul,

thanks for the very useful hints und links!

3. At this point, other good folks joined the effort, culminating in
the documented way of 3rd party vs Zephyr build system
integration:
https://www.zephyrproject.org/doc/1.6.0/application
/apps_structure.html#support-for-building-third-party-library-code

5. As a new twist of the story,
https://gerrit.zephyrproject.org/r/#/c/9387/ removed the docs section
linked above (for 1.7 docs), I'm raising the alarm:
https://jira.zephyrproject.org/browse/ZEP-1733
I didn't know about these docs, thanks!
This is something i really looked for.
We should extend it with the link to
https://github.com/nashif/zephyr_modules
as an example and with some further examples.

Regards,
Richard