Skip to content

Commit

Permalink
Switch example build to search for folder names lol
Browse files Browse the repository at this point in the history
  • Loading branch information
mcm001 committed Sep 23, 2023
1 parent 2a6fa1b commit ed6aa15
Show file tree
Hide file tree
Showing 10 changed files with 60 additions and 17 deletions.
16 changes: 16 additions & 0 deletions photonlib-cpp-examples/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
## PhotonLib C++ Examples

### Building

Build photonvision and publish it locally with:

```
photonvision$ ./gradlew photon-lib:publishtomavenlocal
```

Now, cd into here, pull in the latest vendor json, and simulate the project of choice

```
photonvision/photonlib-cpp-exaples: ./gradlew copyPhotonlib
photonvision/photonlib-cpp-exaples: ./gradlew aimandrange:simulateNativeRelease
```
4 changes: 3 additions & 1 deletion photonlib-cpp-examples/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@ spotless {
}
}

apply from: "examples.gradle"

// Task that depends on the build task for every example
task buildAllExamples { task ->
new File('examples.txt').eachLine { line ->
exampleFolderNames.each { line ->
task.dependsOn(line + ":build")
}
}
9 changes: 9 additions & 0 deletions photonlib-cpp-examples/examples.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// These should be the only 2 non-project subdirectories in the examples folder
// I could check for (it)/build.gradle to exist, but w/e
def EXCLUDED_DIRS = [".gradle", "bin"]

// List all non-hidden directories not in EXCUDED_DIRS
ext.exampleFolderNames = file("${rootDir}")
.listFiles()
.findAll { it.isDirectory() && !it.isHidden() && !(it.name in EXCLUDED_DIRS) }
.collect { it.name }
4 changes: 0 additions & 4 deletions photonlib-cpp-examples/examples.txt

This file was deleted.

4 changes: 3 additions & 1 deletion photonlib-cpp-examples/settings.gradle
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
new File('examples.txt').eachLine { line -> include line }
apply from: "examples.gradle"

exampleFolderNames.each { line -> include line }
15 changes: 15 additions & 0 deletions photonlib-java-examples/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
## PhotonLib Java Examples

### Building

Build photonvision and publish it locally with:

```
photonvision$ ./gradlew photon-lib:publishtomavenlocal
```

Now, cd into here, pull in the latest vendor json, and simulate the project of choice

```
photonvision/photonlib-java-exaples: ./gradlew copyPhotonlib
photonvision/photonlib-java-exaples: ./gradlew aimandrange:simulateJava
```

### [**`aimattarget`**](aimattarget)

A simple demonstration of using PhotonVision's 2d target yaw to align a differential drivetrain with a target.
Expand Down
4 changes: 3 additions & 1 deletion photonlib-java-examples/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ plugins {
id "com.diffplug.spotless" version "6.1.2"
}

apply from: "examples.gradle"

allprojects {
repositories {
mavenCentral()
Expand Down Expand Up @@ -29,7 +31,7 @@ spotless {

// Task that depends on the build task for every example
task buildAllExamples { task ->
new File('examples.txt').eachLine { line ->
exampleFolderNames.each { line ->
task.dependsOn(line + ":build")
}
}
9 changes: 9 additions & 0 deletions photonlib-java-examples/examples.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// These should be the only 2 non-project subdirectories in the examples folder
// I could check for (it)/build.gradle to exist, but w/e
def EXCLUDED_DIRS = [".gradle", "bin"]

// List all non-hidden directories not in EXCUDED_DIRS
ext.exampleFolderNames = file("${rootDir}")
.listFiles()
.findAll { it.isDirectory() && !it.isHidden() && !(it.name in EXCLUDED_DIRS) }
.collect { it.name }
5 changes: 0 additions & 5 deletions photonlib-java-examples/examples.txt

This file was deleted.

7 changes: 2 additions & 5 deletions photonlib-java-examples/settings.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
include 'photon-targeting'
include 'photon-core'
include 'photon-server'
include 'photon-lib'
apply from: "examples.gradle"

new File('examples.txt').eachLine { line -> include line }
exampleFolderNames.each { line -> include line }

0 comments on commit ed6aa15

Please sign in to comment.