import org.tizen.nativecommon.build.SmartBuildInterface;
import org.tizen.nativeplatform.Activator;
+public class PlatformBuildCommandLauncher extends CommandLauncher {
+ @Override
+ public Process execute(IPath commandPath, String[] args, String[] env, IPath changeToDirectory,
+ IProgressMonitor monitor) throws CoreException {
-public class PlatformBuildCommandLauncher extends CommandLauncher {
- @Override
- public Process execute(IPath commandPath, String[] args, String[] env,
- IPath changeToDirectory, IProgressMonitor monitor) throws CoreException {
+ Process proc = null;
- Process proc = null;
-
- if (commandPath.toString().contains("sbi-make")) {
- IProject proj = getProject();
- PlatformProjectDependentPackager packager = (PlatformProjectDependentPackager)
- ProjectTypeManager.getProjectPackagerInstance(proj);
- SmartBuildInterface sbi = SmartBuildInterface.getInstance(proj);
- IConfiguration config = ManagedBuildManager.getBuildInfo(proj).getDefaultConfiguration();
- IPath workingPath = new Path(proj.getLocation().toOSString());
- String[] newEnvs = packager.getEnvsWithProxy();
-
- String cmd = "";
- if ("clean".equals(args[0])) {
- cmd = packager.getCleanCmd(config);
+ if (commandPath.toString().contains("sbi-make")) {
+ IProject proj = getProject();
+ PlatformProjectDependentPackager packager = (PlatformProjectDependentPackager) ProjectTypeManager
+ .getProjectPackagerInstance(proj);
+ SmartBuildInterface sbi = SmartBuildInterface.getInstance(proj);
+ IConfiguration config = ManagedBuildManager.getBuildInfo(proj)
+ .getDefaultConfiguration();
+ IPath workingPath = new Path(proj.getLocation().toOSString());
+ String[] new_envs = packager.getEnvironment(config);
+ String cmd = "";
+ if ("clean".equals(args[0])) {
+ cmd = packager.getCleanCmd(config);
} else {
- cmd = packager.getBuildPackageCmd(config);
+ cmd = packager.getBuildPackageCmd(config);
+ }
+ if (cmd == null || cmd.isEmpty()) {
+ Status status = new Status(Status.ERROR, Activator.PLUGIN_ID,
+ "Failed to build the project", null);
+ throw new CoreException(status);
}
- if (cmd == null || cmd.isEmpty()) {
- Status status = new Status(Status.ERROR, Activator.PLUGIN_ID,
- "Failed to build the project", null);
- throw new CoreException(status);
- }
-
- String[] cmds = sbi.parseCommandString(cmd);
- String[] argus = new String[cmds.length - 1];
- for (int i = 0; i < cmds.length - 1; i++) {
- argus[i] = cmds[i + 1];
- }
-
- proc = super.execute(new Path(cmds[0]), argus, newEnvs, workingPath, new NullProgressMonitor());
-
- if ("clean".equals(args[0])) {
- proj.touch(monitor);
- ProjectUtil.refreshResources(proj);
- }
-
- } else {
- proc = super.execute(commandPath, args, env, changeToDirectory, monitor);
- }
-
- ProcessMonitorThread pmt = new ProcessMonitorThread(proc, monitor);
- pmt.start();
- return proc;
- }
+ String[] cmds = sbi.parseCommandString(cmd);
+ String[] argus = new String[cmds.length - 1];
+ for (int i = 0; i < cmds.length - 1; i++) {
+ argus[i] = cmds[i + 1];
+ }
+
+ proc = super.execute(new Path(cmds[0]), argus, new_envs, workingPath,
+ new NullProgressMonitor());
+
+ if ("clean".equals(args[0])) {
+ proj.touch(monitor);
+ ProjectUtil.refreshResources(proj);
+ }
+
+ } else {
+ proc = super.execute(commandPath, args, env, changeToDirectory, monitor);
+ }
+
+ ProcessMonitorThread pmt = new ProcessMonitorThread(proc, monitor);
+ pmt.start();
+
+ return proc;
+ }
}
package org.tizen.nativeplatform.build;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.envvar.IEnvironmentVariable;
+import org.eclipse.cdt.core.envvar.IEnvironmentVariableManager;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.core.resources.IProject;
public class PlatformProjectDependentPackager extends CommonProjectDependentPackager {
private static final String ACTION_BUILDPACKAGE = "buildpackage";
- private static final String ACTION_CHECKPKGDEPS = "checkbuilddeps";
private static final String CONSOLE_NAME = "Packaging";
private static PlatformProjectDependentPackager instance = new PlatformProjectDependentPackager();
// command "build package" from specified configuration and pkgType
private void buildPackage(IConfiguration config, String pkgType) throws SBIException {
String projectDir = getProjectPath();
- String[] new_envs = getEnvsWithProxy();
+ String[] new_envs = getEnvironment(config);
String cmd = getBuildPackageCmd(config);
if (cmd == null || cmd.isEmpty()) {
throw new SBIException("Failed to build the project");
sbi.actionConsole(cmd, projectDir, new_envs, CONSOLE_NAME);
}
+ public String[] getEnvironment(IConfiguration config) {
+ List<String> newEnvArray = new ArrayList<String>();
+ ICConfigurationDescription cfgDes = ManagedBuildManager
+ .getDescriptionForConfiguration(config);
+ IEnvironmentVariableManager mngr = CCorePlugin.getDefault().getBuildEnvironmentManager();
+ IEnvironmentVariable[] vars = mngr.getVariables(cfgDes, true);
+ Map<String, String> envMap = new HashMap<String, String>();
+ for (IEnvironmentVariable var : vars) {
+ envMap.put(var.getName(), var.getValue());
+ }
+ // add proxySet variable to Map
+ if (PreferencesManager.isProxyUsed()) {
+ String[] proxyInfo = PreferencesManager.getProxyParsedURL();
+ if (proxyInfo != null) {
+ String protocol = proxyInfo[0];
+ String host = proxyInfo[1];
+ String port = proxyInfo[2];
+ String envKey = String.format("%s_proxy", protocol);
+ String envValue = String.format("%s://%s:%s", protocol, host, port);
+ envMap.put(envKey, envValue);
+ }
+ }
+ for (Entry<String, String> entry : envMap.entrySet()) {
+ newEnvArray.add(String.format("%s=%s", entry.getKey(), entry.getValue()));
+ }
+ return newEnvArray.toArray(new String[0]);
+ }
+
public String getCleanCmd(IConfiguration config) {
String targetId = getTargetID(config);
IPath configPath = project.getLocation().append(config.getName());