mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-07 17:56:01 +02:00
Bug 531985 - Support Container build with new Core Build
- add support for Container build to Meson - add fixes to MesonBuildConfiguration clean build to use sh -c like normal meson build - add new refreshScannerInfo method to MesonBuildConfiguration to re-process the commands json file so indexing will correctly switch from local to Container build and vice-versa - add MESON_PROJECT_ARGUMENTS to IMesonConstants - in MesonBuildConfigurationProvider getCBuildConfiguration method, remove checks for toolChainfile and for Container build, name the configuration based on the image name Change-Id: Ia8a85c05e0cb9d46d2987ed4d39fcee914302467
This commit is contained in:
parent
c9822e117e
commit
82b0f6ab28
8 changed files with 152 additions and 47 deletions
|
@ -38,7 +38,10 @@ import org.eclipse.core.resources.IResource;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
|
import org.eclipse.core.runtime.IStatus;
|
||||||
|
import org.eclipse.core.runtime.Status;
|
||||||
import org.eclipse.core.runtime.SubMonitor;
|
import org.eclipse.core.runtime.SubMonitor;
|
||||||
|
import org.eclipse.core.runtime.jobs.Job;
|
||||||
import org.osgi.service.prefs.BackingStoreException;
|
import org.osgi.service.prefs.BackingStoreException;
|
||||||
import org.osgi.service.prefs.Preferences;
|
import org.osgi.service.prefs.Preferences;
|
||||||
|
|
||||||
|
@ -147,6 +150,11 @@ public class MesonBuildConfiguration extends CBuildConfiguration {
|
||||||
b.append(" "); //$NON-NLS-1$
|
b.append(" "); //$NON-NLS-1$
|
||||||
b.append(userArgs);
|
b.append(userArgs);
|
||||||
}
|
}
|
||||||
|
String projOptions = getProperty(IMesonConstants.MESON_PROJECT_OPTIONS);
|
||||||
|
if (projOptions != null) {
|
||||||
|
b.append(" "); //$NON-NLS-1$
|
||||||
|
b.append(projOptions);
|
||||||
|
}
|
||||||
b.append(" "); //$NON-NLS-1$
|
b.append(" "); //$NON-NLS-1$
|
||||||
b.append(getBuildDirectory().toString());
|
b.append(getBuildDirectory().toString());
|
||||||
argsList.add(b.toString());
|
argsList.add(b.toString());
|
||||||
|
@ -169,7 +177,8 @@ public class MesonBuildConfiguration extends CBuildConfiguration {
|
||||||
|
|
||||||
org.eclipse.core.runtime.Path shPath = new org.eclipse.core.runtime.Path("/bin/sh"); //$NON-NLS-1$
|
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 ? envStr : "", //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
"sh -c \"meson", userArgs != null ? userArgs : "", getBuildDirectory().getParent().getParent().toString() + "\"\n")); //$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());
|
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(shPath, argsList.toArray(new String[0]), env, workingDir, monitor);
|
||||||
if (p == null || launcher.waitAndRead(outStream, outStream, SubMonitor.convert(monitor)) != ICommandLauncher.OK) {
|
if (p == null || launcher.waitAndRead(outStream, outStream, SubMonitor.convert(monitor)) != ICommandLauncher.OK) {
|
||||||
|
@ -235,8 +244,8 @@ public class MesonBuildConfiguration extends CBuildConfiguration {
|
||||||
|
|
||||||
project.refreshLocal(IResource.DEPTH_INFINITE, monitor);
|
project.refreshLocal(IResource.DEPTH_INFINITE, monitor);
|
||||||
|
|
||||||
// Load compile_commands.json file
|
// Process compile_commands.json file and generate Scanner info
|
||||||
processCompileCommandsFile(monitor);
|
refreshScannerInfo();
|
||||||
|
|
||||||
outStream.write(String.format(Messages.MesonBuildConfiguration_BuildingComplete, buildDir.toString()));
|
outStream.write(String.format(Messages.MesonBuildConfiguration_BuildingComplete, buildDir.toString()));
|
||||||
|
|
||||||
|
@ -256,6 +265,13 @@ public class MesonBuildConfiguration extends CBuildConfiguration {
|
||||||
|
|
||||||
Path buildDir = getBuildDirectory();
|
Path buildDir = getBuildDirectory();
|
||||||
|
|
||||||
|
outStream.write(String.format(Messages.MesonBuildConfiguration_BuildingIn, buildDir.toString()));
|
||||||
|
|
||||||
|
if (!Files.exists(buildDir.resolve("build.ninja"))) { //$NON-NLS-1$
|
||||||
|
console.getOutputStream().write(Messages.MesonBuildConfiguration_NoNinjaFileToClean);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try (ErrorParserManager epm = new ErrorParserManager(project, getBuildDirectoryURI(), this,
|
try (ErrorParserManager epm = new ErrorParserManager(project, getBuildDirectoryURI(), this,
|
||||||
getToolChain().getErrorParserIds())) {
|
getToolChain().getErrorParserIds())) {
|
||||||
epm.setOutputStream(console.getOutputStream());
|
epm.setOutputStream(console.getOutputStream());
|
||||||
|
@ -263,16 +279,16 @@ public class MesonBuildConfiguration extends CBuildConfiguration {
|
||||||
|
|
||||||
String cleanCommand = getProperty(IMesonConstants.CLEAN_COMMAND);
|
String cleanCommand = getProperty(IMesonConstants.CLEAN_COMMAND);
|
||||||
if (cleanCommand == null) {
|
if (cleanCommand == null) {
|
||||||
cleanCommand = "ninja clean"; //$NON-NLS-1$
|
cleanCommand = "ninja clean -v"; //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
String[] command = cleanCommand.split(" "); //$NON-NLS-1$
|
String[] command = cleanCommand.split(" "); //$NON-NLS-1$
|
||||||
|
|
||||||
Path cmdPath = findCommand(command[0]);
|
IPath cmd = new org.eclipse.core.runtime.Path("sh");
|
||||||
if (cmdPath != null) {
|
|
||||||
command[0] = cmdPath.toString();
|
List<String> argList = new ArrayList<>();
|
||||||
}
|
argList.add("-c"); //$NON-NLS-1$
|
||||||
|
argList.add(cleanCommand);
|
||||||
|
|
||||||
IPath cmd = new org.eclipse.core.runtime.Path(command[0]);
|
|
||||||
ICommandLauncher launcher = CommandLauncherManager.getInstance().getCommandLauncher(this);
|
ICommandLauncher launcher = CommandLauncherManager.getInstance().getCommandLauncher(this);
|
||||||
|
|
||||||
launcher.setProject(getProject());
|
launcher.setProject(getProject());
|
||||||
|
@ -280,17 +296,13 @@ public class MesonBuildConfiguration extends CBuildConfiguration {
|
||||||
((ICBuildCommandLauncher)launcher).setBuildConfiguration(this);
|
((ICBuildCommandLauncher)launcher).setBuildConfiguration(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
String[] commandargs = new String[0];
|
|
||||||
if (command.length > 1) {
|
|
||||||
commandargs = Arrays.copyOfRange(command, 1, command.length);
|
|
||||||
}
|
|
||||||
org.eclipse.core.runtime.Path workingDir = new org.eclipse.core.runtime.Path(buildDir.toString());
|
org.eclipse.core.runtime.Path workingDir = new org.eclipse.core.runtime.Path(buildDir.toString());
|
||||||
|
|
||||||
String[] env = new String[0];
|
String[] env = new String[0];
|
||||||
|
|
||||||
outStream.write(String.join(" ", command) + '\n'); //$NON-NLS-1$
|
outStream.write(String.join(" ", command) + '\n'); //$NON-NLS-1$
|
||||||
launcher.execute(cmd, commandargs, env, workingDir, monitor);
|
Process p = launcher.execute(cmd, argList.toArray(new String[0]), env, workingDir, monitor);
|
||||||
if (launcher.waitAndRead(epm.getOutputStream(), epm.getOutputStream(), SubMonitor.convert(monitor)) != ICommandLauncher.OK) {
|
if (p == null || launcher.waitAndRead(epm.getOutputStream(), epm.getOutputStream(), SubMonitor.convert(monitor)) != ICommandLauncher.OK) {
|
||||||
String errMsg = launcher.getErrorMessage();
|
String errMsg = launcher.getErrorMessage();
|
||||||
console.getErrorStream().write(String.format(Messages.MesonBuildConfiguration_RunningNinjaFailure, errMsg));
|
console.getErrorStream().write(String.format(Messages.MesonBuildConfiguration_RunningNinjaFailure, errMsg));
|
||||||
return;
|
return;
|
||||||
|
@ -303,6 +315,23 @@ public class MesonBuildConfiguration extends CBuildConfiguration {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void refreshScannerInfo() throws CoreException {
|
||||||
|
Job job = new Job(Messages.MesonBuildConfiguration_RefreshingScannerInfo) {
|
||||||
|
@Override
|
||||||
|
protected IStatus run(IProgressMonitor monitor) {
|
||||||
|
try {
|
||||||
|
processCompileCommandsFile(monitor);
|
||||||
|
} catch (CoreException e) {
|
||||||
|
return e.getStatus();
|
||||||
|
}
|
||||||
|
return Status.OK_STATUS;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
// TODO: should this have a scheduling rule??
|
||||||
|
job.schedule();
|
||||||
|
}
|
||||||
|
|
||||||
private void processCompileCommandsFile(IProgressMonitor monitor) throws CoreException {
|
private void processCompileCommandsFile(IProgressMonitor monitor) throws CoreException {
|
||||||
IProject project = getProject();
|
IProject project = getProject();
|
||||||
Path commandsFile = getBuildDirectory().resolve("compile_commands.json"); //$NON-NLS-1$
|
Path commandsFile = getBuildDirectory().resolve("compile_commands.json"); //$NON-NLS-1$
|
||||||
|
|
|
@ -72,11 +72,11 @@ public class MesonBuildConfigurationProvider implements ICBuildConfigurationProv
|
||||||
MesonBuildConfiguration mesonConfig = new MesonBuildConfiguration(config, name);
|
MesonBuildConfiguration mesonConfig = new MesonBuildConfiguration(config, name);
|
||||||
IMesonToolChainFile tcFile = mesonConfig.getToolChainFile();
|
IMesonToolChainFile tcFile = mesonConfig.getToolChainFile();
|
||||||
IToolChain toolChain = mesonConfig.getToolChain();
|
IToolChain toolChain = mesonConfig.getToolChain();
|
||||||
if (toolChain == null || tcFile == null) {
|
if (toolChain == null) {
|
||||||
// config not complete?
|
// config not complete
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (!toolChain.equals(tcFile.getToolChain())) {
|
if (tcFile != null && !toolChain.equals(tcFile.getToolChain())) {
|
||||||
// toolchain changed
|
// toolchain changed
|
||||||
return new MesonBuildConfiguration(config, name, tcFile.getToolChain(), tcFile,
|
return new MesonBuildConfiguration(config, name, tcFile.getToolChain(), tcFile,
|
||||||
mesonConfig.getLaunchMode());
|
mesonConfig.getLaunchMode());
|
||||||
|
@ -109,6 +109,11 @@ public class MesonBuildConfigurationProvider implements ICBuildConfigurationProv
|
||||||
// create config
|
// create config
|
||||||
StringBuilder configName = new StringBuilder("meson."); //$NON-NLS-1$
|
StringBuilder configName = new StringBuilder("meson."); //$NON-NLS-1$
|
||||||
configName.append(launchMode);
|
configName.append(launchMode);
|
||||||
|
if ("linux-container".equals(os)) { //$NON-NLS-1$
|
||||||
|
String osConfigName = toolChain.getProperty("linux-container-id"); //$NON-NLS-1$
|
||||||
|
configName.append('.');
|
||||||
|
configName.append(osConfigName);
|
||||||
|
} else {
|
||||||
if (os != null) {
|
if (os != null) {
|
||||||
configName.append('.');
|
configName.append('.');
|
||||||
configName.append(os);
|
configName.append(os);
|
||||||
|
@ -117,6 +122,7 @@ public class MesonBuildConfigurationProvider implements ICBuildConfigurationProv
|
||||||
configName.append('.');
|
configName.append('.');
|
||||||
configName.append(arch);
|
configName.append(arch);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
String name = configName.toString();
|
String name = configName.toString();
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while (configManager.hasConfiguration(this, project, name)) {
|
while (configManager.hasConfiguration(this, project, name)) {
|
||||||
|
|
|
@ -20,10 +20,12 @@ public class Messages extends NLS {
|
||||||
public static String MesonBuildConfiguration_Cleaning;
|
public static String MesonBuildConfiguration_Cleaning;
|
||||||
public static String MesonBuildConfiguration_RunningMeson;
|
public static String MesonBuildConfiguration_RunningMeson;
|
||||||
public static String MesonBuildConfiguration_RunningNinja;
|
public static String MesonBuildConfiguration_RunningNinja;
|
||||||
|
public static String MesonBuildConfiguration_RefreshingScannerInfo;
|
||||||
public static String MesonBuildConfiguration_RunningMesonFailure;
|
public static String MesonBuildConfiguration_RunningMesonFailure;
|
||||||
public static String MesonBuildConfiguration_RunningNinjaFailure;
|
public static String MesonBuildConfiguration_RunningNinjaFailure;
|
||||||
public static String MesonBuildConfiguration_NoToolchainFile;
|
public static String MesonBuildConfiguration_NoToolchainFile;
|
||||||
public static String MesonBuildConfiguration_NoNinjaFile;
|
public static String MesonBuildConfiguration_NoNinjaFile;
|
||||||
|
public static String MesonBuildConfiguration_NoNinjaFileToClean;
|
||||||
public static String MesonBuildConfiguration_ProcCompCmds;
|
public static String MesonBuildConfiguration_ProcCompCmds;
|
||||||
public static String MesonBuildConfiguration_ProcCompJson;
|
public static String MesonBuildConfiguration_ProcCompJson;
|
||||||
|
|
||||||
|
|
|
@ -13,11 +13,13 @@ MesonBuildConfiguration_BuildingComplete=Build complete: %s\n
|
||||||
MesonBuildConfiguration_Cleaning=Cleaning %s
|
MesonBuildConfiguration_Cleaning=Cleaning %s
|
||||||
MesonBuildConfiguration_RunningMeson=Running meson
|
MesonBuildConfiguration_RunningMeson=Running meson
|
||||||
MesonBuildConfiguration_RunningNinja=Running ninja
|
MesonBuildConfiguration_RunningNinja=Running ninja
|
||||||
|
MesonBuildConfiguration_RefreshingScannerInfo=Refreshing Scanner Info
|
||||||
MesonBuildConfiguration_ProcCompCmds=Processing compile commands %s
|
MesonBuildConfiguration_ProcCompCmds=Processing compile commands %s
|
||||||
MesonBuildConfiguration_ProcCompJson=Processing compile_commands.json
|
MesonBuildConfiguration_ProcCompJson=Processing compile_commands.json
|
||||||
MesonBuildConfiguration_NoToolchainFile=No toolchain file found for this target.
|
MesonBuildConfiguration_NoToolchainFile=No toolchain file found for this target.
|
||||||
MesonBuildConfiguration_RunningMesonFailure=Failure running meson: %s
|
MesonBuildConfiguration_RunningMesonFailure=Failure running meson: %s
|
||||||
MesonBuildConfiguration_RunningNinjaFailure=Failure running ninja: %s
|
MesonBuildConfiguration_RunningNinjaFailure=Failure running ninja: %s
|
||||||
|
MesonBuildConfiguration_NoNinjaFileToClean=No ninja.build file so clean has nothing to do
|
||||||
MesonBuildConfiguration_NoNinjaFile=Meson did not create a ninja.build file so build cannot complete
|
MesonBuildConfiguration_NoNinjaFile=Meson did not create a ninja.build file so build cannot complete
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,7 @@ public interface IMesonConstants {
|
||||||
|
|
||||||
public static final String MESON_ARGUMENTS = "meson.arguments"; //$NON-NLS-1$
|
public static final String MESON_ARGUMENTS = "meson.arguments"; //$NON-NLS-1$
|
||||||
public static final String MESON_ENV = "meson.environment"; //$NON-NLS-1$
|
public static final String MESON_ENV = "meson.environment"; //$NON-NLS-1$
|
||||||
|
public static final String MESON_PROJECT_OPTIONS = "meson.project.options"; //$NON-NLS-1$
|
||||||
public static final String NINJA_ENV = "meson.ninja.environment"; //$NON-NLS-1$
|
public static final String NINJA_ENV = "meson.ninja.environment"; //$NON-NLS-1$
|
||||||
public static final String NINJA_ARGUMENTS = "meson.ninja.arguments"; //$NON-NLS-1$
|
public static final String NINJA_ARGUMENTS = "meson.ninja.arguments"; //$NON-NLS-1$
|
||||||
public static final String MESON_ENV_SEPARATOR = "|"; //$NON-NLS-1$
|
public static final String MESON_ENV_SEPARATOR = "|"; //$NON-NLS-1$
|
||||||
|
|
|
@ -27,6 +27,7 @@ import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.CommandLauncherManager;
|
import org.eclipse.cdt.core.CommandLauncherManager;
|
||||||
import org.eclipse.cdt.core.ICommandLauncher;
|
import org.eclipse.cdt.core.ICommandLauncher;
|
||||||
import org.eclipse.cdt.core.build.CBuildConfiguration;
|
import org.eclipse.cdt.core.build.CBuildConfiguration;
|
||||||
|
import org.eclipse.cdt.core.build.ICBuildCommandLauncher;
|
||||||
import org.eclipse.cdt.core.build.ICBuildConfiguration;
|
import org.eclipse.cdt.core.build.ICBuildConfiguration;
|
||||||
import org.eclipse.cdt.core.resources.IConsole;
|
import org.eclipse.cdt.core.resources.IConsole;
|
||||||
import org.eclipse.cdt.meson.core.IMesonConstants;
|
import org.eclipse.cdt.meson.core.IMesonConstants;
|
||||||
|
@ -65,6 +66,7 @@ public class MesonPropertyPage extends PropertyPage {
|
||||||
private boolean configured;
|
private boolean configured;
|
||||||
private CBuildConfiguration buildConfig;
|
private CBuildConfiguration buildConfig;
|
||||||
private Text envText;
|
private Text envText;
|
||||||
|
private Text projText;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Control createContents(Composite parent) {
|
protected Control createContents(Composite parent) {
|
||||||
|
@ -84,7 +86,13 @@ public class MesonPropertyPage extends PropertyPage {
|
||||||
if (configured) {
|
if (configured) {
|
||||||
|
|
||||||
ICommandLauncher launcher = CommandLauncherManager.getInstance().getCommandLauncher(project.getActiveBuildConfig().getAdapter(ICBuildConfiguration.class));
|
ICommandLauncher launcher = CommandLauncherManager.getInstance().getCommandLauncher(project.getActiveBuildConfig().getAdapter(ICBuildConfiguration.class));
|
||||||
Process p = launcher.execute(new Path("meson"), new String[] { "configure", buildDir}, new String[0], sourceDir, new NullProgressMonitor());
|
launcher.setProject(project);
|
||||||
|
if (launcher instanceof ICBuildCommandLauncher) {
|
||||||
|
((ICBuildCommandLauncher)launcher).setBuildConfiguration(buildConfig);
|
||||||
|
}
|
||||||
|
Process p = launcher.execute(new Path("/bin/sh"), new String[] { "-c", "meson configure " + buildDir}, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||||
|
new String[0], sourceDir, new NullProgressMonitor());
|
||||||
|
if (p != null) {
|
||||||
ByteArrayOutputStream stdout = new ByteArrayOutputStream();
|
ByteArrayOutputStream stdout = new ByteArrayOutputStream();
|
||||||
ByteArrayOutputStream stderr = new ByteArrayOutputStream();
|
ByteArrayOutputStream stderr = new ByteArrayOutputStream();
|
||||||
int rc = -1;
|
int rc = -1;
|
||||||
|
@ -99,10 +107,18 @@ public class MesonPropertyPage extends PropertyPage {
|
||||||
if (rc == 0) {
|
if (rc == 0) {
|
||||||
componentList = parseConfigureOutput(stdout, composite);
|
componentList = parseConfigureOutput(stdout, composite);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
ICommandLauncher launcher = CommandLauncherManager.getInstance().getCommandLauncher(project.getActiveBuildConfig().getAdapter(ICBuildConfiguration.class));
|
ICommandLauncher launcher = CommandLauncherManager.getInstance().getCommandLauncher(project.getActiveBuildConfig().getAdapter(ICBuildConfiguration.class));
|
||||||
Process p = launcher.execute(new Path("meson"), new String[] { "-h"}, new String[0], sourceDir, new NullProgressMonitor());
|
launcher.setProject(project);
|
||||||
|
if (launcher instanceof ICBuildCommandLauncher) {
|
||||||
|
((ICBuildCommandLauncher)launcher).setBuildConfiguration(buildConfig);
|
||||||
|
}
|
||||||
|
Process p = launcher.execute(new Path("/bin/sh"), new String[] { "-c", "meson -h"}, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||||
|
new String[0], sourceDir, new NullProgressMonitor());
|
||||||
|
if (p == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
ByteArrayOutputStream stdout = new ByteArrayOutputStream();
|
ByteArrayOutputStream stdout = new ByteArrayOutputStream();
|
||||||
ByteArrayOutputStream stderr = new ByteArrayOutputStream();
|
ByteArrayOutputStream stderr = new ByteArrayOutputStream();
|
||||||
int rc = -1;
|
int rc = -1;
|
||||||
|
@ -118,13 +134,13 @@ public class MesonPropertyPage extends PropertyPage {
|
||||||
Map<String, String> argMap = new HashMap<>();
|
Map<String, String> argMap = new HashMap<>();
|
||||||
String mesonArgs = buildConfig.getProperty(IMesonConstants.MESON_ARGUMENTS);
|
String mesonArgs = buildConfig.getProperty(IMesonConstants.MESON_ARGUMENTS);
|
||||||
if (mesonArgs != null) {
|
if (mesonArgs != null) {
|
||||||
String[] argStrings = mesonArgs.split("\\s+");
|
String[] argStrings = mesonArgs.split("\\s+"); //$NON-NLS-1$
|
||||||
for (String argString : argStrings) {
|
for (String argString : argStrings) {
|
||||||
String[] s = argString.split("=");
|
String[] s = argString.split("="); //$NON-NLS-1$
|
||||||
if (s.length == 2) {
|
if (s.length == 2) {
|
||||||
argMap.put(s[0], s[1]);
|
argMap.put(s[0], s[1]);
|
||||||
} else {
|
} else {
|
||||||
argMap.put(argString, "true");
|
argMap.put(argString, "true"); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -135,7 +151,7 @@ public class MesonPropertyPage extends PropertyPage {
|
||||||
layout.marginRight = 10;
|
layout.marginRight = 10;
|
||||||
group.setLayout(layout);
|
group.setLayout(layout);
|
||||||
group.setLayoutData(new GridData(GridData.FILL_BOTH));
|
group.setLayoutData(new GridData(GridData.FILL_BOTH));
|
||||||
group.setText("Environment");
|
group.setText(Messages.MesonPropertyPage_env_group);
|
||||||
|
|
||||||
Label envLabel = new Label(group, SWT.NONE);
|
Label envLabel = new Label(group, SWT.NONE);
|
||||||
envLabel.setText(Messages.MesonPropertyPage_env_label);
|
envLabel.setText(Messages.MesonPropertyPage_env_label);
|
||||||
|
@ -157,6 +173,33 @@ public class MesonPropertyPage extends PropertyPage {
|
||||||
data.horizontalSpan = 1;
|
data.horizontalSpan = 1;
|
||||||
envText.setLayoutData(data);
|
envText.setLayoutData(data);
|
||||||
|
|
||||||
|
group = new Group(composite, SWT.BORDER);
|
||||||
|
layout = new GridLayout(2, true);
|
||||||
|
layout.marginLeft = 10;
|
||||||
|
layout.marginRight = 10;
|
||||||
|
group.setLayout(layout);
|
||||||
|
group.setLayoutData(new GridData(GridData.FILL_BOTH));
|
||||||
|
group.setText(Messages.MesonPropertyPage_project_group);
|
||||||
|
|
||||||
|
Label projLabel = new Label(group, SWT.NONE);
|
||||||
|
projLabel.setText(Messages.MesonPropertyPage_project_label);
|
||||||
|
data = new GridData(GridData.FILL, GridData.FILL, true, false);
|
||||||
|
data.grabExcessHorizontalSpace = true;
|
||||||
|
data.horizontalSpan = 1;
|
||||||
|
projLabel.setLayoutData(data);
|
||||||
|
|
||||||
|
String mesonProjOptions = buildConfig.getProperty(IMesonConstants.MESON_PROJECT_OPTIONS);
|
||||||
|
|
||||||
|
projText = new Text(group, SWT.BORDER);
|
||||||
|
if (mesonProjOptions != null) {
|
||||||
|
projText.setText(mesonProjOptions);
|
||||||
|
}
|
||||||
|
projText.setToolTipText(Messages.MesonPropertyPage_project_tooltip);
|
||||||
|
data = new GridData(GridData.FILL, GridData.FILL, true, false);
|
||||||
|
data.grabExcessHorizontalSpace = true;
|
||||||
|
data.horizontalSpan = 1;
|
||||||
|
projText.setLayoutData(data);
|
||||||
|
|
||||||
// default buildtype based on active build configuration
|
// default buildtype based on active build configuration
|
||||||
// user can always override and we will use override from then on
|
// user can always override and we will use override from then on
|
||||||
String defaultBuildType = "release"; //$NON-NLS-1$
|
String defaultBuildType = "release"; //$NON-NLS-1$
|
||||||
|
@ -195,13 +238,14 @@ public class MesonPropertyPage extends PropertyPage {
|
||||||
public boolean performOk() {
|
public boolean performOk() {
|
||||||
List<String> args = new ArrayList<>();
|
List<String> args = new ArrayList<>();
|
||||||
if (configured) {
|
if (configured) {
|
||||||
|
args.add("meson"); //$NON-NLS-1$
|
||||||
args.add("configure"); //$NON-NLS-1$
|
args.add("configure"); //$NON-NLS-1$
|
||||||
for (IMesonPropertyPageControl control : componentList) {
|
for (IMesonPropertyPageControl control : componentList) {
|
||||||
if (control.isValueChanged()) {
|
if (control.isValueChanged()) {
|
||||||
args.add(control.getConfiguredString()); //$NON-NLS-1$ //$NON-NLS-2$
|
args.add(control.getConfiguredString()); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (args.size() == 1) {
|
if (args.size() == 2) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
@ -209,8 +253,17 @@ public class MesonPropertyPage extends PropertyPage {
|
||||||
IPath sourceDir = project.getLocation();
|
IPath sourceDir = project.getLocation();
|
||||||
String buildDir = project.getLocation().append("build").append(configName).toOSString(); //$NON-NLS-1$
|
String buildDir = project.getLocation().append("build").append(configName).toOSString(); //$NON-NLS-1$
|
||||||
ICommandLauncher launcher = CommandLauncherManager.getInstance().getCommandLauncher(project.getActiveBuildConfig().getAdapter(ICBuildConfiguration.class));
|
ICommandLauncher launcher = CommandLauncherManager.getInstance().getCommandLauncher(project.getActiveBuildConfig().getAdapter(ICBuildConfiguration.class));
|
||||||
args.add(buildDir);
|
launcher.setProject(project);
|
||||||
Process p = launcher.execute(new Path("meson"), args.toArray(new String[0]), new String[0], sourceDir, new NullProgressMonitor());
|
if (launcher instanceof ICBuildCommandLauncher) {
|
||||||
|
((ICBuildCommandLauncher)launcher).setBuildConfiguration(buildConfig);
|
||||||
|
}
|
||||||
|
StringBuilder b = new StringBuilder();
|
||||||
|
for (String arg : args) {
|
||||||
|
b.append(arg);
|
||||||
|
b.append(" "); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
b.append(buildDir);
|
||||||
|
Process p = launcher.execute(new Path("/bin/sh"), new String[] { "-c", b.toString() }, new String[0], sourceDir, new NullProgressMonitor()); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
int rc = -1;
|
int rc = -1;
|
||||||
IConsole console = CCorePlugin.getDefault().getConsole();
|
IConsole console = CCorePlugin.getDefault().getConsole();
|
||||||
console.start(project);
|
console.start(project);
|
||||||
|
@ -258,6 +311,7 @@ public class MesonPropertyPage extends PropertyPage {
|
||||||
}
|
}
|
||||||
buildConfig.setProperty(IMesonConstants.MESON_ARGUMENTS, mesonargs.toString());
|
buildConfig.setProperty(IMesonConstants.MESON_ARGUMENTS, mesonargs.toString());
|
||||||
buildConfig.setProperty(IMesonConstants.MESON_ENV, envText.getText().trim());
|
buildConfig.setProperty(IMesonConstants.MESON_ENV, envText.getText().trim());
|
||||||
|
buildConfig.setProperty(IMesonConstants.MESON_PROJECT_OPTIONS, projText.getText().trim());
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,10 +23,17 @@ public class Messages extends NLS {
|
||||||
public static String MesonPropertyPage_configure_failed;
|
public static String MesonPropertyPage_configure_failed;
|
||||||
public static String MesonPropertyPage_terminated_rc;
|
public static String MesonPropertyPage_terminated_rc;
|
||||||
|
|
||||||
public static String MesonPropertyPage_options_group;
|
|
||||||
|
public static String MesonPropertyPage_env_group;
|
||||||
public static String MesonPropertyPage_env_tooltip;
|
public static String MesonPropertyPage_env_tooltip;
|
||||||
public static String MesonPropertyPage_env_label;
|
public static String MesonPropertyPage_env_label;
|
||||||
|
|
||||||
|
public static String MesonPropertyPage_project_group;
|
||||||
|
public static String MesonPropertyPage_project_tooltip;
|
||||||
|
public static String MesonPropertyPage_project_label;
|
||||||
|
|
||||||
|
public static String MesonPropertyPage_options_group;
|
||||||
|
|
||||||
public static String MesonPropertyPage_prefix_tooltip;
|
public static String MesonPropertyPage_prefix_tooltip;
|
||||||
public static String MesonPropertyPage_libdir_tooltip;
|
public static String MesonPropertyPage_libdir_tooltip;
|
||||||
public static String MesonPropertyPage_libexecdir_tooltip;
|
public static String MesonPropertyPage_libexecdir_tooltip;
|
||||||
|
|
|
@ -18,6 +18,10 @@ MesonPropertyPage_configure_failed=Meson configure command failed (see console o
|
||||||
MesonPropertyPage_terminated_rc=Command terminated with rc={0}\n
|
MesonPropertyPage_terminated_rc=Command terminated with rc={0}\n
|
||||||
|
|
||||||
MesonPropertyPage_options_group=Options
|
MesonPropertyPage_options_group=Options
|
||||||
|
MesonPropertyPage_project_group=Project
|
||||||
|
MesonPropertyPage_project_label=Options
|
||||||
|
MesonPropertyPage_project_tooltip=Use this for manually specifying one or more project options (-D option)
|
||||||
|
MesonPropertyPage_env_group=Environment
|
||||||
MesonPropertyPage_env_tooltip=Environment variables for initial meson call
|
MesonPropertyPage_env_tooltip=Environment variables for initial meson call
|
||||||
MesonPropertyPage_env_label=Environment
|
MesonPropertyPage_env_label=Environment
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue