Skip to content

buildsystem/pkg: expand packages from USEPKG early as path into PKG_PATHS#17551

Merged
fjmolinas merged 4 commits intoRIOT-OS:masterfrom
NikLeberg:feature/pkg_paths
Jan 30, 2022
Merged

buildsystem/pkg: expand packages from USEPKG early as path into PKG_PATHS#17551
fjmolinas merged 4 commits intoRIOT-OS:masterfrom
NikLeberg:feature/pkg_paths

Conversation

@NikLeberg
Copy link
Contributor

@NikLeberg NikLeberg commented Jan 22, 2022

Contribution description

This pr it a split from pr #17211 as requested by @fjmolinas.

It changes the way packages are handled. The updated rules now don't explicitly use RIOTPKG but instead the new PKG_PATHS variable. This new variable holds the path to the packages that were found in RIOTPKG and were requested by USEPKG. This makes the Makefile rules independent from the actual location of the package. The intention is (with another pr) to allow to seach in additional paths (external to riot) for packages.

Testing procedure

I've ran make static-test with no errors (don't know what exactly is tested though).
I've also compiled the hello-world example with make BOARD=esp8266-esp-12x or the suit_update example.
Regarding a specific test case, I don't think one is needed. As I only change how something is done and don't add anything new, existing tests should cover this pr. CI will tell us :)

Issues/PRs references

pr #17211

@github-actions github-actions bot added the Area: build system Area: Build system label Jan 22, 2022
@benpicco benpicco requested review from fjmolinas and maribu January 22, 2022 21:57
@benpicco benpicco added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Jan 22, 2022
@fjmolinas
Copy link
Contributor

Hmm, on a first run I do not get the same results as the CI (failing builds succeeding locally)

@fjmolinas
Copy link
Contributor

Hmm, on a first run I do not get the same results as the CI (failing builds succeeding locally)

Ahh got it, its the Kconfig build that fails:

TEST_KCONFIG=1 RIOT_CI_BUILD=1 BOARD=arduino-due make -C tests/pkg_relic/ clean all -j
make: Nothing to be done for 'clean'.
Building application "tests_pkg_relic" for "arduino-due" with MCU "sam3".

/home/francisco/workspace/RIOT/tests/pkg_relic/main.c:16:10: fatal error: relic.h: No such file or directory
   16 | #include "relic.h"
      |          ^~~~~~~~~
compilation terminated.
make[1]: *** [/home/francisco/workspace/RIOT/Makefile.base:146: /home/francisco/workspace/RIOT/tests/pkg_relic/bin/arduino-due/application_tests_pkg_relic/main.o] Error 1
make[1]: *** Waiting for unfinished jobs....
make: *** [/home/francisco/workspace/RIOT/tests/pkg_relic/../../Makefile.include:703: application_tests_pkg_relic.module] Error 2

@fjmolinas
Copy link
Contributor

@NikLeberg Could you apply the following patch?:

diff --git a/Makefile.include b/Makefile.include
index 6c1369cd6d..74dd9b78a2 100644
--- a/Makefile.include
+++ b/Makefile.include
@@ -416,6 +416,10 @@ ifeq (1,$(TEST_KCONFIG))
   USEMODULE := $(KCONFIG_MODULES)
   KCONFIG_PACKAGES := $(call lowercase,$(patsubst CONFIG_PACKAGE_%,%,$(filter CONFIG_PACKAGE_%,$(.VARIABLES))))
   USEPKG := $(KCONFIG_PACKAGES)
+
+  # Locate used modules in $(RIOTPKG).
+  PKG_PATHS := $(sort $(foreach dir,$(RIOTPKG),\
+    $(foreach pkg,$(USEPKG),$(dir $(wildcard $(dir)/$(pkg)/Makefile)))))
 else
   # always select provided architecture features
   FEATURES_REQUIRED += $(filter arch_%,$(FEATURES_PROVIDED))

This should fix the builds, I will then run some test to check dependencies.

@fjmolinas
Copy link
Contributor

Hmmm looking better but still some failures

@NikLeberg
Copy link
Contributor Author

Hi @fjmolinas thanks for looking into this.
Yeah I see the failures too. They seem to all be with esp8266 boards. If I run locally I can reproduce and get following error:

[INFO] patch esp8266_sdk
Patch is empty.

The empty patch leaves git in an am session and further git commands won't work... Do you have a clue where that could come from?

@github-actions github-actions bot added the Area: pkg Area: External package ports label Jan 24, 2022
@fjmolinas
Copy link
Contributor

[INFO] patch esp8266_sdk
Patch is empty.

I don't think this should be an issue, and so 765f25b should not be needed. Can you be sure you are trying for a clean state?

rm -r RIOT/build

Regarding the murdock build issue, it seems to be some kind of make ordering issue, but couldn't figure it out after a short debug session, will try again as soon as posible.

@fjmolinas
Copy link
Contributor

@NikLeberg can you remove 765f25b and ad this patch, it should fix the issue (hopefully).

diff --git a/pkg/esp8266_sdk/Makefile b/pkg/esp8266_sdk/Makefile
index 1453c63006..59cde6131d 100644
--- a/pkg/esp8266_sdk/Makefile
+++ b/pkg/esp8266_sdk/Makefile
@@ -20,7 +20,9 @@ ESP_SDK_LIBS = $(addprefix $(ESP8266_SDK_BUILD_DIR)/, $(ESP_SDK_COMPONENT_LIBS))

 all: $(ESP_SDK_LIBS) $(ESP8266_SDK_BUILD_DIR)/esp8266_idf_version.h

-$(ESP8266_SDK_BUILD_DIR):
+$(PKG_PREPARED): $(ESP8266_SDK_BUILD_DIR)
+
+$(ESP8266_SDK_BUILD_DIR): $(PKG_PATCHED)
        $(Q)mkdir -p $(ESP8266_SDK_BUILD_DIR)

 # Set the SDK version from the SDK hash/tag. For example "v3.1-51-g913a06a9".

@NikLeberg
Copy link
Contributor Author

Thanks for fixing that makefile order issue @fjmolinas.
As now the build for the esp32 fails, I suspect that it also does things similar and needs a rule update with $(PKG_PREPARED) and $(PKG_PATCHED). I wanted to apply your patch to the esp32 packages.. but I don't find them?
Is Murdock running the tests from within the pr, or is it merging the pr to the latest master and then running the tests? In the second case, I probably need to rebase, do I?

@fjmolinas
Copy link
Contributor

Is Murdock running the tests from within the pr, or is it merging the pr to the latest master and then running the tests? In the second case, I probably need to rebase, do I?

It's doing the second thing! If you want to rebase feel free to do so

@fjmolinas
Copy link
Contributor

Is Murdock running the tests from within the pr, or is it merging the pr to the latest master and then running the tests? In the second case, I probably need to rebase, do I?

It's doing the second thing! If you want to rebase feel free to do so

Here is a patch that works for me locally, can you apply it? ( I didn't have
c3f4846 in my tree so you might have a conflict).

diff --git a/pkg/esp32_sdk/Makefile b/pkg/esp32_sdk/Makefile
index 0d0c813b5d..1538c7d02c 100644
--- a/pkg/esp32_sdk/Makefile
+++ b/pkg/esp32_sdk/Makefile
@@ -20,11 +20,13 @@ ESP32_SDK_LIBS = $(addprefix $(ESP32_SDK_BUILD_DIR)/, $(ESP32_SDK_COMPONENT_LIBS
 
 all: $(ESP32_SDK_LIBS) $(ESP32_SDK_VER_FILE)
 
-$(ESP32_SDK_BUILD_DIR):
+$(PKG_PREPARED): $(ESP32_SDK_BUILD_DIR) $(ESP32_SDK_VER_FILE)
+
+$(ESP32_SDK_BUILD_DIR): $(PKG_PATCHED)
        $(Q)mkdir -p $(ESP32_SDK_BUILD_DIR)
 
 # Set the SDK version from the SDK hash/tag. For example "v3.1-51-g913a06a9".
-$(ESP32_SDK_VER_FILE):
+$(ESP32_SDK_VER_FILE): $(PKG_PATCHED) | $(ESP32_SDK_BUILD_DIR)
        $(Q)echo "#define IDF_VER \"$(ESP32_SDK_VER_CMD)\"" > $@
 
 $(ESP32_SDK_BUILD_DIR)/lib%.a: \

If the ci is green after this, could you rebase keeping individual commits for those esp32 and esp86 patches, a descriptive commit would be much appreciated, something like:

pkg/esp32_sdk: add requirements to PKG_PREPARE

The share `build-dir` directory needs to be available for modules/packages that depend on the SDK before that package is eventually compiled.

This also includes header files such as `esp32_idf_version.h`.

Packages are downloaded, patches, prepared before any module is compiled. By adding the directory creation and header as a dependency of `PKG_PREPARE` we make sure they are included before compilation starts.

In c3f4846 you also patches esp32_sdk_libs, I think that also makes sense, but if possible add an individual commit for it :).

Thanks for sticking through!

@fjmolinas
Copy link
Contributor

@NikLeberg all green! Please squash!

@fjmolinas fjmolinas added the CI: run tests If set, CI server will run tests on hardware for the labeled PR label Jan 28, 2022
@NikLeberg
Copy link
Contributor Author

@fjmolinas like so? Or should I squash all of them again into one commit?

@fjmolinas
Copy link
Contributor

@fjmolinas like so? Or should I squash all of them again into one commit?

No that's perfect!

Copy link
Contributor

@fjmolinas fjmolinas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK, I added run-tests to be safe.

@fjmolinas
Copy link
Contributor

Non relevant tests failed, will re-run without the flag

@fjmolinas fjmolinas added CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR and removed CI: run tests If set, CI server will run tests on hardware for the labeled PR CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Jan 28, 2022
@fjmolinas fjmolinas enabled auto-merge January 28, 2022 20:44
@NikLeberg
Copy link
Contributor Author

NikLeberg commented Jan 28, 2022

Uh oh.. I clicked the GitHub button "fetch upstram" on the wrong branch... Sorry. :( Will undo the auto-merge and reapply the commits.

@fjmolinas fjmolinas disabled auto-merge January 30, 2022 18:53
The shared `build-libs` directory needs to be available for
modules/packages that depend on the SDK before that package
is eventually compiled.

Packages are downloaded, patched and prepared before any
module is compiled. By adding the directory creation and
header as a dependency of `PKG_PREPARE` we make sure the
rule is run before compilation starts.
The shared `build-libs` directory needs to be available for
modules/packages that depend on the SDK before that package
is eventually compiled.

This also includes header files such as `esp32_idf_version.h`.

Packages are downloaded, patched, prepared before any module
is compiled. By adding the directory creation and header as
a dependency of `PKG_PREPARE` we make sure the rules are ran
before compilation starts.
The shared `build-libs` directory needs to be available for
modules/packages that depend on the SDK before that package
is eventually compiled.

Packages are downloaded, patched, prepared before any module
is compiled. By adding the directory creation as a dependency
of `PKG_PREPARE` we make sure the rule is run before compilation
starts.
@fjmolinas
Copy link
Contributor

Rebased, and fixed authorship that was distorted in my first rebase.

@fjmolinas fjmolinas enabled auto-merge January 30, 2022 19:02
@fjmolinas fjmolinas merged commit f29f73d into RIOT-OS:master Jan 30, 2022
@fjmolinas
Copy link
Contributor

Thanks for this one @NikLeberg!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: build system Area: Build system Area: pkg Area: External package ports CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants