Skip to content

Commit

Permalink
Merge pull request #21121 from fabian18/pr/subdirs_unique
Browse files Browse the repository at this point in the history
buildsystem: keep subfolders of sources unique
  • Loading branch information
mguetschow authored Jan 6, 2025
2 parents ff92ec9 + b5101d9 commit e62e388
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Makefile.base
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ ifneq (,$(SUBDIRS_IN_DIRS))
$(patsubst $(CURDIR)/%,./%, $(SUBDIRS_IN_DIRS)). \
Please select a single approach for each subfolder to prevent linking errors.)
endif
SUBDIRS := $(filter-out $(BINDIR)/$(MODULE)/, $(dir $(OBJ)))
SUBDIRS := $(sort $(filter-out $(BINDIR)/$(MODULE)/, $(dir $(OBJ))))

include $(RIOTMAKE)/blob.inc.mk
include $(RIOTMAKE)/tools/fixdep.inc.mk
Expand Down
2 changes: 1 addition & 1 deletion examples/subfolders/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ USEMODULE += my_module # name as defined in module/Makefile

# Add source files in subfolders manually
SRC += main.c
SRC += folder/a.c folder/subfolder/b.c
SRC += folder/a.c folder/subfolder/b.c folder/subfolder/c.c

# Alternative method to add files in subfolders using wildcards
# SRC += $(wildcard *.c folder/*.c folder/**/*.c)
Expand Down
14 changes: 14 additions & 0 deletions examples/subfolders/folder/subfolder/c.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* Copyright (C) 2025 ML!PA Consulting GmbH
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/

#include <stdio.h>

void folder_c(void)
{
puts("./folder/subfolder/c.c");
}
2 changes: 2 additions & 0 deletions examples/subfolders/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ void module_a(void);
void module_b(void);
void folder_a(void);
void folder_b(void);
void folder_c(void);

int main(void)
{
Expand All @@ -34,6 +35,7 @@ int main(void)
// call functions from subfolder
folder_a();
folder_b();
folder_c();

return 0;
}

0 comments on commit e62e388

Please sign in to comment.