mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-26 01:51:41 +00:00
Change debug strip to be part of link task (as doLast).
This avoids spurious re-linking.
This commit is contained in:
@@ -152,13 +152,7 @@ def cameraserverZipTask = { project ->
|
||||
|
||||
project.build.dependsOn project.cameraserverZip
|
||||
|
||||
def releaseTasks = [project.cameraserverZip]
|
||||
|
||||
if (includeJava) {
|
||||
releaseTasks.add(project.jar)
|
||||
}
|
||||
|
||||
project.releaseSetup(releaseTasks)
|
||||
project.debugStripSetup()
|
||||
|
||||
project.tasks.whenTaskAdded { task ->
|
||||
def name = task.name.toLowerCase()
|
||||
|
||||
@@ -77,32 +77,16 @@ ext.setupDebugDefines = { cppCompiler, linker ->
|
||||
// Used only on Windows.
|
||||
ext.setupDef = { linker, deffile -> }
|
||||
|
||||
ext.releaseSetup = { releaseTasks ->
|
||||
model {
|
||||
binaries {
|
||||
withType(SharedLibraryBinarySpec) { binary ->
|
||||
if (!project.hasProperty('debug')) {
|
||||
def library = binary.sharedLibraryFile.absolutePath
|
||||
def debugLibrary = binary.sharedLibraryFile.absolutePath + ".debug"
|
||||
if (project.tasks.findByName("firstObjcopy${binary.name}") == null) {
|
||||
def firstObjcopy = project.tasks.create("firstObjcopy${binary.name}", Exec) { task ->
|
||||
task.commandLine "${compilerPrefix}objcopy", '--only-keep-debug', library, debugLibrary
|
||||
}
|
||||
def strip = project.tasks.create("strip${binary.name}", Exec) { task ->
|
||||
task.commandLine "${compilerPrefix}strip", '-g', library
|
||||
}
|
||||
def secondObjcopy = project.tasks.create("secondObjcopy${binary.name}", Exec) { task ->
|
||||
task.commandLine "${compilerPrefix}objcopy", "--add-gnu-debuglink=$debugLibrary", library
|
||||
}
|
||||
secondObjcopy.dependsOn strip
|
||||
strip.dependsOn firstObjcopy
|
||||
binary.tasks.whenObjectAdded { task ->
|
||||
if (task.name.contains('link')) {
|
||||
firstObjcopy.dependsOn task
|
||||
}
|
||||
}
|
||||
}
|
||||
releaseTasks.each { it.dependsOn project.tasks.getByName("secondObjcopy${binary.name}") }
|
||||
ext.debugStripSetup = {
|
||||
if (!project.hasProperty('debug')) {
|
||||
project.tasks.whenObjectAdded { task ->
|
||||
if (task.name.contains('link') && task.name.contains('SharedLibrary')) {
|
||||
def library = task.outputFile.absolutePath
|
||||
def debugLibrary = task.outputFile.absolutePath + ".debug"
|
||||
task.doLast {
|
||||
exec { commandLine "${compilerPrefix}objcopy", '--only-keep-debug', library, debugLibrary }
|
||||
exec { commandLine "${compilerPrefix}strip", '-g', library }
|
||||
exec { commandLine "${compilerPrefix}objcopy", "--add-gnu-debuglink=$debugLibrary", library }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,32 +44,16 @@ ext.setupDebugDefines = { cppCompiler, linker ->
|
||||
// Used only on Windows.
|
||||
ext.setupDef = { linker, deffile -> }
|
||||
|
||||
ext.releaseSetup = { releaseTasks ->
|
||||
model {
|
||||
binaries {
|
||||
withType(SharedLibraryBinarySpec) { binary ->
|
||||
if (!project.hasProperty('debug')) {
|
||||
def library = binary.sharedLibraryFile.absolutePath
|
||||
def debugLibrary = binary.sharedLibraryFile.absolutePath + ".debug"
|
||||
if (project.tasks.findByName("firstObjcopy${binary.name}") == null) {
|
||||
def firstObjcopy = project.tasks.create("firstObjcopy${binary.name}", Exec) { task ->
|
||||
task.commandLine 'objcopy', '--only-keep-debug', library, debugLibrary
|
||||
}
|
||||
def strip = project.tasks.create("strip${binary.name}", Exec) { task ->
|
||||
task.commandLine 'strip', '-g', library
|
||||
}
|
||||
def secondObjcopy = project.tasks.create("secondObjcopy${binary.name}", Exec) { task ->
|
||||
task.commandLine 'objcopy', "--add-gnu-debuglink=$debugLibrary", library
|
||||
}
|
||||
secondObjcopy.dependsOn strip
|
||||
strip.dependsOn firstObjcopy
|
||||
binary.tasks.whenObjectAdded { task ->
|
||||
if (task.name.contains('link')) {
|
||||
firstObjcopy.dependsOn task
|
||||
}
|
||||
}
|
||||
}
|
||||
releaseTasks.each { it.dependsOn project.tasks.getByName("secondObjcopy${binary.name}") }
|
||||
ext.debugStripSetup = {
|
||||
if (!project.hasProperty('debug')) {
|
||||
project.tasks.whenObjectAdded { task ->
|
||||
if (task.name.contains('link') && task.name.contains('SharedLibrary')) {
|
||||
def library = task.outputFile.absolutePath
|
||||
def debugLibrary = task.outputFile.absolutePath + ".debug"
|
||||
task.doLast {
|
||||
exec { commandLine "objcopy", '--only-keep-debug', library, debugLibrary }
|
||||
exec { commandLine "strip", '-g', library }
|
||||
exec { commandLine "objcopy", "--add-gnu-debuglink=$debugLibrary", library }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,27 +33,14 @@ ext.setupDebugDefines = { cppCompiler, linker ->
|
||||
// Used only on Windows.
|
||||
ext.setupDef = { linker, deffile -> }
|
||||
|
||||
ext.releaseSetup = { releaseTasks ->
|
||||
model {
|
||||
binaries {
|
||||
withType(SharedLibraryBinarySpec) { binary ->
|
||||
if (!project.hasProperty('debug')) {
|
||||
def library = binary.sharedLibraryFile.absolutePath
|
||||
if (project.tasks.findByName("strip${binary.name}") == null) {
|
||||
def dsymutil = project.tasks.create("dsymutil${binary.name}", Exec) { task ->
|
||||
task.commandLine 'dsymutil', library
|
||||
}
|
||||
def strip = project.tasks.create("strip${binary.name}", Exec) { task ->
|
||||
task.commandLine 'strip', '-S', library
|
||||
}
|
||||
strip.dependsOn dsymutil
|
||||
binary.tasks.whenObjectAdded { task ->
|
||||
if (task.name.contains('link')) {
|
||||
dsymutil.dependsOn task
|
||||
}
|
||||
}
|
||||
}
|
||||
releaseTasks.each { it.dependsOn project.tasks.getByName("strip${binary.name}") }
|
||||
ext.debugStripSetup = {
|
||||
if (!project.hasProperty('debug')) {
|
||||
project.tasks.whenObjectAdded { task ->
|
||||
if (task.name.contains('link') && task.name.contains('SharedLibrary')) {
|
||||
def library = task.outputFile.absolutePath
|
||||
task.doLast {
|
||||
exec { commandLine "dsymutil", library }
|
||||
exec { commandLine "strip", '-S', library }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,4 +49,4 @@ ext.setupDef = { linker, deffile ->
|
||||
|
||||
// This is a noop on Windows. On gcc platforms, we strip the release binary and create a separate
|
||||
// debug library, but Windows already separates debug symbols into a .pdb file.
|
||||
ext.releaseSetup = { releaseTasks -> }
|
||||
ext.debugStripSetup = { }
|
||||
|
||||
Reference in New Issue
Block a user