Skip to content

Commit

Permalink
format build files
Browse files Browse the repository at this point in the history
  • Loading branch information
spacey-sooty committed Mar 9, 2024
1 parent 8307048 commit 0b2703d
Show file tree
Hide file tree
Showing 4 changed files with 119 additions and 84 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,15 @@ jobs:
run: wpiformat
- name: Check output
run: git --no-pager diff --exit-code HEAD

spotless:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 17
- run: ./gradlew spotlessCheck
85 changes: 54 additions & 31 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ plugins {
id "cpp"
id "google-test-test-suite"
id "edu.wpi.first.GradleRIO" version "2024.2.1"
id 'com.diffplug.spotless' version '6.20.0'
}

def debug = project.hasProperty("debug");
Expand Down Expand Up @@ -69,25 +70,25 @@ model {
}
}

binaries.all {
if (release && debug) {
throw new InvalidUserDataException("Cannot be both release and debug project");
}
binaries.all {
if (release && debug) {
throw new InvalidUserDataException("Cannot be both release and debug project");
}

if(!release && !debug) {
cppCompiler.define("RELEASE");
}
if(!release && !debug) {
cppCompiler.define("RELEASE");
}

if(release) {
cppCompiler.define("RELEASE");
}
if(release) {
cppCompiler.define("RELEASE");
}

if (debug) {
cppCompiler.define("DEBUG");
}
if (debug) {
cppCompiler.define("DEBUG");
}

lib project: ':wombat', library: 'Wombat', linkage: 'static'
}
lib project: ':wombat', library: 'Wombat', linkage: 'static'
}

// Set deploy task to deploy this component
deployArtifact.component = it
Expand All @@ -113,25 +114,25 @@ model {
}
}

binaries.all {
if (release && debug) {
throw new InvalidUserDataException("Cannot be both release and debug project");
}
binaries.all {
if (release && debug) {
throw new InvalidUserDataException("Cannot be both release and debug project");
}

if(!release && !debug) {
cppCompiler.define("RELEASE");
}
if(!release && !debug) {
cppCompiler.define("RELEASE");
}

if(release) {
cppCompiler.define("RELEASE");
}
if(release) {
cppCompiler.define("RELEASE");
}

if (debug) {
cppCompiler.define("DEBUG");
}
if (debug) {
cppCompiler.define("DEBUG");
}

lib project: ':wombat', library: 'Wombat', linkage: 'static'
}
lib project: ':wombat', library: 'Wombat', linkage: 'static'
}

// Enable run tasks for this component
wpi.cpp.enableExternalTasks(it)
Expand All @@ -144,10 +145,32 @@ model {
}

subprojects {
project.buildDir = rootProject.buildDir
project.buildDir = rootProject.buildDir
}

wrapper {
gradleVersion = '8.6'
distributionType = Wrapper.DistributionType.BIN
}

spotless {
groovyGradle {
target fileTree('.') {
include '**/*.gradle'
exclude '**/build/**', '**/build-*/**'
}
greclipse()
indentWithSpaces(4)
trimTrailingWhitespace()
endWithNewline()
}
format 'misc', {
target fileTree('.') {
include '**/*.md', '**/.gitignore'
exclude '**/build/**', '**/build-*/**'
}
trimTrailingWhitespace()
indentWithSpaces(2)
endWithNewline()
}
}
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pluginManagement {
if (OperatingSystem.current().isWindows()) {
String publicFolder = System.getenv('PUBLIC')
if (publicFolder == null) {
publicFolder = "C:\\Users\\Public"
publicFolder = "C:\\Users\\Public"
}
def homeRoot = new File(publicFolder, "wpilib")
frcHome = new File(homeRoot, frcYear)
Expand Down
104 changes: 52 additions & 52 deletions wombat/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,69 +9,69 @@ def debug = project.hasProperty("debug");
def release = project.hasProperty("release");

model {
components {
Wombat(NativeLibrarySpec) {
targetPlatform NativePlatforms.desktop
targetPlatform NativePlatforms.roborio
components {
Wombat(NativeLibrarySpec) {
targetPlatform NativePlatforms.desktop
targetPlatform NativePlatforms.roborio

sources {
sources.cpp {
source {
srcDir 'src/main/cpp'
include '**/*.cpp', '**/*.cc'
}
sources {
sources.cpp {
source {
srcDir 'src/main/cpp'
include '**/*.cpp', '**/*.cc'
}

exportedHeaders {
srcDir 'src/main/include'
}
}
}
exportedHeaders {
srcDir 'src/main/include'
}
}
}

binaries.all {
if (release && debug) {
throw new InvalidUserDataException("Cannot be both release and debug project");
}
binaries.all {
if (release && debug) {
throw new InvalidUserDataException("Cannot be both release and debug project");
}

if(!release && !debug) {
cppCompiler.define("RELEASE");
}
if(!release && !debug) {
cppCompiler.define("RELEASE");
}

if(release) {
cppCompiler.define("RELEASE");
}
if(release) {
cppCompiler.define("RELEASE");
}

if (debug) {
cppCompiler.define("DEBUG");
}
if (debug) {
cppCompiler.define("DEBUG");
}

if (it.targetPlatform.name == "linuxathena")
cppCompiler.define "PLATFORM_ROBORIO"
else
cppCompiler.define "PLATFORM_DESKTOP"
}
if (it.targetPlatform.name == "linuxathena")
cppCompiler.define "PLATFORM_ROBORIO"
else
cppCompiler.define "PLATFORM_DESKTOP"
}

wpi.cpp.vendor.cpp(it)
wpi.cpp.deps.wpilib(it)
wpi.cpp.vendor.cpp(it)
wpi.cpp.deps.wpilib(it)
}
}
}
testSuites {
WombatTest(GoogleTestTestSuiteSpec) {
testing $.components.Wombat;
testSuites {
WombatTest(GoogleTestTestSuiteSpec) {
testing $.components.Wombat;

sources.cpp {
source {
srcDir 'src/test/cpp'
include '**/*.cpp'
}
sources.cpp {
source {
srcDir 'src/test/cpp'
include '**/*.cpp'
}

exportedHeaders {
srcDir 'src/test/include'
}
}
exportedHeaders {
srcDir 'src/test/include'
}
}

wpi.cpp.vendor.cpp(it)
wpi.cpp.deps.wpilib(it)
wpi.cpp.deps.googleTest(it)
wpi.cpp.vendor.cpp(it)
wpi.cpp.deps.wpilib(it)
wpi.cpp.deps.googleTest(it)
}
}
}
}

0 comments on commit 0b2703d

Please sign in to comment.