Skip to content

Commit

Permalink
add generated headers in task config
Browse files Browse the repository at this point in the history
  • Loading branch information
srimanachanta committed Nov 22, 2023
1 parent 20f359c commit 76dd2a8
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 28 deletions.
48 changes: 20 additions & 28 deletions photon-lib/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,37 +9,14 @@ import java.nio.file.Path
ext {
nativeName = "photonlib"
includePhotonTargeting = true
// Include the generated Version file
generatedHeaders = "src/generate/native/include"
}

apply from: "${rootDir}/shared/javacpp/setupBuild.gradle"
apply from: "${rootDir}/versioningHelper.gradle"

model {
components {
all {
it.sources.each {
it.exportedHeaders {
srcDirs "src/main/native/include"
srcDirs "src/generate/native/include"
}
}
}
}

// Publish the vendordep json
publishing {
publications {
vendorjson(MavenPublication) {
artifact vendorJson

artifactId = "${nativeName}-json"
groupId = "org.photonvision"
version "1.0"
}
}
}
}

// Include the version file in the distributed sources
cppHeadersZip {
from('src/generate/native/include') {
into '/'
Expand All @@ -49,8 +26,6 @@ cppHeadersZip {
def photonlibFileInput = file("src/generate/photonlib.json.in")
ext.photonlibFileOutput = file("$buildDir/generated/vendordeps/photonlib.json")

def vendorJson = artifacts.add('archives', file("$photonlibFileOutput"))

task generateVendorJson() {
description = "Generates the vendor JSON file"
group = "PhotonVision"
Expand Down Expand Up @@ -85,3 +60,20 @@ task writeCurrentVersion {
}

build.mustRunAfter writeCurrentVersion

def vendorJson = artifacts.add('archives', file("$photonlibFileOutput"))

model {
// Publish the vendordep json
publishing {
publications {
vendorjson(MavenPublication) {
artifact vendorJson

artifactId = "${nativeName}-json"
groupId = "org.photonvision"
version "1.0"
}
}
}
}
3 changes: 3 additions & 0 deletions shared/javacpp/setupBuild.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ model {
}
exportedHeaders {
srcDirs 'src/main/native/include'
if (project.hasProperty('generatedHeaders')) {
srcDir generatedHeaders
}
include "**/*.h"
}
}
Expand Down

0 comments on commit 76dd2a8

Please sign in to comment.