Skip to content

Commit

Permalink
Merge pull request #77 from johanlindquist/static-lib-support
Browse files Browse the repository at this point in the history
Static lib support
  • Loading branch information
mosabua committed Nov 7, 2011
2 parents 38ccd3b + d176279 commit 532af47
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 4 deletions.
Expand Up @@ -47,6 +47,12 @@ public static String createMakefileFromArtifacts( File outputDir, Set<Artifact>
makeFile.append( '\n' );
makeFile.append("$(shell echo \"LOCAL_PATH=$(LOCAL_PATH)\" >> $(ANDROID_MAVEN_PLUGIN_LOCAL_C_INCLUDES_FILE))");
makeFile.append( '\n' );
makeFile.append("$(shell echo \"LOCAL_MODULE_FILENAME=$(LOCAL_MODULE_FILENAME)\" >> $(ANDROID_MAVEN_PLUGIN_LOCAL_C_INCLUDES_FILE))");
makeFile.append( '\n' );
makeFile.append("$(shell echo \"LOCAL_MODULE=$(LOCAL_MODULE)\" >> $(ANDROID_MAVEN_PLUGIN_LOCAL_C_INCLUDES_FILE))");
makeFile.append( '\n' );
makeFile.append("$(shell echo \"LOCAL_CFLAGS=$(LOCAL_CFLAGS)\" >> $(ANDROID_MAVEN_PLUGIN_LOCAL_C_INCLUDES_FILE))");
makeFile.append( '\n' );

if ( !artifacts.isEmpty() )
{
Expand Down
Expand Up @@ -63,6 +63,18 @@ public class NdkBuildMojo extends AbstractAndroidMojo {
*/
private Ndk ndk;

/** Allows for overriding the default ndk-build executable.
*
* @parameter expression="${android.ndk.ndk-build-executable}"
*/
private String ndkBuildExecutable;

/**
*
* @parameter expression="${android.ndk.ndk-build-directory}" default="${basedir}";
*/
private String ndkBuildDirectory;

/**
* <p>Parameter designed to pick up <code>-Dandroid.ndk.path</code> in case there is no pom with an
* <code>&lt;ndk&gt;</code> configuration tag.</p>
Expand Down Expand Up @@ -240,6 +252,9 @@ public class NdkBuildMojo extends AbstractAndroidMojo {
* Defines the regular expression used to detect whether error/warning output from ndk-build is a minor compile warning
* or is actually an error which should cause the build to fail.
*
* If the pattern matches, the output from the compiler will <strong>not</strong> be considered an error and compile
* will be successful.
*
* @parameter expression="${android.ndk.build.build-warnings-regular-expression}" default=".*[warning|note]: .*"
*/
private String buildWarningsRegularExpression = ".*[warning|note]: .*";
Expand Down Expand Up @@ -312,8 +327,8 @@ public boolean isError(String error) {
File localCIncludesFile = null;
//
try {
localCIncludesFile = File.createTempFile("android_maven_plugin_local_c_includes", ".tmp");
// localCIncludesFile.deleteOnExit();
localCIncludesFile = File.createTempFile("android_maven_plugin_makefile_captures", ".tmp");
localCIncludesFile.deleteOnExit();
executor.addEnvironment( "ANDROID_MAVEN_PLUGIN_LOCAL_C_INCLUDES_FILE", localCIncludesFile.getAbsolutePath());
} catch (IOException e) {
throw new MojoExecutionException(e.getMessage());
Expand All @@ -330,7 +345,11 @@ public boolean isError(String error) {
final List<String> commands = new ArrayList<String>();

commands.add( "-C" );
commands.add( project.getBasedir().getAbsolutePath() );
if (ndkBuildDirectory == null)
{
ndkBuildDirectory = project.getBasedir().getAbsolutePath();
}
commands.add( ndkBuildDirectory );

if ( ndkBuildAdditionalCommandline != null ) {
String[] additionalCommands = ndkBuildAdditionalCommandline.split( " " );
Expand All @@ -348,7 +367,7 @@ else if ( "a".equals( project.getPackaging() ) ) {
commands.add( project.getArtifactId() );
}

final String ndkBuildPath = getAndroidNdk().getNdkBuildPath();
final String ndkBuildPath = resolveNdkBuildExecutable();
getLog().info( ndkBuildPath + " " + commands.toString() );

try {
Expand Down Expand Up @@ -423,6 +442,15 @@ public boolean accept( final File dir, final String name ) {

}

private String resolveNdkBuildExecutable() throws MojoExecutionException {
if (ndkBuildExecutable != null)
{
getLog().debug("ndk-build overriden, using " + ndkBuildExecutable);
return ndkBuildExecutable;
}
return getAndroidNdk().getNdkBuildPath();
}

private void processHeaderFileIncludes(File localCIncludesFile) throws MojoExecutionException {

try
Expand Down

0 comments on commit 532af47

Please sign in to comment.