Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build system: support for application subfolders #20024

Merged
merged 3 commits into from
Nov 12, 2024

Conversation

mguetschow
Copy link
Contributor

Contribution description

Currently, it is not possible to:

  1. organize code in subfolders without using RIOT modules (both in an application and in other modules)
  2. define source files manually for an application in it's Makefile

Using RIOT modules for subfolders has two drawbacks which I found annoying enough to look into this:

This PR addresses both issues by:

  • passing SRC, SRCXX, ASMSRC and ASSMSRC down to the recursive call to make for the application module, following the approach used for BLOB
  • automatically creating the folder structure necessary for compilation of source files in subfolders, if they are manually added to SRC and friends (the automatic recognition of source files is still restricted to the application/module folder)

Additionally, it adds a Makefile warning to ensure users are not using the same subfolder both as a RIOT module and manually in SRC (inspired by a chat with @miri64 about this topic).

Testing procedure

The second commit adds an example that show-cases both the traditional RIOT module approach and the newly supported SRC variable approach in examples/subfolders.

@mguetschow mguetschow requested a review from jia200x as a code owner October 26, 2023 16:11
@github-actions github-actions bot added Area: doc Area: Documentation Area: build system Area: Build system Area: examples Area: Example Applications labels Oct 26, 2023
@bergzand bergzand requested a review from aabadie November 2, 2023 10:59
@maribu
Copy link
Member

maribu commented Nov 17, 2023

I'm personally not fully convinced that this solves a real problem. As you pointed out, the build system does support external modules. Those do require a one-liner Makefile, but they don't need to list all the source by hand. This is less clutter when subfolders contain more than one C file. (But if a subfolder only contains one C file, creating the folder doesn't really help organizing the code, does it?)

More generally: The buildsystem is a pain in the ass to maintain as it is and few maintainers like to actually maintain it, most maintainers/developers much rather maintain/write C code than Makefiles. I'm personally reluctant on adding features that makes niche use cases a tiny bit more convenient. And again: I personally don't think that this indeed is an improvement over using external modules, anyway.

@Teufelchen1
Copy link
Contributor

@mguetschow so far two maintainer have voted against this and there has been little interest. Do you want convert it into a draft and discuss / find a common ground?

@mguetschow mguetschow marked this pull request as draft March 13, 2024 08:55
@plmorange
Copy link
Contributor

@maribu only for applications, this feature can be beneficial. It allows for easy organization of folders and subfolders without having to create a module each time. It's also better for people discovering RIOT, as it seems easier to create one file and add SRC in it than to create a Makefile for each folder in an application.

@mguetschow
Copy link
Contributor Author

I've come across the need for subfolder SRC for external packages as well, whose folder structure is not under RIOT's control.

Copy link
Member

@maribu maribu left a comment

Choose a reason for hiding this comment

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

Let's have this.

Requests for this feature have been popping up in the Matrix chat and in the forum a few times. I think it is fair to say that this proves me wrong that just using modules for code organization is sufficient.

The code changes look sane to me and I trust your testing.

@mguetschow
Copy link
Contributor Author

We actually had a side-discussion with @plmorange over at mguetschow#1. They proposed a test for the BLOB in subfolder case and I was wondering if the application showcasing the subfolder functionality should actually rather go into tests/build_system instead of examples. WDYT?

@maribu
Copy link
Member

maribu commented Nov 1, 2024

Hmm, given how often this question popped up recently, I'd personally favor the example to increase visibility. But I think both are fine.

@github-actions github-actions bot added the Area: tests Area: tests and testing framework label Nov 4, 2024
@github-actions github-actions bot removed the Area: tests Area: tests and testing framework label Nov 4, 2024
@mguetschow
Copy link
Contributor Author

@plmorange I've now reworded the documentation to mainly link to the example. Also I found that there was already a test for testing blob files in subdirectories with tests/build_system/blob (this PR does not add support for it, it just followed the example of BLOB to pass down source files to recursive make invocations).

@maribu After checking the CI generated documentation, this should be ready for merge.

@mguetschow mguetschow added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Nov 4, 2024
@riot-ci
Copy link

riot-ci commented Nov 4, 2024

Murdock results

✔️ PASSED

518f75f docs: link to subfolders example in documentation

Success Failures Total Runtime
10233 0 10233 16m:40s

Artifacts

@mguetschow mguetschow marked this pull request as ready for review November 4, 2024 11:45
@mguetschow mguetschow requested a review from maribu November 4, 2024 11:45
@maribu maribu added this pull request to the merge queue Nov 12, 2024
Merged via the queue into RIOT-OS:master with commit 15086a2 Nov 12, 2024
26 checks passed
@mguetschow
Copy link
Contributor Author

Thank you all!

@mguetschow mguetschow deleted the makefile-subfolders branch November 13, 2024 09:04
@MrKevinWeiss MrKevinWeiss added this to the Release 2025.01 milestone Jan 20, 2025
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: doc Area: Documentation Area: examples Area: Example Applications 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.

6 participants