You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
:description: See how to customize the source layout of {an application} implemented in {C} using the Gradle Nokee plugins.
7
7
8
8
NOTE: You can open this sample inside an IDE using the https://www.jetbrains.com/help/idea/gradle.html#gradle_import_project_start[IntelliJ native importer] or https://projects.eclipse.org/projects/tools.buildship[Eclipse Buildship].
9
9
10
-
This sample shows how to configure the source layout of a {C application}.
11
-
The library has no dependencies, and the build has a minimal configuration.
12
-
13
-
In this sample, we are configuring source layout of {an application} implemented in {C}; however, this applies to other native components and languages as well.
14
-
10
+
Here is a sample where we configure the source layout of {an application} implemented in {C} with no dependencies and minimal configuration.
15
11
[source,groovy]
16
12
----
17
13
plugins {
18
-
id 'dev.nokee.c-application'
14
+
id 'dev.nokee.c-application' // <1>
19
15
}
20
16
21
17
application {
22
-
cSources.setFrom('srcs') // <1>
23
-
privateHeaders.setFrom('incs') // <2>
18
+
cSources.setFrom('srcs') // <2>
19
+
privateHeaders.setFrom('incs') // <3>
24
20
}
25
21
26
22
----
27
-
<1> Configure C sources to include everything under `srcs` directory.
28
-
<2> Configure private headers to include everything under `incs` directory.
23
+
<1> Apply the C application plugin.
24
+
<2> Set C sources to include everything under `srcs` directory.
25
+
<3> Set private headers to include everything under `incs` directory.
29
26
30
-
To build the application:
27
+
Build the application:
31
28
32
29
[source,terminal]
33
30
----
@@ -36,19 +33,18 @@ $ ./gradlew assemble
36
33
BUILD SUCCESSFUL
37
34
4 actionable tasks: 4 executed
38
35
----
39
-
40
-
If we create invalid source code at the conventional location and rebuild the application, as expected, the build succeeds.
41
-
36
+
Setting the sources layout will exclude the conventional sources location as per example below.
42
37
[source,terminal]
43
38
----
44
-
$ mkdir -p src/main/cpp
45
-
$ echo "broken!" > src/main/cpp/broken.cpp
39
+
$ mkdir -p src/main/c
40
+
$ echo "broken!" > src/main/c/broken.c
46
41
$ mkdir -p src/main/headers
47
42
$ echo "broken!" > src/main/headers/greeter.h
48
43
$ ./gradlew clean assemble
49
44
50
45
BUILD SUCCESSFUL
51
46
5 actionable tasks: 5 executed
52
47
----
48
+
It can also be applied to other native components and languages : link other example here
53
49
54
50
For more information, see link:working-with-source-files.adoc[working with source files chapter].
0 commit comments