Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeff Johnston2018-03-26 22:36:36 +0000
committerJeff Johnston2018-03-26 22:36:36 +0000
commit407352736a328a00be88fcac2cb4d12efdcc806c (patch)
tree6725a0a44f296c2a1be1ee7d2ea3eb55a1f88ec3
parentebab079cbfae28769ad6d1c33d1b266f078023e8 (diff)
downloadorg.eclipse.cdt-407352736a328a00be88fcac2cb4d12efdcc806c.tar.gz
org.eclipse.cdt-407352736a328a00be88fcac2cb4d12efdcc806c.tar.xz
org.eclipse.cdt-407352736a328a00be88fcac2cb4d12efdcc806c.zip
Bug 532917 - env vars in Meson properties causes failures to occur
- fix MesonBuildConfiguration to check if any environment variables have been specified in properties page and if so, to change the command to run /usr/bin/env ENVVARS /bin/sh -c "meson ..." - using env will cause the current env to be used (both locally and in a Container where the env has been set up) and modify it according to what the user specifies Change-Id: Ide3997cf78edf65857dea3119f0a9d71679cfe68
-rw-r--r--build/org.eclipse.cdt.meson.core/src/org/eclipse/cdt/internal/meson/core/MesonBuildConfiguration.java28
1 files changed, 16 insertions, 12 deletions
diff --git a/build/org.eclipse.cdt.meson.core/src/org/eclipse/cdt/internal/meson/core/MesonBuildConfiguration.java b/build/org.eclipse.cdt.meson.core/src/org/eclipse/cdt/internal/meson/core/MesonBuildConfiguration.java
index 21aa8aed54..6accbad440 100644
--- a/build/org.eclipse.cdt.meson.core/src/org/eclipse/cdt/internal/meson/core/MesonBuildConfiguration.java
+++ b/build/org.eclipse.cdt.meson.core/src/org/eclipse/cdt/internal/meson/core/MesonBuildConfiguration.java
@@ -17,6 +17,8 @@ import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Properties;
import org.eclipse.cdt.core.CommandLauncherManager;
import org.eclipse.cdt.core.ConsoleOutputStream;
@@ -138,8 +140,18 @@ public class MesonBuildConfiguration extends CBuildConfiguration {
boolean runMeson = !Files.exists(buildDir.resolve("build.ninja")); //$NON-NLS-1$
if (runMeson) { // $NON-NLS-1$
+ org.eclipse.core.runtime.Path cmdPath = new org.eclipse.core.runtime.Path("/bin/sh"); //$NON-NLS-1$
+
List<String> argsList = new ArrayList<>();
+ // if we have env variables, use "env" command with modifications specified after to
+ // add to environment without replacing it (e.g. losing default path)
+ String envStr = getProperty(IMesonConstants.MESON_ENV);
+ if (envStr != null) {
+ cmdPath = new org.eclipse.core.runtime.Path("/usr/bin/env"); //$NON-NLS-1$
+ argsList.addAll(MesonUtils.stripEnvVars(envStr));
+ argsList.add("/bin/sh"); //$NON-NLS-1$
+ }
argsList.add("-c"); //$NON-NLS-1$
StringBuilder b = new StringBuilder();
@@ -159,28 +171,20 @@ public class MesonBuildConfiguration extends CBuildConfiguration {
b.append(getBuildDirectory().toString());
argsList.add(b.toString());
- List<String> envList = new ArrayList<>();
- String envStr = getProperty(IMesonConstants.MESON_ENV);
- if (envStr != null) {
- envList.addAll(MesonUtils.stripEnvVars(envStr));
- }
- String[] env = envList.toArray(new String[0]);
-
ICommandLauncher launcher = CommandLauncherManager.getInstance().getCommandLauncher(this);
-
+
launcher.setProject(getProject());
if (launcher instanceof ICBuildCommandLauncher) {
((ICBuildCommandLauncher)launcher).setBuildConfiguration(this);
}
-
+
monitor.subTask(Messages.MesonBuildConfiguration_RunningMeson);
- org.eclipse.core.runtime.Path shPath = new org.eclipse.core.runtime.Path("/bin/sh"); //$NON-NLS-1$
- outStream.write(String.join(" ", envStr != null ? envStr : "", //$NON-NLS-1$ //$NON-NLS-2$
+ outStream.write(String.join(" ", envStr != null ? ("env " + envStr) : "", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
"sh -c \"meson", userArgs != null ? userArgs : "", projOptions != null ? projOptions : "", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
getBuildDirectory().getParent().getParent().toString() + "\"\n")); //$NON-NLS-1$
org.eclipse.core.runtime.Path workingDir = new org.eclipse.core.runtime.Path(getBuildDirectory().getParent().getParent().toString());
- Process p = launcher.execute(shPath, argsList.toArray(new String[0]), env, workingDir, monitor);
+ Process p = launcher.execute(cmdPath, argsList.toArray(new String[0]), new String[0], workingDir, monitor);
if (p == null || launcher.waitAndRead(outStream, outStream, SubMonitor.convert(monitor)) != ICommandLauncher.OK) {
String errMsg = p == null ? "" : launcher.getErrorMessage(); //$NON-NLS-1$
console.getErrorStream().write(String.format(Messages.MesonBuildConfiguration_RunningMesonFailure, errMsg));

Back to the top