Skip to content

Commit

Permalink
Support explicitly configuring which build tool to use on windows.
Browse files Browse the repository at this point in the history
  • Loading branch information
chirino committed Mar 20, 2013
1 parent 373da49 commit 3567b1d
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,14 @@ public class BuildMojo extends AbstractMojo {
*/
private String nativeSrcUrl;

/**
* The build tool to use on Windows systems. Set
* to 'msbuild', 'vcbuild', or 'detect'
*
* @parameter default-value="detect"
*/
private String windowsBuildTool;

private final CLI cli = new CLI();

public void execute() throws MojoExecutionException {
Expand Down Expand Up @@ -262,8 +270,32 @@ private void vsBasedBuild(File buildDir) throws CommandLineException, MojoExecut
throw new MojoExecutionException("Usupported platform: "+library.getPlatform());
}

String toolset = System.getenv("PlatformToolset");
if( "Windows7.1SDK".equals(toolset) ) {
boolean useMSBuild = false;
String tool = windowsBuildTool.toLowerCase().trim();
if( "detect".equals(tool) ) {
String toolset = System.getenv("PlatformToolset");
if( "Windows7.1SDK".equals(toolset) ) {
useMSBuild = true;
} else {
String vcinstalldir = System.getenv("VCINSTALLDIR");
if( vcinstalldir!=null ) {
if( vcinstalldir.contains("Microsoft Visual Studio 10") ||
vcinstalldir.contains("Microsoft Visual Studio 11") ||
vcinstalldir.contains("Microsoft Visual Studio 12")
) {
useMSBuild = true;
}
}
}
} else if( "msbuild".equals(tool) ) {
useMSBuild = true;
} else if( "vcbuild".equals(tool) ) {
useMSBuild = false;
} else {
throw new MojoExecutionException("Invalid setting for windowsBuildTool: "+windowsBuildTool);
}

if( useMSBuild ) {
// vcbuild was removed.. use the msbuild tool instead.
int rc = cli.system(buildDir, new String[]{"msbuild", "vs2010.vcxproj", "/property:Platform="+platform, "/property:Configuration="+configuration});
if( rc != 0 ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,14 @@ public class GenerateMojo extends AbstractMojo {
*/
private boolean callbacks;

/**
* The build tool to use on Windows systems. Set
* to 'msbuild', 'vcbuild', or 'detect'
*
* @parameter default-value="detect"
*/
private String windowsBuildTool;

private File targetSrcDir;

private CLI cli = new CLI();
Expand Down Expand Up @@ -212,8 +220,18 @@ private void generateBuildSystem() throws MojoExecutionException {
copyTemplateResource("m4/osx-universal.m4", false);

// To support windows based builds..
copyTemplateResource("vs2008.vcproj", true);
copyTemplateResource("vs2010.vcxproj", true);
String tool = windowsBuildTool.toLowerCase().trim();
if( "detect".equals(tool) ) {
copyTemplateResource("vs2008.vcproj", true);
copyTemplateResource("vs2010.vcxproj", true);
} else if( "msbuild".equals(tool) ) {
copyTemplateResource("vs2010.vcxproj", true);
} else if( "vcbuild".equals(tool) ) {
copyTemplateResource("vs2008.vcproj", true);
} else if( "none".equals(tool) ) {
} else {
throw new MojoExecutionException("Invalid setting for windowsBuildTool: "+windowsBuildTool);
}

File autogen = new File(packageDirectory, "autogen.sh");
File configure = new File(packageDirectory, "configure");
Expand Down

0 comments on commit 3567b1d

Please sign in to comment.