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

NDK: set APP_BUILD_SCRIPT for makefile parameter instead of -f #670

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class AndroidNdk
+ "alternative, you may add the parameter to commandline: -Dandroid.ndk.path=... or set environment "
+ "variable " + NdkBuildMojo.ENV_ANDROID_NDK_HOME + ".";

public static final String[] NDK_ARCHITECTURES = { "armeabi", "armeabi-v7a", "mips", "mips64", "x86", "x86_64" };
public static final String[] NDK_ARCHITECTURES = { "armeabi", "armeabi-v7a", "arm64-v8a", "mips", "mips64", "x86", "x86_64" };

/**
* Arm toolchain implementations.
Expand Down Expand Up @@ -122,7 +122,10 @@ else if ( SystemUtils.IS_OS_MAC || SystemUtils.IS_OS_MAC_OSX )
}

String fileName = "";
if ( toolchain.startsWith( "arm" ) )
if( toolchain.startsWith( "arm64-v8a")) {
fileName = "aarch64-linux-android-strip" + extension;
}
else if ( toolchain.startsWith( "arm" ) )
{
fileName = "arm-linux-androideabi-strip" + extension;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,6 @@ public class NdkBuildMojo extends AbstractAndroidMojo

/**
* <p>Folder containing native, static libraries compiled and linked by the NDK.</p>
*
* The NDK build executable seems determined to create the native libs in the root folder.
* TODO work out how to create them in /target.
*/
@Parameter(
property = "android.nativeLibrariesOutputDirectory",
Expand Down Expand Up @@ -411,15 +408,17 @@ harArtifactHandler, getUnpackedLibsDirectory()
getLog().error( "Specified makefile " + makeFile + " does not exist" );
throw new MojoExecutionException( "Specified makefile " + makeFile + " does not exist" );
}
commands.add( "-f" );
commands.add( makefile );
commands.add( "APP_BUILD_SCRIPT=" + makefile );
}

configureApplicationMakefile( commands );
configureMaxJobs( commands );
configureNdkToolchain( architecture, commands );
configureAdditionalCommands( commands );

commands.add( "NDK_LIBS_OUT=" + ndkOutputDirectory.getAbsolutePath() );
commands.add( "NDK_OUT=" + ndkOutputDirectory.getAbsolutePath() );

// If a build target is specified, tag that onto the command line as the very last of the parameters
if ( target != null )
{
Expand All @@ -438,14 +437,7 @@ harArtifactHandler, getUnpackedLibsDirectory()
executor.executeCommand( ndkBuildPath, commands, ndkBuildDirectory, true );
getLog().debug( "Executed NDK " + architecture + " make at : " + ndkBuildDirectory );

// Where the NDK build creates the libs.
final File nativeLibOutputDirectory = new File( nativeLibrariesOutputDirectory, architecture );
nativeLibOutputDirectory.mkdirs();

// Move the built native libs into the packaging folder.
// We don't create them there to start with because the NDK build seems determined to create them in the root.
final File destinationDirectory = new File( ndkOutputDirectory, architecture );
FileUtils.moveDirectory( nativeLibOutputDirectory, destinationDirectory );

// Attempt to attach the native library if the project is defined as a "pure" native Android library
// (packaging is 'so' or 'a') or if the plugin has been configured to attach the native library to the build
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
libs
obj
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.acme.hellojni"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="3" />
</manifest>
40 changes: 40 additions & 0 deletions src/test/projects/native/native-code-nonstandard-structure/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>com.jayway.maven.plugins.android.generation2.samples</groupId>
<artifactId>native-parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>

<artifactId>native-code-nonstandard-structure</artifactId>
<!--
Packaging is defined as 'so' - this will indicate to the Maven Android
plugin that it is meant to compile the native code. The resulting native
library is attached to the build
-->
<packaging>so</packaging>

<name>Android NDK - Native Sample Non-standard folder structure</name>

<build>
<plugins>
<plugin>
<groupId>com.simpligility.maven.plugins</groupId>

<artifactId>android-maven-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<ndkArchitectures>x86 armeabi</ndkArchitectures>
<makefile>src/Android.mk</makefile>
<applicationMakefile>src/Application.mk</applicationMakefile>
<attachHeaderFiles>false</attachHeaderFiles>
</configuration>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Copyright (C) 2009 The Android Open Source Project
#
# 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.
#
LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE := native-code-nonstandard-structure
LOCAL_SRC_FILES := hello-jni.c

include $(BUILD_SHARED_LIBRARY)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
APP_ABI := armeabi x86
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright (C) 2009 The Android Open Source Project
*
* 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.
*
*/
#include <string.h>
#include <jni.h>

/* This is a trivial JNI example where we use a native method
* to return a new VM String. See the corresponding Java source
* file located at:
*
* apps/samples/hello-jni/project/src/com/example/HelloJni/HelloJni.java
*/
jstring
Java_com_acme_hellojni_HelloJni_stringFromJNI( JNIEnv* env,
jobject thiz )
{
return (*env)->NewStringUTF(env, "Hello from Native JNI!");
}
1 change: 1 addition & 0 deletions src/test/projects/native/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
<module>java-with-native-apklib-dependency</module>
<!-- <module>mixed-java-native-with-apklib-dependency</module> -->
<module>transient-apklib-with-native</module>
<module>native-code-nonstandard-structure</module>
</modules>

<dependencyManagement>
Expand Down