1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-07 17:56:01 +02:00

extern'd strings

This commit is contained in:
David Inglis 2004-03-03 16:40:02 +00:00
parent fc37d2f92c
commit 496956a5ac
40 changed files with 261 additions and 143 deletions

View file

@ -20,7 +20,7 @@ import org.eclipse.cdt.make.core.makefile.IDefaultRule;
public class DefaultRule extends SpecialRule implements IDefaultRule { public class DefaultRule extends SpecialRule implements IDefaultRule {
public DefaultRule(Directive parent, Command[] cmds) { public DefaultRule(Directive parent, Command[] cmds) {
super(parent, new Target(".DEFAULT"), new String[0], cmds); //$NON-NLS-1$ super(parent, new Target(MakeFileConstants.RULE_DEFAULT), new String[0], cmds);
} }
} }

View file

@ -21,7 +21,7 @@ import org.eclipse.cdt.make.core.makefile.IIgnoreRule;
public class IgnoreRule extends SpecialRule implements IIgnoreRule { public class IgnoreRule extends SpecialRule implements IIgnoreRule {
public IgnoreRule(Directive parent, String[] reqs) { public IgnoreRule(Directive parent, String[] reqs) {
super(parent, new Target(".IGNORE"), reqs, new Command[0]); //$NON-NLS-1$ super(parent, new Target(MakeFileConstants.RULE_IGNORE), reqs, new Command[0]);
} }
} }

View file

@ -0,0 +1,22 @@
/*
* Created on Mar 2, 2004
*
* Copyright (c) 2002,2003 QNX Software Systems Ltd.
*
* Contributors:
* QNX Software Systems - Initial API and implementation
***********************************************************************/
package org.eclipse.cdt.make.internal.core.makefile;
public class MakeFileConstants {
public static final String RULE_DEFAULT = ".DEFAULT"; //$NON-NLS-1$
public static final String RULE_IGNORE =".IGNORE"; //$NON-NLS-1$
public static final String RULE_POSIX = ".POSIX"; //$NON-NLS-1$
public static final String RULE_PRECIOUS = ".PRECIOUS"; //$NON-NLS-1$
public static final String RULE_SCCS_GET = ".SCCS_GET"; //$NON-NLS-1$
public static final String RULE_SILENT = ".SILENT"; //$NON-NLS-1$
public static final String RULE_SUFFIXES = ".SUFFIXES"; //$NON-NLS-1$
}

View file

@ -0,0 +1,13 @@
MakefileValidator.errorBuild=Error Build
MakefileValidator.errorResource=Error resource
MakefileValidator.warningInfo=Warning info
MakefileValidator.warning=Warning
MakefileValidator.unknown=unknown
MakefileValidator.checkingFile=Checking file :
MakefileValidator.fileChecked=File checked
MakefileValidator.error.elseMissingIfCondition=else missing if condition
MakefileValidator.error.endifMissingIfElseCondition=Endif missing if/else condition
MakefileValidator.error.endefMissingOverrideDefine=endef missing [override] define
MakefileValidator.error.unknownDirective=unknow directive
MakefileValidator.error.noMatchingEndifForCondition=No matching endif for condition
MakefileValidator.error.noMatchingEndefForOverrideDefine=No matching endef for [override] define

View file

@ -0,0 +1,31 @@
/*
* Created on Mar 3, 2004
*
* Copyright (c) 2002,2003 QNX Software Systems Ltd.
*
* Contributors:
* QNX Software Systems - Initial API and implementation
***********************************************************************/
package org.eclipse.cdt.make.internal.core.makefile;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
public class MakefileMessages {
private static final String BUNDLE_NAME = "org.eclipse.cdt.make.internal.core.makefile.MakeFileResources";//$NON-NLS-1$
private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle
.getBundle(BUNDLE_NAME);
private MakefileMessages() {
}
public static String getString(String key) {
try {
return RESOURCE_BUNDLE.getString(key);
} catch (MissingResourceException e) {
return '!' + key + '!';
}
}
}

View file

@ -20,6 +20,6 @@ import org.eclipse.cdt.make.core.makefile.IPosixRule;
public class PosixRule extends SpecialRule implements IPosixRule { public class PosixRule extends SpecialRule implements IPosixRule {
public PosixRule(Directive parent) { public PosixRule(Directive parent) {
super(parent, new Target(".POSIX"), new String[0], new Command[0]); //$NON-NLS-1$ super(parent, new Target(MakeFileConstants.RULE_POSIX), new String[0], new Command[0]);
} }
} }

View file

@ -20,7 +20,7 @@ import org.eclipse.cdt.make.core.makefile.IPreciousRule;
public class PreciousRule extends SpecialRule implements IPreciousRule { public class PreciousRule extends SpecialRule implements IPreciousRule {
public PreciousRule(Directive parent, String[] reqs) { public PreciousRule(Directive parent, String[] reqs) {
super(parent, new Target(".PRECIOUS"), reqs, new Command[0]); //$NON-NLS-1$ super(parent, new Target(MakeFileConstants.RULE_PRECIOUS), reqs, new Command[0]);
} }
} }

View file

@ -22,7 +22,7 @@ import org.eclipse.cdt.make.core.makefile.ISccsGetRule;
public class SccsGetRule extends SpecialRule implements ISccsGetRule { public class SccsGetRule extends SpecialRule implements ISccsGetRule {
public SccsGetRule(Directive parent, Command[] cmds) { public SccsGetRule(Directive parent, Command[] cmds) {
super(parent, new Target(".SCCS_GET"), new String[0], cmds); //$NON-NLS-1$ super(parent, new Target(MakeFileConstants.RULE_SCCS_GET), new String[0], cmds);
} }
} }

View file

@ -21,7 +21,7 @@ import org.eclipse.cdt.make.core.makefile.ISilentRule;
public class SilentRule extends SpecialRule implements ISilentRule { public class SilentRule extends SpecialRule implements ISilentRule {
public SilentRule(Directive parent, String[] reqs) { public SilentRule(Directive parent, String[] reqs) {
super(parent, new Target(".SILENT"), reqs, new Command[0]); //$NON-NLS-1$ super(parent, new Target(MakeFileConstants.RULE_SILENT), reqs, new Command[0]);
} }
} }

View file

@ -21,7 +21,7 @@ import org.eclipse.cdt.make.core.makefile.ISuffixesRule;
public class SuffixesRule extends SpecialRule implements ISuffixesRule { public class SuffixesRule extends SpecialRule implements ISuffixesRule {
public SuffixesRule(Directive parent, String[] suffixes) { public SuffixesRule(Directive parent, String[] suffixes) {
super(parent, new Target(".SUFFIXES"), suffixes, new Command[0]); //$NON-NLS-1$ super(parent, new Target(MakeFileConstants.RULE_SUFFIXES), suffixes, new Command[0]);
} }
} }

View file

@ -16,6 +16,7 @@ import org.eclipse.cdt.make.internal.core.makefile.Parent;
public abstract class Conditional extends Parent implements IConditional { public abstract class Conditional extends Parent implements IConditional {
private static final String EMPTY = ""; //$NON-NLS-1$
String cond; String cond;
String arg1; String arg1;
String arg2; String arg2;
@ -27,7 +28,7 @@ public abstract class Conditional extends Parent implements IConditional {
} }
public Conditional(Directive parent) { public Conditional(Directive parent) {
this(parent, "", "", ""); this(parent, EMPTY, EMPTY, EMPTY);
} }
public Conditional(Directive parent, String conditional, String argument1, String argument2) { public Conditional(Directive parent, String conditional, String argument1, String argument2) {
@ -88,7 +89,7 @@ public abstract class Conditional extends Parent implements IConditional {
char terminal = line.charAt(0) == '(' ? ',' : line.charAt(0); char terminal = line.charAt(0) == '(' ? ',' : line.charAt(0);
if (line.length() < 5 && terminal != ',' && terminal != '"' && terminal != '\'') { if (line.length() < 5 && terminal != ',' && terminal != '"' && terminal != '\'') {
arg1 = arg2 = ""; arg1 = arg2 = EMPTY;
return; return;
} }
@ -125,7 +126,7 @@ public abstract class Conditional extends Parent implements IConditional {
terminal = terminal == ',' ? ')' : line.charAt(0); terminal = terminal == ',' ? ')' : line.charAt(0);
if (terminal != ')' && terminal != '"' && terminal != '\'') { if (terminal != ')' && terminal != '"' && terminal != '\'') {
arg2 = ""; arg2 = EMPTY;
return; return;
} }

View file

@ -24,10 +24,10 @@ public class DefineVariable extends VariableDefinition {
} }
public String toString() { public String toString() {
StringBuffer sb = new StringBuffer("define"); StringBuffer sb = new StringBuffer(GNUMakefileConstants.VARIABLE_DEFINE);
sb.append(getName()).append('\n'); sb.append(getName()).append('\n');
sb.append(getValue()); sb.append(getValue());
sb.append("endef"); sb.append(GNUMakefileConstants.TERMINAL_ENDEF);
return sb.toString(); return sb.toString();
} }
} }

View file

@ -26,7 +26,7 @@ import org.eclipse.cdt.make.internal.core.makefile.Target;
public class DeleteOnErrorRule extends SpecialRule implements IDeleteOnErrorRule { public class DeleteOnErrorRule extends SpecialRule implements IDeleteOnErrorRule {
public DeleteOnErrorRule(Directive parent, String[] reqs) { public DeleteOnErrorRule(Directive parent, String[] reqs) {
super(parent, new Target(".DELETE_ON_ERROR"), reqs, new Command[0]); super(parent, new Target(GNUMakefileConstants.RULE_DELETE_ON_ERROR), reqs, new Command[0]);
} }
} }

View file

@ -24,6 +24,6 @@ public class Else extends Conditional {
} }
public String toString() { public String toString() {
return "else"; return GNUMakefileConstants.CONDITIONAL_ELSE;
} }
} }

View file

@ -22,4 +22,8 @@ public class Endef extends Terminal {
public boolean isEndef() { public boolean isEndef() {
return true; return true;
} }
public String toString() {
return GNUMakefileConstants.TERMINAL_ENDEF;
}
} }

View file

@ -22,4 +22,7 @@ public class Endif extends Terminal {
return true; return true;
} }
public String toString() {
return GNUMakefileConstants.TERMINAL_ENDIF;
}
} }

View file

@ -24,7 +24,7 @@ import org.eclipse.cdt.make.internal.core.makefile.Target;
public class ExportAllVariablesRule extends SpecialRule implements IExportAllVariablesRule { public class ExportAllVariablesRule extends SpecialRule implements IExportAllVariablesRule {
public ExportAllVariablesRule(Directive parent, String[] reqs) { public ExportAllVariablesRule(Directive parent, String[] reqs) {
super(parent, new Target(".EXPORT_ALL_VARIABLES"), reqs, new Command[0]); super(parent, new Target(GNUMakefileConstants.RULE_EXPORT_ALL_VARIABLES), reqs, new Command[0]);
} }
} }

View file

@ -34,6 +34,7 @@ import org.eclipse.cdt.make.internal.core.makefile.EmptyLine;
import org.eclipse.cdt.make.internal.core.makefile.IgnoreRule; import org.eclipse.cdt.make.internal.core.makefile.IgnoreRule;
import org.eclipse.cdt.make.internal.core.makefile.InferenceRule; import org.eclipse.cdt.make.internal.core.makefile.InferenceRule;
import org.eclipse.cdt.make.internal.core.makefile.MacroDefinition; import org.eclipse.cdt.make.internal.core.makefile.MacroDefinition;
import org.eclipse.cdt.make.internal.core.makefile.MakeFileConstants;
import org.eclipse.cdt.make.internal.core.makefile.MakefileReader; import org.eclipse.cdt.make.internal.core.makefile.MakefileReader;
import org.eclipse.cdt.make.internal.core.makefile.PosixRule; import org.eclipse.cdt.make.internal.core.makefile.PosixRule;
import org.eclipse.cdt.make.internal.core.makefile.PreciousRule; import org.eclipse.cdt.make.internal.core.makefile.PreciousRule;
@ -65,8 +66,8 @@ import org.eclipse.core.runtime.Path;
public class GNUMakefile extends AbstractMakefile implements IGNUMakefile { public class GNUMakefile extends AbstractMakefile implements IGNUMakefile {
public static String PATH_SEPARATOR = System.getProperty("path.separator", ":"); public static String PATH_SEPARATOR = System.getProperty("path.separator", ":"); //$NON-NLS-1$ //$NON-NLS-2$
public static String FILE_SEPARATOR = System.getProperty("file.separator", "/"); public static String FILE_SEPARATOR = System.getProperty("file.separator", "/"); //$NON-NLS-1$ //$NON-NLS-2$
String[] includeDirectories = new String[0]; String[] includeDirectories = new String[0];
IDirective[] builtins = null; IDirective[] builtins = null;
@ -392,33 +393,33 @@ public class GNUMakefile extends AbstractMakefile implements IGNUMakefile {
keyword = line; keyword = line;
reqs = new String[0]; reqs = new String[0];
} }
if (".IGNORE".equals(keyword)) { if (keyword.equals(MakeFileConstants.RULE_IGNORE)) {
special = new IgnoreRule(this, reqs); special = new IgnoreRule(this, reqs);
} else if (".POSIX".equals(keyword)) { } else if (keyword.equals(MakeFileConstants.RULE_POSIX)) {
special = new PosixRule(this); special = new PosixRule(this);
} else if (".PRECIOUS".equals(keyword)) { } else if (keyword.equals(MakeFileConstants.RULE_PRECIOUS)) {
special = new PreciousRule(this, reqs); special = new PreciousRule(this, reqs);
} else if (".SILENT".equals(keyword)) { } else if (keyword.equals(MakeFileConstants.RULE_SILENT)) {
special = new SilentRule(this, reqs); special = new SilentRule(this, reqs);
} else if (".SUFFIXES".equals(keyword)) { } else if (keyword.equals(MakeFileConstants.RULE_SUFFIXES)) {
special = new SuffixesRule(this, reqs); special = new SuffixesRule(this, reqs);
} else if (".DEFAULT".equals(keyword)) { } else if (keyword.equals(MakeFileConstants.RULE_DEFAULT)) {
special = new DefaultRule(this, new Command[0]); special = new DefaultRule(this, new Command[0]);
} else if (".SCCS_GET".equals(keyword)) { } else if (keyword.equals(MakeFileConstants.RULE_SCCS_GET)) {
special = new SccsGetRule(this, new Command[0]); special = new SccsGetRule(this, new Command[0]);
} else if (".PHONY".equals(keyword)) { } else if (keyword.equals(GNUMakefileConstants.RULE_PHONY)) {
special = new PhonyRule(this, reqs); special = new PhonyRule(this, reqs);
} else if (".INTERMEDIATE".equals(keyword)) { } else if (keyword.equals(GNUMakefileConstants.RULE_INTERMEDIATE)) {
special = new IntermediateRule(this, reqs); special = new IntermediateRule(this, reqs);
} else if (".SECONDARY".equals(keyword)) { } else if (keyword.equals(GNUMakefileConstants.RULE_SECONDARY)) {
special = new SecondaryRule(this, reqs); special = new SecondaryRule(this, reqs);
} else if (".DELETE_ON_ERROR".equals(keyword)) { } else if (keyword.equals(GNUMakefileConstants.RULE_DELETE_ON_ERROR)) {
special = new DeleteOnErrorRule(this, reqs); special = new DeleteOnErrorRule(this, reqs);
} else if (".LOW_RESOLUTION_TIME".equals(keyword)) { } else if (keyword.equals(GNUMakefileConstants.RULE_LOW_RESOLUTION_TIME)) {
special = new LowResolutionTimeRule(this, reqs); special = new LowResolutionTimeRule(this, reqs);
} else if (".EXPORT_ALL_VARIABLES".equals(keyword)) { } else if (keyword.equals(GNUMakefileConstants.RULE_EXPORT_ALL_VARIABLES)) {
special = new ExportAllVariablesRule(this, reqs); special = new ExportAllVariablesRule(this, reqs);
} else if (".NOTPARALLEL".equals(keyword)) { } else if (keyword.equals(GNUMakefileConstants.RULE_NOT_PARALLEL)) {
special = new NotParallelRule(this, reqs); special = new NotParallelRule(this, reqs);
} }
return special; return special;
@ -449,15 +450,15 @@ public class GNUMakefile extends AbstractMakefile implements IGNUMakefile {
if (keyword == null) { if (keyword == null) {
keyword = line; keyword = line;
} }
if (keyword.equals("ifdef")) { if (keyword.equals(GNUMakefileConstants.CONDITIONAL_IFDEF)) {
condition = new Ifdef(this, line); condition = new Ifdef(this, line);
} else if (keyword.equals("ifndef")) { } else if (keyword.equals(GNUMakefileConstants.CONDITIONAL_IFNDEF)) {
condition = new Ifndef(this, line); condition = new Ifndef(this, line);
} else if (keyword.equals("ifeq")) { } else if (keyword.equals(GNUMakefileConstants.CONDITIONAL_IFEQ)) {
condition = new Ifeq(this, line); condition = new Ifeq(this, line);
} else if (keyword.equals("ifneq")) { } else if (keyword.equals(GNUMakefileConstants.CONDITIONAL_IFNEQ)) {
condition = new Ifneq(this, line); condition = new Ifneq(this, line);
} else if (keyword.equals("else")) { } else if (keyword.equals(GNUMakefileConstants.CONDITIONAL_ELSE)) {
condition = new Else(this); condition = new Else(this);
} }
return condition; return condition;
@ -516,7 +517,7 @@ public class GNUMakefile extends AbstractMakefile implements IGNUMakefile {
} else if (count == 1) { } else if (count == 1) {
pattern = st.nextToken(); pattern = st.nextToken();
} else if (count == 3) { } else if (count == 3) {
String delim = " \t\n\r\f" + GNUMakefile.PATH_SEPARATOR; String delim = " \t\n\r\f" + GNUMakefile.PATH_SEPARATOR; //$NON-NLS-1$
dirs.add(st.nextToken(delim)); dirs.add(st.nextToken(delim));
} else { } else {
dirs.add(st.nextToken()); dirs.add(st.nextToken());
@ -559,7 +560,7 @@ public class GNUMakefile extends AbstractMakefile implements IGNUMakefile {
// Some TargetRule have "::" for separator // Some TargetRule have "::" for separator
String req = line.substring(index + 1); String req = line.substring(index + 1);
doubleColon = req.startsWith(":"); doubleColon = req.startsWith(":"); //$NON-NLS-1$
if (doubleColon) { if (doubleColon) {
// move pass the second ':' // move pass the second ':'
req = req.substring(1); req = req.substring(1);
@ -581,7 +582,7 @@ public class GNUMakefile extends AbstractMakefile implements IGNUMakefile {
orderReq = req.substring(pipe + 1); orderReq = req.substring(pipe + 1);
} else { } else {
normalReq = req; normalReq = req;
orderReq = ""; orderReq = ""; //$NON-NLS-1$
} }
normalReqs = GNUMakefileUtil.findPrerequisites(normalReq.trim()); normalReqs = GNUMakefileUtil.findPrerequisites(normalReq.trim());
@ -612,7 +613,7 @@ public class GNUMakefile extends AbstractMakefile implements IGNUMakefile {
boolean isOverride = false; boolean isOverride = false;
boolean isTargetVariable = false; boolean isTargetVariable = false;
boolean isExport = false; boolean isExport = false;
String targetName = ""; String targetName = ""; //$NON-NLS-1$
String name; String name;
StringBuffer value = new StringBuffer(); StringBuffer value = new StringBuffer();
@ -625,7 +626,7 @@ public class GNUMakefile extends AbstractMakefile implements IGNUMakefile {
targetName = line.substring(0, colon).trim(); targetName = line.substring(0, colon).trim();
line = line.substring(colon + 1).trim(); line = line.substring(colon + 1).trim();
} else { } else {
targetName = ""; targetName = ""; //$NON-NLS-1$
} }
} }
@ -726,12 +727,12 @@ public class GNUMakefile extends AbstractMakefile implements IGNUMakefile {
prereqPatterns[i] = st.nextToken(); prereqPatterns[i] = st.nextToken();
} }
} else { } else {
targetPattern = ""; targetPattern = ""; //$NON-NLS-1$
prereqPatterns = new String[0]; prereqPatterns = new String[0];
} }
} else { } else {
targets = new String[0]; targets = new String[0];
targetPattern = ""; targetPattern = ""; //$NON-NLS-1$
prereqPatterns = new String[0]; prereqPatterns = new String[0];
} }
@ -762,7 +763,7 @@ public class GNUMakefile extends AbstractMakefile implements IGNUMakefile {
*/ */
public IDirective[] getBuiltins() { public IDirective[] getBuiltins() {
if (builtins == null) { if (builtins == null) {
String location = "builtin" + File.separator + "gnu.mk"; String location = "builtin" + File.separator + "gnu.mk"; //$NON-NLS-1$ //$NON-NLS-2$
try { try {
InputStream stream = MakeCorePlugin.getDefault().openStream(new Path(location)); InputStream stream = MakeCorePlugin.getDefault().openStream(new Path(location));
GNUMakefile gnu = new GNUMakefile(); GNUMakefile gnu = new GNUMakefile();
@ -793,7 +794,7 @@ public class GNUMakefile extends AbstractMakefile implements IGNUMakefile {
public static void main(String[] args) { public static void main(String[] args) {
try { try {
String filename = "Makefile"; String filename = "Makefile"; //$NON-NLS-1$
if (args.length == 1) { if (args.length == 1) {
filename = args[0]; filename = args[0];
} }

View file

@ -122,7 +122,7 @@ public class GNUMakefileChecker extends ACBuilder {
protected IFile[] getCandidateMakefiles(IProject proj) { protected IFile[] getCandidateMakefiles(IProject proj) {
// FIXME: Find the candidate in the store somewhere. // FIXME: Find the candidate in the store somewhere.
IFile defaultMakefile = proj.getFile(new Path("Makefile")); IFile defaultMakefile = proj.getFile(new Path("Makefile")); //$NON-NLS-1$
if (defaultMakefile.exists()) { if (defaultMakefile.exists()) {
return new IFile[] {defaultMakefile}; return new IFile[] {defaultMakefile};
} }

View file

@ -0,0 +1,40 @@
/*
* Created on Mar 2, 2004
*
* Copyright (c) 2002,2003 QNX Software Systems Ltd.
*
* Contributors:
* QNX Software Systems - Initial API and implementation
***********************************************************************/
package org.eclipse.cdt.make.internal.core.makefile.gnu;
import org.eclipse.cdt.make.internal.core.makefile.MakeFileConstants;
public class GNUMakefileConstants extends MakeFileConstants {
static final String CONDITIONAL_ELSE = "else"; //$NON-NLS-1$
static final String CONDITIONAL_IFNEQ = "ifneq"; //$NON-NLS-1$
static final String CONDITIONAL_IFNDEF = "ifndef"; //$NON-NLS-1$
static final String CONDITIONAL_IFEQ = "ifeq"; //$NON-NLS-1$
static final String CONDITIONAL_IFDEF = "ifdef"; //$NON-NLS-1$
static final String TERMINAL_ENDEF = "endef"; //$NON-NLS-1$
static final String TERMINAL_ENDIF = "endif"; //$NON-NLS-1$
static final String DIRECTIVE_VPATH = "vpath"; //$NON-NLS-1$
static final String DIRECTIVE_UNEXPORT = "unexport"; //$NON-NLS-1$
static final String VARIABLE_DEFINE = "define"; //$NON-NLS-1$
static final String VARIABLE_EXPORT = "export"; //$NON-NLS-1$
static final String VARIABLE_OVERRIDE = "override"; //$NON-NLS-1$
static final String DIRECTIVE_INCLUDE = "include"; //$NON-NLS-1$
static final String RULE_DELETE_ON_ERROR = ".DELETE_ON_ERROR"; //$NON-NLS-1$
static final String RULE_PHONY = ".PHONY"; //$NON-NLS-1$
static final String RULE_SECONDARY = ".SECONDARY"; //$NON-NLS-1$
static final String RULE_LOW_RESOLUTION_TIME = ".LOW_RESOLUTION_TIME"; //$NON-NLS-1$
static final String RULE_NOT_PARALLEL = ".NOTPARALLEL"; //$NON-NLS-1$
static final String RULE_EXPORT_ALL_VARIABLES = ".EXPORT_ALL_VARIABLES"; //$NON-NLS-1$
static final String RULE_INTERMEDIATE = ".INTERMEDIATE"; //$NON-NLS-1$
}

View file

@ -20,75 +20,75 @@ public class GNUMakefileUtil extends PosixMakefileUtil {
public static boolean isInclude(String line) { public static boolean isInclude(String line) {
line = line.trim(); line = line.trim();
boolean isInclude = line.startsWith("include") && line.length() > 7 && Character.isWhitespace(line.charAt(7)); boolean isInclude = line.startsWith(GNUMakefileConstants.DIRECTIVE_INCLUDE) && line.length() > 7 && Character.isWhitespace(line.charAt(7));
boolean isDashInclude = line.startsWith("-include") && line.length() > 8 && Character.isWhitespace(line.charAt(8)); boolean isDashInclude = line.startsWith("-" + GNUMakefileConstants.DIRECTIVE_INCLUDE) && line.length() > 8 && Character.isWhitespace(line.charAt(8)); //$NON-NLS-1$
boolean isSInclude = line.startsWith("sinclude") && line.length() > 8 && Character.isWhitespace(line.charAt(8)); boolean isSInclude = line.startsWith("s" + GNUMakefileConstants.DIRECTIVE_INCLUDE) && line.length() > 8 && Character.isWhitespace(line.charAt(8)); //$NON-NLS-1$
return isInclude || isDashInclude || isSInclude; return isInclude || isDashInclude || isSInclude;
} }
public static boolean isVPath(String line) { public static boolean isVPath(String line) {
line = line.trim(); line = line.trim();
return line.equals("vpath") || line.startsWith("vpath") && line.length() > 5 && Character.isWhitespace(line.charAt(5)); return line.equals(GNUMakefileConstants.DIRECTIVE_VPATH) || line.startsWith(GNUMakefileConstants.DIRECTIVE_VPATH) && line.length() > 5 && Character.isWhitespace(line.charAt(5));
} }
public static boolean isExport(String line) { public static boolean isExport(String line) {
line = line.trim(); line = line.trim();
return line.equals("export") || line.startsWith("export") && line.length() > 6 && Character.isWhitespace(line.charAt(6)); return line.equals(GNUMakefileConstants.VARIABLE_EXPORT) || line.startsWith(GNUMakefileConstants.VARIABLE_EXPORT) && line.length() > 6 && Character.isWhitespace(line.charAt(6));
} }
public static boolean isUnExport(String line) { public static boolean isUnExport(String line) {
line = line.trim(); line = line.trim();
return line.startsWith("unexport") && line.length() > 8 && Character.isWhitespace(line.charAt(8)); return line.startsWith(GNUMakefileConstants.DIRECTIVE_UNEXPORT) && line.length() > 8 && Character.isWhitespace(line.charAt(8));
} }
public static boolean isDefine(String line) { public static boolean isDefine(String line) {
line = line.trim(); line = line.trim();
return line.startsWith("define") && line.length() > 6 && Character.isWhitespace(line.charAt(6)); return line.startsWith(GNUMakefileConstants.VARIABLE_DEFINE) && line.length() > 6 && Character.isWhitespace(line.charAt(6));
} }
public static boolean isEndef(String line) { public static boolean isEndef(String line) {
return line.trim().equals("endef"); return line.trim().equals(GNUMakefileConstants.TERMINAL_ENDEF);
} }
public static boolean isOverride(String line) { public static boolean isOverride(String line) {
line = line.trim(); line = line.trim();
return line.startsWith("override") && line.length() > 8 && Character.isWhitespace(line.charAt(8)); return line.startsWith(GNUMakefileConstants.VARIABLE_OVERRIDE) && line.length() > 8 && Character.isWhitespace(line.charAt(8));
} }
public static boolean isIfeq(String line) { public static boolean isIfeq(String line) {
line = line.trim(); line = line.trim();
return line.startsWith("ifeq") && line.length() > 4 && Character.isWhitespace(line.charAt(4)); return line.startsWith(GNUMakefileConstants.CONDITIONAL_IFEQ) && line.length() > 4 && Character.isWhitespace(line.charAt(4));
} }
public static boolean isIfneq(String line) { public static boolean isIfneq(String line) {
line = line.trim(); line = line.trim();
return line.startsWith("ifneq") && line.length() > 5 && Character.isWhitespace(line.charAt(5)); return line.startsWith(GNUMakefileConstants.CONDITIONAL_IFNEQ) && line.length() > 5 && Character.isWhitespace(line.charAt(5));
} }
public static boolean isIfdef(String line) { public static boolean isIfdef(String line) {
line = line.trim(); line = line.trim();
return line.startsWith("ifdef") && line.length() > 5 && Character.isWhitespace(line.charAt(5)); return line.startsWith(GNUMakefileConstants.CONDITIONAL_IFDEF) && line.length() > 5 && Character.isWhitespace(line.charAt(5));
} }
public static boolean isIfndef(String line) { public static boolean isIfndef(String line) {
line = line.trim(); line = line.trim();
return line.startsWith("ifndef") && line.length() > 6 && Character.isWhitespace(line.charAt(6)); return line.startsWith(GNUMakefileConstants.CONDITIONAL_IFNDEF) && line.length() > 6 && Character.isWhitespace(line.charAt(6));
} }
public static boolean isElse(String line) { public static boolean isElse(String line) {
return line.trim().equals("else"); return line.trim().equals(GNUMakefileConstants.CONDITIONAL_ELSE);
} }
public static boolean isEndif(String line) { public static boolean isEndif(String line) {
return line.trim().equals("endif"); return line.trim().equals(GNUMakefileConstants.TERMINAL_ENDIF);
} }
public static boolean isOverrideDefine(String line) { public static boolean isOverrideDefine(String line) {
line = line.trim(); line = line.trim();
if (line.startsWith("override")) { if (line.startsWith(GNUMakefileConstants.VARIABLE_OVERRIDE)) {
int i = 8; int i = 8;
for (; i < line.length() && Character.isWhitespace(line.charAt(i)); i++); for (; i < line.length() && Character.isWhitespace(line.charAt(i)); i++);
if (line.startsWith("define", i)) { if (line.startsWith(GNUMakefileConstants.VARIABLE_DEFINE, i)) {
return true; return true;
} }
} }
@ -157,7 +157,7 @@ public class GNUMakefileUtil extends PosixMakefileUtil {
int colon = Util.indexOf(line, ':'); int colon = Util.indexOf(line, ':');
if (colon > 0) { if (colon > 0) {
line = line.substring(0, colon).trim(); line = line.substring(0, colon).trim();
return line.equals(".PHONY"); return line.equals(GNUMakefileConstants.RULE_PHONY);
} }
return false; return false;
} }
@ -167,7 +167,7 @@ public class GNUMakefileUtil extends PosixMakefileUtil {
int colon = Util.indexOf(line, ':'); int colon = Util.indexOf(line, ':');
if (colon > 0) { if (colon > 0) {
line = line.substring(0, colon).trim(); line = line.substring(0, colon).trim();
return line.equals(".INTERMEDIATE"); return line.equals(GNUMakefileConstants.RULE_INTERMEDIATE);
} }
return false; return false;
} }
@ -177,7 +177,7 @@ public class GNUMakefileUtil extends PosixMakefileUtil {
int colon = Util.indexOf(line, ':'); int colon = Util.indexOf(line, ':');
if (colon > 0) { if (colon > 0) {
line = line.substring(0, colon).trim(); line = line.substring(0, colon).trim();
return line.equals(".SECONDARY"); return line.equals(GNUMakefileConstants.RULE_SECONDARY);
} }
return false; return false;
} }
@ -187,7 +187,7 @@ public class GNUMakefileUtil extends PosixMakefileUtil {
int colon = Util.indexOf(line, ':'); int colon = Util.indexOf(line, ':');
if (colon > 0) { if (colon > 0) {
line = line.substring(0, colon).trim(); line = line.substring(0, colon).trim();
return line.equals(".DELETE_ON_ERROR"); return line.equals(GNUMakefileConstants.RULE_DELETE_ON_ERROR);
} }
return false; return false;
} }
@ -197,7 +197,7 @@ public class GNUMakefileUtil extends PosixMakefileUtil {
int colon = Util.indexOf(line, ':'); int colon = Util.indexOf(line, ':');
if (colon > 0) { if (colon > 0) {
line = line.substring(0, colon).trim(); line = line.substring(0, colon).trim();
return line.equals(".LOW_RESOLUTION_TIME"); return line.equals(GNUMakefileConstants.RULE_LOW_RESOLUTION_TIME);
} }
return false; return false;
} }
@ -207,7 +207,7 @@ public class GNUMakefileUtil extends PosixMakefileUtil {
int colon = Util.indexOf(line, ':'); int colon = Util.indexOf(line, ':');
if (colon > 0) { if (colon > 0) {
line = line.substring(0, colon).trim(); line = line.substring(0, colon).trim();
return line.equals(".EXPORT_ALL_VARIABLES"); return line.equals(GNUMakefileConstants.RULE_EXPORT_ALL_VARIABLES);
} }
return false; return false;
} }
@ -217,7 +217,7 @@ public class GNUMakefileUtil extends PosixMakefileUtil {
int colon = Util.indexOf(line, ':'); int colon = Util.indexOf(line, ':');
if (colon > 0) { if (colon > 0) {
line = line.substring(0, colon).trim(); line = line.substring(0, colon).trim();
return line.equals(".NOTPARALLEL"); return line.equals(GNUMakefileConstants.RULE_NOT_PARALLEL);
} }
return false; return false;
} }

View file

@ -16,13 +16,14 @@ import java.io.InputStreamReader;
import java.io.Reader; import java.io.Reader;
import org.eclipse.cdt.core.IMarkerGenerator; import org.eclipse.cdt.core.IMarkerGenerator;
import org.eclipse.cdt.make.core.makefile.*;
import org.eclipse.cdt.make.core.makefile.IBadDirective; import org.eclipse.cdt.make.core.makefile.IBadDirective;
import org.eclipse.cdt.make.core.makefile.IDirective; import org.eclipse.cdt.make.core.makefile.IDirective;
import org.eclipse.cdt.make.core.makefile.IMakefileValidator;
import org.eclipse.cdt.make.core.makefile.ISpecialRule; import org.eclipse.cdt.make.core.makefile.ISpecialRule;
import org.eclipse.cdt.make.core.makefile.gnu.IConditional; import org.eclipse.cdt.make.core.makefile.gnu.IConditional;
import org.eclipse.cdt.make.core.makefile.gnu.ITerminal; import org.eclipse.cdt.make.core.makefile.gnu.ITerminal;
import org.eclipse.cdt.make.core.makefile.gnu.IVariableDefinition; import org.eclipse.cdt.make.core.makefile.gnu.IVariableDefinition;
import org.eclipse.cdt.make.internal.core.makefile.MakefileMessages;
import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
@ -48,7 +49,7 @@ public class GNUMakefileValidator implements IMakefileValidator {
reporter = new IMarkerGenerator() { reporter = new IMarkerGenerator() {
public void addMarker(IResource file, int lineNumber, String errorDesc, int severity, String errorVar) { public void addMarker(IResource file, int lineNumber, String errorDesc, int severity, String errorVar) {
String name = "Makefile"; String name = "Makefile"; //$NON-NLS-1$
if (file != null) { if (file != null) {
name = file.getName(); name = file.getName();
} }
@ -66,15 +67,15 @@ public class GNUMakefileValidator implements IMakefileValidator {
public String getSeverity(int severity) { public String getSeverity(int severity) {
if (severity == IMarkerGenerator.SEVERITY_ERROR_BUILD) { if (severity == IMarkerGenerator.SEVERITY_ERROR_BUILD) {
return "Error Build"; return MakefileMessages.getString("MakefileValidator.errorBuild"); //$NON-NLS-1$
} else if (severity == IMarkerGenerator.SEVERITY_ERROR_RESOURCE) { } else if (severity == IMarkerGenerator.SEVERITY_ERROR_RESOURCE) {
return "Error resource"; return MakefileMessages.getString("MakefileValidator.errorResource"); //$NON-NLS-1$
} else if (severity == IMarkerGenerator.SEVERITY_INFO) { } else if (severity == IMarkerGenerator.SEVERITY_INFO) {
return "Warning info"; return MakefileMessages.getString("MakefileValidator.warningInfo"); //$NON-NLS-1$
} else if (severity == IMarkerGenerator.SEVERITY_WARNING) { } else if (severity == IMarkerGenerator.SEVERITY_WARNING) {
return "Warning"; return MakefileMessages.getString("MakefileValidator.warning"); //$NON-NLS-1$
} }
return "unknown"; return MakefileMessages.getString("MakefileValidator.unknown"); //$NON-NLS-1$
} }
}; };
@ -83,7 +84,7 @@ public class GNUMakefileValidator implements IMakefileValidator {
} }
public void checkFile(IFile file, IProgressMonitor monitor) { public void checkFile(IFile file, IProgressMonitor monitor) {
String message = "Checking file : " + file.getFullPath().toString(); String message = MakefileMessages.getString("MakefileValidator.checkingFile") + file.getFullPath().toString(); //$NON-NLS-1$
monitor.subTask(message); monitor.subTask(message);
GNUMakefile gnu = new GNUMakefile(); GNUMakefile gnu = new GNUMakefile();
InputStream stream = null; InputStream stream = null;
@ -102,7 +103,7 @@ public class GNUMakefileValidator implements IMakefileValidator {
} }
} }
} }
monitor.subTask("File checked"); monitor.subTask(MakefileMessages.getString("MakefileValidator.fileChecked")); //$NON-NLS-1$
monitor.done(); monitor.done();
} }
@ -124,7 +125,7 @@ public class GNUMakefileValidator implements IMakefileValidator {
if (conditionCount == 0) { if (conditionCount == 0) {
// ERROR else missing conditon. // ERROR else missing conditon.
int startLine = condition.getStartLine(); int startLine = condition.getStartLine();
String msg = "else missing if condition"; String msg = MakefileMessages.getString("MakefileValidator.error.elseMissingIfCondition"); //$NON-NLS-1$
int severity = IMarkerGenerator.SEVERITY_ERROR_RESOURCE; int severity = IMarkerGenerator.SEVERITY_ERROR_RESOURCE;
String varName = condition.toString().trim(); String varName = condition.toString().trim();
marker.addMarker(res, startLine, msg, severity, varName); marker.addMarker(res, startLine, msg, severity, varName);
@ -136,7 +137,7 @@ public class GNUMakefileValidator implements IMakefileValidator {
if (conditionCount == 0) { if (conditionCount == 0) {
// ERROR missing condition. // ERROR missing condition.
int startLine = terminal.getStartLine(); int startLine = terminal.getStartLine();
String msg = "Endif missing if/else condition"; String msg = MakefileMessages.getString("MakefileValidator.error.endifMissingIfElseCondition"); //$NON-NLS-1$
int severity = IMarkerGenerator.SEVERITY_ERROR_RESOURCE; int severity = IMarkerGenerator.SEVERITY_ERROR_RESOURCE;
String varName = terminal.toString().trim(); String varName = terminal.toString().trim();
marker.addMarker(res, startLine, msg, severity, varName); marker.addMarker(res, startLine, msg, severity, varName);
@ -147,7 +148,7 @@ public class GNUMakefileValidator implements IMakefileValidator {
if (defineCount == 0) { if (defineCount == 0) {
// ERROR missing define. // ERROR missing define.
int startLine = terminal.getStartLine(); int startLine = terminal.getStartLine();
String msg = "endef missing [override] define"; String msg = MakefileMessages.getString("MakefileValidator.error.endefMissingOverrideDefine"); //$NON-NLS-1$
int severity = IMarkerGenerator.SEVERITY_ERROR_RESOURCE; int severity = IMarkerGenerator.SEVERITY_ERROR_RESOURCE;
String varName = terminal.toString().trim(); String varName = terminal.toString().trim();
marker.addMarker(res, startLine, msg, severity, varName); marker.addMarker(res, startLine, msg, severity, varName);
@ -163,7 +164,7 @@ public class GNUMakefileValidator implements IMakefileValidator {
} else if (directive instanceof IBadDirective) { } else if (directive instanceof IBadDirective) {
// ERROR unknow statement. // ERROR unknow statement.
int startLine = directive.getStartLine(); int startLine = directive.getStartLine();
String msg = "unknow directive"; String msg = MakefileMessages.getString("MakefileValidator.error.unknownDirective"); //$NON-NLS-1$
int severity = IMarkerGenerator.SEVERITY_ERROR_RESOURCE; int severity = IMarkerGenerator.SEVERITY_ERROR_RESOURCE;
String varName = directive.toString().trim(); String varName = directive.toString().trim();
marker.addMarker(res, startLine, msg, severity, varName); marker.addMarker(res, startLine, msg, severity, varName);
@ -174,7 +175,7 @@ public class GNUMakefileValidator implements IMakefileValidator {
if (conditionCount > 0) { if (conditionCount > 0) {
// ERROR no matching endif for condition. // ERROR no matching endif for condition.
int startLine = 0; int startLine = 0;
String varName = ""; String varName = ""; //$NON-NLS-1$
int severity = IMarkerGenerator.SEVERITY_ERROR_RESOURCE; int severity = IMarkerGenerator.SEVERITY_ERROR_RESOURCE;
for (int i = directives.length - 1; i >= 0; i--) { for (int i = directives.length - 1; i >= 0; i--) {
if (directives[i] instanceof IConditional) { if (directives[i] instanceof IConditional) {
@ -183,13 +184,13 @@ public class GNUMakefileValidator implements IMakefileValidator {
break; break;
} }
} }
String msg = "No matching endif for condition"; String msg = MakefileMessages.getString("MakefileValidator.error.noMatchingEndifForCondition"); //$NON-NLS-1$
marker.addMarker(res, startLine, msg, severity, varName); marker.addMarker(res, startLine, msg, severity, varName);
} }
if (defineCount > 0) { if (defineCount > 0) {
// ERROR no matching endef for define. // ERROR no matching endef for define.
int startLine = 0; int startLine = 0;
String varName = ""; String varName = ""; //$NON-NLS-1$
int severity = IMarkerGenerator.SEVERITY_ERROR_RESOURCE; int severity = IMarkerGenerator.SEVERITY_ERROR_RESOURCE;
for (int i = directives.length - 1; i >= 0; i--) { for (int i = directives.length - 1; i >= 0; i--) {
if (directives[i] instanceof IVariableDefinition) { if (directives[i] instanceof IVariableDefinition) {
@ -201,7 +202,7 @@ public class GNUMakefileValidator implements IMakefileValidator {
} }
} }
} }
String msg = "No matching endef for [override] define"; String msg = MakefileMessages.getString("MakefileValidator.error.noMatchingEndefForOverrideDefine"); //$NON-NLS-1$
marker.addMarker(res, startLine, msg, severity, varName); marker.addMarker(res, startLine, msg, severity, varName);
} }
} }

View file

@ -55,7 +55,7 @@ public class GNUTargetRule extends TargetRule {
} }
reqs = getOrderOnlyPrerequisites(); reqs = getOrderOnlyPrerequisites();
if (reqs.length > 0) { if (reqs.length > 0) {
buffer.append(" |"); buffer.append(" |"); //$NON-NLS-1$
for (int i = 0; i < reqs.length; i++) { for (int i = 0; i < reqs.length; i++) {
buffer.append(' ').append(reqs[i]); buffer.append(' ').append(reqs[i]);
} }

View file

@ -14,9 +14,10 @@ import org.eclipse.cdt.make.internal.core.makefile.Directive;
public class Ifdef extends Conditional { public class Ifdef extends Conditional {
private static final String EMPTY = ""; //$NON-NLS-1$
public Ifdef(Directive parent, String var) { public Ifdef(Directive parent, String var) {
super(parent, var, "", ""); super(parent, var, EMPTY, EMPTY);
} }
public boolean isIfdef() { public boolean isIfdef() {
@ -24,7 +25,7 @@ public class Ifdef extends Conditional {
} }
public String toString() { public String toString() {
StringBuffer sb = new StringBuffer("ifdef"); StringBuffer sb = new StringBuffer(GNUMakefileConstants.CONDITIONAL_IFDEF);
sb.append(' ').append(getVariable()); sb.append(' ').append(getVariable());
return sb.toString(); return sb.toString();
} }

View file

@ -24,7 +24,7 @@ public class Ifeq extends Conditional {
} }
public String toString() { public String toString() {
StringBuffer sb = new StringBuffer("ifeq"); StringBuffer sb = new StringBuffer(GNUMakefileConstants.CONDITIONAL_IFEQ);
sb.append(' ').append(getConditional()); sb.append(' ').append(getConditional());
return sb.toString(); return sb.toString();
} }

View file

@ -15,8 +15,9 @@ import org.eclipse.cdt.make.internal.core.makefile.Directive;
public class Ifndef extends Conditional { public class Ifndef extends Conditional {
private static final String EMPTY = ""; //$NON-NLS-1$
public Ifndef(Directive parent, String var) { public Ifndef(Directive parent, String var) {
super(parent, var, "", ""); super(parent, var, EMPTY, EMPTY);
} }
public boolean isIfndef() { public boolean isIfndef() {
@ -24,7 +25,7 @@ public class Ifndef extends Conditional {
} }
public String toString() { public String toString() {
StringBuffer sb = new StringBuffer("ifndef"); StringBuffer sb = new StringBuffer(GNUMakefileConstants.CONDITIONAL_IFNDEF);
sb.append(' ').append(getVariable()); sb.append(' ').append(getVariable());
return sb.toString(); return sb.toString();
} }

View file

@ -24,7 +24,7 @@ public class Ifneq extends Conditional {
} }
public String toString() { public String toString() {
StringBuffer sb = new StringBuffer("ifneq"); StringBuffer sb = new StringBuffer(GNUMakefileConstants.CONDITIONAL_IFNEQ);
sb.append(' ').append(getConditional()); sb.append(' ').append(getConditional());
return sb.toString(); return sb.toString();
} }

View file

@ -29,7 +29,7 @@ public class Include extends Parent implements IInclude {
} }
public String toString() { public String toString() {
StringBuffer sb = new StringBuffer("include"); StringBuffer sb = new StringBuffer(GNUMakefileConstants.DIRECTIVE_INCLUDE);
for (int i = 0; i < filenames.length; i++) { for (int i = 0; i < filenames.length; i++) {
sb.append(' ').append(filenames[i]); sb.append(' ').append(filenames[i]);
} }

View file

@ -24,7 +24,7 @@ import org.eclipse.cdt.make.internal.core.makefile.Target;
public class IntermediateRule extends SpecialRule implements IIntermediateRule { public class IntermediateRule extends SpecialRule implements IIntermediateRule {
public IntermediateRule(Directive parent, String[] reqs) { public IntermediateRule(Directive parent, String[] reqs) {
super(parent, new Target(".INTERMEDIATE"), reqs, new Command[0]); super(parent, new Target(GNUMakefileConstants.RULE_INTERMEDIATE), reqs, new Command[0]);
} }
} }

View file

@ -25,7 +25,7 @@ import org.eclipse.cdt.make.internal.core.makefile.Target;
public class LowResolutionTimeRule extends SpecialRule implements ILowResolutionTimeRule { public class LowResolutionTimeRule extends SpecialRule implements ILowResolutionTimeRule {
public LowResolutionTimeRule(Directive parent, String[] reqs) { public LowResolutionTimeRule(Directive parent, String[] reqs) {
super(parent, new Target(".LOW_RESOLUTION_TIME"), reqs, new Command[0]); super(parent, new Target(GNUMakefileConstants.RULE_LOW_RESOLUTION_TIME), reqs, new Command[0]);
} }
} }

View file

@ -27,7 +27,7 @@ import org.eclipse.cdt.make.internal.core.makefile.Target;
public class NotParallelRule extends SpecialRule implements INotParallelRule { public class NotParallelRule extends SpecialRule implements INotParallelRule {
public NotParallelRule(Directive parent, String[] reqs) { public NotParallelRule(Directive parent, String[] reqs) {
super(parent, new Target(".NOTPARALLEL"), reqs, new Command[0]); super(parent, new Target(GNUMakefileConstants.RULE_NOT_PARALLEL), reqs, new Command[0]);
} }
} }

View file

@ -20,10 +20,10 @@ public class OverrideDefine extends DefineVariable {
} }
public String toString() { public String toString() {
StringBuffer sb = new StringBuffer("override define "); StringBuffer sb = new StringBuffer(GNUMakefileConstants.VARIABLE_OVERRIDE + " " + GNUMakefileConstants.VARIABLE_DEFINE); //$NON-NLS-1$
sb.append(getName()).append('\n'); sb.append(getName()).append('\n');
sb.append(getValue()); sb.append(getValue());
sb.append("endef"); sb.append(GNUMakefileConstants.TERMINAL_ENDEF);
return sb.toString(); return sb.toString();
} }

View file

@ -25,7 +25,7 @@ import org.eclipse.cdt.make.internal.core.makefile.Target;
public class PhonyRule extends SpecialRule implements IPhonyRule { public class PhonyRule extends SpecialRule implements IPhonyRule {
public PhonyRule(Directive parent, String[] reqs) { public PhonyRule(Directive parent, String[] reqs) {
super(parent, new Target(".PHONY"), reqs, new Command[0]); super(parent, new Target(GNUMakefileConstants.RULE_PHONY), reqs, new Command[0]);
} }
} }

View file

@ -27,7 +27,7 @@ import org.eclipse.cdt.make.internal.core.makefile.Target;
public class SecondaryRule extends SpecialRule implements ISecondaryRule { public class SecondaryRule extends SpecialRule implements ISecondaryRule {
public SecondaryRule(Directive parent, String[] reqs) { public SecondaryRule(Directive parent, String[] reqs) {
super(parent, new Target(".SECONDARY"), reqs, new Command[0]); super(parent, new Target(GNUMakefileConstants.RULE_SECONDARY), reqs, new Command[0]);
} }
} }

View file

@ -13,7 +13,7 @@ package org.eclipse.cdt.make.internal.core.makefile.gnu;
import org.eclipse.cdt.make.core.makefile.gnu.ITerminal; import org.eclipse.cdt.make.core.makefile.gnu.ITerminal;
import org.eclipse.cdt.make.internal.core.makefile.Directive; import org.eclipse.cdt.make.internal.core.makefile.Directive;
public class Terminal extends Directive implements ITerminal { public abstract class Terminal extends Directive implements ITerminal {
public Terminal(Directive parent) { public Terminal(Directive parent) {
super(parent); super(parent);
@ -28,11 +28,6 @@ public class Terminal extends Directive implements ITerminal {
} }
public String toString() { public String toString() {
if (isEndif()) { return "\n"; //$NON-NLS-1$
return "endif\n";
} else if (isEndef()){
return "endef\n";
}
return "\n";
} }
} }

View file

@ -23,7 +23,7 @@ public class UnExport extends Directive implements IUnExport {
} }
public String toString() { public String toString() {
StringBuffer sb = new StringBuffer("unexport"); StringBuffer sb = new StringBuffer(GNUMakefileConstants.DIRECTIVE_UNEXPORT);
sb.append(' ').append(variable); sb.append(' ').append(variable);
return sb.toString(); return sb.toString();
} }

View file

@ -25,7 +25,7 @@ public class VPath extends Directive implements IVPath {
} }
public String toString() { public String toString() {
StringBuffer sb = new StringBuffer("vpath"); StringBuffer sb = new StringBuffer(GNUMakefileConstants.DIRECTIVE_VPATH);
if (pattern != null && pattern.length() > 0) { if (pattern != null && pattern.length() > 0) {
sb.append(' ').append(pattern); sb.append(' ').append(pattern);
} }

View file

@ -36,7 +36,7 @@ public class VariableDefinition extends MacroDefinition implements IVariableDefi
} }
public VariableDefinition(Directive parent, String name, StringBuffer value, int type) { public VariableDefinition(Directive parent, String name, StringBuffer value, int type) {
this(parent, "", name, value, type); this(parent, "", name, value, type); //$NON-NLS-1$
} }
public VariableDefinition(Directive parent, String target, String name, StringBuffer value, int type) { public VariableDefinition(Directive parent, String target, String name, StringBuffer value, int type) {
@ -51,29 +51,32 @@ public class VariableDefinition extends MacroDefinition implements IVariableDefi
public String toString() { public String toString() {
StringBuffer sb = new StringBuffer(); StringBuffer sb = new StringBuffer();
if (isTargetSpecific()) { if (isTargetSpecific()) {
sb.append(getTarget()).append(": "); sb.append(getTarget()).append(": "); //$NON-NLS-1$
} }
if (isOverride()) { if (isOverride()) {
sb.append("override "); sb.append(GNUMakefileConstants.VARIABLE_OVERRIDE);
} }
if (isMultiLine()) { if (isMultiLine()) {
sb.append("define "); sb.append(GNUMakefileConstants.VARIABLE_DEFINE);
sb.append(' ');
sb.append(getName()).append('\n'); sb.append(getName()).append('\n');
sb.append(getValue()).append('\n'); sb.append(getValue()).append('\n');
sb.append("endef\n"); sb.append(GNUMakefileConstants.TERMINAL_ENDEF);
sb.append('\n');
} else { } else {
if (isExport()) { if (isExport()) {
sb.append("export "); sb.append(GNUMakefileConstants.VARIABLE_EXPORT);
sb.append(' ');
} }
sb.append(getName()); sb.append(getName());
if (isRecursivelyExpanded()) { if (isRecursivelyExpanded()) {
sb.append(" = "); sb.append(" = "); //$NON-NLS-1$
} else if (isSimplyExpanded()) { } else if (isSimplyExpanded()) {
sb.append(" := "); sb.append(" := "); //$NON-NLS-1$
} else if (isConditional()) { } else if (isConditional()) {
sb.append(" ?= "); sb.append(" ?= "); //$NON-NLS-1$
} else if (isAppend()) { } else if (isAppend()) {
sb.append(" += "); sb.append(" += "); //$NON-NLS-1$
} }
sb.append(getValue()).append('\n'); sb.append(getValue()).append('\n');
} }

View file

@ -29,6 +29,7 @@ import org.eclipse.cdt.make.internal.core.makefile.EmptyLine;
import org.eclipse.cdt.make.internal.core.makefile.IgnoreRule; import org.eclipse.cdt.make.internal.core.makefile.IgnoreRule;
import org.eclipse.cdt.make.internal.core.makefile.InferenceRule; import org.eclipse.cdt.make.internal.core.makefile.InferenceRule;
import org.eclipse.cdt.make.internal.core.makefile.MacroDefinition; import org.eclipse.cdt.make.internal.core.makefile.MacroDefinition;
import org.eclipse.cdt.make.internal.core.makefile.MakeFileConstants;
import org.eclipse.cdt.make.internal.core.makefile.MakefileReader; import org.eclipse.cdt.make.internal.core.makefile.MakefileReader;
import org.eclipse.cdt.make.internal.core.makefile.PosixRule; import org.eclipse.cdt.make.internal.core.makefile.PosixRule;
import org.eclipse.cdt.make.internal.core.makefile.PreciousRule; import org.eclipse.cdt.make.internal.core.makefile.PreciousRule;
@ -199,7 +200,7 @@ public class PosixMakefile extends AbstractMakefile {
*/ */
public IDirective[] getBuiltins() { public IDirective[] getBuiltins() {
if (builtins == null) { if (builtins == null) {
String location = "builtin" + File.separator + "posix.mk"; String location = "builtin" + File.separator + "posix.mk"; //$NON-NLS-1$ //$NON-NLS-2$
try { try {
InputStream stream = MakeCorePlugin.getDefault().openStream(new Path(location)); InputStream stream = MakeCorePlugin.getDefault().openStream(new Path(location));
PosixMakefile gnu = new PosixMakefile(); PosixMakefile gnu = new PosixMakefile();
@ -238,19 +239,19 @@ public class PosixMakefile extends AbstractMakefile {
keyword = line; keyword = line;
reqs = new String[0]; reqs = new String[0];
} }
if (".IGNORE".equals(keyword)) { if (keyword.equals(MakeFileConstants.RULE_IGNORE)) {
special = new IgnoreRule(this, reqs); special = new IgnoreRule(this, reqs);
} else if (".POSIX".equals(keyword)) { } else if (keyword.equals(MakeFileConstants.RULE_POSIX)) {
special = new PosixRule(this); special = new PosixRule(this);
} else if (".PRECIOUS".equals(keyword)) { } else if (keyword.equals(MakeFileConstants.RULE_PRECIOUS)) {
special = new PreciousRule(this, reqs); special = new PreciousRule(this, reqs);
} else if (".SILENT".equals(keyword)) { } else if (keyword.equals(MakeFileConstants.RULE_SILENT)) {
special = new SilentRule(this, reqs); special = new SilentRule(this, reqs);
} else if (".SUFFIXES".equals(keyword)) { } else if (keyword.equals(MakeFileConstants.RULE_SUFFIXES)) {
special = new SuffixesRule(this, reqs); special = new SuffixesRule(this, reqs);
} else if (".DEFAULT".equals(keyword)) { } else if (keyword.equals(MakeFileConstants.RULE_DEFAULT)) {
special = new DefaultRule(this, new Command[0]); special = new DefaultRule(this, new Command[0]);
} else if (".SCCS_GET".equals(keyword)) { } else if (keyword.equals(MakeFileConstants.RULE_SCCS_GET)) {
special = new SccsGetRule(this, new Command[0]); special = new SccsGetRule(this, new Command[0]);
} }
return special; return special;
@ -282,7 +283,7 @@ public class PosixMakefile extends AbstractMakefile {
value = line.substring(index + 1).trim(); value = line.substring(index + 1).trim();
} else { } else {
name = line; name = line;
value = ""; value = ""; //$NON-NLS-1$
} }
return new MacroDefinition(this, name, new StringBuffer(value)); return new MacroDefinition(this, name, new StringBuffer(value));
} }
@ -328,7 +329,7 @@ public class PosixMakefile extends AbstractMakefile {
public static void main(String[] args) { public static void main(String[] args) {
try { try {
String filename = "Makefile"; String filename = "Makefile"; //$NON-NLS-1$
if (args.length == 1) { if (args.length == 1) {
filename = args[0]; filename = args[0];
} }

View file

@ -13,6 +13,7 @@ package org.eclipse.cdt.make.internal.core.makefile.posix;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.eclipse.cdt.make.internal.core.makefile.MakeFileConstants;
import org.eclipse.cdt.make.internal.core.makefile.Util; import org.eclipse.cdt.make.internal.core.makefile.Util;
/** /**
@ -28,7 +29,7 @@ public class PosixMakefileUtil {
int space; int space;
// Trim away trailing and prepending spaces. // Trim away trailing and prepending spaces.
line = line.trim(); line = line.trim();
while ((space = Util.indexOf(line, " \t")) != -1) { while ((space = Util.indexOf(line, " \t")) != -1) { //$NON-NLS-1$
aList.add(line.substring(0, space).trim()); aList.add(line.substring(0, space).trim());
line = line.substring(space + 1).trim(); line = line.substring(space + 1).trim();
} }
@ -57,11 +58,11 @@ public class PosixMakefileUtil {
public static boolean isInferenceRule(String line) { public static boolean isInferenceRule(String line) {
line = line.trim(); line = line.trim();
if (line.startsWith(".")) { if (line.startsWith(".")) { //$NON-NLS-1$
int index = Util.indexOf(line, ':'); int index = Util.indexOf(line, ':');
if (index > 1) { if (index > 1) {
line = line.substring(index + 1).trim(); line = line.substring(index + 1).trim();
if (line.length() == 0 || line.equals(";")) { if (line.length() == 0 || line.equals(";")) { //$NON-NLS-1$
return true; return true;
} }
} }
@ -74,7 +75,7 @@ public class PosixMakefileUtil {
int colon = Util.indexOf(line, ':'); int colon = Util.indexOf(line, ':');
if (colon > 0) { if (colon > 0) {
line = line.substring(0, colon).trim(); line = line.substring(0, colon).trim();
return line.equals(".DEFAULT"); return line.equals(MakeFileConstants.RULE_DEFAULT);
} }
return false; return false;
} }
@ -84,7 +85,7 @@ public class PosixMakefileUtil {
int colon = Util.indexOf(line, ':'); int colon = Util.indexOf(line, ':');
if (colon > 0) { if (colon > 0) {
line = line.substring(0, colon).trim(); line = line.substring(0, colon).trim();
return line.equals(".IGNORE"); return line.equals(MakeFileConstants.RULE_IGNORE);
} }
return false; return false;
} }
@ -94,7 +95,7 @@ public class PosixMakefileUtil {
int colon = Util.indexOf(line, ':'); int colon = Util.indexOf(line, ':');
if (colon > 0) { if (colon > 0) {
line = line.substring(0, colon).trim(); line = line.substring(0, colon).trim();
return line.equals(".POSIX"); return line.equals(MakeFileConstants.RULE_POSIX);
} }
return false; return false;
} }
@ -104,7 +105,7 @@ public class PosixMakefileUtil {
int colon = Util.indexOf(line, ':'); int colon = Util.indexOf(line, ':');
if (colon > 0) { if (colon > 0) {
line = line.substring(0, colon).trim(); line = line.substring(0, colon).trim();
return line.equals(".PRECIOUS"); return line.equals(MakeFileConstants.RULE_PRECIOUS);
} }
return false; return false;
} }
@ -114,7 +115,7 @@ public class PosixMakefileUtil {
int colon = Util.indexOf(line, ':'); int colon = Util.indexOf(line, ':');
if (colon > 0) { if (colon > 0) {
line = line.substring(0, colon).trim(); line = line.substring(0, colon).trim();
return line.equals(".SCCS_GET"); return line.equals(MakeFileConstants.RULE_SCCS_GET);
} }
return false; return false;
} }
@ -124,7 +125,7 @@ public class PosixMakefileUtil {
int colon = Util.indexOf(line, ':'); int colon = Util.indexOf(line, ':');
if (colon > 0) { if (colon > 0) {
line = line.substring(0, colon).trim(); line = line.substring(0, colon).trim();
return line.equals(".SILENT"); return line.equals(MakeFileConstants.RULE_SILENT);
} }
return false; return false;
} }
@ -134,7 +135,7 @@ public class PosixMakefileUtil {
int colon = Util.indexOf(line, ':'); int colon = Util.indexOf(line, ':');
if (colon > 0) { if (colon > 0) {
line = line.substring(0, colon).trim(); line = line.substring(0, colon).trim();
return line.equals(".SUFFIXES"); return line.equals(MakeFileConstants.RULE_SUFFIXES);
} }
return false; return false;
} }