mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-20 07:25:23 +02:00
Invoke "gcc" to build assembler files
Enables pre-processing of *.S and *.sx source files.
This commit is contained in:
parent
61c3568839
commit
233c6d8696
14 changed files with 118 additions and 7 deletions
|
@ -2,7 +2,7 @@ Manifest-Version: 1.0
|
||||||
Bundle-ManifestVersion: 2
|
Bundle-ManifestVersion: 2
|
||||||
Bundle-Name: %pluginName
|
Bundle-Name: %pluginName
|
||||||
Bundle-SymbolicName: org.eclipse.cdt.managedbuilder.core.tests; singleton:=true
|
Bundle-SymbolicName: org.eclipse.cdt.managedbuilder.core.tests; singleton:=true
|
||||||
Bundle-Version: 8.2.300.qualifier
|
Bundle-Version: 8.2.400.qualifier
|
||||||
Bundle-Activator: org.eclipse.cdt.managedbuilder.testplugin.CTestPlugin
|
Bundle-Activator: org.eclipse.cdt.managedbuilder.testplugin.CTestPlugin
|
||||||
Bundle-Vendor: %providerName
|
Bundle-Vendor: %providerName
|
||||||
Bundle-Localization: plugin
|
Bundle-Localization: plugin
|
||||||
|
|
|
@ -6,6 +6,7 @@ ASM_SRCS :=
|
||||||
C_SRCS :=
|
C_SRCS :=
|
||||||
OBJ_SRCS :=
|
OBJ_SRCS :=
|
||||||
O_SRCS :=
|
O_SRCS :=
|
||||||
|
SX_SRCS :=
|
||||||
S_UPPER_SRCS :=
|
S_UPPER_SRCS :=
|
||||||
C_DEPS :=
|
C_DEPS :=
|
||||||
EXECUTABLES :=
|
EXECUTABLES :=
|
||||||
|
|
|
@ -6,6 +6,7 @@ ASM_SRCS :=
|
||||||
C_SRCS :=
|
C_SRCS :=
|
||||||
OBJ_SRCS :=
|
OBJ_SRCS :=
|
||||||
O_SRCS :=
|
O_SRCS :=
|
||||||
|
SX_SRCS :=
|
||||||
S_UPPER_SRCS :=
|
S_UPPER_SRCS :=
|
||||||
C_DEPS :=
|
C_DEPS :=
|
||||||
EXECUTABLES :=
|
EXECUTABLES :=
|
||||||
|
|
|
@ -6,6 +6,7 @@ ASM_SRCS :=
|
||||||
C_SRCS :=
|
C_SRCS :=
|
||||||
OBJ_SRCS :=
|
OBJ_SRCS :=
|
||||||
O_SRCS :=
|
O_SRCS :=
|
||||||
|
SX_SRCS :=
|
||||||
S_UPPER_SRCS :=
|
S_UPPER_SRCS :=
|
||||||
C_DEPS :=
|
C_DEPS :=
|
||||||
EXECUTABLES :=
|
EXECUTABLES :=
|
||||||
|
|
|
@ -12,6 +12,7 @@ CXXM_SRCS :=
|
||||||
CXX_SRCS :=
|
CXX_SRCS :=
|
||||||
C_UPPER_SRCS :=
|
C_UPPER_SRCS :=
|
||||||
LOG_SRCS :=
|
LOG_SRCS :=
|
||||||
|
SX_SRCS :=
|
||||||
S_UPPER_SRCS :=
|
S_UPPER_SRCS :=
|
||||||
TAR_SRCS :=
|
TAR_SRCS :=
|
||||||
LOGFILE :=
|
LOGFILE :=
|
||||||
|
|
|
@ -6,6 +6,7 @@ ASM_SRCS :=
|
||||||
C_SRCS :=
|
C_SRCS :=
|
||||||
OBJ_SRCS :=
|
OBJ_SRCS :=
|
||||||
O_SRCS :=
|
O_SRCS :=
|
||||||
|
SX_SRCS :=
|
||||||
S_UPPER_SRCS :=
|
S_UPPER_SRCS :=
|
||||||
C_DEPS :=
|
C_DEPS :=
|
||||||
EXECUTABLES :=
|
EXECUTABLES :=
|
||||||
|
|
|
@ -14,6 +14,7 @@ C_SRCS :=
|
||||||
C_UPPER_SRCS :=
|
C_UPPER_SRCS :=
|
||||||
OBJ_SRCS :=
|
OBJ_SRCS :=
|
||||||
O_SRCS :=
|
O_SRCS :=
|
||||||
|
SX_SRCS :=
|
||||||
S_UPPER_SRCS :=
|
S_UPPER_SRCS :=
|
||||||
C++M_DEPS :=
|
C++M_DEPS :=
|
||||||
C++_DEPS :=
|
C++_DEPS :=
|
||||||
|
|
|
@ -14,6 +14,7 @@ C_SRCS :=
|
||||||
C_UPPER_SRCS :=
|
C_UPPER_SRCS :=
|
||||||
OBJ_SRCS :=
|
OBJ_SRCS :=
|
||||||
O_SRCS :=
|
O_SRCS :=
|
||||||
|
SX_SRCS :=
|
||||||
S_UPPER_SRCS :=
|
S_UPPER_SRCS :=
|
||||||
C++M_DEPS :=
|
C++M_DEPS :=
|
||||||
C++_DEPS :=
|
C++_DEPS :=
|
||||||
|
|
|
@ -2,7 +2,7 @@ Manifest-Version: 1.0
|
||||||
Bundle-ManifestVersion: 2
|
Bundle-ManifestVersion: 2
|
||||||
Bundle-Name: %pluginName
|
Bundle-Name: %pluginName
|
||||||
Bundle-SymbolicName: org.eclipse.cdt.managedbuilder.core; singleton:=true
|
Bundle-SymbolicName: org.eclipse.cdt.managedbuilder.core; singleton:=true
|
||||||
Bundle-Version: 9.6.200.qualifier
|
Bundle-Version: 9.6.300.qualifier
|
||||||
Bundle-Activator: org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin
|
Bundle-Activator: org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin
|
||||||
Bundle-Vendor: %providerName
|
Bundle-Vendor: %providerName
|
||||||
Bundle-Localization: plugin
|
Bundle-Localization: plugin
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2006, 2010 Intel Corporation and others.
|
* Copyright (c) 2006, 2024 Intel Corporation and others.
|
||||||
*
|
*
|
||||||
* This program and the accompanying materials
|
* This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License 2.0
|
* are made available under the terms of the Eclipse Public License 2.0
|
||||||
|
@ -10,6 +10,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Intel Corporation - Initial API and implementation
|
* Intel Corporation - Initial API and implementation
|
||||||
|
* John Dallaway - Provide getter for IConfiguration (#666)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.managedbuilder.internal.buildmodel;
|
package org.eclipse.cdt.managedbuilder.internal.buildmodel;
|
||||||
|
@ -36,6 +37,10 @@ public class FileMacroExplicitSubstitutor extends SupplierBasedCdtVariableSubsti
|
||||||
fBuilder = builder;
|
fBuilder = builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IConfiguration getConfiguration() {
|
||||||
|
return fCfg;
|
||||||
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.managedbuilder.internal.macros.DefaultMacroSubstitutor#resolveMacro(org.eclipse.cdt.managedbuilder.macros.IBuildMacro)
|
* @see org.eclipse.cdt.managedbuilder.internal.macros.DefaultMacroSubstitutor#resolveMacro(org.eclipse.cdt.managedbuilder.macros.IBuildMacro)
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -2,7 +2,7 @@ Manifest-Version: 1.0
|
||||||
Bundle-ManifestVersion: 2
|
Bundle-ManifestVersion: 2
|
||||||
Bundle-Name: %pluginName
|
Bundle-Name: %pluginName
|
||||||
Bundle-SymbolicName: org.eclipse.cdt.managedbuilder.gnu.ui; singleton:=true
|
Bundle-SymbolicName: org.eclipse.cdt.managedbuilder.gnu.ui; singleton:=true
|
||||||
Bundle-Version: 8.6.100.qualifier
|
Bundle-Version: 8.7.0.qualifier
|
||||||
Bundle-Activator: org.eclipse.cdt.managedbuilder.gnu.ui.GnuUIPlugin
|
Bundle-Activator: org.eclipse.cdt.managedbuilder.gnu.ui.GnuUIPlugin
|
||||||
Bundle-Vendor: %providerName
|
Bundle-Vendor: %providerName
|
||||||
Bundle-Localization: plugin
|
Bundle-Localization: plugin
|
||||||
|
|
|
@ -565,7 +565,7 @@
|
||||||
id="gnu.windres.option.preprocessor.undefined.symbols"/>
|
id="gnu.windres.option.preprocessor.undefined.symbols"/>
|
||||||
</tool-->
|
</tool-->
|
||||||
<tool
|
<tool
|
||||||
command="as"
|
command="gcc"
|
||||||
name="%ToolName.assembler.gnu"
|
name="%ToolName.assembler.gnu"
|
||||||
outputFlag="-o"
|
outputFlag="-o"
|
||||||
id="cdt.managedbuild.tool.gnu.assembler"
|
id="cdt.managedbuild.tool.gnu.assembler"
|
||||||
|
@ -579,6 +579,8 @@
|
||||||
<option
|
<option
|
||||||
name="%Option.Gnu.Assembler.Flags"
|
name="%Option.Gnu.Assembler.Flags"
|
||||||
category="gnu.asm.category.general"
|
category="gnu.asm.category.general"
|
||||||
|
commandGenerator="org.eclipse.cdt.managedbuilder.gnu.ui.GnuAsmFlagsCommandGenerator"
|
||||||
|
defaultValue="-c"
|
||||||
valueType="string"
|
valueType="string"
|
||||||
id="gnu.both.asm.option.flags">
|
id="gnu.both.asm.option.flags">
|
||||||
</option>
|
</option>
|
||||||
|
@ -607,7 +609,7 @@
|
||||||
id="cdt.managedbuild.tool.gnu.assembler.input"
|
id="cdt.managedbuild.tool.gnu.assembler.input"
|
||||||
languageId="org.eclipse.cdt.core.assembly"
|
languageId="org.eclipse.cdt.core.assembly"
|
||||||
sourceContentType="org.eclipse.cdt.core.asmSource"
|
sourceContentType="org.eclipse.cdt.core.asmSource"
|
||||||
sources="s,S">
|
sources="s,sx,S">
|
||||||
</inputType>
|
</inputType>
|
||||||
<outputType
|
<outputType
|
||||||
outputs="o"
|
outputs="o"
|
||||||
|
|
|
@ -0,0 +1,97 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2024 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 (#666)
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.managedbuilder.gnu.ui;
|
||||||
|
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.cdtvariables.CdtVariableException;
|
||||||
|
import org.eclipse.cdt.managedbuilder.core.BuildException;
|
||||||
|
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
||||||
|
import org.eclipse.cdt.managedbuilder.core.IOption;
|
||||||
|
import org.eclipse.cdt.managedbuilder.core.IOptionCommandGenerator;
|
||||||
|
import org.eclipse.cdt.managedbuilder.core.ITool;
|
||||||
|
import org.eclipse.cdt.managedbuilder.internal.buildmodel.FileMacroExplicitSubstitutor;
|
||||||
|
import org.eclipse.cdt.managedbuilder.internal.macros.BuildfileMacroSubstitutor;
|
||||||
|
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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Assembler flags command generator.
|
||||||
|
* This command generator supports managed build projects that were
|
||||||
|
* created using older versions of the GNU toolchain build description
|
||||||
|
* where assembly files were built by invoking the GNU "as" tool directly.
|
||||||
|
* @noextend This class is not intended to be subclassed by clients.
|
||||||
|
* @noinstantiate This class is not intended to be instantiated by clients.
|
||||||
|
* @since 8.7
|
||||||
|
*/
|
||||||
|
public class GnuAsmFlagsCommandGenerator implements IOptionCommandGenerator {
|
||||||
|
|
||||||
|
private static final String DO_NOT_LINK_FLAG = "-c"; //$NON-NLS-1$
|
||||||
|
private static final Pattern DO_NOT_LINK_PATTERN = Pattern.compile("(^|\\s)-c($|\\s)"); //$NON-NLS-1$
|
||||||
|
private static final Pattern ASM_FLAG_PATTERN = Pattern.compile("-[aDKLR]\\S*"); //$NON-NLS-1$
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String generateCommand(IOption option, IVariableSubstitutor macroSubstitutor) {
|
||||||
|
String toolCommand = getToolCommand(option, macroSubstitutor);
|
||||||
|
try {
|
||||||
|
if (null != toolCommand && IOption.STRING == option.getValueType() && option.getCommand().isEmpty()) {
|
||||||
|
String optionValue = option.getStringValue();
|
||||||
|
if (toolCommand.equals("gcc")) { //$NON-NLS-1$
|
||||||
|
// if the default assembler tool command has not been overridden
|
||||||
|
String command = CdtVariableResolver.resolveToString(optionValue, macroSubstitutor);
|
||||||
|
if (!DO_NOT_LINK_PATTERN.matcher(command).find()) {
|
||||||
|
// if the "-c" flag is not already present on the command line we
|
||||||
|
// assume the flags target the GNU "as" command line rather than the
|
||||||
|
// "gcc" command line so we add the "-c" flag and apply the "-Wa,"
|
||||||
|
// prefix to those flags that are intended only for the assembler
|
||||||
|
return DO_NOT_LINK_FLAG + " " + ASM_FLAG_PATTERN.matcher(command).replaceAll("-Wa,$0"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
}
|
||||||
|
} else if (toolCommand.endsWith("as") && optionValue.equals(DO_NOT_LINK_FLAG)) { //$NON-NLS-1$
|
||||||
|
// if GNU "as" is called directly and the default assembler flags have
|
||||||
|
// not been overridden we remove the "-c" flag
|
||||||
|
return ""; //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (BuildException | CdtVariableException e) {
|
||||||
|
Platform.getLog(getClass()).log(Status.error("Error generating GNU assembler command", e)); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
return null; // fallback to default command generator
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String getToolCommand(IOption option, IVariableSubstitutor macroSubstitutor) {
|
||||||
|
// the option holder may be a super class of the assembler tool so we must
|
||||||
|
// locate the tool from the build configuration to obtain the correct tool command
|
||||||
|
IConfiguration config = getConfiguration(macroSubstitutor);
|
||||||
|
if (config != null) {
|
||||||
|
String optionHolderId = option.getOptionHolder().getId();
|
||||||
|
ITool[] tools = config.getToolsBySuperClassId(optionHolderId);
|
||||||
|
if (1 == tools.length) {
|
||||||
|
return tools[0].getToolCommand();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static IConfiguration getConfiguration(IVariableSubstitutor macroSubstitutor) {
|
||||||
|
if (macroSubstitutor instanceof BuildfileMacroSubstitutor bms) { // case ToolSettingsPrefStore
|
||||||
|
return bms.getConfiguration();
|
||||||
|
} else if (macroSubstitutor instanceof FileMacroExplicitSubstitutor fmes) { // case BuildStep
|
||||||
|
return fmes.getConfiguration();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -625,7 +625,7 @@
|
||||||
<!-- declares a content type for ASM Source files -->
|
<!-- declares a content type for ASM Source files -->
|
||||||
<content-type id="asmSource" name="%asmSourceName"
|
<content-type id="asmSource" name="%asmSourceName"
|
||||||
base-type="org.eclipse.core.runtime.text"
|
base-type="org.eclipse.core.runtime.text"
|
||||||
file-extensions="S,s,asm,ASM"
|
file-extensions="S,s,sx,asm,ASM"
|
||||||
priority="high"/>
|
priority="high"/>
|
||||||
</extension>
|
</extension>
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue