forked from eclipse-cdt/cdt
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Invoke "gcc" to build assembler files
Enables pre-processing of *.S and *.sx source files.
- Loading branch information
Showing
9 changed files
with
76 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ ASM_SRCS := | |
C_SRCS := | ||
OBJ_SRCS := | ||
O_SRCS := | ||
SX_SRCS := | ||
S_UPPER_SRCS := | ||
C_DEPS := | ||
EXECUTABLES := | ||
|
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 |
---|---|---|
|
@@ -6,6 +6,7 @@ ASM_SRCS := | |
C_SRCS := | ||
OBJ_SRCS := | ||
O_SRCS := | ||
SX_SRCS := | ||
S_UPPER_SRCS := | ||
C_DEPS := | ||
EXECUTABLES := | ||
|
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 |
---|---|---|
|
@@ -6,6 +6,7 @@ ASM_SRCS := | |
C_SRCS := | ||
OBJ_SRCS := | ||
O_SRCS := | ||
SX_SRCS := | ||
S_UPPER_SRCS := | ||
C_DEPS := | ||
EXECUTABLES := | ||
|
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 |
---|---|---|
|
@@ -14,6 +14,7 @@ C_SRCS := | |
C_UPPER_SRCS := | ||
OBJ_SRCS := | ||
O_SRCS := | ||
SX_SRCS := | ||
S_UPPER_SRCS := | ||
C++M_DEPS := | ||
C++_DEPS := | ||
|
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
65 changes: 65 additions & 0 deletions
65
...builder.gnu.ui/src/org/eclipse/cdt/managedbuilder/gnu/ui/GnuAsmFlagsCommandGenerator.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,65 @@ | ||
/******************************************************************************* | ||
* 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.IHoldsOptions; | ||
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.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. | ||
* @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 Pattern DO_NOT_LINK_FLAG = Pattern.compile("(^|\\s)-c($|\\s)"); //$NON-NLS-1$ | ||
private static final Pattern ASM_FLAG = Pattern.compile("-[aDKLR]\\S*"); //$NON-NLS-1$ | ||
|
||
@Override | ||
public String generateCommand(IOption option, IVariableSubstitutor macroSubstitutor) { | ||
IHoldsOptions optionHolder = option.getOptionHolder(); | ||
if (optionHolder instanceof ITool tool) { | ||
try { | ||
// if the default assembler tool command has not been overridden | ||
if (tool.getToolCommand().equals("gcc") && option.getCommand().isEmpty() //$NON-NLS-1$ | ||
&& IOption.STRING == option.getValueType()) { | ||
String optionValue = option.getStringValue(); | ||
String command = CdtVariableResolver.resolveToString(optionValue, macroSubstitutor); | ||
if (!DO_NOT_LINK_FLAG.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 "-c " + ASM_FLAG.matcher(command).replaceAll("-Wa,$0"); //$NON-NLS-1$ //$NON-NLS-2$ | ||
} | ||
} | ||
} 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 | ||
} | ||
|
||
} |
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