Skip to content

Commit ec27d9e

Browse files
committed
[#592] add Group libraries
1 parent 78e3ebe commit ec27d9e

File tree

10 files changed

+278
-54
lines changed

10 files changed

+278
-54
lines changed

README-MAINTAINER.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,8 @@ Use copy/paste/edit.
459459

460460
**Pull** new commits.
461461

462+
NOTE: to be updated for Pull Requests!
463+
462464
In Eclipse:
463465

464466
- import existing project `org.eclipse.simrel.build`

plugins/org.eclipse.embedcdt.managedbuild.cross.arm.core/plugin.xml

Lines changed: 35 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<?eclipse version="3.4"?>
3-
<!--
4-
Copyright (c) 2009, 2023 Wind River Systems, Inc. and others.
5-
This program and the accompanying materials
6-
are made available under the terms of the Eclipse Public License 2.0
7-
which accompanies this distribution, and is available at
3+
<!--
4+
Copyright (c) 2009, 2023 Wind River Systems, Inc. and others.
5+
This program and the accompanying materials
6+
are made available under the terms of the Eclipse Public License 2.0
7+
which accompanies this distribution, and is available at
88
https://www.eclipse.org/legal/epl-2.0/
99
10-
SPDX-License-Identifier: EPL-2.0
10+
SPDX-License-Identifier: EPL-2.0
1111
12-
Contributors:
13-
Doug Schaefer (Wind River) - initial API and implementation
14-
Anna Dushistova (Mentor Graphics)- [329531][crossgcc] crossgcc fails to build a project
15-
Liviu Ionescu - Arm version
12+
Contributors:
13+
Doug Schaefer (Wind River) - initial API and implementation
14+
Anna Dushistova (Mentor Graphics)- [329531][crossgcc] crossgcc fails to build a project
15+
Liviu Ionescu - Arm version
1616
John Dallaway - use GNU ELF binary parser (#567)
1717
-->
1818
<plugin>
@@ -1248,11 +1248,11 @@
12481248
</or>
12491249
</not>
12501250
</enablement>
1251-
<!-- <enablement attribute="defaultValue" extensionAdjustment="false"
1252-
type="CONTAINER_ATTRIBUTE" value="ilg.gnuarmeclipse.managedbuild.cross.option.arm.target.fpu.unit.fpv4spd16">
1253-
<checkOption holderId="ilg.gnuarmeclipse.managedbuild.cross.toolchain.base"
1254-
optionId="ilg.gnuarmeclipse.managedbuild.cross.option.base.arm.target.family"
1255-
value="ilg.gnuarmeclipse.managedbuild.cross.option.arm.target.mcpu.cortex-m4">
1251+
<!-- <enablement attribute="defaultValue" extensionAdjustment="false"
1252+
type="CONTAINER_ATTRIBUTE" value="ilg.gnuarmeclipse.managedbuild.cross.option.arm.target.fpu.unit.fpv4spd16">
1253+
<checkOption holderId="ilg.gnuarmeclipse.managedbuild.cross.toolchain.base"
1254+
optionId="ilg.gnuarmeclipse.managedbuild.cross.option.base.arm.target.family"
1255+
value="ilg.gnuarmeclipse.managedbuild.cross.option.arm.target.mcpu.cortex-m4">
12561256
</checkOption> </enablement> -->
12571257
<enumeratedOptionValue
12581258
id="ilg.gnuarmeclipse.managedbuild.cross.option.arm.target.fpu.unit.default"
@@ -2901,7 +2901,13 @@
29012901
<option
29022902
category="ilg.gnuarmeclipse.managedbuild.cross.optionCategory.c.linker.libs"
29032903
id="ilg.gnuarmeclipse.managedbuild.cross.option.c.linker.libs"
2904-
superClass="ilg.gnumcueclipse.managedbuild.cross.option.base.linker.libs">
2904+
superClass="ilg.gnumcueclipse.managedbuild.cross.option.base.linker.libs"
2905+
commandGenerator="org.eclipse.embedcdt.managedbuild.cross.arm.core.LibrariesCommandGeneratorC">
2906+
</option>
2907+
<option
2908+
category="ilg.gnuarmeclipse.managedbuild.cross.optionCategory.c.linker.libs"
2909+
id="ilg.gnuarmeclipse.managedbuild.cross.option.c.linker.grouplibs"
2910+
superClass="ilg.gnumcueclipse.managedbuild.cross.option.base.linker.grouplibs">
29052911
</option>
29062912
<option
29072913
category="ilg.gnuarmeclipse.managedbuild.cross.optionCategory.c.linker.libs"
@@ -3091,7 +3097,13 @@
30913097
<option
30923098
category="ilg.gnuarmeclipse.managedbuild.cross.optionCategory.cpp.linker.libs"
30933099
id="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.linker.libs"
3094-
superClass="ilg.gnumcueclipse.managedbuild.cross.option.base.linker.libs">
3100+
superClass="ilg.gnumcueclipse.managedbuild.cross.option.base.linker.libs"
3101+
commandGenerator="org.eclipse.embedcdt.managedbuild.cross.arm.core.LibrariesCommandGeneratorCpp">
3102+
</option>
3103+
<option
3104+
category="ilg.gnuarmeclipse.managedbuild.cross.optionCategory.cpp.linker.libs"
3105+
id="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.linker.grouplibs"
3106+
superClass="ilg.gnumcueclipse.managedbuild.cross.option.base.linker.grouplibs">
30953107
</option>
30963108
<option
30973109
category="ilg.gnuarmeclipse.managedbuild.cross.optionCategory.cpp.linker.libs"
@@ -3580,14 +3592,14 @@
35803592
name="FLASH Hex file"
35813593
priority="normal">
35823594
</content-type>
3583-
<!-- <content-type id="ilg.gnuarmeclipse.managedbuild.cross.content-type.s"
3584-
name=".s Assembly file" base-type="org.eclipse.cdt.core.asmSource" file-extensions="s"
3585-
priority="high" /> <file-association content-type="org.eclipse.cdt.core.asmSource"
3595+
<!-- <content-type id="ilg.gnuarmeclipse.managedbuild.cross.content-type.s"
3596+
name=".s Assembly file" base-type="org.eclipse.cdt.core.asmSource" file-extensions="s"
3597+
priority="high" /> <file-association content-type="org.eclipse.cdt.core.asmSource"
35863598
file-extensions="s,S,asm"> </file-association> -->
35873599
</extension>
3588-
<!-- <extension point="org.eclipse.cdt.core.language"> <language class="org.eclipse.cdt.core.model.AssemblyLanguage"
3589-
id="ilg.gnuarmeclipse.managedbuild.cross.assembly" name="Assembly"> <contentType
3590-
id="ilg.gnuarmeclipse.managedbuild.cross.content-type.s"> </contentType>
3600+
<!-- <extension point="org.eclipse.cdt.core.language"> <language class="org.eclipse.cdt.core.model.AssemblyLanguage"
3601+
id="ilg.gnuarmeclipse.managedbuild.cross.assembly" name="Assembly"> <contentType
3602+
id="ilg.gnuarmeclipse.managedbuild.cross.content-type.s"> </contentType>
35913603
</language> </extension> -->
35923604
<extension point="org.eclipse.cdt.core.templates">
35933605
<template
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2023 John Dallaway and others.
3+
*
4+
* This program and the accompanying materials
5+
* are made available under the terms of the Eclipse Public License 2.0
6+
* which accompanies this distribution, and is available at
7+
* https://www.eclipse.org/legal/epl-2.0/
8+
*
9+
* SPDX-License-Identifier: EPL-2.0
10+
*
11+
* Contributors:
12+
* John Dallaway - initial implementation (#608)
13+
* Liviu Ionescu - adjust for ECDT
14+
*******************************************************************************/
15+
package org.eclipse.embedcdt.managedbuild.cross.arm.core;
16+
17+
import org.eclipse.embedcdt.managedbuild.cross.core.LibrariesCommandGenerator;
18+
19+
/**
20+
* A libraries command generator for GNU C projects.
21+
* @noextend This class is not intended to be subclassed by clients.
22+
* @noinstantiate This class is not intended to be instantiated by clients.
23+
* @since 8.6
24+
*/
25+
public class LibrariesCommandGeneratorC extends LibrariesCommandGenerator {
26+
27+
public LibrariesCommandGeneratorC() {
28+
super("ilg.gnuarmeclipse.managedbuild.cross.option.c.linker.grouplibs"); //$NON-NLS-1$
29+
}
30+
31+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2023 John Dallaway and others.
3+
*
4+
* This program and the accompanying materials
5+
* are made available under the terms of the Eclipse Public License 2.0
6+
* which accompanies this distribution, and is available at
7+
* https://www.eclipse.org/legal/epl-2.0/
8+
*
9+
* SPDX-License-Identifier: EPL-2.0
10+
*
11+
* Contributors:
12+
* John Dallaway - initial implementation (#608)
13+
* Liviu Ionescu - adjust for ECDT
14+
*******************************************************************************/
15+
package org.eclipse.embedcdt.managedbuild.cross.arm.core;
16+
17+
import org.eclipse.embedcdt.managedbuild.cross.core.LibrariesCommandGenerator;
18+
19+
/**
20+
* A libraries command generator for GNU C projects.
21+
* @noextend This class is not intended to be subclassed by clients.
22+
* @noinstantiate This class is not intended to be instantiated by clients.
23+
* @since 8.6
24+
*/
25+
public class LibrariesCommandGeneratorCpp extends LibrariesCommandGenerator {
26+
27+
public LibrariesCommandGeneratorCpp() {
28+
super("ilg.gnuarmeclipse.managedbuild.cross.option.cpp.linker.grouplibs"); //$NON-NLS-1$
29+
}
30+
31+
}

plugins/org.eclipse.embedcdt.managedbuild.cross.core/plugin.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ option.linker.printgcsections=Print removed sections (-Xlinker --print-gc-sectio
9191
option.linker.strip=Omit all symbol information (-s)
9292
option.linker.libs=Libraries (-l)
9393
option.linker.paths=Library search path (-L)
94+
option.linker.grouplibs=Group libraries (-Wl,--start-group, ... ,--end-group)
9495
option.linker.flags=Linker flags (-Xlinker [option])
9596
option.linker.otherobjs=Other objects
9697
option.linker.other=Other linker flags

plugins/org.eclipse.embedcdt.managedbuild.cross.core/plugin.xml

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<?eclipse version="3.4"?>
3-
<!--
4-
Copyright (c) 2009, 2011 Wind River Systems, Inc. and others.
5-
This program and the accompanying materials
6-
are made available under the terms of the Eclipse Public License 2.0
7-
which accompanies this distribution, and is available at
3+
<!--
4+
Copyright (c) 2009, 2011 Wind River Systems, Inc. and others.
5+
This program and the accompanying materials
6+
are made available under the terms of the Eclipse Public License 2.0
7+
which accompanies this distribution, and is available at
88
https://www.eclipse.org/legal/epl-2.0/
99
10-
SPDX-License-Identifier: EPL-2.0
11-
12-
Contributors:
13-
Doug Schaefer (Wind River) - initial API and implementation
14-
Anna Dushistova (Mentor Graphics)- [329531][crossgcc] crossgcc fails to
15-
build a project
16-
Liviu Ionescu - MCU version
10+
SPDX-License-Identifier: EPL-2.0
11+
12+
Contributors:
13+
Doug Schaefer (Wind River) - initial API and implementation
14+
Anna Dushistova (Mentor Graphics)- [329531][crossgcc] crossgcc fails to
15+
build a project
16+
Liviu Ionescu - MCU version
1717
-->
1818
<plugin>
1919
<extension point="org.eclipse.cdt.managedbuilder.core.buildDefinitions">
@@ -662,6 +662,13 @@
662662
name="%option.linker.paths"
663663
valueType="libPaths">
664664
</option>
665+
<option
666+
defaultValue="false"
667+
id="ilg.gnumcueclipse.managedbuild.cross.option.base.linker.grouplibs"
668+
isAbstract="true"
669+
name="%option.linker.grouplibs"
670+
valueType="boolean">
671+
</option>
665672
<option
666673
command="-Xlinker ${VALUE}"
667674
id="ilg.gnumcueclipse.managedbuild.cross.option.base.linker.flags"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2023 John Dallaway and others.
3+
*
4+
* This program and the accompanying materials
5+
* are made available under the terms of the Eclipse Public License 2.0
6+
* which accompanies this distribution, and is available at
7+
* https://www.eclipse.org/legal/epl-2.0/
8+
*
9+
* SPDX-License-Identifier: EPL-2.0
10+
*
11+
* Contributors:
12+
* John Dallaway - initial implementation (#608)
13+
* Liviu Ionescu - use single `-Wl,` string
14+
*******************************************************************************/
15+
package org.eclipse.embedcdt.managedbuild.cross.core;
16+
17+
import java.util.Arrays;
18+
import java.util.stream.Collectors;
19+
20+
import org.eclipse.cdt.core.cdtvariables.CdtVariableException;
21+
import org.eclipse.cdt.managedbuilder.core.BuildException;
22+
import org.eclipse.cdt.managedbuilder.core.IOption;
23+
import org.eclipse.cdt.managedbuilder.core.IOptionCommandGenerator;
24+
import org.eclipse.cdt.utils.cdtvariables.CdtVariableResolver;
25+
import org.eclipse.cdt.utils.cdtvariables.IVariableSubstitutor;
26+
import org.eclipse.core.runtime.Platform;
27+
import org.eclipse.core.runtime.Status;
28+
29+
/**
30+
* An option command generator to group libraries on the GNU linker command line
31+
* @noinstantiate This class is not intended to be instantiated by clients.
32+
* @since 8.6
33+
*/
34+
public class LibrariesCommandGenerator implements IOptionCommandGenerator {
35+
36+
private static final String GROUP_LIBRARIES_COMMAND_FORMAT = "-Wl,--start-group,%s,--end-group"; //$NON-NLS-1$
37+
38+
private final String fGroupLibrariesOptionId;
39+
40+
/**
41+
* @param groupLibrariesOptionId the ID of the IOption controlling library grouping
42+
*/
43+
protected LibrariesCommandGenerator(String groupLibrariesOptionId) {
44+
fGroupLibrariesOptionId = groupLibrariesOptionId;
45+
}
46+
47+
@Override
48+
public String generateCommand(IOption option, IVariableSubstitutor macroSubstitutor) {
49+
IOption groupOption = option.getOptionHolder().getOptionBySuperClassId(fGroupLibrariesOptionId);
50+
try {
51+
if ((groupOption != null) && groupOption.getBooleanValue()) { // if library grouping enabled
52+
String command = option.getCommand();
53+
String libraries = Arrays.stream(option.getLibraries()).map(lib -> command + lib)
54+
.collect(Collectors.joining(",")); //$NON-NLS-1$
55+
if (!libraries.isEmpty()) {
56+
libraries = CdtVariableResolver.resolveToString(libraries, macroSubstitutor);
57+
return String.format(GROUP_LIBRARIES_COMMAND_FORMAT, libraries);
58+
}
59+
}
60+
} catch (BuildException | CdtVariableException e) {
61+
Platform.getLog(getClass()).log(Status.error("Error generating libraries command", e)); //$NON-NLS-1$
62+
}
63+
return null; // fallback to default command generator
64+
}
65+
66+
}

plugins/org.eclipse.embedcdt.managedbuild.cross.riscv.core/plugin.xml

Lines changed: 31 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<?eclipse version="3.4"?>
3-
<!--
4-
Copyright (c) 2009, 2023 Wind River Systems, Inc. and others.
3+
<!--
4+
Copyright (c) 2009, 2023 Wind River Systems, Inc. and others.
55
6-
This program and the accompanying materials
7-
are made available under the terms of the Eclipse Public License 2.0
8-
which accompanies this distribution, and is available at
6+
This program and the accompanying materials
7+
are made available under the terms of the Eclipse Public License 2.0
8+
which accompanies this distribution, and is available at
99
https://www.eclipse.org/legal/epl-2.0/
1010
11-
SPDX-License-Identifier: EPL-2.0
11+
SPDX-License-Identifier: EPL-2.0
1212
13-
Contributors:
14-
Doug Schaefer (Wind River) - initial API and implementation
15-
Anna Dushistova (Mentor Graphics)- [329531][crossgcc] crossgcc fails to build a project
16-
Liviu Ionescu - RISC-V version
13+
Contributors:
14+
Doug Schaefer (Wind River) - initial API and implementation
15+
Anna Dushistova (Mentor Graphics)- [329531][crossgcc] crossgcc fails to build a project
16+
Liviu Ionescu - RISC-V version
1717
Alexander Fedorov (ArSysOp) - extract UI part
1818
John Dallaway - use GNU ELF binary parser (#567)
1919
-->
@@ -595,7 +595,7 @@
595595
command="-mno-strict-align"
596596
name="%option.target.align.nostrict">
597597
</enumeratedOptionValue>
598-
</option>
598+
</option>
599599
</tool>
600600
<toolChain
601601
archList="all"
@@ -1812,7 +1812,13 @@
18121812
<option
18131813
category="ilg.gnumcueclipse.managedbuild.cross.riscv.optionCategory.c.linker.libs"
18141814
id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.libs"
1815-
superClass="ilg.gnumcueclipse.managedbuild.cross.option.base.linker.libs">
1815+
superClass="ilg.gnumcueclipse.managedbuild.cross.option.base.linker.libs"
1816+
commandGenerator="org.eclipse.embedcdt.managedbuild.cross.riscv.core.LibrariesCommandGeneratorC">
1817+
</option>
1818+
<option
1819+
category="ilg.gnumcueclipse.managedbuild.cross.riscv.optionCategory.c.linker.libs"
1820+
id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.grouplibs"
1821+
superClass="ilg.gnumcueclipse.managedbuild.cross.option.base.linker.grouplibs">
18161822
</option>
18171823
<option
18181824
category="ilg.gnumcueclipse.managedbuild.cross.riscv.optionCategory.c.linker.libs"
@@ -2002,7 +2008,13 @@
20022008
<option
20032009
category="ilg.gnumcueclipse.managedbuild.cross.riscv.optionCategory.cpp.linker.libs"
20042010
id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.libs"
2005-
superClass="ilg.gnumcueclipse.managedbuild.cross.option.base.linker.libs">
2011+
superClass="ilg.gnumcueclipse.managedbuild.cross.option.base.linker.libs"
2012+
commandGenerator="org.eclipse.embedcdt.managedbuild.cross.riscv.core.LibrariesCommandGeneratorCpp">
2013+
</option>
2014+
<option
2015+
category="ilg.gnumcueclipse.managedbuild.cross.riscv.optionCategory.cpp.linker.libs"
2016+
id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.grouplibs"
2017+
superClass="ilg.gnumcueclipse.managedbuild.cross.option.base.linker.grouplibs">
20062018
</option>
20072019
<option
20082020
category="ilg.gnumcueclipse.managedbuild.cross.riscv.optionCategory.cpp.linker.libs"
@@ -2493,14 +2505,14 @@
24932505
name="FLASH Hex file"
24942506
priority="normal">
24952507
</content-type>
2496-
<!-- <content-type id="ilg.gnumcueclipse.managedbuild.cross.riscv.content-type.s"
2497-
name=".s Assembly file" base-type="org.eclipse.cdt.core.asmSource" file-extensions="s"
2498-
priority="high" /> <file-association content-type="org.eclipse.cdt.core.asmSource"
2508+
<!-- <content-type id="ilg.gnumcueclipse.managedbuild.cross.riscv.content-type.s"
2509+
name=".s Assembly file" base-type="org.eclipse.cdt.core.asmSource" file-extensions="s"
2510+
priority="high" /> <file-association content-type="org.eclipse.cdt.core.asmSource"
24992511
file-extensions="s,S,asm"> </file-association> -->
25002512
</extension>
2501-
<!-- <extension point="org.eclipse.cdt.core.language"> <language class="org.eclipse.cdt.core.model.AssemblyLanguage"
2502-
id="ilg.gnumcueclipse.managedbuild.cross.riscv.assembly" name="Assembly">
2503-
<contentType id="ilg.gnumcueclipse.managedbuild.cross.riscv.content-type.s">
2513+
<!-- <extension point="org.eclipse.cdt.core.language"> <language class="org.eclipse.cdt.core.model.AssemblyLanguage"
2514+
id="ilg.gnumcueclipse.managedbuild.cross.riscv.assembly" name="Assembly">
2515+
<contentType id="ilg.gnumcueclipse.managedbuild.cross.riscv.content-type.s">
25042516
</contentType> </language> </extension> -->
25052517
<extension point="org.eclipse.cdt.core.templates">
25062518
<template

0 commit comments

Comments
 (0)