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

Use binary output folder as the compiler's working directory #89

Merged
merged 1 commit into from
Mar 12, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -368,7 +370,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