imakerplugin/com.nokia.s60tools.imaker/src/com/nokia/s60tools/imaker/internal/console/IMakerJob.java
equal
deleted
inserted
replaced
20 |
20 |
21 import java.io.File; |
21 import java.io.File; |
22 import java.io.IOException; |
22 import java.io.IOException; |
23 import java.io.PipedInputStream; |
23 import java.io.PipedInputStream; |
24 import java.io.PipedOutputStream; |
24 import java.io.PipedOutputStream; |
25 import java.util.List; |
|
26 import java.util.regex.Matcher; |
25 import java.util.regex.Matcher; |
27 import java.util.regex.Pattern; |
26 import java.util.regex.Pattern; |
28 |
27 |
29 import org.eclipse.core.runtime.IProgressMonitor; |
28 import org.eclipse.core.runtime.IProgressMonitor; |
30 import org.eclipse.core.runtime.IStatus; |
29 import org.eclipse.core.runtime.IStatus; |
46 import com.nokia.s60tools.imaker.exceptions.IMakerCoreAlreadyRunningException; |
45 import com.nokia.s60tools.imaker.exceptions.IMakerCoreAlreadyRunningException; |
47 import com.nokia.s60tools.imaker.exceptions.IMakerCoreExecutionException; |
46 import com.nokia.s60tools.imaker.exceptions.IMakerCoreExecutionException; |
48 import com.nokia.s60tools.imaker.exceptions.IMakerCoreNotFoundException; |
47 import com.nokia.s60tools.imaker.exceptions.IMakerCoreNotFoundException; |
49 |
48 |
50 public class IMakerJob extends Job { |
49 public class IMakerJob extends Job { |
51 private List<String> command; |
50 private File file; |
52 public volatile boolean done = false; |
51 public volatile boolean done = false; |
53 private IIMakerWrapper wrapper; |
52 private IIMakerWrapper wrapper; |
54 private String epocroot; |
53 private String epocroot; |
55 |
54 |
56 public static final int DEFAULT_THREAD_SLEEP_TIME = 20; |
55 public static final int DEFAULT_THREAD_SLEEP_TIME = 20; |
60 public static final String BUILD_FAILURE_MESSAGE = Messages.getString("ImageBuilder.3"); //$NON-NLS-1$ |
59 public static final String BUILD_FAILURE_MESSAGE = Messages.getString("ImageBuilder.3"); //$NON-NLS-1$ |
61 |
60 |
62 public static final Pattern VARIABLE_PATTERN1 = Pattern.compile(".*\\s*=\\s*.([\\\\/].*)."); |
61 public static final Pattern VARIABLE_PATTERN1 = Pattern.compile(".*\\s*=\\s*.([\\\\/].*)."); |
63 public static final Pattern VARIABLE_PATTERN2 = Pattern.compile(".*\\s*=\\s*.(.:.*)."); |
62 public static final Pattern VARIABLE_PATTERN2 = Pattern.compile(".*\\s*=\\s*.(.:.*)."); |
64 |
63 |
65 public IMakerJob(String name, List<String> cmd, IIMakerWrapper wrapper) { |
64 public IMakerJob(String name, File file, IIMakerWrapper wrapper) { |
66 super(name); |
65 super(name); |
67 this.command = cmd; |
66 this.file = file; |
68 this.wrapper = wrapper; |
67 this.wrapper = wrapper; |
69 this.epocroot = IMakerUtils.getLocationDrive(wrapper.getTool().get(0)); |
68 this.epocroot = IMakerUtils.getLocationDrive(wrapper.getTool().get(0)); |
70 } |
69 } |
71 |
70 |
72 @Override |
71 @Override |
78 MessageConsoleStream errorStream = console.getNewMessageConsoleStream(IMakerConsole.MSG_ERROR); |
77 MessageConsoleStream errorStream = console.getNewMessageConsoleStream(IMakerConsole.MSG_ERROR); |
79 |
78 |
80 //print command |
79 //print command |
81 infoStream.println(BUILD_START_MESSAGE); |
80 infoStream.println(BUILD_START_MESSAGE); |
82 infoStream.print(BUILD_CMD); |
81 infoStream.print(BUILD_CMD); |
83 infoStream.println(wrapper.getBuildCommand(command)); |
82 infoStream.println(wrapper.getBuildCommand(file)); |
84 |
83 |
85 try { |
84 try { |
86 PipedInputStream pin = new PipedInputStream(); |
85 PipedInputStream pin = new PipedInputStream(); |
87 PipedOutputStream pout = new PipedOutputStream(pin); |
86 PipedOutputStream pout = new PipedOutputStream(pin); |
88 |
87 |
89 IMakerConsoleLogger logger = new IMakerConsoleLogger(pin); |
88 IMakerConsoleLogger logger = new IMakerConsoleLogger(pin); |
90 logger.start(); |
89 logger.start(); |
91 |
90 |
92 boolean success = false; |
91 boolean success = false; |
93 success = wrapper.buildImage(command,pout); |
92 success = wrapper.buildImage(file,pout); |
94 |
93 |
95 // Stop the thread. |
94 // Stop the thread. |
96 logger.done = true; |
95 logger.done = true; |
97 if (success) { |
96 if (success) { |
98 infoStream.println(BUILD_SUCCESS_MESSAGE); |
97 infoStream.println(BUILD_SUCCESS_MESSAGE); |