Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
sdedwards committed May 23, 2015
2 parents 9ff8920 + cdbb8ef commit bb0eb27
Show file tree
Hide file tree
Showing 88 changed files with 4,566 additions and 4,905 deletions.
2 changes: 1 addition & 1 deletion com.github.sdedwards.m2e-nar.tests/it/it-parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ under the License.
<plugin>
<groupId>com.github.maven-nar</groupId>
<artifactId>nar-maven-plugin</artifactId>
<version>3.0.0-rc1</version>
<version>3.0.0</version>
</plugin>
</plugins>
</pluginManagement>
Expand Down
5 changes: 5 additions & 0 deletions com.github.sdedwards.m2e-nar.tests/it/it0003-jni/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ under the License.
<linkCPP>false</linkCPP>
</library>
</libraries>
<javah>
<includes>
<include></include>
</includes>
</javah>
</configuration>
</plugin>
</plugins>
Expand Down
12 changes: 12 additions & 0 deletions com.github.sdedwards.m2e-nar.tests/it/it0004-java-dep-jni/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,18 @@ under the License.
<groupId>com.github.maven-nar</groupId>
<artifactId>nar-maven-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<c>
<debug>true</debug>
</c>
<libraries>
<library>
<type>jni</type>
<narSystemPackage>it0004.test</narSystemPackage>
<linkCPP>false</linkCPP>
</library>
</libraries>
</configuration>
</plugin>
</plugins>
</build>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#include "it0004_test_Hello.h"

JNIEXPORT jbyte JNICALL Java_it0004_test_Hello_say
(JNIEnv *env, jclass clazz, jobject object)
{
return (jbyte)13;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package it0004.test;

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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 it0003.HelloWorldJNI;

public class Hello {
static
{
NarSystem.loadLibrary();
}

public native static byte say(HelloWorldJNI app);
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,9 @@ public class HelloWorldJavaDepJNITest

Assert.assertEquals( "Hello NAR World!", app.sayHello() );
}

@Test public final void testNativeMethod()
{
Assert.assertEquals(13, Hello.say(null));
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
Expand Down
3 changes: 2 additions & 1 deletion com.github.sdedwards.m2e-nar/lifecycle-mapping-metadata.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<pluginExecutionFilter>
<groupId>com.github.maven-nar</groupId>
<artifactId>nar-maven-plugin</artifactId>
<versionRange>[3.0.0-rc1,)</versionRange>
<versionRange>[3.0.0-rc1,),[3.0.0-rc-2,),[3.0.0,)</versionRange>
<goals>
<goal>nar-validate</goal>
<goal>nar-download</goal>
Expand All @@ -48,6 +48,7 @@
<goal>nar-process-libraries</goal>
<goal>nar-testDownload</goal>
<goal>nar-testUnpack</goal>
<goal>nar-test-unpack</goal>
<goal>nar-testCompile</goal>
<goal>nar-test</goal>
</goals>
Expand Down
204 changes: 97 additions & 107 deletions com.github.sdedwards.m2e-nar/src/com/github/maven_nar/AOL.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,111 +23,101 @@
* @author Mark Donszelmann
* @version $Id$
*/
public class AOL
{

private String architecture;

private String os;

private String linkerName;

private String suffix;

// FIXME, need more complicated parsing for numbers as part of os.
public AOL( String aolWithSuffix )
{
final int suffixIndex = 3;
final int linkerIndex = 2;
final int osIndex = 1;
final int architectureIndex = 0;

String[] aolString = aolWithSuffix.split( "-", suffixIndex+1 );
switch ( aolString.length )
{
case suffixIndex+1:
suffix = aolString[suffixIndex];
case linkerIndex+1:
linkerName = aolString[linkerIndex];
case osIndex+1:
os = aolString[osIndex];
case architectureIndex+1:
architecture = aolString[architectureIndex];
break;

default:
throw new IllegalArgumentException( "AOL '" + aolWithSuffix + "' cannot be parsed." );
}
}

public AOL( String aol, String aolSuffix )
{
this(aol);
suffix = aolSuffix;
}

public AOL( String architecture, String os, String linkerName, String suffix )
{
this.architecture = architecture;
this.os = os;
this.linkerName = linkerName;
this.suffix = suffix;
}

/**
* Returns an AOL string (arch-os-linker) to use as directory or file.
* @return dash separated AOL
*/
public final String toString()
{
String tempLinkerName = null;
if ( linkerName == null ) {
tempLinkerName = "";
} else if ( linkerName.equals("g++") ) {
tempLinkerName = "-gpp";
} else {
if ( linkerName.equals("g++") ) {
tempLinkerName = "-gpp";
} else {
tempLinkerName = "-" + linkerName;
}
if ( suffix != null ) {
tempLinkerName += "-" + suffix;
}
}

return architecture
+ ((os == null) ? "" : "-" + os
+ tempLinkerName);
}

// FIXME, maybe change to something like isCompatible (AOL).
public final boolean hasLinker( String linker )
{
return linkerName.equals(linker);
}

/**
* Returns an AOL key (arch.os.linker) to search in the properties files.
* @return dot separated AOL
*/
public final String getKey()
{
String tempLinkerName = null;
if ( linkerName == null ) {
tempLinkerName = "";
} else if ( linkerName.equals("g++") ) {
tempLinkerName = ".gpp";
} else {
tempLinkerName = "." + linkerName;
}

return architecture
+ ((os == null) ? "" : "." + os
+ tempLinkerName);
}

final String getOS() {
return os;
}
public class AOL {

private String architecture;

private String os;

private String linkerName;

private String suffix;

// FIXME, need more complicated parsing for numbers as part of os.
public AOL(String aolWithSuffix) {
final int suffixIndex = 3;
final int linkerIndex = 2;
final int osIndex = 1;
final int architectureIndex = 0;

String[] aolString = aolWithSuffix.split("-", suffixIndex + 1);
switch (aolString.length) {
case suffixIndex + 1:
suffix = aolString[suffixIndex];
case linkerIndex + 1:
linkerName = aolString[linkerIndex];
case osIndex + 1:
os = aolString[osIndex];
case architectureIndex + 1:
architecture = aolString[architectureIndex];
break;

default:
throw new IllegalArgumentException("AOL '" + aolWithSuffix + "' cannot be parsed.");
}
}

public AOL(String aol, String aolSuffix) {
this(aol);
suffix = aolSuffix;
}

public AOL(String architecture, String os, String linkerName, String suffix) {
this.architecture = architecture;
this.os = os;
this.linkerName = linkerName;
this.suffix = suffix;
}

/**
* Returns an AOL string (arch-os-linker) to use as directory or file.
*
* @return dash separated AOL
*/
public final String toString() {
String tempLinkerName = null;
if (linkerName == null) {
tempLinkerName = "";
} else if (linkerName.equals("g++")) {
tempLinkerName = "-gpp";
} else {
if (linkerName.equals("g++")) {
tempLinkerName = "-gpp";
} else {
tempLinkerName = "-" + linkerName;
}
if (suffix != null) {
tempLinkerName += "-" + suffix;
}
}

return architecture + ((os == null) ? "" : "-" + os + tempLinkerName);
}

// FIXME, maybe change to something like isCompatible (AOL).
public final boolean hasLinker(String linker) {
return linkerName.equals(linker);
}

/**
* Returns an AOL key (arch.os.linker) to search in the properties files.
*
* @return dot separated AOL
*/
public final String getKey() {
String tempLinkerName = null;
if (linkerName == null) {
tempLinkerName = "";
} else if (linkerName.equals("g++")) {
tempLinkerName = ".gpp";
} else {
tempLinkerName = "." + linkerName;
}

return architecture + ((os == null) ? "" : "." + os + tempLinkerName);
}

final String getOS() {
return os;
}
}
Loading

0 comments on commit bb0eb27

Please sign in to comment.