mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Add GNU C++ linker library grouping option to MBS
This commit is contained in:
parent
e31815210e
commit
f39707a293
4 changed files with 75 additions and 4 deletions
|
@ -83,7 +83,7 @@
|
||||||
name="%Option.Posix.Libs"
|
name="%Option.Posix.Libs"
|
||||||
category="gnu.c.link.category.libs"
|
category="gnu.c.link.category.libs"
|
||||||
command="-l"
|
command="-l"
|
||||||
commandGenerator="org.eclipse.cdt.managedbuilder.gnu.ui.LibrariesCommandGenerator"
|
commandGenerator="org.eclipse.cdt.managedbuilder.gnu.ui.GnuCLibrariesCommandGenerator"
|
||||||
id="gnu.c.link.option.libs"
|
id="gnu.c.link.option.libs"
|
||||||
browseType="none"
|
browseType="none"
|
||||||
valueType="libs">
|
valueType="libs">
|
||||||
|
@ -300,6 +300,7 @@
|
||||||
name="%Option.Posix.Libs"
|
name="%Option.Posix.Libs"
|
||||||
category="gnu.cpp.link.category.libs"
|
category="gnu.cpp.link.category.libs"
|
||||||
command="-l"
|
command="-l"
|
||||||
|
commandGenerator="org.eclipse.cdt.managedbuilder.gnu.ui.GnuCppLibrariesCommandGenerator"
|
||||||
id="gnu.cpp.link.option.libs"
|
id="gnu.cpp.link.option.libs"
|
||||||
browseType="none"
|
browseType="none"
|
||||||
valueType="libs">
|
valueType="libs">
|
||||||
|
@ -312,6 +313,13 @@
|
||||||
browseType="directory"
|
browseType="directory"
|
||||||
valueType="libPaths">
|
valueType="libPaths">
|
||||||
</option>
|
</option>
|
||||||
|
<option
|
||||||
|
defaultValue="false"
|
||||||
|
name="%Option.Posix.Linker.GroupLibs"
|
||||||
|
category="gnu.cpp.link.category.libs"
|
||||||
|
id="gnu.cpp.link.option.group"
|
||||||
|
valueType="boolean">
|
||||||
|
</option>
|
||||||
<optionCategory
|
<optionCategory
|
||||||
owner="cdt.managedbuild.tool.gnu.cpp.linker"
|
owner="cdt.managedbuild.tool.gnu.cpp.linker"
|
||||||
name="%OptionCategory.Misc"
|
name="%OptionCategory.Misc"
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2023 John Dallaway and others.
|
||||||
|
*
|
||||||
|
* This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License 2.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* https://www.eclipse.org/legal/epl-2.0/
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: EPL-2.0
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* John Dallaway - initial implementation (#608)
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.managedbuilder.gnu.ui;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A libraries command generator for GNU C projects.
|
||||||
|
* @noextend This class is not intended to be subclassed by clients.
|
||||||
|
* @noinstantiate This class is not intended to be instantiated by clients.
|
||||||
|
* @since 8.6
|
||||||
|
*/
|
||||||
|
public class GnuCLibrariesCommandGenerator extends LibrariesCommandGenerator {
|
||||||
|
|
||||||
|
public GnuCLibrariesCommandGenerator() {
|
||||||
|
super("gnu.c.link.option.group"); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2023 John Dallaway and others.
|
||||||
|
*
|
||||||
|
* This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License 2.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* https://www.eclipse.org/legal/epl-2.0/
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: EPL-2.0
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* John Dallaway - initial implementation (#608)
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.managedbuilder.gnu.ui;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A libraries command generator for GNU C++ projects.
|
||||||
|
* @noextend This class is not intended to be subclassed by clients.
|
||||||
|
* @noinstantiate This class is not intended to be instantiated by clients.
|
||||||
|
* @since 8.6
|
||||||
|
*/
|
||||||
|
public class GnuCppLibrariesCommandGenerator extends LibrariesCommandGenerator {
|
||||||
|
|
||||||
|
public GnuCppLibrariesCommandGenerator() {
|
||||||
|
super("gnu.cpp.link.option.group"); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -27,18 +27,25 @@ import org.eclipse.core.runtime.Status;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An option command generator to group libraries on the GNU linker command line
|
* An option command generator to group libraries on the GNU linker command line
|
||||||
* @noextend This class is not intended to be subclassed by clients.
|
|
||||||
* @noinstantiate This class is not intended to be instantiated by clients.
|
* @noinstantiate This class is not intended to be instantiated by clients.
|
||||||
* @since 8.6
|
* @since 8.6
|
||||||
*/
|
*/
|
||||||
public class LibrariesCommandGenerator implements IOptionCommandGenerator {
|
public class LibrariesCommandGenerator implements IOptionCommandGenerator {
|
||||||
|
|
||||||
private static final String GROUP_LIBRARIES_COMMAND_FORMAT = "-Wl,--start-group %s -Wl,--end-group"; //$NON-NLS-1$
|
private static final String GROUP_LIBRARIES_COMMAND_FORMAT = "-Wl,--start-group %s -Wl,--end-group"; //$NON-NLS-1$
|
||||||
private static final String GROUP_LIBRARIES_OPTION_ID = "gnu.c.link.option.group"; //$NON-NLS-1$
|
|
||||||
|
private final String fGroupLibrariesOptionId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param groupLibrariesOptionId the ID of the IOption controlling library grouping
|
||||||
|
*/
|
||||||
|
protected LibrariesCommandGenerator(String groupLibrariesOptionId) {
|
||||||
|
fGroupLibrariesOptionId = groupLibrariesOptionId;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String generateCommand(IOption option, IVariableSubstitutor macroSubstitutor) {
|
public String generateCommand(IOption option, IVariableSubstitutor macroSubstitutor) {
|
||||||
IOption groupOption = option.getOptionHolder().getOptionBySuperClassId(GROUP_LIBRARIES_OPTION_ID);
|
IOption groupOption = option.getOptionHolder().getOptionBySuperClassId(fGroupLibrariesOptionId);
|
||||||
try {
|
try {
|
||||||
if ((groupOption != null) && groupOption.getBooleanValue()) { // if library grouping enabled
|
if ((groupOption != null) && groupOption.getBooleanValue()) { // if library grouping enabled
|
||||||
String command = option.getCommand();
|
String command = option.getCommand();
|
||||||
|
|
Loading…
Add table
Reference in a new issue