Last active
August 31, 2019 18:34
-
-
Save Stephen-Seo/2466754204909435a160 to your computer and use it in GitHub Desktop.
a build.gradle scipt that builds multilib c++ and for windows (mingw-w64) (currently for Gradle 2.2 nightly, check earlier revisions for earlier versions of Gradle compatibility)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apply plugin: 'cpp' | |
model { | |
buildTypes { | |
debug | |
release | |
} | |
platforms { | |
linux_x86 { | |
operatingSystem "linux" | |
architecture "x86" | |
} | |
linux_x86_64 { | |
operatingSystem "linux" | |
architecture "x86_64" | |
} | |
windows_x86 { | |
operatingSystem "windows" | |
architecture "x86" | |
} | |
windows_x86_64 { | |
operatingSystem "windows" | |
architecture "x86_64" | |
} | |
} | |
toolChains { | |
gcc(Gcc) { | |
path "/usr/bin" | |
eachPlatform() { | |
cppCompiler.executable "g++" | |
} | |
target("linux_x86") { | |
cppCompiler.withArguments { List<String> args -> | |
args << "-m32" << "-march=i686" << "-mtune=generic" | |
} | |
linker.withArguments { List<String> args -> | |
args << "-m32" | |
} | |
} | |
target("linux_x86_64") | |
} | |
mingw_x86(Gcc) { | |
path "/usr/bin" | |
eachPlatform() { | |
cCompiler.executable "i686-w64-mingw32-gcc" | |
cppCompiler.executable "i686-w64-mingw32-g++" | |
linker.executable "i686-w64-mingw32-g++" | |
assembler.executable "i686-w64-mingw32-as" | |
staticLibArchiver.executable "i686-w64-mingw32-ar" | |
} | |
target("windows_x86") | |
} | |
mingw_x86_64(Gcc) { | |
path "/usr/bin" | |
eachPlatform() { | |
cCompiler.executable "x86_64-w64-mingw32-gcc" | |
cppCompiler.executable "x86_64-w64-mingw32-g++" | |
linker.executable "x86_64-w64-mingw32-g++" | |
assembler.executable "x86_64-w64-mingw32-as" | |
staticLibArchiver.executable "x86_64-w64-mingw32-ar" | |
} | |
target("windows_x86_64") | |
} | |
} | |
} | |
libraries { | |
ResourcePacker { | |
targetPlatforms "linux_x86", "linux_x86_64", "windows_x86", "windows_x86_64" | |
binaries.all { | |
cppCompiler.args "-std=c++11", "-Wall", "-Wextra" | |
if(buildType == buildTypes.debug) { | |
cppCompiler.args "-O0", "-g" | |
} | |
if(buildType == buildTypes.release) { | |
cppCompiler.define "NDEBUG" | |
cppCompiler.args "-O3" | |
} | |
} | |
binaries.withType(SharedLibraryBinarySpec) { binary -> | |
cppCompiler.define "BUILD_SHARED_LIBS" | |
if(targetPlatform == platforms.windows_x86 || targetPlatform == platforms.windows_x86_64) { | |
cppCompiler.define "ResourcePacker_EXPORTS" | |
def importLibPath = binary.sharedLibraryLinkFile.absolutePath.replace(".dll", ".a") | |
importLibPath = importLibPath.substring(0, importLibPath.lastIndexOf("ResourcePacker")) + "lib" + importLibPath.substring(importLibPath.lastIndexOf("ResourcePacker")) | |
//println "Generating import lib: ${importLibPath}" | |
linker.args "-Wl,--out-implib,${importLibPath}" | |
} | |
} | |
} | |
} | |
executables { | |
main { | |
targetPlatforms "linux_x86", "linux_x86_64", "windows_x86", "windows_x86_64" | |
binaries.all { | |
cppCompiler.args "-std=c++11", "-Wall", "-Wextra" | |
if(buildType == buildTypes.debug) { | |
cppCompiler.args "-O0", "-g" | |
} | |
if(buildType == buildTypes.release) { | |
cppCompiler.define "NDEBUG" | |
cppCompiler.args "-O3" | |
} | |
} | |
} | |
} | |
sources { | |
main { | |
cpp { | |
lib libraries.ResourcePacker | |
exportedHeaders { | |
srcDir "src/ResourcePacker/headers" | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment