-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Finished porting the Platform to use the XTC plugin. Rewrite some of …
…the documentation
- Loading branch information
Showing
8 changed files
with
123 additions
and
129 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,54 +1,93 @@ | ||
/* | ||
/** | ||
* Main build file for the "platform" project. | ||
*/ | ||
|
||
/** | ||
* Plugins required: | ||
* | ||
* Enable the XTC plugin, so that we can parse this build file. In the interest to avoid | ||
* hardcoded artifact descriptors, and copy-and-paste for versions, we refer to the | ||
* plugin aliases declared in "gradle/libs.versions.toml" | ||
*/ | ||
plugins { | ||
alias(libs.plugins.xtc) | ||
alias(libs.plugins.tasktree) // for debugging purposes, for example: | ||
} | ||
|
||
/** | ||
* Dependencies to other projects, configurations and artifacts. | ||
* | ||
* These are the dependencies to other projects, and to the XDK proper (versioned). We follow | ||
* the Gradle Version Catalog standard for this project, and normally, when changing the version | ||
* of any requested artifact or plugin, there should only be the need to change | ||
* "gradle/libs.versions.toml" | ||
*/ | ||
dependencies { | ||
xdkZip(libs.xdk) | ||
xtcModule(project(":kernel")) | ||
xtcModule(project(":kernel")) // main module to run. | ||
xtcModule(project(":common")) // runtime path | ||
xtcModule(project(":platformDB")) // runtime path | ||
xtcModule(project(":host")) // runtime path | ||
xtcModule(project(":platformDB")) // runtime path | ||
xtcModule(project(":platformUI")) // runtime path | ||
} | ||
|
||
//x/ec -L lib/ kernel.xtc [password]") | ||
internal val mainModuleName = "kernel" | ||
|
||
/* | ||
* xtcRun is a configuration for anything launching from the main source set. | ||
* xtcRunTest | ||
/** | ||
* This is the run configuration, which configures all xtcRun taks for the main source set. (runXtc, runAllXtc) | ||
* The DSL for modules to run is a list of "module { }" elements or a list of moduleName("...") statements. | ||
* To look at the DSL for all parts of the XTC build, you can use your IDE and browse the implementing | ||
* classes. For example, there should be a hint in IntelliJ with the type for the xtcRun element and | ||
* the modules element (DefaultXtcRuntimeExtension and XtcRuntimeExtension.XtcRunModule, respectively). | ||
* It is a good way to understand how the build DSL works, so you can add your own powerful XTC build | ||
* syntax constructs and nice syntactic sugar/shorthand for things you feel should be simpler to write. | ||
*/ | ||
xtcRun { | ||
verbose = true | ||
module { | ||
moduleName = "kernel" | ||
// TOOD: Check that grabbing properties through -P or -D or System.getenv works and maps to XTC properties. | ||
// TODO: Implement arg() and args() syntactic sugar | ||
args = listOf(readPassword()) | ||
moduleName = mainModuleName | ||
args(readPassword().get()) // TODO: Implement a version of args that takes a provider (Object...) so we can evaluate the password just as we are about to use it. | ||
// methodName = "run" // This is default, and we don't need to specify it. | ||
} | ||
} | ||
|
||
val runXtc by tasks.existing { | ||
// Add a dependency on the build to ensure that any subcomponents that have "build" tasks, but may not have them | ||
// due to being proper Gradle lifecycle projects, are built. I am 99% sure we can just remove this. | ||
dependsOn(tasks.build) | ||
} | ||
|
||
val run by tasks.registering { | ||
group = "application" | ||
description = "Build (if necessary) and run the platform (equivalent to 'xec [-L <module>]+ kernel.xtc <password>)" | ||
dependsOn("runXtc") | ||
dependsOn(tasks.runXtc) | ||
doFirst { | ||
logger.lifecycle("Starting the XTC platform (kernel).") | ||
} | ||
} | ||
|
||
internal fun readPassword(): String { | ||
val password = findProperty("org.xtclang.platform.password")?.toString() ?: "" | ||
/** | ||
* Read the password. Typically, the password is either placed as a Gradle property | ||
* with the key "org.xtclang.kernel.password" in an external gradle.properties or init | ||
* file outside of the project. The most common choice is $GRADLE_USER_HOME/.gradle.properties, | ||
* which generatally contains secrets. | ||
* | ||
* You can also send values as project properties for the root project by using the | ||
* "-P" switch on the Gradle command line, like so: | ||
* "./gradlew run -Porg.xtclang.kernel.password=Uhlers0th" | ||
* | ||
* Here, we have also added a final way of passing the password property through a Java | ||
* System property, which is equivalent to the above, but would use the "-D" switch instead | ||
* of the "-P" switch, and would make the property value available to any project under | ||
* the same "gradlew" run, just like for a Java program. For example: | ||
* "./gradlew run -Dorg.xtclang.kernel.password=Uhlers0th" | ||
*/ | ||
internal fun readPassword(): Provider<String> = provider { | ||
val key = "org.xtclang.${project.name}.password" | ||
val password = findProperty(key)?.toString() ?: System.getProperty(key) ?: "" | ||
if (password.isEmpty()) { | ||
throw GradleException("Error. No password was given.") | ||
throw GradleException("Error. No password was found for key: '$key'.") | ||
} | ||
logger.lifecycle("Resolved password: [REDACTED]") | ||
return password | ||
} | ||
logger.lifecycle("Successfully resolved password: '$key' -> [REDACTED]") | ||
password | ||
} |
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
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
Oops, something went wrong.