Skip to content

Commit

Permalink
Merge pull request #89 from osialr/staging/compiler-working-directory
Browse files Browse the repository at this point in the history
 * Use the `outputDirectory` as the compiler's working directory
  • Loading branch information
saudet committed Mar 12, 2016
2 parents 1d40779 + 49b4f90 commit 0c2b518
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/main/java/org/bytedeco/javacpp/tools/Builder.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
import java.util.zip.ZipEntry;
import org.bytedeco.javacpp.ClassProperties;
import org.bytedeco.javacpp.Loader;
import org.bytedeco.javacpp.annotation.Platform;

/**
* The Builder is responsible for coordinating efforts between the Parser, the
Expand Down Expand Up @@ -156,7 +155,7 @@ static void includeJavaPaths(ClassProperties properties, boolean header) {
* @throws IOException
* @throws InterruptedException
*/
int compile(String sourceFilename, String outputFilename, ClassProperties properties)
int compile(String sourceFilename, String outputFilename, ClassProperties properties, File workingDirectory)
throws IOException, InterruptedException {
ArrayList<String> command = new ArrayList<String>();

Expand Down Expand Up @@ -314,6 +313,9 @@ int compile(String sourceFilename, String outputFilename, ClassProperties proper
logger.info(text);

ProcessBuilder pb = new ProcessBuilder(command);
// Use the library output path as the working directory so that
// intermediate build files from MSVC are dumped there
pb.directory(workingDirectory);
if (environmentVariables != null) {
pb.environment().putAll(environmentVariables);
}
Expand Down Expand Up @@ -371,7 +373,7 @@ File generateAndCompile(Class[] classes, String outputName) throws IOException,
if (compile) {
String libraryFilename = outputPath.getPath() + File.separator + libraryName;
logger.info("Compiling " + libraryFilename);
int exitValue = compile(sourceFilename, libraryFilename, p);
int exitValue = compile(sourceFilename, libraryFilename, p, outputPath);
if (exitValue == 0) {
new File(sourceFilename).delete();
outputFile = new File(libraryFilename);
Expand Down

0 comments on commit 0c2b518

Please sign in to comment.