-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add integration tests for processing defines
Note for now we only analyze each file for itself. Defines specified in header A which is then included in header B do not yet influence the defines processing in header B.
- Loading branch information
Showing
6 changed files
with
86 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
Defines can influence which include statements are relevant. | ||
|
||
These tests concentrate on parsing single files based on defines: | ||
|
||
- specified in the parsed file itself | ||
- coming from the C/C++ toolchain | ||
- defined by the Bazel target attributes `defines`, `local_defines` or `cops` | ||
|
||
Defines can also be imported into a file via an included header which specifies a define. | ||
This use case is not yet supported. | ||
We might add it at a later stage. |
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,17 @@ | ||
#ifdef SOME_DEFINE | ||
#include "test/aspect/defines/lib/a.h" | ||
#else | ||
#include "test/aspect/defines/lib/b.h" | ||
#endif | ||
|
||
#ifdef LOCAL_DEFINE | ||
#include "test/aspect/defines/lib/a.h" | ||
#else | ||
#include "test/aspect/defines/lib/b.h" | ||
#endif | ||
|
||
#if SOME_COPT > 40 | ||
#include "test/aspect/defines/lib/a.h" | ||
#else | ||
#include "test/aspect/defines/lib/b.h" | ||
#endif |
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,7 @@ | ||
cc_library( | ||
name = "transitive_define", | ||
copts = ["-DLOCAL_COPT"], # should not influence other targets | ||
defines = ["TRANSITIVE_DEFINE"], | ||
local_defines = ["LOCAL_DEFINE"], # should not influence other targets | ||
visibility = ["//test/aspect/defines:__pkg__"], | ||
) |
18 changes: 18 additions & 0 deletions
18
test/aspect/defines/transitive_defines_from_bazel_target.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,18 @@ | ||
// Define introduced through target on which we depend. The target uses the attribute 'defines' which is propagated to | ||
// all users of the target. | ||
#ifdef TRANSITIVE_DEFINE | ||
#include "test/aspect/defines/lib/a.h" | ||
#else | ||
#include "test/aspect/defines/lib/b.h" | ||
#endif | ||
|
||
// The following defines shall never be active as they are set though Bazel target attributes 'copts' and | ||
// 'local_defines' which should not leak to users of the target | ||
|
||
#ifdef LOCAL_DEFINE | ||
#include "test/aspect/defines/lib/b.h" | ||
#endif | ||
|
||
#ifdef LOCAL_COPT | ||
#include "test/aspect/defines/lib/b.h" | ||
#endif |
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