-
-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
278 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
...core/src/org/eclipse/embedcdt/managedbuild/cross/arm/core/LibrariesCommandGeneratorC.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/******************************************************************************* | ||
* 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) | ||
* Liviu Ionescu - adjust for ECDT | ||
*******************************************************************************/ | ||
package org.eclipse.embedcdt.managedbuild.cross.arm.core; | ||
|
||
import org.eclipse.embedcdt.managedbuild.cross.core.LibrariesCommandGenerator; | ||
|
||
/** | ||
* 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 LibrariesCommandGeneratorC extends LibrariesCommandGenerator { | ||
|
||
public LibrariesCommandGeneratorC() { | ||
super("ilg.gnuarmeclipse.managedbuild.cross.option.c.linker.grouplibs"); //$NON-NLS-1$ | ||
} | ||
|
||
} |
31 changes: 31 additions & 0 deletions
31
...re/src/org/eclipse/embedcdt/managedbuild/cross/arm/core/LibrariesCommandGeneratorCpp.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/******************************************************************************* | ||
* 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) | ||
* Liviu Ionescu - adjust for ECDT | ||
*******************************************************************************/ | ||
package org.eclipse.embedcdt.managedbuild.cross.arm.core; | ||
|
||
import org.eclipse.embedcdt.managedbuild.cross.core.LibrariesCommandGenerator; | ||
|
||
/** | ||
* 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 LibrariesCommandGeneratorCpp extends LibrariesCommandGenerator { | ||
|
||
public LibrariesCommandGeneratorCpp() { | ||
super("ilg.gnuarmeclipse.managedbuild.cross.option.cpp.linker.grouplibs"); //$NON-NLS-1$ | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
...ross.core/src/org/eclipse/embedcdt/managedbuild/cross/core/LibrariesCommandGenerator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/******************************************************************************* | ||
* 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) | ||
* Liviu Ionescu - use single `-Wl,` string | ||
*******************************************************************************/ | ||
package org.eclipse.embedcdt.managedbuild.cross.core; | ||
|
||
import java.util.Arrays; | ||
import java.util.stream.Collectors; | ||
|
||
import org.eclipse.cdt.core.cdtvariables.CdtVariableException; | ||
import org.eclipse.cdt.managedbuilder.core.BuildException; | ||
import org.eclipse.cdt.managedbuilder.core.IOption; | ||
import org.eclipse.cdt.managedbuilder.core.IOptionCommandGenerator; | ||
import org.eclipse.cdt.utils.cdtvariables.CdtVariableResolver; | ||
import org.eclipse.cdt.utils.cdtvariables.IVariableSubstitutor; | ||
import org.eclipse.core.runtime.Platform; | ||
import org.eclipse.core.runtime.Status; | ||
|
||
/** | ||
* An option command generator to group libraries on the GNU linker command line | ||
* @noinstantiate This class is not intended to be instantiated by clients. | ||
* @since 8.6 | ||
*/ | ||
public class LibrariesCommandGenerator implements IOptionCommandGenerator { | ||
|
||
private static final String GROUP_LIBRARIES_COMMAND_FORMAT = "-Wl,--start-group,%s,--end-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 | ||
public String generateCommand(IOption option, IVariableSubstitutor macroSubstitutor) { | ||
IOption groupOption = option.getOptionHolder().getOptionBySuperClassId(fGroupLibrariesOptionId); | ||
try { | ||
if ((groupOption != null) && groupOption.getBooleanValue()) { // if library grouping enabled | ||
String command = option.getCommand(); | ||
String libraries = Arrays.stream(option.getLibraries()).map(lib -> command + lib) | ||
.collect(Collectors.joining(",")); //$NON-NLS-1$ | ||
if (!libraries.isEmpty()) { | ||
libraries = CdtVariableResolver.resolveToString(libraries, macroSubstitutor); | ||
return String.format(GROUP_LIBRARIES_COMMAND_FORMAT, libraries); | ||
} | ||
} | ||
} catch (BuildException | CdtVariableException e) { | ||
Platform.getLog(getClass()).log(Status.error("Error generating libraries command", e)); //$NON-NLS-1$ | ||
} | ||
return null; // fallback to default command generator | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.