Until now, the pkg-configuration (path to pkg-config binary, values of
PKG_CONFIG_PATH and PKG_CONFIG_LIBDIR) were set through global preferences.
This is unfortunately too limited for people doing cross-compilation, as they
may have different cross-compilation environments (for different platforms,
different projects), each having its own set of libraries, and its own
pkg-config binary and PKG_CONFIG_PATH/PKG_CONFIG_LIBDIR values.
Therefore, this patch moves the configuration of all pkg-config settings to
per-project preferences. The global pkg-config configuration UI is removed,
and a per-project pkg-config UI is added. This per-project UI is also slightly
improved compared to the original global UI:
* Only the library list is visible by default, all other options are hidden
behind an "Advanced" button
* The dialog box that opens when the "Advanced" button is clicked allows to
configure the path to the pkg-config binary, to enter a list of paths
containing .pc files, and to select whether those paths are to be added to
the default pkg-config search path (PKG_CONFIG_PATH) or replace the default
pkg-config search path (PKG_CONFIG_LIBDIR)
.../plugin.xml | 8 -
.../pkgconfig/preferences/Messages.java | 4 +
.../preferences/PkgConfigPathListEditor.java | 22 +-
.../preferences/PkgConfigSettingsDialog.java | 173 +++++++++++++++
.../pkgconfig/preferences/PreferencePage.java | 104 ---------
.../pkgconfig/preferences/PreferenceStore.java | 227 ++++++++------------
.../pkgconfig/preferences/messages.properties | 6 +-
.../pkgconfig/properties/DataModelProvider.java | 10 +-
.../pkgconfig/properties/PkgConfigPropertyTab.java | 214 +++++++++++-------
.../settings/PkgConfigExternalSettingProvider.java | 173 +++++++++------
.../pkgconfig/util/PkgConfigUtil.java | 149 ++++++++-----
11 files changed, 625 insertions(+), 465 deletions(-)
create mode 100644 org.eclipse.cdt.managedbuilder.pkgconfig/src/org/eclipse/cdt/managedbuilder/pkgconfig/preferences/PkgConfigSettingsDialog.java
delete mode 100644 org.eclipse.cdt.managedbuilder.pkgconfig/src/org/eclipse/cdt/managedbuilder/pkgconfig/preferences/PreferencePage.java
diff --git a/org.eclipse.cdt.managedbuilder.pkgconfig/plugin.xml b/org.eclipse.cdt.managedbuilder.pkgconfig/plugin.xml
index b1b58ef..85e1c23 100644
--- a/org.eclipse.cdt.managedbuilder.pkgconfig/plugin.xml
+++ b/org.eclipse.cdt.managedbuilder.pkgconfig/plugin.xml
@@ -8,14 +8,6 @@
</initializer>
</extension>
<extension
- point="org.eclipse.ui.preferencePages">
- <page
- class="org.eclipse.cdt.managedbuilder.pkgconfig.preferences.PreferencePage"
- id="org.eclipse.cdt.managedbuilder.pkgconfig.preferences.PreferencePage"
- name="%
page.name">
- </page>
- </extension>
- <extension
point="org.eclipse.cdt.ui.cPropertyTab">
<tab
class="org.eclipse.cdt.managedbuilder.pkgconfig.properties.PkgConfigPropertyTab"
diff --git a/org.eclipse.cdt.managedbuilder.pkgconfig/src/org/eclipse/cdt/managedbuilder/pkgconfig/preferences/Messages.java b/org.eclipse.cdt.managedbuilder.pkgconfig/src/org/eclipse/cdt/managedbuilder/pkgconfig/preferences/Messages.java
index 31986b9..91dc9f1 100644
--- a/org.eclipse.cdt.managedbuilder.pkgconfig/src/org/eclipse/cdt/managedbuilder/pkgconfig/preferences/Messages.java
+++ b/org.eclipse.cdt.managedbuilder.pkgconfig/src/org/eclipse/cdt/managedbuilder/pkgconfig/preferences/Messages.java
@@ -15,6 +15,10 @@ import org.eclipse.osgi.util.NLS;
public class Messages extends NLS {
private static final String BUNDLE_NAME = "org.eclipse.cdt.managedbuilder.pkgconfig.preferences.messages"; //$NON-NLS-1$
+ public static String PkgConfigSettingsDialog_0;
+ public static String PkgConfigSettingsDialog_1;
+ public static String PkgConfigSettingsDialog_2;
+ public static String PkgConfigPropertyTab_0;
public static String PkgConfigPathListEditor_0;
public static String PkgConfigPathListEditor_1;
public static String PreferencePage_0;
diff --git a/org.eclipse.cdt.managedbuilder.pkgconfig/src/org/eclipse/cdt/managedbuilder/pkgconfig/preferences/PkgConfigPathListEditor.java b/org.eclipse.cdt.managedbuilder.pkgconfig/src/org/eclipse/cdt/managedbuilder/pkgconfig/preferences/PkgConfigPathListEditor.java
index 5f31e37..f52fc1c 100644
--- a/org.eclipse.cdt.managedbuilder.pkgconfig/src/org/eclipse/cdt/managedbuilder/pkgconfig/preferences/PkgConfigPathListEditor.java
+++ b/org.eclipse.cdt.managedbuilder.pkgconfig/src/org/eclipse/cdt/managedbuilder/pkgconfig/preferences/PkgConfigPathListEditor.java
@@ -7,6 +7,7 @@
*
* Contributors:
* Petri Tuononen - Initial implementation
+ * Melanie Bats - Pkg-config variables can be set by project
*******************************************************************************/
package org.eclipse.cdt.managedbuilder.pkgconfig.preferences;
@@ -19,7 +20,6 @@ import org.eclipse.swt.widgets.Text;
/**
* New implementation of PkgConfigListEditor.
* Used to select PKG_CONFIG_PATH values from the dialog.
- *
*/
public class PkgConfigPathListEditor extends PkgConfigListEditor {
@@ -30,7 +30,7 @@ public class PkgConfigPathListEditor extends PkgConfigListEditor {
* @param labelText the label text of the field editor
* @param parent the parent of the field editor's control
*/
- PkgConfigPathListEditor(String name, String labelText, Composite parent) {
+ public PkgConfigPathListEditor(String name, String labelText, Composite parent) {
super(name, labelText, parent);
}
@@ -63,8 +63,6 @@ public class PkgConfigPathListEditor extends PkgConfigListEditor {
}
}
}
- //add a new PKG_CONFIG_PATH to the preference store
- PreferenceStore.appendPkgConfigPath(dir);
return dir;
}
return null;
@@ -79,11 +77,21 @@ public class PkgConfigPathListEditor extends PkgConfigListEditor {
setPresentsDefaultValue(false);
String[] selected = incList.getSelection();
for (String s : selected) {
- //remove PKG_CONFIG_PATH from the preference store
- PreferenceStore.removePkgConfigPath(s);
incList.remove(s);
selectionChanged();
}
}
-
+
+ /**
+ * Get the pkg config paths.
+ *
+ * @return Array of pkg-config paths
+ */
+ public String[] getPkgConfigPaths() {
+ return getList().getItems();
+ }
+
+ public void setData(String[] pkgConfigs) {
+ getList().setItems(pkgConfigs);
+ }
}
\ No newline at end of file
diff --git a/org.eclipse.cdt.managedbuilder.pkgconfig/src/org/eclipse/cdt/managedbuilder/pkgconfig/preferences/PkgConfigSettingsDialog.java b/org.eclipse.cdt.managedbuilder.pkgconfig/src/org/eclipse/cdt/managedbuilder/pkgconfig/preferences/PkgConfigSettingsDialog.java
new file mode 100644
index 0000000..cb1634f
--- /dev/null
+++ b/org.eclipse.cdt.managedbuilder.pkgconfig/src/org/eclipse/cdt/managedbuilder/pkgconfig/preferences/PkgConfigSettingsDialog.java
@@ -0,0 +1,173 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Melanie Bats and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ *
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Melanie Bats - Initial implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.managedbuilder.pkgconfig.preferences;
+
+import org.eclipse.cdt.ui.newui.AbstractPropertyDialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+
+public class PkgConfigSettingsDialog extends AbstractPropertyDialog {
+ private static final String UNSET_PKG_CONFIG = ""; //$NON-NLS-1$
+ private static final String PKG_CONFIG_PATH = Messages.PkgConfigSettingsDialog_0;
+ private static final String PKG_CONFIG_LIBDIR = Messages.PkgConfigSettingsDialog_1;
+
+ private Combo pkgConfigPathKindCombo;
+ private PkgConfigBinPathFieldEditor pkgconfigBinPathEditor;
+ private PkgConfigPathListEditor configPathListEditor;
+
+ private Button buttonOk;
+ private Button buttonCancel;
+
+ private String projectName;
+
+ public PkgConfigSettingsDialog(Shell _parent, String title,
+ String projectName) {
+ super(_parent, title);
+ this.projectName = projectName;
+ }
+
+ @Override
+ public void buttonPressed(SelectionEvent e) {
+ if (e.widget.equals(this.buttonOk)) {
+ String pkgConfigBinEditorValue = this.pkgconfigBinPathEditor
+ .getStringValue();
+ PreferenceStore.setPkgConfigBinPath(pkgConfigBinEditorValue,
+ this.projectName);
+
+ String pkgConfigPathKind = this.pkgConfigPathKindCombo.getText();
+
+ PreferenceStore.clearPkgConfigLibDir(this.projectName);
+ PreferenceStore.clearPkgConfigPath(this.projectName);
+ if (pkgConfigPathKind.length() != 0) {
+ for (String pkgConfigPath : this.configPathListEditor
+ .getPkgConfigPaths()) {
+ if (PKG_CONFIG_PATH.equals(pkgConfigPathKind)) {
+ PreferenceStore.setPkgConfigPath(pkgConfigPath,
+ this.projectName);
+ } else if (PKG_CONFIG_LIBDIR.equals(pkgConfigPathKind)) {
+ PreferenceStore.setPkgConfigLibDir(pkgConfigPath,
+ this.projectName);
+ }
+ }
+ }
+ }
+
+ this.shell.dispose();
+ }
+
+ @Override
+ protected Control createDialogArea(Composite parent) {
+ this.shell.setSize(700, 250);
+ GridLayout gridLayout = new GridLayout();
+ parent.setLayout(gridLayout);
+ Composite composite = new Composite(parent, SWT.None);
+ GridData layoutData = new GridData(GridData.FILL_BOTH);
+ composite.setLayoutData(layoutData);
+ composite.setLayout(new GridLayout(3, false));
+
+ this.pkgconfigBinPathEditor = new PkgConfigBinPathFieldEditor(
+ PreferenceConstants.PKG_CONFIG_BIN, Messages.PreferencePage_3,
+ composite);
+
+ this.pkgconfigBinPathEditor.setStringValue(PreferenceStore
+ .getPkgConfigBinPath(this.projectName));
+
+ Label comboLabel = new Label(composite, SWT.WRAP);
+ GridData comboLabelLayout = new GridData();
+ comboLabel.setLayoutData(comboLabelLayout);
+ comboLabel.setText(Messages.PkgConfigSettingsDialog_2);
+
+ this.pkgConfigPathKindCombo = new Combo(composite, SWT.BORDER
+ | SWT.READ_ONLY);
+ GridData comboLayout = new GridData();
+
+ this.pkgConfigPathKindCombo.setItems(new String[] { UNSET_PKG_CONFIG,
+ PKG_CONFIG_PATH, PKG_CONFIG_LIBDIR });
+ this.pkgConfigPathKindCombo.setLayoutData(comboLayout);
+
+ // Get pkg-config path and pkg-config libdir for the current project
+ String[] pkgConfigPath = PreferenceStore
+ .getPkgConfigPath(this.projectName);
+ String[] pkgConfigLibDir = PreferenceStore
+ .getPkgConfigLibDir(this.projectName);
+
+ Composite composite2 = new Composite(composite, SWT.None);
+ GridData layoutData2 = new GridData(GridData.FILL_BOTH);
+ layoutData2.horizontalAlignment = SWT.FILL;
+ layoutData2.horizontalSpan = 3;
+
+ composite2.setLayoutData(layoutData2);
+ composite2.setLayout(new GridLayout(2, false));
+ this.configPathListEditor = new PkgConfigPathListEditor(
+ PreferenceConstants.PKG_CONFIG_PATH, "", composite2); //$NON-NLS-1$
+
+ // Initialize combo to current value
+ if (pkgConfigLibDir != null) {
+ // Select lib dir
+ this.pkgConfigPathKindCombo.select(2);
+ this.configPathListEditor.setData(pkgConfigLibDir);
+ } else if (pkgConfigPath != null) {
+ // Select config path
+ this.pkgConfigPathKindCombo.select(1);
+ this.configPathListEditor.setData(pkgConfigPath);
+ } else {
+ // None
+ this.pkgConfigPathKindCombo.select(0);
+ this.pkgConfigPathKindCombo.setData(UNSET_PKG_CONFIG);
+ }
+
+ // Buttons
+ Composite compButtons = new Composite(composite, SWT.FILL);
+ GridData gd = new GridData(SWT.RIGHT, SWT.BOTTOM, true, false);
+ gd.horizontalSpan = 4;
+ // gd.grabExcessVerticalSpace = true;
+ compButtons.setLayoutData(gd);
+ compButtons.setLayout(new GridLayout(2, true));
+
+ // Button Cancel
+ this.buttonCancel = new Button(compButtons, SWT.PUSH);
+ this.buttonCancel.setText(IDialogConstants.CANCEL_LABEL);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ this.buttonCancel.setLayoutData(gd);
+ this.buttonCancel.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent event) {
+ buttonPressed(event);
+ }
+ });
+
+ // Button OK
+ this.buttonOk = new Button(compButtons, SWT.PUSH);
+ this.buttonOk.setText(IDialogConstants.OK_LABEL);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ this.buttonOk.setLayoutData(gd);
+ this.buttonOk.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent event) {
+ buttonPressed(event);
+ }
+ });
+
+ parent.getShell().setDefaultButton(this.buttonOk);
+ return parent;
+ }
+}
diff --git a/org.eclipse.cdt.managedbuilder.pkgconfig/src/org/eclipse/cdt/managedbuilder/pkgconfig/preferences/PreferencePage.java b/org.eclipse.cdt.managedbuilder.pkgconfig/src/org/eclipse/cdt/managedbuilder/pkgconfig/preferences/PreferencePage.java
deleted file mode 100644
index 7a2bb4e..0000000
--- a/org.eclipse.cdt.managedbuilder.pkgconfig/src/org/eclipse/cdt/managedbuilder/pkgconfig/preferences/PreferencePage.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 Petri Tuononen and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- *
http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Petri Tuononen - Initial implementation
- *******************************************************************************/
-package org.eclipse.cdt.managedbuilder.pkgconfig.preferences;
-
-import org.eclipse.cdt.managedbuilder.pkgconfig.Activator;
-import org.eclipse.jface.preference.FieldEditorPreferencePage;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchPreferencePage;
-
-/**
- * This class represents a preference page that
- * is contributed to the Preferences dialog.
- *
- * This page is used to modify preferences only. They
- * are stored in the preference store that belongs to
- * the main plug-in class.
- *
- */
-public class PreferencePage extends FieldEditorPreferencePage
-implements IWorkbenchPreferencePage {
-
- private PkgConfigBinPathFieldEditor pkgConfigBinEditor;
- private PkgConfigPathListEditor configPathListEditor;
- private LibDirFieldEditor libDirEditor;
-
- /**
- * Constructor.
- * Set preference page to use the pkg-config preference store.
- */
- public PreferencePage() {
- setPreferenceStore(Activator.getDefault().getPreferenceStore());
- setDescription(Messages.PreferencePage_0);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
- */
- @Override
- public void init(IWorkbench workbench) {
- //nothing here
- }
-
- @Override
- /**
- * Get Description name.
- *
- * @param String Description
- */
- public String getDescription() {
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.preference.IPreferencePage#performOk()
- */
- @Override
- public boolean performOk() {
- //create PKG_CONFIG_LIBDIR environment variable
- String libEditorValue = this.libDirEditor.getStringValue();
- PreferenceStore.setPkgConfigLibDir(libEditorValue);
-
- // create PKG_CONFIG_BIN environment variable
- String pkgConfigBinEditorValue = this.pkgConfigBinEditor
- .getStringValue();
- PreferenceStore.setPkgConfigBin(pkgConfigBinEditorValue);
-
- return true;
- }
-
- @Override
- protected void performApply() {
- performOk();
- }
-
- @Override
- /**
- * Creates field editors for the preference page.
- */
- protected void createFieldEditors() {
- // field PKG_CONFIG_BIN
- this.pkgConfigBinEditor = new PkgConfigBinPathFieldEditor(
- PreferenceConstants.PKG_CONFIG_BIN, Messages.PreferencePage_3,
- getFieldEditorParent());
- addField(this.pkgConfigBinEditor);
- //list editor for PKG_CONFIG_PATH values
- this.configPathListEditor = new PkgConfigPathListEditor(
- PreferenceConstants.PKG_CONFIG_PATH, Messages.PreferencePage_1,
- getFieldEditorParent());
- addField(this.configPathListEditor);
- //field PKG_CONFIG_LIBDIR
- this.libDirEditor = new LibDirFieldEditor(PreferenceConstants.PKG_CONFIG_LIBDIR,
- Messages.PreferencePage_2, getFieldEditorParent());
- addField(this.libDirEditor);
- }
-
-}
\ No newline at end of file
diff --git a/org.eclipse.cdt.managedbuilder.pkgconfig/src/org/eclipse/cdt/managedbuilder/pkgconfig/preferences/PreferenceStore.java b/org.eclipse.cdt.managedbuilder.pkgconfig/src/org/eclipse/cdt/managedbuilder/pkgconfig/preferences/PreferenceStore.java
index 3829e8b..542e735 100644
--- a/org.eclipse.cdt.managedbuilder.pkgconfig/src/org/eclipse/cdt/managedbuilder/pkgconfig/preferences/PreferenceStore.java
+++ b/org.eclipse.cdt.managedbuilder.pkgconfig/src/org/eclipse/cdt/managedbuilder/pkgconfig/preferences/PreferenceStore.java
@@ -12,7 +12,6 @@ package org.eclipse.cdt.managedbuilder.pkgconfig.preferences;
import org.eclipse.cdt.managedbuilder.pkgconfig.Activator;
import org.eclipse.cdt.managedbuilder.pkgconfig.util.ArrayUtil;
-import org.eclipse.cdt.managedbuilder.pkgconfig.util.Separators;
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.eclipse.core.runtime.preferences.InstanceScope;
@@ -23,6 +22,11 @@ import org.eclipse.core.runtime.preferences.InstanceScope;
*/
public class PreferenceStore {
+ private static final String PATH_SEPARATOR = ";"; //$NON-NLS-1$
+ private static final String PKG_CONFIG_BIN = "PKG_CONFIG_BIN"; //$NON-NLS-1$
+ private static final String PKG_CONFIG_LIBDIR = "PKG_CONFIG_LIBDIR"; //$NON-NLS-1$
+ private static final String PKG_CONFIG_PATH = "PKG_CONFIG_PATH"; //$NON-NLS-1$
+
/**
* Get the Pkg-config preference store.
*
@@ -52,15 +56,26 @@ public class PreferenceStore {
public static void setPreferenceStoreValue(String name, String value) {
getPreferenceStore().put(name, value);
}
-
+
+ /**
+ * Clear preference store value.
+ *
+ * @param name
+ * the name of the preference
+ */
+ public static void clearPreferenceStoreValue(String name) {
+ getPreferenceStore().put(name, ""); //$NON-NLS-1$
+ }
+
/**
* Set pkg-config bin to the preference store.
*
* @param path
* The pkg-config bin.
+ * @param project
*/
- public static void setPkgConfigBin(String path) {
- setPreferenceStoreValue(PreferenceConstants.PKG_CONFIG_BIN, path);
+ public static void setPkgConfigBinPath(String path, String project) {
+ setPreferenceStoreValue(getPkgConfigBinKey(project), path);
}
/**
@@ -68,8 +83,8 @@ public class PreferenceStore {
*
* @return pkg-config bin path.
*/
- public static String getPkgConfigBinPath() {
- return getPreferenceStoreValue(PreferenceConstants.PKG_CONFIG_BIN);
+ public static String getPkgConfigBinPath(String project) {
+ return getPreferenceStoreValue(getPkgConfigBinKey(project));
}
/**
@@ -77,177 +92,121 @@ public class PreferenceStore {
*
* @return pkg-config path.
*/
- public static String getPkgConfigPath() {
- return getPreferenceStoreValue(PreferenceConstants.PKG_CONFIG_PATH);
+ public static String[] getPkgConfigPath(String project) {
+ String pkgConfigPathStringValue = getPreferenceStoreValue(getPkgConfigPathKey(project));
+ if (pkgConfigPathStringValue.length() == 0)
+ return null;
+ return pkgConfigPathStringValue.split(PATH_SEPARATOR);
}
/**
* Set pkg-config path to the preference store.
*
- * @param path The pkg-config path.
+ * @param path The pkg-config path
+ * @param project The project name
*/
- public static void setPkgConfigPath(String path) {
- setPreferenceStoreValue(PreferenceConstants.PKG_CONFIG_PATH, path);
+ public static void setPkgConfigPath(String path, String project) {
+ String pkgConfigPath = getPreferenceStoreValue(getPkgConfigPathKey(project));
+ if (pkgConfigPath.length() != 0) {
+ pkgConfigPath += PATH_SEPARATOR;
+ }
+ setPreferenceStoreValue(getPkgConfigPathKey(project), pkgConfigPath
+ + path);
}
-
+
/**
* Get pkg-config libdir from the preference store.
*
* @return pkg-config libdir.
*/
- public static String getPkgConfigLibDir() {
- return getPreferenceStoreValue(PreferenceConstants.PKG_CONFIG_LIBDIR);
+ public static String[] getPkgConfigLibDir(String project) {
+ String pkgConfigLibDirStringValue = getPreferenceStoreValue(getPkgConfigLibDirKey(project));
+ if (pkgConfigLibDirStringValue.length() == 0)
+ return null;
+ return pkgConfigLibDirStringValue.split(PATH_SEPARATOR);
}
/**
* Set pkg-config libdir to the preference store.
*
- * @param path The pkg-config libdir.
+ * @param path The pkg-config libdir
+ * @param project The project name
*/
- public static void setPkgConfigLibDir(String path) {
- setPreferenceStoreValue(PreferenceConstants.PKG_CONFIG_LIBDIR, path);
+ public static void setPkgConfigLibDir(String path, String project) {
+ String pkgConfigPath = getPreferenceStoreValue(getPkgConfigLibDirKey(project));
+ if (pkgConfigPath.length() != 0) {
+ pkgConfigPath += PATH_SEPARATOR;
+ }
+ setPreferenceStoreValue(getPkgConfigLibDirKey(project), pkgConfigPath
+ + path);
}
-
+
/**
- * Get values from the preference store as a String array.
- * Used to get preference store values which consist of multiple paths
- * separated by a path separator.
+ * Clear pkg-config path to the preference store.
*
- * @param name the name of the preference
- * @return A String array containing all preference store values
+ * @param project
+ * The project name
*/
- public static String[] getPreferenceStoreValueAsArray(String name) {
- return ArrayUtil.stringToArray(name);
+ public static void clearPkgConfigPath(String project) {
+ clearPreferenceStoreValue(getPkgConfigPathKey(project));
}
/**
- * Get existing paths from the Preference store.
+ * Clear pkg-config libdir path to the preference store.
*
- * @param name the name of the preference
- * @return paths
+ * @param project
+ * The project name
*/
- private static String getExistingValues(String name) {
- String paths = ""; //$NON-NLS-1$
- if (name.equals(PreferenceConstants.PKG_CONFIG_PATH)) {
- paths = getPkgConfigPath();
- } else if (name.equals(PreferenceConstants.PKG_CONFIG_LIBDIR)) {
- paths = getPkgConfigLibDir();
- }
- return paths;
+ public static void clearPkgConfigLibDir(String project) {
+ clearPreferenceStoreValue(getPkgConfigLibDirKey(project));
}
/**
- * Append a new value to the Preference store if it doesn't already exists.
+ * Get values from the preference store as a String array. Used to get
+ * preference store values which consist of multiple paths separated by a
+ * path separator.
*
- * @param name the name of the preference
- * @param value the string-valued preference
+ * @param name
+ * the name of the preference
+ * @return A String array containing all preference store values
*/
- public static void appendValue(String name, String value) {
- StringBuffer sB = new StringBuffer();
- String paths = null;
- //get existing paths
- paths = getExistingValues(name);
- //if values exist
- if (paths.length()!=0) {
- //if the value is reasonable
- if (!value.equalsIgnoreCase("") && value.length()!=0) { //$NON-NLS-1$
- //if the paths doesn't contain the new value
- if (!paths.contains(value)) {
- //append existing paths to the string buffer
- sB.append(paths);
- //add a path separator in the end if it doesn't exists
- if (paths.charAt(paths.length()-1) != Separators.getPathSeparator().charAt(0)) {
- sB.append(Separators.getPathSeparator());
- }
- //append the new value to end of the list
- sB.append(value);
- }
- }
- } else { //no existing values
- //if the value is reasonable
- if (!value.equalsIgnoreCase("") && value.length()!=0) { //$NON-NLS-1$
- //append a new path to the string buffer
- sB.append(value);
- }
- }
- String newValues = sB.toString();
- if (newValues.length()!=0) {
- //set the new preference store value
- setPreferenceStoreValue(name, newValues);
- }
+ public static String[] getPreferenceStoreValueAsArray(String name) {
+ return ArrayUtil.stringToArray(name);
}
/**
- * Append pkg-config path to the preference store.
- *
- * @param path The pkg-config path.
- */
- public static void appendPkgConfigPath(String path) {
- appendValue(PreferenceConstants.PKG_CONFIG_PATH, path);
- }
-
- /**
- * Remove a value from the preference store.
- *
- * @param name Name of the preference
- * @param value Value to be removed from the preference store
- */
- public static void removeValue(String name, String value) {
- StringBuffer sB = new StringBuffer();
- String existingValues = null;
- String newValue = null;
- //get existing values
- existingValues = getExistingValues(name);
- //if the String contains the value
- if (existingValues.contains(value)) {
- //if many values i.e. contains path separator
- if (existingValues.contains(Separators.getPathSeparator())) {
- //separate String of values to an array
- String[] exValArray = existingValues.split(Separators.getPathSeparator());
- //if more than one value
- if (exValArray.length > 1) {
- //remove the value from the array
- exValArray = ArrayUtil.removePathFromExistingPathList(exValArray, value);
- //if the array isn't empty
- if (exValArray.length > 0) {
- //append all values to the StringBuffer excluding the removed one
- for (String val : exValArray) {
- //append a value
- sB.append(val);
- //append a path separator
- sB.append(Separators.getPathSeparator());
- }
- //form a String
- newValue = sB.toString();
- }
- } else { //only one value with a path separator at the end
- newValue = ""; //$NON-NLS-1$
- }
-
- } else { //only value without a path separator at the end
- newValue = ""; //$NON-NLS-1$
- }
- //set the new preference store value
- setPreferenceStoreValue(name, newValue);
- }
+ * Compute the key for the given pkg-config binary and the given project.
+ *
+ * @param project
+ * Project name
+ * @return Key
+ */
+ private static String getPkgConfigBinKey(String project) {
+ return PKG_CONFIG_BIN + " - " //$NON-NLS-1$
+ + project;
}
/**
- * Remove pkg-config path from the preference store.
+ * Compute the key for the given pkg-config lib dir and the given project.
*
- * @param path The include path to be removed from the preference store.
+ * @param project
+ * Project name
+ * @return Key
*/
- public static void removePkgConfigPath(String path) {
- removeValue(PreferenceConstants.PKG_CONFIG_PATH, path);
+ private static String getPkgConfigLibDirKey(String project) {
+ return PKG_CONFIG_LIBDIR + " - " //$NON-NLS-1$
+ + project;
}
-
+
/**
- * Remove pkg-config libdir from the preference store.
+ * Compute the key for the given pkg-config path and the given project.
*
- * @param path The pkg-config libdir to be removed from the preference store.
+ * @param project
+ * Project name
+ * @return Key
*/
- public static void removeLibraryPath(String path) {
- removeValue(PreferenceConstants.PKG_CONFIG_LIBDIR, path);
+ private static String getPkgConfigPathKey(String project) {
+ return PKG_CONFIG_PATH + " - " //$NON-NLS-1$
+ + project;
}
-
}
\ No newline at end of file
diff --git a/org.eclipse.cdt.managedbuilder.pkgconfig/src/org/eclipse/cdt/managedbuilder/pkgconfig/preferences/messages.properties b/org.eclipse.cdt.managedbuilder.pkgconfig/src/org/eclipse/cdt/managedbuilder/pkgconfig/preferences/messages.properties
index cee06c7..064627e 100644
--- a/org.eclipse.cdt.managedbuilder.pkgconfig/src/org/eclipse/cdt/managedbuilder/pkgconfig/preferences/messages.properties
+++ b/org.eclipse.cdt.managedbuilder.pkgconfig/src/org/eclipse/cdt/managedbuilder/pkgconfig/preferences/messages.properties
@@ -3,4 +3,8 @@ PreferencePage_1=PKG_CONFIG_PATH:
PreferencePage_2=PKG_CONFIG_LIBDIR (replaces default):
PreferencePage_3=Path to pkg-config executable:
PkgConfigPathListEditor_0=Browse a directory path
-PkgConfigPathListEditor_1=Select a directory
\ No newline at end of file
+PkgConfigPathListEditor_1=Select a directory
+PkgConfigPropertyTab_0=Pkg-config project settings
+PkgConfigSettingsDialog_0=Append to (PKG_CONFIG_PATH)
+PkgConfigSettingsDialog_1=Replace (PKG_CONFIG_LIBDIR)
+PkgConfigSettingsDialog_2=Adjust the default pkg-config search path :
\ No newline at end of file
diff --git a/org.eclipse.cdt.managedbuilder.pkgconfig/src/org/eclipse/cdt/managedbuilder/pkgconfig/properties/DataModelProvider.java b/org.eclipse.cdt.managedbuilder.pkgconfig/src/org/eclipse/cdt/managedbuilder/pkgconfig/properties/DataModelProvider.java
index 0ffe7bf..55635f9 100644
--- a/org.eclipse.cdt.managedbuilder.pkgconfig/src/org/eclipse/cdt/managedbuilder/pkgconfig/properties/DataModelProvider.java
+++ b/org.eclipse.cdt.managedbuilder.pkgconfig/src/org/eclipse/cdt/managedbuilder/pkgconfig/properties/DataModelProvider.java
@@ -19,18 +19,18 @@ import java.util.List;
import org.eclipse.cdt.managedbuilder.pkgconfig.util.Parser;
import org.eclipse.cdt.managedbuilder.pkgconfig.util.PkgConfigUtil;
-public enum DataModelProvider {
- INSTANCE;
+public class DataModelProvider {
- private List<DataModel> dms;
+ List<DataModel> dms;
/**
* Initialize.
+ * @param project Project
*/
- private DataModelProvider() {
+ DataModelProvider(String project) {
this.dms = new ArrayList<DataModel>();
- List<String> packages = PkgConfigUtil.getAllPackages();
+ List<String> packages = PkgConfigUtil.getAllPackages(project);
List<String> pkgList = Parser.parsePackageList(packages);
List<String> nonSortedPkgList = Parser.parsePackageList(packages);
HashMap<Integer, Integer> origSortedIdx = new HashMap<Integer, Integer>();
diff --git a/org.eclipse.cdt.managedbuilder.pkgconfig/src/org/eclipse/cdt/managedbuilder/pkgconfig/properties/PkgConfigPropertyTab.java b/org.eclipse.cdt.managedbuilder.pkgconfig/src/org/eclipse/cdt/managedbuilder/pkgconfig/properties/PkgConfigPropertyTab.java
index 4c69057..ed91846 100644
--- a/org.eclipse.cdt.managedbuilder.pkgconfig/src/org/eclipse/cdt/managedbuilder/pkgconfig/properties/PkgConfigPropertyTab.java
+++ b/org.eclipse.cdt.managedbuilder.pkgconfig/src/org/eclipse/cdt/managedbuilder/pkgconfig/properties/PkgConfigPropertyTab.java
@@ -25,6 +25,11 @@ import org.eclipse.cdt.core.settings.model.ICResourceDescription;
import org.eclipse.cdt.core.settings.model.ICStorageElement;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.pkgconfig.Activator;
+import org.eclipse.cdt.managedbuilder.pkgconfig.preferences.LibDirFieldEditor;
+import org.eclipse.cdt.managedbuilder.pkgconfig.preferences.Messages;
+import org.eclipse.cdt.managedbuilder.pkgconfig.preferences.PkgConfigBinPathFieldEditor;
+import org.eclipse.cdt.managedbuilder.pkgconfig.preferences.PkgConfigPathListEditor;
+import org.eclipse.cdt.managedbuilder.pkgconfig.preferences.PkgConfigSettingsDialog;
import org.eclipse.cdt.managedbuilder.pkgconfig.settings.PkgConfigExternalSettingProvider;
import org.eclipse.cdt.managedbuilder.pkgconfig.util.Parser;
import org.eclipse.cdt.managedbuilder.pkgconfig.util.PathToToolOption;
@@ -55,29 +60,37 @@ import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.TableItem;
/**
- * Property tab to select packages and add pkg-config output
- * of checked packages to compiler and linker (MBS).
+ * Property tab to select packages and add pkg-config output of checked packages
+ * to compiler and linker (MBS).
*
*/
public class PkgConfigPropertyTab extends AbstractCPropertyTab {
- private CheckboxTableViewer pkgCfgViewer;
+ PkgConfigBinPathFieldEditor pkgConfigBinPathFieldEditor;
+ PkgConfigPathListEditor configPathListEditor;
+ LibDirFieldEditor libDirEditor;
+ CheckboxTableViewer pkgCfgViewer;
private Set<Object> previouslyChecked;
private ArrayList<Object> newItems = new ArrayList<Object>();
private static final int BUTTON_SELECT = 0;
private static final int BUTTON_DESELECT = 1;
+ private static final int BUTTON_ADVANCED = 2;
private final String PACKAGES = "packages"; //$NON-NLS-1$
private boolean reindexToggle = false;
private SashForm sashForm;
- private static final String[] BUTTONS = new String[] {
- "Select", //$NON-NLS-1$
- "Deselect" //$NON-NLS-1$
+ private static final String[] BUTTONS = new String[] { "Select", //$NON-NLS-1$
+ "Deselect", //$NON-NLS-1$
+ "Advanced..." //$NON-NLS-1$
};
- /* (non-Javadoc)
- * @see org.eclipse.cdt.ui.newui.AbstractCPropertyTab#createControls(org.eclipse.swt.widgets.Composite)
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.cdt.ui.newui.AbstractCPropertyTab#createControls(org.eclipse
+ * .swt.widgets.Composite)
*/
@Override
public void createControls(Composite parent) {
@@ -85,19 +98,21 @@ public class PkgConfigPropertyTab extends AbstractCPropertyTab {
this.usercomp.setLayout(new GridLayout(1, false));
this.sashForm = new SashForm(this.usercomp, SWT.NONE);
- this.sashForm.setBackground(this.sashForm.getDisplay().getSystemColor(SWT.COLOR_GRAY));
+ this.sashForm.setBackground(this.sashForm.getDisplay().getSystemColor(
+ SWT.COLOR_GRAY));
this.sashForm.setLayoutData(new GridData(GridData.FILL_BOTH));
GridLayout layout = new GridLayout(1, false);
layout.marginHeight = 5;
this.sashForm.setLayout(layout);
- Composite c1 = new Composite(this.sashForm, SWT.NONE);
+ final Composite c1 = new Composite(this.sashForm, SWT.NONE);
GridLayout layout2 = new GridLayout(3, false);
c1.setLayout(layout2);
- this.pkgCfgViewer = CheckboxTableViewer.newCheckList(c1, SWT.MULTI | SWT.H_SCROLL
- | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);
+ this.pkgCfgViewer = CheckboxTableViewer
+ .newCheckList(c1, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL
+ | SWT.FULL_SELECTION | SWT.BORDER);
final Table tbl = this.pkgCfgViewer.getTable();
tbl.setHeaderVisible(true);
tbl.setLinesVisible(true);
@@ -108,7 +123,8 @@ public class PkgConfigPropertyTab extends AbstractCPropertyTab {
createColumns(c1, this.pkgCfgViewer);
this.pkgCfgViewer.setContentProvider(new ArrayContentProvider());
- this.pkgCfgViewer.setInput(DataModelProvider.INSTANCE.getEntries());
+ this.pkgCfgViewer.setInput(new DataModelProvider(this.page.getProject()
+ .getName()).getEntries());
this.pkgCfgViewer.addCheckStateListener(new PkgListener());
@@ -125,16 +141,18 @@ public class PkgConfigPropertyTab extends AbstractCPropertyTab {
}
});
- //buttons
+ // buttons
Composite compositeButtons = new Composite(c1, SWT.NONE);
initButtons(compositeButtons, BUTTONS);
initializePackageStates();
- this.previouslyChecked = new HashSet<Object>(Arrays.asList(getCheckedItems()));
+ this.previouslyChecked = new HashSet<Object>(
+ Arrays.asList(getCheckedItems()));
}
/**
* Get checked items.
+ *
* @return
*/
private Object[] getCheckedItems() {
@@ -147,11 +165,11 @@ public class PkgConfigPropertyTab extends AbstractCPropertyTab {
void handleCheckStateChange() {
Object[] checkedItems = getCheckedItems();
- //check if new items checked
- if(checkedItems.length > this.previouslyChecked.size()) {
- //add checked items to an array list
+ // check if new items checked
+ if (checkedItems.length > this.previouslyChecked.size()) {
+ // add checked items to an array list
for (Object o : checkedItems) {
- //if new item
+ // if new item
if (!this.previouslyChecked.contains(o)) {
this.newItems.add(o);
}
@@ -162,23 +180,27 @@ public class PkgConfigPropertyTab extends AbstractCPropertyTab {
saveChecked();
updateData(getResDesc());
- this.previouslyChecked = new HashSet<Object>(Arrays.asList(checkedItems));
+ this.previouslyChecked = new HashSet<Object>(
+ Arrays.asList(checkedItems));
this.newItems.clear();
}
/**
- * Add new flags that the packages need to Tools' Options.
- * Only for other flags.
+ * Add new flags that the packages need to Tools' Options. Only for other
+ * flags.
*
- * @param addedItems Object[]
- * @param proj IProject
+ * @param addedItems
+ * Object[]
+ * @param proj
+ * IProject
*/
private static void addPackageValues(Object[] addedItems, IProject proj) {
for (Object item : addedItems) {
- //handle options
- String cflags = PkgConfigUtil.getCflags(item.toString());
+ // handle options
+ String cflags = PkgConfigUtil.getCflags(
+ item.toString(), proj.getName());
String[] optionsArray = Parser.parseCflagOptions(cflags);
- if (optionsArray!=null) {
+ if (optionsArray != null) {
for (String option : optionsArray) {
PathToToolOption.addOtherFlag(option, proj);
}
@@ -197,10 +219,10 @@ public class PkgConfigPropertyTab extends AbstractCPropertyTab {
strgElem = desc.getStorage(this.PACKAGES, true);
TableItem[] items = this.pkgCfgViewer.getTable().getItems();
String value = null;
- for(TableItem item : items) {
+ for (TableItem item : items) {
/*
- * The package names with + symbols were converted so that
- * + -> plus in order to prevent an error when saving to
+ * The package names with + symbols were converted so that + ->
+ * plus in order to prevent an error when saving to
* ICStorageElement.
*/
if (item.getText().contains("+")) { //$NON-NLS-1$
@@ -209,8 +231,8 @@ public class PkgConfigPropertyTab extends AbstractCPropertyTab {
} else {
value = strgElem.getAttribute(item.getText());
}
- if(value!=null) {
- if(value.equals("true")) { //$NON-NLS-1$
+ if (value != null) {
+ if (value.equals("true")) { //$NON-NLS-1$
item.setChecked(true);
}
}
@@ -223,48 +245,49 @@ public class PkgConfigPropertyTab extends AbstractCPropertyTab {
/**
* Saves checked state of the packages.
*/
- private void saveChecked() {
+ private void saveChecked() {
ICConfigurationDescription desc = getResDesc().getConfiguration();
ICStorageElement strgElem = null;
- //get storage or create one if it doesn't exist
+ // get storage or create one if it doesn't exist
try {
strgElem = desc.getStorage(this.PACKAGES, true);
} catch (CoreException e) {
- Activator.getDefault().log(e, "Getting packages from the storage failed."); //$NON-NLS-1$
+ Activator.getDefault().log(e,
+ "Getting packages from the storage failed."); //$NON-NLS-1$
}
TableItem[] items = this.pkgCfgViewer.getTable().getItems();
- for(TableItem item : items) {
- if(item != null) {
+ for (TableItem item : items) {
+ if (item != null) {
String chkd;
- //form literal form of boolean state
- if(item.getChecked()) {
+ // form literal form of boolean state
+ if (item.getChecked()) {
chkd = "true"; //$NON-NLS-1$
} else {
chkd = "false"; //$NON-NLS-1$
}
/*
- * add package name and the checkbox state
- * to the storage
+ * add package name and the checkbox state to the storage
*/
- try {
+ try {
String pkgName = item.getText();
- //need to convert + symbols to "plus"
+ // need to convert + symbols to "plus"
if (pkgName.contains("+")) { //$NON-NLS-1$
String newPkgName = pkgName.replace("+", "plus"); //$NON-NLS-1$ //$NON-NLS-2$
- if (strgElem!=null) {
+ if (strgElem != null) {
strgElem.setAttribute(newPkgName, chkd);
}
} else {
- if (strgElem!=null) {
+ if (strgElem != null) {
strgElem.setAttribute(pkgName, chkd);
}
}
} catch (Exception e) {
- Activator.getDefault().log(e, "Setting attribute to ICStorageElement failed."); //$NON-NLS-1$
- //Seems like ICStorageElement cannot store Strings with +
+ Activator.getDefault().log(e,
+ "Setting attribute to ICStorageElement failed."); //$NON-NLS-1$
+ // Seems like ICStorageElement cannot store Strings with +
/*
- * INVALID_CHARACTER_ERR: An invalid or
- * illegal XML character is specified.
+ * INVALID_CHARACTER_ERR: An invalid or illegal XML
+ * character is specified.
*/
}
}
@@ -279,16 +302,16 @@ public class PkgConfigPropertyTab extends AbstractCPropertyTab {
@Override
protected void performDefaults() {
- //uncheck every checkbox
+ // uncheck every checkbox
this.pkgCfgViewer.setCheckedElements(new Object[] {});
- //remove values from Tools Options
+ // remove values from Tools Options
handleCheckStateChange();
}
@Override
protected void performOK() {
- //freshen index if new packages have been selected
+ // freshen index if new packages have been selected
if (this.reindexToggle) {
rebuiltIndex();
}
@@ -297,7 +320,7 @@ public class PkgConfigPropertyTab extends AbstractCPropertyTab {
@Override
protected void updateButtons() {
- //nothing here
+ // nothing here
}
@Override
@@ -308,22 +331,24 @@ public class PkgConfigPropertyTab extends AbstractCPropertyTab {
Job j = new Job("Update Pkg-config exernal settings provider") { //$NON-NLS-1$
@Override
protected IStatus run(IProgressMonitor monitor) {
- //a set holding external setting providers
- Set<String> externalSettingsProviders = new
- LinkedHashSet<String>(Arrays.asList(confDesc.getExternalSettingsProviderIds()));
-
- //remove pkg-config external setting provider
- externalSettingsProviders.remove(PkgConfigExternalSettingProvider.ID);
- confDesc.setExternalSettingsProviderIds(externalSettingsProviders.toArray(new
- String[externalSettingsProviders.size()]));
-
- //add pkg-config external setting provider
- externalSettingsProviders.add(PkgConfigExternalSettingProvider.ID);
- confDesc.setExternalSettingsProviderIds(externalSettingsProviders.toArray(new
- String[externalSettingsProviders.size()]));
-
- //update external setting providers
- confDesc.updateExternalSettingsProviders(new String[] {PkgConfigExternalSettingProvider.ID});
+ // a set holding external setting providers
+ Set<String> externalSettingsProviders = new LinkedHashSet<String>(
+ Arrays.asList(confDesc.getExternalSettingsProviderIds()));
+
+ // remove pkg-config external setting provider
+ externalSettingsProviders
+ .remove(PkgConfigExternalSettingProvider.ID);
+ confDesc.setExternalSettingsProviderIds(externalSettingsProviders
+ .toArray(new String[externalSettingsProviders.size()]));
+
+ // add pkg-config external setting provider
+ externalSettingsProviders
+ .add(PkgConfigExternalSettingProvider.ID);
+ confDesc.setExternalSettingsProviderIds(externalSettingsProviders
+ .toArray(new String[externalSettingsProviders.size()]));
+
+ // update external setting providers
+ confDesc.updateExternalSettingsProviders(new String[] { PkgConfigExternalSettingProvider.ID });
return Status.OK_STATUS;
}
};
@@ -331,15 +356,17 @@ public class PkgConfigPropertyTab extends AbstractCPropertyTab {
j.schedule();
try {
- CoreModel.getDefault().setProjectDescription(this.page.getProject(), projDesc);
+ CoreModel.getDefault().setProjectDescription(
+ this.page.getProject(), projDesc);
} catch (CoreException e) {
- Activator.getDefault().log(e, "Setting/updating the project description failed."); //$NON-NLS-1$
+ Activator.getDefault().log(e,
+ "Setting/updating the project description failed."); //$NON-NLS-1$
}
}
/**
* Check state listener for the table viewer.
- *
+ *
*/
public class PkgListener implements ICheckStateListener {
@@ -355,12 +382,13 @@ public class PkgConfigPropertyTab extends AbstractCPropertyTab {
* @param parent
* @param viewer
*/
- private void createColumns(@SuppressWarnings("unused") final Composite parent,
+ private void createColumns(
+ @SuppressWarnings("unused") final Composite parent,
@SuppressWarnings("unused") final TableViewer viewer) {
String[] titles = { "Packages", "Description" }; //$NON-NLS-1$ //$NON-NLS-2$
int[] bounds = { 200, 450 };
- //first column is for the package
+ // first column is for the package
TableViewerColumn col = createTableViewerColumn(titles[0], bounds[0]);
col.setLabelProvider(new ColumnLabelProvider() {
@Override
@@ -370,7 +398,7 @@ public class PkgConfigPropertyTab extends AbstractCPropertyTab {
}
});
- //second column is for the description
+ // second column is for the description
col = createTableViewerColumn(titles[1], bounds[1]);
col.setLabelProvider(new ColumnLabelProvider() {
@Override
@@ -378,7 +406,7 @@ public class PkgConfigPropertyTab extends AbstractCPropertyTab {
DataModel dm = (DataModel) element;
return dm.getDescription();
}
- });
+ });
}
/**
@@ -390,8 +418,8 @@ public class PkgConfigPropertyTab extends AbstractCPropertyTab {
*/
private TableViewerColumn createTableViewerColumn(String title, int bound) {
- final TableViewerColumn viewerColumn = new TableViewerColumn(this.pkgCfgViewer,
- SWT.NONE);
+ final TableViewerColumn viewerColumn = new TableViewerColumn(
+ this.pkgCfgViewer, SWT.NONE);
final TableColumn column = viewerColumn.getColumn();
column.setText(title);
@@ -411,11 +439,13 @@ public class PkgConfigPropertyTab extends AbstractCPropertyTab {
return selected;
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.eclipse.cdt.ui.newui.AbstractCPropertyTab#buttonPressed(int)
*/
@Override
- public void buttonPressed (int n) {
+ public void buttonPressed(int n) {
switch (n) {
case BUTTON_SELECT:
selectedButtonPressed();
@@ -423,6 +453,9 @@ public class PkgConfigPropertyTab extends AbstractCPropertyTab {
case BUTTON_DESELECT:
deselectedButtonPressed();
break;
+ case BUTTON_ADVANCED:
+ advancedButtonPressed();
+ break;
default:
break;
}
@@ -452,10 +485,29 @@ public class PkgConfigPropertyTab extends AbstractCPropertyTab {
}
/**
+ * Action for the Select button.
+ */
+ private void advancedButtonPressed() {
+ // Create new dialog
+ PkgConfigSettingsDialog dialog = new PkgConfigSettingsDialog(
+ this.usercomp.getShell(), Messages.PkgConfigPropertyTab_0,
+ this.page.getProject().getName());
+ dialog.open();
+ if (PkgConfigPropertyTab.this.pkgCfgViewer != null) {
+ // Update pkg-config libraries for the project
+ PkgConfigPropertyTab.this.pkgCfgViewer
+ .setInput(new DataModelProvider(
+ PkgConfigPropertyTab.this.page.getProject()
+ .getName()).getEntries());
+ }
+ }
+
+ /**
* Rebuilts the index of the selected project in the workspace.
*/
private void rebuiltIndex() {
- ICProject cproject = CoreModel.getDefault().getCModel().getCProject(this.page.getProject().getName());
+ ICProject cproject = CoreModel.getDefault().getCModel()
+ .getCProject(this.page.getProject().getName());
CCorePlugin.getIndexManager().reindex(cproject);
}
diff --git a/org.eclipse.cdt.managedbuilder.pkgconfig/src/org/eclipse/cdt/managedbuilder/pkgconfig/settings/PkgConfigExternalSettingProvider.java b/org.eclipse.cdt.managedbuilder.pkgconfig/src/org/eclipse/cdt/managedbuilder/pkgconfig/settings/PkgConfigExternalSettingProvider.java
index 6f1f5fa..d5782ec 100644
--- a/org.eclipse.cdt.managedbuilder.pkgconfig/src/org/eclipse/cdt/managedbuilder/pkgconfig/settings/PkgConfigExternalSettingProvider.java
+++ b/org.eclipse.cdt.managedbuilder.pkgconfig/src/org/eclipse/cdt/managedbuilder/pkgconfig/settings/PkgConfigExternalSettingProvider.java
@@ -47,45 +47,53 @@ public class PkgConfigExternalSettingProvider extends CExternalSettingProvider {
public static final String ID = "org.eclipse.cdt.managedbuilder.pkgconfig.extSettings"; //$NON-NLS-1$
private final static String PACKAGES = "packages"; //$NON-NLS-1$
-
+
@Override
public CExternalSetting[] getSettings(IProject proj,
ICConfigurationDescription cfg) {
-
+
if (proj != null) {
- ICSettingEntry[] includes = getEntries(proj, ICSettingEntry.INCLUDE_PATH);
- ICSettingEntry[] libFiles = getEntries(proj, ICSettingEntry.LIBRARY_FILE);
- ICSettingEntry[] libPaths = getEntries(proj, ICSettingEntry.LIBRARY_PATH);
-
- CExternalSetting includeSettings = new CExternalSetting(null, new String[] {
- "org.eclipse.cdt.core.cSource", "org.eclipse.cdt.core.cxxSource" }, null, includes); //$NON-NLS-1$ //$NON-NLS-2$
-
- CExternalSetting libraryFileSettings =
- new CExternalSetting(null, new String[] {
- "org.eclipse.cdt.managedbuilder.core.compiledObjectFile" }, null, libFiles); //$NON-NLS-1$
-
- CExternalSetting libraryPathSettings =
- new CExternalSetting(null, new String[] {
- "org.eclipse.cdt.managedbuilder.core.compiledObjectFile" }, null, libPaths); //$NON-NLS-1$
-
+ ICSettingEntry[] includes = getEntries(proj,
+ ICSettingEntry.INCLUDE_PATH);
+ ICSettingEntry[] libFiles = getEntries(proj,
+ ICSettingEntry.LIBRARY_FILE);
+ ICSettingEntry[] libPaths = getEntries(proj,
+ ICSettingEntry.LIBRARY_PATH);
+
+ CExternalSetting includeSettings = new CExternalSetting(
+ null,
+ new String[] {
+ "org.eclipse.cdt.core.cSource", "org.eclipse.cdt.core.cxxSource" }, null, includes); //$NON-NLS-1$ //$NON-NLS-2$
+
+ CExternalSetting libraryFileSettings = new CExternalSetting(
+ null,
+ new String[] { "org.eclipse.cdt.managedbuilder.core.compiledObjectFile" }, null, libFiles); //$NON-NLS-1$
+
+ CExternalSetting libraryPathSettings = new CExternalSetting(
+ null,
+ new String[] { "org.eclipse.cdt.managedbuilder.core.compiledObjectFile" }, null, libPaths); //$NON-NLS-1$
+
addOtherFlagsToTools(proj);
-
- return new CExternalSetting[] { includeSettings, libraryFileSettings, libraryPathSettings };
+
+ return new CExternalSetting[] { includeSettings,
+ libraryFileSettings, libraryPathSettings };
}
- return new CExternalSetting[] { };
+ return new CExternalSetting[] {};
}
/**
* Get language setting entries for given ICSettingEntry.
+ *
* @param proj
* @param settingEntry
* @return
*/
- private static ICLanguageSettingEntry[] getEntries(IProject proj, int settingEntry) {
+ private static ICLanguageSettingEntry[] getEntries(IProject proj,
+ int settingEntry) {
String[] values = null;
ICLanguageSettingEntry[] newEntries = null;
ICLanguageSetting lang = getGCCLanguageSetting(proj);
- if (lang!=null) {
+ if (lang != null) {
switch (settingEntry) {
case ICSettingEntry.INCLUDE_PATH:
values = getIncludePathsFromCheckedPackages(proj);
@@ -108,19 +116,21 @@ public class PkgConfigExternalSettingProvider extends CExternalSettingProvider {
}
return newEntries;
}
-
+
/**
* Get language settings for given project and language id.
+ *
* @param proj
* @param languageId
* @return
*/
- private static ICLanguageSetting getLanguageSetting(IProject proj, String languageId) {
+ private static ICLanguageSetting getLanguageSetting(IProject proj,
+ String languageId) {
ICLanguageSetting[] langSettings = getLanguageSettings(proj);
ICLanguageSetting lang = null;
for (ICLanguageSetting langSetting : langSettings) {
String id = langSetting.getLanguageId();
- if(id != null) {
+ if (id != null) {
if (id.equalsIgnoreCase(languageId)) {
lang = langSetting;
return lang;
@@ -129,76 +139,89 @@ public class PkgConfigExternalSettingProvider extends CExternalSettingProvider {
}
return null;
}
-
+
/**
* Get language settings for the given project.
+ *
* @param proj
* @return
*/
private static ICLanguageSetting[] getLanguageSettings(IProject proj) {
- ICProjectDescription projectDescription = CoreModel.getDefault().getProjectDescription(proj);
- ICConfigurationDescription activeConf = projectDescription.getActiveConfiguration();
- ICFolderDescription folderDesc = activeConf.getRootFolderDescription();
+ ICProjectDescription projectDescription = CoreModel.getDefault()
+ .getProjectDescription(proj);
+ ICConfigurationDescription activeConf = projectDescription
+ .getActiveConfiguration();
+ ICFolderDescription folderDesc = activeConf.getRootFolderDescription();
ICLanguageSetting[] langSettings = folderDesc.getLanguageSettings();
return langSettings;
}
-
+
/**
* Get language settings for C projects.
+ *
* @param proj
* @return
*/
private static ICLanguageSetting getGCCLanguageSetting(IProject proj) {
return getLanguageSetting(proj, "org.eclipse.cdt.core.gcc"); //$NON-NLS-1$
}
-
+
/**
* Form ICIncludePathEntry array from include path String array.
+ *
* @param includes
* @return
*/
- private static ICLanguageSettingEntry[] formIncludePathEntries(String[] includes) {
+ private static ICLanguageSettingEntry[] formIncludePathEntries(
+ String[] includes) {
List<ICLanguageSettingEntry> incPathEntries = new ArrayList<ICLanguageSettingEntry>();
- for(String inc : includes) {
- ICIncludePathEntry incPathEntry = new CIncludePathEntry(new Path(inc),
- ICSettingEntry.INCLUDE_PATH);
+ for (String inc : includes) {
+ ICIncludePathEntry incPathEntry = new CIncludePathEntry(new Path(
+ inc), ICSettingEntry.INCLUDE_PATH);
incPathEntries.add(incPathEntry);
}
- return incPathEntries.toArray(new ICLanguageSettingEntry[incPathEntries.size()]);
+ return incPathEntries.toArray(new ICLanguageSettingEntry[incPathEntries
+ .size()]);
}
-
+
/**
* Form CLibraryFileEntry array from library file String array.
+ *
* @param libs
* @return
*/
private static ICLanguageSettingEntry[] formLibraryFileEntries(String[] libs) {
List<ICLanguageSettingEntry> libEntries = new ArrayList<ICLanguageSettingEntry>();
- for(String lib : libs) {
+ for (String lib : libs) {
CLibraryFileEntry libFileEntry = new CLibraryFileEntry(lib,
ICSettingEntry.LIBRARY_FILE);
libEntries.add(libFileEntry);
}
- return libEntries.toArray(new ICLanguageSettingEntry[libEntries.size()]);
+ return libEntries
+ .toArray(new ICLanguageSettingEntry[libEntries.size()]);
}
-
+
/**
* Form CLibraryPathEntry array from library path String array.
+ *
* @param libPaths
* @return
*/
- private static ICLanguageSettingEntry[] formLibraryPathEntries(String[] libPaths) {
+ private static ICLanguageSettingEntry[] formLibraryPathEntries(
+ String[] libPaths) {
List<ICLanguageSettingEntry> libPathEntries = new ArrayList<ICLanguageSettingEntry>();
- for(String libPath : libPaths) {
- CLibraryPathEntry libPathEntry = new CLibraryPathEntry(new Path(libPath),
- ICSettingEntry.LIBRARY_PATH);
+ for (String libPath : libPaths) {
+ CLibraryPathEntry libPathEntry = new CLibraryPathEntry(new Path(
+ libPath), ICSettingEntry.LIBRARY_PATH);
libPathEntries.add(libPathEntry);
}
- return libPathEntries.toArray(new ICLanguageSettingEntry[libPathEntries.size()]);
+ return libPathEntries.toArray(new ICLanguageSettingEntry[libPathEntries
+ .size()]);
}
-
+
/**
* Get include paths from the checked packages.
+ *
* @param proj
* @return
*/
@@ -208,17 +231,18 @@ public class PkgConfigExternalSettingProvider extends CExternalSettingProvider {
String cflags = null;
String[] includeArray = null;
for (String pkg : pkgs) {
- cflags = PkgConfigUtil.getCflags(pkg);
+ cflags = PkgConfigUtil.getCflags(pkg, proj.getName());
includeArray = Parser.parseIncPaths(cflags);
- if (includeArray!=null) {
+ if (includeArray != null) {
Collections.addAll(includeList, includeArray);
}
}
return includeList.toArray(new String[includeList.size()]);
}
-
+
/**
* Get library files from the checked packages.
+ *
* @param proj
* @return
*/
@@ -228,17 +252,18 @@ public class PkgConfigExternalSettingProvider extends CExternalSettingProvider {
String libs = null;
String[] libArray = null;
for (String pkg : pkgs) {
- libs = PkgConfigUtil.getLibFilesOnly(pkg);
+ libs = PkgConfigUtil.getLibFilesOnly(pkg, proj.getName());
libArray = Parser.parseLibs2(libs);
- if (libArray!=null) {
+ if (libArray != null) {
Collections.addAll(libList, libArray);
}
}
return libList.toArray(new String[libList.size()]);
}
-
+
/**
* Get library paths from the checked packages.
+ *
* @param proj
* @return
*/
@@ -248,17 +273,18 @@ public class PkgConfigExternalSettingProvider extends CExternalSettingProvider {
String libPaths = null;
String[] libPathArray = null;
for (String pkg : pkgs) {
- libPaths = PkgConfigUtil.getLibPathsOnly(pkg);
+ libPaths = PkgConfigUtil.getLibPathsOnly(pkg, proj.getName());
libPathArray = Parser.parseLibPaths2(libPaths);
- if (libPathArray!=null) {
+ if (libPathArray != null) {
Collections.addAll(libPathList, libPathArray);
}
}
return libPathList.toArray(new String[libPathList.size()]);
}
-
+
/**
* Get other flags from the checked packages.
+ *
* @param proj
* @return
*/
@@ -268,17 +294,18 @@ public class PkgConfigExternalSettingProvider extends CExternalSettingProvider {
String cflags = null;
String[] otherFlagArray = null;
for (String pkg : pkgs) {
- cflags = PkgConfigUtil.getCflags(pkg);
+ cflags = PkgConfigUtil.getCflags(proj.getName(), pkg);
otherFlagArray = Parser.parseCflagOptions(cflags);
- if (otherFlagArray!=null) {
+ if (otherFlagArray != null) {
Collections.addAll(otherFlagList, otherFlagArray);
}
}
return otherFlagList.toArray(new String[otherFlagList.size()]);
}
-
+
/**
* Add other flags to Tool's Option.
+ *
* @param proj
*/
private static void addOtherFlagsToTools(final IProject proj) {
@@ -298,29 +325,35 @@ public class PkgConfigExternalSettingProvider extends CExternalSettingProvider {
/**
* Get a storage element which stores the checked packages.
+ *
* @param proj
* @return
*/
private static ICStorageElement getPackageStorage(IProject proj) {
try {
- ICProjectDescription projectDescription = CoreModel.getDefault().getProjectDescription(proj);
- ICConfigurationDescription activeConf = projectDescription.getActiveConfiguration();
+ ICProjectDescription projectDescription = CoreModel.getDefault()
+ .getProjectDescription(proj);
+ ICConfigurationDescription activeConf = projectDescription
+ .getActiveConfiguration();
ICConfigurationDescription desc = activeConf.getConfiguration();
ICStorageElement strgElem = null;
try {
strgElem = desc.getStorage(PACKAGES, true);
return strgElem;
} catch (CoreException e) {
- Activator.getDefault().log(e, "Getting packages from the storage failed."); //$NON-NLS-1$
+ Activator.getDefault().log(e,
+ "Getting packages from the storage failed."); //$NON-NLS-1$
}
} catch (NullPointerException e) {
- Activator.getDefault().log(e, "Getting project description failed."); //$NON-NLS-1$
+ Activator.getDefault()
+ .log(e, "Getting project description failed."); //$NON-NLS-1$
}
return null;
}
-
+
/**
* Get names of the checked packages.
+ *
* @param proj
* @return
*/
@@ -329,14 +362,14 @@ public class PkgConfigExternalSettingProvider extends CExternalSettingProvider {
String[] pkgNames = pkgStorage.getAttributeNames();
List<String> pkgs = new ArrayList<String>();
String value = null;
- for(String pkgName : pkgNames) {
+ for (String pkgName : pkgNames) {
value = pkgStorage.getAttribute(pkgName);
- if(value!=null) {
- if(value.equals("true")) { //$NON-NLS-1$
+ if (value != null) {
+ if (value.equals("true")) { //$NON-NLS-1$
/*
- * replace + symbols, because + symbols in package names
- * had to be replaced when storing them to
- * ICStorageElement to prevent error
+ * replace + symbols, because + symbols in package names had
+ * to be replaced when storing them to ICStorageElement to
+ * prevent error
*/
if (pkgName.contains("plus")) { //$NON-NLS-1$
pkgName = pkgName.replace("plus", "+"); //$NON-NLS-1$ //$NON-NLS-2$
@@ -347,5 +380,5 @@ public class PkgConfigExternalSettingProvider extends CExternalSettingProvider {
}
return pkgs.toArray(new String[pkgs.size()]);
}
-
+
}
diff --git a/org.eclipse.cdt.managedbuilder.pkgconfig/src/org/eclipse/cdt/managedbuilder/pkgconfig/util/PkgConfigUtil.java b/org.eclipse.cdt.managedbuilder.pkgconfig/src/org/eclipse/cdt/managedbuilder/pkgconfig/util/PkgConfigUtil.java
index 923753c..e0e4127 100644
--- a/org.eclipse.cdt.managedbuilder.pkgconfig/src/org/eclipse/cdt/managedbuilder/pkgconfig/util/PkgConfigUtil.java
+++ b/org.eclipse.cdt.managedbuilder.pkgconfig/src/org/eclipse/cdt/managedbuilder/pkgconfig/util/PkgConfigUtil.java
@@ -20,13 +20,15 @@ import org.eclipse.cdt.managedbuilder.pkgconfig.Activator;
import org.eclipse.cdt.managedbuilder.pkgconfig.preferences.PreferenceStore;
/**
- * Runs pkg-config utility in the command line and outputs necessary
- * options to build the given package.
+ * Runs pkg-config utility in the command line and outputs necessary options to
+ * build the given package.
*
*/
public class PkgConfigUtil {
- //Constant variables
+ private static final String UNIX_PATH_SEPARATOR = ":"; //$NON-NLS-1$
+ private static final String WINDOWS_PATH_SEPARATOR = ";"; //$NON-NLS-1$
+ // Constant variables
private static final String PKG_CONFIG = "pkg-config"; //$NON-NLS-1$
private static final String LIST_PACKAGES = "--list-all"; //$NON-NLS-1$
private static final String OUTPUT_LIBS = "--libs"; //$NON-NLS-1$
@@ -36,16 +38,16 @@ public class PkgConfigUtil {
private static final String OUTPUT_ONLY_LIB_FILES = "--libs-only-l"; //$NON-NLS-1$
/**
- * Get options needed to build the given package.
- * Does not like spaces on paths except that getAllPackages seem to work.
+ * Get options needed to build the given package. Does not like spaces on
+ * paths except that getAllPackages seem to work.
*
* @param pkgConfigOptions
* Pkg-config options
* @param pkg
* @return
*/
- private static String getPkgOutput(String pkgConfigOptions) {
- List<String> pkgOutputs = getPkgOutputs(pkgConfigOptions);
+ private static String getPkgOutput(String project, String pkgConfigOptions) {
+ List<String> pkgOutputs = getPkgOutputs(project, pkgConfigOptions);
if (pkgOutputs.isEmpty())
return null;
return pkgOutputs.get(0);
@@ -57,14 +59,14 @@ public class PkgConfigUtil {
*
* @param pkgconfigOptions
* Pkg-config options as --list-all, --libs...
- * @param pkg
- * Pkg-config library name. In case of --list-all option, it must
- * be set to null
+ * @param project
+ * Project name
* @return pkg-config command results as a list of string
*/
- private static List<String> getPkgOutputs(String pkgconfigOptions) {
+ private static List<String> getPkgOutputs(String project,
+ String pkgconfigOptions) {
ProcessBuilder pb = null;
- String pkgConfigBinPath = PreferenceStore.getPkgConfigBinPath();
+ String pkgConfigBinPath = PreferenceStore.getPkgConfigBinPath(project);
if (pkgConfigBinPath.isEmpty()) {
if (OSDetector.isWindows())
@@ -73,30 +75,60 @@ public class PkgConfigUtil {
pkgConfigBinPath = PKG_CONFIG;
}
- String pkgConfigPath = PreferenceStore.getPkgConfigPath();
+ String[] pkgConfigPaths = PreferenceStore.getPkgConfigPath(project);
StringBuffer pkgConfigCmd = new StringBuffer();
+ String pkgConfigPath = ""; //$NON-NLS-1$
+
+ if (pkgConfigPaths != null) {
+ for (int i = 0; i < pkgConfigPaths.length; i++) {
+ String pkgConfigPathValue = pkgConfigPaths[i];
+ pkgConfigPath += pkgConfigPathValue;
+ if (i != pkgConfigPaths.length - 1) {
+ if (OSDetector.isWindows()) {
+ pkgConfigPath += WINDOWS_PATH_SEPARATOR;
+ } else {
+ pkgConfigPath += UNIX_PATH_SEPARATOR;
+ }
+ }
+ }
- if (pkgConfigPath != null && !pkgConfigPath.isEmpty()) {
- pkgConfigPath = pkgConfigPath.replace(" ", "\\ "); //$NON-NLS-1$ //$NON-NLS-2$
- if (OSDetector.isWindows()) {
- pkgConfigCmd
- .append(" set PKG_CONFIG_PATH=" + pkgConfigPath + " ");//$NON-NLS-1$ //$NON-NLS-2$
- } else {
- pkgConfigCmd.append(" PKG_CONFIG_PATH=" + pkgConfigPath + " ");//$NON-NLS-1$ //$NON-NLS-2$
+ if (!pkgConfigPath.isEmpty()) {
+ pkgConfigPath = pkgConfigPath.replace(" ", "\\ "); //$NON-NLS-1$ //$NON-NLS-2$
+ if (OSDetector.isWindows()) {
+ pkgConfigCmd
+ .append(" set PKG_CONFIG_PATH=" + pkgConfigPath + "&");//$NON-NLS-1$ //$NON-NLS-2$
+ } else {
+ pkgConfigCmd
+ .append(" PKG_CONFIG_PATH=" + pkgConfigPath + " ");//$NON-NLS-1$ //$NON-NLS-2$
+ }
}
}
- String pkgConfigLibDirPath = PreferenceStore.getPkgConfigLibDir();
- if (pkgConfigLibDirPath != null && !pkgConfigLibDirPath.isEmpty()) {
- pkgConfigLibDirPath = pkgConfigLibDirPath.replace(" ", "\\ "); //$NON-NLS-1$ //$NON-NLS-2$
- if (OSDetector.isWindows()) {
- if (pkgConfigPath != null && !pkgConfigPath.isEmpty())
- pkgConfigCmd.append("&&"); //$NON-NLS-1$
- pkgConfigCmd
- .append(" set PKG_CONFIG_LIBDIR=" + pkgConfigLibDirPath + " ");//$NON-NLS-1$ //$NON-NLS-2$
- } else {
- pkgConfigCmd
- .append(" PKG_CONFIG_LIBDIR=" + pkgConfigLibDirPath + " ");//$NON-NLS-1$ //$NON-NLS-2$
+ String[] pkgConfigLibDirPaths = PreferenceStore
+ .getPkgConfigLibDir(project);
+ if (pkgConfigLibDirPaths != null) {
+ String pkgConfigLibDirPath = ""; //$NON-NLS-1$
+ for (int i = 0; i < pkgConfigLibDirPaths.length; i++) {
+ String pkgConfigPathValue = pkgConfigLibDirPaths[i];
+ pkgConfigLibDirPath += pkgConfigPathValue;
+ if (pkgConfigPaths != null && i != pkgConfigPaths.length - 1) {
+ if (OSDetector.isWindows()) {
+ pkgConfigPath += WINDOWS_PATH_SEPARATOR;
+ } else {
+ pkgConfigPath += UNIX_PATH_SEPARATOR;
+ }
+ }
+ }
+
+ if (!pkgConfigLibDirPath.isEmpty()) {
+ pkgConfigLibDirPath = pkgConfigLibDirPath.replace(" ", "\\ "); //$NON-NLS-1$ //$NON-NLS-2$
+ if (OSDetector.isWindows()) {
+ pkgConfigCmd
+ .append(" set PKG_CONFIG_LIBDIR=" + pkgConfigLibDirPath + "&");//$NON-NLS-1$ //$NON-NLS-2$
+ } else {
+ pkgConfigCmd
+ .append(" PKG_CONFIG_LIBDIR=" + pkgConfigLibDirPath + " ");//$NON-NLS-1$ //$NON-NLS-2$
+ }
}
}
pkgConfigCmd.append(pkgConfigBinPath);
@@ -148,65 +180,72 @@ public class PkgConfigUtil {
}
return results;
}
-
+
/**
* Get cflags and libraries needed to build the given package.
*
- * @param pkg
+ * @param pkg Package
+ * @param project Project name
* @return
*/
- public static String getAll(String pkg) {
- return getPkgOutput(OUTPUT_ALL + " " + pkg); //$NON-NLS-1$
+ public static String getAll(String pkg, String project) {
+ return getPkgOutput(project, OUTPUT_ALL + " " + pkg); //$NON-NLS-1$
}
-
+
/**
* Get libraries (files and paths) needed to build the given package.
*
- * @param pkg
+ * @param pkg Package
+ * @param project Project name
* @return
*/
- public static String getLibs(String pkg) {
- return getPkgOutput(OUTPUT_LIBS + " " + pkg); //$NON-NLS-1$
+ public static String getLibs(String pkg, String project) {
+ return getPkgOutput(project, OUTPUT_LIBS + " " + pkg); //$NON-NLS-1$
}
-
+
/**
* Get library paths needed to build the given package.
*
- * @param pkg
+ * @param pkg Package
+ * @param project Project name
* @return
*/
- public static String getLibPathsOnly(String pkg) {
- return getPkgOutput(OUTPUT_ONLY_LIB_PATHS + " " + pkg); //$NON-NLS-1$
+ public static String getLibPathsOnly(String pkg, String project) {
+ return getPkgOutput(project, OUTPUT_ONLY_LIB_PATHS + " " + pkg); //$NON-NLS-1$
}
/**
* Get library files needed to build the given package.
*
- * @param pkg
- * @return
+ * @param pkg Package
+ * @param project Project name
+ * @return
*/
- public static String getLibFilesOnly(String pkg) {
- return getPkgOutput(OUTPUT_ONLY_LIB_FILES + " " + pkg); //$NON-NLS-1$
+ public static String getLibFilesOnly(String pkg, String project) {
+ return getPkgOutput(project, OUTPUT_ONLY_LIB_FILES + " " + pkg); //$NON-NLS-1$
}
-
+
/**
* Get cflags needed to build the given package.
*
- * @param pkg
+ * @param pkg Package
+ * @param project Project name
* @return
*/
- public static String getCflags(String pkg) {
- return getPkgOutput(OUTPUT_CFLAGS + " " + pkg); //$NON-NLS-1$
+ public static String getCflags(String pkg, String project) {
+ return getPkgOutput(project, OUTPUT_CFLAGS + " " + pkg); //$NON-NLS-1$
}
-
+
/**
* Get all packages that pkg-config utility finds (package name with
* description).
*
+ * @param project
+ *
* @return
*/
- public static List<String> getAllPackages() {
- return getPkgOutputs(LIST_PACKAGES);
+ public static List<String> getAllPackages(String project) {
+ return getPkgOutputs(project, LIST_PACKAGES);
}
-
+
}
--
1.7.9.5