Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
= {C Application} Custom Source Layout Configuration
:summary: Set custom source layout for a {C application}.
:type: sample-chapter
:tags: sample, {application}, sources, native, {C}, gradle
:category: {C}
:description: See how to customize the source layout of {an application} implemented in {C} using the Gradle Nokee plugins.

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].

Here is a sample where we configure the source layout of {an application} implemented in {C} with no dependencies and minimal configuration.
[source,groovy]
----
plugins {
id 'dev.nokee.c-application' // <1>
}

application {
cSources.setFrom('srcs') // <2>
privateHeaders.setFrom('incs') // <3>
}

----
<1> Apply the C application plugin.
<2> Set C sources to include everything under `srcs` directory.
<3> Set private headers to include everything under `incs` directory.

Build the application:
//build & run ?
[source,terminal]
----
$ ./gradlew assemble

BUILD SUCCESSFUL
4 actionable tasks: 4 executed
----
Setting the source layout will exclude the conventional source location as per example below.
//TODO change "conventional source location" ?
[source,terminal]
----
$ mkdir -p src/main/c
$ echo "broken!" > src/main/c/broken.c
$ mkdir -p src/main/headers
$ echo "broken!" > src/main/headers/greeter.h
$ ./gradlew clean assemble

BUILD SUCCESSFUL
5 actionable tasks: 5 executed
----
It can also be applied to other native components and languages : link other example here

For more information, see link:working-with-source-files.adoc[working with source files chapter].