-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Daniel Lacasse
committed
Oct 3, 2019
1 parent
9c9e96b
commit 99c462e
Showing
8 changed files
with
2,274 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,69 @@ | ||
import org.asciidoctor.gradle.AsciidoctorTask | ||
import org.gradle.samples.Sample | ||
import org.gradle.samples.plugins.generators.CppLibraryTemplate | ||
import org.gradle.samples.plugins.generators.SourceCopyTask | ||
import org.gradle.samples.plugins.generators.SwiftLibraryTemplate | ||
import org.gradle.util.GUtil | ||
|
||
// This root project is simply a container of sample builds | ||
plugins { | ||
id("org.gradle.samples.wrapper") | ||
id("org.gradle.samples") | ||
} | ||
|
||
tasks.withType<AsciidoctorTask>().matching { it.name.contains("Sample") }.configureEach { | ||
options(mapOf("doctype" to "book")) | ||
|
||
inputs.file("src/docs/css/manual.css") | ||
.withPropertyName("manual") | ||
.withPathSensitivity(PathSensitivity.RELATIVE) | ||
|
||
attributes(mapOf("stylesdir" to file("src/docs/css/").absolutePath, | ||
"stylesheet" to "manual.css", | ||
"nofooter" to true, | ||
"sectanchors" to true, | ||
"sectlinks" to true, | ||
"linkattrs" to true)) | ||
} | ||
|
||
val cppUtilsLib = CppLibraryTemplate.of("cpp-lib-with-api-dep", "utilities") | ||
val cppListLib = CppLibraryTemplate.of("cpp-lib", "list") | ||
val cppMessageLib = CppLibraryTemplate.of("cpp-message-api", "message") | ||
|
||
val swiftUtilsLib = SwiftLibraryTemplate.of("swift-lib-with-api-dep", "Utilities") | ||
val swiftListLib = SwiftLibraryTemplate.of("swift-lib", "List") | ||
|
||
val samples = project.extensions.getByName("samples") as NamedDomainObjectContainer<Sample> | ||
|
||
fun Sample.copySource(configuration: SourceCopyTask.() -> kotlin.Unit) { | ||
val sample = this | ||
val copySourceTask = tasks.register("generate${GUtil.toCamelCase(sample.name)}Sample", SourceCopyTask::class.java) { | ||
val outputDir = project.layout.buildDirectory.dir("sample-generators/${sample.name}") | ||
sampleDir.set(outputDir) | ||
templatesDir.set(file("samples-dev/src/templates")) | ||
|
||
// Patch over the stubbed Gradle wrappers | ||
doLast { | ||
outputDir.get().file("gradlew").asFile.delete() | ||
outputDir.get().file("gradlew.bat").asFile.delete() | ||
} | ||
} | ||
copySourceTask.configure(configuration) | ||
|
||
val sourceContent = project.files(copySourceTask.flatMap { it.sampleDir }) { | ||
builtBy(copySourceTask) | ||
} | ||
sample.archiveContent.from(sourceContent) | ||
} | ||
|
||
samples.create("cpp-application") { | ||
sampleDir.set(file("cpp-application")) | ||
copySource { | ||
appProject(".").buildRoot() | ||
appProject(".").fromTemplate("cpp-app") | ||
appProject(".").fromTemplate(cppMessageLib) | ||
appProject(".").fromTemplate("cpp-message-static") | ||
appProject(".").fromTemplate(cppUtilsLib) | ||
appProject(".").fromTemplate(cppListLib) | ||
} | ||
} |
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,22 @@ | ||
= Simple application (application) | ||
|
||
ifndef::env-github[] | ||
- link:{zip-base-file-name}-groovy-dsl.zip[Download Groovy DSL ZIP] | ||
- link:{zip-base-file-name}-kotlin-dsl.zip[Download Kotlin DSL ZIP] | ||
endif::[] | ||
|
||
This sample shows how a simple C++ application can be built with Gradle. The application has no dependencies and the build has minimal configuration. | ||
|
||
Although there is currently no out-of-the-box support for building applications and libraries from C, there is also a sample build that shows how the C++ support can be configured to build a C application. | ||
|
||
To build and run the application: | ||
|
||
``` | ||
> cd cpp-application | ||
> ./gradlew assemble | ||
|
||
BUILD SUCCESSFUL in 1s | ||
|
||
> ./build/install/main/debug/app | ||
Hello, World! | ||
``` |
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,5 @@ | ||
plugins { | ||
id 'cpp-application' | ||
id 'xcode' | ||
id 'visual-studio' | ||
} |
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 @@ | ||
rootProject.name = 'app' |
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,5 @@ | ||
plugins { | ||
`cpp-application` | ||
xcode | ||
`visual-studio` | ||
} |
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 @@ | ||
rootProject.name = "app" |
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
Oops, something went wrong.