Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8987 from cladmi/pr/improve/external_modules
make: process include and dep for external modules
- Loading branch information
Showing
11 changed files
with
144 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
APPLICATION = external_module_dirs | ||
BOARD ?= native | ||
RIOTBASE ?= $(CURDIR)/../.. | ||
|
||
USEMODULE += random | ||
|
||
USEMODULE += external_module | ||
EXTERNAL_MODULE_DIRS += $(CURDIR)/external_module | ||
|
||
include $(RIOTBASE)/Makefile.include |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
Test of `EXTERNAL_MODULE_DIRS` handling | ||
======================================= | ||
|
||
This is a test for the `EXTERNAL_MODULE_DIRS` variable. | ||
|
||
It demonstrates: | ||
|
||
* Adding a module with source code | ||
* Setting a header include directory | ||
* Adding dependencies, which are evaluated before other modules dependencies | ||
|
||
If the application compiles, everything is ok. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
include $(RIOTBASE)/Makefile.base |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
USEMODULE += random | ||
# Set a different prng than the default prng_tinymt32 | ||
USEMODULE += prng_xorshift |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Use an immediate variable to evaluate `MAKEFILE_LIST` now | ||
USEMODULE_INCLUDES_external_module := $(abspath $(dir $(lastword $(MAKEFILE_LIST))))/include | ||
USEMODULE_INCLUDES += $(USEMODULE_INCLUDES_external_module) |
24 changes: 24 additions & 0 deletions
24
tests/external_module_dirs/external_module/external_module.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Copyright (C) 2018 Freie Universität Berlin | ||
* | ||
* 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. | ||
*/ | ||
|
||
/** | ||
* @ingroup tests | ||
* @{ | ||
* | ||
* @file | ||
* @brief Test the EXTERNAL_MODULE_DIRS feature | ||
* @note Define a shared variable | ||
* | ||
* @author Gaëtan Harter <gaetan.harter@fu-berlin.de> | ||
* | ||
* @} | ||
*/ | ||
|
||
#include "external_module.h" | ||
|
||
char *external_module_message = "Linking worked"; |
37 changes: 37 additions & 0 deletions
37
tests/external_module_dirs/external_module/include/external_module.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Copyright (C) 2018 Freie Universität Berlin | ||
* | ||
* 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. | ||
*/ | ||
|
||
/** | ||
* @defgroup | ||
* @ingroup | ||
* @brief | ||
* @{ | ||
* | ||
* @file | ||
* @brief | ||
* | ||
* @author Gaëtan Harter <gaetan.harter@fu-berlin.de> | ||
*/ | ||
#ifndef EXTERNAL_MODULE_H | ||
#define EXTERNAL_MODULE_H | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
/** | ||
* @brief A simple string message | ||
*/ | ||
extern char *external_module_message; | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
/** @} */ | ||
#endif /* EXTERNAL_MODULE_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Copyright (C) 2018 Freie Universität Berlin | ||
* | ||
* 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. | ||
*/ | ||
|
||
/** | ||
* @ingroup tests | ||
* @{ | ||
* | ||
* @file | ||
* @brief Test the EXTERNAL_MODULE_DIRS feature | ||
* | ||
* @author Gaëtan Harter <gaetan.harter@fu-berlin.de> | ||
* | ||
* @} | ||
*/ | ||
|
||
#include <stdio.h> | ||
|
||
#include "external_module.h" | ||
|
||
#ifdef MODULE_PRNG_TINYMT32 | ||
#error "Error: it included the default dependency" | ||
#endif | ||
|
||
#ifndef MODULE_PRNG_XORSHIFT | ||
#error "Dependency not included" | ||
#endif | ||
|
||
int main(void) | ||
{ | ||
puts("If it compiles, it works!"); | ||
printf("Message: %s\n", external_module_message); | ||
return 0; | ||
} |