Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 45 additions & 6 deletions ddprof-lib/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ def createDebugLinkTask(config, linkTask, extractDebugTask) {
dependsOn extractDebugTask
description = 'Add debug link to the original library'

inputs.files linkTask, extractDebugTask
outputs.file { linkTask.get().linkedFile.get().asFile }

doFirst {
def sourceFile = linkTask.get().linkedFile.get().asFile
def debugFile = getDebugFilePath(config)
Expand Down Expand Up @@ -265,7 +268,34 @@ tasks.register('copyExternalLibs', Copy) {
def cloneAPTask = tasks.register('cloneAsyncProfiler') {
description = 'Clones async-profiler repo if directory is missing or updates it if commit hash differs'
inputs.file("${rootDir}/gradle/ap-lock.properties")
doFirst {
outputs.dir("${projectDir}/build/async-profiler")
outputs.upToDateWhen {
def targetDir = file("${projectDir}/build/async-profiler")
if (!targetDir.exists()) {
return false
}
def currentCommit = ""
try {
new ByteArrayOutputStream().withStream { os ->
exec {
workingDir targetDir.absolutePath
commandLine 'git', 'rev-parse', 'HEAD'
standardOutput = os
}
currentCommit = os.toString().trim()
}
return currentCommit == commit_lock
} catch (Exception e) {
return false
}
}
doLast {
// Fix for CI environments where git detects dubious ownership
exec {
commandLine 'git', 'config', '--global', '--add', 'safe.directory', projectDir.parentFile.absolutePath
ignoreExitValue = true // Don't fail if this command fails
}

def targetDir = file("${projectDir}/build/async-profiler")
if (!targetDir.exists()) {
println "Cloning missing async-profiler git subdirectory..."
Expand All @@ -277,6 +307,13 @@ def cloneAPTask = tasks.register('cloneAsyncProfiler') {
commandLine 'git', 'checkout', commit_lock
}
} else {
// Also fix git ownership for existing directory
exec {
workingDir targetDir.absolutePath
commandLine 'git', 'config', '--global', '--add', 'safe.directory', targetDir.absolutePath
ignoreExitValue = true
}

def currentCommit = ""
new ByteArrayOutputStream().withStream { os ->
exec {
Expand Down Expand Up @@ -336,6 +373,9 @@ def patchStackFrame = tasks.register("patchStackFrame") {
configure {
dependsOn copyUpstreamFiles
}
inputs.files copyUpstreamFiles
outputs.file("${projectDir}/src/main/cpp-external/stackFrame_x64.cpp")

doLast {
def file = file("${projectDir}/src/main/cpp-external/stackFrame_x64.cpp")
if (!file.exists()) throw new GradleException("File not found: ${file}")
Expand Down Expand Up @@ -386,8 +426,11 @@ def patchStackFrame = tasks.register("patchStackFrame") {
def patchStackWalker = tasks.register("patchStackWalker") {
description = 'Patch stackWalker.cpp after copying'
configure {
dependsOn copyUpstreamFiles
dependsOn copyUpstreamFiles, patchStackFrame
}
inputs.files copyUpstreamFiles
outputs.file("${projectDir}/src/main/cpp-external/stackWalker.cpp")

doLast {
def file = file("${projectDir}/src/main/cpp-external/stackWalker.cpp")
if (!file.exists()) throw new GradleException("File not found: ${file}")
Expand Down Expand Up @@ -644,10 +687,6 @@ gradle.projectsEvaluated {
copyTask.dependsOn linkTask
}
}
def gtestTask = project(':ddprof-lib:gtest').tasks.findByName("gtest${it.capitalize()}")
if (gtestTask != null) {
linkTask.dependsOn gtestTask
}
}
def javadocTask = tasks.findByName("javadoc")
def copyReleaseLibs = tasks.findByName("copyReleaseLibs")
Expand Down
3 changes: 2 additions & 1 deletion ddprof-lib/gtest/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,8 @@ tasks.whenTaskAdded { task ->
}

inputs.files binary
outputs.upToDateWhen {true}
// Test tasks should run every time the test command is run
outputs.upToDateWhen { false }
}

def compileTask = tasks.findByName("compileGtest${config.name.capitalize()}_${testName}")
Expand Down
6 changes: 6 additions & 0 deletions ddprof-test/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -120,5 +120,11 @@ gradle.projectsEvaluated {
if (testTask && assembleTask) {
assembleTask.dependsOn testTask
}

// Hook C++ gtest tasks to run as part of the corresponding Java test tasks
def gtestTask = project(':ddprof-lib:gtest').tasks.findByName("gtest${it.capitalize()}")
if (testTask && gtestTask) {
testTask.dependsOn gtestTask
}
}
}
Loading