Forces CRLF files to LF (#1054)

This commit is contained in:
Thad House
2018-05-13 19:37:20 -07:00
committed by Peter Johnson
parent 01d8d0c795
commit eec4f53a65
3 changed files with 495 additions and 495 deletions

View File

@@ -1,111 +1,111 @@
import edu.wpi.first.nativeutils.*
import org.gradle.internal.os.OperatingSystem
import org.apache.tools.ant.filters.*;
public class NiDependencySet implements NativeDependencySet {
private Project m_project
public NiDependencySet(Project project) {
m_project = project
}
public FileCollection getIncludeRoots() {
return m_project.files("${m_project.projectDir}/include")
}
private FileCollection getFiles() {
def f = m_project.fileTree("${m_project.projectDir}/lib").filter { it.isFile() }
return f
}
public FileCollection getLinkFiles() {
return getFiles()
}
public FileCollection getRuntimeFiles() {
return m_project.files()
}
}
ext.addNiLibrariesToLinker = { binary ->
if (binary.targetPlatform.architecture.name == 'athena') {
binary.lib(new NiDependencySet(project))
}
}
def outputsFolder = file("$project.buildDir/outputs")
def niLibBaseName = '_GROUP_edu_wpi_first_ni-libraries_ID_ni-libraries_CLS'
task libZip(type: Zip) {
destinationDir = outputsFolder
baseName = niLibBaseName
classifier = "linuxathena"
from('lib') {
into '/linux/athena/shared/'
}
}
task headersZip(type: Zip) {
destinationDir = outputsFolder
baseName = niLibBaseName
classifier = "headers"
from('include') {
into '/'
}
}
task build() {}
build.dependsOn headersZip
build.dependsOn libZip
addTaskToCopyAllOutputs(headersZip)
addTaskToCopyAllOutputs(libZip)
apply from: 'publish.gradle'
task patchNiLibraries() {
doLast {
// Patch ChipObject headers to be self contained
FileTree chipTree = fileTree(dir: "$rootDir/ni-libraries/include/FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace")
chipTree.each { File file ->
String contents = file.getText('UTF-8')
contents = contents.replaceAll('#include \"tSystemInterface.h\"', '#include \"../tSystem.h\"\n#include \"../tSystemInterface.h\"')
file.write(contents, 'UTF-8')
}
// Patch NetComm headers to work on Windows
FileTree netTree = fileTree(dir: "$rootDir/ni-libraries/include/FRC_NetworkCommunication")
netTree.each { File file ->
String contents = file.getText('UTF-8')
contents = contents.replaceAll('#ifdef WIN32', '#ifdef _WIN32')
contents = contents.replaceAll('# include <vxWorks_compat.h>', '#include <windows.h>')
contents = contents.replaceAll('#include <vxWorks_compat.h>', '#include <windows.h>')
file.write(contents, 'UTF-8')
}
FileTree allTree = fileTree(dir: "$rootDir/ni-libraries/include/")
allTree.each { File file ->
String contents = file.getText('UTF-8')
contents = contents.replaceAll('\r\n', '\n')
file.write(contents, 'UTF-8')
}
// Move UsageReporting header to the HAL, because it is necessary for our
// UsageReporting in WPILibC.
copy {
from("$rootDir/ni-libraries/include/FRC_NetworkCommunication") {
include 'UsageReporting.h'
}
into "$rootDir/hal/src/main/native/include/HAL"
}
delete {
delete "$rootDir/ni-libraries/include/FRC_NetworkCommunication/UsageReporting.h"
}
}
}
import edu.wpi.first.nativeutils.*
import org.gradle.internal.os.OperatingSystem
import org.apache.tools.ant.filters.*;
public class NiDependencySet implements NativeDependencySet {
private Project m_project
public NiDependencySet(Project project) {
m_project = project
}
public FileCollection getIncludeRoots() {
return m_project.files("${m_project.projectDir}/include")
}
private FileCollection getFiles() {
def f = m_project.fileTree("${m_project.projectDir}/lib").filter { it.isFile() }
return f
}
public FileCollection getLinkFiles() {
return getFiles()
}
public FileCollection getRuntimeFiles() {
return m_project.files()
}
}
ext.addNiLibrariesToLinker = { binary ->
if (binary.targetPlatform.architecture.name == 'athena') {
binary.lib(new NiDependencySet(project))
}
}
def outputsFolder = file("$project.buildDir/outputs")
def niLibBaseName = '_GROUP_edu_wpi_first_ni-libraries_ID_ni-libraries_CLS'
task libZip(type: Zip) {
destinationDir = outputsFolder
baseName = niLibBaseName
classifier = "linuxathena"
from('lib') {
into '/linux/athena/shared/'
}
}
task headersZip(type: Zip) {
destinationDir = outputsFolder
baseName = niLibBaseName
classifier = "headers"
from('include') {
into '/'
}
}
task build() {}
build.dependsOn headersZip
build.dependsOn libZip
addTaskToCopyAllOutputs(headersZip)
addTaskToCopyAllOutputs(libZip)
apply from: 'publish.gradle'
task patchNiLibraries() {
doLast {
// Patch ChipObject headers to be self contained
FileTree chipTree = fileTree(dir: "$rootDir/ni-libraries/include/FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace")
chipTree.each { File file ->
String contents = file.getText('UTF-8')
contents = contents.replaceAll('#include \"tSystemInterface.h\"', '#include \"../tSystem.h\"\n#include \"../tSystemInterface.h\"')
file.write(contents, 'UTF-8')
}
// Patch NetComm headers to work on Windows
FileTree netTree = fileTree(dir: "$rootDir/ni-libraries/include/FRC_NetworkCommunication")
netTree.each { File file ->
String contents = file.getText('UTF-8')
contents = contents.replaceAll('#ifdef WIN32', '#ifdef _WIN32')
contents = contents.replaceAll('# include <vxWorks_compat.h>', '#include <windows.h>')
contents = contents.replaceAll('#include <vxWorks_compat.h>', '#include <windows.h>')
file.write(contents, 'UTF-8')
}
FileTree allTree = fileTree(dir: "$rootDir/ni-libraries/include/")
allTree.each { File file ->
String contents = file.getText('UTF-8')
contents = contents.replaceAll('\r\n', '\n')
file.write(contents, 'UTF-8')
}
// Move UsageReporting header to the HAL, because it is necessary for our
// UsageReporting in WPILibC.
copy {
from("$rootDir/ni-libraries/include/FRC_NetworkCommunication") {
include 'UsageReporting.h'
}
into "$rootDir/hal/src/main/native/include/HAL"
}
delete {
delete "$rootDir/ni-libraries/include/FRC_NetworkCommunication/UsageReporting.h"
}
}
}

View File

@@ -1,31 +1,31 @@
apply plugin: 'maven-publish'
apply plugin: 'edu.wpi.first.wpilib.versioning.WPILibVersioningPlugin'
if (!hasProperty('releaseType')) {
WPILibVersion {
releaseType = 'dev'
}
}
def pubVersion
if (project.hasProperty("publishVersion")) {
pubVersion = project.publishVersion
} else {
pubVersion = WPILibVersion.version
}
def baseArtifactId = 'ni-libraries'
def artifactGroupId = 'edu.wpi.first.ni-libraries'
publishing {
publications {
nilibraries(MavenPublication) {
artifact libZip
artifact headersZip
artifactId = "${baseArtifactId}"
groupId artifactGroupId
version pubVersion
}
}
}
apply plugin: 'maven-publish'
apply plugin: 'edu.wpi.first.wpilib.versioning.WPILibVersioningPlugin'
if (!hasProperty('releaseType')) {
WPILibVersion {
releaseType = 'dev'
}
}
def pubVersion
if (project.hasProperty("publishVersion")) {
pubVersion = project.publishVersion
} else {
pubVersion = WPILibVersion.version
}
def baseArtifactId = 'ni-libraries'
def artifactGroupId = 'edu.wpi.first.ni-libraries'
publishing {
publications {
nilibraries(MavenPublication) {
artifact libZip
artifact headersZip
artifactId = "${baseArtifactId}"
groupId artifactGroupId
version pubVersion
}
}
}

View File

@@ -1,353 +1,353 @@
import edu.wpi.first.nativeutils.*
import org.gradle.internal.os.OperatingSystem
def windowsCompilerArgs = ['/EHsc', '/DNOMINMAX', '/Zi', '/FS', '/Zc:inline', '/MT']
def windowsCCompilerArgs = ['/Zi', '/FS', '/Zc:inline', '/MT']
def windowsReleaseCompilerArgs = ['/O2']
def windowsLinkerArgs = ['/DEBUG:FULL']
def windowsReleaseLinkerArgs = ['/OPT:REF', '/OPT:ICF']
def linuxCompilerArgs = ['-std=c++14', '-Wformat=2', '-Wall', '-Wextra', '-Werror', '-pedantic', '-Wno-psabi', '-g',
'-Wno-unused-parameter', '-fPIC', '-rdynamic', '-pthread']
def linuxCCompilerArgs = ['-Wformat=2', '-Wall', '-Wextra', '-Werror', '-pedantic', '-Wno-psabi', '-g',
'-Wno-unused-parameter', '-fPIC', '-rdynamic', '-pthread']
def linuxLinkerArgs = ['-rdynamic', '-pthread', '-ldl']
def linuxReleaseCompilerArgs = ['-Og']
def linuxDebugCompilerArgs = ['-O0']
def linux32BitArg = '-m32'
def macCompilerArgs = ['-std=c++14', '-Wall', '-Wextra', '-Werror', '-pedantic-errors', '-fPIC', '-g',
'-Wno-unused-parameter', '-Wno-missing-field-initializers', '-Wno-unused-private-field',
'-Wno-unused-const-variable', '-pthread']
def macCCompilerArgs = ['-Wall', '-Wextra', '-Werror', '-pedantic-errors', '-fPIC', '-g',
'-Wno-unused-parameter', '-Wno-missing-field-initializers', '-Wno-unused-private-field']
def macReleaseCompilerArgs = ['-O2']
def macDebugCompilerArgs = ['-O0']
def mac32BitArg = '-m32'
def buildAll = project.hasProperty('buildAll')
def windows64PlatformDetect = {
def arch = System.getProperty("os.arch")
def isWin = OperatingSystem.current().isWindows()
if (buildAll) {
return isWin
} else {
return isWin && arch == 'amd64'
}
}
def windows32PlatformDetect = {
def arch = System.getProperty("os.arch")
def isWin = OperatingSystem.current().isWindows()
if (buildAll) {
return isWin
} else {
return isWin && arch == 'x86'
}
}
def linux32IntelPlatformDetect = {
def arch = System.getProperty("os.arch")
def isLinux = OperatingSystem.current().isLinux()
def isIntel = (arch == 'amd64' || arch == 'i386')
if (buildAll) {
return isLinux && isIntel
} else {
return isLinux && arch == 'i386'
}
}
def linux64IntelPlatformDetect = {
def arch = System.getProperty("os.arch")
def isLinux = OperatingSystem.current().isLinux()
def isIntel = (arch == 'amd64' || arch == 'i386')
if (buildAll) {
return isLinux && isIntel
} else {
return isLinux && arch == 'amd64'
}
}
def linuxArmPlatformDetect = {
def arch = System.getProperty("os.arch")
def isIntel = (arch == 'amd64' || arch == 'i386')
return OperatingSystem.current().isLinux() && !isIntel
}
def mac64PlatformDetect = {
def arch = System.getProperty("os.arch")
def isMac = OperatingSystem.current().isMacOsX()
if (buildAll) {
return isMac
} else {
return isMac && arch == 'x86_64'
}
}
def mac32PlatformDetect = {
def arch = System.getProperty("os.arch")
def isMac = OperatingSystem.current().isMacOsX()
if (buildAll) {
return isMac
} else {
return isMac && arch == 'x86'
}
}
if (!project.hasProperty('skipAthena')) {
model {
buildConfigs {
roboRio(CrossBuildConfig) {
architecture = 'athena'
operatingSystem = 'linux'
toolChainPrefix = 'arm-frc-linux-gnueabi-'
compilerArgs = linuxCompilerArgs
CCompilerArgs = linuxCCompilerArgs
linkerArgs = linuxLinkerArgs
debugCompilerArgs = linuxDebugCompilerArgs
releaseCompilerArgs = linuxReleaseCompilerArgs
releaseStripBinaries = true
compilerFamily = 'Gcc'
}
}
}
}
if (!project.hasProperty('onlyAthena')) {
model {
buildConfigs {
winX86(BuildConfig) {
architecture = 'x86'
operatingSystem = 'windows'
compilerArgs = windowsCompilerArgs
CCompilerArgs = windowsCCompilerArgs
linkerArgs = windowsLinkerArgs
releaseCompilerArgs = windowsReleaseCompilerArgs
releaseLinkerArgs = windowsReleaseLinkerArgs
compilerFamily = 'VisualCpp'
detectPlatform = windows32PlatformDetect
}
winX64(BuildConfig) {
architecture = 'x86-64'
operatingSystem = 'windows'
compilerArgs = windowsCompilerArgs
CCompilerArgs = windowsCCompilerArgs
linkerArgs = windowsLinkerArgs
releaseCompilerArgs = windowsReleaseCompilerArgs
releaseLinkerArgs = windowsReleaseLinkerArgs
compilerFamily = 'VisualCpp'
detectPlatform = windows64PlatformDetect
}
/* Disable 32 bit linux until we can figure out jenkins
linuxX86(BuildConfig) {
architecture = 'x86'
operatingSystem = 'linux'
compilerArgs = linuxCompilerArgs
compilerArgs << linux32BitArg
CCompilerArgs = linuxCCompilerArgs
CCompilerArgs << linux32BitArg
linkerArgs = linuxLinkerArgs
linkerArgs << linux32BitArg
debugCompilerArgs = linuxDebugCompilerArgs
releaseCompilerArgs = linuxReleaseCompilerArgs
releaseStripBinaries = true
compilerFamily = 'Gcc'
detectPlatform = linux32IntelPlatformDetect
exclude << 'halAthena'
}
*/
linuxX64(BuildConfig) {
architecture = 'x86-64'
operatingSystem = 'linux'
compilerArgs = linuxCompilerArgs
CCompilerArgs = linuxCCompilerArgs
linkerArgs = linuxLinkerArgs
debugCompilerArgs = linuxDebugCompilerArgs
releaseCompilerArgs = linuxReleaseCompilerArgs
releaseStripBinaries = true
compilerFamily = 'Gcc'
detectPlatform = linux64IntelPlatformDetect
}
/* 32 bit Mac OS X not supported by OpenCV.
* If support is ever added, will add this back in
macX86(BuildConfig) {
architecture = 'x86'
operatingSystem = 'osx'
compilerArgs = macCompilerArgs
compilerArgs << mac32BitArg
CCompilerArgs = macCCompilerArgs
CCompilerArgs << mac32BitArg
linkerArgs << mac32BitArg
debugCompilerArgs = macDebugCompilerArgs
releaseCompilerArgs = macReleaseCompilerArgs
releaseStripBinaries = true
compilerFamily = 'Clang'
detectPlatform = mac32PlatformDetect
}
*/
macX64(BuildConfig) {
architecture = 'x86-64'
operatingSystem = 'osx'
compilerArgs = macCompilerArgs
CCompilerArgs = macCCompilerArgs
debugCompilerArgs = macDebugCompilerArgs
releaseCompilerArgs = macReleaseCompilerArgs
releaseStripBinaries = true
compilerFamily = 'Clang'
detectPlatform = mac64PlatformDetect
}
}
}
}
if (project.hasProperty('linuxCross')) {
model {
buildConfigs {
linuxArm(CrossBuildConfig) {
architecture = 'nativearm'
operatingSystem = 'linux'
toolChainPrefix = 'PLEASE_PROVIDE_A_COMPILER_NAME'
compilerArgs = linuxCompilerArgs
CCompilerArgs = linuxCCompilerArgs
linkerArgs = linuxLinkerArgs
debugCompilerArgs = linuxDebugCompilerArgs
releaseCompilerArgs = linuxReleaseCompilerArgs
releaseStripBinaries = true
skipByDefault = true
compilerFamily = 'Gcc'
}
}
}
} else {
model {
buildConfigs {
linuxArm(BuildConfig) {
architecture = 'nativearm'
operatingSystem = 'linux'
compilerArgs = linuxCompilerArgs
CCompilerArgs = linuxCCompilerArgs
linkerArgs = linuxLinkerArgs
debugCompilerArgs = linuxDebugCompilerArgs
releaseCompilerArgs = linuxReleaseCompilerArgs
releaseStripBinaries = true
compilerFamily = 'Gcc'
detectPlatform = linuxArmPlatformDetect
}
}
}
}
ext.getClassifier = { binary ->
return NativeUtils.getClassifier(binary)
}
ext.getPlatformPath = { binary ->
return NativeUtils.getPlatformPath(binary)
}
ext.createComponentZipTasks = { components, name, base, type, project, func ->
def configMap = [:]
components.each {
if (it in NativeLibrarySpec && it.name == name) {
it.binaries.each {
def target = getClassifier(it)
if (configMap.containsKey(target)) {
configMap.get(target).add(it)
} else {
configMap.put(target, [])
configMap.get(target).add(it)
}
}
}
}
def taskList = []
def outputsFolder = file("$project.buildDir/outputs")
configMap.each { key, value ->
def task = project.tasks.create(base + "-${key}", type) {
description = 'Creates component archive for platform ' + key
destinationDir = outputsFolder
classifier = key
baseName = '_M_' + base
duplicatesStrategy = 'exclude'
from(licenseFile) {
into '/'
}
func(it, value)
}
taskList.add(task)
project.build.dependsOn task
project.artifacts {
task
}
addTaskToCopyAllOutputs(task)
}
return taskList
}
ext.createAllCombined = { list, name, base, type, project ->
def outputsFolder = file("$project.buildDir/outputs")
def task = project.tasks.create(base + '-all', type) {
description = 'Creates component archive for all classifiers'
destinationDir = outputsFolder
classifier = 'all'
baseName = base
duplicatesStrategy = 'exclude'
list.each {
it.outputs.files.each {
from project.zipTree(it)
}
dependsOn it
}
}
project.build.dependsOn task
project.artifacts {
task
}
return task
}
ext.includeStandardZipFormat = { task, value ->
value.each { binary ->
if (binary.buildable) {
if (binary instanceof SharedLibraryBinarySpec) {
task.dependsOn binary.buildTask
task.from(new File(binary.sharedLibraryFile.absolutePath + ".debug")) {
into getPlatformPath(binary) + '/shared'
}
task.from(binary.sharedLibraryFile) {
into getPlatformPath(binary) + '/shared'
}
task.from(binary.sharedLibraryLinkFile) {
into getPlatformPath(binary) + '/shared'
}
} else if (binary instanceof StaticLibraryBinarySpec) {
task.dependsOn binary.buildTask
task.from(binary.staticLibraryFile) {
into getPlatformPath(binary) + '/static'
}
}
}
}
}
ext.getCurrentArch = {
def arch = System.getProperty('os.arch');
if (arch.equals("x86") || arch.equals("i386")) {
return 'x86'
} else if (arch.equals("amd64") || arch.equals("x86_64")) {
return 'x86-64'
} else {
return arch
}
}
import edu.wpi.first.nativeutils.*
import org.gradle.internal.os.OperatingSystem
def windowsCompilerArgs = ['/EHsc', '/DNOMINMAX', '/Zi', '/FS', '/Zc:inline', '/MT']
def windowsCCompilerArgs = ['/Zi', '/FS', '/Zc:inline', '/MT']
def windowsReleaseCompilerArgs = ['/O2']
def windowsLinkerArgs = ['/DEBUG:FULL']
def windowsReleaseLinkerArgs = ['/OPT:REF', '/OPT:ICF']
def linuxCompilerArgs = ['-std=c++14', '-Wformat=2', '-Wall', '-Wextra', '-Werror', '-pedantic', '-Wno-psabi', '-g',
'-Wno-unused-parameter', '-fPIC', '-rdynamic', '-pthread']
def linuxCCompilerArgs = ['-Wformat=2', '-Wall', '-Wextra', '-Werror', '-pedantic', '-Wno-psabi', '-g',
'-Wno-unused-parameter', '-fPIC', '-rdynamic', '-pthread']
def linuxLinkerArgs = ['-rdynamic', '-pthread', '-ldl']
def linuxReleaseCompilerArgs = ['-Og']
def linuxDebugCompilerArgs = ['-O0']
def linux32BitArg = '-m32'
def macCompilerArgs = ['-std=c++14', '-Wall', '-Wextra', '-Werror', '-pedantic-errors', '-fPIC', '-g',
'-Wno-unused-parameter', '-Wno-missing-field-initializers', '-Wno-unused-private-field',
'-Wno-unused-const-variable', '-pthread']
def macCCompilerArgs = ['-Wall', '-Wextra', '-Werror', '-pedantic-errors', '-fPIC', '-g',
'-Wno-unused-parameter', '-Wno-missing-field-initializers', '-Wno-unused-private-field']
def macReleaseCompilerArgs = ['-O2']
def macDebugCompilerArgs = ['-O0']
def mac32BitArg = '-m32'
def buildAll = project.hasProperty('buildAll')
def windows64PlatformDetect = {
def arch = System.getProperty("os.arch")
def isWin = OperatingSystem.current().isWindows()
if (buildAll) {
return isWin
} else {
return isWin && arch == 'amd64'
}
}
def windows32PlatformDetect = {
def arch = System.getProperty("os.arch")
def isWin = OperatingSystem.current().isWindows()
if (buildAll) {
return isWin
} else {
return isWin && arch == 'x86'
}
}
def linux32IntelPlatformDetect = {
def arch = System.getProperty("os.arch")
def isLinux = OperatingSystem.current().isLinux()
def isIntel = (arch == 'amd64' || arch == 'i386')
if (buildAll) {
return isLinux && isIntel
} else {
return isLinux && arch == 'i386'
}
}
def linux64IntelPlatformDetect = {
def arch = System.getProperty("os.arch")
def isLinux = OperatingSystem.current().isLinux()
def isIntel = (arch == 'amd64' || arch == 'i386')
if (buildAll) {
return isLinux && isIntel
} else {
return isLinux && arch == 'amd64'
}
}
def linuxArmPlatformDetect = {
def arch = System.getProperty("os.arch")
def isIntel = (arch == 'amd64' || arch == 'i386')
return OperatingSystem.current().isLinux() && !isIntel
}
def mac64PlatformDetect = {
def arch = System.getProperty("os.arch")
def isMac = OperatingSystem.current().isMacOsX()
if (buildAll) {
return isMac
} else {
return isMac && arch == 'x86_64'
}
}
def mac32PlatformDetect = {
def arch = System.getProperty("os.arch")
def isMac = OperatingSystem.current().isMacOsX()
if (buildAll) {
return isMac
} else {
return isMac && arch == 'x86'
}
}
if (!project.hasProperty('skipAthena')) {
model {
buildConfigs {
roboRio(CrossBuildConfig) {
architecture = 'athena'
operatingSystem = 'linux'
toolChainPrefix = 'arm-frc-linux-gnueabi-'
compilerArgs = linuxCompilerArgs
CCompilerArgs = linuxCCompilerArgs
linkerArgs = linuxLinkerArgs
debugCompilerArgs = linuxDebugCompilerArgs
releaseCompilerArgs = linuxReleaseCompilerArgs
releaseStripBinaries = true
compilerFamily = 'Gcc'
}
}
}
}
if (!project.hasProperty('onlyAthena')) {
model {
buildConfigs {
winX86(BuildConfig) {
architecture = 'x86'
operatingSystem = 'windows'
compilerArgs = windowsCompilerArgs
CCompilerArgs = windowsCCompilerArgs
linkerArgs = windowsLinkerArgs
releaseCompilerArgs = windowsReleaseCompilerArgs
releaseLinkerArgs = windowsReleaseLinkerArgs
compilerFamily = 'VisualCpp'
detectPlatform = windows32PlatformDetect
}
winX64(BuildConfig) {
architecture = 'x86-64'
operatingSystem = 'windows'
compilerArgs = windowsCompilerArgs
CCompilerArgs = windowsCCompilerArgs
linkerArgs = windowsLinkerArgs
releaseCompilerArgs = windowsReleaseCompilerArgs
releaseLinkerArgs = windowsReleaseLinkerArgs
compilerFamily = 'VisualCpp'
detectPlatform = windows64PlatformDetect
}
/* Disable 32 bit linux until we can figure out jenkins
linuxX86(BuildConfig) {
architecture = 'x86'
operatingSystem = 'linux'
compilerArgs = linuxCompilerArgs
compilerArgs << linux32BitArg
CCompilerArgs = linuxCCompilerArgs
CCompilerArgs << linux32BitArg
linkerArgs = linuxLinkerArgs
linkerArgs << linux32BitArg
debugCompilerArgs = linuxDebugCompilerArgs
releaseCompilerArgs = linuxReleaseCompilerArgs
releaseStripBinaries = true
compilerFamily = 'Gcc'
detectPlatform = linux32IntelPlatformDetect
exclude << 'halAthena'
}
*/
linuxX64(BuildConfig) {
architecture = 'x86-64'
operatingSystem = 'linux'
compilerArgs = linuxCompilerArgs
CCompilerArgs = linuxCCompilerArgs
linkerArgs = linuxLinkerArgs
debugCompilerArgs = linuxDebugCompilerArgs
releaseCompilerArgs = linuxReleaseCompilerArgs
releaseStripBinaries = true
compilerFamily = 'Gcc'
detectPlatform = linux64IntelPlatformDetect
}
/* 32 bit Mac OS X not supported by OpenCV.
* If support is ever added, will add this back in
macX86(BuildConfig) {
architecture = 'x86'
operatingSystem = 'osx'
compilerArgs = macCompilerArgs
compilerArgs << mac32BitArg
CCompilerArgs = macCCompilerArgs
CCompilerArgs << mac32BitArg
linkerArgs << mac32BitArg
debugCompilerArgs = macDebugCompilerArgs
releaseCompilerArgs = macReleaseCompilerArgs
releaseStripBinaries = true
compilerFamily = 'Clang'
detectPlatform = mac32PlatformDetect
}
*/
macX64(BuildConfig) {
architecture = 'x86-64'
operatingSystem = 'osx'
compilerArgs = macCompilerArgs
CCompilerArgs = macCCompilerArgs
debugCompilerArgs = macDebugCompilerArgs
releaseCompilerArgs = macReleaseCompilerArgs
releaseStripBinaries = true
compilerFamily = 'Clang'
detectPlatform = mac64PlatformDetect
}
}
}
}
if (project.hasProperty('linuxCross')) {
model {
buildConfigs {
linuxArm(CrossBuildConfig) {
architecture = 'nativearm'
operatingSystem = 'linux'
toolChainPrefix = 'PLEASE_PROVIDE_A_COMPILER_NAME'
compilerArgs = linuxCompilerArgs
CCompilerArgs = linuxCCompilerArgs
linkerArgs = linuxLinkerArgs
debugCompilerArgs = linuxDebugCompilerArgs
releaseCompilerArgs = linuxReleaseCompilerArgs
releaseStripBinaries = true
skipByDefault = true
compilerFamily = 'Gcc'
}
}
}
} else {
model {
buildConfigs {
linuxArm(BuildConfig) {
architecture = 'nativearm'
operatingSystem = 'linux'
compilerArgs = linuxCompilerArgs
CCompilerArgs = linuxCCompilerArgs
linkerArgs = linuxLinkerArgs
debugCompilerArgs = linuxDebugCompilerArgs
releaseCompilerArgs = linuxReleaseCompilerArgs
releaseStripBinaries = true
compilerFamily = 'Gcc'
detectPlatform = linuxArmPlatformDetect
}
}
}
}
ext.getClassifier = { binary ->
return NativeUtils.getClassifier(binary)
}
ext.getPlatformPath = { binary ->
return NativeUtils.getPlatformPath(binary)
}
ext.createComponentZipTasks = { components, name, base, type, project, func ->
def configMap = [:]
components.each {
if (it in NativeLibrarySpec && it.name == name) {
it.binaries.each {
def target = getClassifier(it)
if (configMap.containsKey(target)) {
configMap.get(target).add(it)
} else {
configMap.put(target, [])
configMap.get(target).add(it)
}
}
}
}
def taskList = []
def outputsFolder = file("$project.buildDir/outputs")
configMap.each { key, value ->
def task = project.tasks.create(base + "-${key}", type) {
description = 'Creates component archive for platform ' + key
destinationDir = outputsFolder
classifier = key
baseName = '_M_' + base
duplicatesStrategy = 'exclude'
from(licenseFile) {
into '/'
}
func(it, value)
}
taskList.add(task)
project.build.dependsOn task
project.artifacts {
task
}
addTaskToCopyAllOutputs(task)
}
return taskList
}
ext.createAllCombined = { list, name, base, type, project ->
def outputsFolder = file("$project.buildDir/outputs")
def task = project.tasks.create(base + '-all', type) {
description = 'Creates component archive for all classifiers'
destinationDir = outputsFolder
classifier = 'all'
baseName = base
duplicatesStrategy = 'exclude'
list.each {
it.outputs.files.each {
from project.zipTree(it)
}
dependsOn it
}
}
project.build.dependsOn task
project.artifacts {
task
}
return task
}
ext.includeStandardZipFormat = { task, value ->
value.each { binary ->
if (binary.buildable) {
if (binary instanceof SharedLibraryBinarySpec) {
task.dependsOn binary.buildTask
task.from(new File(binary.sharedLibraryFile.absolutePath + ".debug")) {
into getPlatformPath(binary) + '/shared'
}
task.from(binary.sharedLibraryFile) {
into getPlatformPath(binary) + '/shared'
}
task.from(binary.sharedLibraryLinkFile) {
into getPlatformPath(binary) + '/shared'
}
} else if (binary instanceof StaticLibraryBinarySpec) {
task.dependsOn binary.buildTask
task.from(binary.staticLibraryFile) {
into getPlatformPath(binary) + '/static'
}
}
}
}
}
ext.getCurrentArch = {
def arch = System.getProperty('os.arch');
if (arch.equals("x86") || arch.equals("i386")) {
return 'x86'
} else if (arch.equals("amd64") || arch.equals("x86_64")) {
return 'x86-64'
} else {
return arch
}
}