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

Support multiple architectures #6

Open
wants to merge 27 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
ebdcc6c
ci: add linux/arm64 to Travis
gotson Jul 24, 2020
76bca27
build: cross compilation using dockcross
gotson Jul 27, 2020
b95b72b
refactor: changed native loader to handle more architecture
gotson Jul 27, 2020
cd90959
ci: install java on linux arm
gotson Jul 27, 2020
83d810f
build: try previous win64 lib
gotson Jul 27, 2020
a1117e6
build: try cross-compiled win64 lib
gotson Jul 27, 2020
c3f8972
ci: try to fix Mac build
gotson Jul 27, 2020
9e0ad23
build: disable windows cross-compilation
gotson Jul 27, 2020
80a9451
build: disable windows cross-compilation
gotson Jul 27, 2020
61e1d8e
build: restore working libs for windows
gotson Jul 27, 2020
46ddc0d
build: restore working libs for mac
gotson Jul 27, 2020
4daf0f5
build: restore working libs for windows
gotson Jul 27, 2020
7e0b13f
ci: try mac lib
gotson Jul 28, 2020
53bbda2
ci: try mac lib
gotson Jul 28, 2020
8a95664
ci: add more mac environments
gotson Jul 28, 2020
5ca4b28
ci: test mac lib 10.9
gotson Jul 28, 2020
c5ea7df
build: fix osx minimum version
gotson Jul 28, 2020
d8c6f60
build: disable maven toolchain
gotson Jul 28, 2020
3ee970c
build: add maven wrapper
gotson Jul 28, 2020
69907e8
build: build with release config
gotson Jul 28, 2020
68a3abb
ci: try win64 lib
gotson Jul 28, 2020
867d522
build: try win64 static lib
gotson Jul 28, 2020
ba67852
ci: run windows job first
gotson Jul 28, 2020
ab74ee1
build: try win64 static lib
gotson Jul 28, 2020
b6b1924
build: use dockcross static for windows
gotson Jul 28, 2020
56d738a
build: cross-compile for mac with 10.5 target
gotson Jul 28, 2020
b628b56
expose method to load native library and get result
gotson Oct 24, 2020
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
117 changes: 117 additions & 0 deletions .mvn/wrapper/MavenWrapperDownloader.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
/*
* Copyright 2007-present the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import java.net.*;
import java.io.*;
import java.nio.channels.*;
import java.util.Properties;

public class MavenWrapperDownloader {

private static final String WRAPPER_VERSION = "0.5.6";
/**
* Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
*/
private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/"
+ WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar";

/**
* Path to the maven-wrapper.properties file, which might contain a downloadUrl property to
* use instead of the default one.
*/
private static final String MAVEN_WRAPPER_PROPERTIES_PATH =
".mvn/wrapper/maven-wrapper.properties";

/**
* Path where the maven-wrapper.jar will be saved to.
*/
private static final String MAVEN_WRAPPER_JAR_PATH =
".mvn/wrapper/maven-wrapper.jar";

/**
* Name of the property which should be used to override the default download url for the wrapper.
*/
private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";

public static void main(String args[]) {
System.out.println("- Downloader started");
File baseDirectory = new File(args[0]);
System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath());

// If the maven-wrapper.properties exists, read it and check if it contains a custom
// wrapperUrl parameter.
File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
String url = DEFAULT_DOWNLOAD_URL;
if(mavenWrapperPropertyFile.exists()) {
FileInputStream mavenWrapperPropertyFileInputStream = null;
try {
mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
Properties mavenWrapperProperties = new Properties();
mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream);
url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url);
} catch (IOException e) {
System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
} finally {
try {
if(mavenWrapperPropertyFileInputStream != null) {
mavenWrapperPropertyFileInputStream.close();
}
} catch (IOException e) {
// Ignore ...
}
}
}
System.out.println("- Downloading from: " + url);

File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
if(!outputFile.getParentFile().exists()) {
if(!outputFile.getParentFile().mkdirs()) {
System.out.println(
"- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'");
}
}
System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
try {
downloadFileFromURL(url, outputFile);
System.out.println("Done");
System.exit(0);
} catch (Throwable e) {
System.out.println("- Error downloading");
e.printStackTrace();
System.exit(1);
}
}

private static void downloadFileFromURL(String urlString, File destination) throws Exception {
if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) {
String username = System.getenv("MVNW_USERNAME");
char[] password = System.getenv("MVNW_PASSWORD").toCharArray();
Authenticator.setDefault(new Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(username, password);
}
});
}
URL website = new URL(urlString);
ReadableByteChannel rbc;
rbc = Channels.newChannel(website.openStream());
FileOutputStream fos = new FileOutputStream(destination);
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
fos.close();
rbc.close();
}

}
Binary file added .mvn/wrapper/maven-wrapper.jar
Binary file not shown.
2 changes: 2 additions & 0 deletions .mvn/wrapper/maven-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar
68 changes: 55 additions & 13 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
os: linux
dist: xenial

jobs:
include:
- os: linux
language: java
dist: xenial
jdk: openjdk8
script: mvn clean test

- os: osx
language: java
osx_image: xcode9
script: mvn clean test

- os: windows
language: shell
before_install:
Expand All @@ -26,7 +18,57 @@ jobs:
echo $MAVEN_HOME/bin
ls $MAVEN_HOME/bin
mvn -version


script: mvn clean test

- os: linux
arch: amd64
jdk: openjdk8
script: mvn clean test

- os: linux
arch: amd64
jdk: openjdk11
script: mvn clean test

- os: linux
arch: arm64
before_install:
- sudo apt-get update
- sudo apt-get -y install openjdk-8-jdk maven
script: mvn clean test

# Cannot install JDK 11 on Linux/arm64
# - os: linux
# arch: arm64
# before_install:
# - sudo apt-get update
# - sudo apt-get install -y openjdk-11-jdk maven
# script: mvn clean test

- os: osx
language: java
osx_image: xcode7.3
script: mvn clean test

- os: osx
language: java
osx_image: xcode8.3
script: mvn clean test

- os: osx
language: java
osx_image: xcode9.3
script: mvn clean test

- os: osx
language: java
osx_image: xcode10.2
script: mvn clean test

- os: osx
language: java
osx_image: xcode11.4
script: mvn clean test

install: true
install: true
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
cmake_minimum_required( VERSION 2.8.12 )
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.5" CACHE STRING "Minimum OS X deployment version")
project ( webp-imageio )

set(CMAKE_POSITION_INDEPENDENT_CODE ON)
Expand Down
12 changes: 12 additions & 0 deletions compile-all.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash
./dockcross/dockcross-linux-armv5 bash -c './compile.sh Linux arm'
./dockcross/dockcross-linux-armv7 bash -c './compile.sh Linux armv7'
./dockcross/dockcross-linux-arm64 bash -c './compile.sh Linux aarch64'
./dockcross/dockcross-linux-x86 bash -c './compile.sh Linux x86'
./dockcross/dockcross-linux-x64 bash -c './compile.sh Linux x86_64'
./dockcross/dockcross-linux-ppc64le bash -c './compile.sh Linux ppc64'

./dockcross/dockcross-windows-static-x86 bash -c './compile.sh Windows x86'
./dockcross/dockcross-windows-static-x64 bash -c './compile.sh Windows x86_64'

docker run --rm -v $(pwd):/workdir -e CROSS_TRIPLE=x86_64-apple-darwin multiarch/crossbuild ./compile.sh Mac x86_64 /workdir/multiarch-darwin.cmake
24 changes: 24 additions & 0 deletions compile.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env bash
echo Building for OS: $1, Arch: $2, Toolchain: $3
mkdir -p build/$1/$2
cd build/$1/$2

if [ -z "$3" ]; then
cmake ../../..
else
cmake ../../.. -DCMAKE_TOOLCHAIN_FILE=$3
fi

cmake --build . --config Release

cd ../../..

LIB="libwebp-imageio.so"
if [ "$1" == "Windows" ]; then
LIB="webp-imageio.dll"
elif [ "$1" == "Mac" ]; then
LIB="libwebp-imageio.dylib"
fi

mkdir -p src/main/resources/native/$1/$2/
cp build/$1/$2/src/main/c/${LIB} src/main/resources/native/$1/$2/
Loading