Skip to content
This repository has been archived by the owner on Oct 4, 2019. It is now read-only.

Feature/appcode3 xcodepath #45

Merged
merged 3 commits into from
Oct 24, 2014
Merged
Show file tree
Hide file tree
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
16 changes: 9 additions & 7 deletions Scripts/dyci-recompile.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,13 +162,15 @@ def copyResource(source, dyci):
os.chdir(workingDir)
params = params[:-1]


# Searching where is Xcode with it's Clang located
process = Popen(["xcode-select","-print-path"],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
xcodeLocation, err = process.communicate()
xcodeLocation = xcodeLocation.rstrip(os.linesep)
if len(args)>1:
xcodeLocation = args[2]
else:
# Searching where is Xcode with it's Clang located
process = Popen(["xcode-select","-print-path"],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
xcodeLocation, err = process.communicate()
xcodeLocation = xcodeLocation.rstrip(os.linesep)

compileString = [xcodeLocation + '/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang-real'] \
+ params
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,13 @@

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;

import javax.xml.xpath.*;
import org.xml.sax.InputSource;

/**
* Created with IntelliJ IDEA.
* User: paultaykalo
Expand Down Expand Up @@ -48,6 +52,24 @@ public void actionPerformed(final AnActionEvent actionEvent) {
this.injectFile(actionEvent, path);


}

private String xcodePath(java.io.FileReader fileReader){
String xpathExpression = "/application/component[@name='XcodeSettings']/option[@name='selectedXcode']/@value";

XPathFactory xpathFactory = XPathFactory.newInstance();
XPath xpath = xpathFactory.newXPath();
try{
XPathExpression expr = xpath.compile(xpathExpression);
InputSource inputSource = new InputSource(fileReader);
String result = expr.evaluate(inputSource);
return result;

} catch(Exception e){
LOG.error("Exception getting Xcode path: " + e.getMessage());
this.showMessageBubble(actionEvent, MessageType.ERROR, "Failed to run injection script");
}

}

private void injectFile(final AnActionEvent actionEvent, final String path) {
Expand All @@ -69,9 +91,21 @@ private void injectFile(final AnActionEvent actionEvent, final String path) {
this.showMessageBubble(actionEvent, MessageType.ERROR, "Cannot run injection. No Dyci scripts were found. Make sure, that you've ran install.sh");
return;
}

String appcodeOptionsFilename = System.getProperty("user.home") + "/Library/Preferences/appCode30/options/other.xml";

String[] commands;
try {
FileReader appcodeOptions = new FileReader(appcodeOptionsFilename);
String xcodePath = xcodePath(appcodeOptions);
commands = new String[] {dyciScriptLocation, path, xcodePath};
} catch(IOException e) {
// If the file cannot be found, it might not be a problem (user has appcode 2 or maybe the setting wasn't saved)
// We'll just leave it up to the dyci script to find Xcode.
commands = new String[] {dyciScriptLocation, path};
}

Runtime rt = Runtime.getRuntime();
String[] commands = {dyciScriptLocation, path};
try {
Process proc = rt.exec(commands);

Expand Down