Skip to content

Commit

Permalink
[#592] add Group libraries
Browse files Browse the repository at this point in the history
  • Loading branch information
ilg-ul committed Mar 19, 2024
1 parent 78e3ebe commit ec27d9e
Show file tree
Hide file tree
Showing 10 changed files with 278 additions and 54 deletions.
2 changes: 2 additions & 0 deletions README-MAINTAINER.md
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,8 @@ Use copy/paste/edit.

**Pull** new commits.

NOTE: to be updated for Pull Requests!

In Eclipse:

- import existing project `org.eclipse.simrel.build`
Expand Down
58 changes: 35 additions & 23 deletions plugins/org.eclipse.embedcdt.managedbuild.cross.arm.core/plugin.xml
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<!--
Copyright (c) 2009, 2023 Wind River Systems, Inc. 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
<!--
Copyright (c) 2009, 2023 Wind River Systems, Inc. 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
SPDX-License-Identifier: EPL-2.0
Contributors:
Doug Schaefer (Wind River) - initial API and implementation
Anna Dushistova (Mentor Graphics)- [329531][crossgcc] crossgcc fails to build a project
Liviu Ionescu - Arm version
Contributors:
Doug Schaefer (Wind River) - initial API and implementation
Anna Dushistova (Mentor Graphics)- [329531][crossgcc] crossgcc fails to build a project
Liviu Ionescu - Arm version
John Dallaway - use GNU ELF binary parser (#567)
-->
<plugin>
Expand Down Expand Up @@ -1248,11 +1248,11 @@
</or>
</not>
</enablement>
<!-- <enablement attribute="defaultValue" extensionAdjustment="false"
type="CONTAINER_ATTRIBUTE" value="ilg.gnuarmeclipse.managedbuild.cross.option.arm.target.fpu.unit.fpv4spd16">
<checkOption holderId="ilg.gnuarmeclipse.managedbuild.cross.toolchain.base"
optionId="ilg.gnuarmeclipse.managedbuild.cross.option.base.arm.target.family"
value="ilg.gnuarmeclipse.managedbuild.cross.option.arm.target.mcpu.cortex-m4">
<!-- <enablement attribute="defaultValue" extensionAdjustment="false"
type="CONTAINER_ATTRIBUTE" value="ilg.gnuarmeclipse.managedbuild.cross.option.arm.target.fpu.unit.fpv4spd16">
<checkOption holderId="ilg.gnuarmeclipse.managedbuild.cross.toolchain.base"
optionId="ilg.gnuarmeclipse.managedbuild.cross.option.base.arm.target.family"
value="ilg.gnuarmeclipse.managedbuild.cross.option.arm.target.mcpu.cortex-m4">
</checkOption> </enablement> -->
<enumeratedOptionValue
id="ilg.gnuarmeclipse.managedbuild.cross.option.arm.target.fpu.unit.default"
Expand Down Expand Up @@ -2901,7 +2901,13 @@
<option
category="ilg.gnuarmeclipse.managedbuild.cross.optionCategory.c.linker.libs"
id="ilg.gnuarmeclipse.managedbuild.cross.option.c.linker.libs"
superClass="ilg.gnumcueclipse.managedbuild.cross.option.base.linker.libs">
superClass="ilg.gnumcueclipse.managedbuild.cross.option.base.linker.libs"
commandGenerator="org.eclipse.embedcdt.managedbuild.cross.arm.core.LibrariesCommandGeneratorC">
</option>
<option
category="ilg.gnuarmeclipse.managedbuild.cross.optionCategory.c.linker.libs"
id="ilg.gnuarmeclipse.managedbuild.cross.option.c.linker.grouplibs"
superClass="ilg.gnumcueclipse.managedbuild.cross.option.base.linker.grouplibs">
</option>
<option
category="ilg.gnuarmeclipse.managedbuild.cross.optionCategory.c.linker.libs"
Expand Down Expand Up @@ -3091,7 +3097,13 @@
<option
category="ilg.gnuarmeclipse.managedbuild.cross.optionCategory.cpp.linker.libs"
id="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.linker.libs"
superClass="ilg.gnumcueclipse.managedbuild.cross.option.base.linker.libs">
superClass="ilg.gnumcueclipse.managedbuild.cross.option.base.linker.libs"
commandGenerator="org.eclipse.embedcdt.managedbuild.cross.arm.core.LibrariesCommandGeneratorCpp">
</option>
<option
category="ilg.gnuarmeclipse.managedbuild.cross.optionCategory.cpp.linker.libs"
id="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.linker.grouplibs"
superClass="ilg.gnumcueclipse.managedbuild.cross.option.base.linker.grouplibs">
</option>
<option
category="ilg.gnuarmeclipse.managedbuild.cross.optionCategory.cpp.linker.libs"
Expand Down Expand Up @@ -3580,14 +3592,14 @@
name="FLASH Hex file"
priority="normal">
</content-type>
<!-- <content-type id="ilg.gnuarmeclipse.managedbuild.cross.content-type.s"
name=".s Assembly file" base-type="org.eclipse.cdt.core.asmSource" file-extensions="s"
priority="high" /> <file-association content-type="org.eclipse.cdt.core.asmSource"
<!-- <content-type id="ilg.gnuarmeclipse.managedbuild.cross.content-type.s"
name=".s Assembly file" base-type="org.eclipse.cdt.core.asmSource" file-extensions="s"
priority="high" /> <file-association content-type="org.eclipse.cdt.core.asmSource"
file-extensions="s,S,asm"> </file-association> -->
</extension>
<!-- <extension point="org.eclipse.cdt.core.language"> <language class="org.eclipse.cdt.core.model.AssemblyLanguage"
id="ilg.gnuarmeclipse.managedbuild.cross.assembly" name="Assembly"> <contentType
id="ilg.gnuarmeclipse.managedbuild.cross.content-type.s"> </contentType>
<!-- <extension point="org.eclipse.cdt.core.language"> <language class="org.eclipse.cdt.core.model.AssemblyLanguage"
id="ilg.gnuarmeclipse.managedbuild.cross.assembly" name="Assembly"> <contentType
id="ilg.gnuarmeclipse.managedbuild.cross.content-type.s"> </contentType>
</language> </extension> -->
<extension point="org.eclipse.cdt.core.templates">
<template
Expand Down
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$
}

}
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$
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ option.linker.printgcsections=Print removed sections (-Xlinker --print-gc-sectio
option.linker.strip=Omit all symbol information (-s)
option.linker.libs=Libraries (-l)
option.linker.paths=Library search path (-L)
option.linker.grouplibs=Group libraries (-Wl,--start-group, ... ,--end-group)
option.linker.flags=Linker flags (-Xlinker [option])
option.linker.otherobjs=Other objects
option.linker.other=Other linker flags
Expand Down
31 changes: 19 additions & 12 deletions plugins/org.eclipse.embedcdt.managedbuild.cross.core/plugin.xml
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<!--
Copyright (c) 2009, 2011 Wind River Systems, Inc. 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
<!--
Copyright (c) 2009, 2011 Wind River Systems, Inc. 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:
Doug Schaefer (Wind River) - initial API and implementation
Anna Dushistova (Mentor Graphics)- [329531][crossgcc] crossgcc fails to
build a project
Liviu Ionescu - MCU version
SPDX-License-Identifier: EPL-2.0
Contributors:
Doug Schaefer (Wind River) - initial API and implementation
Anna Dushistova (Mentor Graphics)- [329531][crossgcc] crossgcc fails to
build a project
Liviu Ionescu - MCU version
-->
<plugin>
<extension point="org.eclipse.cdt.managedbuilder.core.buildDefinitions">
Expand Down Expand Up @@ -662,6 +662,13 @@
name="%option.linker.paths"
valueType="libPaths">
</option>
<option
defaultValue="false"
id="ilg.gnumcueclipse.managedbuild.cross.option.base.linker.grouplibs"
isAbstract="true"
name="%option.linker.grouplibs"
valueType="boolean">
</option>
<option
command="-Xlinker ${VALUE}"
id="ilg.gnumcueclipse.managedbuild.cross.option.base.linker.flags"
Expand Down
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
}

}
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<!--
Copyright (c) 2009, 2023 Wind River Systems, Inc. and others.
<!--
Copyright (c) 2009, 2023 Wind River Systems, Inc. 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
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
SPDX-License-Identifier: EPL-2.0
Contributors:
Doug Schaefer (Wind River) - initial API and implementation
Anna Dushistova (Mentor Graphics)- [329531][crossgcc] crossgcc fails to build a project
Liviu Ionescu - RISC-V version
Contributors:
Doug Schaefer (Wind River) - initial API and implementation
Anna Dushistova (Mentor Graphics)- [329531][crossgcc] crossgcc fails to build a project
Liviu Ionescu - RISC-V version
Alexander Fedorov (ArSysOp) - extract UI part
John Dallaway - use GNU ELF binary parser (#567)
-->
Expand Down Expand Up @@ -595,7 +595,7 @@
command="-mno-strict-align"
name="%option.target.align.nostrict">
</enumeratedOptionValue>
</option>
</option>
</tool>
<toolChain
archList="all"
Expand Down Expand Up @@ -1812,7 +1812,13 @@
<option
category="ilg.gnumcueclipse.managedbuild.cross.riscv.optionCategory.c.linker.libs"
id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.libs"
superClass="ilg.gnumcueclipse.managedbuild.cross.option.base.linker.libs">
superClass="ilg.gnumcueclipse.managedbuild.cross.option.base.linker.libs"
commandGenerator="org.eclipse.embedcdt.managedbuild.cross.riscv.core.LibrariesCommandGeneratorC">
</option>
<option
category="ilg.gnumcueclipse.managedbuild.cross.riscv.optionCategory.c.linker.libs"
id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.grouplibs"
superClass="ilg.gnumcueclipse.managedbuild.cross.option.base.linker.grouplibs">
</option>
<option
category="ilg.gnumcueclipse.managedbuild.cross.riscv.optionCategory.c.linker.libs"
Expand Down Expand Up @@ -2002,7 +2008,13 @@
<option
category="ilg.gnumcueclipse.managedbuild.cross.riscv.optionCategory.cpp.linker.libs"
id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.libs"
superClass="ilg.gnumcueclipse.managedbuild.cross.option.base.linker.libs">
superClass="ilg.gnumcueclipse.managedbuild.cross.option.base.linker.libs"
commandGenerator="org.eclipse.embedcdt.managedbuild.cross.riscv.core.LibrariesCommandGeneratorCpp">
</option>
<option
category="ilg.gnumcueclipse.managedbuild.cross.riscv.optionCategory.cpp.linker.libs"
id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.grouplibs"
superClass="ilg.gnumcueclipse.managedbuild.cross.option.base.linker.grouplibs">
</option>
<option
category="ilg.gnumcueclipse.managedbuild.cross.riscv.optionCategory.cpp.linker.libs"
Expand Down Expand Up @@ -2493,14 +2505,14 @@
name="FLASH Hex file"
priority="normal">
</content-type>
<!-- <content-type id="ilg.gnumcueclipse.managedbuild.cross.riscv.content-type.s"
name=".s Assembly file" base-type="org.eclipse.cdt.core.asmSource" file-extensions="s"
priority="high" /> <file-association content-type="org.eclipse.cdt.core.asmSource"
<!-- <content-type id="ilg.gnumcueclipse.managedbuild.cross.riscv.content-type.s"
name=".s Assembly file" base-type="org.eclipse.cdt.core.asmSource" file-extensions="s"
priority="high" /> <file-association content-type="org.eclipse.cdt.core.asmSource"
file-extensions="s,S,asm"> </file-association> -->
</extension>
<!-- <extension point="org.eclipse.cdt.core.language"> <language class="org.eclipse.cdt.core.model.AssemblyLanguage"
id="ilg.gnumcueclipse.managedbuild.cross.riscv.assembly" name="Assembly">
<contentType id="ilg.gnumcueclipse.managedbuild.cross.riscv.content-type.s">
<!-- <extension point="org.eclipse.cdt.core.language"> <language class="org.eclipse.cdt.core.model.AssemblyLanguage"
id="ilg.gnumcueclipse.managedbuild.cross.riscv.assembly" name="Assembly">
<contentType id="ilg.gnumcueclipse.managedbuild.cross.riscv.content-type.s">
</contentType> </language> </extension> -->
<extension point="org.eclipse.cdt.core.templates">
<template
Expand Down
Loading

0 comments on commit ec27d9e

Please sign in to comment.