Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for LZMA-enabled artifacts #428

Merged
merged 5 commits into from
Jun 2, 2015
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
122 changes: 81 additions & 41 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ ext {
java_home = java_home

libDir = "${buildDir}/lib"
lzmaDir = "${libDir}/lzma"

buildOptions = ['', '-lzma']
}

repositories {
Expand Down Expand Up @@ -110,32 +113,40 @@ model {
}

tasks {
platforms.each { platform ->
if(platform.operatingSystem.name == "windows") {
def artifactName = platform.architecture.name == "i386" ? 'win32' : 'win64'
buildOptions.each { buildOption ->
platforms.each { platform ->
if(platform.operatingSystem.name == "windows") {
def artifactName = platform.architecture.name == "i386" ? 'win32' : 'win64'

task "extract${platform.name}"(type: Copy) {
from {
tarTree(configurations."${platform.name}".find { it.name =~ artifactName })
task "extract${platform.name}${buildOption}"(type: Copy) {
from {
tarTree(configurations."${platform.name}".find { it.name =~ artifactName })
}
into "${libDir}/tools"
}
into "${libDir}/tools"
}
}

task "build${platform.name}"(type: Exec) {
executable "make"
args "platform=${platform.operatingSystem.name}",
"arch=${platform.architecture.name}"
if(platform.operatingSystem.name == "windows") {
dependsOn "extract${platform.name}"
args "win32=${libDir}/tools/win32",
"win64=${libDir}/tools/win64"
task "build${platform.name}${buildOption}"(type: Exec) {
executable "make"
args "platform=${platform.operatingSystem.name}",
"arch=${platform.architecture.name}"

if(buildOption == "-lzma") {
dependsOn 'extractLzma'
args "lzma=${lzmaDir}"
}

if(platform.operatingSystem.name == "windows") {
dependsOn "extract${platform.name}${buildOption}"
args "win32=${libDir}/tools/win32",
"win64=${libDir}/tools/win64"
}
environment JAVA_HOME: java_home
}
environment JAVA_HOME: java_home
}

assemble {
dependsOn "build${platform.name}"
assemble {
dependsOn "build${platform.name}${buildOption}"
}
}
}
}
Expand Down Expand Up @@ -175,6 +186,19 @@ jar {
baseName "classpath-avian"
}

task downloadLzma(type: Exec) {
commandLine "curl"
args "--create-dirs", "-o", "${lzmaDir}/lzma920.tar.bz2", "-f", "http://oss.readytalk.com/avian-web/lzma920.tar.bz2"
}

task extractLzma(type: Copy) {
dependsOn downloadLzma
from {
tarTree(resources.bzip2("${lzmaDir}/lzma920.tar.bz2"))
}
into lzmaDir
}

task install {
dependsOn assemble, publish
}
Expand Down Expand Up @@ -205,37 +229,53 @@ publishing {

def publishBinSuffix = currentPlatform == "windows" ? "exe" : "bin"
def binSuffix = currentPlatform == "windows" ? ".exe" : ""
artifact("${buildDir}/${currentPlatform}-${currentArch}/binaryToObject/binaryToObject") {
artifact("${buildDir}/${currentPlatform}-${currentArch}/binaryToObject/binaryToObject${binSuffix}") {
name "binaryToObject"
type publishBinSuffix
extension binSuffix
extension publishBinSuffix
}
}

platforms.each { platform ->
def binSuffix=""
def publishBinSuffix="bin"
buildOptions.each { buildOption ->
platforms.each { platform ->
def binSuffix=""
def publishBinSuffix="bin"

create(platform.name, IvyPublication) {
def nativeBuildDir = "${buildDir}/${platform.operatingSystem.name}-${platform.architecture.name}"
create("${platform.name}${buildOption}", IvyPublication) {
def nativeBuildDir = "${buildDir}/${platform.operatingSystem.name}-${platform.architecture.name}${buildOption}"

if(platform.operatingSystem.name == "windows") {
publishBinSuffix = "exe"
binSuffix = ".${publishBinSuffix}"
}
if(platform.operatingSystem.name == "windows") {
publishBinSuffix = "exe"
binSuffix = ".${publishBinSuffix}"
}

module "runtime-avian-${platform.name}"
module "runtime-avian${buildOption}-${platform.name}"

artifact("${nativeBuildDir}/avian${binSuffix}") {
name "avian"
type publishBinSuffix
extension publishBinSuffix
}
artifact("${nativeBuildDir}/avian${binSuffix}") {
name "avian"
type publishBinSuffix
extension publishBinSuffix
}

artifact("${nativeBuildDir}/libavian.a") {
name "libavian"
type "a"
extension "a"
artifact("${nativeBuildDir}/libavian.a") {
name "libavian"
type "a"
extension "a"
}

if (buildOption == "-lzma") {
artifact("${nativeBuildDir}/libavian-lzma.a") {
name "libavian-lzma"
type "a"
extension "a"
}

artifact("${nativeBuildDir}/lzma/lzma${binSuffix}") {
name "lzma"
type publishBinSuffix
extension publishBinSuffix
}
}
}
}
}
Expand Down
21 changes: 19 additions & 2 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -1409,6 +1409,8 @@ ifneq ($(lzma),)
$(call generator-c-objects,$(lzma-encoder-lzma-sources),$(lzma)/C,$(build))

lzma-loader = $(build)/lzma/load.o

lzma-library = $(build)/libavian-lzma.a
endif

generator-cpp-objects = \
Expand Down Expand Up @@ -1586,11 +1588,11 @@ test-args = $(test-flags) $(input)

.PHONY: build
ifneq ($(supports_avian_executable),false)
build: $(static-library) $(executable) $(dynamic-library) $(lzma-loader) \
build: $(static-library) $(executable) $(dynamic-library) $(lzma-library) \
$(lzma-encoder) $(executable-dynamic) $(classpath-dep) $(test-dep) \
$(test-extra-dep) $(embed) $(build)/classpath.jar
else
build: $(static-library) $(dynamic-library) $(lzma-loader) \
build: $(static-library) $(dynamic-library) $(lzma-library) \
$(lzma-encoder) $(classpath-dep) $(test-dep) \
$(test-extra-dep) $(embed) $(build)/classpath.jar
endif
Expand Down Expand Up @@ -1920,6 +1922,21 @@ $(lzma-encoder-objects): $(build)/lzma/%.o: $(src)/lzma/%.cpp
$(lzma-encoder): $(lzma-encoder-objects) $(lzma-encoder-lzma-objects)
$(build-cc) $(^) -g -o $(@)

$(lzma-library): $(lzma-loader) $(lzma-decode-objects)
@echo "creating $(@)"
@rm -rf $(build)/libavian-lzma
@mkdir -p $(build)/libavian-lzma
rm -rf $(@)
for x in $(^); \
do cp $${x} $(build)/libavian-lzma/$$(echo $${x} | sed s:/:_:g); \
done
ifdef ms_cl_compiler
$(ar) $(arflags) $(build)/libavian-lzma/*.o -out:$(@)
else
$(ar) cru $(@) $(build)/libavian-lzma/*.o
$(ranlib) $(@)
endif

$(lzma-loader): $(src)/lzma/load.cpp
$(compile-object)

Expand Down