How to (re)compile components

chevdor
Posts: 3
Joined: Wed Jul 12, 2017 10:42 am

How to (re)compile components

Postby chevdor » Fri Jul 14, 2017 9:08 am

Hello,

I am trying to do things right: user components and tests :)
I am running however into a few issue and I have questions.

First of all, as there is for 'apps', is there a template repo that could be cloned for components?

I realized a few things that may help other, please comment if I am mistaken:
- you should write your components inside $IDF_PATH/components, other path won´t work
- ensure you have

Code: Select all

COMPONENT_ADD_LDFLAGS = -Wl,--whole-archive -l$(COMPONENT_NAME) -Wl,--no-whole-archive
in your

Code: Select all

comp/test/component.mk
- you compile from

Code: Select all

$IDF_PATH/tools/unit-test-app
with

Code: Select all

make TESTS_ALL=1 
or

Code: Select all

make TEST_COMPONENTS='myComp' 
- then you can flash, select your test and run it

Here are the issues I ran into. For the following, let´s assume my components is called myComp and located in

Code: Select all

$IDF_PATH/components/myComp
. The make commands are ran from

Code: Select all

$IDF_PATH/tools/unit-test-app

Code: Select all

make TESTS_ALL=1
=> works (telling me I can now flash, ...)

Code: Select all

make TEST_COMPONENTS='myComp'
=> works, tell me I can flash

Code: Select all

make TEST_COMPONENTS='I surely don't exist'
=> works, tell me I can flash :?

Code: Select all

make clean && make TEST_COMPONENTS='myComp' && make flash
=> works

After that I tried introducing a typo in my components´ code.

Code: Select all

make TEST_COMPONENTS='myComp'
=> all happy :?

Code: Select all

make clean && make TEST_COMPONENTS='myComp' 
=> the error is still not caught

Code: Select all

make TESTS_ALL=1
=> the error is still not caught :?

A typo in the tests is caught properly however.

Disclaimer: I admit my C knowledge being rusty (no pun intended)

mh-dev
Posts: 25
Joined: Mon Nov 30, 2015 5:14 am

Re: How to (re)compile components

Postby mh-dev » Fri Jul 14, 2017 1:48 pm

That what you're most likely looking for is the environment variable EXTRA_COMPONENT_DIRS

I've never tested it with multiple external component directories, but at least it works for me reliable for external folder.

A folder referenced here behaves similar to the components directory in the environment variable IDF_PATH. The only difference is that EXTRA_COMPONENT_DIRS must contain the path to the components folder directly.

Extra info test execution is not optimal, because the unity is not part of the SDK components. To execute tests in your reusable components directory add unity to the components and create the main similar to
https://github.com/espressif/esp-idf/bl ... app_main.c

I've reported this months ago with some other problems in the build system with external component folder. Everything except the unity folder was changed afterwards.

chevdor
Posts: 3
Joined: Wed Jul 12, 2017 10:42 am

Re: How to (re)compile components

Postby chevdor » Fri Jul 14, 2017 3:49 pm

Great, thanks for your answer.

This topic is rather critical because I realized that if you have a bad component in one of the components folders, it will screw up your whole toolchain.

Would you mind being more specific regarding:
add unity to the components
I hope you don´t suggest adding all the unity files in each new component.
Or do you mind that unity should be brought as component to the EXTRA_COMPONENT_DIRS as well?

Once I sort that out, I am putting on Github a component template with the info I gathered, including what you just mentioned:
https://github.com/chevdor/esp32-component-template


Thanks again for your time answering.

mh-dev
Posts: 25
Joined: Mon Nov 30, 2015 5:14 am

Re: How to (re)compile components

Postby mh-dev » Sat Jul 15, 2017 1:21 pm

I have a project that contains all my own components structured in the following way.

Code: Select all

Project dir
    components
        component1
        component2
    unity
        copy of https://github.com/espressif/esp-idf/tree/master/tools/unit-test-app/components/unity
    main
        copy of https://github.com/espressif/esp-idf/tree/master/tools/unit-test-app/main
There are other alternatives too, but that's the one that I am using right now.

The Github repository that you mentioned has no proper License which makes it unusable for everyone else and a few unnecessary things. I try to find some time this weekend to wrap up the whole topic plus options up and but it in a repository.

chevdor
Posts: 3
Joined: Wed Jul 12, 2017 10:42 am

Re: How to (re)compile components

Postby chevdor » Sat Jul 15, 2017 7:33 pm

That would be awesome and thanks a lot for sharing.
When all works on my end and the license is the last issue, I am more than happy to fix that on my end.
Let me know if I can help as well.

mh-dev
Posts: 25
Joined: Mon Nov 30, 2015 5:14 am

Re: How to (re)compile components

Postby mh-dev » Sun Jul 16, 2017 2:35 pm


Who is online

Users browsing this forum: Baidu [Spider] and 69 guests