+ *
+ */
+ public void setName(AslcompilerEnum name) throws BuildException {
+ if (isReference()) {
+ throw tooManyAttributes();
+ }
+ Aslcompiler aslcompiler = name.getAslcompiler();
+ setProcessor(aslcompiler);
+ }
+
+ protected void setProcessor(Processor proc) throws BuildException {
+ try {
+ super.setProcessor((Aslcompiler) proc);
+ } catch (ClassCastException ex) {
+ throw new BuildException(ex);
+ }
+ }
+
+ /**
+ * Enables or disables default flags.
+ *
+ * @param defaultflag
+ * if true, default flags will add to command line.
+ *
+ */
+ public void setDefaultflag(boolean defaultflag) {
+ if (isReference()) {
+ throw tooManyAttributes();
+ }
+ this.defaultflag = booleanValueOf(defaultflag);
+ }
+
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/AslcompilerEnum.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/AslcompilerEnum.java
new file mode 100644
index 0000000000..fa9806916f
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/AslcompilerEnum.java
@@ -0,0 +1,54 @@
+/*
+ *
+ * Copyright 2001-2005 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks;
+
+import net.sf.antcontrib.cpptasks.compiler.Aslcompiler;
+import net.sf.antcontrib.cpptasks.devstudio.DevStudioAslcompiler;
+import net.sf.antcontrib.cpptasks.intel.IntelWin32Aslcompiler;
+
+import org.apache.tools.ant.types.EnumeratedAttribute;
+
+/**
+ * Enumeration of supported ASL Compilers
+ *
+ *
Supported ASL Compilers
+ *
+ *
iasl (default)
+ *
Intel ACPI Source Language
+ *
+ *
+ *
asl
+ *
Microsoft ACPI Source Language
+ *
+ *
+ *
+ */
+public class AslcompilerEnum extends EnumeratedAttribute {
+ private final static ProcessorEnumValue[] aslcompiler = new ProcessorEnumValue[] {
+ new ProcessorEnumValue("iasl", IntelWin32Aslcompiler
+ .getInstance()),
+ new ProcessorEnumValue("asl", DevStudioAslcompiler
+ .getInstance()), };
+
+ public Aslcompiler getAslcompiler() {
+ return (Aslcompiler) aslcompiler[getIndex()].getProcessor();
+ }
+
+ public String[] getValues() {
+ return ProcessorEnumValue.getValues(aslcompiler);
+ }
+}
\ No newline at end of file
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/AssemblerDef.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/AssemblerDef.java
new file mode 100644
index 0000000000..aeae215780
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/AssemblerDef.java
@@ -0,0 +1,237 @@
+/*
+ *
+ * Copyright 2001-2005 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.util.Vector;
+
+import net.sf.antcontrib.cpptasks.compiler.Assembler;
+import net.sf.antcontrib.cpptasks.compiler.Processor;
+import net.sf.antcontrib.cpptasks.gcc.GccAssembler;
+import net.sf.antcontrib.cpptasks.types.AssemblerArgument;
+import net.sf.antcontrib.cpptasks.types.ConditionalPath;
+import net.sf.antcontrib.cpptasks.types.IncludePath;
+import net.sf.antcontrib.cpptasks.types.SystemIncludePath;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Project;
+
+/**
+ * A assembler definition. Assembler elements may be placed either as children
+ * of a cc element or the project element. A assembler element with an id
+ * attribute may be referenced from assembler elements with refid or extends
+ * attributes.
+ *
+ */
+public final class AssemblerDef extends ProcessorDef {
+
+ private final Vector includePaths = new Vector();
+
+ private final Vector sysIncludePaths = new Vector();
+
+ private Boolean defaultflag = new Boolean(true);
+
+ public AssemblerDef () {
+ }
+
+ /**
+ * Adds a assembler command-line arg.
+ */
+ public void addConfiguredAssemblerArg(AssemblerArgument arg) {
+ if (isReference()) {
+ throw noChildrenAllowed();
+ }
+ addConfiguredProcessorArg(arg);
+ }
+
+ /**
+ * Creates an include path.
+ */
+ public IncludePath createIncludePath() {
+ Project p = getProject();
+ if (p == null) {
+ throw new java.lang.IllegalStateException("project must be set");
+ }
+ if (isReference()) {
+ throw noChildrenAllowed();
+ }
+ IncludePath path = new IncludePath(p);
+ includePaths.addElement(path);
+ return path;
+ }
+
+ /**
+ * Creates an include path.
+ */
+ public SystemIncludePath createSysIncludePath() {
+ Project p = getProject();
+ if (p == null) {
+ throw new java.lang.IllegalStateException("project must be set");
+ }
+ if (isReference()) {
+ throw noChildrenAllowed();
+ }
+ SystemIncludePath path = new SystemIncludePath(p);
+ sysIncludePaths.addElement(path);
+ return path;
+ }
+
+ /**
+ * Add a or if specify the file attribute
+ *
+ * @throws BuildException
+ * if the specify file not exist
+ */
+ protected void loadFile(Vector activePath, File file) throws BuildException {
+ FileReader fileReader;
+ BufferedReader in;
+ String str;
+ if (!file.exists()) {
+ throw new BuildException("The file " + file + " is not existed");
+ }
+ try {
+ fileReader = new FileReader(file);
+ in = new BufferedReader(fileReader);
+ while ((str = in.readLine()) != null) {
+ if (str.trim() == "") {
+ continue;
+ }
+ str = getProject().replaceProperties(str);
+ activePath.addElement(str.trim());
+ }
+ } catch (Exception e) {
+ throw new BuildException(e.getMessage());
+ }
+ }
+
+ public void execute() throws org.apache.tools.ant.BuildException {
+ throw new org.apache.tools.ant.BuildException(
+ "Not an actual task, but looks like one for documentation purposes");
+ }
+
+ /**
+ * Returns the assembler-specific include path.
+ */
+ public String[] getActiveIncludePaths() {
+ if (isReference()) {
+ return ((AssemblerDef) getCheckedRef(AssemblerDef.class,
+ "AssemblerDef")).getActiveIncludePaths();
+ }
+ return getActivePaths(includePaths);
+ }
+
+ /**
+ * Returns the assembler-specific sysinclude path.
+ */
+ public String[] getActiveSysIncludePaths() {
+ if (isReference()) {
+ return ((AssemblerDef) getCheckedRef(AssemblerDef.class,
+ "AssemblerDef")).getActiveSysIncludePaths();
+ }
+ return getActivePaths(sysIncludePaths);
+ }
+
+ private String[] getActivePaths(Vector paths) {
+ Project p = getProject();
+ if (p == null) {
+ throw new java.lang.IllegalStateException("project not set");
+ }
+ Vector activePaths = new Vector(paths.size());
+ for (int i = 0; i < paths.size(); i++) {
+ ConditionalPath path = (ConditionalPath) paths.elementAt(i);
+ if (path.isActive(p)) {
+ if (path.getFile() == null) {
+ String[] pathEntries = path.list();
+ for (int j = 0; j < pathEntries.length; j++) {
+ activePaths.addElement(pathEntries[j]);
+ }
+ } else {
+ loadFile(activePaths, path.getFile());
+ }
+ }
+ }
+ String[] pathNames = new String[activePaths.size()];
+ activePaths.copyInto(pathNames);
+ return pathNames;
+ }
+
+ public final Boolean getDefaultflag(AssemblerDef[] defaultProviders,
+ int index) {
+ if (isReference()) {
+ return ((AssemblerDef) getCheckedRef(AssemblerDef.class,
+ "AssemblerDef")).getDefaultflag(defaultProviders,
+ index);
+ }
+ return defaultflag;
+ }
+
+ public Processor getProcessor() {
+ Processor processor = super.getProcessor();
+ if (processor == null) {
+ processor = GccAssembler.getInstance();
+ }
+ return processor;
+ }
+
+ /**
+ * Sets r type.
+ *
+ *
Supported assemblers
+ *
+ *
gcc (default)
+ *
GAS assembler
+ *
+ *
+ *
masm
+ *
MASM assembler
+ *
+ *
+ *
+ */
+ public void setName(AssemblerEnum name) throws BuildException {
+ if (isReference()) {
+ throw tooManyAttributes();
+ }
+ Assembler assembler = name.getAssembler();
+ setProcessor(assembler);
+ }
+
+ protected void setProcessor(Processor proc) throws BuildException {
+ try {
+ super.setProcessor((Assembler) proc);
+ } catch (ClassCastException ex) {
+ throw new BuildException(ex);
+ }
+ }
+
+ /**
+ * Enables or disables default flags.
+ *
+ * @param defaultflag
+ * if true, default flags will add to command line.
+ *
+ */
+ public void setDefaultflag(boolean defaultflag) {
+ if (isReference()) {
+ throw tooManyAttributes();
+ }
+ this.defaultflag = booleanValueOf(defaultflag);
+ }
+
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/AssemblerEnum.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/AssemblerEnum.java
new file mode 100644
index 0000000000..9abf9f496d
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/AssemblerEnum.java
@@ -0,0 +1,53 @@
+/*
+ *
+ * Copyright 2001-2005 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks;
+
+import net.sf.antcontrib.cpptasks.compiler.Assembler;
+import net.sf.antcontrib.cpptasks.devstudio.DevStudioAssembler;
+import net.sf.antcontrib.cpptasks.gcc.GccAssembler;
+
+import org.apache.tools.ant.types.EnumeratedAttribute;
+
+/**
+ * Enumeration of supported assemblers
+ *
+ *
Supported assemblers
+ *
+ *
gas (default)
+ *
GAS assembler
+ *
+ *
+ *
masm
+ *
MASM assembler
+ *
+ *
+ *
+ */
+public class AssemblerEnum extends EnumeratedAttribute {
+ private final static ProcessorEnumValue[] assemblers = new ProcessorEnumValue[] {
+ new ProcessorEnumValue("gas", GccAssembler.getInstance()),
+ new ProcessorEnumValue("masm", DevStudioAssembler
+ .getInstance()), };
+
+ public Assembler getAssembler() {
+ return (Assembler) assemblers[getIndex()].getProcessor();
+ }
+
+ public String[] getValues() {
+ return ProcessorEnumValue.getValues(assemblers);
+ }
+}
\ No newline at end of file
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/CCTask.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/CCTask.java
new file mode 100644
index 0000000000..d044df1288
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/CCTask.java
@@ -0,0 +1,1749 @@
+/*
+ *
+ * Copyright 2001-2005 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Enumeration;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.Vector;
+
+import net.sf.antcontrib.cpptasks.compiler.AslcompilerConfiguration;
+import net.sf.antcontrib.cpptasks.compiler.AssemblerConfiguration;
+import net.sf.antcontrib.cpptasks.compiler.CompilerConfiguration;
+import net.sf.antcontrib.cpptasks.compiler.LinkType;
+import net.sf.antcontrib.cpptasks.compiler.Linker;
+import net.sf.antcontrib.cpptasks.compiler.LinkerConfiguration;
+import net.sf.antcontrib.cpptasks.compiler.Processor;
+import net.sf.antcontrib.cpptasks.compiler.ProcessorConfiguration;
+import net.sf.antcontrib.cpptasks.types.AslcompilerArgument;
+import net.sf.antcontrib.cpptasks.types.AssemblerArgument;
+import net.sf.antcontrib.cpptasks.types.CompilerArgument;
+import net.sf.antcontrib.cpptasks.types.ConditionalFileSet;
+import net.sf.antcontrib.cpptasks.types.DefineSet;
+import net.sf.antcontrib.cpptasks.types.IncludePath;
+import net.sf.antcontrib.cpptasks.types.LibrarySet;
+import net.sf.antcontrib.cpptasks.types.LinkerArgument;
+import net.sf.antcontrib.cpptasks.types.SystemIncludePath;
+import net.sf.antcontrib.cpptasks.types.SystemLibrarySet;
+import net.sf.antcontrib.cpptasks.userdefine.UserDefineCompiler;
+import net.sf.antcontrib.cpptasks.userdefine.UserDefineDef;
+import net.sf.antcontrib.cpptasks.VersionInfo;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.Task;
+import org.apache.tools.ant.types.Environment;
+
+/**
+ * Compile, link, assembler and asl compile task.
+ *
+ *
+ * This task can compile various source languages and produce executables,
+ * shared libraries (aka DLL's) and static libraries. Compiler adaptors are
+ * currently available for several C/C++ compilers, FORTRAN, MIDL and Windows
+ * Resource files. Assembler adaptors are currently available for MASM and GAS.
+ * And aslcompiler support to ASL and IASL command.
+ *
+ *
+ *
+ *
+ * Copyright (c) 2001-2005, The Ant-Contrib project.
+ *
+ *
+ *
+ * Licensed under the Apache Software License 2.0,
+ * http://www.apache.org/licenses/LICENSE-2.0.
+ *
+ *
+ *
+ * For use with Apache Ant 1.5 or later. This software is not a product of the
+ * of the Apache Software Foundation and no endorsement is implied.
+ *
+ *
+ *
+ * THIS SOFTWARE IS PROVIDED 'AS-IS', See
+ * http://www.apache.org/licenses/LICENSE-2.0 for additional disclaimers.
+ *
+ *
+ * To use:
+ *
+ *
Place cpptasks.jar into the lib directory of Ant 1.5 or later.
+ *
Add <taskdef resource="cpptasks.tasks"/> and <typedef
+ * resource="cpptasks.types"/> to build.xml.
+ *
Add <cc/>, <compiler/> <linker/> <assembler/>
+ * and <aslcompiler/> elements to project.
+ *
Set path and environment variables to be able to run compiler from
+ * command line.
+ *
Build project.
+ *
+ *
+ * @author Adam Murdoch
+ * @author Curt Arnold
+ */
+public class CCTask extends Task {
+ private class SystemLibraryCollector implements FileVisitor {
+ private Hashtable libraries;
+
+ private Linker linker;
+
+ public SystemLibraryCollector (Linker linker, Hashtable libraries) {
+ this.linker = linker;
+ this.libraries = libraries;
+ }
+
+ public void visit(File basedir, String filename) {
+ if (linker.bid(filename) > 0) {
+ File libfile = new File(basedir, filename);
+ String key = linker.getLibraryKey(libfile);
+ libraries.put(key, libfile);
+ }
+ }
+ }
+
+ private static final ProcessorConfiguration[] EMPTY_CONFIG_ARRAY = new ProcessorConfiguration[0];
+
+ /**
+ * Builds a Hashtable to targets needing to be rebuilt keyed by compiler
+ * configuration
+ */
+ public static Hashtable getTargetsToBuildByConfiguration(Hashtable targets) {
+ Hashtable targetsByConfig = new Hashtable();
+ Enumeration targetEnum = targets.elements();
+ while (targetEnum.hasMoreElements()) {
+ TargetInfo target = (TargetInfo) targetEnum.nextElement();
+ if (target.getRebuild()) {
+ Vector targetsForSameConfig = (Vector) targetsByConfig
+ .get(target.getConfiguration());
+ if (targetsForSameConfig != null) {
+ targetsForSameConfig.addElement(target);
+ } else {
+ targetsForSameConfig = new Vector();
+ targetsForSameConfig.addElement(target);
+ targetsByConfig.put(target.getConfiguration(),
+ targetsForSameConfig);
+ }
+ }
+ }
+ return targetsByConfig;
+ }
+
+ /** The userdefine definitions. */
+ private Vector _userdefines = new Vector();
+
+ /** The compiler definitions. */
+ private Vector _compilers = new Vector();
+
+ /** The output file type. */
+ // private LinkType _linkType = LinkType.EXECUTABLE;
+ /** The library sets. */
+ private Vector _libsets = new Vector();
+
+ /** The aslcompiler definitions. */
+ private Vector _aslcompiler = new Vector();
+
+ /** The assembler definitions. */
+ private Vector _assemblers = new Vector();
+
+ /** The linker definitions. */
+ private Vector _linkers = new Vector();
+
+ /** The object directory. */
+ private File _objDir;
+
+ /** The output file. */
+ private File _outfile;
+
+ private boolean userdefine = false;
+ private String arch;
+ private String os;
+ private String vendor;
+
+ /** the flag for assembler */
+ private boolean assembler = true;
+
+ /** the flag for aslcompiler */
+ private boolean aslcompiler = true;
+
+ /** The linker definitions. */
+ private final Vector targetPlatforms = new Vector();
+
+ /** The distributer definitions. */
+ private Vector distributers = new Vector();
+
+ /**
+ * If true, stop build on compile failure.
+ */
+ protected boolean failOnError = true;
+
+ /**
+ * Content that appears in and also in are maintained by a
+ * captive CompilerDef instance
+ */
+ private final CompilerDef compilerDef = new CompilerDef();
+
+ /**
+ * Content that appears in and also in are maintained by a
+ * captive AslcompilerDef instance
+ */
+ private final AslcompilerDef aslcompilerDef = new AslcompilerDef();
+
+ /** The OS390 dataset to build to object to */
+ private String dataset;
+
+ /**
+ *
+ * Depth of dependency checking
+ *
+ * Values < 0 indicate full dependency checking Values >= 0 indicate partial
+ * dependency checking and for superficial compilation checks. Will throw
+ * BuildException before attempting link
+ */
+ private int dependencyDepth = -1;
+
+ /**
+ * Content that appears in and also in are maintained by a
+ * captive AssemblerDef instance
+ */
+ private final AssemblerDef assemblerDef = new AssemblerDef();
+
+ /**
+ * Content that appears in and also in are maintained by a
+ * captive CompilerDef instance
+ */
+ private final LinkerDef linkerDef = new LinkerDef();
+
+ /**
+ * contains the subsystem, output type and
+ *
+ */
+ private final LinkType linkType = new LinkType();
+
+ /**
+ * The property name which will be set with the physical filename of the
+ * file that is generated by the linker
+ */
+ private String outputFileProperty;
+
+ /**
+ * if relentless = true, compilations should attempt to compile as many
+ * files as possible before throwing a BuildException
+ */
+ private boolean relentless;
+
+ public CCTask () {
+ }
+
+
+ public void addConfiguredCommand(UserDefineDef userdefineDef) {
+ if (userdefineDef == null) {
+ throw new NullPointerException("UserDefineDef");
+ }
+ userdefineDef.setProject(getProject());
+ _userdefines.addElement(userdefineDef);
+ }
+ /**
+ * Adds a asl compiler definition or reference.
+ *
+ * @param Aslcompiler
+ * aslcompiler
+ * @throws NullPointerException
+ * if aslcompiler is null
+ */
+ public void addConfiguredAslcompiler(AslcompilerDef aslcompier) {
+ if (aslcompier == null) {
+ throw new NullPointerException("aslcompier");
+ }
+ aslcompier.setProject(getProject());
+ _aslcompiler.addElement(aslcompier);
+ }
+
+ /**
+ * Adds a asl command-line arg. Argument will be inherited by all nested
+ * aslcompiler elements that do not have inherit="false".
+ *
+ */
+ public void addConfiguredAslcompilerArg(AslcompilerArgument arg) {
+ aslcompilerDef.addConfiguredAslcompilerArg(arg);
+ }
+
+ /**
+ * Adds a assembler definition or reference.
+ *
+ * @param assembler
+ * assemblera
+ * @throws NullPointerException
+ * if assembler is null
+ */
+ public void addConfiguredAssembler(AssemblerDef assembler) {
+ if (assembler == null) {
+ throw new NullPointerException("assembler");
+ }
+ assembler.setProject(getProject());
+ _assemblers.addElement(assembler);
+ }
+
+ /**
+ * Adds a assembler command-line arg. Argument will be inherited by all
+ * nested assembler elements that do not have inherit="false".
+ *
+ */
+ public void addConfiguredAssemblerArg(AssemblerArgument arg) {
+ assemblerDef.addConfiguredAssemblerArg(arg);
+ }
+
+ /**
+ * Adds a compiler definition or reference.
+ *
+ * @param compiler
+ * compiler
+ * @throws NullPointerException
+ * if compiler is null
+ */
+ public void addConfiguredCompiler(CompilerDef compiler) {
+ if (compiler == null) {
+ throw new NullPointerException("compiler");
+ }
+ compiler.setProject(getProject());
+ _compilers.addElement(compiler);
+ }
+
+ /**
+ * Adds a compiler command-line arg. Argument will be inherited by all
+ * nested compiler elements that do not have inherit="false".
+ *
+ */
+ public void addConfiguredCompilerArg(CompilerArgument arg) {
+ compilerDef.addConfiguredCompilerArg(arg);
+ }
+
+ /**
+ * Adds a defineset. Will be inherited by all compiler elements that do not
+ * have inherit="false".
+ *
+ * @param defs
+ * Define set
+ */
+ public void addConfiguredDefineset(DefineSet defs) {
+ compilerDef.addConfiguredDefineset(defs);
+ }
+
+ /**
+ * Adds a linker definition. The first linker that is not disqualified by
+ * its "if" and "unless" attributes will perform the link. If no child
+ * linker element is active, the linker implied by the cc elements name or
+ * classname attribute will be used.
+ *
+ * @param linker
+ * linker
+ * @throws NullPointerException
+ * if linker is null
+ */
+ public void addConfiguredLinker(LinkerDef linker) {
+ if (linker == null) {
+ throw new NullPointerException("linker");
+ }
+ linker.setProject(getProject());
+ _linkers.addElement(linker);
+ }
+
+ /**
+ * Adds a linker command-line arg. Argument will be inherited by all nested
+ * linker elements that do not have inherit="false".
+ */
+ public void addConfiguredLinkerArg(LinkerArgument arg) {
+ linkerDef.addConfiguredLinkerArg(arg);
+ }
+
+ /**
+ * Add an environment variable to the launched process.
+ */
+ public void addEnv(Environment.Variable var) {
+ compilerDef.addEnv(var);
+ linkerDef.addEnv(var);
+ assemblerDef.addEnv(var);
+ aslcompilerDef.addEnv(var);
+ }
+
+ /**
+ * Adds a source file set.
+ *
+ * Files in these filesets will be auctioned to the available compiler
+ * configurations, with the default compiler implied by the cc element
+ * bidding last. If no compiler is interested in the file, it will be passed
+ * to the linker.
+ *
+ * To have a file be processed by a particular compiler configuration, add a
+ * fileset to the corresponding compiler element.
+ */
+ public void addFileset(ConditionalFileSet srcSet) {
+ compilerDef.addFileset(srcSet);
+ }
+
+ /**
+ * Adds a library set.
+ *
+ * Library sets will be inherited by all linker elements that do not have
+ * inherit="false".
+ *
+ * @param libset
+ * library set
+ * @throws NullPointerException
+ * if libset is null.
+ */
+ public void addLibset(LibrarySet libset) {
+ if (libset == null) {
+ throw new NullPointerException("libset");
+ }
+ linkerDef.addLibset(libset);
+ }
+
+ /**
+ * Adds a system library set. Timestamps and locations of system library
+ * sets are not used in dependency analysis.
+ *
+ * Essential libraries (such as C Runtime libraries) should not be specified
+ * since the task will attempt to identify the correct libraries based on
+ * the multithread, debug and runtime attributes.
+ *
+ * System library sets will be inherited by all linker elements that do not
+ * have inherit="false".
+ *
+ * @param libset
+ * library set
+ * @throws NullPointerException
+ * if libset is null.
+ */
+ public void addSyslibset(SystemLibrarySet libset) {
+ if (libset == null) {
+ throw new NullPointerException("libset");
+ }
+ linkerDef.addSyslibset(libset);
+ }
+
+ /**
+ * Checks all targets that are not forced to be rebuilt or are missing
+ * object files to be checked for modified include files
+ *
+ * @returns total number of targets to be rebuilt
+ *
+ */
+ protected int checkForChangedIncludeFiles(Hashtable targets) {
+ int potentialTargets = 0;
+ int definiteTargets = 0;
+ Enumeration targetEnum = targets.elements();
+ while (targetEnum.hasMoreElements()) {
+ TargetInfo target = (TargetInfo) targetEnum.nextElement();
+ if (!target.getRebuild()) {
+ potentialTargets++;
+ } else {
+ definiteTargets++;
+ }
+ }
+ //
+ // If there were remaining targets that
+ // might be out of date
+ //
+ if (potentialTargets > 0) {
+ log("Starting dependency analysis for "
+ + Integer.toString(potentialTargets) + " files.");
+ DependencyTable dependencyTable = new DependencyTable(_objDir);
+ try {
+ dependencyTable.load();
+ } catch (Exception ex) {
+ log("Problem reading dependencies.xml: " + ex.toString());
+ }
+ targetEnum = targets.elements();
+ while (targetEnum.hasMoreElements()) {
+ TargetInfo target = (TargetInfo) targetEnum.nextElement();
+ if (!target.getRebuild()) {
+ if (dependencyTable.needsRebuild(this, target,
+ dependencyDepth)) {
+ target.mustRebuild();
+ }
+ }
+ }
+ dependencyTable.commit(this);
+ }
+ //
+ // count files being rebuilt now
+ //
+ int currentTargets = 0;
+ targetEnum = targets.elements();
+ while (targetEnum.hasMoreElements()) {
+ TargetInfo target = (TargetInfo) targetEnum.nextElement();
+ if (target.getRebuild()) {
+ currentTargets++;
+ }
+ }
+ if (potentialTargets > 0) {
+ log(Integer.toString(potentialTargets - currentTargets
+ + definiteTargets)
+ + " files are up to date.");
+ log(Integer.toString(currentTargets - definiteTargets)
+ + " files to be recompiled from dependency analysis.");
+ }
+ log(Integer.toString(currentTargets) + " total files to be compiled.");
+ return currentTargets;
+ }
+
+ protected LinkerConfiguration collectExplicitObjectFiles(
+ Vector objectFiles, Vector sysObjectFiles) {
+ //
+ // find the first eligible linker
+ //
+ //
+ ProcessorConfiguration linkerConfig = null;
+ LinkerDef selectedLinkerDef = null;
+ Linker selectedLinker = null;
+ Hashtable sysLibraries = new Hashtable();
+ TargetDef targetPlatform = getTargetPlatform();
+ FileVisitor objCollector = null;
+ FileVisitor sysLibraryCollector = null;
+ for (int i = 0; i < _linkers.size(); i++) {
+ LinkerDef currentLinkerDef = (LinkerDef) _linkers.elementAt(i);
+ if (currentLinkerDef.isActive()) {
+ selectedLinkerDef = currentLinkerDef;
+ selectedLinker = currentLinkerDef.getProcessor().getLinker(
+ linkType);
+ //
+ // skip the linker if it doesn't know how to
+ // produce the specified link type
+ if (selectedLinker != null) {
+ linkerConfig = currentLinkerDef.createConfiguration(this,
+ linkType, linkerDef, targetPlatform);
+ if (linkerConfig != null) {
+ //
+ // create collectors for object files
+ // and system libraries
+ objCollector = new ObjectFileCollector(selectedLinker,
+ objectFiles);
+ sysLibraryCollector = new SystemLibraryCollector(
+ selectedLinker, sysLibraries);
+ //
+ // if the has embedded 's
+ // (such as linker specific libraries)
+ // add them as object files.
+ //
+ if (currentLinkerDef.hasFileSets()) {
+ currentLinkerDef.visitFiles(objCollector);
+ }
+ //
+ // user libraries are just a specialized form
+ // of an object fileset
+ selectedLinkerDef.visitUserLibraries(selectedLinker,
+ objCollector);
+ }
+ break;
+ }
+ }
+ }
+ if (linkerConfig == null) {
+ linkerConfig = linkerDef.createConfiguration(this, linkType, null,
+ targetPlatform);
+ selectedLinker = (Linker) linkerDef.getProcessor().getLinker(
+ linkType);
+ objCollector = new ObjectFileCollector(selectedLinker, objectFiles);
+ sysLibraryCollector = new SystemLibraryCollector(selectedLinker,
+ sysLibraries);
+ }
+ //
+ // unless there was a element that
+ // explicitly did not inherit files from
+ // containing element
+ if (selectedLinkerDef == null || selectedLinkerDef.getInherit()) {
+ linkerDef.visitUserLibraries(selectedLinker, objCollector);
+ linkerDef.visitSystemLibraries(selectedLinker, sysLibraryCollector);
+ }
+ //
+ // if there was a in a nested
+ // evaluate it last so it takes priority over
+ // identically named libs from element
+ //
+ if (selectedLinkerDef != null) {
+ //
+ // add any system libraries to the hashtable
+ // done in reverse order so the earliest
+ // on the classpath takes priority
+ selectedLinkerDef.visitSystemLibraries(selectedLinker,
+ sysLibraryCollector);
+ }
+ //
+ // copy over any system libraries to the
+ // object files vector
+ //
+ Enumeration sysLibEnum = sysLibraries.elements();
+ while (sysLibEnum.hasMoreElements()) {
+ sysObjectFiles.addElement(sysLibEnum.nextElement());
+ }
+ return (LinkerConfiguration) linkerConfig;
+ }
+
+ /**
+ * Adds an include path.
+ *
+ * Include paths will be inherited by nested compiler elements that do not
+ * have inherit="false".
+ */
+ public IncludePath createIncludePath() {
+ return compilerDef.createIncludePath();
+ }
+
+ /**
+ * Specifies precompilation prototype file and exclusions. Inherited by all
+ * compilers that do not have inherit="false".
+ *
+ */
+ public PrecompileDef createPrecompile() throws BuildException {
+ return compilerDef.createPrecompile();
+ }
+
+ /**
+ * Adds a system include path. Locations and timestamps of files located
+ * using the system include paths are not used in dependency analysis.
+ *
+ *
+ * Standard include locations should not be specified. The compiler adapters
+ * should recognized the settings from the appropriate environment variables
+ * or configuration files.
+ *
+ * System include paths will be inherited by nested compiler elements that
+ * do not have inherit="false".
+ */
+ public SystemIncludePath createSysIncludePath() {
+ return compilerDef.createSysIncludePath();
+ }
+
+ /**
+ * Executes the task. Compiles the given files.
+ *
+ * @throws BuildException
+ * if someting goes wrong with the build
+ */
+ public void execute() throws BuildException {
+ //
+ // if link type allowed objdir to be defaulted
+ // provide it from outfile
+ if (_objDir == null) {
+ if (_outfile != null) {
+ _objDir = new File(_outfile.getParent());
+ } else {
+ _objDir = new File(".");
+ }
+ }
+
+ //
+ // if the object directory does not exist
+ //
+ if (!_objDir.exists()) {
+ throw new BuildException("Object directory does not exist");
+ }
+
+ //
+ // if userdefine is true, then run all user defined command
+ //
+ if (userdefine) {
+ Iterator iter = _userdefines.iterator();
+ while( iter.hasNext()) {
+ UserDefineDef userdefineDef = (UserDefineDef)iter.next();
+ UserDefineCompiler userdefineCompiler = new UserDefineCompiler(this, userdefineDef);
+ userdefineCompiler.command(this, userdefineDef);
+ }
+ return ;
+ }
+
+ TargetHistoryTable objHistory = new TargetHistoryTable(this, _objDir);
+ //
+ // determine the eventual linker configuration
+ // (may be null) and collect any explicit
+ // object files or libraries
+ Vector objectFiles = new Vector();
+ Vector sysObjectFiles = new Vector();
+ LinkerConfiguration linkerConfig = collectExplicitObjectFiles(
+ objectFiles, sysObjectFiles);
+ //
+ // Assembler hashtable of all files
+ // that we know how to compile (keyed by output file name)
+ //
+ Hashtable targets = getTargets(linkerConfig, objectFiles);
+ Hashtable acpiTarget = new Hashtable();
+ if (aslcompiler) {
+ acpiTarget = getAcpiTargets(linkerConfig, new Vector());
+ }
+ Hashtable assemblerTarget = new Hashtable();
+ if (assembler) {
+ assemblerTarget = getAssemblerTargets(linkerConfig, objectFiles);
+ }
+ TargetInfo linkTarget = null;
+ //
+ // if output file is not specified,
+ // then skip link step
+ //
+ if (_outfile != null) {
+ linkTarget = getLinkTarget(linkerConfig, objectFiles,
+ sysObjectFiles, targets, assemblerTarget);
+ }
+ //
+ // If specify the aslcompiler, then call asl compiler
+ //
+ if (aslcompiler) {
+ BuildException acpiException = null;
+ Hashtable targetsByConfig = getTargetsToBuildByConfiguration(acpiTarget);
+ Enumeration acpiTargetEnum = targetsByConfig.elements();
+ Vector[] targetVectors = new Vector[targetsByConfig.size()];
+ int index = 0;
+ while (acpiTargetEnum.hasMoreElements()) {
+ Vector targetsForConfig = (Vector) acpiTargetEnum.nextElement();
+ targetVectors[index++] = targetsForConfig;
+ }
+ for (int i = 0; i < targetVectors.length; i++) {
+ //
+ // get the targets for this configuration
+ //
+ Vector targetsForConfig = targetVectors[i];
+ //
+ // get the configuration from the first entry
+ //
+ AslcompilerConfiguration config = (AslcompilerConfiguration) ((TargetInfo) targetsForConfig
+ .elementAt(0)).getConfiguration();
+ //
+ // prepare the list of source files
+ //
+ String[] sourceFiles = new String[targetsForConfig.size()];
+ Enumeration targetsEnum = targetsForConfig.elements();
+ index = 0;
+ while (targetsEnum.hasMoreElements()) {
+ TargetInfo targetInfo = ((TargetInfo) targetsEnum
+ .nextElement());
+ sourceFiles[index++] = targetInfo.getSources()[0]
+ .toString();
+ }
+ try {
+ config.aslcompiler(this, _objDir, sourceFiles);
+ log(sourceFiles.length
+ + " total ACPI source files to be compiled.");
+ } catch (BuildException ex) {
+ if (acpiException == null) {
+ acpiException = ex;
+ }
+ if (!relentless)
+ break;
+ }
+ }
+ }
+ //
+ // If specify the assembler, then call assembler
+ //
+ if (assembler) {
+ BuildException assemblerException = null;
+ Hashtable targetsByConfig = getTargetsToBuildByConfiguration(assemblerTarget);
+ Enumeration assembleTargetEnum = targetsByConfig.elements();
+ Vector[] targetVectors = new Vector[targetsByConfig.size()];
+ int index = 0;
+ while (assembleTargetEnum.hasMoreElements()) {
+ Vector targetsForConfig = (Vector) assembleTargetEnum
+ .nextElement();
+ targetVectors[index++] = targetsForConfig;
+ }
+ for (int i = 0; i < targetVectors.length; i++) {
+ //
+ // get the targets for this configuration
+ //
+ Vector targetsForConfig = targetVectors[i];
+ //
+ // get the configuration from the first entry
+ //
+ AssemblerConfiguration config = (AssemblerConfiguration) ((TargetInfo) targetsForConfig
+ .elementAt(0)).getConfiguration();
+ //
+ // prepare the list of source files
+ //
+ String[] sourceFiles = new String[targetsForConfig.size()];
+ Enumeration targetsEnum = targetsForConfig.elements();
+ index = 0;
+ while (targetsEnum.hasMoreElements()) {
+ TargetInfo targetInfo = ((TargetInfo) targetsEnum
+ .nextElement());
+ sourceFiles[index++] = targetInfo.getSources()[0]
+ .toString();
+ }
+ try {
+ config.assembler(this, _objDir, sourceFiles);
+ log(sourceFiles.length + " total files to be assembled.");
+ } catch (BuildException ex) {
+ if (assemblerException == null) {
+ assemblerException = ex;
+ }
+ if (!relentless)
+ break;
+ }
+ }
+ //
+ // if we threw a assembler exception and
+ // didn't throw it at the time because
+ // we were relentless then
+ // save the history and
+ // throw the exception
+ //
+ if (assemblerException != null) {
+ if (failOnError) {
+ throw assemblerException;
+ } else {
+ log(assemblerException.getMessage(), Project.MSG_ERR);
+ return;
+ }
+ }
+ }
+
+ //
+ // mark targets that don't have a history record or
+ // whose source last modification time is not
+ // the same as the history to be rebuilt
+ //
+ objHistory.markForRebuild(targets);
+ CCTaskProgressMonitor monitor = new CCTaskProgressMonitor(objHistory);
+ //
+ // check for changed include files
+ //
+ int rebuildCount = checkForChangedIncludeFiles(targets);
+ if (rebuildCount > 0) {
+ BuildException compileException = null;
+ //
+ // compile all targets with getRebuild() == true
+ //
+ Hashtable targetsByConfig = getTargetsToBuildByConfiguration(targets);
+ //
+ // build array containing Vectors with precompiled generation
+ // steps going first
+ //
+ Vector[] targetVectors = new Vector[targetsByConfig.size()];
+ int index = 0;
+ Enumeration targetVectorEnum = targetsByConfig.elements();
+ while (targetVectorEnum.hasMoreElements()) {
+ Vector targetsForConfig = (Vector) targetVectorEnum
+ .nextElement();
+ //
+ // get the configuration from the first entry
+ //
+ CompilerConfiguration config = (CompilerConfiguration) ((TargetInfo) targetsForConfig
+ .elementAt(0)).getConfiguration();
+ if (config.isPrecompileGeneration()) {
+ targetVectors[index++] = targetsForConfig;
+ }
+ }
+ targetVectorEnum = targetsByConfig.elements();
+ while (targetVectorEnum.hasMoreElements()) {
+ Vector targetsForConfig = (Vector) targetVectorEnum
+ .nextElement();
+ for (int i = 0; i < targetVectors.length; i++) {
+ if (targetVectors[i] == targetsForConfig) {
+ break;
+ }
+ if (targetVectors[i] == null) {
+ targetVectors[i] = targetsForConfig;
+ break;
+ }
+ }
+ }
+ for (int i = 0; i < targetVectors.length; i++) {
+ //
+ // get the targets for this configuration
+ //
+ Vector targetsForConfig = targetVectors[i];
+ //
+ // get the configuration from the first entry
+ //
+ CompilerConfiguration config = (CompilerConfiguration) ((TargetInfo) targetsForConfig
+ .elementAt(0)).getConfiguration();
+ //
+ // prepare the list of source files
+ //
+ String[] sourceFiles = new String[targetsForConfig.size()];
+ Enumeration targetsEnum = targetsForConfig.elements();
+ index = 0;
+ while (targetsEnum.hasMoreElements()) {
+ TargetInfo targetInfo = ((TargetInfo) targetsEnum
+ .nextElement());
+ sourceFiles[index++] = targetInfo.getSources()[0]
+ .toString();
+ }
+ try {
+ config.compile(this, _objDir, sourceFiles, relentless,
+ monitor);
+ } catch (BuildException ex) {
+ if (compileException == null) {
+ compileException = ex;
+ }
+ if (!relentless)
+ break;
+ }
+ }
+ //
+ // save the details of the object file compilation
+ // settings to disk for dependency analysis
+ //
+ try {
+ objHistory.commit();
+ } catch (IOException ex) {
+ this.log("Error writing history.xml: " + ex.toString());
+ }
+ //
+ // if we threw a compile exception and
+ // didn't throw it at the time because
+ // we were relentless then
+ // save the history and
+ // throw the exception
+ //
+ if (compileException != null) {
+ if (failOnError) {
+ throw compileException;
+ } else {
+ log(compileException.getMessage(), Project.MSG_ERR);
+ return;
+ }
+ }
+ }
+ //
+ // if the dependency tree was not fully
+ // evaluated, then throw an exception
+ // since we really didn't do what we
+ // should have done
+ //
+ //
+ if (dependencyDepth >= 0) {
+ throw new BuildException(
+ "All files at depth "
+ + Integer.toString(dependencyDepth)
+ + " from changes successfully compiled.\n"
+ + "Remove or change dependencyDepth to -1 to perform full compilation.");
+ }
+ //
+ // if no link target then
+ // commit the history for the object files
+ // and leave the task
+ if (linkTarget != null) {
+ //
+ // get the history for the link target (may be the same
+ // as the object history)
+ TargetHistoryTable linkHistory = getLinkHistory(objHistory);
+ //
+ // see if it needs to be rebuilt
+ //
+ linkHistory.markForRebuild(linkTarget);
+ //
+ // if it needs to be rebuilt, rebuild it
+ //
+ File output = linkTarget.getOutput();
+ if (linkTarget.getRebuild()) {
+ log("Starting link");
+ LinkerConfiguration linkConfig = (LinkerConfiguration) linkTarget
+ .getConfiguration();
+ if (failOnError) {
+ linkConfig.link(this, linkTarget);
+ } else {
+ try {
+ linkConfig.link(this, linkTarget);
+ } catch (BuildException ex) {
+ log(ex.getMessage(), Project.MSG_ERR);
+ return;
+ }
+ }
+ if (outputFileProperty != null)
+ getProject().setProperty(outputFileProperty,
+ output.getAbsolutePath());
+ linkHistory.update(linkTarget);
+ try {
+ linkHistory.commit();
+ } catch (IOException ex) {
+ log("Error writing link history.xml: " + ex.toString());
+ }
+ } else {
+ if (outputFileProperty != null)
+ getProject().setProperty(outputFileProperty,
+ output.getAbsolutePath());
+ }
+ }
+ }
+
+ /**
+ * Gets the dataset.
+ *
+ * @return Returns a String
+ */
+ public String getDataset() {
+ return dataset;
+ }
+
+ protected TargetHistoryTable getLinkHistory(TargetHistoryTable objHistory) {
+ File outputFileDir = new File(_outfile.getParent());
+ //
+ // if the output file is being produced in the link
+ // directory, then we can use the same history file
+ //
+ if (_objDir.equals(outputFileDir)) {
+ return objHistory;
+ }
+ return new TargetHistoryTable(this, outputFileDir);
+ }
+
+ protected TargetInfo getLinkTarget(LinkerConfiguration linkerConfig,
+ Vector objectFiles, Vector sysObjectFiles,
+ Hashtable compileTargets, Hashtable assemblerTargets) {
+ //
+ // walk the compile phase targets and
+ // add those sources that have already been
+ // assigned to the linker or
+ // our output files the linker knows how to consume
+ // files the linker knows how to consume
+ //
+ Enumeration compileTargetsEnum = compileTargets.elements();
+ while (compileTargetsEnum.hasMoreElements()) {
+ TargetInfo compileTarget = (TargetInfo) compileTargetsEnum
+ .nextElement();
+ //
+ // output of compile tasks
+ //
+ int bid = linkerConfig.bid(compileTarget.getOutput().toString());
+ if (bid > 0) {
+ objectFiles.addElement(compileTarget.getOutput());
+ }
+ }
+ //
+ // walk the assembler phase targets and
+ // add those sources that have already been
+ // assigned to the linker or
+ // our output files the linker knows how to consume
+ // files the linker knows how to consume
+ //
+ Enumeration assembleTargetsEnum = assemblerTargets.elements();
+ while (assembleTargetsEnum.hasMoreElements()) {
+ TargetInfo assemblerTarget = (TargetInfo) assembleTargetsEnum
+ .nextElement();
+ //
+ // output of assemble tasks
+ //
+ int bid = linkerConfig.bid(assemblerTarget.getOutput().toString());
+ if (bid > 0) {
+ objectFiles.addElement(assemblerTarget.getOutput());
+ }
+ }
+ File[] objectFileArray = new File[objectFiles.size()];
+ objectFiles.copyInto(objectFileArray);
+ File[] sysObjectFileArray = new File[sysObjectFiles.size()];
+ sysObjectFiles.copyInto(sysObjectFileArray);
+ String baseName = _outfile.getName();
+ String fullName = linkerConfig.getOutputFileName(baseName);
+ File outputFile = new File(_outfile.getParent(), fullName);
+ return new TargetInfo(linkerConfig, objectFileArray,
+ sysObjectFileArray, outputFile, linkerConfig
+ .getRebuild());
+ }
+
+ public File getObjdir() {
+ return _objDir;
+ }
+
+ public File getOutfile() {
+ return _outfile;
+ }
+
+ public TargetDef getTargetPlatform() {
+ return null;
+ }
+
+ /**
+ * This method collects a Hashtable, keyed by output file name, of
+ * TargetInfo's for every source file that is specified in the filesets of
+ * the elements. The TargetInfo's contain the appropriate ACPI
+ * configurations for their possible acpi
+ *
+ */
+ private Hashtable getAcpiTargets(LinkerConfiguration linkerConfig,
+ Vector objectFiles) {
+ Hashtable targets = new Hashtable(1000);
+ TargetDef targetPlatform = getTargetPlatform();
+ Vector biddingProcessors = new Vector(_aslcompiler.size());
+ for (int i = 0; i < _aslcompiler.size(); i++) {
+ AslcompilerDef currentAslDef = (AslcompilerDef) _aslcompiler
+ .elementAt(i);
+ if (currentAslDef.isActive()) {
+ ProcessorConfiguration config = currentAslDef
+ .createConfiguration(this, linkType,
+ aslcompilerDef, targetPlatform);
+ //
+ // if the aslcompiler has a fileset
+ // then allow it to add its files to
+ // the set of potential targets
+ //
+ ProcessorConfiguration[] localConfigs = new ProcessorConfiguration[] { config };
+ if (currentAslDef.hasFileSets()) {
+ TargetMatcher matcher = new TargetMatcher(this, _objDir,
+ localConfigs, linkerConfig, objectFiles,
+ targets);
+ currentAslDef.visitFiles(matcher);
+ }
+ biddingProcessors.addElement(config);
+ }
+ }
+ //
+ // add fallback compiler at the end
+ //
+ ProcessorConfiguration config = aslcompilerDef.createConfiguration(
+ this, linkType, null, targetPlatform);
+ biddingProcessors.addElement(config);
+ ProcessorConfiguration[] bidders = new ProcessorConfiguration[biddingProcessors
+ .size()];
+ biddingProcessors.copyInto(bidders);
+ TargetMatcher matcher = new TargetMatcher(this, _objDir, bidders,
+ linkerConfig, objectFiles, targets);
+ aslcompilerDef.visitFiles(matcher);
+ return targets;
+ }
+
+ /**
+ * This method collects a Hashtable, keyed by output file name, of
+ * TargetInfo's for every source file that is specified in the filesets of
+ * the elements. The TargetInfo's contain the appropriate
+ * assembler configurations for their possible assembly
+ *
+ */
+ private Hashtable getAssemblerTargets(LinkerConfiguration linkerConfig,
+ Vector objectFiles) {
+ Hashtable targets = new Hashtable(1000);
+ TargetDef targetPlatform = getTargetPlatform();
+ Vector biddingProcessors = new Vector(_assemblers.size());
+ for (int i = 0; i < _assemblers.size(); i++) {
+ AssemblerDef currentAssemblerDef = (AssemblerDef) _assemblers
+ .elementAt(i);
+ if (currentAssemblerDef.isActive()) {
+ ProcessorConfiguration config = currentAssemblerDef
+ .createConfiguration(this, linkType,
+ assemblerDef, targetPlatform);
+ //
+ // if the assembler has a fileset
+ // then allow it to add its files to
+ // the set of potential targets
+ //
+ ProcessorConfiguration[] localConfigs = new ProcessorConfiguration[] { config };
+ if (currentAssemblerDef.hasFileSets()) {
+ TargetMatcher matcher = new TargetMatcher(this, _objDir,
+ localConfigs, linkerConfig, objectFiles,
+ targets);
+ currentAssemblerDef.visitFiles(matcher);
+ }
+ biddingProcessors.addElement(config);
+ }
+ }
+ //
+ // add fallback assembler at the end
+ //
+ ProcessorConfiguration config = assemblerDef.createConfiguration(this,
+ linkType, null, targetPlatform);
+ biddingProcessors.addElement(config);
+ ProcessorConfiguration[] bidders = new ProcessorConfiguration[biddingProcessors
+ .size()];
+ biddingProcessors.copyInto(bidders);
+ TargetMatcher matcher = new TargetMatcher(this, _objDir, bidders,
+ linkerConfig, objectFiles, targets);
+ assemblerDef.visitFiles(matcher);
+ return targets;
+ }
+
+ /**
+ * This method collects a Hashtable, keyed by output file name, of
+ * TargetInfo's for every source file that is specified in the filesets of
+ * the and nested elements. The TargetInfo's contain the
+ * appropriate compiler configurations for their possible compilation
+ *
+ */
+ private Hashtable getTargets(LinkerConfiguration linkerConfig,
+ Vector objectFiles) {
+ Hashtable targets = new Hashtable(1000);
+ TargetDef targetPlatform = getTargetPlatform();
+ //
+ // find active (specialized) compilers
+ //
+ Vector biddingProcessors = new Vector(_compilers.size());
+ for (int i = 0; i < _compilers.size(); i++) {
+ CompilerDef currentCompilerDef = (CompilerDef) _compilers
+ .elementAt(i);
+ if (currentCompilerDef.isActive()) {
+ ProcessorConfiguration config = currentCompilerDef
+ .createConfiguration(this, linkType,
+ compilerDef, targetPlatform);
+ //
+ // see if this processor had a precompile child element
+ //
+ PrecompileDef precompileDef = currentCompilerDef
+ .getActivePrecompile(compilerDef);
+ ProcessorConfiguration[] localConfigs = new ProcessorConfiguration[] { config };
+ //
+ // if it does then
+ //
+ if (precompileDef != null) {
+ File prototype = precompileDef.getPrototype();
+ //
+ // will throw exceptions if prototype doesn't exist, etc
+ //
+ if (!prototype.exists()) {
+ throw new BuildException("prototype ("
+ + prototype.toString()
+ + ") does not exist.");
+ }
+ if (prototype.isDirectory()) {
+ throw new BuildException("prototype ("
+ + prototype.toString()
+ + ") is a directory.");
+ }
+ String[] exceptFiles = precompileDef.getExceptFiles();
+ //
+ // create a precompile building and precompile using
+ // variants of the configuration
+ // or return null if compiler doesn't support
+ // precompilation
+ CompilerConfiguration[] configs = ((CompilerConfiguration) config)
+ .createPrecompileConfigurations(prototype,
+ exceptFiles);
+ if (configs != null && configs.length == 2) {
+ //
+ // visit the precompiled file to add it into the
+ // targets list (just like any other file if
+ // compiler doesn't support precompilation)
+ TargetMatcher matcher = new TargetMatcher(
+ this,
+ _objDir,
+ new ProcessorConfiguration[] { configs[0] },
+ linkerConfig, objectFiles, targets);
+ matcher.visit(new File(prototype.getParent()),
+ prototype.getName());
+ //
+ // only the configuration that uses the
+ // precompiled header gets added to the bidding list
+ biddingProcessors.addElement(configs[1]);
+ localConfigs = new ProcessorConfiguration[2];
+ localConfigs[0] = configs[1];
+ localConfigs[1] = config;
+ }
+ }
+ //
+ // if the compiler has a fileset
+ // then allow it to add its files
+ // to the set of potential targets
+ if (currentCompilerDef.hasFileSets()) {
+ TargetMatcher matcher = new TargetMatcher(this, _objDir,
+ localConfigs, linkerConfig, objectFiles,
+ targets);
+ currentCompilerDef.visitFiles(matcher);
+ }
+ biddingProcessors.addElement(config);
+ }
+ }
+ //
+ // add fallback compiler at the end
+ //
+ ProcessorConfiguration config = compilerDef.createConfiguration(this,
+ linkType, null, targetPlatform);
+ biddingProcessors.addElement(config);
+ ProcessorConfiguration[] bidders = new ProcessorConfiguration[biddingProcessors
+ .size()];
+ biddingProcessors.copyInto(bidders);
+ //
+ // bid out the 's in the cctask
+ //
+ TargetMatcher matcher = new TargetMatcher(this, _objDir, bidders,
+ linkerConfig, objectFiles, targets);
+ compilerDef.visitFiles(matcher);
+ return targets;
+ }
+
+ /**
+ * Sets the default compiler adapter. Use the "name" attribute when the
+ * compiler is a supported compiler.
+ *
+ * @param classname
+ * fully qualified classname which implements CompilerAdapter
+ */
+ public void setClassname(String classname) {
+ compilerDef.setClassname(classname);
+ linkerDef.setClassname(classname);
+ assemblerDef.setClassname(classname);
+ aslcompilerDef.setClassname(classname);
+ }
+
+ /**
+ * Sets the dataset for OS/390 builds.
+ *
+ * @param dataset
+ * The dataset to set
+ */
+ public void setDataset(String dataset) {
+ this.dataset = dataset;
+ }
+
+ /**
+ * Enables or disables generation of debug info.
+ */
+ public void setDebug(boolean debug) {
+ compilerDef.setDebug(debug);
+ linkerDef.setDebug(debug);
+ assemblerDef.setDebug(debug);
+ aslcompilerDef.setDebug(debug);
+ }
+
+ /**
+ * Deprecated.
+ *
+ * Controls the depth of the dependency evaluation. Used to do a quick check
+ * of changes before a full build.
+ *
+ * Any negative value which will perform full dependency checking. Positive
+ * values will truncate dependency checking. A value of 0 will cause only
+ * those files that changed to be recompiled, a value of 1 which cause files
+ * that changed or that explicitly include a file that changed to be
+ * recompiled.
+ *
+ * Any non-negative value will cause a BuildException to be thrown before
+ * attempting a link or completing the task.
+ *
+ */
+ public void setDependencyDepth(int depth) {
+ dependencyDepth = depth;
+ }
+
+ /**
+ * Enables generation of exception handling code
+ */
+ public void setExceptions(boolean exceptions) {
+ compilerDef.setExceptions(exceptions);
+ }
+
+ /**
+ * Enables run-time type information.
+ */
+ public void setRtti(boolean rtti) {
+ compilerDef.setRtti(rtti);
+ }
+
+ // public LinkType getLinkType() {
+ // return linkType;
+ // }
+ /**
+ * Enables or disables incremental linking.
+ *
+ * @param incremental
+ * new state
+ */
+ public void setIncremental(boolean incremental) {
+ linkerDef.setIncremental(incremental);
+ }
+
+ /**
+ * Set use of libtool.
+ *
+ * If set to true, the "libtool " will be prepended to the command line for
+ * compatible processors
+ *
+ * @param libtool
+ * If true, use libtool.
+ */
+ public void setLibtool(boolean libtool) {
+ compilerDef.setLibtool(libtool);
+ linkerDef.setLibtool(libtool);
+ assemblerDef.setLibtool(libtool);
+ aslcompilerDef.setLibtool(libtool);
+ }
+
+ /**
+ * Sets the output file type. Supported values "executable", "shared", and
+ * "static". Deprecated, specify outtype instead.
+ *
+ * @deprecated
+ */
+ public void setLink(OutputTypeEnum outputType) {
+ linkType.setOutputType(outputType);
+ }
+
+ /**
+ * Enables or disables generation of multithreaded code
+ *
+ * @param multi
+ * If true, generated code may be multithreaded.
+ */
+ public void setMultithreaded(boolean multi) {
+ compilerDef.setMultithreaded(multi);
+ }
+
+ //
+ // keep near duplicate comment at CompilerDef.setName in sync
+ //
+ /**
+ * Sets type of the default compiler and linker.
+ *
+ *
Supported compilers
+ *
+ *
gcc (default)
+ *
GCC C++ compiler
+ *
+ *
+ *
g++
+ *
GCC C++ compiler
+ *
+ *
+ *
c++
+ *
GCC C++ compiler
+ *
+ *
+ *
g77
+ *
GNU FORTRAN compiler
+ *
+ *
+ *
msvc
+ *
Microsoft Visual C++
+ *
+ *
+ *
bcc
+ *
Borland C++ Compiler
+ *
+ *
+ *
msrc
+ *
Microsoft Resource Compiler
+ *
+ *
+ *
brc
+ *
Borland Resource Compiler
+ *
+ *
+ *
df
+ *
Compaq Visual Fortran Compiler
+ *
+ *
+ *
midl
+ *
Microsoft MIDL Compiler
+ *
+ *
+ *
icl
+ *
Intel C++ compiler for Windows (IA-32)
+ *
+ *
+ *
ecl
+ *
Intel C++ compiler for Windows (IA-64)
+ *
+ *
+ *
icc
+ *
Intel C++ compiler for Linux (IA-32)
+ *
+ *
+ *
ecc
+ *
Intel C++ compiler for Linux (IA-64)
+ *
+ *
+ *
CC
+ *
Sun ONE C++ compiler
+ *
+ *
+ *
aCC
+ *
HP aC++ C++ Compiler
+ *
+ *
+ *
os390
+ *
OS390 C Compiler
+ *
+ *
+ *
os400
+ *
Icc Compiler
+ *
+ *
+ *
sunc89
+ *
Sun C89 C Compiler
+ *
+ *
+ *
xlC
+ *
VisualAge C Compiler
+ *
+ *
+ *
+ */
+ public void setName(CompilerEnum name) {
+ compilerDef.setName(name);
+ Processor compiler = compilerDef.getProcessor();
+ Linker linker = compiler.getLinker(linkType);
+ linkerDef.setProcessor(linker);
+ }
+
+ /**
+ * Do not propagate old environment when new environment variables are
+ * specified.
+ */
+ public void setNewenvironment(boolean newenv) {
+ compilerDef.setNewenvironment(newenv);
+ linkerDef.setNewenvironment(newenv);
+ assemblerDef.setNewenvironment(newenv);
+ aslcompilerDef.setNewenvironment(newenv);
+ }
+
+ /**
+ * Sets the destination directory for object files.
+ *
+ * Generally this should be a property expression that evaluates to distinct
+ * debug and release object file directories.
+ *
+ * @param dir
+ * object directory
+ */
+ public void setObjdir(File dir) {
+ if (dir == null) {
+ throw new NullPointerException("dir");
+ }
+ _objDir = dir;
+ }
+
+ /**
+ * Sets the output file name. If not specified, the task will only compile
+ * files and not attempt to link. If an extension is not specified, the task
+ * may use a system appropriate extension and prefix, for example,
+ * outfile="example" may result in "libexample.so" being created.
+ *
+ * @param outfile
+ * output file name
+ */
+ public void setOutfile(File outfile) {
+ //
+ // if file name was empty, skip link step
+ //
+ if (outfile == null || outfile.toString().length() > 0) {
+ _outfile = outfile;
+ }
+ }
+
+ /**
+ * Specifies the name of a property to set with the physical filename that
+ * is produced by the linker
+ */
+ public void setOutputFileProperty(String outputFileProperty) {
+ this.outputFileProperty = outputFileProperty;
+ }
+
+ /**
+ * Sets the output file type. Supported values "executable", "shared", and
+ * "static".
+ */
+ public void setOuttype(OutputTypeEnum outputType) {
+ linkType.setOutputType(outputType);
+ }
+
+ /**
+ * Sets the project.
+ */
+ public void setProject(Project project) {
+ super.setProject(project);
+ compilerDef.setProject(project);
+ linkerDef.setProject(project);
+ assemblerDef.setProject(project);
+ aslcompilerDef.setProject(project);
+ }
+
+ /**
+ * If set to true, all files will be rebuilt.
+ *
+ * @paran rebuildAll If true, all files will be rebuilt. If false, up to
+ * date files will not be rebuilt.
+ */
+ public void setRebuild(boolean rebuildAll) {
+ compilerDef.setRebuild(rebuildAll);
+ linkerDef.setRebuild(rebuildAll);
+ assemblerDef.setRebuild(rebuildAll);
+ aslcompilerDef.setRebuild(rebuildAll);
+ }
+
+ /**
+ * If set to true, compilation errors will not stop the task until all files
+ * have been attempted.
+ *
+ * @param relentless
+ * If true, don't stop on the first compilation error
+ *
+ */
+ public void setRelentless(boolean relentless) {
+ this.relentless = relentless;
+ }
+
+ /**
+ * Sets the type of runtime library, possible values "dynamic", "static".
+ */
+ public void setRuntime(RuntimeType rtlType) {
+ linkType.setStaticRuntime((rtlType.getIndex() == 1));
+ }
+
+ /**
+ * Sets the nature of the subsystem under which that the program will
+ * execute.
+ *
+ *
Supported subsystems
+ *
+ *
gui
+ *
Graphical User Interface
+ *
+ *
+ *
console
+ *
Command Line Console
+ *
+ *
+ *
other
+ *
Other
+ *
+ *
+ *
+ * @param subsystem
+ * subsystem
+ * @throws NullPointerException
+ * if subsystem is null
+ */
+ public void setSubsystem(SubsystemEnum subsystem) {
+ if (subsystem == null) {
+ throw new NullPointerException("subsystem");
+ }
+ linkType.setSubsystem(subsystem);
+ }
+
+ /**
+ * Enumerated attribute with the values "none", "severe", "default",
+ * "production", "diagnostic", and "failtask".
+ */
+ public void setWarnings(CompilerDef.WarningLevel level) {
+ compilerDef.setWarnings(level);
+ }
+
+ /**
+ * Indicates whether the build will continue even if there are compilation
+ * errors; defaults to true.
+ *
+ * @param fail
+ * if true halt the build on failure
+ */
+ public void setFailonerror(boolean fail) {
+ failOnError = fail;
+ }
+
+ /**
+ * Gets the failonerror flag.
+ *
+ * @return the failonerror flag
+ */
+ public boolean getFailonerror() {
+ return failOnError;
+ }
+
+ /**
+ * Adds descriptive version information to be included in the generated
+ * file. The first active version info block will be used. (Non-functional
+ * prototype)
+ */
+ public void addConfiguredVersioninfo(VersionInfo info) {
+ linkerDef.addConfiguredVersioninfo(info);
+ }
+
+ /**
+ * Adds a target definition or reference (Non-functional prototype).
+ *
+ * @param target
+ * target
+ * @throws NullPointerException
+ * if compiler is null
+ */
+ public void addConfiguredTarget(TargetDef target) {
+ if (target == null) {
+ throw new NullPointerException("target");
+ }
+ target.setProject(getProject());
+ targetPlatforms.addElement(target);
+ }
+
+ /**
+ * Adds a distributer definition or reference (Non-functional prototype).
+ *
+ * @param distributer
+ * distributer
+ * @throws NullPointerException
+ * if compiler is null
+ */
+ public void addConfiguredDistributer(DistributerDef distributer) {
+ if (distributer == null) {
+ throw new NullPointerException("distributer");
+ }
+ distributer.setProject(getProject());
+ distributers.addElement(distributer);
+ }
+
+ /**
+ * Sets optimization.
+ * @param optimization
+ */
+ public void setOptimize(OptimizationEnum optimization) {
+ compilerDef.setOptimize(optimization);
+ }
+
+ public boolean isAssembler() {
+ return assembler;
+ }
+
+ public void setAssembler(boolean assembler) {
+ this.assembler = assembler;
+ }
+
+ public boolean isAslcompiler() {
+ return aslcompiler;
+ }
+
+ public void setAslcompiler(boolean aslcompiler) {
+ this.aslcompiler = aslcompiler;
+ }
+
+ public boolean isUserdefine() {
+ return userdefine;
+ }
+
+ public void setUserdefine(boolean userdefine) {
+ this.userdefine = userdefine;
+ }
+
+ public String getArch() {
+ return arch;
+ }
+
+ public void setArch(String arch) {
+ this.arch = arch;
+ }
+
+ public String getOs() {
+ return os;
+ }
+
+ public void setOs(String os) {
+ this.os = os;
+ }
+
+ public String getVendor() {
+ return vendor;
+ }
+
+ public void setVendor(String vendor) {
+ this.vendor = vendor;
+ }
+
+
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/CCTaskProgressMonitor.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/CCTaskProgressMonitor.java
new file mode 100644
index 0000000000..78192a5ba7
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/CCTaskProgressMonitor.java
@@ -0,0 +1,56 @@
+/*
+ *
+ * Copyright 2001-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks;
+import java.io.IOException;
+
+import net.sf.antcontrib.cpptasks.compiler.ProcessorConfiguration;
+import net.sf.antcontrib.cpptasks.compiler.ProgressMonitor;
+public class CCTaskProgressMonitor implements ProgressMonitor {
+ private ProcessorConfiguration config;
+ private TargetHistoryTable history;
+ private long lastCommit = -1;
+ public CCTaskProgressMonitor(TargetHistoryTable history) {
+ this.history = history;
+ }
+ public void finish(ProcessorConfiguration config, boolean normal) {
+ long current = System.currentTimeMillis();
+ if ((current - lastCommit) > 120000) {
+ try {
+ history.commit();
+ lastCommit = System.currentTimeMillis();
+ } catch (IOException ex) {
+ }
+ }
+ }
+ public void progress(String[] sources) {
+ history.update(config, sources);
+ long current = System.currentTimeMillis();
+ if ((current - lastCommit) > 120000) {
+ try {
+ history.commit();
+ lastCommit = current;
+ } catch (IOException ex) {
+ }
+ }
+ }
+ public void start(ProcessorConfiguration config) {
+ if (lastCommit < 0) {
+ lastCommit = System.currentTimeMillis();
+ }
+ this.config = config;
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/CPUEnum.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/CPUEnum.java
new file mode 100644
index 0000000000..ba73902361
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/CPUEnum.java
@@ -0,0 +1,71 @@
+/*
+ *
+ * Copyright 2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks;
+
+import org.apache.tools.ant.types.EnumeratedAttribute;
+
+/**
+ * Enumeration of cpu types.
+ *
+ * @author Curt Arnold
+ *
+ */
+public final class CPUEnum
+ extends EnumeratedAttribute {
+
+ /**
+ * Constructor.
+ *
+ * Set by default to "pentium3"
+ *
+ * @see java.lang.Object#Object()
+ */
+ public CPUEnum() {
+ setValue("pentium3");
+ }
+
+ /**
+ * Gets list of acceptable values.
+ *
+ * @see org.apache.tools.ant.types.EnumeratedAttribute#getValues()
+ */
+ public String[] getValues() {
+ return new String[] {
+ "i386",
+ "i486",
+ "i586",
+ "i686",
+ "pentium",
+ "pentium-mmx",
+ "pentiumpro",
+ "pentium2",
+ "pentium3",
+ "pentium4",
+ "k6",
+ "k6-2",
+ "k6-3",
+ "athlon",
+ "athlon-tbird",
+ "athlon-4",
+ "athlon-xp",
+ "athlon-mp",
+ "winchip-c6",
+ "winchip2",
+ "c3" };
+ }
+
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/CUtil.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/CUtil.java
new file mode 100644
index 0000000000..074e8b42f8
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/CUtil.java
@@ -0,0 +1,461 @@
+/*
+ *
+ * Copyright 2001-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks;
+import java.io.File;
+import java.io.IOException;
+import java.util.Enumeration;
+import java.util.Hashtable;
+import java.util.StringTokenizer;
+import java.util.Vector;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.taskdefs.Execute;
+import org.apache.tools.ant.taskdefs.LogStreamHandler;
+import org.apache.tools.ant.types.Commandline;
+import org.apache.tools.ant.types.Environment;
+/**
+ * Some utilities used by the CC and Link tasks.
+ *
+ * @author Adam Murdoch
+ */
+public class CUtil {
+ /**
+ * A class that splits a white-space, comma-separated list into a String
+ * array. Used for task attributes.
+ */
+ public static final class StringArrayBuilder {
+ private String[] _value;
+ public StringArrayBuilder(String value) {
+ // Split the defines up
+ StringTokenizer tokens = new StringTokenizer(value, ", ");
+ Vector vallist = new Vector();
+ while (tokens.hasMoreTokens()) {
+ String val = tokens.nextToken().trim();
+ if (val.length() == 0) {
+ continue;
+ }
+ vallist.addElement(val);
+ }
+ _value = new String[vallist.size()];
+ vallist.copyInto(_value);
+ }
+ public String[] getValue() {
+ return _value;
+ }
+ }
+ /**
+ * Adds the elements of the array to the given vector
+ */
+ public static void addAll(Vector dest, Object[] src) {
+ if (src == null) {
+ return;
+ }
+ for (int i = 0; i < src.length; i++) {
+ dest.addElement(src[i]);
+ }
+ }
+ /**
+ * Checks a array of names for non existent or non directory entries and
+ * nulls them out.
+ *
+ * @return Count of non-null elements
+ */
+ public static int checkDirectoryArray(String[] names) {
+ int count = 0;
+ for (int i = 0; i < names.length; i++) {
+ if (names[i] != null) {
+ File dir = new File(names[i]);
+ if (dir.exists() && dir.isDirectory()) {
+ count++;
+ } else {
+ names[i] = null;
+ }
+ }
+ }
+ return count;
+ }
+ /**
+ * Extracts the basename of a file, removing the extension, if present
+ */
+ public static String getBasename(File file) {
+ String path = file.getPath();
+ // Remove the extension
+ String basename = file.getName();
+ int pos = basename.lastIndexOf('.');
+ if (pos != -1) {
+ basename = basename.substring(0, pos);
+ }
+ return basename;
+ }
+ /**
+ * Gets the parent directory for the executable file name using the current
+ * directory and system executable path
+ *
+ * @param exeName
+ * Name of executable such as "cl.exe"
+ * @return parent directory or null if not located
+ */
+ public static File getExecutableLocation(String exeName) {
+ //
+ // must add current working directory to the
+ // from of the path from the "path" environment variable
+ File currentDir = new File(System.getProperty("user.dir"));
+ if (new File(currentDir, exeName).exists()) {
+ return currentDir;
+ }
+ File[] envPath = CUtil.getPathFromEnvironment("PATH",
+ File.pathSeparator);
+ for (int i = 0; i < envPath.length; i++) {
+ if (new File(envPath[i], exeName).exists()) {
+ return envPath[i];
+ }
+ }
+ return null;
+ }
+ /**
+ * Extracts the parent of a file
+ */
+ public static String getParentPath(String path) {
+ int pos = path.lastIndexOf(File.separator);
+ if (pos <= 0) {
+ return null;
+ }
+ return path.substring(0, pos);
+ }
+ /**
+ * Returns an array of File for each existing directory in the specified
+ * environment variable
+ *
+ * @param envVariable
+ * environment variable name such as "LIB" or "INCLUDE"
+ * @param delim
+ * delimitor used to separate parts of the path, typically ";"
+ * or ":"
+ * @return array of File's for each part that is an existing directory
+ */
+ public static File[] getPathFromEnvironment(String envVariable, String delim) {
+ // OS/4000 does not support the env command.
+ if (System.getProperty("os.name").equals("OS/400"))
+ return new File[]{};
+ Vector osEnv = Execute.getProcEnvironment();
+ String match = envVariable.concat("=");
+ for (Enumeration e = osEnv.elements(); e.hasMoreElements();) {
+ String entry = ((String) e.nextElement()).trim();
+ if (entry.length() > match.length()) {
+ String entryFrag = entry.substring(0, match.length());
+ if (entryFrag.equalsIgnoreCase(match)) {
+ String path = entry.substring(match.length());
+ return parsePath(path, delim);
+ }
+ }
+ }
+ File[] noPath = new File[0];
+ return noPath;
+ }
+ /**
+ * Returns a relative path for the targetFile relative to the base
+ * directory.
+ *
+ * @param canonicalBase
+ * base directory as returned by File.getCanonicalPath()
+ * @param targetFile
+ * target file
+ * @return relative path of target file. Returns targetFile if there were
+ * no commonalities between the base and the target
+ *
+ * @author Curt Arnold
+ */
+ public static String getRelativePath(String base, File targetFile) {
+ try {
+ //
+ // remove trailing file separator
+ //
+ String canonicalBase = base;
+ if (base.charAt(base.length() - 1) == File.separatorChar) {
+ canonicalBase = base.substring(0, base.length() - 1);
+ }
+ //
+ // get canonical name of target and remove trailing separator
+ //
+ String canonicalTarget;
+ if (System.getProperty("os.name").equals("OS/400"))
+ canonicalTarget = targetFile.getPath();
+ else
+ canonicalTarget = targetFile.getCanonicalPath();
+ if (canonicalTarget.charAt(canonicalTarget.length() - 1) == File.separatorChar) {
+ canonicalTarget = canonicalTarget.substring(0, canonicalTarget
+ .length() - 1);
+ }
+ if (canonicalTarget.equals(canonicalBase)) {
+ return ".";
+ }
+ //
+ // see if the prefixes are the same
+ //
+ if (canonicalBase.substring(0, 2).equals("\\\\")) {
+ //
+ // UNC file name, if target file doesn't also start with same
+ // server name, don't go there
+ int endPrefix = canonicalBase.indexOf('\\', 2);
+ String prefix1 = canonicalBase.substring(0, endPrefix);
+ String prefix2 = canonicalTarget.substring(0, endPrefix);
+ if (!prefix1.equals(prefix2)) {
+ return canonicalTarget;
+ }
+ } else {
+ if (canonicalBase.substring(1, 3).equals(":\\")) {
+ int endPrefix = 2;
+ String prefix1 = canonicalBase.substring(0, endPrefix);
+ String prefix2 = canonicalTarget.substring(0, endPrefix);
+ if (!prefix1.equals(prefix2)) {
+ return canonicalTarget;
+ }
+ } else {
+ if (canonicalBase.charAt(0) == '/') {
+ if (canonicalTarget.charAt(0) != '/') {
+ return canonicalTarget;
+ }
+ }
+ }
+ }
+ char separator = File.separatorChar;
+ int lastSeparator = -1;
+ int minLength = canonicalBase.length();
+ if (canonicalTarget.length() < minLength) {
+ minLength = canonicalTarget.length();
+ }
+ int firstDifference = minLength + 1;
+ //
+ // walk to the shorter of the two paths
+ // finding the last separator they have in common
+ for (int i = 0; i < minLength; i++) {
+ if (canonicalTarget.charAt(i) == canonicalBase.charAt(i)) {
+ if (canonicalTarget.charAt(i) == separator) {
+ lastSeparator = i;
+ }
+ } else {
+ firstDifference = lastSeparator + 1;
+ break;
+ }
+ }
+ StringBuffer relativePath = new StringBuffer(50);
+ //
+ // walk from the first difference to the end of the base
+ // adding "../" for each separator encountered
+ //
+ if (canonicalBase.length() > firstDifference) {
+ relativePath.append("..");
+ for (int i = firstDifference; i < canonicalBase.length(); i++) {
+ if (canonicalBase.charAt(i) == separator) {
+ relativePath.append(separator);
+ relativePath.append("..");
+ }
+ }
+ }
+ if (canonicalTarget.length() > firstDifference) {
+ //
+ // append the rest of the target
+ //
+ //
+ if (relativePath.length() > 0) {
+ relativePath.append(separator);
+ }
+ relativePath.append(canonicalTarget.substring(firstDifference));
+ }
+ return relativePath.toString();
+ } catch (IOException ex) {
+ }
+ return targetFile.toString();
+ }
+ public static boolean isActive(Project p, String ifCond, String unlessCond)
+ throws BuildException {
+ if (ifCond != null) {
+ String ifValue = p.getProperty(ifCond);
+ if (ifValue == null) {
+ return false;
+ } else {
+ if (ifValue.equals("false") || ifValue.equals("no")) {
+ throw new BuildException("if condition \"" + ifCond
+ + "\" has suspicious value \"" + ifValue);
+ }
+ }
+ }
+ if (unlessCond != null) {
+ String unlessValue = p.getProperty(unlessCond);
+ if (unlessValue != null) {
+ if (unlessValue.equals("false") || unlessValue.equals("no")) {
+ throw new BuildException("unless condition \"" + unlessCond
+ + "\" has suspicious value \"" + unlessValue);
+ }
+ return false;
+ }
+ }
+ return true;
+ }
+ /**
+ * Parse a string containing directories into an File[]
+ *
+ * @param path
+ * path string, for example ".;c:\something\include"
+ * @param delim
+ * delimiter, typically ; or :
+ */
+ public static File[] parsePath(String path, String delim) {
+ Vector libpaths = new Vector();
+ int delimPos = 0;
+ for (int startPos = 0; startPos < path.length(); startPos = delimPos
+ + delim.length()) {
+ delimPos = path.indexOf(delim, startPos);
+ if (delimPos < 0) {
+ delimPos = path.length();
+ }
+ //
+ // don't add an entry for zero-length paths
+ //
+ if (delimPos > startPos) {
+ String dirName = path.substring(startPos, delimPos);
+ File dir = new File(dirName);
+ if (dir.exists() && dir.isDirectory()) {
+ libpaths.addElement(dir);
+ }
+ }
+ }
+ File[] paths = new File[libpaths.size()];
+ libpaths.copyInto(paths);
+ return paths;
+ }
+ /**
+ * This method is exposed so test classes can overload and test the
+ * arguments without actually spawning the compiler
+ */
+ public static int runCommand(CCTask task, File workingDir,
+ String[] cmdline, boolean newEnvironment, Environment env)
+ throws BuildException {
+ try {
+ task.log(Commandline.toString(cmdline), Project.MSG_VERBOSE);
+ Execute exe = new Execute(new LogStreamHandler(task,
+ Project.MSG_INFO, Project.MSG_ERR));
+ if (System.getProperty("os.name").equals("OS/390"))
+ exe.setVMLauncher(false);
+ exe.setAntRun(task.getProject());
+ exe.setCommandline(cmdline);
+ exe.setWorkingDirectory(workingDir);
+ if (env != null) {
+ String[] environment = env.getVariables();
+ if (environment != null) {
+ for (int i = 0; i < environment.length; i++) {
+ task.log("Setting environment variable: "
+ + environment[i], Project.MSG_VERBOSE);
+ }
+ }
+ exe.setEnvironment(environment);
+ }
+ exe.setNewenvironment(newEnvironment);
+ return exe.execute();
+ } catch (java.io.IOException exc) {
+ throw new BuildException("Could not launch " + cmdline[0] + ": "
+ + exc, task.getLocation());
+ }
+ }
+ /**
+ * Compares the contents of 2 arrays for equaliy.
+ */
+ public static boolean sameList(Object[] a, Object[] b) {
+ if (a == null || b == null || a.length != b.length) {
+ return false;
+ }
+ for (int i = 0; i < a.length; i++) {
+ if (!a[i].equals(b[i])) {
+ return false;
+ }
+ }
+ return true;
+ }
+ /**
+ * Compares the contents of an array and a Vector for equality.
+ */
+ public static boolean sameList(Vector v, Object[] a) {
+ if (v == null || a == null || v.size() != a.length) {
+ return false;
+ }
+ for (int i = 0; i < a.length; i++) {
+ Object o = a[i];
+ if (!o.equals(v.elementAt(i))) {
+ return false;
+ }
+ }
+ return true;
+ }
+ /**
+ * Compares the contents of an array and a Vector for set equality. Assumes
+ * input array and vector are sets (i.e. no duplicate entries)
+ */
+ public static boolean sameSet(Object[] a, Vector b) {
+ if (a == null || b == null || a.length != b.size()) {
+ return false;
+ }
+ if (a.length == 0) {
+ return true;
+ }
+ // Convert the array into a set
+ Hashtable t = new Hashtable();
+ for (int i = 0; i < a.length; i++) {
+ t.put(a[i], a[i]);
+ }
+ for (int i = 0; i < b.size(); i++) {
+ Object o = b.elementAt(i);
+ if (t.remove(o) == null) {
+ return false;
+ }
+ }
+ return (t.size() == 0);
+ }
+ /**
+ * Converts a vector to a string array.
+ */
+ public static String[] toArray(Vector src) {
+ String[] retval = new String[src.size()];
+ src.copyInto(retval);
+ return retval;
+ }
+ /**
+ * Replaces any embedded quotes in the string so that the value can be
+ * placed in an attribute in an XML file
+ *
+ * @param attrValue
+ * value to be expressed
+ * @return equivalent attribute literal
+ *
+ */
+ public static String xmlAttribEncode(String attrValue) {
+ int quotePos = attrValue.indexOf('\"');
+ if (quotePos < 0) {
+ return attrValue;
+ }
+ int startPos = 0;
+ StringBuffer buf = new StringBuffer(attrValue.length() + 20);
+ while (quotePos >= 0) {
+ buf.append(attrValue.substring(startPos, quotePos));
+ buf.append(""");
+ startPos = quotePos + 1;
+ quotePos = attrValue.indexOf('\"', startPos);
+ }
+ buf.append(attrValue.substring(startPos));
+ return buf.toString();
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/CompilerDef.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/CompilerDef.java
new file mode 100644
index 0000000000..0a92a51512
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/CompilerDef.java
@@ -0,0 +1,556 @@
+/*
+ *
+ * Copyright 2001-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.util.Enumeration;
+import java.util.Vector;
+
+import net.sf.antcontrib.cpptasks.compiler.CommandLineCompiler;
+import net.sf.antcontrib.cpptasks.compiler.Compiler;
+import net.sf.antcontrib.cpptasks.compiler.Processor;
+import net.sf.antcontrib.cpptasks.gcc.GccCCompiler;
+import net.sf.antcontrib.cpptasks.types.CompilerArgument;
+import net.sf.antcontrib.cpptasks.types.ConditionalPath;
+import net.sf.antcontrib.cpptasks.types.DefineSet;
+import net.sf.antcontrib.cpptasks.types.IncludePath;
+import net.sf.antcontrib.cpptasks.types.SystemIncludePath;
+import net.sf.antcontrib.cpptasks.types.UndefineArgument;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.types.EnumeratedAttribute;
+import org.apache.tools.ant.*;
+/**
+ * A compiler definition. compiler elements may be placed either as children of
+ * a cc element or the project element. A compiler element with an id attribute
+ * may be referenced from compiler elements with refid or extends attributes.
+ *
+ * @author Adam Murdoch
+ */
+public final class CompilerDef extends ProcessorDef {
+ /**
+ * Enumerated attribute with the values "none", "severe", "default",
+ * "production", "diagnostic", and "failtask".
+ */
+ public static class WarningLevel extends EnumeratedAttribute {
+ public String[] getValues() {
+ return new String[]{"none", "severe", "default", "production",
+ "diagnostic", "aserror"};
+ }
+ }
+ /** The source file sets. */
+ private final Vector defineSets = new Vector();
+ private Boolean exceptions;
+ private Boolean rtti;
+ private final Vector includePaths = new Vector();
+ private Boolean multithreaded;
+ private final Vector precompileDefs = new Vector();
+ private final Vector sysIncludePaths = new Vector();
+ private OptimizationEnum optimization;
+ private int warnings = -1;
+ private Boolean defaultflag = new Boolean(true);
+ public CompilerDef() {
+ }
+ /**
+ * Adds a compiler command-line arg.
+ */
+ public void addConfiguredCompilerArg(CompilerArgument arg) {
+ if (isReference()) {
+ throw noChildrenAllowed();
+ }
+ addConfiguredProcessorArg(arg);
+ }
+ /**
+ * Adds a compiler command-line arg.
+ */
+ public void addConfiguredCompilerParam(CompilerParam param) {
+ if (isReference()) {
+ throw noChildrenAllowed();
+ }
+ addConfiguredProcessorParam(param);
+ }
+ /**
+ * Adds a defineset.
+ */
+ public void addConfiguredDefineset(DefineSet defs) {
+ if (defs == null) {
+ throw new NullPointerException("defs");
+ }
+ if (isReference()) {
+ throw noChildrenAllowed();
+ }
+ defineSets.addElement(defs);
+ }
+ /**
+ * Creates an include path.
+ */
+ public IncludePath createIncludePath() {
+ Project p = getProject();
+ if (p == null) {
+ throw new java.lang.IllegalStateException("project must be set");
+ }
+ if (isReference()) {
+ throw noChildrenAllowed();
+ }
+ IncludePath path = new IncludePath(p);
+ includePaths.addElement(path);
+ return path;
+ }
+ /**
+ * Add a or if specify the file
+ * attribute
+ *
+ * @throws BuildException
+ * if the specify file not exist
+ */
+ protected void loadFile(Vector activePath,File file) throws BuildException {
+ FileReader fileReader;
+ BufferedReader in;
+ String str;
+ if (! file.exists()){
+ throw new BuildException("The file " + file + " is not existed");
+ }
+ try {
+ fileReader = new FileReader(file);
+ in = new BufferedReader(fileReader);
+ while ( (str = in.readLine()) != null ){
+ if(str.trim() == ""){
+ continue ;
+ }
+ str = getProject().replaceProperties(str);
+ activePath.addElement(str.trim());
+ }
+ }
+ catch(Exception e){
+ throw new BuildException(e.getMessage());
+ }
+ }
+
+ /**
+ * Specifies precompilation prototype file and exclusions.
+ *
+ */
+ public PrecompileDef createPrecompile() throws BuildException {
+ Project p = getProject();
+ if (isReference()) {
+ throw noChildrenAllowed();
+ }
+ PrecompileDef precomp = new PrecompileDef();
+ precomp.setProject(p);
+ precompileDefs.addElement(precomp);
+ return precomp;
+ }
+ /**
+ * Creates a system include path. Locations and timestamps of files located
+ * using the system include paths are not used in dependency analysis.
+ *
+ *
+ * Standard include locations should not be specified. The compiler
+ * adapters should recognized the settings from the appropriate environment
+ * variables or configuration files.
+ */
+ public SystemIncludePath createSysIncludePath() {
+ Project p = getProject();
+ if (p == null) {
+ throw new java.lang.IllegalStateException("project must be set");
+ }
+ if (isReference()) {
+ throw noChildrenAllowed();
+ }
+ SystemIncludePath path = new SystemIncludePath(p);
+ sysIncludePaths.addElement(path);
+ return path;
+ }
+ public void execute() throws org.apache.tools.ant.BuildException {
+ throw new org.apache.tools.ant.BuildException(
+ "Not an actual task, but looks like one for documentation purposes");
+ }
+ public UndefineArgument[] getActiveDefines() {
+ Project p = getProject();
+ if (p == null) {
+ throw new java.lang.IllegalStateException(
+ "project must be set before this call");
+ }
+ if (isReference()) {
+ return ((CompilerDef) getCheckedRef(CompilerDef.class,
+ "CompilerDef")).getActiveDefines();
+ }
+ Vector actives = new Vector();
+ for (int i = 0; i < defineSets.size(); i++) {
+ DefineSet currentSet = (DefineSet) defineSets.elementAt(i);
+ UndefineArgument[] defines = currentSet.getDefines();
+ for (int j = 0; j < defines.length; j++) {
+ if (defines[j].isActive(p)) {
+ actives.addElement(defines[j]);
+ }
+ }
+ }
+ UndefineArgument[] retval = new UndefineArgument[actives.size()];
+ actives.copyInto(retval);
+ return retval;
+ }
+ /**
+ * Returns the compiler-specific include path.
+ */
+ public String[] getActiveIncludePaths() {
+ if (isReference()) {
+ return ((CompilerDef) getCheckedRef(CompilerDef.class,
+ "CompilerDef")).getActiveIncludePaths();
+ }
+ return getActivePaths(includePaths);
+ }
+ private String[] getActivePaths(Vector paths) {
+ Project p = getProject();
+ if (p == null) {
+ throw new java.lang.IllegalStateException("project not set");
+ }
+ Vector activePaths = new Vector(paths.size());
+ for (int i = 0; i < paths.size(); i++) {
+ ConditionalPath path = (ConditionalPath) paths.elementAt(i);
+ if (path.isActive(p)) {
+ if (path.getFile() == null) {
+ String[] pathEntries = path.list();
+ for (int j = 0; j < pathEntries.length; j++) {
+ activePaths.addElement(pathEntries[j]);
+ }
+ }
+ else {
+ loadFile(activePaths, path.getFile());
+ }
+ }
+ }
+ String[] pathNames = new String[activePaths.size()];
+ activePaths.copyInto(pathNames);
+ return pathNames;
+ }
+ public PrecompileDef getActivePrecompile(CompilerDef ccElement) {
+ if (isReference()) {
+ return ((CompilerDef) getCheckedRef(CompilerDef.class,
+ "CompilerDef")).getActivePrecompile(ccElement);
+ }
+ PrecompileDef current = null;
+ Enumeration enumPrecompilerDef = precompileDefs.elements();
+ while (enumPrecompilerDef.hasMoreElements()) {
+ current = (PrecompileDef) enumPrecompilerDef.nextElement();
+ if (current.isActive()) {
+ return current;
+ }
+ }
+ CompilerDef extendedDef = (CompilerDef) getExtends();
+ if (extendedDef != null) {
+ current = extendedDef.getActivePrecompile(null);
+ if (current != null) {
+ return current;
+ }
+ }
+ if (ccElement != null && getInherit()) {
+ return ccElement.getActivePrecompile(null);
+ }
+ return null;
+ }
+ public String[] getActiveSysIncludePaths() {
+ if (isReference()) {
+ return ((CompilerDef) getCheckedRef(CompilerDef.class,
+ "CompilerDef")).getActiveSysIncludePaths();
+ }
+ return getActivePaths(sysIncludePaths);
+ }
+ public final boolean getExceptions(CompilerDef[] defaultProviders, int index) {
+ if (isReference()) {
+ return ((CompilerDef) getCheckedRef(CompilerDef.class,
+ "CompilerDef")).getExceptions(defaultProviders, index);
+ }
+ if (exceptions != null) {
+ return exceptions.booleanValue();
+ } else {
+ if (defaultProviders != null && index < defaultProviders.length) {
+ return defaultProviders[index].getExceptions(defaultProviders,
+ index + 1);
+ }
+ }
+ return false;
+ }
+ public final Boolean getRtti(CompilerDef[] defaultProviders, int index) {
+ if (isReference()) {
+ return ((CompilerDef) getCheckedRef(CompilerDef.class,
+ "CompilerDef")).getRtti(defaultProviders, index);
+ }
+ if (rtti != null) {
+ return rtti;
+ } else {
+ if (defaultProviders != null && index < defaultProviders.length) {
+ return defaultProviders[index].getRtti(defaultProviders,
+ index + 1);
+ }
+ }
+ return null;
+ }
+ public final Boolean getDefaultflag(CompilerDef[] defaultProviders, int index) {
+ if (isReference()) {
+ return ((CompilerDef) getCheckedRef(CompilerDef.class,
+ "CompilerDef")).getDefaultflag(defaultProviders, index);
+ }
+ return defaultflag;
+ }
+ public final OptimizationEnum getOptimization(CompilerDef[] defaultProviders, int index) {
+ if (isReference()) {
+ return ((CompilerDef) getCheckedRef(CompilerDef.class,
+ "CompilerDef")).getOptimization(defaultProviders, index);
+ }
+ if (optimization != null) {
+ return optimization;
+ } else {
+ if (defaultProviders != null && index < defaultProviders.length) {
+ return defaultProviders[index].getOptimization(defaultProviders,
+ index + 1);
+ }
+ }
+ return null;
+ }
+
+ public boolean getMultithreaded(CompilerDef[] defaultProviders, int index) {
+ if (isReference()) {
+ return ((CompilerDef) getCheckedRef(CompilerDef.class,
+ "CompilerDef")).getMultithreaded(defaultProviders, index);
+ }
+ if (multithreaded != null) {
+ return multithreaded.booleanValue();
+ } else {
+ if (defaultProviders != null && index < defaultProviders.length) {
+ return defaultProviders[index].getMultithreaded(
+ defaultProviders, index + 1);
+ }
+ }
+ return true;
+ }
+ public Processor getProcessor() {
+ Processor processor = super.getProcessor();
+ if (processor == null) {
+ processor = GccCCompiler.getInstance();
+ }
+ if (getLibtool() && processor instanceof CommandLineCompiler) {
+ CommandLineCompiler compiler = (CommandLineCompiler) processor;
+ processor = compiler.getLibtoolCompiler();
+ }
+ return processor;
+ }
+ public int getWarnings(CompilerDef[] defaultProviders, int index) {
+ if (isReference()) {
+ return ((CompilerDef) getCheckedRef(CompilerDef.class,
+ "CompilerDef")).getWarnings(defaultProviders, index);
+ }
+ if (warnings == -1) {
+ if (defaultProviders != null && index < defaultProviders.length) {
+ return defaultProviders[index].getWarnings(defaultProviders,
+ index + 1);
+ }
+ }
+ return warnings;
+ }
+ /**
+ * Sets the default compiler adapter. Use the "name" attribute when the
+ * compiler is a supported compiler.
+ *
+ * @param classname
+ * fully qualified classname which implements CompilerAdapter
+ */
+ public void setClassname(String classname) throws BuildException {
+ if (isReference()) {
+ throw tooManyAttributes();
+ }
+ super.setClassname(classname);
+ Processor proc = getProcessor();
+ if (!(proc instanceof Compiler)) {
+ throw new BuildException(classname + " does not implement Compiler");
+ }
+ }
+ /**
+ * Enables or disables exception support.
+ *
+ * @param exceptions
+ * if true, exceptions are supported.
+ *
+ */
+ public void setExceptions(boolean exceptions) {
+ if (isReference()) {
+ throw tooManyAttributes();
+ }
+ this.exceptions = booleanValueOf(exceptions);
+ }
+
+ /**
+ * Enables or disables run-time type information.
+ *
+ * @param rtti
+ * if true, run-time type information is supported.
+ *
+ */
+ public void setRtti(boolean rtti) {
+ if (isReference()) {
+ throw tooManyAttributes();
+ }
+ this.rtti = booleanValueOf(rtti);
+ }
+
+ /**
+ * Enables or disables generation of multithreaded code. Unless specified,
+ * multithreaded code generation is enabled.
+ *
+ * @param multi
+ * If true, generated code may be multithreaded.
+ */
+ public void setMultithreaded(boolean multithreaded) {
+ if (isReference()) {
+ throw tooManyAttributes();
+ }
+ this.multithreaded = booleanValueOf(multithreaded);
+ }
+ /**
+ * Sets compiler type.
+ *
+ *
+ *
Supported compilers
+ *
+ *
gcc (default)
+ *
GCC C++ compiler
+ *
+ *
+ *
g++
+ *
GCC C++ compiler
+ *
+ *
+ *
c++
+ *
GCC C++ compiler
+ *
+ *
+ *
g77
+ *
GNU Fortran compiler
+ *
+ *
+ *
msvc
+ *
Microsoft Visual C++
+ *
+ *
+ *
bcc
+ *
Borland C++ Compiler
+ *
+ *
+ *
msrc
+ *
Microsoft Resource Compiler
+ *
+ *
+ *
brc
+ *
Borland Resource Compiler
+ *
+ *
+ *
df
+ *
Compaq Visual Fortran Compiler
+ *
+ *
+ *
midl
+ *
Microsoft MIDL Compiler
+ *
+ *
+ *
icl
+ *
Intel C++ compiler for Windows (IA-32)
+ *
+ *
+ *
ecl
+ *
Intel C++ compiler for Windows (IA-64)
+ *
+ *
+ *
icc
+ *
Intel C++ compiler for Linux (IA-32)
+ *
+ *
+ *
ecc
+ *
Intel C++ compiler for Linux (IA-64)
+ *
+ *
+ *
CC
+ *
Sun ONE C++ compiler
+ *
+ *
+ *
aCC
+ *
HP aC++ C++ Compiler
+ *
+ *
+ *
os390
+ *
OS390 C Compiler
+ *
+ *
+ *
os400
+ *
Icc Compiler
+ *
+ *
+ *
sunc89
+ *
Sun C89 C Compiler
+ *
+ *
+ *
xlC
+ *
VisualAge C Compiler
+ *
+ *
+ *
+ */
+ public void setName(CompilerEnum name) throws BuildException {
+ if (isReference()) {
+ throw tooManyAttributes();
+ }
+ Compiler compiler = name.getCompiler();
+ setProcessor(compiler);
+ }
+ protected void setProcessor(Processor proc) throws BuildException {
+ try {
+ super.setProcessor((Compiler) proc);
+ } catch (ClassCastException ex) {
+ throw new BuildException(ex);
+ }
+ }
+ /**
+ * Enumerated attribute with the values "none", "severe", "default",
+ * "production", "diagnostic", and "failtask".
+ */
+ public void setWarnings(CompilerDef.WarningLevel level) {
+ warnings = level.getIndex();
+ }
+ /**
+ * Sets optimization level.
+ *
+ * @param value optimization level
+ */
+ public void setOptimize(OptimizationEnum value) {
+ if (isReference()) {
+ throw tooManyAttributes();
+ }
+ this.optimization = value;
+ }
+ /**
+ * Enables or disables default flags.
+ *
+ * @param defaultflag
+ * if true, default flags will add to command line.
+ *
+ */
+ public void setDefaultflag(boolean defaultflag) {
+ if (isReference()) {
+ throw tooManyAttributes();
+ }
+ this.defaultflag = booleanValueOf(defaultflag);
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/CompilerEnum.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/CompilerEnum.java
new file mode 100644
index 0000000000..a017243522
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/CompilerEnum.java
@@ -0,0 +1,221 @@
+/*
+ *
+ * Copyright 2002-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks;
+import net.sf.antcontrib.cpptasks.arm.ADSCCompiler;
+import net.sf.antcontrib.cpptasks.borland.BorlandCCompiler;
+import net.sf.antcontrib.cpptasks.borland.BorlandResourceCompiler;
+import net.sf.antcontrib.cpptasks.compaq.CompaqVisualFortranCompiler;
+import net.sf.antcontrib.cpptasks.compiler.Compiler;
+import net.sf.antcontrib.cpptasks.devstudio.DevStudioCCompiler;
+import net.sf.antcontrib.cpptasks.devstudio.DevStudioMIDLCompiler;
+import net.sf.antcontrib.cpptasks.devstudio.DevStudioResourceCompiler;
+import net.sf.antcontrib.cpptasks.gcc.GccCCompiler;
+import net.sf.antcontrib.cpptasks.hp.aCCCompiler;
+import net.sf.antcontrib.cpptasks.ibm.VisualAgeCCompiler;
+import net.sf.antcontrib.cpptasks.intel.IntelLinux32CCompiler;
+import net.sf.antcontrib.cpptasks.intel.IntelLinux64CCompiler;
+import net.sf.antcontrib.cpptasks.intel.IntelWin32CCompiler;
+import net.sf.antcontrib.cpptasks.intel.IntelWin64CCompiler;
+import net.sf.antcontrib.cpptasks.os390.OS390CCompiler;
+import net.sf.antcontrib.cpptasks.os400.IccCompiler;
+import net.sf.antcontrib.cpptasks.sun.C89CCompiler;
+import net.sf.antcontrib.cpptasks.sun.ForteCCCompiler;
+import net.sf.antcontrib.cpptasks.ti.ClxxCCompiler;
+
+import org.apache.tools.ant.types.EnumeratedAttribute;
+/**
+ * Enumeration of supported compilers
+ *
+ *
Supported compilers
+ *
+ *
gcc (default)
+ *
GCC C++ compiler
+ *
+ *
+ *
g++
+ *
GCC C++ compiler
+ *
+ *
+ *
c++
+ *
GCC C++ compiler
+ *
+ *
+ *
g77
+ *
GNU FORTRAN compiler
+ *
+ *
+ *
msvc
+ *
Microsoft Visual C++
+ *
+ *
+ *
bcc
+ *
Borland C++ Compiler
+ *
+ *
+ *
msrc
+ *
Microsoft Resource Compiler
+ *
+ *
+ *
brc
+ *
Borland Resource Compiler
+ *
+ *
+ *
df
+ *
Compaq Visual Fortran Compiler
+ *
+ *
+ *
midl
+ *
Microsoft MIDL Compiler
+ *
+ *
+ *
icl
+ *
Intel C++ compiler for Windows (IA-32)
+ *
+ *
+ *
ecl
+ *
Intel C++ compiler for Windows (IA-64)
+ *
+ *
+ *
icc
+ *
Intel C++ compiler for Linux (IA-32)
+ *
+ *
+ *
ecc
+ *
Intel C++ compiler for Linux (IA-64)
+ *
+ *
+ *
CC
+ *
Sun ONE C++ compiler
+ *
+ *
+ *
aCC
+ *
HP aC++ C++ Compiler
+ *
+ *
+ *
os390
+ *
OS390 C Compiler
+ *
+ *
+ *
os400
+ *
Icc Compiler
+ *
+ *
+ *
sunc89
+ *
Sun C89 C Compiler
+ *
+ *
+ *
xlC
+ *
VisualAge C Compiler
+ *
+ *
+ *
cl6x
+ *
TI TMS320C6000 Optimizing Compiler
+ *
+ *
+ *
cl55
+ *
TI TMS320C55x Optimizing C/C++ Compiler
+ *
+ *
+ *
armcpp
+ *
ARM 32-bit C++ compiler
+ *
+ *
+ *
armcc
+ *
ARM 32-bit C compiler
+ *
+ *
+ *
tcpp
+ *
ARM 16-bit C++ compiler
+ *
+ *
+ *
tcc
+ *
ARM 16-bit C compiler
+ *
+ *
+ *
+ * @author Curt Arnold
+ *
+ */
+public class CompilerEnum extends EnumeratedAttribute {
+ private final static ProcessorEnumValue[] compilers = new ProcessorEnumValue[]{
+ new ProcessorEnumValue("gcc", GccCCompiler.getInstance()),
+ new ProcessorEnumValue("g++", GccCCompiler.getGppInstance()),
+ new ProcessorEnumValue("c++", GccCCompiler.getCppInstance()),
+ new ProcessorEnumValue("g77", GccCCompiler.getG77Instance()),
+ new ProcessorEnumValue("msvc", DevStudioCCompiler.getInstance()),
+ new ProcessorEnumValue("bcc", BorlandCCompiler.getInstance()),
+ new ProcessorEnumValue("msrc", DevStudioResourceCompiler
+ .getInstance()),
+ new ProcessorEnumValue("brc", BorlandResourceCompiler.getInstance()),
+ new ProcessorEnumValue("df", CompaqVisualFortranCompiler
+ .getInstance()),
+ new ProcessorEnumValue("midl", DevStudioMIDLCompiler.getInstance()),
+ new ProcessorEnumValue("icl", IntelWin32CCompiler.getInstance()),
+ new ProcessorEnumValue("ecl", IntelWin64CCompiler.getInstance()),
+ new ProcessorEnumValue("icc", IntelLinux32CCompiler.getInstance()),
+ new ProcessorEnumValue("ecc", IntelLinux64CCompiler.getInstance()),
+ new ProcessorEnumValue("CC", ForteCCCompiler.getInstance()),
+ new ProcessorEnumValue("aCC", aCCCompiler.getInstance()),
+ new ProcessorEnumValue("os390", OS390CCompiler.getInstance()),
+ new ProcessorEnumValue("os400", IccCompiler.getInstance()),
+ new ProcessorEnumValue("sunc89", C89CCompiler.getInstance()),
+ new ProcessorEnumValue("xlC", VisualAgeCCompiler.getInstance()),
+ new ProcessorEnumValue("cl6x", ClxxCCompiler.getCl6xInstance()),
+ new ProcessorEnumValue("cl55", ClxxCCompiler.getCl55Instance()),
+ new ProcessorEnumValue("armcc", ADSCCompiler.getArmCC()),
+ new ProcessorEnumValue("armcpp", ADSCCompiler.getArmCpp()),
+ new ProcessorEnumValue("tcc", ADSCCompiler.getThumbCC()),
+ new ProcessorEnumValue("tcpp", ADSCCompiler.getThumbCpp()),
+ // userdefined
+ //new ProcessorEnumValue("userdefine", UserdefineCompiler.getInstance()),
+ // GCC Cross Compilers
+ new ProcessorEnumValue(
+ "sparc-sun-solaris2-gcc",
+ net.sf.antcontrib.cpptasks.gcc.cross.sparc_sun_solaris2.GccCCompiler
+ .getInstance()),
+ new ProcessorEnumValue(
+ "sparc-sun-solaris2-g++",
+ net.sf.antcontrib.cpptasks.gcc.cross.sparc_sun_solaris2.GccCCompiler
+ .getGppInstance()),
+ new ProcessorEnumValue(
+ "sparc-sun-solaris2-c++",
+ net.sf.antcontrib.cpptasks.gcc.cross.sparc_sun_solaris2.GccCCompiler
+ .getCppInstance()),
+ new ProcessorEnumValue(
+ "sparc-sun-solaris2-g77",
+ net.sf.antcontrib.cpptasks.gcc.cross.sparc_sun_solaris2.GccCCompiler
+ .getG77Instance()),
+ // GCC Cross Compilers
+ new ProcessorEnumValue("gcc-cross",
+ net.sf.antcontrib.cpptasks.gcc.cross.GccCCompiler
+ .getInstance()),
+ new ProcessorEnumValue("g++-cross",
+ net.sf.antcontrib.cpptasks.gcc.cross.GccCCompiler
+ .getGppInstance()),
+ new ProcessorEnumValue("c++-cross",
+ net.sf.antcontrib.cpptasks.gcc.cross.GccCCompiler
+ .getCppInstance()),
+ new ProcessorEnumValue("g77-cross",
+ net.sf.antcontrib.cpptasks.gcc.cross.GccCCompiler
+ .getG77Instance()),};
+ public Compiler getCompiler() {
+ return (Compiler) compilers[getIndex()].getProcessor();
+ }
+ public String[] getValues() {
+ return ProcessorEnumValue.getValues(compilers);
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/CompilerParam.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/CompilerParam.java
new file mode 100644
index 0000000000..82eb6ee425
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/CompilerParam.java
@@ -0,0 +1,33 @@
+/*
+ *
+ * Copyright 2001-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks;
+/*******************************************************************************
+ * Place class description here.
+ *
+ * @author inger
+ * @author
+ *
+ * @since
+ ******************************************************************************/
+public class CompilerParam extends ProcessorParam {
+ public CompilerParam() {
+ }
+ public void execute() throws org.apache.tools.ant.BuildException {
+ throw new org.apache.tools.ant.BuildException(
+ "Not an actual task, but looks like one for documentation purposes");
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/DependencyInfo.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/DependencyInfo.java
new file mode 100644
index 0000000000..429d2b0107
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/DependencyInfo.java
@@ -0,0 +1,86 @@
+/*
+ *
+ * Copyright 2002-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks;
+import java.util.Vector;
+/**
+ * @author Curt Arnold
+ */
+public final class DependencyInfo {
+ /**
+ * Last modified time of this file or anything that it depends on.
+ *
+ * Not persisted since almost any change could invalidate it. Initialized
+ * to long.MIN_VALUE on construction.
+ */
+ private long compositeLastModified;
+ private/* final */String includePathIdentifier;
+ private/* final */String[] includes;
+ private/* final */String source;
+ private/* final */long sourceLastModified;
+ private/* final */String[] sysIncludes;
+ public DependencyInfo(String includePathIdentifier, String source,
+ long sourceLastModified, Vector includes, Vector sysIncludes) {
+ if (source == null) {
+ throw new NullPointerException("source");
+ }
+ if (includePathIdentifier == null) {
+ throw new NullPointerException("includePathIdentifier");
+ }
+ this.source = source;
+ this.sourceLastModified = sourceLastModified;
+ this.includePathIdentifier = includePathIdentifier;
+ this.includes = new String[includes.size()];
+ if (includes.size() == 0) {
+ compositeLastModified = sourceLastModified;
+ } else {
+ includes.copyInto(this.includes);
+ compositeLastModified = Long.MIN_VALUE;
+ }
+ this.sysIncludes = new String[sysIncludes.size()];
+ sysIncludes.copyInto(this.sysIncludes);
+ }
+ /**
+ * Returns the latest modification date of the source or anything that it
+ * depends on.
+ *
+ * @returns the composite lastModified time, returns Long.MIN_VALUE if not
+ * set
+ */
+ public long getCompositeLastModified() {
+ return compositeLastModified;
+ }
+ public String getIncludePathIdentifier() {
+ return includePathIdentifier;
+ }
+ public String[] getIncludes() {
+ String[] includesClone = (String[]) includes.clone();
+ return includesClone;
+ }
+ public String getSource() {
+ return source;
+ }
+ public long getSourceLastModified() {
+ return sourceLastModified;
+ }
+ public String[] getSysIncludes() {
+ String[] sysIncludesClone = (String[]) sysIncludes.clone();
+ return sysIncludesClone;
+ }
+ public void setCompositeLastModified(long lastMod) {
+ compositeLastModified = lastMod;
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/DependencyTable.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/DependencyTable.java
new file mode 100644
index 0000000000..3cbee7a625
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/DependencyTable.java
@@ -0,0 +1,609 @@
+/*
+ *
+ * Copyright 2002-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+import java.io.UnsupportedEncodingException;
+import java.util.Enumeration;
+import java.util.Hashtable;
+import java.util.Vector;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+import net.sf.antcontrib.cpptasks.compiler.CompilerConfiguration;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Project;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.DefaultHandler;
+/**
+ * @author Curt Arnold
+ */
+public final class DependencyTable {
+ /**
+ * This class handles populates the TargetHistory hashtable in response to
+ * SAX parse events
+ */
+ private class DependencyTableHandler extends DefaultHandler {
+ private File baseDir;
+ private final DependencyTable dependencyTable;
+ private String includePath;
+ private Vector includes;
+ private String source;
+ private long sourceLastModified;
+ private Vector sysIncludes;
+ /**
+ * Constructor
+ *
+ * @param history
+ * hashtable of TargetHistory keyed by output name
+ * @param outputFiles
+ * existing files in output directory
+ */
+ private DependencyTableHandler(DependencyTable dependencyTable,
+ File baseDir) {
+ this.dependencyTable = dependencyTable;
+ this.baseDir = baseDir;
+ includes = new Vector();
+ sysIncludes = new Vector();
+ source = null;
+ }
+ public void endElement(String namespaceURI, String localName,
+ String qName) throws SAXException {
+ //
+ // if then
+ // create Dependency object and add to hashtable
+ // if corresponding source file exists and
+ // has the same timestamp
+ //
+ if (qName.equals("source")) {
+ if (source != null && includePath != null) {
+ File existingFile = new File(baseDir, source);
+ //
+ // if the file exists and the time stamp is right
+ // preserve the dependency info
+ if (existingFile.exists()) {
+ //
+ // would have expected exact matches
+ // but was seeing some unexpected difference by
+ // a few tens of milliseconds, as long
+ // as the times are within a second
+ long existingLastModified = existingFile.lastModified();
+ long diff = existingLastModified - sourceLastModified;
+ if (diff >= -500 && diff <= 500) {
+ DependencyInfo dependInfo = new DependencyInfo(
+ includePath, source, sourceLastModified,
+ includes, sysIncludes);
+ dependencyTable.putDependencyInfo(source,
+ dependInfo);
+ }
+ }
+ source = null;
+ includes.setSize(0);
+ }
+ } else {
+ //
+ // this causes any elements outside the
+ // scope of an to be discarded
+ //
+ if (qName.equals("includePath")) {
+ includePath = null;
+ }
+ }
+ }
+ /**
+ * startElement handler
+ */
+ public void startElement(String namespaceURI, String localName,
+ String qName, Attributes atts) throws SAXException {
+ //
+ // if includes, then add relative file name to vector
+ //
+ if (qName.equals("include")) {
+ includes.addElement(atts.getValue("file"));
+ } else {
+ if (qName.equals("sysinclude")) {
+ sysIncludes.addElement(atts.getValue("file"));
+ } else {
+ //
+ // if source then
+ // capture source file name,
+ // modification time and reset includes vector
+ //
+ if (qName.equals("source")) {
+ source = atts.getValue("file");
+ sourceLastModified = Long.parseLong(atts
+ .getValue("lastModified"), 16);
+ includes.setSize(0);
+ sysIncludes.setSize(0);
+ } else {
+ if (qName.equals("includePath")) {
+ includePath = atts.getValue("signature");
+ }
+ }
+ }
+ }
+ }
+ }
+ public abstract class DependencyVisitor {
+ /**
+ * Previews all the children of this source file.
+ *
+ * May be called multiple times as DependencyInfo's for children are
+ * filled in.
+ *
+ * @return true to continue towards recursion into included files
+ */
+ public abstract boolean preview(DependencyInfo parent,
+ DependencyInfo[] children);
+ /**
+ * Called if the dependency depth exhausted the stack.
+ */
+ public abstract void stackExhausted();
+ /**
+ * Visits the dependency info.
+ *
+ * @returns true to continue towards recursion into included files
+ */
+ public abstract boolean visit(DependencyInfo dependInfo);
+ }
+ public class TimestampChecker extends DependencyVisitor {
+ private boolean noNeedToRebuild;
+ private long outputLastModified;
+ private boolean rebuildOnStackExhaustion;
+ public TimestampChecker(final long outputLastModified,
+ boolean rebuildOnStackExhaustion) {
+ this.outputLastModified = outputLastModified;
+ noNeedToRebuild = true;
+ this.rebuildOnStackExhaustion = rebuildOnStackExhaustion;
+ }
+ public boolean getMustRebuild() {
+ return !noNeedToRebuild;
+ }
+ public boolean preview(DependencyInfo parent, DependencyInfo[] children) {
+ int withCompositeTimes = 0;
+ long parentCompositeLastModified = parent.getSourceLastModified();
+ for (int i = 0; i < children.length; i++) {
+ if (children[i] != null) {
+ //
+ // expedient way to determine if a child forces us to
+ // rebuild
+ //
+ visit(children[i]);
+ long childCompositeLastModified = children[i]
+ .getCompositeLastModified();
+ if (childCompositeLastModified != Long.MIN_VALUE) {
+ withCompositeTimes++;
+ if (childCompositeLastModified > parentCompositeLastModified) {
+ parentCompositeLastModified = childCompositeLastModified;
+ }
+ }
+ }
+ }
+ if (withCompositeTimes == children.length) {
+ parent.setCompositeLastModified(parentCompositeLastModified);
+ }
+ //
+ // may have been changed by an earlier call to visit()
+ //
+ return noNeedToRebuild;
+ }
+ public void stackExhausted() {
+ if (rebuildOnStackExhaustion) {
+ noNeedToRebuild = false;
+ }
+ }
+ public boolean visit(DependencyInfo dependInfo) {
+ if (noNeedToRebuild) {
+ if (dependInfo.getSourceLastModified() > outputLastModified
+ || dependInfo.getCompositeLastModified() > outputLastModified) {
+ noNeedToRebuild = false;
+ }
+ }
+ //
+ // only need to process the children if
+ // it has not yet been determined whether
+ // we need to rebuild and the composite modified time
+ // has not been determined for this file
+ return noNeedToRebuild
+ && dependInfo.getCompositeLastModified() == Long.MIN_VALUE;
+ }
+ }
+ private/* final */File baseDir;
+ private String baseDirPath;
+ /**
+ * a hashtable of DependencyInfo[] keyed by output file name
+ */
+ private final Hashtable dependencies = new Hashtable();
+ /** The file the cache was loaded from. */
+ private/* final */File dependenciesFile;
+ /** Flag indicating whether the cache should be written back to file. */
+ private boolean dirty;
+ /**
+ * Creates a target history table from dependencies.xml in the prject
+ * directory, if it exists. Otherwise, initializes the dependencies empty.
+ *
+ * @param task
+ * task used for logging history load errors
+ * @param baseDir
+ * output directory for task
+ */
+ public DependencyTable(File baseDir) {
+ if (baseDir == null) {
+ throw new NullPointerException("baseDir");
+ }
+ this.baseDir = baseDir;
+ try {
+ baseDirPath = baseDir.getCanonicalPath();
+ } catch (IOException ex) {
+ baseDirPath = baseDir.toString();
+ }
+ dirty = false;
+ //
+ // load any existing dependencies from file
+ dependenciesFile = new File(baseDir, "dependencies.xml");
+ }
+ public void commit(CCTask task) {
+ //
+ // if not dirty, no need to update file
+ //
+ if (dirty) {
+ //
+ // walk through dependencies to get vector of include paths
+ // identifiers
+ //
+ Vector includePaths = getIncludePaths();
+ //
+ //
+ // write dependency file
+ //
+ try {
+ FileOutputStream outStream = new FileOutputStream(
+ dependenciesFile);
+ OutputStreamWriter streamWriter;
+ //
+ // Early VM's may not have UTF-8 support
+ // fallback to default code page which
+ // "should" be okay unless there are
+ // non ASCII file names
+ String encodingName = "UTF-8";
+ try {
+ streamWriter = new OutputStreamWriter(outStream, "UTF-8");
+ } catch (UnsupportedEncodingException ex) {
+ streamWriter = new OutputStreamWriter(outStream);
+ encodingName = streamWriter.getEncoding();
+ }
+ BufferedWriter writer = new BufferedWriter(streamWriter);
+ writer.write("\n");
+ writer.write("\n");
+ StringBuffer buf = new StringBuffer();
+ Enumeration includePathEnum = includePaths.elements();
+ while (includePathEnum.hasMoreElements()) {
+ writeIncludePathDependencies((String) includePathEnum
+ .nextElement(), writer, buf);
+ }
+ writer.write("\n");
+ writer.close();
+ dirty = false;
+ } catch (IOException ex) {
+ task.log("Error writing " + dependenciesFile.toString() + ":"
+ + ex.toString());
+ }
+ }
+ }
+ /**
+ * Returns an enumerator of DependencyInfo's
+ */
+ public Enumeration elements() {
+ return dependencies.elements();
+ }
+ /**
+ * This method returns a DependencyInfo for the specific source file and
+ * include path identifier
+ *
+ */
+ public DependencyInfo getDependencyInfo(String sourceRelativeName,
+ String includePathIdentifier) {
+ DependencyInfo dependInfo = null;
+ DependencyInfo[] dependInfos = (DependencyInfo[]) dependencies
+ .get(sourceRelativeName);
+ if (dependInfos != null) {
+ for (int i = 0; i < dependInfos.length; i++) {
+ dependInfo = dependInfos[i];
+ if (dependInfo.getIncludePathIdentifier().equals(
+ includePathIdentifier)) {
+ return dependInfo;
+ }
+ }
+ }
+ return null;
+ }
+ private Vector getIncludePaths() {
+ Vector includePaths = new Vector();
+ DependencyInfo[] dependInfos;
+ Enumeration dependenciesEnum = dependencies.elements();
+ while (dependenciesEnum.hasMoreElements()) {
+ dependInfos = (DependencyInfo[]) dependenciesEnum.nextElement();
+ for (int i = 0; i < dependInfos.length; i++) {
+ DependencyInfo dependInfo = dependInfos[i];
+ boolean matchesExisting = false;
+ final String dependIncludePath = dependInfo
+ .getIncludePathIdentifier();
+ Enumeration includePathEnum = includePaths.elements();
+ while (includePathEnum.hasMoreElements()) {
+ if (dependIncludePath.equals(includePathEnum.nextElement())) {
+ matchesExisting = true;
+ break;
+ }
+ }
+ if (!matchesExisting) {
+ includePaths.addElement(dependIncludePath);
+ }
+ }
+ }
+ return includePaths;
+ }
+ public void load() throws IOException, ParserConfigurationException,
+ SAXException {
+ dependencies.clear();
+ if (dependenciesFile.exists()) {
+ SAXParserFactory factory = SAXParserFactory.newInstance();
+ factory.setValidating(false);
+ SAXParser parser = factory.newSAXParser();
+ parser.parse(dependenciesFile, new DependencyTableHandler(this,
+ baseDir));
+ dirty = false;
+ }
+ }
+ /**
+ * Determines if the specified target needs to be rebuilt.
+ *
+ * This task may result in substantial IO as files are parsed to determine
+ * their dependencies
+ */
+ public boolean needsRebuild(CCTask task, TargetInfo target,
+ int dependencyDepth) {
+ // look at any files where the compositeLastModified
+ // is not known, but the includes are known
+ //
+ boolean mustRebuild = false;
+ CompilerConfiguration compiler = (CompilerConfiguration) target
+ .getConfiguration();
+ String includePathIdentifier = compiler.getIncludePathIdentifier();
+ File[] sources = target.getSources();
+ DependencyInfo[] dependInfos = new DependencyInfo[sources.length];
+ long outputLastModified = target.getOutput().lastModified();
+ //
+ // try to solve problem using existing dependency info
+ // (not parsing any new files)
+ //
+ DependencyInfo[] stack = new DependencyInfo[50];
+ boolean rebuildOnStackExhaustion = true;
+ if (dependencyDepth >= 0) {
+ if (dependencyDepth < 50) {
+ stack = new DependencyInfo[dependencyDepth];
+ }
+ rebuildOnStackExhaustion = false;
+ }
+ TimestampChecker checker = new TimestampChecker(outputLastModified,
+ rebuildOnStackExhaustion);
+ for (int i = 0; i < sources.length && !mustRebuild; i++) {
+ File source = sources[i];
+ String relative = CUtil.getRelativePath(baseDirPath, source);
+ DependencyInfo dependInfo = getDependencyInfo(relative,
+ includePathIdentifier);
+ if (dependInfo == null) {
+ task.log("Parsing " + relative, Project.MSG_VERBOSE);
+ dependInfo = parseIncludes(task, compiler, source);
+ }
+ walkDependencies(task, dependInfo, compiler, stack, checker);
+ mustRebuild = checker.getMustRebuild();
+ }
+ return mustRebuild;
+ }
+ public DependencyInfo parseIncludes(CCTask task,
+ CompilerConfiguration compiler, File source) {
+ DependencyInfo dependInfo = compiler.parseIncludes(task, baseDir,
+ source);
+ String relativeSource = CUtil.getRelativePath(baseDirPath, source);
+ putDependencyInfo(relativeSource, dependInfo);
+ return dependInfo;
+ }
+ private void putDependencyInfo(String key, DependencyInfo dependInfo) {
+ //
+ // optimistic, add new value
+ //
+ DependencyInfo[] old = (DependencyInfo[]) dependencies.put(key,
+ new DependencyInfo[]{dependInfo});
+ dirty = true;
+ //
+ // something was already there
+ //
+ if (old != null) {
+ //
+ // see if the include path matches a previous entry
+ // if so replace it
+ String includePathIdentifier = dependInfo
+ .getIncludePathIdentifier();
+ for (int i = 0; i < old.length; i++) {
+ DependencyInfo oldDepend = old[i];
+ if (oldDepend.getIncludePathIdentifier().equals(
+ includePathIdentifier)) {
+ old[i] = dependInfo;
+ dependencies.put(key, old);
+ return;
+ }
+ }
+ //
+ // no match prepend the new entry to the array
+ // of dependencies for the file
+ DependencyInfo[] combined = new DependencyInfo[old.length + 1];
+ combined[0] = dependInfo;
+ for (int i = 0; i < old.length; i++) {
+ combined[i + 1] = old[i];
+ }
+ dependencies.put(key, combined);
+ }
+ return;
+ }
+ public void walkDependencies(CCTask task, DependencyInfo dependInfo,
+ CompilerConfiguration compiler, DependencyInfo[] stack,
+ DependencyVisitor visitor) throws BuildException {
+ //
+ // visit this node
+ // if visit returns true then
+ // visit the referenced include and sysInclude dependencies
+ //
+ if (visitor.visit(dependInfo)) {
+ //
+ // find first null entry on stack
+ //
+ int stackPosition = -1;
+ for (int i = 0; i < stack.length; i++) {
+ if (stack[i] == null) {
+ stackPosition = i;
+ stack[i] = dependInfo;
+ break;
+ } else {
+ //
+ // if we have appeared early in the calling history
+ // then we didn't exceed the criteria
+ if (stack[i] == dependInfo) {
+ return;
+ }
+ }
+ }
+ if (stackPosition == -1) {
+ visitor.stackExhausted();
+ return;
+ }
+ //
+ // locate dependency infos
+ //
+ String[] includes = dependInfo.getIncludes();
+ String includePathIdentifier = compiler.getIncludePathIdentifier();
+ DependencyInfo[] includeInfos = new DependencyInfo[includes.length];
+ for (int i = 0; i < includes.length; i++) {
+ DependencyInfo includeInfo = getDependencyInfo(includes[i],
+ includePathIdentifier);
+ includeInfos[i] = includeInfo;
+ }
+ //
+ // preview with only the already available dependency infos
+ //
+ if (visitor.preview(dependInfo, includeInfos)) {
+ //
+ // now need to fill in the missing DependencyInfos
+ //
+ int missingCount = 0;
+ for (int i = 0; i < includes.length; i++) {
+ if (includeInfos[i] == null) {
+ missingCount++;
+ task.log("Parsing " + includes[i], Project.MSG_VERBOSE);
+ // If the include is part of a UNC don't go building a
+ // relative file name.
+ File src = includes[i].startsWith("\\\\") ? new File(
+ includes[i]) : new File(baseDir, includes[i]);
+ DependencyInfo includeInfo = parseIncludes(task,
+ compiler, src);
+ includeInfos[i] = includeInfo;
+ }
+ }
+ //
+ // if it passes a review the second time
+ // then recurse into all the children
+ if (missingCount == 0
+ || visitor.preview(dependInfo, includeInfos)) {
+ //
+ // recurse into
+ //
+ for (int i = 0; i < includeInfos.length; i++) {
+ DependencyInfo includeInfo = includeInfos[i];
+ walkDependencies(task, includeInfo, compiler, stack,
+ visitor);
+ }
+ }
+ }
+ stack[stackPosition] = null;
+ }
+ }
+ private void writeDependencyInfo(BufferedWriter writer, StringBuffer buf,
+ DependencyInfo dependInfo) throws IOException {
+ String[] includes = dependInfo.getIncludes();
+ String[] sysIncludes = dependInfo.getSysIncludes();
+ //
+ // if the includes have not been evaluted then
+ // it is not worth our time saving it
+ // and trying to distiguish between files with
+ // no dependencies and those with undetermined dependencies
+ buf.setLength(0);
+ buf.append(" \n");
+ writer.write(buf.toString());
+ for (int i = 0; i < includes.length; i++) {
+ buf.setLength(0);
+ buf.append(" \n");
+ writer.write(buf.toString());
+ }
+ for (int i = 0; i < sysIncludes.length; i++) {
+ buf.setLength(0);
+ buf.append(" \n");
+ writer.write(buf.toString());
+ }
+ writer.write(" \n");
+ return;
+ }
+ private void writeIncludePathDependencies(String includePathIdentifier,
+ BufferedWriter writer, StringBuffer buf) throws IOException {
+ //
+ // include path element
+ //
+ buf.setLength(0);
+ buf.append(" \n");
+ writer.write(buf.toString());
+ Enumeration dependenciesEnum = dependencies.elements();
+ while (dependenciesEnum.hasMoreElements()) {
+ DependencyInfo[] dependInfos = (DependencyInfo[]) dependenciesEnum
+ .nextElement();
+ for (int i = 0; i < dependInfos.length; i++) {
+ DependencyInfo dependInfo = dependInfos[i];
+ //
+ // if this is for the same include path
+ // then output the info
+ if (dependInfo.getIncludePathIdentifier().equals(
+ includePathIdentifier)) {
+ writeDependencyInfo(writer, buf, dependInfo);
+ }
+ }
+ }
+ writer.write(" \n");
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/DistributerDef.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/DistributerDef.java
new file mode 100644
index 0000000000..ee4f656ccc
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/DistributerDef.java
@@ -0,0 +1,243 @@
+/*
+ *
+ * Copyright 2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks;
+
+
+import org.apache.tools.ant.types.DataType;
+import org.apache.tools.ant.types.Reference;
+import java.util.Vector;
+
+/**
+ * Distributed build information (Non-functional prototype).
+ *
+ */
+public final class DistributerDef
+ extends DataType {
+ /**
+ * if property.
+ */
+ private String ifCond;
+
+ /**
+ * unless property.
+ */
+ private String unlessCond;
+
+ /**
+ * hosts.
+ *
+ */
+ private String hosts;
+
+ /**
+ * Protocol.
+ *
+ */
+ private DistributerProtocolEnum protocol;
+
+ /**
+ * Not sure what this is.
+ */
+ private int tcpCork;
+
+ /**
+ * user name.
+ */
+ private String user;
+
+ /**
+ * local to remote file name maps.
+ */
+ private final Vector maps = new Vector();
+
+ /**
+ * Constructor.
+ *
+ */
+ public DistributerDef() {
+ }
+
+ /**
+ * Required by documentation generator.
+ */
+ public void execute() {
+ throw new org.apache.tools.ant.BuildException(
+ "Not an actual task, but looks like one for documentation purposes");
+ }
+
+ /**
+ * Returns true if the if and unless conditions (if any) are
+ * satisfied.
+ * @return true if definition is active.
+ */
+ public boolean isActive() {
+ return CUtil.isActive(getProject(), ifCond, unlessCond);
+ }
+
+ /**
+ * Sets an id that can be used to reference this element.
+ *
+ * @param id
+ * id
+ */
+ public void setId(final String id) {
+ //
+ // this is actually accomplished by a different
+ // mechanism, but we can document it
+ //
+ }
+
+ /**
+ * Sets the property name for the 'if' condition.
+ *
+ * The define will be ignored unless the property is defined.
+ *
+ * The value of the property is insignificant, but values that would imply
+ * misinterpretation ("false", "no") will throw an exception when
+ * evaluated.
+ *
+ * @param propName
+ * property name
+ */
+ public void setIf(final String propName) {
+ ifCond = propName;
+ }
+
+ /**
+ * Specifies that this element should behave as if the content of the
+ * element with the matching id attribute was inserted at this location. If
+ * specified, no other attributes should be specified.
+ * @param r reference name
+ */
+ public void setRefid(final Reference r) {
+ super.setRefid(r);
+ }
+
+ /**
+ * Set the property name for the 'unless' condition.
+ *
+ * If named property is set, the define will be ignored.
+ *
+ * The value of the property is insignificant, but values that would imply
+ * misinterpretation ("false", "no") of the behavior will throw an
+ * exception when evaluated.
+ *
+ * @param propName
+ * name of property
+ */
+ public void setUnless(final String propName) {
+ unlessCond = propName;
+ }
+
+ /**
+ * Gets hosts.
+ * @return hosts, may be null.
+ *
+ */
+ public String getHosts() {
+ if (isReference()) {
+ DistributerDef refDistributer = (DistributerDef)
+ getCheckedRef(DistributerDef.class,
+ "DistributerDef");
+ return refDistributer.getHosts();
+ }
+ return hosts;
+ }
+
+ /**
+ * Gets tcp cork.
+ * @return TCP_CORK value.
+ *
+ */
+ public int getTcpcork() {
+ if (isReference()) {
+ DistributerDef refDistributer = (DistributerDef)
+ getCheckedRef(DistributerDef.class,
+ "DistributerDef");
+ return refDistributer.getTcpcork();
+ }
+ return tcpCork;
+ }
+
+ /**
+ * Gets protocol.
+ * @return protocol, may be null.
+ *
+ */
+ public DistributerProtocolEnum getProtocol() {
+ if (isReference()) {
+ DistributerDef refDistributer = (DistributerDef)
+ getCheckedRef(DistributerDef.class,
+ "DistributerDef");
+ return refDistributer.getProtocol();
+ }
+ return protocol;
+ }
+
+ /**
+ * Sets hosts.
+ * @param value new value
+ */
+ public void setHosts(final String value) {
+ if (isReference()) {
+ throw tooManyAttributes();
+ }
+ hosts = value;
+ }
+
+ /**
+ * Sets TCP_CORK value.
+ * @param value new value
+ */
+ public void setTcpcork(final int value) {
+ if (isReference()) {
+ throw tooManyAttributes();
+ }
+ tcpCork = value;
+ }
+
+ /**
+ * Sets protocol.
+ * @param value new value
+ */
+ public void setProtocol(final DistributerProtocolEnum value) {
+ if (isReference()) {
+ throw tooManyAttributes();
+ }
+ protocol = value;
+ }
+
+ /**
+ * Local to remote filename maps.
+ * @return new map
+ */
+ public DistributerMap createMap() {
+ DistributerMap map = new DistributerMap();
+ map.setProject(getProject());
+ maps.addElement(map);
+ return map;
+ }
+
+ /**
+ * Sets remote user name.
+ * @param value user name
+ */
+ public void setUser(final String value) {
+ user = value;
+ }
+
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/DistributerMap.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/DistributerMap.java
new file mode 100644
index 0000000000..aeacf551fa
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/DistributerMap.java
@@ -0,0 +1,218 @@
+/*
+ *
+ * Copyright 2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.types.DataType;
+
+/**
+ * Local to remote filename mapping (Experimental).
+ *
+ */
+public final class DistributerMap
+ extends DataType {
+ /**
+ * if property.
+ */
+ private String ifCond;
+
+ /**
+ * unless property.
+ */
+ private String unlessCond;
+
+ /**
+ * local directory name.
+ *
+ */
+ private File localName;
+
+ /**
+ * Canonical local file name.
+ */
+ private String canonicalPath;
+
+ /**
+ * remote name.
+ *
+ */
+ private String remoteName;
+
+ /**
+ * Separator (/ or \) character on remote system.
+ */
+ private char remoteSeparator = File.separatorChar;
+
+ /**
+ * hosts that for which this map is valid.
+ *
+ */
+ private String hosts;
+
+ /**
+ * Constructor.
+ *
+ */
+ public DistributerMap() {
+ }
+
+ /**
+ * Required by documentation generator.
+ */
+ public void execute() {
+ throw new org.apache.tools.ant.BuildException(
+ "Not an actual task, but looks like one for documentation purposes");
+ }
+
+ /**
+ * Returns true if the if and unless conditions (if any) are
+ * satisfied.
+ *
+ * @return true if this object is active.
+ */
+ public boolean isActive() {
+ return CUtil.isActive(getProject(), ifCond, unlessCond);
+ }
+
+ /**
+ * Sets the property name for the 'if' condition.
+ *
+ * This object will be ignored unless the property is defined.
+ *
+ * The value of the property is insignificant, but values that would imply
+ * misinterpretation ("false", "no") will throw an exception when
+ * evaluated.
+ *
+ * @param propName
+ * property name
+ */
+ public void setIf(final String propName) {
+ ifCond = propName;
+ }
+
+ /**
+ * Set the property name for the 'unless' condition.
+ *
+ * If named property is set, the define will be ignored.
+ *
+ * The value of the property is insignificant, but values that would imply
+ * misinterpretation ("false", "no") of the behavior will throw an
+ * exception when evaluated.
+ *
+ * @param propName
+ * name of property
+ */
+ public void setUnless(final String propName) {
+ unlessCond = propName;
+ }
+
+ /**
+ * Gets local directory.
+ * @return local directory, may be null.
+ *
+ */
+ public File getLocal() {
+ return localName;
+ }
+
+ /**
+ * Gets remote name for directory.
+ * @return remote name, may be null.
+ *
+ */
+ public String getRemote() {
+ return remoteName;
+ }
+
+ /**
+ * Converts the local file name to the remote name for the same file.
+ *
+ * @param host host
+ * @param localFile local file
+ * @return remote name for local file, null if unknown.
+ */
+ public String toRemote(final String host, final File localFile) {
+ if (remoteName != null
+ && (hosts == null || hosts.indexOf(host) >= 0)) {
+ try {
+ String canonical = localFile.getCanonicalPath();
+ if (canonical.startsWith(canonicalPath)) {
+ if (isActive()) {
+ return remoteName
+ + canonical.substring(canonicalPath.length()).replace(File.
+ separatorChar, remoteSeparator);
+ }
+ }
+ } catch (IOException ex) {
+ return null;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Sets local directory for base of mapping.
+ *
+ * @param value value
+ */
+ public void setLocal(final File value) {
+ if (value == null) {
+ throw new NullPointerException("value");
+ }
+ if (value.exists() && !value.isDirectory()) {
+ throw new BuildException("local should be a directory");
+ }
+ localName = value;
+ try {
+ canonicalPath = localName.getCanonicalPath();
+ } catch (IOException ex) {
+ throw new BuildException(ex);
+ }
+ }
+
+ /**
+ * Sets remote name for directory.
+ * @param value remote name for directory
+ */
+ public void setRemote(final String value) {
+ remoteName = value;
+ }
+
+ /**
+ * Sets the separator character (/ or \) for the remote system.
+ * @param value separator character
+ */
+ public void setRemoteSeparator(final String value) {
+ if (value != null && value.length() != 1) {
+ throw new BuildException("remote separator must be a single character");
+ }
+ remoteSeparator = value.charAt(0);
+ }
+
+ /**
+ * Sets hosts for which this mapping is valid.
+ *
+ * @param value hosts
+ */
+ public void setHosts(final String value) {
+ hosts = value;
+ }
+
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/DistributerProtocolEnum.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/DistributerProtocolEnum.java
new file mode 100644
index 0000000000..5606d47a08
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/DistributerProtocolEnum.java
@@ -0,0 +1,50 @@
+/*
+ *
+ * Copyright 2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks;
+
+import org.apache.tools.ant.types.EnumeratedAttribute;
+
+/**
+ * Distributer prococol names (experimental).
+ *
+ * @author Curt Arnold
+ *
+ */
+public final class DistributerProtocolEnum
+ extends EnumeratedAttribute {
+ /**
+ * Constructor.
+ *
+ * Set by default to "distcc"
+ *
+ * @see java.lang.Object#Object()
+ */
+ public DistributerProtocolEnum() {
+ setValue("distcc");
+ }
+
+ /**
+ * Gets list of acceptable values.
+ *
+ * @see org.apache.tools.ant.types.EnumeratedAttribute#getValues()
+ */
+ public String[] getValues() {
+ return new String[] {
+ "distcc",
+ "ssh"};
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/FileVisitor.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/FileVisitor.java
new file mode 100644
index 0000000000..24aef25fb6
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/FileVisitor.java
@@ -0,0 +1,27 @@
+/*
+ *
+ * Copyright 2002-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks;
+import java.io.File;
+
+import org.apache.tools.ant.BuildException;
+/**
+ * An abstract class implemented to walk over the fileset members of a
+ * ProcessorDef
+ */
+public interface FileVisitor {
+ abstract void visit(File parentDir, String filename) throws BuildException;
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/LinkerDef.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/LinkerDef.java
new file mode 100644
index 0000000000..d997b2f992
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/LinkerDef.java
@@ -0,0 +1,549 @@
+/*
+ *
+ * Copyright 2002-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks;
+import java.io.File;
+import java.util.Enumeration;
+import java.util.Vector;
+
+import net.sf.antcontrib.cpptasks.compiler.CommandLineLinker;
+import net.sf.antcontrib.cpptasks.compiler.LinkType;
+import net.sf.antcontrib.cpptasks.compiler.Linker;
+import net.sf.antcontrib.cpptasks.compiler.Processor;
+import net.sf.antcontrib.cpptasks.compiler.ProcessorConfiguration;
+import net.sf.antcontrib.cpptasks.gcc.GccLinker;
+import net.sf.antcontrib.cpptasks.types.FlexLong;
+import net.sf.antcontrib.cpptasks.types.LibrarySet;
+import net.sf.antcontrib.cpptasks.types.LinkerArgument;
+import net.sf.antcontrib.cpptasks.types.SystemLibrarySet;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.types.FlexInteger;
+/**
+ * A linker definition. linker elements may be placed either as children of a
+ * cc element or the project element. A linker element with an id attribute may
+ * be referenced by linker elements with refid or extends attributes.
+ *
+ * @author Adam Murdoch
+ * @author Curt Arnold
+ */
+public class LinkerDef extends ProcessorDef {
+ private long base;
+ private String entry;
+ private Boolean fixed;
+ private Boolean incremental;
+ private final Vector librarySets = new Vector();
+ private Boolean map;
+ private int stack;
+ private final Vector sysLibrarySets = new Vector();
+ private final Vector versionInfos = new Vector();
+ private Boolean defaultflag = new Boolean(true);
+ /**
+ * Default constructor
+ *
+ * @see java.lang.Object#Object()
+ */
+ public LinkerDef() {
+ base = -1;
+ stack = -1;
+ }
+ private void addActiveLibrarySet(Project project, Vector libsets,
+ Vector srcSets) {
+ Enumeration srcenum = srcSets.elements();
+ while (srcenum.hasMoreElements()) {
+ LibrarySet set = (LibrarySet) srcenum.nextElement();
+ if (set.isActive(project)) {
+ libsets.addElement(set);
+ }
+ }
+ }
+ private void addActiveSystemLibrarySets(Project project, Vector libsets) {
+ addActiveLibrarySet(project, libsets, sysLibrarySets);
+ }
+ private void addActiveUserLibrarySets(Project project, Vector libsets) {
+ addActiveLibrarySet(project, libsets, librarySets);
+ }
+ /**
+ * Adds a linker command-line arg.
+ */
+ public void addConfiguredLinkerArg(LinkerArgument arg) {
+ addConfiguredProcessorArg(arg);
+ }
+ /**
+ * Adds a compiler command-line arg.
+ */
+ public void addConfiguredLinkerParam(LinkerParam param) {
+ if (isReference()) {
+ throw noChildrenAllowed();
+ }
+ addConfiguredProcessorParam(param);
+ }
+ /**
+ * Adds a system library set.
+ */
+ public void addLibset(LibrarySet libset) {
+ if (isReference()) {
+ throw super.noChildrenAllowed();
+ }
+ if (libset == null) {
+ throw new NullPointerException("libset");
+ }
+ librarySets.addElement(libset);
+ }
+ /**
+ * Adds a system library set.
+ */
+ public void addSyslibset(SystemLibrarySet libset) {
+ if (isReference()) {
+ throw super.noChildrenAllowed();
+ }
+ if (libset == null) {
+ throw new NullPointerException("libset");
+ }
+ sysLibrarySets.addElement(libset);
+ }
+
+ /**
+ * Adds desriptive version information to be included in the
+ * generated file. The first active version info block will
+ * be used.
+ */
+ public void addConfiguredVersioninfo(VersionInfo newVersionInfo) {
+ if (isReference()) {
+ throw noChildrenAllowed();
+ }
+ newVersionInfo.setProject(this.getProject());
+ versionInfos.addElement(newVersionInfo);
+ }
+
+ public ProcessorConfiguration createConfiguration(CCTask task,
+ LinkType linkType, ProcessorDef baseDef, TargetDef targetPlatform) {
+ //
+ // must combine some local context (the linkType)
+ // with the referenced element
+ //
+ // get a pointer to the definition (either local or referenced)
+ ProcessorDef thisDef = this;
+ if (isReference()) {
+ thisDef = ((ProcessorDef) getCheckedRef(ProcessorDef.class,
+ "ProcessorDef"));
+ }
+ //
+ // find the appropriate processor (combines local linkType
+ // with possibly remote linker name)
+ Processor proc = getProcessor();
+ proc = proc.getLinker(linkType);
+ ProcessorDef[] defaultProviders = getDefaultProviders(baseDef);
+ return proc.createConfiguration(task, linkType, defaultProviders,
+ thisDef, targetPlatform);
+ }
+ public void execute() throws org.apache.tools.ant.BuildException {
+ throw new org.apache.tools.ant.BuildException(
+ "Not an actual task, but looks like one for documentation purposes");
+ }
+ /**
+ * Returns an array of active library sets for this linker definition.
+ */
+ public LibrarySet[] getActiveLibrarySets(LinkerDef[] defaultProviders,
+ int index) {
+ if (isReference()) {
+ return ((LinkerDef) getCheckedRef(LinkerDef.class, "LinkerDef"))
+ .getActiveUserLibrarySets(defaultProviders, index);
+ }
+ Project p = getProject();
+ Vector libsets = new Vector();
+ for (int i = index; i < defaultProviders.length; i++) {
+ defaultProviders[i].addActiveUserLibrarySets(p, libsets);
+ defaultProviders[i].addActiveSystemLibrarySets(p, libsets);
+ }
+ addActiveUserLibrarySets(p, libsets);
+ addActiveSystemLibrarySets(p, libsets);
+ LibrarySet[] sets = new LibrarySet[libsets.size()];
+ libsets.copyInto(sets);
+ return sets;
+ }
+ /**
+ * Returns an array of active library sets for this linker definition.
+ */
+ public LibrarySet[] getActiveSystemLibrarySets(
+ LinkerDef[] defaultProviders, int index) {
+ if (isReference()) {
+ return ((LinkerDef) getCheckedRef(LinkerDef.class, "LinkerDef"))
+ .getActiveUserLibrarySets(defaultProviders, index);
+ }
+ Project p = getProject();
+ Vector libsets = new Vector();
+ for (int i = index; i < defaultProviders.length; i++) {
+ defaultProviders[i].addActiveSystemLibrarySets(p, libsets);
+ }
+ addActiveSystemLibrarySets(p, libsets);
+ LibrarySet[] sets = new LibrarySet[libsets.size()];
+ libsets.copyInto(sets);
+ return sets;
+ }
+ /**
+ * Returns an array of active library sets for this linker definition.
+ */
+ public LibrarySet[] getActiveUserLibrarySets(LinkerDef[] defaultProviders,
+ int index) {
+ if (isReference()) {
+ return ((LinkerDef) getCheckedRef(LinkerDef.class, "LinkerDef"))
+ .getActiveUserLibrarySets(defaultProviders, index);
+ }
+ Project p = getProject();
+ Vector libsets = new Vector();
+ for (int i = index; i < defaultProviders.length; i++) {
+ defaultProviders[i].addActiveUserLibrarySets(p, libsets);
+ }
+ addActiveUserLibrarySets(p, libsets);
+ LibrarySet[] sets = new LibrarySet[libsets.size()];
+ libsets.copyInto(sets);
+ return sets;
+ }
+ public long getBase(LinkerDef[] defaultProviders, int index) {
+ if (isReference()) {
+ return ((LinkerDef) getCheckedRef(LinkerDef.class, "LinkerDef"))
+ .getBase(defaultProviders, index);
+ }
+ if (base <= 0) {
+ if (defaultProviders != null && index < defaultProviders.length) {
+ return defaultProviders[index].getBase(defaultProviders,
+ index + 1);
+ }
+ }
+ return base;
+ }
+ public Boolean getFixed(LinkerDef[] defaultProviders, int index) {
+ if (isReference()) {
+ return ((LinkerDef) getCheckedRef(LinkerDef.class, "LinkerDef"))
+ .getFixed(defaultProviders, index);
+ }
+ if (fixed == null) {
+ if (defaultProviders != null && index < defaultProviders.length) {
+ return defaultProviders[index].getFixed(defaultProviders,
+ index + 1);
+ }
+ }
+ return fixed;
+ }
+ public boolean getIncremental(LinkerDef[] defaultProviders, int index) {
+ if (isReference()) {
+ return ((LinkerDef) getCheckedRef(LinkerDef.class, "LinkerDef"))
+ .getIncremental(defaultProviders, index);
+ }
+ if (incremental != null) {
+ return incremental.booleanValue();
+ }
+ if (defaultProviders != null && index < defaultProviders.length) {
+ return defaultProviders[index].getIncremental(defaultProviders, index + 1);
+ }
+ return false;
+ }
+ public boolean getMap(LinkerDef[] defaultProviders, int index) {
+ if (isReference()) {
+ return ((LinkerDef) getCheckedRef(LinkerDef.class, "LinkerDef"))
+ .getMap(defaultProviders, index);
+ }
+ if (map != null) {
+ return map.booleanValue();
+ }
+ if (defaultProviders != null && index < defaultProviders.length) {
+ return defaultProviders[index].getMap(defaultProviders, index + 1);
+ }
+ return false;
+ }
+ public final Boolean getDefaultflag(LinkerDef[] defaultProviders, int index) {
+ if (isReference()) {
+ return ((LinkerDef) getCheckedRef(LinkerDef.class,
+ "LinkerDef")).getDefaultflag(defaultProviders, index);
+ }
+ return defaultflag;
+ }
+ public String getEntry(LinkerDef[] defaultProviders, int index) {
+ if (isReference()) {
+ return ((LinkerDef) getCheckedRef(LinkerDef.class, "LinkerDef"))
+ .getEntry(defaultProviders, index);
+ }
+ if (entry != null) {
+ return entry;
+ }
+ if (defaultProviders != null && index < defaultProviders.length) {
+ return defaultProviders[index].getEntry(defaultProviders, index + 1);
+ }
+ return null;
+ }
+
+ public Processor getProcessor() {
+ Linker linker = (Linker) super.getProcessor();
+ if (linker == null) {
+ linker = GccLinker.getInstance();
+ }
+ if (getLibtool() && linker instanceof CommandLineLinker) {
+ CommandLineLinker cmdLineLinker = (CommandLineLinker) linker;
+ linker = cmdLineLinker.getLibtoolLinker();
+ }
+ return linker;
+ }
+ public int getStack(LinkerDef[] defaultProviders, int index) {
+ if (isReference()) {
+ return ((LinkerDef) getCheckedRef(LinkerDef.class, "LinkerDef"))
+ .getStack(defaultProviders, index);
+ }
+ if (stack < 0) {
+ if (defaultProviders != null && index < defaultProviders.length) {
+ return defaultProviders[index].getStack(defaultProviders,
+ index + 1);
+ }
+ }
+ return stack;
+ }
+ /**
+ * Sets the base address. May be specified in either decimal or hex.
+ *
+ * @param base
+ * base address
+ *
+ */
+ public void setBase(FlexLong base) {
+ if (isReference()) {
+ throw tooManyAttributes();
+ }
+ this.base = base.longValue();
+ }
+ /**
+ * Sets the starting address.
+ *
+ * @param name
+ * function name
+ */
+ public void setEntry(String entry) {
+ if (isReference()) {
+ throw tooManyAttributes();
+ }
+ this.entry = entry;
+ }
+ /**
+ * If true, marks the file to be loaded only at its preferred address.
+ */
+ public void setFixed(boolean fixed) {
+ if (isReference()) {
+ throw tooManyAttributes();
+ }
+ this.fixed = booleanValueOf(fixed);
+ }
+ /**
+ * If true, allows incremental linking.
+ *
+ */
+ public void setIncremental(boolean incremental) {
+ if (isReference()) {
+ throw tooManyAttributes();
+ }
+ this.incremental = booleanValueOf(incremental);
+ }
+ /**
+ * If set to true, a map file will be produced.
+ */
+ public void setMap(boolean map) {
+ if (isReference()) {
+ throw tooManyAttributes();
+ }
+ this.map = booleanValueOf(map);
+ }
+ /**
+ * Sets linker type.
+ *
+ *
+ *
Supported linkers
+ *
+ *
gcc
+ *
Gcc Linker
+ *
+ *
+ *
g++
+ *
G++ Linker
+ *
+ *
+ *
ld
+ *
Ld Linker
+ *
+ *
+ *
ar
+ *
Gcc Librarian
+ *
+ *
+ *
msvc
+ *
Microsoft Linker
+ *
+ *
+ *
bcc
+ *
Borland Linker
+ *
+ *
+ *
df
+ *
Compaq Visual Fortran Linker
+ *
+ *
+ *
icl
+ *
Intel Linker for Windows (IA-32)
+ *
+ *
+ *
ecl
+ *
Intel Linker for Windows (IA-64)
+ *
+ *
+ *
icc
+ *
Intel Linker for Linux (IA-32)
+ *
+ *
+ *
ecc
+ *
Intel Linker for Linux (IA-64)
+ *
+ *
+ *
CC
+ *
Sun ONE Linker
+ *
+ *
+ *
aCC
+ *
HP aC++ Linker
+ *
+ *
+ *
os390
+ *
OS390 Linker
+ *
+ *
+ *
os390batch
+ *
OS390 Linker
+ *
+ *
+ *
os400
+ *
IccLinker
+ *
+ *
+ *
sunc89
+ *
C89 Linker
+ *
+ *
+ *
xlC
+ *
VisualAge Linker
+ *
+ *
+ *
+ */
+ public void setName(LinkerEnum name) throws BuildException {
+ if (isReference()) {
+ throw tooManyAttributes();
+ }
+ Linker linker = name.getLinker();
+ super.setProcessor(linker);
+ }
+ protected void setProcessor(Processor proc) throws BuildException {
+ Linker linker = null;
+ if (proc instanceof Linker) {
+ linker = (Linker) proc;
+ } else {
+ LinkType linkType = new LinkType();
+ linker = proc.getLinker(linkType);
+ }
+ super.setProcessor(linker);
+ }
+ /**
+ * Sets stack size in bytes.
+ */
+ public void setStack(FlexInteger stack) {
+ if (isReference()) {
+ throw tooManyAttributes();
+ }
+ this.stack = stack.intValue();
+ }
+ public void visitSystemLibraries(Linker linker, FileVisitor libraryVisitor) {
+ Project p = getProject();
+ if (p == null) {
+ throw new java.lang.IllegalStateException("project must be set");
+ }
+ if (isReference()) {
+ LinkerDef master = ((LinkerDef) getCheckedRef(LinkerDef.class,
+ "Linker"));
+ master.visitSystemLibraries(linker, libraryVisitor);
+ } else {
+ //
+ // if this linker extends another,
+ // visit its libraries first
+ //
+ LinkerDef extendsDef = (LinkerDef) getExtends();
+ if (extendsDef != null) {
+ extendsDef.visitSystemLibraries(linker, libraryVisitor);
+ }
+ if (sysLibrarySets.size() > 0) {
+ File[] libpath = linker.getLibraryPath();
+ for (int i = 0; i < sysLibrarySets.size(); i++) {
+ LibrarySet set = (LibrarySet) sysLibrarySets.elementAt(i);
+ if (set.isActive(p)) {
+ set.visitLibraries(p, linker, libpath,
+ libraryVisitor);
+ }
+ }
+ }
+ }
+ }
+ public void visitUserLibraries(Linker linker, FileVisitor libraryVisitor) {
+ Project p = getProject();
+ if (p == null) {
+ throw new java.lang.IllegalStateException("project must be set");
+ }
+ if (isReference()) {
+ LinkerDef master = ((LinkerDef) getCheckedRef(LinkerDef.class,
+ "Linker"));
+ master.visitUserLibraries(linker, libraryVisitor);
+ } else {
+ //
+ // if this linker extends another,
+ // visit its libraries first
+ //
+ LinkerDef extendsDef = (LinkerDef) getExtends();
+ if (extendsDef != null) {
+ extendsDef.visitUserLibraries(linker, libraryVisitor);
+ }
+ //
+ // visit the user libraries
+ //
+ if (librarySets.size() > 0) {
+ File[] libpath = linker.getLibraryPath();
+ for (int i = 0; i < librarySets.size(); i++) {
+ LibrarySet set = (LibrarySet) librarySets.elementAt(i);
+ if (set.isActive(p)) {
+ set.visitLibraries(p, linker, libpath,
+ libraryVisitor);
+ }
+ }
+ }
+ }
+ }
+ /**
+ * Enables or disables default flags.
+ *
+ * @param defaultflag
+ * if true, default flags will add to command line.
+ *
+ */
+ public void setDefaultflag(boolean defaultflag) {
+ if (isReference()) {
+ throw tooManyAttributes();
+ }
+ this.defaultflag = booleanValueOf(defaultflag);
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/LinkerEnum.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/LinkerEnum.java
new file mode 100644
index 0000000000..cfe8984c23
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/LinkerEnum.java
@@ -0,0 +1,106 @@
+/*
+ *
+ * Copyright 2002-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks;
+import net.sf.antcontrib.cpptasks.arm.ADSLinker;
+import net.sf.antcontrib.cpptasks.borland.BorlandLinker;
+import net.sf.antcontrib.cpptasks.compaq.CompaqVisualFortranLinker;
+import net.sf.antcontrib.cpptasks.compiler.Linker;
+import net.sf.antcontrib.cpptasks.devstudio.DevStudioLinker;
+import net.sf.antcontrib.cpptasks.gcc.GccLibrarian;
+import net.sf.antcontrib.cpptasks.gcc.GccLinker;
+import net.sf.antcontrib.cpptasks.gcc.GppLinker;
+import net.sf.antcontrib.cpptasks.gcc.LdLinker;
+import net.sf.antcontrib.cpptasks.hp.aCCLinker;
+import net.sf.antcontrib.cpptasks.ibm.VisualAgeLinker;
+import net.sf.antcontrib.cpptasks.intel.IntelLinux32Linker;
+import net.sf.antcontrib.cpptasks.intel.IntelLinux64Linker;
+import net.sf.antcontrib.cpptasks.intel.IntelWin32Linker;
+import net.sf.antcontrib.cpptasks.os390.OS390Linker;
+import net.sf.antcontrib.cpptasks.os400.IccLinker;
+import net.sf.antcontrib.cpptasks.sun.C89Linker;
+import net.sf.antcontrib.cpptasks.sun.ForteCCLinker;
+import net.sf.antcontrib.cpptasks.ti.ClxxLinker;
+import org.apache.tools.ant.types.EnumeratedAttribute;
+/**
+ * Enumeration of supported linkers
+ *
+ * @author Curt Arnold
+ *
+ */
+public class LinkerEnum extends EnumeratedAttribute {
+ private final static ProcessorEnumValue[] linkers = new ProcessorEnumValue[]{
+ new ProcessorEnumValue("gcc", GccLinker.getInstance()),
+ new ProcessorEnumValue("g++", GppLinker.getInstance()),
+ new ProcessorEnumValue("ld", LdLinker.getInstance()),
+ new ProcessorEnumValue("ar", GccLibrarian.getInstance()),
+ new ProcessorEnumValue("msvc", DevStudioLinker.getInstance()),
+ new ProcessorEnumValue("bcc", BorlandLinker.getInstance()),
+ new ProcessorEnumValue("df", CompaqVisualFortranLinker
+ .getInstance()),
+ new ProcessorEnumValue("icl", IntelWin32Linker.getInstance()),
+ new ProcessorEnumValue("ecl", IntelWin32Linker.getInstance()),
+ new ProcessorEnumValue("icc", IntelLinux32Linker.getInstance()),
+ new ProcessorEnumValue("ecc", IntelLinux64Linker.getInstance()),
+ new ProcessorEnumValue("CC", ForteCCLinker.getInstance()),
+ new ProcessorEnumValue("aCC", aCCLinker.getInstance()),
+ new ProcessorEnumValue("os390", OS390Linker.getInstance()),
+ new ProcessorEnumValue("os390batch", OS390Linker
+ .getDataSetInstance()),
+ new ProcessorEnumValue("os400", IccLinker.getInstance()),
+ new ProcessorEnumValue("sunc89", C89Linker.getInstance()),
+ new ProcessorEnumValue("xlC", VisualAgeLinker.getInstance()),
+ new ProcessorEnumValue("cl6x", ClxxLinker.getCl6xInstance()),
+ new ProcessorEnumValue("cl55", ClxxLinker.getCl55Instance()),
+ new ProcessorEnumValue("armcc", ADSLinker.getInstance()),
+ new ProcessorEnumValue("armcpp", ADSLinker.getInstance()),
+ new ProcessorEnumValue("tcc", ADSLinker.getInstance()),
+ new ProcessorEnumValue("tcpp", ADSLinker.getInstance()),
+ // gcc cross compilers
+ new ProcessorEnumValue(
+ "sparc-sun-solaris2-gcc",
+ net.sf.antcontrib.cpptasks.gcc.cross.sparc_sun_solaris2.GccLinker
+ .getInstance()),
+ new ProcessorEnumValue(
+ "sparc-sun-solaris2-g++",
+ net.sf.antcontrib.cpptasks.gcc.cross.sparc_sun_solaris2.GppLinker
+ .getInstance()),
+ new ProcessorEnumValue(
+ "sparc-sun-solaris2-ld",
+ net.sf.antcontrib.cpptasks.gcc.cross.sparc_sun_solaris2.LdLinker
+ .getInstance()),
+ new ProcessorEnumValue(
+ "sparc-sun-solaris2-ar",
+ net.sf.antcontrib.cpptasks.gcc.cross.sparc_sun_solaris2.GccLibrarian
+ .getInstance()),
+ new ProcessorEnumValue("gcc-cross",
+ net.sf.antcontrib.cpptasks.gcc.cross.GccLinker
+ .getInstance()),
+ new ProcessorEnumValue("g++-cross",
+ net.sf.antcontrib.cpptasks.gcc.cross.GppLinker
+ .getInstance()),
+ new ProcessorEnumValue("ld-cross",
+ net.sf.antcontrib.cpptasks.gcc.cross.LdLinker.getInstance()),
+ new ProcessorEnumValue("ar-cross",
+ net.sf.antcontrib.cpptasks.gcc.cross.GccLibrarian
+ .getInstance()),};
+ public Linker getLinker() {
+ return (Linker) linkers[getIndex()].getProcessor();
+ }
+ public String[] getValues() {
+ return ProcessorEnumValue.getValues(linkers);
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/LinkerParam.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/LinkerParam.java
new file mode 100644
index 0000000000..383bae55c9
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/LinkerParam.java
@@ -0,0 +1,33 @@
+/*
+ *
+ * Copyright 2001-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks;
+/*******************************************************************************
+ * Place class description here.
+ *
+ * @author inger
+ * @author
+ *
+ * @since
+ ******************************************************************************/
+public class LinkerParam extends ProcessorParam {
+ public LinkerParam() {
+ }
+ public void execute() throws org.apache.tools.ant.BuildException {
+ throw new org.apache.tools.ant.BuildException(
+ "Not an actual task, but looks like one for documentation purposes");
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/OSFamilyEnum.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/OSFamilyEnum.java
new file mode 100644
index 0000000000..536d9922d3
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/OSFamilyEnum.java
@@ -0,0 +1,59 @@
+/*
+ *
+ * Copyright 2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks;
+
+import org.apache.tools.ant.types.EnumeratedAttribute;
+
+/**
+ * Enumeration of cpu types.
+ *
+ * @author Curt Arnold
+ *
+ */
+public final class OSFamilyEnum
+ extends EnumeratedAttribute {
+ /**
+ * Constructor.
+ *
+ * Set by default to "pentium3"
+ *
+ * @see java.lang.Object#Object()
+ */
+ public OSFamilyEnum() {
+ setValue("windows");
+ }
+
+ /**
+ * Gets list of acceptable values.
+ *
+ * @see org.apache.tools.ant.types.EnumeratedAttribute#getValues()
+ */
+ public String[] getValues() {
+ return new String[] {
+ "windows",
+ "dos",
+ "mac",
+ "unix",
+ "netware",
+ "os/2",
+ "tandem",
+ "win9x",
+ "z/os",
+ "os/400",
+ "openvms"};
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/ObjectFileCollector.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/ObjectFileCollector.java
new file mode 100644
index 0000000000..3e97fa40af
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/ObjectFileCollector.java
@@ -0,0 +1,42 @@
+/*
+ *
+ * Copyright 2001-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks;
+import java.io.File;
+import java.util.Vector;
+
+import net.sf.antcontrib.cpptasks.compiler.Linker;
+
+import org.apache.tools.ant.BuildException;
+/**
+ * Collects object files for the link step.
+ *
+ *
+ */
+public final class ObjectFileCollector implements FileVisitor {
+ private final Vector files;
+ private final Linker linker;
+ public ObjectFileCollector(Linker linker, Vector files) {
+ this.linker = linker;
+ this.files = files;
+ }
+ public void visit(File parentDir, String filename) throws BuildException {
+ int bid = linker.bid(filename);
+ if (bid >= 1) {
+ files.addElement(new File(parentDir, filename));
+ }
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/OptimizationEnum.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/OptimizationEnum.java
new file mode 100644
index 0000000000..4a0d17953e
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/OptimizationEnum.java
@@ -0,0 +1,82 @@
+/*
+ *
+ * Copyright 2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks;
+
+import org.apache.tools.ant.types.EnumeratedAttribute;
+
+/**
+ * Enumeration of optimization levels (experimental).
+ *
+ * @author Curt Arnold
+ *
+ */
+public final class OptimizationEnum
+ extends EnumeratedAttribute {
+ /**
+ * Constructor.
+ *
+ * Set by default to "speed"
+ *
+ * @see java.lang.Object#Object()
+ */
+ public OptimizationEnum() {
+ setValue("speed");
+ }
+
+ /**
+ * Gets list of acceptable values.
+ *
+ * @see org.apache.tools.ant.types.EnumeratedAttribute#getValues()
+ */
+ public String[] getValues() {
+ return new String[] {
+ "none",
+ "size",
+ "minimal",
+ "speed",
+ "full",
+ "aggressive",
+ "extreme",
+ "unsafe"
+ };
+ }
+
+ /**
+ * Is size optimized.
+ * @return boolean true if size is optimized.
+ */
+ public boolean isSize() {
+ return "speed".equals(getValue());
+ }
+
+ /**
+ * Is speed optimized.
+ * @return boolean true if speed is optimized.
+ */
+ public boolean isSpeed() {
+ return !isSize() && !isNoOptimization();
+ }
+
+ /**
+ * Is no optimization performed.
+ * @return boolean true if no optimization is performed.
+ */
+ public boolean isNoOptimization() {
+ return "none".equals(getValue());
+ }
+
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/OutputTypeEnum.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/OutputTypeEnum.java
new file mode 100644
index 0000000000..fb37843fbc
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/OutputTypeEnum.java
@@ -0,0 +1,48 @@
+/*
+ *
+ * Copyright 2002-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks;
+import org.apache.tools.ant.types.EnumeratedAttribute;
+/**
+ * Enumeration of supported subsystems
+ *
+ * @author Curt Arnold
+ *
+ */
+public class OutputTypeEnum extends EnumeratedAttribute {
+ /**
+ * Constructor
+ *
+ * Set by default to "executable"
+ *
+ * @see java.lang.Object#Object()
+ */
+ public OutputTypeEnum() {
+ setValue("executable");
+ }
+ /**
+ * Gets list of acceptable values
+ *
+ * @see org.apache.tools.ant.types.EnumeratedAttribute#getValues()
+ */
+ public String[] getValues() {
+ return new String[]{"executable", // executable program
+ "plugin", // plugin module
+ "shared", // dynamically linkable module
+ "static" // convenience library
+ };
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/PrecompileDef.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/PrecompileDef.java
new file mode 100644
index 0000000000..828e2c2f48
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/PrecompileDef.java
@@ -0,0 +1,215 @@
+/*
+ *
+ * Copyright 2002-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks;
+import java.io.File;
+import java.util.Enumeration;
+import java.util.Vector;
+
+import net.sf.antcontrib.cpptasks.types.ConditionalFileSet;
+
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.DirectoryScanner;
+import org.apache.tools.ant.types.DataType;
+/**
+ * An element that specifies a prototype file and rules for source files that
+ * should not use precompiled headers
+ *
+ * @author Curt Arnold
+ */
+public final class PrecompileDef extends DataType {
+ private final Vector exceptSets = new Vector();
+ private String ifCond;
+ /**
+ * Directory of prototype file
+ */
+ private File prototype = new File("stdafx.cpp");
+ private String unlessCond;
+ /**
+ * Constructor
+ *
+ */
+ public PrecompileDef() {
+ }
+ /**
+ * Method used by PrecompileExceptDef to add exception set to
+ * PrecompileDef.
+ */
+ public void appendExceptFileSet(ConditionalFileSet exceptSet) {
+ exceptSet.setProject(getProject());
+ exceptSets.addElement(exceptSet);
+ }
+ /**
+ * Adds filesets that specify files that should not be processed with
+ * precompiled headers enabled.
+ *
+ * @param exceptSet
+ * FileSet specify files that should not be processed with
+ * precompiled headers enabled.
+ */
+ public PrecompileExceptDef createExcept() {
+ return new PrecompileExceptDef(this);
+ }
+ public void execute() throws org.apache.tools.ant.BuildException {
+ throw new org.apache.tools.ant.BuildException(
+ "Not an actual task, but looks like one for documentation purposes");
+ }
+ public String[] getExceptFiles() {
+ PrecompileDef ref = getRef();
+ if (ref != null) {
+ return ref.getExceptFiles();
+ }
+ if (exceptSets.size() == 0) {
+ return new String[0];
+ }
+ Project p = getProject();
+ String[] exceptFiles = null;
+ Enumeration setEnum = exceptSets.elements();
+ while (setEnum.hasMoreElements()) {
+ ConditionalFileSet exceptSet = (ConditionalFileSet) setEnum
+ .nextElement();
+ if (exceptSet.isActive()) {
+ DirectoryScanner scanner = exceptSet
+ .getDirectoryScanner(p);
+ String[] scannerFiles = scanner.getIncludedFiles();
+ if (exceptFiles == null) {
+ exceptFiles = scannerFiles;
+ } else {
+ if (scannerFiles.length > 0) {
+ String[] newFiles = new String[exceptFiles.length
+ + scannerFiles.length];
+ for (int i = 0; i < exceptFiles.length; i++) {
+ newFiles[i] = exceptFiles[i];
+ }
+ int index = exceptFiles.length;
+ for (int i = 0; i < scannerFiles.length; i++) {
+ newFiles[index++] = scannerFiles[i];
+ }
+ exceptFiles = newFiles;
+ }
+ }
+ }
+ }
+ if (exceptFiles == null) {
+ exceptFiles = new String[0];
+ }
+ return exceptFiles;
+ }
+ /**
+ * Gets prototype source file
+ *
+ */
+ public File getPrototype() {
+ PrecompileDef ref = getRef();
+ if (ref != null) {
+ return ref.getPrototype();
+ }
+ return prototype;
+ }
+ private PrecompileDef getRef() {
+ if (isReference()) {
+ return ((PrecompileDef) getCheckedRef(PrecompileDef.class,
+ "PrecompileDef"));
+ }
+ return null;
+ }
+ public boolean isActive() {
+ boolean isActive = CUtil.isActive(getProject(), ifCond, unlessCond);
+ if (!isActive) {
+ PrecompileDef ref = getRef();
+ if (ref != null) {
+ return ref.isActive();
+ }
+ }
+ return isActive;
+ }
+ /**
+ * Sets a description of the current data type.
+ */
+ public void setDescription(String desc) {
+ super.setDescription(desc);
+ }
+ /**
+ * Sets an id that can be used to reference this element.
+ *
+ * @param id
+ * id
+ */
+ public void setId(String id) {
+ //
+ // this is actually accomplished by a different
+ // mechanism, but we can document it
+ //
+ }
+ /**
+ * Set the 'if' condition.
+ *
+ * The processor will be ignored unless the property is defined.
+ *
+ * The value of property is insignificant, but values that would imply
+ * misinterpretation ("false", "no") will throw an exception when
+ * isActive() is evaluated.
+ *
+ * @param propName
+ * name of property
+ */
+ public void setIf(String propName) {
+ ifCond = propName;
+ }
+ /**
+ * Sets file to precompile.
+ *
+ * Should be a source file that includes only one unguarded header file.
+ * Default value is "stdafx.cpp".
+ *
+ * @param prototype
+ * file path for prototype source file
+ */
+ public void setPrototype(File prototype) {
+ if (isReference()) {
+ throw tooManyAttributes();
+ }
+ if (prototype == null) {
+ throw new NullPointerException("prototype");
+ }
+ this.prototype = prototype;
+ }
+ /**
+ * Specifies that this element should behave as if the content of the
+ * element with the matching id attribute was inserted at this location.
+ *
+ * @param ref
+ * Reference to other element
+ *
+ */
+ public void setRefid(org.apache.tools.ant.types.Reference ref) {
+ super.setRefid(ref);
+ }
+ /**
+ * Set the 'unless' condition. If named property exists at execution time,
+ * the processor will be ignored.
+ *
+ * Value of property is insignificant, but values that would imply
+ * misinterpretation ("false", "no") of the behavior will throw an
+ * exception when isActive is called.
+ *
+ * @param propName
+ * name of property
+ */
+ public void setUnless(String propName) {
+ unlessCond = propName;
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/PrecompileExceptDef.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/PrecompileExceptDef.java
new file mode 100644
index 0000000000..d6cdd6025f
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/PrecompileExceptDef.java
@@ -0,0 +1,80 @@
+/*
+ *
+ * Copyright 2002-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks;
+import java.io.File;
+
+import net.sf.antcontrib.cpptasks.types.ConditionalFileSet;
+
+import org.apache.tools.ant.BuildException;
+/**
+ * Specifies files that should not be compiled using precompiled headers.
+ *
+ * @author Curt Arnold
+ */
+public final class PrecompileExceptDef {
+ private ConditionalFileSet localSet = null;
+ /**
+ * Collection of contained by definition
+ */
+ private PrecompileDef owner;
+ /**
+ * Constructor
+ *
+ */
+ public PrecompileExceptDef(PrecompileDef owner) {
+ this.owner = owner;
+ }
+ /**
+ * Adds filesets that specify files that should not be processed using
+ * precompiled headers.
+ *
+ * @param exceptSet
+ * FileSet specify files that should not be processed with
+ * precompiled headers enabled.
+ */
+ public void addFileset(ConditionalFileSet exceptSet) {
+ owner.appendExceptFileSet(exceptSet);
+ }
+ public void execute() throws org.apache.tools.ant.BuildException {
+ throw new org.apache.tools.ant.BuildException(
+ "Not an actual task, but looks like one for documentation purposes");
+ }
+ /**
+ * Sets the base-directory
+ */
+ public void setDir(File dir) throws BuildException {
+ if (localSet == null) {
+ localSet = new ConditionalFileSet();
+ owner.appendExceptFileSet(localSet);
+ }
+ localSet.setDir(dir);
+ }
+ /**
+ * Comma or space separated list of file patterns that should not be
+ * compiled using precompiled headers.
+ *
+ * @param includes
+ * the string containing the include patterns
+ */
+ public void setIncludes(String includes) {
+ if (localSet == null) {
+ localSet = new ConditionalFileSet();
+ owner.appendExceptFileSet(localSet);
+ }
+ localSet.setIncludes(includes);
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/ProcessorDef.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/ProcessorDef.java
new file mode 100644
index 0000000000..38faf427e7
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/ProcessorDef.java
@@ -0,0 +1,714 @@
+/*
+ *
+ * Copyright 2002-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.lang.reflect.Method;
+import java.util.Vector;
+import net.sf.antcontrib.cpptasks.compiler.LinkType;
+import net.sf.antcontrib.cpptasks.compiler.Processor;
+import net.sf.antcontrib.cpptasks.compiler.ProcessorConfiguration;
+import net.sf.antcontrib.cpptasks.types.CommandLineArgument;
+import net.sf.antcontrib.cpptasks.types.ConditionalFileSet;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.DirectoryScanner;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.types.DataType;
+import org.apache.tools.ant.types.Environment;
+import org.apache.tools.ant.types.Reference;
+/**
+ * An abstract compiler/linker definition.
+ *
+ * @author Curt Arnold
+ */
+public abstract class ProcessorDef extends DataType {
+ /**
+ * Returns the equivalent Boolean object for the specified value
+ *
+ * Equivalent to Boolean.valueOf in JDK 1.4
+ *
+ * @param val
+ * boolean value
+ * @return Boolean.TRUE or Boolean.FALSE
+ */
+ protected static Boolean booleanValueOf(boolean val) {
+ if (val) {
+ return Boolean.TRUE;
+ }
+ return Boolean.FALSE;
+ }
+ /**
+ * if true, targets will be built for debugging
+ */
+ private Boolean debug;
+ private Environment env = null;
+ /**
+ * Reference for "extends" processor definition
+ */
+ private Reference extendsRef = null;
+ /**
+ * Name of property that must be present or definition will be ignored. May
+ * be null.
+ */
+ private String ifProp;
+ /**
+ * if true, processor definition inherits values from containing
+ * element
+ */
+ private boolean inherit;
+ private Boolean libtool = null;
+ protected boolean newEnvironment = false;
+ /**
+ * Processor.
+ */
+ private Processor processor;
+ /**
+ * Collection of or contained by definition
+ */
+ private final Vector processorArgs = new Vector();
+ /**
+ * Collection of or contained by definition
+ */
+ private final Vector processorParams = new Vector();
+ /**
+ * if true, all targets will be unconditionally rebuilt
+ */
+ private Boolean rebuild;
+ /**
+ * Collection of contained by definition
+ */
+ private final Vector srcSets = new Vector();
+ /**
+ * Name of property that if present will cause definition to be ignored.
+ * May be null.
+ */
+ private String unlessProp;
+ /**
+ * Constructor
+ *
+ */
+ protected ProcessorDef() throws NullPointerException {
+ inherit = true;
+ }
+ /**
+ * Adds a or
+ *
+ * @param arg
+ * command line argument, must not be null
+ * @throws NullPointerException
+ * if arg is null
+ * @throws BuildException
+ * if this definition is a reference
+ */
+ protected void addConfiguredProcessorArg(CommandLineArgument arg)
+ throws NullPointerException, BuildException {
+ if (arg == null) {
+ throw new NullPointerException("arg");
+ }
+ if (isReference()) {
+ throw noChildrenAllowed();
+ }
+ if(arg.getFile() == null ) {
+ processorArgs.addElement(arg);
+ }
+ else {
+ loadFile(arg.getFile());
+ }
+ }
+ /**
+ * Add a or if specify the file attribute
+ *
+ * @param arg
+ * command line argument, must not be null
+ * @throws BuildException
+ * if the specify file not exist
+ */
+ protected void loadFile(File file)
+ throws BuildException {
+ FileReader fileReader;
+ BufferedReader in;
+ String str;
+ if (! file.exists()){
+ throw new BuildException("The file " + file + " is not existed");
+ }
+ try {
+ fileReader = new FileReader(file);
+ in = new BufferedReader(fileReader);
+ while ( (str = in.readLine()) != null ){
+ if(str.trim() == ""){
+ continue ;
+ }
+ str = getProject().replaceProperties(str);
+ CommandLineArgument newarg = new CommandLineArgument();
+ newarg.setValue(str.trim());
+ processorArgs.addElement(newarg);
+ }
+ }
+ catch(Exception e){
+ throw new BuildException(e.getMessage());
+ }
+ }
+ /**
+ * Adds a or
+ *
+ * @param arg
+ * command line argument, must not be null
+ * @throws NullPointerException
+ * if arg is null
+ * @throws BuildException
+ * if this definition is a reference
+ */
+ protected void addConfiguredProcessorParam(ProcessorParam param)
+ throws NullPointerException, BuildException {
+ if (param == null) {
+ throw new NullPointerException("param");
+ }
+ if (isReference()) {
+ throw noChildrenAllowed();
+ }
+ processorParams.addElement(param);
+ }
+ /**
+ * Add an environment variable to the launched process.
+ */
+ public void addEnv(Environment.Variable var) {
+ if (env == null) {
+ env = new Environment();
+ }
+ env.addVariable(var);
+ }
+ /**
+ * Adds a source file set.
+ *
+ * Files in these set will be processed by this configuration and will not
+ * participate in the auction.
+ *
+ * @param srcSet
+ * Fileset identifying files that should be processed by this
+ * processor
+ * @throws BuildException
+ * if processor definition is a reference
+ */
+ public void addFileset(ConditionalFileSet srcSet) throws BuildException {
+ if (isReference()) {
+ throw noChildrenAllowed();
+ }
+ srcSet.setProject(getProject());
+ srcSets.addElement(srcSet);
+ }
+ /**
+ * Creates a configuration
+ *
+ * @param baseDef
+ * reference to def from containing element, may be null
+ * @return configuration
+ *
+ */
+ public ProcessorConfiguration createConfiguration(CCTask task,
+ LinkType linkType, ProcessorDef baseDef, TargetDef targetPlatform) {
+ if (isReference()) {
+ return ((ProcessorDef) getCheckedRef(ProcessorDef.class,
+ "ProcessorDef")).createConfiguration(task, linkType,
+ baseDef, targetPlatform);
+ }
+ ProcessorDef[] defaultProviders = getDefaultProviders(baseDef);
+ Processor proc = getProcessor();
+ return proc.createConfiguration(task, linkType, defaultProviders, this, targetPlatform);
+ }
+ /**
+ * Prepares list of processor arguments ( , ) that
+ * are active for the current project settings.
+ *
+ * @return active compiler arguments
+ */
+ public CommandLineArgument[] getActiveProcessorArgs() {
+ Project p = getProject();
+ if (p == null) {
+ throw new java.lang.IllegalStateException("project must be set");
+ }
+ if (isReference()) {
+ return ((ProcessorDef) getCheckedRef(ProcessorDef.class,
+ "ProcessorDef")).getActiveProcessorArgs();
+ }
+ Vector activeArgs = new Vector(processorArgs.size());
+ for (int i = 0; i < processorArgs.size(); i++) {
+ CommandLineArgument arg = (CommandLineArgument) processorArgs
+ .elementAt(i);
+ if (arg.isActive(p)) {
+ activeArgs.addElement(arg);
+ }
+ }
+ CommandLineArgument[] array = new CommandLineArgument[activeArgs.size()];
+ activeArgs.copyInto(array);
+ return array;
+ }
+ /**
+ * Prepares list of processor arguments ( , ) that
+ * are active for the current project settings.
+ *
+ * @return active compiler arguments
+ */
+ public ProcessorParam[] getActiveProcessorParams() {
+ Project p = getProject();
+ if (p == null) {
+ throw new java.lang.IllegalStateException("project must be set");
+ }
+ if (isReference()) {
+ return ((ProcessorDef) getCheckedRef(ProcessorDef.class,
+ "ProcessorDef")).getActiveProcessorParams();
+ }
+ Vector activeParams = new Vector(processorParams.size());
+ for (int i = 0; i < processorParams.size(); i++) {
+ ProcessorParam param = (ProcessorParam) processorParams
+ .elementAt(i);
+ if (param.isActive(p)) {
+ activeParams.addElement(param);
+ }
+ }
+ ProcessorParam[] array = new ProcessorParam[activeParams.size()];
+ activeParams.copyInto(array);
+ return array;
+ }
+ /**
+ * Gets boolean indicating debug build
+ *
+ * @param defaultProviders
+ * array of ProcessorDef's in descending priority
+ * @param index
+ * index to first element in array that should be considered
+ * @return if true, built targets for debugging
+ */
+ public boolean getDebug(ProcessorDef[] defaultProviders, int index) {
+ if (isReference()) {
+ return ((ProcessorDef) getCheckedRef(ProcessorDef.class,
+ "ProcessorDef")).getDebug(defaultProviders, index);
+ }
+ if (debug != null) {
+ return debug.booleanValue();
+ } else {
+ if (defaultProviders != null && index < defaultProviders.length) {
+ return defaultProviders[index].getDebug(defaultProviders,
+ index + 1);
+ }
+ }
+ return false;
+ }
+ /**
+ * Creates an chain of objects which provide default values in descending
+ * order of significance.
+ *
+ * @param baseDef
+ * corresponding ProcessorDef from CCTask, will be last element
+ * in array unless inherit = false
+ * @return default provider array
+ *
+ */
+ protected final ProcessorDef[] getDefaultProviders(ProcessorDef baseDef) {
+ ProcessorDef extendsDef = getExtends();
+ Vector chain = new Vector();
+ while (extendsDef != null && !chain.contains(extendsDef)) {
+ chain.addElement(extendsDef);
+ extendsDef = extendsDef.getExtends();
+ }
+ if (baseDef != null && getInherit()) {
+ chain.addElement(baseDef);
+ }
+ ProcessorDef[] defaultProviders = new ProcessorDef[chain.size()];
+ chain.copyInto(defaultProviders);
+ return defaultProviders;
+ }
+ /**
+ * Gets the ProcessorDef specified by the extends attribute
+ *
+ * @return Base ProcessorDef, null if extends is not specified
+ * @throws BuildException
+ * if reference is not same type object
+ */
+ public ProcessorDef getExtends() throws BuildException {
+ if (extendsRef != null) {
+ Object obj = extendsRef.getReferencedObject(getProject());
+ if (!getClass().isInstance(obj)) {
+ throw new BuildException("Referenced object "
+ + extendsRef.getRefId() + " not correct type, is "
+ + obj.getClass().getName() + " should be "
+ + getClass().getName());
+ }
+ return (ProcessorDef) obj;
+ }
+ return null;
+ }
+ /**
+ * Gets the inherit attribute. If the inherit value is true, this processor
+ * definition will inherit default values from the containing element.
+ *
+ * @return if true then properties from the containing element are
+ * used.
+ */
+ public final boolean getInherit() {
+ return inherit;
+ }
+ public boolean getLibtool() {
+ if (libtool != null) {
+ return libtool.booleanValue();
+ }
+ if (isReference()) {
+ return ((ProcessorDef) getCheckedRef(ProcessorDef.class,
+ "ProcessorDef")).getLibtool();
+ }
+ ProcessorDef extendsDef = getExtends();
+ if (extendsDef != null) {
+ return extendsDef.getLibtool();
+ }
+ return false;
+ }
+ /**
+ * Obtains the appropriate processor (compiler, linker)
+ *
+ * @return processor
+ */
+ protected Processor getProcessor() {
+ if (isReference()) {
+ return ((ProcessorDef) getCheckedRef(ProcessorDef.class,
+ "ProcessorDef")).getProcessor();
+ }
+ //
+ // if a processor has not been explicitly set
+ // then may be set by an extended definition
+ if (processor == null) {
+ ProcessorDef extendsDef = getExtends();
+ if (extendsDef != null) {
+ return extendsDef.getProcessor();
+ }
+ }
+ return processor;
+ }
+ /**
+ * Gets a boolean value indicating whether all targets must be rebuilt
+ * regardless of dependency analysis.
+ *
+ * @param defaultProviders
+ * array of ProcessorDef's in descending priority
+ * @param index
+ * index to first element in array that should be considered
+ * @return true if all targets should be rebuilt.
+ */
+ public boolean getRebuild(ProcessorDef[] defaultProviders, int index) {
+ if (isReference()) {
+ return ((ProcessorDef) getCheckedRef(ProcessorDef.class,
+ "ProcessorDef")).getRebuild(defaultProviders, index);
+ }
+ if (rebuild != null) {
+ return rebuild.booleanValue();
+ } else {
+ if (defaultProviders != null && index < defaultProviders.length) {
+ return defaultProviders[index].getRebuild(defaultProviders,
+ index + 1);
+ }
+ }
+ return false;
+ }
+ /**
+ * Returns true if the processor definition contains embedded file set
+ * definitions
+ *
+ * @return true if processor definition contains embedded filesets
+ */
+ public boolean hasFileSets() {
+ if (isReference()) {
+ return ((ProcessorDef) getCheckedRef(ProcessorDef.class,
+ "ProcessorDef")).hasFileSets();
+ }
+ return srcSets.size() > 0;
+ }
+ /**
+ * Determine if this def should be used.
+ *
+ * Definition will be active if the "if" variable (if specified) is set and
+ * the "unless" variable (if specified) is not set and that all reference
+ * or extended definitions are active
+ *
+ * @return true if processor is active
+ * @throws IllegalStateException
+ * if not properly initialized
+ * @throws BuildException
+ * if "if" or "unless" variable contains suspicious values
+ * "false" or "no" which indicates possible confusion
+ */
+ public boolean isActive() throws BuildException, IllegalStateException {
+ Project project = getProject();
+ if (!CUtil.isActive(project, ifProp, unlessProp)) {
+ return false;
+ }
+ if (isReference()) {
+ if (!((ProcessorDef) getCheckedRef(ProcessorDef.class,
+ "ProcessorDef")).isActive()) {
+ return false;
+ }
+ }
+ //
+ // walk through any extended definitions
+ //
+ ProcessorDef[] defaultProviders = getDefaultProviders(null);
+ for (int i = 0; i < defaultProviders.length; i++) {
+ if (!defaultProviders[i].isActive()) {
+ return false;
+ }
+ }
+ return true;
+ }
+ /**
+ * Sets the class name for the adapter. Use the "name" attribute when the
+ * tool is supported.
+ *
+ * @param className
+ * full class name
+ *
+ */
+ public void setClassname(String className) throws BuildException {
+ Object proc = null;
+ try {
+ Class implClass = ProcessorDef.class.getClassLoader().loadClass(
+ className);
+ try {
+ Method getInstance = implClass.getMethod("getInstance",
+ new Class[0]);
+ proc = getInstance.invoke(null, new Object[0]);
+ } catch (Exception ex) {
+ proc = implClass.newInstance();
+ }
+ } catch (Exception ex) {
+ throw new BuildException(ex);
+ }
+ setProcessor((Processor) proc);
+ }
+ /**
+ * If set true, all targets will be built for debugging.
+ *
+ * @param debug
+ * true if targets should be built for debugging
+ * @throws BuildException
+ * if processor definition is a reference
+ */
+ public void setDebug(boolean debug) throws BuildException {
+ if (isReference()) {
+ throw tooManyAttributes();
+ }
+ this.debug = booleanValueOf(debug);
+ }
+ /**
+ * Sets a description of the current data type.
+ */
+ public void setDescription(String desc) {
+ super.setDescription(desc);
+ }
+ /**
+ * Specifies that this element extends the element with id attribute with a
+ * matching value. The configuration will be constructed from the settings
+ * of this element, element referenced by extends, and the containing cc
+ * element.
+ *
+ * @param extendsRef
+ * Reference to the extended processor definition.
+ * @throws BuildException
+ * if this processor definition is a reference
+ */
+ public void setExtends(Reference extendsRef) throws BuildException {
+ if (isReference()) {
+ throw tooManyAttributes();
+ }
+ this.extendsRef = extendsRef;
+ }
+ /**
+ * Sets an id that can be used to reference this element.
+ *
+ * @param id
+ * id
+ */
+ public void setId(String id) {
+ //
+ // this is actually accomplished by a different
+ // mechanism, but we can document it
+ //
+ }
+ /**
+ * Sets the property name for the 'if' condition.
+ *
+ * The configuration will be ignored unless the property is defined.
+ *
+ * The value of the property is insignificant, but values that would imply
+ * misinterpretation ("false", "no") will throw an exception when
+ * evaluated.
+ *
+ * @param propName
+ * name of property
+ */
+ public void setIf(String propName) {
+ ifProp = propName;
+ }
+ /**
+ * If inherit has the default value of true, defines, includes and other
+ * settings from the containing element will be inherited.
+ *
+ * @param inherit
+ * new value
+ * @throws BuildException
+ * if processor definition is a reference
+ */
+ public void setInherit(boolean inherit) throws BuildException {
+ if (isReference()) {
+ throw super.tooManyAttributes();
+ }
+ this.inherit = inherit;
+ }
+ /**
+ * Set use of libtool.
+ *
+ * If set to true, the "libtool " will be prepended to the command line
+ *
+ * @param libtool
+ * If true, use libtool.
+ */
+ public void setLibtool(boolean libtool) {
+ if (isReference()) {
+ throw tooManyAttributes();
+ }
+ this.libtool = booleanValueOf(libtool);
+ }
+ /**
+ * Do not propagate old environment when new environment variables are
+ * specified.
+ */
+ public void setNewenvironment(boolean newenv) {
+ newEnvironment = newenv;
+ }
+ /**
+ * Sets the processor
+ *
+ * @param processor
+ * processor, may not be null.
+ * @throws BuildException
+ * if ProcessorDef is a reference
+ * @throws NullPointerException
+ * if processor is null
+ */
+ protected void setProcessor(Processor processor) throws BuildException,
+ NullPointerException {
+ if (processor == null) {
+ throw new NullPointerException("processor");
+ }
+ if (isReference()) {
+ throw super.tooManyAttributes();
+ }
+ if (env == null && !newEnvironment) {
+ this.processor = processor;
+ } else {
+ this.processor = processor.changeEnvironment(newEnvironment, env);
+ }
+ }
+ /**
+ * If set true, all targets will be unconditionally rebuilt.
+ *
+ * @param rebuild
+ * if true, rebuild all targets.
+ * @throws BuildException
+ * if processor definition is a reference
+ */
+ public void setRebuild(boolean rebuild) throws BuildException {
+ if (isReference()) {
+ throw tooManyAttributes();
+ }
+ this.rebuild = booleanValueOf(rebuild);
+ }
+ /**
+ * Specifies that this element should behave as if the content of the
+ * element with the matching id attribute was inserted at this location. If
+ * specified, no other attributes or child content should be specified,
+ * other than "if", "unless" and "description".
+ *
+ * @param ref
+ * Reference to other element
+ *
+ */
+ public void setRefid(org.apache.tools.ant.types.Reference ref) {
+ super.setRefid(ref);
+ }
+ /**
+ * Set the property name for the 'unless' condition.
+ *
+ * If named property is set, the configuration will be ignored.
+ *
+ * The value of the property is insignificant, but values that would imply
+ * misinterpretation ("false", "no") of the behavior will throw an
+ * exception when evaluated.
+ *
+ * @param propName
+ * name of property
+ */
+ public void setUnless(String propName) {
+ unlessProp = propName;
+ }
+ /**
+ * This method calls the FileVistor's visit function for every file in the
+ * processors definition
+ *
+ * @param visitor
+ * object whose visit method is called for every file
+ */
+ public void visitFiles(FileVisitor visitor) {
+ Project p = getProject();
+ if (p == null) {
+ throw new java.lang.IllegalStateException(
+ "project must be set before this call");
+ }
+ if (isReference()) {
+ ((ProcessorDef) getCheckedRef(ProcessorDef.class, "ProcessorDef"))
+ .visitFiles(visitor);
+ }
+ //
+ // if this processor extends another,
+ // visit its files first
+ //
+ ProcessorDef extendsDef = getExtends();
+ if (extendsDef != null) {
+ extendsDef.visitFiles(visitor);
+ }
+ for (int i = 0; i < srcSets.size(); i++) {
+ ConditionalFileSet srcSet = (ConditionalFileSet) srcSets
+ .elementAt(i);
+ if (srcSet.isActive()) {
+ // Find matching source files
+ DirectoryScanner scanner = srcSet.getDirectoryScanner(p);
+ // Check each source file - see if it needs compilation
+ String[] fileNames = scanner.getIncludedFiles();
+ File parentDir = scanner.getBasedir();
+ for (int j = 0; j < fileNames.length; j++) {
+ String currentFile = fileNames[j];
+ visitor.visit(parentDir, currentFile);
+ }
+ }
+ }
+ }
+ public Vector getSrcSets() {
+ if (isReference()) {
+ return ((ProcessorDef) getCheckedRef(ProcessorDef.class,
+ "ProcessorDef")).getSrcSets();
+ }
+ return srcSets;
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/ProcessorEnumValue.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/ProcessorEnumValue.java
new file mode 100644
index 0000000000..d028052232
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/ProcessorEnumValue.java
@@ -0,0 +1,47 @@
+/*
+ *
+ * Copyright 2002-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks;
+import net.sf.antcontrib.cpptasks.compiler.Processor;
+/**
+ * One entry in the arrays used by the CompilerEnum and LinkerEnum classes.
+ *
+ * @author Curt Arnold
+ * @see CompilerEnum
+ * @see LinkerEnum
+ *
+ */
+public class ProcessorEnumValue {
+ public static String[] getValues(ProcessorEnumValue[] processors) {
+ String[] values = new String[processors.length];
+ for (int i = 0; i < processors.length; i++) {
+ values[i] = processors[i].getName();
+ }
+ return values;
+ }
+ private String name;
+ private Processor processor;
+ public ProcessorEnumValue(String name, Processor processor) {
+ this.name = name;
+ this.processor = processor;
+ }
+ public String getName() {
+ return name;
+ }
+ public Processor getProcessor() {
+ return processor;
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/ProcessorParam.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/ProcessorParam.java
new file mode 100644
index 0000000000..b2d47962ed
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/ProcessorParam.java
@@ -0,0 +1,100 @@
+/*
+ *
+ * Copyright 2001-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks;
+/*******************************************************************************
+ * Place class description here.
+ *
+ * @author inger
+ * @author
+ *
+ * @since
+ ******************************************************************************/
+public class ProcessorParam {
+ private String ifCond;
+ private String name;
+ private String unlessCond;
+ private String value;
+ public ProcessorParam() {
+ }
+ public String getName() {
+ return name;
+ }
+ public String getValue() {
+ return value;
+ }
+ /**
+ * Returns true if the define's if and unless conditions (if any) are
+ * satisfied.
+ */
+ public boolean isActive(org.apache.tools.ant.Project p) {
+ if (value == null) {
+ return false;
+ }
+ if (ifCond != null && p.getProperty(ifCond) == null) {
+ return false;
+ } else if (unlessCond != null && p.getProperty(unlessCond) != null) {
+ return false;
+ }
+ return true;
+ }
+ /**
+ * Sets the property name for the 'if' condition.
+ *
+ * The argument will be ignored unless the property is defined.
+ *
+ * The value of the property is insignificant, but values that would imply
+ * misinterpretation ("false", "no") will throw an exception when
+ * evaluated.
+ */
+ public void setIf(String propName) {
+ ifCond = propName;
+ }
+ /**
+ * Specifies relative location of argument on command line. "start" will
+ * place argument at start of command line, "mid" will place argument after
+ * all "start" arguments but before filenames, "end" will place argument
+ * after filenames.
+ *
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+ /**
+ * Set the property name for the 'unless' condition.
+ *
+ * If named property is set, the argument will be ignored.
+ *
+ * The value of the property is insignificant, but values that would imply
+ * misinterpretation ("false", "no") of the behavior will throw an
+ * exception when evaluated.
+ *
+ * @param propName
+ * name of property
+ */
+ public void setUnless(String propName) {
+ unlessCond = propName;
+ }
+ /**
+ * Specifies the string that should appear on the command line. The
+ * argument will be quoted if it contains embedded blanks. Use multiple
+ * arguments to avoid quoting.
+ *
+ */
+ public void setValue(String value) {
+ this.value = value;
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/RuntimeType.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/RuntimeType.java
new file mode 100644
index 0000000000..02da661917
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/RuntimeType.java
@@ -0,0 +1,26 @@
+/*
+ *
+ * Copyright 2001-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks;
+import org.apache.tools.ant.types.EnumeratedAttribute;
+/**
+ * Enumerated attribute with the values "dynamic" and "static",
+ */
+public class RuntimeType extends EnumeratedAttribute {
+ public String[] getValues() {
+ return new String[]{"dynamic", "static"};
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/SourceHistory.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/SourceHistory.java
new file mode 100644
index 0000000000..0c608b4d87
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/SourceHistory.java
@@ -0,0 +1,51 @@
+/*
+ *
+ * Copyright 2002-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks;
+import java.io.File;
+import java.io.IOException;
+/**
+ * The history of a source file used to build a target
+ *
+ * @author Curt Arnold
+ */
+public final class SourceHistory {
+ private/* final */long lastModified;
+ private/* final */String relativePath;
+ /**
+ * Constructor
+ */
+ public SourceHistory(String relativePath, long lastModified) {
+ if (relativePath == null) {
+ throw new NullPointerException("relativePath");
+ }
+ this.relativePath = relativePath;
+ this.lastModified = lastModified;
+ }
+ public String getAbsolutePath(File baseDir) {
+ try {
+ return new File(baseDir, relativePath).getCanonicalPath();
+ } catch (IOException ex) {
+ }
+ return relativePath;
+ }
+ public long getLastModified() {
+ return lastModified;
+ }
+ public String getRelativePath() {
+ return relativePath;
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/SubsystemEnum.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/SubsystemEnum.java
new file mode 100644
index 0000000000..3dc342a38a
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/SubsystemEnum.java
@@ -0,0 +1,34 @@
+/*
+ *
+ * Copyright 2001-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks;
+import org.apache.tools.ant.types.EnumeratedAttribute;
+/**
+ * Enumeration of supported subsystems
+ *
+ * @author Curt Arnold
+ *
+ */
+public final class SubsystemEnum extends EnumeratedAttribute {
+ private final static String[] values = new String[]{"gui", "console",
+ "other"};
+ public SubsystemEnum() {
+ setValue("gui");
+ }
+ public String[] getValues() {
+ return (String[]) values.clone();
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/TargetDef.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/TargetDef.java
new file mode 100644
index 0000000000..8e46cb7c6c
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/TargetDef.java
@@ -0,0 +1,228 @@
+/*
+ *
+ * Copyright 2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks;
+
+import org.apache.tools.ant.types.DataType;
+import org.apache.tools.ant.types.Reference;
+
+/**
+ * Information on the execution platforms for the generated code.
+ * (Non-functional prototype)
+ *
+ */
+public final class TargetDef
+ extends DataType {
+ /**
+ * if property.
+ */
+ private String ifCond;
+
+ /**
+ * unless property.
+ */
+ private String unlessCond;
+
+ /**
+ * cpu.
+ *
+ */
+ private CPUEnum cpu;
+
+ /**
+ * architecture.
+ *
+ */
+ private ArchEnum arch;
+
+ /**
+ * OS Family.
+ *
+ */
+ private OSFamilyEnum osFamily;
+
+ /**
+ * Constructor.
+ *
+ */
+ public TargetDef() {
+ }
+
+ /**
+ * Bogus method required for documentation generation.
+ */
+ public void execute() {
+ throw new org.apache.tools.ant.BuildException(
+ "Not an actual task, but looks like one for documentation purposes");
+ }
+
+ /**
+ * Returns true if the define's if and unless conditions (if any) are
+ * satisfied.
+ * @return true if active
+ */
+ public boolean isActive() {
+ return CUtil.isActive(getProject(), ifCond, unlessCond);
+ }
+
+ /**
+ * Sets a description of the current data type.
+ * @param desc description
+ */
+ public void setDescription(final String desc) {
+ super.setDescription(desc);
+ }
+
+ /**
+ * Sets an id that can be used to reference this element.
+ *
+ * @param id
+ * id
+ */
+ public void setId(final String id) {
+ //
+ // this is actually accomplished by a different
+ // mechanism, but we can document it
+ //
+ }
+
+ /**
+ * Sets the property name for the 'if' condition.
+ *
+ * The define will be ignored unless the property is defined.
+ *
+ * The value of the property is insignificant, but values that would imply
+ * misinterpretation ("false", "no") will throw an exception when
+ * evaluated.
+ *
+ * @param propName
+ * property name
+ */
+ public void setIf(final String propName) {
+ ifCond = propName;
+ }
+
+ /**
+ * Specifies that this element should behave as if the content of the
+ * element with the matching id attribute was inserted at this location. If
+ * specified, no other attributes should be specified.
+ * @param r id of referenced target
+ */
+ public void setRefid(final Reference r) {
+ super.setRefid(r);
+ }
+
+ /**
+ * Set the property name for the 'unless' condition.
+ *
+ * If named property is set, the define will be ignored.
+ *
+ * The value of the property is insignificant, but values that would imply
+ * misinterpretation ("false", "no") of the behavior will throw an
+ * exception when evaluated.
+ *
+ * @param propName
+ * name of property
+ */
+ public void setUnless(final String propName) {
+ unlessCond = propName;
+ }
+
+ /**
+ * Gets cpu.
+ * @return cpu, may be null.
+ *
+ */
+ public CPUEnum getCpu() {
+ if (isReference()) {
+ TargetDef refPlatform = (TargetDef)
+ getCheckedRef(TargetDef.class,
+ "TargetDef");
+ return refPlatform.getCpu();
+ }
+ return cpu;
+ }
+
+ /**
+ * Gets arch.
+ * @return arch, may be null.
+ *
+ */
+ public ArchEnum getArch() {
+ if (isReference()) {
+ TargetDef refPlatform = (TargetDef)
+ getCheckedRef(TargetDef.class,
+ "TargetDef");
+ return refPlatform.getArch();
+ }
+ return arch;
+ }
+
+ /**
+ * Gets operating system family.
+ * @return os family, may be null.
+ *
+ */
+ public OSFamilyEnum getOsfamily() {
+ if (isReference()) {
+ TargetDef refPlatform = (TargetDef)
+ getCheckedRef(TargetDef.class,
+ "TargetDef");
+ return refPlatform.getOsfamily();
+ }
+ return osFamily;
+ }
+
+ /**
+ * Sets preferred cpu, but does not use cpu specific instructions.
+ * @param value new value
+ */
+ public void setCpu(final CPUEnum value) {
+ if (isReference()) {
+ throw tooManyAttributes();
+ }
+ cpu = value;
+ }
+
+ /**
+ * Sets cpu architecture, compiler may use cpu specific instructions.
+ * @param value new value
+ */
+ public void setArch(final ArchEnum value) {
+ if (isReference()) {
+ throw tooManyAttributes();
+ }
+ if (cpu != null) {
+ throw tooManyAttributes();
+ }
+ arch = value;
+ }
+
+ /**
+ * Sets operating system family.
+ * @param value new value
+ */
+ public void setOsfamily(final OSFamilyEnum value) {
+ if (isReference()) {
+ throw tooManyAttributes();
+ }
+ if (cpu != null) {
+ throw tooManyAttributes();
+ }
+ osFamily = value;
+ }
+
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/TargetHistory.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/TargetHistory.java
new file mode 100644
index 0000000000..0094c8ecec
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/TargetHistory.java
@@ -0,0 +1,58 @@
+/*
+ *
+ * Copyright 2002-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks;
+/**
+ * A description of a file built or to be built
+ */
+public final class TargetHistory {
+ private/* final */String config;
+ private/* final */String output;
+ private/* final */long outputLastModified;
+ private/* final */SourceHistory[] sources;
+ /**
+ * Constructor from build step
+ */
+ public TargetHistory(String config, String output, long outputLastModified,
+ SourceHistory[] sources) {
+ if (config == null) {
+ throw new NullPointerException("config");
+ }
+ if (sources == null) {
+ throw new NullPointerException("source");
+ }
+ if (output == null) {
+ throw new NullPointerException("output");
+ }
+ this.config = config;
+ this.output = output;
+ this.outputLastModified = outputLastModified;
+ this.sources = (SourceHistory[]) sources.clone();
+ }
+ public String getOutput() {
+ return output;
+ }
+ public long getOutputLastModified() {
+ return outputLastModified;
+ }
+ public String getProcessorConfiguration() {
+ return config;
+ }
+ public SourceHistory[] getSources() {
+ SourceHistory[] clone = (SourceHistory[]) sources.clone();
+ return clone;
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/TargetHistoryTable.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/TargetHistoryTable.java
new file mode 100644
index 0000000000..9fb0a7b642
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/TargetHistoryTable.java
@@ -0,0 +1,426 @@
+/*
+ *
+ * Copyright 2002-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+import java.io.UnsupportedEncodingException;
+import java.util.Enumeration;
+import java.util.Hashtable;
+import java.util.Vector;
+
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+
+import net.sf.antcontrib.cpptasks.compiler.ProcessorConfiguration;
+
+import org.apache.tools.ant.BuildException;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.DefaultHandler;
+/**
+ * A history of the compiler and linker settings used to build the files in the
+ * same directory as the history.
+ *
+ * @author Curt Arnold
+ */
+public final class TargetHistoryTable {
+ /**
+ * This class handles populates the TargetHistory hashtable in response to
+ * SAX parse events
+ */
+ private class TargetHistoryTableHandler extends DefaultHandler {
+ private final File baseDir;
+ private String config;
+ private final Hashtable history;
+ private String output;
+ private long outputLastModified;
+ private final Vector sources = new Vector();
+ /**
+ * Constructor
+ *
+ * @param history
+ * hashtable of TargetHistory keyed by output name
+ * @param outputFiles
+ * existing files in output directory
+ */
+ private TargetHistoryTableHandler(Hashtable history, File baseDir) {
+ this.history = history;
+ config = null;
+ output = null;
+ this.baseDir = baseDir;
+ }
+ public void endElement(String namespaceURI, String localName,
+ String qName) throws SAXException {
+ //
+ // if then
+ // create TargetHistory object and add to hashtable
+ // if corresponding output file exists and
+ // has the same timestamp
+ //
+ if (qName.equals("target")) {
+ if (config != null && output != null) {
+ File existingFile = new File(baseDir, output);
+ //
+ // if the corresponding files doesn't exist or has a
+ // different
+ // modification time, then discard this record
+ if (existingFile.exists()) {
+ long existingLastModified = existingFile.lastModified();
+ //
+ // would have expected exact time stamps
+ // but have observed slight differences
+ // in return value for multiple evaluations of
+ // lastModified(). Check if times are within
+ // a second
+ long diff = outputLastModified - existingLastModified;
+ if (diff >= -500 && diff <= 500) {
+ SourceHistory[] sourcesArray = new SourceHistory[sources
+ .size()];
+ sources.copyInto(sourcesArray);
+ TargetHistory targetHistory = new TargetHistory(
+ config, output, outputLastModified,
+ sourcesArray);
+ history.put(output, targetHistory);
+ }
+ }
+ }
+ output = null;
+ sources.setSize(0);
+ } else {
+ //
+ // reset config so targets not within a processor element
+ // don't pick up a previous processors signature
+ //
+ if (qName.equals("processor")) {
+ config = null;
+ }
+ }
+ }
+ /**
+ * startElement handler
+ */
+ public void startElement(String namespaceURI, String localName,
+ String qName, Attributes atts) throws SAXException {
+ //
+ // if sourceElement
+ //
+ if (qName.equals("source")) {
+ String sourceFile = atts.getValue("file");
+ long sourceLastModified = Long.parseLong(atts
+ .getValue("lastModified"), 16);
+ sources.addElement(new SourceHistory(sourceFile,
+ sourceLastModified));
+ } else {
+ //
+ // if element,
+ // grab file name and lastModified values
+ // TargetHistory object will be created in endElement
+ //
+ if (qName.equals("target")) {
+ sources.setSize(0);
+ output = atts.getValue("file");
+ outputLastModified = Long.parseLong(atts
+ .getValue("lastModified"), 16);
+ } else {
+ //
+ // if element,
+ // grab signature attribute
+ //
+ if (qName.equals("processor")) {
+ config = atts.getValue("signature");
+ }
+ }
+ }
+ }
+ }
+ /** Flag indicating whether the cache should be written back to file. */
+ private boolean dirty;
+ /**
+ * a hashtable of TargetHistory's keyed by output file name
+ */
+ private final Hashtable history = new Hashtable();
+ /** The file the cache was loaded from. */
+ private/* final */File historyFile;
+ private/* final */File outputDir;
+ private String outputDirPath;
+ /**
+ * Creates a target history table from history.xml in the output directory,
+ * if it exists. Otherwise, initializes the history table empty.
+ *
+ * @param task
+ * task used for logging history load errors
+ * @param outputDir
+ * output directory for task
+ */
+ public TargetHistoryTable(CCTask task, File outputDir)
+ throws BuildException {
+ if (outputDir == null) {
+ throw new NullPointerException("outputDir");
+ }
+ if (!outputDir.isDirectory()) {
+ throw new BuildException("Output directory is not a directory");
+ }
+ if (!outputDir.exists()) {
+ throw new BuildException("Output directory does not exist");
+ }
+ this.outputDir = outputDir;
+ try {
+ outputDirPath = outputDir.getCanonicalPath();
+ } catch (IOException ex) {
+ outputDirPath = outputDir.toString();
+ }
+ //
+ // load any existing history from file
+ // suppressing any records whose corresponding
+ // file does not exist, is zero-length or
+ // last modified dates differ
+ historyFile = new File(outputDir, "history.xml");
+ if (historyFile.exists()) {
+ SAXParserFactory factory = SAXParserFactory.newInstance();
+ factory.setValidating(false);
+ try {
+ SAXParser parser = factory.newSAXParser();
+ parser.parse(historyFile, new TargetHistoryTableHandler(
+ history, outputDir));
+ } catch (Exception ex) {
+ //
+ // a failure on loading this history is not critical
+ // but should be logged
+ task.log("Error reading history.xml: " + ex.toString());
+ }
+ } else {
+ //
+ // create empty history file for identifying new files by last
+ // modified
+ // timestamp comperation (to compare with
+ // System.currentTimeMillis() don't work on Unix, because it
+ // maesure timestamps only in seconds).
+ //
+ try {
+ FileOutputStream outputStream = new FileOutputStream(
+ historyFile);
+ byte[] historyElement = new byte[]{0x3C, 0x68, 0x69, 0x73,
+ 0x74, 0x6F, 0x72, 0x79, 0x2F, 0x3E};
+ outputStream.write(historyElement);
+ outputStream.close();
+ } catch (IOException ex) {
+ throw new BuildException("Can't create history file", ex);
+ }
+ }
+ }
+ public void commit() throws IOException {
+ //
+ // if not dirty, no need to update file
+ //
+ if (dirty) {
+ //
+ // build (small) hashtable of config id's in history
+ //
+ Hashtable configs = new Hashtable(20);
+ Enumeration elements = history.elements();
+ while (elements.hasMoreElements()) {
+ TargetHistory targetHistory = (TargetHistory) elements
+ .nextElement();
+ String configId = targetHistory.getProcessorConfiguration();
+ if (configs.get(configId) == null) {
+ configs.put(configId, configId);
+ }
+ }
+ FileOutputStream outStream = new FileOutputStream(historyFile);
+ OutputStreamWriter outWriter;
+ //
+ // early VM's don't support UTF-8 encoding
+ // try and fallback to the default encoding
+ // otherwise
+ String encodingName = "UTF-8";
+ try {
+ outWriter = new OutputStreamWriter(outStream, "UTF-8");
+ } catch (UnsupportedEncodingException ex) {
+ outWriter = new OutputStreamWriter(outStream);
+ encodingName = outWriter.getEncoding();
+ }
+ BufferedWriter writer = new BufferedWriter(outWriter);
+ writer.write("\n");
+ writer.write("\n");
+ StringBuffer buf = new StringBuffer(200);
+ Enumeration configEnum = configs.elements();
+ while (configEnum.hasMoreElements()) {
+ String configId = (String) configEnum.nextElement();
+ buf.setLength(0);
+ buf.append(" \n");
+ writer.write(buf.toString());
+ elements = history.elements();
+ while (elements.hasMoreElements()) {
+ TargetHistory targetHistory = (TargetHistory) elements
+ .nextElement();
+ if (targetHistory.getProcessorConfiguration().equals(
+ configId)) {
+ buf.setLength(0);
+ buf.append(" \n");
+ writer.write(buf.toString());
+ SourceHistory[] sourceHistories = targetHistory
+ .getSources();
+ for (int i = 0; i < sourceHistories.length; i++) {
+ buf.setLength(0);
+ buf.append(" \n");
+ writer.write(buf.toString());
+ }
+ writer.write(" \n");
+ }
+ }
+ writer.write(" \n");
+ }
+ writer.write("\n");
+ writer.close();
+ dirty = false;
+ }
+ }
+ public TargetHistory get(String configId, String outputName) {
+ TargetHistory targetHistory = (TargetHistory) history.get(outputName);
+ if (targetHistory != null) {
+ if (!targetHistory.getProcessorConfiguration().equals(configId)) {
+ targetHistory = null;
+ }
+ }
+ return targetHistory;
+ }
+ public void markForRebuild(Hashtable targetInfos) {
+ Enumeration targetInfoEnum = targetInfos.elements();
+ while (targetInfoEnum.hasMoreElements()) {
+ markForRebuild((TargetInfo) targetInfoEnum.nextElement());
+ }
+ }
+ public void markForRebuild(TargetInfo targetInfo) {
+ //
+ // if it must already be rebuilt, no need to check further
+ //
+ if (!targetInfo.getRebuild()) {
+ TargetHistory history = get(targetInfo.getConfiguration()
+ .toString(), targetInfo.getOutput().getName());
+ if (history == null) {
+ targetInfo.mustRebuild();
+ } else {
+ SourceHistory[] sourceHistories = history.getSources();
+ File[] sources = targetInfo.getSources();
+ if (sourceHistories.length != sources.length) {
+ targetInfo.mustRebuild();
+ } else {
+ for (int i = 0; i < sourceHistories.length
+ && !targetInfo.getRebuild(); i++) {
+ //
+ // relative file name, must absolutize it on output
+ // directory
+ //
+ boolean foundMatch = false;
+ String historySourcePath = sourceHistories[i]
+ .getAbsolutePath(outputDir);
+ for (int j = 0; j < sources.length; j++) {
+ File targetSource = sources[j];
+ String targetSourcePath = targetSource
+ .getAbsolutePath();
+ if (targetSourcePath.equals(historySourcePath)) {
+ foundMatch = true;
+ if (targetSource.lastModified() != sourceHistories[i]
+ .getLastModified()) {
+ targetInfo.mustRebuild();
+ break;
+ }
+ }
+ }
+ if (!foundMatch) {
+ targetInfo.mustRebuild();
+ }
+ }
+ }
+ }
+ }
+ }
+ public void update(ProcessorConfiguration config, String[] sources) {
+ String configId = config.getIdentifier();
+ String[] onesource = new String[1];
+ String outputName;
+ for (int i = 0; i < sources.length; i++) {
+ onesource[0] = sources[i];
+ outputName = config.getOutputFileName(sources[i]);
+ update(configId, outputName, onesource);
+ }
+ }
+ private void update(String configId, String outputName, String[] sources) {
+ File outputFile = new File(outputDir, outputName);
+ //
+ // if output file doesn't exist or predates the start of the
+ // compile step (most likely a compilation error) then
+ // do not write add a history entry
+ //
+ if (outputFile.exists()
+ && outputFile.lastModified() >= historyFile.lastModified()) {
+ dirty = true;
+ history.remove(outputName);
+ SourceHistory[] sourceHistories = new SourceHistory[sources.length];
+ for (int i = 0; i < sources.length; i++) {
+ File sourceFile = new File(sources[i]);
+ long lastModified = sourceFile.lastModified();
+ String relativePath = CUtil.getRelativePath(outputDirPath,
+ sourceFile);
+ sourceHistories[i] = new SourceHistory(relativePath,
+ lastModified);
+ }
+ TargetHistory newHistory = new TargetHistory(configId, outputName,
+ outputFile.lastModified(), sourceHistories);
+ history.put(outputName, newHistory);
+ }
+ }
+ public void update(TargetInfo linkTarget) {
+ File outputFile = linkTarget.getOutput();
+ String outputName = outputFile.getName();
+ //
+ // if output file doesn't exist or predates the start of the
+ // compile or link step (most likely a compilation error) then
+ // do not write add a history entry
+ //
+ if (outputFile.exists()
+ && outputFile.lastModified() >= historyFile.lastModified()) {
+ dirty = true;
+ history.remove(outputName);
+ SourceHistory[] sourceHistories = linkTarget
+ .getSourceHistories(outputDirPath);
+ TargetHistory newHistory = new TargetHistory(linkTarget
+ .getConfiguration().getIdentifier(), outputName, outputFile
+ .lastModified(), sourceHistories);
+ history.put(outputName, newHistory);
+ }
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/TargetInfo.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/TargetInfo.java
new file mode 100644
index 0000000000..3a9dd14b16
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/TargetInfo.java
@@ -0,0 +1,127 @@
+/*
+ *
+ * Copyright 2002-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks;
+import java.io.File;
+
+import net.sf.antcontrib.cpptasks.compiler.ProcessorConfiguration;
+/**
+ * A description of a file built or to be built
+ */
+public final class TargetInfo {
+ private static final File[] emptyFileArray = new File[0];
+ private/* final */ProcessorConfiguration config;
+ private/* final */File output;
+ private boolean rebuild;
+ private/* final */File[] sources;
+ private File[] sysSources;
+ public TargetInfo(ProcessorConfiguration config, File[] sources,
+ File[] sysSources, File output, boolean rebuild) {
+ if (config == null) {
+ throw new NullPointerException("config");
+ }
+ if (sources == null) {
+ throw new NullPointerException("sources");
+ }
+ if (output == null) {
+ throw new NullPointerException("output");
+ }
+ this.config = config;
+ this.sources = (File[]) sources.clone();
+ if (sysSources == null) {
+ this.sysSources = emptyFileArray;
+ } else {
+ this.sysSources = (File[]) sysSources.clone();
+ }
+ this.output = output;
+ this.rebuild = rebuild;
+ //
+ // if the output doesn't exist, must rebuild it
+ //
+ if (!output.exists()) {
+ rebuild = true;
+ }
+ }
+ public String[] getAllSourcePaths() {
+ String[] paths = new String[sysSources.length + sources.length];
+ for (int i = 0; i < sysSources.length; i++) {
+ paths[i] = sysSources[i].toString();
+ }
+ int offset = sysSources.length;
+ for (int i = 0; i < sources.length; i++) {
+ paths[offset + i] = sources[i].toString();
+ }
+ return paths;
+ }
+ public File[] getAllSources() {
+ File[] allSources = new File[sources.length + sysSources.length];
+ for (int i = 0; i < sysSources.length; i++) {
+ allSources[i] = sysSources[i];
+ }
+ int offset = sysSources.length;
+ for (int i = 0; i < sources.length; i++) {
+ allSources[i + offset] = sources[i];
+ }
+ return allSources;
+ }
+ public ProcessorConfiguration getConfiguration() {
+ return config;
+ }
+ public File getOutput() {
+ return output;
+ }
+ public boolean getRebuild() {
+ return rebuild;
+ }
+ /**
+ * Returns an array of SourceHistory objects (contains relative path and
+ * last modified time) for the source[s] of this target
+ */
+ public SourceHistory[] getSourceHistories(String basePath) {
+ SourceHistory[] histories = new SourceHistory[sources.length];
+ for (int i = 0; i < sources.length; i++) {
+ String relativeName = CUtil.getRelativePath(basePath, sources[i]);
+ long lastModified = sources[i].lastModified();
+ histories[i] = new SourceHistory(relativeName, lastModified);
+ }
+ return histories;
+ }
+ public String[] getSourcePaths() {
+ String[] paths = new String[sources.length];
+ for (int i = 0; i < sources.length; i++) {
+ paths[i] = sources[i].toString();
+ }
+ return paths;
+ }
+ public File[] getSources() {
+ File[] clone = (File[]) sources.clone();
+ return clone;
+ }
+ public String[] getSysSourcePaths() {
+ String[] paths = new String[sysSources.length];
+ for (int i = 0; i < sysSources.length; i++) {
+ paths[i] = sysSources[i].toString();
+ }
+ return paths;
+ }
+ public File[] getSysSources() {
+ File[] clone = (File[]) sysSources.clone();
+ return clone;
+ }
+ public void mustRebuild() {
+ this.rebuild = true;
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/TargetMatcher.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/TargetMatcher.java
new file mode 100644
index 0000000000..2574e1561f
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/TargetMatcher.java
@@ -0,0 +1,117 @@
+/*
+ *
+ * Copyright 2002-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks;
+import java.io.File;
+import java.util.Hashtable;
+import java.util.Vector;
+
+import net.sf.antcontrib.cpptasks.compiler.LinkerConfiguration;
+import net.sf.antcontrib.cpptasks.compiler.ProcessorConfiguration;
+
+import org.apache.tools.ant.BuildException;
+/**
+ * This class matches each visited file with an appropriate compiler
+ *
+ * @author Curt Arnold
+ */
+public final class TargetMatcher implements FileVisitor {
+ private LinkerConfiguration linker;
+ private Vector objectFiles;
+ private File outputDir;
+ private ProcessorConfiguration[] processors;
+ private final File sourceFiles[] = new File[1];
+ private Hashtable targets;
+ private CCTask task;
+ public TargetMatcher(CCTask task, File outputDir,
+ ProcessorConfiguration[] processors, LinkerConfiguration linker,
+ Vector objectFiles, Hashtable targets) {
+ this.task = task;
+ this.outputDir = outputDir;
+ this.processors = processors;
+ this.targets = targets;
+ this.linker = linker;
+ this.objectFiles = objectFiles;
+ }
+ public void visit(File parentDir, String filename) throws BuildException {
+ //
+ // see if any processor wants to bid
+ // on this one
+ ProcessorConfiguration selectedCompiler = null;
+ int bid = 0;
+ if (processors != null) {
+ for (int k = 0; k < processors.length; k++) {
+ int newBid = processors[k].bid(filename);
+ if (newBid > bid) {
+ bid = newBid;
+ selectedCompiler = processors[k];
+ }
+ }
+ }
+ //
+ // no processor interested in file
+ // log diagnostic message
+ if (bid <= 0) {
+ if (linker != null) {
+ int linkerbid = linker.bid(filename);
+ if (linkerbid > 0) {
+ File objFile = new File(parentDir, filename);
+ objectFiles.addElement(objFile);
+ if (linkerbid == 1) {
+ task.log("Unrecognized file type " + objFile.toString()
+ + " will be passed to linker");
+ }
+ }
+ }
+ } else {
+ //
+ // get output file name
+ //
+ String outputFileName = selectedCompiler
+ .getOutputFileName(filename);
+ //
+ // if there is some output for this task
+ // (that is a source file and not an header file)
+ //
+ if (outputFileName != null) {
+ sourceFiles[0] = new File(parentDir, filename);
+ //
+ // see if the same output file has already been registered
+ //
+ TargetInfo previousTarget = (TargetInfo) targets
+ .get(outputFileName);
+ if (previousTarget == null) {
+ targets.put(outputFileName, new TargetInfo(
+ selectedCompiler, sourceFiles, null, new File(
+ outputDir, outputFileName),
+ selectedCompiler.getRebuild()));
+ } else {
+ if (!previousTarget.getSources()[0].equals(sourceFiles[0])) {
+ StringBuffer builder = new StringBuffer(
+ "Output filename conflict: ");
+ builder.append(outputFileName);
+ builder.append(" would be produced from ");
+ builder.append(previousTarget.getSources()[0]
+ .toString());
+ builder.append(" and ");
+ builder.append(filename);
+ throw new BuildException(builder.toString());
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/VersionInfo.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/VersionInfo.java
new file mode 100644
index 0000000000..f55b976fef
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/VersionInfo.java
@@ -0,0 +1,550 @@
+/*
+ *
+ * Copyright 2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks;
+
+import java.io.IOException;
+import java.io.Writer;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.types.DataType;
+import org.apache.tools.ant.types.Reference;
+
+/**
+ * Version Information. (Non-functional prototype)
+ *
+ */
+public class VersionInfo extends DataType {
+ /**
+ * if property.
+ */
+ private String ifCond;
+ /**
+ * unless property.
+ */
+ private String unlessCond;
+
+ /**
+ * extends property.
+ */
+ private String extendsId;
+
+ /**
+ * file version.
+ *
+ */
+ private String fileVersion;
+ /**
+ * Product version.
+ *
+ */
+ private String productVersion;
+ /**
+ * file language.
+ *
+ */
+ private String language;
+
+ /**
+ * comments.
+ *
+ */
+ private String fileComments;
+ /**
+ * Company name.
+ *
+ */
+ private String companyName;
+ /**
+ * Description.
+ *
+ */
+ private String description;
+ /**
+ * internal name.
+ */
+ private String internalName;
+ /**
+ * legal copyright.
+ *
+ */
+ private String legalCopyright;
+ /**
+ * legal trademark.
+ *
+ */
+ private String legalTrademark;
+ /**
+ * original filename.
+ *
+ */
+ private String originalFilename;
+ /**
+ * private build.
+ *
+ */
+ private String privateBuild;
+ /**
+ * product name.
+ *
+ */
+ private String productName;
+ /**
+ * Special build
+ */
+ private String specialBuild;
+ /**
+ * compatibility version
+ *
+ */
+ private String compatibilityVersion;
+
+
+ /**
+ * Constructor.
+ *
+ */
+ public VersionInfo() {
+ }
+ public void execute() throws org.apache.tools.ant.BuildException {
+ throw new org.apache.tools.ant.BuildException(
+ "Not an actual task, but looks like one for documentation purposes");
+ }
+ /**
+ * Returns true if the define's if and unless conditions (if any) are
+ * satisfied.
+ *
+ * @exception BuildException
+ * throws build exception if name is not set
+ */
+ public final boolean isActive() throws BuildException {
+ return CUtil.isActive(getProject(), ifCond, unlessCond);
+ }
+ /**
+ * Sets an id that can be used to reference this element.
+ *
+ * @param id
+ * id
+ */
+ public void setId(String id) {
+ //
+ // this is actually accomplished by a different
+ // mechanism, but we can document it
+ //
+ }
+ /**
+ * Sets the name of a version info that this info extends.
+ *
+ * @param id
+ * id
+ */
+ public void setExtends(String id) {
+ extendsId = id;
+ }
+
+
+ /**
+ * Sets the property name for the 'if' condition.
+ *
+ * The define will be ignored unless the property is defined.
+ *
+ * The value of the property is insignificant, but values that would imply
+ * misinterpretation ("false", "no") will throw an exception when
+ * evaluated.
+ *
+ * @param propName
+ * property name
+ */
+ public final void setIf(String propName) {
+ ifCond = propName;
+ }
+ /**
+ * Specifies that this element should behave as if the content of the
+ * element with the matching id attribute was inserted at this location. If
+ * specified, no other attributes should be specified.
+ *
+ */
+ public void setRefid(Reference r) throws BuildException {
+ super.setRefid(r);
+ }
+ /**
+ * Set the property name for the 'unless' condition.
+ *
+ * If named property is set, the define will be ignored.
+ *
+ * The value of the property is insignificant, but values that would imply
+ * misinterpretation ("false", "no") of the behavior will throw an
+ * exception when evaluated.
+ *
+ * @param propName
+ * name of property
+ */
+ public final void setUnless(String propName) {
+ unlessCond = propName;
+ }
+ /**
+ * Gets file version.
+ * @return file version, may be null.
+ *
+ */
+ public String getFileversion() {
+ if (isReference()) {
+ VersionInfo refVersion = (VersionInfo)
+ getCheckedRef(VersionInfo.class,
+ "VersionInfo");
+ return refVersion.getFileversion();
+ }
+ return fileVersion;
+ }
+ /**
+ * Gets Product version.
+ * @return product version, may be null
+ */
+ public String getProductversion() {
+ if (isReference()) {
+ VersionInfo refVersion = (VersionInfo)
+ getCheckedRef(VersionInfo.class,
+ "VersionInfo");
+ return refVersion.getProductversion();
+ }
+ return productVersion;
+ }
+ /**
+ * Gets compatibility version.
+ * @return compatibility version, may be null
+ */
+ public String getCompatibilityversion() {
+ if (isReference()) {
+ VersionInfo refVersion = (VersionInfo)
+ getCheckedRef(VersionInfo.class,
+ "VersionInfo");
+ return refVersion.getCompatibilityversion();
+ }
+ return compatibilityVersion;
+ }
+ /**
+ * Gets file language, should be an IETF RFC 3066 identifier, for example, en-US.
+ * @return language, may be null.
+ */
+ public String getLanguage() {
+ if (isReference()) {
+ VersionInfo refVersion = (VersionInfo)
+ getCheckedRef(VersionInfo.class,
+ "VersionInfo");
+ return refVersion.getLanguage();
+ }
+ return language;
+ }
+
+ /**
+ * Gets comments.
+ * @return comments, may be null.
+ */
+ public String getFilecomments() {
+ if (isReference()) {
+ VersionInfo refVersion = (VersionInfo)
+ getCheckedRef(VersionInfo.class,
+ "VersionInfo");
+ return refVersion.getFilecomments();
+ }
+ return fileComments;
+ }
+ /**
+ * Gets Company name.
+ * @return company name, may be null.
+ */
+ public String getCompanyname() {
+ if (isReference()) {
+ VersionInfo refVersion = (VersionInfo)
+ getCheckedRef(VersionInfo.class,
+ "VersionInfo");
+ return refVersion.getCompanyname();
+ }
+ return companyName;
+ }
+ /**
+ * Gets Description.
+ * @return description, may be null.
+ */
+ public String getDescription() {
+ if (isReference()) {
+ VersionInfo refVersion = (VersionInfo)
+ getCheckedRef(VersionInfo.class,
+ "VersionInfo");
+ return refVersion.getDescription();
+ }
+ return description;
+ }
+ /**
+ * Gets internal name.
+ * @return internal name, may be null.
+ */
+ public String getInternalname() {
+ if (isReference()) {
+ VersionInfo refVersion = (VersionInfo)
+ getCheckedRef(VersionInfo.class,
+ "VersionInfo");
+ return refVersion.getInternalname();
+ }
+ return internalName;
+ }
+ /**
+ * Gets legal copyright.
+ * @return legal copyright, may be null.
+ */
+ public String getLegalcopyright() {
+ if (isReference()) {
+ VersionInfo refVersion = (VersionInfo)
+ getCheckedRef(VersionInfo.class,
+ "VersionInfo");
+ return refVersion.getLegalcopyright();
+ }
+ return legalCopyright;
+ }
+ /**
+ * Gets legal trademark.
+ * @return legal trademark, may be null;
+ */
+ public String getLegaltrademark() {
+ if (isReference()) {
+ VersionInfo refVersion = (VersionInfo)
+ getCheckedRef(VersionInfo.class,
+ "VersionInfo");
+ return refVersion.getLegaltrademark();
+ }
+ return legalTrademark;
+ }
+ /**
+ * Gets original filename.
+ * @return original filename, may be null.
+ */
+ public String getOriginalfilename() {
+ if (isReference()) {
+ VersionInfo refVersion = (VersionInfo)
+ getCheckedRef(VersionInfo.class,
+ "VersionInfo");
+ return refVersion.getOriginalfilename();
+ }
+ return originalFilename;
+ }
+ /**
+ * Gets private build.
+ * @return private build, may be null.
+ */
+ public String getPrivatebuild() {
+ if (isReference()) {
+ VersionInfo refVersion = (VersionInfo)
+ getCheckedRef(VersionInfo.class,
+ "VersionInfo");
+ return refVersion.getPrivatebuild();
+ }
+ return privateBuild;
+ }
+ /**
+ * Gets product name.
+ * @return product name, may be null.
+ */
+ public String getProductname() {
+ if (isReference()) {
+ VersionInfo refVersion = (VersionInfo)
+ getCheckedRef(VersionInfo.class,
+ "VersionInfo");
+ return refVersion.getProductname();
+ }
+ return productName;
+ }
+ /**
+ * Special build
+ * @return special build, may be null.
+ */
+ public String getSpecialbuild() {
+ if (isReference()) {
+ VersionInfo refVersion = (VersionInfo)
+ getCheckedRef(VersionInfo.class,
+ "VersionInfo");
+ return refVersion.getSpecialbuild();
+ }
+ return specialBuild;
+ }
+
+ /**
+ * Sets file version.
+ * @param value new value
+ * @throws BuildException if specified with refid
+ */
+ public void setFileversion(String value) throws BuildException {
+ if (isReference()) {
+ throw tooManyAttributes();
+ }
+ fileVersion = value;
+ }
+ /**
+ * Sets product version.
+ * @param value new value
+ * @throws BuildException if specified with refid
+ */
+ public void setProductversion(String value) throws BuildException {
+ if (isReference()) {
+ throw tooManyAttributes();
+ }
+ productVersion = value;
+ }
+ /**
+ * Sets compatibility version.
+ * @param value new value
+ * @throws BuildException if specified with refid
+ */
+ public void setCompatibilityversion(String value) throws BuildException {
+ if (isReference()) {
+ throw tooManyAttributes();
+ }
+ compatibilityVersion = value;
+ }
+ /**
+ * Sets language.
+ * @param value new value, should be an IETF RFC 3066 language identifier.
+ * @throws BuildException if specified with refid
+ */
+ public void setLanguage(String value) throws BuildException {
+ if (isReference()) {
+ throw tooManyAttributes();
+ }
+ language = value;
+ }
+ /**
+ * Sets comments.
+ * @param value new value
+ * @throws BuildException if specified with refid
+ */
+ public void setFilecomments(String value) throws BuildException {
+ if (isReference()) {
+ throw tooManyAttributes();
+ }
+ fileComments = value;
+ }
+
+ /**
+ * Sets company name.
+ * @param value new value
+ * @throws BuildException if specified with refid
+ */
+ public void setCompanyname(String value) throws BuildException {
+ if (isReference()) {
+ throw tooManyAttributes();
+ }
+ companyName = value;
+ }
+
+
+ /**
+ * Sets internal name. Internal name will automatically be
+ * specified from build step, only set this value if
+ * intentionally overriding that value.
+ *
+ * @param value new value
+ * @throws BuildException if specified with refid
+ */
+ public void setInternalname(String value) throws BuildException {
+ if (isReference()) {
+ throw tooManyAttributes();
+ }
+ internalName = value;
+ }
+
+ /**
+ * Sets legal copyright.
+ * @param value new value
+ * @throws BuildException if specified with refid
+ */
+ public void setLegalcopyright(String value) throws BuildException {
+ if (isReference()) {
+ throw tooManyAttributes();
+ }
+ legalCopyright = value;
+ }
+ /**
+ * Sets legal trademark.
+ * @param value new value
+ * @throws BuildException if specified with refid
+ */
+ public void setLegaltrademark(String value) throws BuildException {
+ if (isReference()) {
+ throw tooManyAttributes();
+ }
+ legalTrademark = value;
+ }
+ /**
+ * Sets original name. Only set this value if
+ * intentionally overriding the value from the build set.
+ *
+ * @param value new value
+ * @throws BuildException if specified with refid
+ */
+ public void setOriginalfilename(String value) throws BuildException {
+ if (isReference()) {
+ throw tooManyAttributes();
+ }
+ originalFilename = value;
+ }
+ /**
+ * Sets private build.
+ * @param value new value
+ * @throws BuildException if specified with refid
+ */
+ public void setPrivatebuild(String value) throws BuildException {
+ if (isReference()) {
+ throw tooManyAttributes();
+ }
+ privateBuild = value;
+ }
+ /**
+ * Sets product name.
+ * @param value new value
+ * @throws BuildException if specified with refid
+ */
+ public void setProductname(String value) throws BuildException {
+ if (isReference()) {
+ throw tooManyAttributes();
+ }
+ productName= value;
+ }
+ /**
+ * Sets private build.
+ * @param value new value
+ * @throws BuildException if specified with refid
+ */
+ public void setSpecialbuild(String value) throws BuildException {
+ if (isReference()) {
+ throw tooManyAttributes();
+ }
+ specialBuild = value;
+ }
+
+ /**
+ * Writes windows resource
+ * @param writer writer, may not be null.
+ * @param project project, may not be null
+ * @param executableName name of executable
+ */
+ public void writeResource(final Writer writer,
+ final Project p,
+ final String executableName) throws IOException {
+ // TODO:
+
+ }
+
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/arm/ADSCCompiler.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/arm/ADSCCompiler.java
new file mode 100644
index 0000000000..78489b8c31
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/arm/ADSCCompiler.java
@@ -0,0 +1,215 @@
+/*
+ *
+ * Copyright 2003-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.arm;
+import java.io.File;
+import java.util.Vector;
+
+import net.sf.antcontrib.cpptasks.CUtil;
+import net.sf.antcontrib.cpptasks.OptimizationEnum;
+import net.sf.antcontrib.cpptasks.compiler.CommandLineCCompiler;
+import net.sf.antcontrib.cpptasks.compiler.LinkType;
+import net.sf.antcontrib.cpptasks.compiler.Linker;
+
+import org.apache.tools.ant.types.Environment;
+/**
+ * Adapter for the ARM C Compilers
+ *
+ * See Doc No: ARM DUI 0151A, Issued: Nov 2001 at
+ * http://www.arm.com/arm/User_Guides?OpenDocument
+ *
+ * @author Curt Arnold
+ *
+ */
+public class ADSCCompiler extends CommandLineCCompiler {
+ /**
+ * Header file extensions
+ */
+ private static final String[] headerExtensions = new String[]{".h", ".hpp",
+ ".inl"};
+ /**
+ * Source file extensions
+ */
+ private static final String[] sourceExtensions = new String[]{".c", ".cc",
+ ".cpp", ".cxx", ".c++"};
+ /**
+ * Singleton for ARM 32-bit C compiler
+ */
+ private static final ADSCCompiler armcc = new ADSCCompiler("armcc", false,
+ null);
+ /**
+ * Singleton for ARM 32-bit C++ compiler
+ */
+ private static final ADSCCompiler armcpp = new ADSCCompiler("armcpp",
+ false, null);
+ /**
+ * Singleton for ARM 16-bit C compiler
+ */
+ private static final ADSCCompiler tcc = new ADSCCompiler("tcc", false, null);
+ /**
+ * Singleton for ARM 16-bit C++ compiler
+ */
+ private static final ADSCCompiler tcpp = new ADSCCompiler("tcpp", false,
+ null);
+ /**
+ * Singleton for ARM 32-bit C compiler
+ */
+ public static ADSCCompiler getArmCC() {
+ return armcc;
+ }
+ /**
+ * Singleton for ARM 32-bit C++ compiler
+ */
+ public static ADSCCompiler getArmCpp() {
+ return armcpp;
+ }
+ /**
+ * Singleton for ARM 16-bit C compiler
+ */
+ public static ADSCCompiler getThumbCC() {
+ return tcpp;
+ }
+ /**
+ * Singleton for ARM 16-bit C++ compiler
+ */
+ public static ADSCCompiler getThumbCpp() {
+ return tcpp;
+ }
+ private static void quoteFile(StringBuffer buf, String outPath) {
+ if (outPath.indexOf(' ') >= 0) {
+ buf.append('\"');
+ buf.append(outPath);
+ buf.append('\"');
+ } else {
+ buf.append(outPath);
+ }
+ }
+ /**
+ * Private constructor
+ *
+ * @param command
+ * executable name
+ * @param newEnvironment
+ * Change environment
+ * @param env
+ * New environment
+ */
+ private ADSCCompiler(String command, boolean newEnvironment, Environment env) {
+ super(command, "-vsn", sourceExtensions, headerExtensions, ".o", false,
+ null, newEnvironment, env);
+ }
+ /**
+ * Adds command switches for generic configuration options
+ *
+ * @see net.sf.antcontrib.cpptasks.compiler.CommandLineCompiler#addImpliedArgs(java.util.Vector,
+ * boolean, boolean, boolean,
+ * net.sf.antcontrib.cpptasks.compiler.LinkType)
+ */
+ protected void addImpliedArgs(Vector args,
+ final boolean debug,
+ final boolean multithreaded,
+ final boolean exceptions,
+ final LinkType linkType,
+ final Boolean rtti,
+ final OptimizationEnum optimization,
+ final Boolean defaultflag) {
+ if (debug) {
+ args.addElement("-g");
+ }
+ //
+ // didn't see anything about producing
+ // anything other than executables in the docs
+ if (linkType.isExecutable()) {
+ } else if (linkType.isSharedLibrary()) {
+ }
+ }
+ /**
+ * Adds flags that customize the warnings reported
+ *
+ * Compiler does not appear to have warning levels but ability to turn off
+ * specific errors by explicit switches, could fabricate levels by
+ * prioritizing errors.
+ *
+ * @see net.sf.antcontrib.cpptasks.compiler.CommandLineCompiler#addWarningSwitch(java.util.Vector,
+ * int)
+ */
+ protected void addWarningSwitch(Vector args, int warnings) {
+ }
+ /**
+ * Add command line options for preprocessor macro
+ *
+ * @see net.sf.antcontrib.cpptasks.compiler.CommandLineCompiler#getDefineSwitch(java.lang.StringBuffer,
+ * java.lang.String, java.lang.String)
+ */
+ protected void getDefineSwitch(StringBuffer buffer, String define,
+ String value) {
+ buffer.append("-D");
+ buffer.append(define);
+ if (value != null) {
+ buffer.append('=');
+ buffer.append(value);
+ }
+ }
+ /**
+ * ARMINC environment variable contains the default include path
+ *
+ * @see net.sf.antcontrib.cpptasks.compiler.CommandLineCompiler#getEnvironmentIncludePath()
+ */
+ protected File[] getEnvironmentIncludePath() {
+ return CUtil.getPathFromEnvironment("ARMINC", ";");
+ }
+ /**
+ * Returns command line option to specify include directory
+ *
+ */
+ protected String getIncludeDirSwitch(String source) {
+ StringBuffer buf = new StringBuffer("-I");
+ quoteFile(buf, source);
+ return buf.toString();
+ }
+ /*
+ * (non-Javadoc)
+ *
+ * @see net.sf.antcontrib.cpptasks.compiler.Processor#getLinker(net.sf.antcontrib.cpptasks.compiler.LinkType)
+ */
+ public Linker getLinker(LinkType type) {
+ if (type.isStaticLibrary()) {
+ return ADSLibrarian.getInstance();
+ }
+ if (type.isSharedLibrary()) {
+ return ADSLinker.getDllInstance();
+ }
+ return ADSLinker.getInstance();
+ }
+ /**
+ * Maximum command line length
+ *
+ * @see net.sf.antcontrib.cpptasks.compiler.CommandLineCompiler#getMaximumCommandLength()
+ */
+ public int getMaximumCommandLength() {
+ return 1000;
+ }
+ /*
+ * Adds command to undefine preprocessor macro
+ *
+ * @see net.sf.antcontrib.cpptasks.compiler.CommandLineCompiler#getUndefineSwitch(java.lang.StringBuffer,
+ * java.lang.String)
+ */
+ protected void getUndefineSwitch(StringBuffer buffer, String define) {
+ buffer.append("-U");
+ buffer.append(define);
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/arm/ADSLibrarian.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/arm/ADSLibrarian.java
new file mode 100644
index 0000000000..0ff53d309f
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/arm/ADSLibrarian.java
@@ -0,0 +1,160 @@
+/*
+ *
+ * Copyright 2003-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.arm;
+
+import java.io.File;
+import java.util.Vector;
+
+import net.sf.antcontrib.cpptasks.compiler.CommandLineLinker;
+import net.sf.antcontrib.cpptasks.compiler.LinkType;
+import net.sf.antcontrib.cpptasks.compiler.Linker;
+import net.sf.antcontrib.cpptasks.types.LibraryTypeEnum;
+
+/**
+ * Adapter for ARM Librarian
+ *
+ * @author Curt Arnold
+ */
+public class ADSLibrarian extends CommandLineLinker {
+
+ private static final ADSLibrarian instance = new ADSLibrarian();
+
+ public static ADSLibrarian getInstance() {
+ return instance;
+ }
+
+ private ADSLibrarian()
+ {
+ super("armar",null,
+ new String[] { ".o" }, new String[0], ".lib", false, null);
+ }
+
+ /* (non-Javadoc)
+ * @see net.sf.antcontrib.cpptasks.compiler.CommandLineLinker#addBase(long, java.util.Vector)
+ */
+ protected void addBase(long base, Vector args) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see net.sf.antcontrib.cpptasks.compiler.CommandLineLinker#addFixed(java.lang.Boolean, java.util.Vector)
+ */
+ protected void addFixed(Boolean fixed, Vector args) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see net.sf.antcontrib.cpptasks.compiler.CommandLineLinker#addImpliedArgs(boolean, net.sf.antcontrib.cpptasks.compiler.LinkType, java.util.Vector)
+ */
+ protected void addImpliedArgs(
+ boolean debug,
+ LinkType linkType,
+ Vector args,
+ Boolean defaultflag) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see net.sf.antcontrib.cpptasks.compiler.CommandLineLinker#addIncremental(boolean, java.util.Vector)
+ */
+ protected void addIncremental(boolean incremental, Vector args) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see net.sf.antcontrib.cpptasks.compiler.CommandLineLinker#addMap(boolean, java.util.Vector)
+ */
+ protected void addMap(boolean map, Vector args) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see net.sf.antcontrib.cpptasks.compiler.CommandLineLinker#addStack(int, java.util.Vector)
+ */
+ protected void addStack(int stack, Vector args) {
+ // TODO Auto-generated method stub
+
+ }
+ /* (non-Javadoc)
+ * @see net.sf.antcontrib.cpptasks.compiler.CommandLineLinker#addEntry(int, java.util.Vector)
+ */
+ protected void addEntry(String entry, Vector args) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see net.sf.antcontrib.cpptasks.compiler.CommandLineLinker#getCommandFileSwitch(java.lang.String)
+ */
+ protected String getCommandFileSwitch(String commandFile) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see net.sf.antcontrib.cpptasks.compiler.Linker#getLibraryPath()
+ */
+ public File[] getLibraryPath() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see net.sf.antcontrib.cpptasks.compiler.Linker#getLibraryPatterns(java.lang.String[])
+ */
+ public String[] getLibraryPatterns(String[] libnames, LibraryTypeEnum libType) {
+ return new String[0];
+ }
+
+ /* (non-Javadoc)
+ * @see net.sf.antcontrib.cpptasks.compiler.Processor#getLinker(net.sf.antcontrib.cpptasks.compiler.LinkType)
+ */
+ public Linker getLinker(LinkType linkType) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see net.sf.antcontrib.cpptasks.compiler.CommandLineLinker#getMaximumCommandLength()
+ */
+ protected int getMaximumCommandLength() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ /* (non-Javadoc)
+ * @see net.sf.antcontrib.cpptasks.compiler.CommandLineLinker#getOutputFileSwitch(java.lang.String)
+ */
+ protected String[] getOutputFileSwitch(String outputFile) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see net.sf.antcontrib.cpptasks.compiler.Linker#isCaseSensitive()
+ */
+ public boolean isCaseSensitive() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/arm/ADSLinker.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/arm/ADSLinker.java
new file mode 100644
index 0000000000..042eb217ec
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/arm/ADSLinker.java
@@ -0,0 +1,166 @@
+/*
+ *
+ * Copyright 2003-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.arm;
+import java.io.File;
+import java.util.Vector;
+
+import net.sf.antcontrib.cpptasks.CUtil;
+import net.sf.antcontrib.cpptasks.compiler.CommandLineLinker;
+import net.sf.antcontrib.cpptasks.compiler.LinkType;
+import net.sf.antcontrib.cpptasks.compiler.Linker;
+import net.sf.antcontrib.cpptasks.types.LibraryTypeEnum;
+
+/**
+ * Adapter for the ARM Linker
+ *
+ * @author CurtA
+ */
+public class ADSLinker extends CommandLineLinker {
+ private static final ADSLinker dllInstance = new ADSLinker(".o");
+ private static final ADSLinker instance = new ADSLinker(".axf");
+ public static ADSLinker getDllInstance() {
+ return dllInstance;
+ }
+ public static ADSLinker getInstance() {
+ return instance;
+ }
+ private ADSLinker(String outputSuffix) {
+ super("armlink", "-vsn", new String[]{".o", ".lib", ".res"},
+ new String[]{".map", ".pdb", ".lnk"}, outputSuffix, false, null);
+ }
+ /*
+ * (non-Javadoc)
+ *
+ * @see net.sf.antcontrib.cpptasks.compiler.CommandLineLinker#addBase(long,
+ * java.util.Vector)
+ */
+ protected void addBase(long base, Vector args) {
+ // TODO Auto-generated method stub
+ }
+ /*
+ * (non-Javadoc)
+ *
+ * @see net.sf.antcontrib.cpptasks.compiler.CommandLineLinker#addFixed(java.lang.Boolean,
+ * java.util.Vector)
+ */
+ protected void addFixed(Boolean fixed, Vector args) {
+ // TODO Auto-generated method stub
+ }
+ /*
+ * (non-Javadoc)
+ *
+ * @see net.sf.antcontrib.cpptasks.compiler.CommandLineLinker#addImpliedArgs(boolean,
+ * net.sf.antcontrib.cpptasks.compiler.LinkType, java.util.Vector)
+ */
+ protected void addImpliedArgs(boolean debug, LinkType linkType, Vector args, Boolean defaultflag) {
+ if (debug) {
+ args.addElement("-debug");
+ }
+ }
+ /*
+ * (non-Javadoc)
+ *
+ * @see net.sf.antcontrib.cpptasks.compiler.CommandLineLinker#addIncremental(boolean,
+ * java.util.Vector)
+ */
+ protected void addIncremental(boolean incremental, Vector args) {
+ // TODO Auto-generated method stub
+ }
+ /*
+ * (non-Javadoc)
+ *
+ * @see net.sf.antcontrib.cpptasks.compiler.CommandLineLinker#addMap(boolean,
+ * java.util.Vector)
+ */
+ protected void addMap(boolean map, Vector args) {
+ // TODO Auto-generated method stub
+ }
+ /*
+ * (non-Javadoc)
+ *
+ * @see net.sf.antcontrib.cpptasks.compiler.CommandLineLinker#addStack(int,
+ * java.util.Vector)
+ */
+ protected void addStack(int stack, Vector args) {
+ // TODO Auto-generated method stub
+ }
+ /* (non-Javadoc)
+ * @see net.sf.antcontrib.cpptasks.compiler.CommandLineLinker#addEntry(int, java.util.Vector)
+ */
+ protected void addEntry(String entry, Vector args) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /**
+ * May have to make this String array return
+ *
+ * @see net.sf.antcontrib.cpptasks.compiler.CommandLineLinker#getCommandFileSwitch(java.lang.String)
+ */
+ protected String getCommandFileSwitch(String commandFile) {
+ return "-via" + commandFile;
+ }
+ /*
+ * (non-Javadoc)
+ *
+ * @see net.sf.antcontrib.cpptasks.compiler.Linker#getLibraryPath()
+ */
+ public File[] getLibraryPath() {
+ return CUtil.getPathFromEnvironment("ARMLIB", ";");
+ }
+ /*
+ * @see net.sf.antcontrib.cpptasks.compiler.Linker#getLibraryPatterns(java.lang.String[])
+ */
+ public String[] getLibraryPatterns(String[] libnames, LibraryTypeEnum libType) {
+ //
+ // TODO: looks like bad extension
+ //
+ return new String[]{".o"};
+ }
+ /*
+ * (non-Javadoc)
+ *
+ * @see net.sf.antcontrib.cpptasks.compiler.Processor#getLinker(net.sf.antcontrib.cpptasks.compiler.LinkType)
+ */
+ public Linker getLinker(LinkType linkType) {
+ return this;
+ }
+ /*
+ * (non-Javadoc)
+ *
+ * @see net.sf.antcontrib.cpptasks.compiler.CommandLineLinker#getMaximumCommandLength()
+ */
+ protected int getMaximumCommandLength() {
+ return 1024;
+ }
+ /*
+ * (non-Javadoc)
+ *
+ * @see net.sf.antcontrib.cpptasks.compiler.CommandLineLinker#getOutputFileSwitch(java.lang.String)
+ */
+ protected String[] getOutputFileSwitch(String outputFile) {
+ return new String[]{"-output", outputFile};
+ }
+ /*
+ * (non-Javadoc)
+ *
+ * @see net.sf.antcontrib.cpptasks.compiler.Linker#isCaseSensitive()
+ */
+ public boolean isCaseSensitive() {
+ return false;
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/borland/BorlandCCompiler.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/borland/BorlandCCompiler.java
new file mode 100644
index 0000000000..3304c9a860
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/borland/BorlandCCompiler.java
@@ -0,0 +1,135 @@
+/*
+ *
+ * Copyright 2002-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.borland;
+import java.io.File;
+import java.util.Vector;
+
+import net.sf.antcontrib.cpptasks.compiler.CommandLineCompilerConfiguration;
+import net.sf.antcontrib.cpptasks.compiler.CompilerConfiguration;
+import net.sf.antcontrib.cpptasks.compiler.LinkType;
+import net.sf.antcontrib.cpptasks.compiler.Linker;
+import net.sf.antcontrib.cpptasks.compiler.PrecompilingCommandLineCCompiler;
+import net.sf.antcontrib.cpptasks.compiler.Processor;
+import net.sf.antcontrib.cpptasks.OptimizationEnum;
+
+import org.apache.tools.ant.types.Environment;
+/**
+ * Adapter for the Borland(r) C/C++ compiler.
+ *
+ * @author Curt Arnold
+ */
+public class BorlandCCompiler extends PrecompilingCommandLineCCompiler {
+ private static final String[] headerExtensions = new String[]{".h", ".hpp",
+ ".inl"};
+ private static final String[] sourceExtensions = new String[]{".c", ".cc",
+ ".cpp", ".cxx", ".c++"};
+ private static final BorlandCCompiler instance = new BorlandCCompiler(
+ false, null);
+ public static BorlandCCompiler getInstance() {
+ return instance;
+ }
+ private BorlandCCompiler(boolean newEnvironment, Environment env) {
+ super("bcc32", "--version", sourceExtensions, headerExtensions, ".obj", false,
+ null, newEnvironment, env);
+ }
+ protected void addImpliedArgs(final Vector args,
+ final boolean debug,
+ final boolean multithreaded,
+ final boolean exceptions,
+ final LinkType linkType,
+ final Boolean rtti,
+ final OptimizationEnum optimization,
+ final Boolean defaultflag) {
+ args.addElement("-c");
+ //
+ // turn off compiler autodependency since
+ // we do it ourselves
+ args.addElement("-X");
+ if (exceptions) {
+ args.addElement("-x");
+ } else {
+ args.addElement("-x-");
+ }
+ if (multithreaded) {
+ args.addElement("-tWM");
+ }
+ if (debug) {
+ args.addElement("-Od");
+ args.addElement("-v");
+ } else {
+ if (optimization != null) {
+ if (optimization.isSpeed()) {
+ args.addElement("-O1");
+ } else {
+ if (optimization.isSpeed()) {
+ args.addElement("-O2");
+ } else {
+ if (optimization.isNoOptimization()) {
+ args.addElement("-Od");
+ }
+ }
+ }
+ }
+ }
+ if (rtti != null && !rtti.booleanValue()) {
+ args.addElement("-RT-");
+ }
+ }
+ protected void addWarningSwitch(Vector args, int level) {
+ BorlandProcessor.addWarningSwitch(args, level);
+ }
+ public Processor changeEnvironment(boolean newEnvironment, Environment env) {
+ if (newEnvironment || env != null) {
+ return new BorlandCCompiler(newEnvironment, env);
+ }
+ return this;
+ }
+ protected CompilerConfiguration createPrecompileGeneratingConfig(
+ CommandLineCompilerConfiguration baseConfig, File prototype,
+ String lastInclude) {
+ String[] additionalArgs = new String[]{"-H=" + lastInclude, "-Hc"};
+ return new CommandLineCompilerConfiguration(baseConfig, additionalArgs,
+ null, true);
+ }
+ protected CompilerConfiguration createPrecompileUsingConfig(
+ CommandLineCompilerConfiguration baseConfig, File prototype,
+ String lastInclude, String[] exceptFiles) {
+ String[] additionalArgs = new String[]{"-Hu"};
+ return new CommandLineCompilerConfiguration(baseConfig, additionalArgs,
+ exceptFiles, false);
+ }
+ protected void getDefineSwitch(StringBuffer buffer, String define,
+ String value) {
+ BorlandProcessor.getDefineSwitch(buffer, define, value);
+ }
+ protected File[] getEnvironmentIncludePath() {
+ return BorlandProcessor.getEnvironmentPath("bcc32", 'I',
+ new String[]{"..\\include"});
+ }
+ protected String getIncludeDirSwitch(String includeDir) {
+ return BorlandProcessor.getIncludeDirSwitch("-I", includeDir);
+ }
+ public Linker getLinker(LinkType type) {
+ return BorlandLinker.getInstance().getLinker(type);
+ }
+ public int getMaximumCommandLength() {
+ return 1024;
+ }
+ protected void getUndefineSwitch(StringBuffer buffer, String define) {
+ BorlandProcessor.getUndefineSwitch(buffer, define);
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/borland/BorlandCfgParser.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/borland/BorlandCfgParser.java
new file mode 100644
index 0000000000..19daedd203
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/borland/BorlandCfgParser.java
@@ -0,0 +1,70 @@
+/*
+ *
+ * Copyright 2002-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.borland;
+import java.io.IOException;
+import java.io.Reader;
+import java.util.Vector;
+
+import net.sf.antcontrib.cpptasks.parser.AbstractParser;
+import net.sf.antcontrib.cpptasks.parser.AbstractParserState;
+import net.sf.antcontrib.cpptasks.parser.LetterState;
+import net.sf.antcontrib.cpptasks.parser.WhitespaceOrLetterState;
+/**
+ * A parser that paths from a borland cfg file
+ *
+ * @author Curt Arnold
+ */
+public final class BorlandCfgParser extends AbstractParser {
+ private AbstractParserState newLineState;
+ private final Vector path = new Vector();
+ /**
+ *
+ *
+ */
+ public BorlandCfgParser(char switchChar) {
+ //
+ // a quoted path (-I"some path")
+ // doesn't end till a close quote and will be abandoned
+ // if a new line is encountered first
+ //
+ AbstractParserState quote = new CfgFilenameState(this, new char[]{'"'});
+ //
+ // an unquoted path (-Ic:\borland\include)
+ // ends at the first space or new line
+ AbstractParserState unquote = new CfgFilenameState(this, new char[]{
+ ' ', '\n', '\r'});
+ AbstractParserState quoteBranch = new QuoteBranchState(this, quote,
+ unquote);
+ AbstractParserState toNextSwitch = new ConsumeToSpaceOrNewLine(this);
+ AbstractParserState switchState = new LetterState(this, switchChar,
+ quoteBranch, toNextSwitch);
+ newLineState = new WhitespaceOrLetterState(this, '-', switchState);
+ }
+ public void addFilename(String include) {
+ path.addElement(include);
+ }
+ public AbstractParserState getNewLineState() {
+ return newLineState;
+ }
+ public String[] parsePath(Reader reader) throws IOException {
+ path.setSize(0);
+ super.parse(reader);
+ String[] retval = new String[path.size()];
+ path.copyInto(retval);
+ return retval;
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/borland/BorlandLibrarian.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/borland/BorlandLibrarian.java
new file mode 100644
index 0000000000..5fb3eb0827
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/borland/BorlandLibrarian.java
@@ -0,0 +1,200 @@
+/*
+ *
+ * Copyright 2002-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.borland;
+import java.io.File;
+import java.io.IOException;
+import java.util.Vector;
+import org.apache.tools.ant.BuildException;
+
+import net.sf.antcontrib.cpptasks.CUtil;
+import net.sf.antcontrib.cpptasks.compiler.CommandLineLinker;
+import net.sf.antcontrib.cpptasks.compiler.LinkType;
+import net.sf.antcontrib.cpptasks.compiler.Linker;
+import net.sf.antcontrib.cpptasks.CCTask;
+import net.sf.antcontrib.cpptasks.compiler.CommandLineLinkerConfiguration;
+import net.sf.antcontrib.cpptasks.types.LibraryTypeEnum;
+
+/**
+ * Adapter for the Borland(r) tlib Librarian
+ *
+ * @author Curt Arnold
+ */
+public class BorlandLibrarian extends CommandLineLinker {
+ private static final BorlandLibrarian instance = new BorlandLibrarian();
+ public static BorlandLibrarian getInstance() {
+ return instance;
+ }
+ private BorlandLibrarian() {
+ super("tlib", "--version", new String[]{".obj"}, new String[0], ".lib", false,
+ null);
+ }
+ protected void addBase(long base, Vector args) {
+ }
+ protected void addFixed(Boolean fixed, Vector args) {
+ }
+ protected void addImpliedArgs(boolean debug, LinkType linkType, Vector args, Boolean defaultflag) {
+ }
+ protected void addIncremental(boolean incremental, Vector args) {
+ }
+ protected void addMap(boolean map, Vector args) {
+ }
+ protected void addStack(int stack, Vector args) {
+ }
+ /* (non-Javadoc)
+ * @see net.sf.antcontrib.cpptasks.compiler.CommandLineLinker#addEntry(int, java.util.Vector)
+ */
+ protected void addEntry(String entry, Vector args) {
+ }
+
+ protected String getCommandFileSwitch(String cmdFile) {
+ return BorlandProcessor.getCommandFileSwitch(cmdFile);
+ }
+ public File[] getLibraryPath() {
+ return CUtil.getPathFromEnvironment("LIB", ";");
+ }
+ public String[] getLibraryPatterns(String[] libnames, LibraryTypeEnum libType) {
+ return BorlandProcessor.getLibraryPatterns(libnames, libType);
+ }
+ public Linker getLinker(LinkType type) {
+ return BorlandLinker.getInstance().getLinker(type);
+ }
+ public int getMaximumCommandLength() {
+ return 1024;
+ }
+ public String[] getOutputFileSwitch(String outFile) {
+ return BorlandProcessor.getOutputFileSwitch(outFile);
+ }
+ public boolean isCaseSensitive() {
+ return BorlandProcessor.isCaseSensitive();
+ }
+ /**
+ * Gets identifier for the linker.
+ *
+ * TLIB will lockup when attempting to get version
+ * information. Since the Librarian version isn't critical
+ * just return a stock response.
+ */
+ public String getIdentifier() {
+ return "TLIB 4.5 Copyright (c) 1987, 1999 Inprise Corporation";
+ }
+
+ /**
+ * Prepares argument list for exec command.
+ *
+ * @param outputFile
+ * linker output file
+ * @param sourceFiles
+ * linker input files (.obj, .o, .res)
+ * @param args
+ * linker arguments
+ * @return arguments for runTask
+ */
+ protected String[] prepareArguments(
+ CCTask task,
+ String outputDir,
+ String outputName,
+ String[] sourceFiles,
+ CommandLineLinkerConfiguration config) {
+ String[] preargs = config.getPreArguments();
+ String[] endargs = config.getEndArguments();
+ StringBuffer buf = new StringBuffer();
+ Vector execArgs = new Vector(preargs.length + endargs.length + 10
+ + sourceFiles.length);
+
+ execArgs.addElement(this.getCommand());
+ String outputFileName = new File(outputDir, outputName).toString();
+ execArgs.addElement(quoteFilename(buf, outputFileName));
+
+ for (int i = 0; i < preargs.length; i++) {
+ execArgs.addElement(preargs[i]);
+ }
+
+ //
+ // add a place-holder for page size
+ //
+ int pageSizeIndex = execArgs.size();
+ execArgs.addElement(null);
+
+ int objBytes = 0;
+
+ for (int i = 0; i < sourceFiles.length; i++) {
+ String last4 = sourceFiles[i]
+ .substring(sourceFiles[i].length() - 4).toLowerCase();
+ if (last4.equals(".def")) {
+ } else {
+ if (last4.equals(".res")) {
+ } else {
+ if (last4.equals(".lib")) {
+ } else {
+ execArgs.addElement("+" + quoteFilename(buf, sourceFiles[i]));
+ objBytes += new File(sourceFiles[i]).length();
+ }
+ }
+ }
+ }
+
+ for (int i = 0; i < endargs.length; i++) {
+ execArgs.addElement(endargs[i]);
+ }
+
+ String[] execArguments = new String[execArgs.size()];
+ execArgs.copyInto(execArguments);
+
+ int minPageSize = objBytes >> 16;
+ int pageSize = 0;
+ for(int i = 4; i <= 15; i++) {
+ pageSize = 1 << i;
+ if (pageSize > minPageSize) break;
+ }
+ execArguments[pageSizeIndex] = "/P" + Integer.toString(pageSize);
+
+ return execArguments;
+ }
+
+ /**
+ * Prepares argument list to execute the linker using a response file.
+ *
+ * @param outputFile
+ * linker output file
+ * @param args
+ * output of prepareArguments
+ * @return arguments for runTask
+ */
+ protected String[] prepareResponseFile(File outputFile, String[] args)
+ throws IOException {
+ return BorlandProcessor.prepareResponseFile(outputFile, args, " & \n");
+ }
+
+ /**
+ * Builds a library
+ *
+ */
+ public void link(CCTask task,
+ File outputFile,
+ String[] sourceFiles,
+ CommandLineLinkerConfiguration config)
+ throws BuildException
+ {
+ //
+ // delete any existing library
+ outputFile.delete();
+ //
+ // build a new library
+ super.link(task, outputFile, sourceFiles, config);
+ }
+
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/borland/BorlandLinker.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/borland/BorlandLinker.java
new file mode 100644
index 0000000000..f425c528bd
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/borland/BorlandLinker.java
@@ -0,0 +1,264 @@
+/*
+ *
+ * Copyright 2002-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.borland;
+import java.io.File;
+import java.io.IOException;
+import java.util.Enumeration;
+import java.util.Vector;
+
+import net.sf.antcontrib.cpptasks.CCTask;
+import net.sf.antcontrib.cpptasks.compiler.CommandLineLinker;
+import net.sf.antcontrib.cpptasks.compiler.CommandLineLinkerConfiguration;
+import net.sf.antcontrib.cpptasks.compiler.LinkType;
+import net.sf.antcontrib.cpptasks.compiler.Linker;
+import net.sf.antcontrib.cpptasks.types.LibraryTypeEnum;
+
+/**
+ * Adapter for the Borland(r) ilink32 linker
+ *
+ * @author Curt Arnold
+ */
+public final class BorlandLinker extends CommandLineLinker {
+ private static final BorlandLinker dllLinker = new BorlandLinker(".dll");
+ private static final BorlandLinker instance = new BorlandLinker(".exe");
+ public static BorlandLinker getInstance() {
+ return instance;
+ }
+ private BorlandLinker(String outputSuffix) {
+ super("ilink32", "-r", new String[]{".obj", ".lib", ".res"},
+ new String[]{".map", ".pdb", ".lnk"}, outputSuffix, false, null);
+ }
+ protected void addBase(long base, Vector args) {
+ if (base >= 0) {
+ String baseAddr = Long.toHexString(base);
+ args.addElement("-b:" + baseAddr);
+ }
+ }
+ protected void addFixed(Boolean fixed, Vector args) {
+ }
+ protected void addImpliedArgs(boolean debug, LinkType linkType, Vector args, Boolean defaultflag) {
+ if (linkType.isExecutable()) {
+ if (linkType.isSubsystemConsole()) {
+ args.addElement("/ap");
+ } else {
+ if (linkType.isSubsystemGUI()) {
+ args.addElement("/Tpe");
+ }
+ }
+ }
+ if (linkType.isSharedLibrary()) {
+ args.addElement("/Tpd");
+ args.addElement("/Gi");
+ }
+ }
+ protected void addIncremental(boolean incremental, Vector args) {
+ }
+ protected void addMap(boolean map, Vector args) {
+ if (!map) {
+ args.addElement("-x");
+ }
+ }
+ protected void addStack(int stack, Vector args) {
+ if (stack >= 0) {
+ String stackStr = Integer.toHexString(stack);
+ args.addElement("-S:" + stackStr);
+ }
+ }
+ /* (non-Javadoc)
+ * @see net.sf.antcontrib.cpptasks.compiler.CommandLineLinker#addEntry(int, java.util.Vector)
+ */
+ protected void addEntry(String entry, Vector args) {
+ }
+
+ public String getCommandFileSwitch(String commandFile) {
+ return "@" + commandFile;
+ }
+ public String getIdentifier() {
+ return "Borland Linker";
+ }
+ public File[] getLibraryPath() {
+ return BorlandProcessor.getEnvironmentPath("ilink32", 'L',
+ new String[]{"..\\lib"});
+ }
+ public String[] getLibraryPatterns(String[] libnames, LibraryTypeEnum libType) {
+ return BorlandProcessor.getLibraryPatterns(libnames, libType);
+ }
+ public Linker getLinker(LinkType type) {
+ if (type.isStaticLibrary()) {
+ return BorlandLibrarian.getInstance();
+ }
+ if (type.isSharedLibrary()) {
+ return dllLinker;
+ }
+ return instance;
+ }
+ public int getMaximumCommandLength() {
+ return 1024;
+ }
+ public String[] getOutputFileSwitch(String outFile) {
+ return BorlandProcessor.getOutputFileSwitch(outFile);
+ }
+ protected String getStartupObject(LinkType linkType) {
+ if (linkType.isSharedLibrary()) {
+ return "c0d32.obj";
+ }
+ if (linkType.isSubsystemGUI()) {
+ return "c0w32.obj";
+ }
+ if (linkType.isSubsystemConsole()) {
+ return "c0x32.obj";
+ }
+ return null;
+ }
+ public boolean isCaseSensitive() {
+ return BorlandProcessor.isCaseSensitive();
+ }
+ /**
+ * Prepares argument list for exec command.
+ *
+ * @param outputFile
+ * linker output file
+ * @param sourceFiles
+ * linker input files (.obj, .o, .res)
+ * @param args
+ * linker arguments
+ * @return arguments for runTask
+ */
+ protected String[] prepareArguments(
+ CCTask task,
+ String outputDir,
+ String outputName,
+ String[] sourceFiles,
+ CommandLineLinkerConfiguration config) {
+ String[] preargs = config.getPreArguments();
+ String[] endargs = config.getEndArguments();
+ Vector execArgs = new Vector(preargs.length + endargs.length + 10
+ + sourceFiles.length);
+ execArgs.addElement(this.getCommand());
+ for (int i = 0; i < preargs.length; i++) {
+ execArgs.addElement(preargs[i]);
+ }
+ for (int i = 0; i < endargs.length; i++) {
+ execArgs.addElement(endargs[i]);
+ }
+ //
+ // see if the input files have any known startup obj files
+ //
+ String startup = null;
+ for (int i = 0; i < sourceFiles.length; i++) {
+ String filename = new File(sourceFiles[i]).getName().toLowerCase();
+ if (startup != null && filename.substring(0, 2).equals("c0")
+ && filename.substring(3, 5).equals("32")
+ && filename.substring(filename.length() - 4).equals(".obj")) {
+ startup = sourceFiles[i];
+ }
+ }
+ //
+ // c0w32.obj, c0x32.obj or c0d32.obj depending on
+ // link type
+ if (startup == null) {
+ startup = config.getStartupObject();
+ }
+ execArgs.addElement(startup);
+ Vector resFiles = new Vector();
+ Vector libFiles = new Vector();
+ String defFile = null;
+ StringBuffer buf = new StringBuffer();
+ for (int i = 0; i < sourceFiles.length; i++) {
+ String last4 = sourceFiles[i]
+ .substring(sourceFiles[i].length() - 4).toLowerCase();
+ if (last4.equals(".def")) {
+ defFile = quoteFilename(buf, sourceFiles[i]);
+ } else {
+ if (last4.equals(".res")) {
+ resFiles.addElement(quoteFilename(buf, sourceFiles[i]));
+ } else {
+ if (last4.equals(".lib")) {
+ libFiles.addElement(quoteFilename(buf, sourceFiles[i]));
+ } else {
+ execArgs.addElement(quoteFilename(buf, sourceFiles[i]));
+ }
+ }
+ }
+ }
+ //
+ // output file name
+ //
+ String outputFileName = new File(outputDir, outputName).toString();
+ execArgs.addElement("," + quoteFilename(buf, outputFileName));
+ if (config.getMap()) {
+ int lastPeriod = outputFileName.lastIndexOf('.');
+ String mapName;
+ if (lastPeriod < outputFileName.length() - 4) {
+ mapName = outputFileName + ".map";
+ } else {
+ mapName = outputFileName.substring(0, lastPeriod) + ".map";
+ }
+ execArgs.addElement("," + quoteFilename(buf, mapName) + ",");
+ } else {
+ execArgs.addElement(",,");
+ }
+ //
+ // add all the libraries
+ //
+ Enumeration libEnum = libFiles.elements();
+ boolean hasImport32 = false;
+ boolean hasCw32 = false;
+ while (libEnum.hasMoreElements()) {
+ String libName = (String) libEnum.nextElement();
+ if (libName.equalsIgnoreCase("import32.lib")) {
+ hasImport32 = true;
+ }
+ if (libName.equalsIgnoreCase("cw32.lib")) {
+ hasImport32 = true;
+ }
+ execArgs.addElement(quoteFilename(buf, libName));
+ }
+ if (!hasCw32) {
+ execArgs.addElement(quoteFilename(buf, "cw32.lib"));
+ }
+ if (!hasImport32) {
+ execArgs.addElement(quoteFilename(buf, "import32.lib"));
+ }
+ if (defFile == null) {
+ execArgs.addElement(",,");
+ } else {
+ execArgs.addElement("," + quoteFilename(buf, defFile) + ",");
+ }
+ Enumeration resEnum = resFiles.elements();
+ while (resEnum.hasMoreElements()) {
+ String resName = (String) resEnum.nextElement();
+ execArgs.addElement(quoteFilename(buf, resName));
+ }
+ String[] execArguments = new String[execArgs.size()];
+ execArgs.copyInto(execArguments);
+ return execArguments;
+ }
+ /**
+ * Prepares argument list to execute the linker using a response file.
+ *
+ * @param outputFile
+ * linker output file
+ * @param args
+ * output of prepareArguments
+ * @return arguments for runTask
+ */
+ protected String[] prepareResponseFile(File outputFile, String[] args)
+ throws IOException {
+ return BorlandProcessor.prepareResponseFile(outputFile, args, " + \n");
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/borland/BorlandProcessor.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/borland/BorlandProcessor.java
new file mode 100644
index 0000000000..d53f00cc12
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/borland/BorlandProcessor.java
@@ -0,0 +1,219 @@
+/*
+ *
+ * Copyright 2002-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.borland;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.Reader;
+import java.util.Vector;
+import java.io.FileWriter;
+
+import net.sf.antcontrib.cpptasks.CUtil;
+import net.sf.antcontrib.cpptasks.types.LibraryTypeEnum;
+/**
+ * A add-in class for Borland(r) processor adapters
+ *
+ *
+ */
+public final class BorlandProcessor {
+ public static void addWarningSwitch(Vector args, int level) {
+ switch (level) {
+ case 0 :
+ args.addElement("-w-");
+ break;
+ case 5 :
+ args.addElement("-w!");
+ break;
+ default :
+ args.addElement("-w");
+ break;
+ }
+ }
+ public static String getCommandFileSwitch(String cmdFile) {
+ StringBuffer buf = new StringBuffer("@");
+ quoteFile(buf, cmdFile);
+ return buf.toString();
+ }
+ public static void getDefineSwitch(StringBuffer buffer, String define,
+ String value) {
+ buffer.append("-D");
+ buffer.append(define);
+ if (value != null && value.length() > 0) {
+ buffer.append('=');
+ buffer.append(value);
+ }
+ }
+ /**
+ * This method extracts path information from the appropriate .cfg file in
+ * the install directory.
+ *
+ * @param toolName
+ * Tool name, for example, "bcc32", "brc32", "ilink32"
+ * @param switchChar
+ * Command line switch character, for example "L" for libraries
+ * @param defaultRelativePaths
+ * default paths relative to executable directory
+ * @return path
+ */
+ public static File[] getEnvironmentPath(String toolName, char switchChar,
+ String[] defaultRelativePath) {
+ if (toolName == null) {
+ throw new NullPointerException("toolName");
+ }
+ if (defaultRelativePath == null) {
+ throw new NullPointerException("defaultRelativePath");
+ }
+ String[] path = defaultRelativePath;
+ File exeDir = CUtil.getExecutableLocation(toolName + ".exe");
+ if (exeDir != null) {
+ File cfgFile = new File(exeDir, toolName + ".cfg");
+ if (cfgFile.exists()) {
+ try {
+ Reader reader = new BufferedReader(new FileReader(cfgFile));
+ BorlandCfgParser cfgParser = new BorlandCfgParser(
+ switchChar);
+ path = cfgParser.parsePath(reader);
+ reader.close();
+ } catch (IOException ex) {
+ //
+ // could be logged
+ //
+ }
+ }
+ } else {
+ //
+ // if can't find the executable,
+ // assume current directory to resolve relative paths
+ //
+ exeDir = new File(System.getProperty("user.dir"));
+ }
+ int nonExistant = 0;
+ File[] resourcePath = new File[path.length];
+ for (int i = 0; i < path.length; i++) {
+ resourcePath[i] = new File(path[i]);
+ if (!resourcePath[i].isAbsolute()) {
+ resourcePath[i] = new File(exeDir, path[i]);
+ }
+ //
+ // if any of the entries do not exist or are
+ // not directories, null them out
+ if (!(resourcePath[i].exists() && resourcePath[i].isDirectory())) {
+ resourcePath[i] = null;
+ nonExistant++;
+ }
+ }
+ //
+ // if there were some non-existant or non-directory
+ // entries in the configuration file then
+ // create a shorter array
+ if (nonExistant > 0) {
+ File[] culled = new File[resourcePath.length - nonExistant];
+ int index = 0;
+ for (int i = 0; i < resourcePath.length; i++) {
+ if (resourcePath[i] != null) {
+ culled[index++] = resourcePath[i];
+ }
+ }
+ resourcePath = culled;
+ }
+ return resourcePath;
+ }
+ public static String getIncludeDirSwitch(String includeOption,
+ String includeDir) {
+ StringBuffer buf = new StringBuffer(includeOption);
+ quoteFile(buf, includeDir);
+ return buf.toString();
+ }
+ public static String[] getLibraryPatterns(String[] libnames, LibraryTypeEnum libType) {
+ StringBuffer buf = new StringBuffer();
+ String[] patterns = new String[libnames.length];
+ for (int i = 0; i < libnames.length; i++) {
+ buf.setLength(0);
+ buf.append(libnames[i]);
+ buf.append(".lib");
+ patterns[i] = buf.toString();
+ }
+ return patterns;
+ }
+ public static String[] getOutputFileSwitch(String outFile) {
+ return new String[0];
+ }
+ public static void getUndefineSwitch(StringBuffer buffer, String define) {
+ buffer.append("-U");
+ buffer.append(define);
+ }
+ public static boolean isCaseSensitive() {
+ return false;
+ }
+ private static void quoteFile(StringBuffer buf, String outPath) {
+ if (outPath.indexOf(' ') >= 0) {
+ buf.append('\"');
+ buf.append(outPath);
+ buf.append('\"');
+ } else {
+ buf.append(outPath);
+ }
+ }
+
+ /**
+ * Prepares argument list to execute the linker using a response file.
+ *
+ * @param outputFile
+ * linker output file
+ * @param args
+ * output of prepareArguments
+ * @return arguments for runTask
+ */
+ public static String[] prepareResponseFile(File outputFile,
+ String[] args,
+ String continuation)
+ throws IOException {
+ String baseName = outputFile.getName();
+ File commandFile = new File(outputFile.getParent(), baseName + ".lnk");
+ FileWriter writer = new FileWriter(commandFile);
+ for (int i = 1; i < args.length - 1; i++) {
+ writer.write(args[i]);
+ //
+ // if either the current argument ends with
+ // or next argument starts with a comma then
+ // don't split the line
+ if (args[i].endsWith(",") || args[i + 1].startsWith(",")) {
+ writer.write(' ');
+ } else {
+ //
+ // split the line to make it more readable
+ //
+ writer.write(continuation);
+ }
+ }
+ //
+ // write the last argument
+ //
+ if (args.length > 1) {
+ writer.write(args[args.length - 1]);
+ }
+ writer.close();
+ String[] execArgs = new String[2];
+ execArgs[0] = args[0];
+ execArgs[1] = getCommandFileSwitch(commandFile.toString());
+ return execArgs;
+ }
+
+ private BorlandProcessor() {
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/borland/BorlandResourceCompiler.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/borland/BorlandResourceCompiler.java
new file mode 100644
index 0000000000..5e8609797e
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/borland/BorlandResourceCompiler.java
@@ -0,0 +1,130 @@
+/*
+ *
+ * Copyright 2002-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.borland;
+import java.io.File;
+import java.util.Vector;
+import net.sf.antcontrib.cpptasks.CCTask;
+import net.sf.antcontrib.cpptasks.compiler.CommandLineCompiler;
+import net.sf.antcontrib.cpptasks.compiler.CommandLineCompilerConfiguration;
+import net.sf.antcontrib.cpptasks.compiler.LinkType;
+import net.sf.antcontrib.cpptasks.compiler.Linker;
+import net.sf.antcontrib.cpptasks.compiler.Processor;
+import net.sf.antcontrib.cpptasks.compiler.ProgressMonitor;
+import net.sf.antcontrib.cpptasks.parser.CParser;
+import net.sf.antcontrib.cpptasks.parser.Parser;
+import net.sf.antcontrib.cpptasks.OptimizationEnum;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.types.Environment;
+/**
+ * Adapter for the Borland(r) brc32 Resource compiler.
+ *
+ * @author Curt Arnold
+ */
+public class BorlandResourceCompiler extends CommandLineCompiler {
+ private static final BorlandResourceCompiler instance = new BorlandResourceCompiler(
+ false, null);
+ public static BorlandResourceCompiler getInstance() {
+ return instance;
+ }
+ private BorlandResourceCompiler(boolean newEnvironment, Environment env) {
+ super("brc32", "c:\\__bogus\\__bogus.rc", new String[]{".rc"},
+ new String[]{".h", ".hpp", ".inl"}, ".res", false, null,
+ newEnvironment, env);
+ }
+ protected void addImpliedArgs(final Vector args,
+ final boolean debug,
+ final boolean multithreaded,
+ final boolean exceptions,
+ final LinkType linkType,
+ final Boolean rtti,
+ final OptimizationEnum optimization,
+ final Boolean defaultflag) {
+ //
+ // compile only
+ //
+ args.addElement("-r");
+ }
+ protected void addWarningSwitch(Vector args, int level) {
+ }
+ public Processor changeEnvironment(boolean newEnvironment, Environment env) {
+ if (newEnvironment || env != null) {
+ return new BorlandResourceCompiler(newEnvironment, env);
+ }
+ return this;
+ }
+ public void compile(CCTask task, File outputDir, String[] sourceFiles,
+ String[] args, String[] endArgs, boolean relentless,
+ CommandLineCompilerConfiguration config, ProgressMonitor monitor)
+ throws BuildException {
+ super.compile(task, outputDir, sourceFiles, args, endArgs, relentless,
+ config, monitor);
+ }
+ /**
+ * The include parser for C will work just fine, but we didn't want to
+ * inherit from CommandLineCCompiler
+ */
+ protected Parser createParser(File source) {
+ return new CParser();
+ }
+ protected int getArgumentCountPerInputFile() {
+ return 2;
+ }
+ protected void getDefineSwitch(StringBuffer buffer, String define,
+ String value) {
+ buffer.append("-d");
+ buffer.append(define);
+ if (value != null && value.length() > 0) {
+ buffer.append('=');
+ buffer.append(value);
+ }
+ }
+ protected File[] getEnvironmentIncludePath() {
+ return BorlandProcessor.getEnvironmentPath("brc32", 'i',
+ new String[]{"..\\include"});
+ }
+ protected String getIncludeDirSwitch(String includeDir) {
+ return BorlandProcessor.getIncludeDirSwitch("-i", includeDir);
+ }
+ protected String getInputFileArgument(File outputDir, String filename,
+ int index) {
+ if (index == 0) {
+ String outputFileName = getOutputFileName(filename);
+ String fullOutputName = new File(outputDir, outputFileName)
+ .toString();
+ return "-fo" + fullOutputName;
+ }
+ return filename;
+ }
+ public Linker getLinker(LinkType type) {
+ return BorlandLinker.getInstance().getLinker(type);
+ }
+ public int getMaximumCommandLength() {
+ return 1024;
+ }
+ protected int getMaximumInputFilesPerCommand() {
+ return 1;
+ }
+ protected int getTotalArgumentLengthForInputFile(File outputDir,
+ String inputFile) {
+ String arg1 = getInputFileArgument(outputDir, inputFile, 0);
+ String arg2 = getInputFileArgument(outputDir, inputFile, 1);
+ return arg1.length() + arg2.length() + 2;
+ }
+ protected void getUndefineSwitch(StringBuffer buffer, String define) {
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/borland/CfgFilenameState.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/borland/CfgFilenameState.java
new file mode 100644
index 0000000000..a3651d3b25
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/borland/CfgFilenameState.java
@@ -0,0 +1,46 @@
+/*
+ *
+ * Copyright 2002-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.borland;
+import net.sf.antcontrib.cpptasks.parser.AbstractParser;
+import net.sf.antcontrib.cpptasks.parser.AbstractParserState;
+import net.sf.antcontrib.cpptasks.parser.FilenameState;
+public class CfgFilenameState extends FilenameState {
+ private char terminator;
+ public CfgFilenameState(AbstractParser parser, char[] terminators) {
+ super(parser, terminators);
+ terminator = terminators[0];
+ }
+ public AbstractParserState consume(char ch) {
+ //
+ // if a ';' is encountered then
+ // close the previous filename by sending a
+ // recognized terminator to our super class
+ // and stay in this state for more filenamese
+ if (ch == ';') {
+ super.consume(terminator);
+ return this;
+ }
+ AbstractParserState newState = super.consume(ch);
+ //
+ // change null (consume to end of line)
+ // to look for next switch character
+ if (newState == null) {
+ newState = getParser().getNewLineState();
+ }
+ return newState;
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/borland/ConsumeToSpaceOrNewLine.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/borland/ConsumeToSpaceOrNewLine.java
new file mode 100644
index 0000000000..d1dd072cce
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/borland/ConsumeToSpaceOrNewLine.java
@@ -0,0 +1,30 @@
+/*
+ *
+ * Copyright 2002-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.borland;
+import net.sf.antcontrib.cpptasks.parser.AbstractParser;
+import net.sf.antcontrib.cpptasks.parser.AbstractParserState;
+public class ConsumeToSpaceOrNewLine extends AbstractParserState {
+ public ConsumeToSpaceOrNewLine(AbstractParser parser) {
+ super(parser);
+ }
+ public AbstractParserState consume(char ch) {
+ if (ch == ' ' || ch == '\t' || ch == '\n') {
+ return getParser().getNewLineState();
+ }
+ return this;
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/borland/QuoteBranchState.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/borland/QuoteBranchState.java
new file mode 100644
index 0000000000..89724b26e5
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/borland/QuoteBranchState.java
@@ -0,0 +1,35 @@
+/*
+ *
+ * Copyright 2002-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.borland;
+import net.sf.antcontrib.cpptasks.parser.AbstractParser;
+import net.sf.antcontrib.cpptasks.parser.AbstractParserState;
+public class QuoteBranchState extends AbstractParserState {
+ private AbstractParserState quote;
+ private AbstractParserState unquote;
+ public QuoteBranchState(AbstractParser parser, AbstractParserState quote,
+ AbstractParserState unquote) {
+ super(parser);
+ this.quote = quote;
+ this.unquote = unquote;
+ }
+ public AbstractParserState consume(char ch) {
+ if (ch == '"') {
+ return quote;
+ }
+ return unquote.consume(ch);
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/compaq/CompaqVisualFortranCompiler.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/compaq/CompaqVisualFortranCompiler.java
new file mode 100644
index 0000000000..e1d3deb8b6
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/compaq/CompaqVisualFortranCompiler.java
@@ -0,0 +1,138 @@
+/*
+ *
+ * Copyright 2002-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.compaq;
+import java.io.File;
+import java.util.Vector;
+
+import net.sf.antcontrib.cpptasks.CUtil;
+import net.sf.antcontrib.cpptasks.compiler.CommandLineFortranCompiler;
+import net.sf.antcontrib.cpptasks.compiler.LinkType;
+import net.sf.antcontrib.cpptasks.compiler.Linker;
+import net.sf.antcontrib.cpptasks.compiler.Processor;
+import net.sf.antcontrib.cpptasks.OptimizationEnum;
+
+
+import org.apache.tools.ant.types.Environment;
+/**
+ * Adapter for the Compaq(r) Visual Fortran compiler.
+ *
+ * @author Curt Arnold
+ */
+public class CompaqVisualFortranCompiler extends CommandLineFortranCompiler {
+ private static final CompaqVisualFortranCompiler[] instance = new CompaqVisualFortranCompiler[]{new CompaqVisualFortranCompiler(
+ false, null)};
+ public static CompaqVisualFortranCompiler getInstance() {
+ return instance[0];
+ }
+ private CompaqVisualFortranCompiler(boolean newEnvironment, Environment env) {
+ super("DF", null, new String[]{".f90", ".for", ".f"}, new String[]{
+ ".i", ".i90", ".fpp", ".inc", ".bak", ".exe"}, ".obj", false,
+ null, newEnvironment, env);
+ }
+ protected void addImpliedArgs(final Vector args,
+ final boolean debug,
+ final boolean multithreaded,
+ final boolean exceptions,
+ final LinkType linkType,
+ final Boolean rtti,
+ final OptimizationEnum optimization,
+ final Boolean defaultflag) {
+ args.addElement("/nologo");
+ args.addElement("/compile_only");
+ if (debug) {
+ args.addElement("/debug:full");
+ args.addElement("/define:_DEBUG");
+ } else {
+ args.addElement("/debug:none");
+ args.addElement("/define:NDEBUG");
+ }
+ if (multithreaded) {
+ args.addElement("/threads");
+ args.addElement("/define:_MT");
+ } else {
+ args.addElement("/nothreads");
+ }
+ boolean staticRuntime = linkType.isStaticRuntime();
+ if (staticRuntime) {
+ args.addElement("/libs:static");
+ } else {
+ args.addElement("/libs:dll");
+ }
+ if (linkType.isSharedLibrary()) {
+ args.addElement("/dll");
+ args.addElement("/define:_DLL");
+ }
+ }
+ public void addWarningSwitch(Vector args, int level) {
+ switch (level) {
+ case 0 :
+ args.addElement("/nowarn");
+ break;
+ case 1 :
+ break;
+ case 2 :
+ break;
+ case 3 :
+ args.addElement("/warn:usage");
+ break;
+ case 4 :
+ args.addElement("/warn:all");
+ break;
+ case 5 :
+ args.addElement("/warn:errors");
+ break;
+ }
+ }
+ public Processor changeEnvironment(boolean newEnvironment, Environment env) {
+ if (newEnvironment || env != null) {
+ return new CompaqVisualFortranCompiler(newEnvironment, env);
+ }
+ return this;
+ }
+ protected void getDefineSwitch(StringBuffer buf, String define, String value) {
+ buf.append("/define:");
+ buf.append(define);
+ if (value != null && value.length() > 0) {
+ buf.append('=');
+ buf.append(value);
+ }
+ }
+ protected File[] getEnvironmentIncludePath() {
+ return CUtil.getPathFromEnvironment("INCLUDE", ";");
+ }
+ protected String getIncludeDirSwitch(String includeDir) {
+ StringBuffer buf = new StringBuffer("/include:");
+ if (includeDir.indexOf(' ') >= 0) {
+ buf.append('"');
+ buf.append(includeDir);
+ buf.append('"');
+ } else {
+ buf.append(includeDir);
+ }
+ return buf.toString();
+ }
+ public Linker getLinker(LinkType type) {
+ return CompaqVisualFortranLinker.getInstance().getLinker(type);
+ }
+ public int getMaximumCommandLength() {
+ return 1024;
+ }
+ protected void getUndefineSwitch(StringBuffer buf, String define) {
+ buf.append("/undefine:");
+ buf.append(define);
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/compaq/CompaqVisualFortranLibrarian.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/compaq/CompaqVisualFortranLibrarian.java
new file mode 100644
index 0000000000..eb4a40769e
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/compaq/CompaqVisualFortranLibrarian.java
@@ -0,0 +1,82 @@
+/*
+ *
+ * Copyright 2002-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.compaq;
+import java.io.File;
+import java.util.Vector;
+
+import net.sf.antcontrib.cpptasks.compiler.CommandLineLinker;
+import net.sf.antcontrib.cpptasks.compiler.LinkType;
+import net.sf.antcontrib.cpptasks.compiler.Linker;
+import net.sf.antcontrib.cpptasks.devstudio.DevStudioLibrarian;
+import net.sf.antcontrib.cpptasks.devstudio.DevStudioProcessor;
+import net.sf.antcontrib.cpptasks.types.LibraryTypeEnum;
+
+/**
+ * Adapter for the Compaq(r) Visual Fortran Librarian
+ *
+ * @author Curt Arnold
+ */
+public class CompaqVisualFortranLibrarian extends CommandLineLinker {
+ private static final CompaqVisualFortranLibrarian instance = new CompaqVisualFortranLibrarian();
+ public static CompaqVisualFortranLibrarian getInstance() {
+ return instance;
+ }
+ private CompaqVisualFortranLibrarian() {
+ super("lib", "/bogus", new String[]{".obj"}, new String[0], ".lib",
+ false, null);
+ }
+ protected void addBase(long base, Vector args) {
+ }
+ protected void addFixed(Boolean fixed, Vector args) {
+ }
+ protected void addImpliedArgs(boolean debug, LinkType linkType, Vector args, Boolean defaultflag) {
+ args.addElement("/nologo");
+ }
+ protected void addIncremental(boolean incremental, Vector args) {
+ }
+ protected void addMap(boolean map, Vector args) {
+ }
+ protected void addStack(int stack, Vector args) {
+ }
+ /* (non-Javadoc)
+ * @see net.sf.antcontrib.cpptasks.compiler.CommandLineLinker#addEntry(int, java.util.Vector)
+ */
+ protected void addEntry(String entry, Vector args) {
+ }
+
+ protected String getCommandFileSwitch(String commandFile) {
+ return DevStudioProcessor.getCommandFileSwitch(commandFile);
+ }
+ public File[] getLibraryPath() {
+ return new File[0];
+ }
+ public String[] getLibraryPatterns(String[] libnames, LibraryTypeEnum libType) {
+ return new String[0];
+ }
+ public Linker getLinker(LinkType type) {
+ return CompaqVisualFortranLinker.getInstance().getLinker(type);
+ }
+ protected int getMaximumCommandLength() {
+ return DevStudioLibrarian.getInstance().getMaximumCommandLength();
+ }
+ protected String[] getOutputFileSwitch(String outputFile) {
+ return DevStudioLibrarian.getInstance().getOutputFileSwitch(outputFile);
+ }
+ public boolean isCaseSensitive() {
+ return false;
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/compaq/CompaqVisualFortranLinker.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/compaq/CompaqVisualFortranLinker.java
new file mode 100644
index 0000000000..d83e3b213d
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/compaq/CompaqVisualFortranLinker.java
@@ -0,0 +1,77 @@
+/*
+ *
+ * Copyright 2002-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.compaq;
+import java.util.Vector;
+
+import net.sf.antcontrib.cpptasks.compiler.LinkType;
+import net.sf.antcontrib.cpptasks.compiler.Linker;
+import net.sf.antcontrib.cpptasks.devstudio.DevStudioCompatibleLinker;
+/**
+ * Adapter for the Compaq(r) Visual Fortran linker.
+ *
+ * @author Curt Arnold
+ */
+public final class CompaqVisualFortranLinker extends DevStudioCompatibleLinker {
+ private static final CompaqVisualFortranLinker dllLinker = new CompaqVisualFortranLinker(
+ ".dll");
+ private static final CompaqVisualFortranLinker instance = new CompaqVisualFortranLinker(
+ ".exe");
+ public static CompaqVisualFortranLinker getInstance() {
+ return instance;
+ }
+ private CompaqVisualFortranLinker(String outputSuffix) {
+ super("DF", "__bogus__.xxx", outputSuffix);
+ }
+ protected void addImpliedArgs(boolean debug, LinkType linkType, Vector args) {
+ args.addElement("/NOLOGO");
+ boolean staticRuntime = linkType.isStaticRuntime();
+ if (staticRuntime) {
+ args.addElement("/libs:static");
+ } else {
+ args.addElement("/libs:dll");
+ }
+ if (debug) {
+ args.addElement("/debug");
+ } else {
+ }
+ if (linkType.isSharedLibrary()) {
+ args.addElement("/dll");
+ } else {
+ args.addElement("/exe");
+ }
+ }
+ public Linker getLinker(LinkType type) {
+ if (type.isStaticLibrary()) {
+ return CompaqVisualFortranLibrarian.getInstance();
+ }
+ if (type.isSharedLibrary()) {
+ return dllLinker;
+ }
+ return instance;
+ }
+ public String[] getOutputFileSwitch(String outputFile) {
+ StringBuffer buf = new StringBuffer("/OUT:");
+ if (outputFile.indexOf(' ') >= 0) {
+ buf.append('"');
+ buf.append(outputFile);
+ buf.append('"');
+ } else {
+ buf.append(outputFile);
+ }
+ return new String[]{buf.toString()};
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/compiler/AbstractAslcompiler.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/compiler/AbstractAslcompiler.java
new file mode 100644
index 0000000000..90c539c965
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/compiler/AbstractAslcompiler.java
@@ -0,0 +1,75 @@
+/*
+ *
+ * Copyright 2001-2005 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.compiler;
+
+import java.io.File;
+
+import net.sf.antcontrib.cpptasks.AslcompilerDef;
+import net.sf.antcontrib.cpptasks.CCTask;
+import net.sf.antcontrib.cpptasks.ProcessorDef;
+import net.sf.antcontrib.cpptasks.TargetDef;
+
+/**
+ * An abstract asl compiler implementation.
+ *
+ */
+public abstract class AbstractAslcompiler extends AbstractProcessor
+implements Aslcompiler {
+ private String outputSuffix;
+ protected AbstractAslcompiler(String[] sourceExtensions,
+ String[] headerExtensions, String outputSuffix) {
+ super(sourceExtensions, headerExtensions);
+ this.outputSuffix = outputSuffix;
+ }
+ abstract protected AslcompilerConfiguration createConfiguration(CCTask task,
+ LinkType linkType, ProcessorDef[] baseConfigs,
+ AslcompilerDef specificConfig, TargetDef targetPlatform);
+
+ public ProcessorConfiguration createConfiguration(CCTask task,
+ LinkType linkType, ProcessorDef[] baseConfigs,
+ ProcessorDef specificConfig, TargetDef targetPlatform) {
+ if (specificConfig == null) {
+ throw new NullPointerException("specificConfig");
+ }
+ return createConfiguration(task, linkType, baseConfigs,
+ (AslcompilerDef) specificConfig, targetPlatform);
+ }
+
+ public String getOutputFileName(String inputFile) {
+ if (bid(inputFile) > 1) {
+ String baseName = getBaseOutputName(inputFile);
+ return baseName + outputSuffix;
+ }
+ return null;
+ }
+ protected String getBaseOutputName(String inputFile) {
+ int lastSlash = inputFile.lastIndexOf('/');
+ int lastReverse = inputFile.lastIndexOf('\\');
+ int lastSep = inputFile.lastIndexOf(File.separatorChar);
+ if (lastReverse > lastSlash) {
+ lastSlash = lastReverse;
+ }
+ if (lastSep > lastSlash) {
+ lastSlash = lastSep;
+ }
+ int lastPeriod = inputFile.lastIndexOf('.');
+ if (lastPeriod < 0) {
+ lastPeriod = inputFile.length();
+ }
+ return inputFile.substring(lastSlash + 1, lastPeriod);
+ }
+}
\ No newline at end of file
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/compiler/AbstractAssembler.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/compiler/AbstractAssembler.java
new file mode 100644
index 0000000000..1d49232a05
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/compiler/AbstractAssembler.java
@@ -0,0 +1,72 @@
+/*
+ *
+ * Copyright 2001-2005 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.compiler;
+
+import java.io.File;
+
+import net.sf.antcontrib.cpptasks.AssemblerDef;
+import net.sf.antcontrib.cpptasks.CCTask;
+import net.sf.antcontrib.cpptasks.ProcessorDef;
+import net.sf.antcontrib.cpptasks.TargetDef;
+/**
+ * An abstract assembler implementation.
+ *
+ */
+public abstract class AbstractAssembler extends AbstractProcessor
+implements Assembler {
+ private String outputSuffix;
+ protected AbstractAssembler(String[] sourceExtensions,
+ String[] headerExtensions, String outputSuffix) {
+ super(sourceExtensions, headerExtensions);
+ this.outputSuffix = outputSuffix;
+ }
+ abstract protected AssemblerConfiguration createConfiguration(CCTask task,
+ LinkType linkType, ProcessorDef[] baseConfigs,
+ AssemblerDef specificConfig, TargetDef targetPlatform);
+ public ProcessorConfiguration createConfiguration(CCTask task,
+ LinkType linkType, ProcessorDef[] baseConfigs,
+ ProcessorDef specificConfig, TargetDef targetPlatform) {
+ if (specificConfig == null) {
+ throw new NullPointerException("specificConfig");
+ }
+ return createConfiguration(task, linkType, baseConfigs,
+ (AssemblerDef) specificConfig, targetPlatform);
+ }
+ public String getOutputFileName(String inputFile) {
+ if (bid(inputFile) > 1) {
+ String baseName = getBaseOutputName(inputFile);
+ return baseName + outputSuffix;
+ }
+ return null;
+ }
+ protected String getBaseOutputName(String inputFile) {
+ int lastSlash = inputFile.lastIndexOf('/');
+ int lastReverse = inputFile.lastIndexOf('\\');
+ int lastSep = inputFile.lastIndexOf(File.separatorChar);
+ if (lastReverse > lastSlash) {
+ lastSlash = lastReverse;
+ }
+ if (lastSep > lastSlash) {
+ lastSlash = lastSep;
+ }
+ int lastPeriod = inputFile.lastIndexOf('.');
+ if (lastPeriod < 0) {
+ lastPeriod = inputFile.length();
+ }
+ return inputFile.substring(lastSlash + 1, lastPeriod);
+ }
+}
\ No newline at end of file
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/compiler/AbstractCompiler.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/compiler/AbstractCompiler.java
new file mode 100644
index 0000000000..f16ec6caf3
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/compiler/AbstractCompiler.java
@@ -0,0 +1,205 @@
+/*
+ *
+ * Copyright 2002-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.compiler;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.Reader;
+import java.util.Vector;
+import net.sf.antcontrib.cpptasks.CCTask;
+import net.sf.antcontrib.cpptasks.CUtil;
+import net.sf.antcontrib.cpptasks.CompilerDef;
+import net.sf.antcontrib.cpptasks.DependencyInfo;
+import net.sf.antcontrib.cpptasks.ProcessorDef;
+import net.sf.antcontrib.cpptasks.parser.Parser;
+import net.sf.antcontrib.cpptasks.TargetDef;
+
+/**
+ * An abstract compiler implementation.
+ *
+ * @author Adam Murdoch
+ * @author Curt Arnold
+ */
+public abstract class AbstractCompiler extends AbstractProcessor
+ implements
+ Compiler {
+ private static final String[] emptyIncludeArray = new String[0];
+ private String outputSuffix;
+ protected AbstractCompiler(String[] sourceExtensions,
+ String[] headerExtensions, String outputSuffix) {
+ super(sourceExtensions, headerExtensions);
+ this.outputSuffix = outputSuffix;
+ }
+ /**
+ * Checks file name to see if parse should be attempted
+ *
+ * Default implementation returns false for files with extensions '.dll',
+ * 'tlb', '.res'
+ *
+ */
+ protected boolean canParse(File sourceFile) {
+ String sourceName = sourceFile.toString();
+ int lastPeriod = sourceName.lastIndexOf('.');
+ if (lastPeriod >= 0 && lastPeriod == sourceName.length() - 4) {
+ String ext = sourceName.substring(lastPeriod).toUpperCase();
+ if (ext.equals(".DLL") || ext.equals(".TLB") || ext.equals(".RES")) {
+ return false;
+ }
+ }
+ return true;
+ }
+ abstract protected CompilerConfiguration createConfiguration(CCTask task,
+ LinkType linkType, ProcessorDef[] baseConfigs,
+ CompilerDef specificConfig, TargetDef targetPlatform);
+ public ProcessorConfiguration createConfiguration(CCTask task,
+ LinkType linkType, ProcessorDef[] baseConfigs,
+ ProcessorDef specificConfig, TargetDef targetPlatform) {
+ if (specificConfig == null) {
+ throw new NullPointerException("specificConfig");
+ }
+ return createConfiguration(task, linkType, baseConfigs,
+ (CompilerDef) specificConfig, targetPlatform);
+ }
+ abstract protected Parser createParser(File sourceFile);
+ protected String getBaseOutputName(String inputFile) {
+ int lastSlash = inputFile.lastIndexOf('/');
+ int lastReverse = inputFile.lastIndexOf('\\');
+ int lastSep = inputFile.lastIndexOf(File.separatorChar);
+ if (lastReverse > lastSlash) {
+ lastSlash = lastReverse;
+ }
+ if (lastSep > lastSlash) {
+ lastSlash = lastSep;
+ }
+ int lastPeriod = inputFile.lastIndexOf('.');
+ if (lastPeriod < 0) {
+ lastPeriod = inputFile.length();
+ }
+ return inputFile.substring(lastSlash + 1, lastPeriod);
+ }
+ public String getOutputFileName(String inputFile) {
+ //
+ // if a recognized input file
+ //
+ if (bid(inputFile) > 1) {
+ String baseName = getBaseOutputName(inputFile);
+ return baseName + outputSuffix;
+ }
+ return null;
+ }
+ /**
+ * Returns dependency info for the specified source file
+ *
+ * @param task
+ * task for any diagnostic output
+ * @param source
+ * file to be parsed
+ * @param includePath
+ * include path to be used to resolve included files
+ *
+ * @param sysIncludePath
+ * sysinclude path from build file, files resolved using
+ * sysInclude path will not participate in dependency analysis
+ *
+ * @param envIncludePath
+ * include path from environment variable, files resolved with
+ * envIncludePath will not participate in dependency analysis
+ *
+ * @param baseDir
+ * used to produce relative paths in DependencyInfo
+ * @param includePathIdentifier
+ * used to distinguish DependencyInfo's from different include
+ * path settings
+ *
+ * @author Curt Arnold
+ */
+ public final DependencyInfo parseIncludes(CCTask task, File source,
+ File[] includePath, File[] sysIncludePath, File[] envIncludePath,
+ File baseDir, String includePathIdentifier) {
+ //
+ // if any of the include files can not be identified
+ // change the sourceLastModified to Long.MAX_VALUE to
+ // force recompilation of anything that depends on it
+ long sourceLastModified = source.lastModified();
+ File[] sourcePath = new File[1];
+ sourcePath[0] = new File(source.getParent());
+ Vector onIncludePath = new Vector();
+ Vector onSysIncludePath = new Vector();
+ String baseDirPath;
+ try {
+ baseDirPath = baseDir.getCanonicalPath();
+ } catch (IOException ex) {
+ baseDirPath = baseDir.toString();
+ }
+ String relativeSource = CUtil.getRelativePath(baseDirPath, source);
+ String[] includes = emptyIncludeArray;
+ if (canParse(source)) {
+ Parser parser = createParser(source);
+ try {
+ Reader reader = new BufferedReader(new FileReader(source));
+ parser.parse(reader);
+ includes = parser.getIncludes();
+ } catch (IOException ex) {
+ task.log("Error parsing " + source.toString() + ":"
+ + ex.toString());
+ includes = new String[0];
+ }
+ }
+ for (int i = 0; i < includes.length; i++) {
+ String includeName = includes[i];
+ if (!resolveInclude(includeName, sourcePath, onIncludePath)) {
+ if (!resolveInclude(includeName, includePath, onIncludePath)) {
+ if (!resolveInclude(includeName, sysIncludePath,
+ onSysIncludePath)) {
+ if (!resolveInclude(includeName, envIncludePath,
+ onSysIncludePath)) {
+ //
+ // this should be enough to require us to reparse
+ // the file with the missing include for dependency
+ // information without forcing a rebuild
+ sourceLastModified++;
+ }
+ }
+ }
+ }
+ }
+ for (int i = 0; i < onIncludePath.size(); i++) {
+ String relativeInclude = CUtil.getRelativePath(baseDirPath,
+ (File) onIncludePath.elementAt(i));
+ onIncludePath.setElementAt(relativeInclude, i);
+ }
+ for (int i = 0; i < onSysIncludePath.size(); i++) {
+ String relativeInclude = CUtil.getRelativePath(baseDirPath,
+ (File) onSysIncludePath.elementAt(i));
+ onSysIncludePath.setElementAt(relativeInclude, i);
+ }
+ return new DependencyInfo(includePathIdentifier, relativeSource,
+ sourceLastModified, onIncludePath, onSysIncludePath);
+ }
+ protected boolean resolveInclude(String includeName, File[] includePath,
+ Vector onThisPath) {
+ for (int i = 0; i < includePath.length; i++) {
+ File includeFile = new File(includePath[i], includeName);
+ if (includeFile.exists()) {
+ onThisPath.addElement(includeFile);
+ return true;
+ }
+ }
+ return false;
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/compiler/AbstractLinker.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/compiler/AbstractLinker.java
new file mode 100644
index 0000000000..20580e5d33
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/compiler/AbstractLinker.java
@@ -0,0 +1,85 @@
+/*
+ *
+ * Copyright 2001-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.compiler;
+import java.io.File;
+
+import net.sf.antcontrib.cpptasks.CCTask;
+import net.sf.antcontrib.cpptasks.LinkerDef;
+import net.sf.antcontrib.cpptasks.ProcessorDef;
+import net.sf.antcontrib.cpptasks.TargetDef;
+
+
+import org.apache.tools.ant.types.Environment;
+/**
+ * An abstract Linker implementation.
+ *
+ * @author Adam Murdoch
+ */
+public abstract class AbstractLinker extends AbstractProcessor
+ implements
+ Linker {
+ public AbstractLinker(String[] objExtensions, String[] ignoredExtensions) {
+ super(objExtensions, ignoredExtensions);
+ }
+ /**
+ * Returns the bid of the processor for the file.
+ *
+ * A linker will bid 1 on any unrecognized file type.
+ *
+ * @param inputFile
+ * filename of input file
+ * @return bid for the file, 0 indicates no interest, 1 indicates that the
+ * processor recognizes the file but doesn't process it (header
+ * files, for example), 100 indicates strong interest
+ */
+ public int bid(String inputFile) {
+ int bid = super.bid(inputFile);
+ switch (bid) {
+ //
+ // unrecognized extension, take the file
+ //
+ case 0 :
+ return 1;
+ //
+ // discard the ignored extensions
+ //
+ case 1 :
+ return 0;
+ }
+ return bid;
+ }
+ public Processor changeEnvironment(boolean newEnvironment, Environment env) {
+ return this;
+ }
+ abstract protected LinkerConfiguration createConfiguration(CCTask task,
+ LinkType linkType, ProcessorDef[] baseConfigs,
+ LinkerDef specificConfig, TargetDef targetPlatform);
+ public ProcessorConfiguration createConfiguration(CCTask task,
+ LinkType linkType, ProcessorDef[] baseConfigs,
+ ProcessorDef specificConfig,
+ TargetDef targetPlatform) {
+ if (specificConfig == null) {
+ throw new NullPointerException("specificConfig");
+ }
+ return createConfiguration(task, linkType, baseConfigs,
+ (LinkerDef) specificConfig, targetPlatform);
+ }
+ public String getLibraryKey(File libfile) {
+ return libfile.getName();
+ }
+ public abstract String getOutputFileName(String fileName);
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/compiler/AbstractProcessor.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/compiler/AbstractProcessor.java
new file mode 100644
index 0000000000..b6456d5e3e
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/compiler/AbstractProcessor.java
@@ -0,0 +1,129 @@
+/*
+ *
+ * Copyright 2002-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.compiler;
+import org.apache.tools.ant.types.Environment;
+/**
+ * An abstract processor (compiler/linker) implementation.
+ *
+ * @author Curt Arnold
+ */
+public abstract class AbstractProcessor implements Processor, Cloneable {
+ /**
+ * default bid for a file name that the processor recognizes but does not
+ * process and does not want to fall through to the linker
+ */
+ public final static int DEFAULT_DISCARD_BID = 1;
+ /**
+ * default bid for a file name that the processor desires to process
+ */
+ public final static int DEFAULT_PROCESS_BID = 100;
+ /**
+ * Determines the identification of a command line processor by capture the
+ * first line of its output for a specific command.
+ *
+ * @param command
+ * array of command line arguments starting with executable
+ * name. For example, { "cl" }
+ * @param fallback
+ * start of identifier if there is an error in executing the
+ * command
+ * @return identifier for the processor
+ */
+ protected static String getIdentifier(String[] command, String fallback) {
+ String identifier = fallback;
+ try {
+ String[] cmdout = CaptureStreamHandler.run(command);
+ if (cmdout.length > 0) {
+ identifier = cmdout[0];
+ }
+ } catch (Throwable ex) {
+ identifier = fallback + ":" + ex.toString();
+ }
+ return identifier;
+ }
+ private final String[] headerExtensions;
+ private final String[] sourceExtensions;
+ protected AbstractProcessor(String[] sourceExtensions,
+ String[] headerExtensions) {
+ this.sourceExtensions = (String[]) sourceExtensions.clone();
+ this.headerExtensions = (String[]) headerExtensions.clone();
+ }
+ /**
+ * Returns the bid of the processor for the file.
+ *
+ * @param inputFile
+ * filename of input file
+ * @return bid for the file, 0 indicates no interest, 1 indicates that the
+ * processor recognizes the file but doesn't process it (header
+ * files, for example), 100 indicates strong interest
+ */
+ public int bid(String inputFile) {
+ String lower = inputFile.toLowerCase();
+ for (int i = 0; i < sourceExtensions.length; i++) {
+ if (lower.endsWith(sourceExtensions[i])) {
+ return DEFAULT_PROCESS_BID;
+ }
+ }
+ for (int i = 0; i < headerExtensions.length; i++) {
+ if (lower.endsWith(headerExtensions[i])) {
+ return DEFAULT_DISCARD_BID;
+ }
+ }
+ return 0;
+ }
+ public Processor changeEnvironment(boolean newEnvironment, Environment env) {
+ return this;
+ }
+ protected Object clone() throws CloneNotSupportedException {
+ return super.clone();
+ }
+ public String[] getHeaderExtensions() {
+ return (String[]) this.headerExtensions.clone();
+ }
+ abstract public String getIdentifier();
+ /**
+ * Gets the target operating system architecture
+ *
+ * @return String target operating system architecture
+ */
+ protected String getOSArch() {
+ return System.getProperty("os.arch");
+ }
+ /**
+ * Gets the target operating system name
+ *
+ * @return String target operating system name
+ */
+ protected String getOSName() {
+ return System.getProperty("os.name");
+ }
+ public String[] getSourceExtensions() {
+ return (String[]) this.sourceExtensions.clone();
+ }
+ /**
+ * Returns true if the target operating system is Mac OS X or Darwin.
+ *
+ * @return boolean
+ */
+ protected boolean isDarwin() {
+ String osName = getOSName();
+ return "Mac OS X".equals(osName);
+ }
+ public final String toString() {
+ return getIdentifier();
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/compiler/Aslcompiler.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/compiler/Aslcompiler.java
new file mode 100644
index 0000000000..a210e1c684
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/compiler/Aslcompiler.java
@@ -0,0 +1,23 @@
+/*
+ *
+ * Copyright 2001-2005 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.compiler;
+/**
+ * A asl compiler.
+ *
+ */
+public interface Aslcompiler extends Processor {
+}
\ No newline at end of file
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/compiler/AslcompilerConfiguration.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/compiler/AslcompilerConfiguration.java
new file mode 100644
index 0000000000..62ac2760c6
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/compiler/AslcompilerConfiguration.java
@@ -0,0 +1,29 @@
+/*
+ *
+ * Copyright 2001-2005 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.compiler;
+
+import java.io.File;
+
+import net.sf.antcontrib.cpptasks.CCTask;
+import org.apache.tools.ant.BuildException;
+/**
+ * A configuration for an ASL compiler
+ *
+ */
+public interface AslcompilerConfiguration extends ProcessorConfiguration {
+ void aslcompiler(CCTask task, File outputDir, String[] sourceFiles) throws BuildException;
+}
\ No newline at end of file
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/compiler/Assembler.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/compiler/Assembler.java
new file mode 100644
index 0000000000..1b6d7b5d11
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/compiler/Assembler.java
@@ -0,0 +1,23 @@
+/*
+ *
+ * Copyright 2001-2005 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.compiler;
+/**
+ * A assembler.
+ *
+ */
+public interface Assembler extends Processor {
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/compiler/AssemblerConfiguration.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/compiler/AssemblerConfiguration.java
new file mode 100644
index 0000000000..9411551b47
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/compiler/AssemblerConfiguration.java
@@ -0,0 +1,29 @@
+/*
+ *
+ * Copyright 2001-2005 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.compiler;
+
+import java.io.File;
+
+import net.sf.antcontrib.cpptasks.CCTask;
+import org.apache.tools.ant.BuildException;
+/**
+ * A configuration for an assembler
+ *
+ */
+public interface AssemblerConfiguration extends ProcessorConfiguration {
+ void assembler(CCTask task, File outputDir, String[] sourceFiles) throws BuildException;
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/compiler/CaptureStreamHandler.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/compiler/CaptureStreamHandler.java
new file mode 100644
index 0000000000..1b89a70a58
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/compiler/CaptureStreamHandler.java
@@ -0,0 +1,122 @@
+/*
+ *
+ * Copyright 2001-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.compiler;
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.util.Vector;
+
+import org.apache.tools.ant.taskdefs.Execute;
+import org.apache.tools.ant.taskdefs.ExecuteStreamHandler;
+/**
+ * Implements ExecuteStreamHandler to capture the output of a Execute to an
+ * array of strings
+ *
+ * @author Curt Arnold
+ */
+public class CaptureStreamHandler implements ExecuteStreamHandler {
+ /**
+ * Runs an executable and captures the output in a String array
+ *
+ * @param cmdline
+ * command line arguments
+ * @return output of process
+ */
+ public static String[] run(String[] cmdline) {
+ CaptureStreamHandler handler = new CaptureStreamHandler();
+ Execute exec = new Execute(handler);
+ exec.setCommandline(cmdline);
+ try {
+ int status = exec.execute();
+ } catch (IOException ex) {
+ }
+ return handler.getOutput();
+ }
+ private InputStream errorStream;
+ private InputStream fromProcess;
+ public CaptureStreamHandler() {
+ }
+ public String[] getOutput() {
+ String[] output;
+ if (fromProcess != null) {
+ Vector lines = new Vector(10);
+ try {
+ BufferedReader reader = new BufferedReader(
+ new InputStreamReader(errorStream));
+ for (int i = 0; i < 2; i++) {
+ for (int j = 0; j < 100; j++) {
+ String line = reader.readLine();
+ if (line == null) {
+ reader = new BufferedReader(new InputStreamReader(
+ fromProcess));
+ break;
+ }
+ lines.addElement(line);
+ }
+ }
+ } catch (IOException ex) {
+ }
+ output = new String[lines.size()];
+ lines.copyInto(output);
+ return output;
+ }
+ output = new String[0];
+ return output;
+ }
+ /**
+ * Install a handler for the error stream of the subprocess.
+ *
+ * @param is
+ * input stream to read from the error stream from the
+ * subprocess
+ */
+ public void setProcessErrorStream(InputStream is) throws IOException {
+ errorStream = is;
+ }
+ /**
+ * Install a handler for the input stream of the subprocess.
+ *
+ * @param os
+ * output stream to write to the standard input stream of the
+ * subprocess
+ */
+ public void setProcessInputStream(OutputStream os) throws IOException {
+ os.close();
+ }
+ /**
+ * Install a handler for the output stream of the subprocess.
+ *
+ * @param is
+ * input stream to read from the error stream from the
+ * subprocess
+ */
+ public void setProcessOutputStream(InputStream is) throws IOException {
+ fromProcess = is;
+ }
+ /**
+ * Start handling of the streams.
+ */
+ public void start() throws IOException {
+ }
+ /**
+ * Stop handling of the streams - will not be restarted.
+ */
+ public void stop() {
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/compiler/CommandLineAslcompiler.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/compiler/CommandLineAslcompiler.java
new file mode 100644
index 0000000000..88dda5796f
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/compiler/CommandLineAslcompiler.java
@@ -0,0 +1,226 @@
+/*
+ *
+ * Copyright 2001-2005 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.compiler;
+
+import java.io.File;
+import java.util.Enumeration;
+import java.util.Vector;
+
+import net.sf.antcontrib.cpptasks.AslcompilerDef;
+import net.sf.antcontrib.cpptasks.CCTask;
+import net.sf.antcontrib.cpptasks.CUtil;
+import net.sf.antcontrib.cpptasks.ProcessorDef;
+import net.sf.antcontrib.cpptasks.TargetDef;
+import net.sf.antcontrib.cpptasks.types.CommandLineArgument;
+
+import org.apache.tools.ant.BuildException;
+/**
+ * An abstract ASL Compiler implementation which uses an external program to
+ * perform the ASL compile.
+ *
+ */
+public abstract class CommandLineAslcompiler extends AbstractAslcompiler{
+
+ private String command;
+ private String identifier;
+ private String identifierArg;
+
+ protected CommandLineAslcompiler(String command, String identifierArg,
+ String[] sourceExtensions, String[] headerExtensions,
+ String outputSuffix) {
+ super(sourceExtensions, headerExtensions, outputSuffix);
+ this.command = command;
+ this.identifierArg = identifierArg;
+ }
+
+ abstract protected void addImpliedArgs(Vector args, boolean debug,
+ Boolean defaultflag);
+
+ /**
+ * Compile a ACPI source file
+ *
+ */
+ public void aslcompiler(CCTask task, File outputDir, String[] sourceFiles,
+ String[] args, String[] endArgs) throws BuildException{
+ String command = getCommand();
+ int baseLength = command.length() + args.length + endArgs.length;
+ for (int i = 0; i < args.length; i++) {
+ baseLength += args[i].length();
+ }
+ for (int i = 0; i < endArgs.length; i++) {
+ baseLength += endArgs[i].length();
+ }
+ if (baseLength > getMaximumCommandLength()) {
+ throw new BuildException(
+ "Command line is over maximum length without sepcifying source file");
+ }
+ int maxInputFilesPerCommand = getMaximumInputFilesPerCommand();
+ int argumentCountPerInputFile = getArgumentCountPerInputFIle();
+ for (int sourceIndex = 0; sourceIndex < sourceFiles.length;) {
+ int cmdLength = baseLength;
+ int firstFileNextExec;
+ for (firstFileNextExec = sourceIndex; firstFileNextExec < sourceFiles.length
+ && (firstFileNextExec - sourceIndex) < maxInputFilesPerCommand; firstFileNextExec++) {
+ cmdLength += getTotalArgumentLengthForInputFile(outputDir,
+ sourceFiles[firstFileNextExec]);
+ if (cmdLength >= getMaximumCommandLength())
+ break;
+ }
+ if (firstFileNextExec == sourceIndex) {
+ throw new BuildException(
+ "Extremely long file name, can't fit on command line");
+ }
+ int argCount = args.length + 1 + endArgs.length
+ + (firstFileNextExec - sourceIndex)
+ * argumentCountPerInputFile;
+ String[] commandline = new String[argCount];
+ int index = 0;
+ commandline[index++] = command;
+ for (int j = 0; j < args.length; j++) {
+ commandline[index++] = args[j];
+ }
+ for (int j = sourceIndex; j < firstFileNextExec; j++) {
+ for (int k = 0; k < argumentCountPerInputFile; k++) {
+ commandline[index++] = getInputFileArgument(outputDir,
+ sourceFiles[j], k);
+ }
+ }
+ for (int j = 0; j < endArgs.length; j++) {
+ commandline[index++] = endArgs[j];
+ }
+ int retval = runCommand(task, outputDir, commandline);
+ // if with monitor, add more code
+ if (retval != 0) {
+ throw new BuildException(this.getCommand()
+ + " failed with return code " + retval,
+ task.getLocation());
+ }
+ sourceIndex = firstFileNextExec;
+ }
+ }
+
+ protected AslcompilerConfiguration createConfiguration(final CCTask task,
+ final LinkType linkType,
+ final ProcessorDef[] baseDefs,
+ final AslcompilerDef specificDef,
+ final TargetDef targetPlatform) {
+ Vector args = new Vector();
+ AslcompilerDef[] defaultProviders = new AslcompilerDef[baseDefs.length +1];
+ for (int i = 0; i < baseDefs.length; i++) {
+ defaultProviders[i + 1] = (AslcompilerDef) baseDefs[i];
+ }
+ defaultProviders[0] = specificDef;
+ Vector cmdArgs = new Vector();
+ //
+ // add command line arguments inherited from element
+ // any "extends" and finally and specific AslcompilerDef
+ //
+ CommandLineArgument[] commandArgs;
+ for (int i = defaultProviders.length - 1; i >=0; i--){
+ commandArgs = defaultProviders[i].getActiveProcessorArgs();
+ for (int j = 0; j < commandArgs.length; j++) {
+ if (commandArgs[j].getLocation() == 0) {
+ args.addElement(commandArgs[j].getValue());
+ }
+ else {
+ cmdArgs.addElement(commandArgs[j]);
+ }
+ }
+ }
+ // omit param
+ boolean debug = specificDef.getDebug(baseDefs, 0);
+ Boolean defaultflag = specificDef.getDefaultflag(defaultProviders, 1);
+ this.addImpliedArgs(args, debug, defaultflag);
+ Enumeration argEnum = cmdArgs.elements();
+ int endCount = 0;
+ while( argEnum.hasMoreElements()) {
+ CommandLineArgument arg = (CommandLineArgument) argEnum.nextElement();
+ switch (arg.getLocation()) {
+ case 1 :
+ args.addElement(arg.getValue());
+ break;
+ case 2 :
+ endCount++;
+ break;
+ }
+ }
+ String[] endArgs = new String[endCount];
+ argEnum = cmdArgs.elements();
+ int index = 0;
+ while (argEnum.hasMoreElements()) {
+ CommandLineArgument arg = (CommandLineArgument) argEnum.nextElement();
+ if (arg.getLocation() == 2) {
+ endArgs[index++] = arg.getValue();
+ }
+ }
+ String[] argArray = new String[args.size()];
+ args.copyInto(argArray);
+ return new CommandLineAslcompilerConfiguration(this, argArray, true, endArgs);
+ }
+
+ protected int getArgumentCountPerInputFile() {
+ return 1;
+ }
+
+ public String getIdentifier() {
+ if (identifier == null) {
+ if (identifierArg == null) {
+ identifier = getIdentifier(new String[]{command}, command);
+ }
+ else {
+ identifier = getIdentifier(
+ new String[]{command, identifierArg}, command);
+ }
+ }
+ return identifier;
+ }
+
+ public final String getCommand() {
+ return command;
+ }
+ abstract public int getMaximumCommandLength();
+ public void setCommand(String command) {
+ this.command = command;
+ }
+ protected int getTotalArgumentLengthForInputFile(File outputDir,
+ String inputFile) {
+ return inputFile.length() + 1;
+ }
+ protected int runCommand(CCTask task, File workingDir, String[] cmdline)
+ throws BuildException {
+ return CUtil.runCommand(task, workingDir, cmdline, false, null);
+
+ }
+ protected int getMaximumInputFilesPerCommand(){
+ return 1;
+ }
+ protected int getArgumentCountPerInputFIle(){
+ return 1;
+ }
+ protected String getInputFileArgument(File outputDir, String filename, int index) {
+ //
+ // if there is an embedded space,
+ // must enclose in quotes
+ if (filename.indexOf(' ') >= 0) {
+ StringBuffer buf = new StringBuffer("\"");
+ buf.append(filename);
+ buf.append("\"");
+ return buf.toString();
+ }
+ return filename;
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/compiler/CommandLineAslcompilerConfiguration.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/compiler/CommandLineAslcompilerConfiguration.java
new file mode 100644
index 0000000000..9a3457dafb
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/compiler/CommandLineAslcompilerConfiguration.java
@@ -0,0 +1,93 @@
+/*
+ *
+ * Copyright 2001-2005 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.compiler;
+
+import java.io.File;
+
+import org.apache.tools.ant.BuildException;
+
+import net.sf.antcontrib.cpptasks.CCTask;
+import net.sf.antcontrib.cpptasks.ProcessorParam;
+
+/**
+ * A configuration for an ASL compiler
+ *
+ */
+public final class CommandLineAslcompilerConfiguration implements
+ AslcompilerConfiguration {
+
+ private String[] args;
+
+ private CommandLineAslcompiler acpi;
+
+ private String[] endArgs;
+
+ private boolean rebuild;
+
+ public CommandLineAslcompilerConfiguration (CommandLineAslcompiler acpi,
+ String[] args, boolean rebuild, String[] endArgs) {
+ if (acpi == null) {
+ throw new NullPointerException("acpi");
+ }
+ if (args == null) {
+ this.args = new String[0];
+ } else {
+ this.args = (String[]) args.clone();
+ }
+ this.acpi = acpi;
+ this.rebuild = rebuild;
+ this.endArgs = (String[]) endArgs.clone();
+ }
+
+ public int bid (String inputFile) {
+ int acpiBid = acpi.bid(inputFile);
+ return acpiBid;
+ }
+
+ public void aslcompiler (CCTask task, File outputDir, String[] sourceFiles)
+ throws BuildException {
+ try {
+ acpi.aslcompiler(task, outputDir, sourceFiles, args, endArgs);
+ } catch (BuildException ex) {
+ throw ex;
+ }
+ }
+
+ public String getIdentifier () {
+ return acpi.getCommand();
+ }
+
+ public ProcessorParam[] getParams () {
+ return new ProcessorParam[0];
+ }
+
+ public boolean getRebuild () {
+ return rebuild;
+ }
+
+ public String[] getPreArguments () {
+ return (String[]) args.clone();
+ }
+
+ public String[] getEndArguments () {
+ return (String[]) endArgs.clone();
+ }
+
+ public String getOutputFileName (String inputFile) {
+ return acpi.getOutputFileName(inputFile);
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/compiler/CommandLineAssembler.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/compiler/CommandLineAssembler.java
new file mode 100644
index 0000000000..f01fc5ee61
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/compiler/CommandLineAssembler.java
@@ -0,0 +1,326 @@
+/*
+ *
+ * Copyright 2001-2005 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.compiler;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Enumeration;
+import java.util.Vector;
+
+import net.sf.antcontrib.cpptasks.AssemblerDef;
+import net.sf.antcontrib.cpptasks.CCTask;
+import net.sf.antcontrib.cpptasks.CUtil;
+import net.sf.antcontrib.cpptasks.ProcessorDef;
+import net.sf.antcontrib.cpptasks.TargetDef;
+import net.sf.antcontrib.cpptasks.types.CommandLineArgument;
+
+import org.apache.tools.ant.BuildException;
+
+/**
+ * An abstract Assembler implementation which uses an external program to
+ * perform the assemble.
+ *
+ */
+public abstract class CommandLineAssembler extends AbstractAssembler {
+
+ private String command;
+
+ private String identifier;
+
+ private String identifierArg;
+
+ protected CommandLineAssembler (String command, String identifierArg,
+ String[] sourceExtensions, String[] headerExtensions,
+ String outputSuffix) {
+ super(sourceExtensions, headerExtensions, outputSuffix);
+ this.command = command;
+ this.identifierArg = identifierArg;
+ }
+
+ abstract protected void addImpliedArgs(Vector args, boolean debug,
+ Boolean defaultflag);
+
+ /**
+ * Adds command-line arguments for include directories.
+ *
+ * If relativeArgs is not null will add corresponding relative paths include
+ * switches to that vector (for use in building a configuration identifier
+ * that is consistent between machines).
+ *
+ * @param baseDirPaths
+ * A vector containing the parts of the working directory,
+ * produced by CUtil.DecomposeFile.
+ * @param includeDirs
+ * Array of include directory paths
+ * @param args
+ * Vector of command line arguments used to execute the task
+ * @param relativeArgs
+ * Vector of command line arguments used to build the
+ * configuration identifier
+ */
+ protected void addIncludes(String baseDirPath, File[] includeDirs,
+ Vector args, Vector relativeArgs, StringBuffer includePathId) {
+ for (int i = 0; i < includeDirs.length; i++) {
+ args.addElement(getIncludeDirSwitch(includeDirs[i]
+ .getAbsolutePath()));
+ if (relativeArgs != null) {
+ String relative = CUtil.getRelativePath(baseDirPath,
+ includeDirs[i]);
+ relativeArgs.addElement(getIncludeDirSwitch(relative));
+ if (includePathId != null) {
+ if (includePathId.length() == 0) {
+ includePathId.append("/I");
+ } else {
+ includePathId.append(" /I");
+ }
+ includePathId.append(relative);
+ }
+ }
+ }
+ }
+
+ abstract protected String getIncludeDirSwitch(String source);
+
+ /**
+ * Assembles a source file
+ *
+ */
+ public void assembler(CCTask task, File outputDir, String[] sourceFiles,
+ String[] args, String[] endArgs) throws BuildException {
+ String command = getCommand();
+ int baseLength = command.length() + args.length + endArgs.length;
+ for (int i = 0; i < args.length; i++) {
+ baseLength += args[i].length();
+ }
+ for (int i = 0; i < endArgs.length; i++) {
+ baseLength += endArgs[i].length();
+ }
+ if (baseLength > getMaximumCommandLength()) {
+ throw new BuildException(
+ "Command line is over maximum length without sepcifying source file");
+ }
+ int maxInputFilesPerCommand = getMaximumInputFilesPerCommand();
+ int argumentCountPerInputFile = getArgumentCountPerInputFIle();
+ for (int sourceIndex = 0; sourceIndex < sourceFiles.length;) {
+ int cmdLength = baseLength;
+ int firstFileNextExec;
+ for (firstFileNextExec = sourceIndex; firstFileNextExec < sourceFiles.length
+ && (firstFileNextExec - sourceIndex) < maxInputFilesPerCommand; firstFileNextExec++) {
+ cmdLength += getTotalArgumentLengthForInputFile(outputDir,
+ sourceFiles[firstFileNextExec]);
+ if (cmdLength >= getMaximumCommandLength())
+ break;
+ }
+ if (firstFileNextExec == sourceIndex) {
+ throw new BuildException(
+ "Extremely long file name, can't fit on command line");
+ }
+ int argCount = args.length + 1 + endArgs.length
+ + (firstFileNextExec - sourceIndex)
+ * argumentCountPerInputFile;
+ String[] commandline = new String[argCount];
+ int index = 0;
+ commandline[index++] = command;
+ for (int j = 0; j < args.length; j++) {
+ commandline[index++] = args[j];
+ }
+ for (int j = sourceIndex; j < firstFileNextExec; j++) {
+ for (int k = 0; k < argumentCountPerInputFile; k++) {
+ commandline[index++] = getInputFileArgument(outputDir,
+ sourceFiles[j], k);
+ }
+ }
+ for (int j = 0; j < endArgs.length; j++) {
+ commandline[index++] = endArgs[j];
+ }
+ int retval = runCommand(task, outputDir, commandline);
+ // if with monitor, add more code
+ if (retval != 0) {
+ throw new BuildException(this.getCommand()
+ + " failed with return code " + retval, task
+ .getLocation());
+ }
+ sourceIndex = firstFileNextExec;
+ }
+ }
+
+ protected AssemblerConfiguration createConfiguration(final CCTask task,
+ final LinkType linkType, final ProcessorDef[] baseDefs,
+ final AssemblerDef specificDef,
+ final TargetDef targetPlatform) {
+ Vector args = new Vector();
+ AssemblerDef[] defaultProviders = new AssemblerDef[baseDefs.length + 1];
+ for (int i = 0; i < baseDefs.length; i++) {
+ defaultProviders[i + 1] = (AssemblerDef) baseDefs[i];
+ }
+ defaultProviders[0] = specificDef;
+ Vector cmdArgs = new Vector();
+ //
+ // add command line arguments inherited from element
+ // any "extends" and finally and specific AssemblerDef
+ //
+ CommandLineArgument[] commandArgs;
+ for (int i = defaultProviders.length - 1; i >= 0; i--) {
+ commandArgs = defaultProviders[i].getActiveProcessorArgs();
+ for (int j = 0; j < commandArgs.length; j++) {
+ if (commandArgs[j].getLocation() == 0) {
+ args.addElement(commandArgs[j].getValue());
+ } else {
+ cmdArgs.addElement(commandArgs[j]);
+ }
+ }
+ }
+ // omit param
+ boolean debug = specificDef.getDebug(baseDefs, 0);
+ Boolean defaultflag = specificDef.getDefaultflag(defaultProviders, 1);
+ this.addImpliedArgs(args, debug, defaultflag);
+ //
+ // Want to have distinct set of arguments with relative
+ // path names for includes that are used to build
+ // the configuration identifier
+ //
+ Vector relativeArgs = (Vector) args.clone();
+ //
+ // add all active include an
+ //
+ StringBuffer includePathIdentifier = new StringBuffer();
+ File baseDir = specificDef.getProject().getBaseDir();
+ String baseDirPath;
+ try {
+ baseDirPath = baseDir.getCanonicalPath();
+ } catch (IOException ex) {
+ baseDirPath = baseDir.toString();
+ }
+ Vector includePath = new Vector();
+ Vector sysIncludePath = new Vector();
+ for (int i = defaultProviders.length - 1; i >= 0; i--) {
+ String[] incPath = defaultProviders[i].getActiveIncludePaths();
+ for (int j = 0; j < incPath.length; j++) {
+ includePath.addElement(incPath[j]);
+ }
+ incPath = defaultProviders[i].getActiveSysIncludePaths();
+ for (int j = 0; j < incPath.length; j++) {
+ sysIncludePath.addElement(incPath[j]);
+ }
+ }
+ File[] incPath = new File[includePath.size()];
+ for (int i = 0; i < includePath.size(); i++) {
+ incPath[i] = new File((String) includePath.elementAt(i));
+ }
+ File[] sysIncPath = new File[sysIncludePath.size()];
+ for (int i = 0; i < sysIncludePath.size(); i++) {
+ sysIncPath[i] = new File((String) sysIncludePath.elementAt(i));
+ }
+ addIncludes(baseDirPath, incPath, args, relativeArgs,
+ includePathIdentifier);
+ addIncludes(baseDirPath, sysIncPath, args, null, null);
+ StringBuffer buf = new StringBuffer(getIdentifier());
+ for (int i = 0; i < relativeArgs.size(); i++) {
+ buf.append(relativeArgs.elementAt(i));
+ buf.append(' ');
+ }
+ buf.setLength(buf.length() - 1);
+ Enumeration argEnum = cmdArgs.elements();
+ int endCount = 0;
+ while (argEnum.hasMoreElements()) {
+ CommandLineArgument arg = (CommandLineArgument) argEnum
+ .nextElement();
+ switch (arg.getLocation()) {
+ case 1:
+ args.addElement(arg.getValue());
+ break;
+ case 2:
+ endCount++;
+ break;
+ }
+ }
+ String[] endArgs = new String[endCount];
+ argEnum = cmdArgs.elements();
+ int index = 0;
+ while (argEnum.hasMoreElements()) {
+ CommandLineArgument arg = (CommandLineArgument) argEnum
+ .nextElement();
+ if (arg.getLocation() == 2) {
+ endArgs[index++] = arg.getValue();
+ }
+ }
+ String[] argArray = new String[args.size()];
+ args.copyInto(argArray);
+ return new CommandLineAssemblerConfiguration(this, incPath, sysIncPath,
+ new File[0], argArray, true, endArgs, new String[0]);
+ }
+
+ protected int getArgumentCountPerInputFile() {
+ return 1;
+ }
+
+ protected abstract File[] getEnvironmentIncludePath();
+
+ public String getIdentifier() {
+ if (identifier == null) {
+ if (identifierArg == null) {
+ identifier = getIdentifier(new String[] { command }, command);
+ } else {
+ identifier = getIdentifier(new String[] { command,
+ identifierArg }, command);
+ }
+ }
+ return identifier;
+ }
+
+ public final String getCommand() {
+ return command;
+ }
+
+ abstract public int getMaximumCommandLength();
+
+ public void setCommand(String command) {
+ this.command = command;
+ }
+
+ protected int getTotalArgumentLengthForInputFile(File outputDir,
+ String inputFile) {
+ return inputFile.length() + 1;
+ }
+
+ protected int runCommand(CCTask task, File workingDir, String[] cmdline)
+ throws BuildException {
+ return CUtil.runCommand(task, workingDir, cmdline, false, null);
+ }
+
+ protected int getMaximumInputFilesPerCommand() {
+ return Integer.MAX_VALUE;
+ }
+
+ protected int getArgumentCountPerInputFIle() {
+ return 1;
+ }
+
+ protected String getInputFileArgument(File outputDir, String filename,
+ int index) {
+ //
+ // if there is an embedded space,
+ // must enclose in quotes
+ if (filename.indexOf(' ') >= 0) {
+ StringBuffer buf = new StringBuffer("\"");
+ buf.append(filename);
+ buf.append("\"");
+ return buf.toString();
+ }
+ return filename;
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/compiler/CommandLineAssemblerConfiguration.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/compiler/CommandLineAssemblerConfiguration.java
new file mode 100644
index 0000000000..542d441559
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/compiler/CommandLineAssemblerConfiguration.java
@@ -0,0 +1,123 @@
+/*
+ *
+ * Copyright 2001-2005 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.compiler;
+
+import java.io.File;
+
+import org.apache.tools.ant.BuildException;
+
+import net.sf.antcontrib.cpptasks.CCTask;
+import net.sf.antcontrib.cpptasks.ProcessorParam;
+
+/**
+ * A configuration for an assember
+ *
+ */
+public final class CommandLineAssemblerConfiguration implements
+ AssemblerConfiguration {
+
+ private String[] args;
+
+ private CommandLineAssembler assembler;
+
+ private String[] endArgs;
+
+ //
+ // include path from environment variable
+ // not explicitly stated in Ant script
+ //
+ private File[] envIncludePath;
+
+ private String[] exceptFiles;
+
+ private File[] includePath;
+
+ private boolean rebuild;
+
+ private File[] sysIncludePath;
+
+ public CommandLineAssemblerConfiguration (CommandLineAssembler assembler,
+ File[] includePath, File[] sysIncludePath,
+ File[] envIncludePath, String[] args, boolean rebuild,
+ String[] endArgs, String[] exceptFiles) {
+ if (assembler == null) {
+ throw new NullPointerException("assembler");
+ }
+ if (args == null) {
+ this.args = new String[0];
+ } else {
+ this.args = (String[]) args.clone();
+ }
+ if (includePath == null) {
+ this.includePath = new File[0];
+ } else {
+ this.includePath = (File[]) includePath.clone();
+ }
+ if (sysIncludePath == null) {
+ this.sysIncludePath = new File[0];
+ } else {
+ this.sysIncludePath = (File[]) sysIncludePath.clone();
+ }
+ if (envIncludePath == null) {
+ this.envIncludePath = new File[0];
+ } else {
+ this.envIncludePath = (File[]) envIncludePath.clone();
+ }
+ this.assembler = assembler;
+ this.rebuild = rebuild;
+ this.endArgs = (String[]) endArgs.clone();
+ this.exceptFiles = (String[]) exceptFiles.clone();
+ }
+
+ public int bid(String inputFile) {
+ int assembleBid = assembler.bid(inputFile);
+ return assembleBid;
+ }
+
+ public void assembler(CCTask task, File outputDir, String[] sourceFiles)
+ throws BuildException {
+ try {
+ assembler.assembler(task, outputDir, sourceFiles, args, endArgs);
+ } catch (BuildException ex) {
+ throw ex;
+ }
+ }
+
+ public String getOutputFileName(String inputFile) {
+ return assembler.getOutputFileName(inputFile);
+ }
+
+ public String getIdentifier() {
+ return assembler.getCommand();
+ }
+
+ public ProcessorParam[] getParams() {
+ return new ProcessorParam[0];
+ }
+
+ public boolean getRebuild() {
+ return rebuild;
+ }
+
+ public String[] getPreArguments() {
+ return (String[]) args.clone();
+ }
+
+ public String[] getEndArguments() {
+ return (String[]) endArgs.clone();
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/compiler/CommandLineCCompiler.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/compiler/CommandLineCCompiler.java
new file mode 100644
index 0000000000..442d6b8187
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/compiler/CommandLineCCompiler.java
@@ -0,0 +1,42 @@
+/*
+ *
+ * Copyright 2002-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.compiler;
+import java.io.File;
+
+import net.sf.antcontrib.cpptasks.parser.CParser;
+import net.sf.antcontrib.cpptasks.parser.Parser;
+
+import org.apache.tools.ant.types.Environment;
+/**
+ * An abstract Compiler implementation which uses an external program to
+ * perform the compile.
+ *
+ * @author Adam Murdoch
+ */
+public abstract class CommandLineCCompiler extends CommandLineCompiler {
+ protected CommandLineCCompiler(String command, String identifierArg,
+ String[] sourceExtensions, String[] headerExtensions,
+ String outputSuffix, boolean libtool,
+ CommandLineCCompiler libtoolCompiler, boolean newEnvironment,
+ Environment env) {
+ super(command, identifierArg, sourceExtensions, headerExtensions,
+ outputSuffix, libtool, libtoolCompiler, newEnvironment, env);
+ }
+ protected Parser createParser(File source) {
+ return new CParser();
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/compiler/CommandLineCompiler.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/compiler/CommandLineCompiler.java
new file mode 100644
index 0000000000..3f45ce539d
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/compiler/CommandLineCompiler.java
@@ -0,0 +1,435 @@
+/*
+ *
+ * Copyright 2002-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.compiler;
+import java.io.File;
+import java.io.IOException;
+import java.util.Enumeration;
+import java.util.Vector;
+import net.sf.antcontrib.cpptasks.CCTask;
+import net.sf.antcontrib.cpptasks.CUtil;
+import net.sf.antcontrib.cpptasks.CompilerDef;
+import net.sf.antcontrib.cpptasks.ProcessorDef;
+import net.sf.antcontrib.cpptasks.ProcessorParam;
+import net.sf.antcontrib.cpptasks.types.CommandLineArgument;
+import net.sf.antcontrib.cpptasks.types.UndefineArgument;
+import net.sf.antcontrib.cpptasks.TargetDef;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.types.Environment;
+import net.sf.antcontrib.cpptasks.OptimizationEnum;;
+/**
+ * An abstract Compiler implementation which uses an external program to
+ * perform the compile.
+ *
+ * @author Adam Murdoch
+ */
+public abstract class CommandLineCompiler extends AbstractCompiler {
+ private String command;
+ private final Environment env;
+ private String identifier;
+ private String identifierArg;
+ private boolean libtool;
+ private CommandLineCompiler libtoolCompiler;
+ private final boolean newEnvironment;
+ protected CommandLineCompiler(String command, String identifierArg,
+ String[] sourceExtensions, String[] headerExtensions,
+ String outputSuffix, boolean libtool,
+ CommandLineCompiler libtoolCompiler, boolean newEnvironment,
+ Environment env) {
+ super(sourceExtensions, headerExtensions, outputSuffix);
+ this.command = command;
+ if (libtool && libtoolCompiler != null) {
+ throw new java.lang.IllegalArgumentException(
+ "libtoolCompiler should be null when libtool is true");
+ }
+ this.libtool = libtool;
+ this.libtoolCompiler = libtoolCompiler;
+ this.identifierArg = identifierArg;
+ this.newEnvironment = newEnvironment;
+ this.env = env;
+ }
+ abstract protected void addImpliedArgs(Vector args, boolean debug,
+ boolean multithreaded, boolean exceptions, LinkType linkType,
+ Boolean rtti, OptimizationEnum optimization, Boolean defaultflag);
+ /**
+ * Adds command-line arguments for include directories.
+ *
+ * If relativeArgs is not null will add corresponding relative paths
+ * include switches to that vector (for use in building a configuration
+ * identifier that is consistent between machines).
+ *
+ * @param baseDirPaths
+ * A vector containing the parts of the working directory,
+ * produced by CUtil.DecomposeFile.
+ * @param includeDirs
+ * Array of include directory paths
+ * @param args
+ * Vector of command line arguments used to execute the task
+ * @param relativeArgs
+ * Vector of command line arguments used to build the
+ * configuration identifier
+ */
+ protected void addIncludes(String baseDirPath, File[] includeDirs,
+ Vector args, Vector relativeArgs, StringBuffer includePathId) {
+ for (int i = 0; i < includeDirs.length; i++) {
+ args.addElement(getIncludeDirSwitch(includeDirs[i]
+ .getAbsolutePath()));
+ if (relativeArgs != null) {
+ String relative = CUtil.getRelativePath(baseDirPath,
+ includeDirs[i]);
+ relativeArgs.addElement(getIncludeDirSwitch(relative));
+ if (includePathId != null) {
+ if (includePathId.length() == 0) {
+ includePathId.append("/I");
+ } else {
+ includePathId.append(" /I");
+ }
+ includePathId.append(relative);
+ }
+ }
+ }
+ }
+ abstract protected void addWarningSwitch(Vector args, int warnings);
+ protected void buildDefineArguments(CompilerDef[] defs, Vector args) {
+ //
+ // assume that we aren't inheriting defines from containing
+ //
+ UndefineArgument[] merged = defs[0].getActiveDefines();
+ for (int i = 1; i < defs.length; i++) {
+ //
+ // if we are inheriting, merge the specific defines with the
+ // containing defines
+ merged = UndefineArgument.merge(defs[i].getActiveDefines(), merged);
+ }
+ StringBuffer buf = new StringBuffer(30);
+ for (int i = 0; i < merged.length; i++) {
+ buf.setLength(0);
+ UndefineArgument current = merged[i];
+ if (current.isDefine()) {
+ getDefineSwitch(buf, current.getName(), current.getValue());
+ } else {
+ getUndefineSwitch(buf, current.getName());
+ }
+ args.addElement(buf.toString());
+ }
+ }
+ /**
+ * Compiles a source file.
+ *
+ * @author Curt Arnold
+ */
+ public void compile(CCTask task, File outputDir, String[] sourceFiles,
+ String[] args, String[] endArgs, boolean relentless,
+ CommandLineCompilerConfiguration config, ProgressMonitor monitor)
+ throws BuildException {
+ BuildException exc = null;
+ //
+ // determine length of executable name and args
+ //
+ String command = getCommand();
+ int baseLength = command.length() + args.length + endArgs.length;
+ if (libtool) {
+ baseLength += 8;
+ }
+ for (int i = 0; i < args.length; i++) {
+ baseLength += args[i].length();
+ }
+ for (int i = 0; i < endArgs.length; i++) {
+ baseLength += endArgs[i].length();
+ }
+ if (baseLength > getMaximumCommandLength()) {
+ throw new BuildException(
+ "Command line is over maximum length without specifying source file");
+ }
+ //
+ // typically either 1 or Integer.MAX_VALUE
+ //
+ int maxInputFilesPerCommand = getMaximumInputFilesPerCommand();
+ int argumentCountPerInputFile = getArgumentCountPerInputFile();
+ for (int sourceIndex = 0; sourceIndex < sourceFiles.length;) {
+ int cmdLength = baseLength;
+ int firstFileNextExec;
+ for (firstFileNextExec = sourceIndex; firstFileNextExec < sourceFiles.length
+ && (firstFileNextExec - sourceIndex) < maxInputFilesPerCommand; firstFileNextExec++) {
+ cmdLength += getTotalArgumentLengthForInputFile(outputDir,
+ sourceFiles[firstFileNextExec]);
+ if (cmdLength >= getMaximumCommandLength())
+ break;
+ }
+ if (firstFileNextExec == sourceIndex) {
+ throw new BuildException(
+ "Extremely long file name, can't fit on command line");
+ }
+ int argCount = args.length + 1 + endArgs.length
+ + (firstFileNextExec - sourceIndex)
+ * argumentCountPerInputFile;
+ if (libtool) {
+ argCount++;
+ }
+ String[] commandline = new String[argCount];
+ int index = 0;
+ if (libtool) {
+ commandline[index++] = "libtool";
+ }
+ commandline[index++] = command;
+ for (int j = 0; j < args.length; j++) {
+ commandline[index++] = args[j];
+ }
+ for (int j = sourceIndex; j < firstFileNextExec; j++) {
+ for (int k = 0; k < argumentCountPerInputFile; k++) {
+ commandline[index++] = getInputFileArgument(outputDir,
+ sourceFiles[j], k);
+ }
+ }
+ for (int j = 0; j < endArgs.length; j++) {
+ commandline[index++] = endArgs[j];
+ }
+ int retval = runCommand(task, outputDir, commandline);
+ if (monitor != null) {
+ String[] fileNames = new String[firstFileNextExec - sourceIndex];
+ for (int j = 0; j < fileNames.length; j++) {
+ fileNames[j] = sourceFiles[sourceIndex + j];
+ }
+ monitor.progress(fileNames);
+ }
+ //
+ // if the process returned a failure code and
+ // we aren't holding an exception from an earlier
+ // interation
+ if (retval != 0 && exc == null) {
+ //
+ // construct the exception
+ //
+ exc = new BuildException(this.getCommand()
+ + " failed with return code " + retval, task
+ .getLocation());
+ //
+ // and throw it now unless we are relentless
+ //
+ if (!relentless) {
+ throw exc;
+ }
+ }
+ sourceIndex = firstFileNextExec;
+ }
+ //
+ // if the compiler returned a failure value earlier
+ // then throw an exception
+ if (exc != null) {
+ throw exc;
+ }
+ }
+ protected CompilerConfiguration createConfiguration(final CCTask task,
+ final LinkType linkType,
+ final ProcessorDef[] baseDefs,
+ final CompilerDef specificDef,
+ final TargetDef targetPlatform) {
+ Vector args = new Vector();
+ CompilerDef[] defaultProviders = new CompilerDef[baseDefs.length + 1];
+ for (int i = 0; i < baseDefs.length; i++) {
+ defaultProviders[i + 1] = (CompilerDef) baseDefs[i];
+ }
+ defaultProviders[0] = specificDef;
+ Vector cmdArgs = new Vector();
+ //
+ // add command line arguments inherited from element
+ // any "extends" and finally the specific CompilerDef
+ CommandLineArgument[] commandArgs;
+ for (int i = defaultProviders.length - 1; i >= 0; i--) {
+ commandArgs = defaultProviders[i].getActiveProcessorArgs();
+ for (int j = 0; j < commandArgs.length; j++) {
+ if (commandArgs[j].getLocation() == 0) {
+ args.addElement(commandArgs[j].getValue());
+ } else {
+ cmdArgs.addElement(commandArgs[j]);
+ }
+ }
+ }
+ Vector params = new Vector();
+ //
+ // add command line arguments inherited from element
+ // any "extends" and finally the specific CompilerDef
+ ProcessorParam[] paramArray;
+ for (int i = defaultProviders.length - 1; i >= 0; i--) {
+ paramArray = defaultProviders[i].getActiveProcessorParams();
+ for (int j = 0; j < paramArray.length; j++) {
+ params.add(paramArray[j]);
+ }
+ }
+ paramArray = (ProcessorParam[]) (params
+ .toArray(new ProcessorParam[params.size()]));
+ boolean multithreaded = specificDef.getMultithreaded(defaultProviders,
+ 1);
+ boolean debug = specificDef.getDebug(baseDefs, 0);
+ boolean exceptions = specificDef.getExceptions(defaultProviders, 1);
+ Boolean rtti = specificDef.getRtti(defaultProviders, 1);
+ Boolean defaultflag = specificDef.getDefaultflag(defaultProviders, 1);
+ OptimizationEnum optimization = specificDef.getOptimization(defaultProviders, 1);
+ this.addImpliedArgs(args, debug, multithreaded, exceptions, linkType, rtti, optimization, defaultflag);
+ //
+ // add all appropriate defines and undefines
+ //
+ buildDefineArguments(defaultProviders, args);
+ //
+ // Want to have distinct set of arguments with relative
+ // path names for includes that are used to build
+ // the configuration identifier
+ //
+ Vector relativeArgs = (Vector) args.clone();
+ //
+ // add all active include and sysincludes
+ //
+ StringBuffer includePathIdentifier = new StringBuffer();
+ File baseDir = specificDef.getProject().getBaseDir();
+ String baseDirPath;
+ try {
+ baseDirPath = baseDir.getCanonicalPath();
+ } catch (IOException ex) {
+ baseDirPath = baseDir.toString();
+ }
+ Vector includePath = new Vector();
+ Vector sysIncludePath = new Vector();
+ for (int i = defaultProviders.length - 1; i >= 0; i--) {
+ String[] incPath = defaultProviders[i].getActiveIncludePaths();
+ for (int j = 0; j < incPath.length; j++) {
+ includePath.addElement(incPath[j]);
+ }
+ incPath = defaultProviders[i].getActiveSysIncludePaths();
+ for (int j = 0; j < incPath.length; j++) {
+ sysIncludePath.addElement(incPath[j]);
+ }
+ }
+ File[] incPath = new File[includePath.size()];
+ for (int i = 0; i < includePath.size(); i++) {
+ incPath[i] = new File((String) includePath.elementAt(i));
+ }
+ File[] sysIncPath = new File[sysIncludePath.size()];
+ for (int i = 0; i < sysIncludePath.size(); i++) {
+ sysIncPath[i] = new File((String) sysIncludePath.elementAt(i));
+ }
+ addIncludes(baseDirPath, incPath, args, relativeArgs,
+ includePathIdentifier);
+ addIncludes(baseDirPath, sysIncPath, args, null, null);
+ StringBuffer buf = new StringBuffer(getIdentifier());
+ for (int i = 0; i < relativeArgs.size(); i++) {
+ buf.append(relativeArgs.elementAt(i));
+ buf.append(' ');
+ }
+ buf.setLength(buf.length() - 1);
+ String configId = buf.toString();
+ int warnings = specificDef.getWarnings(defaultProviders, 0);
+ addWarningSwitch(args, warnings);
+ Enumeration argEnum = cmdArgs.elements();
+ int endCount = 0;
+ while (argEnum.hasMoreElements()) {
+ CommandLineArgument arg = (CommandLineArgument) argEnum
+ .nextElement();
+ switch (arg.getLocation()) {
+ case 1 :
+ args.addElement(arg.getValue());
+ break;
+ case 2 :
+ endCount++;
+ break;
+ }
+ }
+ String[] endArgs = new String[endCount];
+ argEnum = cmdArgs.elements();
+ int index = 0;
+ while (argEnum.hasMoreElements()) {
+ CommandLineArgument arg = (CommandLineArgument) argEnum
+ .nextElement();
+ if (arg.getLocation() == 2) {
+ endArgs[index++] = arg.getValue();
+ }
+ }
+ String[] argArray = new String[args.size()];
+ args.copyInto(argArray);
+ boolean rebuild = specificDef.getRebuild(baseDefs, 0);
+ File[] envIncludePath = getEnvironmentIncludePath();
+ return new CommandLineCompilerConfiguration(this, configId, incPath,
+ sysIncPath, envIncludePath, includePathIdentifier.toString(),
+ argArray, paramArray, rebuild, endArgs);
+ }
+ protected int getArgumentCountPerInputFile() {
+ return 1;
+ }
+ protected final String getCommand() {
+ return command;
+ }
+ abstract protected void getDefineSwitch(StringBuffer buffer, String define,
+ String value);
+ protected abstract File[] getEnvironmentIncludePath();
+ public String getIdentifier() {
+ if (identifier == null) {
+ if (identifierArg == null) {
+ identifier = getIdentifier(new String[]{command}, command);
+ } else {
+ identifier = getIdentifier(
+ new String[]{command, identifierArg}, command);
+ }
+ }
+ return identifier;
+ }
+ abstract protected String getIncludeDirSwitch(String source);
+ protected String getInputFileArgument(File outputDir, String filename,
+ int index) {
+ //
+ // if there is an embedded space,
+ // must enclose in quotes
+ if (filename.indexOf(' ') >= 0) {
+ StringBuffer buf = new StringBuffer("\"");
+ buf.append(filename);
+ buf.append("\"");
+ return buf.toString();
+ }
+ return filename;
+ }
+ protected final boolean getLibtool() {
+ return libtool;
+ }
+ /**
+ * Obtains the same compiler, but with libtool set
+ *
+ * Default behavior is to ignore libtool
+ */
+ public final CommandLineCompiler getLibtoolCompiler() {
+ if (libtoolCompiler != null) {
+ return libtoolCompiler;
+ }
+ return this;
+ }
+ abstract public int getMaximumCommandLength();
+ protected int getMaximumInputFilesPerCommand() {
+ return Integer.MAX_VALUE;
+ }
+ protected int getTotalArgumentLengthForInputFile(File outputDir,
+ String inputFile) {
+ return inputFile.length() + 1;
+ }
+ abstract protected void getUndefineSwitch(StringBuffer buffer, String define);
+ /**
+ * This method is exposed so test classes can overload and test the
+ * arguments without actually spawning the compiler
+ */
+ protected int runCommand(CCTask task, File workingDir, String[] cmdline)
+ throws BuildException {
+ return CUtil.runCommand(task, workingDir, cmdline, newEnvironment, env);
+ }
+ protected final void setCommand(String command) {
+ this.command = command;
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/compiler/CommandLineCompilerConfiguration.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/compiler/CommandLineCompilerConfiguration.java
new file mode 100644
index 0000000000..4c53df105b
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/compiler/CommandLineCompilerConfiguration.java
@@ -0,0 +1,216 @@
+/*
+ *
+ * Copyright 2002-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.compiler;
+import java.io.File;
+
+import net.sf.antcontrib.cpptasks.CCTask;
+import net.sf.antcontrib.cpptasks.CompilerParam;
+import net.sf.antcontrib.cpptasks.DependencyInfo;
+import net.sf.antcontrib.cpptasks.ProcessorParam;
+
+import org.apache.tools.ant.BuildException;
+/**
+ * A configuration for a C++ compiler
+ *
+ * @author Curt Arnold
+ */
+public final class CommandLineCompilerConfiguration
+ implements
+ CompilerConfiguration {
+ private/* final */String[] args;
+ private/* final */CommandLineCompiler compiler;
+ private String[] endArgs;
+ //
+ // include path from environment variable not
+ // explicitly stated in Ant script
+ private/* final */File[] envIncludePath;
+ private String[] exceptFiles;
+ private/* final */String identifier;
+ private/* final */File[] includePath;
+ private/* final */String includePathIdentifier;
+ private boolean isPrecompiledHeaderGeneration;
+ private/* final */ProcessorParam[] params;
+ private/* final */boolean rebuild;
+ private/* final */File[] sysIncludePath;
+ public CommandLineCompilerConfiguration(CommandLineCompiler compiler,
+ String identifier, File[] includePath, File[] sysIncludePath,
+ File[] envIncludePath, String includePathIdentifier, String[] args,
+ ProcessorParam[] params, boolean rebuild, String[] endArgs) {
+ if (compiler == null) {
+ throw new NullPointerException("compiler");
+ }
+ if (identifier == null) {
+ throw new NullPointerException("identifier");
+ }
+ if (includePathIdentifier == null) {
+ throw new NullPointerException("includePathIdentifier");
+ }
+ if (args == null) {
+ this.args = new String[0];
+ } else {
+ this.args = (String[]) args.clone();
+ }
+ if (includePath == null) {
+ this.includePath = new File[0];
+ } else {
+ this.includePath = (File[]) includePath.clone();
+ }
+ if (sysIncludePath == null) {
+ this.sysIncludePath = new File[0];
+ } else {
+ this.sysIncludePath = (File[]) sysIncludePath.clone();
+ }
+ if (envIncludePath == null) {
+ this.envIncludePath = new File[0];
+ } else {
+ this.envIncludePath = (File[]) envIncludePath.clone();
+ }
+ this.compiler = compiler;
+ this.params = (ProcessorParam[]) params.clone();
+ this.rebuild = rebuild;
+ this.identifier = identifier;
+ this.includePathIdentifier = includePathIdentifier;
+ this.endArgs = (String[]) endArgs.clone();
+ exceptFiles = null;
+ isPrecompiledHeaderGeneration = false;
+ }
+ public CommandLineCompilerConfiguration(
+ CommandLineCompilerConfiguration base, String[] additionalArgs,
+ String[] exceptFiles, boolean isPrecompileHeaderGeneration) {
+ compiler = base.compiler;
+ identifier = base.identifier;
+ rebuild = base.rebuild;
+ includePath = (File[]) base.includePath.clone();
+ sysIncludePath = (File[]) base.sysIncludePath.clone();
+ endArgs = (String[]) base.endArgs.clone();
+ envIncludePath = (File[]) base.envIncludePath.clone();
+ includePathIdentifier = base.includePathIdentifier;
+ if (exceptFiles != null) {
+ this.exceptFiles = (String[]) exceptFiles.clone();
+ }
+ this.isPrecompiledHeaderGeneration = isPrecompileHeaderGeneration;
+ args = new String[base.args.length + additionalArgs.length];
+ for (int i = 0; i < base.args.length; i++) {
+ args[i] = base.args[i];
+ }
+ int index = base.args.length;
+ for (int i = 0; i < additionalArgs.length; i++) {
+ args[index++] = additionalArgs[i];
+ }
+ }
+ public int bid(String inputFile) {
+ int compilerBid = compiler.bid(inputFile);
+ if (compilerBid > 0 && exceptFiles != null) {
+ for (int i = 0; i < exceptFiles.length; i++) {
+ if (inputFile.equals(exceptFiles[i])) {
+ return 0;
+ }
+ }
+ }
+ return compilerBid;
+ }
+ public void compile(CCTask task, File outputDir, String[] sourceFiles,
+ boolean relentless, ProgressMonitor monitor) throws BuildException {
+ if (monitor != null) {
+ monitor.start(this);
+ }
+ try {
+ compiler.compile(task, outputDir, sourceFiles, args, endArgs,
+ relentless, this, monitor);
+ if (monitor != null) {
+ monitor.finish(this, true);
+ }
+ } catch (BuildException ex) {
+ if (monitor != null) {
+ monitor.finish(this, false);
+ }
+ throw ex;
+ }
+ }
+ /**
+ *
+ * This method may be used to get two distinct compiler configurations, one
+ * for compiling the specified file and producing a precompiled header
+ * file, and a second for compiling other files using the precompiled
+ * header file.
+ *
+ * The last (preferrably only) include directive in the prototype file will
+ * be used to mark the boundary between pre-compiled and normally compiled
+ * headers.
+ *
+ * @param prototype
+ * A source file (for example, stdafx.cpp) that is used to build
+ * the precompiled header file. @returns null if precompiled
+ * headers are not supported or a two element array containing
+ * the precompiled header generation configuration and the
+ * consuming configuration
+ *
+ */
+ public CompilerConfiguration[] createPrecompileConfigurations(
+ File prototype, String[] nonPrecompiledFiles) {
+ if (compiler instanceof PrecompilingCompiler) {
+ return ((PrecompilingCompiler) compiler)
+ .createPrecompileConfigurations(this, prototype,
+ nonPrecompiledFiles);
+ }
+ return null;
+ }
+ /**
+ * Returns a string representation of this configuration. Should be
+ * canonical so that equivalent configurations will have equivalent string
+ * representations
+ */
+ public String getIdentifier() {
+ return identifier;
+ }
+ public String getIncludePathIdentifier() {
+ return includePathIdentifier;
+ }
+ public String getOutputFileName(String inputFile) {
+ return compiler.getOutputFileName(inputFile);
+ }
+ public CompilerParam getParam(String name) {
+ for (int i = 0; i < params.length; i++) {
+ if (name.equals(params[i].getName()))
+ return (CompilerParam) params[i];
+ }
+ return null;
+ }
+ public ProcessorParam[] getParams() {
+ return params;
+ }
+ public boolean getRebuild() {
+ return rebuild;
+ }
+ public boolean isPrecompileGeneration() {
+ return isPrecompiledHeaderGeneration;
+ }
+ public DependencyInfo parseIncludes(CCTask task, File baseDir, File source) {
+ return compiler.parseIncludes(task, source, includePath,
+ sysIncludePath, envIncludePath, baseDir,
+ getIncludePathIdentifier());
+ }
+ public String toString() {
+ return identifier;
+ }
+ public String[] getPreArguments() {
+ return (String[]) args.clone();
+ }
+ public String[] getEndArguments() {
+ return (String[]) endArgs.clone();
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/compiler/CommandLineFortranCompiler.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/compiler/CommandLineFortranCompiler.java
new file mode 100644
index 0000000000..d01cb9e356
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/compiler/CommandLineFortranCompiler.java
@@ -0,0 +1,42 @@
+/*
+ *
+ * Copyright 2002-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.compiler;
+import java.io.File;
+
+import net.sf.antcontrib.cpptasks.parser.FortranParser;
+import net.sf.antcontrib.cpptasks.parser.Parser;
+
+import org.apache.tools.ant.types.Environment;
+/**
+ * An abstract Compiler implementation which uses an external program to
+ * perform the compile.
+ *
+ * @author Curt Arnold
+ */
+public abstract class CommandLineFortranCompiler extends CommandLineCompiler {
+ protected CommandLineFortranCompiler(String command, String identifierArg,
+ String[] sourceExtensions, String[] headerExtensions,
+ String outputSuffix, boolean libtool,
+ CommandLineFortranCompiler libtoolCompiler, boolean newEnvironment,
+ Environment env) {
+ super(command, identifierArg, sourceExtensions, headerExtensions,
+ outputSuffix, libtool, libtoolCompiler, newEnvironment, env);
+ }
+ protected Parser createParser(File source) {
+ return new FortranParser();
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/compiler/CommandLineLinker.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/compiler/CommandLineLinker.java
new file mode 100644
index 0000000000..4161469a8f
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/compiler/CommandLineLinker.java
@@ -0,0 +1,404 @@
+/*
+ *
+ * Copyright 2002-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.compiler;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.util.Enumeration;
+import java.util.Vector;
+
+import net.sf.antcontrib.cpptasks.CCTask;
+import net.sf.antcontrib.cpptasks.CUtil;
+import net.sf.antcontrib.cpptasks.LinkerDef;
+import net.sf.antcontrib.cpptasks.ProcessorDef;
+import net.sf.antcontrib.cpptasks.ProcessorParam;
+import net.sf.antcontrib.cpptasks.types.CommandLineArgument;
+import net.sf.antcontrib.cpptasks.types.LibrarySet;
+import net.sf.antcontrib.cpptasks.TargetDef;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.types.Environment;
+
+
+/**
+ * An abstract Linker implementation that performs the link via an external
+ * command.
+ *
+ * @author Adam Murdoch
+ */
+public abstract class CommandLineLinker extends AbstractLinker
+{
+ private String command;
+ private Environment env = null;
+ private String identifier;
+ private String identifierArg;
+ private boolean isLibtool;
+ private String[] librarySets;
+ private CommandLineLinker libtoolLinker;
+ private boolean newEnvironment = false;
+ private String outputSuffix;
+
+
+ /** Creates a comand line linker invocation */
+ public CommandLineLinker(String command,
+ String identifierArg,
+ String[] extensions,
+ String[] ignoredExtensions, String outputSuffix,
+ boolean isLibtool, CommandLineLinker libtoolLinker)
+ {
+ super(extensions, ignoredExtensions);
+ this.command = command;
+ this.identifierArg = identifierArg;
+ this.outputSuffix = outputSuffix;
+ this.isLibtool = isLibtool;
+ this.libtoolLinker = libtoolLinker;
+ }
+ protected abstract void addBase(long base, Vector args);
+
+ protected abstract void addFixed(Boolean fixed, Vector args);
+
+ abstract protected void addImpliedArgs(boolean debug,
+ LinkType linkType, Vector args, Boolean defaultflag);
+ protected abstract void addIncremental(boolean incremental, Vector args);
+
+ //
+ // Windows processors handle these through file list
+ //
+ protected String[] addLibrarySets(CCTask task, LibrarySet[] libsets, Vector preargs,
+ Vector midargs, Vector endargs) {
+ return null;
+ }
+ protected abstract void addMap(boolean map, Vector args);
+ protected abstract void addStack(int stack, Vector args);
+ protected abstract void addEntry(String entry, Vector args);
+
+ protected LinkerConfiguration createConfiguration(
+ CCTask task,
+ LinkType linkType,
+ ProcessorDef[] baseDefs, LinkerDef specificDef, TargetDef targetPlatform) {
+
+ Vector preargs = new Vector();
+ Vector midargs = new Vector();
+ Vector endargs = new Vector();
+ Vector[] args = new Vector[] { preargs, midargs, endargs };
+
+ LinkerDef[] defaultProviders = new LinkerDef[baseDefs.length+1];
+ defaultProviders[0] = specificDef;
+ for(int i = 0; i < baseDefs.length; i++) {
+ defaultProviders[i+1] = (LinkerDef) baseDefs[i];
+ }
+ //
+ // add command line arguments inherited from element
+ // any "extends" and finally the specific CompilerDef
+ CommandLineArgument[] commandArgs;
+ for(int i = defaultProviders.length-1; i >= 0; i--) {
+ commandArgs = defaultProviders[i].getActiveProcessorArgs();
+ for(int j = 0; j < commandArgs.length; j++) {
+ args[commandArgs[j].getLocation()].
+ addElement(commandArgs[j].getValue());
+ }
+ }
+
+ Vector params = new Vector();
+ //
+ // add command line arguments inherited from element
+ // any "extends" and finally the specific CompilerDef
+ ProcessorParam[] paramArray;
+ for (int i = defaultProviders.length - 1; i >= 0; i--) {
+ paramArray = defaultProviders[i].getActiveProcessorParams();
+ for (int j = 0; j < paramArray.length; j++) {
+ params.add(paramArray[j]);
+ }
+ }
+
+ paramArray = (ProcessorParam[])(params.toArray(new ProcessorParam[params.size()]));
+
+ boolean debug = specificDef.getDebug(baseDefs,0);
+
+
+ String startupObject = getStartupObject(linkType);
+ Boolean defaultflag = specificDef.getDefaultflag(defaultProviders, 1);
+ addImpliedArgs(debug, linkType, preargs, defaultflag);
+ addIncremental(specificDef.getIncremental(defaultProviders,1), preargs);
+ addFixed(specificDef.getFixed(defaultProviders,1), preargs);
+ addMap(specificDef.getMap(defaultProviders,1), preargs);
+ addBase(specificDef.getBase(defaultProviders,1), preargs);
+ addStack(specificDef.getStack(defaultProviders,1), preargs);
+ addEntry(specificDef.getEntry(defaultProviders, 1), preargs);
+
+ String[] libnames = null;
+ LibrarySet[] libsets = specificDef.getActiveLibrarySets(defaultProviders,1);
+ if (libsets.length > 0) {
+ libnames = addLibrarySets(task, libsets, preargs, midargs, endargs);
+ }
+
+ StringBuffer buf = new StringBuffer(getIdentifier());
+ for (int i = 0; i < 3; i++) {
+ Enumeration argenum = args[i].elements();
+ while (argenum.hasMoreElements()) {
+ buf.append(' ');
+ buf.append(argenum.nextElement().toString());
+ }
+ }
+ String configId = buf.toString();
+
+ String[][] options = new String[][] {
+ new String[args[0].size() + args[1].size()],
+ new String[args[2].size()] };
+ args[0].copyInto(options[0]);
+ int offset = args[0].size();
+ for (int i = 0; i < args[1].size(); i++) {
+ options[0][i+offset] = (String) args[1].elementAt(i);
+ }
+ args[2].copyInto(options[1]);
+
+
+ boolean rebuild = specificDef.getRebuild(baseDefs,0);
+ boolean map = specificDef.getMap(defaultProviders,1);
+
+ //task.log("libnames:"+libnames.length, Project.MSG_VERBOSE);
+ return new CommandLineLinkerConfiguration(this,configId,options,
+ paramArray,
+ rebuild,map,libnames, startupObject);
+ }
+
+ /**
+ * Allows drived linker to decorate linker option.
+ * Override by GccLinker to prepend a "-Wl," to
+ * pass option to through gcc to linker.
+ *
+ * @param buf buffer that may be used and abused in the decoration process,
+ * must not be null.
+ * @param arg linker argument
+ */
+ protected String decorateLinkerOption(StringBuffer buf, String arg) {
+ return arg;
+ }
+
+ protected final String getCommand() {
+ return command;
+ }
+ protected abstract String getCommandFileSwitch(String commandFile);
+
+
+ public String getIdentifier() {
+ if(identifier == null) {
+ if (identifierArg == null) {
+ identifier = getIdentifier(new String[] { command }, command);
+ } else {
+ identifier = getIdentifier(new String[] { command, identifierArg },
+ command);
+ }
+ }
+ return identifier;
+ }
+ public final CommandLineLinker getLibtoolLinker() {
+ if (libtoolLinker != null) {
+ return libtoolLinker;
+ }
+ return this;
+ }
+ protected abstract int getMaximumCommandLength();
+
+ public String getOutputFileName(String baseName) {
+ return baseName + outputSuffix;
+ }
+
+ protected String[] getOutputFileSwitch(CCTask task, String outputFile) {
+ return getOutputFileSwitch(outputFile);
+ }
+ protected abstract String[] getOutputFileSwitch(String outputFile);
+ protected String getStartupObject(LinkType linkType) {
+ return null;
+ }
+
+ /**
+ * Performs a link using a command line linker
+ *
+ */
+ public void link(CCTask task,
+ File outputFile,
+ String[] sourceFiles,
+ CommandLineLinkerConfiguration config)
+ throws BuildException
+ {
+ File parentDir = new File(outputFile.getParent());
+ String parentPath;
+ try {
+ parentPath = parentDir.getCanonicalPath();
+ } catch(IOException ex) {
+ parentPath = parentDir.getAbsolutePath();
+ }
+ String[] execArgs = prepareArguments(task, parentPath,outputFile.getName(),
+ sourceFiles, config);
+ int commandLength = 0;
+ for(int i = 0; i < execArgs.length; i++) {
+ commandLength += execArgs[i].length() + 1;
+ }
+
+ //
+ // if command length exceeds maximum
+ // (1024 for Windows) then create a temporary
+ // file containing everything but the command name
+ if(commandLength >= this.getMaximumCommandLength()) {
+ try {
+ execArgs = prepareResponseFile(outputFile,execArgs);
+ }
+ catch(IOException ex) {
+ throw new BuildException(ex);
+ }
+ }
+
+ int retval = runCommand(task,parentDir,execArgs);
+ //
+ // if the process returned a failure code then
+ // throw an BuildException
+ //
+ if(retval != 0) {
+ //
+ // construct the exception
+ //
+ throw new BuildException(this.getCommand() + " failed with return code " + retval, task.getLocation());
+ }
+
+ }
+
+
+ /**
+ * Prepares argument list for exec command. Will return null
+ * if command line would exceed allowable command line buffer.
+ *
+ * @param outputFile linker output file
+ * @param sourceFiles linker input files (.obj, .o, .res)
+ * @param args linker arguments
+ * @return arguments for runTask
+ */
+ protected String[] prepareArguments(
+ CCTask task,
+ String outputDir,
+ String outputFile,
+ String[] sourceFiles,
+ CommandLineLinkerConfiguration config) {
+
+ String[] preargs = config.getPreArguments();
+ String[] endargs = config.getEndArguments();
+ String outputSwitch[] = getOutputFileSwitch(task, outputFile);
+ int allArgsCount = preargs.length + 1 + outputSwitch.length +
+ sourceFiles.length + endargs.length;
+ if (isLibtool) {
+ allArgsCount++;
+ }
+ String[] allArgs = new String[allArgsCount];
+ int index = 0;
+ if (isLibtool) {
+ allArgs[index++] = "libtool";
+ }
+ allArgs[index++] = this.getCommand();
+ StringBuffer buf = new StringBuffer();
+ for (int i = 0; i < preargs.length; i++) {
+ allArgs[index++] = decorateLinkerOption(buf, preargs[i]);
+ }
+ for (int i = 0; i < outputSwitch.length; i++) {
+ allArgs[index++] = outputSwitch[i];
+ }
+ for (int i = 0; i < sourceFiles.length; i++) {
+ allArgs[index++] = prepareFilename(buf,outputDir,sourceFiles[i]);
+ }
+ for (int i = 0; i < endargs.length; i++) {
+ allArgs[index++] = decorateLinkerOption(buf, endargs[i]);
+ }
+ return allArgs;
+ }
+
+ /**
+ * Processes filename into argument form
+ *
+ */
+ protected String prepareFilename(StringBuffer buf,
+ String outputDir, String sourceFile) {
+ String relativePath = CUtil.getRelativePath(outputDir,
+ new File(sourceFile));
+ return quoteFilename(buf,relativePath);
+ }
+
+ /**
+ * Prepares argument list to execute the linker using a
+ * response file.
+ *
+ * @param outputFile linker output file
+ * @param args output of prepareArguments
+ * @return arguments for runTask
+ */
+ protected String[] prepareResponseFile(File outputFile,String[] args) throws IOException
+ {
+ String baseName = outputFile.getName();
+ File commandFile = new File(outputFile.getParent(),baseName + ".rsp");
+ FileWriter writer = new FileWriter(commandFile);
+ int execArgCount = 1;
+ if (isLibtool) {
+ execArgCount++;
+ }
+ String[] execArgs = new String[execArgCount+1];
+ for (int i = 0; i < execArgCount; i++) {
+ execArgs[i] = args[i];
+ }
+ execArgs[execArgCount] = getCommandFileSwitch(commandFile.toString());
+ for(int i = execArgCount; i < args.length; i++) {
+ //
+ // if embedded space and not quoted then
+ // quote argument
+ if (args[i].indexOf(" ") >= 0 && args[i].charAt(0) != '\"') {
+ writer.write('\"');
+ writer.write(args[i]);
+ writer.write("\"\n");
+ } else {
+ writer.write(args[i]);
+ writer.write('\n');
+ }
+ }
+ writer.close();
+ return execArgs;
+ }
+
+
+ protected String quoteFilename(StringBuffer buf,String filename) {
+ if(filename.indexOf(' ') >= 0) {
+ buf.setLength(0);
+ buf.append('\"');
+ buf.append(filename);
+ buf.append('\"');
+ return buf.toString();
+ }
+ return filename;
+ }
+
+ /**
+ * This method is exposed so test classes can overload
+ * and test the arguments without actually spawning the
+ * compiler
+ */
+ protected int runCommand(CCTask task, File workingDir,String[] cmdline)
+ throws BuildException {
+ return CUtil.runCommand(task,workingDir,cmdline, newEnvironment, env);
+ }
+
+ protected final void setCommand(String command) {
+ this.command = command;
+ }
+
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/compiler/CommandLineLinkerConfiguration.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/compiler/CommandLineLinkerConfiguration.java
new file mode 100644
index 0000000000..b3a7290b00
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/compiler/CommandLineLinkerConfiguration.java
@@ -0,0 +1,119 @@
+/*
+ *
+ * Copyright 2002-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.compiler;
+import net.sf.antcontrib.cpptasks.CCTask;
+import net.sf.antcontrib.cpptasks.LinkerParam;
+import net.sf.antcontrib.cpptasks.ProcessorParam;
+import net.sf.antcontrib.cpptasks.TargetInfo;
+
+import org.apache.tools.ant.BuildException;
+/**
+ * A configuration for a command line linker
+ *
+ * @author Curt Arnold
+ */
+public final class CommandLineLinkerConfiguration
+ implements
+ LinkerConfiguration {
+ private/* final */String[][] args;
+ private/* final */String identifier;
+ private String[] libraryNames;
+ private/* final */CommandLineLinker linker;
+ private/* final */boolean map;
+ private/* final */ProcessorParam[] params;
+ private/* final */boolean rebuild;
+ private String startupObject;
+ public CommandLineLinkerConfiguration(CommandLineLinker linker,
+ String identifier, String[][] args, ProcessorParam[] params,
+ boolean rebuild, boolean map, String[] libraryNames,
+ String startupObject) {
+ if (linker == null) {
+ throw new NullPointerException("linker");
+ }
+ if (args == null) {
+ throw new NullPointerException("args");
+ } else {
+ this.args = (String[][]) args.clone();
+ }
+ this.linker = linker;
+ this.params = (ProcessorParam[]) params.clone();
+ this.rebuild = rebuild;
+ this.identifier = identifier;
+ this.map = map;
+ if (libraryNames == null) {
+ this.libraryNames = new String[0];
+ } else {
+ this.libraryNames = (String[]) libraryNames.clone();
+ }
+ this.startupObject = startupObject;
+ }
+ public int bid(String filename) {
+ return linker.bid(filename);
+ }
+ public String[] getEndArguments() {
+ String[] clone = (String[]) args[1].clone();
+ return clone;
+ }
+ /**
+ * Returns a string representation of this configuration. Should be
+ * canonical so that equivalent configurations will have equivalent string
+ * representations
+ */
+ public String getIdentifier() {
+ return identifier;
+ }
+ public String[] getLibraryNames() {
+ String[] clone = (String[]) libraryNames.clone();
+ return clone;
+ }
+ public boolean getMap() {
+ return map;
+ }
+ public String getOutputFileName(String inputFile) {
+ return linker.getOutputFileName(inputFile);
+ }
+ public LinkerParam getParam(String name) {
+ for (int i = 0; i < params.length; i++) {
+ if (name.equals(params[i].getName()))
+ return (LinkerParam) params[i];
+ }
+ return null;
+ }
+ public ProcessorParam[] getParams() {
+ return params;
+ }
+ public String[] getPreArguments() {
+ String[] clone = (String[]) args[0].clone();
+ return clone;
+ }
+ public boolean getRebuild() {
+ return rebuild;
+ }
+ public String getStartupObject() {
+ return startupObject;
+ }
+ public void link(CCTask task, TargetInfo linkTarget) throws BuildException {
+ //
+ // AllSourcePath's include any syslibsets
+ //
+ String[] sourcePaths = linkTarget.getAllSourcePaths();
+ linker.link(task, linkTarget.getOutput(), sourcePaths, this);
+ }
+ public String toString() {
+ return identifier;
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/compiler/Compiler.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/compiler/Compiler.java
new file mode 100644
index 0000000000..bbb6c99c5d
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/compiler/Compiler.java
@@ -0,0 +1,24 @@
+/*
+ *
+ * Copyright 2001-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.compiler;
+/**
+ * A compiler.
+ *
+ * @author Adam Murdoch
+ */
+public interface Compiler extends Processor {
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/compiler/CompilerConfiguration.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/compiler/CompilerConfiguration.java
new file mode 100644
index 0000000000..72abb8b5f4
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/compiler/CompilerConfiguration.java
@@ -0,0 +1,64 @@
+/*
+ *
+ * Copyright 2002-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.compiler;
+import java.io.File;
+
+import net.sf.antcontrib.cpptasks.CCTask;
+import net.sf.antcontrib.cpptasks.CompilerParam;
+import net.sf.antcontrib.cpptasks.DependencyInfo;
+
+import org.apache.tools.ant.BuildException;
+/**
+ * A configuration for a compiler
+ *
+ * @author Curt Arnold
+ */
+public interface CompilerConfiguration extends ProcessorConfiguration {
+ void compile(CCTask task, File outputDir, String[] sourceFiles,
+ boolean relentless, ProgressMonitor monitor) throws BuildException;
+ /**
+ *
+ * This method may be used to get two distinct compiler configurations, one
+ * for compiling the specified file and producing a precompiled header
+ * file, and a second for compiling other files using the precompiled
+ * header file.
+ *
+ * The last (preferrably only) include directive in the prototype file will
+ * be used to mark the boundary between pre-compiled and normally compiled
+ * headers.
+ *
+ * @param prototype
+ * A source file (for example, stdafx.cpp) that is used to build
+ * the precompiled header file. @returns null if precompiled
+ * headers are not supported or a two element array containing
+ * the precompiled header generation configuration and the
+ * consuming configuration
+ *
+ */
+ CompilerConfiguration[] createPrecompileConfigurations(File prototype,
+ String[] nonPrecompiledFiles);
+ /**
+ * Returns an digest for the include path for the configuration.
+ *
+ * This is used to determine if cached dependency information is invalid
+ * because the include paths have changed
+ */
+ String getIncludePathIdentifier();
+ public CompilerParam getParam(String name);
+ boolean isPrecompileGeneration();
+ DependencyInfo parseIncludes(CCTask task, File baseDir, File source);
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/compiler/LinkType.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/compiler/LinkType.java
new file mode 100644
index 0000000000..7d6041ff93
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/compiler/LinkType.java
@@ -0,0 +1,134 @@
+/*
+ *
+ * Copyright 2001-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.compiler;
+import net.sf.antcontrib.cpptasks.OutputTypeEnum;
+import net.sf.antcontrib.cpptasks.SubsystemEnum;
+/**
+ * This class represents the target platform for the compile and link step. The
+ * name is an anachronism and should be changed.
+ *
+ * @author Curt Arnold
+ */
+public class LinkType {
+ private OutputTypeEnum outputType = new OutputTypeEnum();
+ private boolean staticRuntime = false;
+ private SubsystemEnum subsystem = new SubsystemEnum();
+ /**
+ * Constructor
+ *
+ * By default, an gui executable with a dynamically linked runtime
+ *
+ */
+ public LinkType() {
+ }
+ /**
+ * Gets whether the link should produce an executable
+ *
+ * @return boolean
+ */
+ public boolean isExecutable() {
+ String value = outputType.getValue();
+ return value.equals("executable");
+ }
+ /**
+ * Gets whether the link should produce a plugin module.
+ *
+ * @return boolean
+ */
+ public boolean isPluginModule() {
+ String value = outputType.getValue();
+ return value.equals("plugin");
+ }
+ /**
+ * Gets whether the link should produce a shared library.
+ *
+ * @return boolean
+ */
+ public boolean isSharedLibrary() {
+ String value = outputType.getValue();
+ return value.equals("shared") || value.equals("plugin");
+ }
+ /**
+ * Gets whether the link should produce a static library.
+ *
+ * @return boolean
+ */
+ public boolean isStaticLibrary() {
+ String value = outputType.getValue();
+ return value.equals("static");
+ }
+ /**
+ * Gets whether the module should use a statically linked runtime library.
+ *
+ * @return boolean
+ */
+ public boolean isStaticRuntime() {
+ return staticRuntime;
+ }
+ /**
+ * Gets whether the link should produce a module for a console subsystem.
+ *
+ * @return boolean
+ */
+ public boolean isSubsystemConsole() {
+ String value = subsystem.getValue();
+ return value.equals("console");
+ }
+ /**
+ * Gets whether the link should produce a module for a graphical user
+ * interface subsystem.
+ *
+ * @return boolean
+ */
+ public boolean isSubsystemGUI() {
+ String value = subsystem.getValue();
+ return value.equals("gui");
+ }
+ /**
+ * Sets the output type (execuable, shared, etc).
+ *
+ * @param outputType,
+ * may not be null
+ */
+ public void setOutputType(OutputTypeEnum outputType) {
+ if (outputType == null) {
+ throw new IllegalArgumentException("outputType");
+ }
+ this.outputType = outputType;
+ }
+ /**
+ * Requests use of a static runtime library.
+ *
+ * @param staticRuntime
+ * if true, use static runtime library if possible.
+ */
+ public void setStaticRuntime(boolean staticRuntime) {
+ this.staticRuntime = staticRuntime;
+ }
+ /**
+ * Sets the subsystem (gui, console, etc).
+ *
+ * @param subsystem
+ * subsystem, may not be null
+ */
+ public void setSubsystem(SubsystemEnum subsystem) {
+ if (subsystem == null) {
+ throw new IllegalArgumentException("subsystem");
+ }
+ this.subsystem = subsystem;
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/compiler/Linker.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/compiler/Linker.java
new file mode 100644
index 0000000000..776a808ac7
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/compiler/Linker.java
@@ -0,0 +1,57 @@
+/*
+ *
+ * Copyright 2001-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.compiler;
+import java.io.File;
+import net.sf.antcontrib.cpptasks.types.LibraryTypeEnum;
+/**
+ * A linker for executables, and static and dynamic libraries.
+ *
+ * @author Adam Murdoch
+ */
+public interface Linker extends Processor {
+ /**
+ * Extracts the significant part of a library name to ensure there aren't
+ * collisions
+ */
+ String getLibraryKey(File libname);
+ /**
+ * returns the library path for the linker
+ */
+ File[] getLibraryPath();
+ /**
+ * Returns a set of filename patterns corresponding to library names.
+ *
+ * For example, "advapi32" would be expanded to "advapi32.dll" by
+ * DevStudioLinker and to "libadvapi32.a" and "libadvapi32.so" by
+ * GccLinker.
+ *
+ * @param libnames
+ * array of library names
+ */
+ String[] getLibraryPatterns(String[] libnames, LibraryTypeEnum libraryType);
+ /**
+ * Gets the linker for the specified link type.
+ *
+ * @return appropriate linker or null, will return this if this linker can
+ * handle the specified link type
+ */
+ Linker getLinker(LinkType linkType);
+ /**
+ * Returns true if the linker is case-sensitive
+ */
+ boolean isCaseSensitive();
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/compiler/LinkerConfiguration.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/compiler/LinkerConfiguration.java
new file mode 100644
index 0000000000..c2d62c4137
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/compiler/LinkerConfiguration.java
@@ -0,0 +1,31 @@
+/*
+ *
+ * Copyright 2002-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.compiler;
+import net.sf.antcontrib.cpptasks.CCTask;
+import net.sf.antcontrib.cpptasks.LinkerParam;
+import net.sf.antcontrib.cpptasks.TargetInfo;
+
+import org.apache.tools.ant.BuildException;
+/**
+ * A configuration for a linker
+ *
+ * @author Curt Arnold
+ */
+public interface LinkerConfiguration extends ProcessorConfiguration {
+ public LinkerParam getParam(String name);
+ void link(CCTask task, TargetInfo linkTarget) throws BuildException;
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/compiler/PrecompilingCommandLineCCompiler.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/compiler/PrecompilingCommandLineCCompiler.java
new file mode 100644
index 0000000000..eb64119299
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/compiler/PrecompilingCommandLineCCompiler.java
@@ -0,0 +1,43 @@
+/*
+ *
+ * Copyright 2001-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.compiler;
+import java.io.File;
+
+import net.sf.antcontrib.cpptasks.parser.CParser;
+import net.sf.antcontrib.cpptasks.parser.Parser;
+
+import org.apache.tools.ant.types.Environment;
+/**
+ * A command line C compiler that can utilize precompilation of header files
+ *
+ * @author Curt Arnold
+ */
+public abstract class PrecompilingCommandLineCCompiler
+ extends
+ PrecompilingCommandLineCompiler {
+ protected PrecompilingCommandLineCCompiler(String command,
+ String identifierArg, String[] sourceExtensions,
+ String[] headerExtensions, String outputSuffix, boolean libtool,
+ PrecompilingCommandLineCCompiler libtoolCompiler,
+ boolean newEnvironment, Environment env) {
+ super(command, identifierArg, sourceExtensions, headerExtensions,
+ outputSuffix, libtool, libtoolCompiler, newEnvironment, env);
+ }
+ protected Parser createParser(File source) {
+ return new CParser();
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/compiler/PrecompilingCommandLineCompiler.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/compiler/PrecompilingCommandLineCompiler.java
new file mode 100644
index 0000000000..6e3c145675
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/compiler/PrecompilingCommandLineCompiler.java
@@ -0,0 +1,104 @@
+/*
+ *
+ * Copyright 2002-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.compiler;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.Reader;
+
+import net.sf.antcontrib.cpptasks.parser.Parser;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.types.Environment;
+/**
+ * A command line C compiler that can utilize precompilation of header files
+ *
+ * @author Curt Arnold
+ */
+public abstract class PrecompilingCommandLineCompiler
+ extends
+ CommandLineCompiler implements PrecompilingCompiler {
+ protected PrecompilingCommandLineCompiler(String command,
+ String identifierArg, String[] sourceExtensions,
+ String[] headerExtensions, String outputSuffix, boolean libtool,
+ PrecompilingCommandLineCompiler libtoolCompiler,
+ boolean newEnvironment, Environment env) {
+ super(command, identifierArg, sourceExtensions, headerExtensions,
+ outputSuffix, libtool, libtoolCompiler, newEnvironment, env);
+ }
+ /**
+ *
+ * This method may be used to get two distinct compiler configurations, one
+ * for compiling the specified file and producing a precompiled header
+ * file, and a second for compiling other files using the precompiled
+ * header file.
+ *
+ * The last (preferrably only) include directive in the prototype file will
+ * be used to mark the boundary between pre-compiled and normally compiled
+ * headers.
+ *
+ * @param config
+ * base configuration
+ * @param prototype
+ * A source file (for example, stdafx.cpp) that is used to build
+ * the precompiled header file. @returns null if precompiled
+ * headers are not supported or a two element array containing
+ * the precompiled header generation configuration and the
+ * consuming configuration
+ *
+ */
+ public CompilerConfiguration[] createPrecompileConfigurations(
+ CompilerConfiguration config, File prototype, String[] exceptFiles) {
+ //
+ // cast should success or someone is passing us a configuration
+ // that was prepared by another processor
+ //
+ CommandLineCompilerConfiguration cmdLineConfig = (CommandLineCompilerConfiguration) config;
+ //
+ // parse prototype file to determine last header
+ //
+ Parser parser = createParser(prototype);
+ String[] includes;
+ try {
+ Reader reader = new BufferedReader(new FileReader(prototype));
+ parser.parse(reader);
+ includes = parser.getIncludes();
+ } catch (IOException ex) {
+ throw new BuildException(
+ "Error parsing precompiled header protoype: "
+ + prototype.toString() + ":" + ex.toString());
+ }
+ if (includes.length == 0) {
+ throw new BuildException("Precompiled header prototype: "
+ + prototype.toString()
+ + " does not contain any include directives.");
+ }
+ CompilerConfiguration[] configs = new CompilerConfiguration[2];
+ configs[0] = createPrecompileGeneratingConfig(cmdLineConfig, prototype,
+ includes[0]);
+ configs[1] = createPrecompileUsingConfig(cmdLineConfig, prototype,
+ includes[0], exceptFiles);
+ return configs;
+ }
+ abstract protected CompilerConfiguration createPrecompileGeneratingConfig(
+ CommandLineCompilerConfiguration baseConfig, File prototype,
+ String lastInclude);
+ abstract protected CompilerConfiguration createPrecompileUsingConfig(
+ CommandLineCompilerConfiguration baseConfig, File prototype,
+ String lastInclude, String[] exceptFiles);
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/compiler/PrecompilingCompiler.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/compiler/PrecompilingCompiler.java
new file mode 100644
index 0000000000..e60b1da8e6
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/compiler/PrecompilingCompiler.java
@@ -0,0 +1,49 @@
+/*
+ *
+ * Copyright 2002-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.compiler;
+import java.io.File;
+/**
+ * A compiler that can utilize precompilation of header files
+ *
+ * @author Curt Arnold
+ */
+public interface PrecompilingCompiler {
+ /**
+ *
+ * This method may be used to get two distinct compiler configurations, one
+ * for compiling the specified file and producing a precompiled header
+ * file, and a second for compiling other files using the precompiled
+ * header file.
+ *
+ * The last (preferrably only) include directive in the prototype file will
+ * be used to mark the boundary between pre-compiled and normally compiled
+ * headers.
+ *
+ * @param config
+ * base configuration
+ * @param prototype
+ * A source file (for example, stdafx.cpp) that is used to build
+ * the precompiled header file. @returns null if precompiled
+ * headers are not supported or a two element array containing
+ * the precompiled header generation configuration and the
+ * consuming configuration
+ *
+ */
+ CompilerConfiguration[] createPrecompileConfigurations(
+ CompilerConfiguration config, File prototype,
+ String[] nonPrecompiledFiles);
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/compiler/Processor.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/compiler/Processor.java
new file mode 100644
index 0000000000..6fb74e9ea3
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/compiler/Processor.java
@@ -0,0 +1,73 @@
+/*
+ *
+ * Copyright 2002-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.compiler;
+import net.sf.antcontrib.cpptasks.CCTask;
+import net.sf.antcontrib.cpptasks.ProcessorDef;
+import net.sf.antcontrib.cpptasks.TargetDef;
+import org.apache.tools.ant.types.Environment;
+/**
+ * A processor. Base interface for Compiler and Linker
+ *
+ * @author Curt Arnold
+ */
+public interface Processor {
+ /**
+ * Returns a bid indicating the desire of this compiler to process the
+ * file.
+ *
+ * @param inputFile
+ * input file
+ * @return 0 = no interest, 100 = high interest
+ */
+ int bid(String inputFile);
+ Processor changeEnvironment(boolean newEnvironment, Environment env);
+ /**
+ * Returns the compiler configuration for or element.
+ *
+ * @param defaultProviders
+ * When specificConfig corresponds to a or linker
+ * element, defaultProvider will be a zero to two element array.
+ * If there is an extends attribute, the first element will be
+ * the referenced ProcessorDef, unless inherit = false, the last
+ * element will be the containing element
+ * @param specificConfig
+ * A or element.
+ * @return resulting configuration
+ */
+ ProcessorConfiguration createConfiguration(CCTask task, LinkType linkType,
+ ProcessorDef[] defaultProviders, ProcessorDef specificConfig,
+ TargetDef targetPlatform);
+ /**
+ * Retrieve an identifier that identifies the specific version of the
+ * compiler. Compilers with the same identifier should produce the same
+ * output files for the same input files and command line switches.
+ */
+ String getIdentifier();
+ /**
+ * Gets the linker that is associated with this processors
+ */
+ Linker getLinker(LinkType type);
+ /**
+ * Output file name (no path components) corresponding to source file
+ *
+ * @param inputFile
+ * input file
+ * @return output file name or null if no output file or name not
+ * determined by input file
+ */
+ String getOutputFileName(String inputFile);
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/compiler/ProcessorConfiguration.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/compiler/ProcessorConfiguration.java
new file mode 100644
index 0000000000..dd75483d6d
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/compiler/ProcessorConfiguration.java
@@ -0,0 +1,52 @@
+/*
+ *
+ * Copyright 2002-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.compiler;
+import net.sf.antcontrib.cpptasks.ProcessorParam;
+/**
+ * A configuration for a C++ compiler, linker or other processor
+ *
+ * @author Curt Arnold
+ */
+public interface ProcessorConfiguration {
+ /**
+ * An indication of how much this compiler would like to process this file
+ *
+ * @return 0 is no interest to process, 100 is strong interest to process
+ */
+ int bid(String filename);
+ /**
+ * Returns a string representation of this configuration. Should be
+ * canonical so that equivalent configurations will have equivalent string
+ * representations
+ */
+ String getIdentifier();
+ /**
+ * Output file name (no path components) corresponding to source file
+ *
+ * @param inputFile
+ * input file
+ * @return output file name or null if no output file or name not
+ * determined by input file
+ */
+ String getOutputFileName(String inputFile);
+ ProcessorParam[] getParams();
+ /**
+ * If true, all files using this configuration should be rebuilt and any
+ * existing output files should be ignored
+ */
+ boolean getRebuild();
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/compiler/ProgressMonitor.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/compiler/ProgressMonitor.java
new file mode 100644
index 0000000000..2206ed874e
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/compiler/ProgressMonitor.java
@@ -0,0 +1,31 @@
+/*
+ *
+ * Copyright 2001-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.compiler;
+/**
+ * Interface to receive notification of compile progress
+ *
+ * @author Curt Arnold
+ */
+public interface ProgressMonitor {
+ public void finish(ProcessorConfiguration config, boolean normal);
+ /**
+ * Called to notify monitor of progress
+ *
+ */
+ void progress(String[] sources);
+ public void start(ProcessorConfiguration config);
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/devstudio/DevStudioAslcompiler.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/devstudio/DevStudioAslcompiler.java
new file mode 100644
index 0000000000..f0be5945a3
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/devstudio/DevStudioAslcompiler.java
@@ -0,0 +1,70 @@
+/*
+ *
+ * Copyright 2001-2005 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.devstudio;
+
+import java.util.Vector;
+
+import net.sf.antcontrib.cpptasks.compiler.CommandLineAslcompiler;
+import net.sf.antcontrib.cpptasks.compiler.LinkType;
+import net.sf.antcontrib.cpptasks.compiler.Linker;
+
+/**
+ * Adaptor for Microsoft ASL compiler.
+ *
+ */
+public final class DevStudioAslcompiler extends CommandLineAslcompiler {
+ private final static String[] sourceExtensions = new String[] { ".asl" };
+
+ private final static String[] headerExtensions = new String[] {};
+
+ private final static String[] defaultflags = new String[] {};
+
+ private static final DevStudioAslcompiler instance = new DevStudioAslcompiler(
+ "asl", sourceExtensions, headerExtensions, false);
+
+ /**
+ * Gets asl adapter
+ */
+ public static DevStudioAslcompiler getInstance() {
+ return instance;
+ }
+
+ /**
+ * Private constructor. Use DevStudioAslcompiler.getInstance() to get
+ * singleton instance of this class.
+ */
+ private DevStudioAslcompiler (String command, String[] sourceExtensions,
+ String[] headerExtensions, boolean isLibtool) {
+ super(command, null, sourceExtensions, headerExtensions, ".aml");
+ }
+
+ public void addImpliedArgs(Vector args, boolean debug, Boolean defaultflag) {
+ if (defaultflag != null && defaultflag.booleanValue()) {
+ for (int i = 0; i < defaultflags.length; i++) {
+ args.addElement(defaultflags[i]);
+ }
+ }
+ }
+
+ public int getMaximumCommandLength() {
+ return Integer.MAX_VALUE;
+ }
+
+ public Linker getLinker(LinkType linkType) {
+ return DevStudioLinker.getInstance().getLinker(linkType);
+ }
+}
\ No newline at end of file
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/devstudio/DevStudioAssembler.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/devstudio/DevStudioAssembler.java
new file mode 100644
index 0000000000..23d319ecd9
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/devstudio/DevStudioAssembler.java
@@ -0,0 +1,84 @@
+/*
+ *
+ * Copyright 2001-2005 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.devstudio;
+
+import java.io.File;
+import java.util.Vector;
+
+import net.sf.antcontrib.cpptasks.CUtil;
+import net.sf.antcontrib.cpptasks.compiler.CommandLineAssembler;
+import net.sf.antcontrib.cpptasks.compiler.LinkType;
+import net.sf.antcontrib.cpptasks.compiler.Linker;
+
+/**
+ * Adaptor for Microsoft MASM
+ *
+ */
+public final class DevStudioAssembler extends CommandLineAssembler {
+ private final static String[] sourceExtensions = new String[] { ".asm" };
+
+ private final static String[] headerExtensions = new String[] { ".h",
+ ".inc" };
+
+ private final static String[] defaultflags = new String[] { "/nologo", "/c" };
+
+ private static final DevStudioAssembler instance = new DevStudioAssembler(
+ "ml", sourceExtensions, headerExtensions, false);
+
+ /**
+ * Gets masm adapter
+ */
+ public static DevStudioAssembler getInstance() {
+ return instance;
+ }
+
+ /**
+ * Private constructor. Use DevStudioAssembler.getInstance() to get
+ * singleton instance of this class.
+ */
+ private DevStudioAssembler (String command, String[] sourceExtensions,
+ String[] headerExtensions, boolean isLibtool) {
+ super(command, null, sourceExtensions, headerExtensions, ".obj");
+ }
+
+ public void addImpliedArgs(Vector args, boolean debug, Boolean defaultflag) {
+ if (defaultflag != null && defaultflag.booleanValue()) {
+ for (int i = 0; i < defaultflags.length; i++) {
+ args.addElement(defaultflags[i]);
+ }
+ }
+ if (debug) {
+ args.addElement("Zi");
+ }
+ }
+
+ public int getMaximumCommandLength() {
+ return Integer.MAX_VALUE;
+ }
+
+ public Linker getLinker(LinkType linkType) {
+ return DevStudioLinker.getInstance().getLinker(linkType);
+ }
+
+ protected File[] getEnvironmentIncludePath() {
+ return CUtil.getPathFromEnvironment("INCLUDE", ";");
+ }
+
+ protected String getIncludeDirSwitch(String includeDir) {
+ return "/I" + includeDir.replace('/', '\\');
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/devstudio/DevStudioCCompiler.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/devstudio/DevStudioCCompiler.java
new file mode 100644
index 0000000000..3bb5181250
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/devstudio/DevStudioCCompiler.java
@@ -0,0 +1,50 @@
+/*
+ *
+ * Copyright 2002-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.devstudio;
+import net.sf.antcontrib.cpptasks.compiler.LinkType;
+import net.sf.antcontrib.cpptasks.compiler.Linker;
+import net.sf.antcontrib.cpptasks.compiler.Processor;
+
+import org.apache.tools.ant.types.Environment;
+/**
+ * Adapter for the Microsoft(r) C/C++ Optimizing Compiler
+ *
+ * @author Adam Murdoch
+ */
+public final class DevStudioCCompiler extends DevStudioCompatibleCCompiler {
+ private static final DevStudioCCompiler instance = new DevStudioCCompiler(
+ "cl", false, null);
+ public static DevStudioCCompiler getInstance() {
+ return instance;
+ }
+ private DevStudioCCompiler(String command, boolean newEnvironment,
+ Environment env) {
+ super(command, "/bogus", newEnvironment, env);
+ }
+ public Processor changeEnvironment(boolean newEnvironment, Environment env) {
+ if (newEnvironment || env != null) {
+ return new DevStudioCCompiler(getCommand(), newEnvironment, env);
+ }
+ return this;
+ }
+ public Linker getLinker(LinkType type) {
+ return DevStudioLinker.getInstance().getLinker(type);
+ }
+ public int getMaximumCommandLength() {
+ return 4096;
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/devstudio/DevStudioCompatibleCCompiler.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/devstudio/DevStudioCompatibleCCompiler.java
new file mode 100644
index 0000000000..5e29a323c7
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/devstudio/DevStudioCompatibleCCompiler.java
@@ -0,0 +1,136 @@
+/*
+ *
+ * Copyright 2002-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.devstudio;
+import java.io.File;
+import java.util.Vector;
+import net.sf.antcontrib.cpptasks.CUtil;
+import net.sf.antcontrib.cpptasks.compiler.CommandLineCompilerConfiguration;
+import net.sf.antcontrib.cpptasks.compiler.CompilerConfiguration;
+import net.sf.antcontrib.cpptasks.compiler.LinkType;
+import net.sf.antcontrib.cpptasks.compiler.PrecompilingCommandLineCCompiler;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.types.Environment;
+import net.sf.antcontrib.cpptasks.OptimizationEnum;
+
+/**
+ * An abstract base class for compilers that are basically command line
+ * compatible with Microsoft(r) C/C++ Optimizing Compiler
+ *
+ * @author Curt Arnold
+ */
+public abstract class DevStudioCompatibleCCompiler
+ extends
+ PrecompilingCommandLineCCompiler {
+ private static String[] mflags = new String[]{
+ //
+ // first four are single-threaded
+ // (runtime=static,debug=false), (..,debug=true),
+ // (runtime=dynamic,debug=true), (..,debug=false), (not supported)
+ // next four are multi-threaded, same sequence
+ "/ML", "/MLd", null, null, "/MT", "/MTd", "/MD", "/MDd"};
+ private static String[] defaultflags = new String[]{"/nologo", "/c"};
+ protected DevStudioCompatibleCCompiler(String command,
+ String identifierArg, boolean newEnvironment, Environment env) {
+ super(command, identifierArg, new String[]{".c", ".cc", ".cpp", ".cxx",
+ ".c++"}, new String[]{".h", ".hpp", ".inl"}, ".obj", false,
+ null, newEnvironment, env);
+ }
+ protected void addImpliedArgs(final Vector args,
+ final boolean debug,
+ final boolean multithreaded,
+ final boolean exceptions,
+ final LinkType linkType,
+ final Boolean rtti,
+ final OptimizationEnum optimization,
+ final Boolean defaultflag) {
+ if (defaultflag != null && defaultflag.booleanValue()) {
+ for (int i = 0; i < defaultflags.length; i++) {
+ args.addElement(defaultflags[i]);
+ }
+ }
+ if (exceptions) {
+ args.addElement("/GX");
+ }
+ int mindex = 0;
+ if (multithreaded) {
+ mindex += 4;
+ }
+ boolean staticRuntime = linkType.isStaticRuntime();
+ if (!staticRuntime) {
+ mindex += 2;
+ }
+ if (debug) {
+ mindex += 1;
+ args.addElement("/Zi");
+ args.addElement("/Od");
+ args.addElement("/GZ");
+ args.addElement("/D_DEBUG");
+ } else {
+ if (optimization != null) {
+ if (optimization.isSize()) {
+ args.addElement("/O1");
+ }
+ if (optimization.isSpeed()) {
+ args.addElement("/O2");
+ }
+ }
+ args.addElement("/DNDEBUG");
+ }
+ String mflag = mflags[mindex];
+ if (mflag == null) {
+ throw new BuildException(
+ "multithread='false' and runtime='dynamic' not supported");
+ }
+ args.addElement(mflag);
+ if (rtti != null && rtti.booleanValue()) {
+ args.addElement("/GR");
+ }
+ }
+ protected void addWarningSwitch(Vector args, int level) {
+ DevStudioProcessor.addWarningSwitch(args, level);
+ }
+ protected CompilerConfiguration createPrecompileGeneratingConfig(
+ CommandLineCompilerConfiguration baseConfig, File prototype,
+ String lastInclude) {
+ String[] additionalArgs = new String[]{
+ "/Fp" + CUtil.getBasename(prototype) + ".pch", "/Yc"};
+ return new CommandLineCompilerConfiguration(baseConfig, additionalArgs,
+ null, true);
+ }
+ protected CompilerConfiguration createPrecompileUsingConfig(
+ CommandLineCompilerConfiguration baseConfig, File prototype,
+ String lastInclude, String[] exceptFiles) {
+ String[] additionalArgs = new String[]{
+ "/Fp" + CUtil.getBasename(prototype) + ".pch",
+ "/Yu" + lastInclude};
+ return new CommandLineCompilerConfiguration(baseConfig, additionalArgs,
+ exceptFiles, false);
+ }
+ protected void getDefineSwitch(StringBuffer buffer, String define,
+ String value) {
+ DevStudioProcessor.getDefineSwitch(buffer, define, value);
+ }
+ protected File[] getEnvironmentIncludePath() {
+ return CUtil.getPathFromEnvironment("INCLUDE", ";");
+ }
+ protected String getIncludeDirSwitch(String includeDir) {
+ return DevStudioProcessor.getIncludeDirSwitch(includeDir);
+ }
+ protected void getUndefineSwitch(StringBuffer buffer, String define) {
+ DevStudioProcessor.getUndefineSwitch(buffer, define);
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/devstudio/DevStudioCompatibleLibrarian.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/devstudio/DevStudioCompatibleLibrarian.java
new file mode 100644
index 0000000000..40bef6e239
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/devstudio/DevStudioCompatibleLibrarian.java
@@ -0,0 +1,86 @@
+/*
+ *
+ * Copyright 2002-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.devstudio;
+import java.io.File;
+import java.util.Vector;
+
+import net.sf.antcontrib.cpptasks.compiler.CommandLineLinker;
+import net.sf.antcontrib.cpptasks.compiler.LinkType;
+import net.sf.antcontrib.cpptasks.types.LibraryTypeEnum;
+/**
+ * Abstract base adapter for librarians with command line options compatible
+ * with the Microsoft(r) Library Manager
+ *
+ * @author Curt Arnold
+ */
+public abstract class DevStudioCompatibleLibrarian extends CommandLineLinker {
+ private static String[] defaultflags = new String[]{"/nologo"};
+ public DevStudioCompatibleLibrarian(String command, String identifierArg) {
+ super(command, identifierArg, new String[]{".obj"}, new String[0],
+ ".lib", false, null);
+ }
+ protected void addBase(long base, Vector args) {
+ }
+ protected void addFixed(Boolean fixed, Vector args) {
+ }
+ protected void addImpliedArgs(boolean debug, LinkType linkType,
+ Vector args, Boolean defaultflag) {
+ if(defaultflag != null && defaultflag.booleanValue()){
+ for (int i = 0; i < defaultflags.length; i++) {
+ args.addElement(defaultflags[i]);
+ }
+ }
+ }
+ protected void addIncremental(boolean incremental, Vector args) {
+ }
+ protected void addMap(boolean map, Vector args) {
+ }
+ protected void addStack(int stack, Vector args) {
+ }
+ /* (non-Javadoc)
+ * @see net.sf.antcontrib.cpptasks.compiler.CommandLineLinker#addEntry(int, java.util.Vector)
+ */
+ protected void addEntry(String entry, Vector args) {
+ }
+
+ protected String getCommandFileSwitch(String cmdFile) {
+ return "@" + cmdFile;
+ }
+ public File[] getLibraryPath() {
+ return new File[0];
+ }
+ public String[] getLibraryPatterns(String[] libnames, LibraryTypeEnum libType) {
+ return new String[0];
+ }
+ public int getMaximumCommandLength() {
+ return 4096;
+ }
+ public String[] getOutputFileSwitch(String outFile) {
+ StringBuffer buf = new StringBuffer("/OUT:");
+ if (outFile.indexOf(' ') >= 0) {
+ buf.append('"');
+ buf.append(outFile);
+ buf.append('"');
+ } else {
+ buf.append(outFile);
+ }
+ return new String[]{buf.toString()};
+ }
+ public boolean isCaseSensitive() {
+ return false;
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/devstudio/DevStudioCompatibleLinker.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/devstudio/DevStudioCompatibleLinker.java
new file mode 100644
index 0000000000..9e156b0426
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/devstudio/DevStudioCompatibleLinker.java
@@ -0,0 +1,127 @@
+/*
+ *
+ * Copyright 2002-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.devstudio;
+import java.io.File;
+import java.util.Vector;
+
+import net.sf.antcontrib.cpptasks.CUtil;
+import net.sf.antcontrib.cpptasks.compiler.CommandLineLinker;
+import net.sf.antcontrib.cpptasks.compiler.LinkType;
+import net.sf.antcontrib.cpptasks.types.LibraryTypeEnum;
+/**
+ * Abstract base class for linkers that try to mimic the command line arguments
+ * for the Microsoft (r) Incremental Linker
+ *
+ * @author Curt Arnold
+ */
+public abstract class DevStudioCompatibleLinker extends CommandLineLinker {
+ private static String[] defaultflags = new String[]{"/NOLOGO"};
+ public DevStudioCompatibleLinker(String command, String identifierArg,
+ String outputSuffix) {
+ super(command, identifierArg, new String[]{".obj", ".lib", ".res"},
+ new String[]{".map", ".pdb", ".lnk", ".dll"}, outputSuffix,
+ false, null);
+ }
+ protected void addBase(long base, Vector args) {
+ if (base >= 0) {
+ String baseAddr = Long.toHexString(base);
+ args.addElement("/BASE:0x" + baseAddr);
+ }
+ }
+ protected void addFixed(Boolean fixed, Vector args) {
+ if (fixed != null) {
+ if (fixed.booleanValue()) {
+ args.addElement("/FIXED");
+ } else {
+ args.addElement("/FIXED:NO");
+ }
+ }
+ }
+ protected void addImpliedArgs(boolean debug, LinkType linkType,
+ Vector args, Boolean defaultflag) {
+ if(defaultflag != null && defaultflag.booleanValue()){
+ for (int i = 0; i < defaultflags.length; i++) {
+ args.addElement(defaultflags[i]);
+ }
+ }
+ if (debug) {
+ args.addElement("/DEBUG");
+ }
+ if (linkType.isSharedLibrary()) {
+ args.addElement("/DLL");
+ }
+ /*
+ * if(linkType.isSubsystemGUI()) {
+ * args.addElement("/SUBSYSTEM:WINDOWS"); } else {
+ * if(linkType.isSubsystemConsole()) {
+ * args.addElement("/SUBSYSTEM:CONSOLE"); } }
+ */
+ }
+ protected void addIncremental(boolean incremental, Vector args) {
+ if (incremental) {
+ args.addElement("/INCREMENTAL:YES");
+ } else {
+ args.addElement("/INCREMENTAL:NO");
+ }
+ }
+ protected void addMap(boolean map, Vector args) {
+ if (map) {
+ args.addElement("/MAP");
+ }
+ }
+ protected void addStack(int stack, Vector args) {
+ if (stack >= 0) {
+ String stackStr = Integer.toHexString(stack);
+ args.addElement("/STACK:0x" + stackStr);
+ }
+ }
+ /* (non-Javadoc)
+ * @see net.sf.antcontrib.cpptasks.compiler.CommandLineLinker#addEntry(int, java.util.Vector)
+ */
+ protected void addEntry(String entry, Vector args) {
+ if (entry != null) {
+ args.addElement("/ENTRY:" + entry);
+ }
+ }
+
+ public String getCommandFileSwitch(String commandFile) {
+ return "@" + commandFile;
+ }
+ public File[] getLibraryPath() {
+ return CUtil.getPathFromEnvironment("LIB", ";");
+ }
+ public String[] getLibraryPatterns(String[] libnames, LibraryTypeEnum libType) {
+ StringBuffer buf = new StringBuffer();
+ String[] patterns = new String[libnames.length];
+ for (int i = 0; i < libnames.length; i++) {
+ buf.setLength(0);
+ buf.append(libnames[i]);
+ buf.append(".lib");
+ patterns[i] = buf.toString();
+ }
+ return patterns;
+ }
+ public int getMaximumCommandLength() {
+ return 4096;
+ }
+ public String[] getOutputFileSwitch(String outputFile) {
+ return new String[]{"/OUT:" + outputFile};
+ }
+ public boolean isCaseSensitive() {
+ return false;
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/devstudio/DevStudioLibrarian.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/devstudio/DevStudioLibrarian.java
new file mode 100644
index 0000000000..06eac71e19
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/devstudio/DevStudioLibrarian.java
@@ -0,0 +1,36 @@
+/*
+ *
+ * Copyright 2002-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.devstudio;
+import net.sf.antcontrib.cpptasks.compiler.LinkType;
+import net.sf.antcontrib.cpptasks.compiler.Linker;
+/**
+ * Adapter for the Microsoft (r) Library Manager
+ *
+ * @author Curt Arnold
+ */
+public final class DevStudioLibrarian extends DevStudioCompatibleLibrarian {
+ private static final DevStudioLibrarian instance = new DevStudioLibrarian();
+ public static DevStudioLibrarian getInstance() {
+ return instance;
+ }
+ private DevStudioLibrarian() {
+ super("lib", "/bogus");
+ }
+ public Linker getLinker(LinkType type) {
+ return DevStudioLinker.getInstance().getLinker(type);
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/devstudio/DevStudioLinker.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/devstudio/DevStudioLinker.java
new file mode 100644
index 0000000000..7ae0178a8b
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/devstudio/DevStudioLinker.java
@@ -0,0 +1,44 @@
+/*
+ *
+ * Copyright 2001-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.devstudio;
+import net.sf.antcontrib.cpptasks.compiler.LinkType;
+import net.sf.antcontrib.cpptasks.compiler.Linker;
+/**
+ * Adapter for the Microsoft (r) Incremental Linker
+ *
+ * @author Adam Murdoch
+ * @author Curt Arnold
+ */
+public final class DevStudioLinker extends DevStudioCompatibleLinker {
+ private static final DevStudioLinker dllLinker = new DevStudioLinker(".dll");
+ private static final DevStudioLinker instance = new DevStudioLinker(".exe");
+ public static DevStudioLinker getInstance() {
+ return instance;
+ }
+ private DevStudioLinker(String outputSuffix) {
+ super("link", "/DLL", outputSuffix);
+ }
+ public Linker getLinker(LinkType type) {
+ if (type.isSharedLibrary()) {
+ return dllLinker;
+ }
+ if (type.isStaticLibrary()) {
+ return DevStudioLibrarian.getInstance();
+ }
+ return instance;
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/devstudio/DevStudioMIDLCompiler.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/devstudio/DevStudioMIDLCompiler.java
new file mode 100644
index 0000000000..7df898b92f
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/devstudio/DevStudioMIDLCompiler.java
@@ -0,0 +1,113 @@
+/*
+ *
+ * Copyright 2002-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.devstudio;
+import java.io.File;
+import java.util.Vector;
+import net.sf.antcontrib.cpptasks.CUtil;
+import net.sf.antcontrib.cpptasks.compiler.CommandLineCompiler;
+import net.sf.antcontrib.cpptasks.compiler.LinkType;
+import net.sf.antcontrib.cpptasks.compiler.Linker;
+import net.sf.antcontrib.cpptasks.compiler.Processor;
+import net.sf.antcontrib.cpptasks.parser.CParser;
+import net.sf.antcontrib.cpptasks.parser.Parser;
+import org.apache.tools.ant.types.Environment;
+import net.sf.antcontrib.cpptasks.OptimizationEnum;
+
+/**
+ * Adapter for the Microsoft (r) MIDL Compiler
+ *
+ * @author Curt Arnold
+ */
+public final class DevStudioMIDLCompiler extends CommandLineCompiler {
+ private static final DevStudioMIDLCompiler instance = new DevStudioMIDLCompiler(
+ false, null);
+ public static DevStudioMIDLCompiler getInstance() {
+ return instance;
+ }
+ private DevStudioMIDLCompiler(boolean newEnvironment, Environment env) {
+ super("midl", null, new String[]{".idl", ".odl"}, new String[]{},
+ ".tlb", false, null, newEnvironment, env);
+ }
+ protected void addImpliedArgs(final Vector args,
+ final boolean debug,
+ final boolean multithreaded,
+ final boolean exceptions,
+ final LinkType linkType,
+ final Boolean rtti,
+ final OptimizationEnum optimization,
+ final Boolean defaultflag) {
+ }
+ protected void addWarningSwitch(Vector args, int level) {
+ DevStudioProcessor.addWarningSwitch(args, level);
+ }
+ public Processor changeEnvironment(boolean newEnvironment, Environment env) {
+ if (newEnvironment || env != null) {
+ return new DevStudioMIDLCompiler(newEnvironment, env);
+ }
+ return this;
+ }
+ /**
+ * The include parser for C will work just fine, but we didn't want to
+ * inherit from CommandLineCCompiler
+ */
+ protected Parser createParser(File source) {
+ return new CParser();
+ }
+ protected int getArgumentCountPerInputFile() {
+ return 3;
+ }
+ protected void getDefineSwitch(StringBuffer buffer, String define,
+ String value) {
+ DevStudioProcessor.getDefineSwitch(buffer, define, value);
+ }
+ protected File[] getEnvironmentIncludePath() {
+ return CUtil.getPathFromEnvironment("INCLUDE", ";");
+ }
+ protected String getIncludeDirSwitch(String includeDir) {
+ return DevStudioProcessor.getIncludeDirSwitch(includeDir);
+ }
+ protected String getInputFileArgument(File outputDir, String filename,
+ int index) {
+ switch (index) {
+ case 0 :
+ return "/tlb";
+ case 1 :
+ return new File(outputDir, getOutputFileName(filename))
+ .getAbsolutePath();
+ }
+ return filename;
+ }
+ public Linker getLinker(LinkType type) {
+ return DevStudioLinker.getInstance().getLinker(type);
+ }
+ public int getMaximumCommandLength() {
+ return 1024;
+ }
+ protected int getMaximumInputFilesPerCommand() {
+ return 1;
+ }
+ protected int getTotalArgumentLengthForInputFile(File outputDir,
+ String inputFile) {
+ String arg1 = getInputFileArgument(outputDir, inputFile, 0);
+ String arg2 = getInputFileArgument(outputDir, inputFile, 1);
+ String arg3 = getInputFileArgument(outputDir, inputFile, 2);
+ return arg1.length() + arg2.length() + arg3.length() + 3;
+ }
+ protected void getUndefineSwitch(StringBuffer buffer, String define) {
+ DevStudioProcessor.getUndefineSwitch(buffer, define);
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/devstudio/DevStudioProcessor.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/devstudio/DevStudioProcessor.java
new file mode 100644
index 0000000000..6b2af7ed54
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/devstudio/DevStudioProcessor.java
@@ -0,0 +1,90 @@
+/*
+ *
+ * Copyright 2002-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.devstudio;
+import java.util.Vector;
+/**
+ * A add-in class for Microsoft Developer Studio processors
+ *
+ *
+ */
+public class DevStudioProcessor {
+ public static void addWarningSwitch(Vector args, int level) {
+ switch (level) {
+ case 0 :
+ args.addElement("/W0");
+ break;
+ case 1 :
+ args.addElement("/W1");
+ break;
+ case 2 :
+ break;
+ case 3 :
+ args.addElement("/W3");
+ break;
+ case 4 :
+ args.addElement("/W4");
+ break;
+ case 5 :
+ args.addElement("/WX");
+ break;
+ }
+ }
+ public static String getCommandFileSwitch(String cmdFile) {
+ StringBuffer buf = new StringBuffer("@");
+ if (cmdFile.indexOf(' ') >= 0) {
+ buf.append('\"');
+ buf.append(cmdFile.replace('/', '\\'));
+ buf.append('\"');
+ } else {
+ buf.append(cmdFile);
+ }
+ return buf.toString();
+ }
+ public static void getDefineSwitch(StringBuffer buffer, String define,
+ String value) {
+ buffer.append("/D");
+ buffer.append(define);
+ if (value != null && value.length() > 0) {
+ buffer.append('=');
+ buffer.append(value);
+ }
+ }
+ public static String getIncludeDirSwitch(String includeDir) {
+ return "/I" + includeDir.replace('/', '\\');
+ }
+ public static String[] getOutputFileSwitch(String outPath) {
+ StringBuffer buf = new StringBuffer("/Fo");
+ if (outPath.indexOf(' ') >= 0) {
+ buf.append('\"');
+ buf.append(outPath);
+ buf.append('\"');
+ } else {
+ buf.append(outPath);
+ }
+ String[] retval = new String[]{buf.toString()};
+ return retval;
+ }
+ public static void getUndefineSwitch(StringBuffer buffer, String define) {
+ buffer.append("/U");
+ buffer.append(define);
+ }
+ public static boolean isCaseSensitive() {
+ return false;
+ }
+ private DevStudioProcessor() {
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/devstudio/DevStudioResourceCompiler.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/devstudio/DevStudioResourceCompiler.java
new file mode 100644
index 0000000000..d6e2fd4442
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/devstudio/DevStudioResourceCompiler.java
@@ -0,0 +1,117 @@
+/*
+ *
+ * Copyright 2002-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.devstudio;
+import java.io.File;
+import java.util.Vector;
+
+import net.sf.antcontrib.cpptasks.CUtil;
+import net.sf.antcontrib.cpptasks.compiler.CommandLineCompiler;
+import net.sf.antcontrib.cpptasks.compiler.LinkType;
+import net.sf.antcontrib.cpptasks.compiler.Linker;
+import net.sf.antcontrib.cpptasks.compiler.Processor;
+import net.sf.antcontrib.cpptasks.parser.CParser;
+import net.sf.antcontrib.cpptasks.parser.Parser;
+import net.sf.antcontrib.cpptasks.OptimizationEnum;
+
+import org.apache.tools.ant.types.Environment;
+/**
+ * Adapter for the Microsoft (r) Windows 32 Resource Compiler
+ *
+ * @author Curt Arnold
+ */
+public final class DevStudioResourceCompiler extends CommandLineCompiler {
+ private static final DevStudioResourceCompiler instance = new DevStudioResourceCompiler(
+ false, null);
+ public static DevStudioResourceCompiler getInstance() {
+ return instance;
+ }
+ private String identifier;
+ private DevStudioResourceCompiler(boolean newEnvironment, Environment env) {
+ super("rc", null, new String[]{".rc"}, new String[]{".h", ".hpp",
+ ".inl"}, ".res", false, null, newEnvironment, env);
+ }
+ protected void addImpliedArgs(final Vector args,
+ final boolean debug,
+ final boolean multithreaded,
+ final boolean exceptions,
+ final LinkType linkType,
+ final Boolean rtti,
+ final OptimizationEnum optimization,
+ final Boolean defaultflag) {
+ if (debug) {
+ args.addElement("/D_DEBUG");
+ } else {
+ args.addElement("/DNDEBUG");
+ }
+ }
+ protected void addWarningSwitch(Vector args, int level) {
+ }
+ public Processor changeEnvironment(boolean newEnvironment, Environment env) {
+ if (newEnvironment || env != null) {
+ return new DevStudioResourceCompiler(newEnvironment, env);
+ }
+ return this;
+ }
+ /**
+ * The include parser for C will work just fine, but we didn't want to
+ * inherit from CommandLineCCompiler
+ */
+ protected Parser createParser(File source) {
+ return new CParser();
+ }
+ protected int getArgumentCountPerInputFile() {
+ return 2;
+ }
+ protected void getDefineSwitch(StringBuffer buffer, String define,
+ String value) {
+ DevStudioProcessor.getDefineSwitch(buffer, define, value);
+ }
+ protected File[] getEnvironmentIncludePath() {
+ return CUtil.getPathFromEnvironment("INCLUDE", ";");
+ }
+ protected String getIncludeDirSwitch(String includeDir) {
+ return DevStudioProcessor.getIncludeDirSwitch(includeDir);
+ }
+ protected String getInputFileArgument(File outputDir, String filename,
+ int index) {
+ if (index == 0) {
+ String outputFileName = getOutputFileName(filename);
+ String fullOutputName = new File(outputDir, outputFileName)
+ .toString();
+ return "/fo" + fullOutputName;
+ }
+ return filename;
+ }
+ public Linker getLinker(LinkType type) {
+ return DevStudioLinker.getInstance().getLinker(type);
+ }
+ public int getMaximumCommandLength() {
+ return 1024;
+ }
+ protected int getMaximumInputFilesPerCommand() {
+ return 1;
+ }
+ protected int getTotalArgumentLengthForInputFile(File outputDir,
+ String inputFile) {
+ String arg1 = getInputFileArgument(outputDir, inputFile, 0);
+ String arg2 = getInputFileArgument(outputDir, inputFile, 1);
+ return arg1.length() + arg2.length() + 2;
+ }
+ protected void getUndefineSwitch(StringBuffer buffer, String define) {
+ DevStudioProcessor.getUndefineSwitch(buffer, define);
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/gcc/AbstractArLibrarian.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/gcc/AbstractArLibrarian.java
new file mode 100644
index 0000000000..f7bb2eab95
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/gcc/AbstractArLibrarian.java
@@ -0,0 +1,106 @@
+/*
+ *
+ * Copyright 2001-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.gcc;
+import java.io.File;
+import java.util.Vector;
+
+import net.sf.antcontrib.cpptasks.CCTask;
+import net.sf.antcontrib.cpptasks.compiler.CommandLineLinker;
+import net.sf.antcontrib.cpptasks.compiler.CommandLineLinkerConfiguration;
+import net.sf.antcontrib.cpptasks.compiler.LinkType;
+import net.sf.antcontrib.cpptasks.types.LibraryTypeEnum;
+
+import org.apache.tools.ant.BuildException;
+/**
+ * Adapter for the "ar" tool
+ *
+ * @author Adam Murdoch
+ * @author Curt Arnold
+ */
+public abstract class AbstractArLibrarian extends CommandLineLinker {
+ private/* final */
+ String outputPrefix;
+ private static String[] defaultflags = new String[]{};
+ protected AbstractArLibrarian(String command, String identificationArg,
+ String[] inputExtensions, String[] ignoredExtensions,
+ String outputPrefix, String outputExtension, boolean isLibtool,
+ AbstractArLibrarian libtoolLibrarian) {
+ super(command, identificationArg, inputExtensions, ignoredExtensions,
+ outputExtension, isLibtool, libtoolLibrarian);
+ this.outputPrefix = outputPrefix;
+ }
+ public void addBase(long base, Vector args) {
+ }
+ public void addFixed(Boolean fixed, Vector args) {
+ }
+ public void addImpliedArgs(boolean debug, LinkType linkType, Vector args, Boolean defaultflag) {
+ if(defaultflag != null && defaultflag.booleanValue()){
+ for (int i = 0; i < defaultflags.length; i++) {
+ args.addElement(defaultflags[i]);
+ }
+ }
+ }
+ public void addIncremental(boolean incremental, Vector args) {
+ }
+ public void addMap(boolean map, Vector args) {
+ }
+ public void addStack(int stack, Vector args) {
+ }
+ /* (non-Javadoc)
+ * @see net.sf.antcontrib.cpptasks.compiler.CommandLineLinker#addEntry(int, java.util.Vector)
+ */
+ protected void addEntry(String entry, Vector args) {
+ }
+
+ public String getCommandFileSwitch(String commandFile) {
+ return null;
+ }
+ public File[] getLibraryPath() {
+ return new File[0];
+ }
+ public String[] getLibraryPatterns(String[] libnames, LibraryTypeEnum libType) {
+ return new String[0];
+ }
+ public int getMaximumCommandLength() {
+ return Integer.MAX_VALUE;
+ }
+ public String getOutputFileName(String baseName) {
+ return outputPrefix + super.getOutputFileName(baseName);
+ }
+ public String[] getOutputFileSwitch(String outputFile) {
+ return GccProcessor.getOutputFileSwitch("rvs", outputFile);
+ }
+ public boolean isCaseSensitive() {
+ return true;
+ }
+ public void link(CCTask task, File outputFile, String[] sourceFiles,
+ CommandLineLinkerConfiguration config) throws BuildException {
+ //
+ // if there is an existing library then
+ // we must delete it before executing "ar"
+ if (outputFile.exists()) {
+ if (!outputFile.delete()) {
+ throw new BuildException("Unable to delete "
+ + outputFile.getAbsolutePath());
+ }
+ }
+ //
+ // delegate to CommandLineLinker
+ //
+ super.link(task, outputFile, sourceFiles, config);
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/gcc/AbstractLdLinker.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/gcc/AbstractLdLinker.java
new file mode 100644
index 0000000000..f6e376643f
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/gcc/AbstractLdLinker.java
@@ -0,0 +1,323 @@
+/*
+ *
+ * Copyright 2002-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.gcc;
+import java.io.File;
+import java.util.Vector;
+
+import net.sf.antcontrib.cpptasks.CCTask;
+import net.sf.antcontrib.cpptasks.CUtil;
+import net.sf.antcontrib.cpptasks.compiler.CommandLineLinker;
+import net.sf.antcontrib.cpptasks.compiler.CommandLineLinkerConfiguration;
+import net.sf.antcontrib.cpptasks.compiler.LinkType;
+import net.sf.antcontrib.cpptasks.types.LibrarySet;
+import net.sf.antcontrib.cpptasks.types.LibraryTypeEnum;
+
+/**
+ * Abstract adapter for ld-like linkers
+ *
+ * @author Curt Arnold
+ */
+public abstract class AbstractLdLinker extends CommandLineLinker {
+ private String outputPrefix;
+ private static String[] defaultflags = new String[]{};
+ protected AbstractLdLinker(String command, String identifierArg,
+ String[] extensions, String[] ignoredExtensions,
+ String outputPrefix, String outputSuffix, boolean isLibtool,
+ AbstractLdLinker libtoolLinker) {
+ super(command, identifierArg, extensions, ignoredExtensions,
+ outputSuffix, isLibtool, libtoolLinker);
+ this.outputPrefix = outputPrefix;
+ }
+ public void addBase(long base, Vector args) {
+ if (base >= 0) {
+ args.addElement("--image-base");
+ args.addElement(Long.toHexString(base));
+ }
+ }
+ public void addFixed(Boolean fixed, Vector args) {
+ }
+ protected void addImpliedArgs(boolean debug, LinkType linkType, Vector args, Boolean defaultflag) {
+ if(defaultflag != null && defaultflag.booleanValue()){
+ for (int i = 0; i < defaultflags.length; i++) {
+ args.addElement(defaultflags[i]);
+ }
+ }
+ if (debug) {
+ args.addElement("-g");
+ }
+ if (isDarwin()) {
+ if (linkType.isPluginModule()) {
+ args.addElement("-bundle");
+ } else {
+ if (linkType.isSharedLibrary()) {
+ args.addElement("-prebind");
+ args.addElement("-dynamiclib");
+ }
+ }
+ } else {
+ if (linkType.isStaticRuntime()) {
+ args.addElement("-static");
+ }
+ if (linkType.isPluginModule()) {
+ args.addElement("-shared");
+ } else {
+ if (linkType.isSharedLibrary()) {
+ args.addElement("-shared");
+ }
+ }
+ }
+ }
+ public void addIncremental(boolean incremental, Vector args) {
+ if (incremental) {
+ args.addElement("-i");
+ }
+ }
+ protected int addLibraryPatterns(String[] libnames, StringBuffer buf,
+ String prefix, String extension, String[] patterns, int offset) {
+ for (int i = 0; i < libnames.length; i++) {
+ buf.setLength(0);
+ buf.append(prefix);
+ buf.append(libnames[i]);
+ buf.append(extension);
+ patterns[offset + i] = buf.toString();
+ }
+ return offset + libnames.length;
+ }
+ public String[] addLibrarySets(CCTask task, LibrarySet[] libsets,
+ Vector preargs, Vector midargs, Vector endargs) {
+ Vector libnames = new Vector();
+ super.addLibrarySets(task, libsets, preargs, midargs, endargs);
+ LibraryTypeEnum previousLibraryType = null;
+ for (int i = 0; i < libsets.length; i++) {
+ LibrarySet set = libsets[i];
+ File libdir = set.getDir(null);
+ String[] libs = set.getLibs();
+ if (libdir != null) {
+ if (set.getType() != null &&
+ "framework".equals(set.getType().getValue()) &&
+ isDarwin()) {
+ endargs.addElement("-F" + libdir.getAbsolutePath());
+ } else {
+ endargs.addElement("-L" + libdir.getAbsolutePath());
+ }
+ }
+ //
+ // if there has been a change of library type
+ //
+ if (set.getType() != previousLibraryType) {
+ if (set.getType() != null && "static".equals(set.getType().getValue())) {
+ endargs.addElement("-Bstatic");
+ previousLibraryType = set.getType();
+ } else {
+ if (set.getType() == null ||
+ !"framework".equals(set.getType().getValue()) ||
+ !isDarwin()) {
+ endargs.addElement("-Bdynamic");
+ previousLibraryType = set.getType();
+ }
+ }
+ }
+ StringBuffer buf = new StringBuffer("-l");
+ if (set.getType() != null &&
+ "framework".equals(set.getType().getValue()) &&
+ isDarwin()) {
+ buf.setLength(0);
+ buf.append("-framework ");
+ }
+ int initialLength = buf.length();
+ for (int j = 0; j < libs.length; j++) {
+ //
+ // reset the buffer to just "-l"
+ //
+ buf.setLength(initialLength);
+ //
+ // add the library name
+ buf.append(libs[j]);
+ libnames.addElement(libs[j]);
+ //
+ // add the argument to the list
+ endargs.addElement(buf.toString());
+ }
+ }
+ String rc[] = new String[libnames.size()];
+ for (int i = 0; i < libnames.size(); i++) {
+ rc[i] = (String) libnames.elementAt(i);
+ }
+ return rc;
+ }
+ public void addMap(boolean map, Vector args) {
+ if (map) {
+ args.addElement("-M");
+ }
+ }
+ public void addStack(int stack, Vector args) {
+ if (stack > 0) {
+ args.addElement("--stack");
+ args.addElement(Integer.toString(stack));
+ }
+ }
+ /* (non-Javadoc)
+ * @see net.sf.antcontrib.cpptasks.compiler.CommandLineLinker#addEntry(int, java.util.Vector)
+ */
+ protected void addEntry(String entry, Vector args) {
+ if (entry != null) {
+ args.addElement("-e");
+ args.addElement(entry);
+ }
+ }
+
+ public String getCommandFileSwitch(String commandFile) {
+ throw new IllegalStateException("ld does not support command files");
+ }
+ /**
+ * Returns library path.
+ *
+ */
+ protected File[] getEnvironmentIncludePath() {
+ return CUtil.getPathFromEnvironment("LIB", ":");
+ }
+ public String getLibraryKey(File libfile) {
+ String libname = libfile.getName();
+ int lastDot = libname.lastIndexOf('.');
+ if (lastDot >= 0) {
+ return libname.substring(0, lastDot);
+ }
+ return libname;
+ }
+ /**
+ * Returns library path.
+ *
+ */
+ public File[] getLibraryPath() {
+ return new File[0];
+ }
+ public String[] getLibraryPatterns(String[] libnames, LibraryTypeEnum libType) {
+ StringBuffer buf = new StringBuffer();
+ int patternCount = libnames.length;
+ if (libType == null) {
+ patternCount *= 2;
+ }
+ String[] patterns = new String[patternCount];
+ int offset = 0;
+ if (libType == null || "static".equals(libType.getValue())) {
+ offset = addLibraryPatterns(libnames, buf, "lib", ".a", patterns, 0);
+ }
+ if (libType != null && "framework".equals(libType.getValue()) && isDarwin()) {
+ for(int i = 0; i < libnames.length; i++) {
+ buf.setLength(0);
+ buf.append(libnames[i]);
+ buf.append(".framework/");
+ buf.append(libnames[i]);
+ patterns[offset++] = buf.toString();
+ }
+ } else {
+ if (libType == null || !"static".equals(libType.getValue())) {
+ if (isHPUX()) {
+ offset = addLibraryPatterns(libnames, buf, "lib", ".sl", patterns,
+ offset);
+ } else {
+ offset = addLibraryPatterns(libnames, buf, "lib", ".so", patterns,
+ offset);
+ }
+ }
+ }
+ return patterns;
+ }
+ public int getMaximumCommandLength() {
+ return Integer.MAX_VALUE;
+ }
+ public String getOutputFileName(String baseName) {
+ return outputPrefix + super.getOutputFileName(baseName);
+ }
+ public String[] getOutputFileSwitch(String outputFile) {
+ return GccProcessor.getOutputFileSwitch("-o", outputFile);
+ }
+ public boolean isCaseSensitive() {
+ return true;
+ }
+ protected boolean isHPUX() {
+ String osname = System.getProperty("os.name").toLowerCase();
+ if (osname.indexOf("hp") >= 0 && osname.indexOf("ux") >= 0) {
+ return true;
+ }
+ return false;
+ }
+ /**
+ * Prepares argument list for exec command. Will return null if command
+ * line would exceed allowable command line buffer.
+ *
+ * @param outputFile
+ * linker output file
+ * @param sourceFiles
+ * linker input files (.obj, .o, .res)
+ * @param args
+ * linker arguments
+ * @return arguments for runTask
+ */
+ public String[] prepareArguments(CCTask task, String outputDir,
+ String outputFile, String[] sourceFiles,
+ CommandLineLinkerConfiguration config) {
+ //
+ // need to suppress sources that correspond to
+ // library set entries since they are already
+ // in the argument list
+ String[] libnames = config.getLibraryNames();
+ if (libnames == null || libnames.length == 0) {
+ return super.prepareArguments(task, outputDir, outputFile,
+ sourceFiles, config);
+ }
+ //
+ //
+ // null out any sources that correspond to library names
+ //
+ String[] localSources = (String[]) sourceFiles.clone();
+ int extra = 0;
+ for (int i = 0; i < libnames.length; i++) {
+ String libname = libnames[i];
+ for (int j = 0; j < localSources.length; j++) {
+ if (localSources[j] != null
+ && localSources[j].indexOf(libname) > 0
+ && localSources[j].indexOf("lib") > 0) {
+ String filename = new File(localSources[j]).getName();
+ if (filename.startsWith("lib")
+ && filename.substring(3).startsWith(libname)) {
+ String extension = filename
+ .substring(libname.length() + 3);
+ if (extension.equals(".a") || extension.equals(".so")
+ || extension.equals(".sl")) {
+ localSources[j] = null;
+ extra++;
+ }
+ }
+ }
+ }
+ }
+ if (extra == 0) {
+ return super.prepareArguments(task, outputDir, outputFile,
+ sourceFiles, config);
+ }
+ String[] finalSources = new String[localSources.length - extra];
+ int index = 0;
+ for (int i = 0; i < localSources.length; i++) {
+ if (localSources[i] != null) {
+ finalSources[index++] = localSources[i];
+ }
+ }
+ return super.prepareArguments(task, outputDir, outputFile,
+ finalSources, config);
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/gcc/GccAssembler.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/gcc/GccAssembler.java
new file mode 100644
index 0000000000..412bffa847
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/gcc/GccAssembler.java
@@ -0,0 +1,76 @@
+/*
+ *
+ * Copyright 2001-2005 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.gcc;
+
+import java.io.File;
+import java.util.Vector;
+
+import net.sf.antcontrib.cpptasks.CUtil;
+import net.sf.antcontrib.cpptasks.compiler.CommandLineAssembler;
+import net.sf.antcontrib.cpptasks.compiler.LinkType;
+import net.sf.antcontrib.cpptasks.compiler.Linker;
+
+/**
+ * Adapter for gcc assemble
+ *
+ */
+public final class GccAssembler extends CommandLineAssembler {
+ private final static String[] sourceExtensions = new String[] { ".asm" };
+
+ private final static String[] headerExtensions = new String[] { ".h",
+ ".inc" };
+
+ private static final GccAssembler instance = new GccAssembler("gas",
+ sourceExtensions, headerExtensions, false);
+
+ /**
+ * Gets gcc adapter
+ */
+ public static GccAssembler getInstance() {
+ return instance;
+ }
+
+ /**
+ * Private constructor. Use GccAssembler.getInstance() to get singleton
+ * instance of this class.
+ */
+ private GccAssembler (String command, String[] sourceExtensions,
+ String[] headerExtensions, boolean isLibtool) {
+ super(command, null, sourceExtensions, headerExtensions,
+ isLibtool ? ".fo" : ".o");
+ }
+
+ public void addImpliedArgs(Vector args, boolean debug, Boolean defaultflag) {
+
+ }
+
+ public int getMaximumCommandLength() {
+ return Integer.MAX_VALUE;
+ }
+
+ public Linker getLinker(LinkType linkType) {
+ return GccLinker.getInstance().getLinker(linkType);
+ }
+
+ protected File[] getEnvironmentIncludePath() {
+ return CUtil.getPathFromEnvironment("INCLUDE", ":");
+ }
+
+ protected String getIncludeDirSwitch(String includeDir) {
+ return "-I" + includeDir;
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/gcc/GccCCompiler.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/gcc/GccCCompiler.java
new file mode 100644
index 0000000000..af3b26b134
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/gcc/GccCCompiler.java
@@ -0,0 +1,243 @@
+/*
+ *
+ * Copyright 2001-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.gcc;
+import java.io.File;
+import java.util.Vector;
+
+import net.sf.antcontrib.cpptasks.CUtil;
+import net.sf.antcontrib.cpptasks.compiler.LinkType;
+import net.sf.antcontrib.cpptasks.compiler.Linker;
+import net.sf.antcontrib.cpptasks.compiler.Processor;
+import net.sf.antcontrib.cpptasks.parser.CParser;
+import net.sf.antcontrib.cpptasks.parser.FortranParser;
+import net.sf.antcontrib.cpptasks.parser.Parser;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.types.Environment;
+import net.sf.antcontrib.cpptasks.OptimizationEnum;
+
+/**
+ * Adapter for the GCC C/C++ compiler
+ *
+ * @author Adam Murdoch
+ */
+public final class GccCCompiler extends GccCompatibleCCompiler {
+ private final static String[] sourceExtensions = new String[]{".c", /* C */
+ ".cc", /* C++ */
+ ".cpp", /* C++ */
+ ".cxx", /* C++ */
+ ".c++", /* C++ */
+ ".i", /* preprocessed C */
+ ".ii", /* preprocessed C++ */
+ ".f", /* FORTRAN */
+ ".for", /* FORTRAN */
+ ".m", /* Objective-C */
+ ".mm", /* Objected-C++ */
+ ".s" /* Assembly */
+ };
+ private final static String[] headerExtensions = new String[]{".h", ".hpp",
+ ".inl"};
+ private static final GccCCompiler cppInstance = new GccCCompiler("c++",
+ sourceExtensions, headerExtensions, false,
+ new GccCCompiler("c++", sourceExtensions, headerExtensions, true,
+ null, false, null), false, null);
+ private static final GccCCompiler g77Instance = new GccCCompiler("g77",
+ sourceExtensions, headerExtensions, false,
+ new GccCCompiler("g77", sourceExtensions, headerExtensions, true,
+ null, false, null), false, null);
+ private static final GccCCompiler gppInstance = new GccCCompiler("g++",
+ sourceExtensions, headerExtensions, false,
+ new GccCCompiler("g++", sourceExtensions, headerExtensions, true,
+ null, false, null), false, null);
+ private static final GccCCompiler instance = new GccCCompiler("gcc",
+ sourceExtensions, headerExtensions, false,
+ new GccCCompiler("gcc", sourceExtensions, headerExtensions, true,
+ null, false, null), false, null);
+ /**
+ * Gets c++ adapter
+ */
+ public static GccCCompiler getCppInstance() {
+ return cppInstance;
+ }
+ /**
+ * Gets g77 adapter
+ */
+ public static GccCCompiler getG77Instance() {
+ return g77Instance;
+ }
+ /**
+ * Gets gpp adapter
+ */
+ public static GccCCompiler getGppInstance() {
+ return gppInstance;
+ }
+ /**
+ * Gets gcc adapter
+ */
+ public static GccCCompiler getInstance() {
+ return instance;
+ }
+ private String identifier;
+ private File[] includePath;
+ private boolean isPICMeaningful = true;
+ /**
+ * Private constructor. Use GccCCompiler.getInstance() to get singleton
+ * instance of this class.
+ */
+ private GccCCompiler(String command, String[] sourceExtensions,
+ String[] headerExtensions, boolean isLibtool,
+ GccCCompiler libtoolCompiler, boolean newEnvironment,
+ Environment env) {
+ super(command, null, sourceExtensions, headerExtensions, isLibtool,
+ libtoolCompiler, newEnvironment, env);
+ isPICMeaningful = System.getProperty("os.name").indexOf("Windows") < 0;
+ }
+ public void addImpliedArgs(final Vector args,
+ final boolean debug,
+ final boolean multithreaded,
+ final boolean exceptions,
+ final LinkType linkType,
+ final Boolean rtti,
+ final OptimizationEnum optimization,
+ final Boolean defaultflag) {
+ super.addImpliedArgs(args, debug, multithreaded,
+ exceptions, linkType, rtti, optimization, defaultflag);
+ if (isPICMeaningful && linkType.isSharedLibrary()) {
+ args.addElement("-fPIC");
+ }
+ }
+ public Processor changeEnvironment(boolean newEnvironment, Environment env) {
+ if (newEnvironment || env != null) {
+ return new GccCCompiler(getCommand(), this.getSourceExtensions(),
+ this.getHeaderExtensions(), this.getLibtool(),
+ (GccCCompiler) this.getLibtoolCompiler(), newEnvironment,
+ env);
+ }
+ return this;
+ }
+ /**
+ * Create parser to determine dependencies.
+ *
+ * Will create appropriate parser (C++, FORTRAN) based on file extension.
+ *
+ */
+ protected Parser createParser(File source) {
+ if (source != null) {
+ String sourceName = source.getName();
+ int lastDot = sourceName.lastIndexOf('.');
+ if (lastDot >= 0 && lastDot + 1 < sourceName.length()) {
+ char afterDot = sourceName.charAt(lastDot + 1);
+ if (afterDot == 'f' || afterDot == 'F') {
+ return new FortranParser();
+ }
+ }
+ }
+ return new CParser();
+ }
+ public File[] getEnvironmentIncludePath() {
+ if (includePath == null) {
+ //
+ // construct default include path from machine id and version id
+ //
+ String[] defaultInclude = new String[1];
+ StringBuffer buf = new StringBuffer("/lib/");
+ buf.append(GccProcessor.getMachine());
+ buf.append('/');
+ buf.append(GccProcessor.getVersion());
+ buf.append("/include");
+ defaultInclude[0] = buf.toString();
+ //
+ // read specs file and look for -istart and -idirafter
+ //
+ String[] specs = GccProcessor.getSpecs();
+ String[][] optionValues = GccProcessor.parseSpecs(specs, "*cpp:",
+ new String[]{"-isystem ", "-idirafter "});
+ //
+ // if no entries were found, then use a default path
+ //
+ if (optionValues[0].length == 0 && optionValues[1].length == 0) {
+ optionValues[0] = new String[]{"/usr/local/include",
+ "/usr/include", "/usr/include/win32api"};
+ }
+ //
+ // remove mingw entries.
+ // For MinGW compiles this will mean the
+ // location of the sys includes will be
+ // wrong in dependencies.xml
+ // but that should have no significant effect
+ for (int i = 0; i < optionValues.length; i++) {
+ for (int j = 0; j < optionValues[i].length; j++) {
+ if (optionValues[i][j].indexOf("mingw") > 0) {
+ optionValues[i][j] = null;
+ }
+ }
+ }
+ //
+ // if cygwin then
+ // we have to prepend location of gcc32
+ // and .. to start of absolute filenames to
+ // have something that will exist in the
+ // windows filesystem
+ if (GccProcessor.isCygwin()) {
+ GccProcessor.convertCygwinFilenames(optionValues[0]);
+ GccProcessor.convertCygwinFilenames(optionValues[1]);
+ GccProcessor.convertCygwinFilenames(defaultInclude);
+ }
+ int count = CUtil.checkDirectoryArray(optionValues[0]);
+ count += CUtil.checkDirectoryArray(optionValues[1]);
+ count += CUtil.checkDirectoryArray(defaultInclude);
+ includePath = new File[count];
+ int index = 0;
+ for (int i = 0; i < optionValues.length; i++) {
+ for (int j = 0; j < optionValues[i].length; j++) {
+ if (optionValues[i][j] != null) {
+ includePath[index++] = new File(optionValues[i][j]);
+ }
+ }
+ }
+ for (int i = 0; i < defaultInclude.length; i++) {
+ if (defaultInclude[i] != null) {
+ includePath[index++] = new File(defaultInclude[i]);
+ }
+ }
+ }
+ return (File[]) includePath.clone();
+ }
+ public String getIdentifier() throws BuildException {
+ if (identifier == null) {
+ StringBuffer buf;
+ if (getLibtool()) {
+ buf = new StringBuffer("libtool ");
+ } else {
+ buf = new StringBuffer(' ');
+ }
+ buf.append(getCommand());
+ buf.append(' ');
+ buf.append(GccProcessor.getVersion());
+ buf.append(' ');
+ buf.append(GccProcessor.getMachine());
+ identifier = buf.toString();
+ }
+ return identifier;
+ }
+ public Linker getLinker(LinkType linkType) {
+ return GccLinker.getInstance().getLinker(linkType);
+ }
+ public int getMaximumCommandLength() {
+ return Integer.MAX_VALUE;
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/gcc/GccCompatibleCCompiler.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/gcc/GccCompatibleCCompiler.java
new file mode 100644
index 0000000000..98f086ed61
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/gcc/GccCompatibleCCompiler.java
@@ -0,0 +1,152 @@
+/*
+ *
+ * Copyright 2002-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.gcc;
+import java.io.File;
+import java.util.Vector;
+import net.sf.antcontrib.cpptasks.CUtil;
+import net.sf.antcontrib.cpptasks.compiler.CommandLineCCompiler;
+import net.sf.antcontrib.cpptasks.compiler.LinkType;
+import org.apache.tools.ant.types.Environment;
+import net.sf.antcontrib.cpptasks.OptimizationEnum;
+
+/**
+ * Abstract base class for compilers that attempt to be command line compatible
+ * with GCC
+ *
+ * @author Adam Murdoch
+ * @author Curt Arnold
+ */
+public abstract class GccCompatibleCCompiler extends CommandLineCCompiler {
+ private final static String[] headerExtensions = new String[]{".h", ".hpp",
+ ".inl"};
+ private final static String[] sourceExtensions = new String[]{".c", ".cc",
+ ".cpp", ".cxx", ".c++", ".i", ".f", ".for"};
+ private final static String[] defaultflags = new String[]{"-c"};
+ /**
+ * Private constructor. Use GccCCompiler.getInstance() to get singleton
+ * instance of this class.
+ */
+ protected GccCompatibleCCompiler(String command, String identifierArg,
+ boolean libtool, GccCompatibleCCompiler libtoolCompiler,
+ boolean newEnvironment, Environment env) {
+ super(command, identifierArg, sourceExtensions, headerExtensions,
+ libtool ? ".fo" : ".o", libtool, libtoolCompiler,
+ newEnvironment, env);
+ }
+ /**
+ * Private constructor. Use GccCCompiler.getInstance() to get singleton
+ * instance of this class.
+ */
+ protected GccCompatibleCCompiler(String command, String identifierArg,
+ String[] sourceExtensions, String[] headerExtensions,
+ boolean libtool, GccCompatibleCCompiler libtoolCompiler,
+ boolean newEnvironment, Environment env) {
+ super(command, identifierArg, sourceExtensions, headerExtensions,
+ libtool ? ".fo" : ".o", libtool, libtoolCompiler,
+ newEnvironment, env);
+ }
+ public void addImpliedArgs(final Vector args,
+ final boolean debug,
+ final boolean multithreaded,
+ final boolean exceptions,
+ final LinkType linkType,
+ final Boolean rtti,
+ final OptimizationEnum optimization,
+ final Boolean defaultflag) {
+ //
+ // -fPIC is too much trouble
+ // users have to manually add it for
+ // operating systems that make sense
+ //
+ if (defaultflag != null && defaultflag.booleanValue()) {
+ for (int i = 0; i < defaultflags.length; i++) {
+ args.addElement(defaultflags[i]);
+ }
+ }
+ if (debug) {
+ args.addElement("-g");
+ } else {
+ if (optimization != null) {
+ if (optimization.isSize()) {
+ args.addElement("-Os");
+ } else if (optimization.isSpeed()) {
+ if ("full".equals(optimization.getValue())) {
+ args.addElement("-O2");
+ } else {
+ if ("speed".equals(optimization.getValue())) {
+ args.addElement("-O1");
+ } else {
+ args.addElement("-O3");
+ }
+ }
+ }
+ }
+ }
+ if (getIdentifier().indexOf("mingw") >= 0) {
+ if (linkType.isSubsystemConsole()) {
+ args.addElement("-mconsole");
+ }
+ if (linkType.isSubsystemGUI()) {
+ args.addElement("-mwindows");
+ }
+ }
+ if (rtti != null && !rtti.booleanValue()) {
+ args.addElement("-fno-rtti");
+ }
+
+ }
+ /**
+ * Adds an include path to the command.
+ */
+ public void addIncludePath(String path, Vector cmd) {
+ cmd.addElement("-I" + path);
+ }
+ public void addWarningSwitch(Vector args, int level) {
+ switch (level) {
+ case 0 :
+ args.addElement("-w");
+ break;
+ case 5 :
+ args.addElement("-Werror");
+ /* nobreak */
+ case 4 :
+ args.addElement("-W");
+ /* nobreak */
+ case 3 :
+ args.addElement("-Wall");
+ break;
+ }
+ }
+ public void getDefineSwitch(StringBuffer buffer, String define, String value) {
+ buffer.append("-D");
+ buffer.append(define);
+ if (value != null && value.length() > 0) {
+ buffer.append('=');
+ buffer.append(value);
+ }
+ }
+ protected File[] getEnvironmentIncludePath() {
+ return CUtil.getPathFromEnvironment("INCLUDE", ":");
+ }
+ public String getIncludeDirSwitch(String includeDir) {
+ return "-I" + includeDir;
+ }
+ public void getUndefineSwitch(StringBuffer buffer, String define) {
+ buffer.append("-U");
+ buffer.append(define);
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/gcc/GccLibrarian.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/gcc/GccLibrarian.java
new file mode 100644
index 0000000000..62500021cf
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/gcc/GccLibrarian.java
@@ -0,0 +1,41 @@
+/*
+ *
+ * Copyright 2002-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.gcc;
+import net.sf.antcontrib.cpptasks.compiler.LinkType;
+import net.sf.antcontrib.cpptasks.compiler.Linker;
+/**
+ * Adapter for the 'ar' archiver
+ *
+ * @author Adam Murdoch
+ */
+public final class GccLibrarian extends AbstractArLibrarian {
+ private static String[] objFileExtensions = new String[]{".o"};
+ private static GccLibrarian instance = new GccLibrarian("ar",
+ objFileExtensions, false, new GccLibrarian("ar", objFileExtensions,
+ true, null));
+ public static GccLibrarian getInstance() {
+ return instance;
+ }
+ private GccLibrarian(String command, String[] inputExtensions,
+ boolean isLibtool, GccLibrarian libtoolLibrarian) {
+ super(command, "V", inputExtensions, new String[0], "lib", ".a",
+ isLibtool, libtoolLibrarian);
+ }
+ public Linker getLinker(LinkType type) {
+ return GccLinker.getInstance().getLinker(type);
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/gcc/GccLinker.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/gcc/GccLinker.java
new file mode 100644
index 0000000000..f37f55092a
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/gcc/GccLinker.java
@@ -0,0 +1,210 @@
+/*
+ *
+ * Copyright 2002-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.gcc;
+import java.io.File;
+import java.util.Vector;
+
+import net.sf.antcontrib.cpptasks.CUtil;
+import net.sf.antcontrib.cpptasks.compiler.LinkType;
+import net.sf.antcontrib.cpptasks.compiler.Linker;
+/**
+ * Adapter for the GCC linker
+ *
+ * @author Adam Murdoch
+ */
+public class GccLinker extends AbstractLdLinker {
+ private static final String[] discardFiles = new String[0];
+ private static final String[] objFiles = new String[]{".o", ".a", ".lib",
+ ".dll", ".so", ".sl"};
+ private static final String[] libtoolObjFiles = new String[]{".fo", ".a",
+ ".lib", ".dll", ".so", ".sl"};
+ private static String[] linkerOptions = new String[]{"-bundle",
+ "-dynamiclib", "-nostartfiles", "-nostdlib", "-prebind", "-s",
+ "-static", "-shared", "-symbolic", "-Xlinker",
+ "--export-all-symbols", "-static-libgcc",};
+ private static final GccLinker dllLinker = new GccLinker("gcc", objFiles,
+ discardFiles, "lib", ".so", false, new GccLinker("gcc", objFiles,
+ discardFiles, "lib", ".so", true, null));
+ private static final GccLinker instance = new GccLinker("gcc", objFiles,
+ discardFiles, "", "", false, null);
+ private static final GccLinker machBundleLinker = new GccLinker("gcc",
+ objFiles, discardFiles, "lib", ".bundle", false, null);
+ private static final GccLinker machDllLinker = new GccLinker("gcc",
+ objFiles, discardFiles, "lib", ".dylib", false, null);
+ public static GccLinker getInstance() {
+ return instance;
+ }
+ private File[] libDirs;
+ protected GccLinker(String command, String[] extensions,
+ String[] ignoredExtensions, String outputPrefix,
+ String outputSuffix, boolean isLibtool, GccLinker libtoolLinker) {
+ super(command, "-dumpversion", extensions, ignoredExtensions,
+ outputPrefix, outputSuffix, isLibtool, libtoolLinker);
+ }
+ protected void addImpliedArgs(boolean debug, LinkType linkType, Vector args, Boolean defaultflag) {
+ super.addImpliedArgs(debug, linkType, args, defaultflag);
+ if (getIdentifier().indexOf("mingw") >= 0) {
+ if (linkType.isSubsystemConsole()) {
+ args.addElement("-mconsole");
+ }
+ if (linkType.isSubsystemGUI()) {
+ args.addElement("-mwindows");
+ }
+ }
+ }
+ /**
+ * Allows drived linker to decorate linker option. Override by GccLinker to
+ * prepend a "-Wl," to pass option to through gcc to linker.
+ *
+ * @param buf
+ * buffer that may be used and abused in the decoration process,
+ * must not be null.
+ * @param arg
+ * linker argument
+ */
+ public String decorateLinkerOption(StringBuffer buf, String arg) {
+ String decoratedArg = arg;
+ if (arg.length() > 1 && arg.charAt(0) == '-') {
+ switch (arg.charAt(1)) {
+ //
+ // passed automatically by GCC
+ //
+ case 'g' :
+ case 'f' :
+ case 'F' :
+ /* Darwin */
+ case 'm' :
+ case 'O' :
+ case 'W' :
+ case 'l' :
+ case 'L' :
+ case 'u' :
+ case 'v' :
+ break;
+ default :
+ boolean known = false;
+ for (int i = 0; i < linkerOptions.length; i++) {
+ if (linkerOptions[i].equals(arg)) {
+ known = true;
+ break;
+ }
+ }
+ if (!known) {
+ buf.setLength(0);
+ buf.append("-Wl,");
+ buf.append(arg);
+ decoratedArg = buf.toString();
+ }
+ break;
+ }
+ }
+ return decoratedArg;
+ }
+ /**
+ * Returns library path.
+ *
+ */
+ public File[] getLibraryPath() {
+ if (libDirs == null) {
+ //
+ // construct gcc lib path from machine and version
+ //
+ StringBuffer buf = new StringBuffer("/lib/gcc-lib/");
+ buf.append(GccProcessor.getMachine());
+ buf.append('/');
+ buf.append(GccProcessor.getVersion());
+ //
+ // build default path from gcc and system /lib and /lib/w32api
+ //
+ String[] impliedLibPath = new String[]{buf.toString(),
+ "/lib/w32api", "/lib"};
+ //
+ // read gcc specs file for other library paths
+ //
+ String[] specs = GccProcessor.getSpecs();
+ String[][] libpaths = GccProcessor.parseSpecs(specs, "*link:",
+ new String[]{"%q"});
+ String[] libpath;
+ if (libpaths[0].length > 0) {
+ libpath = new String[libpaths[0].length + 3];
+ int i = 0;
+ for (; i < libpaths[0].length; i++) {
+ libpath[i] = libpaths[0][i];
+ }
+ libpath[i++] = buf.toString();
+ libpath[i++] = "/lib/w32api";
+ libpath[i++] = "/lib";
+ } else {
+ //
+ // if a failure to find any matches then
+ // use some default values for lib path entries
+ libpath = new String[]{"/usr/local/lib/mingw",
+ "/usr/local/lib", "/usr/lib/w32api", "/usr/lib/mingw",
+ "/usr/lib", buf.toString(), "/lib/w32api", "/lib"};
+ }
+ for (int i = 0; i < libpath.length; i++) {
+ if (libpath[i].indexOf("mingw") >= 0) {
+ libpath[i] = null;
+ }
+ }
+ //
+ // if cygwin then
+ // we have to prepend location of gcc32
+ // and .. to start of absolute filenames to
+ // have something that will exist in the
+ // windows filesystem
+ if (GccProcessor.isCygwin()) {
+ GccProcessor.convertCygwinFilenames(libpath);
+ }
+ //
+ // check that remaining entries are actual directories
+ //
+ int count = CUtil.checkDirectoryArray(libpath);
+ //
+ // populate return array with remaining entries
+ //
+ libDirs = new File[count];
+ int index = 0;
+ for (int i = 0; i < libpath.length; i++) {
+ if (libpath[i] != null) {
+ libDirs[index++] = new File(libpath[i]);
+ }
+ }
+ }
+ return libDirs;
+ }
+ public Linker getLinker(LinkType type) {
+ if (type.isStaticLibrary()) {
+ return GccLibrarian.getInstance();
+ }
+ if (type.isPluginModule()) {
+ if (isDarwin()) {
+ return machBundleLinker;
+ } else {
+ return dllLinker;
+ }
+ }
+ if (type.isSharedLibrary()) {
+ if (isDarwin()) {
+ return machDllLinker;
+ } else {
+ return dllLinker;
+ }
+ }
+ return instance;
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/gcc/GccProcessor.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/gcc/GccProcessor.java
new file mode 100644
index 0000000000..236969f5e7
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/gcc/GccProcessor.java
@@ -0,0 +1,299 @@
+/*
+ *
+ * Copyright 2002-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.gcc;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.Vector;
+
+import net.sf.antcontrib.cpptasks.CUtil;
+import net.sf.antcontrib.cpptasks.compiler.CaptureStreamHandler;
+/**
+ * A add-in class for Gcc processors
+ *
+ *
+ */
+public class GccProcessor {
+ // the results from gcc -dumpmachine
+ private static String machine;
+ private static String[] specs;
+ // the results from gcc -dumpversion
+ private static String version;
+ private static int addLibraryPatterns(String[] libnames, StringBuffer buf,
+ String prefix, String extension, String[] patterns, int offset) {
+ for (int i = 0; i < libnames.length; i++) {
+ buf.setLength(0);
+ buf.append(prefix);
+ buf.append(libnames[i]);
+ buf.append(extension);
+ patterns[offset + i] = buf.toString();
+ }
+ return offset + libnames.length;
+ }
+ /**
+ * Converts absolute Cygwin file or directory names to the corresponding
+ * Win32 name.
+ *
+ * @param names
+ * array of names, some elements may be null, will be changed in
+ * place.
+ */
+ public static void convertCygwinFilenames(String[] names) {
+ if (names == null) {
+ throw new NullPointerException("names");
+ }
+ File gccDir = CUtil.getExecutableLocation("gcc.exe");
+ if (gccDir != null) {
+ String prefix = gccDir.getAbsolutePath() + "/..";
+ StringBuffer buf = new StringBuffer();
+ for (int i = 0; i < names.length; i++) {
+ String name = names[i];
+ if (name != null && name.length() > 1 && name.charAt(0) == '/') {
+ buf.setLength(0);
+ buf.append(prefix);
+ buf.append(name);
+ names[i] = buf.toString();
+ }
+ }
+ }
+ }
+ public static String[] getLibraryPatterns(String[] libnames) {
+ StringBuffer buf = new StringBuffer();
+ String[] patterns = new String[libnames.length * 2];
+ int offset = addLibraryPatterns(libnames, buf, "lib", ".a", patterns, 0);
+ if (isHPUX()) {
+ offset = addLibraryPatterns(libnames, buf, "lib", ".sl", patterns,
+ offset);
+ } else {
+ offset = addLibraryPatterns(libnames, buf, "lib", ".so", patterns,
+ offset);
+ }
+ return patterns;
+ }
+ public static String getMachine() {
+ if (machine == null) {
+ String[] args = new String[]{"gcc", "-dumpmachine"};
+ String[] cmdout = CaptureStreamHandler.run(args);
+ if (cmdout.length == 0) {
+ machine = "nomachine";
+ } else {
+ machine = cmdout[0];
+ }
+ }
+ return machine;
+ }
+ public static String[] getOutputFileSwitch(String letter, String outputFile) {
+ StringBuffer buf = new StringBuffer();
+ if (outputFile.indexOf(' ') >= 0) {
+ buf.append('"');
+ buf.append(outputFile.replace('\\', '/'));
+ buf.append('"');
+ } else {
+ buf.append(outputFile.replace('\\', '/'));
+ }
+ String[] retval = new String[]{letter, buf.toString()};
+ return retval;
+ }
+ /**
+ * Returns the contents of the gcc specs file.
+ *
+ * The implementation locates gcc.exe in the executable path and then
+ * builds a relative path name from the results of -dumpmachine and
+ * -dumpversion. Attempts to use gcc -dumpspecs to provide this information
+ * resulted in stalling on the Execute.run
+ *
+ * @returns contents of the specs file
+ */
+ public static String[] getSpecs() {
+ if (specs == null) {
+ File gccParent = CUtil.getExecutableLocation("gcc.exe");
+ if (gccParent != null) {
+ //
+ // build a relative path like
+ // ../lib/gcc-lib/i686-pc-cygwin/2.95.3-5/specs
+ //
+ StringBuffer buf = new StringBuffer("../lib/gcc-lib/");
+ buf.append(getMachine());
+ buf.append('/');
+ buf.append(getVersion());
+ buf.append("/specs");
+ //
+ // resolve it relative to the location of gcc.exe
+ //
+ String relativePath = buf.toString();
+ File specsFile = new File(gccParent, relativePath);
+ //
+ // found the specs file
+ //
+ try {
+ //
+ // read the lines in the file
+ //
+ BufferedReader reader = new BufferedReader(new FileReader(
+ specsFile));
+ Vector lines = new Vector(100);
+ String line = reader.readLine();
+ while (line != null) {
+ lines.addElement(line);
+ line = reader.readLine();
+ }
+ specs = new String[lines.size()];
+ lines.copyInto(specs);
+ } catch (IOException ex) {
+ }
+ }
+ }
+ if (specs == null) {
+ specs = new String[0];
+ }
+ return specs;
+ }
+ public static String getVersion() {
+ if (version == null) {
+ String[] args = new String[]{"gcc", "-dumpversion"};
+ String[] cmdout = CaptureStreamHandler.run(args);
+ if (cmdout.length == 0) {
+ version = "noversion";
+ } else {
+ version = cmdout[0];
+ }
+ }
+ return version;
+ }
+ public static boolean isCaseSensitive() {
+ return true;
+ }
+ /**
+ * Determines if task is running with cygwin
+ *
+ * @return true if cygwin was detected
+ */
+ public static boolean isCygwin() {
+ return getMachine().indexOf("cygwin") > 0;
+ }
+ private static boolean isHPUX() {
+ String osname = System.getProperty("os.name").toLowerCase();
+ if (osname.indexOf("hp") >= 0 && osname.indexOf("ux") >= 0) {
+ return true;
+ }
+ return false;
+ }
+ /**
+ *
+ * Parses the results of the specs file for a specific processor and
+ * options
+ *
+ * @param specsContent
+ * Contents of specs file as returned from getSpecs
+ * @param specSectionStart
+ * start of spec section, for example "*cpp:"
+ * @param options
+ * command line switches such as "-istart"
+ */
+ public static String[][] parseSpecs(String[] specsContent,
+ String specSectionStart, String[] options) {
+ if (specsContent == null) {
+ throw new NullPointerException("specsContent");
+ }
+ if (specSectionStart == null) {
+ throw new NullPointerException("specSectionStart");
+ }
+ if (options == null) {
+ throw new NullPointerException("option");
+ }
+ String[][] optionValues = new String[options.length][];
+ StringBuffer optionValue = new StringBuffer(40);
+ for (int i = 0; i < specsContent.length; i++) {
+ String specLine = specsContent[i];
+ //
+ // if start of section then start paying attention
+ //
+ if (specLine.startsWith(specSectionStart)) {
+ Vector[] optionVectors = new Vector[options.length];
+ for (int j = 0; j < options.length; j++) {
+ optionVectors[j] = new Vector(10);
+ }
+ //
+ // go to next line and examine contents
+ // and repeat until end of file
+ //
+ for (i++; i < specsContent.length; i++) {
+ specLine = specsContent[i];
+ for (int j = 0; j < options.length; j++) {
+ int optionStart = specLine.indexOf(options[j]);
+ while (optionStart >= 0) {
+ optionValue.setLength(0);
+ //
+ // walk rest of line looking for first non
+ // whitespace
+ // and then next space
+ boolean hasNonBlank = false;
+ int k = optionStart + options[j].length();
+ for (; k < specLine.length(); k++) {
+ //
+ // either a blank or a "}" (close of
+ // conditional)
+ // section will end the path
+ //
+ if (specLine.charAt(k) == ' '
+ || specLine.charAt(k) == '}') {
+ if (hasNonBlank) {
+ break;
+ }
+ } else {
+ hasNonBlank = true;
+ optionValue.append(specLine.charAt(k));
+ }
+ }
+ //
+ // transition back to whitespace
+ // value is over, add it to vector
+ if (hasNonBlank) {
+ optionVectors[j].addElement(optionValue
+ .toString());
+ }
+ //
+ // find next occurance on line
+ //
+ optionStart = specLine.indexOf(options[j], k);
+ }
+ }
+ }
+ //
+ // copy vectors over to option arrays
+ //
+ for (int j = 0; j < options.length; j++) {
+ optionValues[j] = new String[optionVectors[j].size()];
+ optionVectors[j].copyInto(optionValues[j]);
+ }
+ }
+ }
+ //
+ // fill in any missing option values with
+ // a zero-length string array
+ for (int i = 0; i < optionValues.length; i++) {
+ String[] zeroLenArray = new String[0];
+ if (optionValues[i] == null) {
+ optionValues[i] = zeroLenArray;
+ }
+ }
+ return optionValues;
+ }
+ private GccProcessor() {
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/gcc/GppLinker.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/gcc/GppLinker.java
new file mode 100644
index 0000000000..e7036abe16
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/gcc/GppLinker.java
@@ -0,0 +1,203 @@
+/*
+ *
+ * Copyright 2003-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.gcc;
+import java.io.File;
+import java.util.Vector;
+
+import net.sf.antcontrib.cpptasks.CCTask;
+import net.sf.antcontrib.cpptasks.CUtil;
+import net.sf.antcontrib.cpptasks.compiler.CaptureStreamHandler;
+import net.sf.antcontrib.cpptasks.compiler.LinkType;
+import net.sf.antcontrib.cpptasks.compiler.Linker;
+import net.sf.antcontrib.cpptasks.types.LibrarySet;
+/**
+ * Adapter for the g++ variant of the GCC linker
+ *
+ * @author Stephen M. Webb
+ */
+public class GppLinker extends AbstractLdLinker {
+ protected static final String[] discardFiles = new String[0];
+ protected static final String[] objFiles = new String[]{".o", ".a", ".lib",
+ ".dll", ".so", ".sl"};
+ private static final GppLinker dllLinker = new GppLinker("gcc", objFiles,
+ discardFiles, "lib", ".so", false, new GppLinker("gcc", objFiles,
+ discardFiles, "lib", ".so", true, null));
+ private final static String libPrefix = "libraries: =";
+ protected static final String[] libtoolObjFiles = new String[]{".fo", ".a",
+ ".lib", ".dll", ".so", ".sl"};
+ private static String[] linkerOptions = new String[]{"-bundle", "-dylib",
+ "-dynamic", "-dynamiclib", "-nostartfiles", "-nostdlib",
+ "-prebind", "-s", "-static", "-shared", "-symbolic", "-Xlinker"};
+ private static final GppLinker instance = new GppLinker("gcc", objFiles,
+ discardFiles, "", "", false, null);
+ private static final GppLinker machDllLinker = new GppLinker("gcc",
+ objFiles, discardFiles, "lib", ".dylib", false, null);
+ private static final GppLinker machPluginLinker = new GppLinker("gcc",
+ objFiles, discardFiles, "lib", ".bundle", false, null);
+ public static GppLinker getInstance() {
+ return instance;
+ }
+ private File[] libDirs;
+ private String runtimeLibrary;
+ protected GppLinker(String command, String[] extensions,
+ String[] ignoredExtensions, String outputPrefix,
+ String outputSuffix, boolean isLibtool, GppLinker libtoolLinker) {
+ super(command, "-dumpversion", extensions, ignoredExtensions,
+ outputPrefix, outputSuffix, isLibtool, libtoolLinker);
+ }
+ protected void addImpliedArgs(boolean debug, LinkType linkType, Vector args, Boolean defaultflag) {
+ super.addImpliedArgs(debug, linkType, args, defaultflag);
+ if (getIdentifier().indexOf("mingw") >= 0) {
+ if (linkType.isSubsystemConsole()) {
+ args.addElement("-mconsole");
+ }
+ if (linkType.isSubsystemGUI()) {
+ args.addElement("-mwindows");
+ }
+ }
+ if (linkType.isStaticRuntime()) {
+ String[] cmdin = new String[]{"g++", "-print-file-name=libstdc++.a"};
+ String[] cmdout = CaptureStreamHandler.run(cmdin);
+ if (cmdout.length > 0) {
+ runtimeLibrary = cmdout[0];
+ } else {
+ runtimeLibrary = null;
+ }
+ } else {
+ runtimeLibrary = "-lstdc++";
+ }
+ }
+ public String[] addLibrarySets(CCTask task, LibrarySet[] libsets,
+ Vector preargs, Vector midargs, Vector endargs) {
+ String[] rs = super.addLibrarySets(task, libsets, preargs, midargs,
+ endargs);
+ if (runtimeLibrary != null) {
+ endargs.addElement(runtimeLibrary);
+ }
+ return rs;
+ }
+ /**
+ * Allows drived linker to decorate linker option. Override by GppLinker to
+ * prepend a "-Wl," to pass option to through gcc to linker.
+ *
+ * @param buf
+ * buffer that may be used and abused in the decoration process,
+ * must not be null.
+ * @param arg
+ * linker argument
+ */
+ public String decorateLinkerOption(StringBuffer buf, String arg) {
+ String decoratedArg = arg;
+ if (arg.length() > 1 && arg.charAt(0) == '-') {
+ switch (arg.charAt(1)) {
+ //
+ // passed automatically by GCC
+ //
+ case 'g' :
+ case 'f' :
+ case 'F' :
+ /* Darwin */
+ case 'm' :
+ case 'O' :
+ case 'W' :
+ case 'l' :
+ case 'L' :
+ case 'u' :
+ break;
+ default :
+ boolean known = false;
+ for (int i = 0; i < linkerOptions.length; i++) {
+ if (linkerOptions[i].equals(arg)) {
+ known = true;
+ break;
+ }
+ }
+ if (!known) {
+ buf.setLength(0);
+ buf.append("-Wl,");
+ buf.append(arg);
+ decoratedArg = buf.toString();
+ }
+ break;
+ }
+ }
+ return decoratedArg;
+ }
+ /**
+ * Returns library path.
+ *
+ */
+ public File[] getLibraryPath() {
+ if (libDirs == null) {
+ Vector dirs = new Vector();
+ // Ask GCC where it will look for its libraries.
+ String[] args = new String[]{"g++", "-print-search-dirs"};
+ String[] cmdout = CaptureStreamHandler.run(args);
+ for (int i = 0; i < cmdout.length; ++i) {
+ int prefixIndex = cmdout[i].indexOf(libPrefix);
+ if (prefixIndex >= 0) {
+ // Special case DOS-type GCCs like MinGW or Cygwin
+ int s = prefixIndex + libPrefix.length();
+ int t = cmdout[i].indexOf(';', s);
+ while (t > 0) {
+ dirs.addElement(cmdout[i].substring(s, t));
+ s = t + 1;
+ t = cmdout[i].indexOf(';', s);
+ }
+ dirs.addElement(cmdout[i].substring(s));
+ ++i;
+ for (; i < cmdout.length; ++i) {
+ dirs.addElement(cmdout[i]);
+ }
+ }
+ }
+ // Eliminate all but actual directories.
+ String[] libpath = new String[dirs.size()];
+ dirs.copyInto(libpath);
+ int count = CUtil.checkDirectoryArray(libpath);
+ // Build return array.
+ libDirs = new File[count];
+ int index = 0;
+ for (int i = 0; i < libpath.length; ++i) {
+ if (libpath[i] != null) {
+ libDirs[index++] = new File(libpath[i]);
+ }
+ }
+ }
+ return libDirs;
+ }
+ public Linker getLinker(LinkType type) {
+ if (type.isStaticLibrary()) {
+ return GccLibrarian.getInstance();
+ }
+ if (type.isPluginModule()) {
+ if (GccProcessor.getMachine().indexOf("darwin") >= 0) {
+ return machPluginLinker;
+ } else {
+ return dllLinker;
+ }
+ }
+ if (type.isSharedLibrary()) {
+ if (GccProcessor.getMachine().indexOf("darwin") >= 0) {
+ return machDllLinker;
+ } else {
+ return dllLinker;
+ }
+ }
+ return instance;
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/gcc/LdLinker.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/gcc/LdLinker.java
new file mode 100644
index 0000000000..e05fa5b2db
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/gcc/LdLinker.java
@@ -0,0 +1,57 @@
+/*
+ *
+ * Copyright 2001-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.gcc;
+import java.io.File;
+
+import net.sf.antcontrib.cpptasks.compiler.LinkType;
+import net.sf.antcontrib.cpptasks.compiler.Linker;
+/**
+ * Adapter for the 'ld' linker
+ *
+ * @author Curt Arnold
+ */
+public final class LdLinker extends AbstractLdLinker {
+ private static final String[] discardFiles = new String[0];
+ private static final String[] objFiles = new String[]{".o", ".a", ".lib",
+ ".dll", ".so", ".sl"};
+ private static final LdLinker dllLinker = new LdLinker("ld", objFiles,
+ discardFiles, "lib", ".so", false, new LdLinker("ld", objFiles,
+ discardFiles, "lib", ".so", true, null));
+ private static final LdLinker instance = new LdLinker("ld", objFiles,
+ discardFiles, "", "", false, null);
+ private static final String[] libtoolObjFiles = new String[]{".fo", ".a",
+ ".lib", ".dll", ".so", ".sl"};
+ public static LdLinker getInstance() {
+ return instance;
+ }
+ private File[] libDirs;
+ private LdLinker(String command, String[] extensions,
+ String[] ignoredExtensions, String outputPrefix,
+ String outputSuffix, boolean isLibtool, LdLinker libtoolLinker) {
+ super(command, "-version", extensions, ignoredExtensions, outputPrefix,
+ outputSuffix, isLibtool, libtoolLinker);
+ }
+ public Linker getLinker(LinkType type) {
+ if (type.isStaticLibrary()) {
+ return GccLibrarian.getInstance();
+ }
+ if (type.isSharedLibrary()) {
+ return dllLinker;
+ }
+ return instance;
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/gcc/cross/GccCCompiler.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/gcc/cross/GccCCompiler.java
new file mode 100644
index 0000000000..6a5697eb80
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/gcc/cross/GccCCompiler.java
@@ -0,0 +1,273 @@
+/*
+ *
+ * Copyright 2001-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.gcc.cross;
+import java.io.File;
+import java.util.Vector;
+import net.sf.antcontrib.cpptasks.CCTask;
+import net.sf.antcontrib.cpptasks.CUtil;
+import net.sf.antcontrib.cpptasks.CompilerParam;
+import net.sf.antcontrib.cpptasks.compiler.CommandLineCompilerConfiguration;
+import net.sf.antcontrib.cpptasks.compiler.LinkType;
+import net.sf.antcontrib.cpptasks.compiler.Linker;
+import net.sf.antcontrib.cpptasks.compiler.Processor;
+import net.sf.antcontrib.cpptasks.compiler.ProgressMonitor;
+import net.sf.antcontrib.cpptasks.gcc.GccCompatibleCCompiler;
+import net.sf.antcontrib.cpptasks.parser.CParser;
+import net.sf.antcontrib.cpptasks.parser.FortranParser;
+import net.sf.antcontrib.cpptasks.parser.Parser;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.types.Environment;
+import net.sf.antcontrib.cpptasks.OptimizationEnum;
+
+/**
+ * Adapter for the GCC C/C++ compiler
+ *
+ * @author Adam Murdoch
+ */
+public final class GccCCompiler extends GccCompatibleCCompiler {
+ private final static String[] headerExtensions = new String[]{".h", ".hpp",
+ ".inl"};
+ private final static String[] sourceExtensions = new String[]{".c", /* C */
+ ".cc", /* C++ */
+ ".cpp", /* C++ */
+ ".cxx", /* C++ */
+ ".c++", /* C++ */
+ ".i", /* preprocessed C */
+ ".ii", /* preprocessed C++ */
+ ".f", /* FORTRAN */
+ ".for", /* FORTRAN */
+ ".m", /* Objective-C */
+ ".mm", /* Objected-C++ */
+ ".s" /* Assembly */
+ };
+ private static final GccCCompiler cppInstance = new GccCCompiler("c++",
+ sourceExtensions, headerExtensions, false,
+ new GccCCompiler("c++", sourceExtensions, headerExtensions, true,
+ null, false, null), false, null);
+ private static final GccCCompiler g77Instance = new GccCCompiler("g77",
+ sourceExtensions, headerExtensions, false,
+ new GccCCompiler("g77", sourceExtensions, headerExtensions, true,
+ null, false, null), false, null);
+ private static final GccCCompiler gppInstance = new GccCCompiler("g++",
+ sourceExtensions, headerExtensions, false,
+ new GccCCompiler("g++", sourceExtensions, headerExtensions, true,
+ null, false, null), false, null);
+ private static final GccCCompiler instance = new GccCCompiler("gcc",
+ sourceExtensions, headerExtensions, false,
+ new GccCCompiler("gcc", sourceExtensions, headerExtensions, true,
+ null, false, null), false, null);
+ /**
+ * Gets c++ adapter
+ */
+ public static GccCCompiler getCppInstance() {
+ return cppInstance;
+ }
+ /**
+ * Gets g77 adapter
+ */
+ public static GccCCompiler getG77Instance() {
+ return g77Instance;
+ }
+ /**
+ * Gets gpp adapter
+ */
+ public static GccCCompiler getGppInstance() {
+ return gppInstance;
+ }
+ /**
+ * Gets gcc adapter
+ */
+ public static GccCCompiler getInstance() {
+ return instance;
+ }
+ private String identifier;
+ private File[] includePath;
+ private boolean isPICMeaningful = true;
+ /**
+ * Private constructor. Use GccCCompiler.getInstance() to get singleton
+ * instance of this class.
+ */
+ private GccCCompiler(String command, String[] sourceExtensions,
+ String[] headerExtensions, boolean isLibtool,
+ GccCCompiler libtoolCompiler, boolean newEnvironment,
+ Environment env) {
+ super(command, null, sourceExtensions, headerExtensions, isLibtool,
+ libtoolCompiler, newEnvironment, env);
+ isPICMeaningful = System.getProperty("os.name").indexOf("Windows") < 0;
+ }
+ public void addImpliedArgs(final Vector args,
+ final boolean debug,
+ final boolean multithreaded,
+ final boolean exceptions,
+ final LinkType linkType,
+ final Boolean rtti,
+ final OptimizationEnum optimization,
+ final Boolean defaultflag) {
+ super.addImpliedArgs(args, debug, multithreaded,
+ exceptions, linkType, rtti, optimization, defaultflag);
+ if (isPICMeaningful && linkType.isSharedLibrary()) {
+ args.addElement("-fPIC");
+ }
+ }
+ public Processor changeEnvironment(boolean newEnvironment, Environment env) {
+ if (newEnvironment || env != null) {
+ return new GccCCompiler(getCommand(), this.getSourceExtensions(),
+ this.getHeaderExtensions(), this.getLibtool(),
+ (GccCCompiler) this.getLibtoolCompiler(), newEnvironment,
+ env);
+ }
+ return this;
+ }
+ protected Object clone() throws CloneNotSupportedException {
+ GccCCompiler clone = (GccCCompiler) super.clone();
+ return clone;
+ }
+ public void compile(CCTask task, File outputDir, String[] sourceFiles,
+ String[] args, String[] endArgs, boolean relentless,
+ CommandLineCompilerConfiguration config, ProgressMonitor monitor)
+ throws BuildException {
+ try {
+ GccCCompiler clone = (GccCCompiler) this.clone();
+ CompilerParam param = config.getParam("target");
+ if (param != null)
+ clone.setCommand(param.getValue() + "-" + this.getCommand());
+ clone.supercompile(task, outputDir, sourceFiles, args, endArgs,
+ relentless, config, monitor);
+ } catch (CloneNotSupportedException e) {
+ supercompile(task, outputDir, sourceFiles, args, endArgs,
+ relentless, config, monitor);
+ }
+ }
+ /**
+ * Create parser to determine dependencies.
+ *
+ * Will create appropriate parser (C++, FORTRAN) based on file extension.
+ *
+ */
+ protected Parser createParser(File source) {
+ if (source != null) {
+ String sourceName = source.getName();
+ int lastDot = sourceName.lastIndexOf('.');
+ if (lastDot >= 0 && lastDot + 1 < sourceName.length()) {
+ char afterDot = sourceName.charAt(lastDot + 1);
+ if (afterDot == 'f' || afterDot == 'F') {
+ return new FortranParser();
+ }
+ }
+ }
+ return new CParser();
+ }
+ public File[] getEnvironmentIncludePath() {
+ if (includePath == null) {
+ //
+ // construct default include path from machine id and version id
+ //
+ String[] defaultInclude = new String[1];
+ StringBuffer buf = new StringBuffer("/lib/");
+ buf.append(GccProcessor.getMachine());
+ buf.append('/');
+ buf.append(GccProcessor.getVersion());
+ buf.append("/include");
+ defaultInclude[0] = buf.toString();
+ //
+ // read specs file and look for -istart and -idirafter
+ //
+ String[] specs = GccProcessor.getSpecs();
+ String[][] optionValues = GccProcessor.parseSpecs(specs, "*cpp:",
+ new String[]{"-isystem ", "-idirafter "});
+ //
+ // if no entries were found, then use a default path
+ //
+ if (optionValues[0].length == 0 && optionValues[1].length == 0) {
+ optionValues[0] = new String[]{"/usr/local/include",
+ "/usr/include", "/usr/include/win32api"};
+ }
+ //
+ // remove mingw entries.
+ // For MinGW compiles this will mean the
+ // location of the sys includes will be
+ // wrong in dependencies.xml
+ // but that should have no significant effect
+ for (int i = 0; i < optionValues.length; i++) {
+ for (int j = 0; j < optionValues[i].length; j++) {
+ if (optionValues[i][j].indexOf("mingw") > 0) {
+ optionValues[i][j] = null;
+ }
+ }
+ }
+ //
+ // if cygwin then
+ // we have to prepend location of gcc32
+ // and .. to start of absolute filenames to
+ // have something that will exist in the
+ // windows filesystem
+ if (GccProcessor.isCygwin()) {
+ GccProcessor.convertCygwinFilenames(optionValues[0]);
+ GccProcessor.convertCygwinFilenames(optionValues[1]);
+ GccProcessor.convertCygwinFilenames(defaultInclude);
+ }
+ int count = CUtil.checkDirectoryArray(optionValues[0]);
+ count += CUtil.checkDirectoryArray(optionValues[1]);
+ count += CUtil.checkDirectoryArray(defaultInclude);
+ includePath = new File[count];
+ int index = 0;
+ for (int i = 0; i < optionValues.length; i++) {
+ for (int j = 0; j < optionValues[i].length; j++) {
+ if (optionValues[i][j] != null) {
+ includePath[index++] = new File(optionValues[i][j]);
+ }
+ }
+ }
+ for (int i = 0; i < defaultInclude.length; i++) {
+ if (defaultInclude[i] != null) {
+ includePath[index++] = new File(defaultInclude[i]);
+ }
+ }
+ }
+ return (File[]) includePath.clone();
+ }
+ public String getIdentifier() throws BuildException {
+ if (identifier == null) {
+ StringBuffer buf;
+ if (getLibtool()) {
+ buf = new StringBuffer("libtool ");
+ } else {
+ buf = new StringBuffer(' ');
+ }
+ buf.append(getCommand());
+ buf.append(' ');
+ buf.append(GccProcessor.getVersion());
+ buf.append(' ');
+ buf.append(GccProcessor.getMachine());
+ identifier = buf.toString();
+ }
+ return identifier;
+ }
+ public Linker getLinker(LinkType linkType) {
+ return GccLinker.getInstance().getLinker(linkType);
+ }
+ public int getMaximumCommandLength() {
+ return Integer.MAX_VALUE;
+ }
+ private void supercompile(CCTask task, File outputDir,
+ String[] sourceFiles, String[] args, String[] endArgs,
+ boolean relentless, CommandLineCompilerConfiguration config,
+ ProgressMonitor monitor) throws BuildException {
+ super.compile(task, outputDir, sourceFiles, args, endArgs, relentless,
+ config, monitor);
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/gcc/cross/GccLibrarian.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/gcc/cross/GccLibrarian.java
new file mode 100644
index 0000000000..ea2278a6e7
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/gcc/cross/GccLibrarian.java
@@ -0,0 +1,69 @@
+/*
+ *
+ * Copyright 2002-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.gcc.cross;
+import java.io.File;
+
+import net.sf.antcontrib.cpptasks.CCTask;
+import net.sf.antcontrib.cpptasks.LinkerParam;
+import net.sf.antcontrib.cpptasks.compiler.CommandLineLinkerConfiguration;
+import net.sf.antcontrib.cpptasks.compiler.LinkType;
+import net.sf.antcontrib.cpptasks.compiler.Linker;
+import net.sf.antcontrib.cpptasks.gcc.AbstractArLibrarian;
+
+import org.apache.tools.ant.BuildException;
+/**
+ * Adapter for the 'ar' archiver
+ *
+ * @author Adam Murdoch
+ */
+public final class GccLibrarian extends AbstractArLibrarian {
+ private static String[] objFileExtensions = new String[]{".o"};
+ private static GccLibrarian instance = new GccLibrarian("ar",
+ objFileExtensions, false, new GccLibrarian("ar", objFileExtensions,
+ true, null));
+ public static GccLibrarian getInstance() {
+ return instance;
+ }
+ private GccLibrarian(String command, String[] inputExtensions,
+ boolean isLibtool, GccLibrarian libtoolLibrarian) {
+ super(command, "V", inputExtensions, new String[0], "lib", ".a",
+ isLibtool, libtoolLibrarian);
+ }
+ protected Object clone() throws CloneNotSupportedException {
+ GccLibrarian clone = (GccLibrarian) super.clone();
+ return clone;
+ }
+ public Linker getLinker(LinkType type) {
+ return GccLinker.getInstance().getLinker(type);
+ }
+ public void link(CCTask task, File outputFile, String[] sourceFiles,
+ CommandLineLinkerConfiguration config) throws BuildException {
+ try {
+ GccLibrarian clone = (GccLibrarian) this.clone();
+ LinkerParam param = config.getParam("target");
+ if (param != null)
+ clone.setCommand(param.getValue() + "-" + this.getCommand());
+ clone.superlink(task, outputFile, sourceFiles, config);
+ } catch (CloneNotSupportedException e) {
+ superlink(task, outputFile, sourceFiles, config);
+ }
+ }
+ private void superlink(CCTask task, File outputFile, String[] sourceFiles,
+ CommandLineLinkerConfiguration config) throws BuildException {
+ super.link(task, outputFile, sourceFiles, config);
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/gcc/cross/GccLinker.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/gcc/cross/GccLinker.java
new file mode 100644
index 0000000000..3293829d13
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/gcc/cross/GccLinker.java
@@ -0,0 +1,234 @@
+/*
+ *
+ * Copyright 2001-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.gcc.cross;
+import java.io.File;
+import java.util.Vector;
+import net.sf.antcontrib.cpptasks.CCTask;
+import net.sf.antcontrib.cpptasks.CUtil;
+import net.sf.antcontrib.cpptasks.LinkerParam;
+import net.sf.antcontrib.cpptasks.compiler.CommandLineLinkerConfiguration;
+import net.sf.antcontrib.cpptasks.compiler.LinkType;
+import net.sf.antcontrib.cpptasks.compiler.Linker;
+import net.sf.antcontrib.cpptasks.gcc.AbstractLdLinker;
+import org.apache.tools.ant.BuildException;
+/**
+ * Adapter for the GCC linker
+ *
+ * @author Adam Murdoch
+ */
+public class GccLinker extends AbstractLdLinker {
+ private static final String[] discardFiles = new String[0];
+ private static final String[] objFiles = new String[]{".o", ".a", ".lib",
+ ".dll", ".so", ".sl"};
+ private static final GccLinker dllLinker = new GccLinker("gcc", objFiles,
+ discardFiles, "lib", ".so", false, new GccLinker("gcc", objFiles,
+ discardFiles, "lib", ".so", true, null));
+ private static final GccLinker instance = new GccLinker("gcc", objFiles,
+ discardFiles, "", "", false, null);
+ private static final String[] libtoolObjFiles = new String[]{".fo", ".a",
+ ".lib", ".dll", ".so", ".sl"};
+ private static String[] linkerOptions = new String[]{"-bundle",
+ "-dynamiclib", "-nostartfiles", "-nostdlib", "-prebind", "-s",
+ "-static", "-shared", "-symbolic", "-Xlinker",
+ "--export-all-symbols", "-static-libgcc",};
+ private static final GccLinker machBundleLinker = new GccLinker("gcc",
+ objFiles, discardFiles, "lib", ".bundle", false, null);
+ private static final GccLinker machDllLinker = new GccLinker("gcc",
+ objFiles, discardFiles, "lib", ".dylib", false, null);
+ public static GccLinker getInstance() {
+ return instance;
+ }
+ private File[] libDirs;
+ protected GccLinker(String command, String[] extensions,
+ String[] ignoredExtensions, String outputPrefix,
+ String outputSuffix, boolean isLibtool, GccLinker libtoolLinker) {
+ super(command, "-dumpversion", extensions, ignoredExtensions,
+ outputPrefix, outputSuffix, isLibtool, libtoolLinker);
+ }
+ protected void addImpliedArgs(boolean debug, LinkType linkType, Vector args, Boolean defaultflag) {
+ super.addImpliedArgs(debug, linkType, args, defaultflag);
+ if (getIdentifier().indexOf("mingw") >= 0) {
+ if (linkType.isSubsystemConsole()) {
+ args.addElement("-mconsole");
+ }
+ if (linkType.isSubsystemGUI()) {
+ args.addElement("-mwindows");
+ }
+ }
+ }
+ protected Object clone() throws CloneNotSupportedException {
+ GccLinker clone = (GccLinker) super.clone();
+ return clone;
+ }
+ /**
+ * Allows drived linker to decorate linker option. Override by GccLinker to
+ * prepend a "-Wl," to pass option to through gcc to linker.
+ *
+ * @param buf
+ * buffer that may be used and abused in the decoration process,
+ * must not be null.
+ * @param arg
+ * linker argument
+ */
+ public String decorateLinkerOption(StringBuffer buf, String arg) {
+ String decoratedArg = arg;
+ if (arg.length() > 1 && arg.charAt(0) == '-') {
+ switch (arg.charAt(1)) {
+ //
+ // passed automatically by GCC
+ //
+ case 'g' :
+ case 'f' :
+ case 'F' :
+ /* Darwin */
+ case 'm' :
+ case 'O' :
+ case 'W' :
+ case 'l' :
+ case 'L' :
+ case 'u' :
+ case 'v' :
+ break;
+ default :
+ boolean known = false;
+ for (int i = 0; i < linkerOptions.length; i++) {
+ if (linkerOptions[i].equals(arg)) {
+ known = true;
+ break;
+ }
+ }
+ if (!known) {
+ buf.setLength(0);
+ buf.append("-Wl,");
+ buf.append(arg);
+ decoratedArg = buf.toString();
+ }
+ break;
+ }
+ }
+ return decoratedArg;
+ }
+ /**
+ * Returns library path.
+ *
+ */
+ public File[] getLibraryPath() {
+ if (libDirs == null) {
+ //
+ // construct gcc lib path from machine and version
+ //
+ StringBuffer buf = new StringBuffer("/lib/gcc-lib/");
+ buf.append(GccProcessor.getMachine());
+ buf.append('/');
+ buf.append(GccProcessor.getVersion());
+ //
+ // build default path from gcc and system /lib and /lib/w32api
+ //
+ String[] impliedLibPath = new String[]{buf.toString(),
+ "/lib/w32api", "/lib"};
+ //
+ // read gcc specs file for other library paths
+ //
+ String[] specs = GccProcessor.getSpecs();
+ String[][] libpaths = GccProcessor.parseSpecs(specs, "*link:",
+ new String[]{"%q"});
+ String[] libpath;
+ if (libpaths[0].length > 0) {
+ libpath = new String[libpaths[0].length + 3];
+ int i = 0;
+ for (; i < libpaths[0].length; i++) {
+ libpath[i] = libpaths[0][i];
+ }
+ libpath[i++] = buf.toString();
+ libpath[i++] = "/lib/w32api";
+ libpath[i++] = "/lib";
+ } else {
+ //
+ // if a failure to find any matches then
+ // use some default values for lib path entries
+ libpath = new String[]{"/usr/local/lib/mingw",
+ "/usr/local/lib", "/usr/lib/w32api", "/usr/lib/mingw",
+ "/usr/lib", buf.toString(), "/lib/w32api", "/lib"};
+ }
+ for (int i = 0; i < libpath.length; i++) {
+ if (libpath[i].indexOf("mingw") >= 0) {
+ libpath[i] = null;
+ }
+ }
+ //
+ // if cygwin then
+ // we have to prepend location of gcc32
+ // and .. to start of absolute filenames to
+ // have something that will exist in the
+ // windows filesystem
+ if (GccProcessor.isCygwin()) {
+ GccProcessor.convertCygwinFilenames(libpath);
+ }
+ //
+ // check that remaining entries are actual directories
+ //
+ int count = CUtil.checkDirectoryArray(libpath);
+ //
+ // populate return array with remaining entries
+ //
+ libDirs = new File[count];
+ int index = 0;
+ for (int i = 0; i < libpath.length; i++) {
+ if (libpath[i] != null) {
+ libDirs[index++] = new File(libpath[i]);
+ }
+ }
+ }
+ return libDirs;
+ }
+ public Linker getLinker(LinkType type) {
+ if (type.isStaticLibrary()) {
+ return GccLibrarian.getInstance();
+ }
+ if (type.isPluginModule()) {
+ if (isDarwin()) {
+ return machBundleLinker;
+ } else {
+ return dllLinker;
+ }
+ }
+ if (type.isSharedLibrary()) {
+ if (isDarwin()) {
+ return machDllLinker;
+ } else {
+ return dllLinker;
+ }
+ }
+ return instance;
+ }
+ public void link(CCTask task, File outputFile, String[] sourceFiles,
+ CommandLineLinkerConfiguration config) throws BuildException {
+ try {
+ GccLinker clone = (GccLinker) this.clone();
+ LinkerParam param = config.getParam("target");
+ if (param != null)
+ clone.setCommand(param.getValue() + "-" + this.getCommand());
+ clone.superlink(task, outputFile, sourceFiles, config);
+ } catch (CloneNotSupportedException e) {
+ superlink(task, outputFile, sourceFiles, config);
+ }
+ }
+ private void superlink(CCTask task, File outputFile, String[] sourceFiles,
+ CommandLineLinkerConfiguration config) throws BuildException {
+ super.link(task, outputFile, sourceFiles, config);
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/gcc/cross/GccProcessor.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/gcc/cross/GccProcessor.java
new file mode 100644
index 0000000000..283df63314
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/gcc/cross/GccProcessor.java
@@ -0,0 +1,288 @@
+/*
+ *
+ * Copyright 2002-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.gcc.cross;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.Vector;
+
+import net.sf.antcontrib.cpptasks.CUtil;
+import net.sf.antcontrib.cpptasks.compiler.CaptureStreamHandler;
+
+/**
+ * A add-in class for Gcc processors
+ *
+ *
+ */
+public class GccProcessor {
+ // the results from gcc -dumpmachine
+ private static String machine;
+ private static String[] specs;
+ // the results from gcc -dumpversion
+ private static String version;
+ private static int addLibraryPatterns(String[] libnames, StringBuffer buf,
+ String prefix, String extension, String[] patterns, int offset) {
+ for (int i = 0; i < libnames.length; i++) {
+ buf.setLength(0);
+ buf.append(prefix);
+ buf.append(libnames[i]);
+ buf.append(extension);
+ patterns[offset + i] = buf.toString();
+ }
+ return offset + libnames.length;
+ }
+ /**
+ * Converts absolute Cygwin file or directory names to the corresponding
+ * Win32 name.
+ *
+ * @param names
+ * array of names, some elements may be null, will be changed in
+ * place.
+ */
+ public static void convertCygwinFilenames(String[] names) {
+ if (names == null) {
+ throw new NullPointerException("names");
+ }
+ File gccDir = CUtil.getExecutableLocation("gcc.exe");
+ if (gccDir != null) {
+ String prefix = gccDir.getAbsolutePath() + "/..";
+ StringBuffer buf = new StringBuffer();
+ for (int i = 0; i < names.length; i++) {
+ String name = names[i];
+ if (name != null && name.length() > 1 && name.charAt(0) == '/') {
+ buf.setLength(0);
+ buf.append(prefix);
+ buf.append(name);
+ names[i] = buf.toString();
+ }
+ }
+ }
+ }
+
+ public static String getMachine() {
+ if (machine == null) {
+ String[] args = new String[]{"gcc", "-dumpmachine"};
+ String[] cmdout = CaptureStreamHandler.run(args);
+ if (cmdout.length == 0) {
+ machine = "nomachine";
+ } else {
+ machine = cmdout[0];
+ }
+ }
+ return machine;
+ }
+ public static String[] getOutputFileSwitch(String letter, String outputFile) {
+ StringBuffer buf = new StringBuffer();
+ if (outputFile.indexOf(' ') >= 0) {
+ buf.append('"');
+ buf.append(outputFile.replace('\\', '/'));
+ buf.append('"');
+ } else {
+ buf.append(outputFile.replace('\\', '/'));
+ }
+ String[] retval = new String[]{letter, buf.toString()};
+ return retval;
+ }
+ /**
+ * Returns the contents of the gcc specs file.
+ *
+ * The implementation locates gcc.exe in the executable path and then
+ * builds a relative path name from the results of -dumpmachine and
+ * -dumpversion. Attempts to use gcc -dumpspecs to provide this information
+ * resulted in stalling on the Execute.run
+ *
+ * @returns contents of the specs file
+ */
+ public static String[] getSpecs() {
+ if (specs == null) {
+ File gccParent = CUtil.getExecutableLocation("gcc.exe");
+ if (gccParent != null) {
+ //
+ // build a relative path like
+ // ../lib/gcc-lib/i686-pc-cygwin/2.95.3-5/specs
+ //
+ StringBuffer buf = new StringBuffer("../lib/gcc-lib/");
+ buf.append(getMachine());
+ buf.append('/');
+ buf.append(getVersion());
+ buf.append("/specs");
+ //
+ // resolve it relative to the location of gcc.exe
+ //
+ String relativePath = buf.toString();
+ File specsFile = new File(gccParent, relativePath);
+ //
+ // found the specs file
+ //
+ try {
+ //
+ // read the lines in the file
+ //
+ BufferedReader reader = new BufferedReader(new FileReader(
+ specsFile));
+ Vector lines = new Vector(100);
+ String line = reader.readLine();
+ while (line != null) {
+ lines.addElement(line);
+ line = reader.readLine();
+ }
+ specs = new String[lines.size()];
+ lines.copyInto(specs);
+ } catch (IOException ex) {
+ }
+ }
+ }
+ if (specs == null) {
+ specs = new String[0];
+ }
+ return specs;
+ }
+ public static String getVersion() {
+ if (version == null) {
+ String[] args = new String[]{"gcc", "-dumpversion"};
+ String[] cmdout = CaptureStreamHandler.run(args);
+ if (cmdout.length == 0) {
+ version = "noversion";
+ } else {
+ version = cmdout[0];
+ }
+ }
+ return version;
+ }
+ public static boolean isCaseSensitive() {
+ return true;
+ }
+ /**
+ * Determines if task is running with cygwin
+ *
+ * @return true if cygwin was detected
+ */
+ public static boolean isCygwin() {
+ return getMachine().indexOf("cygwin") > 0;
+ }
+ private static boolean isHPUX() {
+ String osname = System.getProperty("os.name").toLowerCase();
+ if (osname.indexOf("hp") >= 0 && osname.indexOf("ux") >= 0) {
+ return true;
+ }
+ return false;
+ }
+ /**
+ *
+ * Parses the results of the specs file for a specific processor and
+ * options
+ *
+ * @param specsContent
+ * Contents of specs file as returned from getSpecs
+ * @param specSectionStart
+ * start of spec section, for example "*cpp:"
+ * @param options
+ * command line switches such as "-istart"
+ */
+ public static String[][] parseSpecs(String[] specsContent,
+ String specSectionStart, String[] options) {
+ if (specsContent == null) {
+ throw new NullPointerException("specsContent");
+ }
+ if (specSectionStart == null) {
+ throw new NullPointerException("specSectionStart");
+ }
+ if (options == null) {
+ throw new NullPointerException("option");
+ }
+ String[][] optionValues = new String[options.length][];
+ StringBuffer optionValue = new StringBuffer(40);
+ for (int i = 0; i < specsContent.length; i++) {
+ String specLine = specsContent[i];
+ //
+ // if start of section then start paying attention
+ //
+ if (specLine.startsWith(specSectionStart)) {
+ Vector[] optionVectors = new Vector[options.length];
+ for (int j = 0; j < options.length; j++) {
+ optionVectors[j] = new Vector(10);
+ }
+ //
+ // go to next line and examine contents
+ // and repeat until end of file
+ //
+ for (i++; i < specsContent.length; i++) {
+ specLine = specsContent[i];
+ for (int j = 0; j < options.length; j++) {
+ int optionStart = specLine.indexOf(options[j]);
+ while (optionStart >= 0) {
+ optionValue.setLength(0);
+ //
+ // walk rest of line looking for first non
+ // whitespace
+ // and then next space
+ boolean hasNonBlank = false;
+ int k = optionStart + options[j].length();
+ for (; k < specLine.length(); k++) {
+ //
+ // either a blank or a "}" (close of
+ // conditional)
+ // section will end the path
+ //
+ if (specLine.charAt(k) == ' '
+ || specLine.charAt(k) == '}') {
+ if (hasNonBlank) {
+ break;
+ }
+ } else {
+ hasNonBlank = true;
+ optionValue.append(specLine.charAt(k));
+ }
+ }
+ //
+ // transition back to whitespace
+ // value is over, add it to vector
+ if (hasNonBlank) {
+ optionVectors[j].addElement(optionValue
+ .toString());
+ }
+ //
+ // find next occurance on line
+ //
+ optionStart = specLine.indexOf(options[j], k);
+ }
+ }
+ }
+ //
+ // copy vectors over to option arrays
+ //
+ for (int j = 0; j < options.length; j++) {
+ optionValues[j] = new String[optionVectors[j].size()];
+ optionVectors[j].copyInto(optionValues[j]);
+ }
+ }
+ }
+ //
+ // fill in any missing option values with
+ // a zero-length string array
+ for (int i = 0; i < optionValues.length; i++) {
+ String[] zeroLenArray = new String[0];
+ if (optionValues[i] == null) {
+ optionValues[i] = zeroLenArray;
+ }
+ }
+ return optionValues;
+ }
+ private GccProcessor() {
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/gcc/cross/GppLinker.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/gcc/cross/GppLinker.java
new file mode 100644
index 0000000000..3ba8f06bf8
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/gcc/cross/GppLinker.java
@@ -0,0 +1,228 @@
+/*
+ *
+ * Copyright 2003-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.gcc.cross;
+import java.io.File;
+import java.util.Vector;
+
+import net.sf.antcontrib.cpptasks.CCTask;
+import net.sf.antcontrib.cpptasks.CUtil;
+import net.sf.antcontrib.cpptasks.LinkerParam;
+import net.sf.antcontrib.cpptasks.compiler.CaptureStreamHandler;
+import net.sf.antcontrib.cpptasks.compiler.CommandLineLinkerConfiguration;
+import net.sf.antcontrib.cpptasks.compiler.LinkType;
+import net.sf.antcontrib.cpptasks.compiler.Linker;
+import net.sf.antcontrib.cpptasks.gcc.AbstractLdLinker;
+import net.sf.antcontrib.cpptasks.types.LibrarySet;
+
+import org.apache.tools.ant.BuildException;
+/**
+ * Adapter for the g++ variant of the GCC linker
+ *
+ * @author Stephen M. Webb
+ */
+public class GppLinker extends AbstractLdLinker {
+ protected static final String[] discardFiles = new String[0];
+ protected static final String[] objFiles = new String[]{".o", ".a", ".lib",
+ ".dll", ".so", ".sl"};
+ private static final GppLinker dllLinker = new GppLinker("gcc", objFiles,
+ discardFiles, "lib", ".so", false, new GppLinker("gcc", objFiles,
+ discardFiles, "lib", ".so", true, null));
+ private final static String libPrefix = "libraries: =";
+ protected static final String[] libtoolObjFiles = new String[]{".fo", ".a",
+ ".lib", ".dll", ".so", ".sl"};
+ private static String[] linkerOptions = new String[]{"-bundle", "-dylib",
+ "-dynamic", "-dynamiclib", "-nostartfiles", "-nostdlib",
+ "-prebind", "-s", "-static", "-shared", "-symbolic", "-Xlinker"};
+ private static final GppLinker instance = new GppLinker("gcc", objFiles,
+ discardFiles, "", "", false, null);
+ private static final GppLinker machDllLinker = new GppLinker("gcc",
+ objFiles, discardFiles, "lib", ".dylib", false, null);
+ private static final GppLinker machPluginLinker = new GppLinker("gcc",
+ objFiles, discardFiles, "lib", ".bundle", false, null);
+ public static GppLinker getInstance() {
+ return instance;
+ }
+ private File[] libDirs;
+ private String runtimeLibrary;
+ protected GppLinker(String command, String[] extensions,
+ String[] ignoredExtensions, String outputPrefix,
+ String outputSuffix, boolean isLibtool, GppLinker libtoolLinker) {
+ super(command, "-dumpversion", extensions, ignoredExtensions,
+ outputPrefix, outputSuffix, isLibtool, libtoolLinker);
+ }
+ protected void addImpliedArgs(boolean debug, LinkType linkType, Vector args, Boolean defaultflag) {
+ super.addImpliedArgs(debug, linkType, args, defaultflag);
+ if (getIdentifier().indexOf("mingw") >= 0) {
+ if (linkType.isSubsystemConsole()) {
+ args.addElement("-mconsole");
+ }
+ if (linkType.isSubsystemGUI()) {
+ args.addElement("-mwindows");
+ }
+ }
+ if (linkType.isStaticRuntime()) {
+ String[] cmdin = new String[]{"g++", "-print-file-name=libstdc++.a"};
+ String[] cmdout = CaptureStreamHandler.run(cmdin);
+ if (cmdout.length > 0) {
+ runtimeLibrary = cmdout[0];
+ } else {
+ runtimeLibrary = null;
+ }
+ } else {
+ runtimeLibrary = "-lstdc++";
+ }
+ }
+ public String[] addLibrarySets(CCTask task, LibrarySet[] libsets,
+ Vector preargs, Vector midargs, Vector endargs) {
+ String[] rs = super.addLibrarySets(task, libsets, preargs, midargs,
+ endargs);
+ if (runtimeLibrary != null) {
+ endargs.addElement(runtimeLibrary);
+ }
+ return rs;
+ }
+ protected Object clone() throws CloneNotSupportedException {
+ GppLinker clone = (GppLinker) super.clone();
+ return clone;
+ }
+ /**
+ * Allows drived linker to decorate linker option. Override by GppLinker to
+ * prepend a "-Wl," to pass option to through gcc to linker.
+ *
+ * @param buf
+ * buffer that may be used and abused in the decoration process,
+ * must not be null.
+ * @param arg
+ * linker argument
+ */
+ public String decorateLinkerOption(StringBuffer buf, String arg) {
+ String decoratedArg = arg;
+ if (arg.length() > 1 && arg.charAt(0) == '-') {
+ switch (arg.charAt(1)) {
+ //
+ // passed automatically by GCC
+ //
+ case 'g' :
+ case 'f' :
+ case 'F' :
+ /* Darwin */
+ case 'm' :
+ case 'O' :
+ case 'W' :
+ case 'l' :
+ case 'L' :
+ case 'u' :
+ break;
+ default :
+ boolean known = false;
+ for (int i = 0; i < linkerOptions.length; i++) {
+ if (linkerOptions[i].equals(arg)) {
+ known = true;
+ break;
+ }
+ }
+ if (!known) {
+ buf.setLength(0);
+ buf.append("-Wl,");
+ buf.append(arg);
+ decoratedArg = buf.toString();
+ }
+ break;
+ }
+ }
+ return decoratedArg;
+ }
+ /**
+ * Returns library path.
+ *
+ */
+ public File[] getLibraryPath() {
+ if (libDirs == null) {
+ Vector dirs = new Vector();
+ // Ask GCC where it will look for its libraries.
+ String[] args = new String[]{"g++", "-print-search-dirs"};
+ String[] cmdout = CaptureStreamHandler.run(args);
+ for (int i = 0; i < cmdout.length; ++i) {
+ int prefixIndex = cmdout[i].indexOf(libPrefix);
+ if (prefixIndex >= 0) {
+ // Special case DOS-type GCCs like MinGW or Cygwin
+ int s = prefixIndex + libPrefix.length();
+ int t = cmdout[i].indexOf(';', s);
+ while (t > 0) {
+ dirs.addElement(cmdout[i].substring(s, t));
+ s = t + 1;
+ t = cmdout[i].indexOf(';', s);
+ }
+ dirs.addElement(cmdout[i].substring(s));
+ ++i;
+ for (; i < cmdout.length; ++i) {
+ dirs.addElement(cmdout[i]);
+ }
+ }
+ }
+ // Eliminate all but actual directories.
+ String[] libpath = new String[dirs.size()];
+ dirs.copyInto(libpath);
+ int count = CUtil.checkDirectoryArray(libpath);
+ // Build return array.
+ libDirs = new File[count];
+ int index = 0;
+ for (int i = 0; i < libpath.length; ++i) {
+ if (libpath[i] != null) {
+ libDirs[index++] = new File(libpath[i]);
+ }
+ }
+ }
+ return libDirs;
+ }
+ public Linker getLinker(LinkType type) {
+ if (type.isStaticLibrary()) {
+ return GccLibrarian.getInstance();
+ }
+ if (type.isPluginModule()) {
+ if (GccProcessor.getMachine().indexOf("darwin") >= 0) {
+ return machPluginLinker;
+ } else {
+ return dllLinker;
+ }
+ }
+ if (type.isSharedLibrary()) {
+ if (GccProcessor.getMachine().indexOf("darwin") >= 0) {
+ return machDllLinker;
+ } else {
+ return dllLinker;
+ }
+ }
+ return instance;
+ }
+ public void link(CCTask task, File outputFile, String[] sourceFiles,
+ CommandLineLinkerConfiguration config) throws BuildException {
+ try {
+ GppLinker clone = (GppLinker) this.clone();
+ LinkerParam param = config.getParam("target");
+ if (param != null)
+ clone.setCommand(param.getValue() + "-" + this.getCommand());
+ clone.superlink(task, outputFile, sourceFiles, config);
+ } catch (CloneNotSupportedException e) {
+ superlink(task, outputFile, sourceFiles, config);
+ }
+ }
+ private void superlink(CCTask task, File outputFile, String[] sourceFiles,
+ CommandLineLinkerConfiguration config) throws BuildException {
+ super.link(task, outputFile, sourceFiles, config);
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/gcc/cross/LdLinker.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/gcc/cross/LdLinker.java
new file mode 100644
index 0000000000..8ac0cf82a7
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/gcc/cross/LdLinker.java
@@ -0,0 +1,83 @@
+/*
+ *
+ * Copyright 2001-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.gcc.cross;
+import java.io.File;
+
+import net.sf.antcontrib.cpptasks.CCTask;
+import net.sf.antcontrib.cpptasks.LinkerParam;
+import net.sf.antcontrib.cpptasks.compiler.CommandLineLinkerConfiguration;
+import net.sf.antcontrib.cpptasks.compiler.LinkType;
+import net.sf.antcontrib.cpptasks.compiler.Linker;
+import net.sf.antcontrib.cpptasks.gcc.AbstractLdLinker;
+
+import org.apache.tools.ant.BuildException;
+/**
+ * Adapter for the 'ld' linker
+ *
+ * @author Curt Arnold
+ */
+public final class LdLinker extends AbstractLdLinker {
+ private static final String[] libtoolObjFiles = new String[]{".fo", ".a",
+ ".lib", ".dll", ".so", ".sl"};
+ private static final String[] objFiles = new String[]{".o", ".a", ".lib",
+ ".dll", ".so", ".sl"};
+ private static final String[] discardFiles = new String[0];
+ private static final LdLinker dllLinker = new LdLinker("ld", objFiles,
+ discardFiles, "lib", ".so", false, new LdLinker("ld", objFiles,
+ discardFiles, "lib", ".so", true, null));
+ private static final LdLinker instance = new LdLinker("ld", objFiles,
+ discardFiles, "", "", false, null);
+ public static LdLinker getInstance() {
+ return instance;
+ }
+ private File[] libDirs;
+ private LdLinker(String command, String[] extensions,
+ String[] ignoredExtensions, String outputPrefix,
+ String outputSuffix, boolean isLibtool, LdLinker libtoolLinker) {
+ super(command, "-version", extensions, ignoredExtensions, outputPrefix,
+ outputSuffix, isLibtool, libtoolLinker);
+ }
+ protected Object clone() throws CloneNotSupportedException {
+ LdLinker clone = (LdLinker) super.clone();
+ return clone;
+ }
+ public Linker getLinker(LinkType type) {
+ if (type.isStaticLibrary()) {
+ return GccLibrarian.getInstance();
+ }
+ if (type.isSharedLibrary()) {
+ return dllLinker;
+ }
+ return instance;
+ }
+ public void link(CCTask task, File outputFile, String[] sourceFiles,
+ CommandLineLinkerConfiguration config) throws BuildException {
+ try {
+ LdLinker clone = (LdLinker) this.clone();
+ LinkerParam param = config.getParam("target");
+ if (param != null)
+ clone.setCommand(param.getValue() + "-" + this.getCommand());
+ clone.superlink(task, outputFile, sourceFiles, config);
+ } catch (CloneNotSupportedException e) {
+ superlink(task, outputFile, sourceFiles, config);
+ }
+ }
+ private void superlink(CCTask task, File outputFile, String[] sourceFiles,
+ CommandLineLinkerConfiguration config) throws BuildException {
+ super.link(task, outputFile, sourceFiles, config);
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/gcc/cross/sparc_sun_solaris2/GccCCompiler.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/gcc/cross/sparc_sun_solaris2/GccCCompiler.java
new file mode 100644
index 0000000000..62d65b910c
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/gcc/cross/sparc_sun_solaris2/GccCCompiler.java
@@ -0,0 +1,245 @@
+/*
+ *
+ * Copyright 2001-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.gcc.cross.sparc_sun_solaris2;
+import java.io.File;
+import java.util.Vector;
+
+import net.sf.antcontrib.cpptasks.CUtil;
+import net.sf.antcontrib.cpptasks.compiler.LinkType;
+import net.sf.antcontrib.cpptasks.compiler.Linker;
+import net.sf.antcontrib.cpptasks.compiler.Processor;
+import net.sf.antcontrib.cpptasks.gcc.GccCompatibleCCompiler;
+import net.sf.antcontrib.cpptasks.parser.CParser;
+import net.sf.antcontrib.cpptasks.parser.FortranParser;
+import net.sf.antcontrib.cpptasks.parser.Parser;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.types.Environment;
+import net.sf.antcontrib.cpptasks.OptimizationEnum;
+
+/**
+ * Adapter for the GCC C/C++ compiler
+ *
+ * @author Adam Murdoch
+ */
+public final class GccCCompiler extends GccCompatibleCCompiler {
+ private final static String[] sourceExtensions = new String[]{".c", /* C */
+ ".cc", /* C++ */
+ ".cpp", /* C++ */
+ ".cxx", /* C++ */
+ ".c++", /* C++ */
+ ".i", /* preprocessed C */
+ ".ii", /* preprocessed C++ */
+ ".f", /* FORTRAN */
+ ".for", /* FORTRAN */
+ ".m", /* Objective-C */
+ ".mm", /* Objected-C++ */
+ ".s" /* Assembly */
+ };
+ private final static String[] headerExtensions = new String[]{".h", ".hpp",
+ ".inl"};
+ public static final String CMD_PREFIX = "sparc-sun-solaris2-";
+ private static final GccCCompiler cppInstance = new GccCCompiler(CMD_PREFIX
+ + "c++", sourceExtensions, headerExtensions, false,
+ new GccCCompiler(CMD_PREFIX + "c++", sourceExtensions,
+ headerExtensions, true, null, false, null), false, null);
+ private static final GccCCompiler g77Instance = new GccCCompiler(CMD_PREFIX
+ + "g77", sourceExtensions, headerExtensions, false,
+ new GccCCompiler(CMD_PREFIX + "g77", sourceExtensions,
+ headerExtensions, true, null, false, null), false, null);
+ private static final GccCCompiler gppInstance = new GccCCompiler(CMD_PREFIX
+ + "g++", sourceExtensions, headerExtensions, false,
+ new GccCCompiler(CMD_PREFIX + "g++", sourceExtensions,
+ headerExtensions, true, null, false, null), false, null);
+ private static final GccCCompiler instance = new GccCCompiler(CMD_PREFIX
+ + "gcc", sourceExtensions, headerExtensions, false,
+ new GccCCompiler(CMD_PREFIX + "gcc", sourceExtensions,
+ headerExtensions, true, null, false, null), false, null);
+ /**
+ * Gets c++ adapter
+ */
+ public static GccCCompiler getCppInstance() {
+ return cppInstance;
+ }
+ /**
+ * Gets g77 adapter
+ */
+ public static GccCCompiler getG77Instance() {
+ return g77Instance;
+ }
+ /**
+ * Gets gpp adapter
+ */
+ public static GccCCompiler getGppInstance() {
+ return gppInstance;
+ }
+ /**
+ * Gets gcc adapter
+ */
+ public static GccCCompiler getInstance() {
+ return instance;
+ }
+ private String identifier;
+ private File[] includePath;
+ private boolean isPICMeaningful = true;
+ /**
+ * Private constructor. Use GccCCompiler.getInstance() to get singleton
+ * instance of this class.
+ */
+ private GccCCompiler(String command, String[] sourceExtensions,
+ String[] headerExtensions, boolean isLibtool,
+ GccCCompiler libtoolCompiler, boolean newEnvironment,
+ Environment env) {
+ super(command, null, sourceExtensions, headerExtensions, isLibtool,
+ libtoolCompiler, newEnvironment, env);
+ isPICMeaningful = System.getProperty("os.name").indexOf("Windows") < 0;
+ }
+ public void addImpliedArgs(final Vector args,
+ final boolean debug,
+ final boolean multithreaded,
+ final boolean exceptions,
+ final LinkType linkType,
+ final Boolean rtti,
+ final OptimizationEnum optimization,
+ final Boolean defaultflag) {
+ super.addImpliedArgs(args, debug, multithreaded,
+ exceptions, linkType, rtti, optimization, defaultflag);
+ if (isPICMeaningful && linkType.isSharedLibrary()) {
+ args.addElement("-fPIC");
+ }
+ }
+ public Processor changeEnvironment(boolean newEnvironment, Environment env) {
+ if (newEnvironment || env != null) {
+ return new GccCCompiler(getCommand(), this.getSourceExtensions(),
+ this.getHeaderExtensions(), this.getLibtool(),
+ (GccCCompiler) this.getLibtoolCompiler(), newEnvironment,
+ env);
+ }
+ return this;
+ }
+ /**
+ * Create parser to determine dependencies.
+ *
+ * Will create appropriate parser (C++, FORTRAN) based on file extension.
+ *
+ */
+ protected Parser createParser(File source) {
+ if (source != null) {
+ String sourceName = source.getName();
+ int lastDot = sourceName.lastIndexOf('.');
+ if (lastDot >= 0 && lastDot + 1 < sourceName.length()) {
+ char afterDot = sourceName.charAt(lastDot + 1);
+ if (afterDot == 'f' || afterDot == 'F') {
+ return new FortranParser();
+ }
+ }
+ }
+ return new CParser();
+ }
+ public File[] getEnvironmentIncludePath() {
+ if (includePath == null) {
+ //
+ // construct default include path from machine id and version id
+ //
+ String[] defaultInclude = new String[1];
+ StringBuffer buf = new StringBuffer("/lib/");
+ buf.append(GccProcessor.getMachine());
+ buf.append('/');
+ buf.append(GccProcessor.getVersion());
+ buf.append("/include");
+ defaultInclude[0] = buf.toString();
+ //
+ // read specs file and look for -istart and -idirafter
+ //
+ String[] specs = GccProcessor.getSpecs();
+ String[][] optionValues = GccProcessor.parseSpecs(specs, "*cpp:",
+ new String[]{"-isystem ", "-idirafter "});
+ //
+ // if no entries were found, then use a default path
+ //
+ if (optionValues[0].length == 0 && optionValues[1].length == 0) {
+ optionValues[0] = new String[]{"/usr/local/include",
+ "/usr/include", "/usr/include/win32api"};
+ }
+ //
+ // remove mingw entries.
+ // For MinGW compiles this will mean the
+ // location of the sys includes will be
+ // wrong in dependencies.xml
+ // but that should have no significant effect
+ for (int i = 0; i < optionValues.length; i++) {
+ for (int j = 0; j < optionValues[i].length; j++) {
+ if (optionValues[i][j].indexOf("mingw") > 0) {
+ optionValues[i][j] = null;
+ }
+ }
+ }
+ //
+ // if cygwin then
+ // we have to prepend location of gcc32
+ // and .. to start of absolute filenames to
+ // have something that will exist in the
+ // windows filesystem
+ if (GccProcessor.isCygwin()) {
+ GccProcessor.convertCygwinFilenames(optionValues[0]);
+ GccProcessor.convertCygwinFilenames(optionValues[1]);
+ GccProcessor.convertCygwinFilenames(defaultInclude);
+ }
+ int count = CUtil.checkDirectoryArray(optionValues[0]);
+ count += CUtil.checkDirectoryArray(optionValues[1]);
+ count += CUtil.checkDirectoryArray(defaultInclude);
+ includePath = new File[count];
+ int index = 0;
+ for (int i = 0; i < optionValues.length; i++) {
+ for (int j = 0; j < optionValues[i].length; j++) {
+ if (optionValues[i][j] != null) {
+ includePath[index++] = new File(optionValues[i][j]);
+ }
+ }
+ }
+ for (int i = 0; i < defaultInclude.length; i++) {
+ if (defaultInclude[i] != null) {
+ includePath[index++] = new File(defaultInclude[i]);
+ }
+ }
+ }
+ return (File[]) includePath.clone();
+ }
+ public String getIdentifier() throws BuildException {
+ if (identifier == null) {
+ StringBuffer buf;
+ if (getLibtool()) {
+ buf = new StringBuffer("libtool ");
+ } else {
+ buf = new StringBuffer(' ');
+ }
+ buf.append(getCommand());
+ buf.append(' ');
+ buf.append(GccProcessor.getVersion());
+ buf.append(' ');
+ buf.append(GccProcessor.getMachine());
+ identifier = buf.toString();
+ }
+ return identifier;
+ }
+ public Linker getLinker(LinkType linkType) {
+ return GccLinker.getInstance().getLinker(linkType);
+ }
+ public int getMaximumCommandLength() {
+ return Integer.MAX_VALUE;
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/gcc/cross/sparc_sun_solaris2/GccLibrarian.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/gcc/cross/sparc_sun_solaris2/GccLibrarian.java
new file mode 100644
index 0000000000..bb243879af
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/gcc/cross/sparc_sun_solaris2/GccLibrarian.java
@@ -0,0 +1,43 @@
+/*
+ *
+ * Copyright 2002-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.gcc.cross.sparc_sun_solaris2;
+import net.sf.antcontrib.cpptasks.compiler.LinkType;
+import net.sf.antcontrib.cpptasks.compiler.Linker;
+import net.sf.antcontrib.cpptasks.gcc.AbstractArLibrarian;
+/**
+ * Adapter for the 'ar' archiver
+ *
+ * @author Adam Murdoch
+ */
+public final class GccLibrarian extends AbstractArLibrarian {
+ private static String[] objFileExtensions = new String[]{".o"};
+ private static GccLibrarian instance = new GccLibrarian(
+ GccCCompiler.CMD_PREFIX + "ar", objFileExtensions, false,
+ new GccLibrarian(GccCCompiler.CMD_PREFIX + "ar", objFileExtensions,
+ true, null));
+ public static GccLibrarian getInstance() {
+ return instance;
+ }
+ private GccLibrarian(String command, String[] inputExtensions,
+ boolean isLibtool, GccLibrarian libtoolLibrarian) {
+ super(command, "V", inputExtensions, new String[0], "lib", ".a",
+ isLibtool, libtoolLibrarian);
+ }
+ public Linker getLinker(LinkType type) {
+ return GccLinker.getInstance().getLinker(type);
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/gcc/cross/sparc_sun_solaris2/GccLinker.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/gcc/cross/sparc_sun_solaris2/GccLinker.java
new file mode 100644
index 0000000000..914da34439
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/gcc/cross/sparc_sun_solaris2/GccLinker.java
@@ -0,0 +1,215 @@
+/*
+ *
+ * Copyright 2001-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.gcc.cross.sparc_sun_solaris2;
+import java.io.File;
+import java.util.Vector;
+
+import net.sf.antcontrib.cpptasks.CUtil;
+import net.sf.antcontrib.cpptasks.compiler.LinkType;
+import net.sf.antcontrib.cpptasks.compiler.Linker;
+import net.sf.antcontrib.cpptasks.gcc.AbstractLdLinker;
+/**
+ * Adapter for the GCC linker
+ *
+ * @author Adam Murdoch
+ */
+public class GccLinker extends AbstractLdLinker {
+ private static final String[] discardFiles = new String[0];
+ private static final String[] objFiles = new String[]{".o", ".a", ".lib",
+ ".dll", ".so", ".sl"};
+ private static final String[] libtoolObjFiles = new String[]{".fo", ".a",
+ ".lib", ".dll", ".so", ".sl"};
+ private static String[] linkerOptions = new String[]{"-bundle",
+ "-dynamiclib", "-nostartfiles", "-nostdlib", "-prebind", "-s",
+ "-static", "-shared", "-symbolic", "-Xlinker",
+ "--export-all-symbols", "-static-libgcc",};
+ private static final GccLinker dllLinker = new GccLinker(
+ GccCCompiler.CMD_PREFIX + "gcc", objFiles, discardFiles, "lib",
+ ".so", false, new GccLinker(GccCCompiler.CMD_PREFIX + "gcc",
+ objFiles, discardFiles, "lib", ".so", true, null));
+ private static final GccLinker instance = new GccLinker(
+ GccCCompiler.CMD_PREFIX + "gcc", objFiles, discardFiles, "", "",
+ false, null);
+ private static final GccLinker machBundleLinker = new GccLinker(
+ GccCCompiler.CMD_PREFIX + "gcc", objFiles, discardFiles, "lib",
+ ".bundle", false, null);
+ private static final GccLinker machDllLinker = new GccLinker(
+ GccCCompiler.CMD_PREFIX + "gcc", objFiles, discardFiles, "lib",
+ ".dylib", false, null);
+ public static GccLinker getInstance() {
+ return instance;
+ }
+ private File[] libDirs;
+ protected GccLinker(String command, String[] extensions,
+ String[] ignoredExtensions, String outputPrefix,
+ String outputSuffix, boolean isLibtool, GccLinker libtoolLinker) {
+ super(command, "-dumpversion", extensions, ignoredExtensions,
+ outputPrefix, outputSuffix, isLibtool, libtoolLinker);
+ }
+ protected void addImpliedArgs(boolean debug, LinkType linkType, Vector args, Boolean defaultflag) {
+ super.addImpliedArgs(debug, linkType, args, defaultflag);
+ if (getIdentifier().indexOf("mingw") >= 0) {
+ if (linkType.isSubsystemConsole()) {
+ args.addElement("-mconsole");
+ }
+ if (linkType.isSubsystemGUI()) {
+ args.addElement("-mwindows");
+ }
+ }
+ }
+ /**
+ * Allows drived linker to decorate linker option. Override by GccLinker to
+ * prepend a "-Wl," to pass option to through gcc to linker.
+ *
+ * @param buf
+ * buffer that may be used and abused in the decoration process,
+ * must not be null.
+ * @param arg
+ * linker argument
+ */
+ public String decorateLinkerOption(StringBuffer buf, String arg) {
+ String decoratedArg = arg;
+ if (arg.length() > 1 && arg.charAt(0) == '-') {
+ switch (arg.charAt(1)) {
+ //
+ // passed automatically by GCC
+ //
+ case 'g' :
+ case 'f' :
+ case 'F' :
+ /* Darwin */
+ case 'm' :
+ case 'O' :
+ case 'W' :
+ case 'l' :
+ case 'L' :
+ case 'u' :
+ case 'v' :
+ break;
+ default :
+ boolean known = false;
+ for (int i = 0; i < linkerOptions.length; i++) {
+ if (linkerOptions[i].equals(arg)) {
+ known = true;
+ break;
+ }
+ }
+ if (!known) {
+ buf.setLength(0);
+ buf.append("-Wl,");
+ buf.append(arg);
+ decoratedArg = buf.toString();
+ }
+ break;
+ }
+ }
+ return decoratedArg;
+ }
+ /**
+ * Returns library path.
+ *
+ */
+ public File[] getLibraryPath() {
+ if (libDirs == null) {
+ //
+ // construct gcc lib path from machine and version
+ //
+ StringBuffer buf = new StringBuffer("/lib/gcc-lib/");
+ buf.append(GccProcessor.getMachine());
+ buf.append('/');
+ buf.append(GccProcessor.getVersion());
+ //
+ // build default path from gcc and system /lib and /lib/w32api
+ //
+ String[] impliedLibPath = new String[]{buf.toString(),
+ "/lib/w32api", "/lib"};
+ //
+ // read gcc specs file for other library paths
+ //
+ String[] specs = GccProcessor.getSpecs();
+ String[][] libpaths = GccProcessor.parseSpecs(specs, "*link:",
+ new String[]{"%q"});
+ String[] libpath;
+ if (libpaths[0].length > 0) {
+ libpath = new String[libpaths[0].length + 3];
+ int i = 0;
+ for (; i < libpaths[0].length; i++) {
+ libpath[i] = libpaths[0][i];
+ }
+ libpath[i++] = buf.toString();
+ libpath[i++] = "/lib/w32api";
+ libpath[i++] = "/lib";
+ } else {
+ //
+ // if a failure to find any matches then
+ // use some default values for lib path entries
+ libpath = new String[]{"/usr/local/lib/mingw",
+ "/usr/local/lib", "/usr/lib/w32api", "/usr/lib/mingw",
+ "/usr/lib", buf.toString(), "/lib/w32api", "/lib"};
+ }
+ for (int i = 0; i < libpath.length; i++) {
+ if (libpath[i].indexOf("mingw") >= 0) {
+ libpath[i] = null;
+ }
+ }
+ //
+ // if cygwin then
+ // we have to prepend location of gcc32
+ // and .. to start of absolute filenames to
+ // have something that will exist in the
+ // windows filesystem
+ if (GccProcessor.isCygwin()) {
+ GccProcessor.convertCygwinFilenames(libpath);
+ }
+ //
+ // check that remaining entries are actual directories
+ //
+ int count = CUtil.checkDirectoryArray(libpath);
+ //
+ // populate return array with remaining entries
+ //
+ libDirs = new File[count];
+ int index = 0;
+ for (int i = 0; i < libpath.length; i++) {
+ if (libpath[i] != null) {
+ libDirs[index++] = new File(libpath[i]);
+ }
+ }
+ }
+ return libDirs;
+ }
+ public Linker getLinker(LinkType type) {
+ if (type.isStaticLibrary()) {
+ return GccLibrarian.getInstance();
+ }
+ if (type.isPluginModule()) {
+ if (isDarwin()) {
+ return machBundleLinker;
+ } else {
+ return dllLinker;
+ }
+ }
+ if (type.isSharedLibrary()) {
+ if (isDarwin()) {
+ return machDllLinker;
+ } else {
+ return dllLinker;
+ }
+ }
+ return instance;
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/gcc/cross/sparc_sun_solaris2/GccProcessor.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/gcc/cross/sparc_sun_solaris2/GccProcessor.java
new file mode 100644
index 0000000000..599d6a8013
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/gcc/cross/sparc_sun_solaris2/GccProcessor.java
@@ -0,0 +1,305 @@
+/*
+ *
+ * Copyright 2002-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.gcc.cross.sparc_sun_solaris2;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.Vector;
+
+import net.sf.antcontrib.cpptasks.CUtil;
+import net.sf.antcontrib.cpptasks.compiler.CaptureStreamHandler;
+import net.sf.antcontrib.cpptasks.types.LibraryTypeEnum;
+
+/**
+ * A add-in class for Gcc processors
+ *
+ *
+ */
+public class GccProcessor {
+ // the results from gcc -dumpmachine
+ private static String machine;
+ private static String[] specs;
+ // the results from gcc -dumpversion
+ private static String version;
+ private static int addLibraryPatterns(String[] libnames, StringBuffer buf,
+ String prefix, String extension, String[] patterns, int offset) {
+ for (int i = 0; i < libnames.length; i++) {
+ buf.setLength(0);
+ buf.append(prefix);
+ buf.append(libnames[i]);
+ buf.append(extension);
+ patterns[offset + i] = buf.toString();
+ }
+ return offset + libnames.length;
+ }
+ /**
+ * Converts absolute Cygwin file or directory names to the corresponding
+ * Win32 name.
+ *
+ * @param names
+ * array of names, some elements may be null, will be changed in
+ * place.
+ */
+ public static void convertCygwinFilenames(String[] names) {
+ if (names == null) {
+ throw new NullPointerException("names");
+ }
+ File gccDir = CUtil.getExecutableLocation(GccCCompiler.CMD_PREFIX
+ + "gcc.exe");
+ if (gccDir != null) {
+ String prefix = gccDir.getAbsolutePath() + "/..";
+ StringBuffer buf = new StringBuffer();
+ for (int i = 0; i < names.length; i++) {
+ String name = names[i];
+ if (name != null && name.length() > 1 && name.charAt(0) == '/') {
+ buf.setLength(0);
+ buf.append(prefix);
+ buf.append(name);
+ names[i] = buf.toString();
+ }
+ }
+ }
+ }
+ public static String[] getLibraryPatterns(String[] libnames, LibraryTypeEnum libType) {
+ StringBuffer buf = new StringBuffer();
+ String[] patterns = new String[libnames.length * 2];
+ int offset = addLibraryPatterns(libnames, buf, "lib", ".a", patterns, 0);
+ if (isHPUX()) {
+ offset = addLibraryPatterns(libnames, buf, "lib", ".sl", patterns,
+ offset);
+ } else {
+ offset = addLibraryPatterns(libnames, buf, "lib", ".so", patterns,
+ offset);
+ }
+ return patterns;
+ }
+ public static String getMachine() {
+ if (machine == null) {
+ String[] args = new String[]{GccCCompiler.CMD_PREFIX + "gcc",
+ "-dumpmachine"};
+ String[] cmdout = CaptureStreamHandler.run(args);
+ if (cmdout.length == 0) {
+ machine = "nomachine";
+ } else {
+ machine = cmdout[0];
+ }
+ }
+ return machine;
+ }
+ public static String[] getOutputFileSwitch(String letter, String outputFile) {
+ StringBuffer buf = new StringBuffer();
+ if (outputFile.indexOf(' ') >= 0) {
+ buf.append('"');
+ buf.append(outputFile.replace('\\', '/'));
+ buf.append('"');
+ } else {
+ buf.append(outputFile.replace('\\', '/'));
+ }
+ String[] retval = new String[]{letter, buf.toString()};
+ return retval;
+ }
+ /**
+ * Returns the contents of the gcc specs file.
+ *
+ * The implementation locates gcc.exe in the executable path and then
+ * builds a relative path name from the results of -dumpmachine and
+ * -dumpversion. Attempts to use gcc -dumpspecs to provide this information
+ * resulted in stalling on the Execute.run
+ *
+ * @returns contents of the specs file
+ */
+ public static String[] getSpecs() {
+ if (specs == null) {
+ File gccParent = CUtil
+ .getExecutableLocation(GccCCompiler.CMD_PREFIX + "gcc.exe");
+ if (gccParent != null) {
+ //
+ // build a relative path like
+ // ../lib/gcc-lib/i686-pc-cygwin/2.95.3-5/specs
+ //
+ StringBuffer buf = new StringBuffer("../lib/gcc-lib/");
+ buf.append(getMachine());
+ buf.append('/');
+ buf.append(getVersion());
+ buf.append("/specs");
+ //
+ // resolve it relative to the location of gcc.exe
+ //
+ String relativePath = buf.toString();
+ File specsFile = new File(gccParent, relativePath);
+ //
+ // found the specs file
+ //
+ try {
+ //
+ // read the lines in the file
+ //
+ BufferedReader reader = new BufferedReader(new FileReader(
+ specsFile));
+ Vector lines = new Vector(100);
+ String line = reader.readLine();
+ while (line != null) {
+ lines.addElement(line);
+ line = reader.readLine();
+ }
+ specs = new String[lines.size()];
+ lines.copyInto(specs);
+ } catch (IOException ex) {
+ }
+ }
+ }
+ if (specs == null) {
+ specs = new String[0];
+ }
+ return specs;
+ }
+ public static String getVersion() {
+ if (version == null) {
+ String[] args = new String[]{GccCCompiler.CMD_PREFIX + "gcc",
+ "-dumpversion"};
+ String[] cmdout = CaptureStreamHandler.run(args);
+ if (cmdout.length == 0) {
+ version = "noversion";
+ } else {
+ version = cmdout[0];
+ }
+ }
+ return version;
+ }
+ public static boolean isCaseSensitive() {
+ return true;
+ }
+ /**
+ * Determines if task is running with cygwin
+ *
+ * @return true if cygwin was detected
+ */
+ public static boolean isCygwin() {
+ return getMachine().indexOf("cygwin") > 0;
+ }
+ private static boolean isHPUX() {
+ String osname = System.getProperty("os.name").toLowerCase();
+ if (osname.indexOf("hp") >= 0 && osname.indexOf("ux") >= 0) {
+ return true;
+ }
+ return false;
+ }
+ /**
+ *
+ * Parses the results of the specs file for a specific processor and
+ * options
+ *
+ * @param specsContent
+ * Contents of specs file as returned from getSpecs
+ * @param specSectionStart
+ * start of spec section, for example "*cpp:"
+ * @param options
+ * command line switches such as "-istart"
+ */
+ public static String[][] parseSpecs(String[] specsContent,
+ String specSectionStart, String[] options) {
+ if (specsContent == null) {
+ throw new NullPointerException("specsContent");
+ }
+ if (specSectionStart == null) {
+ throw new NullPointerException("specSectionStart");
+ }
+ if (options == null) {
+ throw new NullPointerException("option");
+ }
+ String[][] optionValues = new String[options.length][];
+ StringBuffer optionValue = new StringBuffer(40);
+ for (int i = 0; i < specsContent.length; i++) {
+ String specLine = specsContent[i];
+ //
+ // if start of section then start paying attention
+ //
+ if (specLine.startsWith(specSectionStart)) {
+ Vector[] optionVectors = new Vector[options.length];
+ for (int j = 0; j < options.length; j++) {
+ optionVectors[j] = new Vector(10);
+ }
+ //
+ // go to next line and examine contents
+ // and repeat until end of file
+ //
+ for (i++; i < specsContent.length; i++) {
+ specLine = specsContent[i];
+ for (int j = 0; j < options.length; j++) {
+ int optionStart = specLine.indexOf(options[j]);
+ while (optionStart >= 0) {
+ optionValue.setLength(0);
+ //
+ // walk rest of line looking for first non
+ // whitespace
+ // and then next space
+ boolean hasNonBlank = false;
+ int k = optionStart + options[j].length();
+ for (; k < specLine.length(); k++) {
+ //
+ // either a blank or a "}" (close of
+ // conditional)
+ // section will end the path
+ //
+ if (specLine.charAt(k) == ' '
+ || specLine.charAt(k) == '}') {
+ if (hasNonBlank) {
+ break;
+ }
+ } else {
+ hasNonBlank = true;
+ optionValue.append(specLine.charAt(k));
+ }
+ }
+ //
+ // transition back to whitespace
+ // value is over, add it to vector
+ if (hasNonBlank) {
+ optionVectors[j].addElement(optionValue
+ .toString());
+ }
+ //
+ // find next occurance on line
+ //
+ optionStart = specLine.indexOf(options[j], k);
+ }
+ }
+ }
+ //
+ // copy vectors over to option arrays
+ //
+ for (int j = 0; j < options.length; j++) {
+ optionValues[j] = new String[optionVectors[j].size()];
+ optionVectors[j].copyInto(optionValues[j]);
+ }
+ }
+ }
+ //
+ // fill in any missing option values with
+ // a zero-length string array
+ for (int i = 0; i < optionValues.length; i++) {
+ String[] zeroLenArray = new String[0];
+ if (optionValues[i] == null) {
+ optionValues[i] = zeroLenArray;
+ }
+ }
+ return optionValues;
+ }
+ private GccProcessor() {
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/gcc/cross/sparc_sun_solaris2/GppLinker.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/gcc/cross/sparc_sun_solaris2/GppLinker.java
new file mode 100644
index 0000000000..6a4c0ab14b
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/gcc/cross/sparc_sun_solaris2/GppLinker.java
@@ -0,0 +1,210 @@
+/*
+ *
+ * Copyright 2003-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.gcc.cross.sparc_sun_solaris2;
+import java.io.File;
+import java.util.Vector;
+
+import net.sf.antcontrib.cpptasks.CCTask;
+import net.sf.antcontrib.cpptasks.CUtil;
+import net.sf.antcontrib.cpptasks.compiler.CaptureStreamHandler;
+import net.sf.antcontrib.cpptasks.compiler.LinkType;
+import net.sf.antcontrib.cpptasks.compiler.Linker;
+import net.sf.antcontrib.cpptasks.gcc.AbstractLdLinker;
+import net.sf.antcontrib.cpptasks.types.LibrarySet;
+/**
+ * Adapter for the g++ variant of the GCC linker
+ *
+ * @author Stephen M. Webb
+ */
+public class GppLinker extends AbstractLdLinker {
+ protected static final String[] discardFiles = new String[0];
+ protected static final String[] objFiles = new String[]{".o", ".a", ".lib",
+ ".dll", ".so", ".sl"};
+ private final static String libPrefix = "libraries: =";
+ protected static final String[] libtoolObjFiles = new String[]{".fo", ".a",
+ ".lib", ".dll", ".so", ".sl"};
+ private static String[] linkerOptions = new String[]{"-bundle", "-dylib",
+ "-dynamic", "-dynamiclib", "-nostartfiles", "-nostdlib",
+ "-prebind", "-s", "-static", "-shared", "-symbolic", "-Xlinker"};
+ private static final GppLinker dllLinker = new GppLinker(
+ GccCCompiler.CMD_PREFIX + "gcc", objFiles, discardFiles, "lib",
+ ".so", false, new GppLinker(GccCCompiler.CMD_PREFIX + "gcc",
+ objFiles, discardFiles, "lib", ".so", true, null));
+ private static final GppLinker instance = new GppLinker(
+ GccCCompiler.CMD_PREFIX + "gcc", objFiles, discardFiles, "", "",
+ false, null);
+ private static final GppLinker machDllLinker = new GppLinker(
+ GccCCompiler.CMD_PREFIX + "gcc", objFiles, discardFiles, "lib",
+ ".dylib", false, null);
+ private static final GppLinker machPluginLinker = new GppLinker(
+ GccCCompiler.CMD_PREFIX + "gcc", objFiles, discardFiles, "lib",
+ ".bundle", false, null);
+ public static GppLinker getInstance() {
+ return instance;
+ }
+ private File[] libDirs;
+ private String runtimeLibrary;
+ protected GppLinker(String command, String[] extensions,
+ String[] ignoredExtensions, String outputPrefix,
+ String outputSuffix, boolean isLibtool, GppLinker libtoolLinker) {
+ super(command, "-dumpversion", extensions, ignoredExtensions,
+ outputPrefix, outputSuffix, isLibtool, libtoolLinker);
+ }
+ protected void addImpliedArgs(boolean debug, LinkType linkType, Vector args, Boolean defaultflag) {
+ super.addImpliedArgs(debug, linkType, args, defaultflag);
+ if (getIdentifier().indexOf("mingw") >= 0) {
+ if (linkType.isSubsystemConsole()) {
+ args.addElement("-mconsole");
+ }
+ if (linkType.isSubsystemGUI()) {
+ args.addElement("-mwindows");
+ }
+ }
+ if (linkType.isStaticRuntime()) {
+ String[] cmdin = new String[]{GccCCompiler.CMD_PREFIX + "g++",
+ "-print-file-name=libstdc++.a"};
+ String[] cmdout = CaptureStreamHandler.run(cmdin);
+ if (cmdout.length > 0) {
+ runtimeLibrary = cmdout[0];
+ } else {
+ runtimeLibrary = null;
+ }
+ } else {
+ runtimeLibrary = "-lstdc++";
+ }
+ }
+ public String[] addLibrarySets(CCTask task, LibrarySet[] libsets,
+ Vector preargs, Vector midargs, Vector endargs) {
+ String[] rs = super.addLibrarySets(task, libsets, preargs, midargs,
+ endargs);
+ if (runtimeLibrary != null) {
+ endargs.addElement(runtimeLibrary);
+ }
+ return rs;
+ }
+ /**
+ * Allows drived linker to decorate linker option. Override by GppLinker to
+ * prepend a "-Wl," to pass option to through gcc to linker.
+ *
+ * @param buf
+ * buffer that may be used and abused in the decoration process,
+ * must not be null.
+ * @param arg
+ * linker argument
+ */
+ public String decorateLinkerOption(StringBuffer buf, String arg) {
+ String decoratedArg = arg;
+ if (arg.length() > 1 && arg.charAt(0) == '-') {
+ switch (arg.charAt(1)) {
+ //
+ // passed automatically by GCC
+ //
+ case 'g' :
+ case 'f' :
+ case 'F' :
+ /* Darwin */
+ case 'm' :
+ case 'O' :
+ case 'W' :
+ case 'l' :
+ case 'L' :
+ case 'u' :
+ break;
+ default :
+ boolean known = false;
+ for (int i = 0; i < linkerOptions.length; i++) {
+ if (linkerOptions[i].equals(arg)) {
+ known = true;
+ break;
+ }
+ }
+ if (!known) {
+ buf.setLength(0);
+ buf.append("-Wl,");
+ buf.append(arg);
+ decoratedArg = buf.toString();
+ }
+ break;
+ }
+ }
+ return decoratedArg;
+ }
+ /**
+ * Returns library path.
+ *
+ */
+ public File[] getLibraryPath() {
+ if (libDirs == null) {
+ Vector dirs = new Vector();
+ // Ask GCC where it will look for its libraries.
+ String[] args = new String[]{GccCCompiler.CMD_PREFIX + "g++",
+ "-print-search-dirs"};
+ String[] cmdout = CaptureStreamHandler.run(args);
+ for (int i = 0; i < cmdout.length; ++i) {
+ int prefixIndex = cmdout[i].indexOf(libPrefix);
+ if (prefixIndex >= 0) {
+ // Special case DOS-type GCCs like MinGW or Cygwin
+ int s = prefixIndex + libPrefix.length();
+ int t = cmdout[i].indexOf(';', s);
+ while (t > 0) {
+ dirs.addElement(cmdout[i].substring(s, t));
+ s = t + 1;
+ t = cmdout[i].indexOf(';', s);
+ }
+ dirs.addElement(cmdout[i].substring(s));
+ ++i;
+ for (; i < cmdout.length; ++i) {
+ dirs.addElement(cmdout[i]);
+ }
+ }
+ }
+ // Eliminate all but actual directories.
+ String[] libpath = new String[dirs.size()];
+ dirs.copyInto(libpath);
+ int count = CUtil.checkDirectoryArray(libpath);
+ // Build return array.
+ libDirs = new File[count];
+ int index = 0;
+ for (int i = 0; i < libpath.length; ++i) {
+ if (libpath[i] != null) {
+ libDirs[index++] = new File(libpath[i]);
+ }
+ }
+ }
+ return libDirs;
+ }
+ public Linker getLinker(LinkType type) {
+ if (type.isStaticLibrary()) {
+ return GccLibrarian.getInstance();
+ }
+ if (type.isPluginModule()) {
+ if (GccProcessor.getMachine().indexOf("darwin") >= 0) {
+ return machPluginLinker;
+ } else {
+ return dllLinker;
+ }
+ }
+ if (type.isSharedLibrary()) {
+ if (GccProcessor.getMachine().indexOf("darwin") >= 0) {
+ return machDllLinker;
+ } else {
+ return dllLinker;
+ }
+ }
+ return instance;
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/gcc/cross/sparc_sun_solaris2/LdLinker.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/gcc/cross/sparc_sun_solaris2/LdLinker.java
new file mode 100644
index 0000000000..fc7761e87c
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/gcc/cross/sparc_sun_solaris2/LdLinker.java
@@ -0,0 +1,60 @@
+/*
+ *
+ * Copyright 2001-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.gcc.cross.sparc_sun_solaris2;
+import java.io.File;
+
+import net.sf.antcontrib.cpptasks.compiler.LinkType;
+import net.sf.antcontrib.cpptasks.compiler.Linker;
+import net.sf.antcontrib.cpptasks.gcc.AbstractLdLinker;
+/**
+ * Adapter for the 'ld' linker
+ *
+ * @author Curt Arnold
+ */
+public final class LdLinker extends AbstractLdLinker {
+ private static final String[] discardFiles = new String[0];
+ private static final String[] libtoolObjFiles = new String[]{".fo", ".a",
+ ".lib", ".dll", ".so", ".sl"};
+ private static final String[] objFiles = new String[]{".o", ".a", ".lib",
+ ".dll", ".so", ".sl"};
+ private static final LdLinker dllLinker = new LdLinker(
+ GccCCompiler.CMD_PREFIX + "ld", objFiles, discardFiles, "lib",
+ ".so", false, new LdLinker(GccCCompiler.CMD_PREFIX + "ld",
+ objFiles, discardFiles, "lib", ".so", true, null));
+ private static final LdLinker instance = new LdLinker(
+ GccCCompiler.CMD_PREFIX + "ld", objFiles, discardFiles, "", "",
+ false, null);
+ public static LdLinker getInstance() {
+ return instance;
+ }
+ private File[] libDirs;
+ private LdLinker(String command, String[] extensions,
+ String[] ignoredExtensions, String outputPrefix,
+ String outputSuffix, boolean isLibtool, LdLinker libtoolLinker) {
+ super(command, "-version", extensions, ignoredExtensions, outputPrefix,
+ outputSuffix, isLibtool, libtoolLinker);
+ }
+ public Linker getLinker(LinkType type) {
+ if (type.isStaticLibrary()) {
+ return GccLibrarian.getInstance();
+ }
+ if (type.isSharedLibrary()) {
+ return dllLinker;
+ }
+ return instance;
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/hp/aCCCompiler.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/hp/aCCCompiler.java
new file mode 100644
index 0000000000..951bfc1a75
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/hp/aCCCompiler.java
@@ -0,0 +1,104 @@
+/*
+ *
+ * Copyright 2001-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.hp;
+import java.io.File;
+import java.util.Vector;
+
+import net.sf.antcontrib.cpptasks.CUtil;
+import net.sf.antcontrib.cpptasks.compiler.LinkType;
+import net.sf.antcontrib.cpptasks.compiler.Linker;
+import net.sf.antcontrib.cpptasks.gcc.GccCompatibleCCompiler;
+import net.sf.antcontrib.cpptasks.OptimizationEnum;
+
+import org.apache.tools.ant.types.Environment;
+/**
+ * Adapter for the HP aC++ C++ compiler
+ *
+ * @author Curt Arnold
+ */
+public final class aCCCompiler extends GccCompatibleCCompiler {
+ private static final aCCCompiler instance = new aCCCompiler("aCC", false,
+ null);
+ /**
+ * Gets singleton instance of this class
+ */
+ public static aCCCompiler getInstance() {
+ return instance;
+ }
+ private String identifier;
+ private File[] includePath;
+ /**
+ * Private constructor. Use GccCCompiler.getInstance() to get singleton
+ * instance of this class.
+ */
+ private aCCCompiler(String command, boolean newEnvironment, Environment env) {
+ super(command, "-help", false, null, newEnvironment, env);
+ }
+ public void addImpliedArgs(Vector args, boolean debug,
+ boolean multithreaded, boolean exceptions, LinkType linkType,
+ final Boolean rtti,
+ final OptimizationEnum optimization) {
+ args.addElement("-c");
+ if (debug) {
+ args.addElement("-g");
+ }
+ /*
+ * if (multithreaded) { args.addElement("-mt"); }
+ */
+ if (linkType.isSharedLibrary()) {
+ args.addElement("+z");
+ }
+ }
+ public void addWarningSwitch(Vector args, int level) {
+ switch (level) {
+ case 0 :
+ args.addElement("-w");
+ break;
+ case 1 :
+ case 2 :
+ args.addElement("+w");
+ break;
+ /*
+ * case 3: case 4: case 5: args.addElement("+w2"); break;
+ */
+ }
+ }
+ public File[] getEnvironmentIncludePath() {
+ if (includePath == null) {
+ File ccLoc = CUtil.getExecutableLocation("aCC");
+ if (ccLoc != null) {
+ File compilerIncludeDir = new File(
+ new File(ccLoc, "../include").getAbsolutePath());
+ if (compilerIncludeDir.exists()) {
+ includePath = new File[2];
+ includePath[0] = compilerIncludeDir;
+ }
+ }
+ if (includePath == null) {
+ includePath = new File[1];
+ }
+ includePath[includePath.length - 1] = new File("/usr/include");
+ }
+ return includePath;
+ }
+ public Linker getLinker(LinkType linkType) {
+ return aCCLinker.getInstance().getLinker(linkType);
+ }
+ public int getMaximumCommandLength() {
+ return Integer.MAX_VALUE;
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/hp/aCCLinker.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/hp/aCCLinker.java
new file mode 100644
index 0000000000..86b22e0522
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/hp/aCCLinker.java
@@ -0,0 +1,100 @@
+/*
+ *
+ * Copyright 2001-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.hp;
+import java.io.File;
+import java.util.Vector;
+
+import net.sf.antcontrib.cpptasks.CUtil;
+import net.sf.antcontrib.cpptasks.compiler.LinkType;
+import net.sf.antcontrib.cpptasks.compiler.Linker;
+import net.sf.antcontrib.cpptasks.gcc.AbstractLdLinker;
+/**
+ * Adapter for Sun (r) Forte(tm) C++ Linker
+ *
+ * @author Curt Arnold
+ */
+public final class aCCLinker extends AbstractLdLinker {
+ private static final String[] discardFiles = new String[0];
+ private static final String[] objFiles = new String[]{".o", ".a", ".lib",
+ ".dll", ".so", ".sl"};
+ private static final aCCLinker arLinker = new aCCLinker("aCC", objFiles,
+ discardFiles, "", ".a");
+ private static final aCCLinker dllLinker = new aCCLinker("aCC", objFiles,
+ discardFiles, "lib", ".sl");
+ private static final aCCLinker instance = new aCCLinker("aCC", objFiles,
+ discardFiles, "", "");
+ public static aCCLinker getInstance() {
+ return instance;
+ }
+ private File[] libDirs;
+ private aCCLinker(String command, String[] extensions,
+ String[] ignoredExtensions, String outputPrefix, String outputSuffix) {
+ super(command, "-help", extensions, ignoredExtensions, outputPrefix,
+ outputSuffix, false, null);
+ }
+ public void addImpliedArgs(boolean debug, LinkType linkType, Vector args) {
+ if (debug) {
+ args.addElement("-g");
+ }
+ /*
+ * if(linkType.isStaticRuntime()) { args.addElement("-static"); }
+ */
+ if (linkType.isSharedLibrary()) {
+ args.addElement("-b");
+ }
+ /*
+ * if (linkType.isStaticLibrary()) { args.addElement("-Wl,-noshared"); }
+ */
+ }
+ public void addIncremental(boolean incremental, Vector args) {
+ /*
+ * if (incremental) { args.addElement("-xidlon"); } else {
+ * args.addElement("-xidloff"); }
+ */
+ }
+ /**
+ * Returns library path.
+ *
+ */
+ public File[] getLibraryPath() {
+ if (libDirs == null) {
+ File CCloc = CUtil.getExecutableLocation("aCC");
+ if (CCloc != null) {
+ File compilerLib = new File(new File(CCloc, "../lib")
+ .getAbsolutePath());
+ if (compilerLib.exists()) {
+ libDirs = new File[2];
+ libDirs[0] = compilerLib;
+ }
+ }
+ if (libDirs == null) {
+ libDirs = new File[1];
+ }
+ }
+ libDirs[libDirs.length - 1] = new File("/usr/lib");
+ return libDirs;
+ }
+ public Linker getLinker(LinkType type) {
+ if (type.isStaticLibrary()) {
+ return arLinker;
+ }
+ if (type.isSharedLibrary()) {
+ return dllLinker;
+ }
+ return instance;
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/ibm/VisualAgeCCompiler.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/ibm/VisualAgeCCompiler.java
new file mode 100644
index 0000000000..f181c0e3af
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/ibm/VisualAgeCCompiler.java
@@ -0,0 +1,111 @@
+/*
+ *
+ * Copyright 2001-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.ibm;
+import java.io.File;
+import java.util.Vector;
+
+import net.sf.antcontrib.cpptasks.compiler.LinkType;
+import net.sf.antcontrib.cpptasks.compiler.Linker;
+import net.sf.antcontrib.cpptasks.gcc.GccCompatibleCCompiler;
+import net.sf.antcontrib.cpptasks.OptimizationEnum;
+
+import org.apache.tools.ant.types.Environment;
+/**
+ * Adapter for the IBM(r) Visual Age(tm) C++ compiler for AIX(tm)
+ *
+ * @author Curt Arnold
+ */
+public final class VisualAgeCCompiler extends GccCompatibleCCompiler {
+ private static final VisualAgeCCompiler instance = new VisualAgeCCompiler(
+ "xlC", false, null);
+ /**
+ * Gets singleton instance of this class
+ */
+ public static VisualAgeCCompiler getInstance() {
+ return instance;
+ }
+ private String identifier;
+ private File[] includePath;
+ /**
+ * Private constructor. Use getInstance() to get singleton instance of this
+ * class.
+ */
+ private VisualAgeCCompiler(String command, boolean newEnvironment,
+ Environment env) {
+ super(command, "-help", false, null, newEnvironment, env);
+ }
+ public void addImpliedArgs(final Vector args,
+ final boolean debug,
+ final boolean multithreaded,
+ final boolean exceptions,
+ final LinkType linkType,
+ final Boolean rtti,
+ final OptimizationEnum optimization) {
+ args.addElement("-c");
+ if (debug) {
+ args.addElement("-g");
+ }
+ if (linkType.isSharedLibrary()) {
+ args.addElement("-fpic");
+ }
+ if (rtti != null) {
+ if (rtti.booleanValue()) {
+ args.addElement("-qrtti=all");
+ } else {
+ args.addElement("-qnortti");
+ }
+ }
+ }
+ public void addWarningSwitch(Vector args, int level) {
+ switch (level) {
+ case 0 :
+ args.addElement("-w");
+ break;
+ case 1 :
+ args.addElement("-qflag=s:s");
+ break;
+ case 2 :
+ args.addElement("-qflag=e:e");
+ break;
+ case 3 :
+ args.addElement("-qflag=w:w");
+ break;
+ case 4 :
+ args.addElement("-qflag=i:i");
+ break;
+ case 5 :
+ args.addElement("-qhalt=w:w");
+ break;
+ }
+ }
+ public Linker getLinker(LinkType linkType) {
+ return VisualAgeLinker.getInstance().getLinker(linkType);
+ }
+ public int getMaximumCommandLength() {
+ return Integer.MAX_VALUE;
+ }
+ /**
+ * Gets identifier for the compiler.
+ *
+ * Initial attempt at extracting version information
+ * would lock up. Using a stock response.
+ */
+ public String getIdentifier() {
+ return "VisualAge compiler - unidentified version";
+ }
+
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/ibm/VisualAgeLinker.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/ibm/VisualAgeLinker.java
new file mode 100644
index 0000000000..f0a811b4ea
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/ibm/VisualAgeLinker.java
@@ -0,0 +1,75 @@
+/*
+ *
+ * Copyright 2001-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.ibm;
+import java.util.Vector;
+
+import net.sf.antcontrib.cpptasks.compiler.LinkType;
+import net.sf.antcontrib.cpptasks.compiler.Linker;
+import net.sf.antcontrib.cpptasks.gcc.AbstractLdLinker;
+import net.sf.antcontrib.cpptasks.gcc.GccLibrarian;
+/**
+ * Adapter for IBM(r) Visual Age(tm) Linker for AIX(tm)
+ *
+ * @author Curt Arnold
+ */
+public final class VisualAgeLinker extends AbstractLdLinker {
+ private static final String[] discardFiles = new String[]{};
+ private static final String[] objFiles = new String[]{".o", ".a", ".lib",
+ ".dll", ".so", ".sl"};
+ private static final VisualAgeLinker dllLinker = new VisualAgeLinker(
+ "makeC++SharedLib", objFiles, discardFiles, "lib", ".so");
+ private static final VisualAgeLinker instance = new VisualAgeLinker("xlC",
+ objFiles, discardFiles, "", "");
+ public static VisualAgeLinker getInstance() {
+ return instance;
+ }
+ private VisualAgeLinker(String command, String[] extensions,
+ String[] ignoredExtensions, String outputPrefix, String outputSuffix) {
+ //
+ // just guessing that -? might display something useful
+ //
+ super(command, "-?", extensions, ignoredExtensions, outputPrefix,
+ outputSuffix, false, null);
+ }
+ public void addImpliedArgs(boolean debug, LinkType linkType, Vector args) {
+ if (debug) {
+ //args.addElement("-g");
+ }
+ if (linkType.isSharedLibrary()) {
+ //args.addElement("-G");
+ }
+ }
+ public Linker getLinker(LinkType type) {
+ if (type.isStaticLibrary()) {
+ return GccLibrarian.getInstance();
+ }
+ if (type.isSharedLibrary()) {
+ return dllLinker;
+ }
+ return instance;
+ }
+ /**
+ * Gets identifier for the compiler.
+ *
+ * Initial attempt at extracting version information
+ * would lock up. Using a stock response.
+ */
+ public String getIdentifier() {
+ return "VisualAge linker - unidentified version";
+ }
+
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/intel/IntelLinux32CCompiler.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/intel/IntelLinux32CCompiler.java
new file mode 100644
index 0000000000..65402f41fb
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/intel/IntelLinux32CCompiler.java
@@ -0,0 +1,58 @@
+/*
+ *
+ * Copyright 2002-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.intel;
+import net.sf.antcontrib.cpptasks.compiler.LinkType;
+import net.sf.antcontrib.cpptasks.compiler.Linker;
+import net.sf.antcontrib.cpptasks.compiler.Processor;
+import net.sf.antcontrib.cpptasks.gcc.GccCompatibleCCompiler;
+
+import org.apache.tools.ant.types.Environment;
+/**
+ * Adapter for the Intel (r) C/C++ compiler for IA-32 Linux (r)
+ *
+ * The Intel (r) C/C++ compiler for IA32 Linux mimics the command options for
+ * gcc compiler.
+ *
+ * @author Curt Arnold
+ */
+public final class IntelLinux32CCompiler extends GccCompatibleCCompiler {
+ private static final IntelLinux32CCompiler instance = new IntelLinux32CCompiler(
+ false, new IntelLinux32CCompiler(true, null, false, null), false,
+ null);
+ public static IntelLinux32CCompiler getInstance() {
+ return instance;
+ }
+ private IntelLinux32CCompiler(boolean isLibtool,
+ IntelLinux32CCompiler libtoolCompiler, boolean newEnvironment,
+ Environment env) {
+ super("icc", "-V", isLibtool, libtoolCompiler, newEnvironment, env);
+ }
+ public Processor changeEnvironment(boolean newEnvironment, Environment env) {
+ if (newEnvironment || env != null) {
+ return new IntelLinux32CCompiler(getLibtool(),
+ (IntelLinux32CCompiler) getLibtoolCompiler(),
+ newEnvironment, env);
+ }
+ return this;
+ }
+ public Linker getLinker(LinkType type) {
+ return IntelLinux32Linker.getInstance().getLinker(type);
+ }
+ public int getMaximumCommandLength() {
+ return Integer.MAX_VALUE;
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/intel/IntelLinux32Linker.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/intel/IntelLinux32Linker.java
new file mode 100644
index 0000000000..268f490ff3
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/intel/IntelLinux32Linker.java
@@ -0,0 +1,55 @@
+/*
+ *
+ * Copyright 2002-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.intel;
+import net.sf.antcontrib.cpptasks.compiler.LinkType;
+import net.sf.antcontrib.cpptasks.compiler.Linker;
+import net.sf.antcontrib.cpptasks.gcc.AbstractLdLinker;
+import net.sf.antcontrib.cpptasks.gcc.GccLibrarian;
+/**
+ * Adapter for the Intel (r) Linker for Linux (r) for IA-32
+ *
+ * @author Curt Arnold
+ */
+public final class IntelLinux32Linker extends AbstractLdLinker {
+ private static final String[] discardFiles = new String[0];
+ private static final String[] libtoolObjFiles = new String[]{".fo", ".a",
+ ".lib", ".dll", ".so", ".sl"};
+ private static final String[] objFiles = new String[]{".o", ".a", ".lib",
+ ".dll", ".so", ".sl"};
+ private static final IntelLinux32Linker dllLinker = new IntelLinux32Linker(
+ "lib", ".so", false, new IntelLinux32Linker("lib", ".so", true,
+ null));
+ private static final IntelLinux32Linker instance = new IntelLinux32Linker(
+ "", "", false, null);
+ public static IntelLinux32Linker getInstance() {
+ return instance;
+ }
+ private IntelLinux32Linker(String outputPrefix, String outputSuffix,
+ boolean isLibtool, IntelLinux32Linker libtoolLinker) {
+ super("icc", "-V", objFiles, discardFiles, outputPrefix, outputSuffix,
+ isLibtool, libtoolLinker);
+ }
+ public Linker getLinker(LinkType type) {
+ if (type.isStaticLibrary()) {
+ return GccLibrarian.getInstance();
+ }
+ if (type.isSharedLibrary()) {
+ return dllLinker;
+ }
+ return instance;
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/intel/IntelLinux64CCompiler.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/intel/IntelLinux64CCompiler.java
new file mode 100644
index 0000000000..5a506e0d85
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/intel/IntelLinux64CCompiler.java
@@ -0,0 +1,58 @@
+/*
+ *
+ * Copyright 2002-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.intel;
+import net.sf.antcontrib.cpptasks.compiler.LinkType;
+import net.sf.antcontrib.cpptasks.compiler.Linker;
+import net.sf.antcontrib.cpptasks.compiler.Processor;
+import net.sf.antcontrib.cpptasks.gcc.GccCompatibleCCompiler;
+
+import org.apache.tools.ant.types.Environment;
+/**
+ * Adapter for the Intel (r) C/C++ compiler for IA-64 Linux (r)
+ *
+ * The Intel C/C++ compiler for IA-64 Linux mimics the command options for gcc
+ * compiler.
+ *
+ * @author Curt Arnold
+ */
+public final class IntelLinux64CCompiler extends GccCompatibleCCompiler {
+ private static final IntelLinux64CCompiler instance = new IntelLinux64CCompiler(
+ false, new IntelLinux64CCompiler(true, null, false, null), false,
+ null);
+ public static IntelLinux64CCompiler getInstance() {
+ return instance;
+ }
+ private IntelLinux64CCompiler(boolean isLibtool,
+ IntelLinux64CCompiler libtoolCompiler, boolean newEnvironment,
+ Environment env) {
+ super("ecc", "-V", isLibtool, libtoolCompiler, newEnvironment, env);
+ }
+ public Processor changeEnvironment(boolean newEnvironment, Environment env) {
+ if (newEnvironment || env != null) {
+ return new IntelLinux64CCompiler(getLibtool(),
+ (IntelLinux64CCompiler) this.getLibtoolCompiler(),
+ newEnvironment, env);
+ }
+ return this;
+ }
+ public Linker getLinker(LinkType type) {
+ return IntelLinux64Linker.getInstance().getLinker(type);
+ }
+ public int getMaximumCommandLength() {
+ return Integer.MAX_VALUE;
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/intel/IntelLinux64Linker.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/intel/IntelLinux64Linker.java
new file mode 100644
index 0000000000..f381403510
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/intel/IntelLinux64Linker.java
@@ -0,0 +1,55 @@
+/*
+ *
+ * Copyright 2002-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.intel;
+import net.sf.antcontrib.cpptasks.compiler.LinkType;
+import net.sf.antcontrib.cpptasks.compiler.Linker;
+import net.sf.antcontrib.cpptasks.gcc.AbstractLdLinker;
+import net.sf.antcontrib.cpptasks.gcc.GccLibrarian;
+/**
+ * Adapter for the Intel (r) linker for Linux for IA-64
+ *
+ * @author Curt Arnold
+ */
+public final class IntelLinux64Linker extends AbstractLdLinker {
+ private static final String[] discardFiles = new String[0];
+ private static final String[] libtoolObjFiles = new String[]{".fo", ".a",
+ ".lib", ".dll", ".so", ".sl"};
+ private static final String[] objFiles = new String[]{".o", ".a", ".lib",
+ ".dll", ".so", ".sl"};
+ private static final IntelLinux64Linker dllLinker = new IntelLinux64Linker(
+ "lib", ".so", false, new IntelLinux64Linker("lib", ".so", true,
+ null));
+ private static final IntelLinux64Linker instance = new IntelLinux64Linker(
+ "", "", false, null);
+ public static IntelLinux64Linker getInstance() {
+ return instance;
+ }
+ private IntelLinux64Linker(String outputPrefix, String outputSuffix,
+ boolean isLibtool, IntelLinux64Linker libtoolLinker) {
+ super("ecc", "-V", objFiles, discardFiles, outputPrefix, outputSuffix,
+ isLibtool, libtoolLinker);
+ }
+ public Linker getLinker(LinkType type) {
+ if (type.isStaticLibrary()) {
+ return GccLibrarian.getInstance();
+ }
+ if (type.isSharedLibrary()) {
+ return dllLinker;
+ }
+ return instance;
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/intel/IntelProcessor.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/intel/IntelProcessor.java
new file mode 100644
index 0000000000..d1b4eafec5
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/intel/IntelProcessor.java
@@ -0,0 +1,51 @@
+/*
+ *
+ * Copyright 2002-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.intel;
+import java.util.Vector;
+
+import net.sf.antcontrib.cpptasks.devstudio.DevStudioProcessor;
+/**
+ * A add-in class for Intel (r) compilers and linkers
+ *
+ *
+ */
+public class IntelProcessor {
+ public static void addWarningSwitch(Vector args, int level) {
+ DevStudioProcessor.addWarningSwitch(args, level);
+ }
+ public static String getCommandFileSwitch(String cmdFile) {
+ return DevStudioProcessor.getCommandFileSwitch(cmdFile);
+ }
+ public static void getDefineSwitch(StringBuffer buffer, String define,
+ String value) {
+ DevStudioProcessor.getDefineSwitch(buffer, define, value);
+ }
+ public static String getIncludeDirSwitch(String includeDir) {
+ return DevStudioProcessor.getIncludeDirSwitch(includeDir);
+ }
+ public static String[] getOutputFileSwitch(String outPath) {
+ return DevStudioProcessor.getOutputFileSwitch(outPath);
+ }
+ public static void getUndefineSwitch(StringBuffer buffer, String define) {
+ DevStudioProcessor.getUndefineSwitch(buffer, define);
+ }
+ public static boolean isCaseSensitive() {
+ return false;
+ }
+ private IntelProcessor() {
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/intel/IntelWin32Aslcompiler.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/intel/IntelWin32Aslcompiler.java
new file mode 100644
index 0000000000..5255cb90ce
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/intel/IntelWin32Aslcompiler.java
@@ -0,0 +1,66 @@
+/*
+ *
+ * Copyright 2001-2005 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.intel;
+
+import java.util.Vector;
+
+import net.sf.antcontrib.cpptasks.compiler.CommandLineAslcompiler;
+import net.sf.antcontrib.cpptasks.compiler.LinkType;
+import net.sf.antcontrib.cpptasks.compiler.Linker;
+import net.sf.antcontrib.cpptasks.devstudio.DevStudioLinker;
+/**
+ * Adapter for Intel ASL compiler
+ *
+ */
+public final class IntelWin32Aslcompiler extends CommandLineAslcompiler{
+ private final static String[] sourceExtensions = new String[]{".asl"};
+ private final static String[] headerExtensions = new String[]{};
+ private final static String[] defaultflags = new String[]{};
+ private static final IntelWin32Aslcompiler instance = new IntelWin32Aslcompiler("iasl",
+ sourceExtensions, headerExtensions, false);
+
+ /**
+ * Gets gcc adapter
+ */
+ public static IntelWin32Aslcompiler getInstance() {
+ return instance;
+ }
+
+ /**
+ * Private constructor. Use GccAssembler.getInstance() to get singleton
+ * instance of this class.
+ */
+ private IntelWin32Aslcompiler(String command, String[] sourceExtensions,
+ String[] headerExtensions, boolean isLibtool){
+ super(command, null, sourceExtensions, headerExtensions,
+ ".aml");
+ }
+ public void addImpliedArgs(Vector args, boolean debug,
+ Boolean defaultflag){
+ if (defaultflag != null && defaultflag.booleanValue()) {
+ for (int i = 0; i < defaultflags.length; i++) {
+ args.addElement(defaultflags[i]);
+ }
+ }
+ }
+ public int getMaximumCommandLength() {
+ return Integer.MAX_VALUE;
+ }
+ public Linker getLinker(LinkType linkType) {
+ return DevStudioLinker.getInstance().getLinker(linkType);
+ }
+}
\ No newline at end of file
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/intel/IntelWin32CCompiler.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/intel/IntelWin32CCompiler.java
new file mode 100644
index 0000000000..7aef79999f
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/intel/IntelWin32CCompiler.java
@@ -0,0 +1,53 @@
+/*
+ *
+ * Copyright 2002-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.intel;
+import net.sf.antcontrib.cpptasks.compiler.LinkType;
+import net.sf.antcontrib.cpptasks.compiler.Linker;
+import net.sf.antcontrib.cpptasks.compiler.Processor;
+import net.sf.antcontrib.cpptasks.devstudio.DevStudioCompatibleCCompiler;
+
+import org.apache.tools.ant.types.Environment;
+/**
+ * Adapter for the Intel (r) C++ compiler for 32-bit applications
+ *
+ * The Intel (r) C++ compiler for IA32 Windows mimics the command options for
+ * the Microsoft (r) C++ compiler.
+ *
+ * @author Curt Arnold
+ */
+public final class IntelWin32CCompiler extends DevStudioCompatibleCCompiler {
+ private static final IntelWin32CCompiler instance = new IntelWin32CCompiler(
+ false, null);
+ public static IntelWin32CCompiler getInstance() {
+ return instance;
+ }
+ private IntelWin32CCompiler(boolean newEnvironment, Environment env) {
+ super("icl", null, newEnvironment, env);
+ }
+ public Processor changeEnvironment(boolean newEnvironment, Environment env) {
+ if (newEnvironment || env != null) {
+ return new IntelWin32CCompiler(newEnvironment, env);
+ }
+ return this;
+ }
+ public Linker getLinker(LinkType type) {
+ return IntelWin32Linker.getInstance().getLinker(type);
+ }
+ public int getMaximumCommandLength() {
+ return 1024;
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/intel/IntelWin32Librarian.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/intel/IntelWin32Librarian.java
new file mode 100644
index 0000000000..e83da1ce0b
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/intel/IntelWin32Librarian.java
@@ -0,0 +1,38 @@
+/*
+ *
+ * Copyright 2002-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.intel;
+import net.sf.antcontrib.cpptasks.compiler.LinkType;
+import net.sf.antcontrib.cpptasks.compiler.Linker;
+import net.sf.antcontrib.cpptasks.devstudio.DevStudioCompatibleLibrarian;
+/**
+ * Adapter for the xilib from the Intel(r) C++ Compiler for IA-32 or IA-64
+ * systems running Microsoft (r) operating systems
+ *
+ * @author Curt Arnold
+ */
+public class IntelWin32Librarian extends DevStudioCompatibleLibrarian {
+ private static final IntelWin32Librarian instance = new IntelWin32Librarian();
+ public static IntelWin32Librarian getInstance() {
+ return instance;
+ }
+ protected IntelWin32Librarian() {
+ super("xilib", "/bogus");
+ }
+ public Linker getLinker(LinkType type) {
+ return IntelWin32Linker.getInstance().getLinker(type);
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/intel/IntelWin32Linker.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/intel/IntelWin32Linker.java
new file mode 100644
index 0000000000..51258e23ca
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/intel/IntelWin32Linker.java
@@ -0,0 +1,46 @@
+/*
+ *
+ * Copyright 2002-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.intel;
+import net.sf.antcontrib.cpptasks.compiler.LinkType;
+import net.sf.antcontrib.cpptasks.compiler.Linker;
+import net.sf.antcontrib.cpptasks.devstudio.DevStudioCompatibleLinker;
+/**
+ * Adapter for the Intel (r) linker for 32-bit applications
+ *
+ * @author Curt Arnold
+ */
+public final class IntelWin32Linker extends DevStudioCompatibleLinker {
+ private static final IntelWin32Linker dllLinker = new IntelWin32Linker(
+ ".dll");
+ private static final IntelWin32Linker instance = new IntelWin32Linker(
+ ".exe");
+ public static IntelWin32Linker getInstance() {
+ return instance;
+ }
+ private IntelWin32Linker(String outputSuffix) {
+ super("xilink", "/bogus", outputSuffix);
+ }
+ public Linker getLinker(LinkType type) {
+ if (type.isStaticLibrary()) {
+ return IntelWin32Librarian.getInstance();
+ }
+ if (type.isSharedLibrary()) {
+ return dllLinker;
+ }
+ return instance;
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/intel/IntelWin64CCompiler.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/intel/IntelWin64CCompiler.java
new file mode 100644
index 0000000000..9b8d2c9db4
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/intel/IntelWin64CCompiler.java
@@ -0,0 +1,53 @@
+/*
+ *
+ * Copyright 2002-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.intel;
+import net.sf.antcontrib.cpptasks.compiler.LinkType;
+import net.sf.antcontrib.cpptasks.compiler.Linker;
+import net.sf.antcontrib.cpptasks.compiler.Processor;
+import net.sf.antcontrib.cpptasks.devstudio.DevStudioCompatibleCCompiler;
+
+import org.apache.tools.ant.types.Environment;
+/**
+ * Adapter for the Intel C++ compiler for Itanium(TM) Applications
+ *
+ * @author Curt Arnold
+ */
+public final class IntelWin64CCompiler extends DevStudioCompatibleCCompiler {
+ private static final IntelWin64CCompiler instance = new IntelWin64CCompiler(
+ false, null);
+ public static IntelWin64CCompiler getInstance() {
+ return instance;
+ }
+ private IntelWin64CCompiler(boolean newEnvironment, Environment env) {
+ super("ecl", null, newEnvironment, env);
+ }
+ public Processor changeEnvironment(boolean newEnvironment, Environment env) {
+ if (newEnvironment || env != null) {
+ return new IntelWin64CCompiler(newEnvironment, env);
+ }
+ return this;
+ }
+ public Linker getLinker(LinkType type) {
+ //
+ // currently the Intel Win32 and Win64 linkers
+ // are command line equivalent
+ return IntelWin32Linker.getInstance().getLinker(type);
+ }
+ public int getMaximumCommandLength() {
+ return 1024;
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/os390/OS390CCompiler.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/os390/OS390CCompiler.java
new file mode 100644
index 0000000000..633b55ec0c
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/os390/OS390CCompiler.java
@@ -0,0 +1,157 @@
+/*
+ *
+ * Copyright 2002-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.os390;
+import java.io.File;
+import java.util.Vector;
+
+import net.sf.antcontrib.cpptasks.CUtil;
+import net.sf.antcontrib.cpptasks.CompilerDef;
+import net.sf.antcontrib.cpptasks.compiler.AbstractCompiler;
+import net.sf.antcontrib.cpptasks.compiler.CommandLineCCompiler;
+import net.sf.antcontrib.cpptasks.compiler.LinkType;
+import net.sf.antcontrib.cpptasks.compiler.Linker;
+import net.sf.antcontrib.cpptasks.compiler.Processor;
+import net.sf.antcontrib.cpptasks.types.DefineArgument;
+import net.sf.antcontrib.cpptasks.types.UndefineArgument;
+import net.sf.antcontrib.cpptasks.OptimizationEnum;
+
+
+import org.apache.tools.ant.types.Environment;
+/**
+ * Adapter for the IBM (R) OS/390 (tm) C++ Compiler
+ *
+ * @author Hiram Chirino (cojonudo14@hotmail.com)
+ */
+public class OS390CCompiler extends CommandLineCCompiler {
+ private static final AbstractCompiler instance = new OS390CCompiler(false,
+ null);
+ public static AbstractCompiler getInstance() {
+ return instance;
+ }
+ private OS390CCompiler(boolean newEnvironment, Environment env) {
+ super("cxx", null, new String[]{".c", ".cc", ".cpp", ".cxx", ".c++",
+ ".s"}, new String[]{".h", ".hpp"}, ".o", false, null,
+ newEnvironment, env);
+ }
+ protected void addImpliedArgs(final Vector args,
+ final boolean debug,
+ final boolean multithreaded,
+ final boolean exceptions,
+ final LinkType linkType,
+ final Boolean rtti,
+ final OptimizationEnum optimization,
+ final Boolean defaultflag) {
+ // Specifies that only compilations and assemblies be done.
+ // Link-edit is not done
+ args.addElement("-c");
+ args.addElement("-W");
+ args.addElement("c,NOEXPMAC,NOSHOWINC");
+ /*
+ * if (exceptions) { args.addElement("/GX"); }
+ */
+ if (debug) {
+ args.addElement("-g");
+ args.addElement("-D");
+ args.addElement("_DEBUG");
+ /*
+ * if (multithreaded) { args.addElement("/D_MT"); if (staticLink) {
+ * args.addElement("/MTd"); } else { args.addElement("/MDd");
+ * args.addElement("/D_DLL"); } } else { args.addElement("/MLd"); }
+ */
+ } else {
+ args.addElement("-D");
+ args.addElement("NEBUG");
+ /*
+ * if (multithreaded) { args.addElement("/D_MT"); if (staticLink) {
+ * args.addElement("/MT"); } else { args.addElement("/MD");
+ * args.addElement("/D_DLL"); } } else { args.addElement("/ML"); }
+ */
+ }
+ }
+ protected void addWarningSwitch(Vector args, int level) {
+ OS390Processor.addWarningSwitch(args, level);
+ }
+ /**
+ * The buildDefineArguments implementation CommandLineCCompiler is not good
+ * for us because os390 defines are give by -D definex instead of
+ * /Ddefinex, 2 args not 1! since we implement this ourslefs, we do not
+ * have to implement the getDefineSwitch() and the getUndefineSwitch().
+ */
+ protected void buildDefineArguments(CompilerDef[] defs, Vector args) {
+ //
+ // assume that we aren't inheriting defines from containing
+ //
+ UndefineArgument[] merged = defs[0].getActiveDefines();
+ for (int i = 1; i < defs.length; i++) {
+ //
+ // if we are inheriting, merge the specific defines with the
+ // containing defines
+ merged = DefineArgument.merge(defs[i].getActiveDefines(), merged);
+ }
+ StringBuffer buf = new StringBuffer(30);
+ for (int i = 0; i < merged.length; i++) {
+ buf.setLength(0);
+ UndefineArgument current = merged[i];
+ if (current.isDefine()) {
+ args.addElement("-D");
+ buf.append(current.getName());
+ if (current.getValue() != null
+ && current.getValue().length() > 0) {
+ buf.append('=');
+ buf.append(current.getValue());
+ }
+ args.addElement(buf.toString());
+ } else {
+ args.addElement("-U");
+ args.addElement(current.getName());
+ }
+ }
+ }
+ public Processor changeEnvironment(boolean newEnvironment, Environment env) {
+ if (newEnvironment || env != null) {
+ return new OS390CCompiler(newEnvironment, env);
+ }
+ return this;
+ }
+ /*
+ * @see CommandLineCompiler#getDefineSwitch(StringBuffer, String, String)
+ */
+ protected void getDefineSwitch(StringBuffer buffer, String define,
+ String value) {
+ }
+ protected File[] getEnvironmentIncludePath() {
+ return CUtil.getPathFromEnvironment("INCLUDE", ":");
+ }
+ protected String getIncludeDirSwitch(String includeDir) {
+ return OS390Processor.getIncludeDirSwitch(includeDir);
+ }
+ public Linker getLinker(LinkType type) {
+ return OS390Linker.getInstance().getLinker(type);
+ }
+ public int getMaximumCommandLength() {
+ return Integer.MAX_VALUE;
+ }
+ /* Only compile one file at time for now */
+ protected int getMaximumInputFilesPerCommand() {
+ return Integer.MAX_VALUE;
+ }
+ /*
+ * @see CommandLineCompiler#getUndefineSwitch(StringBuffer, String)
+ */
+ protected void getUndefineSwitch(StringBuffer buffer, String define) {
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/os390/OS390Linker.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/os390/OS390Linker.java
new file mode 100644
index 0000000000..f6653b7be4
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/os390/OS390Linker.java
@@ -0,0 +1,201 @@
+/*
+ *
+ * Copyright 2002-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.os390;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.Vector;
+
+import net.sf.antcontrib.cpptasks.CCTask;
+import net.sf.antcontrib.cpptasks.CUtil;
+import net.sf.antcontrib.cpptasks.compiler.CommandLineLinker;
+import net.sf.antcontrib.cpptasks.compiler.CommandLineLinkerConfiguration;
+import net.sf.antcontrib.cpptasks.compiler.LinkType;
+import net.sf.antcontrib.cpptasks.compiler.Linker;
+import net.sf.antcontrib.cpptasks.types.LibrarySet;
+import net.sf.antcontrib.cpptasks.types.LibraryTypeEnum;
+
+import org.apache.tools.ant.BuildException;
+/**
+ * Adapter for the IBM (R) OS/390 (tm) Linker
+ *
+ * @author Hiram Chirino (cojonudo14@hotmail.com)
+ */
+public final class OS390Linker extends CommandLineLinker {
+ private static final OS390Linker datasetLinker = new OS390Linker();
+ private static final OS390Linker dllLinker = new OS390Linker("", ".dll");
+ private static final OS390Linker instance = new OS390Linker("", "");
+ public static OS390Linker getDataSetInstance() {
+ return datasetLinker;
+ }
+ public static OS390Linker getInstance() {
+ return instance;
+ }
+ private boolean isADatasetLinker;
+ File outputFile;
+ private String outputPrefix;
+ CCTask task;
+ private OS390Linker() {
+ super("cxx", "/bogus", new String[]{".o", ".a", ".lib", ".xds"},
+ new String[]{".dll", ".x"}, ".xds", false, null);
+ this.outputPrefix = "";
+ this.isADatasetLinker = true;
+ }
+ private OS390Linker(String outputPrefix, String outputSuffix) {
+ super("cxx", "/bogus", new String[]{".o", ".a", ".lib", ".x"},
+ new String[]{".dll"}, outputSuffix, false, null);
+ this.outputPrefix = outputPrefix;
+ this.isADatasetLinker = false;
+ }
+ protected void addBase(long base, Vector args) {
+ }
+ protected void addFixed(Boolean fixed, Vector args) {
+ }
+ protected void addImpliedArgs(boolean debug, LinkType linkType, Vector args, Boolean defaultflag) {
+ if (linkType.isSharedLibrary()) {
+ args.addElement("-W");
+ args.addElement("l,DLL");
+ }
+ }
+ protected void addIncremental(boolean incremental, Vector args) {
+ }
+ /*
+ * @see CommandLineLinker#addLibrarySets(LibrarySet[], Vector, Vector,
+ * Vector)
+ */
+ protected String[] addLibrarySets(CCTask task, LibrarySet[] libsets,
+ Vector preargs, Vector midargs, Vector endargs) {
+ // If yo want to link against a library sitting in a dataset and
+ // not in the HFS, you can just use the //'dataset' notation
+ // to specify it. e.g:
+ //
+ //
+ // We have to have special handling here because the file is not
+ // on the normal filesystem so the task will not noramly include it
+ // as part of the link command.
+ if (libsets != null) {
+ for (int i = 0; i < libsets.length; i++) {
+ String libs[] = libsets[i].getLibs();
+ for (int j = 0; j < libs.length; j++) {
+ if (libs[j].startsWith("//")) {
+ endargs.addElement("-l");
+ endargs.addElement(libs[j]);
+ } else if (libsets[i].getDataset() != null) {
+ String ds = libsets[i].getDataset();
+ endargs.addElement("//'" + ds + "(" + libs[j] + ")'");
+ }
+ }
+ }
+ }
+ return super.addLibrarySets(task, libsets, preargs, midargs, endargs);
+ }
+ protected void addMap(boolean map, Vector args) {
+ }
+ protected void addStack(int stack, Vector args) {
+ }
+ protected void addEntry(String entry, Vector args) {
+ }
+
+ public String getCommandFileSwitch(String commandFile) {
+ return "@" + commandFile;
+ }
+ public File[] getLibraryPath() {
+ return CUtil.getPathFromEnvironment("LIB", ";");
+ }
+
+ public String[] getLibraryPatterns(String[] libnames, LibraryTypeEnum libType) {
+ StringBuffer buf = new StringBuffer();
+ String[] patterns = new String[libnames.length * 3];
+ int offset = addLibraryPatterns(libnames, buf, "lib", ".a", patterns, 0);
+ offset = addLibraryPatterns(libnames, buf, "", ".x", patterns, offset);
+ offset = addLibraryPatterns(libnames, buf, "", ".o", patterns, offset);
+ return patterns;
+ }
+
+ private static int addLibraryPatterns(String[] libnames, StringBuffer buf,
+ String prefix, String extension, String[] patterns, int offset) {
+ for (int i = 0; i < libnames.length; i++) {
+ buf.setLength(0);
+ buf.append(prefix);
+ buf.append(libnames[i]);
+ buf.append(extension);
+ patterns[offset + i] = buf.toString();
+ }
+ return offset + libnames.length;
+ }
+
+ public Linker getLinker(LinkType linkType) {
+ if (this == datasetLinker)
+ return datasetLinker;
+ if (linkType.isSharedLibrary())
+ return dllLinker;
+ return instance;
+ }
+ public int getMaximumCommandLength() {
+ return Integer.MAX_VALUE;
+ }
+ public String getOutputFileName(String baseName) {
+ return outputPrefix + super.getOutputFileName(baseName);
+ }
+ protected String[] getOutputFileSwitch(CCTask task, String outputFile) {
+ if (isADatasetLinker && task.getDataset() != null) {
+ String ds = task.getDataset();
+ outputFile = "//'" + ds + "(" + outputFile + ")'";
+ }
+ return getOutputFileSwitch(outputFile);
+ }
+ public String[] getOutputFileSwitch(String outputFile) {
+ return new String[]{"-o", outputFile};
+ }
+ public boolean isCaseSensitive() {
+ return OS390Processor.isCaseSensitive();
+ }
+ /*
+ * @see CommandLineLinker#link(Task, File, String[],
+ * CommandLineLinkerConfiguration)
+ */
+ public void link(CCTask task, File outputFile, String[] sourceFiles,
+ CommandLineLinkerConfiguration config) throws BuildException {
+ this.task = task;
+ this.outputFile = outputFile;
+ if (isADatasetLinker) {
+ int p = outputFile.getName().indexOf(".");
+ if (p >= 0) {
+ String newname = outputFile.getName().substring(0, p);
+ outputFile = new File(outputFile.getParent(), newname);
+ }
+ }
+ super.link(task, outputFile, sourceFiles, config);
+ }
+ /*
+ * @see CommandLineLinker#runCommand(Task, File, String[])
+ */
+ protected int runCommand(CCTask task, File workingDir, String[] cmdline)
+ throws BuildException {
+ int rc = super.runCommand(task, workingDir, cmdline);
+ // create the .xds file if everything was ok.
+ if (rc == 0) {
+ try {
+ outputFile.delete();
+ new FileOutputStream(outputFile).close();
+ } catch (IOException e) {
+ throw new BuildException(e.getMessage());
+ }
+ }
+ return rc;
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/os390/OS390Processor.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/os390/OS390Processor.java
new file mode 100644
index 0000000000..2c209dd6bb
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/os390/OS390Processor.java
@@ -0,0 +1,71 @@
+/*
+ *
+ * Copyright 2002-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.os390;
+import java.util.Vector;
+/**
+ * A add-in class for IBM (r) OS/390 compilers and linkers
+ *
+ * @author Hiram Chirino (cojonudo14@hotmail.com)
+ */
+public class OS390Processor {
+ public static void addWarningSwitch(Vector args, int level) {
+ switch (level) {
+ /*
+ * case 0: args.addElement("/W0"); break;
+ *
+ * case 1: args.addElement("/W1"); break;
+ *
+ * case 2: break;
+ *
+ * case 3: args.addElement("/W3"); break;
+ *
+ * case 4: args.addElement("/W4"); break;
+ */
+ }
+ }
+ public static String getCommandFileSwitch(String cmdFile) {
+ StringBuffer buf = new StringBuffer("@");
+ if (cmdFile.indexOf(' ') >= 0) {
+ buf.append('\"');
+ buf.append(cmdFile);
+ buf.append('\"');
+ } else {
+ buf.append(cmdFile);
+ }
+ return buf.toString();
+ }
+ public static String getIncludeDirSwitch(String includeDir) {
+ return "-I" + includeDir;
+ }
+ public static String[] getOutputFileSwitch(String outPath) {
+ StringBuffer buf = new StringBuffer("-o ");
+ if (outPath.indexOf(' ') >= 0) {
+ buf.append('\"');
+ buf.append(outPath);
+ buf.append('\"');
+ } else {
+ buf.append(outPath);
+ }
+ String[] retval = new String[]{buf.toString()};
+ return retval;
+ }
+ public static boolean isCaseSensitive() {
+ return true;
+ }
+ private OS390Processor() {
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/os400/IccCompiler.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/os400/IccCompiler.java
new file mode 100644
index 0000000000..f40858f71b
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/os400/IccCompiler.java
@@ -0,0 +1,124 @@
+/*
+ *
+ * Copyright 2002-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.os400;
+import java.io.File;
+import java.util.Vector;
+
+import net.sf.antcontrib.cpptasks.CUtil;
+import net.sf.antcontrib.cpptasks.compiler.AbstractCompiler;
+import net.sf.antcontrib.cpptasks.compiler.CommandLineCCompiler;
+import net.sf.antcontrib.cpptasks.compiler.LinkType;
+import net.sf.antcontrib.cpptasks.compiler.Linker;
+import net.sf.antcontrib.cpptasks.compiler.Processor;
+import net.sf.antcontrib.cpptasks.OptimizationEnum;
+
+
+import org.apache.tools.ant.types.Environment;
+/**
+ * Adapter for the IBM (R) OS/390 (tm) C++ Compiler
+ *
+ * @author Hiram Chirino (cojonudo14@hotmail.com)
+ */
+public class IccCompiler extends CommandLineCCompiler {
+ private static final AbstractCompiler instance = new IccCompiler(false,
+ null);
+ public static AbstractCompiler getInstance() {
+ return instance;
+ }
+ private IccCompiler(boolean newEnvironment, Environment env) {
+ super("icc", null, new String[]{".c", ".cc", ".cpp", ".cxx", ".c++",
+ ".s"}, new String[]{".h", ".hpp"}, ".o", false, null,
+ newEnvironment, env);
+ }
+ protected void addImpliedArgs(final Vector args,
+ final boolean debug,
+ final boolean multithreaded,
+ final boolean exceptions,
+ final LinkType linkType,
+ final Boolean rtti,
+ final OptimizationEnum optimization,
+ final Boolean defaultflag) {
+ // Specifies that only compilations and assemblies be done.
+ // Link-edit is not done
+ args.addElement("-c");
+ /*
+ * if (exceptions) { args.addElement("/GX"); }
+ */
+ if (debug) {
+ args.addElement("-g");
+ /*
+ * args.addElement("-D"); args.addElement("_DEBUG"); if
+ * (multithreaded) { args.addElement("/D_MT"); if (staticLink) {
+ * args.addElement("/MTd"); } else { args.addElement("/MDd");
+ * args.addElement("/D_DLL"); } } else { args.addElement("/MLd"); }
+ */
+ } else {
+ /*
+ * args.addElement("-D"); args.addElement("NEBUG"); if
+ * (multithreaded) { args.addElement("/D_MT"); if (staticLink) {
+ * args.addElement("/MT"); } else { args.addElement("/MD");
+ * args.addElement("/D_DLL"); } } else { args.addElement("/ML"); }
+ */
+ }
+ }
+ protected void addWarningSwitch(Vector args, int level) {
+ IccProcessor.addWarningSwitch(args, level);
+ }
+ public Processor changeEnvironment(boolean newEnvironment, Environment env) {
+ if (newEnvironment || env != null) {
+ return new IccCompiler(newEnvironment, env);
+ }
+ return this;
+ }
+ /*
+ * @see CommandLineCompiler#getDefineSwitch(StringBuffer, String, String)
+ */
+ protected void getDefineSwitch(StringBuffer buffer, String define,
+ String value) {
+ buffer.append("-q");
+ buffer.append(define);
+ if (value != null && value.length() > 0) {
+ buffer.append('=');
+ buffer.append(value);
+ }
+ }
+ protected File[] getEnvironmentIncludePath() {
+ return CUtil.getPathFromEnvironment("INCLUDE", ":");
+ }
+ protected String getIncludeDirSwitch(String includeDir) {
+ return IccProcessor.getIncludeDirSwitch(includeDir);
+ }
+ public Linker getLinker(LinkType type) {
+ return IccLinker.getInstance().getLinker(type);
+ }
+ public int getMaximumCommandLength() {
+ return Integer.MAX_VALUE;
+ }
+ /* Only compile one file at time for now */
+ protected int getMaximumInputFilesPerCommand() {
+ return 1;
+ //return Integer.MAX_VALUE;
+ }
+ /*
+ * @see CommandLineCompiler#getUndefineSwitch(StringBuffer, String)
+ */
+ protected void getUndefineSwitch(StringBuffer buffer, String define) {
+ /*
+ * buffer.addElement("-q"); buf.append(define);
+ */
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/os400/IccLinker.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/os400/IccLinker.java
new file mode 100644
index 0000000000..5e4e2f229a
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/os400/IccLinker.java
@@ -0,0 +1,202 @@
+/*
+ *
+ * Copyright 2002-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.os400;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.Vector;
+import net.sf.antcontrib.cpptasks.CCTask;
+import net.sf.antcontrib.cpptasks.CUtil;
+import net.sf.antcontrib.cpptasks.compiler.CommandLineLinker;
+import net.sf.antcontrib.cpptasks.compiler.CommandLineLinkerConfiguration;
+import net.sf.antcontrib.cpptasks.compiler.LinkType;
+import net.sf.antcontrib.cpptasks.compiler.Linker;
+import net.sf.antcontrib.cpptasks.types.LibrarySet;
+import net.sf.antcontrib.cpptasks.types.LibraryTypeEnum;
+import org.apache.tools.ant.BuildException;
+/**
+ * Adapter for the IBM (R) OS/390 (tm) Linker
+ *
+ * @author Hiram Chirino (cojonudo14@hotmail.com)
+ */
+public final class IccLinker extends CommandLineLinker {
+ private static final IccLinker datasetLinker = new IccLinker();
+ private static final IccLinker dllLinker = new IccLinker("", ".dll");
+ private static final IccLinker instance = new IccLinker("", "");
+ public static IccLinker getDataSetInstance() {
+ return datasetLinker;
+ }
+ public static IccLinker getInstance() {
+ return instance;
+ }
+ private boolean isADatasetLinker;
+ File outputFile;
+ private String outputPrefix;
+ CCTask task;
+ private IccLinker() {
+ super("icc", "/bogus", new String[]{".o", ".a", ".lib", ".xds"},
+ new String[]{".dll", ".x"}, ".xds", false, null);
+ this.outputPrefix = "";
+ this.isADatasetLinker = true;
+ }
+ private IccLinker(String outputPrefix, String outputSuffix) {
+ super("icc", "/bogus", new String[]{".o", ".a", ".lib", ".x"},
+ new String[]{".dll"}, outputSuffix, false, null);
+ this.outputPrefix = outputPrefix;
+ this.isADatasetLinker = false;
+ }
+ protected void addBase(long base, Vector args) {
+ }
+ protected void addFixed(Boolean fixed, Vector args) {
+ }
+ protected void addImpliedArgs(boolean debug, LinkType linkType, Vector args, Boolean defaultflag) {
+ if (linkType.isSharedLibrary()) {
+ args.addElement("-W");
+ args.addElement("l,DLL");
+ }
+ }
+ protected void addIncremental(boolean incremental, Vector args) {
+ }
+ /*
+ * @see CommandLineLinker#addLibrarySets(LibrarySet[], Vector, Vector,
+ * Vector)
+ */
+ protected String[] addLibrarySets(CCTask task, LibrarySet[] libsets,
+ Vector preargs, Vector midargs, Vector endargs) {
+ // If yo want to link against a library sitting in a dataset and
+ // not in the HFS, you can just use the //'dataset' notation
+ // to specify it. e.g:
+ //
+ //
+ // We have to have special handling here because the file is not
+ // on the normal filesystem so the task will not noramly include it
+ // as part of the link command.
+ if (libsets != null) {
+ for (int i = 0; i < libsets.length; i++) {
+ String libs[] = libsets[i].getLibs();
+ for (int j = 0; j < libs.length; j++) {
+ if (libs[j].startsWith("//")) {
+ endargs.addElement("-l");
+ endargs.addElement(libs[j]);
+ } else if (libsets[i].getDataset() != null) {
+ String ds = libsets[i].getDataset();
+ endargs.addElement("//'" + ds + "(" + libs[j] + ")'");
+ }
+ }
+ }
+ }
+ return super.addLibrarySets(task, libsets, preargs, midargs, endargs);
+ }
+ protected void addMap(boolean map, Vector args) {
+ }
+ protected void addStack(int stack, Vector args) {
+ }
+ /* (non-Javadoc)
+ * @see net.sf.antcontrib.cpptasks.compiler.CommandLineLinker#addEntry(int, java.util.Vector)
+ */
+ protected void addEntry(String entry, Vector args) {
+ }
+
+ public String getCommandFileSwitch(String commandFile) {
+ return "@" + commandFile;
+ }
+ public File[] getLibraryPath() {
+ return CUtil.getPathFromEnvironment("LIB", ";");
+ }
+ public String[] getLibraryPatterns(String[] libnames, LibraryTypeEnum libType) {
+ StringBuffer buf = new StringBuffer();
+ String[] patterns = new String[libnames.length * 3];
+ int offset = addLibraryPatterns(libnames, buf, "lib", ".a", patterns, 0);
+ offset = addLibraryPatterns(libnames, buf, "", ".x", patterns, offset);
+ offset = addLibraryPatterns(libnames, buf, "", ".o", patterns, offset);
+ return patterns;
+ }
+
+ private static int addLibraryPatterns(String[] libnames, StringBuffer buf,
+ String prefix, String extension, String[] patterns, int offset) {
+ for (int i = 0; i < libnames.length; i++) {
+ buf.setLength(0);
+ buf.append(prefix);
+ buf.append(libnames[i]);
+ buf.append(extension);
+ patterns[offset + i] = buf.toString();
+ }
+ return offset + libnames.length;
+ }
+
+
+ public Linker getLinker(LinkType linkType) {
+ if (this == datasetLinker)
+ return datasetLinker;
+ if (linkType.isSharedLibrary())
+ return dllLinker;
+ return instance;
+ }
+ public int getMaximumCommandLength() {
+ return Integer.MAX_VALUE;
+ }
+ protected String[] getOutputFileSwitch(CCTask task, String outputFile) {
+ if (isADatasetLinker && task.getDataset() != null) {
+ String ds = task.getDataset();
+ outputFile = "//'" + ds + "(" + outputFile + ")'";
+ }
+ return getOutputFileSwitch(outputFile);
+ }
+ public String[] getOutputFileSwitch(String outputFile) {
+ return new String[]{"-o", outputFile};
+ }
+ public boolean isCaseSensitive() {
+ return IccProcessor.isCaseSensitive();
+ }
+ /*
+ * @see CommandLineLinker#link(Task, File, String[],
+ * CommandLineLinkerConfiguration)
+ */
+ public void link(CCTask task, File outputFile, String[] sourceFiles,
+ CommandLineLinkerConfiguration config) throws BuildException {
+ this.task = task;
+ this.outputFile = outputFile;
+ if (isADatasetLinker) {
+ int p = outputFile.getName().indexOf(".");
+ if (p >= 0) {
+ String newname = outputFile.getName().substring(0, p);
+ outputFile = new File(outputFile.getParent(), newname);
+ }
+ }
+ super.link(task, outputFile, sourceFiles, config);
+ }
+ /*
+ * @see CommandLineLinker#runCommand(Task, File, String[])
+ */
+ protected int runCommand(CCTask task, File workingDir, String[] cmdline)
+ throws BuildException {
+ int rc = super.runCommand(task, workingDir, cmdline);
+ // create the .xds file if everything was ok.
+ if (rc == 0) {
+ try {
+ outputFile.delete();
+ new FileOutputStream(outputFile).close();
+ } catch (IOException e) {
+ throw new BuildException(e.getMessage());
+ }
+ }
+ return rc;
+ }
+ public String xgetOutputFileName(String baseName) {
+ return outputPrefix + super.getOutputFileName(baseName);
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/os400/IccProcessor.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/os400/IccProcessor.java
new file mode 100644
index 0000000000..4cc7b36ab3
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/os400/IccProcessor.java
@@ -0,0 +1,71 @@
+/*
+ *
+ * Copyright 2002-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.os400;
+import java.util.Vector;
+/**
+ * A add-in class for IBM (r) OS/390 compilers and linkers
+ *
+ * @author Hiram Chirino (cojonudo14@hotmail.com)
+ */
+public class IccProcessor {
+ public static void addWarningSwitch(Vector args, int level) {
+ switch (level) {
+ /*
+ * case 0: args.addElement("/W0"); break;
+ *
+ * case 1: args.addElement("/W1"); break;
+ *
+ * case 2: break;
+ *
+ * case 3: args.addElement("/W3"); break;
+ *
+ * case 4: args.addElement("/W4"); break;
+ */
+ }
+ }
+ public static String getCommandFileSwitch(String cmdFile) {
+ StringBuffer buf = new StringBuffer("@");
+ if (cmdFile.indexOf(' ') >= 0) {
+ buf.append('\"');
+ buf.append(cmdFile);
+ buf.append('\"');
+ } else {
+ buf.append(cmdFile);
+ }
+ return buf.toString();
+ }
+ public static String getIncludeDirSwitch(String includeDir) {
+ return "-I" + includeDir;
+ }
+ public static String[] getOutputFileSwitch(String outPath) {
+ StringBuffer buf = new StringBuffer("-o ");
+ if (outPath.indexOf(' ') >= 0) {
+ buf.append('\"');
+ buf.append(outPath);
+ buf.append('\"');
+ } else {
+ buf.append(outPath);
+ }
+ String[] retval = new String[]{buf.toString()};
+ return retval;
+ }
+ public static boolean isCaseSensitive() {
+ return true;
+ }
+ private IccProcessor() {
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/parser/AbstractParser.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/parser/AbstractParser.java
new file mode 100644
index 0000000000..6f0b79c072
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/parser/AbstractParser.java
@@ -0,0 +1,67 @@
+/*
+ *
+ * Copyright 2001-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.parser;
+import java.io.IOException;
+import java.io.Reader;
+/**
+ * An abstract base class for simple parsers
+ *
+ * @author Curt Arnold
+ */
+public abstract class AbstractParser {
+ /**
+ *
+ *
+ */
+ protected AbstractParser() {
+ }
+ protected abstract void addFilename(String filename);
+ public abstract AbstractParserState getNewLineState();
+ protected void parse(Reader reader) throws IOException {
+ char[] buf = new char[4096];
+ AbstractParserState newLineState = getNewLineState();
+ AbstractParserState state = newLineState;
+ int charsRead = -1;
+ do {
+ charsRead = reader.read(buf, 0, buf.length);
+ if (state == null) {
+ for (int i = 0; i < charsRead; i++) {
+ if (buf[i] == '\n') {
+ state = newLineState;
+ break;
+ }
+ }
+ }
+ if (state != null) {
+ for (int i = 0; i < charsRead; i++) {
+ state = state.consume(buf[i]);
+ //
+ // didn't match a production, skip to a new line
+ //
+ if (state == null) {
+ for (; i < charsRead; i++) {
+ if (buf[i] == '\n') {
+ state = newLineState;
+ break;
+ }
+ }
+ }
+ }
+ }
+ } while (charsRead >= 0);
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/parser/AbstractParserState.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/parser/AbstractParserState.java
new file mode 100644
index 0000000000..fe66dbbef0
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/parser/AbstractParserState.java
@@ -0,0 +1,41 @@
+/*
+ *
+ * Copyright 2002-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.parser;
+/**
+ * An base class for objects that represent the state of an AbstractParser.
+ *
+ * @author CurtArnold
+ * @see AbstractParser
+ */
+public abstract class AbstractParserState {
+ private AbstractParser parser;
+ protected AbstractParserState(AbstractParser parser) {
+ if (parser == null) {
+ throw new NullPointerException("parser");
+ }
+ this.parser = parser;
+ }
+ /**
+ * Consume a character
+ *
+ * @return new state, may be null to ignore the rest of the line
+ */
+ public abstract AbstractParserState consume(char ch);
+ protected AbstractParser getParser() {
+ return parser;
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/parser/BranchState.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/parser/BranchState.java
new file mode 100644
index 0000000000..370c7d5836
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/parser/BranchState.java
@@ -0,0 +1,46 @@
+/*
+ *
+ * Copyright 2002-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.parser;
+public class BranchState extends AbstractParserState {
+ private char[] branchChars;
+ private AbstractParserState[] branchStates;
+ private AbstractParserState noMatchState;
+ public BranchState(AbstractParser parser, char[] branchChars,
+ AbstractParserState[] branchStates, AbstractParserState noMatchState) {
+ super(parser);
+ this.branchChars = (char[]) branchChars.clone();
+ this.branchStates = (AbstractParserState[]) branchStates.clone();
+ this.noMatchState = noMatchState;
+ }
+ public AbstractParserState consume(char ch) {
+ AbstractParserState state;
+ for (int i = 0; i < branchChars.length; i++) {
+ if (ch == branchChars[i]) {
+ state = branchStates[i];
+ return state.consume(ch);
+ }
+ }
+ state = getNoMatchState();
+ if (state != null) {
+ return state.consume(ch);
+ }
+ return state;
+ }
+ protected AbstractParserState getNoMatchState() {
+ return noMatchState;
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/parser/CParser.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/parser/CParser.java
new file mode 100644
index 0000000000..07f8eba4e2
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/parser/CParser.java
@@ -0,0 +1,78 @@
+/*
+ *
+ * Copyright 2002-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.parser;
+import java.io.IOException;
+import java.io.Reader;
+import java.util.Vector;
+/**
+ * A parser that extracts #include statements from a Reader.
+ *
+ * @author Adam Murdoch
+ * @author Curt Arnold
+ */
+public final class CParser extends AbstractParser implements Parser {
+ private final Vector includes = new Vector();
+ private AbstractParserState newLineState;
+ /**
+ *
+ *
+ */
+ public CParser() {
+ AbstractParserState quote = new FilenameState(this, new char[]{'"'});
+ AbstractParserState bracket = new FilenameState(this, new char[]{'>'});
+ AbstractParserState postE = new PostE(this, bracket, quote);
+ //
+ // nclude
+ //
+ AbstractParserState e = new LetterState(this, 'e', postE, null);
+ AbstractParserState d = new LetterState(this, 'd', e, null);
+ AbstractParserState u = new LetterState(this, 'u', d, null);
+ AbstractParserState l = new LetterState(this, 'l', u, null);
+ AbstractParserState c = new LetterState(this, 'c', l, null);
+ AbstractParserState n = new LetterState(this, 'n', c, null);
+ //
+ // mport is equivalent to nclude
+ //
+ AbstractParserState t = new LetterState(this, 't', postE, null);
+ AbstractParserState r = new LetterState(this, 'r', t, null);
+ AbstractParserState o = new LetterState(this, 'o', r, null);
+ AbstractParserState p = new LetterState(this, 'p', o, null);
+ AbstractParserState m = new LetterState(this, 'm', p, null);
+ //
+ // switch between
+ //
+ AbstractParserState n_m = new BranchState(this, new char[]{'n', 'm'},
+ new AbstractParserState[]{n, m}, null);
+ AbstractParserState i = new WhitespaceOrLetterState(this, 'i', n_m);
+ newLineState = new LetterState(this, '#', i, null);
+ }
+ public void addFilename(String include) {
+ includes.addElement(include);
+ }
+ public String[] getIncludes() {
+ String[] retval = new String[includes.size()];
+ includes.copyInto(retval);
+ return retval;
+ }
+ public AbstractParserState getNewLineState() {
+ return newLineState;
+ }
+ public void parse(Reader reader) throws IOException {
+ includes.setSize(0);
+ super.parse(reader);
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/parser/CaseInsensitiveLetterState.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/parser/CaseInsensitiveLetterState.java
new file mode 100644
index 0000000000..a86700f166
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/parser/CaseInsensitiveLetterState.java
@@ -0,0 +1,87 @@
+/*
+ *
+ * Copyright 2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.parser;
+
+/**
+ * This parser state checks consumed characters against a specific character
+ * (case insensitive).
+ *
+ * @author Curt Arnold
+ */
+public final class CaseInsensitiveLetterState
+ extends AbstractParserState {
+ /**
+ * Next state if a match is found.
+ */
+ private final AbstractParserState nextState;
+
+ /**
+ * Next state if not match is found.
+ */
+ private final AbstractParserState noMatchState;
+
+ /**
+ * Lower case version of character to match.
+ */
+ private final char lowerLetter;
+
+ /**
+ * Lower case version of character to match.
+ */
+ private final char upperLetter;
+
+ /**
+ * Constructor.
+ *
+ * @param parser
+ * parser
+ * @param matchLetter
+ * letter to match
+ * @param nextStateArg
+ * next state if a match on the letter
+ * @param noMatchStateArg
+ * state if no match on letter
+ */
+ public CaseInsensitiveLetterState(final AbstractParser parser,
+ final char matchLetter,
+ final AbstractParserState nextStateArg,
+ final AbstractParserState noMatchStateArg) {
+ super(parser);
+ this.lowerLetter = Character.toLowerCase(matchLetter);
+ this.upperLetter = Character.toUpperCase(matchLetter);
+ this.nextState = nextStateArg;
+ this.noMatchState = noMatchStateArg;
+ }
+
+ /**
+ * Consumes a character and returns the next state for the parser.
+ *
+ * @param ch
+ * next character
+ * @return the configured nextState if ch is the expected character or the
+ * configure noMatchState otherwise.
+ */
+ public AbstractParserState consume(final char ch) {
+ if (ch == lowerLetter || ch == upperLetter) {
+ return nextState;
+ }
+ if (ch == '\n') {
+ getParser().getNewLineState();
+ }
+ return noMatchState;
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/parser/FilenameState.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/parser/FilenameState.java
new file mode 100644
index 0000000000..f33940b0a7
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/parser/FilenameState.java
@@ -0,0 +1,41 @@
+/*
+ *
+ * Copyright 2002-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.parser;
+public class FilenameState extends AbstractParserState {
+ private final StringBuffer buf = new StringBuffer();
+ private final char[] terminators;
+ public FilenameState(AbstractParser parser, char[] terminators) {
+ super(parser);
+ this.terminators = (char[]) terminators.clone();
+ }
+ public AbstractParserState consume(char ch) {
+ for (int i = 0; i < terminators.length; i++) {
+ if (ch == terminators[i]) {
+ getParser().addFilename(buf.toString());
+ buf.setLength(0);
+ return null;
+ }
+ }
+ if (ch == '\n') {
+ buf.setLength(0);
+ return getParser().getNewLineState();
+ } else {
+ buf.append(ch);
+ }
+ return this;
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/parser/FortranParser.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/parser/FortranParser.java
new file mode 100644
index 0000000000..261e95ad81
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/parser/FortranParser.java
@@ -0,0 +1,106 @@
+/*
+ *
+ * Copyright 2002-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.parser;
+
+import java.io.IOException;
+import java.io.Reader;
+import java.util.Vector;
+
+/**
+ * A parser that extracts INCLUDE statements from a Reader.
+ *
+ * @author Curt Arnold
+ */
+public final class FortranParser
+ extends AbstractParser
+ implements Parser {
+ /**
+ * List of included filenames.
+ */
+ private final Vector includes = new Vector();
+
+ /**
+ * State that starts consuming content at the beginning of a line.
+ */
+ private final AbstractParserState newLineState;
+
+ /**
+ * Default constructor.
+ *
+ */
+ public FortranParser() {
+ AbstractParserState filename = new FilenameState(this, new char[] {'\'',
+ '/'});
+ AbstractParserState apos = new WhitespaceOrLetterState(this, '\'',
+ filename);
+ AbstractParserState blank = new LetterState(this, ' ', apos, null);
+ AbstractParserState e = new CaseInsensitiveLetterState(this, 'E',
+ blank, null);
+ AbstractParserState d = new CaseInsensitiveLetterState(this, 'D', e,
+ null);
+ AbstractParserState u = new CaseInsensitiveLetterState(this, 'U', d,
+ null);
+ AbstractParserState l = new CaseInsensitiveLetterState(this, 'L', u,
+ null);
+ AbstractParserState c = new CaseInsensitiveLetterState(this, 'C', l,
+ null);
+ AbstractParserState n = new CaseInsensitiveLetterState(this, 'N', c,
+ null);
+ newLineState = new WhitespaceOrCaseInsensitiveLetterState(this, 'I', n);
+ }
+
+ /**
+ * Called by FilenameState at completion of file name production.
+ *
+ * @param include
+ * include file name
+ */
+ public void addFilename(final String include) {
+ includes.addElement(include);
+ }
+
+ /**
+ * Gets collection of include file names encountered in parse.
+ * @return include file names
+ */
+ public String[] getIncludes() {
+ String[] retval = new String[includes.size()];
+ includes.copyInto(retval);
+ return retval;
+ }
+
+ /**
+ * Get the state for the beginning of a new line.
+ * @return start of line state
+ */
+ public AbstractParserState getNewLineState() {
+ return newLineState;
+ }
+
+ /**
+ * Collects all included files from the content of the reader.
+ *
+ * @param reader
+ * character reader containing a FORTRAN source module
+ * @throws IOException
+ * throw if I/O error during parse
+ */
+ public void parse(final Reader reader) throws IOException {
+ includes.setSize(0);
+ super.parse(reader);
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/parser/LetterState.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/parser/LetterState.java
new file mode 100644
index 0000000000..945ae91233
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/parser/LetterState.java
@@ -0,0 +1,80 @@
+/*
+ *
+ * Copyright 2002-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.parser;
+
+/**
+ * This parser state checks consumed characters against a specific character.
+ *
+ * @author Curt Arnold
+ */
+public final class LetterState
+ extends AbstractParserState {
+ /**
+ * Next state if a match is found.
+ */
+ private final AbstractParserState nextState;
+
+ /**
+ * Next state if not match is found.
+ */
+ private final AbstractParserState noMatchState;
+
+ /**
+ * Character to match.
+ */
+ private final char thisLetter;
+
+ /**
+ * Constructor.
+ *
+ * @param parser
+ * parser
+ * @param matchLetter
+ * letter to match
+ * @param nextStateArg
+ * next state if a match on the letter
+ * @param noMatchStateArg
+ * state if no match on letter
+ */
+ public LetterState(final AbstractParser parser,
+ final char matchLetter,
+ final AbstractParserState nextStateArg,
+ final AbstractParserState noMatchStateArg) {
+ super(parser);
+ this.thisLetter = matchLetter;
+ this.nextState = nextStateArg;
+ this.noMatchState = noMatchStateArg;
+ }
+
+ /**
+ * Consumes a character and returns the next state for the parser.
+ *
+ * @param ch
+ * next character
+ * @return the configured nextState if ch is the expected character or the
+ * configure noMatchState otherwise.
+ */
+ public AbstractParserState consume(final char ch) {
+ if (ch == thisLetter) {
+ return nextState;
+ }
+ if (ch == '\n') {
+ getParser().getNewLineState();
+ }
+ return noMatchState;
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/parser/Parser.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/parser/Parser.java
new file mode 100644
index 0000000000..cf759fc7d5
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/parser/Parser.java
@@ -0,0 +1,28 @@
+/*
+ *
+ * Copyright 2002-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.parser;
+import java.io.IOException;
+import java.io.Reader;
+/**
+ * A parser that extracts #include statements from a Reader.
+ *
+ * @author Curt Arnold
+ */
+public interface Parser {
+ String[] getIncludes();
+ void parse(Reader reader) throws IOException;
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/parser/PostE.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/parser/PostE.java
new file mode 100644
index 0000000000..fe225fb35a
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/parser/PostE.java
@@ -0,0 +1,41 @@
+/*
+ *
+ * Copyright 2002-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.parser;
+public class PostE extends AbstractParserState {
+ private AbstractParserState bracket;
+ private AbstractParserState quote;
+ public PostE(CParser parser, AbstractParserState bracket,
+ AbstractParserState quote) {
+ super(parser);
+ this.bracket = bracket;
+ this.quote = quote;
+ }
+ public AbstractParserState consume(char ch) {
+ switch (ch) {
+ case ' ' :
+ case '\t' :
+ return this;
+ case '<' :
+ return bracket;
+ case '"' :
+ return quote;
+ case '\n' :
+ return getParser().getNewLineState();
+ }
+ return null;
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/parser/WhitespaceOrCaseInsensitiveLetterState.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/parser/WhitespaceOrCaseInsensitiveLetterState.java
new file mode 100644
index 0000000000..9d42feeaad
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/parser/WhitespaceOrCaseInsensitiveLetterState.java
@@ -0,0 +1,83 @@
+/*
+ *
+ * Copyright 2002-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.parser;
+
+/**
+ * This parser state checks consumed characters against a specific character
+ * (case insensitive) or whitespace.
+ *
+ * @author Curt Arnold
+ */
+public final class WhitespaceOrCaseInsensitiveLetterState
+ extends
+ AbstractParserState {
+ /**
+ * Next state if the character is found.
+ */
+ private final AbstractParserState nextState;
+
+ /**
+ * Character to match (lower case).
+ */
+ private final char lowerLetter;
+
+ /**
+ * Character to match (upper case).
+ */
+ private final char upperLetter;
+
+ /**
+ * Constructor.
+ *
+ * @param parser
+ * parser
+ * @param matchLetter
+ * letter to match
+ * @param nextStateArg
+ * next state if a match on the letter
+ */
+ public WhitespaceOrCaseInsensitiveLetterState(final AbstractParser parser,
+ final char matchLetter,
+ final AbstractParserState
+ nextStateArg) {
+ super(parser);
+ this.lowerLetter = Character.toLowerCase(matchLetter);
+ this.upperLetter = Character.toUpperCase(matchLetter);
+ this.nextState = nextStateArg;
+ }
+
+ /**
+ * Consumes a character and returns the next state for the parser.
+ *
+ * @param ch
+ * next character
+ * @return the configured nextState if ch is the expected character or the
+ * configure noMatchState otherwise.
+ */
+ public AbstractParserState consume(final char ch) {
+ if (ch == lowerLetter || ch == upperLetter) {
+ return nextState;
+ }
+ if (ch == ' ' || ch == '\t') {
+ return this;
+ }
+ if (ch == '\n') {
+ getParser().getNewLineState();
+ }
+ return null;
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/parser/WhitespaceOrLetterState.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/parser/WhitespaceOrLetterState.java
new file mode 100644
index 0000000000..824abe6b68
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/parser/WhitespaceOrLetterState.java
@@ -0,0 +1,75 @@
+/*
+ *
+ * Copyright 2002-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.parser;
+
+/**
+ * This parser state checks consumed characters against a specific character or
+ * whitespace.
+ *
+ * @author Curt Arnold
+ */
+public final class WhitespaceOrLetterState
+ extends AbstractParserState {
+ /**
+ * Next state if the character is found.
+ */
+ private final AbstractParserState nextState;
+
+ /**
+ * Character to match.
+ */
+ private final char thisLetter;
+
+ /**
+ * Constructor.
+ *
+ * @param parser
+ * parser
+ * @param matchLetter
+ * letter to match
+ * @param nextStateArg
+ * next state if a match on the letter
+ */
+ public WhitespaceOrLetterState(final AbstractParser parser,
+ final char matchLetter,
+ final AbstractParserState nextStateArg) {
+ super(parser);
+ this.thisLetter = matchLetter;
+ this.nextState = nextStateArg;
+ }
+
+ /**
+ * Consumes a character and returns the next state for the parser.
+ *
+ * @param ch
+ * next character @returns the configured nextState if ch is the
+ * expected character or the configure noMatchState otherwise.
+ * @return next state
+ */
+ public AbstractParserState consume(final char ch) {
+ if (ch == thisLetter) {
+ return nextState;
+ }
+ if (ch == ' ' || ch == '\t') {
+ return this;
+ }
+ if (ch == '\n') {
+ getParser().getNewLineState();
+ }
+ return null;
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/sun/C89CCompiler.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/sun/C89CCompiler.java
new file mode 100644
index 0000000000..6679c239dd
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/sun/C89CCompiler.java
@@ -0,0 +1,109 @@
+/*
+ *
+ * Copyright 2002-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.sun;
+import java.io.File;
+import java.util.Vector;
+
+import net.sf.antcontrib.cpptasks.CUtil;
+import net.sf.antcontrib.cpptasks.compiler.AbstractCompiler;
+import net.sf.antcontrib.cpptasks.compiler.CommandLineCCompiler;
+import net.sf.antcontrib.cpptasks.compiler.LinkType;
+import net.sf.antcontrib.cpptasks.compiler.Linker;
+import net.sf.antcontrib.cpptasks.compiler.Processor;
+import net.sf.antcontrib.cpptasks.OptimizationEnum;
+
+
+import org.apache.tools.ant.types.Environment;
+/**
+ * Adapter for the Sun C89 C++ Compiler
+ *
+ * @author Hiram Chirino (cojonudo14@hotmail.com)
+ */
+public class C89CCompiler extends CommandLineCCompiler {
+ private static final AbstractCompiler instance = new C89CCompiler(false,
+ null);
+ public static AbstractCompiler getInstance() {
+ return instance;
+ }
+ private C89CCompiler(boolean newEnvironment, Environment env) {
+ super("c89", null, new String[]{".c", ".cc", ".cpp", ".cxx", ".c++"},
+ new String[]{".h", ".hpp"}, ".o", false, null, newEnvironment,
+ env);
+ }
+ protected void addImpliedArgs(
+ final Vector args,
+ final boolean debug,
+ final boolean multithreaded,
+ final boolean exceptions,
+ final LinkType linkType,
+ final Boolean rtti,
+ final OptimizationEnum optimization,
+ final Boolean defaultflag) {
+ // Specifies that only compilations and assemblies be done.
+ args.addElement("-c");
+ /*
+ * if (exceptions) { args.addElement("/GX"); }
+ */
+ if (debug) {
+ args.addElement("-g");
+ args.addElement("-D_DEBUG");
+ /*
+ * if (multithreaded) { args.addElement("/D_MT"); if (staticLink) {
+ * args.addElement("/MTd"); } else { args.addElement("/MDd");
+ * args.addElement("/D_DLL"); } } else { args.addElement("/MLd"); }
+ */
+ } else {
+ args.addElement("-DNDEBUG");
+ /*
+ * if (multithreaded) { args.addElement("/D_MT"); if (staticLink) {
+ * args.addElement("/MT"); } else { args.addElement("/MD");
+ * args.addElement("/D_DLL"); } } else { args.addElement("/ML"); }
+ */
+ }
+ }
+ protected void addWarningSwitch(Vector args, int level) {
+ C89Processor.addWarningSwitch(args, level);
+ }
+ public Processor changeEnvironment(boolean newEnvironment, Environment env) {
+ if (newEnvironment || env != null) {
+ return new C89CCompiler(newEnvironment, env);
+ }
+ return this;
+ }
+ protected void getDefineSwitch(StringBuffer buf, String define, String value) {
+ C89Processor.getDefineSwitch(buf, define, value);
+ }
+ protected File[] getEnvironmentIncludePath() {
+ return CUtil.getPathFromEnvironment("INCLUDE", ":");
+ }
+ protected String getIncludeDirSwitch(String includeDir) {
+ return C89Processor.getIncludeDirSwitch(includeDir);
+ }
+ public Linker getLinker(LinkType type) {
+ return C89Linker.getInstance().getLinker(type);
+ }
+ public int getMaximumCommandLength() {
+ return Integer.MAX_VALUE;
+ }
+ /* Only compile one file at time for now */
+ protected int getMaximumInputFilesPerCommand() {
+ return 1;
+ }
+ protected void getUndefineSwitch(StringBuffer buf, String define) {
+ C89Processor.getUndefineSwitch(buf, define);
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/sun/C89Linker.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/sun/C89Linker.java
new file mode 100644
index 0000000000..37b3950bbe
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/sun/C89Linker.java
@@ -0,0 +1,125 @@
+/*
+ *
+ * Copyright 2002-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.sun;
+import java.io.File;
+import java.util.Vector;
+
+import net.sf.antcontrib.cpptasks.CCTask;
+import net.sf.antcontrib.cpptasks.CUtil;
+import net.sf.antcontrib.cpptasks.compiler.CommandLineLinker;
+import net.sf.antcontrib.cpptasks.compiler.LinkType;
+import net.sf.antcontrib.cpptasks.compiler.Linker;
+import net.sf.antcontrib.cpptasks.types.LibrarySet;
+import net.sf.antcontrib.cpptasks.types.LibraryTypeEnum;
+
+/**
+ * Adapter for the Sun C89 Linker
+ *
+ * @author Hiram Chirino (cojonudo14@hotmail.com)
+ */
+public final class C89Linker extends CommandLineLinker {
+ private static final C89Linker dllLinker = new C89Linker("lib", ".so");
+ private static final C89Linker instance = new C89Linker("", "");
+ public static C89Linker getInstance() {
+ return instance;
+ }
+ private String outputPrefix;
+ private C89Linker(String outputPrefix, String outputSuffix) {
+ super("ld", "/bogus", new String[]{".o", ".a", ".lib", ".x"},
+ new String[]{}, outputSuffix, false, null);
+ this.outputPrefix = outputPrefix;
+ }
+ protected void addBase(long base, Vector args) {
+ }
+ protected void addFixed(Boolean fixed, Vector args) {
+ }
+ protected void addImpliedArgs(boolean debug, LinkType linkType, Vector args, Boolean defaultflag) {
+ if (linkType.isSharedLibrary()) {
+ args.addElement("-G");
+ }
+ }
+ protected void addIncremental(boolean incremental, Vector args) {
+ }
+ public String[] addLibrarySets(CCTask task, LibrarySet[] libsets,
+ Vector preargs, Vector midargs, Vector endargs) {
+ super.addLibrarySets(task, libsets, preargs, midargs, endargs);
+ StringBuffer buf = new StringBuffer("-l");
+ for (int i = 0; i < libsets.length; i++) {
+ LibrarySet set = libsets[i];
+ File libdir = set.getDir(null);
+ String[] libs = set.getLibs();
+ if (libdir != null) {
+ endargs.addElement("-L");
+ endargs.addElement(libdir.getAbsolutePath());
+ }
+ for (int j = 0; j < libs.length; j++) {
+ //
+ // reset the buffer to just "-l"
+ //
+ buf.setLength(2);
+ //
+ // add the library name
+ buf.append(libs[j]);
+ //
+ // add the argument to the list
+ endargs.addElement(buf.toString());
+ }
+ }
+ return null;
+ }
+ protected void addMap(boolean map, Vector args) {
+ }
+ protected void addStack(int stack, Vector args) {
+ }
+ /* (non-Javadoc)
+ * @see net.sf.antcontrib.cpptasks.compiler.CommandLineLinker#addEntry(int, java.util.Vector)
+ */
+ protected void addEntry(String entry, Vector args) {
+ }
+
+ public String getCommandFileSwitch(String commandFile) {
+ return "@" + commandFile;
+ }
+ public File[] getLibraryPath() {
+ return CUtil.getPathFromEnvironment("LIB", ";");
+ }
+ public String[] getLibraryPatterns(String[] libnames, LibraryTypeEnum libType) {
+ return C89Processor.getLibraryPatterns(libnames, libType);
+ }
+ public Linker getLinker(LinkType linkType) {
+ if (linkType.isSharedLibrary()) {
+ return dllLinker;
+ }
+ /*
+ * if(linkType.isStaticLibrary()) { return
+ * OS390Librarian.getInstance(); }
+ */
+ return instance;
+ }
+ public int getMaximumCommandLength() {
+ return Integer.MAX_VALUE;
+ }
+ public String getOutputFileName(String baseName) {
+ return outputPrefix + super.getOutputFileName(baseName);
+ }
+ public String[] getOutputFileSwitch(String outputFile) {
+ return new String[]{"-o", outputFile};
+ }
+ public boolean isCaseSensitive() {
+ return C89Processor.isCaseSensitive();
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/sun/C89Processor.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/sun/C89Processor.java
new file mode 100644
index 0000000000..c54c866966
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/sun/C89Processor.java
@@ -0,0 +1,116 @@
+/*
+ *
+ * Copyright 2002-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.sun;
+import java.util.Vector;
+import net.sf.antcontrib.cpptasks.types.LibraryTypeEnum;
+
+/**
+ * A add-in class for Sun C89 compilers and linkers
+ *
+ * @author Hiram Chirino (cojonudo14@hotmail.com)
+ */
+public class C89Processor {
+ private static int addLibraryPatterns(String[] libnames, StringBuffer buf,
+ String prefix, String extension, String[] patterns, int offset) {
+ for (int i = 0; i < libnames.length; i++) {
+ buf.setLength(0);
+ buf.append(prefix);
+ buf.append(libnames[i]);
+ buf.append(extension);
+ patterns[offset + i] = buf.toString();
+ }
+ return offset + libnames.length;
+ }
+ public static void addWarningSwitch(Vector args, int level) {
+ switch (level) {
+ /*
+ * case 0: args.addElement("/W0"); break;
+ *
+ * case 1: args.addElement("/W1"); break;
+ *
+ * case 2: break;
+ *
+ * case 3: args.addElement("/W3"); break;
+ *
+ * case 4: args.addElement("/W4"); break;
+ */
+ }
+ }
+ public static String getCommandFileSwitch(String cmdFile) {
+ StringBuffer buf = new StringBuffer("@");
+ if (cmdFile.indexOf(' ') >= 0) {
+ buf.append('\"');
+ buf.append(cmdFile);
+ buf.append('\"');
+ } else {
+ buf.append(cmdFile);
+ }
+ return buf.toString();
+ }
+ public static void getDefineSwitch(StringBuffer buf, String define,
+ String value) {
+ buf.setLength(0);
+ buf.append("-D");
+ buf.append(define);
+ if (value != null && value.length() > 0) {
+ buf.append('=');
+ buf.append(value);
+ }
+ }
+ public static String getIncludeDirSwitch(String includeDir) {
+ return "-I" + includeDir;
+ }
+ public static String[] getLibraryPatterns(String[] libnames, LibraryTypeEnum libType) {
+ StringBuffer buf = new StringBuffer();
+ int patternCount = libnames.length*2;
+ if (libType != null) {
+ patternCount = libnames.length;
+ }
+ String[] patterns = new String[patternCount];
+ int offset = 0;
+ if (libType == null || "static".equals(libType.getValue())) {
+ offset = addLibraryPatterns(libnames, buf, "lib", ".a", patterns, 0);
+ }
+ if (libType == null || !"static".equals(libType.getValue())) {
+ offset = addLibraryPatterns(libnames, buf, "lib", ".so", patterns,
+ offset);
+ }
+ return patterns;
+ }
+ public static String[] getOutputFileSwitch(String outPath) {
+ StringBuffer buf = new StringBuffer("-o ");
+ if (outPath.indexOf(' ') >= 0) {
+ buf.append('\"');
+ buf.append(outPath);
+ buf.append('\"');
+ } else {
+ buf.append(outPath);
+ }
+ String[] retval = new String[]{buf.toString()};
+ return retval;
+ }
+ public static void getUndefineSwitch(StringBuffer buf, String define) {
+ buf.setLength(0);
+ buf.append("-U");
+ buf.append(define);
+ }
+ public static boolean isCaseSensitive() {
+ return true;
+ }
+ private C89Processor() {
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/sun/ForteCCCompiler.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/sun/ForteCCCompiler.java
new file mode 100644
index 0000000000..a35d01af49
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/sun/ForteCCCompiler.java
@@ -0,0 +1,119 @@
+/*
+ *
+ * Copyright 2001-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.sun;
+import java.io.File;
+import java.util.Vector;
+
+import net.sf.antcontrib.cpptasks.CUtil;
+import net.sf.antcontrib.cpptasks.compiler.LinkType;
+import net.sf.antcontrib.cpptasks.compiler.Linker;
+import net.sf.antcontrib.cpptasks.gcc.GccCompatibleCCompiler;
+import net.sf.antcontrib.cpptasks.OptimizationEnum;
+/**
+ * Adapter for the Sun (r) Forte (tm) C++ compiler
+ *
+ * @author Curt Arnold
+ */
+public final class ForteCCCompiler extends GccCompatibleCCompiler {
+ private static final ForteCCCompiler instance = new ForteCCCompiler("CC");
+ /**
+ * Gets singleton instance of this class
+ */
+ public static ForteCCCompiler getInstance() {
+ return instance;
+ }
+ private String identifier;
+ private File[] includePath;
+ /**
+ * Private constructor. Use ForteCCCompiler.getInstance() to get singleton
+ * instance of this class.
+ */
+ private ForteCCCompiler(String command) {
+ super(command, "-V", false, null, false, null);
+ }
+ public void addImpliedArgs(final Vector args,
+ final boolean debug,
+ final boolean multithreaded,
+ final boolean exceptions,
+ final LinkType linkType,
+ final Boolean rtti,
+ final OptimizationEnum optimization) {
+ args.addElement("-c");
+ if (debug) {
+ args.addElement("-g");
+ }
+ if (optimization != null) {
+ if (optimization.isSpeed()) {
+ args.addElement("-xO2");
+ }
+ }
+ if (rtti != null) {
+ if (rtti.booleanValue()) {
+ args.addElement("-features=rtti");
+ } else {
+ args.addElement("-features=no%rtti");
+ }
+ }
+ if (multithreaded) {
+ args.addElement("-mt");
+ }
+ if (linkType.isSharedLibrary()) {
+ args.addElement("-KPIC");
+ }
+
+ }
+ public void addWarningSwitch(Vector args, int level) {
+ switch (level) {
+ case 0 :
+ args.addElement("-w");
+ break;
+ case 1 :
+ case 2 :
+ args.addElement("+w");
+ break;
+ case 3 :
+ case 4 :
+ case 5 :
+ args.addElement("+w2");
+ break;
+ }
+ }
+ public File[] getEnvironmentIncludePath() {
+ if (includePath == null) {
+ File ccLoc = CUtil.getExecutableLocation("CC");
+ if (ccLoc != null) {
+ File compilerIncludeDir = new File(
+ new File(ccLoc, "../include").getAbsolutePath());
+ if (compilerIncludeDir.exists()) {
+ includePath = new File[2];
+ includePath[0] = compilerIncludeDir;
+ }
+ }
+ if (includePath == null) {
+ includePath = new File[1];
+ }
+ includePath[includePath.length - 1] = new File("/usr/include");
+ }
+ return includePath;
+ }
+ public Linker getLinker(LinkType linkType) {
+ return ForteCCLinker.getInstance().getLinker(linkType);
+ }
+ public int getMaximumCommandLength() {
+ return Integer.MAX_VALUE;
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/sun/ForteCCLinker.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/sun/ForteCCLinker.java
new file mode 100644
index 0000000000..c39071af9f
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/sun/ForteCCLinker.java
@@ -0,0 +1,100 @@
+/*
+ *
+ * Copyright 2001-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.sun;
+import java.io.File;
+import java.util.Vector;
+
+import net.sf.antcontrib.cpptasks.CUtil;
+import net.sf.antcontrib.cpptasks.compiler.LinkType;
+import net.sf.antcontrib.cpptasks.compiler.Linker;
+import net.sf.antcontrib.cpptasks.gcc.AbstractLdLinker;
+/**
+ * Adapter for Sun (r) Forte(tm) C++ Linker
+ *
+ * @author Curt Arnold
+ */
+public final class ForteCCLinker extends AbstractLdLinker {
+ private static final String[] discardFiles = new String[]{".dll", ".so",
+ ".sl"};
+ private static final String[] objFiles = new String[]{".o", ".a", ".lib"};
+ private static final ForteCCLinker arLinker = new ForteCCLinker("CC",
+ objFiles, discardFiles, "lib", ".a");
+ private static final ForteCCLinker dllLinker = new ForteCCLinker("CC",
+ objFiles, discardFiles, "lib", ".so");
+ private static final ForteCCLinker instance = new ForteCCLinker("CC",
+ objFiles, discardFiles, "", "");
+ public static ForteCCLinker getInstance() {
+ return instance;
+ }
+ private File[] libDirs;
+ private ForteCCLinker(String command, String[] extensions,
+ String[] ignoredExtensions, String outputPrefix, String outputSuffix) {
+ super(command, "-V", extensions, ignoredExtensions, outputPrefix,
+ outputSuffix, false, null);
+ }
+ public void addImpliedArgs(boolean debug, LinkType linkType, Vector args) {
+ if (debug) {
+ args.addElement("-g");
+ }
+ if (linkType.isStaticRuntime()) {
+ args.addElement("-static");
+ }
+ if (linkType.isSharedLibrary()) {
+ args.addElement("-G");
+ }
+ if (linkType.isStaticLibrary()) {
+ args.addElement("-xar");
+ }
+ }
+ public void addIncremental(boolean incremental, Vector args) {
+ /*
+ * if (incremental) { args.addElement("-xidlon"); } else {
+ * args.addElement("-xidloff"); }
+ */
+ }
+ /**
+ * Returns library path.
+ *
+ */
+ public File[] getLibraryPath() {
+ if (libDirs == null) {
+ File CCloc = CUtil.getExecutableLocation("CC");
+ if (CCloc != null) {
+ File compilerLib = new File(new File(CCloc, "../lib")
+ .getAbsolutePath());
+ if (compilerLib.exists()) {
+ libDirs = new File[2];
+ libDirs[0] = compilerLib;
+ }
+ }
+ if (libDirs == null) {
+ libDirs = new File[1];
+ }
+ }
+ libDirs[libDirs.length - 1] = new File("/usr/lib");
+ return libDirs;
+ }
+ public Linker getLinker(LinkType type) {
+ if (type.isStaticLibrary()) {
+ return arLinker;
+ }
+ if (type.isSharedLibrary()) {
+ return dllLinker;
+ }
+ return instance;
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/ti/ClxxCCompiler.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/ti/ClxxCCompiler.java
new file mode 100644
index 0000000000..d08b9fbbf6
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/ti/ClxxCCompiler.java
@@ -0,0 +1,192 @@
+/*
+ *
+ * Copyright 2001-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.ti;
+import java.io.File;
+import java.util.Vector;
+
+import net.sf.antcontrib.cpptasks.CUtil;
+import net.sf.antcontrib.cpptasks.compiler.CommandLineCCompiler;
+import net.sf.antcontrib.cpptasks.compiler.LinkType;
+import net.sf.antcontrib.cpptasks.compiler.Linker;
+import net.sf.antcontrib.cpptasks.OptimizationEnum;
+
+
+import org.apache.tools.ant.types.Environment;
+/**
+ * Adapter for TI DSP compilers with cl** commands
+ *
+ * @author CurtA
+ */
+public class ClxxCCompiler extends CommandLineCCompiler {
+ /**
+ * Header file extensions
+ */
+ private static final String[] headerExtensions = new String[]{".h", ".hpp",
+ ".inl"};
+ /**
+ * Source file extensions
+ */
+ private static final String[] sourceExtensions = new String[]{".c", ".cc",
+ ".cpp", ".cxx", ".c++"};
+ /**
+ * Singleton for TMS320C55x
+ */
+ private static final ClxxCCompiler cl55 = new ClxxCCompiler("cl55", false,
+ null);
+ /**
+ * Singleton for TMS320C6000
+ */
+ private static final ClxxCCompiler cl6x = new ClxxCCompiler("cl6x", false,
+ null);
+ public static ClxxCCompiler getCl55Instance() {
+ return cl55;
+ }
+ public static ClxxCCompiler getCl6xInstance() {
+ return cl6x;
+ }
+ /**
+ * Private constructor
+ *
+ * @param command
+ * executable name
+ * @param newEnvironment
+ * Change environment
+ * @param env
+ * New environment
+ */
+ private ClxxCCompiler(String command, boolean newEnvironment,
+ Environment env) {
+ super(command, "-h", sourceExtensions, headerExtensions, ".o", false,
+ null, newEnvironment, env);
+ }
+ /*
+ * (non-Javadoc)
+ *
+ * @see net.sf.antcontrib.cpptasks.compiler.CommandLineCompiler#addImpliedArgs(java.util.Vector,
+ * boolean, boolean, boolean,
+ * net.sf.antcontrib.cpptasks.compiler.LinkType)
+ */
+ protected void addImpliedArgs(
+ final Vector args,
+ final boolean debug,
+ final boolean multithreaded,
+ final boolean exceptions,
+ final LinkType linkType,
+ final Boolean rtti,
+ final OptimizationEnum optimization,
+ final Boolean defaultflag) {
+ if (debug) {
+ args.addElement("-gw");
+ }
+ }
+ /*
+ * (non-Javadoc)
+ *
+ * @see net.sf.antcontrib.cpptasks.compiler.CommandLineCompiler#addWarningSwitch(java.util.Vector,
+ * int)
+ */
+ protected void addWarningSwitch(Vector args, int warnings) {
+ // TODO Auto-generated method stub
+ }
+ /*
+ * (non-Javadoc)
+ *
+ * @see net.sf.antcontrib.cpptasks.compiler.CommandLineCompiler#getDefineSwitch(java.lang.StringBuffer,
+ * java.lang.String, java.lang.String)
+ */
+ protected void getDefineSwitch(StringBuffer buffer, String define,
+ String value) {
+ buffer.append("-d");
+ buffer.append(define);
+ if (value != null) {
+ buffer.append('=');
+ buffer.append(value);
+ }
+ }
+ /*
+ * (non-Javadoc)
+ *
+ * @see net.sf.antcontrib.cpptasks.compiler.CommandLineCompiler#getEnvironmentIncludePath()
+ */
+ protected File[] getEnvironmentIncludePath() {
+ File[] c_dir = CUtil.getPathFromEnvironment("C_DIR", ";");
+ File[] cx_dir = CUtil.getPathFromEnvironment("C6X_C_DIR", ";");
+ if (c_dir.length == 0) {
+ return cx_dir;
+ }
+ if (cx_dir.length == 0) {
+ return c_dir;
+ }
+ File[] combo = new File[c_dir.length + cx_dir.length];
+ for (int i = 0; i < cx_dir.length; i++) {
+ combo[i] = cx_dir[i];
+ }
+ for (int i = 0; i < c_dir.length; i++) {
+ combo[i + cx_dir.length] = c_dir[i];
+ }
+ return combo;
+ }
+ /*
+ * (non-Javadoc)
+ *
+ * @see net.sf.antcontrib.cpptasks.compiler.CommandLineCompiler#getIncludeDirSwitch(java.lang.String)
+ */
+ protected String getIncludeDirSwitch(String source) {
+ return "-I" + source;
+ }
+ /*
+ * (non-Javadoc)
+ *
+ * @see net.sf.antcontrib.cpptasks.compiler.Processor#getLinker(net.sf.antcontrib.cpptasks.compiler.LinkType)
+ */
+ public Linker getLinker(LinkType type) {
+ if (type.isStaticLibrary()) {
+ if (this == cl6x) {
+ return ClxxLibrarian.getCl6xInstance();
+ }
+ return ClxxLibrarian.getCl55Instance();
+ }
+ if (type.isSharedLibrary()) {
+ if (this == cl6x) {
+ return ClxxLinker.getCl6xDllInstance();
+ }
+ return ClxxLinker.getCl55DllInstance();
+ }
+ if (this == cl6x) {
+ return ClxxLinker.getCl6xInstance();
+ }
+ return ClxxLinker.getCl55Instance();
+ }
+ /*
+ * (non-Javadoc)
+ *
+ * @see net.sf.antcontrib.cpptasks.compiler.CommandLineCompiler#getMaximumCommandLength()
+ */
+ public int getMaximumCommandLength() {
+ return 1024;
+ }
+ /*
+ * (non-Javadoc)
+ *
+ * @see net.sf.antcontrib.cpptasks.compiler.CommandLineCompiler#getUndefineSwitch(java.lang.StringBuffer,
+ * java.lang.String)
+ */
+ protected void getUndefineSwitch(StringBuffer buffer, String define) {
+ buffer.append("-u");
+ buffer.append(define);
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/ti/ClxxLibrarian.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/ti/ClxxLibrarian.java
new file mode 100644
index 0000000000..082d1a477f
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/ti/ClxxLibrarian.java
@@ -0,0 +1,162 @@
+/*
+ *
+ * Copyright 2001-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.ti;
+import java.io.File;
+import java.util.Vector;
+
+import net.sf.antcontrib.cpptasks.compiler.CommandLineLinker;
+import net.sf.antcontrib.cpptasks.compiler.LinkType;
+import net.sf.antcontrib.cpptasks.compiler.Linker;
+import net.sf.antcontrib.cpptasks.types.LibraryTypeEnum;
+
+/**
+ *
+ * Adapter for TI DSP librarian
+ * *
+ * @author CurtA
+ */
+public class ClxxLibrarian extends CommandLineLinker {
+ private static final ClxxLibrarian cl55Instance = new ClxxLibrarian("ar55");
+ private static final ClxxLibrarian cl6xInstance = new ClxxLibrarian("ar6x");
+ public static final ClxxLibrarian getCl55Instance() {
+ return cl55Instance;
+ }
+ public static final ClxxLibrarian getCl6xInstance() {
+ return cl6xInstance;
+ }
+ private ClxxLibrarian(String command) {
+ super(command, null, new String[]{".o"}, new String[0], ".lib", false,
+ null);
+ }
+ /*
+ * (non-Javadoc)
+ *
+ * @see net.sf.antcontrib.cpptasks.compiler.CommandLineLinker#addBase(long,
+ * java.util.Vector)
+ */
+ protected void addBase(long base, Vector args) {
+ // TODO Auto-generated method stub
+ }
+ /*
+ * (non-Javadoc)
+ *
+ * @see net.sf.antcontrib.cpptasks.compiler.CommandLineLinker#addFixed(java.lang.Boolean,
+ * java.util.Vector)
+ */
+ protected void addFixed(Boolean fixed, Vector args) {
+ // TODO Auto-generated method stub
+ }
+ /*
+ * (non-Javadoc)
+ *
+ * @see net.sf.antcontrib.cpptasks.compiler.CommandLineLinker#addImpliedArgs(boolean,
+ * net.sf.antcontrib.cpptasks.compiler.LinkType, java.util.Vector)
+ */
+ protected void addImpliedArgs(boolean debug, LinkType linkType, Vector args, Boolean defaultflag) {
+ // TODO Auto-generated method stub
+ }
+ /*
+ * (non-Javadoc)
+ *
+ * @see net.sf.antcontrib.cpptasks.compiler.CommandLineLinker#addIncremental(boolean,
+ * java.util.Vector)
+ */
+ protected void addIncremental(boolean incremental, Vector args) {
+ // TODO Auto-generated method stub
+ }
+ /*
+ * (non-Javadoc)
+ *
+ * @see net.sf.antcontrib.cpptasks.compiler.CommandLineLinker#addMap(boolean,
+ * java.util.Vector)
+ */
+ protected void addMap(boolean map, Vector args) {
+ // TODO Auto-generated method stub
+ }
+ /*
+ * (non-Javadoc)
+ *
+ * @see net.sf.antcontrib.cpptasks.compiler.CommandLineLinker#addStack(int,
+ * java.util.Vector)
+ */
+ protected void addStack(int stack, Vector args) {
+ // TODO Auto-generated method stub
+ }
+ /* (non-Javadoc)
+ * @see net.sf.antcontrib.cpptasks.compiler.CommandLineLinker#addEntry(int, java.util.Vector)
+ */
+ protected void addEntry(String entry, Vector args) {
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see net.sf.antcontrib.cpptasks.compiler.CommandLineLinker#getCommandFileSwitch(java.lang.String)
+ */
+ protected String getCommandFileSwitch(String commandFile) {
+ return "@" + commandFile;
+ }
+ /*
+ * (non-Javadoc)
+ *
+ * @see net.sf.antcontrib.cpptasks.compiler.Linker#getLibraryPath()
+ */
+ public File[] getLibraryPath() {
+ return new File[0];
+ }
+ /*
+ * (non-Javadoc)
+ *
+ * @see net.sf.antcontrib.cpptasks.compiler.Linker#getLibraryPatterns(java.lang.String[])
+ */
+ public String[] getLibraryPatterns(String[] libnames, LibraryTypeEnum libType) {
+ return new String[0];
+ }
+ /*
+ * (non-Javadoc)
+ *
+ * @see net.sf.antcontrib.cpptasks.compiler.Processor#getLinker(net.sf.antcontrib.cpptasks.compiler.LinkType)
+ */
+ public Linker getLinker(LinkType linkType) {
+ return null;
+ }
+ /*
+ * (non-Javadoc)
+ *
+ * @see net.sf.antcontrib.cpptasks.compiler.CommandLineLinker#getMaximumCommandLength()
+ */
+ protected int getMaximumCommandLength() {
+ return 1024;
+ }
+ /*
+ * (non-Javadoc)
+ *
+ * @see net.sf.antcontrib.cpptasks.compiler.CommandLineLinker#getOutputFileSwitch(java.lang.String)
+ */
+ protected String[] getOutputFileSwitch(String outputFile) {
+ return new String[]{"-o", outputFile};
+ }
+ /*
+ * (non-Javadoc)
+ *
+ * @see net.sf.antcontrib.cpptasks.compiler.Linker#isCaseSensitive()
+ */
+ public boolean isCaseSensitive() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/ti/ClxxLinker.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/ti/ClxxLinker.java
new file mode 100644
index 0000000000..43ee7c0662
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/ti/ClxxLinker.java
@@ -0,0 +1,181 @@
+/*
+ *
+ * Copyright 2001-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.ti;
+import java.io.File;
+import java.util.Vector;
+
+import net.sf.antcontrib.cpptasks.compiler.CommandLineLinker;
+import net.sf.antcontrib.cpptasks.compiler.LinkType;
+import net.sf.antcontrib.cpptasks.compiler.Linker;
+import net.sf.antcontrib.cpptasks.types.LibraryTypeEnum;
+
+/**
+ * Adapter for TI DSP linkers
+ * *
+ * @author CurtA
+ *
+ */
+public class ClxxLinker extends CommandLineLinker {
+ private static final ClxxLinker cl55DllInstance = new ClxxLinker("lnk55",
+ ".dll");
+ private static final ClxxLinker cl55Instance = new ClxxLinker("lnk55",
+ ".exe");
+ private static final ClxxLinker cl6xDllInstance = new ClxxLinker("lnk6x",
+ ".dll");
+ private static final ClxxLinker cl6xInstance = new ClxxLinker("lnk6x",
+ ".exe");
+ public static ClxxLinker getCl55DllInstance() {
+ return cl55DllInstance;
+ }
+ public static ClxxLinker getCl55Instance() {
+ return cl55Instance;
+ }
+ public static ClxxLinker getCl6xDllInstance() {
+ return cl6xDllInstance;
+ }
+ public static ClxxLinker getCl6xInstance() {
+ return cl6xInstance;
+ }
+ private ClxxLinker(String command, String outputSuffix) {
+ super(command, "-h", new String[]{".o", ".lib", ".res"}, new String[]{
+ ".map", ".pdb", ".lnk"}, outputSuffix, false, null);
+ }
+ /*
+ * (non-Javadoc)
+ *
+ * @see net.sf.antcontrib.cpptasks.compiler.CommandLineLinker#addBase(long,
+ * java.util.Vector)
+ */
+ protected void addBase(long base, Vector args) {
+ }
+ /*
+ * (non-Javadoc)
+ *
+ * @see net.sf.antcontrib.cpptasks.compiler.CommandLineLinker#addFixed(java.lang.Boolean,
+ * java.util.Vector)
+ */
+ protected void addFixed(Boolean fixed, Vector args) {
+ }
+ /*
+ * (non-Javadoc)
+ *
+ * @see net.sf.antcontrib.cpptasks.compiler.CommandLineLinker#addImpliedArgs(boolean,
+ * net.sf.antcontrib.cpptasks.compiler.LinkType, java.util.Vector)
+ */
+ protected void addImpliedArgs(boolean debug, LinkType linkType, Vector args, Boolean defaultflag) {
+ if (linkType.isSharedLibrary()) {
+ args.addElement("-abs");
+ }
+ }
+ /*
+ * (non-Javadoc)
+ *
+ * @see net.sf.antcontrib.cpptasks.compiler.CommandLineLinker#addIncremental(boolean,
+ * java.util.Vector)
+ */
+ protected void addIncremental(boolean incremental, Vector args) {
+ }
+ /*
+ * (non-Javadoc)
+ *
+ * @see net.sf.antcontrib.cpptasks.compiler.CommandLineLinker#addMap(boolean,
+ * java.util.Vector)
+ */
+ protected void addMap(boolean map, Vector args) {
+ if (map) {
+ args.addElement("-m");
+ }
+ }
+ /*
+ * (non-Javadoc)
+ *
+ * @see net.sf.antcontrib.cpptasks.compiler.CommandLineLinker#addStack(int,
+ * java.util.Vector)
+ */
+ protected void addStack(int stack, Vector args) {
+ }
+ /* (non-Javadoc)
+ * @see net.sf.antcontrib.cpptasks.compiler.CommandLineLinker#addEntry(int, java.util.Vector)
+ */
+ protected void addEntry(String entry, Vector args) {
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see net.sf.antcontrib.cpptasks.compiler.CommandLineLinker#getCommandFileSwitch(java.lang.String)
+ */
+ protected String getCommandFileSwitch(String commandFile) {
+ return "@" + commandFile;
+ }
+ /*
+ * (non-Javadoc)
+ *
+ * @see net.sf.antcontrib.cpptasks.compiler.Linker#getLibraryPath()
+ */
+ public File[] getLibraryPath() {
+ return new File[0];
+ }
+ /*
+ * (non-Javadoc)
+ *
+ * @see net.sf.antcontrib.cpptasks.compiler.Linker#getLibraryPatterns(java.lang.String[])
+ */
+ public String[] getLibraryPatterns(String[] libnames, LibraryTypeEnum libType) {
+ //
+ // TODO: Looks bogus, should be .a or .so's not .o's
+ //
+ String[] libpats = new String[libnames.length];
+ for (int i = 0; i < libnames.length; i++) {
+ libpats[i] = libnames[i] + ".o";
+ }
+ return libpats;
+ }
+ /*
+ * (non-Javadoc)
+ *
+ * @see net.sf.antcontrib.cpptasks.compiler.Processor#getLinker(net.sf.antcontrib.cpptasks.compiler.LinkType)
+ */
+ public Linker getLinker(LinkType linkType) {
+ return this;
+ }
+ /*
+ * (non-Javadoc)
+ *
+ * @see net.sf.antcontrib.cpptasks.compiler.CommandLineLinker#getMaximumCommandLength()
+ */
+ protected int getMaximumCommandLength() {
+ return 1024;
+ }
+ /*
+ * (non-Javadoc)
+ *
+ * @see net.sf.antcontrib.cpptasks.compiler.CommandLineLinker#getOutputFileSwitch(java.lang.String)
+ */
+ protected String[] getOutputFileSwitch(String outputFile) {
+ return new String[]{"-o", outputFile};
+ }
+ /*
+ * (non-Javadoc)
+ *
+ * @see net.sf.antcontrib.cpptasks.compiler.Linker#isCaseSensitive()
+ */
+ public boolean isCaseSensitive() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/types/AslcompilerArgument.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/types/AslcompilerArgument.java
new file mode 100644
index 0000000000..87babcf740
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/types/AslcompilerArgument.java
@@ -0,0 +1,30 @@
+/*
+ *
+ * Copyright 2001-2005 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.types;
+
+/**
+ * A aslcompiler command line argument.
+ */
+public class AslcompilerArgument extends CommandLineArgument {
+ public AslcompilerArgument () {
+ }
+
+ public void execute() throws org.apache.tools.ant.BuildException {
+ throw new org.apache.tools.ant.BuildException(
+ "Not an actual task, but looks like one for documentation purposes");
+ }
+}
\ No newline at end of file
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/types/AssemblerArgument.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/types/AssemblerArgument.java
new file mode 100644
index 0000000000..1b5f54d9a7
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/types/AssemblerArgument.java
@@ -0,0 +1,30 @@
+/*
+ *
+ * Copyright 2001-2005 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.types;
+
+/**
+ * A assembler command line argument.
+ */
+public class AssemblerArgument extends CommandLineArgument {
+ public AssemblerArgument () {
+ }
+
+ public void execute() throws org.apache.tools.ant.BuildException {
+ throw new org.apache.tools.ant.BuildException(
+ "Not an actual task, but looks like one for documentation purposes");
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/types/CommandLineArgument.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/types/CommandLineArgument.java
new file mode 100644
index 0000000000..91ab2f6327
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/types/CommandLineArgument.java
@@ -0,0 +1,122 @@
+/*
+ *
+ * Copyright 2001-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.types;
+
+import org.apache.tools.ant.types.EnumeratedAttribute;
+import java.io.File;
+/**
+ * An compiler/linker command line flag.
+ */
+public class CommandLineArgument {
+ /**
+ * Enumerated attribute with the values "start", "mid" and "end",
+ */
+ public static class LocationEnum extends EnumeratedAttribute {
+ public String[] getValues() {
+ return new String[]{"start", "mid", "end"};
+ }
+ }
+ private String ifCond;
+ private int location;
+ private String unlessCond;
+ private String value;
+ private File file;
+ public CommandLineArgument() {
+ }
+ public int getLocation() {
+ return location;
+ }
+ public String getValue() {
+ return value;
+ }
+ public File getFile() {
+ return file;
+ }
+ /**
+ * Returns true if the define's if and unless conditions (if any) are
+ * satisfied.
+ */
+ public boolean isActive(org.apache.tools.ant.Project p) {
+ if (value == null) {
+ return false;
+ }
+ if (ifCond != null && p.getProperty(ifCond) == null) {
+ return false;
+ } else if (unlessCond != null && p.getProperty(unlessCond) != null) {
+ return false;
+ }
+ return true;
+ }
+ /**
+ * Sets the property name for the 'if' condition.
+ *
+ * The argument will be ignored unless the property is defined.
+ *
+ * The value of the property is insignificant, but values that would imply
+ * misinterpretation ("false", "no") will throw an exception when
+ * evaluated.
+ */
+ public void setIf(String propName) {
+ ifCond = propName;
+ }
+ /**
+ * Specifies relative location of argument on command line. "start" will
+ * place argument at start of command line, "mid" will place argument after
+ * all "start" arguments but before filenames, "end" will place argument
+ * after filenames.
+ *
+ */
+ public void setLocation(LocationEnum location) {
+ this.location = location.getIndex();
+ }
+ /**
+ * Set the property name for the 'unless' condition.
+ *
+ * If named property is set, the argument will be ignored.
+ *
+ * The value of the property is insignificant, but values that would imply
+ * misinterpretation ("false", "no") of the behavior will throw an
+ * exception when evaluated.
+ *
+ * @param propName
+ * name of property
+ */
+ public void setUnless(String propName) {
+ unlessCond = propName;
+ }
+ /**
+ * Specifies the string that should appear on the command line. The
+ * argument will be quoted if it contains embedded blanks. Use multiple
+ * arguments to avoid quoting.
+ *
+ */
+ public void setValue(String value) {
+ this.value = value;
+ }
+ /**
+ * Specifies the file which lists many strings that should appear on
+ * the command line. Each line is one argument. The argument will be
+ * quated if it contains embedded blanks. Use multiple arguments in
+ * file to avoid quating.
+ *
+ * @param file
+ * name of the file
+ */
+ public void setFile(File file) {
+ this.file = file;
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/types/CompilerArgument.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/types/CompilerArgument.java
new file mode 100644
index 0000000000..ca9e90e732
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/types/CompilerArgument.java
@@ -0,0 +1,28 @@
+/*
+ *
+ * Copyright 2001-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.types;
+/**
+ * A compiler command line argument.
+ */
+public class CompilerArgument extends CommandLineArgument {
+ public CompilerArgument() {
+ }
+ public void execute() throws org.apache.tools.ant.BuildException {
+ throw new org.apache.tools.ant.BuildException(
+ "Not an actual task, but looks like one for documentation purposes");
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/types/ConditionalFileSet.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/types/ConditionalFileSet.java
new file mode 100644
index 0000000000..af2d141e99
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/types/ConditionalFileSet.java
@@ -0,0 +1,84 @@
+/*
+ *
+ * Copyright 2001-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.types;
+import net.sf.antcontrib.cpptasks.CUtil;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.types.AbstractFileSet;
+import org.apache.tools.ant.types.FileSet;
+/**
+ * An Ant FileSet object augmented with if and unless conditions.
+ *
+ * @author Curt Arnold
+ */
+public class ConditionalFileSet extends FileSet {
+ private String ifCond;
+ private String unlessCond;
+ public ConditionalFileSet() {
+ }
+ public void execute() throws org.apache.tools.ant.BuildException {
+ throw new org.apache.tools.ant.BuildException(
+ "Not an actual task, but looks like one for documentation purposes");
+ }
+ /**
+ * overrides FileSet's implementation which would throw an exception since
+ * the referenced object isn't this type.
+ */
+ protected AbstractFileSet getRef(Project p) {
+ return (AbstractFileSet) getRefid().getReferencedObject(p);
+ }
+ /**
+ * Returns true if the Path's if and unless conditions (if any) are
+ * satisfied.
+ */
+ public boolean isActive() throws BuildException {
+ Project p = getProject();
+ if (p == null) {
+ throw new java.lang.IllegalStateException(
+ "setProject() should have been called");
+ }
+ return CUtil.isActive(p, ifCond, unlessCond);
+ }
+ /**
+ * Sets the property name for the 'if' condition.
+ *
+ * The fileset will be ignored unless the property is defined.
+ *
+ * The value of the property is insignificant, but values that would imply
+ * misinterpretation ("false", "no") will throw an exception when
+ * evaluated.
+ */
+ public void setIf(String propName) {
+ ifCond = propName;
+ }
+ /**
+ * Set the property name for the 'unless' condition.
+ *
+ * If named property is set, the fileset will be ignored.
+ *
+ * The value of the property is insignificant, but values that would imply
+ * misinterpretation ("false", "no") of the behavior will throw an
+ * exception when evaluated.
+ *
+ * @param propName
+ * name of property
+ */
+ public void setUnless(String propName) {
+ unlessCond = propName;
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/types/ConditionalPath.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/types/ConditionalPath.java
new file mode 100644
index 0000000000..dc21189c15
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/types/ConditionalPath.java
@@ -0,0 +1,92 @@
+/*
+ *
+ * Copyright 2001-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.types;
+import java.io.File;
+
+import net.sf.antcontrib.cpptasks.CUtil;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.types.Path;
+/**
+ * An Ant Path object augmented with if and unless conditionals
+ *
+ * @author Curt Arnold
+ */
+public class ConditionalPath extends Path {
+ private String ifCond;
+ private String unlessCond;
+ private File file;
+ public ConditionalPath(Project project) {
+ super(project);
+ }
+ public ConditionalPath(Project p, String path) {
+ super(p, path);
+ }
+ public File getFile() {
+ return file;
+ }
+ /**
+ * Returns true if the Path's if and unless conditions (if any) are
+ * satisfied.
+ */
+ public boolean isActive(org.apache.tools.ant.Project p)
+ throws BuildException {
+ return CUtil.isActive(p, ifCond, unlessCond);
+ }
+ /**
+ * Sets the property name for the 'if' condition.
+ *
+ * The path will be ignored unless the property is defined.
+ *
+ * The value of the property is insignificant, but values that would imply
+ * misinterpretation ("false", "no") will throw an exception when
+ * evaluated.
+ *
+ * @param propName
+ * property name
+ */
+ public void setIf(String propName) {
+ ifCond = propName;
+ }
+ /**
+ * Set the property name for the 'unless' condition.
+ *
+ * If named property is set, the path will be ignored.
+ *
+ * The value of the property is insignificant, but values that would imply
+ * misinterpretation ("false", "no") of the behavior will throw an
+ * exception when evaluated.
+ *
+ * @param propName
+ * name of property
+ */
+ public void setUnless(String propName) {
+ unlessCond = propName;
+ }
+ /**
+ * Specifies the file which lists many include paths that should appear on
+ * the command line. Each line is an include path. The includepath will be
+ * quated if it contains embedded blanks.
+ *
+ * @param file
+ * name of the file
+ */
+ public void setFile(File file) {
+ this.file = file;
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/types/DefineArgument.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/types/DefineArgument.java
new file mode 100644
index 0000000000..824e939481
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/types/DefineArgument.java
@@ -0,0 +1,38 @@
+/*
+ *
+ * Copyright 2001-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.types;
+/**
+ * Preprocessor macro definition.
+ *
+ * @author Mark A Russell mark_russell@csg_systems.com
+ *
+ */
+public class DefineArgument extends UndefineArgument {
+ private String value;
+ public DefineArgument() {
+ super(true);
+ }
+ /** Returns the value of the define */
+ public final String getValue() {
+ return value;
+ }
+ /** Set the value attribute */
+ public final void setValue(String value) {
+ this.value = value;
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/types/DefineSet.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/types/DefineSet.java
new file mode 100644
index 0000000000..9d229fb0ff
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/types/DefineSet.java
@@ -0,0 +1,199 @@
+/*
+ *
+ * Copyright 2001-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.types;
+import java.util.Vector;
+
+import net.sf.antcontrib.cpptasks.CUtil;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.types.DataType;
+import org.apache.tools.ant.types.Reference;
+/**
+ * Set of preprocessor macro defines and undefines.
+ *
+ * @author Mark A Russell mark_russell@csg_systems.com
+ *
+ * @author Adam Murdoch
+ */
+public class DefineSet extends DataType {
+ private Vector defineList = new Vector();
+ private String ifCond = null;
+ private String unlessCond = null;
+ /**
+ *
+ * Adds a define element.
+ *
+ * @throws BuildException
+ * if reference
+ */
+ public void addDefine(DefineArgument arg) throws BuildException {
+ if (isReference()) {
+ throw noChildrenAllowed();
+ }
+ defineList.addElement(arg);
+ }
+ /** Adds defines/undefines. */
+ private void addDefines(String[] defs, boolean isDefine) {
+ for (int i = 0; i < defs.length; i++) {
+ UndefineArgument def;
+ if (isDefine) {
+ def = new DefineArgument();
+ } else {
+ def = new UndefineArgument();
+ }
+ def.setName(defs[i]);
+ defineList.addElement(def);
+ }
+ }
+ /**
+ *
+ * Adds an undefine element.
+ *
+ * @throws BuildException
+ * if reference
+ */
+ public void addUndefine(UndefineArgument arg) throws BuildException {
+ if (isReference()) {
+ throw noChildrenAllowed();
+ }
+ defineList.addElement(arg);
+ }
+ public void execute() throws org.apache.tools.ant.BuildException {
+ throw new org.apache.tools.ant.BuildException(
+ "Not an actual task, but looks like one for documentation purposes");
+ }
+ /** Returns the defines and undefines in this set. */
+ public UndefineArgument[] getDefines() throws BuildException {
+ if (isReference()) {
+ DefineSet defset = (DefineSet) getCheckedRef(DefineSet.class,
+ "DefineSet");
+ return defset.getDefines();
+ } else {
+ if (isActive()) {
+ UndefineArgument[] defs = new UndefineArgument[defineList
+ .size()];
+ defineList.copyInto(defs);
+ return defs;
+ } else {
+ return new UndefineArgument[0];
+ }
+ }
+ }
+ /**
+ * Returns true if the define's if and unless conditions (if any) are
+ * satisfied.
+ *
+ * @exception BuildException
+ * throws build exception if name is not set
+ */
+ public final boolean isActive() throws BuildException {
+ return CUtil.isActive(getProject(), ifCond, unlessCond);
+ }
+ /**
+ * A comma-separated list of preprocessor macros to define. Use nested
+ * define elements to define macro values.
+ *
+ * @param defList
+ * comma-separated list of preprocessor macros
+ * @throws BuildException
+ * throw if defineset is a reference
+ */
+ public void setDefine(CUtil.StringArrayBuilder defList)
+ throws BuildException {
+ if (isReference()) {
+ throw tooManyAttributes();
+ }
+ addDefines(defList.getValue(), true);
+ }
+ /**
+ * Sets a description of the current data type.
+ */
+ public void setDescription(String desc) {
+ super.setDescription(desc);
+ }
+ /**
+ * Sets an id that can be used to reference this element.
+ *
+ * @param id
+ * id
+ */
+ public void setId(String id) {
+ //
+ // this is actually accomplished by a different
+ // mechanism, but we can document it
+ //
+ }
+ /**
+ * Sets the property name for the 'if' condition.
+ *
+ * The define will be ignored unless the property is defined.
+ *
+ * The value of the property is insignificant, but values that would imply
+ * misinterpretation ("false", "no") will throw an exception when
+ * evaluated.
+ *
+ * @param propName
+ * property name
+ */
+ public final void setIf(String propName) {
+ ifCond = propName;
+ }
+ /**
+ * Specifies that this element should behave as if the content of the
+ * element with the matching id attribute was inserted at this location. If
+ * specified, no other attributes or child content should be specified,
+ * other than "description".
+ *
+ */
+ public void setRefid(Reference r) throws BuildException {
+ if (!defineList.isEmpty()) {
+ throw tooManyAttributes();
+ }
+ super.setRefid(r);
+ }
+ /**
+ * A comma-separated list of preprocessor macros to undefine.
+ *
+ * @param undefList
+ * comma-separated list of preprocessor macros
+ * @throws BuildException
+ * throw if defineset is a reference
+ */
+ public void setUndefine(CUtil.StringArrayBuilder undefList)
+ throws BuildException {
+ if (isReference()) {
+ throw tooManyAttributes();
+ }
+ addDefines(undefList.getValue(), false);
+ }
+ /**
+ * Set the property name for the 'unless' condition.
+ *
+ * If named property is set, the define will be ignored.
+ *
+ * The value of the property is insignificant, but values that would imply
+ * misinterpretation ("false", "no") of the behavior will throw an
+ * exception when evaluated.
+ *
+ * @param propName
+ * name of property
+ */
+ public final void setUnless(String propName) {
+ unlessCond = propName;
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/types/FlexLong.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/types/FlexLong.java
new file mode 100644
index 0000000000..d95959f631
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/types/FlexLong.java
@@ -0,0 +1,59 @@
+/*
+ *
+ * Copyright 2002-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.types;
+import java.lang.reflect.Method;
+
+/**
+ * Helper class which can be used for Ant task attribute setter methods to
+ * allow the build file to specify a long in either decimal, octal, or
+ * hexadecimal format.
+ * // FlexInteger author
+ * @author Erik Hatcher
+ * @see org.apache.tools.ant.types.FlexInteger
+ */
+public class FlexLong {
+ private Long value;
+ /**
+ * Constructor used by Ant's introspection mechanism for attribute
+ * population
+ */
+ public FlexLong(String value) {
+ // Java 1.1 did not support Long.decode().. so we call it by
+ // reflection.
+ try {
+ Method m = Long.class
+ .getMethod("decode", new Class[]{String.class});
+ Object rc = m.invoke(null, new Object[]{value});
+ this.value = (Long) rc;
+ } catch (Exception e) {
+ // Try it the old fashioned way, we must be on a 1.1 jre
+ this.value = new Long(value);
+ }
+ }
+ /**
+ * Returns the decimal integer value
+ */
+ public long longValue() {
+ return value.longValue();
+ }
+ /**
+ * Overridden method to return the decimal value for display
+ */
+ public String toString() {
+ return value.toString();
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/types/IncludePath.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/types/IncludePath.java
new file mode 100644
index 0000000000..edcc42103c
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/types/IncludePath.java
@@ -0,0 +1,38 @@
+/*
+ *
+ * Copyright 2001-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.types;
+import org.apache.tools.ant.Project;
+/**
+ * An include path.
+ *
+ * Works like other paths in Ant with with the addition of "if" and "unless"
+ * conditions.
+ *
+ * @author Curt Arnold
+ */
+public class IncludePath extends ConditionalPath {
+ public IncludePath(Project project) {
+ super(project);
+ }
+ public IncludePath(Project p, String path) {
+ super(p, path);
+ }
+ public void execute() throws org.apache.tools.ant.BuildException {
+ throw new org.apache.tools.ant.BuildException(
+ "Not an actual task, but looks like one for documentation purposes");
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/types/LibrarySet.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/types/LibrarySet.java
new file mode 100644
index 0000000000..d522ccc36f
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/types/LibrarySet.java
@@ -0,0 +1,290 @@
+/*
+ *
+ * Copyright 2001-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.types;
+import java.io.File;
+
+import net.sf.antcontrib.cpptasks.CUtil;
+import net.sf.antcontrib.cpptasks.FileVisitor;
+import net.sf.antcontrib.cpptasks.compiler.Linker;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.DirectoryScanner;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.ProjectComponent;
+import org.apache.tools.ant.types.FileSet;
+import org.apache.tools.ant.types.PatternSet;
+/**
+ * A set of library names. Libraries can also be added to a link by specifying
+ * them in a fileset.
+ *
+ * For most Unix-like compilers, libset will result in a series of -l and -L
+ * linker arguments. For Windows compilers, the library names will be used to
+ * locate the appropriate library files which will be added to the linkers
+ * input file list as if they had been specified in a fileset.
+ *
+ * @author Mark A Russell mark_russell@csg_systems.com
+ *
+ * @author Adam Murdoch
+ * @author Curt Arnold
+ */
+public class LibrarySet extends ProjectComponent {
+ private String dataset;
+ private boolean explicitCaseSensitive;
+ private String ifCond;
+ private String[] libnames;
+ private final FileSet set = new FileSet();
+ private String unlessCond;
+ private LibraryTypeEnum libraryType;
+ public LibrarySet() {
+ libnames = new String[0];
+ }
+ public void execute() throws org.apache.tools.ant.BuildException {
+ throw new org.apache.tools.ant.BuildException(
+ "Not an actual task, but looks like one for documentation purposes");
+ }
+ /**
+ * Gets the dataset. Used on OS390 if the libs are in a dataset.
+ *
+ * @return Returns a String
+ */
+ public String getDataset() {
+ return dataset;
+ }
+ public File getDir(Project project) {
+ return set.getDir(project);
+ }
+ protected FileSet getFileSet() {
+ return set;
+ }
+ public String[] getLibs() {
+ String[] retval = (String[]) libnames.clone();
+ return retval;
+ }
+
+ /**
+ * Gets preferred library type
+ *
+ * @return library type, may be null.
+ */
+ public LibraryTypeEnum getType() {
+ return libraryType;
+ }
+ /**
+ * Returns true if the define's if and unless conditions (if any) are
+ * satisfied.
+ */
+ public boolean isActive(org.apache.tools.ant.Project p) {
+ if (p == null) {
+ throw new NullPointerException("p");
+ }
+ if (ifCond != null) {
+ String ifValue = p.getProperty(ifCond);
+ if (ifValue != null) {
+ if (ifValue.equals("no") || ifValue.equals("false")) {
+ throw new BuildException(
+ "property "
+ + ifCond
+ + " used as if condition has value "
+ + ifValue
+ + " which suggests a misunderstanding of if attributes");
+ }
+ } else {
+ return false;
+ }
+ }
+ if (unlessCond != null) {
+ String unlessValue = p.getProperty(unlessCond);
+ if (unlessValue != null) {
+ if (unlessValue.equals("no") || unlessValue.equals("false")) {
+ throw new BuildException(
+ "property "
+ + unlessCond
+ + " used as unless condition has value "
+ + unlessValue
+ + " which suggests a misunderstanding of unless attributes");
+ }
+ return false;
+ }
+ }
+ if (libnames.length == 0) {
+ p.log("libnames not specified or empty.", Project.MSG_WARN);
+ return false;
+ }
+ return true;
+ }
+ /**
+ * Sets case sensitivity of the file system. If not set, will default to
+ * the linker's case sensitivity.
+ *
+ * @param isCaseSensitive
+ * "true"|"on"|"yes" if file system is case sensitive,
+ * "false"|"off"|"no" when not.
+ */
+ public void setCaseSensitive(boolean isCaseSensitive) {
+ explicitCaseSensitive = true;
+ set.setCaseSensitive(isCaseSensitive);
+ }
+ /**
+ * Sets the dataset. Used on OS390 if the libs are in a dataset.
+ *
+ * @param dataset
+ * The dataset to set
+ */
+ public void setDataset(String dataset) {
+ this.dataset = dataset;
+ }
+ /**
+ * Library directory.
+ *
+ * @param dir
+ * library directory
+ *
+ */
+ public void setDir(File dir) throws BuildException {
+ set.setDir(dir);
+ }
+ /**
+ * Sets the property name for the 'if' condition.
+ *
+ * The library set will be ignored unless the property is defined.
+ *
+ * The value of the property is insignificant, but values that would imply
+ * misinterpretation ("false", "no") will throw an exception when
+ * evaluated.
+ *
+ * @param propName
+ * property name
+ */
+ public void setIf(String propName) {
+ ifCond = propName;
+ }
+ /**
+ * Comma-separated list of library names without leading prefixes, such as
+ * "lib", or extensions, such as ".so" or ".a".
+ *
+ */
+ public void setLibs(CUtil.StringArrayBuilder libs) throws BuildException {
+ libnames = libs.getValue();
+ // If this is not active.. then it's ok if the lib names are invalid.
+ // so we can do a:
+ if (!isActive(getProject()))
+ return;
+ for (int i = 0; i < libnames.length; i++) {
+ int lastDot = libnames[i].lastIndexOf('.');
+ if (lastDot >= 0) {
+ String extension = libnames[i].substring(lastDot);
+ if (extension.equalsIgnoreCase(".lib")
+ || extension.equalsIgnoreCase(".so")
+ || extension.equalsIgnoreCase(".a")) {
+ getProject().log(
+ "Suspicious library name ending with \""
+ + extension + "\": " + libnames[i], Project.MSG_DEBUG );
+ }
+ }
+ if (libnames[i].length() >= 3
+ && libnames[i].substring(0, 3).equalsIgnoreCase("lib")) {
+ getProject().log(
+ "Suspicious library name starting with \"lib\": "
+ + libnames[i], Project.MSG_DEBUG);
+ }
+ }
+ }
+ public void setProject(Project project) {
+ set.setProject(project);
+ super.setProject(project);
+ }
+ /**
+ * Set the property name for the 'unless' condition.
+ *
+ * If named property is set, the library set will be ignored.
+ *
+ * The value of the property is insignificant, but values that would imply
+ * misinterpretation ("false", "no") of the behavior will throw an
+ * exception when evaluated.
+ *
+ * @param propName
+ * name of property
+ */
+ public void setUnless(String propName) {
+ unlessCond = propName;
+ }
+
+ /**
+ * Sets the preferred library type. Supported values "shared", "static", and
+ * "framework". "framework" is equivalent to "shared" on non-Darwin platforms.
+ */
+ public void setType(LibraryTypeEnum type) {
+ this.libraryType = type;
+ }
+
+ public void visitLibraries(Project project, Linker linker, File[] libpath,
+ FileVisitor visitor) throws BuildException {
+ FileSet localSet = (FileSet) set.clone();
+ //
+ // unless explicitly set
+ // will default to the linker case sensitivity
+ //
+ if (!explicitCaseSensitive) {
+ boolean linkerCaseSensitive = linker.isCaseSensitive();
+ localSet.setCaseSensitive(linkerCaseSensitive);
+ }
+ //
+ // if there was a libs attribute then
+ // add the corresponding patterns to the FileSet
+ //
+ if (libnames != null && libnames.length > 0) {
+ String[] patterns = linker.getLibraryPatterns(libnames, libraryType);
+ //
+ // if no patterns, then linker does not support libraries
+ //
+ if (patterns.length > 0) {
+ for (int i = 0; i < patterns.length; i++) {
+ PatternSet.NameEntry entry = localSet.createInclude();
+ entry.setName(patterns[i]);
+ }
+ //
+ // if there was no specified directory then
+ // run through the libpath backwards
+ //
+ if (localSet.getDir(project) == null) {
+ //
+ // scan libpath in reverse order
+ // to give earlier entries priority
+ //
+ for (int j = libpath.length - 1; j >= 0; j--) {
+ FileSet clone = (FileSet) localSet.clone();
+ clone.setDir(libpath[j]);
+ DirectoryScanner scanner = clone.getDirectoryScanner(project);
+ File basedir = scanner.getBasedir();
+ String[] files = scanner.getIncludedFiles();
+ for (int k = 0; k < files.length; k++) {
+ visitor.visit(basedir, files[k]);
+ }
+ }
+ } else {
+ DirectoryScanner scanner = localSet.getDirectoryScanner(project);
+ File basedir = scanner.getBasedir();
+ String[] files = scanner.getIncludedFiles();
+ for (int k = 0; k < files.length; k++) {
+ visitor.visit(basedir, files[k]);
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/types/LibraryTypeEnum.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/types/LibraryTypeEnum.java
new file mode 100644
index 0000000000..82d7947bf2
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/types/LibraryTypeEnum.java
@@ -0,0 +1,48 @@
+/*
+ *
+ * Copyright 2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.types;
+import org.apache.tools.ant.types.EnumeratedAttribute;
+/**
+ * Enumeration of library types for LibrarySet
+ *
+ * @author Curt Arnold
+ *
+ */
+public class LibraryTypeEnum extends EnumeratedAttribute {
+ /**
+ * Constructor
+ *
+ * Set by default to "shared"
+ *
+ * @see java.lang.Object#Object()
+ */
+ public LibraryTypeEnum() {
+ setValue("shared");
+ }
+ /**
+ * Gets list of acceptable values
+ *
+ * @see org.apache.tools.ant.types.EnumeratedAttribute#getValues()
+ */
+ public String[] getValues() {
+ return new String[]{"shared", // prefer shared libraries
+ "static", // prefer static libraries
+ "framework" // framework libraries (Mac OS/X)
+ // equiv to shared on other platforms
+ };
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/types/LinkerArgument.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/types/LinkerArgument.java
new file mode 100644
index 0000000000..89bff1881b
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/types/LinkerArgument.java
@@ -0,0 +1,28 @@
+/*
+ *
+ * Copyright 2001-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.types;
+/**
+ * A linker command line argument.
+ */
+public class LinkerArgument extends CommandLineArgument {
+ public LinkerArgument() {
+ }
+ public void execute() throws org.apache.tools.ant.BuildException {
+ throw new org.apache.tools.ant.BuildException(
+ "Not an actual task, but looks like one for documentation purposes");
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/types/SystemIncludePath.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/types/SystemIncludePath.java
new file mode 100644
index 0000000000..be0dbd537a
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/types/SystemIncludePath.java
@@ -0,0 +1,45 @@
+/*
+ *
+ * Copyright 2001-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.types;
+import org.apache.tools.ant.Project;
+/**
+ * A system include path.
+ *
+ * Files located using a system include path will not participate in dependency
+ * analysis.
+ *
+ * Standard include paths for a compiler should not be specified since these
+ * should be determined from environment variables or configuration files by
+ * the compiler adapter.
+ *
+ * Works like other paths in Ant with with the addition of "if" and "unless"
+ * conditions.
+ *
+ * @author Curt Arnold
+ */
+public class SystemIncludePath extends ConditionalPath {
+ public SystemIncludePath(Project project) {
+ super(project);
+ }
+ public SystemIncludePath(Project p, String path) {
+ super(p, path);
+ }
+ public void execute() throws org.apache.tools.ant.BuildException {
+ throw new org.apache.tools.ant.BuildException(
+ "Not an actual task, but looks like one for documentation purposes");
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/types/SystemLibrarySet.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/types/SystemLibrarySet.java
new file mode 100644
index 0000000000..02d08c8ac8
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/types/SystemLibrarySet.java
@@ -0,0 +1,37 @@
+/*
+ *
+ * Copyright 2001-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.types;
+/**
+ * A set of system library names. Timestamp or location of system libraries are
+ * not considered in dependency analysis.
+ *
+ * Libraries can also be added to a link by specifying them in a fileset.
+ *
+ * For most Unix-like compilers, syslibset will result in a series of -l and -L
+ * linker arguments. For Windows compilers, the library names will be used to
+ * locate the appropriate library files which will be added to the linkers
+ * input file list as if they had been specified in a fileset.
+ */
+public class SystemLibrarySet extends LibrarySet {
+ public SystemLibrarySet() {
+ super();
+ }
+ public void execute() throws org.apache.tools.ant.BuildException {
+ throw new org.apache.tools.ant.BuildException(
+ "Not an actual task, but looks like one for documentation purposes");
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/types/UndefineArgument.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/types/UndefineArgument.java
new file mode 100644
index 0000000000..2a18fca6d1
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/types/UndefineArgument.java
@@ -0,0 +1,153 @@
+/*
+ *
+ * Copyright 2001-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.types;
+import java.util.Vector;
+
+import net.sf.antcontrib.cpptasks.CUtil;
+
+import org.apache.tools.ant.BuildException;
+/**
+ * Preprocessor macro undefinition.
+ *
+ * @author Mark A Russell mark_russell@csg_systems.com
+ *
+ */
+public class UndefineArgument {
+ /**
+ * This method returns an array of UndefineArgument and DefineArgument's by
+ * merging a base list with an override list.
+ *
+ * Any define in the base list with a name that appears in the override
+ * list is suppressed. All entries in the override list are preserved
+ *
+ */
+ public static UndefineArgument[] merge(UndefineArgument[] base,
+ UndefineArgument[] override) {
+ if (base.length == 0) {
+ UndefineArgument[] overrideClone = (UndefineArgument[]) override
+ .clone();
+ return overrideClone;
+ }
+ if (override.length == 0) {
+ UndefineArgument[] baseClone = (UndefineArgument[]) base.clone();
+ return baseClone;
+ }
+ Vector unduplicated = new Vector(base.length);
+ for (int i = 0; i < base.length; i++) {
+ UndefineArgument current = base[i];
+ String currentName = current.getName();
+ boolean match = false;
+ if (currentName == null) {
+ match = true;
+ } else {
+ for (int j = 0; j < override.length; j++) {
+ UndefineArgument over = override[j];
+ String overName = over.getName();
+ if (overName != null && overName.equals(currentName)) {
+ match = true;
+ break;
+ }
+ }
+ }
+ if (!match) {
+ unduplicated.addElement(current);
+ }
+ }
+ UndefineArgument[] combined = new UndefineArgument[unduplicated.size()
+ + override.length];
+ unduplicated.copyInto(combined);
+ int offset = unduplicated.size();
+ for (int i = 0; i < override.length; i++) {
+ combined[offset + i] = override[i];
+ }
+ return combined;
+ }
+ private boolean define = false;
+ private String ifCond;
+ private String name;
+ private String unlessCond;
+ public UndefineArgument() {
+ }
+ protected UndefineArgument(boolean isDefine) {
+ this.define = isDefine;
+ }
+ public void execute() throws org.apache.tools.ant.BuildException {
+ throw new org.apache.tools.ant.BuildException(
+ "Not an actual task, but looks like one for documentation purposes");
+ }
+ /** Returns the name of the define */
+ public final String getName() {
+ return name;
+ }
+ /** Returns the value of the define */
+ public String getValue() {
+ return null;
+ }
+ /**
+ * Returns true if the define's if and unless conditions (if any) are
+ * satisfied.
+ *
+ * @exception BuildException
+ * throws build exception if name is not set
+ */
+ public final boolean isActive(org.apache.tools.ant.Project p)
+ throws BuildException {
+ if (name == null) {
+ throw new BuildException(" is missing name attribute");
+ }
+ return CUtil.isActive(p, ifCond, unlessCond);
+ }
+ /** Returns true if this is a define, false if an undefine. */
+ public final boolean isDefine() {
+ return define;
+ }
+ /**
+ * Sets the property name for the 'if' condition.
+ *
+ * The define will be ignored unless the property is defined.
+ *
+ * The value of the property is insignificant, but values that would imply
+ * misinterpretation ("false", "no") will throw an exception when
+ * evaluated.
+ *
+ * @param propName
+ * property name
+ */
+ public final void setIf(String propName) {
+ ifCond = propName;
+ }
+ /** Set the name attribute */
+ public final void setName(String name) {
+ this.name = name;
+ }
+ /**
+ * Set the property name for the 'unless' condition.
+ *
+ * If named property is set, the define will be ignored.
+ *
+ * The value of the property is insignificant, but values that would imply
+ * misinterpretation ("false", "no") of the behavior will throw an
+ * exception when evaluated.
+ *
+ * @param propName
+ * name of property
+ */
+ public final void setUnless(String propName) {
+ unlessCond = propName;
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/userdefine/CommandLineUserDefine.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/userdefine/CommandLineUserDefine.java
new file mode 100644
index 0000000000..7c66eb1cbb
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/userdefine/CommandLineUserDefine.java
@@ -0,0 +1,389 @@
+package net.sf.antcontrib.cpptasks.userdefine;
+
+import java.io.File;
+import java.util.Iterator;
+import java.util.StringTokenizer;
+import java.util.Vector;
+
+import net.sf.antcontrib.cpptasks.CCTask;
+import net.sf.antcontrib.cpptasks.CUtil;
+import net.sf.antcontrib.cpptasks.types.CommandLineArgument;
+import net.sf.antcontrib.cpptasks.types.ConditionalFileSet;
+import net.sf.antcontrib.cpptasks.types.LibrarySet;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.DirectoryScanner;
+import org.apache.tools.ant.Project;
+/*
+ *
+ * Copyright 2001-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+public class CommandLineUserDefine {
+
+ String command;
+
+ /*
+ * The follows variable set at child class.
+ */
+ String includeFileFlag = null;
+ String entryPointFlag = null;
+ String subSystemFlag = null;
+ String mapFlag = null;
+ String pdbFlag = null;
+ String outputFileFlag = null;
+ String includePathDelimiter = null;
+
+ /*
+ * get lib string if Vendor = "gcc", it should respectively aadd "-(" and ")-"
+ * at library set before and end. This value set at userDefineCompiler class.
+ */
+ Vector libSetList = new Vector();
+ Vector fileList = new Vector();
+ public void command(CCTask cctask, UserDefineDef userdefine){
+ File workdir;
+ File outdir;
+ Project project = cctask.getProject();
+ if(userdefine.getWorkdir() == null) {
+ workdir = new File(".");
+ }
+ else {
+ workdir = userdefine.getWorkdir();
+ }
+
+ /*
+ * generate cmdline= command + args + includepath + endargs + outfile
+ */
+ Vector args = new Vector();
+ Vector argsWithoutSpace = new Vector();
+ Vector endargs = new Vector();
+ Vector endargsWithoutSpace = new Vector();
+ Vector includePath = new Vector();
+
+ /*
+ * Generate cmdline = command +
+ * general args +
+ * outputflag + outputfile
+ * subsystemFlag + subsystemValue +
+ * includeFlag + includeFile +
+ * includeFileincludpath +
+ * entryPointFlag + entryPointValue +
+ * mapFlag + mapValue +
+ * pdbFlag + pdbValue +
+ * endargs +
+ *
+ *
+ */
+ /*
+ * get Args.
+ */
+ CommandLineArgument[] argument = userdefine.getActiveProcessorArgs();
+ for (int j = 0; j < argument.length; j++) {
+ if (argument[j].getLocation() == 0) {
+ args.addElement(argument[j].getValue());
+ } else {
+ endargs.addElement(argument[j].getValue());
+ }
+ }
+ /*
+ * get include path.
+ */
+ String[] incPath = userdefine.getActiveIncludePaths();
+ for (int j = 0; j < incPath.length; j++) {
+ if(incPath[j].indexOf(' ') >= 0) {
+ includePath.addElement( includePathDelimiter + incPath[j]);
+ //includePath.addElement( includePathDelimiter + "\"" + incPath[j] + "\"");
+ }
+ else {
+ includePath.addElement( includePathDelimiter + incPath[j]);
+ }
+ }
+ /*
+ * Remove space in args and endargs.
+ */
+ for ( int i=0; i < args.size(); i++) {
+ String str = (String)args.get(i);
+ StringTokenizer st = new StringTokenizer(str);
+ while(st.hasMoreTokens()) {
+ argsWithoutSpace.addElement(st.nextToken());
+ }
+ }
+ for ( int i=0; i < endargs.size(); i++) {
+ String str = (String)endargs.get(i);
+ StringTokenizer st = new StringTokenizer(str);
+ while(st.hasMoreTokens()) {
+ endargsWithoutSpace.addElement(st.nextToken());
+ }
+ }
+
+ int cmdLen = 0;
+ if(userdefine.getOutdir() == null) {
+ outdir = new File(".");
+ /*
+ * command + args + endargs + includepath + sourcefile
+ */
+ cmdLen = 1 + argsWithoutSpace.size() + endargsWithoutSpace.size() + includePath.size() + 1;
+ }
+ else {
+ outdir = userdefine.getOutdir();
+ /*
+ * command + args + endargs + includepath + sourcefile + outfile
+ */
+ cmdLen = 1 + argsWithoutSpace.size() + endargsWithoutSpace.size() + includePath.size() + 2;
+ }
+ if (includeFileFlag != null && includeFileFlag.trim().length() > 0){
+ cmdLen++;
+ }
+ if (entryPointFlag != null && entryPointFlag.trim().length() > 0){
+ cmdLen++;
+ }
+ if (subSystemFlag != null && subSystemFlag.trim().length() > 0){
+ cmdLen++;
+ }
+ if (mapFlag != null && mapFlag.trim().length() > 0){
+ cmdLen++;
+ }
+ if (pdbFlag != null && pdbFlag.trim().length() > 0){
+ cmdLen++;
+ }
+ if (libSetList != null && libSetList.size() > 0){
+ cmdLen = cmdLen + libSetList.size();
+ }
+ if (fileList != null){
+ cmdLen = cmdLen + fileList.size();
+ }
+ /*
+ * In gcc the "cr" flag should follow space then add outputfile name, otherwise
+ * it will pop error.
+ */
+ if (outputFileFlag != null && outputFileFlag.trim().length() > 0){
+ if (outputFileFlag.trim().equalsIgnoreCase("-cr")){
+ cmdLen = cmdLen + 2;
+ }else {
+ cmdLen++;
+ }
+
+ }
+ /*
+ * for every source file
+ * if file is header file, just skip it (add later)
+ */
+ Vector srcSets = userdefine.getSrcSets();
+ if (srcSets.size() == 0) {
+ String[] cmd = new String[cmdLen - 1];
+ int index = 0;
+ cmd[index++] = this.command;
+
+
+
+ Iterator iter = argsWithoutSpace.iterator();
+ while (iter.hasNext()) {
+ cmd[index++] = project.replaceProperties((String)iter.next());
+ //cmd[index++] = (String)iter.next();
+ }
+
+ iter = endargsWithoutSpace.iterator();
+ while (iter.hasNext()) {
+ cmd[index++] = (String)iter.next();
+ }
+
+ /*
+ * "OutputFlag + outputFile" as first option follow command.exe.
+ */
+ if (outputFileFlag != null && outputFileFlag.trim().length() > 0){
+ if (outputFileFlag.trim().equalsIgnoreCase("-cr")){
+ cmd[index++] = outputFileFlag;
+ cmd[index++] = userdefine.getOutputFile();
+ }else {
+ cmd[index++] = outputFileFlag + userdefine.getOutputFile();
+ }
+ }
+
+ /*
+ * Add fileList to cmd
+ */
+ if (fileList != null && fileList.size()> 0){
+ for (int i = 0; i < fileList.size(); i++){
+ cmd[index++] = fileList.get(i);
+ }
+ }
+
+ if (subSystemFlag != null && subSystemFlag.trim().length() > 0){
+ cmd[index++] = subSystemFlag + userdefine.getSubSystemvalue();
+ }
+ if (includeFileFlag != null && includeFileFlag.trim().length() > 0){
+ cmd[index++] = includeFileFlag + userdefine.getIncludeFile();
+ }
+
+ iter = includePath.iterator();
+ while (iter.hasNext()) {
+ cmd[index++] = (String)iter.next();
+ }
+
+ if (entryPointFlag != null && entryPointFlag.trim().length() > 0){
+ //
+ // If GCC link use __ModuleEntrypoint instead of _ModuleEntryPoint;
+ //
+ if (entryPointFlag.equalsIgnoreCase("-e")){
+ cmd[index++] = entryPointFlag + "_" + userdefine.getEntryPointvalue();
+ } else {
+ cmd[index++] = entryPointFlag + userdefine.getEntryPointvalue();
+ }
+
+ }
+ if (mapFlag != null && mapFlag.trim().length() > 0){
+ cmd[index++] = mapFlag + userdefine.getMapvalue();
+ }
+ if (pdbFlag != null && pdbFlag.trim().length() > 0){
+ cmd[index++] = pdbFlag + userdefine.getPdbvalue();
+ }
+
+ if (userdefine.getOutdir() != null){
+ // will add code to generate outfile name and flag
+ cmd[index++] = "/nologo";
+ }
+
+ if (libSetList != null && libSetList.size() > 0){
+ for (int i = 0; i < libSetList.size(); i++){
+ cmd[index++] = libSetList.get(i);
+ }
+ }
+
+ // execute the command
+ int retval = runCommand(cctask, workdir, cmd);
+ // if with monitor, add more code
+ if (retval != 0) {
+ throw new BuildException(this.command
+ + " failed with return code " + retval,
+ cctask.getLocation());
+ }
+ }
+
+ //
+ // if have source file append source file in command land.
+ //
+ for (int i = 0; i < srcSets.size(); i++) {
+ ConditionalFileSet srcSet = (ConditionalFileSet) srcSets
+ .elementAt(i);
+ if (srcSet.isActive()) {
+ // Find matching source files
+ DirectoryScanner scanner = srcSet.getDirectoryScanner(project);
+ // Check each source file - see if it needs compilation
+ String[] fileNames = scanner.getIncludedFiles();
+ for (int j = 0; j < fileNames.length; j++){
+ String[] cmd = new String[cmdLen];
+ int index = 0;
+ cmd[index++] = this.command;
+
+
+
+ Iterator iter = argsWithoutSpace.iterator();
+ while (iter.hasNext()) {
+ cmd[index++] = (String)iter.next();
+ }
+
+ iter = endargsWithoutSpace.iterator();
+ while (iter.hasNext()) {
+ cmd[index++] = (String)iter.next();
+ }
+
+ /*
+ * Add outputFileFlag and output file to cmd
+ */
+ if (outputFileFlag != null && outputFileFlag.length()> 0){
+ if (outputFileFlag.trim().equalsIgnoreCase("-cr")){
+ cmd[index++] = outputFileFlag;
+ cmd[index++] = userdefine.getOutputFile();
+ }else {
+ cmd[index++] = outputFileFlag + userdefine.getOutputFile();
+ }
+ }
+
+ /*
+ * Add fileList to cmd
+ */
+ if (fileList != null && fileList.size()> 0){
+ for (int s = 0; s < fileList.size(); s++){
+ cmd[index++] = fileList.get(s);
+ }
+ }
+ if (subSystemFlag != null && subSystemFlag.length()> 0){
+ cmd[index++] = subSystemFlag + userdefine.getSubSystemvalue();
+ }
+ if (includeFileFlag != null && includeFileFlag.length()> 0){
+ cmd[index++] = includeFileFlag + userdefine.getIncludeFile();
+ }
+
+ iter = includePath.iterator();
+ while (iter.hasNext()) {
+ cmd[index++] = (String)iter.next();
+ }
+ if (userdefine.getOutdir() != null){
+ // will add code to generate outfile name and flag
+ cmd[index++] = "/nologo";
+ }
+
+ if (entryPointFlag != null && entryPointFlag.length()> 0){
+ cmd[index++] = entryPointFlag + userdefine.getEntryPointvalue();
+ }
+ if (mapFlag != null && mapFlag.length() > 0){
+ cmd[index++] = mapFlag + userdefine.getMapvalue();
+ }
+ if (pdbFlag != null && pdbFlag.length() > 0){
+ cmd[index++] = pdbFlag + userdefine.getPdbvalue();
+ }
+
+ if (libSetList != null && libSetList.size() > 0){
+ for (int k = 0; k < libSetList.size(); k++){
+ cmd[index++] = libSetList.get(k);
+ }
+ }
+
+ // execute the command
+ cmd[index++] = scanner.getBasedir() + "/" + fileNames[j];
+ for (int k = 0; k < cmd.length; k++){
+ }
+ int retval = runCommand(cctask, workdir, cmd);
+ // if with monitor, add more code
+ if (retval != 0) {
+ throw new BuildException(this.command
+ + " failed with return code " + retval,
+ cctask.getLocation());
+ }
+ }
+ }
+ }
+ }
+
+ protected int runCommand(CCTask task, File workingDir, String[] cmdline)
+ throws BuildException {
+ return CUtil.runCommand(task, workingDir, cmdline, false, null);
+
+ }
+
+ protected String getInputFileArgument(File outputDir, String filename,
+ int index) {
+ //
+ // if there is an embedded space,
+ // must enclose in quotes
+ if (filename.indexOf(' ') >= 0) {
+ StringBuffer buf = new StringBuffer("\"");
+ buf.append(filename);
+ buf.append("\"");
+ return buf.toString();
+ }
+ return filename;
+ }
+
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/userdefine/UserDefineArgument.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/userdefine/UserDefineArgument.java
new file mode 100644
index 0000000000..85d9a04e73
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/userdefine/UserDefineArgument.java
@@ -0,0 +1,31 @@
+/*
+ *
+ * Copyright 2002-2006 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.userdefine;
+
+import net.sf.antcontrib.cpptasks.types.CommandLineArgument;
+
+public class UserDefineArgument extends CommandLineArgument {
+
+ public UserDefineArgument() {
+ }
+
+ public void execute() throws org.apache.tools.ant.BuildException {
+ throw new org.apache.tools.ant.BuildException(
+ "Not an actual task, but looks like one for documentation purposes");
+ }
+
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/userdefine/UserDefineCompiler.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/userdefine/UserDefineCompiler.java
new file mode 100644
index 0000000000..382975abb0
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/userdefine/UserDefineCompiler.java
@@ -0,0 +1,219 @@
+/*
+ *
+ * Copyright 2002-2006 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.userdefine;
+
+import org.apache.tools.ant.Project;
+
+import net.sf.antcontrib.cpptasks.CCTask;
+import org.tianocore.build.toolchain.*;
+
+public class UserDefineCompiler extends CommandLineUserDefine {
+
+ public UserDefineCompiler(CCTask cctask, UserDefineDef userdefineDef) {
+ String arch = null;
+ String os = null;
+ String vendor = null;
+ String commandType = null;
+ Project project = cctask.getProject();
+ // get command string
+ if (cctask.getArch() == null) {
+ arch = project.getProperty("ARCH");
+ if (arch == null) {
+ arch = System.getProperty("os.arch");
+ }
+ } else {
+ arch = cctask.getArch();
+ }
+ arch = arch.toUpperCase();
+ if (cctask.getOs() == null) {
+ os = project.getProperty("OS");
+ if (os == null) {
+ os = System.getProperty("os.name");
+ }
+ } else {
+ os = cctask.getOs();
+ }
+
+ commandType = userdefineDef.getType();
+
+ if (commandType != null) {
+ if (ToolChainFactory.getValue(arch + "_" + commandType + "_VENDOR") != null
+ && ToolChainFactory.getValue(
+ arch + "_" + commandType + "_VENDOR").trim()
+ .length() > 0) {
+ vendor = ToolChainFactory.getValue(arch + "_" + commandType
+ + "_VENDOR");
+ } else if (ToolChainFactory.getValue(arch + "_VENDOR") != null) {
+ vendor = ToolChainFactory.getValue(arch + "_VENDOR");
+ }
+ }
+
+ // look if ARCH_VENDOR_OS_COMMANDTYPE is existed
+ if (arch != null && vendor != null && os != null && commandType != null) {
+ command = project.getProperty(arch + "_" + vendor + "_" + os + "_"
+ + commandType);
+ }
+ // look if ARCH_VENDOR_COMMANDTYPE is existed
+ if (command == null) {
+ if (arch != null && vendor != null && commandType != null) {
+ command = project.getProperty(arch + "_" + vendor + "_"
+ + commandType);
+ }
+ }
+ // look if ARCH_COMMANDTYPE is existed
+ if (command == null) {
+ if (arch != null && commandType != null) {
+ command = project.getProperty(arch + "_" + commandType);
+ }
+ }
+ // look if COMMANDTYPE is existed
+ if (command == null) {
+ if (commandType != null) {
+ command = project.getProperty(commandType);
+ }
+ }
+ // using the default value from VENDOR_OS_COMMANDTYPE or
+ // VENDOR_COMMANDTYPE
+ if (command == null) {
+ if (vendor != null && os != null && commandType != null) {
+ String str = vendor + "_" + os + "_" + commandType;
+ command = UserDefineMapping.getDefaultCommand(str);
+ }
+ }
+ // VENDOR_COMMANDTYPE
+ if (command == null) {
+ if (vendor != null && commandType != null) {
+ String str = vendor + "_" + commandType;
+ command = UserDefineMapping.getDefaultCommand(str);
+ }
+ }
+ // just give the name whatever
+ if (command == null) {
+ command = "cl";
+ }
+
+ // initialize the includePathDelimiter
+ if (userdefineDef.getIncludepathDelimiter() != null) {
+ includePathDelimiter = userdefineDef.getIncludepathDelimiter();
+ }
+ // else find VENDOR
+ else {
+ if (vendor != null) {
+ includePathDelimiter = UserDefineMapping
+ .getIncludePathDelimiter(vendor, commandType);
+ }
+ }
+ if (includePathDelimiter == null) {
+ includePathDelimiter = "-I";
+ }
+ /*
+ * Set libSet.
+ */
+ if (userdefineDef.getLibSet() != null
+ && userdefineDef.getLibSet().size() > 0) {
+ String[] libList;
+ if (vendor.equalsIgnoreCase("GCC")) {
+ libSetList.add("-(");
+ for (int i = 0; i < userdefineDef.getLibSet().size(); i++) {
+ libList = userdefineDef.getLibSet().get(i).getLibs();
+ for (int j = 0; j < libList.length; j++) {
+ libSetList.add(libList[j]);
+ }
+ }
+ libSetList.add("-)");
+ } else {
+ for (int i = 0; i < userdefineDef.getLibSet().size(); i++) {
+ libList = userdefineDef.getLibSet().get(i).getLibs();
+ for (int j = 0; j < libList.length; j++) {
+ libSetList.add(libList[j]);
+ }
+ }
+ }
+ }
+ /*
+ * set includeFileFlag
+ */
+ if (userdefineDef.getIncludeFile() != null) {
+ if (userdefineDef.getIncludeFileFlag() != null) {
+ includeFileFlag = userdefineDef.getIncludeFileFlag();
+ } else {
+ includeFileFlag = UserDefineMapping.getCompellingIncFileFlag(
+ vendor, commandType);
+ }
+ }
+ /*
+ * set entryPointFlag
+ */
+ if (userdefineDef.getEntryPointvalue() != null) {
+ if (userdefineDef.getEntryPointFlag() != null) {
+ entryPointFlag = userdefineDef.getEntryPointFlag();
+ } else {
+ entryPointFlag = UserDefineMapping.getEntryPointFlag(vendor,
+ commandType);
+ }
+ }
+ /*
+ * set subSystemFlag
+ */
+ if (userdefineDef.getSubSystemvalue() != null) {
+ if (userdefineDef.getSubSystemFlag() != null) {
+ subSystemFlag = userdefineDef.getSubSystemFlag();
+ } else {
+ subSystemFlag = UserDefineMapping.getSubSystemFlag(vendor,
+ commandType);
+ }
+ }
+ /*
+ * set mapFlag
+ */
+ if (userdefineDef.getMapvalue() != null) {
+ if (userdefineDef.getMapFlag() != null) {
+ mapFlag = userdefineDef.getMapFlag();
+ } else {
+ mapFlag = UserDefineMapping.getMapFlag(vendor, commandType);
+ }
+ }
+ /*
+ * set pdbFlag
+ */
+ if (userdefineDef.getPdbvalue() != null) {
+ if (userdefineDef.getPdbFlag() != null) {
+ pdbFlag = userdefineDef.getPdbFlag();
+ } else {
+ pdbFlag = UserDefineMapping.getPdbFlag(vendor, commandType);
+ }
+ }
+ /*
+ * set outputFileFlag
+ */
+ if (userdefineDef.getOutputFile() != null) {
+ if (userdefineDef.getOutPutFlag() != null) {
+ outputFileFlag = userdefineDef.getOutPutFlag();
+ } else {
+ outputFileFlag = UserDefineMapping.getOutputFileFlag(vendor,
+ arch, commandType);
+ }
+ }
+
+ /*
+ * set fileList
+ */
+ if (userdefineDef.getFileList() != null) {
+ fileList = userdefineDef.getFileList();
+ }
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/userdefine/UserDefineDef.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/userdefine/UserDefineDef.java
new file mode 100644
index 0000000000..f17edcf4ae
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/userdefine/UserDefineDef.java
@@ -0,0 +1,497 @@
+/*
+ *
+ * Copyright 2002-2006 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.userdefine;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.util.Vector;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.types.FileList;
+import org.apache.tools.ant.types.FileSet;
+
+import sun.nio.cs.ext.TIS_620;
+
+import net.sf.antcontrib.cpptasks.ProcessorDef;
+import net.sf.antcontrib.cpptasks.types.AslcompilerArgument;
+import net.sf.antcontrib.cpptasks.types.ConditionalPath;
+import net.sf.antcontrib.cpptasks.types.IncludePath;
+import net.sf.antcontrib.cpptasks.types.LibrarySet;
+
+public class UserDefineDef extends ProcessorDef{
+
+ public UserDefineDef () {}
+
+ private String type = "CC";
+ private String includepathDelimiter;
+
+ private File outdir;
+ private File workdir;
+
+ private String inputSuffix;
+ private String outputSuffix;
+
+ private Vector includePaths= new Vector();
+ private Vector fileSetList = new Vector();
+
+ /**
+ * New adding for support GCC toolchain.
+ * Most of those only have one value for example :
+ * entryPoint, mapFile, pdbFile, define those as element because
+ * if attribut too much the command line is not good-lookinng.
+ */
+
+ private Vector includeFiles = new Vector();
+ private Vector outPutFiles = new Vector();
+ private Vector subSystem = new Vector();
+ private Vector entryPoint = new Vector();
+ private Vector map = new Vector();
+ private Vector pdb = new Vector();
+ private Vector libSet = new Vector();
+
+ public void execute() throws org.apache.tools.ant.BuildException {
+ throw new org.apache.tools.ant.BuildException(
+ "Not an actual task, but looks like one for documentation purposes");
+ }
+
+
+ public void addConfiguredArgument(UserDefineArgument arg) {
+ if (isReference()) {
+ throw noChildrenAllowed();
+ }
+ addConfiguredProcessorArg(arg);
+ }
+
+ /**
+ * Creates an include path.
+ */
+ public IncludePath createIncludePath() {
+ Project p = getProject();
+ if (p == null) {
+ throw new java.lang.IllegalStateException("project must be set");
+ }
+ if (isReference()) {
+ throw noChildrenAllowed();
+ }
+ IncludePath path = new IncludePath(p);
+ includePaths.addElement(path);
+ return path;
+ }
+
+
+ /**
+ * Add a if specify the file attribute
+ *
+ * @throws BuildException
+ * if the specify file not exist
+ */
+ protected void loadFile(Vector activePath, File file) throws BuildException {
+ FileReader fileReader;
+ BufferedReader in;
+ String str;
+ if (!file.exists()) {
+ throw new BuildException("The file " + file + " is not existed");
+ }
+ try {
+ fileReader = new FileReader(file);
+ in = new BufferedReader(fileReader);
+ while ((str = in.readLine()) != null) {
+ if (str.trim() == "") {
+ continue;
+ }
+ str = getProject().replaceProperties(str);
+ activePath.addElement(str.trim());
+ }
+ } catch (Exception e) {
+ throw new BuildException(e.getMessage());
+ }
+ }
+
+ /**
+ * Returns the specific include path.
+ */
+ public String[] getActiveIncludePaths() {
+ if (isReference()) {
+ return ((UserDefineDef) getCheckedRef(UserDefineDef.class,
+ "UserDefineDef")).getActiveIncludePaths();
+ }
+ return getActivePaths(includePaths);
+ }
+
+ private String[] getActivePaths(Vector paths) {
+ Project p = getProject();
+ if (p == null) {
+ throw new java.lang.IllegalStateException("project not set");
+ }
+ Vector activePaths = new Vector(paths.size());
+ for (int i = 0; i < paths.size(); i++) {
+ ConditionalPath path = (ConditionalPath) paths.elementAt(i);
+ if (path.isActive(p)) {
+ if (path.getFile() == null) {
+ String[] pathEntries = path.list();
+ for (int j = 0; j < pathEntries.length; j++) {
+ activePaths.addElement(pathEntries[j]);
+ }
+ } else {
+ loadFile(activePaths, path.getFile());
+ }
+ }
+ }
+ String[] pathNames = new String[activePaths.size()];
+ activePaths.copyInto(pathNames);
+ return pathNames;
+ }
+
+ public String getIncludepathDelimiter() {
+ if (isReference()) {
+ return ((UserDefineDef) getCheckedRef(UserDefineDef.class,
+ "UserDefineDef")).getIncludepathDelimiter();
+ }
+ return includepathDelimiter;
+ }
+
+ public void setIncludepathDelimiter(String includepathDelimiter) {
+ if (isReference()) {
+ throw tooManyAttributes();
+ }
+ this.includepathDelimiter = includepathDelimiter;
+ }
+
+ public String getInputSuffix() {
+ if (isReference()) {
+ return ((UserDefineDef) getCheckedRef(UserDefineDef.class,
+ "UserDefineDef")).getInputSuffix();
+ }
+ return inputSuffix;
+ }
+
+ public void setInputSuffix(String inputSuffix) {
+ if (isReference()) {
+ throw tooManyAttributes();
+ }
+ this.inputSuffix = inputSuffix;
+ }
+
+ public File getOutdir() {
+ if (isReference()) {
+ return ((UserDefineDef) getCheckedRef(UserDefineDef.class,
+ "UserDefineDef")).getOutdir();
+ }
+ return outdir;
+ }
+
+ public void setOutdir(File outdir) {
+ if (isReference()) {
+ throw tooManyAttributes();
+ }
+ this.outdir = outdir;
+ }
+
+ public String getOutputSuffix() {
+ if (isReference()) {
+ return ((UserDefineDef) getCheckedRef(UserDefineDef.class,
+ "UserDefineDef")).getOutputSuffix();
+ }
+ return outputSuffix;
+ }
+
+ public void setOutputSuffix(String outputSuffix) {
+ if (isReference()) {
+ throw tooManyAttributes();
+ }
+ this.outputSuffix = outputSuffix;
+ }
+
+ public String getType() {
+ if (isReference()) {
+ return ((UserDefineDef) getCheckedRef(UserDefineDef.class,
+ "UserDefineDef")).getType();
+ }
+ return type;
+ }
+
+ public void setType(String type) {
+ if (isReference()) {
+ throw tooManyAttributes();
+ }
+ this.type = type;
+ }
+
+ public File getWorkdir() {
+ if (isReference()) {
+ return ((UserDefineDef) getCheckedRef(UserDefineDef.class,
+ "UserDefineDef")).getWorkdir();
+ }
+ return workdir;
+ }
+
+ public void setWorkdir(File workdir) {
+ if (isReference()) {
+ throw tooManyAttributes();
+ }
+ this.workdir = workdir;
+ }
+
+ /**
+ * Add an libSet.
+ */
+ public LibrarySet createLibset() {
+ if (isReference()){
+ throw noChildrenAllowed();
+ }
+ LibrarySet lib = new LibrarySet();
+ libSet.addElement(lib);
+ return lib;
+ }
+
+ public String getLibSetString(){
+ String libString = null;
+ for (int i = 0; i < libSet.size(); i++){
+ String[] libList = libSet.get(i).getLibs();
+ for (int j = 0; j < libList.length; j++){
+ libString = libString + libList[j] + " ";
+ }
+ }
+ return libString;
+ }
+
+ public Vector getLibSet(){
+ return this.libSet;
+ }
+
+ /**
+ * Add map element
+ */
+ public void addMap(UserDefineElement mapElement){
+ if (isReference()){
+ throw noChildrenAllowed();
+ }else{
+ this.map.addElement(mapElement);
+ }
+ }
+
+ public Vector getMap (){
+ return this.map;
+ }
+
+ public String getMapvalue (){
+ if (this.map.size() > 0){
+ /*
+ * If user set more than one map use the first one.
+ */
+ return this.map.get(0).value;
+ }
+ return null;
+
+ }
+ public String getMapFlag(){
+ if (this.map.size() > 0){
+ /*
+ * If user set more than one map use the first one.
+ */
+ return this.map.get(0).flag;
+ }
+ return null;
+ }
+ /**
+ * Add pdb element
+ */
+ public void addPdb(UserDefineElement pdbElement){
+ if (isReference()){
+ throw noChildrenAllowed();
+ }
+ this.pdb.addElement(pdbElement);
+ }
+
+ public Vector getPdb(){
+ return this.pdb;
+ }
+ public String getPdbvalue (){
+ if (this.pdb.size() > 0){
+ /*
+ * If user set more than one pdb use the first one.
+ *
+ */
+ return this.pdb.get(0).value;
+ }
+ return null;
+
+ }
+ public String getPdbFlag(){
+ if (this.pdb.size() > 0){
+ /*
+ * If user set more than one pdb use the first one.
+ */
+ return this.pdb.get(0).flag;
+ }
+ return null;
+ }
+
+ /**
+ * add entryPoint element.
+ */
+ public void addEntryPoint(UserDefineElement entryPointElement){
+ if (isReference()){
+ throw noChildrenAllowed();
+ }
+ this.entryPoint.addElement(entryPointElement);
+ }
+
+ public Vector getEntryPoint(){
+ return this.entryPoint;
+ }
+
+ public String getEntryPointvalue (){
+ if (this.entryPoint.size() > 0){
+ /*
+ * If user set more than one entryPoint use the first one.
+ */
+ return this.entryPoint.get(0).value;
+ }
+ return null;
+
+ }
+ public String getEntryPointFlag(){
+ if (this.entryPoint.size() > 0){
+ /*
+ * If user set more than one entry point use the first one.
+ */
+ return this.entryPoint.get(0).flag;
+ }
+ return null;
+ }
+
+ /**
+ * Add subSystem element.
+ */
+ public void addSubSystem (UserDefineElement subSystem){
+ if (isReference()){
+ throw noChildrenAllowed();
+ }
+ this.subSystem.addElement(subSystem);
+ }
+ public Vector getSubSystem (){
+ return this.subSystem;
+ }
+
+ public String getSubSystemvalue (){
+ if (this.subSystem.size() > 0){
+ /*
+ * If user set more than one subsystem use the first one.
+ */
+ return this.subSystem.get(0).value;
+ }
+ return null;
+
+ }
+ public String getSubSystemFlag(){
+ if (this.subSystem.size() > 0){
+ /*
+ * If user set more than one subsystem use the first one.
+ */
+ return this.subSystem.get(0).flag;
+ }
+ return null;
+ }
+ /**
+ * Add includeFile element
+ */
+ public void addIncludeFile (UserDefineElement includeFile){
+ if (isReference()){
+ throw noChildrenAllowed();
+ }
+ this.includeFiles.addElement(includeFile);
+ }
+ public Vector getIncludeFiles(){
+ return this.includeFiles;
+ }
+
+ public String getIncludeFile (){
+ if (this.includeFiles.size() > 0){
+ /*
+ * If user set more than one map use the first one.
+ */
+ return this.includeFiles.get(0).value;
+ }
+ return null;
+
+ }
+ public String getIncludeFileFlag(){
+ if (this.includeFiles.size() > 0){
+ /*
+ * If user set more than one map use the first one.
+ */
+ return this.includeFiles.get(0).flag;
+ }
+ return null;
+ }
+
+ /**
+ * Add OutputFile element
+ */
+ public void addOutputFile (UserDefineElement outPutFile){
+ if (isReference()){
+ throw noChildrenAllowed();
+ }
+ this.outPutFiles.addElement(outPutFile);
+ }
+
+ public Vector getOutputFiles(){
+ return this.outPutFiles;
+ }
+
+ public String getOutputFile (){
+ if (this.outPutFiles.size() > 0){
+ /*
+ * If user set more than one map use the first one.
+ */
+ return this.outPutFiles.get(0).value;
+ }
+ return null;
+
+ }
+ public String getOutPutFlag(){
+ if (this.outPutFiles.size() > 0){
+ /*
+ * If user set more than one map use the first one.
+ */
+ return this.outPutFiles.get(0).flag;
+ }
+ return null;
+ }
+
+ /**
+ * Add fileSet list
+ */
+ public void addFileList(FileList fileSet){
+ this.fileSetList.addElement(fileSet);
+ }
+
+ public Vector getFileList(){
+ Project p = getProject();
+ Vector fileListVector = new Vector();
+ for (int i = 0; i < this.fileSetList.size(); i++){
+ String[] tempStrList = this.fileSetList.get(i).getFiles(p);
+ for (int j = 0; j < tempStrList.length; j++){
+ fileListVector .addElement(tempStrList[j]);
+ }
+ }
+ return fileListVector;
+ }
+}
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/userdefine/UserDefineElement.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/userdefine/UserDefineElement.java
new file mode 100644
index 0000000000..b8c852c51a
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/userdefine/UserDefineElement.java
@@ -0,0 +1,23 @@
+package net.sf.antcontrib.cpptasks.userdefine;
+
+public class UserDefineElement {
+ String flag = null;
+ String value = null;
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+ public String getFlag() {
+ return flag;
+ }
+
+ public void setFlag(String flag) {
+ this.flag = flag;
+ }
+
+}
\ No newline at end of file
diff --git a/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/userdefine/UserDefineMapping.java b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/userdefine/UserDefineMapping.java
new file mode 100644
index 0000000000..bb290efba2
--- /dev/null
+++ b/Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/userdefine/UserDefineMapping.java
@@ -0,0 +1,186 @@
+/*
+ *
+ * Copyright 2001-2004 The Ant-Contrib project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.antcontrib.cpptasks.userdefine;
+public class UserDefineMapping {
+ // list of Arch: EBC, ARM, IA32, X64, IPF, PPC, NT32
+ public final static String[] arch = { "EBC", "ARM", "IA32", "X64", "IPF",
+ "PPC", "NT32" };
+
+ // list of OS: Linux, Windows
+ public final static String[] os = { "WINDOWS", "LINUX" };
+
+ // list of Vendor: Microsoft, Intel, Cygwin, Gcc
+ public final static String[] vendor = { "MSFT", "INTEL", "GCC", "CYGWIN" };
+
+ // list of Command Type: CC, LIB, LINK, ASL, ASM, ASMLINK
+ public final static String[] commandType = { "CC", "LIB", "LINK", "ASL",
+ "ASM", "ASMLINK", "PP" };
+
+ //
+ // flags mapping (Include compellingIncFileFlag,Path Delimiter, Output file
+ // flag,
+ // includepathfalge,
+ // )
+ // Examples: '/I' for MSFT cl.exe while '-I' for GCC
+ // '/Fo' for MSFT cl.exe while '-o' for GCC
+ //
+ public final static String[][] compellingIncFileFlag = {
+ { "MSFT_CC", "/FI" }, { "GCC_CC", "-include" },
+ { "INTEL_CC", "-FI" }, { "WINDDK_CC", "/FI" },
+ { "MSFT_ASM", "/FI" }, { "GCC_ASM", "-include" },
+ { "WINDDK_ASM", "/FI" } };
+
+ public final static String[][] includePathFlag = { { "MSFT_CC", "/I" },
+ { "GCC_CC", "-I" }, { "INTEL_CC", "/I" }, { "WINDDK_CC", "/I" },
+ { "MSFT_ASM", "/I" }, { "GCC_ASM", "-I" }, { "WINDDK_CC", "/I" },
+ { "MSFT_PP", "/I" }, { "GCC_PP", "-I" }, { "WINDDK_PP", "/I" } };
+
+ public final static String[][] outputFileFlag = { { "MSFT_CC", "/Fo" },
+ { "GCC_CC", "-o" }, { "INTEL_CC", "/Fo" }, { "WINDDK_CC", "/Fo" },
+ { "MSFT_LIB", "/OUT:" }, { "GCC_LIB", "-cr" },
+ { "INTEL_LIB", "/OUT:" }, { "WINDDK_LIB", "/OUT:" },
+ { "MSFT_LINK", "/OUT:" }, { "GCC_LINK", "-o" },
+ { "INTEL_LINK", "/OUT:" }, { "WINDDK_LINK", "/OUT:" },
+ { "MSFT_ASM", "/Fo" }, { "GCC_ASM", "-o" },
+ { "WINDDK_ASM", "/Fo" },{"WINDDK_IPF_ASM", "-o"} };
+
+ public final static String[][] subSystemFlag = {
+ { "MSFT_LIB", "/SUBSYSTEM:" }, { "GCC_LIB", "--subsystem=" },
+ { "WINDDk_LIB", "/SUBSYSTEM:" }, { "INTEL_LIB", "/SUBSYSTEM:" },
+ { "MSFT_LINK", "/SUBSYSTEM:" }, { "GCC_LINK", "--subsystem=" },
+ { "INTEL_LINK", "/SUBSYSTEM:" }, { "WINDDK_LINK", "/SUBSYSTEM:" } };
+
+ public final static String[][] outputFileSuffix = {
+ { "WINDOWS_ASM", ".obj" }, { "WINDOWS_CC", ".obj" },
+ { "LINUX_ASM", ".o" }, { "LINUX_CC", ".o" } };
+
+ public final static String[][] entryPointFlag = {
+ { "MSFT_LINK", "/ENTRY:" }, { "GCC_LINK", "-e" },
+ { "INTEL_LINK", "/ENTRY:" },
+ { "WINDDK_LINK", "/ENTRY:" } };
+
+ public final static String[][] mapFlag = { { "MSFT_LINK", "/MAP:" },
+ { "GCC_LINK", "" }, { "INTEL_LINK", "/MAP:" },
+ { "WINDDK_LINK", "/MAP:" } };
+
+ public final static String[][] pdbFlag = { { "MSFT_LINK", "/PDB:" },
+ { "GCC_LINK", "" }, { "INTEL_LINK", "" }, { "WINDDK_LINK", "/PDB:"} };
+
+ public static String getIncludePathDelimiter(String vendor,
+ String commandType) {
+ String key = vendor + "_" + commandType;
+ for (int i = 0; i < includePathFlag.length; i++) {
+ if (includePathFlag[i][0].equalsIgnoreCase(key)) {
+ return includePathFlag[i][1];
+ }
+ }
+ return null;
+ }
+
+ public static String getOutputFileFlag(String vendor, String arch, String commandType) {
+ /*
+ * First find outputfileFlag by vendor_arch_commandType
+ */
+ String key = vendor + "_" + arch + "_" + commandType;
+ for (int i = 0; i < outputFileFlag.length; i++) {
+ if (outputFileFlag[i][0].equalsIgnoreCase(key)) {
+ return outputFileFlag[i][1];
+ }
+ }
+ key = vendor + "_" + commandType;
+ for (int i = 0; i < outputFileFlag.length; i++) {
+ if (outputFileFlag[i][0].equalsIgnoreCase(key)) {
+ return outputFileFlag[i][1];
+ }
+ }
+ return null;
+ }
+
+ public static String getCompellingIncFileFlag(String vendor,
+ String commandType) {
+ String key = vendor + "_" + commandType;
+ for (int i = 0; i < compellingIncFileFlag.length; i++) {
+ if (compellingIncFileFlag[i][0].equalsIgnoreCase(key)) {
+ return compellingIncFileFlag[i][1];
+ }
+ }
+ return null;
+ }
+
+ public static String getSubSystemFlag(String vendor, String commandType) {
+ String key = vendor + "_" + commandType;
+ for (int i = 0; i < subSystemFlag.length; i++) {
+ if (subSystemFlag[i][0].equalsIgnoreCase(key)) {
+ return subSystemFlag[i][1];
+ }
+ }
+ return null;
+ }
+
+ public static String getEntryPointFlag(String vendor, String commandType) {
+ String key = vendor + "_" + commandType;
+ for (int i = 0; i < entryPointFlag.length; i++) {
+ if (entryPointFlag[i][0].equalsIgnoreCase(key)) {
+ return entryPointFlag[i][1];
+ }
+ }
+ return null;
+ }
+
+ public static String getMapFlag(String vendor, String commandType) {
+ String key = vendor + "_" + commandType;
+ for (int i = 0; i < mapFlag.length; i++) {
+ if (mapFlag[i][0].equalsIgnoreCase(key)) {
+ return mapFlag[i][1];
+ }
+ }
+ return null;
+ }
+
+ public static String getPdbFlag(String vendor, String commandType) {
+ String key = vendor + "_" + commandType;
+ for (int i = 0; i < pdbFlag.length; i++) {
+ if (pdbFlag[i][0].equalsIgnoreCase(key)) {
+ return pdbFlag[i][1];
+ }
+ }
+ return null;
+ }
+
+ //
+ // Well-known source file suffix and output file suffix relationship
+ // sourceExtension(Multiple),
+ // headExtension(Multiple) and outputSuffix(Single)
+ //
+
+ //
+ // Default command string such as 'cl' in MSFT while 'gcc' in GCC
+ //
+ public final static String[][] defaultCommand = { { "GCC", "gcc" },
+ { "MSFT_CC", "cl" }, { "MSFT_LIB", "lib" },
+ { "MSFT_LINK", "link" }, };
+
+ public static String getDefaultCommand(String toolchain) {
+ for (int i = 0; i < defaultCommand.length; i++) {
+ if (defaultCommand[i][0].equalsIgnoreCase(toolchain)) {
+ return defaultCommand[i][1];
+ }
+ }
+ return null;
+ }
+
+}
\ No newline at end of file
diff --git a/Tools/Source/CreateMdkPkg/MANIFEST.MF b/Tools/Source/CreateMdkPkg/MANIFEST.MF
new file mode 100644
index 0000000000..28f83c0ce2
--- /dev/null
+++ b/Tools/Source/CreateMdkPkg/MANIFEST.MF
@@ -0,0 +1,2 @@
+Manifest-Version: 1.0
+Main-Class: org.tianocore.packaging.workspace.ui.Welcome
diff --git a/Tools/Source/CreateMdkPkg/build.xml b/Tools/Source/CreateMdkPkg/build.xml
new file mode 100644
index 0000000000..1352d5d8d8
--- /dev/null
+++ b/Tools/Source/CreateMdkPkg/build.xml
@@ -0,0 +1,64 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Tools/Source/CreateMdkPkg/src/org/tianocore/common/Log.java b/Tools/Source/CreateMdkPkg/src/org/tianocore/common/Log.java
new file mode 100644
index 0000000000..383ffa719a
--- /dev/null
+++ b/Tools/Source/CreateMdkPkg/src/org/tianocore/common/Log.java
@@ -0,0 +1,188 @@
+/** @file
+
+ The file is used to provides static interfaces to save log and error information
+
+ Copyright (c) 2006, Intel Corporation
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+ **/
+
+package org.tianocore.common;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+
+import javax.swing.JOptionPane;
+
+/**
+ The class is used to provides static interfaces to save log and error information
+
+ @since CreateMdkPkg 1.0
+
+ **/
+public class Log {
+
+ //
+ //Log file
+ //
+ private static File fleLogFile = null;
+
+ //
+ //Err file
+ //
+ private static File fleErrFile = null;
+
+ //
+ //Log file name
+ //
+ static String strLogFileName = "Log.log";
+
+ //
+ //Err file name
+ //
+ static String strErrFileName = "Err.log";
+
+ /**
+ Main class, used for test
+
+ @param args
+
+ **/
+ public static void main(String[] args) {
+ try {
+ Log.log("Test", "test");
+ Log.err("Test1", "test1");
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ This is the default constructor
+ Do nothing
+
+ **/
+ public Log() {
+ }
+
+ /**
+ Call writeToLogFile to save log item and log information to log file
+
+ @param strItem The log item
+ @param strLog The log information
+
+ **/
+ public static void log(String strItem, String strLog) {
+ try {
+ writeToLogFile(strItem + ":" + strLog);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ Call writeToLogFile to save log information to log file
+
+ @param strLog The log information
+
+ **/
+ public static void log(String strLog) {
+ try {
+ writeToLogFile(strLog);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ Call writeToErrFile to save err item and err information to err file
+
+ @param strItem The err item
+ @param strLog The err information
+
+ **/
+ public static void err(String strItem, String strErr) {
+ try {
+ writeToErrFile("Error when " + strItem + ":" + strErr);
+ JOptionPane.showConfirmDialog(null, "Error when " + strItem + "::" + strErr, "Error",
+ JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE);
+
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ Call writeToErrFile to save err information to err file
+
+ @param strLog The err information
+
+ **/
+ public static void err(String strErr) {
+ try {
+ writeToErrFile("Error::" + strErr);
+ JOptionPane.showConfirmDialog(null, "Error::" + strErr, "Error", JOptionPane.DEFAULT_OPTION,
+ JOptionPane.ERROR_MESSAGE);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ Open log file and write log information
+
+ @param strLog The log information
+ @throws IOException
+
+ **/
+ private static void writeToLogFile(String strLog) throws IOException {
+ try {
+ if (fleLogFile == null) {
+ fleLogFile = new File(strLogFileName);
+ fleLogFile.createNewFile();
+ }
+ FileOutputStream fos = new FileOutputStream(fleLogFile, true);
+ fos.write((Tools.getCurrentDateTime() + "\r\n").getBytes());
+ fos.write((strLog + "\r\n").getBytes());
+ fos.flush();
+ fos.close();
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ Open err file and write err information
+
+ @param strLog The log information
+ @throws IOException
+
+ **/
+ private static void writeToErrFile(String strLog) throws IOException {
+ try {
+ if (fleErrFile == null) {
+ fleErrFile = new File(strErrFileName);
+ fleErrFile.createNewFile();
+ }
+ FileOutputStream fos = new FileOutputStream(fleErrFile, true);
+ fos.write((Tools.getCurrentDateTime() + "\r\n").getBytes());
+ fos.write((strLog + "\r\n").getBytes());
+ fos.flush();
+ fos.close();
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/Tools/Source/CreateMdkPkg/src/org/tianocore/common/Tools.java b/Tools/Source/CreateMdkPkg/src/org/tianocore/common/Tools.java
new file mode 100644
index 0000000000..2494b03815
--- /dev/null
+++ b/Tools/Source/CreateMdkPkg/src/org/tianocore/common/Tools.java
@@ -0,0 +1,120 @@
+/** @file
+
+ The file is used to provides some useful interfaces
+
+ Copyright (c) 2006, Intel Corporation
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+ **/
+
+package org.tianocore.common;
+
+import java.io.File;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.UUID;
+
+/**
+ The class is used to provides some useful interfaces
+
+ @since CreateMdkPkg 1.0
+
+ **/
+public class Tools {
+
+ /**
+ Used for test
+
+ @param args
+
+ **/
+ public static void main(String[] args) {
+ System.out.println(getCurrentDateTime());
+ }
+
+ /**
+ Get current date and time and format it as "yyyy-MM-dd HH:mm"
+
+ @return formatted current date and time
+
+ **/
+ public static String getCurrentDateTime() {
+ Date now = new Date(System.currentTimeMillis());
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
+ return sdf.format(now);
+ }
+
+ /**
+ Delete a folder and all its files
+
+ @param fleFolderName The name of the folder which need be deleted
+
+ @retval true - Delete successfully
+ @retval false - Delete successfully
+
+ **/
+ public static boolean deleteFolder(File fleFolderName) {
+ boolean blnIsDeleted = true;
+ File[] aryAllFiles = fleFolderName.listFiles();
+
+ for (int indexI = 0; indexI < aryAllFiles.length; indexI++) {
+ if (blnIsDeleted) {
+ if (aryAllFiles[indexI].isDirectory()) {
+ //
+ //If is a directory, recursively call this function to delete sub folders
+ //
+ blnIsDeleted = deleteFolder(aryAllFiles[indexI]);
+ } else if (aryAllFiles[indexI].isFile()) {
+ //
+ //If is a file, delete it
+ //
+ if (!aryAllFiles[indexI].delete()) {
+ blnIsDeleted = false;
+ }
+ }
+ }
+ }
+ if (blnIsDeleted) {
+ fleFolderName.delete();
+ }
+ return blnIsDeleted;
+ }
+
+ /**
+ Generate a UUID
+
+ @return the created UUID
+
+ **/
+ public static String generateUuidString() {
+ return UUID.randomUUID().toString();
+ }
+
+ /**
+ Get all system properties and output to the console
+
+ **/
+ public static void getSystemProperties() {
+ System.out.println(System.getProperty("java.class.version"));
+ System.out.println(System.getProperty("java.class.path"));
+ System.out.println(System.getProperty("java.ext.dirs"));
+ System.out.println(System.getProperty("os.name"));
+ System.out.println(System.getProperty("os.arch"));
+ System.out.println(System.getProperty("os.version"));
+ System.out.println(System.getProperty("file.separator"));
+ System.out.println(System.getProperty("path.separator"));
+ System.out.println(System.getProperty("line.separator"));
+ System.out.println(System.getProperty("user.name"));
+ System.out.println(System.getProperty("user.home"));
+ System.out.println(System.getProperty("user.dir"));
+ System.out.println(System.getProperty("PATH"));
+
+ System.out.println(System.getenv("PROCESSOR_REVISION"));
+ }
+}
diff --git a/Tools/Source/CreateMdkPkg/src/org/tianocore/packaging/FrameworkPkg.java b/Tools/Source/CreateMdkPkg/src/org/tianocore/packaging/FrameworkPkg.java
new file mode 100644
index 0000000000..e12b58438f
--- /dev/null
+++ b/Tools/Source/CreateMdkPkg/src/org/tianocore/packaging/FrameworkPkg.java
@@ -0,0 +1,238 @@
+/** @file
+
+ The file is used to install .jar file
+
+ Copyright (c) 2006, Intel Corporation
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+ **/
+
+package org.tianocore.packaging;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Enumeration;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+
+import javax.swing.JFrame;
+
+/**
+ The class is used to install .jar file
+
+ @since CreateMdkPkg 1.0
+
+ **/
+public class FrameworkPkg {
+ //
+ // Define class members
+ //
+ static JFrame frame;
+
+ private String pkg = null;
+
+ private JarFile jf = null;
+
+ /**
+ Main clase, used to test
+
+ @param args
+
+ **/
+ public static void main(String[] args) {
+ FrameworkPkg fp = new FrameworkPkg("C:\\Documents and Settings\\hchen30\\Desktop\\com.jar");
+ try {
+ fp.install("C:\\MyWorkspace" + System.getProperty("file.separator"));
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ This is the default constructor
+
+ **/
+ public FrameworkPkg() {
+
+ }
+
+ /**
+ This is the override constructor
+
+ @param package_name
+
+ **/
+ public FrameworkPkg(String package_name) {
+ pkg = package_name;
+ }
+
+ /**
+ Get package name
+
+ @param package_name
+
+ **/
+ public void setPkg(String package_name) {
+ pkg = package_name;
+ }
+
+ /**
+ Set Jarfile
+
+ @throws IOException
+
+ **/
+ public void setJarFile() throws IOException {
+ jf = new JarFile(pkg);
+ }
+
+ /**
+ Install the jar file to specific path
+
+ @param dir The target path
+ @return 0 - success
+ @throws IOException
+ @throws BasePkgNotInstalled
+ @throws VerNotEqual
+ @throws GuidNotEqual
+ @throws SameAll
+
+ **/
+ public int install(final String dir) throws IOException, BasePkgNotInstalled, VerNotEqual, GuidNotEqual, SameAll {
+ pre_install();
+ extract(dir);
+ post_install();
+ return 0;
+ }
+
+ /**
+
+ @return
+
+ **/
+ public int uninstall() {
+
+ return 0;
+ }
+
+ /**
+ Check before install
+
+ @throws IOException
+ @throws BasePkgNotInstalled
+ @throws VerNotEqual
+ @throws GuidNotEqual
+ @throws SameAll
+
+ **/
+ protected void pre_install() throws IOException, BasePkgNotInstalled, VerNotEqual, GuidNotEqual, SameAll {
+ jf = new JarFile(pkg);
+ if (false) {
+ throw new BasePkgNotInstalled();
+ }
+ if (false) {
+ throw new VerNotEqual();
+ }
+ if (false) {
+ throw new GuidNotEqual();
+ }
+ if (false) {
+ throw new SameAll();
+ }
+ }
+
+ /**
+ End of install
+
+ @throws IOException
+
+ **/
+ protected void post_install() throws IOException {
+ jf.close();
+
+ }
+
+ /**
+ Extract the jar file to specific dir
+
+ @param dir The target path
+ @throws IOException
+
+ **/
+ private synchronized void extract(String dir) throws IOException {
+
+ int i = 0;
+ try {
+ for (Enumeration e = jf.entries(); e.hasMoreElements(); i++) {
+ JarEntry je = (JarEntry) e.nextElement();
+ if (je.getName().contains("META-INF"))
+ continue;
+ if (je.isDirectory()) {
+ new File(dir + je.getName()).mkdirs();
+ continue;
+ }
+
+ if (je != null) {
+ //
+ // Get an input stream for the entry.
+ //
+ InputStream entryStream = jf.getInputStream(je);
+
+ try {
+ //
+ // Create the output file (clobbering the file if it exists).
+ //
+ FileOutputStream file = new FileOutputStream(dir + je.getName());
+
+ try {
+ //
+ // Allocate a buffer for reading the entry data.
+ //
+ byte[] buffer = new byte[1024];
+ int bytesRead;
+
+ //
+ // Read the entry data and write it to the output file.
+ //
+ while ((bytesRead = entryStream.read(buffer)) != -1) {
+ file.write(buffer, 0, bytesRead);
+ }
+
+ System.out.println(je.getName() + " extracted.");
+ } finally {
+ file.close();
+ }
+ } finally {
+ entryStream.close();
+ }
+ }
+ }
+ } finally {
+ jf.close();
+ }
+ }
+}
+
+class BasePkgNotInstalled extends Exception {
+ final static long serialVersionUID = 0;
+}
+
+class VerNotEqual extends Exception {
+ final static long serialVersionUID = 0;
+}
+
+class GuidNotEqual extends Exception {
+ final static long serialVersionUID = 0;
+}
+
+class SameAll extends Exception {
+ final static long serialVersionUID = 0;
+}
diff --git a/Tools/Source/CreateMdkPkg/src/org/tianocore/packaging/MdkPkg.java b/Tools/Source/CreateMdkPkg/src/org/tianocore/packaging/MdkPkg.java
new file mode 100644
index 0000000000..74250cc4a6
--- /dev/null
+++ b/Tools/Source/CreateMdkPkg/src/org/tianocore/packaging/MdkPkg.java
@@ -0,0 +1,59 @@
+/** @file
+
+ The file is used to override FrameworkPkg to provides customized interfaces
+
+ Copyright (c) 2006, Intel Corporation
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+ **/
+
+package org.tianocore.packaging;
+
+import java.io.IOException;
+
+/**
+ The class is used to override FrameworkPkg to provides customized interfaces
+
+ @since CreateMdkPkg 1.0
+
+ **/
+public class MdkPkg extends FrameworkPkg {
+
+ /**
+ Main class, reserved for test
+
+ @param args
+
+ **/
+ public static void main(String[] args) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /**
+ This is the default constructor
+
+ @param strJarFile The jar file need be installed
+ @throws IOException
+
+ **/
+ public MdkPkg(String strJarFile) throws IOException {
+ this.setPkg(strJarFile);
+ this.setJarFile();
+ }
+
+ /* (non-Javadoc)
+ * @see org.tianocore.packaging.FrameworkPkg#pre_install()
+ *
+ * Override pre_install to do nothing
+ *
+ */
+ protected void pre_install() {
+ }
+}
diff --git a/Tools/Source/CreateMdkPkg/src/org/tianocore/packaging/common/ui/ExitConfirm.java b/Tools/Source/CreateMdkPkg/src/org/tianocore/packaging/common/ui/ExitConfirm.java
new file mode 100644
index 0000000000..170ca6255d
--- /dev/null
+++ b/Tools/Source/CreateMdkPkg/src/org/tianocore/packaging/common/ui/ExitConfirm.java
@@ -0,0 +1,264 @@
+/** @file
+
+ The file is used to popup a exit confirmation window when program exists
+
+ Copyright (c) 2006, Intel Corporation
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+ **/
+package org.tianocore.packaging.common.ui;
+
+import java.awt.Dimension;
+import java.awt.Toolkit;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.WindowEvent;
+import java.awt.event.WindowListener;
+
+import javax.swing.JButton;
+import javax.swing.JDialog;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+
+/**
+ The class is used to popup a exit confirmation window when program exists
+ It extends JDialog and implements ActionListener and WindowListener
+
+ @since CreateMdkPkg 1.0
+
+ **/
+public class ExitConfirm extends JDialog implements ActionListener, WindowListener {
+ ///
+ /// Define class Serial Version UID
+ ///
+ private static final long serialVersionUID = -5875921789385911029L;
+
+ //
+ // Define class members
+ //
+ private JPanel jContentPane = null;
+
+ private JLabel jLabelMessage = null;
+
+ private JLabel jLabelResume = null;
+
+ private JLabel jLabelExit = null;
+
+ private JButton jButtonResume = null;
+
+ private JButton jButtonExit = null;
+
+ public boolean isCancel = false;
+
+ /**
+ This method initializes jButtonResume
+
+ @return javax.swing.JButton jButtonResume
+
+ **/
+ private JButton getJButtonResume() {
+ if (jButtonResume == null) {
+ jButtonResume = new JButton();
+ jButtonResume.setText("Resume");
+ jButtonResume.setSize(new java.awt.Dimension(90, 20));
+ jButtonResume.setLocation(new java.awt.Point(150, 105));
+ jButtonResume.setMnemonic('R');
+ jButtonResume.addActionListener(this);
+ }
+ return jButtonResume;
+ }
+
+ /**
+ This method initializes jButtonExit
+
+ @return javax.swing.JButton jButtonExit
+
+ **/
+ private JButton getJButtonExit() {
+ if (jButtonExit == null) {
+ jButtonExit = new JButton();
+ jButtonExit.setText("Exit");
+ jButtonExit.setSize(new java.awt.Dimension(90, 20));
+ jButtonExit.setLocation(new java.awt.Point(260, 105));
+ jButtonExit.setMnemonic('x');
+ jButtonExit.addActionListener(this);
+ }
+ return jButtonExit;
+ }
+
+ /**
+ Main clasee, reserved for test
+
+ @param args
+
+ **/
+ public static void main(String[] args) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /**
+ This is the default constructor
+
+ **/
+ public ExitConfirm(IFrame parentFrame, boolean modal) {
+ super(parentFrame, modal);
+ initialize();
+ }
+
+ /**
+ This method initializes this
+
+ **/
+ private void initialize() {
+ this.setSize(500, 170);
+ this.setTitle("Exit");
+ this.setResizable(false);
+ this.setContentPane(getJContentPane());
+ this.addWindowListener(this);
+ //
+ //Set DO_NOTHING_ON_CLOSE when click Close button on title bar
+ //
+ this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
+ centerWindow();
+ }
+
+ /**
+ This method initializes jContentPane
+
+ @return javax.swing.JPanel jContentPane
+
+ **/
+ private JPanel getJContentPane() {
+ if (jContentPane == null) {
+ jLabelExit = new JLabel();
+ jLabelExit.setSize(new java.awt.Dimension(450, 20));
+ jLabelExit.setLocation(new java.awt.Point(25, 70));
+ jLabelResume = new JLabel();
+ jLabelResume.setSize(new java.awt.Dimension(450, 20));
+ jLabelResume.setLocation(new java.awt.Point(25, 40));
+ jLabelMessage = new JLabel();
+ jLabelMessage.setSize(new java.awt.Dimension(450, 20));
+ jLabelMessage.setLocation(new java.awt.Point(25, 10));
+ jContentPane = new JPanel();
+ jContentPane.setLayout(null);
+ jContentPane.add(jLabelMessage, null);
+ jContentPane.add(jLabelResume, null);
+ jContentPane.add(jLabelExit, null);
+ jContentPane.add(getJButtonResume(), null);
+ jContentPane.add(getJButtonExit(), null);
+ }
+ return jContentPane;
+ }
+
+ /**
+ Call setWarningMessage to set messages of frame when it is used for Setup
+
+ **/
+ public void setSetupMessage() {
+ String strTitle = "Exit Setup";
+ String strMessage = "Setup is not complete. If you quit now, the program will not be installed.";
+ //String strResume = "You may run the setup program at a later time to complete the installation.";
+ String strResume = "";
+ String strExit = "To continue installing, click Resume. To quit the Setup program, click Exit.";
+ setWarningMessage(strTitle, strMessage, strResume, strExit);
+ }
+
+ /**
+ Call setWarningMessage to set messages of frame when it is used for Module Main GUI
+
+ **/
+ public void setModuleMessage() {
+ String strTitle = "Exit";
+ String strMessage = "Do you really want to quit now?";
+ String strResume = "All unsaved module information will be lost.";
+ String strExit = "To continue editing module, click Resume. To quit the program, click Exit.";
+ setWarningMessage(strTitle, strMessage, strResume, strExit);
+ }
+
+ /**
+ Set message information via input data
+
+ @param strTitle The title value
+ @param strMessage The main message value
+ @param strResume The resume message value
+ @param strExit The exit message value
+
+ **/
+ private void setWarningMessage(String strTitle, String strMessage, String strResume, String strExit) {
+ this.setTitle(strTitle);
+ jLabelMessage.setText(strMessage);
+ jLabelResume.setText(strResume);
+ jLabelExit.setText(strExit);
+ }
+
+ /* (non-Javadoc)
+ * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
+ *
+ * Override actionPerformed to listern all actions
+ *
+ */
+ public void actionPerformed(ActionEvent arg0) {
+ //
+ //Set isCancel true when click button "Exit"
+ //
+ Object obj = arg0.getSource();
+ if (obj == jButtonResume) {
+ isCancel = false;
+ }
+ if (obj == jButtonExit) {
+ isCancel = true;
+ }
+ this.setVisible(false);
+ }
+
+ /**
+ Make the window in the center of the screen
+
+ **/
+ private void centerWindow() {
+ Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
+ this.setLocation((d.width - this.getSize().width) / 2, (d.height - this.getSize().height) / 2);
+ }
+
+ public void windowActivated(WindowEvent arg0) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void windowClosed(WindowEvent arg0) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void windowClosing(WindowEvent arg0) {
+ isCancel = false;
+ this.setVisible(false);
+ }
+
+ public void windowDeactivated(WindowEvent arg0) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void windowDeiconified(WindowEvent arg0) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void windowIconified(WindowEvent arg0) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void windowOpened(WindowEvent arg0) {
+ // TODO Auto-generated method stub
+
+ }
+}
diff --git a/Tools/Source/CreateMdkPkg/src/org/tianocore/packaging/common/ui/IFrame.java b/Tools/Source/CreateMdkPkg/src/org/tianocore/packaging/common/ui/IFrame.java
new file mode 100644
index 0000000000..211b9c3adb
--- /dev/null
+++ b/Tools/Source/CreateMdkPkg/src/org/tianocore/packaging/common/ui/IFrame.java
@@ -0,0 +1,203 @@
+/** @file
+
+ The file is used to override Frame to provides customized interfaces
+
+ Copyright (c) 2006, Intel Corporation
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+ **/
+
+package org.tianocore.packaging.common.ui;
+
+import java.awt.Dimension;
+import java.awt.Toolkit;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.WindowEvent;
+import java.awt.event.WindowListener;
+
+import javax.swing.JFrame;
+
+/**
+ The class is used to override Frame to provides customized interfaces
+ It extends JFrame implements ActionListener and WindowListener
+
+ @since CreateMdkPkg 1.0
+
+ **/
+public class IFrame extends JFrame implements ActionListener, WindowListener {
+ ///
+ /// Define class Serial Version UID
+ ///
+ private static final long serialVersionUID = -3324138961029300427L;
+
+ //
+ // Define class members
+ //
+ private ExitConfirm ec = null;
+
+ //
+ // To indicate the status while quit
+ // 0 - When setup (Default)
+ // 1 - Whne editing module
+ //
+ private int intExitType = 0;
+
+ /**
+ Main class, used for test
+
+ @param args
+
+ **/
+ public static void main(String[] args) {
+ IFrame i = new IFrame();
+ i.setVisible(true);
+ }
+
+ /**
+ This is the default constructor
+
+ **/
+ public IFrame() {
+ super();
+ initialize();
+ }
+
+ /**
+ This method initializes this
+
+ **/
+ public void initialize() {
+ this.setResizable(false);
+ this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
+ this.addWindowListener(this);
+ }
+
+ /**
+ Start the dialog at the center of screen
+
+ @param intWidth The width of the dialog
+ @param intHeight The height of the dialog
+
+ **/
+ protected void centerWindow(int intWidth, int intHeight) {
+ Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
+ this.setLocation((d.width - intWidth) / 2, (d.height - intHeight) / 2);
+ }
+
+ /**
+ Start the dialog at the center of screen
+
+ **/
+ protected void centerWindow() {
+ centerWindow(this.getSize().width, this.getSize().height);
+ }
+
+ /**
+ Set the exit window type
+
+ @param ExitType The input data of ExitType
+
+ **/
+ protected void setExitType(int ExitType) {
+ this.intExitType = ExitType;
+ }
+
+ /* (non-Javadoc)
+ * @see java.awt.event.WindowListener#windowClosing(java.awt.event.WindowEvent)
+ *
+ * Override windowClosing to call this.onDisvisible()
+ *
+ */
+ public void windowClosing(WindowEvent arg0) {
+ this.onDisvisible();
+ }
+
+ public void windowOpened(WindowEvent arg0) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void windowClosed(WindowEvent arg0) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void windowIconified(WindowEvent arg0) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void windowDeiconified(WindowEvent arg0) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void windowActivated(WindowEvent arg0) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void windowDeactivated(WindowEvent arg0) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void actionPerformed(ActionEvent arg0) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /**
+ Define the actions when exit
+
+ **/
+ public void onExit() {
+ ec = new ExitConfirm(this, true);
+ //
+ //Show different warning message via different ExitType
+ //
+ switch (intExitType) {
+ case 0:
+ ec.setSetupMessage();
+ break;
+ case 1:
+ ec.setModuleMessage();
+ break;
+ }
+ ec.setVisible(true);
+ if (ec.isCancel) {
+ this.dispose();
+ System.exit(0);
+ }
+ }
+
+ /**
+ Define the actions when disvisible
+
+ **/
+ public void onDisvisible() {
+ ec = new ExitConfirm(this, true);
+ //
+ //Show different warning message via different ExitType
+ //
+ switch (intExitType) {
+ case 0:
+ ec.setSetupMessage();
+ break;
+ case 1:
+ ec.setModuleMessage();
+ break;
+ }
+ ec.setVisible(true);
+ if (ec.isCancel) {
+ this.dispose();
+ }
+ }
+}
diff --git a/Tools/Source/CreateMdkPkg/src/org/tianocore/packaging/workspace/command/InstallWorkspace.java b/Tools/Source/CreateMdkPkg/src/org/tianocore/packaging/workspace/command/InstallWorkspace.java
new file mode 100644
index 0000000000..47bd36fe0a
--- /dev/null
+++ b/Tools/Source/CreateMdkPkg/src/org/tianocore/packaging/workspace/command/InstallWorkspace.java
@@ -0,0 +1,161 @@
+/** @file
+
+ The file is used to override AbstractCellEditor to provides customized interfaces
+
+ Copyright (c) 2006, Intel Corporation
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+ **/
+
+package org.tianocore.packaging.workspace.command;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.tianocore.common.Log;
+import org.tianocore.common.Tools;
+import org.tianocore.packaging.MdkPkg;
+
+/**
+ The class is used to override AbstractCellEditor to provides customized interfaces
+
+ @since CreateMdkPkg 1.0
+
+ **/
+public class InstallWorkspace {
+ /**
+ Main class, reserved for test
+
+ @param args
+
+ **/
+ public static void main(String[] args) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /**
+ This is the default constructor
+ Reserved
+
+ **/
+ public InstallWorkspace() {
+ // TODO
+ }
+
+ /**
+ Check if exist target dir
+
+ @param strInstallDir The install target dir
+ @retval true - The target exists
+ @retval false - The target doesn't exist
+
+ **/
+ public static boolean isExistInstallDir(String strInstallDir) {
+ File id = new File(strInstallDir);
+ return id.exists();
+ }
+
+ /**
+ Create install target dir
+
+ @param strInstallDir The install target dir
+ @retval true - Install success
+ @retval false - Install fail
+
+ **/
+ public static boolean createInstallDir(String strInstallDir) {
+ File id = new File(strInstallDir);
+ try {
+ return id.mkdir();
+ } catch (Exception e) {
+ System.out.print(e.getMessage());
+ return false;
+ }
+ }
+
+ /**
+ Reserved
+
+ @return boolean
+
+ **/
+ public static boolean setSystemEnvironment() {
+ return true;
+ }
+
+ /**
+ Reserved
+
+ @return boolean
+ **/
+ public static boolean setToolChainPath() {
+ return true;
+ }
+
+ /**
+ Reserved
+
+ @return boolean
+ **/
+ public static boolean setToolChain() {
+ return true;
+ }
+
+ /**
+ Reserved
+
+ @return boolean
+ **/
+ public static boolean setFrameworkDatabase() {
+ return true;
+ }
+
+ /**
+ Delete setup files and directory
+
+ @param strPath The delete target dir
+ @retval true - Delete success
+ @retval false - Delete fail
+
+ **/
+ public static boolean delSetupPackage(String strPath) {
+ File f = new File(strPath);
+ try {
+ Tools.deleteFolder(f);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return true;
+ }
+
+ /**
+
+ @param strInstallDir The install target dir
+ @param strJarFile The install target file
+ @retval true - Install success
+ @retval false - Install fail
+ @throws IOException
+
+ **/
+ public static boolean installPackage(String strInstallDir, String strJarFile) throws IOException {
+ Log.log("Install Dir", strInstallDir);
+ Log.log("Jar File Path", strJarFile);
+
+ MdkPkg mp = new MdkPkg(strJarFile);
+ try {
+ mp.install(strInstallDir + System.getProperty("file.separator"));
+ return true;
+ } catch (Exception e) {
+ e.printStackTrace();
+ Log.log("Install Err", e.toString());
+ }
+ return false;
+ }
+}
diff --git a/Tools/Source/CreateMdkPkg/src/org/tianocore/packaging/workspace/ui/Finish.java b/Tools/Source/CreateMdkPkg/src/org/tianocore/packaging/workspace/ui/Finish.java
new file mode 100644
index 0000000000..aab046f570
--- /dev/null
+++ b/Tools/Source/CreateMdkPkg/src/org/tianocore/packaging/workspace/ui/Finish.java
@@ -0,0 +1,295 @@
+/** @file
+
+ The file is used to show a Finish page in the last step of setup
+
+ Copyright (c) 2006, Intel Corporation
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+ **/
+
+package org.tianocore.packaging.workspace.ui;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.WindowEvent;
+
+import javax.swing.JButton;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTextArea;
+
+import org.tianocore.packaging.common.ui.IFrame;
+
+/**
+ The class is used to show a Finish page in the last step of setup
+
+ @since CreateMdkPkg 1.0
+
+ **/
+public class Finish extends IFrame implements ActionListener {
+
+ ///
+ /// Define class Serial Version UID
+ ///
+ private static final long serialVersionUID = 9055339173915836187L;
+
+ //
+ // Define class members
+ //
+ private JPanel jContentPane = null;
+
+ private JTextArea jTextAreaTitle = null;
+
+ private JTextArea jTextAreaContent = null;
+
+ private JPanel jPanel = null;
+
+ private JButton jButtonFinish = null;
+
+ private JLabel jLabel = null;
+
+ private JLabel jLabel1 = null;
+
+ private JScrollPane jScrollPane = null;
+
+ private JTextArea jTextAreaComment = null;
+
+ private String strInstallDir = "";
+
+ /**
+ This method initializes jTextAreaTitle
+
+ @return javax.swing.JTextArea jTextAreaTitle
+
+ **/
+ private JTextArea getJTextAreaTitle() {
+ if (jTextAreaTitle == null) {
+ jTextAreaTitle = new JTextArea();
+ jTextAreaTitle.setLocation(new java.awt.Point(0, 0));
+ jTextAreaTitle.setText(" Click button \"Install\" to start installation");
+ jTextAreaTitle.setFont(new java.awt.Font("Dialog", java.awt.Font.BOLD, 14));
+ jTextAreaTitle.setEditable(false);
+ jTextAreaTitle.setSize(new java.awt.Dimension(495, 20));
+ }
+ return jTextAreaTitle;
+ }
+
+ /**
+ This method initializes jTextAreaContent
+
+ @return javax.swing.JTextArea jTextAreaContent
+
+ **/
+ private JTextArea getJTextAreaContent() {
+ if (jTextAreaContent == null) {
+ jTextAreaContent = new JTextArea();
+ jTextAreaContent.setLocation(new java.awt.Point(0, 20));
+ jTextAreaContent.setText("");
+ jTextAreaContent.setEditable(false);
+ jTextAreaContent.setSize(new java.awt.Dimension(495, 35));
+ }
+ return jTextAreaContent;
+ }
+
+ /**
+ This method initializes jPanel
+
+ @return javax.swing.JPanel jPanel
+
+ **/
+ private JPanel getJPanel() {
+ if (jPanel == null) {
+ jLabel1 = new JLabel();
+ jLabel1.setText("");
+ jLabel1.setLocation(new java.awt.Point(30, 40));
+ jLabel1.setSize(new java.awt.Dimension(435, 20));
+ jLabel = new JLabel();
+ jLabel.setText("");
+ jLabel.setLocation(new java.awt.Point(30, 15));
+ jLabel.setSize(new java.awt.Dimension(435, 20));
+ jPanel = new JPanel();
+ jPanel.setLayout(null);
+ jPanel.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));
+ jPanel.setSize(new java.awt.Dimension(494, 251));
+ jPanel.setLocation(new java.awt.Point(0, 55));
+ jPanel.add(jLabel, null);
+ jPanel.add(jLabel1, null);
+ jPanel.add(getJScrollPane(), null);
+ }
+ return jPanel;
+ }
+
+ /**
+ This method initializes jButtonFinish
+
+ @return javax.swing.JButton jButtonFinish
+
+ **/
+ private JButton getJButtonCancel() {
+ if (jButtonFinish == null) {
+ jButtonFinish = new JButton();
+ jButtonFinish.setText("Finish");
+ jButtonFinish.setBounds(new java.awt.Rectangle(360, 315, 90, 20));
+ jButtonFinish.setEnabled(true);
+ jButtonFinish.setSelected(false);
+ jButtonFinish.setMnemonic('C');
+ jButtonFinish.addActionListener(this);
+ }
+ return jButtonFinish;
+ }
+
+ /**
+ This method initializes jScrollPane
+
+ @return javax.swing.JScrollPane jScrollPane
+
+ **/
+ private JScrollPane getJScrollPane() {
+ if (jScrollPane == null) {
+ jScrollPane = new JScrollPane();
+ jScrollPane.setLocation(new java.awt.Point(30, 65));
+ jScrollPane.setSize(new java.awt.Dimension(435, 180));
+ jScrollPane.setViewportView(getJTextAreaComment());
+ }
+ return jScrollPane;
+ }
+
+ /**
+ This method initializes jTextAreaComment
+
+ @return javax.swing.JTextArea jTextAreaComment
+
+ **/
+ private JTextArea getJTextAreaComment() {
+ if (jTextAreaComment == null) {
+ jTextAreaComment = new JTextArea();
+ jTextAreaComment.setEditable(false);
+ jTextAreaComment.setLineWrap(true);
+ jTextAreaComment.setWrapStyleWord(false);
+ }
+ return jTextAreaComment;
+ }
+
+ /**
+ Main class, used for test
+
+ @param args
+ **/
+ public static void main(String[] args) {
+ Finish f = new Finish();
+ f.setVisible(true);
+ }
+
+ /**
+ This is the override constructor
+
+ @param InstallDir The install target dir
+
+ **/
+ public Finish(String InstallDir) {
+ super();
+ this.strInstallDir = InstallDir;
+ init();
+ }
+
+ /**
+ This is the default constructor
+
+ **/
+ public Finish() {
+ super();
+ init();
+ }
+
+ /**
+ This method initializes this
+
+ **/
+ private void init() {
+ this.setSize(500, 390);
+
+ this.setContentPane(getJContentPane());
+ this.setTitle("Setup - Installing");
+ this.centerWindow();
+ this.getRootPane().setDefaultButton(jButtonFinish);
+ switchFinish();
+ }
+
+ /**
+ This method initializes jContentPane
+
+ @return javax.swing.JPanel jContentPane
+
+ **/
+ private JPanel getJContentPane() {
+ if (jContentPane == null) {
+ jContentPane = new JPanel();
+ jContentPane.setLayout(null);
+ jContentPane.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
+ jContentPane.add(getJTextAreaTitle(), null);
+ jContentPane.add(getJTextAreaContent(), null);
+ jContentPane.add(getJPanel(), null);
+ jContentPane.add(getJButtonCancel(), null);
+ }
+ return jContentPane;
+ }
+
+ /* (non-Javadoc)
+ * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
+ *
+ * Override actionPerformed to listen all actions
+ *
+ */
+ public void actionPerformed(ActionEvent arg0) {
+ Object obj = arg0.getSource();
+
+ if (obj == jButtonFinish) {
+ this.dispose();
+ System.exit(0);
+ }
+ }
+
+ /**
+ Change all message values to Finish contents.
+
+ **/
+ private void switchFinish() {
+ this.setTitle("Setup - Finish");
+ jTextAreaTitle.setText(" Congratulations");
+ jTextAreaContent.setText(" Your workspace was installed!");
+ jLabel.setText("The MDK package was installed successfully");
+ jLabel1.setText("Now you can start the trip with EFI");
+ jTextAreaComment.setText("Please add \"WORKSPACE=" + this.strInstallDir
+ + "\" into your system environment variable");
+ jButtonFinish.setEnabled(true);
+ this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ jButtonFinish.setText("Finish");
+ }
+
+ // private void switchInstall() {
+ // jTextAreaTitle.setText(" Installation is in process...");
+ // jLabel.setText("The MDK package was being installed...");
+ // jLabel1.setText("Just waiting for a second");
+ // jButtonFinish.setEnabled(false);
+ // jButtonFinish.setText("Finish");
+ // }
+
+ /* (non-Javadoc)
+ * @see java.awt.event.WindowListener#windowClosing(java.awt.event.WindowEvent)
+ *
+ * Override windowClosing to exit directly
+ *
+ */
+ public void windowClosing(WindowEvent arg0) {
+ this.dispose();
+ System.exit(0);
+ }
+}
diff --git a/Tools/Source/CreateMdkPkg/src/org/tianocore/packaging/workspace/ui/LicenseAgreement.java b/Tools/Source/CreateMdkPkg/src/org/tianocore/packaging/workspace/ui/LicenseAgreement.java
new file mode 100644
index 0000000000..4661743a57
--- /dev/null
+++ b/Tools/Source/CreateMdkPkg/src/org/tianocore/packaging/workspace/ui/LicenseAgreement.java
@@ -0,0 +1,403 @@
+/** @file
+
+ The class is used to show a License Agreement page in
+ the process of setup
+
+ Copyright (c) 2006, Intel Corporation
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+ **/
+
+package org.tianocore.packaging.workspace.ui;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.WindowEvent;
+
+import javax.swing.JButton;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JRadioButton;
+import javax.swing.JScrollPane;
+import javax.swing.JTextArea;
+
+import org.tianocore.packaging.common.ui.IFrame;
+
+/**
+ The class is used to show a License Agreement page in
+ the process of setup
+
+ @since CreateMdkPkg 1.0
+
+ **/
+public class LicenseAgreement extends IFrame implements ActionListener {
+
+ ///
+ /// Define class Serial Version UID
+ ///
+ private static final long serialVersionUID = 5507683268692334188L;
+
+ //
+ // Define class members
+ //
+ private JPanel jContentPane = null;
+
+ private JTextArea jTextArea = null;
+
+ private JTextArea jTextArea1 = null;
+
+ private JPanel jPanel = null;
+
+ private JButton jButtonBack = null;
+
+ private JButton jButtonNext = null;
+
+ private JButton jButtonCancel = null;
+
+ private JLabel jLabel = null;
+
+ private JRadioButton jRadioButtonAgree = null;
+
+ private JRadioButton jRadioButtonDisagree = null;
+
+ private JScrollPane jScrollPane = null;
+
+ private JTextArea jTextArea2 = null;
+
+ private JLabel jLabel1 = null;
+
+ private Welcome w = null;
+
+ private SelectDestinationDirectory sdd = null;
+
+ /**
+ This method initializes jTextArea
+
+ @return javax.swing.JTextArea jTextArea
+
+ **/
+ private JTextArea getJTextArea() {
+ if (jTextArea == null) {
+ jTextArea = new JTextArea();
+ jTextArea.setLocation(new java.awt.Point(0, 0));
+ jTextArea.setText(" License Agreement");
+ jTextArea.setFont(new java.awt.Font("Dialog", java.awt.Font.BOLD, 14));
+ jTextArea.setEditable(false);
+ jTextArea.setSize(new java.awt.Dimension(495, 20));
+ }
+ return jTextArea;
+ }
+
+ /**
+ This method initializes jTextArea1
+
+ @return javax.swing.JTextArea jTextArea1
+
+ **/
+ private JTextArea getJTextArea1() {
+ if (jTextArea1 == null) {
+ jTextArea1 = new JTextArea();
+ jTextArea1.setLocation(new java.awt.Point(0, 20));
+ jTextArea1.setText(" Please read the following important information before continuing.");
+ jTextArea1.setEditable(false);
+ jTextArea1.setSize(new java.awt.Dimension(495, 35));
+ }
+ return jTextArea1;
+ }
+
+ /**
+ This method initializes jPanel
+
+ @return javax.swing.JPanel jPanel
+
+ **/
+ private JPanel getJPanel() {
+ if (jPanel == null) {
+ jLabel1 = new JLabel();
+ jLabel1.setText(" this agreement before continuing with the installation.");
+ jLabel1.setLocation(new java.awt.Point(30, 35));
+ jLabel1.setSize(new java.awt.Dimension(435, 20));
+ jLabel = new JLabel();
+ jLabel.setText("Please read the following License Agreement. You must accept the terms of");
+ jLabel.setLocation(new java.awt.Point(30, 15));
+ jLabel.setSize(new java.awt.Dimension(435, 20));
+ jPanel = new JPanel();
+ jPanel.setLayout(null);
+ jPanel.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));
+ jPanel.setSize(new java.awt.Dimension(494, 251));
+ jPanel.setLocation(new java.awt.Point(0, 55));
+ jPanel.add(jLabel, null);
+ jPanel.add(getJRadioButtonAgree(), null);
+ jPanel.add(getJRadioButtonDisagree(), null);
+ jPanel.add(getJScrollPane(), null);
+ jPanel.add(jLabel1, null);
+ }
+ return jPanel;
+ }
+
+ /**
+ This method initializes jButtonBack
+
+ @return javax.swing.JButton jButtonBack
+
+ **/
+ private JButton getJButtonBack() {
+ if (jButtonBack == null) {
+ jButtonBack = new JButton();
+ jButtonBack.setText("Back");
+ jButtonBack.setSize(new java.awt.Dimension(90, 20));
+ jButtonBack.setLocation(new java.awt.Point(200, 315));
+ jButtonBack.setMnemonic('B');
+ jButtonBack.addActionListener(this);
+ }
+ return jButtonBack;
+ }
+
+ /**
+ This method initializes jButtonNext
+
+ @return javax.swing.JButton jButtonNext
+
+ **/
+ private JButton getJButtonNext() {
+ if (jButtonNext == null) {
+ jButtonNext = new JButton();
+ jButtonNext.setText("Next");
+ jButtonNext.setBounds(new java.awt.Rectangle(292, 315, 90, 20));
+ jButtonNext.setEnabled(false);
+ jButtonNext.setMnemonic('N');
+ jButtonNext.addActionListener(this);
+ }
+ return jButtonNext;
+ }
+
+ /**
+ This method initializes jButtonCancel
+
+ @return javax.swing.JButton jButtonCancel
+
+ **/
+ private JButton getJButtonCancel() {
+ if (jButtonCancel == null) {
+ jButtonCancel = new JButton();
+ jButtonCancel.setText("Cancel");
+ jButtonCancel.setBounds(new java.awt.Rectangle(390, 315, 90, 20));
+ jButtonCancel.setMnemonic('C');
+ jButtonCancel.addActionListener(this);
+ }
+ return jButtonCancel;
+ }
+
+ /**
+ This method initializes jRadioButtonAgree
+
+ @return javax.swing.JRadioButton jRadioButtonAgree
+
+ **/
+ private JRadioButton getJRadioButtonAgree() {
+ if (jRadioButtonAgree == null) {
+ jRadioButtonAgree = new JRadioButton();
+ jRadioButtonAgree.setText("I accept the agreement");
+ jRadioButtonAgree.setLocation(new java.awt.Point(30, 200));
+ jRadioButtonAgree.setSize(new java.awt.Dimension(156, 19));
+ jRadioButtonAgree.addActionListener(this);
+ }
+ return jRadioButtonAgree;
+ }
+
+ /**
+ This method initializes jRadioButtonDisagree
+
+ @return javax.swing.JRadioButton jRadioButtonDisagree
+
+ **/
+ private JRadioButton getJRadioButtonDisagree() {
+ if (jRadioButtonDisagree == null) {
+ jRadioButtonDisagree = new JRadioButton();
+ jRadioButtonDisagree.setText("I do not accept the agreement");
+ jRadioButtonDisagree.setLocation(new java.awt.Point(30, 220));
+ jRadioButtonDisagree.setSize(new java.awt.Dimension(248, 19));
+ jRadioButtonDisagree.addActionListener(this);
+ }
+ return jRadioButtonDisagree;
+ }
+
+ /**
+ This method initializes jScrollPane
+
+ @return javax.swing.JScrollPane jScrollPane
+
+ **/
+ private JScrollPane getJScrollPane() {
+ if (jScrollPane == null) {
+ jScrollPane = new JScrollPane();
+ jScrollPane.setSize(new java.awt.Dimension(435, 140));
+ jScrollPane.setVerticalScrollBarPolicy(javax.swing.JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
+ jScrollPane.setHorizontalScrollBarPolicy(javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
+ jScrollPane.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));
+ jScrollPane.setViewportView(getJTextArea2());
+ jScrollPane.setLocation(new java.awt.Point(30, 55));
+ }
+ return jScrollPane;
+ }
+
+ /**
+ This method initializes jTextArea2
+
+ @return javax.swing.JTextArea jTextArea2
+
+ **/
+ private JTextArea getJTextArea2() {
+ if (jTextArea2 == null) {
+ jTextArea2 = new JTextArea();
+ jTextArea2.setEditable(false);
+ jTextArea2.setWrapStyleWord(false);
+ jTextArea2.setLineWrap(true);
+ jTextArea2.setText("Copyright (c) 2006, Intel Corp.\n"
+ + "All rights reserved. This program and the accompanying materials "
+ + "are licensed and made available under the terms and conditions of the BSD License "
+ + "which may be found at http://opensource.org/licenses/bsd-license.php\n\n\n"
+ + "THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN \"AS IS\" BASIS, "
+ + "WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.");
+ }
+ return jTextArea2;
+ }
+
+ /**
+ Main class, used for test
+
+ @param args
+
+ **/
+ public static void main(String[] args) {
+ LicenseAgreement la = new LicenseAgreement();
+ la.setVisible(true);
+ }
+
+ /**
+ This is the default constructor
+
+ **/
+ public LicenseAgreement() {
+ super();
+ init();
+ }
+
+ /**
+ This is the override constructor
+
+ @param welcome The input data of Welcome
+
+ **/
+ public LicenseAgreement(Welcome welcome) {
+ super();
+ init();
+ w = welcome;
+ }
+
+ /**
+ This method initializes this
+
+ **/
+ private void init() {
+ this.setSize(500, 390);
+ this.setContentPane(getJContentPane());
+ this.setTitle("Setup - License Agreement");
+ this.centerWindow();
+ this.getRootPane().setDefaultButton(jButtonNext);
+ }
+
+ /**
+ This method initializes jContentPane
+
+ @return javax.swing.JPanel jContentPane
+
+ **/
+ private JPanel getJContentPane() {
+ if (jContentPane == null) {
+ jContentPane = new JPanel();
+ jContentPane.setLayout(null);
+ jContentPane.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
+ jContentPane.add(getJTextArea(), null);
+ jContentPane.add(getJTextArea1(), null);
+ jContentPane.add(getJPanel(), null);
+ jContentPane.add(getJButtonBack(), null);
+ jContentPane.add(getJButtonNext(), null);
+ jContentPane.add(getJButtonCancel(), null);
+ }
+ return jContentPane;
+ }
+
+ /* (non-Javadoc)
+ * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
+ *
+ * Override actionPerformed to listen all actions
+ *
+ */
+ public void actionPerformed(ActionEvent arg0) {
+ Object obj = arg0.getSource();
+ //
+ // Disable button next when select jRadioButtonDisagree
+ //
+ if (obj == jRadioButtonDisagree) {
+ if (jRadioButtonDisagree.isSelected()) {
+ jRadioButtonAgree.setSelected(false);
+ jButtonNext.setEnabled(false);
+ jButtonNext.setFocusable(false);
+ }
+ if (!jRadioButtonAgree.isSelected() && !jRadioButtonDisagree.isSelected()) {
+ jRadioButtonDisagree.setSelected(true);
+ }
+ }
+
+ //
+ // Enable button next when select jRadioButtonAgree
+ //
+ if (obj == jRadioButtonAgree) {
+ if (jRadioButtonAgree.isSelected()) {
+ jRadioButtonDisagree.setSelected(false);
+ jButtonNext.setEnabled(true);
+ jButtonNext.setFocusable(true);
+ }
+ if (!jRadioButtonAgree.isSelected() && !jRadioButtonDisagree.isSelected()) {
+ jRadioButtonAgree.setSelected(true);
+ }
+ }
+
+ if (obj == jButtonBack) {
+ this.setVisible(false);
+ w.setVisible(true);
+ }
+
+ //
+ // Show next page when click button Next
+ //
+ if (obj == jButtonNext) {
+ if (sdd == null) {
+ sdd = new SelectDestinationDirectory(this);
+ }
+ this.setVisible(false);
+ sdd.setVisible(true);
+ }
+
+ if (obj == jButtonCancel) {
+ this.onExit();
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see java.awt.event.WindowListener#windowClosing(java.awt.event.WindowEvent)
+ *
+ * Override windowClosing to show confirm quit dialog
+ *
+ */
+ public void windowClosing(WindowEvent arg0) {
+ this.onExit();
+ }
+}
diff --git a/Tools/Source/CreateMdkPkg/src/org/tianocore/packaging/workspace/ui/SelectDestinationDirectory.java b/Tools/Source/CreateMdkPkg/src/org/tianocore/packaging/workspace/ui/SelectDestinationDirectory.java
new file mode 100644
index 0000000000..4f167dcfec
--- /dev/null
+++ b/Tools/Source/CreateMdkPkg/src/org/tianocore/packaging/workspace/ui/SelectDestinationDirectory.java
@@ -0,0 +1,469 @@
+/** @file
+
+ The file is used to show a Select Destination Directory page in
+ the process of setup
+
+ Copyright (c) 2006, Intel Corporation
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+ **/
+
+package org.tianocore.packaging.workspace.ui;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.WindowEvent;
+
+import javax.swing.JButton;
+import javax.swing.JFileChooser;
+import javax.swing.JLabel;
+import javax.swing.JOptionPane;
+import javax.swing.JPanel;
+import javax.swing.JTextArea;
+import javax.swing.JTextField;
+
+import org.tianocore.common.Log;
+import org.tianocore.packaging.common.ui.IFrame;
+import org.tianocore.packaging.workspace.command.InstallWorkspace;
+
+/**
+ The class is used to show a Select Destination Directory page in
+ the process of setup
+
+ @since CreateMdkPkg 1.0
+
+ **/
+public class SelectDestinationDirectory extends IFrame implements ActionListener {
+
+ ///
+ /// Define class Serial Version UID
+ ///
+ private static final long serialVersionUID = -2924500118774744205L;
+
+ //
+ // Define class members
+ //
+ private JPanel jContentPane = null;
+
+ private JTextArea jTextArea = null;
+
+ private JTextArea jTextArea1 = null;
+
+ private JPanel jPanel = null;
+
+ private JButton jButtonBack = null;
+
+ private JButton jButtonNext = null;
+
+ private JButton jButtonCancel = null;
+
+ private JLabel jLabel = null;
+
+ private JLabel jLabel1 = null;
+
+ private JTextField jTextFieldInstallDir = null;
+
+ private JButton jButtonBrowse = null;
+
+ private JLabel jLabel2 = null;
+
+ private LicenseAgreement la = null;
+
+ /**
+ This method initializes jTextArea
+
+ @return javax.swing.JTextArea jTextArea
+
+ **/
+ private JTextArea getJTextArea() {
+ if (jTextArea == null) {
+ jTextArea = new JTextArea();
+ jTextArea.setLocation(new java.awt.Point(0, 0));
+ jTextArea.setText(" Select Destination Directory");
+ jTextArea.setFont(new java.awt.Font("Dialog", java.awt.Font.BOLD, 14));
+ jTextArea.setEditable(false);
+ jTextArea.setSize(new java.awt.Dimension(495, 20));
+ }
+ return jTextArea;
+ }
+
+ /**
+ This method initializes jTextArea1
+
+ @return javax.swing.JTextArea jTextArea1
+
+ **/
+ private JTextArea getJTextArea1() {
+ if (jTextArea1 == null) {
+ jTextArea1 = new JTextArea();
+ jTextArea1.setLocation(new java.awt.Point(0, 20));
+ jTextArea1.setText(" Where should MDK package be installed?");
+ jTextArea1.setEditable(false);
+ jTextArea1.setSize(new java.awt.Dimension(495, 35));
+ }
+ return jTextArea1;
+ }
+
+ /**
+ This method initializes jPanel
+
+ @return javax.swing.JPanel jPanel
+
+ **/
+ private JPanel getJPanel() {
+ if (jPanel == null) {
+ jLabel2 = new JLabel();
+ jLabel2.setText("At least 10 MB of free disk space is required");
+ jLabel2.setLocation(new java.awt.Point(30, 225));
+ jLabel2.setSize(new java.awt.Dimension(290, 20));
+ jLabel1 = new JLabel();
+ jLabel1.setText("To continue, click Next. If you wuold like to select different folder, click Browse.");
+ jLabel1.setLocation(new java.awt.Point(30, 55));
+ jLabel1.setSize(new java.awt.Dimension(435, 20));
+ jLabel = new JLabel();
+ jLabel.setText("Setup will install MDK package into the following folders:");
+ jLabel.setLocation(new java.awt.Point(30, 15));
+ jLabel.setSize(new java.awt.Dimension(435, 20));
+ jPanel = new JPanel();
+ jPanel.setLayout(null);
+ jPanel.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));
+ jPanel.setSize(new java.awt.Dimension(494, 251));
+ jPanel.setLocation(new java.awt.Point(0, 55));
+ jPanel.add(jLabel, null);
+ jPanel.add(jLabel1, null);
+ jPanel.add(getJTextField(), null);
+ jPanel.add(getJButtonBrowse(), null);
+ jPanel.add(jLabel2, null);
+ }
+ return jPanel;
+ }
+
+ /**
+ This method initializes jButtonBack
+
+ @return javax.swing.JButton jButtonBack
+
+ **/
+ private JButton getJButtonBack() {
+ if (jButtonBack == null) {
+ jButtonBack = new JButton();
+ jButtonBack.setText("Back");
+ jButtonBack.setSize(new java.awt.Dimension(90, 20));
+ jButtonBack.setLocation(new java.awt.Point(200, 315));
+ jButtonBack.setMnemonic('B');
+ jButtonBack.addActionListener(this);
+ }
+ return jButtonBack;
+ }
+
+ /**
+ This method initializes jButtonNext
+
+ @return javax.swing.JButton jButtonNext
+
+ **/
+ private JButton getJButtonNext() {
+ if (jButtonNext == null) {
+ jButtonNext = new JButton();
+ jButtonNext.setText("Next");
+ jButtonNext.setBounds(new java.awt.Rectangle(292, 315, 90, 20));
+ jButtonNext.setEnabled(true);
+ jButtonNext.setMnemonic('N');
+ jButtonNext.addActionListener(this);
+ }
+ return jButtonNext;
+ }
+
+ /**
+ This method initializes jButtonCancel
+
+ @return javax.swing.JButton jButtonCancel
+
+ **/
+ private JButton getJButtonCancel() {
+ if (jButtonCancel == null) {
+ jButtonCancel = new JButton();
+ jButtonCancel.setText("Cancel");
+ jButtonCancel.setBounds(new java.awt.Rectangle(390, 315, 90, 20));
+ jButtonCancel.setMnemonic('C');
+ jButtonCancel.addActionListener(this);
+ }
+ return jButtonCancel;
+ }
+
+ /**
+ This method initializes jTextFieldInstallDir
+
+ @return javax.swing.JTextField jTextFieldInstallDir
+
+ **/
+ private JTextField getJTextField() {
+ if (jTextFieldInstallDir == null) {
+ jTextFieldInstallDir = new JTextField();
+ jTextFieldInstallDir.setLocation(new java.awt.Point(30, 90));
+ jTextFieldInstallDir.setSize(new java.awt.Dimension(320, 20));
+ jTextFieldInstallDir.setText("C:\\MyWorkspace");
+ }
+ return jTextFieldInstallDir;
+ }
+
+ /**
+ This method initializes jButtonBrowse
+
+ @return javax.swing.JButton jButtonBrowse
+
+ **/
+ private JButton getJButtonBrowse() {
+ if (jButtonBrowse == null) {
+ jButtonBrowse = new JButton();
+ jButtonBrowse.setText("Browse");
+ jButtonBrowse.setSize(new java.awt.Dimension(90, 20));
+ jButtonBrowse.setLocation(new java.awt.Point(370, 90));
+ jButtonBrowse.addActionListener(this);
+ }
+ return jButtonBrowse;
+ }
+
+ /**
+ Main class, used for test
+
+ @param args
+
+ **/
+ public static void main(String[] args) {
+ SelectDestinationDirectory sdd = new SelectDestinationDirectory();
+ sdd.setVisible(true);
+ }
+
+ /**
+ This is the default constructor
+
+ **/
+ public SelectDestinationDirectory() {
+ super();
+ init();
+ }
+
+ /**
+ This is the override constructor
+
+ @param licenseagreement The input data of licenseagreement
+
+ **/
+ public SelectDestinationDirectory(LicenseAgreement licenseagreement) {
+ super();
+ init();
+ la = licenseagreement;
+ }
+
+ /**
+ This method initializes this
+
+ **/
+ private void init() {
+ this.setSize(500, 390);
+ this.setTitle("Setup - Select Destination Directory");
+ this.setContentPane(getJContentPane());
+ this.centerWindow();
+ this.getRootPane().setDefaultButton(jButtonNext);
+ }
+
+ /**
+ This method initializes jContentPane
+
+ @return javax.swing.JPanel jContentPane
+
+ **/
+ private JPanel getJContentPane() {
+ if (jContentPane == null) {
+ jContentPane = new JPanel();
+ jContentPane.setLayout(null);
+ jContentPane.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
+ jContentPane.add(getJTextArea(), null);
+ jContentPane.add(getJTextArea1(), null);
+ jContentPane.add(getJPanel(), null);
+ jContentPane.add(getJButtonBack(), null);
+ jContentPane.add(getJButtonNext(), null);
+ jContentPane.add(getJButtonCancel(), null);
+ }
+ return jContentPane;
+ }
+
+ /* (non-Javadoc)
+ * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
+ *
+ * Override actionPerformed to listen all actions
+ *
+ */
+ public void actionPerformed(ActionEvent arg0) {
+ Object obj = arg0.getSource();
+
+ if (obj == jButtonBack) {
+ this.setVisible(false);
+ la.setVisible(true);
+ }
+
+ //
+ // Show next page if click button Next
+ //
+ if (obj == jButtonNext) {
+ if (createWorkspace(jTextFieldInstallDir.getText())) {
+ if (initWorkspace(jTextFieldInstallDir.getText())) {
+ this.setVisible(false);
+ Finish f = new Finish(jTextFieldInstallDir.getText());
+ f.setVisible(true);
+ }
+ }
+ }
+
+ if (obj == jButtonCancel) {
+ this.onExit();
+ }
+
+ if (obj == jButtonBrowse) {
+ JFileChooser fc = new JFileChooser();
+ fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
+ int result = fc.showOpenDialog(new JPanel());
+ if (result == JFileChooser.APPROVE_OPTION) {
+ jTextFieldInstallDir.setText(fc.getCurrentDirectory().toString() + System.getProperty("file.separator")
+ + fc.getSelectedFile().getName());
+ }
+ }
+ }
+
+ /**
+ Create workspace to target dir
+
+ @param strInstallDir The install target dir
+ @retval true - Create success
+ @retval false - Create fail
+
+ **/
+ private boolean createWorkspace(String strInstallDir) {
+ boolean bolCreateDirectory = true;
+ int intResult;
+
+ //
+ //Check if the Install Dir exists
+ //
+ Log.log("is Exist Install Dir");
+ if (InstallWorkspace.isExistInstallDir(strInstallDir)) {
+ intResult = JOptionPane.showConfirmDialog(null, strInstallDir + " already exists, continue anyway?",
+ "Override", JOptionPane.YES_NO_OPTION);
+ if (intResult != JOptionPane.YES_OPTION) {
+ return false;
+ } else {
+ bolCreateDirectory = false;
+ }
+ }
+
+ //
+ //Create the directory
+ //
+ Log.log("Create Directory");
+ if (bolCreateDirectory) {
+ if (!InstallWorkspace.createInstallDir(strInstallDir)) {
+ intResult = JOptionPane.showConfirmDialog(null, "Cannot create direcotry " + strInstallDir
+ + " in system. Click OK to exist.", "Error",
+ JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE);
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ Init created workspace
+
+ @param strInstallDir The dir of workspace
+ @retval true - Init Success
+ @retval false - Init fail
+
+ **/
+ private boolean initWorkspace(String strInstallDir) {
+ String strJarFile = System.getProperty("user.dir") + System.getProperty("file.separator") + "CreateMdkPkg.jar";
+
+ //
+ //Install package
+ //
+ Log.log("Install Package");
+ try {
+ if (!InstallWorkspace.installPackage(strInstallDir, strJarFile)) {
+ JOptionPane.showConfirmDialog(null, "Cannot intall package in system. Click OK to exist.", "Error",
+ JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE);
+ return false;
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ //
+ //Update framework database
+ //
+ Log.log("Set Framework Database");
+ if (!InstallWorkspace.setFrameworkDatabase()) {
+ JOptionPane.showConfirmDialog(null, "Cannot create workspace database in system. Click OK to exist.",
+ "Error", JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE);
+ return false;
+ }
+
+ //
+ //Set System Environment
+ //
+ Log.log("Set System Environment");
+ if (!InstallWorkspace.setSystemEnvironment()) {
+ JOptionPane.showConfirmDialog(null, "Cannot set WORKSPACE variable in system. Click OK to exist.", "Error",
+ JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE);
+ return false;
+ }
+
+ //
+ //Set Tool Chain Path
+ //
+ Log.log("Set Tool Chain Path");
+ if (!InstallWorkspace.setToolChainPath()) {
+ JOptionPane.showConfirmDialog(null, "Cannot set Tool Chain path variable in system. Click OK to exist.",
+ "Error", JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE);
+ return false;
+ }
+
+ //
+ //Install tool chain
+ //
+ Log.log("Set Tool Chain");
+ if (!InstallWorkspace.setToolChain()) {
+ JOptionPane.showConfirmDialog(null, "Cannot set Tool Chain in system. Click OK to exist.", "Error",
+ JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE);
+ return false;
+ }
+
+ //
+ //Delete setup files
+ //
+ Log.log("Delete Setup Files");
+ try {
+ InstallWorkspace.delSetupPackage(strInstallDir + System.getProperty("file.separator") + "org");
+ } catch (Exception e) {
+ e.printStackTrace();
+ Log.log(e.getMessage());
+ }
+
+ return true;
+ }
+
+ /* (non-Javadoc)
+ * @see java.awt.event.WindowListener#windowClosing(java.awt.event.WindowEvent)
+ *
+ * Override windowClosing to show confirm quit dialog
+ *
+ */
+ public void windowClosing(WindowEvent arg0) {
+ this.onExit();
+ }
+}
diff --git a/Tools/Source/CreateMdkPkg/src/org/tianocore/packaging/workspace/ui/Welcome.java b/Tools/Source/CreateMdkPkg/src/org/tianocore/packaging/workspace/ui/Welcome.java
new file mode 100644
index 0000000000..aa2e5861be
--- /dev/null
+++ b/Tools/Source/CreateMdkPkg/src/org/tianocore/packaging/workspace/ui/Welcome.java
@@ -0,0 +1,272 @@
+/** @file
+
+ The file is used to show a welcome page in the process of setup
+
+ Copyright (c) 2006, Intel Corporation
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+ **/
+
+package org.tianocore.packaging.workspace.ui;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.WindowEvent;
+
+import javax.swing.JButton;
+import javax.swing.JPanel;
+import javax.swing.JTextArea;
+
+import org.tianocore.packaging.common.ui.IFrame;
+
+/**
+ The class is used to show a welcome page in the process of setup
+
+ @since CreateMdkPkg 1.0
+
+ **/
+public class Welcome extends IFrame implements ActionListener {
+
+ ///
+ /// Define class Serial Version UID
+ ///
+ private static final long serialVersionUID = 8160041311175680637L;
+
+ //
+ // Define class members
+ //
+ private JPanel jContentPane = null;
+
+ private JPanel jPanel = null;
+
+ private JTextArea jTextArea = null;
+
+ private JTextArea jTextArea1 = null;
+
+ private JTextArea jTextArea2 = null;
+
+ private JTextArea jTextArea3 = null;
+
+ private JButton jButtonNext = null;
+
+ private JButton jButtonCancel = null;
+
+ private LicenseAgreement la = null;
+
+ /**
+ This method initializes jPanel
+
+ @return javax.swing.JPanel jPanel
+
+ **/
+ private JPanel getJPanel() {
+ if (jPanel == null) {
+ jPanel = new JPanel();
+ jPanel.setLayout(null);
+ jPanel.setSize(new java.awt.Dimension(495, 355));
+ jPanel.setLocation(new java.awt.Point(0, 0));
+ jPanel.add(getJTextArea(), null);
+ jPanel.add(getJTextArea1(), null);
+ jPanel.add(getJTextArea2(), null);
+ jPanel.add(getJTextArea3(), null);
+ jPanel.add(getJButtonNext(), null);
+ jPanel.add(getJButtonCancel(), null);
+ }
+ return jPanel;
+ }
+
+ /**
+ This method initializes jTextArea
+
+ @return javax.swing.JTextArea jTextArea
+
+ **/
+ private JTextArea getJTextArea() {
+ if (jTextArea == null) {
+ jTextArea = new JTextArea();
+ jTextArea.setFont(new java.awt.Font("Times New Roman", java.awt.Font.BOLD, 24));
+ jTextArea.setSize(new java.awt.Dimension(495, 70));
+ jTextArea.setLocation(new java.awt.Point(0, 0));
+ jTextArea.setEnabled(true);
+ jTextArea.setEditable(false);
+ jTextArea.setText("Welcome to the MDK Package Setup Wizard");
+ }
+ return jTextArea;
+ }
+
+ /**
+ This method initializes jTextArea1
+
+ @return javax.swing.JTextArea jTextArea1
+
+ **/
+ private JTextArea getJTextArea1() {
+ if (jTextArea1 == null) {
+ jTextArea1 = new JTextArea();
+ jTextArea1.setText("This will install MDK Package on your computer. ");
+ jTextArea1.setSize(new java.awt.Dimension(495, 40));
+ jTextArea1.setEnabled(true);
+ jTextArea1.setEditable(false);
+ jTextArea1.setLocation(new java.awt.Point(0, 70));
+ }
+ return jTextArea1;
+ }
+
+ /**
+ This method initializes jTextArea2
+
+ @return javax.swing.JTextArea jTextArea2
+
+ **/
+ private JTextArea getJTextArea2() {
+ if (jTextArea2 == null) {
+ jTextArea2 = new JTextArea();
+ jTextArea2.setSize(new java.awt.Dimension(495, 50));
+ jTextArea2
+ .setText("It is strongly recommended that you exit all other programs before running this installation program.");
+ jTextArea2.setLineWrap(true);
+ jTextArea2.setEnabled(true);
+ jTextArea2.setEditable(false);
+ jTextArea2.setLocation(new java.awt.Point(0, 110));
+ }
+ return jTextArea2;
+ }
+
+ /**
+ This method initializes jTextArea3
+
+ @return javax.swing.JTextArea jTextArea3
+
+ **/
+ private JTextArea getJTextArea3() {
+ if (jTextArea3 == null) {
+ jTextArea3 = new JTextArea();
+ jTextArea3.setBounds(new java.awt.Rectangle(0, 160, 495, 150));
+ jTextArea3.setEnabled(true);
+ jTextArea3.setEditable(false);
+ jTextArea3.setText("Click Nex to continue. Or click Cancel to exit Setup");
+ }
+ return jTextArea3;
+ }
+
+ /**
+ This method initializes jButtonNext
+
+ @return javax.swing.JButton jButtonNext
+
+ **/
+ private JButton getJButtonNext() {
+ if (jButtonNext == null) {
+ jButtonNext = new JButton();
+ jButtonNext.setText("Next");
+ jButtonNext.setSize(new java.awt.Dimension(90, 20));
+ jButtonNext.setLocation(new java.awt.Point(290, 320));
+ jButtonNext.setMnemonic('N');
+ jButtonNext.addActionListener(this);
+ }
+ return jButtonNext;
+ }
+
+ /**
+ This method initializes jButtonCancel
+
+ @return javax.swing.JButton jButtonCancel
+
+ **/
+ private JButton getJButtonCancel() {
+ if (jButtonCancel == null) {
+ jButtonCancel = new JButton();
+ jButtonCancel.setText("Cancel");
+ jButtonCancel.setSize(new java.awt.Dimension(90, 20));
+ jButtonCancel.setLocation(new java.awt.Point(390, 320));
+ jButtonCancel.setMnemonic('C');
+ jButtonCancel.addActionListener(this);
+ }
+ return jButtonCancel;
+ }
+
+ /**
+ Main class, used for test
+
+ @param args
+ **/
+ public static void main(String[] args) {
+ Welcome w = new Welcome();
+ w.setVisible(true);
+ }
+
+ /**
+ This is the default constructor
+
+ **/
+ public Welcome() {
+ super();
+ init();
+ }
+
+ /**
+ This method initializes this
+
+ **/
+ private void init() {
+ this.setSize(500, 390);
+ this.setContentPane(getJContentPane());
+ this.setTitle("Welcome");
+ this.centerWindow();
+ this.getRootPane().setDefaultButton(jButtonNext);
+ }
+
+ /**
+ This method initializes jContentPane
+
+ @return javax.swing.JPanel jContentPane
+
+ **/
+ private JPanel getJContentPane() {
+ if (jContentPane == null) {
+ jContentPane = new JPanel();
+ jContentPane.setLayout(null);
+ jContentPane.add(getJPanel(), null);
+ }
+ return jContentPane;
+ }
+
+ /* (non-Javadoc)
+ * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
+ *
+ * Override actionPerformed to listen all actions
+ *
+ */
+ public void actionPerformed(ActionEvent arg0) {
+ Object obj = arg0.getSource();
+ //
+ // Show next page if click button Next
+ //
+ if (obj == jButtonNext) {
+ if (la == null) {
+ la = new LicenseAgreement(this);
+ }
+ this.setVisible(false);
+ la.setVisible(true);
+ }
+ if (obj == jButtonCancel) {
+ this.onExit();
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see java.awt.event.WindowListener#windowClosing(java.awt.event.WindowEvent)
+ *
+ * Override windowClosing to show confirm quit dialog
+ *
+ */
+ public void windowClosing(WindowEvent arg0) {
+ this.onExit();
+ }
+}
diff --git a/Tools/Source/FrameworkTasks/build.xml b/Tools/Source/FrameworkTasks/build.xml
new file mode 100644
index 0000000000..0a99a44b48
--- /dev/null
+++ b/Tools/Source/FrameworkTasks/build.xml
@@ -0,0 +1,50 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Tools/Source/FrameworkTasks/frameworktasks.tasks b/Tools/Source/FrameworkTasks/frameworktasks.tasks
new file mode 100644
index 0000000000..f8bafabb0b
--- /dev/null
+++ b/Tools/Source/FrameworkTasks/frameworktasks.tasks
@@ -0,0 +1,11 @@
+fwimage=org.tianocore.framework.tasks.FwImageTask
+setstamp=org.tianocore.framework.tasks.SetStampTask
+gendepex=org.tianocore.framework.tasks.GenDepexTask
+gensection=org.tianocore.framework.tasks.GenSectionTask
+genffsfile=org.tianocore.framework.tasks.GenFfsFileTask
+vfrcompile=org.tianocore.framework.tasks.VfrCompilerTask
+strgather=org.tianocore.framework.tasks.StrGatherTask
+genfvimage=org.tianocore.framework.tasks.GenFvImageTask
+guidchk= org.tianocore.framework.tasks.GuidChkTask
+gencrc32section=org.tianocore.framework.tasks.GenCRC32SectionTask
+makedeps=org.tianocore.framework.tasks.MakeDeps
diff --git a/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/Compress.java b/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/Compress.java
new file mode 100644
index 0000000000..4410ecdda1
--- /dev/null
+++ b/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/Compress.java
@@ -0,0 +1,78 @@
+/** @file
+ Compress class.
+
+ This class is to call CompressDll.dll to compress section.
+
+ Copyright (c) 2006, Intel Corporation
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+ **/
+
+package org.tianocore.framework.tasks;
+
+import java.io.File;
+
+/**
+
+ This class is to call CompressDll.dll to compress section.
+
+**/
+public class Compress {
+ byte[] inputBuffer;
+ byte[] outputBuffer;
+ int size;
+
+ static {
+ String dllPath;
+
+ dllPath = GenFfsFileTask.path;
+ dllPath = dllPath +
+ File.separator +
+ "CompressDll.dll";
+
+ System.load(dllPath);
+ }
+
+ /**
+ CallCompress
+
+ This function is to call the compressDll.dll to compress the contents in
+ buffer.
+
+ @param inputBuffer The input buffer.
+ @param size The size of buffer in byte.
+ @param dllPath The compressDll.dll path.
+ @return The buffer contained the comrpessed input.
+ **/
+ public native byte[] CallCompress (byte[] inputBuffer, int size, String dllPath);
+
+ /**
+ Construct function
+
+ This function is to initialize the class member and call the compress
+ function.
+
+ @param inBuffer The input buffer.
+ @param size The size of buffer in byte.
+ **/
+ public Compress (byte[] inBuffer, int size){
+ this.inputBuffer = inBuffer;
+ this.size = size;
+ String path = GenFfsFileTask.path;
+
+ //
+ // Call Compress function.
+ //
+ this.outputBuffer = CallCompress (
+ this.inputBuffer,
+ this.size,
+ path
+ );
+ }
+}
\ No newline at end of file
diff --git a/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/CompressHeader.java b/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/CompressHeader.java
new file mode 100644
index 0000000000..5992b1d708
--- /dev/null
+++ b/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/CompressHeader.java
@@ -0,0 +1,78 @@
+/** @file
+ CompressHeader class.
+
+ This class is to generate the compressed section header.
+
+ Copyright (c) 2006, Intel Corporation
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+ **/
+
+package org.tianocore.framework.tasks;
+
+import org.apache.tools.ant.BuildException;
+
+/**
+
+ Internal class: This class is to generate the compressed section header.
+
+**/
+public class CompressHeader {
+
+ /**
+ CommonSectionHeader
+
+ This class define the compressed header structor.
+
+ **/
+ public class CommonSectionHeader {
+ byte[] Size = new byte[3];
+ byte type;
+ }
+
+ ///
+ /// Section header.
+ ///
+ public CommonSectionHeader SectionHeader = new CommonSectionHeader();
+
+ ///
+ /// Length of uncompress section in byte.
+ ///
+ public int UncompressLen;
+ ///
+ /// Compress type.
+ ///
+ public byte CompressType;
+
+ ///
+ /// The size of compress header in byte.
+ ///
+ public int GetSize (){
+ return 9;
+ }
+
+ ///
+ /// Write class member to buffer.
+ ///
+ public void StructToBuffer (byte[] Buffer){
+ if (Buffer.length != GetSize()) {
+ throw new BuildException ("CompressHeader Buffer size is not correct!");
+ }
+ for (int i = 0; i < 3; i++){
+ Buffer[i] = SectionHeader.Size[i];
+ }
+ Buffer[3] = SectionHeader.type;
+ Buffer[4] = (byte)(UncompressLen & 0xff);
+ Buffer[5] = (byte)((UncompressLen & 0xff00)>>8);
+ Buffer[6] = (byte)((UncompressLen & 0xff0000)>>16);
+ Buffer[7] = (byte)((UncompressLen & 0xff000000)>>24);
+ Buffer[8] = CompressType;
+ }
+
+}
\ No newline at end of file
diff --git a/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/CompressSection.java b/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/CompressSection.java
new file mode 100644
index 0000000000..8def4ebc95
--- /dev/null
+++ b/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/CompressSection.java
@@ -0,0 +1,209 @@
+/** @file
+ CompressSection class.
+
+ CompressSection indicate that all section which in it should be compressed.
+
+ Copyright (c) 2006, Intel Corporation
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+ **/
+
+
+package org.tianocore.framework.tasks;
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.tools.ant.BuildException;
+
+
+/**
+ CompressSection
+
+ CompressSection indicate that all section which in it should be compressed.
+
+**/
+public class CompressSection implements Section, FfsTypes{
+ //
+ // The attribute of compressName.
+ //
+ String compressName = "";
+ //
+ // The list contained the SectFile element.
+ //
+ List
+
+ @param add the add flags set
+ @param sub the sub flags set
+ @return flags with original format
+ **/
+ private String getRawFlags(Set add, Set sub) {
+ String result = "";
+ add.removeAll(sub);
+ Iterator iter = add.iterator();
+ while (iter.hasNext()) {
+ String str = getProject().replaceProperties((String) iter.next());
+ result += "\"" + str.substring(1, str.length() - 1) + "\", ";
+ }
+ return result;
+ }
+
+ /**
+ Set base name. For ANT use.
+
+ @param baseName Base name
+ **/
+ public void setBaseName(String baseName) {
+ this.baseName = baseName;
+ }
+
+}
diff --git a/Tools/Source/GenBuild/org/tianocore/build/OutputDirSetupTask.java b/Tools/Source/GenBuild/org/tianocore/build/OutputDirSetupTask.java
new file mode 100644
index 0000000000..c2b7cc997b
--- /dev/null
+++ b/Tools/Source/GenBuild/org/tianocore/build/OutputDirSetupTask.java
@@ -0,0 +1,190 @@
+/** @file
+
+ This file is an ANT task OutputDirSetupTask.
+
+ This task main purpose is to setup some necessary properties for Package,
+ Platform or Module clean.
+
+Copyright (c) 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+**/
+package org.tianocore.build;
+
+import java.io.File;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Task;
+import org.apache.xmlbeans.XmlObject;
+
+import org.tianocore.build.global.GlobalData;
+import org.tianocore.build.global.OutputManager;
+import org.tianocore.build.global.SurfaceAreaQuery;
+import org.tianocore.build.toolchain.ToolChainFactory;
+
+/**
+ OutputDirSetupTask is an ANT task that can be used in ANT build
+ system. The main function of this task is to initialize some basic information
+ for Package|Platform|Module clean or cleanall usage.
+
+
Note that all this task doing is part of GenBuildTask.
+
+ @since GenBuild 1.0
+ @see org.tianocore.build.GenBuildTask
+**/
+public class OutputDirSetupTask extends Task {
+
+ ///
+ /// Module surface area file.
+ ///
+ File msaFilename;
+
+ ///
+ /// Module build description file.
+ ///
+ File mbdFilename;
+
+ ///
+ /// Module surface area information after overrided.
+ ///
+ public Map map = new HashMap();
+
+ ///
+ /// Module's base name.
+ ///
+ private String baseName;
+
+ /**
+ Public construct method. It is necessary for ANT task.
+ **/
+ public OutputDirSetupTask () {
+ }
+
+ /**
+ ANT task's entry point, will be called after init(). The main steps is described
+ as following:
+
+
Judge current build mode (MODULE | PACKAGE | PLATFORM). This step will execute
+ only once in whole build process;
+
Initialize global information (Framework DB, SPD files and all MSA files
+ listed in SPD). This step will execute only once in whole build process;
+
Restore some important ANT property. If current build is single module
+ build, here will set many default values;
+
Get the current module's overridded surface area information from
+ global data;
+
Set up the output directories, including BIN_DIR, DEST_DIR_OUTPUT and
+ DEST_DIR_DEBUG;
+
+
+ @throws BuildException
+ From module build, exception from module surface area invalid.
+ **/
+ public void execute() throws BuildException {
+ System.out.println("Deleting module [" + baseName + "] start.");
+ OutputManager.update(getProject());
+ GlobalData.initInfo("Tools" + File.separatorChar + "Conf" + File.separatorChar + "FrameworkDatabase.db", getProject()
+ .getProperty("WORKSPACE_DIR"));
+ recallFixedProperties();
+ map = GlobalData.getDoc(baseName);
+ //
+ // Initialize SurfaceAreaQuery
+ //
+ SurfaceAreaQuery.setDoc(map);
+ //
+ // Setup Output Management
+ //
+ String[] outdir = SurfaceAreaQuery.getOutputDirectory();
+ OutputManager.update(getProject(), outdir[1], outdir[0]);
+ }
+
+ /**
+ Get current module's base name.
+
+ @return base name
+ **/
+ public String getBaseName() {
+ return baseName;
+ }
+
+ /**
+ Set base name. For ANT use.
+
+ @param baseName Base name
+ **/
+ public void setBaseName(String baseName) {
+ this.baseName = baseName;
+ }
+
+ /**
+ Set MBD surface area file. For ANT use.
+
+ @param mbdFilename Surface Area file
+ **/
+ public void setMbdFilename(File mbdFilename) {
+ this.mbdFilename = mbdFilename;
+ }
+
+ /**
+ Set MSA surface area file. For ANT use.
+
+ @param msaFilename Surface Area file
+ **/
+ public void setMsaFilename(File msaFilename) {
+ this.msaFilename = msaFilename;
+ }
+
+ /**
+ Restore some important ANT property. If current build is single module
+ build, here will set many default values.
+
+
If current build is single module build, then the default ARCH
+ is IA32. Also set up the properties PACKAGE,
+ PACKAGE_DIR, TARGET and MODULE_DIR
+
+
Note that for package build, package name is stored in PLATFORM
+ and package directory is stored in PLATFORM_DIR.
+
+ @see org.tianocore.build.global.OutputManager
+ **/
+ private void recallFixedProperties(){
+ //
+ // If build is for module build
+ //
+ if (getProject().getProperty("PACKAGE_DIR") == null) {
+ ToolChainFactory toolChainFactory = new ToolChainFactory(getProject());
+ toolChainFactory.setupToolChain();
+ //
+ // PACKAGE PACKAGE_DIR ARCH (Default) COMMON_FILE BUILD_MACRO
+ //
+ if (getProject().getProperty("ARCH") == null){
+ getProject().setProperty("ARCH", "IA32");
+ }
+ String packageName = GlobalData.getPackageNameForModule(baseName);
+ getProject().setProperty("PACKAGE", packageName);
+ String packageDir = GlobalData.getPackagePath(packageName);
+ getProject().setProperty("PACKAGE_DIR", getProject().getProperty("WORKSPACE_DIR") + File.separatorChar + packageDir);
+ getProject().setProperty("TARGET", toolChainFactory.getCurrentTarget());
+ getProject().setProperty("MODULE_DIR", getProject().replaceProperties(getProject().getProperty("MODULE_DIR")));
+ }
+ if (OutputManager.PLATFORM != null) {
+ getProject().setProperty("PLATFORM", OutputManager.PLATFORM);
+ }
+ if (OutputManager.PLATFORM_DIR != null) {
+ getProject().setProperty("PLATFORM_DIR", OutputManager.PLATFORM_DIR);
+ }
+ }
+}
diff --git a/Tools/Source/GenBuild/org/tianocore/build/autogen/AutoGen.java b/Tools/Source/GenBuild/org/tianocore/build/autogen/AutoGen.java
new file mode 100644
index 0000000000..f1e9c5b4ec
--- /dev/null
+++ b/Tools/Source/GenBuild/org/tianocore/build/autogen/AutoGen.java
@@ -0,0 +1,2006 @@
+/** @file
+ AutoGen class.
+
+ This class is to generate Autogen.h and Autogen.c according to module surface area
+ or library surface area.
+
+ Copyright (c) 2006, Intel Corporation
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+ **/
+
+package org.tianocore.build.autogen;
+
+import org.tianocore.build.global.GlobalData;
+import org.tianocore.build.global.Spd;
+import org.tianocore.build.global.SurfaceAreaQuery;
+import org.tianocore.GuidsDocument;
+import org.tianocore.LibraryClassDocument.LibraryClass;
+import org.tianocore.PPIsDocument;
+import org.tianocore.ProtocolsDocument;
+import org.tianocore.build.pcd.action.PCDAutoGenAction;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.xmlbeans.XmlObject;
+
+import java.io.File;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+/**
+ This class is to generate Autogen.h and Autogen.c according to module surface
+ area or library surface area.
+**/
+public class AutoGen {
+ ///
+ /// The output path of Autogen.h and Autogen.c
+ ///
+ private String outputPath;
+
+ ///
+ /// The base name of module or library.
+ ///
+ private String baseName;
+
+ ///
+ /// The build architecture
+ ///
+ private String arch;
+
+ ///
+ /// PcdAutogen instance which is used to manage how to generate the PCD
+ /// information.
+ ///
+ private PCDAutoGenAction myPcdAutogen;
+
+ ///
+ /// The protocl list which records in module or library surface area and
+ /// it's dependence on library instance surface area.
+ ///
+ private List mProtocolList = new ArrayList();
+
+ ///
+ /// The Ppi list which recorded in module or library surface area and its
+ /// dependency on library instance surface area.
+ ///
+ private List mPpiList = new ArrayList();
+
+ ///
+ /// The Guid list which recoreded in module or library surface are and it's
+ /// dependence on library instance surface area.
+ ///
+ private List mGuidList = new ArrayList();
+
+ /**
+ Construct function
+
+ This function mainly initialize some member variable.
+
+ @param outputPath Output path of AutoGen file.
+ @param baseName Module base name.
+ @param arch Target architecture.
+ **/
+ public AutoGen(String outputPath, String baseName, String arch) {
+ this.outputPath = outputPath;
+ this.baseName = baseName;
+ this.arch = arch;
+
+ }
+
+ /**
+ saveFile function
+
+ This function save the content in stringBuffer to file.
+
+ @param fileName The name of file.
+ @param fileBuffer The content of AutoGen file in buffer.
+ @return "true" successful, "false" failed.
+ **/
+ private boolean saveFile(String fileName, StringBuffer fileBuffer) {
+ try {
+ File autoGenH = new File(fileName);
+
+ //
+ // if the file exists, compare their content
+ //
+ if (autoGenH.exists()) {
+ FileReader fIn = new FileReader(autoGenH);
+ char[] oldFileBuffer = new char[(int) autoGenH.length()];
+ fIn.read(oldFileBuffer, 0, (int) autoGenH.length());
+ fIn.close();
+
+ //
+ // if we got the same file, don't re-generate it to prevent
+ // sources depending on it from re-building
+ //
+ if (fileBuffer.toString().compareTo(new String(oldFileBuffer)) == 0) {
+ return true;
+ }
+ }
+ FileWriter fOut = new FileWriter(autoGenH);
+ fOut.write(fileBuffer.toString());
+ fOut.close();
+ } catch (Exception e) {
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ genAutogen function
+
+ This function call libGenAutoGen or moduleGenAutogen function, which
+ dependence on generate library autogen or module autogen.
+
+ @throws BuildException Failed to creat AutoGen.c & AutoGen.h.
+ **/
+ public void genAutogen() throws BuildException {
+ try {
+ //
+ // If outputPath do not exist, create it.
+ //
+ File path = new File(outputPath);
+ path.mkdirs();
+
+ //
+ // Check current is library or not, then call the corresponding
+ // function.
+ //
+ if (SurfaceAreaQuery.getComponentType().equalsIgnoreCase(
+ CommonDefinition.LibraryStr)) {
+ libGenAutogen();
+ } else {
+ moduleGenAutogen();
+ }
+
+ } catch (Exception e) {
+ throw new BuildException(
+ "Failed to create AutoGen.c & AutoGen.h!\n"
+ + e.getMessage());
+ }
+ }
+
+ /**
+ moduleGenAutogen function
+
+ This function generates AutoGen.c & AutoGen.h for module.
+
+ @throws BuildException Faile to create module AutoGen.c & AutoGen.h.
+ **/
+ void moduleGenAutogen() throws BuildException {
+
+ try {
+ moduleGenAutogenC();
+ moduleGenAutogenH();
+ } catch (Exception e) {
+ throw new BuildException(
+ "Faile to create module AutoGen.c & AutoGen.h!\n"
+ + e.getMessage());
+ }
+ }
+
+ /**
+ libGenAutogen function
+
+ This function generates AutoGen.c & AutoGen.h for library.
+
+ @throws BuildException
+ Faile to create library AutoGen.c & AutoGen.h
+ **/
+ void libGenAutogen() throws BuildException {
+ try {
+ libGenAutogenC();
+ libGenAutogenH();
+ } catch (Exception e) {
+ throw new BuildException(
+ "Faile to create library AutoGen.c & AutoGen.h!\n"
+ + e.getMessage());
+ }
+ }
+
+ /**
+ moduleGenAutogenH
+
+ This function generates AutoGen.h for module.
+
+ @throws BuildException
+ Failed to generate AutoGen.h.
+ **/
+ void moduleGenAutogenH() throws BuildException {
+
+ List libClassIncludeH;
+ String moduleType;
+ List headerFileList;
+
+ StringBuffer fileBuffer = new StringBuffer(8192);
+
+ //
+ // Write Autogen.h header notation
+ //
+ fileBuffer.append(CommonDefinition.autogenHNotation);
+
+ //
+ // Add #ifndef ${BaseName}_AUTOGENH
+ // #def ${BseeName}_AUTOGENH
+ //
+ fileBuffer.append("#ifndef " + this.baseName.toUpperCase() + "_AUTOGENH\r\n");
+ fileBuffer.append("#define " + this.baseName.toUpperCase() + "_AUTOGENH\r\n\r\n");
+
+ //
+ // Write the specification version and release version at the begine
+ // of autogen.h file.
+ // Note: the specification version and release version should
+ // be got from module surface area instead of hard code by it's moduleType.
+ //
+ moduleType = SurfaceAreaQuery.getModuleType();
+ switch (CommonDefinition.getModuleType(moduleType)) {
+ case CommonDefinition.ModuleTypeDxeCore:
+ case CommonDefinition.ModuleTypeDxeDriver:
+ case CommonDefinition.ModuleTypeDxeRuntimeDriver:
+ case CommonDefinition.ModuleTypeDxeSmmDriver:
+ case CommonDefinition.ModuleTypeDxeSalDriver:
+ case CommonDefinition.ModuleTypeUefiDriver:
+ case CommonDefinition.ModuleTypeUefiApplication:
+ fileBuffer.append(CommonDefinition.autoGenHLine1);
+ break;
+ default:
+ fileBuffer.append(CommonDefinition.autoGenHVersionDefault);
+ break;
+ }
+ switch (CommonDefinition.getModuleType(moduleType)) {
+ case CommonDefinition.ModuleTypeUefiDriver:
+ case CommonDefinition.ModuleTypeUefiApplication:
+ fileBuffer.append(CommonDefinition.autoGenHReleaseDefault);
+ break;
+ default:
+ fileBuffer.append(CommonDefinition.autoGenHLine2);
+ break;
+ }
+
+ //
+ // Add "extern int __make_me_compile_correctly;" at begin of
+ // AutoGen.h.
+ //
+ fileBuffer.append(CommonDefinition.autoGenHbegin);
+
+ //
+ // Write consumed package's mdouleInfo related .h file to autogen.h
+ //
+ List consumedPkgList = SurfaceAreaQuery
+ .getIncludePackageName(this.arch);
+ if (consumedPkgList != null) {
+ headerFileList = IncludesToAutogenH(consumedPkgList, moduleType);
+ for (int i = 0; i < headerFileList.size(); i++) {
+ fileBuffer.append(headerFileList.get(i));
+ }
+ }
+
+ //
+ // Write library class's related *.h file to autogen.h.
+ //
+ LibraryClass[] libClassList = SurfaceAreaQuery
+ .getLibraryClassArray(CommonDefinition.AlwaysConsumed);
+ if (libClassList != null) {
+ libClassIncludeH = LibraryClassToAutogenH(libClassList);
+ for (int i = 0; i < libClassIncludeH.size(); i++) {
+ fileBuffer.append(libClassIncludeH.get(i));
+ }
+ }
+
+ libClassList = SurfaceAreaQuery
+ .getLibraryClassArray(CommonDefinition.AlwaysProduced);
+ if (libClassList != null) {
+ libClassIncludeH = LibraryClassToAutogenH(libClassList);
+ for (int i = 0; i < libClassIncludeH.size(); i++) {
+ fileBuffer.append(libClassIncludeH.get(i));
+ }
+ }
+ fileBuffer.append("\r\n");
+
+ //
+ // Write PCD autogen information to AutoGen.h.
+ //
+ if (this.myPcdAutogen != null) {
+ fileBuffer.append(this.myPcdAutogen.OutputH());
+ }
+
+ //
+ // Append the #endif at AutoGen.h
+ //
+ fileBuffer.append("#endif\r\n");
+
+ //
+ // Save string buffer content in AutoGen.h.
+ //
+ if (!saveFile(outputPath + File.separatorChar + "AutoGen.h", fileBuffer)) {
+ throw new BuildException("Failed to generate AutoGen.h !!!");
+ }
+ }
+
+ /**
+ moduleGenAutogenC
+
+ This function generates AutoGen.c for module.
+
+ @throws BuildException
+ Failed to generate AutoGen.c.
+ **/
+ void moduleGenAutogenC() throws BuildException {
+
+ StringBuffer fileBuffer = new StringBuffer(8192);
+ //
+ // Write Autogen.c header notation
+ //
+ fileBuffer.append(CommonDefinition.autogenCNotation);
+
+ //
+ // Write #include at beginning of AutoGen.c
+ //
+ fileBuffer.append(CommonDefinition.includeAutogenH);
+
+ //
+ // Write DriverBinding/ComponentName/DriverConfiguration/DriverDialog
+ // to AutoGen.c
+ //
+ ExternsDriverBindingToAutoGenC(fileBuffer);
+
+ //
+ // Write DriverExitBootServicesEvent/DriverSetVirtualAddressMapEvent
+ // to Autogen.c
+ //
+ ExternCallBackToAutoGenC(fileBuffer);
+
+ //
+ // Write EntryPoint to autgoGen.c
+ //
+ String[] entryPointList = SurfaceAreaQuery.getModuleEntryPointArray();
+ if (entryPointList != null) {
+ EntryPointToAutoGen(entryPointList, fileBuffer);
+ }
+
+ //
+ // Write Guid to autogen.c
+ //
+ String guid = SurfaceAreaQuery.getModuleGuid();
+ fileBuffer
+ .append("GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiCallerIdGuid = {");
+ if (guid == null) {
+ throw new BuildException("Guid value must set!\n");
+ }
+
+ //
+ // Formate Guid as ANSI c form.Example:
+ // {0xd2b2b828, 0x826, 0x48a7,{0xb3, 0xdf, 0x98, 0x3c, 0x0, 0x60, 0x24, 0xf0}}
+ //
+ fileBuffer.append(Spd.formatGuidName(guid));
+ fileBuffer.append("};\r\n");
+
+ //
+ // Generate library instance consumed protocol, guid, ppi, pcd list.
+ // Save those to this.protocolList, this.ppiList, this.pcdList,
+ // this.guidList. Write Consumed library constructor and desconstuct to
+ // autogen.c
+ //
+ LibInstanceToAutogenC(fileBuffer);
+
+ //
+ // Write consumed ppi, guid, protocol to autogen.c
+ //
+ ProtocolGuidToAutogenC(fileBuffer);
+ PpiGuidToAutogenC(fileBuffer);
+ GuidGuidToAutogenC(fileBuffer);
+
+ //
+ // Call pcd autogen. PCDAutoGenAction tool only need module name and
+ // isPcdEmulatedDriver as parameter. Library inherits PCD and module's
+ // PCD information has been collected in FPDParser task by
+ // CollectPCDAction.
+ // Note : when PCD image tool ready,
+ // isPCDEmulatedDriver parameter will be removed.
+ //
+ try {
+ this.myPcdAutogen = new PCDAutoGenAction(baseName,
+ baseName.equalsIgnoreCase("PcdEmulatorPeim"));
+ this.myPcdAutogen.execute();
+ } catch (Exception e) {
+ throw new BuildException("PCD Autogen failed:" + e.getMessage());
+ }
+
+ if (this.myPcdAutogen != null) {
+ fileBuffer.append(this.myPcdAutogen.OutputC());
+ }
+
+ if (!saveFile(outputPath + File.separatorChar + "AutoGen.c", fileBuffer)) {
+ throw new BuildException("Failed to generate AutoGen.c !!!");
+ }
+
+ }
+
+ /**
+ libGenAutogenH
+
+ This function generates AutoGen.h for library.
+
+ @throws BuildException
+ Failed to generate AutoGen.c.
+ **/
+ void libGenAutogenH() throws BuildException {
+
+ List libClassIncludeH;
+ String moduleType;
+ List headerFileList;
+ StringBuffer fileBuffer = new StringBuffer(10240);
+
+ //
+ // Write Autogen.h header notation
+ //
+ fileBuffer.append(CommonDefinition.autogenHNotation);
+
+ //
+ // Add #ifndef ${BaseName}_AUTOGENH
+ // #def ${BseeName}_AUTOGENH
+ //
+ fileBuffer.append("#ifndef " + this.baseName.toUpperCase() + "_AUTOGENH\r\n");
+ fileBuffer.append("#define " + this.baseName.toUpperCase() + "_AUTOGENH\r\n\r\n");
+
+ //
+ // Write EFI_SPECIFICATION_VERSION and EDK_RELEASE_VERSION
+ // to autogen.h file.
+ // Note: the specification version and release version should
+ // be get from module surface area instead of hard code.
+ //
+ fileBuffer.append(CommonDefinition.autoGenHbegin);
+ fileBuffer.append(CommonDefinition.autoGenHLine1);
+ fileBuffer.append(CommonDefinition.autoGenHLine2);
+
+ //
+ // Write consumed package's mdouleInfo related *.h file to autogen.h.
+ //
+ moduleType = SurfaceAreaQuery.getModuleType();
+ List cosumedPkglist = SurfaceAreaQuery
+ .getIncludePackageName(this.arch);
+ headerFileList = IncludesToAutogenH(cosumedPkglist, moduleType);
+ for (int i = 0; i < headerFileList.size(); i++) {
+ fileBuffer.append(headerFileList.get(i));
+ }
+
+ //
+ // Write library class's related *.h file to autogen.h
+ //
+ LibraryClass[] libClassList = SurfaceAreaQuery
+ .getLibraryClassArray(CommonDefinition.AlwaysConsumed);
+ if (libClassList != null) {
+ libClassIncludeH = LibraryClassToAutogenH(libClassList);
+ for (int i = 0; i < libClassIncludeH.size(); i++) {
+ fileBuffer.append(libClassIncludeH.get(i));
+ }
+ }
+
+ libClassList = SurfaceAreaQuery
+ .getLibraryClassArray(CommonDefinition.AlwaysProduced);
+ if (libClassList != null) {
+ libClassIncludeH = LibraryClassToAutogenH(libClassList);
+ for (int i = 0; i < libClassIncludeH.size(); i++) {
+ fileBuffer.append(libClassIncludeH.get(i));
+ }
+ }
+ fileBuffer.append("\r\n");
+
+ //
+ // Write PCD information to library AutoGen.h.
+ //
+ if (this.myPcdAutogen != null) {
+ fileBuffer.append(this.myPcdAutogen.OutputH());
+ }
+
+ //
+ // Append the #endif at AutoGen.h
+ //
+ fileBuffer.append("#endif\r\n");
+
+ //
+ // Save content of string buffer to AutoGen.h file.
+ //
+ if (!saveFile(outputPath + File.separatorChar + "AutoGen.h", fileBuffer)) {
+ throw new BuildException("Failed to generate AutoGen.h !!!");
+ }
+ }
+
+ /**
+ libGenAutogenC
+
+ This function generates AutoGen.h for library.
+
+ @throws BuildException
+ Failed to generate AutoGen.c.
+ **/
+ void libGenAutogenC() throws BuildException {
+ StringBuffer fileBuffer = new StringBuffer(10240);
+
+ //
+ // Write Autogen.c header notation
+ //
+ fileBuffer.append(CommonDefinition.autogenCNotation);
+
+ fileBuffer.append(CommonDefinition.autoGenCLine1);
+ fileBuffer.append("\r\n");
+
+ //
+ // Call pcd autogen. PCDAutoGenAction tool only need module name and
+ // isPcdEmulatedDriver as parameter. Library inherit PCD and module's
+ // PCD information has been collected in FPDParser task by
+ // CollectPCDAction.
+ // Note : when PCD image tool ready,
+ // isPCDEmulatedDriver parameter will be removed.
+ //
+ try {
+ this.myPcdAutogen = new PCDAutoGenAction(baseName, baseName
+ .equalsIgnoreCase("PcdEmulatorPeim"));
+ this.myPcdAutogen.execute();
+ } catch (Exception e) {
+ throw new BuildException(e.getMessage());
+ }
+
+ if (this.myPcdAutogen != null) {
+ fileBuffer.append(this.myPcdAutogen.OutputC());
+ }
+
+ if (!saveFile(outputPath + File.separatorChar + "AutoGen.c", fileBuffer)) {
+ throw new BuildException("Failed to generate AutoGen.c !!!");
+ }
+ }
+
+ /**
+ LibraryClassToAutogenH
+
+ This function returns *.h files declared by library classes which are
+ consumed or produced by current build module or library.
+
+ @param libClassList List of library class which consumed or produce
+ by current build module or library.
+ @return includeStrList List of *.h file.
+ **/
+ List LibraryClassToAutogenH(LibraryClass[] libClassList) {
+ List includStrList = new ArrayList();
+ String includerName;
+ String str = "";
+
+ //
+ // Get include file from GlobalData's SPDTable according to
+ // library class name.
+ //
+ for (int i = 0; i < libClassList.length; i++) {
+ includerName = GlobalData.getLibClassIncluder(libClassList[i]
+ .getStringValue());
+ if (includerName != null) {
+ str = CommonDefinition.include + " " + "<";
+ str = str + includerName + ">\r\n";
+ includStrList.add(str);
+ includerName = null;
+ }
+ }
+ return includStrList;
+ }
+
+ /**
+ IncludesToAutogenH
+
+ This function add include file in AutoGen.h file.
+ @param packageNameList List of module depended package.
+ @param moduleType Module type.
+ @return
+ **/
+ List IncludesToAutogenH(List packageNameList,
+ String moduleType) {
+
+ List includeStrList = new ArrayList();
+ String packageName = "";
+ String includeStr = "";
+
+ //
+ // Get include file from moduleInfo file
+ //
+ for (int i = 0; i < packageNameList.size(); i++) {
+ packageName = packageNameList.get(i);
+ includeStr = GlobalData.getModuleInfoByPackageName(packageName,
+ moduleType);
+ includeStrList.add(includeStr);
+ }
+ return includeStrList;
+ }
+
+ /**
+ EntryPointToAutoGen
+
+ This function convert & information
+ in mas to AutoGen.c
+
+ @param entryPointList List of entry point.
+ @param fileBuffer String buffer fo AutoGen.c.
+ @throws Exception
+ **/
+ void EntryPointToAutoGen(String[] entryPointList, StringBuffer fileBuffer)
+ throws BuildException {
+
+ String typeStr = SurfaceAreaQuery.getModuleType();
+
+ //
+ // The parameters and return value of entryPoint is difference
+ // for difference module type.
+ //
+ switch (CommonDefinition.getModuleType(typeStr)) {
+
+ case CommonDefinition.ModuleTypePeiCore:
+ if (entryPointList.length != 1 || entryPointList[0].equals("")) {
+ throw new BuildException(
+ "Module type = 'PEI_CORE', only have one module entry point!");
+ } else {
+ fileBuffer.append("EFI_STATUS\r\n");
+ fileBuffer.append("EFIAPI\r\n");
+ fileBuffer.append(entryPointList[0]);
+ fileBuffer.append(" (\r\n");
+ fileBuffer
+ .append(" IN EFI_PEI_STARTUP_DESCRIPTOR *PeiStartupDescriptor,\r\n");
+ fileBuffer
+ .append(" IN VOID *OldCoreData\r\n");
+ fileBuffer.append(" );\r\n\r\n");
+
+ fileBuffer.append("EFI_STATUS\r\n");
+ fileBuffer.append("EFIAPI\r\n");
+ fileBuffer.append("ProcessModuleEntryPointList (\r\n");
+ fileBuffer
+ .append(" IN EFI_PEI_STARTUP_DESCRIPTOR *PeiStartupDescriptor,\r\n");
+ fileBuffer
+ .append(" IN VOID *OldCoreData\r\n");
+ fileBuffer.append(" )\r\n\r\n");
+ fileBuffer.append("{\r\n");
+ fileBuffer.append(" return ");
+ fileBuffer.append(entryPointList[0]);
+ fileBuffer.append(" (PeiStartupDescriptor, OldCoreData);\r\n");
+ fileBuffer.append("}\r\n\r\n");
+ }
+ break;
+
+ case CommonDefinition.ModuleTypeDxeCore:
+ fileBuffer.append("const UINT32 _gUefiDriverRevision = 0;\r\n");
+ if (entryPointList.length != 1 || entryPointList[0].equals("")) {
+ throw new BuildException(
+ "Module type = 'DXE_CORE', only have one module entry point!");
+ } else {
+
+ fileBuffer.append("VOID\r\n");
+ fileBuffer.append("EFIAPI\r\n");
+ fileBuffer.append(entryPointList[0]);
+ fileBuffer.append(" (\n");
+ fileBuffer.append(" IN VOID *HobStart\r\n");
+ fileBuffer.append(" );\r\n\r\n");
+
+ fileBuffer.append("VOID\r\n");
+ fileBuffer.append("EFIAPI\r\n");
+ fileBuffer.append("ProcessModuleEntryPointList (\r\n");
+ fileBuffer.append(" IN VOID *HobStart\r\n");
+ fileBuffer.append(" )\r\n\r\n");
+ fileBuffer.append("{\r\n");
+ fileBuffer.append(" ");
+ fileBuffer.append(entryPointList[0]);
+ fileBuffer.append(" (HobStart);\r\n");
+ fileBuffer.append("}\r\n\r\n");
+ }
+ break;
+
+ case CommonDefinition.ModuleTypePeim:
+ int entryPointCount = 0;
+ fileBuffer
+ .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT32 _gPeimRevision = 0;\r\n");
+ for (int i = 0; i < entryPointList.length; i++) {
+ if (!entryPointList[i].equals("")) {
+ fileBuffer.append("EFI_STATUS\r\n");
+ fileBuffer.append("EFIAPI\r\n");
+ fileBuffer.append(entryPointList[i]);
+ fileBuffer.append(" (\r\n");
+ fileBuffer
+ .append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\r\n");
+ fileBuffer
+ .append(" IN EFI_PEI_SERVICES **PeiServices\r\n");
+ fileBuffer.append(" );\r\n");
+ entryPointCount++;
+ } else {
+ break;
+ }
+ }
+
+ fileBuffer.append("EFI_STATUS\r\n");
+ fileBuffer.append("EFIAPI\r\n");
+ fileBuffer.append("ProcessModuleEntryPointList (\r\n");
+ fileBuffer.append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\r\n");
+ fileBuffer.append(" IN EFI_PEI_SERVICES **PeiServices\r\n");
+ fileBuffer.append(" )\r\n\r\n");
+ fileBuffer.append("{\r\n");
+
+ if (entryPointCount == 0) {
+ fileBuffer.append(" return EFI_SUCCESS;\r\n");
+ } else if (entryPointCount == 1) {
+ fileBuffer.append(" return ");
+ fileBuffer.append(entryPointList[0]);
+ fileBuffer.append(" (FfsHeader, PeiServices);\r\n");
+ } else {
+ fileBuffer.append(" EFI_STATUS Status;\r\n");
+ fileBuffer.append(" EFI_STATUS CombinedStatus;\r\n\r\n");
+ fileBuffer.append(" CombinedStatus = EFI_LOAD_ERROR;\r\n\r\n");
+ for (int i = 0; i < entryPointList.length; i++) {
+ if (!entryPointList[i].equals("")) {
+ fileBuffer.append(" Status = ");
+ fileBuffer.append(entryPointList[i]);
+ fileBuffer.append(" (FfsHeader, PeiServices)\r\n");
+ fileBuffer
+ .append(" if (!EFI_ERROR (Status) || EFI_ERROR (CombinedStatus)) {\r\n");
+ fileBuffer.append(" CombinedStatus = Status;\r\n");
+ fileBuffer.append(" }\r\n\r\n");
+ } else {
+ break;
+ }
+ }
+ fileBuffer.append(" return CombinedStatus;\r\n");
+ }
+ fileBuffer.append("}\r\n\r\n");
+ break;
+
+ case CommonDefinition.ModuleTypeDxeSmmDriver:
+ entryPointCount = 0;
+ for (int i = 0; i < entryPointList.length; i++) {
+ if (!entryPointList[i].equals("")) {
+ fileBuffer.append("EFI_STATUS\r\n");
+ fileBuffer.append("EFIAPI\r\n");
+ fileBuffer.append(entryPointList[i]);
+ fileBuffer.append(" (\r\n");
+ fileBuffer.append(" EFI_HANDLE ImageHandle,\r\n");
+ fileBuffer.append(" EFI_SYSTEM_TABLE *SystemTable\r\n");
+ fileBuffer.append(" );\r\n");
+ entryPointCount++;
+ } else {
+ break;
+ }
+ }
+ fileBuffer
+ .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverEntryPointCount = ");
+ fileBuffer.append(Integer.toString(entryPointCount));
+ fileBuffer.append(";\r\n");
+ fileBuffer
+ .append("static BASE_LIBRARY_JUMP_BUFFER mJumpContext;\r\n");
+ fileBuffer
+ .append("static EFI_STATUS mDriverEntryPointStatus = EFI_LOAD_ERROR;\r\n\r\n");
+
+ fileBuffer.append("EFI_STATUS\r\n");
+ fileBuffer.append("EFIAPI\r\n");
+ fileBuffer.append("ProcessModuleEntryPointList (\r\n");
+ fileBuffer.append(" EFI_HANDLE ImageHandle,\r\n");
+ fileBuffer.append(" EFI_SYSTEM_TABLE *SystemTable\r\n");
+ fileBuffer.append(" )\r\n\r\n");
+ fileBuffer.append("{\r\n");
+
+ for (int i = 0; i < entryPointList.length; i++) {
+ if (!entryPointList[i].equals("")) {
+ fileBuffer
+ .append(" if (SetJump (&mJumpContext) == 0) {\r\n");
+ fileBuffer.append(" ExitDriver (");
+ fileBuffer.append(entryPointList[i]);
+ fileBuffer.append(" (ImageHandle, SystemTable));\r\n");
+ fileBuffer.append(" ASSERT (FALSE);\r\n");
+ fileBuffer.append(" }\r\n");
+ } else {
+ break;
+ }
+ }
+ fileBuffer.append(" return mDriverEntryPointStatus;\r\n");
+ fileBuffer.append("}\r\n\r\n");
+
+ fileBuffer.append("VOID\r\n");
+ fileBuffer.append("EFIAPI\r\n");
+ fileBuffer.append("ExitDriver (\r\n");
+ fileBuffer.append(" IN EFI_STATUS Status\n");
+ fileBuffer.append(" )\r\n\r\n");
+ fileBuffer.append("{\r\n");
+ fileBuffer
+ .append(" if (!EFI_ERROR (Status) || EFI_ERROR (mDriverEntryPointStatus)) {\r\n");
+ fileBuffer.append(" mDriverEntryPointStatus = Status;\r\n");
+ fileBuffer.append(" }\r\n");
+ fileBuffer.append(" LongJump (&mJumpContext, (UINTN)-1);\r\n");
+ fileBuffer.append(" ASSERT (FALSE);\r\n");
+ fileBuffer.append("}\r\n\r\n");
+
+ //
+ // Add "ModuleUnloadImage" for DxeSmmDriver module type;
+ //
+ entryPointList = SurfaceAreaQuery.getModuleUnloadImageArray();
+ entryPointCount = 0;
+ if (entryPointList != null) {
+ for (int i = 0; i < entryPointList.length; i++) {
+ if (!entryPointList[i].equals("")) {
+ fileBuffer.append("EFI_STATUS\r\n");
+ fileBuffer.append("EFIAPI\r\n");
+ fileBuffer.append(entryPointList[i]);
+ fileBuffer.append(" (\r\n");
+ fileBuffer
+ .append(" EFI_HANDLE ImageHandle\r\n");
+ fileBuffer.append(" );\r\n");
+ entryPointCount++;
+ } else {
+ break;
+ }
+ }
+ }
+
+ fileBuffer
+ .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverUnloadImageCount = ");
+ fileBuffer.append(Integer.toString(entryPointCount));
+ fileBuffer.append(";\r\n\r\n");
+
+ if (entryPointList != null) {
+ for (int i = 0; i < entryPointList.length; i++) {
+ if (!entryPointList[i].equals("")) {
+ fileBuffer.append("EFI_STATUS\r\n");
+ fileBuffer.append("EFIAPI\r\n");
+ fileBuffer.append(entryPointList[i]);
+ fileBuffer.append(" (\r\n");
+ fileBuffer
+ .append(" EFI_HANDLE ImageHandle\r\n");
+ fileBuffer.append(" );\r\n");
+ } else {
+ break;
+ }
+ }
+ }
+
+ fileBuffer.append("EFI_STATUS\r\n");
+ fileBuffer.append("EFIAPI\r\n");
+ fileBuffer.append("ProcessModuleUnloadList (\r\n");
+ fileBuffer.append(" EFI_HANDLE ImageHandle\r\n");
+ fileBuffer.append(" )\r\n");
+ fileBuffer.append("{\r\n");
+
+ if (entryPointCount == 0) {
+ fileBuffer.append(" return EFI_SUCCESS;\r\n");
+ } else if (entryPointCount == 1) {
+ fileBuffer.append(" return ");
+ fileBuffer.append(entryPointList[0]);
+ fileBuffer.append("(ImageHandle);\r\n");
+ } else {
+ fileBuffer.append(" EFI_STATUS Status;\r\n\r\n");
+ fileBuffer.append(" Status = EFI_SUCCESS;\r\n\r\n");
+ for (int i = 0; i < entryPointList.length; i++) {
+ if (!entryPointList[i].equals("")) {
+ fileBuffer.append(" if (EFI_ERROR (Status)) {\r\n");
+ fileBuffer.append(" ");
+ fileBuffer.append(entryPointList[i]);
+ fileBuffer.append("(ImageHandle);\r\n");
+ fileBuffer.append(" } else {\r\n");
+ fileBuffer.append(" Status = ");
+ fileBuffer.append(entryPointList[i]);
+ fileBuffer.append("(ImageHandle);\r\n");
+ fileBuffer.append(" }\r\n");
+ } else {
+ break;
+ }
+ }
+ fileBuffer.append(" return Status;\r\n");
+ }
+ fileBuffer.append("}\r\n\r\n");
+ break;
+
+ case CommonDefinition.ModuleTypeDxeRuntimeDriver:
+ case CommonDefinition.ModuleTypeDxeDriver:
+ case CommonDefinition.ModuleTypeDxeSalDriver:
+ case CommonDefinition.ModuleTypeUefiDriver:
+ case CommonDefinition.ModuleTypeUefiApplication:
+ entryPointCount = 0;
+ fileBuffer.append("const UINT32 _gUefiDriverRevision = 0;\r\n");
+ for (int i = 0; i < entryPointList.length; i++) {
+ if (!entryPointList[i].equals("")) {
+ fileBuffer.append("EFI_STATUS\r\n");
+ fileBuffer.append("EFIAPI\r\n");
+ fileBuffer.append(entryPointList[i]);
+ fileBuffer.append(" (\r\n");
+ fileBuffer.append(" EFI_HANDLE ImageHandle,\r\n");
+ fileBuffer.append(" EFI_SYSTEM_TABLE *SystemTable\r\n");
+ fileBuffer.append(" );\r\n");
+ entryPointCount++;
+ } else {
+ break;
+ }
+ }
+
+ fileBuffer
+ .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverEntryPointCount = ");
+ fileBuffer.append(Integer.toString(entryPointCount));
+ fileBuffer.append(";\r\n");
+ if (entryPointCount > 1) {
+ fileBuffer
+ .append("static BASE_LIBRARY_JUMP_BUFFER mJumpContext;\r\n");
+ fileBuffer
+ .append("static EFI_STATUS mDriverEntryPointStatus = EFI_LOAD_ERROR;\r\n");
+ }
+ fileBuffer.append("\n");
+
+ fileBuffer.append("EFI_STATUS\r\n");
+ fileBuffer.append("EFIAPI\r\n");
+ fileBuffer.append("ProcessModuleEntryPointList (\r\n");
+ fileBuffer.append(" EFI_HANDLE ImageHandle,\r\n");
+ fileBuffer.append(" EFI_SYSTEM_TABLE *SystemTable\r\n");
+ fileBuffer.append(" )\r\n\r\n");
+ fileBuffer.append("{\r\n");
+
+ if (entryPointCount == 0) {
+ fileBuffer.append(" return EFI_SUCCESS;\r\n");
+ } else if (entryPointCount == 1) {
+ fileBuffer.append(" return (");
+ fileBuffer.append(entryPointList[0]);
+ fileBuffer.append(" (ImageHandle, SystemTable));\r\n");
+ } else {
+ for (int i = 0; i < entryPointList.length; i++) {
+ if (!entryPointList[i].equals("")) {
+ fileBuffer
+ .append(" if (SetJump (&mJumpContext) == 0) {\r\n");
+ fileBuffer.append(" ExitDriver (");
+ fileBuffer.append(entryPointList[i]);
+ fileBuffer.append(" (ImageHandle, SystemTable));\r\n");
+ fileBuffer.append(" ASSERT (FALSE);\r\n");
+ fileBuffer.append(" }\r\n");
+ } else {
+ break;
+ }
+ }
+ fileBuffer.append(" return mDriverEntryPointStatus;\r\n");
+ }
+ fileBuffer.append("}\r\n\r\n");
+
+ fileBuffer.append("VOID\n");
+ fileBuffer.append("EFIAPI\n");
+ fileBuffer.append("ExitDriver (\r\n");
+ fileBuffer.append(" IN EFI_STATUS Status\n");
+ fileBuffer.append(" )\r\n\r\n");
+ fileBuffer.append("{\r\n");
+ if (entryPointCount <= 1) {
+ fileBuffer.append(" if (EFI_ERROR (Status)) {\r\n");
+ fileBuffer
+ .append(" ProcessLibraryDestructorList (gImageHandle, gST);\r\n");
+ fileBuffer.append(" }\r\n");
+ fileBuffer
+ .append(" gBS->Exit (gImageHandle, Status, 0, NULL);\r\n");
+ } else {
+ fileBuffer
+ .append(" if (!EFI_ERROR (Status) || EFI_ERROR (mDriverEntryPointStatus)) {\r\n");
+ fileBuffer.append(" mDriverEntryPointStatus = Status;\r\n");
+ fileBuffer.append(" }\r\n");
+ fileBuffer.append(" LongJump (&mJumpContext, (UINTN)-1);\r\n");
+ fileBuffer.append(" ASSERT (FALSE);\r\n");
+ }
+ fileBuffer.append("}\r\n\r\n");
+
+ //
+ // Add ModuleUnloadImage for DxeDriver and UefiDriver module type.
+ //
+ entryPointList = SurfaceAreaQuery.getModuleUnloadImageArray();
+ entryPointCount = 0;
+ if (entryPointList != null) {
+ for (int i = 0; i < entryPointList.length; i++) {
+ if (!entryPointList[i].equals("")) {
+ fileBuffer.append("EFI_STATUS\r\n");
+ fileBuffer.append("EFIAPI\r\n");
+ fileBuffer.append(entryPointList[i]);
+ fileBuffer.append(" (\r\n");
+ fileBuffer
+ .append(" EFI_HANDLE ImageHandle\r\n");
+ fileBuffer.append(" );\r\n");
+ entryPointCount++;
+ } else {
+ break;
+ }
+ }
+ }
+
+ fileBuffer
+ .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverUnloadImageCount = ");
+ fileBuffer.append(Integer.toString(entryPointCount));
+ fileBuffer.append(";\r\n\r\n");
+
+ if (entryPointList != null) {
+ for (int i = 0; i < entryPointList.length; i++) {
+ if (!entryPointList[i].equals("")) {
+ fileBuffer.append("EFI_STATUS\r\n");
+ fileBuffer.append("EFIAPI\r\n");
+ fileBuffer.append(entryPointList[i]);
+ fileBuffer.append(" (\r\n");
+ fileBuffer
+ .append(" EFI_HANDLE ImageHandle\r\n");
+ fileBuffer.append(" );\r\n");
+ } else {
+ break;
+ }
+ }
+ }
+
+ fileBuffer.append("EFI_STATUS\n");
+ fileBuffer.append("EFIAPI\n");
+ fileBuffer.append("ProcessModuleUnloadList (\r\n");
+ fileBuffer.append(" EFI_HANDLE ImageHandle\r\n");
+ fileBuffer.append(" )\r\n");
+ fileBuffer.append("{\r\n");
+
+ if (entryPointCount == 0) {
+ fileBuffer.append(" return EFI_SUCCESS;\r\n");
+ } else if (entryPointCount == 1) {
+ fileBuffer.append(" return ");
+ fileBuffer.append(entryPointList[0]);
+ fileBuffer.append("(ImageHandle);\r\n");
+ } else {
+ fileBuffer.append(" EFI_STATUS Status;\r\n\r\n");
+ fileBuffer.append(" Status = EFI_SUCCESS;\r\n\r\n");
+ for (int i = 0; i < entryPointList.length; i++) {
+ if (!entryPointList[i].equals("")) {
+ fileBuffer.append(" if (EFI_ERROR (Status)) {\r\n");
+ fileBuffer.append(" ");
+ fileBuffer.append(entryPointList[i]);
+ fileBuffer.append("(ImageHandle);\r\n");
+ fileBuffer.append(" } else {\r\n");
+ fileBuffer.append(" Status = ");
+ fileBuffer.append(entryPointList[i]);
+ fileBuffer.append("(ImageHandle);\r\n");
+ fileBuffer.append(" }\r\n");
+ } else {
+ break;
+ }
+ }
+ fileBuffer.append(" return Status;\r\n");
+ }
+ fileBuffer.append("}\r\n\r\n");
+ break;
+ }
+ }
+
+ /**
+ PpiGuidToAutogenc
+
+ This function gets GUIDs from SPD file accrodeing to information and
+ write those GUIDs to AutoGen.c.
+
+ @param fileBuffer String Buffer for Autogen.c file.
+ @throws BuildException Guid must set value!
+ **/
+ void PpiGuidToAutogenC(StringBuffer fileBuffer) throws BuildException {
+ String[] cNameGuid = null;
+ boolean isEqual = false;
+
+ PPIsDocument.PPIs.Ppi[] ppiList = SurfaceAreaQuery.getPpiArray(null);
+ if (ppiList != null) {
+ for (int i = 0; i < ppiList.length; i++) {
+ isEqual = false;
+ for (int j = 0; j < this.mPpiList.size(); j++) {
+ if (this.mPpiList.get(j).equalsIgnoreCase(
+ ppiList[i].getStringValue())) {
+ isEqual = true;
+ }
+ }
+ if (!isEqual) {
+ this.mPpiList.add(ppiList[i].getStringValue());
+ }
+ }
+ }
+
+ PPIsDocument.PPIs.PpiNotify[] ppiNotifyList = SurfaceAreaQuery
+ .getPpiNotifyArray(null);
+ if (ppiNotifyList != null) {
+ for (int i = 0; i < ppiNotifyList.length; i++) {
+ isEqual = false;
+ for (int j = 0; j < this.mPpiList.size(); j++) {
+ if (this.mPpiList.get(j).equalsIgnoreCase(
+ ppiNotifyList[i].getStringValue())) {
+ isEqual = true;
+ }
+ }
+ if (!isEqual) {
+ this.mPpiList.add(ppiNotifyList[i].getStringValue());
+ }
+ }
+ }
+
+ for (int i = 0; i < this.mPpiList.size(); i++) {
+ if (this.mPpiList.get(i) != null) {
+ cNameGuid = GlobalData.getPpiInfoGuid(this.mPpiList.get(i));
+ if (cNameGuid != null) {
+ fileBuffer
+ .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID ");
+ fileBuffer.append(cNameGuid[0]);
+ fileBuffer.append(" = { ");
+ fileBuffer.append(cNameGuid[1]);
+ fileBuffer.append(" } ;");
+ }
+ } else {
+ throw new BuildException("Guid must set value!");
+ }
+ }
+ }
+
+ /**
+ ProtocolGuidToAutogenc
+
+ This function gets GUIDs from SPD file accrodeing to
+ information and write those GUIDs to AutoGen.c.
+
+ @param fileBuffer String Buffer for Autogen.c file.
+ @throws BuildException Protocol name must set.
+ **/
+ void ProtocolGuidToAutogenC(StringBuffer fileBuffer) throws BuildException {
+ String[] cNameGuid = null;
+ boolean isEqual = false;
+
+ ProtocolsDocument.Protocols.Protocol[] protocolList = SurfaceAreaQuery
+ .getProtocolArray(null);
+ if (protocolList != null) {
+ for (int i = 0; i < protocolList.length; i++) {
+ isEqual = false;
+ for (int j = 0; j < this.mProtocolList.size(); j++) {
+ if (this.mProtocolList.get(j).equalsIgnoreCase(
+ protocolList[i].getStringValue())) {
+ isEqual = true;
+ }
+ }
+ if (!isEqual) {
+ this.mProtocolList.add(protocolList[i].getStringValue());
+
+ }
+ }
+ }
+
+ ProtocolsDocument.Protocols.ProtocolNotify[] protocolNotifyList = SurfaceAreaQuery
+ .getProtocolNotifyArray(null);
+ if (protocolNotifyList != null) {
+ for (int i = 0; i < protocolNotifyList.length; i++) {
+ isEqual = false;
+ for (int j = 0; j < this.mProtocolList.size(); j++) {
+ if (this.mProtocolList.get(j).equalsIgnoreCase(
+ protocolNotifyList[i].getStringValue())) {
+ isEqual = true;
+ }
+ }
+ if (!isEqual) {
+ this.mProtocolList.add(protocolNotifyList[i]
+ .getStringValue());
+
+ }
+ }
+ }
+ if (this.mProtocolList.size() > 0) {
+ for (int i = 0; i < this.mProtocolList.size(); i++) {
+ if (this.mProtocolList.get(i) != null) {
+ cNameGuid = GlobalData
+ .getProtocolInfoGuid(this.mProtocolList.get(i));
+ if (cNameGuid != null) {
+ fileBuffer
+ .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID ");
+ fileBuffer.append(cNameGuid[0]);
+ fileBuffer.append(" = { ");
+ fileBuffer.append(cNameGuid[1]);
+ fileBuffer.append(" } ;");
+ }
+ } else {
+ throw new BuildException("Protocol name must set!");
+ }
+ }
+ }
+ }
+
+ /**
+ GuidGuidToAutogenc
+
+ This function gets GUIDs from SPD file accrodeing to information
+ and write those GUIDs to AutoGen.c.
+
+ @param fileBuffer String Buffer for Autogen.c file.
+
+ **/
+ void GuidGuidToAutogenC(StringBuffer fileBuffer) {
+ String[] cNameGuid = null;
+ boolean isEqual = false;
+ GuidsDocument.Guids.GuidEntry[] guidList = SurfaceAreaQuery
+ .getGuidEntryArray(null);
+
+ if (guidList != null) {
+ for (int i = 0; i < guidList.length; i++) {
+ for (int j = 0; j < this.mGuidList.size(); j++) {
+ isEqual = false;
+ if (this.mGuidList.get(j).getCName().equalsIgnoreCase(
+ guidList[i].getCName().toString())) {
+ isEqual = true;
+ break;
+ }
+ }
+ if (!isEqual) {
+ this.mGuidList.add(guidList[i]);
+
+ }
+
+ }
+ }
+
+ for (int i = 0; i < this.mGuidList.size(); i++) {
+ if (this.mGuidList.get(i).getCName() != null) {
+ cNameGuid = GlobalData.getGuidInfoGuid(this.mGuidList.get(i)
+ .getCName());
+ if (cNameGuid != null) {
+ fileBuffer
+ .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID ");
+ fileBuffer.append(cNameGuid[0]);
+ fileBuffer.append(" = { ");
+ fileBuffer.append(cNameGuid[1]);
+ fileBuffer.append("} ;");
+ }
+ }
+ }
+ }
+
+ /**
+ LibInstanceToAutogenC
+
+ This function adds dependent library instance to autogen.c,which includeing
+ library's constructor, destructor, and library dependent ppi, protocol, guid,
+ pcd information.
+
+ @param fileBuffer String buffer for AutoGen.c
+ @throws BuildException
+ **/
+ void LibInstanceToAutogenC(StringBuffer fileBuffer) throws BuildException {
+ int index;
+ boolean isEqual = false;
+
+ String moduleType = SurfaceAreaQuery.getModuleType();
+ List libConstructList = new ArrayList();
+ List libDestructList = new ArrayList();
+
+ String libConstructName = null;
+ String libDestructName = null;
+ List libraryList = SurfaceAreaQuery.getLibraryInstance(
+ this.arch, CommonDefinition.AlwaysConsumed);
+
+ try {
+ if (libraryList != null) {
+ //
+ // Reorder library instance sequence.
+ //
+ AutogenLibOrder libOrder = new AutogenLibOrder(libraryList);
+ List orderList = libOrder.orderLibInstance();
+
+ if (orderList != null) {
+ //
+ // Process library instance one by one.
+ //
+ for (int i = 0; i < orderList.size(); i++) {
+
+ //
+ // Get library instance basename.
+ //
+ String libInstanceName = orderList.get(i).toString();
+
+ //
+ // Get override map
+ //
+ Map libDoc = GlobalData
+ .getDoc(libInstanceName);
+ SurfaceAreaQuery.push(libDoc);
+
+ //
+ // Get , , list of this library
+ // instance.
+ //
+ PPIsDocument.PPIs.Ppi[] ppiList = SurfaceAreaQuery
+ .getPpiArray(null);
+ PPIsDocument.PPIs.PpiNotify[] ppiNotifyList = SurfaceAreaQuery
+ .getPpiNotifyArray(null);
+ ProtocolsDocument.Protocols.Protocol[] protocolList = SurfaceAreaQuery
+ .getProtocolArray(null);
+ ProtocolsDocument.Protocols.ProtocolNotify[] protocolNotifyList = SurfaceAreaQuery
+ .getProtocolNotifyArray(null);
+ GuidsDocument.Guids.GuidEntry[] guidList = SurfaceAreaQuery
+ .getGuidEntryArray(null);
+
+ //
+ // Add those ppi, protocol, guid in global ppi, protocol, guid
+ // list.
+ //
+ if (ppiList != null) {
+ for (index = 0; index < ppiList.length; index++) {
+ isEqual = false;
+ for (int j = 0; j < this.mPpiList.size(); j++) {
+ if (this.mPpiList.get(j).equalsIgnoreCase(
+ ppiList[index].getStringValue())) {
+ isEqual = true;
+ }
+ }
+ if (!isEqual) {
+ this.mPpiList.add(ppiList[index]
+ .getStringValue());
+ }
+ }
+ }
+ if (ppiNotifyList != null) {
+ for (index = 0; index < ppiNotifyList.length; index++) {
+ isEqual = false;
+ for (int j = 0; j < this.mPpiList.size(); j++) {
+ if (this.mPpiList.get(j).equalsIgnoreCase(
+ ppiNotifyList[index]
+ .getStringValue())) {
+ isEqual = true;
+ }
+ }
+ if (!isEqual) {
+ this.mPpiList.add(ppiNotifyList[index]
+ .getStringValue());
+ }
+ }
+ }
+ if (protocolList != null) {
+ for (index = 0; index < protocolList.length; index++) {
+ isEqual = false;
+ for (int j = 0; j < this.mProtocolList.size(); j++) {
+ if (this.mProtocolList.get(j)
+ .equalsIgnoreCase(
+ protocolList[index]
+ .getStringValue())) {
+ isEqual = true;
+ }
+ }
+ if (!isEqual) {
+ this.mProtocolList.add(protocolList[index]
+ .getStringValue());
+ }
+ }
+ }
+ if (protocolNotifyList != null) {
+ for (index = 0; index < protocolNotifyList.length; index++) {
+ isEqual = false;
+ for (int j = 0; j < this.mProtocolList.size(); j++) {
+ if (this.mProtocolList.get(j)
+ .equalsIgnoreCase(
+ protocolNotifyList[index]
+ .getStringValue())) {
+ isEqual = true;
+ }
+ }
+ if (!isEqual) {
+ this.mProtocolList
+ .add(protocolNotifyList[index]
+ .getStringValue());
+ }
+ }
+ }
+ if (guidList != null) {
+ for (index = 0; index < guidList.length; index++) {
+ isEqual = false;
+ for (int j = 0; j < this.mGuidList.size(); j++) {
+ if (this.mGuidList.get(j).getCName()
+ .equalsIgnoreCase(
+ guidList[index].getCName())) {
+ isEqual = true;
+ }
+ }
+ if (!isEqual) {
+ this.mGuidList.add(guidList[index]);
+ }
+ }
+ }
+
+ //
+ // If not yet parse this library instance's constructor
+ // element,parse it.
+ //
+ if (!GlobalData.isHaveLibInstance(libInstanceName)) {
+ libConstructName = SurfaceAreaQuery
+ .getLibConstructorName();
+ libDestructName = SurfaceAreaQuery
+ .getLibDestructorName();
+
+ GlobalData.setLibInstanceInfo(libInstanceName,
+ libConstructName, libDestructName);
+ } else {
+ libConstructName = GlobalData
+ .getLibInstanceConstructor(libInstanceName);
+ libDestructName = GlobalData
+ .getLibInstanceDestructor(libInstanceName);
+ }
+ SurfaceAreaQuery.pop();
+ //
+ // Add dependent library instance constructor function.
+ //
+ if (libConstructName != null) {
+ libConstructList.add(libConstructName);
+ }
+ //
+ // Add dependent library instance destructor fuction.
+ //
+ if (libDestructName != null) {
+ libDestructList.add(libDestructName);
+ }
+ }
+
+ }
+
+ //
+ // Add library constructor to AutoGen.c
+ //
+ LibConstructorToAutogenC(libConstructList, moduleType,
+ fileBuffer/* autogenC */);
+ //
+ // Add library destructor to AutoGen.c
+ //
+ LibDestructorToAutogenC(libDestructList, moduleType,
+ fileBuffer/* autogenC */);
+ }
+
+ } catch (Exception e) {
+ throw new BuildException(e.getMessage());
+ }
+ }
+
+
+ /**
+ LibConstructorToAutogenc
+
+ This function writes library constructor list to AutoGen.c. The library
+ constructor's parameter and return value depend on module type.
+
+ @param libInstanceList List of library construct name.
+ @param moduleType Module type.
+ @param fileBuffer String buffer for AutoGen.c
+ @throws Exception
+ **/
+ void LibConstructorToAutogenC(List libInstanceList,
+ String moduleType, StringBuffer fileBuffer) throws Exception {
+ boolean isFirst = true;
+
+ //
+ // The library constructor's parameter and return value depend on
+ // module type.
+ //
+ for (int i = 0; i < libInstanceList.size(); i++) {
+ switch (CommonDefinition.getModuleType(moduleType)) {
+ case CommonDefinition.ModuleTypeBase:
+ fileBuffer.append("RETURN_STATUS\r\n");
+ fileBuffer.append(libInstanceList.get(i));
+ fileBuffer.append(" (\r\n");
+ fileBuffer.append(" VOID\r\n");
+ fileBuffer.append(" );\r\n");
+ break;
+
+ case CommonDefinition.ModuleTypePeiCore:
+ case CommonDefinition.ModuleTypePeim:
+ fileBuffer.append("EFI_STATUS\r\n");
+ fileBuffer.append(libInstanceList.get(i));
+ fileBuffer.append(" (\r\n");
+ fileBuffer
+ .append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\r\n");
+ fileBuffer
+ .append(" IN EFI_PEI_SERVICES **PeiServices\r\n");
+ fileBuffer.append(" );\r\n");
+ break;
+
+ case CommonDefinition.ModuleTypeDxeCore:
+ case CommonDefinition.ModuleTypeDxeDriver:
+ case CommonDefinition.ModuleTypeDxeRuntimeDriver:
+ case CommonDefinition.ModuleTypeDxeSmmDriver:
+ case CommonDefinition.ModuleTypeDxeSalDriver:
+ case CommonDefinition.ModuleTypeUefiDriver:
+ case CommonDefinition.ModuleTypeUefiApplication:
+ fileBuffer.append("EFI_STATUS\r\n");
+ fileBuffer.append(libInstanceList.get(i));
+ fileBuffer.append(" (\r\n");
+ fileBuffer.append(" IN EFI_HANDLE ImageHandle,\r\n");
+ fileBuffer.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
+ fileBuffer.append(" );\r\n");
+ break;
+ }
+ }
+
+ //
+ // Add ProcessLibraryConstructorList in AutoGen.c
+ //
+ fileBuffer.append("VOID\r\n");
+ fileBuffer.append("ProcessLibraryConstructorList (\r\n");
+ switch (CommonDefinition.getModuleType(moduleType)) {
+ case CommonDefinition.ModuleTypeBase:
+ fileBuffer.append(" VOID\r\n");
+ break;
+
+ case CommonDefinition.ModuleTypePeiCore:
+ case CommonDefinition.ModuleTypePeim:
+ fileBuffer.append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\r\n");
+ fileBuffer
+ .append(" IN EFI_PEI_SERVICES **PeiServices\r\n");
+ break;
+
+ case CommonDefinition.ModuleTypeDxeCore:
+ case CommonDefinition.ModuleTypeDxeDriver:
+ case CommonDefinition.ModuleTypeDxeRuntimeDriver:
+ case CommonDefinition.ModuleTypeDxeSmmDriver:
+ case CommonDefinition.ModuleTypeDxeSalDriver:
+ case CommonDefinition.ModuleTypeUefiDriver:
+ case CommonDefinition.ModuleTypeUefiApplication:
+ fileBuffer.append(" IN EFI_HANDLE ImageHandle,\r\n");
+ fileBuffer.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
+ break;
+ }
+
+ fileBuffer.append(" )\r\n");
+ fileBuffer.append("{\r\n");
+
+ for (int i = 0; i < libInstanceList.size(); i++) {
+ if (isFirst) {
+ fileBuffer.append(" EFI_STATUS Status;\r\n");
+ fileBuffer.append("\r\n");
+ isFirst = false;
+ }
+ switch (CommonDefinition.getModuleType(moduleType)) {
+ case CommonDefinition.ModuleTypeBase:
+ fileBuffer.append(" Status = ");
+ fileBuffer.append(libInstanceList.get(i));
+ fileBuffer.append("();\r\n");
+ fileBuffer.append(" VOID\r\n");
+ break;
+ case CommonDefinition.ModuleTypePeiCore:
+ case CommonDefinition.ModuleTypePeim:
+ fileBuffer.append(" Status = ");
+ fileBuffer.append(libInstanceList.get(i));
+ fileBuffer.append(" (FfsHeader, PeiServices);\r\n");
+ break;
+ case CommonDefinition.ModuleTypeDxeCore:
+ case CommonDefinition.ModuleTypeDxeDriver:
+ case CommonDefinition.ModuleTypeDxeRuntimeDriver:
+ case CommonDefinition.ModuleTypeDxeSmmDriver:
+ case CommonDefinition.ModuleTypeDxeSalDriver:
+ case CommonDefinition.ModuleTypeUefiDriver:
+ case CommonDefinition.ModuleTypeUefiApplication:
+ fileBuffer.append(" Status = ");
+ fileBuffer.append(libInstanceList.get(i));
+ fileBuffer.append(" (ImageHandle, SystemTable);\r\n");
+ break;
+ }
+ fileBuffer.append(" ASSERT_EFI_ERROR (Status);\r\n");
+ }
+ fileBuffer.append("}\r\n");
+ }
+
+ /**
+ LibDestructorToAutogenc
+
+ This function writes library destructor list to AutoGen.c. The library
+ destructor's parameter and return value depend on module type.
+
+ @param libInstanceList List of library destructor name.
+ @param moduleType Module type.
+ @param fileBuffer String buffer for AutoGen.c
+ @throws Exception
+ **/
+ void LibDestructorToAutogenC(List libInstanceList,
+ String moduleType, StringBuffer fileBuffer) throws Exception {
+ boolean isFirst = true;
+ for (int i = 0; i < libInstanceList.size(); i++) {
+ switch (CommonDefinition.getModuleType(moduleType)) {
+ case CommonDefinition.ModuleTypeBase:
+ fileBuffer.append("RETURN_STATUS\n");
+ fileBuffer.append(libInstanceList.get(i));
+ fileBuffer.append(" (\r\n");
+ fileBuffer.append(" VOID\r\n");
+ fileBuffer.append(" );\r\n");
+ break;
+ case CommonDefinition.ModuleTypePeiCore:
+ case CommonDefinition.ModuleTypePeim:
+ fileBuffer.append("EFI_STATUS\r\n");
+ fileBuffer.append(libInstanceList.get(i));
+ fileBuffer.append(" (\r\n");
+ fileBuffer
+ .append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\r\n");
+ fileBuffer
+ .append(" IN EFI_PEI_SERVICES **PeiServices\r\n");
+ fileBuffer.append(" );\r\n");
+ break;
+ case CommonDefinition.ModuleTypeDxeCore:
+ case CommonDefinition.ModuleTypeDxeDriver:
+ case CommonDefinition.ModuleTypeDxeRuntimeDriver:
+ case CommonDefinition.ModuleTypeDxeSmmDriver:
+ case CommonDefinition.ModuleTypeDxeSalDriver:
+ case CommonDefinition.ModuleTypeUefiDriver:
+ case CommonDefinition.ModuleTypeUefiApplication:
+ fileBuffer.append("EFI_STATUS\r\n");
+ fileBuffer.append(libInstanceList.get(i));
+ fileBuffer.append(" (\r\n");
+ fileBuffer.append(" IN EFI_HANDLE ImageHandle,\r\n");
+ fileBuffer.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
+ fileBuffer.append(" );\r\n");
+ break;
+ }
+ }
+
+ //
+ // Write ProcessLibraryDestructor list to autogen.c
+ //
+ switch (CommonDefinition.getModuleType(moduleType)) {
+ case CommonDefinition.ModuleTypeBase:
+ case CommonDefinition.ModuleTypePeiCore:
+ case CommonDefinition.ModuleTypePeim:
+ break;
+ case CommonDefinition.ModuleTypeDxeCore:
+ case CommonDefinition.ModuleTypeDxeDriver:
+ case CommonDefinition.ModuleTypeDxeRuntimeDriver:
+ case CommonDefinition.ModuleTypeDxeSmmDriver:
+ case CommonDefinition.ModuleTypeDxeSalDriver:
+ case CommonDefinition.ModuleTypeUefiDriver:
+ case CommonDefinition.ModuleTypeUefiApplication:
+ fileBuffer.append("VOID\r\n");
+ fileBuffer.append("ProcessLibraryDestructorList (\r\n");
+ fileBuffer.append(" IN EFI_HANDLE ImageHandle,\r\n");
+ fileBuffer.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
+ fileBuffer.append(" )\r\n");
+ fileBuffer.append("{\r\n");
+
+ for (int i = 0; i < libInstanceList.size(); i++) {
+ if (isFirst) {
+ fileBuffer.append(" EFI_STATUS Status;\r\n");
+ fileBuffer.append("\r\n");
+ isFirst = false;
+ }
+ fileBuffer.append(" Status = ");
+ fileBuffer.append(libInstanceList.get(i));
+ fileBuffer.append("(ImageHandle, SystemTable);\r\n");
+ fileBuffer.append(" ASSERT_EFI_ERROR (Status);\r\n");
+ }
+ fileBuffer.append("}\r\n");
+ break;
+ }
+ }
+
+ /**
+ ExternsDriverBindingToAutoGenC
+
+ This function is to write DRIVER_BINDING, COMPONENT_NAME,
+ DRIVER_CONFIGURATION, DRIVER_DIAGNOSTIC in AutoGen.c.
+
+ @param fileBuffer String buffer for AutoGen.c
+ */
+ void ExternsDriverBindingToAutoGenC(StringBuffer fileBuffer)
+ throws BuildException {
+
+ //
+ // Check what contains. And the number of following elements
+ // under should be same. 1. DRIVER_BINDING 2. COMPONENT_NAME
+ // 3.DRIVER_CONFIGURATION 4. DRIVER_DIAGNOSTIC
+ //
+
+ String[] drvBindList = SurfaceAreaQuery.getDriverBindingArray();
+
+ //
+ // If component name protocol,component configuration protocol,
+ // component diagnostic protocol is not null or empty, check
+ // if every one have the same number of the driver binding protocol.
+ //
+ if (drvBindList == null || drvBindList.length == 0) {
+ return;
+ }
+
+ String[] compNamList = SurfaceAreaQuery.getComponentNameArray();
+ String[] compConfList = SurfaceAreaQuery.getDriverConfigArray();
+ String[] compDiagList = SurfaceAreaQuery.getDriverDiagArray();
+
+ int BitMask = 0;
+
+ //
+ // Write driver binding protocol extern to autogen.c
+ //
+ for (int i = 0; i < drvBindList.length; i++) {
+ fileBuffer.append("extern EFI_DRIVER_BINDING_PROTOCOL ");
+ fileBuffer.append(drvBindList[i]);
+ fileBuffer.append(";\r\n");
+ }
+
+ //
+ // Write component name protocol extern to autogen.c
+ //
+ if (compNamList != null && compNamList.length != 0) {
+ if (drvBindList.length != compNamList.length) {
+ throw new BuildException(
+ "Different number of Driver Binding and Component Name protocols!");
+ }
+
+ BitMask |= 0x01;
+ for (int i = 0; i < compNamList.length; i++) {
+ fileBuffer.append("extern EFI_COMPONENT_NAME_PROTOCOL ");
+ fileBuffer.append(compNamList[i]);
+ fileBuffer.append(";\r\n");
+ }
+ }
+
+ //
+ // Write driver configration protocol extern to autogen.c
+ //
+ if (compConfList != null && compConfList.length != 0) {
+ if (drvBindList.length != compConfList.length) {
+ throw new BuildException(
+ "Different number of Driver Binding and Driver Configuration protocols!");
+ }
+
+ BitMask |= 0x02;
+ for (int i = 0; i < compConfList.length; i++) {
+ fileBuffer.append("extern EFI_DRIVER_CONFIGURATION_PROTOCOL ");
+ fileBuffer.append(compConfList[i]);
+ fileBuffer.append(";\r\n");
+ }
+ }
+
+ //
+ // Write driver dignastic protocol extern to autogen.c
+ //
+ if (compDiagList != null && compDiagList.length != 0) {
+ if (drvBindList.length != compDiagList.length) {
+ throw new BuildException(
+ "Different number of Driver Binding and Driver Configuration protocols!");
+ }
+
+ BitMask |= 0x04;
+ for (int i = 0; i < compDiagList.length; i++) {
+ fileBuffer.append("extern EFI_DRIVER_DIAGNOSTICS_PROTOCOL ");
+ fileBuffer.append(compDiagList[i]);
+ fileBuffer.append(";\r\n");
+ }
+ }
+
+ //
+ // Write driver module protocol bitmask.
+ //
+ fileBuffer
+ .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverModelProtocolBitmask = ");
+ fileBuffer.append(Integer.toString(BitMask));
+ fileBuffer.append(";\r\n");
+
+ //
+ // Write driver module protocol list entry
+ //
+ fileBuffer
+ .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINTN _gDriverModelProtocolListEntries = ");
+
+ fileBuffer.append(Integer.toString(drvBindList.length));
+ fileBuffer.append(";\r\n");
+
+ //
+ // Write drive module protocol list to autogen.c
+ //
+ fileBuffer
+ .append("GLOBAL_REMOVE_IF_UNREFERENCED const EFI_DRIVER_MODEL_PROTOCOL_LIST _gDriverModelProtocolList[] = {");
+ for (int i = 0; i < drvBindList.length; i++) {
+ if (i != 0) {
+ fileBuffer.append(",");
+ }
+ fileBuffer.append("\r\n {\r\n");
+ fileBuffer.append(" &");
+ fileBuffer.append(drvBindList[i]);
+ fileBuffer.append(", \r\n");
+
+ if (compNamList != null) {
+ fileBuffer.append(" &");
+ fileBuffer.append(compNamList[i]);
+ fileBuffer.append(", \r\n");
+ } else {
+ fileBuffer.append(" NULL, \r\n");
+ }
+
+ if (compConfList != null) {
+ fileBuffer.append(" &");
+ fileBuffer.append(compConfList[i]);
+ fileBuffer.append(", \r\n");
+ } else {
+ fileBuffer.append(" NULL, \r\n");
+ }
+
+ if (compDiagList != null) {
+ fileBuffer.append(" &");
+ fileBuffer.append(compDiagList[i]);
+ fileBuffer.append(", \r\n");
+ } else {
+ fileBuffer.append(" NULL, \r\n");
+ }
+ fileBuffer.append(" }");
+ }
+ fileBuffer.append("\r\n};\r\n");
+ }
+
+ /**
+ ExternCallBackToAutoGenC
+
+ This function adds and
+ infomation to AutoGen.c
+
+ @param fileBuffer String buffer for AutoGen.c
+ @throws BuildException
+ **/
+ void ExternCallBackToAutoGenC(StringBuffer fileBuffer)
+ throws BuildException {
+ String[] setVirtualList = SurfaceAreaQuery
+ .getSetVirtualAddressMapCallBackArray();
+ String[] exitBootList = SurfaceAreaQuery
+ .getExitBootServicesCallBackArray();
+ String moduleType = SurfaceAreaQuery.getModuleType();
+ boolean UefiOrDxeModule = false;
+ int Count = 0;
+ int i;
+
+ switch (CommonDefinition.getModuleType(moduleType)) {
+ case CommonDefinition.ModuleTypeDxeDriver:
+ case CommonDefinition.ModuleTypeDxeRuntimeDriver:
+ case CommonDefinition.ModuleTypeDxeSalDriver:
+ case CommonDefinition.ModuleTypeUefiDriver:
+ case CommonDefinition.ModuleTypeUefiApplication:
+ //
+ // Entry point lib for these module types needs to know the count
+ // of entryPoint.
+ //
+ UefiOrDxeModule = true;
+ fileBuffer
+ .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const UINTN _gDriverSetVirtualAddressMapEventCount = ");
+
+ //
+ // If the list is not valid or has no entries set count to zero else
+ // set count to the number of valid entries
+ //
+ Count = 0;
+ if (setVirtualList != null) {
+ for (i = 0; i < setVirtualList.length; i++) {
+ if (setVirtualList[i].equalsIgnoreCase("")) {
+ break;
+ }
+ }
+ Count = i;
+ }
+
+ fileBuffer.append(Integer.toString(Count));
+ fileBuffer.append(";\r\n\r\n");
+ break;
+ default:
+ break;
+ }
+
+ if (setVirtualList == null) {
+ if (UefiOrDxeModule) {
+ //
+ // No data so make a NULL list
+ //
+ fileBuffer
+ .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const EFI_EVENT_NOTIFY _gDriverSetVirtualAddressMapEvent[] = {\r\n");
+ fileBuffer.append(" NULL\r\n");
+ fileBuffer.append("};\r\n\r\n");
+ }
+ } else {
+ //
+ // Write SetVirtualAddressMap function definition.
+ //
+ for (i = 0; i < setVirtualList.length; i++) {
+ if (setVirtualList[i].equalsIgnoreCase("")) {
+ break;
+ }
+ fileBuffer.append("VOID\r\n");
+ fileBuffer.append("EFIAPI\n");
+ fileBuffer.append(setVirtualList[i]);
+ fileBuffer.append(" (\r\n");
+ fileBuffer.append(" IN EFI_EVENT Event,\r\n");
+ fileBuffer.append(" IN VOID *Context\r\n");
+ fileBuffer.append(" );\r\n\r\n");
+ }
+
+ //
+ // Write SetVirtualAddressMap entry point array.
+ //
+ fileBuffer
+ .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const EFI_EVENT_NOTIFY _gDriverSetVirtualAddressMapEvent[] = {");
+ for (i = 0; i < setVirtualList.length; i++) {
+ if (setVirtualList[i].equalsIgnoreCase("")) {
+ break;
+ }
+
+ if (i == 0) {
+ fileBuffer.append("\r\n ");
+ } else {
+ fileBuffer.append(",\r\n ");
+ }
+
+ fileBuffer.append(setVirtualList[i]);
+ }
+ if (Count == 0) {
+ fileBuffer.append("\r\n NULL");
+ }
+ fileBuffer.append("\r\n};\r\n\r\n");
+ }
+
+ if (UefiOrDxeModule) {
+ //
+ // Entry point lib for these module types needs to know the count.
+ //
+ fileBuffer
+ .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const UINTN _gDriverExitBootServicesEventCount = ");
+
+ //
+ // If the list is not valid or has no entries set count to zero else
+ // set count to the number of valid entries.
+ //
+ Count = 0;
+ if (exitBootList != null) {
+ if (setVirtualList != null) {
+ for (i = 0; i < exitBootList.length; i++) {
+ if (exitBootList[i].equalsIgnoreCase("")) {
+ break;
+ }
+ }
+ Count = i;
+ }
+ }
+ fileBuffer.append(Integer.toString(Count));
+ fileBuffer.append(";\r\n\r\n");
+ }
+
+ if (exitBootList == null) {
+ if (UefiOrDxeModule) {
+ //
+ // No data so make a NULL list.
+ //
+ fileBuffer
+ .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const EFI_EVENT_NOTIFY _gDriverExitBootServicesEvent[] = {\r\n");
+ fileBuffer.append(" NULL\r\n");
+ fileBuffer.append("};\r\n\r\n");
+ }
+ } else {
+ //
+ // Write DriverExitBootServices function definition.
+ //
+ for (i = 0; i < exitBootList.length; i++) {
+ if (exitBootList[i].equalsIgnoreCase("")) {
+ break;
+ }
+
+ fileBuffer.append("VOID\r\n");
+ fileBuffer.append("EFIAPI\n");
+ fileBuffer.append(exitBootList[i]);
+ fileBuffer.append(" (\r\n");
+ fileBuffer.append(" IN EFI_EVENT Event,\r\n");
+ fileBuffer.append(" IN VOID *Context\r\n");
+ fileBuffer.append(" );\r\n\r\n");
+ }
+
+ //
+ // Write DriverExitBootServices entry point array.
+ //
+ fileBuffer
+ .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const EFI_EVENT_NOTIFY _gDriverExitBootServicesEvent[] = {");
+ for (i = 0; i < exitBootList.length; i++) {
+ if (exitBootList[i].equalsIgnoreCase("")) {
+ break;
+ }
+
+ if (i == 0) {
+ fileBuffer.append("\r\n ");
+ } else {
+ fileBuffer.append(",\r\n ");
+ }
+ fileBuffer.append(exitBootList[i]);
+ }
+ if (Count == 0) {
+ fileBuffer.append("\r\n NULL");
+ }
+ fileBuffer.append("\r\n};\r\n\r\n");
+ }
+
+ }
+
+}
\ No newline at end of file
diff --git a/Tools/Source/GenBuild/org/tianocore/build/autogen/AutogenLibOrder.java b/Tools/Source/GenBuild/org/tianocore/build/autogen/AutogenLibOrder.java
new file mode 100644
index 0000000000..77404d4007
--- /dev/null
+++ b/Tools/Source/GenBuild/org/tianocore/build/autogen/AutogenLibOrder.java
@@ -0,0 +1,306 @@
+/**@file
+ AutogenLibOrder class.
+
+ This class is to reorder library instance sequence according to library
+ dependence.
+
+ Copyright (c) 2006, Intel Corporation
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+ **/
+package org.tianocore.build.autogen;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.xmlbeans.XmlObject;
+import org.tianocore.LibraryClassDocument.LibraryClass;
+
+import org.tianocore.build.global.GlobalData;
+import org.tianocore.build.global.SurfaceAreaQuery;
+
+/**
+ This class This class is to reorder library instance sequence according to
+ library dependence.
+**/
+public class AutogenLibOrder {
+ ///
+ /// The map of library class and its library instance.
+ ///
+ private Map libClassMap = new HashMap();
+
+ ///
+ /// The map of library instance and its implemet instance.
+ ///
+ private Map libInstanceMap = new HashMap();
+
+ ///
+ /// List of library instance. It is String[3] list, String[0] is libraryName,
+ /// String[1] is libraryConstructor name, String[2] is libDestructor name.
+ ///
+ private List libInstanceList = new ArrayList();
+
+ /**
+ Constructor function
+
+ This function mainly initialize some member variable.
+
+ @param libraryList List of the library instance.
+ @throws Exception
+ **/
+ AutogenLibOrder(List libraryList) throws Exception {
+ String[] libInstance = new String[3];
+ LibraryClass[] libClassDeclList = null;
+ LibraryClass[] libClassConsmList = null;
+
+ for (int i = 0; i < libraryList.size(); i++) {
+ //
+ // Add libraryInstance in to libInstanceList.
+ //
+ libInstance[0] = libraryList.get(i);
+ Map libDoc = GlobalData.getDoc(libInstance[0]);
+ SurfaceAreaQuery.push(libDoc);
+ libInstance[1] = SurfaceAreaQuery.getLibConstructorName();
+ libInstance[2] = SurfaceAreaQuery.getLibDestructorName();
+ libInstanceList.add(libInstance.clone());
+
+ //
+ // Add library instance and consumed library class list to
+ // libInstanceMap.
+ //
+ libClassConsmList = SurfaceAreaQuery
+ .getLibraryClassArray(CommonDefinition.AlwaysConsumed);
+ if (libClassConsmList != null) {
+ String[] classStr = new String[libClassConsmList.length];
+ for (int k = 0; k < libClassConsmList.length; k++) {
+ classStr[k] = libClassConsmList[k].getStringValue();
+ }
+ if (this.libInstanceMap.containsKey(libInstance[0])) {
+ throw new Exception(
+ libInstance[0]
+ + "this library instance is already exist, please check you library instance list!");
+ } else {
+ this.libInstanceMap.put(libInstance[0], classStr);
+ }
+ }
+
+ //
+ // Add library class and library instance map.
+ //
+ libClassDeclList = SurfaceAreaQuery
+ .getLibraryClassArray(CommonDefinition.AlwaysProduced);
+ if (libClassDeclList != null) {
+ for (int j = 0; j < libClassDeclList.length; j++) {
+ if (this.libClassMap.containsKey(libClassDeclList[j]
+ .getStringValue())) {
+ System.out.println(libClassDeclList[j].getStringValue()
+ + " class is already implement by "
+ + this.libClassMap.get(libClassDeclList[j]
+ .getStringValue()));
+ throw new Exception(libClassDeclList
+ + " is already have library instance!");
+ } else {
+ this.libClassMap.put(libClassDeclList[j]
+ .getStringValue(), libInstance[0]);
+ }
+ }
+ }
+ SurfaceAreaQuery.pop();
+ }
+
+ //
+ // Check is the library instance list meet the require;
+ //
+ for (int s = 0; s < this.libInstanceList.size(); s++) {
+ String[] libClass = this.libInstanceMap.get(this.libInstanceList
+ .get(s));
+ if (libClass != null) {
+ for (int t = 0; t < libClass.length; t++) {
+ if (this.libClassMap.get(libClass[t]) == null) {
+ //
+ // Note: There exist a kind of module which depend on
+ // library class with no instance or whose instance will
+ // never be linked into the module.
+ // For this satuation, the module has the description of
+ // library class in MSA file but no description of
+ // corresponding library instance in MBD file. There
+ // will be a warnig message given here after a standard
+ // log way has been decided.
+ //
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ orderLibInstance
+
+ This function reorder the library instance according the library class
+ dependency.
+
+ @return List which content the ordered library instance.
+ **/
+ List orderLibInstance() {
+ List orderList = new ArrayList();
+ //
+ // Stack of node which track the library instance name ant its visiting
+ // flag.
+ //
+ List stackList = new ArrayList();
+ int stackSize = 0;
+ String libInstance = null;
+ if (libInstanceList.size() < 0) {
+ return null;
+ }
+
+ //
+ // Reorder the library instance.
+ //
+ for (int i = 0; i < libInstanceList.size(); i++) {
+ //
+ // If library instance is already in the order list skip it.
+ //
+ if (isInLibInstance(orderList, libInstanceList.get(i)[0])) {
+ continue;
+ }
+
+ Node node = new Node(libInstanceList.get(i)[0], false);
+ //
+ // Use stack to reorder library instance.
+ // Push node to stack.
+ //
+ stackList.add(node);
+ while (stackList.size() > 0) {
+ stackSize = stackList.size() - 1;
+ //
+ // Pop the first node in stack. If the node flag has been visited
+ // add this node to orderlist and remove it from stack.
+ //
+ if (stackList.get(stackSize).isVisit) {
+ if (!isInLibInstance(orderList,
+ stackList.get(stackSize).nodeName)) {
+ orderList.add(stackList.get(stackSize).nodeName);
+ stackList.remove(stackSize);
+ }
+
+ } else {
+ //
+ // Get the node value and set visit flag as true.
+ //
+ stackList.get(stackList.size() - 1).isVisit = true;
+ String[] libClassList = this.libInstanceMap.get(stackList
+ .get(stackSize).nodeName);
+ //
+ // Push the node dependence library instance to the stack.
+ //
+ if (libClassList != null) {
+ for (int j = 0; j < libClassList.length; j++) {
+ libInstance = this.libClassMap.get(libClassList[j]);
+ if (libInstance != null
+ && !isInLibInstance(orderList, libInstance)) {
+ //
+ // If and only if the currently library instance
+ // is not in stack and it have constructor or
+ // destructor function, push this library
+ // instacne in stack.
+ //
+ if (!isInStackList(stackList, this.libClassMap
+ .get(libClassList[j])) && isHaveConsDestructor(libInstance)) {
+ stackList.add(new Node(this.libClassMap
+ .get(libClassList[j]), false));
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ return orderList;
+ }
+
+ /**
+ isInLibInstance
+
+ This function check does the library instance already in the list.
+
+ @param list List of the library instance.
+ @param instanceName Name of library instance.
+ @return "true" the library instance in list |
+ "false" the library instance is not in list.
+ **/
+ private boolean isInLibInstance(List list, String instanceName) {
+ for (int i = 0; i < list.size(); i++) {
+ if (instanceName.equalsIgnoreCase(list.get(i).toString())) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ isInStackList
+
+ This function check if the node already in the stack.
+
+ @param list Stack.
+ @param nodeName Name of node.
+ @return "true" if node have in stack |
+ "false" if node don't in stack.
+ **/
+ private boolean isInStackList(List list, String nodeName) {
+ for (int i = 0; i < list.size(); i++) {
+ if (nodeName.equalsIgnoreCase(list.get(i).nodeName)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ isHaveConsDestructor
+
+ This function check if the library have constructor or destructor
+ function.
+
+ @param libName Name of library
+ @return "true" if library have constructor or desconstructor |
+ "false" if library don't have constructor
+ and desconstructor.
+ **/
+ private boolean isHaveConsDestructor (String libName){
+ for (int i = 0; i < libInstanceList.size(); i++){
+ if (libInstanceList.get(i)[0].equalsIgnoreCase(libName)){
+ if (libInstanceList.get(i)[1] != null || libInstanceList.get(i)[2] != null){
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+}
+
+/**
+ Node
+
+ This class is used as stack node.
+
+ **/
+class Node {
+ String nodeName;
+
+ boolean isVisit;
+
+ Node(String name, boolean isVisit) {
+ this.nodeName = name;
+ this.isVisit = false;
+ }
+}
\ No newline at end of file
diff --git a/Tools/Source/GenBuild/org/tianocore/build/autogen/CommonDefinition.java b/Tools/Source/GenBuild/org/tianocore/build/autogen/CommonDefinition.java
new file mode 100644
index 0000000000..2490d97467
--- /dev/null
+++ b/Tools/Source/GenBuild/org/tianocore/build/autogen/CommonDefinition.java
@@ -0,0 +1,257 @@
+/** @file
+ CommonDefinition class.
+
+ This class is to define some common marcos and funcions, which used by AutoGen.
+
+ Copyright (c) 2006, Intel Corporation
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+ **/
+package org.tianocore.build.autogen;
+
+/**
+ CommonDefinition
+
+ This class is to define some common marcos, which used by AutoGen.
+
+**/
+public class CommonDefinition {
+ public final static String spdSuffix = ".spd";
+ public final static String mbdSuffix = ".mbd";
+ public final static String msaSuffix = ".msa";
+ public final static String LibraryStr = "LIBRARY";
+ public final static String autoGenHbegin = "extern int __make_me_compile_correctly;\r\n";
+ public final static String include = "#include";
+ public final static String autoGenCLine1 = "\r\n";
+
+ public final static String autoGenCLine2 = "const UINT8 _gDebugPropertyMask "
+ + "= DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED"
+ + " | DEBUG_PROPERTY_DEBUG_PRINT_ENABLED"
+ + " | DEBUG_PROPERTY_DEBUG_CODE_ENABLED;\r\n";
+
+ public final static String autoGenCLine3 = "const UINTN _gModuleDefaultErrorLevel"
+ + " = EFI_D_ERROR | EFI_D_LOAD;\r\n";
+
+ public final static String autoGenHLine1 = "#define EFI_SPECIFICATION_VERSION 0x00020000\r\n";
+ public final static String autoGenHVersionDefault = "#define EFI_SPECIFICATION_VERSION 0x00000000\r\n";
+ public final static String autoGenHLine2 = "#define EDK_RELEASE_VERSION 0x00090000\r\n";
+ public final static String autoGenHReleaseDefault = "#define EDK_RELEASE_VERSION 0x00000000\r\n";
+
+ public final static String includeAutogenH = "#include \r\n" ;
+
+ public final static String gEfi = "gEfi";
+ public final static String protocolGuid = "ProtocolGuid";
+ public final static String ppiGuid = "PpiGuid";
+ public final static String guidGuid = "Guid";
+
+ //
+ // AutoGen.h and AutoGen.c file's header
+ //
+ public final static String autogenHNotation =
+ "/**\r\n" +
+ " DO NOT EDIT\r\n" +
+ " FILE auto-generated by GenBuild tasks\r\n" +
+ " Module name:\r\n" +
+ " AutoGen.h\r\n" +
+ " Abstract:" +
+ " Auto-generated AutoGen.h for building module or library.\r\n" +
+ "**/\r\n\r\n";
+
+ public final static String autogenCNotation =
+ "/**\r\n" +
+ " DO NOT EDIT\r\n" +
+ " FILE auto-generated by GenBuild tasks\r\n" +
+ " Module name:\r\n" +
+ " AutoGen.c\r\n" +
+ " Abstract:" +
+ " Auto-generated AutoGen.c for building module or library.\r\n" +
+ "**/\r\n\r\n";
+
+ //
+ // module type
+ //
+ public final static int ModuleTypeBase = 0;
+ public final static int ModuleTypeSec = 1;
+ public final static int ModuleTypePeiCore = 2;
+ public final static int ModuleTypePeim = 3;
+ public final static int ModuleTypeDxeCore = 4;
+ public final static int ModuleTypeDxeDriver = 5;
+ public final static int ModuleTypeDxeRuntimeDriver = 6;
+ public final static int ModuleTypeDxeSmmDriver = 7;
+ public final static int ModuleTypeDxeSalDriver = 8;
+ public final static int ModuleTypeUefiDriver = 9;
+ public final static int ModuleTypeUefiApplication = 10;
+ public final static int ModuleTypeUnknown = 11;
+
+
+ //
+ // component type
+ //
+ public final static int ComponentTypeNull = 0;
+ public final static int ComponentTypeApriori = 1;
+ public final static int ComponentTypeSec = 2;
+ public final static int ComponentTypeLibrary = 3;
+ public final static int ComponentTypeFvImageFile = 4;
+ public final static int ComponentTypeBsDriver = 5;
+ public final static int ComponentTypeRtDriver = 6;
+ public final static int ComponentTypeSalRtDriver =7;
+ public final static int ComponentTypePe32Peim = 8;
+ public final static int ComponentTypePicPeim =9;
+ public final static int ComponentTypeCombinedPeimDriver =10;
+ public final static int ComponentTypePeiCore = 11;
+ public final static int ComponentTypeDxeCore = 12;
+ public final static int ComponentTypeApplication = 13;
+ public final static int ComponentTypeBsDriverEfi = 14;
+ public final static int ComponentTypeShellApp = 15;
+ public final static int ComponentTypeBinary =16;
+ public final static int ComponentTypeLogo = 17;
+ public final static int ComponentTypeCustomBuild = 18;
+ public final static int ComponentTypeUnknown = 19;
+
+
+ //
+ // Usaged style
+ //
+ public final static String AlwaysConsumed = "ALWAYS_CONSUMED";
+ public final static String AlwaysProduced = "ALWAYS_PRODUCED";
+
+
+ public static class MyEnum {
+ String moduleTypeStr;
+ int type;
+
+ MyEnum (String str, int type) {
+ this.type = type;
+ this.moduleTypeStr = str;
+ }
+
+ int ForInt(String str) {
+ if (str.equals(this.moduleTypeStr)) {
+ return this.type;
+ } else
+ return -1;
+ }
+ }
+
+ //
+ // Module type
+ //
+ public static final MyEnum[] moduleEnum = new MyEnum[] {
+ new MyEnum("BASE", ModuleTypeBase),
+ new MyEnum("SEC", ModuleTypeSec),
+ new MyEnum("PEI_CORE", ModuleTypePeiCore),
+ new MyEnum("PEIM", ModuleTypePeim),
+ new MyEnum("DXE_CORE", ModuleTypeDxeCore),
+ new MyEnum("DXE_DRIVER", ModuleTypeDxeRuntimeDriver),
+ new MyEnum("DXE_RUNTIME_DRIVER", ModuleTypeDxeRuntimeDriver),
+ new MyEnum("DXE_SAL_DRIVER", ModuleTypeDxeSmmDriver),
+ new MyEnum("DXE_SMM_DRIVER", ModuleTypeDxeSalDriver),
+ new MyEnum("UEFI_DRIVER", ModuleTypeUefiDriver),
+ new MyEnum("UEFI_APPLICATION", ModuleTypeUefiApplication) };
+
+ //
+ // Component type
+ //
+ public static final MyEnum[] componentEnum = new MyEnum[]{
+ new MyEnum("APRIORI", ComponentTypeApriori),
+ new MyEnum("SEC", ComponentTypeSec),
+ new MyEnum("LIBRARY", ComponentTypeLibrary),
+ new MyEnum("FV_IMAGE_FILE", ComponentTypeFvImageFile),
+ new MyEnum("BS_DRIVER", ComponentTypeBsDriver),
+ new MyEnum("RT_DRIVER", ComponentTypeRtDriver),
+ new MyEnum("SAL_RT_DRIVER", ComponentTypeSalRtDriver),
+ new MyEnum("PE32_PEIM", ComponentTypePe32Peim),
+ new MyEnum("PIC_PEIM", ComponentTypePicPeim),
+ new MyEnum("COMBINED_PEIM_DRIVER", ComponentTypeCombinedPeimDriver),
+ new MyEnum("PEI_CORE", ComponentTypePeiCore),
+ new MyEnum("DXE_CORE", ComponentTypeDxeCore),
+ new MyEnum("APPLICATION", ComponentTypeApplication),
+ new MyEnum("BS_DRIVER_EFI", ComponentTypeBsDriverEfi),
+ new MyEnum("SHELLAPP", ComponentTypeShellApp),
+ new MyEnum("BINARY", ComponentTypeBinary),
+ new MyEnum("LOGO", ComponentTypeLogo),
+ new MyEnum("CUSTOM_BUILD", ComponentTypeCustomBuild)
+ };
+
+ /**
+ getModuleType
+
+ This function get the module type value according module type string.
+
+ @param moduleTypeStr String of modlue type.
+ @return
+ **/
+ static public int getModuleType(String moduleTypeStr) {
+ int returnValue = -1;
+ for (int i = 0; i < CommonDefinition.moduleEnum.length; i++) {
+ returnValue = CommonDefinition.moduleEnum[i].ForInt(moduleTypeStr);
+ if (returnValue != -1) {
+ return returnValue;
+ }
+ }
+ return CommonDefinition.ModuleTypeUnknown;
+ }
+
+ /**
+ getComponentType
+
+ This function get the component type value according commponet type
+ string.
+
+ @param componentTypeStr String of component type.
+ @return
+ **/
+ static public int getComponentType (String componentTypeStr){
+ int returnValue = -1;
+ for (int i = 0; i < CommonDefinition.componentEnum.length; i++) {
+ returnValue = CommonDefinition.componentEnum[i].ForInt(componentTypeStr);
+ if (returnValue != -1) {
+ return returnValue;
+ }
+ }
+ return CommonDefinition.ComponentTypeUnknown;
+ }
+
+ /**
+ getComponentTypeString
+
+ This function get the commponet type string according component type value.
+
+ @param componentType Integer value of component type.
+ @return
+ **/
+ static public String getComponentTypeString (int componentType) {
+ if ((componentType > CommonDefinition.ComponentTypeUnknown) ||
+ (componentType < CommonDefinition.ComponentTypeNull)) {
+ return null;
+ }
+ for (int index = 0; index < CommonDefinition.componentEnum.length; index ++) {
+ if (componentType == CommonDefinition.componentEnum[index].type) {
+ return CommonDefinition.componentEnum[index].moduleTypeStr;
+ }
+ }
+ return null;
+ }
+
+ /**
+ isLibraryComponent
+
+ This function is to check does componet is library according to commponet
+ type value.
+
+ @param componentType Integer value of component type.
+ @return
+ **/
+ static public boolean isLibraryComponent (int componentType) {
+ if (ComponentTypeLibrary == componentType) {
+ return true;
+ }
+ return false;
+ }
+}
\ No newline at end of file
diff --git a/Tools/Source/GenBuild/org/tianocore/build/fpd/FpdModuleIdentification.java b/Tools/Source/GenBuild/org/tianocore/build/fpd/FpdModuleIdentification.java
new file mode 100644
index 0000000000..261cf58a35
--- /dev/null
+++ b/Tools/Source/GenBuild/org/tianocore/build/fpd/FpdModuleIdentification.java
@@ -0,0 +1,131 @@
+/** @file
+ Java class FpdModuleIdentification is used to present a module identification
+ from BaseName, GUID, Version, PackageName, and ARCH.
+
+Copyright (c) 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+**/
+package org.tianocore.build.fpd;
+
+/**
+ This class is used to identify a module with BaseName, GUID, Version, PackageName
+ and ARCH.
+
+ @since GenBuild 1.0
+ **/
+public class FpdModuleIdentification {
+
+ private String arch;
+
+ private String fvBinding;
+
+ private String baseName;
+
+ private String packageName;
+
+ private String guid;
+
+ private String version;
+
+ private String sequence;
+
+ /**
+
+ @param baseName the base name of the module
+ @param guid the GUID of the module
+ @param arch the ARCH of the module
+ **/
+ public FpdModuleIdentification(String baseName, String guid, String arch){
+ this.baseName = baseName;
+ this.guid = guid;
+ this.arch = arch;
+ }
+
+ /**
+ Override java.lang.Object#equals.
+
+
Currently, use BaseName and ARCH to identify a module. It will enhance
+ in the next version.
+
+ @see java.lang.Object#equals(java.lang.Object)
+ **/
+ public boolean equals(Object obj) {
+ if (obj instanceof FpdModuleIdentification) {
+ FpdModuleIdentification moduleIdObj = (FpdModuleIdentification)obj;
+ if ( baseName.equalsIgnoreCase(moduleIdObj.baseName) && arch.equalsIgnoreCase(moduleIdObj.arch)) {
+ return true;
+ }
+ // TBD
+ return false;
+ }
+ else {
+ return super.equals(obj);
+ }
+ }
+
+ public void setArch(String arch) {
+ this.arch = arch;
+ }
+
+ public void setFvBinding(String fvBinding) {
+ this.fvBinding = fvBinding;
+ }
+
+ public void setSequence(String sequence) {
+ this.sequence = sequence;
+ }
+
+ public String toString(){
+ return arch + ":" + guid + "_" + baseName;
+ }
+
+ public void setBaseName(String baseName) {
+ this.baseName = baseName;
+ }
+
+ public void setGuid(String guid) {
+ this.guid = guid;
+ }
+
+ public void setPackageName(String packageName) {
+ this.packageName = packageName;
+ }
+
+ public void setVersion(String version) {
+ this.version = version;
+ }
+
+ public String getArch() {
+ return arch;
+ }
+
+ public String getBaseName() {
+ return baseName;
+ }
+
+ public String getFvBinding() {
+ return fvBinding;
+ }
+
+ public String getGuid() {
+ return guid;
+ }
+
+ public String getPackageName() {
+ return packageName;
+ }
+
+ public String getSequence() {
+ return sequence;
+ }
+
+ public String getVersion() {
+ return version;
+ }
+}
diff --git a/Tools/Source/GenBuild/org/tianocore/build/fpd/FpdParserTask.java b/Tools/Source/GenBuild/org/tianocore/build/fpd/FpdParserTask.java
new file mode 100644
index 0000000000..99b7242ebc
--- /dev/null
+++ b/Tools/Source/GenBuild/org/tianocore/build/fpd/FpdParserTask.java
@@ -0,0 +1,808 @@
+/** @file
+ This file is ANT task FpdParserTask.
+
+ FpdParserTask is used to parse FPD (Framework Platform Description) and generate
+ build.out.xml. It is for Package or Platform build use.
+
+Copyright (c) 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+**/
+package org.tianocore.build.fpd;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.Vector;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Result;
+import javax.xml.transform.Source;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Task;
+import org.apache.tools.ant.taskdefs.Property;
+import org.apache.xmlbeans.XmlObject;
+import org.w3c.dom.Comment;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+import org.tianocore.build.global.GlobalData;
+import org.tianocore.build.global.OutputManager;
+import org.tianocore.build.global.OverrideProcess;
+import org.tianocore.build.global.SurfaceAreaQuery;
+import org.tianocore.build.pcd.action.CollectPCDAction;
+import org.tianocore.build.pcd.action.ActionMessage;
+import org.tianocore.BuildOptionsDocument;
+import org.tianocore.FrameworkPlatformDescriptionDocument;
+import org.tianocore.ModuleSADocument;
+
+
+/**
+ FpdParserTask is an ANT task. The main function is parsing FPD
+ XML file and generating its ANT build script for Platform or Package.
+
+
The usage is (take NT32 Platform for example):
+
+
+ <FPDParser fpdfilename="Build\Nt32.fpd" />
+
+
+
The task will initialize all information through parsing Framework Database,
+ SPD, Tool chain configuration files.
+
+ @since GenBuild 1.0
+**/
+public class FpdParserTask extends Task {
+
+ ///
+ /// FV dir: ${PLATFORM_DIR}/Build/FV
+ ///
+ public static final String FV_OUTPUT_DIR = "${PLATFORM_DIR}" + File.separatorChar + "Build" + File.separatorChar + "FV";
+
+ private File fpdFilename;
+
+ private File guiddatabase;
+
+ ///
+ /// Keep platform buildoption information
+ ///
+ public static XmlObject platformBuildOptions = null;
+
+ ///
+ /// Mapping from modules identification to out put file name
+ ///
+ private Map outfiles = new LinkedHashMap();
+
+ ///
+ /// Mapping from FV name to its modules
+ ///
+ private Map > fvs = new HashMap >();
+
+ ///
+ /// Mapping from sequence number to its modules
+ ///
+ private Map > sequences = new HashMap >();
+
+ ///
+ /// FpdParserTask can specify some ANT properties.
+ ///
+ private Vector properties = new Vector();
+
+ private String info = "====================================================================\n"
+ + "DO NOT EDIT \n"
+ + "File auto-generated by build utility\n"
+ + "\n"
+ + "Abstract:\n"
+ + "Auto-generated ANT build file for building of EFI Modules/Platforms\n"
+ + "=====================================================================";
+
+ /**
+ Public construct method. It is necessary for ANT task.
+ **/
+ public FpdParserTask () {
+ }
+
+ /**
+ ANT task's entry method. The main steps is described as following:
+
+
+
Initialize global information (Framework DB, SPD files and all MSA files
+ listed in SPD). This step will execute only once in whole build process;
+
Parse specified FPD file;
+
Generate FV.inf files;
+
Generate build.out.xml file for Flatform or Package build;
+
Collect PCD information.
+
+
+ @throws BuildException
+ Surface area is not valid.
+ **/
+ public void execute() throws BuildException {
+ OutputManager.update(getProject());
+ //
+ // Parse DB and SPDs files. Initialize Global Data
+ //
+ GlobalData.initInfo("Tools" + File.separatorChar + "Conf" + File.separatorChar + "FrameworkDatabase.db", getProject()
+ .getProperty("WORKSPACE_DIR"));
+ //
+ // Parse FPD file
+ //
+ parseFpdFile();
+ //
+ // Gen Fv.inf files
+ //
+ genFvInfFiles();
+ //
+ // Gen build.xml
+ //
+ genBuildFile();
+ //
+ // Collect PCD information
+ //
+ collectPCDInformation ();
+ }
+
+ /**
+ Generate Fv.inf files. The Fv.inf file is composed with four
+ parts: Options, Attributes, Components and Files. The Fv.inf files
+ will be under ${PLATFOMR_DIR}\Build\Fv.
+
+ @throws BuildException
+ File write FV.inf files error.
+ **/
+ private void genFvInfFiles() throws BuildException{
+ String[] validFv = SurfaceAreaQuery.getFpdValidImageNames();
+ for (int i = 0; i < validFv.length; i++) {
+ getProject().setProperty("FV_FILENAME", validFv[i].toUpperCase());
+ //
+ // Get all global variables from FPD and set them to properties
+ //
+ String[][] globalVariables = SurfaceAreaQuery
+ .getFpdGlobalVariable();
+ for (int j = 0; j < globalVariables.length; j++) {
+ getProject().setProperty(globalVariables[j][0],
+ globalVariables[j][1]);
+ }
+
+ File fvFile = new File(getProject().replaceProperties(
+ FV_OUTPUT_DIR + File.separatorChar + validFv[i].toUpperCase()
+ + ".inf"));
+ fvFile.getParentFile().mkdirs();
+
+ try {
+ FileWriter fw = new FileWriter(fvFile);
+ BufferedWriter bw = new BufferedWriter(fw);
+ //
+ // Options
+ //
+ String[][] options = SurfaceAreaQuery.getFpdOptions(validFv[i]);
+ if (options.length > 0) {
+ bw.write("[options]");
+ bw.newLine();
+ for (int j = 0; j < options.length; j++) {
+ StringBuffer str = new StringBuffer(100);
+ str.append(options[j][0]);
+ while (str.length() < 40) {
+ str.append(' ');
+ }
+ str.append("= ");
+ str.append(options[j][1]);
+ bw.write(getProject().replaceProperties(str.toString()));
+ bw.newLine();
+ }
+ bw.newLine();
+ }
+ //
+ // Attributes;
+ //
+ String[][] attributes = SurfaceAreaQuery
+ .getFpdAttributes(validFv[i]);
+ if (attributes.length > 0) {
+ bw.write("[attributes]");
+ bw.newLine();
+ for (int j = 0; j < attributes.length; j++) {
+ StringBuffer str = new StringBuffer(100);
+ str.append(attributes[j][0]);
+ while (str.length() < 40) {
+ str.append(' ');
+ }
+ str.append("= ");
+ str.append(attributes[j][1]);
+ bw
+ .write(getProject().replaceProperties(
+ str.toString()));
+ bw.newLine();
+ }
+ bw.newLine();
+ }
+ //
+ // Components
+ //
+ String[][] components = SurfaceAreaQuery
+ .getFpdComponents(validFv[i]);
+ if (components.length > 0) {
+ bw.write("[components]");
+ bw.newLine();
+ for (int j = 0; j < components.length; j++) {
+ StringBuffer str = new StringBuffer(100);
+ str.append(components[j][0]);
+ while (str.length() < 40) {
+ str.append(' ');
+ }
+ str.append("= ");
+ str.append(components[j][1]);
+ bw
+ .write(getProject().replaceProperties(
+ str.toString()));
+ bw.newLine();
+ }
+ bw.newLine();
+ }
+ //
+ // Files
+ //
+ Set filesSet = fvs.get(validFv[i].toUpperCase());
+ if (filesSet != null) {
+ FpdModuleIdentification[] files = filesSet.toArray(new FpdModuleIdentification[filesSet
+ .size()]);
+ bw.write("[files]");
+ bw.newLine();
+ for (int j = 0; j < files.length; j++) {
+ String str = outfiles.get(files[j]);
+ bw.write(getProject().replaceProperties(
+ "EFI_FILE_NAME = " + str));
+ bw.newLine();
+ }
+ }
+ bw.flush();
+ bw.close();
+ fw.close();
+ } catch (Exception e) {
+ throw new BuildException("Generate Fv.inf file failed. \n" + e.getMessage());
+ }
+ }
+ }
+
+ /**
+ Parse FPD file.
+
+ @throws BuildException
+ FPD file is not valid.
+ **/
+ private void parseFpdFile() throws BuildException {
+ try {
+ FrameworkPlatformDescriptionDocument doc = (FrameworkPlatformDescriptionDocument) XmlObject.Factory
+ .parse(fpdFilename);
+ if ( ! doc.validate() ){
+ throw new BuildException("FPD file is invalid.");
+ }
+ platformBuildOptions = doc.getFrameworkPlatformDescription()
+ .getBuildOptions();
+ HashMap map = new HashMap();
+ map.put("FrameworkPlatformDescription", doc);
+ SurfaceAreaQuery.setDoc(map);
+ //
+ // Parse all list modules SA
+ //
+ parseModuleSAFiles();
+ SurfaceAreaQuery.setDoc(map);
+ } catch (Exception e) {
+ throw new BuildException("Load FPD file [" + fpdFilename.getPath()
+ + "] error. \n" + e.getMessage());
+ }
+ }
+
+ /**
+ Parse all modules listed in FPD file.
+ **/
+ private void parseModuleSAFiles() {
+ ModuleSADocument.ModuleSA[] moduleSAs = SurfaceAreaQuery
+ .getFpdModules();
+ //
+ // For every Module lists in FPD file.
+ //
+ for (int i = 0; i < moduleSAs.length; i++) {
+ String defaultFv = "NULL";
+ String defaultArch = "IA32";
+ String baseName = moduleSAs[i].getModuleName();
+ if (baseName == null) {
+ System.out.println("Warning: Module Name is not specified.");
+ continue;
+ }
+ String fvBinding = moduleSAs[i].getFvBinding();
+ //
+ // If the module do not specify any FvBinding, use the default value.
+ // Else update the default FvBinding value to this value.
+ //
+ if (fvBinding == null) {
+ fvBinding = defaultFv;
+ }
+ else {
+ defaultFv = fvBinding;
+ }
+ String arch;
+ //
+ // If the module do not specify any Arch, use the default value.
+ // Else update the default Arch value to this value.
+ //
+ if (moduleSAs[i].getArch() == null ){
+ arch = defaultArch;
+ }
+ else {
+ arch = moduleSAs[i].getArch().toString();
+ defaultArch = arch;
+ }
+ Map msaMap = GlobalData.getNativeMsa(baseName);
+ Map mbdMap = GlobalData.getNativeMbd(baseName);
+ Map map = new HashMap();
+ //
+ // Whether the Module SA has parsed before or not
+ //
+ if (!GlobalData.isModuleParsed(baseName)) {
+ OverrideProcess op = new OverrideProcess();
+ //
+ // using overriding rules
+ // Here we can also put platform Build override
+ //
+ map = op.override(mbdMap, msaMap);
+ Map overrideMap = op.override(
+ getPlatformOverrideInfo(moduleSAs[i]),
+ OverrideProcess.deal(map));
+ GlobalData.registerModule(baseName, overrideMap);
+ } else {
+ map = GlobalData.getDoc(baseName);
+ }
+ SurfaceAreaQuery.setDoc(map);
+ String guid = SurfaceAreaQuery.getModuleGuid();
+ String componentType = SurfaceAreaQuery.getComponentType();
+ FpdModuleIdentification moduleId = new FpdModuleIdentification(baseName, guid, arch);
+ updateFvs(fvBinding, moduleId);
+ outfiles.put(moduleId, "${PLATFORM_DIR}" + File.separatorChar + "Build" + File.separatorChar
+ + "${TARGET}" + File.separatorChar + arch
+ + File.separatorChar + guid + "-" + baseName
+ + getSuffix(componentType));
+ }
+ }
+
+ /**
+ Add the current module to corresponding FV.
+
+ @param fvName current FV name
+ @param moduleName current module identification
+ **/
+ private void updateFvs(String fvName, FpdModuleIdentification moduleName) {
+ String upcaseFvName = fvName.toUpperCase();
+ if (fvs.containsKey(upcaseFvName)) {
+ Set set = fvs.get(upcaseFvName);
+ set.add(moduleName);
+ } else {
+ Set set = new LinkedHashSet();
+ set.add(moduleName);
+ fvs.put(upcaseFvName, set);
+ }
+ }
+
+ /**
+ Get the suffix based on component type. Current relationship are listed:
+
+
+
+ @param componentType component type
+ @return
+ @throws BuildException
+ If component type is null
+ **/
+ public static String getSuffix(String componentType) throws BuildException{
+ if (componentType == null) {
+ throw new BuildException("Component type is not specified.");
+ }
+ String str = ".DXE";
+ if (componentType.equalsIgnoreCase("APPLICATION")) {
+ str = ".APP";
+ } else if (componentType.equalsIgnoreCase("SEC")) {
+ str = ".SEC";
+ } else if (componentType.equalsIgnoreCase("PEI_CORE")) {
+ str = ".PEI";
+ } else if (componentType.equalsIgnoreCase("PE32_PEIM")) {
+ str = ".PEI";
+ } else if (componentType.equalsIgnoreCase("RELOCATABLE_PEIM")) {
+ str = ".PEI";
+ } else if (componentType.equalsIgnoreCase("PIC_PEIM")) {
+ str = ".PEI";
+ } else if (componentType.equalsIgnoreCase("COMBINED_PEIM_DRIVER")) {
+ str = ".PEI";
+ } else if (componentType.equalsIgnoreCase("TE_PEIM")) {
+ str = ".PEI";
+ } else if (componentType.equalsIgnoreCase("LOGO")) {
+ str = ".FFS";
+ }
+ return str;
+ }
+
+ /**
+ Parse module surface are info described in FPD file and put them into map.
+
+ @param sa module surface area info descibed in FPD file
+ @return map list with top level elements
+ **/
+ private Map getPlatformOverrideInfo(
+ ModuleSADocument.ModuleSA sa) {
+ Map map = new HashMap();
+ map.put("SourceFiles", sa.getSourceFiles());
+ map.put("Includes", sa.getIncludes());
+ map.put("Libraries", sa.getLibraries());
+ map.put("Protocols", sa.getProtocols());
+ map.put("Events", sa.getEvents());
+ map.put("Hobs", sa.getHobs());
+ map.put("PPIs", sa.getPPIs());
+ map.put("Variables", sa.getVariables());
+ map.put("BootModes", sa.getBootModes());
+ map.put("SystemTables", sa.getSystemTables());
+ map.put("DataHubs", sa.getDataHubs());
+ map.put("Formsets", sa.getFormsets());
+ map.put("Guids", sa.getGuids());
+ map.put("Externs", sa.getExterns());
+ map.put("BuildOptions", platformBuildOptions);
+ return map;
+ }
+
+ /**
+ Generate build.out.xml file.
+
+ @throws BuildException
+ build.out.xml XML document create error
+ **/
+ private void genBuildFile() throws BuildException {
+ DocumentBuilderFactory domfac = DocumentBuilderFactory.newInstance();
+ try {
+ DocumentBuilder dombuilder = domfac.newDocumentBuilder();
+ Document document = dombuilder.newDocument();
+ Comment rootComment = document.createComment(info);
+ //
+ // create root element and its attributes
+ //
+ Element root = document.createElement("project");
+ root.setAttribute("name", getProject().getProperty("PLATFORM"));
+ root.setAttribute("default", "main");
+ root.setAttribute("basedir", ".");
+ //
+ // element for External ANT tasks
+ //
+ root.appendChild(document.createComment("Apply external ANT tasks"));
+ Element ele = document.createElement("taskdef");
+ ele.setAttribute("resource", "GenBuild.tasks");
+ root.appendChild(ele);
+
+ ele = document.createElement("taskdef");
+ ele.setAttribute("resource", "frameworktasks.tasks");
+ root.appendChild(ele);
+
+ ele = document.createElement("property");
+ ele.setAttribute("environment", "env");
+ root.appendChild(ele);
+ //
+ // Default Target
+ //
+ root.appendChild(document.createComment("Default target"));
+ ele = document.createElement("target");
+ ele.setAttribute("name", "main");
+ ele.setAttribute("depends", "modules, fvs");
+ root.appendChild(ele);
+ //
+ // Modules Target
+ //
+ root.appendChild(document.createComment("Modules target"));
+ ele = document.createElement("target");
+ ele.setAttribute("name", "modules");
+
+ Set set = outfiles.keySet();
+ Iterator iter = set.iterator();
+ while (iter.hasNext()) {
+ FpdModuleIdentification moduleId = (FpdModuleIdentification) iter.next();
+ String baseName = moduleId.getBaseName();
+ Element moduleEle = document.createElement("ant");
+ moduleEle.setAttribute("antfile", GlobalData
+ .getModulePath(baseName)
+ + File.separatorChar + "build.xml");
+ moduleEle.setAttribute("target", baseName);
+ //
+ // ARCH
+ //
+ Element property = document.createElement("property");
+ property.setAttribute("name", "ARCH");
+ property.setAttribute("value", moduleId.getArch());
+ moduleEle.appendChild(property);
+ //
+ // PACKAGE_DIR
+ //
+ property = document.createElement("property");
+ property.setAttribute("name", "PACKAGE_DIR");
+ property.setAttribute("value", "${WORKSPACE_DIR}" + File.separatorChar
+ + GlobalData.getPackagePathForModule(baseName));
+ moduleEle.appendChild(property);
+ //
+ // PACKAGE
+ //
+ property = document.createElement("property");
+ property.setAttribute("name", "PACKAGE");
+ property.setAttribute("value", GlobalData
+ .getPackageNameForModule(baseName));
+ moduleEle.appendChild(property);
+ ele.appendChild(moduleEle);
+ }
+ root.appendChild(ele);
+ //
+ // FVS Target
+ //
+ root.appendChild(document.createComment("FVs target"));
+ ele = document.createElement("target");
+ ele.setAttribute("name", "fvs");
+
+ String[] validFv = SurfaceAreaQuery.getFpdValidImageNames();
+ for (int i = 0; i < validFv.length; i++) {
+ String inputFile = FV_OUTPUT_DIR + "" + File.separatorChar
+ + validFv[i].toUpperCase() + ".inf";
+ Element fvEle = document.createElement("genfvimage");
+ fvEle.setAttribute("infFile", inputFile);
+ ele.appendChild(fvEle);
+ Element moveEle = document.createElement("move");
+ moveEle.setAttribute("file", validFv[i].toUpperCase() + ".fv");
+ moveEle.setAttribute("todir", FV_OUTPUT_DIR);
+ ele.appendChild(moveEle);
+ }
+ root.appendChild(ele);
+
+ boolean isUnified = false;
+ BuildOptionsDocument.BuildOptions buildOptions = (BuildOptionsDocument.BuildOptions)platformBuildOptions;
+ if (buildOptions.getOutputDirectory() != null){
+ if (buildOptions.getOutputDirectory().getIntermediateDirectories() != null){
+ if (buildOptions.getOutputDirectory().getIntermediateDirectories().toString().equalsIgnoreCase("UNIFIED")){
+ isUnified = true;
+ }
+ }
+ }
+ //
+ // Clean Target
+ //
+ root.appendChild(document.createComment("Clean target"));
+ ele = document.createElement("target");
+ ele.setAttribute("name", "clean");
+
+ if (isUnified) {
+ Element cleanEle = document.createElement("delete");
+ cleanEle.setAttribute("includeemptydirs", "true");
+ Element filesetEle = document.createElement("fileset");
+ filesetEle.setAttribute("dir", getProject().getProperty("PLATFORM_DIR") + File.separatorChar + "Build" + File.separatorChar + "${TARGET}");
+ filesetEle.setAttribute("includes", "**/OUTPUT/**");
+ cleanEle.appendChild(filesetEle);
+ ele.appendChild(cleanEle);
+ }
+ else {
+ set = outfiles.keySet();
+ iter = set.iterator();
+ while (iter.hasNext()) {
+ FpdModuleIdentification moduleId = (FpdModuleIdentification) iter.next();
+ String baseName = moduleId.getBaseName();
+
+ Element ifEle = document.createElement("if");
+ Element availableEle = document.createElement("available");
+ availableEle.setAttribute("file", GlobalData
+ .getModulePath(baseName)
+ + File.separatorChar + "build.xml");
+ ifEle.appendChild(availableEle);
+ Element elseEle = document.createElement("then");
+
+ Element moduleEle = document.createElement("ant");
+ moduleEle.setAttribute("antfile", GlobalData
+ .getModulePath(baseName)
+ + File.separatorChar + "build.xml");
+ moduleEle.setAttribute("target", baseName + "_clean");
+ //
+ // ARCH
+ //
+ Element property = document.createElement("property");
+ property.setAttribute("name", "ARCH");
+ property.setAttribute("value", moduleId.getArch());
+ moduleEle.appendChild(property);
+ //
+ // PACKAGE_DIR
+ //
+ property = document.createElement("property");
+ property.setAttribute("name", "PACKAGE_DIR");
+ property.setAttribute("value", "${WORKSPACE_DIR}" + File.separatorChar
+ + GlobalData.getPackagePathForModule(baseName));
+ moduleEle.appendChild(property);
+ //
+ // PACKAGE
+ //
+ property = document.createElement("property");
+ property.setAttribute("name", "PACKAGE");
+ property.setAttribute("value", GlobalData
+ .getPackageNameForModule(baseName));
+ moduleEle.appendChild(property);
+ elseEle.appendChild(moduleEle);
+ ifEle.appendChild(elseEle);
+ ele.appendChild(ifEle);
+ }
+ }
+ root.appendChild(ele);
+ //
+ // Deep Clean Target
+ //
+ root.appendChild(document.createComment("Clean All target"));
+ ele = document.createElement("target");
+ ele.setAttribute("name", "cleanall");
+
+ if (isUnified) {
+ Element cleanAllEle = document.createElement("delete");
+ cleanAllEle.setAttribute("dir", getProject().getProperty("PLATFORM_DIR") + File.separatorChar + "Build" + File.separatorChar + "${TARGET}");
+ ele.appendChild(cleanAllEle);
+ }
+ else {
+ set = outfiles.keySet();
+ iter = set.iterator();
+ while (iter.hasNext()) {
+ FpdModuleIdentification moduleId = (FpdModuleIdentification) iter.next();
+ String baseName = moduleId.getBaseName();
+
+ Element ifEle = document.createElement("if");
+ Element availableEle = document.createElement("available");
+ availableEle.setAttribute("file", GlobalData
+ .getModulePath(baseName)
+ + File.separatorChar + "build.xml");
+ ifEle.appendChild(availableEle);
+ Element elseEle = document.createElement("then");
+
+ Element moduleEle = document.createElement("ant");
+ moduleEle.setAttribute("antfile", GlobalData
+ .getModulePath(baseName)
+ + File.separatorChar + "build.xml");
+ moduleEle.setAttribute("target", baseName + "_cleanall");
+ //
+ // ARCH
+ //
+ Element property = document.createElement("property");
+ property.setAttribute("name", "ARCH");
+ property.setAttribute("value", moduleId.getArch());
+ moduleEle.appendChild(property);
+ //
+ // PACKAGE_DIR
+ //
+ property = document.createElement("property");
+ property.setAttribute("name", "PACKAGE_DIR");
+ property.setAttribute("value", "${WORKSPACE_DIR}" + File.separatorChar
+ + GlobalData.getPackagePathForModule(baseName));
+ moduleEle.appendChild(property);
+ //
+ // PACKAGE
+ //
+ property = document.createElement("property");
+ property.setAttribute("name", "PACKAGE");
+ property.setAttribute("value", GlobalData
+ .getPackageNameForModule(baseName));
+ moduleEle.appendChild(property);
+ elseEle.appendChild(moduleEle);
+ ifEle.appendChild(elseEle);
+ ele.appendChild(ifEle);
+ }
+ }
+ root.appendChild(ele);
+
+ document.appendChild(rootComment);
+ document.appendChild(root);
+ //
+ // Prepare the DOM document for writing
+ //
+ Source source = new DOMSource(document);
+ //
+ // Prepare the output file
+ //
+ File file = new File(getProject().getProperty("PLATFORM_DIR")
+ + File.separatorChar + "build.out.xml");
+ //
+ // generate all directory path
+ //
+ (new File(file.getParent())).mkdirs();
+ Result result = new StreamResult(file);
+ //
+ // Write the DOM document to the file
+ //
+ Transformer xformer = TransformerFactory.newInstance()
+ .newTransformer();
+ xformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
+ xformer.setOutputProperty(OutputKeys.INDENT, "yes");
+ xformer.transform(source, result);
+ } catch (Exception ex) {
+ throw new BuildException("Generate build.out.xml failed. \n" + ex.getMessage());
+ }
+ }
+
+ /**
+ Add a property.
+
+ @param p property
+ **/
+ public void addProperty(Property p) {
+ properties.addElement(p);
+ }
+
+ /**
+ Get FPD file name.
+
+ @return FPD file name.
+ **/
+ public File getFpdFilename() {
+ return fpdFilename;
+ }
+
+ /**
+ Set FPD file name.
+
+ @param fpdFilename FPD file name
+ **/
+ public void setFpdFilename(File fpdFilename) {
+ this.fpdFilename = fpdFilename;
+ }
+
+ public File getGuiddatabase() {
+ return guiddatabase;
+ }
+
+ public void setGuiddatabase(File guiddatabase) {
+ this.guiddatabase = guiddatabase;
+ }
+
+ public void collectPCDInformation() {
+ CollectPCDAction collectAction = new CollectPCDAction ();
+ //
+ // Set memory database log file path. It should be put into same directory with FPD file.
+ //
+ GlobalData.getPCDMemoryDBManager().setLogFileName(
+ fpdFilename.getPath() + ".PCDMemroyDatabaseLog.txt"
+ );
+ //
+ // Collect all PCD information from FPD to MSA, and get help information from SPD.
+ // These all information will be stored into memory database for future usage such
+ // as autogen.
+ //
+ try {
+ collectAction.perform (
+ getProject().getProperty("WORKSPACE_DIR"),
+ fpdFilename.getPath(),
+ ActionMessage.NULL_MESSAGE_LEVEL
+ );
+ } catch (Exception exp) {
+ throw new BuildException (exp.getMessage());
+ }
+ }
+}
diff --git a/Tools/Source/GenBuild/org/tianocore/build/global/DpFile.java b/Tools/Source/GenBuild/org/tianocore/build/global/DpFile.java
new file mode 100644
index 0000000000..78cde75604
--- /dev/null
+++ b/Tools/Source/GenBuild/org/tianocore/build/global/DpFile.java
@@ -0,0 +1,129 @@
+/** @file
+This file is used to define class which represents dependency file in ANT task
+
+Copyright (c) 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+package org.tianocore.build.global;
+
+import org.apache.tools.ant.types.DataType;
+import org.apache.tools.ant.types.Path;
+
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.LineNumberReader;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ DpFile is a ANT DataType which can be used to specify dependency files from
+ a file list file, from file list string separated by space, comma or semi-comma,
+ or from file name with absolute path
+ **/
+public class DpFile extends DataType {
+ ///
+ /// keep the list of files path
+ ///
+ private List nameList = new ArrayList();
+
+ /**
+ Empty constructor just in case
+ **/
+ public DpFile() {
+ }
+
+ /**
+ Empty execute method of ANT task, just in case
+ **/
+ public void execute() {
+ }
+
+ /**
+ Standard set method of ANT task/datatype, for ListFile attribute. It simply
+ fetch one file path a line from specified list file, and put them in nameList
+
+ @param fileListFile file which contains a file list, one file a line,
+ with full path
+ **/
+ public void setListFile(String fileListFile) {
+ File file = new File(fileListFile);
+ if (!file.exists()) {
+ return;
+ }
+
+ try {
+ FileReader fileReader = new FileReader(file);
+ LineNumberReader lineReader = new LineNumberReader(fileReader);
+
+ String filePath = null;
+ while ((filePath = lineReader.readLine()) != null) {
+ filePath = filePath.trim();
+ if (filePath.length() == 0) {
+ continue;
+ }
+ this.nameList.add(filePath);
+ }
+
+ lineReader.close();
+ fileReader.close();
+ } catch (IOException e) {
+ System.out.println (e.getMessage());
+ }
+ }
+
+ /**
+ Standard set method of ANT task/datatype, for List attribute.
+
+ @param fileList string with file pathes separated by space, comma,
+ or semi-comma
+ **/
+ public void setList(String fileList) {
+ //
+ // space, comma or semi-comma separated files list
+ //
+ Pattern pattern = Pattern.compile("([^ ,;\n\r]++)[ ,;\n\r]*+");
+ Matcher matcher = pattern.matcher(fileList);
+
+ while (matcher.find()) {
+ //
+ // keep each file name before " ,;\n\r"
+ //
+ String filePath = fileList.substring(matcher.start(1), matcher.end(1)).trim();
+ if (filePath.length() == 0) {
+ continue;
+ }
+ nameList.add(Path.translateFile(filePath));
+ }
+
+ }
+
+ /**
+ Standard set method of ANT task/datatype, for Name attribute.
+
+ @param fileName string of a file full path
+ **/
+ public void setName(String fileName) {
+ this.nameList.add(fileName);
+ }
+
+ /**
+ Fetch the file name list.
+
+ @returns A string list which contains file names specified to check dependnecy
+ **/
+ public List getList() {
+ return this.nameList;
+ }
+}
+
+
diff --git a/Tools/Source/GenBuild/org/tianocore/build/global/DpFileList.java b/Tools/Source/GenBuild/org/tianocore/build/global/DpFileList.java
new file mode 100644
index 0000000000..8b4b4a0add
--- /dev/null
+++ b/Tools/Source/GenBuild/org/tianocore/build/global/DpFileList.java
@@ -0,0 +1,50 @@
+/** @file
+This file is used to nest elements corresponding to DpFile
+
+Copyright (c) 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+package org.tianocore.build.global;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ DpFileList is a container of Dpfile at the point of ANT task/datatype
+ **/
+public class DpFileList {
+ ///
+ /// Keep all the file names from all nested DpFile
+ ///
+ List nameList = new ArrayList();
+
+ /**
+ Empty constructor just in case
+ **/
+ public DpFileList() {
+ }
+
+ /**
+ Empty execute method of ANT task. ANT will call it even we don't need it.
+ **/
+ public void execute() {
+ }
+
+ /**
+ Standard add method of ANT task, for nested DpFile type of elements. It just
+ simply fetch the files list from DpFile and put them in its own nameList.
+
+ @param f a DpFile object which will be instantiated by ANT
+ **/
+ public void addConfiguredFile(DpFile f) {
+ this.nameList.addAll(f.getList());
+ }
+}
+
diff --git a/Tools/Source/GenBuild/org/tianocore/build/global/GlobalData.java b/Tools/Source/GenBuild/org/tianocore/build/global/GlobalData.java
new file mode 100644
index 0000000000..611758a4ef
--- /dev/null
+++ b/Tools/Source/GenBuild/org/tianocore/build/global/GlobalData.java
@@ -0,0 +1,637 @@
+/** @file
+ GlobalData class.
+
+ GlobalData provide initializing, instoring, querying and update global data.
+ It is a bridge to intercommunicate between multiple component, such as AutoGen,
+ PCD and so on.
+
+Copyright (c) 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+**/
+package org.tianocore.build.global;
+
+import java.io.File;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.xmlbeans.XmlObject;
+import org.tianocore.FrameworkDatabaseDocument;
+import org.tianocore.MsaFilesDocument;
+import org.tianocore.PackageListDocument;
+import org.tianocore.PackageSurfaceAreaDocument;
+import org.tianocore.MsaHeaderDocument.MsaHeader;
+import org.tianocore.MsaLibHeaderDocument.MsaLibHeader;
+import org.tianocore.build.pcd.entity.MemoryDatabaseManager;
+import org.tianocore.build.autogen.CommonDefinition;
+import org.tianocore.build.fpd.FpdParserTask;
+
+/**
+ GlobalData provide initializing, instoring, querying and update global data.
+ It is a bridge to intercommunicate between multiple component, such as AutoGen,
+ PCD and so on.
+
+
Note that all global information are initialized incrementally. All data will
+ parse and record only it is necessary during build time.
+
+ @since GenBuild 1.0
+**/
+public class GlobalData {
+
+ ///
+ /// means no surface area information for module
+ ///
+ public static final int NO_SA = 0;
+
+ ///
+ /// means only MSA
+ ///
+ public static final int ONLY_MSA = 1;
+
+ ///
+ /// means only Library MSA
+ ///
+ public static final int ONLY_LIBMSA = 2;
+
+ ///
+ /// means both MSA and MBD
+ ///
+ public static final int MSA_AND_MBD = 3;
+
+ ///
+ /// means both Library MSA and Library MBD
+ ///
+ public static final int LIBMSA_AND_LIBMBD = 4;
+
+ ///
+ /// Be used to ensure Global data will be initialized only once.
+ ///
+ public static boolean globalFlag = false;
+
+ ///
+ /// Record current WORKSPACE Directory
+ ///
+ private static String workspaceDir = "";
+
+ ///
+ /// Two columns: Package Name (Key), Package Path(ralative to WORKSPACE)
+ ///
+ private static final Map packageInfo = new HashMap();
+
+ ///
+ /// spdTable
+ /// Key: Package Name, Value: SPD detail info
+ ///
+ private static final Map spdTable = new HashMap();
+
+ ///
+ /// Three columns:
+ /// 1. Module Name | BaseName (Key)
+ /// 2. Module Path + Msa file name (relative to Package)
+ /// 3. Package Name (This module belong to which package)
+ ///
+ private static final Map moduleInfo = new HashMap();
+
+ ///
+ /// List all libraries for current build module
+ /// Key: Library BaseName, Value: output library path+name
+ ///
+ private static final Map libraries = new HashMap();
+
+ ///
+ /// Store every module's relative library instances BaseName
+ /// Key: Module BaseName, Value: All library instances module depends on.
+ ///
+ private static final Map > moduleLibraryMap = new HashMap >();
+
+ ///
+ /// Key: Module BaseName, Value: original MSA info
+ ///
+ private static final Map > nativeMsa = new HashMap >();
+
+ ///
+ /// Key: Module BaseName, Value: original MBD info
+ ///
+ private static final Map > nativeMbd = new HashMap >();
+
+ ///
+ /// Two columns: Module Name or Base Name as Key
+ /// Value is a HashMap with overridden data from MSA/MBD or/and Platform
+ ///
+ private static final Map > parsedModules = new HashMap >();
+
+ ///
+ /// List all built Module; Value is Module BaseName + Arch. TBD
+ ///
+ private static final Set builtModules = new HashSet();
+
+ ///
+ /// Library instance information table which recored the library and it's
+ /// constructor and distructor function
+ ///
+ private static final Map libInstanceInfo = new HashMap();
+
+ ///
+ /// PCD memory database stored all PCD information which collected from FPD,MSA and SPD.
+ ///
+ private static final MemoryDatabaseManager pcdDbManager = new MemoryDatabaseManager();
+
+ /**
+ Query the module's absolute path with module base name.
+
+ @param moduleName the base name of the module
+ @return the absolute module path
+ **/
+ public synchronized static String getModulePath(String moduleName) {
+ String[] info = moduleInfo.get(moduleName);
+ String packagePath = (String) packageInfo.get(info[1]);
+ File convertFile = new File(workspaceDir + File.separatorChar + packagePath + File.separatorChar + info[0]);
+ return convertFile.getParent();
+ }
+
+ /**
+ Query the module's absolute MSA file path with module base name.
+
+ @param moduleName the base name of the module
+ @return the absolute MSA file name
+ @throws BuildException
+ Base name is not registered in any SPD files
+ **/
+ private synchronized static String getMsaFilename(String moduleName) throws BuildException {
+ String[] info = moduleInfo.get(moduleName);
+ if (info == null) {
+ throw new BuildException("Module base name [" + moduleName + "] can't found in all SPD.");
+ }
+ String packagePath = (String) packageInfo.get(info[1]);
+ File convertFile = new File(workspaceDir + File.separatorChar + packagePath + File.separatorChar + info[0]);
+ return convertFile.getPath();
+ }
+
+ /**
+ Query the module's absolute MBD file path with module base name.
+
+ @param moduleName the base name of the module
+ @return the absolute MBD file name
+ @throws BuildException
+ Base name is not registered in any SPD files
+ **/
+ private synchronized static String getMbdFilename(String moduleName) throws BuildException {
+ String[] info = moduleInfo.get(moduleName);
+ if (info == null) {
+ throw new BuildException("Info: Module base name [" + moduleName + "] can't found in all SPD.");
+ }
+ String packagePath = (String) packageInfo.get(info[1]);
+ File convertFile = new File(workspaceDir + File.separatorChar + packagePath + File.separatorChar + info[0]);
+ return convertFile.getPath().substring(0, convertFile.getPath().length() - 4) + ".mbd";
+ }
+
+ /**
+ Get the current WORKSPACE Directory.
+ @return current workspace directory
+ **/
+ public synchronized static String getWorkspacePath() {
+ return workspaceDir;
+ }
+
+ /**
+ Query package relative path to WORKSPACE_DIR with package name.
+
+ @param packageName the name of the package
+ @return the path relative to WORKSPACE_DIR
+ **/
+ public synchronized static String getPackagePath(String packageName) {
+ return (String) packageInfo.get(packageName);
+ }
+
+ /**
+ Query package (which the module belongs to) relative path to WORSPACE_DIR.
+
+ @param moduleName the base name of the module
+ @return the relative path to WORKSPACE_DIR of the package which the module belongs to
+ **/
+ public synchronized static String getPackagePathForModule(String moduleName) {
+ String[] info = moduleInfo.get(moduleName);
+ String packagePath = (String) packageInfo.get(info[1]);
+ return packagePath;
+ }
+
+ /**
+ Query the package name which the module belongs to with the module's base name.
+
+ @param moduleName the base name of the module
+ @return the package name which the module belongs to
+ **/
+ public synchronized static String getPackageNameForModule(String moduleName) {
+ return moduleInfo.get(moduleName)[1];
+ }
+
+ /**
+ Parse framework database (DB) and all SPD files listed in DB to initialize
+ the environment for next build. This method will only be executed only once
+ in the whole build process.
+
+ @param workspaceDatabaseFile the file name of framework database
+ @param workspaceDir current workspace directory path
+ @throws BuildException
+ Framework Dababase or SPD or MSA file is not valid
+ **/
+ public synchronized static void initInfo(String workspaceDatabaseFile, String workspaceDir) throws BuildException {
+ if (globalFlag) {
+ return;
+ }
+ globalFlag = true;
+ GlobalData.workspaceDir = workspaceDir;
+ File dbFile = new File(workspaceDir + File.separatorChar + workspaceDatabaseFile);
+ try {
+ FrameworkDatabaseDocument db = (FrameworkDatabaseDocument) XmlObject.Factory.parse(dbFile);
+ List packages = db.getFrameworkDatabase().getPackageList()
+ .getPackageList();
+ Iterator iter = packages.iterator();
+ while (iter.hasNext()) {
+ PackageListDocument.PackageList.Package packageItem = (PackageListDocument.PackageList.Package) iter
+ .next();
+ String name = packageItem.getPackageNameArray(0).getStringValue();
+ String path = packageItem.getPathArray(0).getStringValue();
+ packageInfo.put(name, path);
+ File spdFile = new File(workspaceDir + File.separatorChar + path + File.separatorChar + name + ".spd");
+ initPackageInfo(spdFile.getPath(), name);
+ //
+ // SPD Parse.
+ //
+ PackageSurfaceAreaDocument spdDoc = (PackageSurfaceAreaDocument) XmlObject.Factory.parse(spdFile);
+ Spd spd = new Spd(spdDoc, path);
+ spdTable.put(name, spd);
+
+ }
+ } catch (Exception e) {
+ throw new BuildException("Parse workspace Database [" + dbFile.getPath() + "] Error.\n" + e.getMessage());
+ }
+ }
+
+ /**
+ Parse every MSA files, get base name from MSA Header. And record those
+ values to ModuleInfo.
+
+ @param packageFilename the file name of the package
+ @param packageName the name of the package
+ @throws BuildException
+ SPD or MSA file is not valid
+ **/
+ private synchronized static void initPackageInfo(String packageFilename, String packageName) throws BuildException {
+ File packageFile = new File(packageFilename);
+ try {
+ PackageSurfaceAreaDocument spd = (PackageSurfaceAreaDocument) XmlObject.Factory.parse(packageFile);
+ List msasList = spd.getPackageSurfaceArea().getMsaFiles()
+ .getMsaFileList();
+ Iterator msasIter = msasList.iterator();
+ while (msasIter.hasNext()) {
+ MsaFilesDocument.MsaFiles.MsaFile msas = (MsaFilesDocument.MsaFiles.MsaFile) msasIter.next();
+ String msaFilename = msas.getFilename().getStringValue();
+ File msaFile = new File(workspaceDir + File.separatorChar + GlobalData.getPackagePath(packageName)
+ + File.separatorChar + msaFilename);
+ SurfaceAreaParser surfaceAreaParser = new SurfaceAreaParser();
+ Map map = surfaceAreaParser.parseFile(msaFile);
+ String baseName = "";
+ XmlObject header = null;
+ if ((header = map.get("MsaHeader")) != null) {
+ baseName = ((MsaHeader) header).getBaseName().getStringValue();
+ } else if ((header = map.get("MsaLibHeader")) != null) {
+ baseName = ((MsaLibHeader) header).getBaseName().getStringValue();
+ } else {
+ continue;
+ }
+ nativeMsa.put(baseName, map);
+ String[] info = { msaFilename, packageName };
+ moduleInfo.put(baseName, info);
+ }
+ } catch (Exception e) {
+ throw new BuildException("Parse package description file [" + packageFile.getPath() + "] Error.\n"
+ + e.getMessage());
+ }
+ }
+
+ /**
+ Query the libraries which the module depends on.
+
+ @param moduleName the base name of the module
+ @return the libraries which the module depends on
+ **/
+ public synchronized static String[] getModuleLibrary(String moduleName) {
+ Set set = moduleLibraryMap.get(moduleName);
+ return set.toArray(new String[set.size()]);
+ }
+
+ /**
+ Register module's library list which it depends on for later use.
+
+ @param moduleName the base name of the module
+ @param libraryList the libraries which the module depends on
+ **/
+ public synchronized static void addModuleLibrary(String moduleName, Set libraryList) {
+ moduleLibraryMap.put(moduleName, libraryList);
+ }
+
+ /**
+ Query the library absolute file name with library name.
+
+ @param library the base name of the library
+ @return the library absolute file name
+ **/
+ public synchronized static String getLibrary(String library) {
+ return libraries.get(library);
+ }
+
+ /**
+ Register library absolute file name for later use.
+
+ @param library the base name of the library
+ @param resultPath the library absolute file name
+ **/
+ public synchronized static void addLibrary(String library, String resultPath) {
+ libraries.put(library, resultPath);
+ }
+
+ /**
+ Whether the module with ARCH has built in the previous build.
+
+ @param moduleName the base name of the module
+ @param arch current build ARCH
+ @return true if the module has built in previous, otherwise return false
+ **/
+ public synchronized static boolean isModuleBuilt(String moduleName, String arch) {
+ return builtModules.contains(moduleName + "-" + arch);
+ }
+
+ /**
+ Register the module with ARCH has built.
+
+ @param moduleName the base name of the module
+ @param arch current build ARCH
+ **/
+ public synchronized static void registerBuiltModule(String moduleName, String arch) {
+ builtModules.add(moduleName + "-" + arch);
+ }
+
+ /**
+ Whether the module's surface area has parsed in the previous build.
+
+ @param moduleName the base name of the module
+ @return true if the module's surface area has parsed in previous, otherwise
+ return false
+ **/
+ public synchronized static boolean isModuleParsed(String moduleName) {
+ return parsedModules.containsKey(moduleName);
+ }
+
+ /**
+ Query overrided module surface area information. If current is Package
+ or Platform build, also include the information from FPD file.
+
+
Note that surface area parsing is incremental. That means the method will
+ only to parse the MSA and MBD files when never parsed before.
+
+ @param moduleName the base name of the module
+ @return the overrided module surface area information
+ @throws BuildException
+ MSA or MBD is not valid
+ **/
+ public synchronized static Map getDoc(String moduleName) throws BuildException {
+ if (parsedModules.containsKey(moduleName)) {
+ return parsedModules.get(moduleName);
+ }
+ Map msaMap = getNativeMsa(moduleName);
+ Map mbdMap = getNativeMbd(moduleName);
+ OverrideProcess op = new OverrideProcess();
+ Map map = op.override(mbdMap, msaMap);
+ //
+ // IF IT IS A PALTFORM BUILD, OVERRIDE FROM PLATFORM
+ //
+ if (FpdParserTask.platformBuildOptions != null) {
+ Map platformMap = new HashMap();
+ platformMap.put("BuildOptions", FpdParserTask.platformBuildOptions);
+ Map overrideMap = op.override(platformMap, OverrideProcess.deal(map));
+ GlobalData.registerModule(moduleName, overrideMap);
+ return overrideMap;
+ } else {
+ parsedModules.put(moduleName, map);
+ return map;
+ }
+ }
+
+ /**
+ Query the native MSA information with module base name.
+
+
Note that MSA parsing is incremental. That means the method will
+ only to parse the MSA files when never parsed before.
+
+ @param moduleName the base name of the module
+ @return the native MSA information
+ @throws BuildException
+ MSA file is not valid
+ **/
+ public synchronized static Map getNativeMsa(String moduleName) throws BuildException {
+ if (nativeMsa.containsKey(moduleName)) {
+ return nativeMsa.get(moduleName);
+ }
+ String msaFilename = getMsaFilename(moduleName);
+ File msaFile = new File(msaFilename);
+ if (!msaFile.exists()) {
+ throw new BuildException("Info: Surface Area file [" + msaFile.getPath() + "] can't found.");
+ }
+ SurfaceAreaParser surfaceAreaParser = new SurfaceAreaParser();
+ Map map = surfaceAreaParser.parseFile(msaFile);
+ nativeMsa.put(moduleName, map);
+ return map;
+ }
+
+ /**
+ Query the native MBD information with module base name.
+
+
Note that MBD parsing is incremental. That means the method will
+ only to parse the MBD files when never parsed before.
+
+ @param moduleName the base name of the module
+ @return the native MBD information
+ @throws BuildException
+ MBD file is not valid
+ **/
+ public synchronized static Map getNativeMbd(String moduleName) throws BuildException {
+ if (nativeMbd.containsKey(moduleName)) {
+ return nativeMbd.get(moduleName);
+ }
+ String mbdFilename = getMbdFilename(moduleName);
+ File mbdFile = new File(mbdFilename);
+ if (!mbdFile.exists()) {
+ throw new BuildException("Info: Surface Area file [" + mbdFile.getPath() + "] can't found.");
+ }
+ SurfaceAreaParser surfaceAreaParser = new SurfaceAreaParser();
+ Map map = surfaceAreaParser.parseFile(mbdFile);
+ nativeMbd.put(moduleName, map);
+ return map;
+ }
+
+ /**
+ Register module overrided surface area information. If has existed, then update.
+
+ @param moduleName the base name of the module
+ @param map the overrided surface area information
+ **/
+ public synchronized static void registerModule(String moduleName, Map map) {
+ parsedModules.put(moduleName, map);
+ }
+
+ /**
+ *
+ * @param protocolName
+ * @return
+ */
+ public synchronized static String[] getProtocolInfoGuid(String protocolName) {
+ Set set = spdTable.keySet();
+ Iterator iter = set.iterator();
+ String[] cNameGuid = null;
+
+ while (iter.hasNext()) {
+ Spd spd = (Spd) spdTable.get(iter.next());
+ cNameGuid = spd.getProtocolNameGuidArray(protocolName);
+ if (cNameGuid != null) {
+ break;
+ }
+ }
+ return cNameGuid;
+ }
+
+ public synchronized static String[] getPpiInfoGuid(String ppiName) {
+ Set set = spdTable.keySet();
+ Iterator iter = set.iterator();
+ String[] cNameGuid = null;
+
+ while (iter.hasNext()) {
+ Spd spd = (Spd) spdTable.get(iter.next());
+ cNameGuid = spd.getPpiCnameGuidArray(ppiName);
+
+ if (cNameGuid != null) {
+ break;
+ }
+ }
+ return cNameGuid;
+ }
+
+ /**
+ *
+ * @param guidName
+ * @return
+ */
+ public synchronized static String[] getGuidInfoGuid(String guidName) {
+ String[] cNameGuid = null;
+ Set set = spdTable.keySet();
+ Iterator iter = set.iterator();
+
+ while (iter.hasNext()) {
+ Spd spd = (Spd) spdTable.get(iter.next());
+ cNameGuid = spd.getGuidNameArray(guidName);
+ if (cNameGuid != null) {
+ break;
+ }
+ }
+ return cNameGuid;
+ }
+
+ public synchronized static String getLibClassIncluder(String libName) {
+ String libIncluder = null;
+ Set set = spdTable.keySet();
+ Iterator iter = set.iterator();
+
+ while (iter.hasNext()) {
+ String packageName = (String) iter.next();
+ Spd spd = (Spd) spdTable.get(packageName);
+ libIncluder = spd.getLibClassIncluder(libName);
+ String packagePath = spd.packagePath;
+ if (packagePath != null) {
+ packagePath = packagePath.replace('\\', File.separatorChar);
+ packagePath = packagePath.replace('/', File.separatorChar);
+ } else {
+ packagePath = packageName;
+ }
+ if (libIncluder != null) {
+ libIncluder = libIncluder.replace('\\', File.separatorChar);
+ libIncluder = libIncluder.replace('/', File.separatorChar);
+ libIncluder = packageName + File.separatorChar + libIncluder;
+ break;
+ }
+ }
+ return libIncluder;
+ }
+
+ public synchronized static String getModuleInfoByPackageName(String packageName, String moduleType) {
+ Spd spd;
+ String includeFile = null;
+ String includeStr = "";
+ String cleanPath = "";
+
+ spd = (Spd) spdTable.get(packageName);
+ includeFile = spd.getModuleTypeIncluder(moduleType);
+ if (includeFile != null) {
+ includeFile = includeFile.replace('\\', File.separatorChar);
+ includeFile = includeFile.replace('/', File.separatorChar);
+ includeStr = CommonDefinition.include + " <" + includeStr;
+ cleanPath = spd.packagePath;
+ cleanPath = cleanPath.replace('\\', File.separatorChar);
+ cleanPath = cleanPath.replace('/', File.separatorChar);
+
+ if (cleanPath.charAt(spd.packagePath.length() - 1) != File.separatorChar) {
+ cleanPath = cleanPath + File.separatorChar;
+ }
+ includeStr = includeStr + cleanPath;
+ includeStr = includeStr + includeFile;
+ includeStr = includeStr + ">\r\n";
+ }
+
+ return includeStr;
+ }
+
+ public synchronized static void setLibInstanceInfo(String libName, String libConstructor, String libDesturctor) {
+ String[] libConsDes = new String[2];
+ libConsDes[0] = libConstructor;
+ libConsDes[1] = libDesturctor;
+
+ libInstanceInfo.put(libName, libConsDes);
+ }
+
+ public synchronized static boolean isHaveLibInstance(String libName) {
+ return libInstanceInfo.containsKey(libName);
+ }
+
+ public synchronized static String getLibInstanceConstructor(String libName) {
+ String[] libInstanceValue;
+ libInstanceValue = libInstanceInfo.get(libName);
+ if (libInstanceValue != null) {
+ return libInstanceValue[0];
+ } else {
+ return null;
+ }
+ }
+
+ public synchronized static String getLibInstanceDestructor(String libName) {
+ String[] libInstanceValue;
+ libInstanceValue = libInstanceInfo.get(libName);
+ if (libInstanceValue != null) {
+ return libInstanceValue[1];
+ } else {
+ return null;
+ }
+ }
+
+ public synchronized static MemoryDatabaseManager getPCDMemoryDBManager() {
+ return pcdDbManager;
+ }
+}
diff --git a/Tools/Source/GenBuild/org/tianocore/build/global/GlobalShare.java b/Tools/Source/GenBuild/org/tianocore/build/global/GlobalShare.java
new file mode 100644
index 0000000000..5912127a10
--- /dev/null
+++ b/Tools/Source/GenBuild/org/tianocore/build/global/GlobalShare.java
@@ -0,0 +1,178 @@
+/*++
+
+ Copyright (c) 2006, Intel Corporation
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+ Module Name:
+ ShareObject.java
+
+ Abstract:
+
+ --*/
+package org.tianocore.build.global;
+
+import java.util.*;
+
+import org.apache.tools.ant.*;
+import org.apache.tools.ant.types.DataType;
+
+public class GlobalShare extends DataType implements DynamicConfigurator {
+ private static final HashMap objStorage = new HashMap();
+
+ private DataObjectOp op;
+
+ private String objName;
+
+ private Object objInst;
+
+ private String objClassPackage = "org.tianocore";
+
+ public GlobalShare () {
+
+ }
+
+ public GlobalShare (String objName) {
+ this.objName = objName;
+ this.objInst = objStorage.get(this.objName);
+ }
+
+ public GlobalShare (String objName, Object obj) {
+ this.objName = objName;
+ this.objInst = obj;
+ objStorage.put(this.objName, this.objInst);
+ }
+
+ public Object createDynamicElement(String name) throws BuildException {
+ String className = objClassPackage + "." + name;
+ log("GlobalShare.createDynamicElement(" + name + ")",
+ Project.MSG_VERBOSE);
+ try {
+ objInst = Class.forName(className).newInstance();
+ } catch (ClassNotFoundException e) {
+ throw new BuildException("class name is not found");
+ } catch (InstantiationException e) {
+ throw new BuildException("the class cannnot be instantiated");
+ } catch (IllegalAccessException e) {
+ throw new BuildException("cannot access the class");
+ }
+
+ return objInst;
+ }
+
+ public void setDynamicAttribute(String name, String value)
+ throws BuildException {
+ log("name = " + name + " value = " + value, Project.MSG_VERBOSE);
+ throw new BuildException();
+ }
+
+ public void setName(String name) {
+ this.objName = name;
+ if (this.op != null) {
+ issueOperation();
+ }
+ }
+
+ public String getName() {
+ return this.objName;
+ }
+
+ public void setPackage(String name) {
+ log("ShareObject.setPackage(" + name + ")", Project.MSG_VERBOSE);
+ this.objClassPackage = name;
+ }
+
+ public String getPackage() {
+ return this.objClassPackage;
+ }
+
+ public void setOperation(String opName) {
+ log("ShareObject.setOperation(" + opName + ")", Project.MSG_VERBOSE);
+ this.op = DataObjectOp.formString(opName);
+
+ if (this.objName != null) {
+ issueOperation();
+ }
+ }
+
+ public String getOperation() {
+ return this.op.toString();
+ }
+
+ public void issueOperation() {
+ if (this.op == DataObjectOp.ADD) {
+
+ log("ShareObject: adding ... " + this.objName, Project.MSG_VERBOSE);
+ objStorage.put(this.objName, this.objInst);
+
+ } else if (this.op == DataObjectOp.GET) {
+
+ log("ShareObject: fetching ... " + this.objName,
+ Project.MSG_VERBOSE);
+ objInst = objStorage.get(objName);
+
+ } else if (this.op == DataObjectOp.DEL) {
+
+ log("ShareObject: removing ... " + this.objName,
+ Project.MSG_VERBOSE);
+ objInst = objStorage.remove(objName);
+
+ } else {
+ throw new BuildException("not supported operation");
+ }
+ }
+
+ public Object get() {
+ return this.objInst;
+ }
+
+ public static int getObjectNum() {
+ return objStorage.size();
+ }
+
+ public static Object add(String objName, Object obj) {
+ return objStorage.put(objName, obj);
+ }
+
+ public static Object retrieve(String objName) {
+ return objStorage.get(objName);
+ }
+
+ public static Object remove(String objName) {
+ return objStorage.remove(objName);
+ }
+
+ public static void empty() {
+ objStorage.clear();
+ }
+}
+
+class DataObjectOp {
+ private static final HashMap opMap = new HashMap();
+
+ private final String opName;
+
+ private DataObjectOp (String name) {
+ this.opName = name;
+ opMap.put(this.opName, this);
+ }
+
+ public String toString() {
+ return opName;
+ }
+
+ public static DataObjectOp formString(String opName) {
+ return opMap.get(opName);
+ }
+
+ public static final DataObjectOp ADD = new DataObjectOp("ADD");
+
+ public static final DataObjectOp GET = new DataObjectOp("GET");
+
+ public static final DataObjectOp DEL = new DataObjectOp("DEL");
+}
diff --git a/Tools/Source/GenBuild/org/tianocore/build/global/LibBuildFileGenerator.java b/Tools/Source/GenBuild/org/tianocore/build/global/LibBuildFileGenerator.java
new file mode 100644
index 0000000000..4d7e870587
--- /dev/null
+++ b/Tools/Source/GenBuild/org/tianocore/build/global/LibBuildFileGenerator.java
@@ -0,0 +1,412 @@
+/** @file
+ This file is an ANT task.
+
+ LibBuildFileGenerator task is used to generate module's build.xml file.
+
+Copyright (c) 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+package org.tianocore.build.global;
+
+import java.io.File;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+import java.util.Vector;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Result;
+import javax.xml.transform.Source;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Task;
+import org.apache.xmlbeans.XmlObject;
+import org.tianocore.MsaHeaderDocument.MsaHeader;
+import org.tianocore.MsaLibHeaderDocument.MsaLibHeader;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+/**
+ This class LibBuildFileGenerator is an ANT task to generate
+ build.xml for each module. Here are two usages.
+
+
+
+ For one module (bf is LibBuildFileGenerator task name):
+
+
+ @since GenBuild 1.0
+**/
+public class LibBuildFileGenerator extends Task {
+
+ private File buildFile;
+
+ private boolean recursive = false;
+
+ private String license = " Copyright (c) 2006, Intel Corporation \n"
+ + "All rights reserved. This program and the accompanying materials \n"
+ + "are licensed and made available under the terms and conditions of the BSD License \n"
+ + "which accompanies this distribution. The full text of the license may be found at \n"
+ + "http://opensource.org/licenses/bsd-license.php \n"
+ + "\n"
+ + "THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN \"AS IS\" BASIS, \n"
+ + "WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.";
+
+ private String base_name;
+
+ private String module_relative_path;
+
+ private File base_file = new File(".");
+
+ /**
+ Public construct method. It is necessary for ANT task.
+ **/
+ public LibBuildFileGenerator () {
+ }
+
+ /**
+ ANT task's entry point, will be called after init().
+
+ @throws BuildException
+ buildFile do not specify while recursive set to false
+ **/
+ public void execute() throws BuildException {
+ if(recursive){
+ searchMsa(new File("."));
+ }
+ else {
+ Map map = new HashMap();
+ String basename = buildFile.getName();
+ int k = basename.lastIndexOf('.');
+ base_name = basename.substring(0, k);
+ map.put(base_name, buildFile);
+ genBuildFile(map);
+ }
+ }
+
+ /**
+ Recursivly find all MSA files and record all modules.
+
+ @param path Package path
+ **/
+ private void searchMsa(File path){
+ File[] files = path.listFiles();
+ Vector vec = new Vector();
+ for(int i=0; i < files.length; i ++){
+ if (files[i].isFile()){
+ if(files[i].getName().endsWith(".msa")){
+ System.out.println("#" + files[i].getPath());
+ vec.add(files[i]);
+ }
+ }
+ }
+ Map mapBasename = new HashMap();
+ if (vec.size() > 0){
+ base_name = null;
+ for ( int j = 0 ; j < vec.size(); j++){
+ if ( vec.size() > 1){
+ System.out.println("##" + vec.get(0));
+ }
+ File f = (File)vec.get(j);
+ SurfaceAreaParser surfaceAreaParser = new SurfaceAreaParser();
+ Map map = surfaceAreaParser.parseFile(f);
+ String baseName = "";
+ XmlObject header = null;
+ if ( (header = map.get("MsaHeader")) != null ){
+ baseName = ((MsaHeader)header).getBaseName().getStringValue();
+ }
+ else if ( (header = map.get("MsaLibHeader")) != null){
+ baseName = ((MsaLibHeader)header).getBaseName().getStringValue();
+ } else {
+ continue ;
+ }
+ if ( base_name == null || base_name.length() > baseName.length()){
+ base_name = baseName;
+ buildFile = f;
+ try {
+ module_relative_path = buildFile.getParent().substring(base_file.getPath().length() + 1);
+ }
+ catch(Exception e){
+ module_relative_path = ".";
+ }
+ }
+ mapBasename.put(baseName, f);
+ }
+ genBuildFile(mapBasename);
+ }
+
+ for(int i=0; i < files.length; i ++){
+ if (files[i].isDirectory()){
+ searchMsa(files[i]);
+ }
+ }
+ }
+
+ /**
+ Generate build.xml.
+
+ @param map All base name under one module directory
+ **/
+ private void genBuildFile(Map map) {
+ DocumentBuilderFactory domfac = DocumentBuilderFactory.newInstance();
+ try {
+ DocumentBuilder dombuilder = domfac.newDocumentBuilder();
+ Document document = dombuilder.newDocument();
+ //
+ // create root element and its attributes
+ //
+ document.appendChild(document.createComment(license));
+ Element root = document.createElement("project");
+ root.setAttribute("default", base_name);
+ root.setAttribute("basedir", ".");
+ //
+ // element for External ANT tasks
+ //
+ root.appendChild(document.createComment("Apply external ANT tasks"));
+ Element ele = document.createElement("taskdef");
+ ele.setAttribute("resource", "GenBuild.tasks");
+ root.appendChild(ele);
+ //
+ //
+ //
+ ele = document.createElement("taskdef");
+ ele.setAttribute("resource", "net/sf/antcontrib/antlib.xml");
+ root.appendChild(ele);
+
+ ele = document.createElement("property");
+ ele.setAttribute("environment", "env");
+ root.appendChild(ele);
+
+ ele = document.createElement("property");
+ ele.setAttribute("name", "WORKSPACE_DIR");
+ ele.setAttribute("value", "${env.WORKSPACE}");
+ root.appendChild(ele);
+
+ ele = document.createElement("import");
+ ele.setAttribute("file", "${WORKSPACE_DIR}"+File.separatorChar+"Tools"+File.separatorChar+"Conf"+File.separatorChar+"BuildMacro.xml");
+ root.appendChild(ele);
+
+ root.appendChild(document.createComment("MODULE_RELATIVE PATH is relative to PACKAGE_DIR"));
+ ele = document.createElement("property");
+ ele.setAttribute("name", "MODULE_RELATIVE_PATH");
+ ele.setAttribute("value", module_relative_path);
+ root.appendChild(ele);
+
+ ele = document.createElement("property");
+ ele.setAttribute("name", "MODULE_DIR");
+ ele.setAttribute("value", "${PACKAGE_DIR}" + File.separatorChar + "${MODULE_RELATIVE_PATH}");
+ root.appendChild(ele);
+
+ ele = document.createElement("property");
+ ele.setAttribute("name", "COMMON_FILE");
+ ele.setAttribute("value", "${WORKSPACE_DIR}" + File.separatorChar + "Tools"
+ + File.separatorChar + "Conf" + File.separatorChar + "Common.xml");
+ root.appendChild(ele);
+
+ //
+ // generate the buildfmd target
+ //
+ Set set = map.keySet();
+ Iterator iter = set.iterator();
+ while (iter.hasNext()){
+ String bName = (String)iter.next();
+ File msaFile = (File)map.get(bName);
+ String msaFilename = "${MODULE_DIR}" + File.separatorChar + msaFile.getName();
+ String mbdFilename = msaFilename.substring(0 , msaFilename.length() - 4) + ".mbd";
+ ele = document.createElement("target");
+ ele.setAttribute("name", bName);
+ Element target = document.createElement("GenBuild");
+ target.setAttribute("msaFilename", msaFilename);
+ target.setAttribute("mbdFilename", mbdFilename);
+ target.setAttribute("baseName", bName);
+ ele.appendChild(target);
+ root.appendChild(ele);
+ }
+
+ root.appendChild(ele);
+ //
+ // Default clean
+ //
+ ele = document.createElement("target");
+ ele.setAttribute("name", "clean");
+ ele.setAttribute("depends", base_name + "_clean");
+ root.appendChild(ele);
+ //
+ // Default Clean ALl
+ //
+ ele = document.createElement("target");
+ ele.setAttribute("name", "cleanall");
+ ele.setAttribute("depends", base_name + "_cleanall");
+ root.appendChild(ele);
+ //
+ // Every clean target for each BaseName
+ //
+ set = map.keySet();
+ iter = set.iterator();
+ while (iter.hasNext()){
+ String bName = (String)iter.next();
+ File msaFile = (File)map.get(bName);
+ String msaFilename = "${MODULE_DIR}" + File.separatorChar + msaFile.getName();
+ String mbdFilename = msaFilename.substring(0 , msaFilename.length() - 4) + ".mbd";
+
+ ele = document.createElement("target");
+ ele.setAttribute("name", bName + "_clean");
+ //
+ // Output Dir
+ //
+ Element target = document.createElement("OutputDirSetup");
+ target.setAttribute("msaFilename", msaFilename);
+ target.setAttribute("mbdFilename", mbdFilename);
+ target.setAttribute("baseName", bName);
+ ele.appendChild(target);
+ //
+ // Call BaseName_build.xml clean
+ //
+ Element ifEle = document.createElement("if");
+ Element availableEle = document.createElement("available");
+ availableEle.setAttribute("file", "${DEST_DIR_OUTPUT}" + File.separatorChar + bName + "_build.xml");
+ ifEle.appendChild(availableEle);
+ Element elseEle = document.createElement("then");
+
+ Element moduleEle = document.createElement("ant");
+ moduleEle.setAttribute("antfile", "${DEST_DIR_OUTPUT}" + File.separatorChar + bName + "_build.xml");
+ moduleEle.setAttribute("target", "clean");
+
+ elseEle.appendChild(moduleEle);
+ ifEle.appendChild(elseEle);
+ ele.appendChild(ifEle);
+ //
+ // just delete
+ //
+ Element clean = document.createElement("delete");
+ clean.setAttribute("dir", "${DEST_DIR_OUTPUT}");
+ clean.setAttribute("excludes", "*.xml");
+ ele.appendChild(clean);
+
+ root.appendChild(ele);
+ }
+ //
+ // Every Clean ALl target for each BaseName
+ //
+ set = map.keySet();
+ iter = set.iterator();
+ while (iter.hasNext()){
+ String bName = (String)iter.next();
+ File msaFile = (File)map.get(bName);
+ String msaFilename = "${MODULE_DIR}" + File.separatorChar + msaFile.getName();
+ String mbdFilename = msaFilename.substring(0 , msaFilename.length() - 4) + ".mbd";
+
+ ele = document.createElement("target");
+ ele.setAttribute("name", bName + "_cleanall");
+ //
+ // Output Dir
+ //
+ Element target = document.createElement("OutputDirSetup");
+ target.setAttribute("msaFilename", msaFilename);
+ target.setAttribute("mbdFilename", mbdFilename);
+ target.setAttribute("baseName", bName);
+ ele.appendChild(target);
+ //
+ // Call BaseName_build.xml clean
+ //
+ Element ifEle = document.createElement("if");
+ Element availableEle = document.createElement("available");
+ availableEle.setAttribute("file", "${DEST_DIR_OUTPUT}" + File.separatorChar + bName + "_build.xml");
+ ifEle.appendChild(availableEle);
+ Element elseEle = document.createElement("then");
+
+ Element moduleEle = document.createElement("ant");
+ moduleEle.setAttribute("antfile", "${DEST_DIR_OUTPUT}" + File.separatorChar + bName + "_build.xml");
+ moduleEle.setAttribute("target", "cleanall");
+
+ elseEle.appendChild(moduleEle);
+ ifEle.appendChild(elseEle);
+ ele.appendChild(ifEle);
+ //
+ // just delete
+ //
+ Element clean = document.createElement("delete");
+ clean.setAttribute("dir", "${DEST_DIR_OUTPUT}");
+ ele.appendChild(clean);
+
+ clean = document.createElement("delete");
+ clean.setAttribute("dir", "${DEST_DIR_DEBUG}");
+ ele.appendChild(clean);
+
+ clean = document.createElement("delete");
+ Element fileset = document.createElement("fileset");
+ fileset.setAttribute("dir", "${BIN_DIR}");
+ fileset.setAttribute("includes", "**" + bName + "*");
+ clean.appendChild(fileset);
+ ele.appendChild(clean);
+
+ root.appendChild(ele);
+ }
+ document.appendChild(root);
+ //
+ // Prepare the DOM document for writing
+ //
+ Source source = new DOMSource(document);
+ //
+ // Prepare the output file
+ //
+ String filename = buildFile.getParent() + File.separatorChar + "build.xml";
+ File file = new File(getProject().replaceProperties(filename));
+ //
+ // generate all directory path
+ //
+ Result result = new StreamResult(file);
+ //
+ // Write the DOM document to the file
+ //
+ Transformer xformer = TransformerFactory.newInstance()
+ .newTransformer();
+ xformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
+ xformer.setOutputProperty(OutputKeys.INDENT, "yes");
+ xformer.transform(source, result);
+ } catch (Exception ex) {
+ System.out.println("##" + ex);
+ }
+ }
+
+
+ public File getBuildFile() {
+ return buildFile;
+ }
+
+ public void setBuildFile(File buildFile) {
+ this.buildFile = buildFile;
+ }
+
+ public boolean isRecursive() {
+ return recursive;
+ }
+
+ public void setRecursive(boolean recursive) {
+ this.recursive = recursive;
+ }
+}
diff --git a/Tools/Source/GenBuild/org/tianocore/build/global/ModuleIdentification.java b/Tools/Source/GenBuild/org/tianocore/build/global/ModuleIdentification.java
new file mode 100644
index 0000000000..74311d4541
--- /dev/null
+++ b/Tools/Source/GenBuild/org/tianocore/build/global/ModuleIdentification.java
@@ -0,0 +1,55 @@
+package org.tianocore.build.global;
+
+public class ModuleIdentification {
+
+ private String baseName;
+
+ private String packageName;
+
+ private String guid;
+
+ private String version;
+
+ public ModuleIdentification(String baseName, String packageName, String guid, String version){
+ this.baseName = baseName;
+ this.packageName = packageName;
+ this.guid = guid;
+ this.version = version;
+ }
+
+ public boolean equals(Object obj) {
+ if (obj instanceof ModuleIdentification) {
+ ModuleIdentification moduleIdObj = (ModuleIdentification)obj;
+ if ( baseName.equalsIgnoreCase(moduleIdObj.baseName)) {
+ return true;
+ }
+ // TBD
+ return false;
+ }
+ else {
+ return super.equals(obj);
+ }
+ }
+
+ public String toString(){
+ return packageName + ":" + guid + "_" + baseName + "_" + version;
+ }
+
+ public void setBaseName(String baseName) {
+ this.baseName = baseName;
+ }
+
+ public void setGuid(String guid) {
+ this.guid = guid;
+ }
+
+ public void setPackageName(String packageName) {
+ this.packageName = packageName;
+ }
+
+ public void setVersion(String version) {
+ this.version = version;
+ }
+
+
+}
diff --git a/Tools/Source/GenBuild/org/tianocore/build/global/OnDependency.java b/Tools/Source/GenBuild/org/tianocore/build/global/OnDependency.java
new file mode 100644
index 0000000000..936dac8ea3
--- /dev/null
+++ b/Tools/Source/GenBuild/org/tianocore/build/global/OnDependency.java
@@ -0,0 +1,121 @@
+/** @file
+This file is to define OnDependency class.
+
+Copyright (c) 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+--*/
+package org.tianocore.build.global;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Task;
+import org.apache.tools.ant.taskdefs.Sequential;
+
+import java.io.File;
+import java.util.Iterator;
+
+/**
+ Class OnDepdendency is used to check the timestamp between source files and
+ target files, which can be used to determine if the target files are needed to
+ be re-generated from source files.
+ **/
+public class OnDependency extends Task {
+ ///
+ /// source files list
+ ///
+ private DpFileList sources = null;
+ ///
+ /// target files list
+ ///
+ private DpFileList targets = null;
+ ///
+ /// tasks to be performed to generate target files
+ ///
+ private Sequential task = null;
+
+ ///
+ /// An empty constructor for an ANT task can avoid some potential issues
+ ///
+ public OnDependency(){
+ }
+
+ /**
+ Standard execute method of ANT task
+ **/
+ public void execute() {
+ if (isOutOfDate() && task != null) {
+ task.perform();
+ }
+ }
+
+ ///
+ /// check if the target files are outofdate
+ ///
+ private boolean isOutOfDate() {
+ ///
+ /// if no source files specified, take it as a fresh start
+ ///
+ if (sources.nameList.size() == 0) {
+ return true;
+ }
+
+ Iterator dstIt = targets.nameList.iterator();
+ while (dstIt.hasNext()) {
+ String dstFileName = (String)dstIt.next();
+ File dstFile = new File(dstFileName);
+ if (!dstFile.exists()) {
+ return true;
+ }
+
+ long dstTimeStamp = dstFile.lastModified();
+ Iterator srcIt = sources.nameList.iterator();
+ while (srcIt.hasNext()) {
+ String srcFileName = (String)srcIt.next();
+ File srcFile = new File(srcFileName);
+ if (!srcFile.exists()) {
+ throw new BuildException(srcFileName + " doesn't exist !!!");
+ }
+
+ if (dstTimeStamp < srcFile.lastModified()) {
+ return true;
+ }
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ Add method of ANT task for nested element with Sequential type
+
+ @param task Sequential object which contains tasks for generating target files
+ **/
+ public void addSequential(Sequential task) {
+ this.task = task;
+ }
+
+ /**
+ Add method of ANT task for nested element with DpFileList type
+
+ @param sources DpFileList object which contains the list of source files
+ **/
+ public void addSourcefiles(DpFileList sources) {
+ this.sources = sources;
+ }
+
+ /**
+ Add method of ANT task for nested element with DpFileList type
+
+ @param targets DpFileList object which contains the list of target files
+ **/
+ public void addTargetfiles(DpFileList targets) {
+ this.targets = targets;
+ }
+}
+
diff --git a/Tools/Source/GenBuild/org/tianocore/build/global/OutputManager.java b/Tools/Source/GenBuild/org/tianocore/build/global/OutputManager.java
new file mode 100644
index 0000000000..01e24e653f
--- /dev/null
+++ b/Tools/Source/GenBuild/org/tianocore/build/global/OutputManager.java
@@ -0,0 +1,176 @@
+/** @file
+ OutputManager class.
+
+ OutputManager class set output directories for every module by BUILD_MODE.
+
+Copyright (c) 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+**/
+package org.tianocore.build.global;
+
+import org.apache.tools.ant.Project;
+import java.io.File;
+
+/**
+ OutputManager class is used to setup output directories (BIN_DIR, DEST_DIR_OUTPUT,
+ DEST_DIR_DEBUG) according to BUILD_MODE.
+
+ @since GenBuild 1.0
+**/
+public class OutputManager {
+
+ ///
+ /// Single Module build
+ ///
+ public static final String MODULE_BUILD = "MODULE";
+
+ ///
+ /// Package build
+ ///
+ public static final String PACKAGE_BUILD = "PACKAGE";
+
+ ///
+ /// Platform build
+ ///
+ public static final String PLATFORM_BUILD = "PLATFORM";
+
+ public static String buildMode = MODULE_BUILD;
+
+ ///
+ /// For Package build, PLATFORM represent PACKAGE
+ ///
+ public static String PLATFORM;
+
+ ///
+ /// For Platform build, PLATFORM_DIR represent PACKAGE_DIR
+ ///
+ public static String PLATFORM_DIR;
+
+ ///
+ /// means intermediate files will put under Module's dir
+ ///
+ public static final String MODULE = "MODULE";
+
+ ///
+ /// mean intermediate files will put under a unify dir
+ ///
+ public static final String UNIFIED = "UNIFIED";
+
+ ///
+ /// Flag to ensure the function update will be called only one in the whole build.
+ ///
+ private static boolean flag = true;
+
+ /**
+ If BUILD_MODE is PLATFORM or PACKAGE, record PLATFORM and PLARFORM_DIR.
+ Reminder that for PACKAGE build, here set value PACKAGE to PLATFORM and
+ PACKAGE_DIR to PLARFORM_DIR, and also update the ant properties.
+
+
Note that this function will be called only once in the whole build.
+
+ @param project current ANT build Project
+ **/
+ public synchronized static void update(Project project) {
+ if (flag){
+ flag = false;
+ String str = project.getProperty("BUILD_MODE");
+ if (str != null){
+ if (str.equals(PLATFORM_BUILD)) {
+ buildMode = PLATFORM_BUILD;
+ PLATFORM = project.getProperty("PLATFORM");
+ PLATFORM_DIR = project.getProperty("PLATFORM_DIR");
+ }
+ else if (str.equals(PACKAGE_BUILD)) {
+ buildMode = PACKAGE_BUILD;
+ PLATFORM = project.getProperty("PACKAGE");
+ PLATFORM_DIR = project.getProperty("PACKAGE_DIR");
+ project.setProperty("PLATFORM", PLATFORM);
+ project.setProperty("PLATFORM_DIR", PLATFORM_DIR);
+ }
+ }
+ }
+ }
+
+ /**
+ Setup BIN_DIR, DEST_DIR_OUTPUT and DEST_DIR_OUTPUT, following are the rules:
+
+
+ Those three variables are defined as following
+ DEST_DIR_OUTPUT (intermediate files)
+ DEST_DIR_DEBUG (intermediate debug files)
+ BIN_DIR (final files)
+
+ Output Dir (MODULE or UNIFIED):
+ For Module build:
+ All intermediate files are at ${MODULE_DIR}/Build/${TARGET}/${ARCH}/DEBUG|OUTPUT
+ All final files are at ${MODULE_DIR}/Build/${TARGET}/${ARCH}
+
+ For Platform build:
+ If specified with MODULE
+ Intermediate files->${MODULE_DIR}/Build/${PLATFORM}/${TARGET}/${ARCH}/DEBUG|OUTPUT
+ Final files -> ${PLARFORM_DIR}/Build/${TARGET}/${ARCH}
+
+ Else if specified with UNIFIED
+ Intermediate files->${PLARFORM_DIR}/Build/${TARGET}/${ARCH}/${PACKAGE}/${SOURCE_RELATIVE_PATH}/DEBUG|OUTPUT
+ Final files -> ${PLARFORM_DIR}/Build/${TARGET}/${ARCH}
+
+ For Package build:
+ If specified with MODULE
+ Intermediate files->${MODULE_DIR}/Build/${PACKAGE}/${TARGET}/${ARCH}/DEBUG|OUTPUT
+ Final files -> ${PACKAGE_DIR}/Build/${TARGET}/${ARCH}
+
+ Else if specified with UNIFIED
+ Intermediate files->${PACKAGE_DIR}/Build/${TARGET}/${ARCH}/${PACKAGE}/${SOURCE_RELATIVE_PATH}/DEBUG|OUTPUT
+ Final files -> ${PACKAGE_DIR}/Build/${TARGET}/${ARCH}
+
+
+ @param project current ANT build Project
+ @param userdir user-defined directory
+ @param type the module build type (MODULE or UNIFIED)
+ **/
+ public synchronized static void update(Project project, String userdir, String type) {
+ //
+ // userdir TBD
+ //
+ if( type == null || ! type.equals(MODULE)){
+ type = UNIFIED;
+ }
+ if (buildMode.equals(MODULE_BUILD)){
+ project.setProperty("DEST_DIR_OUTPUT", project.replaceProperties("${MODULE_DIR}"
+ + File.separatorChar + "Build" + File.separatorChar + "${TARGET}"
+ + File.separatorChar + "${ARCH}" + File.separatorChar + "OUTPUT"));
+ project.setProperty("DEST_DIR_DEBUG", project.replaceProperties("${MODULE_DIR}" + File.separatorChar + "Build" + File.separatorChar + "${TARGET}" + File.separatorChar + "${ARCH}" + File.separatorChar + "DEBUG"));
+ project.setProperty("BIN_DIR", project.replaceProperties("${MODULE_DIR}" + File.separatorChar + "Build" + File.separatorChar + "${TARGET}" + File.separatorChar + "${ARCH}"));
+ }
+ else if (buildMode.equals(PLATFORM_BUILD)) {
+ if (type.equals(MODULE)) {
+ project.setProperty("DEST_DIR_OUTPUT", project.replaceProperties("${MODULE_DIR}" + File.separatorChar + "Build" + File.separatorChar + "${PLATFORM}" + File.separatorChar + "${TARGET}" + File.separatorChar + "${ARCH}" + File.separatorChar + "OUTPUT"));
+ project.setProperty("DEST_DIR_DEBUG", project.replaceProperties("${MODULE_DIR}" + File.separatorChar + "Build" + File.separatorChar + "${PLATFORM}" + File.separatorChar + "${TARGET}" + File.separatorChar + "${ARCH}" + File.separatorChar + "DEBUG"));
+ project.setProperty("BIN_DIR", project.replaceProperties("${PLATFORM_DIR}" + File.separatorChar + "Build" + File.separatorChar + "${TARGET}" + File.separatorChar + "${ARCH}"));
+ }
+ else if (type.equals(UNIFIED)){
+ project.setProperty("DEST_DIR_OUTPUT", project.replaceProperties("${PLATFORM_DIR}" + File.separatorChar + "Build" + File.separatorChar + "${TARGET}" + File.separatorChar + "${ARCH}" + File.separatorChar + "${PACKAGE}" + File.separatorChar + "${MODULE_RELATIVE_PATH}" + File.separatorChar + "OUTPUT"));
+ project.setProperty("DEST_DIR_DEBUG", project.replaceProperties("${PLATFORM_DIR}" + File.separatorChar + "Build" + File.separatorChar + "${TARGET}" + File.separatorChar + "${ARCH}" + File.separatorChar + "${PACKAGE}" + File.separatorChar + "${MODULE_RELATIVE_PATH}" + File.separatorChar + "DEBUG"));
+ project.setProperty("BIN_DIR", project.replaceProperties("${PLATFORM_DIR}" + File.separatorChar + "Build" + File.separatorChar + "${TARGET}" + File.separatorChar + "${ARCH}"));
+ }
+ }
+ else if (buildMode.equals(PACKAGE_BUILD)) {
+ if (type.equals(MODULE)) {
+ project.setProperty("DEST_DIR_OUTPUT", project.replaceProperties("${MODULE_DIR}" + File.separatorChar + "Build" + File.separatorChar + "${PLATFORM}" + File.separatorChar + "${TARGET}" + File.separatorChar + "${ARCH}" + File.separatorChar + "OUTPUT"));
+ project.setProperty("DEST_DIR_DEBUG", project.replaceProperties("${MODULE_DIR}" + File.separatorChar + "Build" + File.separatorChar + "${PLATFORM}" + File.separatorChar + "${TARGET}" + File.separatorChar + "${ARCH}" + File.separatorChar + "DEBUG"));
+ project.setProperty("BIN_DIR", project.replaceProperties("${PLATFORM_DIR}" + File.separatorChar + "Build" + File.separatorChar + "${TARGET}" + File.separatorChar + "${ARCH}"));
+ }
+ else if (type.equals(UNIFIED)){
+ project.setProperty("DEST_DIR_OUTPUT", project.replaceProperties("${PLATFORM_DIR}" + File.separatorChar + "Build" + File.separatorChar + "${TARGET}" + File.separatorChar + "${ARCH}" + File.separatorChar + "${PACKAGE}" + File.separatorChar + "${MODULE_RELATIVE_PATH}" + File.separatorChar + "OUTPUT"));
+ project.setProperty("DEST_DIR_DEBUG", project.replaceProperties("${PLATFORM_DIR}" + File.separatorChar + "Build" + File.separatorChar + "${TARGET}" + File.separatorChar + "${ARCH}" + File.separatorChar + "${PACKAGE}" + File.separatorChar + "${MODULE_RELATIVE_PATH}" + File.separatorChar + "DEBUG"));
+ project.setProperty("BIN_DIR", project.replaceProperties("${PLATFORM_DIR}" + File.separatorChar + "Build" + File.separatorChar + "${TARGET}" + File.separatorChar + "${ARCH}"));
+ }
+ }
+ }
+}
diff --git a/Tools/Source/GenBuild/org/tianocore/build/global/OverrideProcess.java b/Tools/Source/GenBuild/org/tianocore/build/global/OverrideProcess.java
new file mode 100644
index 0000000000..dae2ca29aa
--- /dev/null
+++ b/Tools/Source/GenBuild/org/tianocore/build/global/OverrideProcess.java
@@ -0,0 +1,354 @@
+/** @file
+ OverrideProcess class.
+
+ OverrideProcess class is used to override surface area information.
+
+Copyright (c) 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+package org.tianocore.build.global;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.xmlbeans.XmlCursor;
+import org.apache.xmlbeans.XmlObject;
+import org.tianocore.BootModesDocument;
+import org.tianocore.BuildOptionsDocument;
+import org.tianocore.DataHubsDocument;
+import org.tianocore.EventsDocument;
+import org.tianocore.ExternsDocument;
+import org.tianocore.FormsetsDocument;
+import org.tianocore.GuidsDocument;
+import org.tianocore.HobsDocument;
+import org.tianocore.IncludesDocument;
+import org.tianocore.LibrariesDocument;
+import org.tianocore.LibraryClassDefinitionsDocument;
+import org.tianocore.MsaHeaderDocument;
+import org.tianocore.MsaLibHeaderDocument;
+import org.tianocore.PCDsDocument;
+import org.tianocore.PPIsDocument;
+import org.tianocore.ProtocolsDocument;
+import org.tianocore.SourceFilesDocument;
+import org.tianocore.SystemTablesDocument;
+import org.tianocore.VariablesDocument;
+
+/**
+ This class is used to override surface area information. For example, MBD can
+ overried MSA, Platform can override all information of the module.
+
+
Override will take effect if two element satisfy one of following two condition:
+
+
Element name and its attribute OverrideID equal each other.
+
Element is defined as exclusive which mean such element can be
+ only appeared in the surface area.
+
+
+
For example, here OutputDirectory element is exclusive:
Note: Until new schema applying, now we can only get CName, ItemType,
+
+ @return 2-array table contains all information of PCD token retrieved from MSA.
+ **/
+ public static Object[][] getModulePCDTokenArray () {
+ int index;
+ Object[][] result;
+ PCDs.PcdData[] pcds;
+ String[] xPath = new String[] {"/PcdData"};
+ XmlObject[] returns = get ("PCDs", xPath);
+
+ if ((returns == null) || (returns.length == 0)) {
+ return null;
+ }
+
+ pcds = (PCDs.PcdData[]) returns;
+ result = new Object[pcds.length][6];
+ for (index = 0; index < pcds.length; index ++) {
+ //
+ // Get CName
+ //
+ result [index][0] = pcds[index].getCName();
+ //
+ // Get ItemType: FEATURE_FLAG, FIXED_AT_BUILD, PATCHABLE_IN_MODLE, DYNAMIC, DYNAMIC_EX
+ //
+ if (pcds[index].getItemType() != null) {
+ result [index][1] = pcds[index].getItemType().toString();
+ } else {
+ result [index][1] = null;
+ }
+
+ //
+ // BUGBUG: following field can *not* be got from current MSA until schema changed.
+ //
+ //result [index][2] = pcds[index].getTokenSpaceName();
+ result [index][2] = null;
+ result [index][3] = pcds[index].getDefaultValue();
+ //result [index][4] = pcds[index].getUsage ();
+ result [index][4] = null;
+ //result [index][5] = pcds[index].getHelpText ();
+ result [index][5] = null;
+ }
+ return result;
+ }
+}
diff --git a/Tools/Source/GenBuild/org/tianocore/build/global/VariableTask.java b/Tools/Source/GenBuild/org/tianocore/build/global/VariableTask.java
new file mode 100644
index 0000000000..f830e0ac76
--- /dev/null
+++ b/Tools/Source/GenBuild/org/tianocore/build/global/VariableTask.java
@@ -0,0 +1,71 @@
+/** @file
+ * This file is ANT task VariableTask.
+ *
+ * VariableTask task implements part of ANT property task. The difference is
+ * this task will override variable with same name, but ANT property task do not.
+ *
+ * Copyright (c) 2006, Intel Corporation
+ * All rights reserved. This program and the accompanying materials
+ * are licensed and made available under the terms and conditions of the BSD License
+ * which accompanies this distribution. The full text of the license may be found at
+ * http://opensource.org/licenses/bsd-license.php
+ *
+ * THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+ */
+package org.tianocore.build.global;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Task;
+
+/**
+ * VariableTask task implements part of ANT property task. The difference is
+ * this task will override variable with same name, but ANT property task do not.
+ *
+ * @since GenBuild 1.0
+ */
+public class VariableTask extends Task {
+
+ /**
+ * property value
+ */
+ private String value;
+
+ /**
+ * property name
+ */
+ private String name;
+
+ /**
+ * Set property name.
+ *
+ * @param name property name
+ */
+ public void setName( String name ) {
+ this.name = name;
+ }
+
+
+ /**
+ * Set property value.
+ *
+ * @param value property value
+ */
+ public void setValue( String value ) {
+ this.value = value;
+ }
+
+ /**
+ * ANT task's entry point, will be called after init().
+ *
+ * @exception BuildException
+ * If name or value is null
+ */
+ public void execute() throws BuildException {
+ if (name == null || value == null) {
+ throw new BuildException("Name or value must not null.");
+ }
+ getProject().setProperty(name, value);
+ }
+}
+
diff --git a/Tools/Source/GenBuild/org/tianocore/build/pcd/action/ActionMessage.java b/Tools/Source/GenBuild/org/tianocore/build/pcd/action/ActionMessage.java
new file mode 100644
index 0000000000..a67d2f9e4d
--- /dev/null
+++ b/Tools/Source/GenBuild/org/tianocore/build/pcd/action/ActionMessage.java
@@ -0,0 +1,129 @@
+/** @file
+ ActionMessage class.
+
+ ActionMessage class take over all message for loging and waning. This class should
+ dispatch message into different class according to instance class type.
+
+Copyright (c) 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+package org.tianocore.build.pcd.action;
+
+import org.apache.tools.ant.Task;
+import org.tianocore.build.pcd.action.BuildAction;
+import org.tianocore.build.pcd.action.UIAction;
+
+/** ActionMessage class take over all message for loging and waning. This class
+ should dispatch message into different Action class according to instance
+ class type.
+**/
+public class ActionMessage {
+ ///
+ /// Macro definition for NULL messge level.
+ /// In this meessage level, all message will be hidden.
+ ///
+ public final static int NULL_MESSAGE_LEVEL = 0;
+ ///
+ /// Macro definition for Log messge level.
+ /// In this message level, Only log information will be shown.
+ ///
+ public final static int LOG_MESSAGE_LEVEL = 1;
+ ///
+ /// Macro definition for Warning message level.
+ /// In this message level, log and waning message will be shown.
+ ///
+ public final static int WARNING_MESSAGE_LEVEL = 2;
+ ///
+ /// Macro definition for Debug mesage level.
+ /// In this message level, log, warning, debug message will be shown.
+ ///
+ public final static int DEBUG_MESSAGE_LEVEL = 3;
+ ///
+ /// Macor definition for MAX message level.
+ /// In this message level, all message will be shown.
+ ///
+ public final static int MAX_MESSAGE_LEVEL = 4;
+ ///
+ /// Current message level. It will control all message output for PCD tool.
+ ///
+ public static int messageLevel = NULL_MESSAGE_LEVEL;
+
+ /**
+ Log() function provide common log information functionality for all
+ PCD tool includes all function
+
+ This function will dispatch message to special class such as BuildAction
+ Class, Entity Class etc.
+
+ @param thisClass The class object who want log information.
+ @param logStr The string contains log information.
+ **/
+ public static void log(Object thisClass, String logStr) {
+ if(messageLevel < LOG_MESSAGE_LEVEL) {
+ return;
+ }
+
+ if(thisClass instanceof Task) {
+ BuildAction.logMsg(thisClass, "$$LOG$$:" + logStr);
+ } else if(thisClass instanceof UIAction) {
+ UIAction.logMsg(thisClass, "$$LOG$$:" + logStr);
+ } else {
+ System.out.println("$$LOG$$:" + logStr);
+ }
+ }
+
+ /**
+ Warning() function provide common warning information functionality for all
+ PCD tool.
+
+ This function will dispatch message to special class such as BuildAction
+ Class, Entity Class etc.
+
+ @param thisClass The class object who want warn information.
+ @param warningStr The string contains warning information.
+ **/
+ public static void warning(Object thisClass, String warningStr) {
+ if(messageLevel < WARNING_MESSAGE_LEVEL) {
+ return;
+ }
+
+ if(thisClass instanceof Task) {
+ BuildAction.warningMsg(thisClass, "**WARNING**:" + warningStr);
+ } else if(thisClass instanceof UIAction) {
+ UIAction.warningMsg(thisClass, "**WARNING**:" + warningStr);
+ } else {
+ System.out.println("**WARNING**:" + warningStr);
+ }
+ }
+
+ /**
+ Debug() function provide common Debug information functionality for all
+ PCD tool.
+
+ This function will dispatch message to special class such as BuildAction
+ Class, Entity Class etc.
+
+ @param thisClass The class object who want Debug information.
+ @param debugStr The string contains Debug information.
+ **/
+ public static void debug(Object thisClass, String debugStr) {
+ if(messageLevel < DEBUG_MESSAGE_LEVEL) {
+ return;
+ }
+
+ if(thisClass instanceof Task) {
+ BuildAction.logMsg(thisClass, "%%DEBUG%%:" + debugStr);
+ } else if(thisClass instanceof UIAction) {
+ UIAction.logMsg(thisClass, "%%DEBUG%%:" + debugStr);
+ } else {
+ System.out.println("%%DEBUG%%:" + debugStr);
+ }
+ }
+}
diff --git a/Tools/Source/GenBuild/org/tianocore/build/pcd/action/BuildAction.java b/Tools/Source/GenBuild/org/tianocore/build/pcd/action/BuildAction.java
new file mode 100644
index 0000000000..c8b0d9dba1
--- /dev/null
+++ b/Tools/Source/GenBuild/org/tianocore/build/pcd/action/BuildAction.java
@@ -0,0 +1,114 @@
+/** @file
+ BuildAction class.
+
+ BuildAction is the parent class for all action related to ant Task. This class will
+ define some common utility functionality, such as logMsg, warningMsg..etc.
+
+Copyright (c) 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+package org.tianocore.build.pcd.action;
+
+import org.apache.tools.ant.Task;
+import org.tianocore.build.pcd.exception.BuildActionException;
+
+/** BuildAction is the parent class for all action related to ant Task. This class will
+ define some common utility functionality, such as logMsg, warningMsg..etc.
+**/
+abstract class BuildAction extends Task {
+ ///
+ /// Original message level before this action. This value will
+ /// be restored when quit this action.
+ ///
+ private int originalMessageLevel;
+
+ /**
+ checkParameter function check all parameter valid.
+
+ This function will be overrided by child class.
+ **/
+ abstract void checkParameter() throws BuildActionException;
+
+ /**
+ performAction is to execute the detail action.
+
+ This function will be overrided by child class.
+ **/
+ abstract void performAction() throws BuildActionException;
+
+ /**
+ setMessageLevel function set current message for task instance object.
+
+ The message should be restored when this action exit.
+
+ @param messageLevel The message level for this action.
+ **/
+ public void setMessageLevel(int messageLevel) {
+ originalMessageLevel = ActionMessage.messageLevel;
+ ActionMessage.messageLevel = messageLevel;
+ }
+
+ /**
+ logMsg function provide common log information functionality for all
+ PCD tool extends from ANT task class.
+
+ This function will use the log function in Ant task class.
+
+ @param action The class object who want log information.
+ @param logStr The string contains log information.
+ **/
+ public static void logMsg(Object action, String logStr) {
+ //
+ // Comment following code because in console debug environment, we can't
+ // get Project instance.
+ //((Task) action).log(errorText, Project.MSG_INFO);
+ //
+ System.out.println(logStr);
+ }
+
+ /**
+ warningMsg function provide common warning information functionality for all
+ PCD tool.
+
+ This function will dispatch message to special class such as BuildAction
+ Class, Entity Class etc.
+
+ @param action The class object who want warn information.
+ @param warningStr The string contains warning information.
+ **/
+ public static void warningMsg(Object action, String warningStr) {
+ //
+ // Comment following code because in console debug environment, we can't
+ // get Project instance.
+ //((Task) action).log(warningText, Project.MSG_WARN);
+ //
+ System.out.println(warningStr);
+ }
+
+ /**
+ execute function is the main flow for all build action class.
+
+ This workflow will be:
+ 1) Check paramet of this action.
+ 2) Perform the child class action function.
+ 3) Restore the message level.
+
+ @throws BuildActionException
+ **/
+ public void execute() throws BuildActionException {
+ checkParameter();
+ performAction();
+
+ //
+ // Restore orignal message level when exist the action.
+ //
+ ActionMessage.messageLevel = originalMessageLevel;
+ }
+}
diff --git a/Tools/Source/GenBuild/org/tianocore/build/pcd/action/CollectPCDAction.java b/Tools/Source/GenBuild/org/tianocore/build/pcd/action/CollectPCDAction.java
new file mode 100644
index 0000000000..055563df1b
--- /dev/null
+++ b/Tools/Source/GenBuild/org/tianocore/build/pcd/action/CollectPCDAction.java
@@ -0,0 +1,669 @@
+/** @file
+ CollectPCDAction class.
+
+ This action class is to collect PCD information from MSA, SPD, FPD xml file.
+ This class will be used for wizard and build tools, So it can *not* inherit
+ from buildAction or wizardAction.
+
+Copyright (c) 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+package org.tianocore.build.pcd.action;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+import org.apache.xmlbeans.XmlException;
+import org.apache.xmlbeans.XmlObject;
+import org.tianocore.FrameworkPlatformDescriptionDocument;
+import org.tianocore.ModuleSADocument;
+import org.tianocore.PackageSurfaceAreaDocument;
+import org.tianocore.PcdBuildDeclarationsDocument.PcdBuildDeclarations.PcdBuildData;
+import org.tianocore.PcdDefinitionsDocument.PcdDefinitions;
+import org.tianocore.build.autogen.CommonDefinition;
+import org.tianocore.build.global.GlobalData;
+import org.tianocore.build.global.SurfaceAreaQuery;
+import org.tianocore.build.pcd.action.ActionMessage;
+import org.tianocore.build.pcd.entity.MemoryDatabaseManager;
+import org.tianocore.build.pcd.entity.SkuInstance;
+import org.tianocore.build.pcd.entity.Token;
+import org.tianocore.build.pcd.entity.UsageInstance;
+import org.tianocore.build.pcd.exception.EntityException;
+
+/** This action class is to collect PCD information from MSA, SPD, FPD xml file.
+ This class will be used for wizard and build tools, So it can *not* inherit
+ from buildAction or UIAction.
+**/
+public class CollectPCDAction {
+ /// memoryDatabase hold all PCD information collected from SPD, MSA, FPD.
+ private MemoryDatabaseManager dbManager;
+
+ /// Workspacepath hold the workspace information.
+ private String workspacePath;
+
+ /// FPD file is the root file.
+ private String fpdFilePath;
+
+ /// Message level for CollectPCDAction.
+ private int originalMessageLevel;
+
+ /**
+ Set WorkspacePath parameter for this action class.
+
+ @param workspacePath parameter for this action
+ **/
+ public void setWorkspacePath(String workspacePath) {
+ this.workspacePath = workspacePath;
+ }
+
+ /**
+ Set action message level for CollectPcdAction tool.
+
+ The message should be restored when this action exit.
+
+ @param actionMessageLevel parameter for this action
+ **/
+ public void setActionMessageLevel(int actionMessageLevel) {
+ originalMessageLevel = ActionMessage.messageLevel;
+ ActionMessage.messageLevel = actionMessageLevel;
+ }
+
+ /**
+ Set FPDFileName parameter for this action class.
+
+ @param fpdFilePath fpd file path
+ **/
+ public void setFPDFilePath(String fpdFilePath) {
+ this.fpdFilePath = fpdFilePath;
+ }
+
+ /**
+ Common function interface for outer.
+
+ @param workspacePath The path of workspace of current build or analysis.
+ @param fpdFilePath The fpd file path of current build or analysis.
+ @param messageLevel The message level for this Action.
+
+ @throws Exception The exception of this function. Because it can *not* be predict
+ where the action class will be used. So only Exception can be throw.
+
+ **/
+ public void perform(String workspacePath, String fpdFilePath,
+ int messageLevel) throws Exception {
+ setWorkspacePath(workspacePath);
+ setFPDFilePath(fpdFilePath);
+ setActionMessageLevel(messageLevel);
+ checkParameter();
+ execute();
+ ActionMessage.messageLevel = originalMessageLevel;
+ }
+
+ /**
+ Core execution function for this action class.
+
+ This function work flows will be:
+ 1) Get all token's platform information from FPD, and create token object into memory database.
+ 2) Get all token's module information from MSA, and create usage instance for every module's PCD entry.
+ 3) Get all token's inherited information from MSA's library, and create usage instance
+ for module who consume this library and create usage instance for library for building.
+ 4) Collect token's package information from SPD, update these information for token in memory
+ database.
+
+ @throws EntityException Exception indicate failed to execute this action.
+
+ **/
+ private void execute() throws EntityException {
+ FrameworkPlatformDescriptionDocument fpdDoc = null;
+ Object[][] modulePCDArray = null;
+ Map docMap = null;
+ ModuleSADocument.ModuleSA[] moduleSAs = null;
+ UsageInstance usageInstance = null;
+ String packageName = null;
+ String packageFullPath = null;
+ int index = 0;
+ int libraryIndex = 0;
+ int pcdArrayIndex = 0;
+ List listLibraryInstance = null;
+ String componentTypeStr = null;
+
+ //
+ // Collect all PCD information defined in FPD file.
+ // Evenry token defind in FPD will be created as an token into
+ // memory database.
+ //
+ fpdDoc = createTokenInDBFromFPD();
+
+ //
+ // Searching MSA and SPD document.
+ // The information of MSA will be used to create usage instance into database.
+ // The information of SPD will be used to update the token information in database.
+ //
+
+ HashMap map = new HashMap();
+ map.put("FrameworkPlatformDescription", fpdDoc);
+ SurfaceAreaQuery.setDoc(map);
+
+ moduleSAs = SurfaceAreaQuery.getFpdModules();
+ for(index = 0; index < moduleSAs.length; index ++) {
+ //
+ // Get module document and use SurfaceAreaQuery to get PCD information
+ //
+ docMap = GlobalData.getDoc(moduleSAs[index].getModuleName());
+ SurfaceAreaQuery.setDoc(docMap);
+ modulePCDArray = SurfaceAreaQuery.getModulePCDTokenArray();
+ componentTypeStr = SurfaceAreaQuery.getComponentType();
+ packageName =
+ GlobalData.getPackageNameForModule(moduleSAs[index].getModuleName());
+ packageFullPath = this.workspacePath + File.separator +
+ GlobalData.getPackagePath(packageName) +
+ packageName + ".spd";
+
+ if(modulePCDArray != null) {
+ //
+ // If current MSA contains information, then create usage
+ // instance for PCD information from MSA
+ //
+ for(pcdArrayIndex = 0; pcdArrayIndex < modulePCDArray.length;
+ pcdArrayIndex ++) {
+ usageInstance =
+ createUsageInstanceFromMSA(moduleSAs[index].getModuleName(),
+ modulePCDArray[pcdArrayIndex]);
+
+ if(usageInstance == null) {
+ continue;
+ }
+ //
+ // Get remaining PCD information from the package which this module belongs to
+ //
+ updateTokenBySPD(usageInstance, packageFullPath);
+ }
+ }
+
+ //
+ // Get inherit PCD information which inherit from library instance of this module.
+ //
+ listLibraryInstance =
+ SurfaceAreaQuery.getLibraryInstance(moduleSAs[index].getArch().toString(),
+ CommonDefinition.AlwaysConsumed);
+ if(listLibraryInstance != null) {
+ for(libraryIndex = 0; libraryIndex < listLibraryInstance.size();
+ libraryIndex ++) {
+ inheritPCDFromLibraryInstance(listLibraryInstance.get(libraryIndex),
+ moduleSAs[index].getModuleName(),
+ packageName,
+ componentTypeStr);
+ }
+ }
+ }
+ }
+
+ /**
+ This function will collect inherit PCD information from library for a module.
+
+ This function will create two usage instance for inherited PCD token, one is
+ for module and another is for library.
+ For module, if it inherited a PCD token from library, this PCD token's value
+ should be instanced in module level, and belongs to module.
+ For library, it also need a usage instance for build.
+
+ @param libraryName The name of library instance.
+ @param moduleName The name of module.
+ @param packageName The name of package while module belongs to.
+ @param parentcomponentType The component type of module.
+
+ @throws EntityException If the token does *not* exist in memory database.
+
+ **/
+ private void inheritPCDFromLibraryInstance(String libraryName,
+ String moduleName,
+ String packageName,
+ String parentcomponentType)
+ throws EntityException {
+ Map docMap = null;
+ String primaryKeyString = null;
+ Object[][] libPcdDataArray = null;
+ UUID nullUUID = new UUID(0,0);
+ UUID platformUUID = nullUUID;
+ UUID tokenSpaceGuid = null;
+ int tokenIndex = 0;
+ Token token = null;
+ Token.PCD_TYPE pcdType = Token.PCD_TYPE.UNKNOWN;
+ UsageInstance usageInstance = null;
+ String packageFullPath = null;
+
+ //
+ // Query PCD information from library's document.
+ //
+ docMap = GlobalData.getDoc(libraryName);
+ SurfaceAreaQuery.setDoc(docMap);
+ libPcdDataArray = SurfaceAreaQuery.getModulePCDTokenArray();
+
+ if(libPcdDataArray == null) {
+ return;
+ }
+
+ for(tokenIndex = 0; tokenIndex < libPcdDataArray.length; tokenIndex ++) {
+ tokenSpaceGuid =((UUID)libPcdDataArray[tokenIndex][2] == null) ?
+ nullUUID :(UUID)libPcdDataArray[tokenIndex][2];
+
+ //
+ // Get token from memory database. The token must be created from FPD already.
+ //
+ primaryKeyString = Token.getPrimaryKeyString((String)libPcdDataArray[tokenIndex][0],
+ tokenSpaceGuid,
+ platformUUID
+ );
+
+ if(dbManager.isTokenInDatabase(primaryKeyString)) {
+ token = dbManager.getTokenByKey(primaryKeyString);
+ } else {
+ throw new EntityException("The PCD token " + primaryKeyString +
+ " defined in module " + moduleName +
+ " does not exist in FPD file!");
+ }
+
+ //
+ // Create usage instance for module.
+ //
+ pcdType = Token.getpcdTypeFromString((String)libPcdDataArray[tokenIndex][1]);
+ usageInstance = new UsageInstance(token,
+ Token.PCD_USAGE.ALWAYS_CONSUMED,
+ pcdType,
+ CommonDefinition.getComponentType(parentcomponentType),
+ libPcdDataArray[tokenIndex][3],
+ null,
+ (String) libPcdDataArray[tokenIndex][5],
+ "",
+ moduleName,
+ packageName,
+ true);
+ if(Token.PCD_USAGE.UNKNOWN == token.isUsageInstanceExist(moduleName)) {
+ token.addUsageInstance(usageInstance);
+
+ packageFullPath = this.workspacePath + File.separator +
+ GlobalData.getPackagePath(packageName) +
+ packageName + ".spd";
+ updateTokenBySPD(usageInstance, packageFullPath);
+ }
+
+ //
+ // We need create second usage instance for inherited case, which
+ // add library as an usage instance, because when build a module, and
+ // if module inherited from base library, then build process will build
+ // library at first.
+ //
+ if(Token.PCD_USAGE.UNKNOWN == token.isUsageInstanceExist(libraryName)) {
+ packageName = GlobalData.getPackageNameForModule(libraryName);
+ usageInstance = new UsageInstance(token,
+ Token.PCD_USAGE.ALWAYS_CONSUMED,
+ pcdType,
+ CommonDefinition.ComponentTypeLibrary,
+ libPcdDataArray[tokenIndex][3],
+ null,
+ (String)libPcdDataArray[tokenIndex][5],
+ "",
+ libraryName,
+ packageName,
+ false);
+ token.addUsageInstance(usageInstance);
+ }
+ }
+ }
+
+ /**
+ Create usage instance for PCD token defined in MSA document
+
+ A PCD token maybe used by many modules, and every module is one of usage
+ instance of this token. For ALWAY_CONSUMED, SOMETIMES_CONSUMED, it is
+ consumer type usage instance of this token, and for ALWAYS_PRODUCED,
+ SOMETIMES_PRODUCED, it is produce type usage instance.
+
+ @param moduleName The name of module
+ @param tokenInfoInMsa The PCD token information array retrieved from MSA.
+
+ @return UsageInstance The usage instance created in memroy database.
+
+ @throws EntityException If token did not exist in database yet.
+
+ **/
+ private UsageInstance createUsageInstanceFromMSA(String moduleName,
+ Object[] tokenInfoInMsa)
+ throws EntityException {
+ String packageName = null;
+ UsageInstance usageInstance = null;
+ UUID tokenSpaceGuid = null;
+ UUID nullUUID = new UUID(0,0);
+ String primaryKeyString = null;
+ UUID platformTokenSpace = nullUUID;
+ Token token = null;
+ Token.PCD_TYPE pcdType = Token.PCD_TYPE.UNKNOWN;
+ Token.PCD_USAGE pcdUsage = Token.PCD_USAGE.UNKNOWN;
+
+ tokenSpaceGuid =((UUID)tokenInfoInMsa[2] == null) ? nullUUID :(UUID)tokenInfoInMsa[2];
+
+ primaryKeyString = Token.getPrimaryKeyString((String)tokenInfoInMsa[0],
+ tokenSpaceGuid,
+ platformTokenSpace);
+
+ //
+ // Get token object from memory database firstly.
+ //
+ if(dbManager.isTokenInDatabase(primaryKeyString)) {
+ token = dbManager.getTokenByKey(primaryKeyString);
+ } else {
+ throw new EntityException("The PCD token " + primaryKeyString + " defined in module " +
+ moduleName + " does not exist in FPD file!" );
+ }
+ pcdType = Token.getpcdTypeFromString((String)tokenInfoInMsa[1]);
+ pcdUsage = Token.getUsageFromString((String)tokenInfoInMsa[4]);
+
+ packageName = GlobalData.getPackageNameForModule(moduleName);
+
+ if(Token.PCD_USAGE.UNKNOWN != token.isUsageInstanceExist(moduleName)) {
+ //
+ // BUGBUG: It should *not* throw exception here. Becaues in MdePkg.fpd,
+ // more than on BaseLib exist. But why? need confirmation.
+ //
+ //throw new EntityException(
+ // "In module " + moduleName + " exist more than one PCD token " + token.cName
+ // );
+ ActionMessage.warning(this,
+ "In module " + moduleName + " exist more than one PCD token " + token.cName
+ );
+ return null;
+ }
+
+ //
+ // BUGBUG: following code could be enabled at current schema. Because
+ // current schema does not provide usage information.
+ //
+ // For FEATRURE_FLAG, FIXED_AT_BUILD, PATCH_IN_MODULE type PCD token, his
+ // usage is always ALWAYS_CONSUMED
+ //
+ //if((pcdType != Token.PCD_TYPE.DYNAMIC) &&
+ // (pcdType != Token.PCD_TYPE.DYNAMIC_EX)) {
+ pcdUsage = Token.PCD_USAGE.ALWAYS_CONSUMED;
+ //}
+
+ usageInstance = new UsageInstance(token,
+ pcdUsage,
+ pcdType,
+ CommonDefinition.getComponentType(SurfaceAreaQuery.getComponentType()),
+ tokenInfoInMsa[3],
+ null,
+ (String) tokenInfoInMsa[5],
+ "",
+ moduleName,
+ packageName,
+ false);
+
+ //
+ // Use default value defined in MSA to update datum of token,
+ // if datum of token does not defined in FPD file.
+ //
+ if((token.datum == null) &&(tokenInfoInMsa[3] != null)) {
+ token.datum = tokenInfoInMsa[3];
+ }
+
+ token.addUsageInstance(usageInstance);
+
+ return usageInstance;
+ }
+
+ /**
+ Create token instance object into memory database, the token information
+ comes for FPD file. Normally, FPD file will contain all token platform
+ informations.
+
+ This fucntion should be executed at firsly before others collection work
+ such as searching token information from MSA, SPD.
+
+ @return FrameworkPlatformDescriptionDocument The FPD document instance for furture usage.
+
+ @throws EntityException Failed to parse FPD xml file.
+
+ **/
+ private FrameworkPlatformDescriptionDocument createTokenInDBFromFPD()
+ throws EntityException {
+ XmlObject doc = null;
+ FrameworkPlatformDescriptionDocument fpdDoc = null;
+ int index = 0;
+ List pcdBuildDataArray = new ArrayList();
+ PcdBuildData pcdBuildData = null;
+ Token token = null;
+ UUID nullUUID = new UUID(0,0);
+ UUID platformTokenSpace= nullUUID;
+ List skuDataArray = new ArrayList();
+ SkuInstance skuInstance = null;
+ int skuIndex = 0;
+
+ //
+ // Get all tokens from FPD file and create token into database.
+ //
+
+ try {
+ doc = XmlObject.Factory.parse(new File(fpdFilePath));
+ } catch(IOException ioE) {
+ throw new EntityException("Can't find the FPD xml fle:" + fpdFilePath);
+ } catch(XmlException xmlE) {
+ throw new EntityException("Can't parse the FPD xml fle:" + fpdFilePath);
+ }
+
+ //
+ // Get memoryDatabaseManager instance from GlobalData.
+ //
+ if((dbManager = GlobalData.getPCDMemoryDBManager()) == null) {
+ throw new EntityException("The instance of PCD memory database manager is null");
+ }
+
+ dbManager = new MemoryDatabaseManager();
+
+ if(!(doc instanceof FrameworkPlatformDescriptionDocument)) {
+ throw new EntityException("File " + fpdFilePath +
+ " is not a FrameworkPlatformDescriptionDocument");
+ }
+
+ fpdDoc =(FrameworkPlatformDescriptionDocument)doc;
+
+ //
+ // Add all tokens in FPD into Memory Database.
+ //
+ pcdBuildDataArray =
+ fpdDoc.getFrameworkPlatformDescription().getPcdBuildDeclarations().getPcdBuildDataList();
+ for(index = 0;
+ index < fpdDoc.getFrameworkPlatformDescription().getPcdBuildDeclarations().sizeOfPcdBuildDataArray();
+ index ++) {
+ pcdBuildData = pcdBuildDataArray.get(index);
+ token = new Token(pcdBuildData.getCName(), new UUID(0, 0), new UUID(0, 0));
+ //
+ // BUGBUG: in FPD, should be defined as
+ //
+ token.datum = pcdBuildData.getDefaultValue();
+ token.hiiEnabled = pcdBuildData.getHiiEnable();
+ token.variableGuid = Token.getGUIDFromSchemaObject(pcdBuildData.getVariableGuid());
+ token.variableName = pcdBuildData.getVariableName();
+ token.variableOffset = Integer.decode(pcdBuildData.getDataOffset());
+ token.skuEnabled = pcdBuildData.getSkuEnable();
+ token.maxSkuCount = Integer.decode(pcdBuildData.getMaxSku());
+ token.skuId = Integer.decode(pcdBuildData.getSkuId());
+ token.skuDataArrayEnabled = pcdBuildData.getSkuDataArrayEnable();
+ token.assignedtokenNumber = Integer.decode(pcdBuildData.getToken().getStringValue());
+ skuDataArray = pcdBuildData.getSkuDataArray1();
+
+ if(skuDataArray != null) {
+ for(skuIndex = 0; skuIndex < skuDataArray.size(); skuIndex ++) {
+ //
+ // BUGBUG: Now in current schema, The value is defined as String type,
+ // it is not correct, the type should be same as the datumType
+ //
+ skuInstance = new SkuInstance(((PcdBuildData.SkuData)skuDataArray.get(skuIndex)).getId(),
+ ((PcdBuildData.SkuData)skuDataArray.get(skuIndex)).getValue());
+ token.skuData.add(skuInstance);
+ }
+ }
+
+ if(dbManager.isTokenInDatabase(Token.getPrimaryKeyString(token.cName,
+ token.tokenSpaceName,
+ platformTokenSpace))) {
+ //
+ // If found duplicate token, Should tool be hold?
+ //
+ ActionMessage.warning(this,
+ "Token " + token.cName + " exists in token database");
+ continue;
+ }
+ token.pcdType = Token.getpcdTypeFromString(pcdBuildData.getItemType().toString());
+ dbManager.addTokenToDatabase(Token.getPrimaryKeyString(token.cName,
+ token.tokenSpaceName,
+ platformTokenSpace),
+ token);
+ }
+
+ return fpdDoc;
+ }
+
+ /**
+ Update PCD token in memory database by help information in SPD.
+
+ After create token from FPD and create usage instance from MSA, we should collect
+ PCD package level information from SPD and update token information in memory
+ database.
+
+ @param usageInstance The usage instance defined in MSA and want to search in SPD.
+ @param packageFullPath The SPD file path.
+
+ @throws EntityException Failed to parse SPD xml file.
+
+ **/
+ private void updateTokenBySPD(UsageInstance usageInstance,
+ String packageFullPath)
+ throws EntityException {
+ PackageSurfaceAreaDocument pkgDoc = null;
+ List pcdEntryArray = new ArrayList();
+ int index;
+ boolean isFoundInSpd = false;
+ Token.DATUM_TYPE datumType = Token.DATUM_TYPE.UNKNOWN;
+
+ try {
+ pkgDoc =(PackageSurfaceAreaDocument)XmlObject.Factory.parse(new File(packageFullPath));
+ } catch(IOException ioE) {
+ throw new EntityException("Can't find the FPD xml fle:" + packageFullPath);
+ } catch(XmlException xmlE) {
+ throw new EntityException("Can't parse the FPD xml fle:" + packageFullPath);
+ }
+
+ pcdEntryArray = pkgDoc.getPackageSurfaceArea().getPcdDefinitions().getPcdEntryList();
+ for(index = 0; index < pcdEntryArray.size(); index ++) {
+ if(pcdEntryArray.get(index).getCName().equalsIgnoreCase(
+ usageInstance.parentToken.cName)) {
+ isFoundInSpd = true;
+ //
+ // From SPD file , we can get following information.
+ // Token: Token number defined in package level.
+ // PcdItemType: This item does not single one. It means all supported item type.
+ // datumType: UINT8, UNIT16, UNIT32, UINT64, VOID*, BOOLEAN
+ // datumSize: The size of default value or maxmine size.
+ // defaultValue: This value is defined in package level.
+ // HelpText: The help text is provided in package level.
+ //
+
+ usageInstance.parentToken.tokenNumber = Integer.decode(pcdEntryArray.get(index).getToken());
+
+ if(pcdEntryArray.get(index).getDatumType() != null) {
+ datumType = Token.getdatumTypeFromString(
+ pcdEntryArray.get(index).getDatumType().toString());
+ if(usageInstance.parentToken.datumType == Token.DATUM_TYPE.UNKNOWN) {
+ usageInstance.parentToken.datumType = datumType;
+ } else {
+ if(datumType != usageInstance.parentToken.datumType) {
+ throw new EntityException("Different datum types are defined for Token :" +
+ usageInstance.parentToken.cName);
+ }
+ }
+
+ } else {
+ throw new EntityException("The datum type for token " + usageInstance.parentToken.cName +
+ " is not defind in SPD file " + packageFullPath);
+ }
+
+ usageInstance.defaultValueInSPD = pcdEntryArray.get(index).getDefaultValue();
+ usageInstance.helpTextInSPD = "Help Text in SPD";
+
+ //
+ // If token's datum is not valid, it indicate that datum is not provided
+ // in FPD and defaultValue is not provided in MSA, then use defaultValue
+ // in SPD as the datum of token.
+ //
+ if(usageInstance.parentToken.datum == null) {
+ if(pcdEntryArray.get(index).getDefaultValue() != null) {
+ usageInstance.parentToken.datum = pcdEntryArray.get(index).getDefaultValue();
+ } else {
+ throw new EntityException("FPD does not provide datum for token " + usageInstance.parentToken.cName +
+ ", MSA and SPD also does not provide for this token!");
+ }
+ }
+ }
+ }
+
+ if(!isFoundInSpd ) {
+ ActionMessage.warning(this,
+ "Can *not* find the PCD token " + usageInstance.parentToken.cName +
+ " in SPD file!");
+ }
+ }
+
+ /**
+ check parameter for this action.
+
+ @throws EntityException Bad parameter.
+ **/
+ private void checkParameter() throws EntityException {
+ File file = null;
+
+ if((fpdFilePath == null) ||(workspacePath == null)) {
+ throw new EntityException("WorkspacePath and FPDFileName should be blank for CollectPCDAtion!");
+ }
+
+ if(fpdFilePath.length() == 0 || workspacePath.length() == 0) {
+ throw new EntityException("WorkspacePath and FPDFileName should be blank for CollectPCDAtion!");
+ }
+
+ file = new File(workspacePath);
+ if(!file.exists()) {
+ throw new EntityException("WorkpacePath " + workspacePath + " does not exist!");
+ }
+
+ file = new File(fpdFilePath);
+
+ if(!file.exists()) {
+ throw new EntityException("FPD File " + fpdFilePath + " does not exist!");
+ }
+ }
+
+ /**
+ Test case function
+
+ @param argv parameter from command line
+ **/
+ public static void main(String argv[]) throws EntityException {
+ CollectPCDAction ca = new CollectPCDAction();
+ ca.setWorkspacePath("G:/mdk");
+ ca.setFPDFilePath("G:/mdk/EdkNt32Pkg/build/Nt32.fpd");
+ ca.setActionMessageLevel(ActionMessage.MAX_MESSAGE_LEVEL);
+ GlobalData.initInfo("Tools" + File.separator + "Conf" + File.separator + "FrameworkDatabase.db",
+ "G:/mdk");
+ ca.execute();
+ }
+}
diff --git a/Tools/Source/GenBuild/org/tianocore/build/pcd/action/PCDAutoGenAction.java b/Tools/Source/GenBuild/org/tianocore/build/pcd/action/PCDAutoGenAction.java
new file mode 100644
index 0000000000..ca65c7546c
--- /dev/null
+++ b/Tools/Source/GenBuild/org/tianocore/build/pcd/action/PCDAutoGenAction.java
@@ -0,0 +1,452 @@
+/** @file
+ PCDAutoGenAction class.
+
+ This class is to manage how to generate the PCD information into Autogen.c and
+ Autogen.h.
+
+Copyright (c) 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+package org.tianocore.build.pcd.action;
+
+import java.io.File;
+import java.util.List;
+
+import org.tianocore.build.global.GlobalData;
+import org.tianocore.build.pcd.entity.MemoryDatabaseManager;
+import org.tianocore.build.pcd.entity.Token;
+import org.tianocore.build.pcd.entity.UsageInstance;
+import org.tianocore.build.pcd.exception.BuildActionException;
+import org.tianocore.build.pcd.exception.EntityException;
+
+/** This class is to manage how to generate the PCD information into Autogen.c and
+ Autogen.h.
+**/
+public class PCDAutoGenAction extends BuildAction {
+ ///
+ /// The reference of DBManager in GlobalData class.
+ ///
+ private MemoryDatabaseManager dbManager;
+ ///
+ /// The name of module which is analysised currently.
+ ///
+ private String moduleName;
+ ///
+ /// Wheter current module is PCD emulated driver. It is only for
+ /// emulated PCD driver and will be kept until PCD IMAGE tool ready.
+ ///
+ private boolean isEmulatedPCDDriver;
+ ///
+ /// The generated string for header file.
+ ///
+ private String hAutoGenString;
+ ///
+ /// The generated string for C code file.
+ ///
+ private String cAutoGenString;
+
+ /**
+ Set parameter ModuleName
+
+ @param moduleName the module name parameter.
+ **/
+ public void setModuleName(String moduleName) {
+ this.moduleName = moduleName;
+ }
+
+ /**
+ Set parameter isEmulatedPCDDriver
+
+ @param isEmulatedPCDDriver whether this module is PeiEmulatedPCD driver
+ **/
+ public void setIsEmulatedPCDDriver(boolean isEmulatedPCDDriver) {
+ this.isEmulatedPCDDriver = isEmulatedPCDDriver;
+ }
+
+ /**
+ Get the output of generated string for header file.
+
+ @return the string of header file for PCD
+ **/
+ public String OutputH() {
+ return hAutoGenString;
+ }
+
+ /**
+ Get the output of generated string for C Code file.
+
+ @return the string of C code file for PCD
+ **/
+ public String OutputC() {
+ return cAutoGenString;
+ }
+
+ /**
+ Construct function
+
+ This function mainly initialize some member variable.
+
+ @param moduleName Parameter of this action class.
+ @param isEmulatedPCDDriver Parameter of this action class.
+ **/
+ public PCDAutoGenAction(String moduleName, boolean isEmulatedPCDDriver) {
+ dbManager = null;
+ setIsEmulatedPCDDriver(isEmulatedPCDDriver);
+ setModuleName(moduleName);
+ }
+
+ /**
+ check the parameter for action class.
+
+ @throws BuildActionException Bad parameter.
+ **/
+ void checkParameter() throws BuildActionException {
+ if(!isEmulatedPCDDriver &&(moduleName == null)) {
+ throw new BuildActionException("Wrong module name parameter for PCDAutoGenAction tool!");
+ }
+
+ if(!isEmulatedPCDDriver && moduleName.length() == 0) {
+ throw new BuildActionException("Wrong module name parameter for PCDAutoGenAction tool!");
+ }
+
+ //
+ // Check the PCD memory database manager is valid.
+ //
+ if(GlobalData.getPCDMemoryDBManager() == null) {
+ throw new BuildActionException("Memory database has not been initlizated!");
+ }
+
+ dbManager = GlobalData.getPCDMemoryDBManager();
+
+ if(dbManager.getDBSize() == 0) {
+ throw new BuildActionException("Memory database does not contain any record!");
+ }
+
+ ActionMessage.debug(this,
+ "PCD memory database contains " + dbManager.getDBSize() + " PCD tokens");
+ }
+
+ /**
+ Core execution function for this action class.
+
+ All PCD information of this module comes from memory dabase. The collection
+ work should be done before this action execution.
+ Currently, we should generated all PCD information(maybe all dynamic) as array
+ in Pei emulated driver for simulating PCD runtime database.
+
+ @throws BuildActionException Failed to execute this aciton class.
+ **/
+ void performAction() throws BuildActionException {
+ ActionMessage.debug(this,
+ "Starting PCDAutoGenAction to generate autogen.h and autogen.c!...");
+
+ hAutoGenString = "";
+ cAutoGenString = "";
+
+ if(isEmulatedPCDDriver) {
+ generateAutogenForPCDEmulatedDriver();
+ } else {
+ generateAutogenForModule();
+ }
+ }
+
+ /**
+ Generate the autogen string for a common module.
+
+ All PCD information of this module comes from memory dabase. The collection
+ work should be done before this action execution.
+ **/
+ private void generateAutogenForModule()
+ {
+ int index;
+ List usageInstanceArray;
+
+ usageInstanceArray = dbManager.getUsageInstanceArrayByModuleName(moduleName);
+
+ if(usageInstanceArray.size() != 0) {
+ //
+ // Add "#include 'PcdLib.h'" for Header file
+ //
+ hAutoGenString = "#include \r\n";
+ }
+
+ for(index = 0; index < usageInstanceArray.size(); index ++) {
+ ActionMessage.debug(this,
+ "Module " + moduleName + "'s PCD [" + Integer.toHexString(index) +
+ "]: " + usageInstanceArray.get(index).parentToken.cName);
+ try {
+ usageInstanceArray.get(index).generateAutoGen();
+ hAutoGenString += usageInstanceArray.get(index).getHAutogenStr() + "\r\n";
+ cAutoGenString += usageInstanceArray.get(index).getCAutogenStr() + "\r\n";
+ } catch(EntityException exp) {
+ throw new BuildActionException(exp.getMessage());
+ }
+ }
+
+ ActionMessage.debug(this,
+ "Module " + moduleName + "'s PCD header file:\r\n" + hAutoGenString + "\r\n"
+ );
+ ActionMessage.debug(this,
+ "Module " + moduleName + "'s PCD C file:\r\n" + cAutoGenString + "\r\n"
+ );
+ }
+
+ /**
+ Generate all PCD autogen string and the emulated PCD IMAGE array for emulated driver.
+
+ Currently, we should generated all PCD information(maybe all dynamic) as array
+ in Pei emulated driver for simulating PCD runtime database.
+
+ **/
+ private void generateAutogenForPCDEmulatedDriver() {
+ int index;
+ Token[] tokenArray;
+ UsageInstance usageInstance;
+
+ //
+ // Add "#include 'PcdLib.h'" for Header file
+ //
+ hAutoGenString = "#include \r\n";
+
+ tokenArray = dbManager.getRecordArray();
+ for(index = 0; index < tokenArray.length; index ++) {
+ //
+ // Get one consumer instance and generate autogen for this token.
+ //
+ if(tokenArray[index].consumers != null ) {
+ if(tokenArray[index].consumers.size() == 0) {
+ continue;
+ }
+
+ usageInstance = tokenArray[index].consumers.get(0);
+ try {
+ usageInstance.generateAutoGen();
+ } catch(EntityException exp) {
+ throw new BuildActionException(exp.getMessage());
+ }
+
+ hAutoGenString += usageInstance.getHAutogenStr();
+ cAutoGenString += usageInstance.getCAutogenStr();
+
+ hAutoGenString += "\r\n";
+ cAutoGenString += "\r\n";
+ }
+ }
+
+ generatePCDEmulatedArray(tokenArray);
+
+ ActionMessage.debug(this,
+ "PCD emulated driver's header: \r\n" + hAutoGenString + "\r\n"
+ );
+ ActionMessage.debug(this,
+ "PCD emulated driver's C code: \r\n" + cAutoGenString + "\r\n"
+ );
+
+ }
+
+ /**
+ Generate PCDEmulated array in PCDEmulated driver for emulated runtime database.
+
+ @param tokenArray All PCD token in memory database.
+
+ @throws BuildActionException Unknown PCD_TYPE
+ **/
+ private void generatePCDEmulatedArray(Token[] tokenArray)
+ throws BuildActionException {
+ int index;
+ Token token;
+ String[] guidStrArray;
+ String value;
+
+ //
+ // The value of String type of PCD entry maybe use byte array but not string direcly
+ // such as {0x1, 0x2, 0x3}, and define PCD1_STRING_Value as L"string define here"
+ // For this case, we should generate a string array to C output and use the address
+ // of generated string array.
+ //
+ for(index = 0; index < tokenArray.length; index ++) {
+ token = tokenArray[index];
+
+ if((token.producers.size() == 0) &&(token.consumers.size() == 0)) {
+ //
+ // If no one use this PCD token, it will not generated in emulated array.
+ //
+ continue;
+ }
+ value = token.datum.toString();
+ if(token.datumType == Token.DATUM_TYPE.POINTER) {
+ if(!((value.charAt(0) == 'L' && value.charAt(1) == '"') ||(value.charAt(0) == '"'))) {
+ cAutoGenString += String.format("UINT8 _mPcdArray%08x[] = %s;\r\n",
+ index,
+ value
+ );
+ }
+ }
+ }
+
+ //
+ // Output emulated PCD entry array
+ //
+ cAutoGenString += "\r\nEMULATED_PCD_ENTRY gEmulatedPcdEntry[] = {\r\n";
+
+ for(index = 0; index < tokenArray.length; index ++) {
+ token = tokenArray[index];
+
+ if((token.producers.size() == 0) &&(token.consumers.size() == 0)) {
+ //
+ // If no one use this PCD token, it will not generated in emulated array.
+ //
+ continue;
+ }
+
+ if(index != 0) {
+ cAutoGenString += ",\r\n";
+ }
+
+ //
+ // Print Start "{" for a Token item in array
+ //
+ cAutoGenString += " {\r\n";
+
+ //
+ // Print Token Name
+ //
+ cAutoGenString += String.format(" _PCD_TOKEN_%s,\r\n", token.cName);
+
+ //
+ // Print Hii information
+ //
+ if(token.hiiEnabled) {
+ cAutoGenString += String.format(" TRUE,\r\n");
+ } else {
+ cAutoGenString += String.format(" FALSE,\r\n");
+ }
+
+ //
+ // Print sku information
+ //
+ if(token.skuEnabled) {
+ cAutoGenString += String.format(" TRUE,\r\n");
+ } else {
+ cAutoGenString += String.format(" FALSE,\r\n");
+ }
+
+ //
+ // Print maxSkuCount
+ //
+ cAutoGenString += String.format(" %d,\r\n", token.maxSkuCount);
+
+ cAutoGenString += String.format(" %d,\r\n", token.skuId);
+
+ if(token.variableGuid == null) {
+ cAutoGenString += " { 0x00000000, 0x0000, 0x0000, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } },\r\n";
+ } else {
+ guidStrArray =(token.variableGuid.toString()).split("-");
+
+ cAutoGenString += String.format(" { 0x%s, 0x%s, 0x%s, { 0x%s, 0x%s, 0x%s, 0x%s, 0x%s, 0x%s, 0x%s, 0x%s } },\r\n",
+ guidStrArray[0],
+ guidStrArray[1],
+ guidStrArray[2],
+ (guidStrArray[3].substring(0, 2)),
+ (guidStrArray[3].substring(2, 4)),
+ (guidStrArray[4].substring(0, 2)),
+ (guidStrArray[4].substring(2, 4)),
+ (guidStrArray[4].substring(4, 6)),
+ (guidStrArray[4].substring(6, 8)),
+ (guidStrArray[4].substring(8, 10)),
+ (guidStrArray[4].substring(10, 12))
+ );
+
+ }
+
+ value = token.datum.toString();
+ if(token.datumType == Token.DATUM_TYPE.POINTER) {
+ if((value.charAt(0) == 'L' && value.charAt(1) == '"') || value.charAt(0) == '"') {
+ cAutoGenString += String.format(" sizeof(_PCD_VALUE_%s),\r\n", token.cName);
+ cAutoGenString += String.format(" 0, %s, %s,\r\n", token.variableName, value);
+ } else {
+ cAutoGenString += String.format(" sizeof(_mPcdArray%08x),\r\n", index);
+ cAutoGenString += String.format(" 0, &_mPcdArray%08x, %s,\r\n", index, token.variableName);
+ }
+ } else {
+ switch(token.datumType) {
+ case UINT8:
+ cAutoGenString += " 1,\r\n";
+ break;
+ case UINT16:
+ cAutoGenString += " 2,\r\n";
+ break;
+ case UINT32:
+ cAutoGenString += " 4,\r\n";
+ break;
+ case UINT64:
+ cAutoGenString += " 8,\r\n";
+ break;
+ case BOOLEAN:
+ cAutoGenString += " 1,\r\n";
+ break;
+ default:
+ throw new BuildActionException("Unknown datum size");
+ }
+ cAutoGenString += String.format(" %s, %s, NULL,\r\n", value, token.variableName);
+ }
+
+ //
+ // Print end "}" for a token item in array
+ //
+ cAutoGenString += " }";
+ }
+
+ cAutoGenString += "\r\n};\r\n";
+ cAutoGenString += "\r\n";
+ cAutoGenString += "UINTN\r\n";
+ cAutoGenString += "GetPcdDataBaseSize(\r\n";
+ cAutoGenString += " VOID\r\n";
+ cAutoGenString += " )\r\n";
+ cAutoGenString += "{\r\n";
+ cAutoGenString += " return sizeof(gEmulatedPcdEntry);\r\n";
+ cAutoGenString += "}\r\n";
+ }
+
+ /**
+ Test case function
+
+ @param argv paramter from command line
+ **/
+ public static void main(String argv[]) {
+ String logFilePath = "G:/mdk/EdkNt32Pkg/build/Nt32.fpd";
+
+ //
+ // At first, CollectPCDAction should be invoked to collect
+ // all PCD information from SPD, MSA, FPD.
+ //
+ CollectPCDAction collectionAction = new CollectPCDAction();
+ GlobalData.initInfo("Tools" + File.separator + "Conf" + File.separator + "FrameworkDatabase.db",
+ "G:/mdk");
+
+ GlobalData.getPCDMemoryDBManager().setLogFileName(logFilePath + ".PCDMemroyDatabaseLog.txt");
+
+ try {
+ collectionAction.perform("G:/mdk",
+ logFilePath,
+ ActionMessage.MAX_MESSAGE_LEVEL);
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+
+ //
+ // Then execute the PCDAuotoGenAction to get generated Autogen.h and Autogen.c
+ //
+ PCDAutoGenAction autogenAction = new PCDAutoGenAction("HelloWorld",
+ true
+ );
+ autogenAction.execute();
+ }
+}
diff --git a/Tools/Source/GenBuild/org/tianocore/build/pcd/action/ShowPCDDatabaseAction.java b/Tools/Source/GenBuild/org/tianocore/build/pcd/action/ShowPCDDatabaseAction.java
new file mode 100644
index 0000000000..cd67dd46c9
--- /dev/null
+++ b/Tools/Source/GenBuild/org/tianocore/build/pcd/action/ShowPCDDatabaseAction.java
@@ -0,0 +1,130 @@
+/** @file
+ ShowPCDDatabase class.
+
+ This class is the action to diplay the PCD database.
+
+Copyright (c) 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+package org.tianocore.build.pcd.action;
+
+import java.io.File;
+
+import org.tianocore.build.global.GlobalData;
+import org.tianocore.build.pcd.exception.UIException;
+import org.tianocore.build.pcd.ui.PCDDatabaseFrame;
+
+/** This class is the action to show PCD database.
+**/
+public class ShowPCDDatabaseAction extends UIAction {
+ ///
+ /// The workspace path parameter.
+ ///
+ private String workspacePath;
+ ///
+ /// The FpdfileName parameter.
+ ///
+ private String fpdFilePath;
+
+ /**
+ set workspace path parameter for this action.
+
+ @param workspacePath the string of workspace path.
+ **/
+ public void setWorkspacePath(String workspacePath) {
+ this.workspacePath = workspacePath;
+ }
+
+ /**
+ set fpd file path parameter for this action.
+
+ @param fpdFilePath file path string
+ **/
+ public void setFPDFilePath(String fpdFilePath) {
+ this.fpdFilePath = "./" + fpdFilePath;
+ }
+
+ /**
+ check paramter for this action.
+
+ @throw UIException wrong paramter.
+ **/
+ void checkParamter() throws UIException {
+ File file = null;
+
+ if((fpdFilePath == null) ||(workspacePath == null)) {
+ throw new UIException("WorkspacePath and FPDFileName should be blank for CollectPCDAtion!");
+ }
+
+ if(fpdFilePath.length() == 0 || workspacePath.length() == 0) {
+ throw new UIException("WorkspacePath and FPDFileName should be blank for CollectPCDAtion!");
+ }
+
+ file = new File(workspacePath);
+ if(!file.exists()) {
+ throw new UIException("WorkpacePath " + workspacePath + " does not exist!");
+ }
+
+ file = new File(fpdFilePath);
+
+ if(!file.exists()) {
+ throw new UIException("FPD File " + fpdFilePath + " does not exist!");
+ }
+ }
+
+ /**
+ Core workflow function.
+
+ @throw UIException Fail to show PCD database.
+ **/
+ void performAction() throws UIException {
+ CollectPCDAction collectAction = null;
+ PCDDatabaseFrame dbFrame = null;
+
+ //
+ // Initialize global data.
+ //
+ GlobalData.initInfo("Tools" + File.separator + "Conf" + File.separator + "FrameworkDatabase.db",
+ workspacePath);
+ GlobalData.getPCDMemoryDBManager().setLogFileName(fpdFilePath + ".PCDMemroyDatabaseLog.txt");
+
+ //
+ // Collect PCD information.
+ //
+ collectAction = new CollectPCDAction();
+
+ try {
+ collectAction.perform(workspacePath,
+ fpdFilePath,
+ ActionMessage.LOG_MESSAGE_LEVEL);
+ } catch(Exception exp) {
+ throw new UIException(exp.getMessage());
+ }
+
+ //
+ // Start tree windows.
+ //
+ dbFrame = new PCDDatabaseFrame(GlobalData.getPCDMemoryDBManager());
+ }
+
+ /**
+ Entry function.
+
+ The action is run from command line.
+
+ @param argv command line parameter.
+ **/
+ public static void main(String[] argv) throws UIException {
+ ShowPCDDatabaseAction showAction = new ShowPCDDatabaseAction();
+ showAction.setWorkspacePath(argv[0]);
+ showAction.setFPDFilePath(argv[1]);
+ showAction.execute();
+ }
+}
diff --git a/Tools/Source/GenBuild/org/tianocore/build/pcd/action/UIAction.java b/Tools/Source/GenBuild/org/tianocore/build/pcd/action/UIAction.java
new file mode 100644
index 0000000000..2cde9b24ec
--- /dev/null
+++ b/Tools/Source/GenBuild/org/tianocore/build/pcd/action/UIAction.java
@@ -0,0 +1,83 @@
+/** @file
+ UIAction class.
+
+ This class is the parent action class of UI wizard.
+
+Copyright (c) 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+package org.tianocore.build.pcd.action;
+
+import org.tianocore.build.pcd.exception.UIException;
+
+/** This class is the parent class for all UI wizard action.
+**/
+public abstract class UIAction {
+ ///
+ /// original message level. when finish this action, original
+ /// message level will be restored.
+ ///
+ private int originalMessageLevel;
+
+ /**
+ Check the parameter for this aciton.
+
+ This function will be overrided by child class.
+ **/
+ abstract void checkParamter() throws UIException;
+
+ /**
+ Perform action.
+
+ This function will be overrided by child class.
+ **/
+ abstract void performAction() throws UIException;
+
+ /**
+ set the message level for this action.
+
+ @param messageLevel message level wanted.
+ **/
+ public void setMessageLevel(int messageLevel) {
+ originalMessageLevel = ActionMessage.messageLevel;
+ ActionMessage.messageLevel = messageLevel;
+ }
+
+ /**
+ log message for UI wizard aciton.
+
+ @param actionObj aciton instance object.
+ @param logStr log message string
+ **/
+ public static void logMsg(Object actionObj, String logStr) {
+ System.out.println(logStr);
+ }
+
+ /**
+ Warning message for UI wizard action.
+
+ @param warningObj action instance object.
+ @param warningStr warning message string.
+ **/
+ public static void warningMsg(Object warningObj, String warningStr) {
+ System.out.println(warningStr);
+ }
+
+ /**
+ Entry function for all UI wizard actions.
+ **/
+ public void execute() throws UIException {
+ checkParamter();
+ performAction();
+
+ ActionMessage.messageLevel = originalMessageLevel;
+ }
+}
diff --git a/Tools/Source/GenBuild/org/tianocore/build/pcd/entity/MemoryDatabaseManager.java b/Tools/Source/GenBuild/org/tianocore/build/pcd/entity/MemoryDatabaseManager.java
new file mode 100644
index 0000000000..6f4f8949ef
--- /dev/null
+++ b/Tools/Source/GenBuild/org/tianocore/build/pcd/entity/MemoryDatabaseManager.java
@@ -0,0 +1,306 @@
+/** @file
+ MemoryDatabaseManager class.
+
+ Database hold all PCD information comes from SPD, MSA, FPD file in memory.
+
+Copyright (c) 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+package org.tianocore.build.pcd.entity;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.tianocore.build.autogen.CommonDefinition;
+import org.tianocore.build.pcd.action.ActionMessage;
+
+/** Database hold all PCD information comes from SPD, MSA, FPD file in memory.
+**/
+public class MemoryDatabaseManager {
+ ///
+ /// Memory database. The string "cName + SpaceNameGuid" is primary key.
+ /// memory database is in global scope, and it will be used for others PCD tools.
+ ///
+ private static Map memoryDatabase = null;
+ ///
+ /// The log file name for dumping memory database.
+ ///
+ private static String logFileName = null;
+
+ /**
+ Constructure function
+ **/
+ public MemoryDatabaseManager() {
+ //
+ // Allocate memory for new database in global scope.
+ //
+ if (memoryDatabase == null) {
+ memoryDatabase = new HashMap();
+ }
+ }
+
+ /**
+ Get the log file name.
+ **/
+ public String getLogFileName() {
+ return logFileName;
+ }
+
+ /**
+ Set parameter log file name.
+
+ @param fileName log file name parameter.
+ **/
+ public void setLogFileName(String fileName) {
+ logFileName = fileName;
+ }
+
+ /**
+ Judege whether token exists in memory database
+
+ @param primaryKey the primaryKey for searching token
+
+ @retval TRUE - token already exist in database.
+ @retval FALSE - token does not exist in database.
+ **/
+ public boolean isTokenInDatabase(String primaryKey) {
+ return (memoryDatabase.get(primaryKey) != null);
+ }
+
+ /**
+ Add a pcd token into memory database.
+
+ @param primaryKey the primary key for searching token
+ @param token token instance
+ **/
+ public void addTokenToDatabase(String primaryKey, Token token) {
+ memoryDatabase.put(primaryKey, token);
+ }
+
+ /**
+ Get a token instance from memory database with primary key.
+
+ @param primaryKey the primary key for searching token
+
+ @return token instance.
+ **/
+ public Token getTokenByKey(String primaryKey) {
+ return memoryDatabase.get(primaryKey);
+ }
+
+ /**
+ Get the number of PCD token record in memory database.
+
+ @return the number of PCD token record in memory database.
+ **/
+ public int getDBSize() {
+ return memoryDatabase.size();
+ }
+
+ /**
+ Get the token record array contained all PCD token in memory database.
+
+ @return the token record array contained all PCD token in memory database.
+ **/
+ public Token[] getRecordArray() {
+ Token[] tokenArray = null;
+ Object[] dataArray = null;
+ Map.Entry entry = null;
+ int index = 0;
+
+ if (memoryDatabase == null) {
+ return null;
+ }
+
+ dataArray = memoryDatabase.entrySet().toArray();
+ tokenArray = new Token[memoryDatabase.size()];
+ for (index = 0; index < memoryDatabase.size(); index ++) {
+ entry =(Map.Entry) dataArray [index];
+ tokenArray[index] =(Token) entry.getValue();
+ }
+
+ return tokenArray;
+ }
+
+ /**
+ Get all PCD record for a module according to module's name.
+
+ @param moduleName the name of module.
+
+ @return all usage instance for this module in memory database.
+ **/
+ public List getUsageInstanceArrayByModuleName(String moduleName) {
+ Token[] tokenArray = null;
+ int recordIndex = 0;
+ int usageInstanceIndex = 0;
+ List usageInstanceArray = null;
+ UsageInstance usageInstance = null;
+ List returnArray = new ArrayList();
+
+ tokenArray = getRecordArray();
+
+ //
+ // Loop to find all PCD record related to current module
+ //
+ for (recordIndex = 0; recordIndex < getDBSize(); recordIndex ++) {
+ if (tokenArray[recordIndex].producers != null) {
+ usageInstanceArray = tokenArray[recordIndex].producers;
+ for (usageInstanceIndex = 0; usageInstanceIndex < usageInstanceArray.size(); usageInstanceIndex ++) {
+ usageInstance =(UsageInstance) usageInstanceArray.get(usageInstanceIndex);
+ if (usageInstance.moduleName.equalsIgnoreCase(moduleName)) {
+ returnArray.add(usageInstance);
+ }
+ }
+ }
+
+ if (tokenArray[recordIndex].consumers != null) {
+ usageInstanceArray = tokenArray[recordIndex].consumers;
+ for (usageInstanceIndex = 0; usageInstanceIndex < usageInstanceArray.size(); usageInstanceIndex ++) {
+ usageInstance =(UsageInstance) usageInstanceArray.get(usageInstanceIndex);
+ if (usageInstance.moduleName.equalsIgnoreCase(moduleName)) {
+ returnArray.add(usageInstance);
+ }
+ }
+ }
+ }
+
+ if (returnArray.size() == 0) {
+ ActionMessage.warning(this, "Can *not* find any usage instance for " + moduleName + " !");
+ }
+
+ return returnArray;
+ }
+
+ /**
+ Get all modules name who contains PCD information
+
+ @return Array for module name
+ **/
+ public List getAllModuleArray()
+ {
+ int indexToken = 0;
+ int usageIndex = 0;
+ int moduleIndex = 0;
+ Token[] tokenArray = null;
+ List moduleNames = new ArrayList();
+ UsageInstance usageInstance = null;
+ boolean bFound = false;
+
+ tokenArray = this.getRecordArray();
+ //
+ // Find all producer usage instance for retrieving module's name
+ //
+ for (indexToken = 0; indexToken < getDBSize(); indexToken ++) {
+ for (usageIndex = 0; usageIndex < tokenArray[indexToken].producers.size(); usageIndex ++) {
+ usageInstance = tokenArray[indexToken].producers.get(usageIndex);
+ bFound = false;
+ for (moduleIndex = 0; moduleIndex < moduleNames.size(); moduleIndex ++) {
+ if (moduleNames.get(moduleIndex).equalsIgnoreCase(usageInstance.moduleName)) {
+ bFound = true;
+ break;
+ }
+ }
+ if (!bFound) {
+ moduleNames.add(usageInstance.moduleName);
+ }
+ }
+ }
+
+ //
+ // Find all consumer usage instance for retrieving module's name
+ //
+ for (indexToken = 0; indexToken < getDBSize(); indexToken ++) {
+ for (usageIndex = 0; usageIndex < tokenArray[indexToken].consumers.size(); usageIndex ++) {
+ usageInstance = tokenArray[indexToken].consumers.get(usageIndex);
+ bFound = false;
+ for (moduleIndex = 0; moduleIndex < moduleNames.size(); moduleIndex ++) {
+ if (moduleNames.get(moduleIndex).equalsIgnoreCase(usageInstance.moduleName)) {
+ bFound = true;
+ break;
+ }
+ }
+ if (!bFound) {
+ moduleNames.add(usageInstance.moduleName);
+ }
+ }
+ }
+ return moduleNames;
+ }
+
+ /**
+ Dump all PCD record into file for reviewing.
+ **/
+ public void DumpAllRecords() {
+ BufferedWriter bWriter = null;
+ Object[] tokenArray = null;
+ Map.Entry entry = null;
+ Token token = null;
+ int index = 0;
+ int usageIndex = 0;
+ UsageInstance usageInstance = null;
+ String inheritString = null;
+ String componentTypeName = null;
+
+ try {
+ bWriter = new BufferedWriter(new FileWriter(new File(logFileName)));
+ tokenArray = memoryDatabase.entrySet().toArray();
+ for (index = 0; index < memoryDatabase.size(); index ++) {
+ entry =(Map.Entry) tokenArray [index];
+ token =(Token) entry.getValue();
+ bWriter.write("****** token [" + Integer.toString(index) + "] ******\r\n");
+ bWriter.write(" cName:" + token.cName + "\r\n");
+ for (usageIndex = 0; usageIndex < token.producers.size(); usageIndex ++) {
+ usageInstance =(UsageInstance)token.producers.get(usageIndex);
+ componentTypeName = CommonDefinition.getComponentTypeString(usageInstance.componentType);
+
+ if (usageInstance.isInherit) {
+ inheritString = "Inherit";
+ } else {
+ inheritString = "";
+ }
+ bWriter.write(String.format(" (Producer)#%d: %s:%s Package:%s %s\r\n",
+ usageIndex,
+ componentTypeName,
+ usageInstance.moduleName,
+ usageInstance.packageName,
+ inheritString
+ )
+ );
+ }
+ for (usageIndex = 0; usageIndex < token.consumers.size(); usageIndex ++) {
+ usageInstance =(UsageInstance)token.consumers.get(usageIndex);
+ componentTypeName = CommonDefinition.getComponentTypeString(usageInstance.componentType);
+ if (usageInstance.isInherit) {
+ inheritString = "Inherit";
+ } else {
+ inheritString = "";
+ }
+ bWriter.write(String.format(" (Consumer)#%d: %s:%s Package:%s %s\r\n",
+ usageIndex,
+ componentTypeName,
+ usageInstance.moduleName,
+ usageInstance.packageName,
+ inheritString
+ )
+ );
+ }
+ }
+ bWriter.close();
+ } catch (IOException exp) {
+ ActionMessage.warning(this, "Failed to open database log file: " + logFileName);
+ }
+ }
+}
diff --git a/Tools/Source/GenBuild/org/tianocore/build/pcd/entity/SkuInstance.java b/Tools/Source/GenBuild/org/tianocore/build/pcd/entity/SkuInstance.java
new file mode 100644
index 0000000000..2886506411
--- /dev/null
+++ b/Tools/Source/GenBuild/org/tianocore/build/pcd/entity/SkuInstance.java
@@ -0,0 +1,40 @@
+/** @file
+ SkuInstance class.
+
+ Sku instance contains ID and value, A pcd token maybe contains more than one Sku instance.
+
+Copyright (c) 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+package org.tianocore.build.pcd.entity;
+
+/** Sku instance contains ID and value, A pcd token maybe contains more than one Sku instance.
+**/
+public class SkuInstance {
+ ///
+ /// The id number of this SKU instance
+ ///
+ public int id;
+ ///
+ /// The value of this SKU instance
+ ///
+ public Object value;
+
+ /**
+ Constructure function
+
+ @param id sku id
+ @param value sku value for this id.
+ **/
+ public SkuInstance(int id, Object value) {
+ this.id = id;
+ this.value = value;
+ }
+}
diff --git a/Tools/Source/GenBuild/org/tianocore/build/pcd/entity/Token.java b/Tools/Source/GenBuild/org/tianocore/build/pcd/entity/Token.java
new file mode 100644
index 0000000000..e4ecfc034c
--- /dev/null
+++ b/Tools/Source/GenBuild/org/tianocore/build/pcd/entity/Token.java
@@ -0,0 +1,641 @@
+/** @file
+ Token class.
+
+ This module contains all classes releted to PCD token.
+
+Copyright (c) 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+package org.tianocore.build.pcd.entity;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.UUID;
+
+import org.tianocore.build.pcd.action.ActionMessage;
+
+/** This class is to descript a PCD token object. The information of a token mainly
+ comes from MSA, SPD and setting produced by platform developer.
+**/
+public class Token {
+ ///
+ /// Enumeration macro defintion for PCD type.
+ /// BUGBUG: Not use upcase charater is to facility for reading. It may be changed
+ /// in coding review.
+ public enum PCD_TYPE {FEATURE_FLAG, FIXED_AT_BUILD, PATCHABLE_IN_MODULE, DYNAMIC,
+ DYNAMIC_EX, UNKNOWN}
+
+ ///
+ /// Enumeration macro definition for datum type. All type mainly comes from ProcessBind.h.
+ /// Wizard maybe expand this type as "int, unsigned int, short, unsigned short etc" in
+ /// prompt dialog.
+ ///
+ public enum DATUM_TYPE {UINT8, UINT16, UINT32, UINT64, BOOLEAN, POINTER, UNKNOWN}
+
+ ///
+ /// Enumeration macor defintion for usage of PCD
+ ///
+ public enum PCD_USAGE {ALWAYS_PRODUCED, ALWAYS_CONSUMED, SOMETIMES_PRODUCED,
+ SOMETIMES_CONSUMED, UNKNOWN}
+
+ ///
+ /// cName is to identify a PCD entry and will be used for generating autogen.h/autogen.c.
+ /// cName will be defined in MSA, SPD and FPD, can be regarded as primary key with token space guid.
+ ///
+ public String cName;
+
+ ///
+ /// Token space name is the guid defined by token itself in package or module level. This
+ /// name mainly for DynamicEx type. For other PCD type token, his token space name is the
+ /// assignedtokenSpaceName as follows.
+ /// tokenSpaceName is defined in MSA, SPD, FPD, can be regarded as primary key with cName.
+ ///
+ public UUID tokenSpaceName;
+
+ ///
+ /// tokenNumber is allocated by platform. tokenNumber indicate an index for this token in
+ /// platform token space.
+ /// tokenNumber is defined in SPD, FPD.
+ ///
+ public int tokenNumber;
+
+ ///
+ /// The token space name assigned by platform. For Non-DynamicEx driver this value is same.
+ /// assignedtokenSpaceName is defined in FPD.
+ ///
+ public UUID assignedtokenSpaceName;
+
+ ///
+ /// The token number assigned by platform. The number indiect the offset of this token in platform
+ /// token space.
+ /// AssgiendtokenNumber is defined in FPD.
+ ///
+ public int assignedtokenNumber;
+
+ ///
+ /// pcdType is the PCD item type defined by platform developer.
+ ///
+ public PCD_TYPE pcdType;
+
+ ///
+ /// PCDtype is set by platform developer. It is final PCD type of this token.
+ /// SupportedPcdType is defined in SPD.
+ ///
+ public PCD_TYPE[] supportedpcdType;
+
+ ///
+ /// datumSize is to descript the fix size or max size for this token.
+ /// datumSize is defined in SPD.
+ ///
+ public int datumSize;
+
+ ///
+ /// datum type is to descript what type can be expressed by a PCD token.
+ /// datumType is defined in SPD.
+ ///
+ public DATUM_TYPE datumType;
+
+ ///
+ /// Isplatform is to descript whether this token is defined in platform level.
+ /// If token is belong to platform level. The value can be different for every
+ /// module. All are determined by platform developer.
+ ///
+ public boolean isPlatform;
+
+ ///
+ /// hiiEnabled is to indicate whether the token support Hii functionality.
+ /// hiiEnabled is defined in FPD.
+ ///
+ public boolean hiiEnabled;
+
+ ///
+ /// variableName is valid only when this token support Hii functionality. variableName
+ /// indicates the value of token is associated with what variable.
+ /// variableName is defined in FPD.
+ ///
+ public String variableName;
+
+ ///
+ /// variableGuid is the GUID this token associated with.
+ /// variableGuid is defined in FPD.
+ ///
+ public UUID variableGuid;
+
+ ///
+ /// Variable offset indicate the associated variable's offset in NV storage.
+ /// variableOffset is defined in FPD.
+ ///
+ public int variableOffset;
+
+ ///
+ /// skuEnabled is to indicate whether the token support Sku functionality.
+ /// skuEnabled is defined in FPD.
+ ///
+ public boolean skuEnabled;
+
+ ///
+ /// skuDataArrayEnabled is to indicate wheter use the skuData array or default value.
+ ///
+ public boolean skuDataArrayEnabled;
+
+ ///
+ /// skuData contains all value for SkuNumber of token.
+ /// skuData is defined in FPD.
+ ///
+ public List skuData;
+
+ ///
+ /// maxSkuCount indicate the max count of sku data.
+ /// maxSkuCount is defined in FPD.
+ ///
+ public int maxSkuCount;
+
+ ///
+ /// SkuId is the id of current selected SKU.
+ /// SkuId is defined in FPD.
+ ///
+ public int skuId;
+
+ ///
+ /// datum is the value set by platform developer.
+ /// datum is defined in FPD.
+ ///
+ public Object datum;
+
+ ///
+ /// Default value of this token.
+ /// This default value is defined in SPD level.
+ ///
+ public Object defaultValue;
+
+ ///
+ /// BUGBUG: fix comment
+ /// vpdEnabled is defined in FPD.
+ ///
+ public boolean vpdEnabled;
+
+ ///
+ /// BUGBUG: fix comment
+ /// vpdOffset is defined in FPD.
+ ///
+ public long vpdOffset;
+
+ ///
+ /// producers array record all module private information who produce this PCD token.
+ ///
+ public List producers;
+
+ ///
+ /// consumers array record all module private information who consume this PCD token.
+ ///
+ public List consumers;
+
+ /**
+ Constructure function.
+
+ Initialize the value of token.
+
+ @param cName The cName of this token
+ @param tokenSpaceName The tokenSpaceName of this token, it is a GUID.
+ @param assignedtokenSpaceName The assignedtokenSpaceName of this token, it is a GUID.
+
+ **/
+ public Token(String cName, UUID tokenSpaceName, UUID assignedtokenSpaceName) {
+ UUID nullUUID = new UUID(0, 0);
+
+ this.cName = cName;
+ this.tokenSpaceName =(tokenSpaceName == null) ? nullUUID : tokenSpaceName;
+ this.assignedtokenSpaceName =(assignedtokenSpaceName == null) ? nullUUID : assignedtokenSpaceName;
+ this.tokenNumber = 0;
+ this.assignedtokenNumber = 0;
+ this.pcdType = PCD_TYPE.UNKNOWN;
+ this.supportedpcdType = null;
+ this.isPlatform = false;
+ this.datumType = DATUM_TYPE.UNKNOWN;
+ this.datumSize = -1;
+ this.defaultValue = null;
+ this.datum = null;
+ this.hiiEnabled = false;
+ this.variableGuid = null;
+ this.variableName = "";
+ this.variableOffset = -1;
+ this.skuEnabled = false;
+ this.skuDataArrayEnabled = false;
+ this.skuId = -1;
+ this.maxSkuCount = -1;
+ this.skuData = new ArrayList();
+ this.vpdEnabled = false;
+ this.vpdOffset = -1;
+
+ this.producers = new ArrayList();
+ this.consumers = new ArrayList();
+ }
+
+ /**
+ Use "TokencName + "-" + SpaceTokenName" as primary key when adding token into database
+
+ @param cName Token name.
+ @param tokenSpaceName The token space guid defined in MSA or SPD
+ @param platformtokenSpaceName The token space guid for current platform token space,
+
+ @return primary key for this token in token database.
+ **/
+ public static String getPrimaryKeyString(String cName, UUID tokenSpaceName,
+ UUID platformtokenSpaceName) {
+ UUID nullUUID = new UUID(0, 0);
+
+ if (platformtokenSpaceName == nullUUID) {
+ return cName + "-" + tokenSpaceName.toString();
+ } else {
+ return cName + "-" + platformtokenSpaceName.toString();
+ }
+ }
+
+ /**
+ Judge datumType is valid
+
+ @param type The datumType want to be judged.
+
+ @retval TRUE - The type is valid.
+ @retval FALSE - The type is invalid.
+ **/
+ public static boolean isValiddatumType(DATUM_TYPE type) {
+ if ((type.ordinal() < DATUM_TYPE.UINT8.ordinal() ) ||
+ (type.ordinal() > DATUM_TYPE.POINTER.ordinal())) {
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ Judge pcdType is valid
+
+ @param type The PCdType want to be judged.
+
+ @retval TRUE - The type is valid.
+ @retval FALSE - The type is invalid.
+ **/
+ public static boolean isValidpcdType(PCD_TYPE type) {
+ if ((type.ordinal() < PCD_TYPE.FEATURE_FLAG.ordinal() ) ||
+ (type.ordinal() > PCD_TYPE.DYNAMIC_EX.ordinal())) {
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ Add an usage instance for token
+
+ @param usageInstance The usage instance
+
+ @retval TRUE - Success to add usage instance.
+ @retval FALSE - Fail to add usage instance
+ **/
+ public boolean addUsageInstance(UsageInstance usageInstance) {
+ if (usageInstance.usage == PCD_USAGE.UNKNOWN) {
+ return false;
+ }
+
+ if ((usageInstance.usage == PCD_USAGE.ALWAYS_PRODUCED) ||
+ (usageInstance.usage == PCD_USAGE.SOMETIMES_PRODUCED)) {
+ producers.add(usageInstance);
+ } else {
+ consumers.add(usageInstance);
+ }
+ return true;
+ }
+
+ /**
+ Judge whether exist an usage instance for this token
+
+ @param moduleName Use xmlFilePath as keyword to search the usage instance
+
+ @retval PCD_USAGE - if UsageInstance exists.
+ @retval UNKNOWN - if UsageInstance does not exist, return UNKONW.
+ **/
+ public PCD_USAGE isUsageInstanceExist(String moduleName) {
+ int index;
+ UsageInstance usageInstance;
+
+ if (moduleName == null) {
+ ActionMessage.warning(this, "Error parameter for isUsageInstanceExist() function!");
+ return PCD_USAGE.UNKNOWN;
+ }
+
+ if (moduleName.length() == 0) {
+ return PCD_USAGE.UNKNOWN;
+ }
+
+ //
+ // Searching the usage instance in module's producer and consumer according to
+ // module's name.
+ //
+ for (index = 0; index < producers.size(); index ++) {
+ usageInstance =(UsageInstance)producers.get(index);
+ if (usageInstance.moduleName.equalsIgnoreCase(moduleName)) {
+ return usageInstance.usage;
+ }
+ }
+
+ for (index = 0; index < consumers.size(); index ++) {
+ usageInstance =(UsageInstance)consumers.get(index);
+ if (usageInstance.moduleName.equalsIgnoreCase(moduleName)) {
+ return usageInstance.usage;
+ }
+ }
+ return PCD_USAGE.UNKNOWN;
+ }
+
+ /**
+ Get usage instance according to a MSA file name
+
+ @param moduleName The file path string of MSA file.
+
+ @return usage instance object.
+ **/
+ public UsageInstance getUsageInstance(String moduleName) {
+ int usageIndex;
+ UsageInstance usageInstance;
+
+ if (moduleName == null) {
+ ActionMessage.warning(this, "Error parameter for isUsageInstanceExist() function!");
+ return null;
+ }
+
+ if (moduleName.length() == 0) {
+ return null;
+ }
+
+ if (producers.size() != 0) {
+ for (usageIndex = 0; usageIndex < producers.size(); usageIndex ++) {
+ usageInstance =(UsageInstance)producers.get(usageIndex);
+ if (usageInstance.moduleName.equalsIgnoreCase(moduleName)) {
+ return usageInstance;
+ }
+ }
+ }
+
+ if (consumers.size() != 0) {
+ for (usageIndex = 0; usageIndex < consumers.size(); usageIndex ++) {
+ usageInstance =(UsageInstance)consumers.get(usageIndex);
+ if (usageInstance.moduleName.equalsIgnoreCase(moduleName)) {
+ return usageInstance;
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ Get the PCD_TYPE according to the string of PCD_TYPE
+
+ @param pcdTypeStr The string of PCD_TYPE
+
+ @return PCD_TYPE
+ **/
+ public static PCD_TYPE getpcdTypeFromString(String pcdTypeStr) {
+ if (pcdTypeStr == null) {
+ return PCD_TYPE.UNKNOWN;
+ }
+
+ if (pcdTypeStr.equalsIgnoreCase("FEATURE_FLAG")) {
+ return PCD_TYPE.FEATURE_FLAG;
+ } else if (pcdTypeStr.equalsIgnoreCase("FIXED_AT_BUILD")) {
+ return PCD_TYPE.FIXED_AT_BUILD;
+ } else if (pcdTypeStr.equalsIgnoreCase("PATCHABLE_IN_MODULE")) {
+ return PCD_TYPE.PATCHABLE_IN_MODULE;
+ } else if (pcdTypeStr.equalsIgnoreCase("DYNAMIC")) {
+ return PCD_TYPE.DYNAMIC;
+ } else if (pcdTypeStr.equalsIgnoreCase("DYNAMIC_EX")) {
+ return PCD_TYPE.DYNAMIC_EX;
+ } else {
+ return PCD_TYPE.UNKNOWN;
+ }
+ }
+
+ /**
+ Get the string of given datumType. This string will be used for generating autogen files
+
+ @param datumType Given datumType
+
+ @return The string of datum type.
+ **/
+ public static String getStringOfdatumType(DATUM_TYPE datumType) {
+ switch (datumType) {
+ case UINT8:
+ return "UINT8";
+ case UINT16:
+ return "UINT16";
+ case UINT32:
+ return "UINT32";
+ case UINT64:
+ return "UINT64";
+ case POINTER:
+ return "POINTER";
+ case BOOLEAN:
+ return "BOOLEAN";
+ }
+ return "UNKNOWN";
+ }
+
+ /**
+ Get the datumType according to a string.
+
+ @param datumTypeStr The string of datumType
+
+ @return DATUM_TYPE
+ **/
+ public static DATUM_TYPE getdatumTypeFromString(String datumTypeStr) {
+ if (datumTypeStr.equalsIgnoreCase("UINT8")) {
+ return DATUM_TYPE.UINT8;
+ } else if (datumTypeStr.equalsIgnoreCase("UINT16")) {
+ return DATUM_TYPE.UINT16;
+ } else if (datumTypeStr.equalsIgnoreCase("UINT32")) {
+ return DATUM_TYPE.UINT32;
+ } else if (datumTypeStr.equalsIgnoreCase("UINT64")) {
+ return DATUM_TYPE.UINT64;
+ } else if (datumTypeStr.equalsIgnoreCase("VOID*")) {
+ return DATUM_TYPE.POINTER;
+ } else if (datumTypeStr.equalsIgnoreCase("BOOLEAN")) {
+ return DATUM_TYPE.BOOLEAN;
+ }
+ return DATUM_TYPE.UNKNOWN;
+ }
+
+ /**
+ Get string of given pcdType
+
+ @param pcdType The given PcdType
+
+ @return The string of PCD_TYPE.
+ **/
+ public static String getStringOfpcdType(PCD_TYPE pcdType) {
+ switch (pcdType) {
+ case FEATURE_FLAG:
+ return "FEATURE_FLAG";
+ case FIXED_AT_BUILD:
+ return "FIXED_AT_BUILD";
+ case PATCHABLE_IN_MODULE:
+ return "PATCHABLE_IN_MODULE";
+ case DYNAMIC:
+ return "DYNAMIC";
+ case DYNAMIC_EX:
+ return "DYNAMIC_EX";
+ }
+ return "UNKNOWN";
+ }
+
+ /**
+ Get the PCD_USAGE according to a string
+
+ @param usageStr The string of PCD_USAGE
+
+ @return The PCD_USAGE
+ **/
+ public static PCD_USAGE getUsageFromString(String usageStr) {
+ if (usageStr == null) {
+ return PCD_USAGE.UNKNOWN;
+ }
+
+ if (usageStr.equalsIgnoreCase("ALWAYS_PRODUCED")) {
+ return PCD_USAGE.ALWAYS_PRODUCED;
+ } else if (usageStr.equalsIgnoreCase("SOMETIMES_PRODUCED")) {
+ return PCD_USAGE.SOMETIMES_PRODUCED;
+ } else if (usageStr.equalsIgnoreCase("ALWAYS_CONSUMED")) {
+ return PCD_USAGE.ALWAYS_CONSUMED;
+ } else if (usageStr.equalsIgnoreCase("SOMETIMES_CONSUMED")) {
+ return PCD_USAGE.SOMETIMES_CONSUMED;
+ }
+
+ return PCD_USAGE.UNKNOWN;
+ }
+
+ /**
+ Get the string of given PCD_USAGE
+
+ @param usage The given PCD_USAGE
+
+ @return The string of PDC_USAGE.
+ **/
+ public static String getStringOfUsage(PCD_USAGE usage) {
+ switch (usage) {
+ case ALWAYS_PRODUCED:
+ return "ALWAYS_PRODUCED";
+ case ALWAYS_CONSUMED:
+ return "ALWAYS_CONSUMED";
+ case SOMETIMES_PRODUCED:
+ return "SOMETIMES_PRODUCED";
+ case SOMETIMES_CONSUMED:
+ return "SOMETIMES_CONSUMED";
+ }
+ return "UNKNOWN";
+ }
+
+ /**
+ Get the Defined datumType string for autogen. The string is for generating some MACROs in Autogen.h
+
+ @param datumType The given datumType
+
+ @return string of datum type for autogen.
+ **/
+ public static String GetAutogenDefinedatumTypeString(DATUM_TYPE datumType) {
+ switch (datumType) {
+
+ case UINT8:
+ return "8";
+ case UINT16:
+ return "16";
+ case BOOLEAN:
+ return "BOOL";
+ case POINTER:
+ return "PTR";
+ case UINT32:
+ return "32";
+ case UINT64:
+ return "64";
+ default:
+ return null;
+ }
+ }
+
+ /**
+ Get the datumType String for Autogen. This string will be used for generating defintions of PCD token in autogen
+
+ @param datumType The given datumType
+
+ @return string of datum type.
+ **/
+ public static String getAutogendatumTypeString(DATUM_TYPE datumType) {
+ switch (datumType) {
+ case UINT8:
+ return "UINT8";
+ case UINT16:
+ return "UINT16";
+ case UINT32:
+ return "UINT32";
+ case UINT64:
+ return "UINT64";
+ case POINTER:
+ return "VOID*";
+ case BOOLEAN:
+ return "BOOLEAN";
+ }
+ return null;
+ }
+
+ /**
+ Get the datumType string for generating some MACROs in autogen file of Library
+
+ @param datumType The given datumType
+
+ @return String of datum for genrating bit charater.
+ **/
+ public static String getAutogenLibrarydatumTypeString(DATUM_TYPE datumType) {
+ switch (datumType) {
+ case UINT8:
+ return "8";
+ case UINT16:
+ return "16";
+ case BOOLEAN:
+ return "Bool";
+ case POINTER:
+ return "Ptr";
+ case UINT32:
+ return "32";
+ case UINT64:
+ return "64";
+ default:
+ return null;
+ }
+ }
+
+ /**
+ UUID defined in Schems is object, this function is to tranlate this object
+ to UUID data.
+
+ @param uuidObj The object comes from schema.
+
+ @return The traslated UUID instance.
+ **/
+ public static UUID getGUIDFromSchemaObject(Object uuidObj) {
+ UUID uuid;
+ if (uuidObj.toString().equalsIgnoreCase("0")) {
+ uuid = new UUID(0,0);
+ } else {
+ uuid = UUID.fromString(uuidObj.toString());
+ }
+
+ return uuid;
+ }
+}
+
+
+
+
diff --git a/Tools/Source/GenBuild/org/tianocore/build/pcd/entity/UsageInstance.java b/Tools/Source/GenBuild/org/tianocore/build/pcd/entity/UsageInstance.java
new file mode 100644
index 0000000000..a11633d91b
--- /dev/null
+++ b/Tools/Source/GenBuild/org/tianocore/build/pcd/entity/UsageInstance.java
@@ -0,0 +1,471 @@
+/** @file
+ UsageInstance class.
+
+ This class indicate an usage instance for a PCD token. This instance maybe a module
+ or platform setting. When a module produce or cosume a PCD token, then this module
+ is an usage instance for this PCD token.
+
+Copyright (c) 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+package org.tianocore.build.pcd.entity;
+
+
+import org.tianocore.build.pcd.exception.EntityException;
+import org.tianocore.build.pcd.action.ActionMessage;
+
+import org.tianocore.build.autogen.CommonDefinition;
+
+/**
+ This class indicate an usage instance for a PCD token. This instance maybe a module
+ or platform setting. When a module produce or cosume a PCD token, then this module
+ is an usage instance for this PCD token.
+**/
+public class UsageInstance {
+ ///
+ /// This parent that this usage instance belongs to.
+ ///
+ public Token parentToken;
+ ///
+ /// The usage of this token for platform or module.
+ ///
+ public Token.PCD_USAGE usage;
+ ///
+ /// Whether this usage instance inherit from library
+ ///
+ public boolean isInherit;
+ ///
+ /// The pcd type of this token for module.
+ ///
+ public Token.PCD_TYPE modulePcdType;
+ ///
+ /// The name of the module who contains this PCD.
+ ///
+ public String moduleName;
+ ///
+ /// The name of the package whose module contains this PCD.
+ ///
+ public String packageName;
+ ///
+ /// The component type for this usage instance.
+ ///
+ public int componentType;
+ ///
+ /// The default value defined in MSA has high prior than defined in SPD.
+ ///
+ public Object defaultValueInMSA;
+ ///
+ /// The default value defined in SPD.
+ ///
+ public Object defaultValueInSPD;
+ ///
+ /// Help text in MSA
+ ///
+ public String helpTextInMSA;
+ ///
+ /// Help text in SPD
+ ///
+ public String helpTextInSPD;
+ ///
+ /// Autogen string for header file.
+ ///
+ public String hAutogenStr;
+ /**
+ * Auotgen string for C code file.
+ */
+ public String cAutogenStr;
+
+ /**
+ Constructure function
+
+ @param parentToken Member variable.
+ @param usage Member variable.
+ @param pcdType Member variable.
+ @param componentType Member variable.
+ @param defaultValueInMSA Member variable.
+ @param defaultValueInSPD Member variable.
+ @param helpTextInMSA Member variable.
+ @param helpTextInSPD Member variable.
+ @param moduleName Member variable.
+ @param packageName Member variable.
+ @param isInherit Member variable.
+ **/
+ public UsageInstance(
+ Token parentToken,
+ Token.PCD_USAGE usage,
+ Token.PCD_TYPE pcdType,
+ int componentType,
+ Object defaultValueInMSA,
+ Object defaultValueInSPD,
+ String helpTextInMSA,
+ String helpTextInSPD,
+ String moduleName,
+ String packageName,
+ boolean isInherit
+ )
+ {
+ this.parentToken = parentToken;
+ this.usage = usage;
+ this.modulePcdType = pcdType;
+ this.componentType = componentType;
+ this.defaultValueInMSA = defaultValueInMSA;
+ this.defaultValueInSPD = defaultValueInSPD;
+ this.helpTextInMSA = helpTextInMSA;
+ this.helpTextInSPD = helpTextInSPD;
+ this.moduleName = moduleName;
+ this.packageName = packageName;
+ this.isInherit = isInherit;
+ }
+
+ /**
+ Generate autogen string for header file and C code file.
+
+ @throws EntityException Fail to generate.
+ **/
+ public void generateAutoGen() throws EntityException {
+ Object value = null;
+ int tokenNumber = 0;
+
+ hAutogenStr = "";
+ cAutogenStr = "";
+
+ value = this.parentToken.datum;
+
+ //
+ // If this pcd token's PCD_TYPE is DYNAMIC_EX, use itself token space name
+ // otherwices use assgined token space name from tool automatically.
+ //
+ if(parentToken.pcdType == Token.PCD_TYPE.DYNAMIC_EX) {
+ tokenNumber = parentToken.tokenNumber;
+ } else {
+ tokenNumber = parentToken.assignedtokenNumber;
+ }
+
+ hAutogenStr += String.format("#define _PCD_TOKEN_%s 0x%016x\r\n",
+ parentToken.cName, tokenNumber);
+
+ switch(modulePcdType) {
+ case FEATURE_FLAG:
+ //
+ // BUGBUG: The judegement of module PCD type and platform PCD type should not be
+ // done here, but in wizard tools, But here is just following something
+ // PcdEmulation driver.
+ //
+ if(parentToken.pcdType.ordinal() > Token.PCD_TYPE.FEATURE_FLAG.ordinal()) {
+ throw new EntityException(
+ String.format(
+ "%s:Platform PCD Type %d is not compatible with Module PCD Type %d\r\n",
+ parentToken.cName,
+ parentToken.pcdType.name(),
+ modulePcdType.name()
+ )
+ );
+ }
+
+ if(CommonDefinition.isLibraryComponent(componentType)) {
+ hAutogenStr += String.format(
+ "extern const BOOLEAN _gPcd_FixedAtBuild_%s;\r\n",
+ parentToken.cName
+ );
+ hAutogenStr += String.format(
+ "#define _PCD_MODE_%s_%s _gPcd_FixedAtBuild_%s\r\n",
+ parentToken.GetAutogenDefinedatumTypeString(parentToken.datumType),
+ parentToken.cName,
+ parentToken.cName
+ );
+ } else {
+ hAutogenStr += String.format(
+ "#define _PCD_VALUE_%s %s\r\n",
+ parentToken.cName,
+ value.toString()
+ );
+ hAutogenStr += String.format(
+ "extern const BOOLEAN _gPcd_FixedAtBuild_%s;\r\n",
+ parentToken.cName
+ );
+ cAutogenStr += String.format(
+ "GLOBAL_REMOVE_IF_UNREFERENCED const BOOLEAN _gPcd_FixedAtBuild_%s = _PCD_VALUE_%s;\r\n",
+ parentToken.cName,
+ parentToken.cName
+ );
+ hAutogenStr += String.format(
+ "#define _PCD_MODE_%s_%s _PCD_VALUE_%s\r\n",
+ Token.GetAutogenDefinedatumTypeString(parentToken.datumType),
+ parentToken.cName,
+ parentToken.cName
+ );
+ }
+ break;
+ case FIXED_AT_BUILD:
+ //
+ // BUGBUG: The judegement of module PCD type and platform PCD type should not be
+ // done here, but in wizard tools, But here is just following something
+ // PcdEmulation driver.
+ //
+ if(parentToken.pcdType.ordinal() > Token.PCD_TYPE.FIXED_AT_BUILD.ordinal()) {
+ throw new EntityException(
+ String.format(
+ "%s:Platform PCD Type %d is not compatible with Module PCD Type %d\r\n",
+ parentToken.cName,
+ parentToken.pcdType.name(),
+ modulePcdType.name()
+ )
+ );
+ }
+
+ if(CommonDefinition.isLibraryComponent(componentType)) {
+ hAutogenStr += String.format(
+ "extern const %s _gPcd_FixedAtBuild_%s;\r\n",
+ Token.getAutogendatumTypeString(parentToken.datumType),
+ parentToken.cName
+ );
+ hAutogenStr += String.format(
+ "#define _PCD_MODE_%s_%s _gPcd_FixedAtBuild_%s\r\n",
+ Token.GetAutogenDefinedatumTypeString(parentToken.datumType),
+ parentToken.cName,
+ parentToken.cName
+ );
+ } else {
+ hAutogenStr += String.format(
+ "#define _PCD_VALUE_%s %s\r\n",
+ parentToken.cName,
+ value.toString()
+ );
+ hAutogenStr += String.format(
+ "extern const %s _gPcd_FixedAtBuild_%s;\r\n",
+ Token.getAutogendatumTypeString(parentToken.datumType),
+ parentToken.cName
+ );
+ cAutogenStr += String.format(
+ "GLOBAL_REMOVE_IF_UNREFERENCED const %s _gPcd_FixedAtBuild_%s = _PCD_VALUE_%s;\r\n",
+ Token.getAutogendatumTypeString(parentToken.datumType),
+ parentToken.cName,
+ parentToken.cName
+ );
+ hAutogenStr += String.format(
+ "#define _PCD_MODE_%s_%s _PCD_VALUE_%s\r\n",
+ Token.GetAutogenDefinedatumTypeString(parentToken.datumType),
+ parentToken.cName,
+ parentToken.cName
+ );
+ }
+ break;
+ case PATCHABLE_IN_MODULE:
+ //
+ // BUGBUG: The judegement of module PCD type and platform PCD type should not be
+ // done here, but in wizard tools, But here is just following something
+ // PcdEmulation driver.
+ //
+ if(parentToken.pcdType.ordinal() > Token.PCD_TYPE.PATCHABLE_IN_MODULE.ordinal()) {
+ throw new EntityException(
+ String.format(
+ "%s:Platform PCD Type %d is not compatible with Module PCD Type %d\r\n",
+ parentToken.cName,
+ parentToken.pcdType.name(),
+ modulePcdType.name()
+ )
+ );
+ }
+
+ if(CommonDefinition.isLibraryComponent(componentType)) {
+ hAutogenStr += String.format(
+ "extern %s _gPcd_BinaryPatch_%s;\r\n",
+ Token.getAutogendatumTypeString(parentToken.datumType),
+ parentToken.cName
+ );
+ hAutogenStr += String.format(
+ "#define _PCD_MODE_%s_%s _gPcd_BinaryPatch_%s\r\n",
+ Token.GetAutogenDefinedatumTypeString(parentToken.datumType),
+ parentToken.cName,
+ parentToken.cName
+ );
+ } else {
+ hAutogenStr += String.format(
+ "#define _PCD_VALUE_%s %s\r\n",
+ parentToken.cName,
+ value
+ );
+ hAutogenStr += String.format(
+ "extern %s _gPcd_BinaryPatch_%s;\r\n",
+ Token.getAutogendatumTypeString(parentToken.datumType),
+ parentToken.cName
+ );
+ cAutogenStr += String.format(
+ "GLOBAL_REMOVE_IF_UNREFERENCED %s _gPcd_BinaryPatch_%s = _PCD_VALUE_%s;\r\n",
+ Token.getAutogendatumTypeString(parentToken.datumType),
+ parentToken.cName,
+ parentToken.cName
+ );
+ hAutogenStr += String.format(
+ "#define _PCD_MODE_%s_%s _gPcd_BinaryPatch_%s\r\n",
+ Token.GetAutogenDefinedatumTypeString(parentToken.datumType),
+ parentToken.cName,
+ parentToken.cName
+ );
+ }
+
+ break;
+ case DYNAMIC:
+ //
+ // BUGBUG: The judegement of module PCD type and platform PCD type should not be
+ // done here, but in wizard tools, But here is just following something
+ // PcdEmulation driver.
+ //
+ if(parentToken.pcdType.ordinal() > Token.PCD_TYPE.DYNAMIC.ordinal()) {
+ throw new EntityException(
+ String.format(
+ "%s:Platform PCD Type %d is not compatible with Module PCD Type %d\r\n",
+ parentToken.cName,
+ parentToken.pcdType.name(),
+ modulePcdType.name()
+ )
+ );
+ }
+
+ switch(parentToken.pcdType) {
+ case FEATURE_FLAG:
+ if(CommonDefinition.isLibraryComponent(componentType)) {
+ hAutogenStr += String.format(
+ "extern const BOOLEAN _gPcd_FixedAtBuild_%s;\r\n",
+ parentToken.cName
+ );
+ hAutogenStr += String.format(
+ "#define _PCD_MODE_%s_%s _gPcd_FixedAtBuild_%s\r\n",
+ Token.GetAutogenDefinedatumTypeString(parentToken.datumType),
+ parentToken.cName,
+ parentToken.cName
+ );
+ } else {
+ hAutogenStr += String.format(
+ "#define _PCD_VALUE_%s %s\r\n",
+ parentToken.cName,
+ value
+ );
+ hAutogenStr += String.format(
+ "extern const BOOLEAN _gPcd_FixedAtBuild_%s;\r\n",
+ parentToken.cName
+ );
+ cAutogenStr += String.format(
+ "const BOOLEAN _gPcd_FixedAtBuild_%s = _PCD_VALUE_%s;\r\n",
+ parentToken.cName,
+ parentToken.cName
+ );
+ hAutogenStr += String.format(
+ "#define _PCD_MODE_%s_%s _PCD_VALUE_%s\r\n",
+ Token.GetAutogenDefinedatumTypeString(parentToken.datumType),
+ parentToken.cName,
+ parentToken.cName
+ );
+ }
+ break;
+ case FIXED_AT_BUILD:
+ if(CommonDefinition.isLibraryComponent(componentType)) {
+ hAutogenStr += String.format(
+ "extern const %s _gPcd_FixedAtBuild_%s;\r\n",
+ Token.getAutogendatumTypeString(parentToken.datumType),
+ parentToken.cName
+ );
+ hAutogenStr += String.format(
+ "#define _PCD_MODE_%s_%s _gPcd_FixedAtBuild_%s\r\n",
+ Token.GetAutogenDefinedatumTypeString(parentToken.datumType),
+ parentToken.cName,
+ parentToken.cName
+ );
+
+ } else {
+ hAutogenStr += String.format(
+ "#define _PCD_VALUE_%s %s\r\n",
+ parentToken.cName,
+ value
+ );
+ hAutogenStr += String.format(
+ "extern const %s _gPcd_FixedAtBuild_%s\r\n",
+ Token.getAutogendatumTypeString(parentToken.datumType),
+ parentToken.cName
+ );
+ cAutogenStr += String.format(
+ "const %s _gPcd_FixedAtBuild_%s = _PCD_VALUE_%s;\r\n",
+ Token.GetAutogenDefinedatumTypeString(parentToken.datumType),
+ parentToken.cName,
+ parentToken.cName
+ );
+ hAutogenStr += String.format(
+ "#define _PCD_MODE_%s_%s _PCD_VALUE_%s\r\n",
+ Token.GetAutogenDefinedatumTypeString(parentToken.datumType),
+ parentToken.cName,
+ parentToken.cName
+ );
+ }
+ break;
+ case PATCHABLE_IN_MODULE:
+ hAutogenStr += String.format(
+ "#define _PCD_VALUE_%s %s\r\n",
+ parentToken.cName,
+ value
+ );
+ hAutogenStr += String.format(
+ "extern %s _gPcd_BinaryPatch_%s;\r\n",
+ Token.getAutogendatumTypeString(parentToken.datumType),
+ parentToken.cName,
+ parentToken.cName
+ );
+ cAutogenStr += String.format(
+ "%s _gPcd_BinaryPatch_%s = _PCD_VALUE_%s;",
+ Token.getAutogendatumTypeString(parentToken.datumType),
+ parentToken.cName,
+ parentToken.cName
+ );
+ hAutogenStr += String.format(
+ "#define _PCD_MODE_%s_%s _gPcd_BinaryPatch_%s\r\n",
+ Token.GetAutogenDefinedatumTypeString(parentToken.datumType),
+ parentToken.cName,
+ parentToken.cName
+ );
+ break;
+ case DYNAMIC:
+ hAutogenStr += String.format(
+ "#define _PCD_MODE_%s_%s LibPcdGet%s(_PCD_TOKEN_%s)\r\n",
+ Token.GetAutogenDefinedatumTypeString(parentToken.datumType),
+ parentToken.cName,
+ Token.getAutogenLibrarydatumTypeString(parentToken.datumType),
+ parentToken.cName
+ );
+ break;
+ default:
+ ActionMessage.log(
+ this,
+ "The PCD_TYPE setted by platform is unknown"
+ );
+ }
+ break;
+ case DYNAMIC_EX:
+ break;
+ }
+ }
+
+ /**
+ Get the autogen string for header file.
+
+ @return The string of header file.
+ **/
+ public String getHAutogenStr() {
+ return hAutogenStr;
+ }
+
+ /**
+ Get the autogen string for C code file.
+
+ @return The string of C Code file.
+ **/
+ public String getCAutogenStr() {
+ return cAutogenStr;
+ }
+}
+
diff --git a/Tools/Source/GenBuild/org/tianocore/build/pcd/exception/BuildActionException.java b/Tools/Source/GenBuild/org/tianocore/build/pcd/exception/BuildActionException.java
new file mode 100644
index 0000000000..357ebf017a
--- /dev/null
+++ b/Tools/Source/GenBuild/org/tianocore/build/pcd/exception/BuildActionException.java
@@ -0,0 +1,33 @@
+/** @file
+ BuildActionException class.
+
+ BuildAction Exception deals with all build action exceptions.
+
+Copyright (c) 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+package org.tianocore.build.pcd.exception;
+
+import org.apache.tools.ant.BuildException;
+
+/**
+ BuildAction Exception deals with all build action exceptions.
+**/
+public class BuildActionException extends BuildException {
+ static final long serialVersionUID = -7034897190740066939L;
+ /**
+ Constructure function
+
+ @param reason exception message string.
+ **/
+ public BuildActionException(String reason) {
+ super(reason);
+ }
+}
diff --git a/Tools/Source/GenBuild/org/tianocore/build/pcd/exception/EntityException.java b/Tools/Source/GenBuild/org/tianocore/build/pcd/exception/EntityException.java
new file mode 100644
index 0000000000..1e7ebfcbe1
--- /dev/null
+++ b/Tools/Source/GenBuild/org/tianocore/build/pcd/exception/EntityException.java
@@ -0,0 +1,31 @@
+/** @file
+ EntityException class.
+
+ The class handle the exception throwed by entity class.
+
+Copyright (c) 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+package org.tianocore.build.pcd.exception;
+
+/**
+ The class handle the exception throwed by entity class.
+**/
+public class EntityException extends Exception {
+ static final long serialVersionUID = -8034897190740066939L;
+ /**
+ Constructure function
+
+ @param expStr exception message string.
+ **/
+ public EntityException(String expStr) {
+ super("[EntityException]:" + expStr);
+ }
+}
diff --git a/Tools/Source/GenBuild/org/tianocore/build/pcd/exception/UIException.java b/Tools/Source/GenBuild/org/tianocore/build/pcd/exception/UIException.java
new file mode 100644
index 0000000000..96575a1450
--- /dev/null
+++ b/Tools/Source/GenBuild/org/tianocore/build/pcd/exception/UIException.java
@@ -0,0 +1,31 @@
+/** @file
+ UIException class.
+
+ The class handle the exception throwed by UI action class.
+
+Copyright (c) 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+package org.tianocore.build.pcd.exception;
+
+/**
+ The class handle the exception throwed by UI action class.
+**/
+public class UIException extends Exception {
+ static final long serialVersionUID = -7034897190740066930L;
+ /**
+ Constructure function
+
+ @param reason exception message string.
+ **/
+ public UIException(String reason) {
+ super(reason);
+ }
+}
diff --git a/Tools/Source/GenBuild/org/tianocore/build/pcd/ui/PCDDatabaseFrame.java b/Tools/Source/GenBuild/org/tianocore/build/pcd/ui/PCDDatabaseFrame.java
new file mode 100644
index 0000000000..81eb63025b
--- /dev/null
+++ b/Tools/Source/GenBuild/org/tianocore/build/pcd/ui/PCDDatabaseFrame.java
@@ -0,0 +1,184 @@
+/** @file
+ PCDDatabaseFrame class.
+
+ The class is the frame class for displaying PCD database in tree method.
+
+Copyright (c) 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+package org.tianocore.build.pcd.ui;
+
+import java.awt.*;
+import java.awt.event.*;
+
+import javax.swing.*;
+import javax.swing.tree.DefaultMutableTreeNode;
+
+import org.tianocore.build.pcd.action.ActionMessage;
+import org.tianocore.build.pcd.entity.MemoryDatabaseManager;
+import org.tianocore.build.pcd.entity.Token;
+import org.tianocore.build.pcd.entity.UsageInstance;
+
+/**
+ The class is the frame class for displaying PCD database in tree method.
+**/
+public class PCDDatabaseFrame extends JFrame {
+ static final long serialVersionUID = -7034897190740068939L;
+ ///
+ /// Database instance
+ ///
+ private MemoryDatabaseManager dbManager;
+ ///
+ /// The token and module tree
+ ///
+ private JTree databaseTree;
+
+ /**
+ Constructure function.
+
+ Create the UI component and display frame.
+
+ @param dbManager databaase manager instance.
+ **/
+ public PCDDatabaseFrame(MemoryDatabaseManager dbManager) {
+ if (dbManager != null) {
+ this.dbManager = dbManager;
+ }
+ //
+ // Put the frame into center of desktop.
+ //
+ setLocation(100, 100);
+ initializeComponent();
+
+ setTitle("PCD View Tool");
+ pack();
+ setVisible(true);
+ }
+
+ /**
+ Initliaze the UI component in Display frame.
+ **/
+ public void initializeComponent() {
+ JScrollPane scrollPane = new JScrollPane();
+ Container contentPane = getContentPane();
+
+ contentPane.setLayout(new BorderLayout());
+ scrollPane.setViewportView(initializeTree());
+ contentPane.add(scrollPane);
+
+ addWindowListener(new PCDDatabaseFrameAdapter());
+ }
+
+ /**
+ Initiliaze the TREE control.
+ **/
+ public JTree initializeTree() {
+ Token[] tokenArray = null;
+ Token token = null;
+ DefaultMutableTreeNode root = new DefaultMutableTreeNode(dbManager.getLogFileName());
+ DefaultMutableTreeNode rootByPCD = new DefaultMutableTreeNode("By PCD");
+ DefaultMutableTreeNode rootByModule = new DefaultMutableTreeNode("By Module");
+ DefaultMutableTreeNode tokenNode = null;
+ DefaultMutableTreeNode usageNode = null;
+ DefaultMutableTreeNode moduleNode = null;
+ java.util.List moduleNames = null;
+ int index = 0;
+ int usageIndex = 0;
+ int moduleIndex = 0;
+ java.util.List usageArray = null;
+ UsageInstance usageInstance = null;
+
+ root.add(rootByPCD);
+ //
+ // By PCD Node
+ //
+
+ tokenArray = dbManager.getRecordArray();
+ for (index = 0; index < tokenArray.length; index ++) {
+ token = tokenArray[index];
+ ActionMessage.debug(this, token.cName);
+ tokenNode = new DefaultMutableTreeNode(token.cName);
+ tokenNode.add(new DefaultMutableTreeNode(String.format("TOKEN NUMBER: 0x%08x", token.tokenNumber)));
+ tokenNode.add(new DefaultMutableTreeNode(String.format("ASSIGNED TOKEN NUMBER: 0x%08x", token.assignedtokenNumber)));
+ tokenNode.add(new DefaultMutableTreeNode("TOKEN SPACE NAME: " + token.tokenSpaceName.toString()));
+ tokenNode.add(new DefaultMutableTreeNode("ASSIGNED TOKEN SPACE NAME: " + token.assignedtokenSpaceName.toString()));
+ tokenNode.add(new DefaultMutableTreeNode("PCD TYPE: " + Token.getStringOfpcdType(token.pcdType)));
+ tokenNode.add(new DefaultMutableTreeNode("DATUM TYPE: " +Token.getStringOfdatumType(token.datumType)));
+ tokenNode.add(new DefaultMutableTreeNode("DATUM: " + token.datum.toString()));
+ tokenNode.add(new DefaultMutableTreeNode("HIIENABLE: " +(token.hiiEnabled?"true":"false")));
+ tokenNode.add(new DefaultMutableTreeNode("VARIABLE NAME: " + token.variableName));
+ tokenNode.add(new DefaultMutableTreeNode("VARIABLE GUID: " + token.variableGuid.toString()));
+ tokenNode.add(new DefaultMutableTreeNode("SKUENABLE: " +(token.skuEnabled?"true":"false")));
+ tokenNode.add(new DefaultMutableTreeNode("SKUDATA ARRAY ENABLE: " +(token.skuDataArrayEnabled?"true":"false")));
+ tokenNode.add(new DefaultMutableTreeNode(String.format("SKUID: %d", token.skuId)));
+ tokenNode.add(new DefaultMutableTreeNode(String.format("MAX SKU COUNT: %d", token.maxSkuCount)));
+ tokenNode.add(new DefaultMutableTreeNode("VPDENABLE: " +(token.vpdEnabled?"true":"false")));
+
+ usageNode = new DefaultMutableTreeNode("PRODUCER");
+ tokenNode.add(usageNode);
+
+ //
+ // Prepare producer's leaf node
+ //
+
+ for (usageIndex = 0; usageIndex < token.producers.size(); usageIndex ++) {
+ usageNode.add(new DefaultMutableTreeNode(token.producers.get(usageIndex).moduleName));
+ }
+
+ //
+ // Prepare consumer's leaf node
+ //
+ usageNode = new DefaultMutableTreeNode("CONSUMER");
+ tokenNode.add(usageNode);
+
+ for (usageIndex = 0; usageIndex < token.consumers.size(); usageIndex ++) {
+ usageNode.add(new DefaultMutableTreeNode(token.consumers.get(usageIndex).moduleName));
+ }
+
+ rootByPCD.add(tokenNode);
+ }
+
+ //
+ // BY MODULE Node
+ //
+ root.add(rootByModule);
+ moduleNames = dbManager.getAllModuleArray();
+ for (moduleIndex = 0; moduleIndex < moduleNames.size(); moduleIndex ++) {
+ ActionMessage.debug(this, "ModuleName:" + moduleNames.get(moduleIndex));
+ }
+ for (moduleIndex = 0; moduleIndex < moduleNames.size(); moduleIndex ++) {
+ moduleNode = new DefaultMutableTreeNode(moduleNames.get(moduleIndex));
+ usageArray = dbManager.getUsageInstanceArrayByModuleName(moduleNames.get(moduleIndex));
+ for (usageIndex = 0; usageIndex < usageArray.size(); usageIndex ++) {
+ usageInstance = usageArray.get(usageIndex);
+ usageNode = new DefaultMutableTreeNode(usageInstance.parentToken.cName);
+ usageNode.add(new DefaultMutableTreeNode("MODULE PCD TYPE: " + Token.getStringOfpcdType(usageInstance.modulePcdType)));
+ usageNode.add(new DefaultMutableTreeNode("HELP TEXT: " + usageInstance.helpTextInMSA));
+ usageNode.add(new DefaultMutableTreeNode("IS INHERIT: " +(usageInstance.isInherit?"true":"false")));
+ usageNode.add(new DefaultMutableTreeNode("USAGE: " + Token.getStringOfUsage(usageInstance.usage)));
+ moduleNode.add(usageNode);
+ }
+ rootByModule.add(moduleNode);
+ }
+
+ databaseTree = new JTree(root);
+ return databaseTree;
+ }
+}
+
+/**
+ The adatper class for PCDDatabaseFrame. This class instance many windows message
+ callback function.
+**/
+class PCDDatabaseFrameAdapter extends WindowAdapter {
+ public void windowClosing(WindowEvent e) {
+ System.exit(0);
+ }
+}
diff --git a/Tools/Source/GenBuild/org/tianocore/build/toolchain/ConfigReader.java b/Tools/Source/GenBuild/org/tianocore/build/toolchain/ConfigReader.java
new file mode 100644
index 0000000000..f48735966e
--- /dev/null
+++ b/Tools/Source/GenBuild/org/tianocore/build/toolchain/ConfigReader.java
@@ -0,0 +1,218 @@
+/** @file
+ ConfigReader class.
+
+ ConfigReader is used to read tool chain config file with flat format.
+
+Copyright (c) 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+**/
+package org.tianocore.build.toolchain;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+import java.util.Vector;
+
+import org.apache.tools.ant.BuildException;
+
+/**
+
+ ConfigReader is used to read tool chain config file with flat format. Comments
+ is line starting with character '#'.
+
+ @since GenBuild 1.0
+**/
+public class ConfigReader {
+
+ private static String confPath = ".";
+
+ /**
+ Public construct method.
+ **/
+ public ConfigReader () {
+ }
+
+ /**
+ Default filepath is ".".
+
+ @param filename the config file name like "target.txt"
+ @return the variables defined in file
+ **/
+ public static synchronized String[][] parse(String filename) {
+ return parse(confPath, filename);
+ }
+
+ /**
+ Get all variables defined in config file. the config file format is flat
+ with "A=B". If line started with '#' looks as comments.
+
+ @param confPath the path of config file
+ @param filename the file name of the config file
+ @return the variables defined in the config file
+ @throws BuildException
+ Config file's format is not valid
+ **/
+ public static synchronized String[][] parse(String confPath, String filename) throws BuildException {
+ try {
+ Map map = new HashMap(20);
+ File file = new File(confPath + File.separatorChar + filename);
+ FileReader reader = new FileReader(file);
+ BufferedReader in = new BufferedReader(reader);
+ String str;
+ while ((str = in.readLine()) != null) {
+ str = str.trim();
+ //
+ // if str is empty line or comments (start with '#')
+ //
+ if (str.equalsIgnoreCase("") || str.startsWith("#")) {
+ continue;
+ }
+ //
+ // if str without '=' or start with '='
+ //
+ if (str.indexOf('=') <= 0) {
+ continue;
+ }
+ //
+ // look as line "A = B"
+ //
+ int index = str.indexOf('=');
+ String key = str.substring(0, index).trim();
+ String value = str.substring(index + 1).trim();
+ //
+ // if key is existed, then update
+ //
+ if (map.containsKey(key)) {
+ map.remove(key);
+ }
+ map.put(key, value);
+ }
+ Set keyset = map.keySet();
+ Iterator iter = keyset.iterator();
+ String[][] result = new String[map.size()][2];
+ int i = 0;
+ while (iter.hasNext()) {
+ String key = (String) iter.next();
+ result[i][0] = key;
+ result[i++][1] = (String) map.get(key);
+ }
+ return result;
+ } catch (Exception e) {
+ throw new BuildException("Processor file [" + filename + "] error. \n" + e.getMessage());
+ }
+ }
+
+ /**
+ Parse global flags table. The format is like such(global flag name, value,
+ vendor_arch_cmd, [add flags], [sub flags]):
+
+
+
+ @param confPath the file path of config file
+ @param filename the file name of config file
+ @return the value list
+ @throws BuildException
+ Config file is not valid
+ **/
+ public static synchronized String[][] parseTable(String confPath,
+ String filename) throws BuildException {
+ try {
+ Vector vector = new Vector(20);
+ File file = new File(confPath + File.separatorChar + filename);
+ FileReader reader = new FileReader(file);
+ BufferedReader in = new BufferedReader(reader);
+ String str;
+ while ((str = in.readLine()) != null) {
+ str = str.trim();
+ //
+ // if str is empty line or comments (start with '#')
+ //
+ if (str.equalsIgnoreCase("") || str.startsWith("#")) {
+ continue;
+ }
+ String[] item = new String[5];
+ for(int i=0; i < item.length; i++){
+ item[i] = "";
+ }
+ //
+ // EFI_DEBUG YES MSFT_IA32_ASM ADD.["/Zi", "/DEBUG"]
+ // FLAGS: EFI_DEBUG
+ //
+ int index = str.indexOf(" ");
+ item[0] = str.substring(0, index);
+ str = str.substring(index + 1).trim();
+ //
+ // Setting: YES
+ //
+ index = str.indexOf(" ");
+ item[1] = str.substring(0, index);
+ str = str.substring(index + 1).trim();
+ //
+ // Vendor_Arch_Commandtype: MSFT_IA32_ASM
+ //
+ index = str.indexOf(" ");
+ item[2] = str.substring(0, index);
+ str = str.substring(index + 1).trim();
+ //
+ // Add or/and Sub
+ //
+ if (str.startsWith("ADD.")) {
+ index = str.indexOf("]");
+ if ( index > 0){
+ item[3] = str.substring(5, index);
+ str = str.substring(index + 1).trim();
+ }
+ }
+ else if(str.startsWith("SUB.")){
+ index = str.indexOf("]");
+ if ( index > 0){
+ item[4] = str.substring(5, index);
+ str = str.substring(index + 1).trim();
+ }
+ }
+ else {
+ throw new BuildException("File [" + filename + "] never conform to Global Flags Table format.");
+ }
+
+ if (str.startsWith("ADD.")) {
+ index = str.indexOf("]");
+ if ( index > 0){
+ item[3] = str.substring(5, index);
+ str = str.substring(index + 1).trim();
+ }
+ }
+ else if(str.startsWith("SUB.")){
+ index = str.indexOf("]");
+ if ( index > 0){
+ item[4] = str.substring(5, index);
+ str = str.substring(index + 1).trim();
+ }
+ }
+ vector.addElement(item);
+ }
+ String[][] result = new String[vector.size()][5];
+ for(int i=0; i < vector.size(); i++){
+ result[i] = (String[])vector.get(i);
+ }
+ return result;
+ } catch (Exception e) {
+ throw new BuildException("Processor file [" + filename + "] error. \n" + e.getMessage());
+ }
+ }
+}
diff --git a/Tools/Source/GenBuild/org/tianocore/build/toolchain/ToolChainFactory.java b/Tools/Source/GenBuild/org/tianocore/build/toolchain/ToolChainFactory.java
new file mode 100644
index 0000000000..e3010fccf4
--- /dev/null
+++ b/Tools/Source/GenBuild/org/tianocore/build/toolchain/ToolChainFactory.java
@@ -0,0 +1,529 @@
+/** @file
+ ToolChainFactory class.
+
+ ToolChainFactory class parse all config files and get STD_FLAGS, GLOBAL_FLAGS,
+ and also command path + name.
+
+Copyright (c) 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+package org.tianocore.build.toolchain;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+import java.util.StringTokenizer;
+import java.io.File;
+
+import org.apache.tools.ant.Project;
+
+
+/**
+ This class parse all config files and get STD_FLAGS, GLOBAL_FLAGS, and also
+ command path + name.
+
+ @since GenBuild 1.0
+**/
+public class ToolChainFactory {
+ ///
+ /// list of Arch: EBC, ARM, IA32, X64, IPF, PPC
+ ///
+ public final static String[] arch = { "EBC", "ARM", "IA32", "X64", "IPF",
+ "PPC"};
+
+ ///
+ /// list of OS: Linux, Windows
+ ///
+ public final static String[] os = { "WINDOWS", "LINUX" };
+
+ ///
+ /// list of Command Type: CC, LIB, LINK, ASL, ASM, ASMLINK, PP
+ ///
+ public final static String[] commandType = { "CC", "LIB", "LINK", "ASL",
+ "ASM", "ASMLINK", "PP" };
+
+ ///
+ /// default command name for every command
+ ///
+ public final static String[][] defaultCmdName = { { "CC", "cl" },
+ { "LIB", "lib" }, { "LINK", "link" }, { "ASL", "iasl" },
+ { "ASM", "ml" }, { "ASMLINK", "link" }, { "PP", "cl" } };
+
+ private String confPath = ".";
+
+ private String toolChainName = "MSFT";
+
+ private String sTargetFilename = "target.txt";
+
+ private String sToolsdefFilename = "tools_def.txt";
+
+ private String sWorkspaceTarget = "WORKSPACE_TARGET";
+
+ private String sTargetArch = "TARGET_ARCH";
+
+ private HashMap filesMap = new HashMap();
+
+ private HashMap globalFlagsMap = new HashMap();
+
+ private String[][] globalFlagTable;
+
+ private String currentTarget = "RELEASE";
+
+ ///
+ /// toolchain array list all results by parsing config files
+ ///
+ public static String[][] toolchain = null;
+
+ /**
+ Public construct method.
+ **/
+ public ToolChainFactory () {
+ }
+
+ /**
+ Public construct method.
+
+ @param project current ANT Project.
+ **/
+ public ToolChainFactory (Project project) {
+ this.confPath = project.replaceProperties("${WORKSPACE_DIR}" + File.separatorChar + "Tools" + File.separatorChar + "Conf");
+ }
+
+ /**
+ Public construct method.
+
+ @param confPath the path of config files
+ @param toolChainName TOOL_CHAIN name
+ **/
+ public ToolChainFactory (String confPath, String toolChainName) {
+ this.confPath = confPath;
+ //
+ // If set tool used the set one, otherwise use default one.
+ // toolChain used to define open tools define txt file.
+ //
+ if (toolChainName != null && toolChainName.length() > 0){
+ this.toolChainName = toolChainName;
+ }
+ }
+
+ /**
+ Parse all config files, following are the detail steps:
+
+
+
Parse target.txt file. This file define the current build TARGET
+ and supported ARCH list.
+
Parse tools_def.txt file. This file define every command name, path
+ and vendor.
+
For every supported ARCH and Command Type, find out STD_FLAGS,
+ GLOBAL_ADD_FLAGS, GLOBAL_SUB_FLAGS.
+
+
+
Note that this method will be called only once during the whole build
+ process.
+ **/
+ public void setupToolChain() {
+ if (toolchain != null) {
+ return ;
+ }
+ Map map = new HashMap(40);
+ //
+ // parse target.txt
+ //
+ String[][] target = ConfigReader.parse(confPath, sTargetFilename);
+ //
+ // get workspace_target and initialize global flags setting
+ //
+ currentTarget = getValue(sWorkspaceTarget, target);
+ parseGlobalSetting(currentTarget);
+ String[] archList = getArchs(getValue(sTargetArch, target));
+
+ //
+ // If user write the ${toolChain}_Tools_Def.txt use this one,
+ // otherwise used "tools_def.txt" file.
+ //
+ File tempFile = new File (confPath + File.separator + toolChainName.toLowerCase() + "_tools_def.txt");
+ if (tempFile.exists()){
+ sToolsdefFilename = toolChainName.toLowerCase() + "_tools_def.txt";
+ }
+
+ System.out.println("Tools definition file is: " + sToolsdefFilename);
+ //
+ // parse tools_def.txt
+ //
+ String[][] tools_def = ConfigReader.parse(confPath, sToolsdefFilename);
+ //
+ // for each arch find all command's path&name and flags
+ //
+ for (int i = 0; i < archList.length; i++) {
+ for (int j = 0; j < commandType.length; j++) {
+ //
+ // Path & Name
+ //
+ map.put(archList[i] + "_" + commandType[j], getAbsoluteCmdPath(
+ archList[i], commandType[j], tools_def));
+ //
+ // Flags: CMD_STD_FLAGS + CMD_GLOBAL_FLAGS + CMD_PROJ_FLAGS
+ // ARCH_CMD_STD_FLAGS
+ //
+ map.put(archList[i] + "_" + commandType[j] + "_STD_FLAGS",
+ getStdFlags(archList[i], commandType[j],
+ tools_def));
+ //
+ // Flags:ARCH_CMD_VENDOR or ARCH_VENDOR
+ //
+ map.put(archList[i]+ "_"+commandType[j]+"_VENDOR", getVendorFlag(archList[i],
+ commandType[j], tools_def));
+ //
+ // ARCH_CMD_GLOBAL_FLAGS
+ //
+ String[] globalFlags = getGlobalFlags(archList[i], commandType[j],
+ tools_def);
+ map.put(archList[i] + "_" + commandType[j] + "_GLOBAL_ADD_FLAGS",
+ globalFlags[0]);
+ map.put(archList[i] + "_" + commandType[j] + "_GLOBAL_SUB_FLAGS",
+ globalFlags[1]);
+ //
+ // ARCH_CMD_GLOBAL_FLAGS, default is "".
+ //
+ map.put(archList[i] + "_" + commandType[j] + "_PROJ_FLAGS", "");
+ }
+ map.put(archList[i]+"_VENDOR", getVendorFlag(archList[i], null, tools_def));
+ }
+ Set keyset = map.keySet();
+ Iterator iter = keyset.iterator();
+ String[][] result = new String[map.size()][2];
+ int i = 0;
+ while (iter.hasNext()) {
+ String key = (String) iter.next();
+ result[i][0] = key;
+ result[i++][1] = (String) map.get(key);
+ }
+ toolchain = result;
+ }
+
+ /**
+ Get the standard flags (STD_FLAGS) for specified arch and command type.
+
+
+
Find out Vendor that cmd Command Type with arch ARCH used. The
+ search sequence is ARCH_CMD_VENDOR -> ARCH_VENDOR -> "MSFT". Here
+ we suppose default Vendor is MSFT.
+
Search ${Vendor}_tools.txt file, and get the corrsponding flags.
+
+
+
+ @param arch the ARCH
+ @param cmd the command type
+ @param map detail flags information of tools_def.txt
+ @return the standard flags of arch ARCH and cmd Command Type
+ **/
+ private String getStdFlags(String arch, String cmd, String[][] map) {
+ //
+ // first is to find out its Vendor in map
+ // ARCH_CMD_VENDOR -> ARCH_VENDOR -> "MSFT"
+ // Here we suppose default Vendor is MSFT.
+ //
+ String vendor = "MSFT";
+ String str;
+ if ((str = getValue(arch + "_" + cmd + "_VENDOR", map)) != null) {
+ vendor = str;
+ } else if ((str = getValue(arch + "_VENDOR", map)) != null) {
+ vendor = str;
+ }
+ //
+ // change to low letter
+ //
+ vendor = vendor.toLowerCase();
+ //
+ // parse the corresponding file and get arch_cmd value
+ //
+ String filename = vendor + "_tools.txt";
+ String[][] flagsMap;
+ if (filesMap.containsKey(filename)) {
+ flagsMap = (String[][]) filesMap.get(filename);
+ } else {
+ //
+ // read file and store in filesMap
+ //
+ flagsMap = ConfigReader.parse(confPath, vendor + "_tools.txt");
+ filesMap.put(filename, flagsMap);
+ }
+ if ((str = getValue(arch + "_" + cmd, flagsMap)) != null) {
+ return str;
+ }
+ return "";
+ }
+
+ /**
+ Get the global flags (GLOBAL_ADD_FLAGS & GLOBAL_SUB_FLAGS) for specified
+ arch and command type.
+
+
+
Find out Vendor that cmd Command Type with arch ARCH used. The
+ search sequence is ARCH_CMD_VENDOR -> ARCH_VENDOR -> "MSFT". Here
+ we suppose default Vendor is MSFT.
+
Search efi_flags_table.txt file, and get the corrsponding flags.
+
+
+
+ @param arch the ARCH
+ @param cmd the command type
+ @param map detail flags information of tools_def.txt
+ @return two values, first is GLOBAL_ADD_FLAGS and another value is
+ GLOBAL_SUB_FLAGS
+ **/
+ private String[] getGlobalFlags(String arch, String cmd, String[][] map) {
+ String addStr = "";
+ String subStr = "";
+ //
+ // first is to find out its Vendor in map
+ // ARCH_CMD_VENDOR -> ARCH_VENDOR -> "MSFT"
+ // Here we suppose default Vendor is MSFT.
+ //
+ String vendor = "MSFT";
+ String str;
+ if ((str = getValue(arch + "_" + cmd + "_VENDOR", map)) != null) {
+ vendor = str;
+ } else if ((str = getValue(arch + "_VENDOR", map)) != null) {
+ vendor = str;
+ }
+ //
+ // parse global flags table
+ //
+ if (globalFlagTable == null) {
+ globalFlagTable = ConfigReader.parseTable(confPath, "efi_flags_table.txt");
+ }
+ for (int i=0; i < globalFlagTable.length; i++){
+ String[] item = globalFlagTable[i];
+ if (item[2].equalsIgnoreCase(vendor + "_" + arch + "_" + cmd)){
+ //
+ // if item[0] == item[1] is existed in globalFlagsMap
+ //
+ if (globalFlagsMap.containsKey(item[0])){
+ if( item[1].equalsIgnoreCase((String)globalFlagsMap.get(item[0]))){
+ addStr += item[3] + " ";
+ subStr += item[4] + " ";
+ }
+ }
+ }
+ }
+
+ return new String[]{addStr, subStr};
+ }
+
+ /**
+ Find out command path and command name.
+
+
+ Command path searching sequence in tools_def.txt file:
+ Path: ARCH_CMD_PATH -> ARCH_PATH -> Set to "".
+
+ Command name searching sequence in tools_def.txt file:
+ Name: ARCH_CMD_NAME -> CMD_NAME -> Default Value.
+
+
+ @param arch the ARCH
+ @param cmd the Command Type
+ @param map detail flags information of tools_def.txt
+ @return the absolute command path and name
+ **/
+ private String getAbsoluteCmdPath(String arch, String cmd, String[][] map) {
+ String path = "";
+ String name = "";
+ String str;
+ //
+ // find Path
+ //
+ if ((str = getValue(arch + "_" + cmd + "_PATH", map)) != null) {
+ path = str;
+ } else if ((str = getValue(arch + "_PATH", map)) != null) {
+ path = str;
+ }
+ //
+ // find Name
+ //
+ if ((str = getValue(arch + "_" + cmd + "_NAME", map)) != null) {
+ name = str;
+ } else if ((str = getValue(cmd + "_NAME", map)) != null) {
+ name = str;
+ } else {
+ name = getValue(cmd, defaultCmdName);
+ }
+ if (path.equalsIgnoreCase("")) {
+ return name;
+ }
+ return path + File.separatorChar + name;
+ }
+
+ /**
+ Find out all global flags value, such as EFI_DEBUG equal YES or NO. Here
+ are three type files: global_efi_flags.txt, ${TARGET}_efi_flags.txt,
+ my_efi_flags.txt. global_efi_flags.txt with the highest priority while
+ my_efi_flags.txt with the lowest priority.
+
+
All global flags value will store in globalFlagsMap for
+ getGlobalFlags using.
+
+ @param target current build TARGET value
+ **/
+ private void parseGlobalSetting(String target){
+ //
+ // parse global_efi_flags -> ${TARGET}_efi_flags -> my_efi_flags
+ // parse global_efi_flags
+ //
+ String[][] map = ConfigReader.parse(confPath, "global_efi_flags.txt");
+ for (int i = 0; i < map.length; i++){
+ if(globalFlagsMap.containsKey(map[i][0])){
+ globalFlagsMap.remove(map[i][0]);
+ }
+ globalFlagsMap.put(map[i][0], map[i][1]);
+ }
+ //
+ // parse ${TARGET}_efi_flags
+ //
+ map = ConfigReader.parse(confPath, target + "_efi_flags.txt");
+ for (int i = 0; i < map.length; i++){
+ if(globalFlagsMap.containsKey(map[i][0])){
+ globalFlagsMap.remove(map[i][0]);
+ }
+ globalFlagsMap.put(map[i][0], map[i][1]);
+ }
+ //
+ // parse my_efi_flags.txt
+ //
+ map = ConfigReader.parse(confPath, "my_efi_flags.txt");
+ for (int i = 0; i < map.length; i++){
+ if(globalFlagsMap.containsKey(map[i][0])){
+ globalFlagsMap.remove(map[i][0]);
+ }
+ globalFlagsMap.put(map[i][0], map[i][1]);
+ }
+ }
+
+ /**
+ Find value with key from map. If not found, return null.
+
+
Note that default is case-insensitive
+
+ @param key key value
+ @param map mapping information
+ @return the related value of key
+ **/
+ private String getValue(String key, String[][] map) {
+ return getValue(key, map, false);
+ }
+
+ /**
+ Find value with key from map. If not found, return null.
+
+ @param key key value
+ @param map mapping information
+ @param caseSensitive whether case sesitive or not
+ @return the related value of key
+ **/
+ private String getValue(String key, String[][] map, boolean caseSensitive) {
+ for (int i = 0; i < map.length; i++) {
+ if (caseSensitive) {
+ if (key.compareTo(map[i][0]) == 0) {
+ return map[i][1];
+ }
+ } else {
+ if (key.compareToIgnoreCase(map[i][0]) == 0) {
+ return map[i][1];
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ Find value with key from toolchain. If not found, return null.
+
+ @param key key value
+ @return the related value of key
+ **/
+ public static String getValue(String key){
+ for (int i = 0; i < toolchain.length; i++) {
+ if (key.compareToIgnoreCase(toolchain[i][0]) == 0) {
+ return toolchain[i][1];
+ }
+ }
+ return null;
+ }
+
+ /**
+ Get Arch list from a string separated with comma.
+
+
+ For example:
+ If the arch string is "IA32, X64, EBC".
+ Then the result is {"IA32", "X64", "EBC"}.
+
+
+ @param arch string separated with comma
+ @return Arch list
+ **/
+ public String[] getArchs(String arch) {
+ if (arch == null) {
+ return new String[0];
+ }
+ StringTokenizer st = new StringTokenizer(arch, " \t,");
+ String[] archs = new String[st.countTokens()];
+ int i = 0;
+ while (st.hasMoreTokens()) {
+ archs[i++] = st.nextToken().toUpperCase();
+ }
+ return archs;
+ }
+
+ /**
+ Get current target value.
+
+ @return current target value
+ **/
+ public String getCurrentTarget() {
+ return currentTarget;
+ }
+
+ /**
+ Find out Vendor that cmd Command Type with arch ARCH used. The
+ search sequence is ARCH_CMD_VENDOR -> ARCH_VENDOR -> "MSFT". Here
+ we suppose default Vendor is MSFT.
+
+ @param arch the ARCH
+ @param cmd the Command Type
+ @param map detail flags information of tools_def.txt
+ @return the related vendor name
+ **/
+ public String getVendorFlag (String arch, String cmdType, String[][] map){
+ //
+ // ARCH_CMD_VENDOR -> ARCH_VENDOR -> "MSFT"
+ // Here we suppose default Vendor is MSFT.
+ //
+ String str;
+ String vendor = "";
+ if (cmdType != null){
+ if ((str = getValue(arch + "_" + cmdType + "_VENDOR", map)) != null) {
+ vendor = str;
+ }else {
+ vendor = "";
+ }
+ }else if (arch != null){
+ if ((str = getValue(arch + "_VENDOR", map)) != null) {
+ vendor = str;
+ }else {
+ vendor = "";
+ }
+ }
+ return vendor;
+ }
+
+}
diff --git a/Tools/Source/GenBuild/org/tianocore/build/toolchain/ToolChainTask.java b/Tools/Source/GenBuild/org/tianocore/build/toolchain/ToolChainTask.java
new file mode 100644
index 0000000000..04dab1c3e3
--- /dev/null
+++ b/Tools/Source/GenBuild/org/tianocore/build/toolchain/ToolChainTask.java
@@ -0,0 +1,60 @@
+/** @file
+ ToolChainTask class.
+
+ ToolChainTask class's main fucntion is read all tool chain related config files.
+
+Copyright (c) 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+package org.tianocore.build.toolchain;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Task;
+
+/**
+ This class is an ANT task. The main function is to read all tool chain related
+ config files.
+
+ @since GenBuild 1.0
+**/
+public class ToolChainTask extends Task{
+
+ private String confPath = ".";
+
+ /**
+ Public construct method. It is necessary for ANT task.
+ **/
+ public ToolChainTask(){
+ }
+
+ /**
+ ANT task's entry point, will be called after init(). Using
+ ToolChainFactory to parse all config files, and
+ set TARGET property.
+
+ @throws BuildException
+ Config files are invalid.
+ **/
+ public void execute() throws BuildException {
+ String toolChain = getProject().getProperty("env.TOOL_CHAIN");
+ ToolChainFactory toolchain = new ToolChainFactory(confPath, toolChain);
+ toolchain.setupToolChain();
+ getProject().setProperty("TARGET", toolchain.getCurrentTarget());
+ }
+
+ /**
+ Set the path of config files.
+
+ @param confPath the path of config files
+ **/
+ public void setConfPath(String confPath) {
+ this.confPath = confPath;
+ }
+}
diff --git a/Tools/Source/ModuleEditor/MANIFEST.MF b/Tools/Source/ModuleEditor/MANIFEST.MF
new file mode 100644
index 0000000000..dffa2192fa
--- /dev/null
+++ b/Tools/Source/ModuleEditor/MANIFEST.MF
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Main-Class: org.tianocore.packaging.module.ui.ModuleMain
+Class-Path: ../Jars/SurfaceArea.jar ../bin/xmlbeans/lib/jsr173_1.0_api.jar ../bin/xmlbeans/lib/xbean.jar ../bin/xmlbeans/lib/xbean_xpath.jar ../bin/xmlbeans/lib/xmlpublic.jar ../bin/xmlbeans/lib/saxon8.jar ../bin/xmlbeans/lib/saxon8-jdom.jar ../bin/xmlbeans/lib/saxon8-sql.jar ../bin/xmlbeans/lib/resolver.jar
diff --git a/Tools/Source/ModuleEditor/build.xml b/Tools/Source/ModuleEditor/build.xml
new file mode 100644
index 0000000000..f78750e819
--- /dev/null
+++ b/Tools/Source/ModuleEditor/build.xml
@@ -0,0 +1,44 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Tools/Source/ModuleEditor/src/org/tianocore/common/DataType.java b/Tools/Source/ModuleEditor/src/org/tianocore/common/DataType.java
new file mode 100644
index 0000000000..ea0731b70f
--- /dev/null
+++ b/Tools/Source/ModuleEditor/src/org/tianocore/common/DataType.java
@@ -0,0 +1,44 @@
+/** @file
+
+ The file is used to define all used final variables
+
+ Copyright (c) 2006, Intel Corporation
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+ **/
+package org.tianocore.common;
+
+/**
+ The class is used to define all used final variables
+
+ @since ModuleEditor 1.0
+
+**/
+public class DataType {
+
+ /**
+
+ @param args
+
+ **/
+ public static void main(String[] args) {
+ // TODO Auto-generated method stub
+
+ }
+
+ //
+ // Define all used final variables
+ //
+ public static final String DOS_LINE_SEPARATOR = "\r\n";
+
+ public static final String UNXI_LINE_SEPARATOR = "\n";
+
+ public static final String EMPTY_SELECT_ITEM = "----";
+
+}
diff --git a/Tools/Source/ModuleEditor/src/org/tianocore/common/DataValidation.java b/Tools/Source/ModuleEditor/src/org/tianocore/common/DataValidation.java
new file mode 100644
index 0000000000..4747343725
--- /dev/null
+++ b/Tools/Source/ModuleEditor/src/org/tianocore/common/DataValidation.java
@@ -0,0 +1,905 @@
+/** @file
+
+ The file is used to provides all kinds of Data Validation interface
+
+ Copyright (c) 2006, Intel Corporation
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+ **/
+
+package org.tianocore.common;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ The class is used to provides all kinds of data validation interface
+
+
All provided interfaces are in static mode
+
+ @since ModuleEditor 1.0
+
+ **/
+public class DataValidation {
+
+ /**
+ Reserved for test
+
+ @param args
+
+ **/
+ public static void main(String[] args) {
+ // TODO Auto-generated method stub
+
+ }
+
+ //
+ // The below is used to check common data types
+ //
+
+ /**
+ Check if the imput data is int
+
+ @param strInt The input string which needs validation
+
+ @retval true - The input is Int
+ @retval false - The input is not Int
+
+ **/
+ public static boolean isInt(String strInt) {
+ return isMatch("^-?[0-9]\\d*$", strInt);
+ }
+
+ /**
+ Check if the input data is int and it is in the valid scope
+ The scope is provided by String
+
+ @param strNumber The input string which needs validation
+ @param BeginNumber The left boundary of the scope
+ @param EndNumber The right boundary of the scope
+
+ @retval true - The input is Int and in the scope;
+ @retval false - The input is not Int or not in the scope
+
+ **/
+ public static boolean isInt(String strNumber, int BeginNumber, int EndNumber) {
+ //
+ //Check if the input data is int first
+ //
+ if (!isInt(strNumber)) {
+ return false;
+ }
+ //
+ //And then check if the data is between the scope
+ //
+ Integer intTemp = new Integer(strNumber);
+ if ((intTemp.intValue() < BeginNumber) || (intTemp.intValue() > EndNumber)) {
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ Check if the input data is int and it is in the valid scope
+ The scope is provided by String
+
+ @param strNumber The input string which needs validation
+ @param strBeginNumber The left boundary of the scope
+ @param strEndNumber The right boundary of the scope
+
+ @retval true - The input is Int and in the scope;
+ @retval false - The input is not Int or not in the scope
+
+ **/
+ public static boolean isInt(String strNumber, String strBeginNumber, String strEndNumber) {
+ //
+ //Check if all input data are int
+ //
+ if (!isInt(strNumber)) {
+ return false;
+ }
+ if (!isInt(strBeginNumber)) {
+ return false;
+ }
+ if (!isInt(strEndNumber)) {
+ return false;
+ }
+ //
+ //And then check if the data is between the scope
+ //
+ Integer intI = new Integer(strNumber);
+ Integer intJ = new Integer(strBeginNumber);
+ Integer intK = new Integer(strEndNumber);
+ if ((intI.intValue() < intJ.intValue()) || (intI.intValue() > intK.intValue())) {
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ Use regex to check if the input data is in valid format
+
+ @param strPattern The input regex
+ @param strMatcher The input data need be checked
+
+ @retval true - The data matches the regex
+ @retval false - The data doesn't match the regex
+
+ **/
+ public static boolean isMatch(String strPattern, String strMatcher) {
+ Pattern pattern = Pattern.compile(strPattern);
+ Matcher matcher = pattern.matcher(strMatcher);
+
+ return matcher.find();
+ }
+
+ //
+ // The below is used to check common customized data types
+ //
+
+ /**
+ Check if the input data is BaseNameConvention
+
+ @param strBaseNameConvention The input string need be checked
+
+ @retval true - The input is BaseNameConvention
+ @retval false - The input is not BaseNameConvention
+
+ **/
+ public static boolean isBaseNameConvention(String strBaseNameConvention) {
+ return isMatch("[A-Z]([a-zA-Z0-9])*(_)?([a-zA-Z0-9])*", strBaseNameConvention);
+ }
+
+ /**
+ Check if the input data is GuidArrayType
+
+ @param strGuidArrayType The input string need be checked
+
+ @retval true - The input is GuidArrayType
+ @retval false - The input is not GuidArrayType
+
+ **/
+ public static boolean isGuidArrayType(String strGuidArrayType) {
+ return isMatch(
+ "0x[a-fA-F0-9]{1,8},( )*0x[a-fA-F0-9]{1,4},( )*0x[a-fA-F0-9]{1,4}(,( )*\\{)?(,?( )*0x[a-fA-F0-9]{1,2}){8}( )*(\\})?",
+ strGuidArrayType);
+ }
+
+ /**
+ Check if the input data is GuidNamingConvention
+
+ @param strGuidNamingConvention The input string need be checked
+
+ @retval true - The input is GuidNamingConvention
+ @retval false - The input is not GuidNamingConvention
+
+ **/
+ public static boolean isGuidNamingConvention(String strGuidNamingConvention) {
+ return isMatch("[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}",
+ strGuidNamingConvention);
+ }
+
+ /**
+ Check if the input data is GuidType
+
+ @param strGuidType The input string need be checked
+
+ @retval true - The input is GuidType
+ @reture false is not GuidType
+
+ **/
+ public static boolean isGuidType(String strGuidType) {
+ return (isGuidArrayType(strGuidType) || isGuidNamingConvention(strGuidType));
+ }
+
+ /**
+ Check if the input data is Guid
+
+ @param strGuid The input string need be checked
+
+ @retval true - The input is Guid
+ @retval false - The input is not Guid
+
+ **/
+ public static boolean isGuid(String strGuid) {
+ return isGuidType(strGuid);
+ }
+
+ /**
+ Check if the input data is Sentence
+
+ @param strSentence The input string need be checked
+
+ @retval true - The input is Sentence
+ @retval false - The input is not Sentence
+
+ **/
+ public static boolean isSentence(String strSentence) {
+ return isMatch("(\\w+\\W*)+( )+(\\W*\\w*\\W*\\s*)*", strSentence);
+ }
+
+ /**
+ Check if the input data is DateType
+
+ @param strDateType The input string need be checked
+
+ @retval true - The input is DateType
+ @retval false - The input is not DateType
+
+ **/
+ public static boolean isDateType(String strDateType) {
+ return isMatch("[1-9][0-9][0-9][0-9]-[0-1][0-9]-[0-3][0-9] [0-2][0-9]:[0-5][0-9]", strDateType);
+ }
+
+ /**
+ Check if the input data is DosPath
+
+ @param strDosPath The input string need be checked
+
+ @retval true - The input is DosPath
+ @retval false - The input is not DosPath
+
+ **/
+ public static boolean isDosPath(String strDosPath) {
+ return isMatch("([a-zA-Z]:\\\\)?(((\\\\?_*-*.*[a-zA-Z0-9]*)*(_*-*.*[a-zA-Z0-9])*)+(\\\\)?)*", strDosPath);
+ }
+
+ /**
+ Check if the input data is UnixPath
+
+ @param strUnixPath The input string need be checked
+
+ @retval true - The input is UnixPath
+ @retval false - The input is not UnixPath
+
+ **/
+ public static boolean isUnixPath(String strUnixPath) {
+ return isMatch("(\\/)?(((_*-*.*[a-zA-Z0-9]*)*(_*-*.*[a-zA-Z0-9])*)+(\\/)?)*", strUnixPath);
+ }
+
+ /**
+ Check if the input data is DirectoryNamingConvention
+
+ @param strDirectoryNamingConvention The input string need be checked
+
+ @retval true - The input is DirectoryNamingConvention
+ @retval false - The input is not DirectoryNamingConvention
+
+ **/
+ public static boolean isDirectoryNamingConvention(String strDirectoryNamingConvention) {
+ return (isDosPath(strDirectoryNamingConvention) || isUnixPath(strDirectoryNamingConvention));
+ }
+
+ /**
+ Check if the input data is HexDoubleWordDataType
+
+ @param strHexDoubleWordDataType The input string need be checked
+
+ @retval true - The input is HexDoubleWordDataType
+ @retval false - The input is not HexDoubleWordDataType
+
+ **/
+ public static boolean isHexDoubleWordDataType(String strHexDoubleWordDataType) {
+ return isMatch("0x[a-fA-F0-9]{1,8}", strHexDoubleWordDataType);
+ }
+
+ /**
+ Check if the input data is V1
+
+ @param strV1 The input string need be checked
+
+ @retval true - The input is V1
+ @retval false - The input is not V1
+
+ **/
+ public static boolean isV1(String strV1) {
+ return isMatch("((%[A-Z](_*[A-Z0-9]*)*%)+((((\\\\)?_*-*.*[a-zA-Z0-9]*)*(_*-*.*[a-zA-Z0-9])*)+(\\\\)?)*)", strV1);
+ }
+
+ /**
+ Check if the input data is V2
+
+ @param strV2 The input string need be checked
+
+ @retval true - The input is V2
+ @retval false - The input is not V2
+
+ **/
+ public static boolean isV2(String strV2) {
+ return isMatch(
+ "(($[A-Z](_*[A-Z0-9]*)*)+||($\\([A-Z](_*[A-Z0-9]*)*\\))+||($\\{[A-Z](_*[A-Z0-9]*)*\\})+)+(\\/)?(((((_*-*.*[a-zA-Z0-9]*)*(_*-*.*[a-zA-Z0-9])*)+(\\/)?)*)*)",
+ strV2);
+ }
+
+ /**
+ Check if the input data is VariableConvention
+
+ @param strVariableConvention The input string need be checked
+
+ @retval true - The input is VariableConvention
+ @retval false - The input is not VariableConvention
+
+ **/
+ public static boolean isVariableConvention(String strVariableConvention) {
+ return (isV1(strVariableConvention) || isV2(strVariableConvention));
+ }
+
+ /**
+ Check if the input data is UCName
+
+ @param strUCName The input string need be checked
+
+ @retval true - The input is UCName
+ @retval false - The input is not UCName
+
+ **/
+ public static boolean isUCName(String strUCName) {
+ return isMatch("[A-Z]+(_*[A-Z0-9]*( )*)*", strUCName);
+ }
+
+ /**
+ Check if the input data is HexByteDataType
+
+ @param strHex64BitDataType The input string need be checked
+
+ @retval true - The input is HexByteDataType
+ @retval false - The input is not HexByteDataType
+
+ **/
+ public static boolean isHexByteDataType(String strHex64BitDataType) {
+ return isMatch("(0x)?[a-fA-F0-9]{1,2}", strHex64BitDataType);
+ }
+
+ /**
+ Check if the input data is Hex64BitDataType
+
+ @param strHex64BitDataType The input string need be checked
+
+ @retval true - The input is Hex64BitDataType
+ @retval false - The input is not Hex64BitDataType
+
+ **/
+ public static boolean isHex64BitDataType(String strHex64BitDataType) {
+ return isMatch("(0x)?[a-fA-F0-9]{1,16}", strHex64BitDataType);
+ }
+
+ /**
+ Check if the input data is HexWordDataType
+
+ @param strHexWordDataType The input string need be checked
+
+ @retval true - The input is HexWordDataType
+ @retval false - The input is not HexWordDataType
+
+ **/
+ public static boolean isHexWordDataType(String strHexWordDataType) {
+ return isMatch("0x[a-fA-F0-9]{1,4}", strHexWordDataType);
+ }
+
+ /**
+ Check if the input data is CName
+
+ @param strCName The input string need be checked
+
+ @retval true - The input is CName
+ @retval false - The input is not CName
+
+ **/
+ public static boolean isCName(String strCName) {
+ return isMatch("((_)*([a-zA-Z])+((_)*[a-zA-Z0-9]*))*", strCName);
+ }
+
+ /**
+ Check if the input data is OverrideID
+
+ @param strOverrideID The input string need be checked
+
+ @retval true - The input is OverrideID
+ @retval false - The input is not OverrideID
+
+ **/
+ public static boolean isOverrideID(String strOverrideID) {
+ return isInt(strOverrideID);
+ }
+
+ //
+ //The below is used to check msaheader data type
+ //
+
+ /**
+ Check if the input data is BaseName
+
+ @param strBaseName The input string need be checked
+
+ @retval true - The input is BaseName
+ @retval false - The input is not BaseName
+
+ **/
+ public static boolean isBaseName(String strBaseName) {
+ return isBaseNameConvention(strBaseName);
+ }
+
+ /**
+ Check if the input data is Abstract
+
+ @param strAbstract The input string need be checked
+
+ @retval true - The input is Abstract
+ @retval false - The input is not Abstract
+
+ **/
+ public static boolean isAbstract(String strAbstract) {
+ return isSentence(strAbstract);
+ }
+
+ /**
+ Check if the input data is Copyright
+
+ @param strCopyright The input string need be checked
+
+ @retval true - The input is Copyright
+ @retval false - The input is not Copyright
+
+ **/
+ public static boolean isCopyright(String strCopyright) {
+ return isSentence(strCopyright);
+ }
+
+ /**
+ Check if the input data is Created
+
+ @param strCreated The input string need be checked
+
+ @retval true - The input is Created
+ @retval false - The input is not Created
+
+ **/
+ public static boolean isCreated(String strCreated) {
+ return isDateType(strCreated);
+ }
+
+ /**
+ Check if the input data is Updated
+
+ @param strUpdated The input string need be checked
+
+ @retval true - The input is Updated
+ @retval false - The input is not Updated
+
+ **/
+ public static boolean isUpdated(String strUpdated) {
+ return isDateType(strUpdated);
+ }
+
+ //
+ // The below is used to check LibraryClass data types
+ //
+
+ /**
+ Check if the input data is LibraryClass
+
+ @param strLibraryClass The input string need be checked
+
+ @retval true - The input is LibraryClass
+ @retval false - The input is not LibraryClass
+
+ **/
+ public static boolean isLibraryClass(String strLibraryClass) {
+ return isBaseNameConvention(strLibraryClass);
+ }
+
+ //
+ // The below is used to check sourcefiles data types
+ //
+
+ /**
+ Check if the input data is Path
+
+ @param strPath The input string need be checked
+
+ @retval true - The input is Path
+ @retval false - The input is not Path
+
+ **/
+ public static boolean isPath(String strPath) {
+ return isDirectoryNamingConvention(strPath);
+ }
+
+ /**
+ Check if the input data is FileName
+
+ @param strFileName The input string need be checked
+
+ @retval true - The input is FileName
+ @retval false - The input is not FileName
+
+ **/
+ public static boolean isFileName(String strFileName) {
+ return isVariableConvention(strFileName);
+ }
+
+ //
+ // The below is used to check includes data types
+ //
+
+ /**
+ Check if the input data is UpdatedDate
+
+ @param strUpdatedDate The input string need be checked
+
+ @retval true - The input is UpdatedDate
+ @retval false - The input is not UpdatedDate
+
+ **/
+ public static boolean isUpdatedDate(String strUpdatedDate) {
+ return isDateType(strUpdatedDate);
+ }
+
+ /**
+ Check if the input data is PackageName
+
+ @param strPackageName The input string need be checked
+
+ @retval true - The input is PackageName
+ @retval false - The input is not PackageName
+
+ **/
+ public static boolean isPackageName(String strPackageName) {
+ return isBaseNameConvention(strPackageName);
+ }
+
+ //
+ // The below is used to check protocols data types
+ //
+
+ /**
+ Check if the input data is ProtocolName
+
+ @param strProtocolName The input string need be checked
+
+ @retval true - The input is ProtocolName
+ @retval false - The input is not ProtocolName
+
+ **/
+ public static boolean isProtocolName(String strProtocolName) {
+ return isCName(strProtocolName);
+ }
+
+ /**
+ Check if the input data is ProtocolNotifyName
+
+ @param strProtocolNotifyName The input string need be checked
+
+ @retval true - The input is ProtocolNotifyName
+ @retval false - The input is not ProtocolNotifyName
+
+ **/
+ public static boolean isProtocolNotifyName(String strProtocolNotifyName) {
+ return isCName(strProtocolNotifyName);
+ }
+
+ //
+ // The below is used to check ppis data types
+ //
+
+ /**
+ Check if the input data is PpiName
+
+ @param strPpiName The input string need be checked
+
+ @retval true - The input is PpiName
+ @retval false - The input is not PpiName
+
+ **/
+ public static boolean isPpiName(String strPpiName) {
+ return isCName(strPpiName);
+ }
+
+ /**
+ Check if the input data is PpiNotifyName
+
+ @param strPpiNotifyName The input string need be checked
+
+ @retval true - The input is PpiNotifyName
+ @retval false - The input is not PpiNotifyName
+
+ **/
+ public static boolean isPpiNotifyName(String strPpiNotifyName) {
+ return isCName(strPpiNotifyName);
+ }
+
+ /**
+ Check if the input data is FeatureFlag
+
+ @param strFeatureFlag The input string need be checked
+
+ @retval true - The input is FeatureFlag
+ @retval false - The input is not FeatureFlag
+
+ **/
+ public static boolean isFeatureFlag(String strFeatureFlag) {
+ return isCName(strFeatureFlag);
+ }
+
+ //
+ // The below is used to check variable data types
+ //
+
+ /**
+ Check if the input data is ByteOffset
+
+ @param strByteOffset The input string need be checked
+
+ @retval true - The input is ByteOffset
+ @retval false - The input is not ByteOffset
+
+ **/
+ public static boolean isByteOffset(String strByteOffset) {
+ return isByteOffset(strByteOffset);
+ }
+
+ /**
+ Check if the input data is BitOffset
+
+ @param strBitOffset The input string need be checked
+
+ @retval true - The input is BitOffset
+ @retval false - The input is not BitOffset
+
+ **/
+ public static boolean isBitOffset(String strBitOffset) {
+ return isInt(strBitOffset, 0, 8);
+ }
+
+ /**
+ Check if the input data is OffsetBitSize
+
+ @param strOffsetBitSize The input string need be checked
+
+ @retval true - The input is OffsetBitSize
+ @retval false - The input is not OffsetBitSize
+
+ **/
+ public static boolean isOffsetBitSize(String strOffsetBitSize) {
+ return isInt(strOffsetBitSize, 0, 7);
+ }
+
+ //
+ // The below is used to check formsets data types
+ //
+
+ /**
+ Check if the input data is Formsets
+
+ @param strFormsets The input string need be checked
+
+ @retval true - The input is Formsets
+ @retval false - The input is not Formsets
+
+ **/
+ public static boolean isFormsets(String strFormsets) {
+ return isCName(strFormsets);
+ }
+
+ //
+ // The below is used to check externs data types
+ //
+
+ /**
+ Check if the input data is Constructor
+
+ @param strConstructor The input string need be checked
+
+ @retval true - The input is Constructor
+ @retval false - The input is not Constructor
+
+ **/
+ public static boolean isConstructor(String strConstructor) {
+ return isCName(strConstructor);
+ }
+
+ /**
+ Check if the input data is Destructor
+
+ @param strDestructor The input string need be checked
+
+ @retval true - The input is Destructor
+ @retval false - The input is not Destructor
+
+ **/
+ public static boolean isDestructor(String strDestructor) {
+ return isCName(strDestructor);
+ }
+
+ /**
+ Check if the input data is DriverBinding
+
+ @param strDriverBinding The input string need be checked
+
+ @retval true - The input is DriverBinding
+ @retval false - The input is not DriverBinding
+
+ **/
+ public static boolean isDriverBinding(String strDriverBinding) {
+ return isCName(strDriverBinding);
+ }
+
+ /**
+ Check if the input data is ComponentName
+
+ @param strComponentName The input string need be checked
+
+ @retval true - The input is ComponentName
+ @retval false - The input is not ComponentName
+
+ **/
+ public static boolean isComponentName(String strComponentName) {
+ return isCName(strComponentName);
+ }
+
+ /**
+ Check if the input data is DriverConfig
+
+ @param strDriverConfig The input string need be checked
+
+ @retval true - The input is DriverConfig
+ @retval false - The input is not DriverConfig
+
+ **/
+ public static boolean isDriverConfig(String strDriverConfig) {
+ return isCName(strDriverConfig);
+ }
+
+ /**
+ Check if the input data is DriverDiag
+
+ @param strDriverDiag The input string need be checked
+
+ @retval true - The input is DriverDiag
+ @retval false - The input is not DriverDiag
+
+ **/
+ public static boolean isDriverDiag(String strDriverDiag) {
+ return isCName(strDriverDiag);
+ }
+
+ /**
+ Check if the input data is SetVirtualAddressMapCallBack
+
+ @param strSetVirtualAddressMapCallBack The input string need be checked
+
+ @retval true - The input is SetVirtualAddressMapCallBack
+ @retval false - The input is not SetVirtualAddressMapCallBack
+
+ **/
+ public static boolean isSetVirtualAddressMapCallBack(String strSetVirtualAddressMapCallBack) {
+ return isCName(strSetVirtualAddressMapCallBack);
+ }
+
+ /**
+ Check if the input data is ExitBootServicesCallBack
+
+ @param strExitBootServicesCallBack The input string need be checked
+
+ @retval true - The input is ExitBootServicesCallBack
+ @retval false - The input is not ExitBootServicesCallBack
+
+ **/
+ public static boolean isExitBootServicesCallBack(String strExitBootServicesCallBack) {
+ return isCName(strExitBootServicesCallBack);
+ }
+
+ /**
+ Check if the input data is UserDefined
+
+ @param strUserDefined The input string need be checked
+
+ @retval true - The input is UserDefined
+ @retval false - The input is not UserDefined
+
+ **/
+ public static boolean isUserDefined(String strUserDefined) {
+ return isCName(strUserDefined);
+ }
+
+ //
+ // The below is used to check PCDs data types
+ //
+
+ /**
+ Check if the input data is Token
+
+ @param strToken The input string need be checked
+
+ @retval true - The input is Token
+ @retval false - The input is not Token
+
+ **/
+ public static boolean isToken(String strToken) {
+ return isHexDoubleWordDataType(strToken);
+ }
+
+ /**
+ Check if the input data is MaxSku
+
+ @param strMaxSku The input string need be checked
+
+ @retval true - The input is MaxSku
+ @retval false - The input is not MaxSku
+
+ **/
+ public static boolean isMaxSku(String strMaxSku) {
+ return isHexByteDataType(strMaxSku);
+ }
+
+ /**
+ Check if the input data is SkuId
+
+ @param strSkuId The input string need be checked
+
+ @retval true - The input is SkuId
+ @retval false - The input is not SkuId
+
+ **/
+ public static boolean isSkuId(String strSkuId) {
+ return isHexByteDataType(strSkuId);
+ }
+
+ /**
+ Check if the input data is DatumSize
+
+ @param strDatumSize The input string need be checked
+
+ @retval true - The input is DatumSize
+ @retval false - The input is not DatumSize
+
+ **/
+ public static boolean isDatumSize(String strDatumSize) {
+ return isInt(strDatumSize, 1, 16777215);
+ }
+
+ /**
+ Check if the input data is VariableGuid
+
+ @param strVariableGuid The input string need be checked
+
+ @retval true - The input is VariableGuid
+ @retval false - The input is not VariableGuid
+
+ **/
+ public static boolean isVariableGuid(String strVariableGuid) {
+ return (isGuid(strVariableGuid) || strVariableGuid.equals("0"));
+ }
+
+ /**
+ Check if the input data is DataOffset
+
+ @param strDataOffset The input string need be checked
+
+ @retval true - The input is DataOffset
+ @retval false - The input is not DataOffset
+
+ **/
+ public static boolean isDataOffset(String strDataOffset) {
+ return isHex64BitDataType(strDataOffset);
+ }
+
+ /**
+ Check if the input data is GuidOffset
+
+ @param strGuidOffset The input string need be checked
+
+ @retval true - The input is GuidOffset
+ @retval false - The input is not GuidOffset
+
+ **/
+ public static boolean isGuidOffset(String strGuidOffset) {
+ return isHex64BitDataType(strGuidOffset);
+ }
+}
diff --git a/Tools/Source/ModuleEditor/src/org/tianocore/common/IFileFilter.java b/Tools/Source/ModuleEditor/src/org/tianocore/common/IFileFilter.java
new file mode 100644
index 0000000000..1daf7fa867
--- /dev/null
+++ b/Tools/Source/ModuleEditor/src/org/tianocore/common/IFileFilter.java
@@ -0,0 +1,87 @@
+/** @file
+
+ The file is used to override FileFilter to provides customized interfaces
+
+ Copyright (c) 2006, Intel Corporation
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+ **/
+
+package org.tianocore.common;
+
+import java.io.File;
+
+import javax.swing.filechooser.FileFilter;
+
+/**
+ The class is used to override FileFilter to provides customized interfaces
+
+ @since ModuleEditor 1.0
+
+ **/
+public class IFileFilter extends FileFilter {
+
+ private String strExt;
+
+ /**
+ Reserved for test
+
+ @param args
+
+ **/
+ public static void main(String[] args) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /**
+ This is the default constructor
+
+ @param ext
+
+ **/
+ public IFileFilter(String ext) {
+ this.strExt = ext;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.swing.filechooser.FileFilter#accept(java.io.File)
+ *
+ * Override method "accept"
+ *
+ */
+ public boolean accept(File file) {
+ if (file.isDirectory()) {
+ return true;
+ }
+ String strFileName = file.getName();
+ int intIndex = strFileName.lastIndexOf('.');
+ if (intIndex > 0 && intIndex < strFileName.length() - 1) {
+ String strExtension = strFileName.substring(intIndex + 1).toLowerCase();
+ if (strExtension.equals(strExt))
+ return true;
+ }
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.swing.filechooser.FileFilter#getDescription()
+ *
+ * Override method "getDescription" to config description via different file type
+ *
+ */
+ public String getDescription() {
+ if (strExt.equals("msa"))
+ return "Module Surface Area File(*.msa)";
+ if (strExt.equals("mbd"))
+ return "Module Build Description File(*.mbd)";
+ return "";
+ }
+
+}
diff --git a/Tools/Source/ModuleEditor/src/org/tianocore/common/Log.java b/Tools/Source/ModuleEditor/src/org/tianocore/common/Log.java
new file mode 100644
index 0000000000..0759fc619c
--- /dev/null
+++ b/Tools/Source/ModuleEditor/src/org/tianocore/common/Log.java
@@ -0,0 +1,211 @@
+/** @file
+
+ The file is used to provides static interfaces to save log and error information
+
+ Copyright (c) 2006, Intel Corporation
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+ **/
+
+package org.tianocore.common;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+
+import javax.swing.JOptionPane;
+
+/**
+ The class is used to provides static interfaces to save log and error information
+
+ @since ModuleEditor 1.0
+
+ **/
+public class Log {
+
+ //
+ //Log file
+ //
+ private static File fleLogFile = null;
+
+ //
+ //Err file
+ //
+ private static File fleErrFile = null;
+
+ //
+ //Log file name
+ //
+ static String strLogFileName = "Log.log";
+
+ //
+ //Err file name
+ //
+ static String strErrFileName = "Err.log";
+
+ /**
+ Main class, used for test
+
+ @param args
+
+ **/
+ public static void main(String[] args) {
+ try {
+ Log.log("Test", "test");
+ Log.err("Test1", "test1");
+ Log.err("sdfsdfsd fsdfsdfsdfsdfj dsfksdjflsdjf sdkfjsdklfjsdkf dskfsjdkfjks dskfjsdklfjsdkf sdkfjsdlf sdkfjsdk kdfjskdf sdkfjsdkf ksdjfksdfjskdf sdkfsjdfksd fskdfjsdf", "dfsdf sdfksdf sd sdfksd fsdf");
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ This is the default constructor
+ Do nothing
+
+ **/
+ public Log() {
+ }
+
+ /**
+ Call writeToLogFile to save log item and log information to log file
+
+ @param strItem The log item
+ @param strLog The log information
+
+ **/
+ public static void log(String strItem, String strLog) {
+ try {
+ writeToLogFile(strItem + ":" + strLog);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ Call writeToLogFile to save log information to log file
+
+ @param strLog The log information
+
+ **/
+ public static void log(String strLog) {
+ try {
+ writeToLogFile(strLog);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ Call writeToErrFile to save err item and err information to err file
+
+ @param strItem The err item
+ @param strLog The err information
+
+ **/
+ public static void err(String strItem, String strErr) {
+ try {
+ writeToErrFile("Error when " + strItem + "::" + strErr);
+ showErrMessage("Error when " + strItem + "::" + strErr);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ Call writeToErrFile to save err information to err file
+
+ @param strLog The err information
+
+ **/
+ public static void err(String strErr) {
+ try {
+ writeToErrFile("Error::" + strErr);
+ showErrMessage("Error::" + strErr);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ Brings up a dialog to show err message
+ When the message's length > defined max length, wrap the text to the next line.
+
+ @param strErr The input data of err message
+
+ **/
+ private static void showErrMessage(String strErr) {
+ int intMaxLength = 40;
+ String strReturn = "";
+ String strTemp = "";
+ while (strErr.length() > 0) {
+ if (strErr.length() > intMaxLength) {
+ strTemp = strErr.substring(0, intMaxLength);
+ strErr = strErr.substring(strTemp.length());
+ strReturn = strReturn + strTemp + DataType.UNXI_LINE_SEPARATOR;
+
+ } else if (strErr.length() <= intMaxLength) {
+ strReturn = strReturn + strErr;
+ strErr = "";
+ }
+ }
+ JOptionPane.showConfirmDialog(null, strReturn, "Error", JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE);
+ }
+
+ /**
+ Open log file and write log information
+
+ @param strLog The log information
+ @throws IOException
+
+ **/
+ private static void writeToLogFile(String strLog) throws IOException {
+ try {
+ if (fleLogFile == null) {
+ fleLogFile = new File(strLogFileName);
+ fleLogFile.createNewFile();
+ }
+ FileOutputStream fos = new FileOutputStream(fleLogFile, true);
+ fos.write((Tools.getCurrentDateTime() + DataType.DOS_LINE_SEPARATOR).getBytes());
+ fos.write((strLog + DataType.DOS_LINE_SEPARATOR).getBytes());
+ fos.flush();
+ fos.close();
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ Open err file and write err information
+
+ @param strLog The log information
+ @throws IOException
+
+ **/
+ private static void writeToErrFile(String strLog) throws IOException {
+ try {
+ if (fleErrFile == null) {
+ fleErrFile = new File(strErrFileName);
+ fleErrFile.createNewFile();
+ }
+ FileOutputStream fos = new FileOutputStream(fleErrFile, true);
+ fos.write((Tools.getCurrentDateTime() + DataType.DOS_LINE_SEPARATOR).getBytes());
+ fos.write((strLog + DataType.DOS_LINE_SEPARATOR).getBytes());
+ fos.flush();
+ fos.close();
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/Tools/Source/ModuleEditor/src/org/tianocore/common/Tools.java b/Tools/Source/ModuleEditor/src/org/tianocore/common/Tools.java
new file mode 100644
index 0000000000..a11df00377
--- /dev/null
+++ b/Tools/Source/ModuleEditor/src/org/tianocore/common/Tools.java
@@ -0,0 +1,120 @@
+/** @file
+
+ The file is used to provides some useful interfaces
+
+ Copyright (c) 2006, Intel Corporation
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+ **/
+
+package org.tianocore.common;
+
+import java.io.File;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.UUID;
+
+/**
+ The class is used to provides some useful interfaces
+
+ @since ModuleEditor 1.0
+
+ **/
+public class Tools {
+
+ /**
+ Used for test
+
+ @param args
+
+ **/
+ public static void main(String[] args) {
+ System.out.println(getCurrentDateTime());
+ }
+
+ /**
+ Get current date and time and format it as "yyyy-MM-dd HH:mm"
+
+ @return formatted current date and time
+
+ **/
+ public static String getCurrentDateTime() {
+ Date now = new Date(System.currentTimeMillis());
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
+ return sdf.format(now);
+ }
+
+ /**
+ Delete a folder and all its files
+
+ @param fleFolderName The name of the folder which need be deleted
+
+ @retval true - Delete successfully
+ @retval false - Delete successfully
+
+ **/
+ public static boolean deleteFolder(File fleFolderName) {
+ boolean blnIsDeleted = true;
+ File[] aryAllFiles = fleFolderName.listFiles();
+
+ for (int indexI = 0; indexI < aryAllFiles.length; indexI++) {
+ if (blnIsDeleted) {
+ if (aryAllFiles[indexI].isDirectory()) {
+ //
+ //If is a directory, recursively call this function to delete sub folders
+ //
+ blnIsDeleted = deleteFolder(aryAllFiles[indexI]);
+ } else if (aryAllFiles[indexI].isFile()) {
+ //
+ //If is a file, delete it
+ //
+ if (!aryAllFiles[indexI].delete()) {
+ blnIsDeleted = false;
+ }
+ }
+ }
+ }
+ if (blnIsDeleted) {
+ fleFolderName.delete();
+ }
+ return blnIsDeleted;
+ }
+
+ /**
+ Generate a UUID
+
+ @return the created UUID
+
+ **/
+ public static String generateUuidString() {
+ return UUID.randomUUID().toString();
+ }
+
+ /**
+ Get all system properties and output to the console
+
+ **/
+ public static void getSystemProperties() {
+ System.out.println(System.getProperty("java.class.version"));
+ System.out.println(System.getProperty("java.class.path"));
+ System.out.println(System.getProperty("java.ext.dirs"));
+ System.out.println(System.getProperty("os.name"));
+ System.out.println(System.getProperty("os.arch"));
+ System.out.println(System.getProperty("os.version"));
+ System.out.println(System.getProperty("file.separator"));
+ System.out.println(System.getProperty("path.separator"));
+ System.out.println(System.getProperty("line.separator"));
+ System.out.println(System.getProperty("user.name"));
+ System.out.println(System.getProperty("user.home"));
+ System.out.println(System.getProperty("user.dir"));
+ System.out.println(System.getProperty("PATH"));
+
+ System.out.println(System.getenv("PROCESSOR_REVISION"));
+ }
+}
diff --git a/Tools/Source/ModuleEditor/src/org/tianocore/packaging/common/ui/ExitConfirm.java b/Tools/Source/ModuleEditor/src/org/tianocore/packaging/common/ui/ExitConfirm.java
new file mode 100644
index 0000000000..2ff84b669b
--- /dev/null
+++ b/Tools/Source/ModuleEditor/src/org/tianocore/packaging/common/ui/ExitConfirm.java
@@ -0,0 +1,265 @@
+/** @file
+
+ The file is used to popup a exit confirmation window when program exists
+
+ Copyright (c) 2006, Intel Corporation
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+ **/
+
+package org.tianocore.packaging.common.ui;
+
+import java.awt.Dimension;
+import java.awt.Toolkit;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.WindowEvent;
+import java.awt.event.WindowListener;
+
+import javax.swing.JButton;
+import javax.swing.JDialog;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+
+/**
+ The class is used to popup a exit confirmation window when program exists
+ It extends JDialog and implements ActionListener and WindowListener
+
+ @since ModuleEditor 1.0
+
+ **/
+public class ExitConfirm extends JDialog implements ActionListener, WindowListener {
+
+ ///
+ /// Define class Serial Version UID
+ ///
+ private static final long serialVersionUID = -5875921789385911029L;
+
+ private JPanel jContentPane = null;
+
+ private JLabel jLabelMessage = null;
+
+ private JLabel jLabelResume = null;
+
+ private JLabel jLabelExit = null;
+
+ private JButton jButtonResume = null;
+
+ private JButton jButtonExit = null;
+
+ public boolean isCancel = false;
+
+ /**
+ This method initializes jButtonResume
+
+ @return javax.swing.JButton jButtonResume
+
+ **/
+ private JButton getJButtonResume() {
+ if (jButtonResume == null) {
+ jButtonResume = new JButton();
+ jButtonResume.setText("Resume");
+ jButtonResume.setSize(new java.awt.Dimension(90, 20));
+ jButtonResume.setLocation(new java.awt.Point(150, 105));
+ jButtonResume.setMnemonic('R');
+ jButtonResume.addActionListener(this);
+ }
+ return jButtonResume;
+ }
+
+ /**
+ This method initializes jButtonExit
+
+ @return javax.swing.JButton jButtonExit
+
+ **/
+ private JButton getJButtonExit() {
+ if (jButtonExit == null) {
+ jButtonExit = new JButton();
+ jButtonExit.setText("Exit");
+ jButtonExit.setSize(new java.awt.Dimension(90, 20));
+ jButtonExit.setLocation(new java.awt.Point(260, 105));
+ jButtonExit.setMnemonic('x');
+ jButtonExit.addActionListener(this);
+ }
+ return jButtonExit;
+ }
+
+ /**
+ Main clasee, reserved for test
+
+ @param args
+
+ **/
+ public static void main(String[] args) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /**
+ This is the default constructor
+
+ **/
+ public ExitConfirm(IFrame parentFrame, boolean modal) {
+ super(parentFrame, modal);
+ initialize();
+ }
+
+ /**
+ This method initializes this
+
+ @return void
+
+ **/
+ private void initialize() {
+ this.setSize(500, 170);
+ this.setTitle("Exit");
+ this.setResizable(false);
+ this.setContentPane(getJContentPane());
+ this.addWindowListener(this);
+ //
+ //Set DO_NOTHING_ON_CLOSE when click Close button on title bar
+ //
+ this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
+ centerWindow();
+ }
+
+ /**
+ This method initializes jContentPane
+
+ @return javax.swing.JPanel jContentPane
+
+ **/
+ private JPanel getJContentPane() {
+ if (jContentPane == null) {
+ jLabelExit = new JLabel();
+ jLabelExit.setSize(new java.awt.Dimension(450, 20));
+ jLabelExit.setLocation(new java.awt.Point(25, 70));
+ jLabelResume = new JLabel();
+ jLabelResume.setSize(new java.awt.Dimension(450, 20));
+ jLabelResume.setLocation(new java.awt.Point(25, 40));
+ jLabelMessage = new JLabel();
+ jLabelMessage.setSize(new java.awt.Dimension(450, 20));
+ jLabelMessage.setLocation(new java.awt.Point(25, 10));
+ jContentPane = new JPanel();
+ jContentPane.setLayout(null);
+ jContentPane.add(jLabelMessage, null);
+ jContentPane.add(jLabelResume, null);
+ jContentPane.add(jLabelExit, null);
+ jContentPane.add(getJButtonResume(), null);
+ jContentPane.add(getJButtonExit(), null);
+ }
+ return jContentPane;
+ }
+
+ /**
+ Call setWarningMessage to set messages of frame when it is used for Setup
+
+ **/
+ public void setSetupMessage() {
+ String strTitle = "Exit Setup";
+ String strMessage = "Setup is not complete. If you quit now, the program will not be installed.";
+ String strResume = "You may run the setup program at a later time to complete the installation.";
+ String strExit = "To continue installing, click Resume. To quit the Setup program, click Exit.";
+ setWarningMessage(strTitle, strMessage, strResume, strExit);
+ }
+
+ /**
+ Call setWarningMessage to set messages of frame when it is used for Module Main GUI
+
+ **/
+ public void setModuleMessage() {
+ String strTitle = "Exit";
+ String strMessage = "Do you really want to quit now?";
+ String strResume = "All unsaved module information will be lost.";
+ String strExit = "To continue editing module, click Resume. To quit the program, click Exit.";
+ setWarningMessage(strTitle, strMessage, strResume, strExit);
+ }
+
+ /**
+ Set message information via input data
+
+ @param strTitle The title value
+ @param strMessage The main message value
+ @param strResume The resume message value
+ @param strExit The exit message value
+
+ **/
+ private void setWarningMessage(String strTitle, String strMessage, String strResume, String strExit) {
+ this.setTitle(strTitle);
+ jLabelMessage.setText(strMessage);
+ jLabelResume.setText(strResume);
+ jLabelExit.setText(strExit);
+ }
+
+ /* (non-Javadoc)
+ * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
+ *
+ * Override actionPerformed to listern all actions
+ *
+ */
+ public void actionPerformed(ActionEvent arg0) {
+ //
+ //Set isCancel true when click button "Exit"
+ //
+ Object obj = arg0.getSource();
+ if (obj == jButtonResume) {
+ isCancel = false;
+ }
+ if (obj == jButtonExit) {
+ isCancel = true;
+ }
+ this.setVisible(false);
+ }
+
+ /**
+ Make the window in the center of the screen
+
+ **/
+ private void centerWindow() {
+ Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
+ this.setLocation((d.width - this.getSize().width) / 2, (d.height - this.getSize().height) / 2);
+ }
+
+ public void windowActivated(WindowEvent arg0) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void windowClosed(WindowEvent arg0) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void windowClosing(WindowEvent arg0) {
+ isCancel = false;
+ this.setVisible(false);
+ }
+
+ public void windowDeactivated(WindowEvent arg0) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void windowDeiconified(WindowEvent arg0) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void windowIconified(WindowEvent arg0) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void windowOpened(WindowEvent arg0) {
+ // TODO Auto-generated method stub
+
+ }
+}
diff --git a/Tools/Source/ModuleEditor/src/org/tianocore/packaging/common/ui/IComboBox.java b/Tools/Source/ModuleEditor/src/org/tianocore/packaging/common/ui/IComboBox.java
new file mode 100644
index 0000000000..f60ebcfe33
--- /dev/null
+++ b/Tools/Source/ModuleEditor/src/org/tianocore/packaging/common/ui/IComboBox.java
@@ -0,0 +1,196 @@
+/** @file
+
+ The file is used to override JComboBox to provides customized interfaces
+
+ Copyright (c) 2006, Intel Corporation
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+ **/
+package org.tianocore.packaging.common.ui;
+
+import java.awt.event.FocusEvent;
+import java.awt.event.FocusListener;
+import java.awt.event.KeyEvent;
+import java.awt.event.KeyListener;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseListener;
+
+import javax.swing.JComboBox;
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+
+/**
+ The class is used to override JComboBox to provides customized interfaces
+ It extends JComboBox implements KeyListener, MouseListener and FocusListener
+
+ @since ModuleEditor 1.0
+
+ **/
+public class IComboBox extends JComboBox implements KeyListener, MouseListener, FocusListener {
+
+ ///
+ /// Define class Serial Version UID
+ ///
+ private static final long serialVersionUID = -1940262568168458911L;
+
+ public void focusGained(FocusEvent arg0) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see java.awt.event.FocusListener#focusLost(java.awt.event.FocusEvent)
+ *
+ * Override focusLost to exit edit mode
+ *
+ */
+ public void focusLost(FocusEvent arg0) {
+ this.closeEdit();
+ }
+
+ /**
+ Main class, used for test
+
+ @param args
+
+ **/
+ public static void main(String[] args) {
+ JFrame jf = new JFrame();
+ jf.setSize(500, 200);
+ JPanel jp = new JPanel();
+ jp.setLayout(null);
+ IComboBox icb = new IComboBox();
+ jp.add(icb, null);
+ jf.setContentPane(jp);
+ jf.setVisible(true);
+ }
+
+ /**
+ This is the default constructor
+
+ **/
+ public IComboBox() {
+ super();
+ init();
+ }
+
+ /**
+ This method initializes this
+
+ **/
+ private void init() {
+ this.setSize(320, 20);
+ this.setEditable(false);
+ this.editor.addActionListener(this);
+ this.addMouseListener(this);
+ this.addKeyListener(this);
+ this.getEditor().getEditorComponent().addKeyListener(this);
+ this.getEditor().getEditorComponent().addFocusListener(this);
+ }
+
+ public void keyPressed(KeyEvent arg0) {
+ // TODO Auto-generated method stub
+ }
+
+ /* (non-Javadoc)
+ * @see java.awt.event.KeyListener#keyReleased(java.awt.event.KeyEvent)
+ *
+ * Override keyReleased to listen key action
+ *
+ */
+ public void keyReleased(KeyEvent arg0) {
+ //
+ //Add new item to list when press ENTER
+ //
+ if (arg0.getSource() == this.getEditor().getEditorComponent()) {
+ if (arg0.getKeyCode() == KeyEvent.VK_ENTER) {
+ String strCurrentText = this.getEditor().getItem().toString().trim();
+ if (strCurrentText.length() == 0) {
+ if (this.getItemCount() > 0) {
+ this.setSelectedIndex(0);
+ }
+ } else {
+ this.addItem(strCurrentText);
+ this.setSelectedItem(strCurrentText);
+ }
+ this.setEditable(false);
+ }
+ if (arg0.getKeyCode() == KeyEvent.VK_ESCAPE) {
+ closeEdit();
+ }
+ }
+
+ if (arg0.getSource() == this) {
+ //
+ //Remove item from the list when press DEL
+ //
+ if (arg0.getKeyCode() == KeyEvent.VK_DELETE) {
+ int intSelected = this.getSelectedIndex();
+ if (intSelected > -1) {
+ this.removeItemAt(this.getSelectedIndex());
+ if (this.getItemCount() > 0) {
+ this.setSelectedIndex(0);
+ } else {
+ this.removeAllItems();
+ }
+ }
+ }
+ }
+ }
+
+ public void keyTyped(KeyEvent arg0) {
+ // TODO Auto-generated method stub
+ }
+
+ /* (non-Javadoc)
+ * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
+ *
+ * Override mouseClicked to enter edit mode when double click mouse
+ *
+ */
+ public void mouseClicked(MouseEvent arg0) {
+ if (arg0.getClickCount() == 2) {
+ this.setEditable(true);
+ this.getEditor().setItem("");
+ }
+
+ }
+
+ public void mouseEntered(MouseEvent arg0) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void mouseExited(MouseEvent arg0) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void mousePressed(MouseEvent arg0) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void mouseReleased(MouseEvent arg0) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /**
+ Exit edit mode
+
+ **/
+ private void closeEdit() {
+ this.setEditable(false);
+ this.getEditor().setItem("");
+ if (this.getItemCount() > 0) {
+ this.setSelectedIndex(0);
+ }
+ }
+}
diff --git a/Tools/Source/ModuleEditor/src/org/tianocore/packaging/common/ui/IDefaultMutableTreeNode.java b/Tools/Source/ModuleEditor/src/org/tianocore/packaging/common/ui/IDefaultMutableTreeNode.java
new file mode 100644
index 0000000000..ae51c5fa45
--- /dev/null
+++ b/Tools/Source/ModuleEditor/src/org/tianocore/packaging/common/ui/IDefaultMutableTreeNode.java
@@ -0,0 +1,307 @@
+/** @file
+
+
+ The file is used to override DefaultMutableTreeNode to provides customized interfaces
+
+ Copyright (c) 2006, Intel Corporation
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+ **/
+
+package org.tianocore.packaging.common.ui;
+
+import javax.swing.tree.DefaultMutableTreeNode;
+
+/**
+ The class is used to override DefaultMutableTreeNode to provides customized interfaces
+ It extends DefaultMutableTreeNode
+
+ @since ModuleEditor 1.0
+
+ **/
+public class IDefaultMutableTreeNode extends DefaultMutableTreeNode {
+ ///
+ /// Define class Serial Version UID
+ ///
+ private static final long serialVersionUID = -1947340717458069548L;
+
+ //
+ //Static final definitions for all kinds of node
+ //
+ public static final int MSA_HEADER = 0;
+
+ public static final int LIBRARYCLASSDEFINITIONS = 1;
+
+ public static final int SOURCEFILES = 2;
+
+ public static final int INCLUDES = 3;
+
+ public static final int PROTOCOLS = 4;
+
+ public static final int EVENTS = 5;
+
+ public static final int HOBS = 6;
+
+ public static final int PPIS = 7;
+
+ public static final int VARIABLES = 8;
+
+ public static final int BOOTMODES = 9;
+
+ public static final int SYSTEMTABLES = 10;
+
+ public static final int DATAHUBS = 11;
+
+ public static final int FORMSETS = 12;
+
+ public static final int GUIDS = 13;
+
+ public static final int EXTERNS = 14;
+
+ public static final int PCDS = 15;
+
+ public static final int MBD_HEADER = 20;
+
+ public static final int MLSA_HEADER = 21;
+
+ public static final int MLBD_HEADER = 22;
+
+ public static final int LIBRARIES = 23;
+
+ public static final int LIBRARY_CLASS_DEFINITION = 101;
+
+ public static final int SOURCEFILES_FILENAME = 210;
+
+ public static final int SOURCEFILES_FILENAME_ITEM = 211;
+
+ public static final int SOURCEFILES_ARCH = 220;
+
+ public static final int SOURCEFILES_ARCH_ITEM = 221;
+
+ public static final int INCLUDES_PACKAGENAME = 310;
+
+ public static final int INCLUDES_PACKAGENAME_ITEM = 311;
+
+ public static final int INCLUDES_ARCH = 320;
+
+ public static final int INCLUDES_ARCH_ITEM = 321;
+
+ public static final int PROTOCOLS_PROTOCOL = 410;
+
+ public static final int PROTOCOLS_PROTOCOL_ITEM = 411;
+
+ public static final int PROTOCOLS_PROTOCOLNOTIFY = 420;
+
+ public static final int PROTOCOLS_PROTOCOLNOTIFY_ITEM = 421;
+
+ public static final int EVENTS_CREATEEVENTS = 510;
+
+ public static final int EVENTS_CREATEEVENTS_ITEM = 511;
+
+ public static final int EVENTS_SIGNALEVENTS = 520;
+
+ public static final int EVENTS_SIGNALEVENTS_ITEM = 521;
+
+ public static final int HOBS_HOB_ITEM = 611;
+
+ public static final int PPIS_PPI = 710;
+
+ public static final int PPIS_PPI_ITEM = 711;
+
+ public static final int PPIS_PPINOTIFY = 720;
+
+ public static final int PPIS_PPINOTIFY_ITEM = 721;
+
+ public static final int VARIABLES_VARIABLE_ITEM = 811;
+
+ public static final int BOOTMODES_BOOTMODE_ITEM = 911;
+
+ public static final int SYSTEMTABLES_SYSTEMTABLE_ITEM = 1011;
+
+ public static final int DATAHUBS_DATAHUB_ITEM = 1111;
+
+ public static final int FORMSETS_FORMSET_ITEM = 1211;
+
+ public static final int GUIDS_GUIDENTRY_ITEM = 1311;
+
+ public static final int EXTERNS_EXTERN_ITEM = 1411;
+
+ public static final int PCDS_PCDDATA_ITEM = 1511;
+
+ public static final int LIBRARIES_LIBRARY = 2310;
+
+ public static final int LIBRARIES_LIBRARY_ITEM = 2311;
+
+ public static final int LIBRARIES_ARCH = 2320;
+
+ public static final int LIBRARIES_ARCH_ITEM = 2321;
+
+ //
+ //Static final definitions for operation
+ //
+ public static final int OPERATION_NULL = 0;
+
+ public static final int OPERATION_ADD = 1;
+
+ public static final int OPERATION_UPDATE = 2;
+
+ public static final int OPERATION_DELETE = 4;
+
+ public static final int OPERATION_ADD_UPDATE = 3;
+
+ public static final int OPERATION_ADD_DELETE = 5;
+
+ public static final int OPERATION_UPDATE_DELETE = 6;
+
+ public static final int OPERATION_ADD_UPDATE_DELETE = 7;
+
+ //
+ //Define 4 node attributes
+ //
+ private int category = 0;
+
+ private int operation = 0;
+
+ private int location = 0;
+
+ private String nodeName = "";
+
+ /**
+ Main class, reserved for test
+
+ @param args
+
+ **/
+ public static void main(String[] args) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /**
+ This is the default constructor
+
+ **/
+ public IDefaultMutableTreeNode() {
+ super();
+ }
+
+ /**
+ This is the overrided constructor
+ Init clase members with input data
+
+ @param strNodeName The name of node
+ @param intCategory The category of node
+ @param intOperation The operation of node
+
+ **/
+ public IDefaultMutableTreeNode(String strNodeName, int intCategory, int intOperation) {
+ super(strNodeName);
+ this.nodeName = strNodeName;
+ this.category = intCategory;
+ this.operation = intOperation;
+ }
+
+ /**
+ This is the overrided constructor
+ Init clase members with input data
+
+ @param strNodeName The name of node
+ @param intCategory The category of node
+ @param intOperation The operation of node
+ @param intLocation The location of node
+
+ **/
+ public IDefaultMutableTreeNode(String strNodeName, int intCategory, int intOperation, int intLocation) {
+ super(strNodeName);
+ this.nodeName = strNodeName;
+ this.category = intCategory;
+ this.operation = intOperation;
+ this.location = intLocation;
+ }
+
+ /**
+ Get category of node
+
+ @return The category of node
+
+ **/
+ public int getCategory() {
+ return category;
+ }
+
+ /**
+ Set category of node
+
+ @param category The input data of node category
+
+ **/
+ public void setCategory(int category) {
+ this.category = category;
+ }
+
+ /**
+ Get name of node
+
+ @return The name of node
+
+ **/
+ public String getNodeName() {
+ return nodeName;
+ }
+
+ /**
+ Set name of node
+
+ @param nodeName The input data of node name
+
+ **/
+ public void setNodeName(String nodeName) {
+ this.nodeName = nodeName;
+ }
+
+ /**
+ Get operation of node
+
+ @return The operation of node
+
+ **/
+ public int getOperation() {
+ return operation;
+ }
+
+ /**
+ Set operation of node
+
+ @param operation The input data of node operation
+
+ **/
+ public void setOperation(int operation) {
+ this.operation = operation;
+ }
+
+ /**
+ Get location of node
+
+ @return The location of node
+
+ **/
+ public int getLocation() {
+ return location;
+ }
+
+ /**
+ Set location of node
+
+ @param location The input data of node location
+
+ **/
+ public void setLocation(int location) {
+ this.location = location;
+ }
+}
diff --git a/Tools/Source/ModuleEditor/src/org/tianocore/packaging/common/ui/IDesktopManager.java b/Tools/Source/ModuleEditor/src/org/tianocore/packaging/common/ui/IDesktopManager.java
new file mode 100644
index 0000000000..b86aa6b484
--- /dev/null
+++ b/Tools/Source/ModuleEditor/src/org/tianocore/packaging/common/ui/IDesktopManager.java
@@ -0,0 +1,76 @@
+/** @file
+
+ The file is used to override DefaultDesktopManager to provides customized interfaces
+
+ Copyright (c) 2006, Intel Corporation
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+ **/
+
+package org.tianocore.packaging.common.ui;
+
+import javax.swing.DefaultDesktopManager;
+import javax.swing.JComponent;
+
+/**
+ The class is used to override DefaultDesktopManager to provides customized interfaces
+ It extends DefaultDesktopManager
+
+ @since ModuleEditor 1.0
+
+ **/
+public class IDesktopManager extends DefaultDesktopManager {
+
+ ///
+ /// Define class Serial Version UID
+ ///
+ private static final long serialVersionUID = -4596986878722011062L;
+
+ /**
+ Main class, reserved for test
+
+ @param args
+
+ **/
+ public static void main(String[] args) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see javax.swing.DesktopManager#dragFrame(javax.swing.JComponent, int, int)
+ *
+ * Override dragFrame to do nothing to forbid internalframe to be draged
+ *
+ */
+ public void dragFrame(JComponent f, int newX, int newY) {
+
+ }
+
+ /* (non-Javadoc)
+ * @see javax.swing.DesktopManager#endDraggingFrame(javax.swing.JComponent)
+ *
+ * Override endDraggingFrame to do nothing to forbid internalframe to be draged
+ *
+ */
+ public void endDraggingFrame(JComponent f) {
+
+ }
+
+ /* (non-Javadoc)
+ * @see javax.swing.DesktopManager#beginResizingFrame(javax.swing.JComponent, int)
+ *
+ * Override beginResizingFrame to do nothing to forbid internalframe to be draged
+ *
+ */
+ public void beginResizingFrame(JComponent f, int direction) {
+
+ }
+
+}
diff --git a/Tools/Source/ModuleEditor/src/org/tianocore/packaging/common/ui/IDialog.java b/Tools/Source/ModuleEditor/src/org/tianocore/packaging/common/ui/IDialog.java
new file mode 100644
index 0000000000..622b54bcca
--- /dev/null
+++ b/Tools/Source/ModuleEditor/src/org/tianocore/packaging/common/ui/IDialog.java
@@ -0,0 +1,144 @@
+/** @file
+
+ The file is used to override Dialog to provides customized interfaces
+
+ Copyright (c) 2006, Intel Corporation
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+ **/
+
+package org.tianocore.packaging.common.ui;
+
+import java.awt.Dimension;
+import java.awt.Toolkit;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+import javax.swing.JDialog;
+
+/**
+ The class is used to override Dialog to provides customized interfaces
+ It extends JDialog implements ActionListener
+
+ @since ModuleEditor 1.0
+
+ **/
+public class IDialog extends JDialog implements ActionListener {
+ ///
+ /// Define class Serial Version UID
+ ///
+ private static final long serialVersionUID = -7692623863358631984L;
+ //
+ //Define class members
+ //
+ private boolean isEdited = false;
+
+ public void actionPerformed(ActionEvent arg0) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /**
+ Main class, used for test
+
+ @param args
+
+ **/
+ public static void main(String[] args) {
+ IDialog id = new IDialog();
+ id.setVisible(true);
+ }
+
+ /**
+ This is the default constructor
+ **/
+ public IDialog() {
+ super();
+ initialize();
+ }
+
+ /**
+ * This is the override constructor
+ */
+ /**
+ This is the override constructor
+
+ @param parentFrame The parent frame which open the dialog
+ @param modal true means the dialog is modal dialog; false means the dialog is not modal dialog
+ **/
+ public IDialog(IFrame parentFrame, boolean modal) {
+ super(parentFrame, modal);
+ initialize();
+ }
+
+ /**
+ This method initializes this
+
+ **/
+ private void initialize() {
+ this.setResizable(false);
+ }
+
+ /**
+ Start the dialog at the center of screen
+
+ @param intWidth The width of the dialog
+ @param intHeight The height of the dialog
+
+ **/
+ protected void centerWindow(int intWidth, int intHeight) {
+ Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
+ this.setLocation((d.width - intWidth) / 2, (d.height - intHeight) / 2);
+ }
+
+ /**
+ Start the dialog at the center of screen
+
+ **/
+ protected void centerWindow() {
+ centerWindow(this.getSize().width, this.getSize().height);
+ }
+
+ /**
+ Get if the dialog has been edited
+
+ @retval true - The dialog has been edited
+ @retval false - The dialog hasn't been edited
+
+ **/
+ public boolean isEdited() {
+ return isEdited;
+ }
+
+ /**
+ Set if the dialog has been edited
+
+ @param isEdited The input data which identify if the dialog has been edited
+
+ **/
+ public void setEdited(boolean isEdited) {
+ this.isEdited = isEdited;
+ }
+
+ /**
+ Check the input data is empty or not
+
+ @param strValue The input data which need be checked
+
+ @retval true - The input data is empty
+ @retval fals - The input data is not empty
+
+ **/
+ public boolean isEmpty(String strValue) {
+ if (strValue.length() > 0) {
+ return false;
+ }
+ return true;
+ }
+}
diff --git a/Tools/Source/ModuleEditor/src/org/tianocore/packaging/common/ui/IFrame.java b/Tools/Source/ModuleEditor/src/org/tianocore/packaging/common/ui/IFrame.java
new file mode 100644
index 0000000000..4e36bd430a
--- /dev/null
+++ b/Tools/Source/ModuleEditor/src/org/tianocore/packaging/common/ui/IFrame.java
@@ -0,0 +1,204 @@
+/** @file
+
+ The file is used to override Frame to provides customized interfaces
+
+ Copyright (c) 2006, Intel Corporation
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+ **/
+
+package org.tianocore.packaging.common.ui;
+
+import java.awt.Dimension;
+import java.awt.Toolkit;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.WindowEvent;
+import java.awt.event.WindowListener;
+
+import javax.swing.JFrame;
+
+/**
+ The class is used to override Frame to provides customized interfaces
+ It extends JFrame implements ActionListener and WindowListener
+
+ @since ModuleEditor 1.0
+
+ **/
+public class IFrame extends JFrame implements ActionListener, WindowListener {
+
+ ///
+ /// Define class Serial Version UID
+ ///
+ private static final long serialVersionUID = -3324138961029300427L;
+
+ //
+ //Define class members
+ //
+ private ExitConfirm ec = null;
+
+ //
+ // To indicate the status while quit
+ // 0 - When setup (Default)
+ // 1 - Whne editing module
+ //
+ private int intExitType = 0;
+
+ /**
+ Main class, used for test
+
+ @param args
+
+ **/
+ public static void main(String[] args) {
+ IFrame i = new IFrame();
+ i.setVisible(true);
+ }
+
+ /**
+ This is the default constructor
+
+ **/
+ public IFrame() {
+ super();
+ initialize();
+ }
+
+ /**
+ This method initializes this
+
+ **/
+ public void initialize() {
+ this.setResizable(false);
+ this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
+ this.addWindowListener(this);
+ }
+
+ /**
+ Start the dialog at the center of screen
+
+ @param intWidth The width of the dialog
+ @param intHeight The height of the dialog
+
+ **/
+ protected void centerWindow(int intWidth, int intHeight) {
+ Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
+ this.setLocation((d.width - intWidth) / 2, (d.height - intHeight) / 2);
+ }
+
+ /**
+ Start the dialog at the center of screen
+
+ **/
+ protected void centerWindow() {
+ centerWindow(this.getSize().width, this.getSize().height);
+ }
+
+ /**
+ Set the exit window type
+
+ @param ExitType The input data of ExitType
+
+ **/
+ protected void setExitType(int ExitType) {
+ this.intExitType = ExitType;
+ }
+
+ /* (non-Javadoc)
+ * @see java.awt.event.WindowListener#windowClosing(java.awt.event.WindowEvent)
+ *
+ * Override windowClosing to call this.onDisvisible()
+ *
+ */
+ public void windowClosing(WindowEvent arg0) {
+ this.onDisvisible();
+ }
+
+ public void windowOpened(WindowEvent arg0) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void windowClosed(WindowEvent arg0) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void windowIconified(WindowEvent arg0) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void windowDeiconified(WindowEvent arg0) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void windowActivated(WindowEvent arg0) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void windowDeactivated(WindowEvent arg0) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void actionPerformed(ActionEvent arg0) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /**
+ Define the actions when exit
+
+ **/
+ public void onExit() {
+ ec = new ExitConfirm(this, true);
+ //
+ //Show different warning message via different ExitType
+ //
+ switch (intExitType) {
+ case 0:
+ ec.setSetupMessage();
+ break;
+ case 1:
+ ec.setModuleMessage();
+ break;
+ }
+ ec.setVisible(true);
+ if (ec.isCancel) {
+ this.dispose();
+ System.exit(0);
+ }
+ }
+
+ /**
+ Define the actions when disvisible
+
+ **/
+ public void onDisvisible() {
+ ec = new ExitConfirm(this, true);
+ //
+ //Show different warning message via different ExitType
+ //
+ switch (intExitType) {
+ case 0:
+ ec.setSetupMessage();
+ break;
+ case 1:
+ ec.setModuleMessage();
+ break;
+ }
+ ec.setVisible(true);
+ if (ec.isCancel) {
+ this.dispose();
+ }
+ }
+}
diff --git a/Tools/Source/ModuleEditor/src/org/tianocore/packaging/common/ui/IInternalFrame.java b/Tools/Source/ModuleEditor/src/org/tianocore/packaging/common/ui/IInternalFrame.java
new file mode 100644
index 0000000000..8fc9d9b489
--- /dev/null
+++ b/Tools/Source/ModuleEditor/src/org/tianocore/packaging/common/ui/IInternalFrame.java
@@ -0,0 +1,109 @@
+/** @file
+
+ The file is used to override JInternalFrame to provides customized interfaces
+
+ Copyright (c) 2006, Intel Corporation
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+ **/
+
+package org.tianocore.packaging.common.ui;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+import javax.swing.JInternalFrame;
+
+/**
+ The class is used to override JInternalFrame to provides customized interfaces
+ It extends JInternalFrame implements ActionListener
+
+ @since ModuleEditor 1.0
+
+ **/
+public class IInternalFrame extends JInternalFrame implements ActionListener {
+
+ ///
+ /// Define class Serial Version UID
+ ///
+ private static final long serialVersionUID = -609841772384875886L;
+ //
+ //Define class members
+ //
+ private boolean isEdited = false;
+
+ /**
+ Main class, reserved for test
+
+ @param args
+
+ **/
+ public static void main(String[] args) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /**
+ This is the default constructor
+
+ **/
+ public IInternalFrame() {
+ super();
+ initialize();
+ }
+
+ /**
+ This method initializes this
+
+ **/
+ private void initialize() {
+ this.setBounds(new java.awt.Rectangle(0, 0, 500, 500));
+ }
+
+ /**
+ Get if the InternalFrame has been edited
+
+ @retval true - The InternalFrame has been edited
+ @retval false - The InternalFrame hasn't been edited
+
+ **/
+ public boolean isEdited() {
+ return isEdited;
+ }
+
+ /**
+ Set if the InternalFrame has been edited
+
+ @param isEdited The input data which identify if the InternalFrame has been edited
+
+ **/
+ public void setEdited(boolean isEdited) {
+ this.isEdited = isEdited;
+ }
+
+ /**
+ Check the input data is empty or not
+
+ @param strValue The input data which need be checked
+
+ @retval true - The input data is empty
+ @retval fals - The input data is not empty
+
+ **/
+ public boolean isEmpty(String strValue) {
+ if (strValue.length() > 0) {
+ return false;
+ }
+ return true;
+ }
+
+ public void actionPerformed(ActionEvent arg0) {
+ // TODO Auto-generated method stub
+ }
+}
diff --git a/Tools/Source/ModuleEditor/src/org/tianocore/packaging/common/ui/ITree.java b/Tools/Source/ModuleEditor/src/org/tianocore/packaging/common/ui/ITree.java
new file mode 100644
index 0000000000..eeb51fce83
--- /dev/null
+++ b/Tools/Source/ModuleEditor/src/org/tianocore/packaging/common/ui/ITree.java
@@ -0,0 +1,204 @@
+/** @file
+
+ The file is used to override JTree to provides customized interfaces
+
+ Copyright (c) 2006, Intel Corporation
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+ **/
+
+package org.tianocore.packaging.common.ui;
+
+import javax.swing.JTree;
+import javax.swing.tree.DefaultMutableTreeNode;
+import javax.swing.tree.DefaultTreeModel;
+import javax.swing.tree.TreeNode;
+import javax.swing.tree.TreePath;
+
+/**
+ The class is used to override JTree to provides customized interfaces
+ It extends JTree
+
+ @since ModuleEditor 1.0
+
+ **/
+public class ITree extends JTree {
+ ///
+ /// Define class Serial Version UID
+ ///
+ private static final long serialVersionUID = -7907086164518295327L;
+
+ //
+ // Define class members
+ //
+ DefaultTreeModel treeModel = null;
+
+ /**
+ This is the default constructor
+
+ **/
+ public ITree() {
+ super();
+ }
+
+ /**
+ This is the overrided constructor
+ Init class members with input data
+
+ @param iDmtRoot The root node of the tree
+
+ **/
+ public ITree(IDefaultMutableTreeNode iDmtRoot) {
+ super(iDmtRoot);
+ }
+
+ /**
+ Get category of selected node
+
+ @return The category of selected node
+
+ **/
+ public int getSelectCategory() {
+ int intCategory = 0;
+ TreePath path = this.getSelectionPath();
+ IDefaultMutableTreeNode node = (IDefaultMutableTreeNode) path.getLastPathComponent();
+ intCategory = node.getCategory();
+ return intCategory;
+ }
+
+ /**
+ Get operation of selected node
+
+ @return The operation of selected node
+
+ **/
+ public int getSelectOperation() {
+ int intOperation = 0;
+ TreePath path = this.getSelectionPath();
+ IDefaultMutableTreeNode node = (IDefaultMutableTreeNode) path.getLastPathComponent();
+ intOperation = node.getOperation();
+ return intOperation;
+ }
+
+ /**
+ Get selectLoaction of selected node
+
+ @return The selectLoaction of selected node
+
+ **/
+ public int getSelectLoaction() {
+ int intLocation = 0;
+ TreePath path = this.getSelectionPath();
+ IDefaultMutableTreeNode node = (IDefaultMutableTreeNode) path.getLastPathComponent();
+ intLocation = node.getLocation();
+ return intLocation;
+ }
+
+ /**
+ Main class, reserved for test
+
+ @param args
+
+ **/
+ public static void main(String[] args) {
+ // TODO Auto-generated method stub
+ }
+
+ /**
+ Add input node as child node for current selected node
+
+ @param strNewNode The name of the node which need be added
+
+ **/
+ public void addNode(String strNewNode) {
+ DefaultMutableTreeNode parentNode = null;
+ DefaultMutableTreeNode newNode = new DefaultMutableTreeNode(strNewNode);
+ newNode.setAllowsChildren(true);
+ TreePath parentPath = this.getSelectionPath();
+
+ /**
+ * Get parent node of new node
+ */
+ parentNode = (DefaultMutableTreeNode) (parentPath.getLastPathComponent());
+
+ /**
+ * Insert new node
+ */
+ treeModel.insertNodeInto(newNode, parentNode, parentNode.getChildCount());
+ this.scrollPathToVisible(new TreePath(newNode.getPath()));
+ }
+
+ /**
+ Add input node as child node for current selected node
+
+ @param newNode The node need be added
+
+ **/
+ public void addNode(IDefaultMutableTreeNode newNode) {
+ IDefaultMutableTreeNode parentNode = null;
+ newNode.setAllowsChildren(true);
+ TreePath parentPath = this.getSelectionPath();
+ parentNode = (IDefaultMutableTreeNode) (parentPath.getLastPathComponent());
+ treeModel.insertNodeInto(newNode, parentNode, parentNode.getChildCount());
+ this.scrollPathToVisible(new TreePath(newNode.getPath()));
+ }
+
+ /**
+ Remove current selectd node
+
+ **/
+ public void removeNode() {
+ TreePath treepath = this.getSelectionPath();
+ if (treepath != null) {
+ DefaultMutableTreeNode selectionNode = (DefaultMutableTreeNode) treepath.getLastPathComponent();
+ TreeNode parent = (TreeNode) selectionNode.getParent();
+ if (parent != null) {
+ treeModel.removeNodeFromParent(selectionNode);
+ }
+ }
+ }
+
+ /**
+ Remove all node on a same level
+
+ **/
+ public void removeNodeOnSameLevel() {
+ TreePath treepath = this.getSelectionPath();
+ IDefaultMutableTreeNode parentNode = (IDefaultMutableTreeNode) treepath.getLastPathComponent();
+ parentNode.removeAllChildren();
+ treeModel.reload();
+ }
+
+ /**
+ Remove the input node by name
+
+ @param strRemovedNode
+
+ **/
+ public void removeNode(String strRemovedNode) {
+ TreePath treepath = this.getSelectionPath();
+ if (treepath != null) {
+ DefaultMutableTreeNode selectionNode = (DefaultMutableTreeNode) treepath.getLastPathComponent();
+ TreeNode parent = (TreeNode) selectionNode.getParent();
+ if (parent != null) {
+ treeModel.removeNodeFromParent(selectionNode);
+ }
+ }
+ }
+
+ /**
+ Remove all nodes of the tree
+
+ **/
+ public void removeAllNode() {
+ DefaultMutableTreeNode rootNode = (DefaultMutableTreeNode) treeModel.getRoot();
+ rootNode.removeAllChildren();
+ treeModel.reload();
+ }
+}
diff --git a/Tools/Source/ModuleEditor/src/org/tianocore/packaging/common/ui/StarLabel.java b/Tools/Source/ModuleEditor/src/org/tianocore/packaging/common/ui/StarLabel.java
new file mode 100644
index 0000000000..c451ac53b9
--- /dev/null
+++ b/Tools/Source/ModuleEditor/src/org/tianocore/packaging/common/ui/StarLabel.java
@@ -0,0 +1,64 @@
+/** @file
+
+ The file is used to override JLabel to provides customized interfaces
+
+ Copyright (c) 2006, Intel Corporation
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+ **/
+
+package org.tianocore.packaging.common.ui;
+
+import javax.swing.JLabel;
+
+/**
+ The class is used to override JLabel to provides customized interfaces
+
+ @since ModuleEditor 1.0
+
+ **/
+public class StarLabel extends JLabel {
+
+ ///
+ /// Define class Serial Version UID
+ ///
+ private static final long serialVersionUID = -6702981027831543919L;
+
+ /**
+ Main class, reserved for test
+
+ @param args
+
+ **/
+ public static void main(String[] args) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /**
+ This is the default constructor
+
+ **/
+ public StarLabel() {
+ super();
+ init();
+ }
+
+ /**
+ To create a RED, BOLD and 14 size "*"
+
+ **/
+ private void init() {
+ this.setText("*");
+ this.setSize(new java.awt.Dimension(10, 20));
+ this.setForeground(java.awt.Color.red);
+ this.setFont(new java.awt.Font("DialogInput", java.awt.Font.BOLD, 14));
+ this.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
+ }
+}
diff --git a/Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/MbdHeader.java b/Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/MbdHeader.java
new file mode 100644
index 0000000000..9176407277
--- /dev/null
+++ b/Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/MbdHeader.java
@@ -0,0 +1,602 @@
+/** @file
+
+ This file is used to create, update MbdHeader of a MBD file
+
+ Copyright (c) 2006, Intel Corporation
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+ **/
+
+package org.tianocore.packaging.module.ui;
+
+import java.awt.event.ActionEvent;
+
+import javax.swing.JButton;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTextArea;
+import javax.swing.JTextField;
+
+import org.tianocore.BaseNameDocument;
+import org.tianocore.GuidDocument;
+import org.tianocore.LicenseDocument;
+import org.tianocore.MbdHeaderDocument;
+import org.tianocore.common.DataValidation;
+import org.tianocore.common.Log;
+import org.tianocore.common.Tools;
+import org.tianocore.packaging.common.ui.IInternalFrame;
+import org.tianocore.packaging.common.ui.StarLabel;
+
+/**
+ This class is used to create, update MbdHeader of a MBD file
+ It extends IInternalFrame
+
+ @since ModuleEditor 1.0
+
+ **/
+public class MbdHeader extends IInternalFrame {
+ ///
+ /// Define class Serial Version UID
+ ///
+ private static final long serialVersionUID = -2015726615436197378L;
+
+ //
+ // Define class members
+ //
+ private JPanel jContentPane = null;
+
+ private JLabel jLabelBaseName = null;
+
+ private JTextField jTextFieldBaseName = null;
+
+ private JLabel jLabelGuid = null;
+
+ private JTextField jTextFieldGuid = null;
+
+ private JLabel jLabelVersion = null;
+
+ private JTextField jTextFieldVersion = null;
+
+ private JButton jButtonGenerateGuid = null;
+
+ private JLabel jLabelLicense = null;
+
+ private JTextArea jTextAreaLicense = null;
+
+ private JLabel jLabelCopyright = null;
+
+ private JTextArea jTextAreaCopyright = null;
+
+ private JLabel jLabelDescription = null;
+
+ private JTextArea jTextAreaDescription = null;
+
+ private JButton jButtonOk = null;
+
+ private JButton jButtonCancel = null;
+
+ private JScrollPane jScrollPaneLicense = null;
+
+ private JScrollPane jScrollPaneCopyright = null;
+
+ private JScrollPane jScrollPaneDescription = null;
+
+ private StarLabel jStarLabel1 = null;
+
+ private StarLabel jStarLabel2 = null;
+
+ private StarLabel jStarLabel3 = null;
+
+ private StarLabel jStarLabel4 = null;
+
+ private StarLabel jStarLabel5 = null;
+
+ private StarLabel jStarLabel6 = null;
+
+ private MbdHeaderDocument.MbdHeader mbdHeader = null;
+
+ /**
+ This method initializes jTextFieldBaseName
+
+ @return javax.swing.JTextField jTextFieldBaseName
+
+ **/
+ private JTextField getJTextFieldBaseName() {
+ if (jTextFieldBaseName == null) {
+ jTextFieldBaseName = new JTextField();
+ jTextFieldBaseName.setBounds(new java.awt.Rectangle(160, 10, 320, 20));
+ }
+ return jTextFieldBaseName;
+ }
+
+ /**
+ This method initializes jTextFieldGuid
+
+ @return javax.swing.JTextField jTextFieldGuid
+
+ **/
+ private JTextField getJTextFieldGuid() {
+ if (jTextFieldGuid == null) {
+ jTextFieldGuid = new JTextField();
+ jTextFieldGuid.setBounds(new java.awt.Rectangle(160, 35, 240, 20));
+ }
+ return jTextFieldGuid;
+ }
+
+ /**
+ This method initializes jTextFieldVersion
+
+ @return javax.swing.JTextField jTextFieldVersion
+
+ **/
+ private JTextField getJTextFieldVersion() {
+ if (jTextFieldVersion == null) {
+ jTextFieldVersion = new JTextField();
+ jTextFieldVersion.setBounds(new java.awt.Rectangle(160, 60, 320, 20));
+ }
+ return jTextFieldVersion;
+ }
+
+ /**
+ This method initializes jButtonGenerateGuid
+
+ @return javax.swing.JButton jButtonGenerateGuid
+
+ **/
+ private JButton getJButtonGenerateGuid() {
+ if (jButtonGenerateGuid == null) {
+ jButtonGenerateGuid = new JButton();
+ jButtonGenerateGuid.setBounds(new java.awt.Rectangle(405, 35, 75, 20));
+ jButtonGenerateGuid.setText("GEN");
+ jButtonGenerateGuid.addActionListener(this);
+ }
+ return jButtonGenerateGuid;
+ }
+
+ /**
+ This method initializes jTextAreaLicense
+
+ @return javax.swing.JTextArea jTextAreaLicense
+
+ **/
+ private JTextArea getJTextAreaLicense() {
+ if (jTextAreaLicense == null) {
+ jTextAreaLicense = new JTextArea();
+ jTextAreaLicense.setText("");
+ jTextAreaLicense.setLineWrap(true);
+ }
+ return jTextAreaLicense;
+ }
+
+ /**
+ This method initializes jTextAreaCopyright
+
+ @return javax.swing.JTextArea jTextAreaCopyright
+
+ **/
+ private JTextArea getJTextAreaCopyright() {
+ if (jTextAreaCopyright == null) {
+ jTextAreaCopyright = new JTextArea();
+ jTextAreaCopyright.setLineWrap(true);
+ }
+ return jTextAreaCopyright;
+ }
+
+ /**
+ This method initializes jTextAreaDescription
+
+ @return javax.swing.JTextArea jTextAreaDescription
+
+ **/
+ private JTextArea getJTextAreaDescription() {
+ if (jTextAreaDescription == null) {
+ jTextAreaDescription = new JTextArea();
+ jTextAreaDescription.setLineWrap(true);
+ }
+ return jTextAreaDescription;
+ }
+
+ /**
+ This method initializes jButtonOk
+
+ @return javax.swing.JButton jButtonOk
+
+ **/
+ private JButton getJButtonOk() {
+ if (jButtonOk == null) {
+ jButtonOk = new JButton();
+ jButtonOk.setText("OK");
+ jButtonOk.setBounds(new java.awt.Rectangle(290, 345, 90, 20));
+ jButtonOk.addActionListener(this);
+ }
+ return jButtonOk;
+ }
+
+ /**
+ This method initializes jButtonCancel
+
+ @return javax.swing.JButton jButtonCancel
+
+ **/
+ private JButton getJButtonCancel() {
+ if (jButtonCancel == null) {
+ jButtonCancel = new JButton();
+ jButtonCancel.setText("Cancel");
+ jButtonCancel.setBounds(new java.awt.Rectangle(390, 345, 90, 20));
+ jButtonCancel.addActionListener(this);
+ }
+ return jButtonCancel;
+ }
+
+ /**
+ This method initializes jScrollPaneLicense
+
+ @return javax.swing.JScrollPane jScrollPaneLicense
+
+ **/
+ private JScrollPane getJScrollPaneLicense() {
+ if (jScrollPaneLicense == null) {
+ jScrollPaneLicense = new JScrollPane();
+ jScrollPaneLicense.setBounds(new java.awt.Rectangle(160, 85, 320, 80));
+ jScrollPaneLicense.setHorizontalScrollBarPolicy(javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
+ jScrollPaneLicense.setViewportView(getJTextAreaLicense());
+ }
+ return jScrollPaneLicense;
+ }
+
+ /**
+ This method initializes jScrollPaneCopyright
+
+ @return javax.swing.JScrollPane jScrollPaneCopyright
+
+ **/
+ private JScrollPane getJScrollPaneCopyright() {
+ if (jScrollPaneCopyright == null) {
+ jScrollPaneCopyright = new JScrollPane();
+ jScrollPaneCopyright.setBounds(new java.awt.Rectangle(160, 170, 320, 80));
+ jScrollPaneCopyright.setHorizontalScrollBarPolicy(javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
+ jScrollPaneCopyright.setViewportView(getJTextAreaCopyright());
+ }
+ return jScrollPaneCopyright;
+ }
+
+ /**
+ This method initializes jScrollPaneDescription
+
+ @return javax.swing.JScrollPane jScrollPaneDescription
+
+ **/
+ private JScrollPane getJScrollPaneDescription() {
+ if (jScrollPaneDescription == null) {
+ jScrollPaneDescription = new JScrollPane();
+ jScrollPaneDescription.setBounds(new java.awt.Rectangle(160, 255, 320, 80));
+ jScrollPaneDescription.setHorizontalScrollBarPolicy(javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
+ jScrollPaneDescription.setViewportView(getJTextAreaDescription());
+ }
+ return jScrollPaneDescription;
+ }
+
+ public static void main(String[] args) {
+
+ }
+
+ /**
+ This is the default constructor
+
+ **/
+ public MbdHeader() {
+ super();
+ init();
+ this.setVisible(true);
+ }
+
+ /**
+ This is the override edit constructor
+
+ **/
+ public MbdHeader(MbdHeaderDocument.MbdHeader inMbdHeader) {
+ super();
+ init(inMbdHeader);
+ this.setVisible(true);
+ this.setViewMode(false);
+ }
+
+ /**
+ This method initializes this
+
+ **/
+ private void init() {
+ this.setSize(500, 515);
+ this.setContentPane(getJContentPane());
+ this.setTitle("Module Build Description Header");
+ initFrame();
+ }
+
+ /**
+ This method initializes this
+ Fill values to all fields if these values are not empty
+
+ @param inMbdHeader The input MbdHeaderDocument.MbdHeader
+
+ **/
+ private void init(MbdHeaderDocument.MbdHeader inMbdHeader) {
+ init();
+ setMbdHeader(inMbdHeader);
+ if (inMbdHeader != null) {
+ if (this.mbdHeader.getBaseName() != null) {
+ this.jTextFieldBaseName.setText(this.mbdHeader.getBaseName().getStringValue());
+ }
+ if (this.mbdHeader.getGuid() != null) {
+ this.jTextFieldGuid.setText(this.mbdHeader.getGuid().getStringValue());
+ }
+ if (this.mbdHeader.getVersion() != null) {
+ this.jTextFieldVersion.setText(this.mbdHeader.getVersion());
+ }
+ if (this.mbdHeader.getLicense() != null) {
+ this.jTextAreaLicense.setText(this.mbdHeader.getLicense().getStringValue());
+ }
+ if (this.mbdHeader.getCopyright() != null) {
+ this.jTextAreaCopyright.setText(this.mbdHeader.getCopyright());
+ }
+ if (this.mbdHeader.getDescription() != null) {
+ this.jTextAreaDescription.setText(this.mbdHeader.getDescription());
+ }
+ }
+ }
+
+ /**
+ Disable all components when the mode is view
+
+ @param isView true - The view mode; false - The non-view mode
+
+ **/
+ public void setViewMode(boolean isView) {
+ this.jButtonOk.setVisible(false);
+ this.jButtonCancel.setVisible(false);
+ if (isView) {
+ this.jTextFieldBaseName.setEnabled(!isView);
+ this.jTextFieldGuid.setEnabled(!isView);
+ this.jTextFieldVersion.setEnabled(!isView);
+ this.jTextAreaLicense.setEnabled(!isView);
+ this.jTextAreaCopyright.setEnabled(!isView);
+ this.jTextAreaDescription.setEnabled(!isView);
+ this.jButtonCancel.setEnabled(!isView);
+ this.jButtonGenerateGuid.setEnabled(!isView);
+ this.jButtonOk.setEnabled(!isView);
+ }
+ }
+
+ /**
+ This method initializes jContentPane
+
+ @return javax.swing.JPanel jContentPane
+
+ **/
+ private JPanel getJContentPane() {
+ if (jContentPane == null) {
+ jLabelDescription = new JLabel();
+ jLabelDescription.setText("Description");
+ jLabelDescription.setBounds(new java.awt.Rectangle(15, 255, 140, 20));
+ jLabelCopyright = new JLabel();
+ jLabelCopyright.setText("Copyright");
+ jLabelCopyright.setBounds(new java.awt.Rectangle(15, 170, 140, 20));
+ jLabelLicense = new JLabel();
+ jLabelLicense.setText("License");
+ jLabelLicense.setBounds(new java.awt.Rectangle(15, 85, 140, 20));
+ jLabelVersion = new JLabel();
+ jLabelVersion.setText("Version");
+ jLabelVersion.setBounds(new java.awt.Rectangle(15, 60, 140, 20));
+ jLabelGuid = new JLabel();
+ jLabelGuid.setPreferredSize(new java.awt.Dimension(25, 15));
+ jLabelGuid.setBounds(new java.awt.Rectangle(15, 35, 140, 20));
+ jLabelGuid.setText("Guid");
+ jLabelBaseName = new JLabel();
+ jLabelBaseName.setText("Base Name");
+ jLabelBaseName.setBounds(new java.awt.Rectangle(15, 10, 140, 20));
+ jContentPane = new JPanel();
+ jContentPane.setLayout(null);
+ jContentPane.setLocation(new java.awt.Point(0, 0));
+ jContentPane.setSize(new java.awt.Dimension(500, 524));
+ jContentPane.add(jLabelBaseName, null);
+ jContentPane.add(getJTextFieldBaseName(), null);
+ jContentPane.add(jLabelGuid, null);
+ jContentPane.add(getJTextFieldGuid(), null);
+ jContentPane.add(jLabelVersion, null);
+ jContentPane.add(getJTextFieldVersion(), null);
+ jContentPane.add(getJButtonGenerateGuid(), null);
+ jContentPane.add(jLabelLicense, null);
+ jContentPane.add(jLabelCopyright, null);
+ jContentPane.add(jLabelDescription, null);
+ jContentPane.add(getJButtonOk(), null);
+ jContentPane.add(getJButtonCancel(), null);
+ jContentPane.add(getJScrollPaneLicense(), null);
+ jContentPane.add(getJScrollPaneCopyright(), null);
+ jContentPane.add(getJScrollPaneDescription(), null);
+
+ jStarLabel1 = new StarLabel();
+ jStarLabel1.setLocation(new java.awt.Point(0, 10));
+ jStarLabel2 = new StarLabel();
+ jStarLabel2.setLocation(new java.awt.Point(0, 35));
+ jStarLabel3 = new StarLabel();
+ jStarLabel3.setLocation(new java.awt.Point(0, 60));
+ jStarLabel4 = new StarLabel();
+ jStarLabel4.setLocation(new java.awt.Point(0, 85));
+ jStarLabel5 = new StarLabel();
+ jStarLabel5.setLocation(new java.awt.Point(0, 170));
+ jStarLabel6 = new StarLabel();
+ jStarLabel6.setLocation(new java.awt.Point(0, 255));
+
+ jContentPane.add(jStarLabel1, null);
+ jContentPane.add(jStarLabel2, null);
+ jContentPane.add(jStarLabel3, null);
+ jContentPane.add(jStarLabel4, null);
+ jContentPane.add(jStarLabel5, null);
+ jContentPane.add(jStarLabel6, null);
+ }
+ return jContentPane;
+ }
+
+ /* (non-Javadoc)
+ * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
+ *
+ * Override actionPerformed to listen all actions
+ *
+ */
+ public void actionPerformed(ActionEvent arg0) {
+ if (arg0.getSource() == jButtonOk) {
+ this.dispose();
+ this.save();
+ this.setEdited(true);
+ }
+ if (arg0.getSource() == jButtonCancel) {
+ this.dispose();
+ this.setEdited(false);
+ }
+ //
+ // Generate GUID
+ //
+ if (arg0.getSource() == jButtonGenerateGuid) {
+ jTextFieldGuid.setText(Tools.generateUuidString());
+ }
+ }
+
+ /**
+ Data validation for all fields
+
+ @retval true - All datas are valid
+ @retval false - At least one data is invalid
+
+ **/
+ public boolean check() {
+ //
+ // Check if all required fields are not empty
+ //
+ if (isEmpty(this.jTextFieldBaseName.getText())) {
+ Log.err("Base Name couldn't be empty");
+ return false;
+ }
+ if (isEmpty(this.jTextFieldGuid.getText())) {
+ Log.err("Guid couldn't be empty");
+ return false;
+ }
+ if (isEmpty(this.jTextFieldVersion.getText())) {
+ Log.err("Version couldn't be empty");
+ return false;
+ }
+ if (isEmpty(this.jTextAreaLicense.getText())) {
+ Log.err("License couldn't be empty");
+ return false;
+ }
+ if (isEmpty(this.jTextAreaCopyright.getText())) {
+ Log.err("Copyright couldn't be empty");
+ return false;
+ }
+ if (isEmpty(this.jTextAreaDescription.getText())) {
+ Log.err("Description couldn't be empty");
+ return false;
+ }
+
+ //
+ // Check if all fields have correct data types
+ //
+ if (!DataValidation.isBaseName(this.jTextFieldBaseName.getText())) {
+ Log.err("Incorrect data type for Base Name");
+ return false;
+ }
+ if (!DataValidation.isGuid((this.jTextFieldGuid).getText())) {
+ Log.err("Incorrect data type for Guid");
+ return false;
+ }
+ if (!DataValidation.isCopyright(this.jTextAreaCopyright.getText())) {
+ Log.err("Incorrect data type for Copyright");
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ Save all components of Mbd Header
+ if exists mbdHeader, set the value directly
+ if not exists mbdHeader, new an instance first
+
+ **/
+ public void save() {
+ try {
+ if (this.mbdHeader == null) {
+ mbdHeader = MbdHeaderDocument.MbdHeader.Factory.newInstance();
+ }
+ if (this.mbdHeader.getBaseName() != null) {
+ this.mbdHeader.getBaseName().setStringValue(this.jTextFieldBaseName.getText());
+ } else {
+ BaseNameDocument.BaseName mBaseName = BaseNameDocument.BaseName.Factory.newInstance();
+ mBaseName.setStringValue(this.jTextFieldBaseName.getText());
+ this.mbdHeader.setBaseName(mBaseName);
+ }
+
+ if (this.mbdHeader.getGuid() != null) {
+ this.mbdHeader.getGuid().setStringValue(this.jTextFieldGuid.getText());
+ } else {
+ GuidDocument.Guid mGuid = GuidDocument.Guid.Factory.newInstance();
+ mGuid.setStringValue(this.jTextFieldGuid.getText());
+ this.mbdHeader.setGuid(mGuid);
+ }
+
+ this.mbdHeader.setVersion(this.jTextFieldVersion.getText());
+
+ if (this.mbdHeader.getLicense() != null) {
+ this.mbdHeader.getLicense().setStringValue(this.jTextAreaLicense.getText());
+ } else {
+ LicenseDocument.License mLicense = LicenseDocument.License.Factory.newInstance();
+ mLicense.setStringValue(this.jTextAreaLicense.getText());
+ this.mbdHeader.setLicense(mLicense);
+ }
+
+ this.mbdHeader.setCopyright(this.jTextAreaCopyright.getText());
+ this.mbdHeader.setDescription(this.jTextAreaDescription.getText());
+
+ if (this.mbdHeader.getCreated() == null) {
+ this.mbdHeader.setCreated(Tools.getCurrentDateTime());
+ } else {
+ this.mbdHeader.setModified(Tools.getCurrentDateTime());
+ }
+
+ } catch (Exception e) {
+ Log.err("Save Module Buid Description", e.getMessage());
+ }
+ }
+
+ /**
+ This method initializes module type and compontent type
+
+ **/
+ private void initFrame() {
+
+ }
+
+ /**
+ Get MbdHeaderDocument.MbdHeader
+
+ @return MbdHeaderDocument.MbdHeader mbdHeader
+
+ **/
+ public MbdHeaderDocument.MbdHeader getMbdHeader() {
+ return mbdHeader;
+ }
+
+ /**
+ Set MbdHeaderDocument.MbdHeader
+
+ @param mbdHeader The input MbdHeaderDocument.MbdHeader
+
+ **/
+ public void setMbdHeader(MbdHeaderDocument.MbdHeader mbdHeader) {
+ this.mbdHeader = mbdHeader;
+ }
+}
diff --git a/Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/MbdLibHeader.java b/Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/MbdLibHeader.java
new file mode 100644
index 0000000000..7f355c1e4d
--- /dev/null
+++ b/Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/MbdLibHeader.java
@@ -0,0 +1,599 @@
+/** @file
+
+ The file is used to create, update MbdLibHeader of a MBD file
+
+ Copyright (c) 2006, Intel Corporation
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+ **/
+package org.tianocore.packaging.module.ui;
+
+import java.awt.event.ActionEvent;
+
+import javax.swing.JButton;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTextArea;
+import javax.swing.JTextField;
+
+import org.tianocore.BaseNameDocument;
+import org.tianocore.GuidDocument;
+import org.tianocore.LicenseDocument;
+import org.tianocore.MbdLibHeaderDocument;
+import org.tianocore.common.DataValidation;
+import org.tianocore.common.Log;
+import org.tianocore.common.Tools;
+import org.tianocore.packaging.common.ui.IInternalFrame;
+import org.tianocore.packaging.common.ui.StarLabel;
+
+/**
+ The class is used to create, update MbdLibHeader of a MBD file
+ It extends IInternalFrame
+
+ @since ModuleEditor 1.0
+
+ **/
+public class MbdLibHeader extends IInternalFrame {
+
+ ///
+ /// Define class Serial Version UID
+ ///
+ private static final long serialVersionUID = -4881447351274201866L;
+
+ //
+ //Define class members
+ //
+ private JPanel jContentPane = null;
+
+ private JLabel jLabelBaseName = null;
+
+ private JTextField jTextFieldBaseName = null;
+
+ private JLabel jLabelGuid = null;
+
+ private JTextField jTextFieldGuid = null;
+
+ private JLabel jLabelVersion = null;
+
+ private JTextField jTextFieldVersion = null;
+
+ private JButton jButtonGenerateGuid = null;
+
+ private JLabel jLabelLicense = null;
+
+ private JTextArea jTextAreaLicense = null;
+
+ private JLabel jLabelCopyright = null;
+
+ private JTextArea jTextAreaCopyright = null;
+
+ private JLabel jLabelDescription = null;
+
+ private JTextArea jTextAreaDescription = null;
+
+ private JButton jButtonOk = null;
+
+ private JButton jButtonCancel = null;
+
+ private JScrollPane jScrollPaneLicense = null;
+
+ private JScrollPane jScrollPaneCopyright = null;
+
+ private JScrollPane jScrollPaneDescription = null;
+
+ private StarLabel jStarLabel1 = null;
+
+ private StarLabel jStarLabel2 = null;
+
+ private StarLabel jStarLabel3 = null;
+
+ private StarLabel jStarLabel4 = null;
+
+ private StarLabel jStarLabel5 = null;
+
+ private StarLabel jStarLabel6 = null;
+
+ private MbdLibHeaderDocument.MbdLibHeader mbdLibHeader = null;
+
+ /**
+ This method initializes jTextFieldBaseName
+
+ @return javax.swing.JTextField jTextFieldBaseName
+
+ **/
+ private JTextField getJTextFieldBaseName() {
+ if (jTextFieldBaseName == null) {
+ jTextFieldBaseName = new JTextField();
+ jTextFieldBaseName.setBounds(new java.awt.Rectangle(160, 10, 320, 20));
+ }
+ return jTextFieldBaseName;
+ }
+
+ /**
+ This method initializes jTextFieldGuid
+
+ @return javax.swing.JTextField jTextFieldGuid
+
+ **/
+ private JTextField getJTextFieldGuid() {
+ if (jTextFieldGuid == null) {
+ jTextFieldGuid = new JTextField();
+ jTextFieldGuid.setBounds(new java.awt.Rectangle(160, 35, 240, 20));
+ }
+ return jTextFieldGuid;
+ }
+
+ /**
+ This method initializes jTextFieldVersion
+
+ @return javax.swing.JTextField jTextFieldVersion
+
+ **/
+ private JTextField getJTextFieldVersion() {
+ if (jTextFieldVersion == null) {
+ jTextFieldVersion = new JTextField();
+ jTextFieldVersion.setBounds(new java.awt.Rectangle(160, 60, 320, 20));
+ }
+ return jTextFieldVersion;
+ }
+
+ /**
+ This method initializes jButtonGenerateGuid
+
+ @return javax.swing.JButton jButtonGenerateGuid
+
+ **/
+ private JButton getJButtonGenerateGuid() {
+ if (jButtonGenerateGuid == null) {
+ jButtonGenerateGuid = new JButton();
+ jButtonGenerateGuid.setBounds(new java.awt.Rectangle(405, 35, 75, 20));
+ jButtonGenerateGuid.setText("GEN");
+ jButtonGenerateGuid.addActionListener(this);
+ }
+ return jButtonGenerateGuid;
+ }
+
+ /**
+ This method initializes jTextAreaLicense
+
+ @return javax.swing.JTextArea jTextAreaLicense
+
+ **/
+ private JTextArea getJTextAreaLicense() {
+ if (jTextAreaLicense == null) {
+ jTextAreaLicense = new JTextArea();
+ jTextAreaLicense.setText("");
+ jTextAreaLicense.setLineWrap(true);
+ }
+ return jTextAreaLicense;
+ }
+
+ /**
+ This method initializes jTextAreaCopyright
+
+ @return javax.swing.JTextArea jTextAreaCopyright
+
+ **/
+ private JTextArea getJTextAreaCopyright() {
+ if (jTextAreaCopyright == null) {
+ jTextAreaCopyright = new JTextArea();
+ jTextAreaCopyright.setLineWrap(true);
+ }
+ return jTextAreaCopyright;
+ }
+
+ /**
+ This method initializes jTextAreaDescription
+
+ @return javax.swing.JTextArea jTextAreaDescription
+
+ **/
+ private JTextArea getJTextAreaDescription() {
+ if (jTextAreaDescription == null) {
+ jTextAreaDescription = new JTextArea();
+ jTextAreaDescription.setLineWrap(true);
+ }
+ return jTextAreaDescription;
+ }
+
+ /**
+ This method initializes jButtonOk
+
+ @return javax.swing.JButton jButtonOk
+
+ **/
+ private JButton getJButtonOk() {
+ if (jButtonOk == null) {
+ jButtonOk = new JButton();
+ jButtonOk.setText("OK");
+ jButtonOk.setBounds(new java.awt.Rectangle(290, 345, 90, 20));
+ jButtonOk.addActionListener(this);
+ }
+ return jButtonOk;
+ }
+
+ /**
+ This method initializes jButtonCancel
+
+ @return javax.swing.JButton jButtonCancel
+
+ **/
+ private JButton getJButtonCancel() {
+ if (jButtonCancel == null) {
+ jButtonCancel = new JButton();
+ jButtonCancel.setText("Cancel");
+ jButtonCancel.setBounds(new java.awt.Rectangle(390, 345, 90, 20));
+ jButtonCancel.addActionListener(this);
+ }
+ return jButtonCancel;
+ }
+
+ /**
+ This method initializes jScrollPaneLicense
+
+ @return javax.swing.JScrollPane jScrollPaneLicense
+
+ **/
+ private JScrollPane getJScrollPaneLicense() {
+ if (jScrollPaneLicense == null) {
+ jScrollPaneLicense = new JScrollPane();
+ jScrollPaneLicense.setBounds(new java.awt.Rectangle(160, 85, 320, 80));
+ jScrollPaneLicense.setHorizontalScrollBarPolicy(javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
+ jScrollPaneLicense.setViewportView(getJTextAreaLicense());
+ }
+ return jScrollPaneLicense;
+ }
+
+ /**
+ This method initializes jScrollPaneCopyright
+
+ @return javax.swing.JScrollPane jScrollPaneCopyright
+
+ **/
+ private JScrollPane getJScrollPaneCopyright() {
+ if (jScrollPaneCopyright == null) {
+ jScrollPaneCopyright = new JScrollPane();
+ jScrollPaneCopyright.setBounds(new java.awt.Rectangle(160, 170, 320, 80));
+ jScrollPaneCopyright.setHorizontalScrollBarPolicy(javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
+ jScrollPaneCopyright.setViewportView(getJTextAreaCopyright());
+ }
+ return jScrollPaneCopyright;
+ }
+
+ /**
+ This method initializes jScrollPaneDescription
+
+ @return javax.swing.JScrollPane jScrollPaneDescription
+
+ **/
+ private JScrollPane getJScrollPaneDescription() {
+ if (jScrollPaneDescription == null) {
+ jScrollPaneDescription = new JScrollPane();
+ jScrollPaneDescription.setBounds(new java.awt.Rectangle(160, 255, 320, 80));
+ jScrollPaneDescription.setHorizontalScrollBarPolicy(javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
+ jScrollPaneDescription.setViewportView(getJTextAreaDescription());
+ }
+ return jScrollPaneDescription;
+ }
+
+ public static void main(String[] args) {
+
+ }
+
+ /**
+ This is the default constructor
+
+ **/
+ public MbdLibHeader() {
+ super();
+ init();
+ this.setVisible(true);
+ }
+
+ /**
+ This is the override edit constructor
+
+ @param inMbdLibHeader The input MbdLibHeaderDocument.MbdLibHeader
+
+ **/
+ public MbdLibHeader(MbdLibHeaderDocument.MbdLibHeader inMbdLibHeader) {
+ super();
+ init(inMbdLibHeader);
+ this.setVisible(true);
+ this.setViewMode(false);
+ }
+
+ /**
+ This method initializes this
+
+ **/
+ private void init() {
+ this.setSize(500, 515);
+ this.setContentPane(getJContentPane());
+ this.setTitle("Library Module Build Description Header");
+ initFrame();
+ }
+
+ /**
+ This method initializes this
+ Fill values to all fields if these values are not empty
+
+ @param inMbdLibHeader The input MbdLibHeaderDocument.MbdLibHeader
+
+ **/
+ private void init(MbdLibHeaderDocument.MbdLibHeader inMbdLibHeader) {
+ init();
+ setMbdLibHeader(inMbdLibHeader);
+ if (inMbdLibHeader != null) {
+ if (this.mbdLibHeader.getBaseName() != null) {
+ this.jTextFieldBaseName.setText(this.mbdLibHeader.getBaseName().getStringValue());
+ }
+ if (this.mbdLibHeader.getGuid() != null) {
+ this.jTextFieldGuid.setText(this.mbdLibHeader.getGuid().getStringValue());
+ }
+ if (this.mbdLibHeader.getVersion() != null) {
+ this.jTextFieldVersion.setText(this.mbdLibHeader.getVersion());
+ }
+ if (this.mbdLibHeader.getLicense() != null) {
+ this.jTextAreaLicense.setText(this.mbdLibHeader.getLicense().getStringValue());
+ }
+ if (this.mbdLibHeader.getCopyright() != null) {
+ this.jTextAreaCopyright.setText(this.mbdLibHeader.getCopyright());
+ }
+ if (this.mbdLibHeader.getDescription() != null) {
+ this.jTextAreaDescription.setText(this.mbdLibHeader.getDescription());
+ }
+ }
+ }
+
+ /**
+ Disable all components when the mode is view
+
+ @param isView true - The view mode; false - The non-view mode
+
+ **/
+ public void setViewMode(boolean isView) {
+ this.jButtonOk.setVisible(false);
+ this.jButtonCancel.setVisible(false);
+ if (isView) {
+ this.jTextFieldBaseName.setEnabled(!isView);
+ this.jTextFieldGuid.setEnabled(!isView);
+ this.jTextFieldVersion.setEnabled(!isView);
+ this.jTextAreaLicense.setEnabled(!isView);
+ this.jTextAreaCopyright.setEnabled(!isView);
+ this.jTextAreaDescription.setEnabled(!isView);
+ this.jButtonCancel.setEnabled(!isView);
+ this.jButtonGenerateGuid.setEnabled(!isView);
+ this.jButtonOk.setEnabled(!isView);
+ }
+ }
+
+ /**
+ This method initializes jContentPane
+
+ @return javax.swing.JPanel jContentPane
+
+ **/
+ private JPanel getJContentPane() {
+ if (jContentPane == null) {
+ jLabelDescription = new JLabel();
+ jLabelDescription.setText("Description");
+ jLabelDescription.setBounds(new java.awt.Rectangle(15, 255, 140, 20));
+ jLabelCopyright = new JLabel();
+ jLabelCopyright.setText("Copyright");
+ jLabelCopyright.setBounds(new java.awt.Rectangle(15, 170, 140, 20));
+ jLabelLicense = new JLabel();
+ jLabelLicense.setText("License");
+ jLabelLicense.setBounds(new java.awt.Rectangle(15, 85, 140, 20));
+ jLabelVersion = new JLabel();
+ jLabelVersion.setText("Version");
+ jLabelVersion.setBounds(new java.awt.Rectangle(15, 60, 140, 20));
+ jLabelGuid = new JLabel();
+ jLabelGuid.setPreferredSize(new java.awt.Dimension(25, 15));
+ jLabelGuid.setBounds(new java.awt.Rectangle(15, 35, 140, 20));
+ jLabelGuid.setText("Guid");
+ jLabelBaseName = new JLabel();
+ jLabelBaseName.setText("Base Name");
+ jLabelBaseName.setBounds(new java.awt.Rectangle(15, 10, 140, 20));
+ jContentPane = new JPanel();
+ jContentPane.setLayout(null);
+ jContentPane.setLocation(new java.awt.Point(0, 0));
+ jContentPane.setSize(new java.awt.Dimension(500, 524));
+ jContentPane.add(jLabelBaseName, null);
+ jContentPane.add(getJTextFieldBaseName(), null);
+ jContentPane.add(jLabelGuid, null);
+ jContentPane.add(getJTextFieldGuid(), null);
+ jContentPane.add(jLabelVersion, null);
+ jContentPane.add(getJTextFieldVersion(), null);
+ jContentPane.add(getJButtonGenerateGuid(), null);
+ jContentPane.add(jLabelLicense, null);
+ jContentPane.add(jLabelCopyright, null);
+ jContentPane.add(jLabelDescription, null);
+ jContentPane.add(getJButtonOk(), null);
+ jContentPane.add(getJButtonCancel(), null);
+ jContentPane.add(getJScrollPaneLicense(), null);
+ jContentPane.add(getJScrollPaneCopyright(), null);
+ jContentPane.add(getJScrollPaneDescription(), null);
+
+ jStarLabel1 = new StarLabel();
+ jStarLabel1.setLocation(new java.awt.Point(0, 10));
+ jStarLabel2 = new StarLabel();
+ jStarLabel2.setLocation(new java.awt.Point(0, 35));
+ jStarLabel3 = new StarLabel();
+ jStarLabel3.setLocation(new java.awt.Point(0, 60));
+ jStarLabel4 = new StarLabel();
+ jStarLabel4.setLocation(new java.awt.Point(0, 85));
+ jStarLabel5 = new StarLabel();
+ jStarLabel5.setLocation(new java.awt.Point(0, 170));
+ jStarLabel6 = new StarLabel();
+ jStarLabel6.setLocation(new java.awt.Point(0, 255));
+
+ jContentPane.add(jStarLabel1, null);
+ jContentPane.add(jStarLabel2, null);
+ jContentPane.add(jStarLabel3, null);
+ jContentPane.add(jStarLabel4, null);
+ jContentPane.add(jStarLabel5, null);
+ jContentPane.add(jStarLabel6, null);
+ }
+ return jContentPane;
+ }
+
+ /* (non-Javadoc)
+ * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
+ *
+ * Override actionPerformed to listen all actions
+ *
+ */
+ public void actionPerformed(ActionEvent arg0) {
+ if (arg0.getSource() == jButtonOk) {
+ this.dispose();
+ this.save();
+ this.setEdited(true);
+ }
+ if (arg0.getSource() == jButtonCancel) {
+ this.dispose();
+ this.setEdited(false);
+ }
+ if (arg0.getSource() == jButtonGenerateGuid) {
+ jTextFieldGuid.setText(Tools.generateUuidString());
+ }
+ }
+
+ /**
+ Data validation for all fields
+
+ @retval true - All datas are valid
+ @retval false - At least one data is invalid
+
+ **/
+ public boolean check() {
+ //
+ // Check if all required fields are not empty
+ //
+ if (isEmpty(this.jTextFieldBaseName.getText())) {
+ Log.err("Base Name couldn't be empty");
+ return false;
+ }
+ if (isEmpty(this.jTextFieldGuid.getText())) {
+ Log.err("Guid couldn't be empty");
+ return false;
+ }
+ if (isEmpty(this.jTextFieldVersion.getText())) {
+ Log.err("Version couldn't be empty");
+ return false;
+ }
+ if (isEmpty(this.jTextAreaLicense.getText())) {
+ Log.err("License couldn't be empty");
+ return false;
+ }
+ if (isEmpty(this.jTextAreaCopyright.getText())) {
+ Log.err("Copyright couldn't be empty");
+ return false;
+ }
+ if (isEmpty(this.jTextAreaDescription.getText())) {
+ Log.err("Description couldn't be empty");
+ return false;
+ }
+
+ //
+ // Check if all fields have correct data types
+ //
+ if (!DataValidation.isBaseName(this.jTextFieldBaseName.getText())) {
+ Log.err("Incorrect data type for Base Name");
+ return false;
+ }
+ if (!DataValidation.isGuid((this.jTextFieldGuid).getText())) {
+ Log.err("Incorrect data type for Guid");
+ return false;
+ }
+ if (!DataValidation.isCopyright(this.jTextAreaCopyright.getText())) {
+ Log.err("Incorrect data type for Copyright");
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ Save all components of Mbd Lib Header
+ if exists mbdLibHeader, set the value directly
+ if not exists mbdLibHeader, new an instance first
+
+ **/
+ public void save() {
+ try {
+ if (this.mbdLibHeader == null) {
+ mbdLibHeader = MbdLibHeaderDocument.MbdLibHeader.Factory.newInstance();
+ }
+ if (this.mbdLibHeader.getBaseName() != null) {
+ this.mbdLibHeader.getBaseName().setStringValue(this.jTextFieldBaseName.getText());
+ } else {
+ BaseNameDocument.BaseName mBaseName = BaseNameDocument.BaseName.Factory.newInstance();
+ mBaseName.setStringValue(this.jTextFieldBaseName.getText());
+ this.mbdLibHeader.setBaseName(mBaseName);
+ }
+
+ if (this.mbdLibHeader.getGuid() != null) {
+ this.mbdLibHeader.getGuid().setStringValue(this.jTextFieldGuid.getText());
+ } else {
+ GuidDocument.Guid mGuid = GuidDocument.Guid.Factory.newInstance();
+ mGuid.setStringValue(this.jTextFieldGuid.getText());
+ this.mbdLibHeader.setGuid(mGuid);
+ }
+
+ this.mbdLibHeader.setVersion(this.jTextFieldVersion.getText());
+
+ if (this.mbdLibHeader.getLicense() != null) {
+ this.mbdLibHeader.getLicense().setStringValue(this.jTextAreaLicense.getText());
+ } else {
+ LicenseDocument.License mLicense = LicenseDocument.License.Factory.newInstance();
+ mLicense.setStringValue(this.jTextAreaLicense.getText());
+ this.mbdLibHeader.setLicense(mLicense);
+ }
+
+ this.mbdLibHeader.setCopyright(this.jTextAreaCopyright.getText());
+ this.mbdLibHeader.setDescription(this.jTextAreaDescription.getText());
+
+ if (this.mbdLibHeader.getCreated() == null) {
+ this.mbdLibHeader.setCreated(Tools.getCurrentDateTime());
+ } else {
+ this.mbdLibHeader.setModified(Tools.getCurrentDateTime());
+ }
+ } catch (Exception e) {
+ Log.err("Save Module Buid Description", e.getMessage());
+ }
+ }
+
+ /**
+ This method initializes module type and compontent type
+
+ **/
+ private void initFrame() {
+ }
+
+ /**
+ Get MbdLibHeaderDocument.MbdLibHeader
+
+ @return MbdLibHeaderDocument.MbdLibHeader
+
+ **/
+ public MbdLibHeaderDocument.MbdLibHeader getMbdLibHeader() {
+ return mbdLibHeader;
+ }
+
+ /**
+ Set MbdLibHeaderDocument.MbdLibHeader
+
+ @param mbdLibHeader The input MbdLibHeaderDocument.MbdLibHeader
+
+ **/
+ public void setMbdLibHeader(MbdLibHeaderDocument.MbdLibHeader mbdLibHeader) {
+ this.mbdLibHeader = mbdLibHeader;
+ }
+}
diff --git a/Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/MbdLibraries.java b/Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/MbdLibraries.java
new file mode 100644
index 0000000000..ffbb3eb4ab
--- /dev/null
+++ b/Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/MbdLibraries.java
@@ -0,0 +1,1048 @@
+/** @file
+
+ The file is used to create, update MbdLibraries of a MBD file
+
+ Copyright (c) 2006, Intel Corporation
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+ **/
+package org.tianocore.packaging.module.ui;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
+import java.util.Vector;
+
+import javax.swing.JButton;
+import javax.swing.JCheckBox;
+import javax.swing.JComboBox;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JTextField;
+
+import org.tianocore.LibrariesDocument;
+import org.tianocore.LibraryUsage;
+import org.tianocore.SupportedArchitectures;
+import org.tianocore.common.DataValidation;
+import org.tianocore.common.Log;
+import org.tianocore.common.Tools;
+import org.tianocore.packaging.common.ui.IDefaultMutableTreeNode;
+import org.tianocore.packaging.common.ui.IInternalFrame;
+import org.tianocore.packaging.common.ui.StarLabel;
+
+/**
+ The class is used to create, update MbdLibraries of a MBD file
+ It extends IInternalFrame
+
+ @since ModuleEditor 1.0
+
+ **/
+public class MbdLibraries extends IInternalFrame implements ItemListener {
+
+ ///
+ /// Define class Serial Version UID
+ ///
+ private static final long serialVersionUID = 8042998899875417568L;
+
+ //
+ //Define class members
+ //
+ private LibrariesDocument.Libraries libraries = null;
+
+ private int location = -1;
+
+ private int intSelectedItemId = 0;
+
+ //
+ //1 - Add; 2 - Update
+ //
+ private int operation = -1;
+
+ private Vector vName = new Vector();
+
+ private Vector vGuid = new Vector();
+
+ private Vector vLibraryClass = new Vector();
+
+ private Vector vClassGuid = new Vector();
+
+ private Vector vVersion = new Vector();
+
+ private Vector vUsage = new Vector();
+
+ private Vector vOverrideID = new Vector();
+
+ private JPanel jContentPane = null;
+
+ private JButton jButtonOk = null;
+
+ private JButton jButtonCancel = null;
+
+ private JLabel jLabelName = null;
+
+ private JTextField jTextFieldFileName = null;
+
+ private JLabel jLabelGuid = null;
+
+ private JTextField jTextFieldGuid = null;
+
+ private JButton jButtonGenerateGuid = null;
+
+ private JComboBox jComboBoxArch = null;
+
+ private JLabel jLabelLibraryClass = null;
+
+ private JTextField jTextFieldLibraryClass = null;
+
+ private JLabel jLabelUsage = null;
+
+ private JLabel jLabelClassGuid = null;
+
+ private JTextField jTextFieldClassGuid = null;
+
+ private JLabel jLabelOverrideID = null;
+
+ private JTextField jTextFieldOverrideID = null;
+
+ private JComboBox jComboBoxUsage = null;
+
+ private StarLabel jStarLabel1 = null;
+
+ private JComboBox jComboBoxFileList = null;
+
+ private JButton jButtonAdd = null;
+
+ private JButton jButtonRemove = null;
+
+ private JButton jButtonUpdate = null;
+
+ private JCheckBox jCheckBoxArch = null;
+
+ private JButton jButtonGenerateGuid2 = null;
+
+ private JLabel jLabelVersion = null;
+
+ private JTextField jTextFieldVersion = null;
+
+ /**
+ This method initializes jButtonOk
+
+ @return javax.swing.JButton jButtonOk
+
+ **/
+ private JButton getJButton() {
+ if (jButtonOk == null) {
+ jButtonOk = new JButton();
+ jButtonOk.setText("OK");
+ jButtonOk.setBounds(new java.awt.Rectangle(290, 240, 90, 20));
+ jButtonOk.addActionListener(this);
+ }
+ return jButtonOk;
+ }
+
+ /**
+ *This method initializes jButtonCancel
+
+ @return javax.swing.JButton jButtonCancel
+
+ **/
+ private JButton getJButtonCancel() {
+ if (jButtonCancel == null) {
+ jButtonCancel = new JButton();
+ jButtonCancel.setText("Cancel");
+ jButtonCancel.setBounds(new java.awt.Rectangle(390, 240, 90, 20));
+ jButtonCancel.setPreferredSize(new java.awt.Dimension(90, 20));
+ jButtonCancel.addActionListener(this);
+ }
+ return jButtonCancel;
+ }
+
+ /**
+ This method initializes jTextFieldFileName
+
+ @return javax.swing.JTextField jTextFieldFileName
+
+ **/
+ private JTextField getJTextFieldSourceFilesDirectory() {
+ if (jTextFieldFileName == null) {
+ jTextFieldFileName = new JTextField();
+ jTextFieldFileName.setBounds(new java.awt.Rectangle(160, 10, 320, 20));
+ }
+ return jTextFieldFileName;
+ }
+
+ /**
+ This method initializes jTextFieldGuid
+
+ @return javax.swing.JTextField jTextFieldGuid
+
+ **/
+ private JTextField getJTextFieldGuid() {
+ if (jTextFieldGuid == null) {
+ jTextFieldGuid = new JTextField();
+ jTextFieldGuid.setBounds(new java.awt.Rectangle(160, 35, 250, 20));
+ }
+ return jTextFieldGuid;
+ }
+
+ /**
+ This method initializes jButtonGenerateGuid
+
+ @return javax.swing.JButton jButtonGenerateGuid
+
+ **/
+ private JButton getJButtonGenerateGuid() {
+ if (jButtonGenerateGuid == null) {
+ jButtonGenerateGuid = new JButton();
+ jButtonGenerateGuid.setBounds(new java.awt.Rectangle(415, 35, 65, 20));
+ jButtonGenerateGuid.setText("GEN");
+ jButtonGenerateGuid.addActionListener(this);
+ }
+ return jButtonGenerateGuid;
+ }
+
+ /**
+ This method initializes jComboBoxArch
+
+ @return javax.swing.JComboBox jComboBoxArch
+
+ **/
+ private JComboBox getJComboBoxArch() {
+ if (jComboBoxArch == null) {
+ jComboBoxArch = new JComboBox();
+ jComboBoxArch.setBounds(new java.awt.Rectangle(140, 210, 340, 20));
+ jComboBoxArch.setEnabled(false);
+ }
+ return jComboBoxArch;
+ }
+
+ /**
+ This method initializes jTextFieldLibraryClass
+
+ @return javax.swing.JTextField jTextFieldLibraryClass
+
+ **/
+ private JTextField getJTextFieldLibraryClass() {
+ if (jTextFieldLibraryClass == null) {
+ jTextFieldLibraryClass = new JTextField();
+ jTextFieldLibraryClass.setBounds(new java.awt.Rectangle(160, 60, 320, 20));
+ }
+ return jTextFieldLibraryClass;
+ }
+
+ /**
+ This method initializes jTextFieldClassGuid
+
+ @return javax.swing.JTextField jTextFieldClassGuid
+
+ **/
+ private JTextField getJTextFieldClassGuid() {
+ if (jTextFieldClassGuid == null) {
+ jTextFieldClassGuid = new JTextField();
+ jTextFieldClassGuid.setBounds(new java.awt.Rectangle(160, 85, 250, 20));
+ }
+ return jTextFieldClassGuid;
+ }
+
+ /**
+ This method initializes jTextFieldOverrideID
+
+ @return javax.swing.JTextField jTextFieldOverrideID
+
+ **/
+ private JTextField getJTextFieldOverrideID() {
+ if (jTextFieldOverrideID == null) {
+ jTextFieldOverrideID = new JTextField();
+ jTextFieldOverrideID.setBounds(new java.awt.Rectangle(160, 160, 50, 20));
+ }
+ return jTextFieldOverrideID;
+ }
+
+ /**
+ This method initializes jComboBoxUsage
+
+ @return javax.swing.JComboBox jComboBoxUsage
+
+ **/
+ private JComboBox getJComboBoxUsage() {
+ if (jComboBoxUsage == null) {
+ jComboBoxUsage = new JComboBox();
+ jComboBoxUsage.setBounds(new java.awt.Rectangle(160, 135, 320, 20));
+ }
+ return jComboBoxUsage;
+ }
+
+ /**
+ This method initializes jComboBoxFileList
+
+ @return javax.swing.JComboBox jComboBoxFileList
+
+ **/
+ private JComboBox getJComboBoxFileList() {
+ if (jComboBoxFileList == null) {
+ jComboBoxFileList = new JComboBox();
+ jComboBoxFileList.setBounds(new java.awt.Rectangle(15, 185, 210, 20));
+ jComboBoxFileList.addItemListener(this);
+ jComboBoxFileList.addActionListener(this);
+ }
+ return jComboBoxFileList;
+ }
+
+ /**
+ This method initializes jButtonAdd
+
+ @return javax.swing.JButton jButtonAdd
+
+ **/
+ private JButton getJButtonAdd() {
+ if (jButtonAdd == null) {
+ jButtonAdd = new JButton();
+ jButtonAdd.setBounds(new java.awt.Rectangle(230, 185, 80, 20));
+ jButtonAdd.setText("Add");
+ jButtonAdd.addActionListener(this);
+ }
+ return jButtonAdd;
+ }
+
+ /**
+ This method initializes jButtonRemove
+
+ @return javax.swing.JButton jButtonRemove
+
+ **/
+ private JButton getJButtonRemove() {
+ if (jButtonRemove == null) {
+ jButtonRemove = new JButton();
+ jButtonRemove.setBounds(new java.awt.Rectangle(400, 185, 80, 20));
+ jButtonRemove.setText("Remove");
+ jButtonRemove.addActionListener(this);
+ }
+ return jButtonRemove;
+ }
+
+ /**
+ This method initializes jButtonUpdate
+
+ @return javax.swing.JButton jButtonUpdate
+
+ **/
+ private JButton getJButtonUpdate() {
+ if (jButtonUpdate == null) {
+ jButtonUpdate = new JButton();
+ jButtonUpdate.setBounds(new java.awt.Rectangle(315, 185, 80, 20));
+ jButtonUpdate.setText("Update");
+ jButtonUpdate.addActionListener(this);
+ }
+ return jButtonUpdate;
+ }
+
+ /**
+ This method initializes jCheckBoxArch
+
+ @return javax.swing.JCheckBox jCheckBoxArch
+
+ **/
+ private JCheckBox getJCheckBoxArch() {
+ if (jCheckBoxArch == null) {
+ jCheckBoxArch = new JCheckBox();
+ jCheckBoxArch.setBounds(new java.awt.Rectangle(10, 210, 119, 20));
+ jCheckBoxArch.setText("Specific Arch");
+ jCheckBoxArch.addActionListener(this);
+ }
+ return jCheckBoxArch;
+ }
+
+ /**
+ This method initializes jButtonGenerateGuid2
+
+ @return javax.swing.JButton jButtonGenerateGuid2
+
+ **/
+ private JButton getJButtonGenerateGuid2() {
+ if (jButtonGenerateGuid2 == null) {
+ jButtonGenerateGuid2 = new JButton();
+ jButtonGenerateGuid2.setBounds(new java.awt.Rectangle(415, 85, 65, 20));
+ jButtonGenerateGuid2.setText("GEN");
+ jButtonGenerateGuid2.addActionListener(this);
+ }
+ return jButtonGenerateGuid2;
+ }
+
+ /**
+ This method initializes jTextFieldVersion
+
+ @return javax.swing.JTextField jTextFieldVersion
+
+ **/
+ private JTextField getJTextFieldVersion() {
+ if (jTextFieldVersion == null) {
+ jTextFieldVersion = new JTextField();
+ jTextFieldVersion.setBounds(new java.awt.Rectangle(160, 110, 320, 20));
+ }
+ return jTextFieldVersion;
+ }
+
+ public static void main(String[] args) {
+
+ }
+
+ /**
+ This is the default constructor
+
+ **/
+ public MbdLibraries() {
+ super();
+ init();
+ this.setVisible(true);
+ }
+
+ /**
+ This is the override edit constructor
+
+ @param inLibraries The input LibrariesDocument.Libraries
+
+ **/
+ public MbdLibraries(LibrariesDocument.Libraries inLibraries) {
+ super();
+ init(inLibraries);
+ this.setVisible(true);
+ }
+
+ /**
+ This is the override edit constructor
+
+ @param inLibraries The input LibrariesDocument.Libraries
+ @param type The input data of node type
+ @param index The input data of node index
+
+ **/
+ public MbdLibraries(LibrariesDocument.Libraries inLibraries, int type, int index) {
+ super();
+ init(inLibraries);
+ this.setVisible(true);
+ }
+
+ /**
+ This is the override edit constructor
+
+ @param inLibraries The input LibrariesDocument.Libraries
+ @param type The input data of node type
+ @param index The input data of node index
+ @param inOperation The input data of operation type
+
+ **/
+ public MbdLibraries(LibrariesDocument.Libraries inLibraries, int type, int index, int inOperation) {
+ super();
+ init(inLibraries, type, index, inOperation);
+ this.operation = inOperation;
+ this.setVisible(true);
+ }
+
+ /**
+ This method initializes this
+
+ @param inLibraries LibrariesDocument.Libraries
+
+ **/
+ private void init(LibrariesDocument.Libraries inLibraries) {
+ init();
+ this.setLibraries(inLibraries);
+ }
+
+ /**
+ This method initializes this
+ Fill values to all fields if these values are not empty
+
+ @param inLibraries LibrariesDocument.Libraries
+ @param type The input data of node type
+ @param index The input data of node index
+ @param inOperation The input data of operation type
+
+ **/
+ private void init(LibrariesDocument.Libraries inLibraries, int type, int index, int inOperation) {
+ init(inLibraries);
+ this.location = index;
+ this.operation = inOperation;
+
+ if (operation == 2) {
+ this.jCheckBoxArch.setEnabled(false);
+ this.jComboBoxArch.setEnabled(false);
+
+ if (type == IDefaultMutableTreeNode.LIBRARIES_LIBRARY) {
+ if (this.libraries.getLibraryList().size() > 0) {
+ for (int indexI = 0; indexI < this.libraries.getLibraryList().size(); indexI++) {
+ if (this.libraries.getLibraryArray(indexI).getStringValue() != null) {
+ vName.addElement(this.libraries.getLibraryArray(indexI).getStringValue());
+ } else {
+ vName.addElement("");
+ }
+ if (this.libraries.getLibraryArray(indexI).getGuid() != null) {
+ vGuid.addElement(this.libraries.getLibraryArray(indexI).getGuid());
+ } else {
+ vGuid.addElement("");
+ }
+ if (this.libraries.getLibraryArray(indexI).getLibraryClass() != null) {
+ vLibraryClass.addElement(this.libraries.getLibraryArray(indexI).getLibraryClass());
+ } else {
+ vLibraryClass.addElement("");
+ }
+ if (this.libraries.getLibraryArray(indexI).getClassGuid() != null) {
+ vClassGuid.addElement(this.libraries.getLibraryArray(indexI).getClassGuid());
+ } else {
+ vClassGuid.addElement("");
+ }
+ if (this.libraries.getLibraryArray(indexI).getVersion() != null) {
+ vVersion.addElement(this.libraries.getLibraryArray(indexI).getVersion());
+ } else {
+ vVersion.addElement("");
+ }
+ if (this.libraries.getLibraryArray(indexI).getUsage() != null) {
+ vUsage.addElement(this.libraries.getLibraryArray(indexI).getUsage().toString());
+ } else {
+ vUsage.addElement("ALWAYS_CONSUMED");
+ }
+ vOverrideID.addElement(String.valueOf(this.libraries.getLibraryArray(indexI).getOverrideID()));
+ jComboBoxFileList.addItem(this.libraries.getLibraryArray(indexI).getStringValue());
+ }
+ }
+ }
+ if (type == IDefaultMutableTreeNode.LIBRARIES_ARCH_ITEM) {
+ this.jCheckBoxArch.setSelected(true);
+ this.jComboBoxArch.setSelectedItem(this.libraries.getArchArray(index).getArchType().toString());
+ for (int indexI = 0; indexI < this.libraries.getArchArray(index).getLibraryList().size(); indexI++) {
+ if (this.libraries.getArchArray(index).getLibraryArray(indexI).getStringValue() != null) {
+ vName.addElement(this.libraries.getArchArray(index).getLibraryArray(indexI).getStringValue());
+ } else {
+ vName.addElement("");
+ }
+ if (this.libraries.getArchArray(index).getLibraryArray(indexI).getGuid() != null) {
+ vGuid.addElement(this.libraries.getArchArray(index).getLibraryArray(indexI).getGuid());
+ } else {
+ vGuid.addElement("");
+ }
+ if (this.libraries.getArchArray(index).getLibraryArray(indexI).getLibraryClass() != null) {
+ vLibraryClass.addElement(this.libraries.getArchArray(index).getLibraryArray(indexI)
+ .getLibraryClass());
+ } else {
+ vLibraryClass.addElement("");
+ }
+ if (this.libraries.getArchArray(index).getLibraryArray(indexI).getClassGuid() != null) {
+ vClassGuid
+ .addElement(this.libraries.getArchArray(index).getLibraryArray(indexI).getClassGuid());
+ } else {
+ vClassGuid.addElement("");
+ }
+ if (this.libraries.getArchArray(index).getLibraryArray(indexI).getVersion() != null) {
+ vVersion.addElement(this.libraries.getArchArray(index).getLibraryArray(indexI).getVersion());
+ } else {
+ vVersion.addElement("");
+ }
+ if (this.libraries.getArchArray(index).getLibraryArray(indexI).getUsage() != null) {
+ vUsage.addElement(this.libraries.getArchArray(index).getLibraryArray(indexI).getUsage()
+ .toString());
+ } else {
+ vUsage.addElement("");
+ }
+ vOverrideID.addElement(String.valueOf(this.libraries.getArchArray(index).getLibraryArray(indexI).getOverrideID()));
+ jComboBoxFileList.addItem(this.libraries.getArchArray(index).getLibraryArray(indexI)
+ .getStringValue());
+ }
+ }
+ }
+ }
+
+ /**
+ This method initializes this
+
+ **/
+ private void init() {
+ this.setSize(500, 515);
+ this.setName("JFrame");
+ this.setContentPane(getJContentPane());
+ this.setTitle("Source Files");
+ initFrame();
+ this.setViewMode(false);
+ }
+
+ /**
+ Disable all components when the mode is view
+
+ @param isView true - The view mode; false - The non-view mode
+
+ **/
+ public void setViewMode(boolean isView) {
+ this.jButtonOk.setVisible(false);
+ this.jButtonCancel.setVisible(false);
+ if (isView) {
+ this.jTextFieldFileName.setEnabled(!isView);
+ this.jTextFieldGuid.setEnabled(!isView);
+ this.jButtonGenerateGuid.setEnabled(!isView);
+ this.jComboBoxArch.setEnabled(!isView);
+ this.jTextFieldLibraryClass.setEnabled(!isView);
+ this.jTextFieldClassGuid.setEnabled(!isView);
+ this.jTextFieldOverrideID.setEnabled(!isView);
+ this.jComboBoxUsage.setEnabled(!isView);
+ this.jButtonAdd.setEnabled(!isView);
+ this.jButtonRemove.setEnabled(!isView);
+ this.jButtonUpdate.setEnabled(!isView);
+ this.jCheckBoxArch.setEnabled(!isView);
+ this.jTextFieldVersion.setEnabled(!isView);
+
+ this.jButtonOk.setEnabled(!isView);
+ this.jButtonCancel.setEnabled(!isView);
+ this.jButtonGenerateGuid.setEnabled(!isView);
+ this.jButtonGenerateGuid2.setEnabled(!isView);
+ }
+ }
+
+ /**
+ This method initializes jContentPane
+
+ @return javax.swing.JPanel jContentPane
+
+ **/
+ private JPanel getJContentPane() {
+ if (jContentPane == null) {
+ jLabelVersion = new JLabel();
+ jLabelVersion.setBounds(new java.awt.Rectangle(15, 110, 140, 20));
+ jLabelVersion.setText("Version");
+ jLabelOverrideID = new JLabel();
+ jLabelOverrideID.setBounds(new java.awt.Rectangle(15, 160, 140, 20));
+ jLabelOverrideID.setText("Override ID");
+ jLabelClassGuid = new JLabel();
+ jLabelClassGuid.setBounds(new java.awt.Rectangle(15, 85, 140, 20));
+ jLabelClassGuid.setText("Class Guid");
+ jLabelUsage = new JLabel();
+ jLabelUsage.setBounds(new java.awt.Rectangle(15, 135, 140, 20));
+ jLabelUsage.setText("Usage");
+ jLabelLibraryClass = new JLabel();
+ jLabelLibraryClass.setBounds(new java.awt.Rectangle(15, 60, 140, 20));
+ jLabelLibraryClass.setText("Library Class");
+ jLabelGuid = new JLabel();
+ jLabelGuid.setBounds(new java.awt.Rectangle(15, 35, 140, 20));
+ jLabelGuid.setText("Guid");
+ jLabelName = new JLabel();
+ jLabelName.setText("Name");
+ jLabelName.setBounds(new java.awt.Rectangle(15, 10, 140, 20));
+ jContentPane = new JPanel();
+ jContentPane.setLayout(null);
+ jContentPane.add(getJButton(), null);
+ jContentPane.add(getJButtonCancel(), null);
+ jContentPane.add(jLabelName, null);
+ jContentPane.add(getJTextFieldSourceFilesDirectory(), null);
+ jContentPane.add(jLabelGuid, null);
+ jContentPane.add(getJTextFieldGuid(), null);
+ jContentPane.add(getJButtonGenerateGuid(), null);
+ jContentPane.add(getJComboBoxArch(), null);
+ jContentPane.add(jLabelLibraryClass, null);
+ jContentPane.add(getJTextFieldLibraryClass(), null);
+ jContentPane.add(jLabelUsage, null);
+ jContentPane.add(jLabelClassGuid, null);
+ jContentPane.add(getJTextFieldClassGuid(), null);
+ jContentPane.add(getJButtonGenerateGuid2(), null);
+ jContentPane.add(jLabelVersion, null);
+ jContentPane.add(getJTextFieldVersion(), null);
+ jContentPane.add(jLabelOverrideID, null);
+ jContentPane.add(getJTextFieldOverrideID(), null);
+ jContentPane.add(getJComboBoxUsage(), null);
+
+ jStarLabel1 = new StarLabel();
+ jStarLabel1.setLocation(new java.awt.Point(0, 10));
+
+ jContentPane.add(jStarLabel1, null);
+ jContentPane.add(getJComboBoxFileList(), null);
+ jContentPane.add(getJButtonAdd(), null);
+ jContentPane.add(getJButtonRemove(), null);
+ jContentPane.add(getJButtonUpdate(), null);
+ jContentPane.add(getJCheckBoxArch(), null);
+
+ }
+ return jContentPane;
+ }
+
+ /* (non-Javadoc)
+ * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
+ *
+ * Override actionPerformed to listen all actions
+ *
+ */
+ public void actionPerformed(ActionEvent arg0) {
+ if (arg0.getSource() == jButtonOk) {
+ this.setEdited(true);
+ this.save();
+ this.dispose();
+ }
+ if (arg0.getSource() == jButtonCancel) {
+ this.dispose();
+ }
+ if (arg0.getSource() == jButtonGenerateGuid) {
+ jTextFieldGuid.setText(Tools.generateUuidString());
+ }
+ if (arg0.getSource() == jButtonGenerateGuid2) {
+ jTextFieldClassGuid.setText(Tools.generateUuidString());
+ }
+ if (arg0.getSource() == jButtonAdd) {
+ if (!checkAdd()) {
+ return;
+ }
+ addToList();
+ }
+ if (arg0.getSource() == jButtonRemove) {
+ removeFromList();
+ }
+ if (arg0.getSource() == jButtonUpdate) {
+ if (!checkAdd()) {
+ return;
+ }
+ updateForList();
+ }
+ if (arg0.getSource() == jCheckBoxArch) {
+ if (this.jCheckBoxArch.isSelected()) {
+ this.jComboBoxArch.setEnabled(true);
+ } else {
+ this.jComboBoxArch.setEnabled(false);
+ }
+ }
+ }
+
+ /**
+ Init the items of Usage and Arch
+
+ **/
+ private void initFrame() {
+ jComboBoxUsage.addItem("ALWAYS_CONSUMED");
+ jComboBoxUsage.addItem("SOMETIMES_CONSUMED");
+ jComboBoxUsage.addItem("ALWAYS_PRODUCED");
+ jComboBoxUsage.addItem("SOMETIMES_PRODUCED");
+ jComboBoxUsage.addItem("DEFAULT");
+ jComboBoxUsage.addItem("PRIVATE");
+
+ jComboBoxArch.addItem("ALL");
+ jComboBoxArch.addItem("EBC");
+ jComboBoxArch.addItem("ARM");
+ jComboBoxArch.addItem("IA32");
+ jComboBoxArch.addItem("X64");
+ jComboBoxArch.addItem("IPF");
+ jComboBoxArch.addItem("PPC");
+ }
+
+ /**
+ Add current item to Vector
+
+ **/
+ private void addToList() {
+ intSelectedItemId = vName.size();
+ vName.addElement(this.jTextFieldFileName.getText());
+ vGuid.addElement(this.jTextFieldGuid.getText());
+ vLibraryClass.addElement(this.jTextFieldLibraryClass.getText());
+ vClassGuid.addElement(this.jTextFieldClassGuid.getText());
+ vVersion.addElement(this.jTextFieldVersion.getText());
+ vUsage.addElement(this.jComboBoxUsage.getSelectedItem().toString());
+ vOverrideID.addElement(this.jTextFieldOverrideID.getText());
+ jComboBoxFileList.addItem(this.jTextFieldFileName.getText());
+ jComboBoxFileList.setSelectedItem(this.jTextFieldFileName.getText());
+
+ //
+ // Reset select item index
+ //
+ intSelectedItemId = vName.size();
+
+ //
+ // Reload all fields of selected item
+ //
+ reloadFromList();
+ }
+
+ /**
+ Remove current item from Vector
+
+ **/
+ private void removeFromList() {
+ int intTempIndex = intSelectedItemId;
+ if (vName.size() < 1) {
+ return;
+ }
+
+ jComboBoxFileList.removeItemAt(intSelectedItemId);
+
+ vName.removeElementAt(intTempIndex);
+ vGuid.removeElementAt(intTempIndex);
+ vLibraryClass.removeElementAt(intTempIndex);
+ vClassGuid.removeElementAt(intTempIndex);
+ vVersion.removeElementAt(intTempIndex);
+ vUsage.removeElementAt(intTempIndex);
+ vOverrideID.removeElementAt(intTempIndex);
+
+ //
+ // Reload all fields of selected item
+ //
+ reloadFromList();
+ }
+
+ /**
+ Update current item of Vector
+
+ **/
+ private void updateForList() {
+ //
+ // Backup selected item index
+ //
+ int intTempIndex = intSelectedItemId;
+ vName.setElementAt(this.jTextFieldFileName.getText(), intSelectedItemId);
+ vGuid.setElementAt(this.jTextFieldGuid.getText(), intSelectedItemId);
+ vLibraryClass.setElementAt(this.jTextFieldLibraryClass.getText(), intSelectedItemId);
+ vClassGuid.setElementAt(this.jTextFieldClassGuid.getText(), intSelectedItemId);
+ vVersion.setElementAt(this.jTextFieldVersion.getText(), intSelectedItemId);
+ vUsage.setElementAt(this.jComboBoxUsage.getSelectedItem().toString(), intSelectedItemId);
+ vOverrideID.setElementAt(this.jTextFieldOverrideID.getText(), intSelectedItemId);
+
+ jComboBoxFileList.removeAllItems();
+ for (int index = 0; index < vName.size(); index++) {
+ jComboBoxFileList.addItem(vName.elementAt(index));
+ }
+
+ //
+ // Restore selected item index
+ //
+ intSelectedItemId = intTempIndex;
+
+ //
+ // Reset select item index
+ //
+ jComboBoxFileList.setSelectedIndex(intSelectedItemId);
+
+ //
+ // Reload all fields of selected item
+ //
+ reloadFromList();
+ }
+
+ /**
+ Refresh all fields' values of selected item of Vector
+
+ **/
+ private void reloadFromList() {
+ if (vName.size() > 0) {
+ //
+ // Get selected item index
+ //
+ intSelectedItemId = jComboBoxFileList.getSelectedIndex();
+
+ this.jTextFieldFileName.setText(vName.elementAt(intSelectedItemId).toString());
+ this.jComboBoxUsage.setSelectedItem(vUsage.elementAt(intSelectedItemId).toString());
+ this.jTextFieldGuid.setText(vGuid.elementAt(intSelectedItemId).toString());
+ this.jTextFieldLibraryClass.setText(vLibraryClass.elementAt(intSelectedItemId).toString());
+ this.jTextFieldClassGuid.setText(vClassGuid.elementAt(intSelectedItemId).toString());
+ this.jTextFieldVersion.setText(vVersion.elementAt(intSelectedItemId).toString());
+ this.jTextFieldOverrideID.setText(vOverrideID.elementAt(intSelectedItemId).toString());
+ } else {
+ this.jTextFieldFileName.setText("");
+ this.jComboBoxUsage.setSelectedIndex(0);
+ this.jTextFieldGuid.setText("");
+ this.jTextFieldLibraryClass.setText("");
+ this.jTextFieldClassGuid.setText("");
+ this.jTextFieldVersion.setText("");
+ this.jTextFieldOverrideID.setText("");
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see java.awt.event.ItemListener#itemStateChanged(java.awt.event.ItemEvent)
+ *
+ * Reflesh the frame when selected item changed
+ */
+ public void itemStateChanged(ItemEvent arg0) {
+ if (arg0.getStateChange() == ItemEvent.SELECTED) {
+ reloadFromList();
+ }
+ }
+
+ /**
+ Data validation for all fields before save
+
+ @retval true - All datas are valid
+ @retval false - At least one data is invalid
+
+ **/
+ public boolean check() {
+ if (this.jComboBoxFileList.getItemCount() < 1) {
+ Log.err("Must have one Library at least!");
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ Data validation for all fields before add current item to Vector
+
+ @retval true - All datas are valid
+ @retval false - At least one data is invalid
+
+ **/
+ public boolean checkAdd() {
+ //
+ // Check if all required fields are not empty
+ //
+ if (isEmpty(this.jTextFieldFileName.getText())) {
+ Log.err("File Name couldn't be empty");
+ return false;
+ }
+
+ //
+ // Check if all fields have correct data types
+ //
+ if (!DataValidation.isBaseName(this.jTextFieldFileName.getText())) {
+ Log.err("Incorrect data type for Name");
+ return false;
+ }
+ if (!isEmpty(this.jTextFieldGuid.getText()) && !DataValidation.isGuid(this.jTextFieldGuid.getText())) {
+ Log.err("Incorrect data type for Guid");
+ return false;
+ }
+ if (!isEmpty(this.jTextFieldLibraryClass.getText())
+ && !DataValidation.isPath(this.jTextFieldLibraryClass.getText())) {
+ Log.err("Incorrect data type for Path");
+ return false;
+ }
+ if (!isEmpty(this.jTextFieldClassGuid.getText()) && !DataValidation.isGuid(this.jTextFieldClassGuid.getText())) {
+ Log.err("Incorrect data type for Guid");
+ return false;
+ }
+ if (!isEmpty(this.jTextFieldOverrideID.getText())
+ && !DataValidation.isOverrideID(this.jTextFieldOverrideID.getText())) {
+ Log.err("Incorrect data type for Override ID");
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ Save all components of Mbd Libraries
+ if exists libraries, set the value directly
+ if not exists libraries, new an instance first
+
+ **/
+ public void save() {
+ try {
+ if (this.libraries == null) {
+ libraries = LibrariesDocument.Libraries.Factory.newInstance();
+ }
+ //
+ //Save as file name
+ //
+ if (!this.jCheckBoxArch.isSelected()) {
+ if (this.operation == 2) { //Add new filename
+ //
+ //First remove all existed filename
+ //
+ if (libraries.getLibraryList().size() > 0) {
+ for (int index = libraries.getLibraryList().size() - 1; index >= 0; index--) {
+ libraries.removeLibrary(index);
+ }
+ }
+ }
+ LibrariesDocument.Libraries.Library library = LibrariesDocument.Libraries.Library.Factory.newInstance();
+ for (int index = 0; index < vName.size(); index++) {
+ if (!isEmpty(vName.elementAt(index).toString())) {
+ library.setStringValue(vName.elementAt(index).toString());
+ }
+ if (!isEmpty(vGuid.elementAt(index).toString())) {
+ library.setGuid(vGuid.elementAt(index).toString());
+ }
+ if (!isEmpty(vLibraryClass.elementAt(index).toString())) {
+ library.setLibraryClass(vLibraryClass.elementAt(index).toString());
+ }
+ if (!isEmpty(vClassGuid.elementAt(index).toString())) {
+ library.setClassGuid(vClassGuid.elementAt(index).toString());
+ }
+ if (!isEmpty(vVersion.elementAt(index).toString())) {
+ library.setVersion(vVersion.elementAt(index).toString());
+ }
+ if (!isEmpty(vUsage.elementAt(index).toString())) {
+ library.setUsage(LibraryUsage.Enum.forString(vUsage.elementAt(index).toString()));
+ }
+ if (!isEmpty(vOverrideID.elementAt(index).toString())) {
+ library.setOverrideID(Integer.parseInt(vOverrideID.elementAt(index).toString()));
+ }
+ libraries.addNewLibrary();
+ libraries.setLibraryArray(libraries.getLibraryList().size() - 1, library);
+ }
+ }
+ //
+ //Save as Arch
+ //
+ if (this.jCheckBoxArch.isSelected()) {
+ LibrariesDocument.Libraries.Arch arch = LibrariesDocument.Libraries.Arch.Factory.newInstance();
+ if (this.operation == 2) {
+ //First remove all existed filename
+ for (int index = libraries.getArchArray(location).getLibraryList().size() - 1; index >= 0; index--) {
+ libraries.getArchArray(location).removeLibrary(index);
+ }
+ }
+ for (int index = 0; index < vName.size(); index++) {
+ LibrariesDocument.Libraries.Arch.Library library = LibrariesDocument.Libraries.Arch.Library.Factory.newInstance();
+ if (!isEmpty(vName.elementAt(index).toString())) {
+ library.setStringValue(vName.elementAt(index).toString());
+ }
+ if (!isEmpty(vGuid.elementAt(index).toString())) {
+ library.setGuid(vGuid.elementAt(index).toString());
+ }
+ if (!isEmpty(vLibraryClass.elementAt(index).toString())) {
+ library.setLibraryClass(vLibraryClass.elementAt(index).toString());
+ }
+ if (!isEmpty(vClassGuid.elementAt(index).toString())) {
+ library.setClassGuid(vClassGuid.elementAt(index).toString());
+ }
+ if (!isEmpty(vVersion.elementAt(index).toString())) {
+ library.setVersion(vVersion.elementAt(index).toString());
+ }
+ if (!isEmpty(vUsage.elementAt(index).toString())) {
+ library.setUsage(LibraryUsage.Enum.forString(vUsage.elementAt(index).toString()));
+ }
+ if (!isEmpty(vOverrideID.elementAt(index).toString())) {
+ library.setOverrideID(Integer.parseInt(vOverrideID.elementAt(index).toString()));
+ }
+ arch.addNewLibrary();
+ arch.setLibraryArray(arch.getLibraryList().size() - 1, library);
+ }
+ arch
+ .setArchType(SupportedArchitectures.Enum.forString(this.jComboBoxArch.getSelectedItem().toString()));
+ if (location > -1) {
+ libraries.setArchArray(location, arch);
+ } else {
+ libraries.addNewArch();
+ libraries.setArchArray(libraries.getArchList().size() - 1, arch);
+ }
+ }
+ } catch (Exception e) {
+ Log.err("Update Source Files", e.getMessage());
+ }
+ }
+
+ /**
+ Get LibrariesDocument.Libraries
+
+ @return LibrariesDocument.Libraries
+
+ **/
+ public LibrariesDocument.Libraries getLibraries() {
+ return libraries;
+ }
+
+ /**
+ Set LibrariesDocument.Libraries
+
+ @param libraries The input LibrariesDocument.Libraries
+
+ **/
+ public void setLibraries(LibrariesDocument.Libraries libraries) {
+ this.libraries = libraries;
+ }
+}
diff --git a/Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/ModuleAbout.java b/Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/ModuleAbout.java
new file mode 100644
index 0000000000..eb217f5f0a
--- /dev/null
+++ b/Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/ModuleAbout.java
@@ -0,0 +1,146 @@
+/** @file
+
+ To show a about window with copyright information
+
+ Copyright (c) 2006, Intel Corporation
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+ **/
+
+package org.tianocore.packaging.module.ui;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.WindowEvent;
+
+import javax.swing.JButton;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+
+import org.tianocore.packaging.common.ui.IDialog;
+
+/**
+ The class is used to show a about window with copyright information
+ It extends IDialog
+
+ @since ModuleEditor 1.0
+
+ **/
+public class ModuleAbout extends IDialog {
+
+ ///
+ /// Define class Serial Version UID
+ ///
+ private static final long serialVersionUID = 2958136136667310962L;
+
+ //
+ //Define class members
+ //
+ private JPanel jContentPane = null;
+
+ private JLabel jLabel = null;
+
+ private JLabel jLabel1 = null;
+
+ private JLabel jLabel2 = null;
+
+ private JButton jButtonOK = null;
+
+ /**
+ This method initializes jButtonOK
+
+ @return javax.swing.JButton jButtonOK
+
+ **/
+ private JButton getJButtonOK() {
+ if (jButtonOK == null) {
+ jButtonOK = new JButton();
+ jButtonOK.setBounds(new java.awt.Rectangle(105, 120, 90, 20));
+ jButtonOK.setText("OK");
+ jButtonOK.addActionListener(this);
+ }
+ return jButtonOK;
+ }
+
+ public static void main(String[] args) {
+ }
+
+ /**
+ This is the default constructor
+
+ **/
+ public ModuleAbout() {
+ super();
+ init();
+ }
+
+ /**
+ This method initializes this
+
+ **/
+ private void init() {
+ this.setSize(300, 200);
+ this.setContentPane(getJContentPane());
+ this.setTitle("About...");
+ this.getRootPane().setDefaultButton(jButtonOK);
+ this.centerWindow();
+ this.setVisible(true);
+ }
+
+ /**
+ This method initializes jContentPane
+
+ @return javax.swing.JPanel jContentPane
+
+ **/
+ private JPanel getJContentPane() {
+ if (jContentPane == null) {
+ jLabel2 = new JLabel();
+ jLabel2.setBounds(new java.awt.Rectangle(15, 80, 270, 20));
+ jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
+ jLabel2.setText("All rights reserved");
+ jLabel1 = new JLabel();
+ jLabel1.setBounds(new java.awt.Rectangle(15, 50, 270, 20));
+ jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
+ jLabel1.setText("Copyright (c) 2006, Intel Corporation");
+ jLabel = new JLabel();
+ jLabel.setToolTipText("");
+ jLabel.setBounds(new java.awt.Rectangle(15, 20, 270, 20));
+ jLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
+ jLabel.setText("Framework Development Package System 1.0");
+ jContentPane = new JPanel();
+ jContentPane.setLayout(null);
+ jContentPane.add(jLabel, null);
+ jContentPane.add(jLabel1, null);
+ jContentPane.add(jLabel2, null);
+ jContentPane.add(getJButtonOK(), null);
+ }
+ return jContentPane;
+ }
+
+ /* (non-Javadoc)
+ * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
+ *
+ * Override actionPerformed to listen all actions
+ */
+ public void actionPerformed(ActionEvent arg0) {
+ if (arg0.getSource() == jButtonOK) {
+ this.dispose();
+ }
+ }
+
+ /**
+ Dispose when windows is closing
+
+ @param arg0
+
+ **/
+ public void windowClosing(WindowEvent arg0) {
+ this.dispose();
+ }
+}
diff --git a/Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/ModuleBootModes.java b/Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/ModuleBootModes.java
new file mode 100644
index 0000000000..1acfa821e7
--- /dev/null
+++ b/Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/ModuleBootModes.java
@@ -0,0 +1,456 @@
+/** @file
+
+ The file is used to create, update BootModes of MSA/MBD file
+
+ Copyright (c) 2006, Intel Corporation
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+ **/
+
+package org.tianocore.packaging.module.ui;
+
+import java.awt.event.ActionEvent;
+
+import javax.swing.JButton;
+import javax.swing.JComboBox;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JTextField;
+
+import org.tianocore.BootModeNames;
+import org.tianocore.BootModeUsage;
+import org.tianocore.BootModesDocument;
+import org.tianocore.common.DataValidation;
+import org.tianocore.common.Log;
+import org.tianocore.common.Tools;
+import org.tianocore.packaging.common.ui.IInternalFrame;
+import org.tianocore.packaging.common.ui.StarLabel;
+
+/**
+ The class is used to create, update BootModes of MSA/MBD file
+ It extends IInternalFrame
+
+ @since ModuleEditor 1.0
+
+ **/
+public class ModuleBootModes extends IInternalFrame {
+
+ ///
+ /// Define class Serial Version UID
+ ///
+ private static final long serialVersionUID = -3888558623432442561L;
+
+ //
+ //Define class members
+ //
+ private BootModesDocument.BootModes bootModes = null;
+
+ private int location = -1;
+
+ private JPanel jContentPane = null;
+
+ private JLabel jLabelGuid = null;
+
+ private JTextField jTextFieldGuid = null;
+
+ private JLabel jLabelBootModeName = null;
+
+ private JComboBox jComboBoxBootModeName = null;
+
+ private JLabel jLabelUsage = null;
+
+ private JComboBox jComboBoxUsage = null;
+
+ private JButton jButtonOk = null;
+
+ private JButton jButtonCancel = null;
+
+ private JLabel jLabelOverrideID = null;
+
+ private JTextField jTextFieldOverrideID = null;
+
+ private JButton jButtonGenerateGuid = null;
+
+ private StarLabel jStarLabel1 = null;
+
+ /**
+ This method initializes jTextFieldGuid
+
+ @return javax.swing.JTextField jTextFieldGuid
+
+ **/
+ private JTextField getJTextFieldGuid() {
+ if (jTextFieldGuid == null) {
+ jTextFieldGuid = new JTextField();
+ jTextFieldGuid.setBounds(new java.awt.Rectangle(160, 35, 240, 20));
+ }
+ return jTextFieldGuid;
+ }
+
+ /**
+ This method initializes jComboBoxBootModeName
+
+ @return javax.swing.JComboBox jComboBoxBootModeName
+
+ **/
+ private JComboBox getJComboBoxBootModeName() {
+ if (jComboBoxBootModeName == null) {
+ jComboBoxBootModeName = new JComboBox();
+ jComboBoxBootModeName.setBounds(new java.awt.Rectangle(160, 10, 320, 20));
+ }
+ return jComboBoxBootModeName;
+ }
+
+ /**
+ This method initializes jComboBoxUsage
+
+ @return javax.swing.JComboBox jComboBoxUsage
+
+ **/
+ private JComboBox getJComboBoxUsage() {
+ if (jComboBoxUsage == null) {
+ jComboBoxUsage = new JComboBox();
+ jComboBoxUsage.setBounds(new java.awt.Rectangle(160, 60, 320, 20));
+ }
+ return jComboBoxUsage;
+ }
+
+ /**
+ This method initializes jButtonOk
+
+ @return javax.swing.JButton jButtonOk
+
+ **/
+ private JButton getJButtonOk() {
+ if (jButtonOk == null) {
+ jButtonOk = new JButton();
+ jButtonOk.setText("OK");
+ jButtonOk.setBounds(new java.awt.Rectangle(280, 115, 90, 20));
+ jButtonOk.addActionListener(this);
+ }
+ return jButtonOk;
+ }
+
+ /**
+ This method initializes jButtonCancel
+
+ @return javax.swing.JButton jButtonCancel
+
+ **/
+ private JButton getJButtonCancel() {
+ if (jButtonCancel == null) {
+ jButtonCancel = new JButton();
+ jButtonCancel.setText("Cancel");
+ jButtonCancel.setBounds(new java.awt.Rectangle(390, 115, 90, 20));
+ jButtonCancel.addActionListener(this);
+ }
+ return jButtonCancel;
+ }
+
+ /**
+ This method initializes jTextFieldOverrideID
+
+ @return javax.swing.JTextField jTextFieldOverrideID
+
+ **/
+ private JTextField getJTextFieldOverrideID() {
+ if (jTextFieldOverrideID == null) {
+ jTextFieldOverrideID = new JTextField();
+ jTextFieldOverrideID.setBounds(new java.awt.Rectangle(160, 85, 320, 20));
+ }
+ return jTextFieldOverrideID;
+ }
+
+ /**
+ This method initializes jButtonGenerateGuid
+
+ @return javax.swing.JButton jButtonGenerateGuid
+
+ **/
+ private JButton getJButtonGenerateGuid() {
+ if (jButtonGenerateGuid == null) {
+ jButtonGenerateGuid = new JButton();
+ jButtonGenerateGuid.setBounds(new java.awt.Rectangle(405, 35, 75, 20));
+ jButtonGenerateGuid.setText("GEN");
+ jButtonGenerateGuid.addActionListener(this);
+ }
+ return jButtonGenerateGuid;
+ }
+
+ public static void main(String[] args) {
+ }
+
+ /**
+ This is the default constructor
+
+ **/
+ public ModuleBootModes() {
+ super();
+ init();
+ this.setVisible(true);
+ }
+
+ /**
+ This is the override edit constructor
+
+ @param inBootModes The input BootModesDocument.BootModes
+
+ **/
+ public ModuleBootModes(BootModesDocument.BootModes inBootModes) {
+ super();
+ init(inBootModes);
+ this.setVisible(true);
+ }
+
+ /**
+ This is the override edit constructor
+
+ @param inBootModes The input BootModesDocument.BootModes
+ @param type The input data of node type
+ @param index The input data of node index
+
+ **/
+ public ModuleBootModes(BootModesDocument.BootModes inBootModes, int type, int index) {
+ super();
+ init(inBootModes, type, index);
+ this.setVisible(true);
+ }
+
+ /**
+ This method initializes this
+
+ @param inBootModes BootModesDocument.BootModes
+
+ **/
+ private void init(BootModesDocument.BootModes inBootModes) {
+ init();
+ this.setBootModes(inBootModes);
+ }
+
+ /**
+ This method initializes this
+ Fill values to all fields if these values are not empty
+
+ @param inBootModes The input BootModesDocument.BootModes
+ @param type The input data of node type
+ @param index The input data of node index
+
+ **/
+ private void init(BootModesDocument.BootModes inBootModes, int type, int index) {
+ init(inBootModes);
+ this.location = index;
+ if (this.bootModes.getBootModeList().size() > 0) {
+ if (this.bootModes.getBootModeArray(index).getBootModeName() != null) {
+ this.jComboBoxBootModeName.setSelectedItem(this.bootModes.getBootModeArray(index).getBootModeName()
+ .toString());
+ }
+ if (this.bootModes.getBootModeArray(index).getGuid() != null) {
+ this.jTextFieldGuid.setText(this.bootModes.getBootModeArray(index).getGuid());
+ }
+ if (this.bootModes.getBootModeArray(index).getUsage() != null) {
+ this.jComboBoxUsage.setSelectedItem(this.bootModes.getBootModeArray(index).getUsage().toString());
+ }
+ this.jTextFieldOverrideID.setText(String.valueOf(this.bootModes.getBootModeArray(index).getOverrideID()));
+ }
+ }
+
+ /**
+ * This method initializes this
+ *
+ * @return void
+ */
+ private void init() {
+ this.setContentPane(getJContentPane());
+ this.setTitle("Boot Mode");
+ this.setBounds(new java.awt.Rectangle(0, 0, 500, 515));
+ initFrame();
+ this.setViewMode(false);
+ }
+
+ /**
+ Disable all components when the mode is view
+
+ @param isView true - The view mode; false - The non-view mode
+
+ **/
+ public void setViewMode(boolean isView) {
+ this.jButtonOk.setVisible(false);
+ this.jButtonCancel.setVisible(false);
+ if (isView) {
+ this.jComboBoxBootModeName.setEnabled(!isView);
+ this.jTextFieldGuid.setEnabled(!isView);
+ this.jComboBoxUsage.setEnabled(!isView);
+ this.jTextFieldOverrideID.setEnabled(!isView);
+ this.jButtonCancel.setEnabled(!isView);
+ this.jButtonGenerateGuid.setEnabled(!isView);
+ this.jButtonOk.setEnabled(!isView);
+ }
+ }
+
+ /**
+ This method initializes jContentPane
+
+ @return javax.swing.JPanel jContentPane
+
+ **/
+ private JPanel getJContentPane() {
+ if (jContentPane == null) {
+ jLabelOverrideID = new JLabel();
+ jLabelOverrideID.setBounds(new java.awt.Rectangle(15, 85, 140, 20));
+ jLabelOverrideID.setText("Override ID");
+ jLabelUsage = new JLabel();
+ jLabelUsage.setText("Usage");
+ jLabelUsage.setBounds(new java.awt.Rectangle(15, 60, 140, 20));
+ jLabelBootModeName = new JLabel();
+ jLabelBootModeName.setText("Boot Mode Name");
+ jLabelBootModeName.setBounds(new java.awt.Rectangle(15, 10, 140, 20));
+ jLabelGuid = new JLabel();
+ jLabelGuid.setText("Guid");
+ jLabelGuid.setBounds(new java.awt.Rectangle(15, 35, 140, 20));
+ jContentPane = new JPanel();
+ jContentPane.setLayout(null);
+ jContentPane.add(jLabelGuid, null);
+ jContentPane.add(getJTextFieldGuid(), null);
+ jContentPane.add(jLabelBootModeName, null);
+ jContentPane.add(getJComboBoxBootModeName(), null);
+ jContentPane.add(jLabelUsage, null);
+ jContentPane.add(getJComboBoxUsage(), null);
+ jContentPane.add(getJButtonOk(), null);
+ jContentPane.add(getJButtonCancel(), null);
+ jContentPane.add(jLabelOverrideID, null);
+ jContentPane.add(getJTextFieldOverrideID(), null);
+ jContentPane.add(getJButtonGenerateGuid(), null);
+
+ jStarLabel1 = new StarLabel();
+ jStarLabel1.setLocation(new java.awt.Point(0, 10));
+
+ jContentPane.add(jStarLabel1, null);
+ }
+ return jContentPane;
+ }
+
+ /**
+ This method initializes BootModeName groups and Usage type
+
+ **/
+ private void initFrame() {
+ jComboBoxUsage.addItem("ALWAYS_CONSUMED");
+ jComboBoxUsage.addItem("SOMETIMES_CONSUMED");
+ jComboBoxUsage.addItem("ALWAYS_PRODUCED");
+ jComboBoxUsage.addItem("SOMETIMES_PRODUCED");
+
+ jComboBoxBootModeName.addItem("FULL");
+ jComboBoxBootModeName.addItem("MINIMAL");
+ jComboBoxBootModeName.addItem("NO_CHANGE");
+ jComboBoxBootModeName.addItem("DIAGNOSTICS");
+ jComboBoxBootModeName.addItem("DEFAULT");
+ jComboBoxBootModeName.addItem("S2_RESUME");
+ jComboBoxBootModeName.addItem("S3_RESUME");
+ jComboBoxBootModeName.addItem("S4_RESUME");
+ jComboBoxBootModeName.addItem("S5_RESUME");
+ jComboBoxBootModeName.addItem("FLASH_UPDATE");
+ jComboBoxBootModeName.addItem("RECOVERY");
+ }
+
+ /* (non-Javadoc)
+ * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
+ *
+ * Override actionPerformed to listen all actions
+ *
+ */
+ public void actionPerformed(ActionEvent arg0) {
+ if (arg0.getSource() == jButtonOk) {
+ this.setEdited(true);
+ this.save();
+ this.dispose();
+ }
+ if (arg0.getSource() == jButtonCancel) {
+ this.dispose();
+ }
+
+ if (arg0.getSource() == jButtonGenerateGuid) {
+ jTextFieldGuid.setText(Tools.generateUuidString());
+ }
+ }
+
+ /**
+ Get BootModesDocument.BootModes
+
+ @return BootModesDocument.BootModes
+
+ **/
+ public BootModesDocument.BootModes getBootModes() {
+ return bootModes;
+ }
+
+ /**
+ Set BootModesDocument.BootModes
+
+ @param bootModes BootModesDocument.BootModes
+
+ **/
+ public void setBootModes(BootModesDocument.BootModes bootModes) {
+ this.bootModes = bootModes;
+ }
+
+ /**
+ Data validation for all fields
+
+ @retval true - All datas are valid
+ @retval false - At least one data is invalid
+
+ **/
+ public boolean check() {
+ //
+ // Check if all fields have correct data types
+ //
+ if (!isEmpty(this.jTextFieldGuid.getText()) && !DataValidation.isGuid(this.jTextFieldGuid.getText())) {
+ Log.err("Incorrect data type for Guid");
+ return false;
+ }
+ if (!isEmpty(this.jTextFieldOverrideID.getText())
+ && !DataValidation.isOverrideID(this.jTextFieldOverrideID.getText())) {
+ Log.err("Incorrect data type for Override ID");
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ Save all components of Mbd Header
+ if exists bootModes, set the value directly
+ if not exists bootModes, new an instance first
+
+ **/
+ public void save() {
+ try {
+ if (this.bootModes == null) {
+ bootModes = BootModesDocument.BootModes.Factory.newInstance();
+ }
+ BootModesDocument.BootModes.BootMode bootMode = BootModesDocument.BootModes.BootMode.Factory.newInstance();
+ bootMode.setBootModeName(BootModeNames.Enum.forString(jComboBoxBootModeName.getSelectedItem().toString()));
+ if (!isEmpty(this.jTextFieldGuid.getText())) {
+ bootMode.setGuid(this.jTextFieldGuid.getText());
+ }
+ bootMode.setUsage(BootModeUsage.Enum.forString(jComboBoxUsage.getSelectedItem().toString()));
+ if (!isEmpty(this.jTextFieldOverrideID.getText())) {
+ bootMode.setOverrideID(Integer.parseInt(this.jTextFieldOverrideID.getText()));
+ }
+ if (location > -1) {
+ bootModes.setBootModeArray(location, bootMode);
+ } else {
+ bootModes.addNewBootMode();
+ bootModes.setBootModeArray(bootModes.getBootModeList().size() - 1, bootMode);
+ }
+ } catch (Exception e) {
+ Log.err("Update Boot Modes", e.getMessage());
+ }
+ }
+}
diff --git a/Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/ModuleDataHubs.java b/Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/ModuleDataHubs.java
new file mode 100644
index 0000000000..1d8e88c061
--- /dev/null
+++ b/Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/ModuleDataHubs.java
@@ -0,0 +1,457 @@
+/** @file
+
+ The file is used to create, update DataHub of MSA/MBD file
+
+ Copyright (c) 2006, Intel Corporation
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+ **/
+
+package org.tianocore.packaging.module.ui;
+
+import java.awt.event.ActionEvent;
+
+import javax.swing.JButton;
+import javax.swing.JComboBox;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JTextField;
+
+import org.tianocore.DataHubUsage;
+import org.tianocore.DataHubsDocument;
+import org.tianocore.common.DataValidation;
+import org.tianocore.common.Log;
+import org.tianocore.common.Tools;
+import org.tianocore.packaging.common.ui.IInternalFrame;
+import org.tianocore.packaging.common.ui.StarLabel;
+
+/**
+ The class is used to create, update DataHub of MSA/MBD file
+ It extends IInternalFrame
+
+ @since ModuleEditor 1.0
+
+ **/
+public class ModuleDataHubs extends IInternalFrame {
+
+ ///
+ /// Define class Serial Version UID
+ ///
+ private static final long serialVersionUID = -3667906991966638892L;
+
+ //
+ //Define class members
+ //
+ private DataHubsDocument.DataHubs dataHubs = null;
+
+ private int location = -1;
+
+ private JPanel jContentPane = null;
+
+ private JLabel jLabelGuid = null;
+
+ private JTextField jTextFieldGuid = null;
+
+ private JLabel jLabelUsage = null;
+
+ private JComboBox jComboBoxUsage = null;
+
+ private JButton jButtonOk = null;
+
+ private JButton jButtonCancel = null;
+
+ private JLabel jLabelDataHubRecord = null;
+
+ private JTextField jTextFieldDataHubRecord = null;
+
+ private JButton jButtonGenerateGuid = null;
+
+ private JLabel jLabelOverrideID = null;
+
+ private JTextField jTextFieldOverrideID = null;
+
+ private StarLabel jStarLabel1 = null;
+
+ /**
+ This method initializes jTextFieldGuid
+
+ @return javax.swing.JTextField jTextFieldGuid
+
+ **/
+ private JTextField getJTextFieldGuid() {
+ if (jTextFieldGuid == null) {
+ jTextFieldGuid = new JTextField();
+ jTextFieldGuid.setBounds(new java.awt.Rectangle(160, 35, 240, 20));
+ }
+ return jTextFieldGuid;
+ }
+
+ /**
+ This method initializes jComboBoxUsage
+
+ @return javax.swing.JComboBox jComboBoxUsage
+
+ **/
+ private JComboBox getJComboBoxUsage() {
+ if (jComboBoxUsage == null) {
+ jComboBoxUsage = new JComboBox();
+ jComboBoxUsage.setBounds(new java.awt.Rectangle(160, 60, 320, 20));
+ }
+ return jComboBoxUsage;
+ }
+
+ /**
+ This method initializes jButtonOk
+
+ @return javax.swing.JButton jButtonOk
+
+ **/
+ private JButton getJButtonOk() {
+ if (jButtonOk == null) {
+ jButtonOk = new JButton();
+ jButtonOk.setText("OK");
+ jButtonOk.setBounds(new java.awt.Rectangle(280, 115, 90, 20));
+ jButtonOk.addActionListener(this);
+ }
+ return jButtonOk;
+ }
+
+ /**
+ This method initializes jButtonCancel
+
+ @return javax.swing.JButton jButtonCancel
+
+ **/
+ private JButton getJButtonCancel() {
+ if (jButtonCancel == null) {
+ jButtonCancel = new JButton();
+ jButtonCancel.setText("Cancel");
+ jButtonCancel.setBounds(new java.awt.Rectangle(390, 115, 90, 20));
+ jButtonCancel.addActionListener(this);
+ }
+ return jButtonCancel;
+ }
+
+ /**
+ This method initializes jTextFieldDataHubRecord
+
+ @return javax.swing.JTextField jTextFieldDataHubRecord
+
+ **/
+ private JTextField getJTextFieldDataHubRecord() {
+ if (jTextFieldDataHubRecord == null) {
+ jTextFieldDataHubRecord = new JTextField();
+ jTextFieldDataHubRecord.setBounds(new java.awt.Rectangle(160, 10, 320, 20));
+ }
+ return jTextFieldDataHubRecord;
+ }
+
+ /**
+ This method initializes jButtonGenerateGuid
+
+ @return javax.swing.JButton jButtonGenerateGuid
+
+ **/
+ private JButton getJButtonGenerateGuid() {
+ if (jButtonGenerateGuid == null) {
+ jButtonGenerateGuid = new JButton();
+ jButtonGenerateGuid.setBounds(new java.awt.Rectangle(405, 35, 75, 20));
+ jButtonGenerateGuid.setText("GEN");
+ jButtonGenerateGuid.addActionListener(this);
+ }
+ return jButtonGenerateGuid;
+ }
+
+ /**
+ This method initializes jTextFieldOverrideID
+
+ @return javax.swing.JTextField jTextFieldOverrideID
+
+ **/
+ private JTextField getJTextFieldOverrideID() {
+ if (jTextFieldOverrideID == null) {
+ jTextFieldOverrideID = new JTextField();
+ jTextFieldOverrideID.setBounds(new java.awt.Rectangle(160, 85, 320, 20));
+ }
+ return jTextFieldOverrideID;
+ }
+
+ public static void main(String[] args) {
+
+ }
+
+ /**
+ This is the default constructor
+
+ **/
+ public ModuleDataHubs() {
+ super();
+ init();
+ this.setVisible(true);
+ }
+
+ /**
+ This is the override edit constructor
+
+ @param inDataHubs The input DataHubsDocument.DataHubs
+
+ **/
+ public ModuleDataHubs(DataHubsDocument.DataHubs inDataHubs) {
+ super();
+ init(inDataHubs);
+ this.setVisible(true);
+ }
+
+ /**
+ This is the override edit constructor
+
+ @param inDataHubs DataHubsDocument.DataHubs
+ @param type The input data of node type
+ @param index The input data of node index
+
+ **/
+ public ModuleDataHubs(DataHubsDocument.DataHubs inDataHubs, int type, int index) {
+ super();
+ init(inDataHubs, type, index);
+ this.setVisible(true);
+ }
+
+ /**
+ This method initializes this
+
+ @param inDataHubs The input DataHubsDocument.DataHubs
+
+ **/
+ private void init(DataHubsDocument.DataHubs inDataHubs) {
+ init();
+ this.setDataHubs(inDataHubs);
+ }
+
+ /**
+ This method initializes this
+ Fill values to all fields if these values are not empty
+
+ @param inDataHubs The input DataHubsDocument.DataHubs
+ @param type The input data of node type
+ @param index The input data of node index
+
+ **/
+ private void init(DataHubsDocument.DataHubs inDataHubs, int type, int index) {
+ init(inDataHubs);
+ this.location = index;
+ if (this.dataHubs.getDataHubRecordList().size() > 0) {
+ if (this.dataHubs.getDataHubRecordArray(index).getStringValue() != null) {
+ this.jTextFieldDataHubRecord.setText(this.dataHubs.getDataHubRecordArray(index).getStringValue()
+ .toString());
+ }
+ if (this.dataHubs.getDataHubRecordArray(index).getGuid() != null) {
+ this.jTextFieldGuid.setText(this.dataHubs.getDataHubRecordArray(index).getGuid());
+ }
+ if (this.dataHubs.getDataHubRecordArray(index).getUsage() != null) {
+ this.jComboBoxUsage.setSelectedItem(this.dataHubs.getDataHubRecordArray(index).getUsage().toString());
+ }
+ this.jTextFieldOverrideID
+ .setText(String
+ .valueOf(this.dataHubs.getDataHubRecordArray(index).getOverrideID()));
+ }
+ }
+
+ /**
+ Disable all components when the mode is view
+
+ @param isView true - The view mode; false - The non-view mode
+
+ **/
+ public void setViewMode(boolean isView) {
+ this.jButtonOk.setVisible(false);
+ this.jButtonCancel.setVisible(false);
+ if (isView) {
+ this.jTextFieldDataHubRecord.setEnabled(!isView);
+ this.jTextFieldGuid.setEnabled(!isView);
+ this.jComboBoxUsage.setEnabled(!isView);
+ this.jTextFieldOverrideID.setEnabled(!isView);
+ this.jButtonCancel.setEnabled(!isView);
+ this.jButtonGenerateGuid.setEnabled(!isView);
+ this.jButtonOk.setEnabled(!isView);
+ }
+ }
+
+ /**
+ This method initializes this
+
+ **/
+ private void init() {
+ this.setSize(500, 515);
+ this.setContentPane(getJContentPane());
+ this.setTitle("Data Hubs");
+ initFrame();
+ this.setViewMode(false);
+ }
+
+ /**
+ This method initializes jContentPane
+
+ @return javax.swing.JPanel jContentPane
+
+ **/
+ private JPanel getJContentPane() {
+ if (jContentPane == null) {
+ jLabelOverrideID = new JLabel();
+ jLabelOverrideID.setBounds(new java.awt.Rectangle(15, 85, 140, 20));
+ jLabelOverrideID.setText("Override ID");
+ jLabelDataHubRecord = new JLabel();
+ jLabelDataHubRecord.setBounds(new java.awt.Rectangle(15, 10, 140, 20));
+ jLabelDataHubRecord.setText("Data Hub Record");
+ jLabelGuid = new JLabel();
+ jLabelGuid.setText("Guid");
+ jLabelGuid.setBounds(new java.awt.Rectangle(15, 35, 140, 20));
+ jLabelUsage = new JLabel();
+ jLabelUsage.setText("Usage");
+ jLabelUsage.setBounds(new java.awt.Rectangle(15, 60, 140, 20));
+ jContentPane = new JPanel();
+ jContentPane.setLayout(null);
+ jContentPane.add(jLabelGuid, null);
+ jContentPane.add(getJTextFieldGuid(), null);
+ jContentPane.add(jLabelUsage, null);
+ jContentPane.add(getJComboBoxUsage(), null);
+ jContentPane.add(getJButtonOk(), null);
+ jContentPane.add(getJButtonCancel(), null);
+ jContentPane.add(jLabelDataHubRecord, null);
+ jContentPane.add(getJTextFieldDataHubRecord(), null);
+ jContentPane.add(getJButtonGenerateGuid(), null);
+ jContentPane.add(jLabelOverrideID, null);
+ jContentPane.add(getJTextFieldOverrideID(), null);
+
+ jStarLabel1 = new StarLabel();
+ jStarLabel1.setLocation(new java.awt.Point(0, 10));
+
+ jContentPane.add(jStarLabel1, null);
+ }
+ return jContentPane;
+ }
+
+ /**
+ This method initializes Usage type
+
+ **/
+ private void initFrame() {
+ jComboBoxUsage.addItem("ALWAYS_CONSUMED");
+ jComboBoxUsage.addItem("SOMETIMES_CONSUMED");
+ jComboBoxUsage.addItem("ALWAYS_PRODUCED");
+ jComboBoxUsage.addItem("SOMETIMES_PRODUCED");
+ jComboBoxUsage.addItem("PRIVATE");
+ }
+
+ /* (non-Javadoc)
+ * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
+ *
+ * Override actionPerformed to listen all actions
+ *
+ */
+ public void actionPerformed(ActionEvent arg0) {
+ if (arg0.getSource() == jButtonOk) {
+ this.setEdited(true);
+ this.save();
+ this.dispose();
+ }
+ if (arg0.getSource() == jButtonCancel) {
+ this.dispose();
+ }
+
+ if (arg0.getSource() == jButtonGenerateGuid) {
+ jTextFieldGuid.setText(Tools.generateUuidString());
+ }
+ }
+
+ /**
+ Get DataHubsDocument.DataHubs
+
+ @return DataHubsDocument.DataHubs
+
+ **/
+ public DataHubsDocument.DataHubs getDataHubs() {
+ return dataHubs;
+ }
+
+ /**
+ Set DataHubsDocument.DataHubs
+
+ @param dataHubs DataHubsDocument.DataHubs
+
+ **/
+ public void setDataHubs(DataHubsDocument.DataHubs dataHubs) {
+ this.dataHubs = dataHubs;
+ }
+
+ /**
+ Data validation for all fields
+
+ @retval true - All datas are valid
+ @retval false - At least one data is invalid
+
+ **/
+ public boolean check() {
+ //
+ // Check if all required fields are not empty
+ //
+ if (isEmpty(this.jTextFieldDataHubRecord.getText())) {
+ Log.err("Data Hub Record couldn't be empty");
+ return false;
+ }
+
+ //
+ // Check if all fields have correct data types
+ //
+ if (!isEmpty(this.jTextFieldGuid.getText()) && !DataValidation.isGuid(this.jTextFieldGuid.getText())) {
+ Log.err("Incorrect data type for Guid");
+ return false;
+ }
+ if (!isEmpty(this.jTextFieldOverrideID.getText())
+ && !DataValidation.isOverrideID(this.jTextFieldOverrideID.getText())) {
+ Log.err("Incorrect data type for Override ID");
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ Save all components of DataHubs
+ if exists dataHubs, set the value directly
+ if not exists dataHubs, new an instance first
+
+ **/
+ public void save() {
+ try {
+ if (this.dataHubs == null) {
+ dataHubs = DataHubsDocument.DataHubs.Factory.newInstance();
+ }
+ DataHubsDocument.DataHubs.DataHubRecord dataHubRecord = DataHubsDocument.DataHubs.DataHubRecord.Factory
+ .newInstance();
+ if (!isEmpty(this.jTextFieldDataHubRecord.getText())) {
+ dataHubRecord.setStringValue(this.jTextFieldDataHubRecord.getText());
+ }
+ if (!isEmpty(this.jTextFieldGuid.getText())) {
+ dataHubRecord.setGuid(this.jTextFieldGuid.getText());
+ }
+ dataHubRecord.setUsage(DataHubUsage.Enum.forString(jComboBoxUsage.getSelectedItem().toString()));
+ if (!isEmpty(this.jTextFieldOverrideID.getText())) {
+ dataHubRecord.setOverrideID(Integer.parseInt(this.jTextFieldOverrideID.getText()));
+ }
+ if (location > -1) {
+ dataHubs.setDataHubRecordArray(location, dataHubRecord);
+ } else {
+ dataHubs.addNewDataHubRecord();
+ dataHubs.setDataHubRecordArray(dataHubs.getDataHubRecordList().size() - 1, dataHubRecord);
+ }
+ } catch (Exception e) {
+ Log.err("Update Data Hubs", e.getMessage());
+ }
+ }
+}
diff --git a/Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/ModuleEvents.java b/Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/ModuleEvents.java
new file mode 100644
index 0000000000..abc3653d29
--- /dev/null
+++ b/Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/ModuleEvents.java
@@ -0,0 +1,626 @@
+/** @file
+
+ The file is used to create, update Event of MSA/MBD file
+
+ Copyright (c) 2006, Intel Corporation
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+ **/
+package org.tianocore.packaging.module.ui;
+
+import java.awt.Dimension;
+import java.awt.event.ActionEvent;
+
+import javax.swing.JButton;
+import javax.swing.JComboBox;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JRadioButton;
+import javax.swing.JTextField;
+
+import org.tianocore.EventTypes;
+import org.tianocore.EventUsage;
+import org.tianocore.EventsDocument;
+import org.tianocore.GuidDocument;
+import org.tianocore.common.DataValidation;
+import org.tianocore.common.Log;
+import org.tianocore.common.Tools;
+import org.tianocore.packaging.common.ui.IDefaultMutableTreeNode;
+import org.tianocore.packaging.common.ui.IInternalFrame;
+import org.tianocore.packaging.common.ui.StarLabel;
+
+/**
+ The class is used to create, update Event of MSA/MBD file
+ It extends IInternalFrame
+
+ @since ModuleEditor 1.0
+
+ **/
+public class ModuleEvents extends IInternalFrame {
+
+ ///
+ /// Define class Serial Version UID
+ ///
+ private static final long serialVersionUID = -4396143706422842331L;
+
+ //
+ //Define class members
+ //
+ private EventsDocument.Events events = null;
+
+ private EventsDocument.Events.CreateEvents createEvent = null;
+
+ private EventsDocument.Events.SignalEvents signalEvent = null;
+
+ private int location = -1;
+
+ private JPanel jContentPane = null;
+
+ private JLabel jLabelEventType = null;
+
+ private JRadioButton jRadioButtonEventCreate = null;
+
+ private JRadioButton jRadioButtonEventSignal = null;
+
+ private JLabel jLabelC_Name = null;
+
+ private JTextField jTextFieldC_Name = null;
+
+ private JLabel jLabelGuid = null;
+
+ private JTextField jTextFieldGuid = null;
+
+ private JLabel jLabelEventGroup = null;
+
+ private JComboBox jComboBoxEventGroup = null;
+
+ private JLabel jLabelUsage = null;
+
+ private JComboBox jComboBoxUsage = null;
+
+ private JButton jButtonOk = null;
+
+ private JButton jButtonCancel = null;
+
+ private JButton jButtonGenerateGuid = null;
+
+ private JLabel jLabelOverrideID = null;
+
+ private JTextField jTextFieldOverrideID = null;
+
+ private StarLabel jStarLabel1 = null;
+
+ private StarLabel jStarLabel2 = null;
+
+ /**
+ This method initializes jRadioButtonEnentType
+
+ @return javax.swing.JRadioButton jRadioButtonEventCreate
+
+ **/
+ private JRadioButton getJRadioButtonEventCreate() {
+ if (jRadioButtonEventCreate == null) {
+ jRadioButtonEventCreate = new JRadioButton();
+ jRadioButtonEventCreate.setText("Create");
+ jRadioButtonEventCreate.setBounds(new java.awt.Rectangle(160, 10, 90, 20));
+ jRadioButtonEventCreate.addActionListener(this);
+ jRadioButtonEventCreate.setSelected(true);
+ }
+ return jRadioButtonEventCreate;
+ }
+
+ /**
+ This method initializes jRadioButtonEventSignal
+
+ @return javax.swing.JRadioButton jRadioButtonEventSignal
+
+ **/
+ private JRadioButton getJRadioButtonEventSignal() {
+ if (jRadioButtonEventSignal == null) {
+ jRadioButtonEventSignal = new JRadioButton();
+ jRadioButtonEventSignal.setText("Signal");
+ jRadioButtonEventSignal.setBounds(new java.awt.Rectangle(320, 10, 90, 20));
+ jRadioButtonEventSignal.addActionListener(this);
+ }
+ return jRadioButtonEventSignal;
+ }
+
+ /**
+ This method initializes jTextFieldC_Name
+
+ @return javax.swing.JTextField jTextFieldC_Name
+
+ **/
+ private JTextField getJTextFieldC_Name() {
+ if (jTextFieldC_Name == null) {
+ jTextFieldC_Name = new JTextField();
+ jTextFieldC_Name.setBounds(new java.awt.Rectangle(160, 35, 320, 20));
+ }
+ return jTextFieldC_Name;
+ }
+
+ /**
+ This method initializes jTextFieldGuid
+
+ @return javax.swing.JTextField jTextFieldGuid
+
+ **/
+ private JTextField getJTextFieldGuid() {
+ if (jTextFieldGuid == null) {
+ jTextFieldGuid = new JTextField();
+ jTextFieldGuid.setBounds(new java.awt.Rectangle(160, 60, 240, 20));
+ }
+ return jTextFieldGuid;
+ }
+
+ /**
+ This method initializes jComboBoxEventGroup
+
+ @return javax.swing.JComboBox jComboBoxEventGroup
+
+ **/
+ private JComboBox getJComboBoxEventGroup() {
+ if (jComboBoxEventGroup == null) {
+ jComboBoxEventGroup = new JComboBox();
+ jComboBoxEventGroup.setBounds(new java.awt.Rectangle(160, 85, 320, 20));
+ }
+ return jComboBoxEventGroup;
+ }
+
+ /**
+ This method initializes jComboBoxUsage
+
+ @return javax.swing.JComboBox jComboBoxUsage
+
+ **/
+ private JComboBox getJComboBoxUsage() {
+ if (jComboBoxUsage == null) {
+ jComboBoxUsage = new JComboBox();
+ jComboBoxUsage.setBounds(new java.awt.Rectangle(160, 110, 320, 20));
+ }
+ return jComboBoxUsage;
+ }
+
+ /**
+ This method initializes jButtonOk
+
+ @return javax.swing.JButton jButtonOk
+
+ **/
+ private JButton getJButton() {
+ if (jButtonOk == null) {
+ jButtonOk = new JButton();
+ jButtonOk.setText("OK");
+ jButtonOk.setBounds(new java.awt.Rectangle(290, 165, 90, 20));
+ jButtonOk.addActionListener(this);
+ }
+ return jButtonOk;
+ }
+
+ /**
+ This method initializes jButtonCancel
+
+ @return javax.swing.JButton jButtonCancel
+
+ **/
+ private JButton getJButtonCancel() {
+ if (jButtonCancel == null) {
+ jButtonCancel = new JButton();
+ jButtonCancel.setText("Cancel");
+ jButtonCancel.setBounds(new java.awt.Rectangle(390, 165, 90, 20));
+ jButtonCancel.setPreferredSize(new Dimension(90, 20));
+ jButtonCancel.addActionListener(this);
+ }
+ return jButtonCancel;
+ }
+
+ /**
+ This method initializes jButtonGenerateGuid
+
+ @return javax.swing.JButton jButtonGenerateGuid
+
+ **/
+ private JButton getJButtonGenerateGuid() {
+ if (jButtonGenerateGuid == null) {
+ jButtonGenerateGuid = new JButton();
+ jButtonGenerateGuid.setBounds(new java.awt.Rectangle(405, 60, 75, 20));
+ jButtonGenerateGuid.setText("GEN");
+ jButtonGenerateGuid.addActionListener(this);
+ }
+ return jButtonGenerateGuid;
+ }
+
+ /**
+ This method initializes jTextFieldOverrideID
+
+ @return javax.swing.JTextField jTextFieldOverrideID
+
+ **/
+ private JTextField getJTextFieldOverrideID() {
+ if (jTextFieldOverrideID == null) {
+ jTextFieldOverrideID = new JTextField();
+ jTextFieldOverrideID.setBounds(new java.awt.Rectangle(160, 135, 320, 20));
+ }
+ return jTextFieldOverrideID;
+ }
+
+ public static void main(String[] args) {
+
+ }
+
+ /**
+ This is the default constructor
+
+ **/
+ public ModuleEvents() {
+ super();
+ init();
+ this.setVisible(true);
+ }
+
+ /**
+ This is the override edit constructor
+
+ @param inEvents The input EventsDocument.Events
+
+ **/
+ public ModuleEvents(EventsDocument.Events inEvents) {
+ super();
+ init(inEvents);
+ this.setVisible(true);
+ }
+
+ /**
+ This is the override edit constructor
+
+ @param inEvents The input EventsDocument.Events
+ @param type The input data of node type
+ @param index The input data of node index
+
+ **/
+ public ModuleEvents(EventsDocument.Events inEvents, int type, int index) {
+ super();
+ init(inEvents, type, index);
+ this.setVisible(true);
+ }
+
+ /**
+ This method initializes this
+
+ @param inEvents The input EventsDocument.Events
+
+ **/
+ private void init(EventsDocument.Events inEvents) {
+ init();
+ this.setEvents(inEvents);
+ }
+
+ /**
+ This method initializes this
+ Fill values to all fields if these values are not empty
+
+ @param inEvents EventsDocument.Events
+ @param type The input data of node type
+ @param index The input data of node index
+
+ **/
+ private void init(EventsDocument.Events inEvents, int type, int index) {
+ init(inEvents);
+ this.location = index;
+ if (type == IDefaultMutableTreeNode.EVENTS_CREATEEVENTS_ITEM) {
+ this.jRadioButtonEventCreate.setSelected(true);
+ this.jRadioButtonEventSignal.setSelected(false);
+ if (this.events.getCreateEvents().getEventArray(index).getCName() != null) {
+ this.jTextFieldC_Name.setText(this.events.getCreateEvents().getEventArray(index).getCName());
+ }
+ if (this.events.getCreateEvents().getEventArray(index).getGuid() != null) {
+ this.jTextFieldGuid.setText(this.events.getCreateEvents().getEventArray(index).getGuid()
+ .getStringValue());
+ }
+ if (this.events.getCreateEvents().getEventArray(index).getEventGroup() != null) {
+ this.jComboBoxEventGroup.setSelectedItem(this.events.getCreateEvents().getEventArray(index)
+ .getEventGroup().toString());
+ }
+ if (this.events.getCreateEvents().getEventArray(index).getUsage() != null) {
+ this.jComboBoxUsage.setSelectedItem(this.events.getCreateEvents().getEventArray(index).getUsage()
+ .toString());
+ }
+ this.jTextFieldOverrideID.setText(String.valueOf(this.events.getCreateEvents().getEventArray(index)
+ .getOverrideID()));
+ } else if (type == IDefaultMutableTreeNode.EVENTS_SIGNALEVENTS_ITEM) {
+ this.jRadioButtonEventCreate.setSelected(false);
+ this.jRadioButtonEventSignal.setSelected(true);
+ this.jComboBoxUsage.setEnabled(false);
+ if (this.events.getSignalEvents().getEventArray(index).getCName() != null) {
+ this.jTextFieldC_Name.setText(this.events.getSignalEvents().getEventArray(index).getCName());
+ }
+ if (this.events.getSignalEvents().getEventArray(index).getGuid() != null) {
+ this.jTextFieldGuid.setText(this.events.getSignalEvents().getEventArray(index).getGuid().toString());
+ }
+ if (this.events.getSignalEvents().getEventArray(index).getEventGroup() != null) {
+ this.jComboBoxEventGroup.setSelectedItem(this.events.getSignalEvents().getEventArray(index)
+ .getEventGroup().toString());
+ }
+ if (this.events.getSignalEvents().getEventArray(index).getUsage() != null) {
+ this.jComboBoxUsage.setSelectedItem(this.events.getSignalEvents().getEventArray(index).getUsage()
+ .toString());
+ }
+ this.jTextFieldOverrideID.setText(String.valueOf(this.events.getSignalEvents().getEventArray(index)
+ .getOverrideID()));
+ }
+ this.jRadioButtonEventCreate.setEnabled(false);
+ this.jRadioButtonEventSignal.setEnabled(false);
+ }
+
+ /**
+ This method initializes this
+
+ **/
+ private void init() {
+ this.setSize(500, 515);
+ this.setContentPane(getJContentPane());
+ this.setTitle("Events");
+ initFrame();
+ this.setViewMode(false);
+ }
+
+ /**
+ Disable all components when the mode is view
+
+ @param isView true - The view mode; false - The non-view mode
+
+ **/
+ public void setViewMode(boolean isView) {
+ this.jButtonOk.setVisible(false);
+ this.jButtonCancel.setVisible(false);
+ if (isView) {
+ this.jRadioButtonEventCreate.setEnabled(!isView);
+ this.jRadioButtonEventSignal.setEnabled(!isView);
+ this.jTextFieldC_Name.setEnabled(!isView);
+ this.jTextFieldGuid.setEnabled(!isView);
+ this.jComboBoxEventGroup.setEnabled(!isView);
+ this.jComboBoxUsage.setEnabled(!isView);
+ this.jTextFieldOverrideID.setEnabled(!isView);
+ this.jButtonCancel.setEnabled(!isView);
+ this.jButtonGenerateGuid.setEnabled(!isView);
+ this.jButtonOk.setEnabled(!isView);
+ }
+ }
+
+ /**
+ This method initializes jContentPane
+
+ @return javax.swing.JPanel jContentPane
+
+ **/
+ private JPanel getJContentPane() {
+ if (jContentPane == null) {
+ jLabelOverrideID = new JLabel();
+ jLabelOverrideID.setBounds(new java.awt.Rectangle(15, 135, 140, 20));
+ jLabelOverrideID.setText("Override ID");
+ jLabelUsage = new JLabel();
+ jLabelUsage.setText("Usage");
+ jLabelUsage.setBounds(new java.awt.Rectangle(15, 110, 140, 20));
+ jLabelEventGroup = new JLabel();
+ jLabelEventGroup.setText("Event Group");
+ jLabelEventGroup.setBounds(new java.awt.Rectangle(15, 85, 140, 20));
+ jLabelGuid = new JLabel();
+ jLabelGuid.setText("Guid");
+ jLabelGuid.setBounds(new java.awt.Rectangle(15, 60, 140, 20));
+ jLabelC_Name = new JLabel();
+ jLabelC_Name.setText("C_Name");
+ jLabelC_Name.setBounds(new java.awt.Rectangle(15, 35, 140, 20));
+ jLabelEventType = new JLabel();
+ jLabelEventType.setText("Event Type");
+ jLabelEventType.setBounds(new java.awt.Rectangle(15, 10, 140, 20));
+ jContentPane = new JPanel();
+ jContentPane.setLayout(null);
+ jContentPane.add(jLabelEventType, null);
+ jContentPane.add(getJRadioButtonEventCreate(), null);
+ jContentPane.add(getJRadioButtonEventSignal(), null);
+ jContentPane.add(jLabelC_Name, null);
+ jContentPane.add(getJTextFieldC_Name(), null);
+ jContentPane.add(jLabelGuid, null);
+ jContentPane.add(getJTextFieldGuid(), null);
+ jContentPane.add(jLabelEventGroup, null);
+ jContentPane.add(getJComboBoxEventGroup(), null);
+ jContentPane.add(jLabelUsage, null);
+ jContentPane.add(getJComboBoxUsage(), null);
+ jContentPane.add(getJButton(), null);
+ jContentPane.add(getJButtonCancel(), null);
+ jContentPane.add(getJButtonGenerateGuid(), null);
+ jContentPane.add(jLabelOverrideID, null);
+ jContentPane.add(getJTextFieldOverrideID(), null);
+
+ jStarLabel1 = new StarLabel();
+ jStarLabel1.setBounds(new java.awt.Rectangle(0, 10, 10, 20));
+ jStarLabel2 = new StarLabel();
+ jStarLabel2.setBounds(new java.awt.Rectangle(0, 35, 10, 20));
+
+ jContentPane.add(jStarLabel1, null);
+ jContentPane.add(jStarLabel2, null);
+ }
+ return jContentPane;
+ }
+
+ /**
+ This method initializes events groups and usage type
+
+ **/
+ private void initFrame() {
+ jComboBoxEventGroup.addItem("EVENT_GROUP_EXIT_BOOT_SERVICES");
+ jComboBoxEventGroup.addItem("EVENT_GROUP_VIRTUAL_ADDRESS_CHANGE");
+ jComboBoxEventGroup.addItem("EVENT_GROUP_MEMORY_MAP_CHANGE");
+ jComboBoxEventGroup.addItem("EVENT_GROUP_READY_TO_BOOT");
+ jComboBoxEventGroup.addItem("EVENT_GROUP_LEGACY_BOOT");
+
+ jComboBoxUsage.addItem("ALWAYS_CONSUMED");
+ jComboBoxUsage.addItem("SOMETIMES_CONSUMED");
+ jComboBoxUsage.addItem("ALWAYS_PRODUCED");
+ jComboBoxUsage.addItem("SOMETIMES_PRODUCED");
+ jComboBoxUsage.addItem("PRIVATE");
+ }
+
+ /* (non-Javadoc)
+ * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
+ *
+ * Override actionPerformed to listen all actions
+ *
+ */
+ public void actionPerformed(ActionEvent arg0) {
+ if (arg0.getSource() == jButtonOk) {
+ this.setEdited(true);
+ this.save();
+ this.dispose();
+ }
+ if (arg0.getSource() == jButtonCancel) {
+ this.dispose();
+ }
+
+ if (arg0.getSource() == jRadioButtonEventCreate) {
+ if (jRadioButtonEventCreate.isSelected()) {
+ jRadioButtonEventSignal.setSelected(false);
+ }
+ if (!jRadioButtonEventSignal.isSelected() && !jRadioButtonEventCreate.isSelected()) {
+ jRadioButtonEventCreate.setSelected(true);
+ }
+ }
+
+ if (arg0.getSource() == jRadioButtonEventSignal) {
+ if (jRadioButtonEventSignal.isSelected()) {
+ jRadioButtonEventCreate.setSelected(false);
+ }
+ if (!jRadioButtonEventSignal.isSelected() && !jRadioButtonEventCreate.isSelected()) {
+ jRadioButtonEventSignal.setSelected(true);
+ }
+ }
+
+ if (arg0.getSource() == jButtonGenerateGuid) {
+ jTextFieldGuid.setText(Tools.generateUuidString());
+ }
+ }
+
+ public EventsDocument.Events getEvents() {
+ return events;
+ }
+
+ public void setEvents(EventsDocument.Events events) {
+ this.events = events;
+ }
+
+ /**
+ Data validation for all fields
+
+ @retval true - All datas are valid
+ @retval false - At least one data is invalid
+
+ **/
+ public boolean check() {
+ //
+ // Check if all required fields are not empty
+ //
+ if (isEmpty(this.jTextFieldC_Name.getText())) {
+ Log.err("C_Name couldn't be empty");
+ return false;
+ }
+
+ //
+ // Check if all fields have correct data types
+ //
+ if (!DataValidation.isCName(this.jTextFieldC_Name.getText())) {
+ Log.err("Incorrect data type for C_Name");
+ return false;
+ }
+ if (!isEmpty(this.jTextFieldGuid.getText()) && !DataValidation.isGuid(this.jTextFieldGuid.getText())) {
+ Log.err("Incorrect data type for Guid");
+ return false;
+ }
+ if (!isEmpty(this.jTextFieldOverrideID.getText())
+ && !DataValidation.isOverrideID(this.jTextFieldOverrideID.getText())) {
+ Log.err("Incorrect data type for Override ID");
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ Save all components of Events
+ if exists events, set the value directly
+ if not exists events, new an instance first
+
+ **/
+ public void save() {
+ try {
+ if (this.events == null) {
+ events = EventsDocument.Events.Factory.newInstance();
+ createEvent = EventsDocument.Events.CreateEvents.Factory.newInstance();
+ signalEvent = EventsDocument.Events.SignalEvents.Factory.newInstance();
+ } else {
+ if (events.getCreateEvents() != null) {
+ createEvent = events.getCreateEvents();
+ } else {
+ createEvent = EventsDocument.Events.CreateEvents.Factory.newInstance();
+ }
+ if (events.getSignalEvents() != null) {
+ signalEvent = events.getSignalEvents();
+ } else {
+ signalEvent = EventsDocument.Events.SignalEvents.Factory.newInstance();
+ }
+
+ }
+ if (this.jRadioButtonEventCreate.isSelected()) {
+ EventsDocument.Events.CreateEvents.Event event = EventsDocument.Events.CreateEvents.Event.Factory
+ .newInstance();
+ event.setCName(this.jTextFieldC_Name.getText());
+ if (!isEmpty(this.jTextFieldGuid.getText())) {
+ GuidDocument.Guid guid = GuidDocument.Guid.Factory.newInstance();
+ guid.setStringValue(this.jTextFieldGuid.getText());
+ event.setGuid(guid);
+ }
+ event.setEventGroup(EventTypes.Enum.forString(jComboBoxEventGroup.getSelectedItem().toString()));
+ event.setUsage(EventUsage.Enum.forString(jComboBoxUsage.getSelectedItem().toString()));
+ if (!isEmpty(this.jTextFieldOverrideID.getText())) {
+ event.setOverrideID(Integer.parseInt(this.jTextFieldOverrideID.getText()));
+ }
+ if (location > -1) {
+ createEvent.setEventArray(location, event);
+ } else {
+ createEvent.addNewEvent();
+ createEvent.setEventArray(createEvent.getEventList().size() - 1, event);
+ }
+ events.setCreateEvents(createEvent);
+ }
+ if (this.jRadioButtonEventSignal.isSelected()) {
+ EventsDocument.Events.SignalEvents.Event event = EventsDocument.Events.SignalEvents.Event.Factory
+ .newInstance();
+ event.setCName(this.jTextFieldC_Name.getText());
+ if (!isEmpty(this.jTextFieldGuid.getText())) {
+ GuidDocument.Guid guid = GuidDocument.Guid.Factory.newInstance();
+ guid.setStringValue(this.jTextFieldGuid.getText());
+ event.setGuid(guid);
+ }
+ event.setEventGroup(EventTypes.Enum.forString(jComboBoxEventGroup.getSelectedItem().toString()));
+ event.setUsage(EventUsage.Enum.forString(jComboBoxUsage.getSelectedItem().toString()));
+ if (!isEmpty(this.jTextFieldOverrideID.getText())) {
+ event.setOverrideID(Integer.parseInt(this.jTextFieldOverrideID.getText()));
+ }
+ if (location > -1) {
+ signalEvent.setEventArray(location, event);
+ } else {
+ signalEvent.addNewEvent();
+ signalEvent.setEventArray(signalEvent.getEventList().size() - 1, event);
+ }
+ events.setSignalEvents(signalEvent);
+ }
+ } catch (Exception e) {
+ Log.err("Update Events", e.getMessage());
+ }
+ }
+}
diff --git a/Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/ModuleExterns.java b/Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/ModuleExterns.java
new file mode 100644
index 0000000000..ad466eb621
--- /dev/null
+++ b/Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/ModuleExterns.java
@@ -0,0 +1,1030 @@
+/** @file
+
+ The file is used to create, update DataHub of MSA/MBD file
+
+ Copyright (c) 2006, Intel Corporation
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+ **/
+package org.tianocore.packaging.module.ui;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
+
+import javax.swing.JButton;
+import javax.swing.JComboBox;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JTextField;
+
+import org.tianocore.ExternUsage;
+import org.tianocore.ExternsDocument;
+import org.tianocore.common.DataValidation;
+import org.tianocore.common.Log;
+import org.tianocore.packaging.common.ui.IComboBox;
+import org.tianocore.packaging.common.ui.IInternalFrame;
+
+/**
+ The class is used to create, update DataHub of MSA/MBD file
+ It extends IInternalFrame
+
+ @since ModuleEditor 1.0
+
+ **/
+public class ModuleExterns extends IInternalFrame implements ItemListener {
+
+ ///
+ /// Define class Serial Version UID
+ ///
+ private static final long serialVersionUID = -7382008402932047191L;
+
+ //
+ //Define class members
+ //
+ private ExternsDocument.Externs externs = null;
+
+ private int location = -1;
+
+ private JPanel jContentPane = null;
+
+ private JLabel jLabelName = null;
+
+ private JLabel jLabelUsage = null;
+
+ private JComboBox jComboBoxUsage = null;
+
+ private JButton jButtonOk = null;
+
+ private JButton jButtonCancel = null;
+
+ private JLabel jLabelOverrideID = null;
+
+ private JTextField jTextFieldOverrideID = null;
+
+ private JPanel jPanelType1 = null;
+
+ private JLabel jLabelModuleEntryPoint = null;
+
+ private JLabel jLabelModuleUnloadImage = null;
+
+ private IComboBox iComboBoxModuleEntryPoint = null;
+
+ private IComboBox iComboBoxModuleUnloadImage = null;
+
+ private JPanel jPanelType2 = null;
+
+ private JLabel jLabelConstructor = null;
+
+ private JTextField jTextFieldConstructor = null;
+
+ private JLabel jLabelDestructor = null;
+
+ private JTextField jTextFieldDestructor = null;
+
+ private JComboBox jComboBoxType = null;
+
+ private JPanel jPanelType3 = null;
+
+ private JLabel jLabelDriverBinding = null;
+
+ private JLabel jLabelComponentName = null;
+
+ private IComboBox iComboBoxComponentName = null;
+
+ private IComboBox iComboBoxDriverBinding = null;
+
+ private JLabel jLabelDriverConfig = null;
+
+ private JLabel jLabelDriverDiag = null;
+
+ private IComboBox iComboBoxDriverDiag = null;
+
+ private IComboBox iComboBoxDriverConfig = null;
+
+ private JPanel jPanelType4 = null;
+
+ private JLabel jLabelSetVirtualAddressMapCallBack = null;
+
+ private IComboBox iComboBoxSetVirtualAddressMapCallBack = null;
+
+ private JLabel jLabelExitBootServicesCallBack = null;
+
+ private IComboBox iComboBoxExitBootServicesCallBack = null;
+
+ private JPanel jPanelType5 = null;
+
+ private JLabel jLabelUserDefined = null;
+
+ private IComboBox iComboBoxUserDefined = null;
+
+ /**
+ This method initializes jComboBoxUsage
+
+ @return javax.swing.JComboBox jComboBoxUsage
+
+ **/
+ private JComboBox getJComboBoxUsage() {
+ if (jComboBoxUsage == null) {
+ jComboBoxUsage = new JComboBox();
+ jComboBoxUsage.setBounds(new java.awt.Rectangle(160, 35, 320, 20));
+ }
+ return jComboBoxUsage;
+ }
+
+ /**
+ This method initializes jButtonOk
+
+ @return javax.swing.JButton jButtonOk
+
+ **/
+ private JButton getJButtonOk() {
+ if (jButtonOk == null) {
+ jButtonOk = new JButton();
+ jButtonOk.setText("OK");
+ jButtonOk.setLocation(new java.awt.Point(290, 215));
+ jButtonOk.setSize(new java.awt.Dimension(90, 20));
+ jButtonOk.addActionListener(this);
+ }
+ return jButtonOk;
+ }
+
+ /**
+ This method initializes jButtonCancel
+
+ @return javax.swing.JButton jButtonCancel
+
+ **/
+ private JButton getJButtonCancel() {
+ if (jButtonCancel == null) {
+ jButtonCancel = new JButton();
+ jButtonCancel.setText("Cancel");
+ jButtonCancel.setLocation(new java.awt.Point(390, 215));
+ jButtonCancel.setSize(new java.awt.Dimension(90, 20));
+ jButtonCancel.addActionListener(this);
+ }
+ return jButtonCancel;
+ }
+
+ /**
+ This method initializes jTextFieldOverrideID
+
+ @return javax.swing.JTextField jTextFieldOverrideID
+
+ **/
+ private JTextField getJTextFieldOverrideID() {
+ if (jTextFieldOverrideID == null) {
+ jTextFieldOverrideID = new JTextField();
+ jTextFieldOverrideID.setBounds(new java.awt.Rectangle(160, 60, 320, 20));
+ }
+ return jTextFieldOverrideID;
+ }
+
+ /**
+ This method initializes jPanelType1
+
+ @return javax.swing.JPanel jPanelType1
+
+ **/
+ private JPanel getJPanelType1() {
+ if (jPanelType1 == null) {
+ jLabelModuleUnloadImage = new JLabel();
+ jLabelModuleUnloadImage.setBounds(new java.awt.Rectangle(15, 30, 140, 20));
+ jLabelModuleUnloadImage.setText("Module Unload Image");
+ jLabelModuleEntryPoint = new JLabel();
+ jLabelModuleEntryPoint.setBounds(new java.awt.Rectangle(15, 5, 140, 20));
+ jLabelModuleEntryPoint.setText("Module Entry Point");
+ jPanelType1 = new JPanel();
+ jPanelType1.setLayout(null);
+ jPanelType1.setBounds(new java.awt.Rectangle(0, 105, 490, 55));
+ jPanelType1.add(jLabelModuleEntryPoint, null);
+ jPanelType1.add(jLabelModuleUnloadImage, null);
+ jPanelType1.add(getIComboBoxModuleUnloadImage(), null);
+ jPanelType1.add(getIComboBoxModuleEntryPoint(), null);
+ }
+ return jPanelType1;
+ }
+
+ /**
+ This method initializes jComboBoxModuleEntryPoint
+
+ @return javax.swing.JComboBox iComboBoxModuleEntryPoint
+
+ **/
+ private IComboBox getIComboBoxModuleEntryPoint() {
+ if (iComboBoxModuleEntryPoint == null) {
+ iComboBoxModuleEntryPoint = new IComboBox();
+ iComboBoxModuleEntryPoint.setBounds(new java.awt.Rectangle(160, 5, 320, 20));
+ }
+ return iComboBoxModuleEntryPoint;
+ }
+
+ /**
+ This method initializes jComboBoxModuleUnloadImage
+
+ @return javax.swing.JComboBox iComboBoxModuleUnloadImage
+
+ **/
+ private IComboBox getIComboBoxModuleUnloadImage() {
+ if (iComboBoxModuleUnloadImage == null) {
+ iComboBoxModuleUnloadImage = new IComboBox();
+ iComboBoxModuleUnloadImage.setBounds(new java.awt.Rectangle(160, 30, 320, 20));
+ }
+ return iComboBoxModuleUnloadImage;
+ }
+
+ /**
+ This method initializes jPanelType2
+
+ @return javax.swing.JPanel jPanelType2
+
+ **/
+ private JPanel getJPanelType2() {
+ if (jPanelType2 == null) {
+ jLabelDestructor = new JLabel();
+ jLabelDestructor.setBounds(new java.awt.Rectangle(15, 30, 140, 20));
+ jLabelDestructor.setText("Destructor");
+ jLabelConstructor = new JLabel();
+ jLabelConstructor.setBounds(new java.awt.Rectangle(15, 5, 140, 20));
+ jLabelConstructor.setText("Constructor");
+ jPanelType2 = new JPanel();
+ jPanelType2.setLayout(null);
+ jPanelType2.setBounds(new java.awt.Rectangle(0, 105, 490, 55));
+ jPanelType2.add(jLabelConstructor, null);
+ jPanelType2.add(getJTextFieldConstructor(), null);
+ jPanelType2.add(jLabelDestructor, null);
+ jPanelType2.add(getJTextFieldDestructor(), null);
+ }
+ return jPanelType2;
+ }
+
+ /**
+ This method initializes jTextFieldConstructor
+
+ @return javax.swing.JTextField jTextFieldConstructor
+
+ **/
+ private JTextField getJTextFieldConstructor() {
+ if (jTextFieldConstructor == null) {
+ jTextFieldConstructor = new JTextField();
+ jTextFieldConstructor.setBounds(new java.awt.Rectangle(160, 5, 320, 20));
+ }
+ return jTextFieldConstructor;
+ }
+
+ /**
+ This method initializes jTextFieldDestructor
+
+ @return javax.swing.JTextField jTextFieldDestructor
+
+ **/
+ private JTextField getJTextFieldDestructor() {
+ if (jTextFieldDestructor == null) {
+ jTextFieldDestructor = new JTextField();
+ jTextFieldDestructor.setBounds(new java.awt.Rectangle(160, 30, 320, 20));
+ }
+ return jTextFieldDestructor;
+ }
+
+ /**
+ This method initializes jComboBoxType
+
+ @return javax.swing.JComboBox jComboBoxType
+
+ **/
+ private JComboBox getJComboBoxType() {
+ if (jComboBoxType == null) {
+ jComboBoxType = new JComboBox();
+ jComboBoxType.setBounds(new java.awt.Rectangle(160, 10, 320, 20));
+ jComboBoxType.addItemListener(this);
+ }
+ return jComboBoxType;
+ }
+
+ /**
+ This method initializes jPanelType3
+
+ @return javax.swing.JPanel jPanelType3
+
+ **/
+ private JPanel getJPanelType3() {
+ if (jPanelType3 == null) {
+ jLabelDriverDiag = new JLabel();
+ jLabelDriverDiag.setBounds(new java.awt.Rectangle(15, 80, 140, 20));
+ jLabelDriverDiag.setText("Driver Diag");
+ jLabelDriverConfig = new JLabel();
+ jLabelDriverConfig.setBounds(new java.awt.Rectangle(15, 55, 140, 20));
+ jLabelDriverConfig.setText("Driver Config");
+ jLabelComponentName = new JLabel();
+ jLabelComponentName.setBounds(new java.awt.Rectangle(15, 30, 140, 20));
+ jLabelComponentName.setText("Component Name");
+ jLabelDriverBinding = new JLabel();
+ jLabelDriverBinding.setBounds(new java.awt.Rectangle(15, 5, 140, 20));
+ jLabelDriverBinding.setText("Driver Binding");
+ jPanelType3 = new JPanel();
+ jPanelType3.setLayout(null);
+ jPanelType3.setBounds(new java.awt.Rectangle(0, 105, 490, 105));
+ jPanelType3.add(jLabelDriverBinding, null);
+ jPanelType3.add(jLabelComponentName, null);
+ jPanelType3.add(getIComboBoxComponentName(), null);
+ jPanelType3.add(getIComboBoxDriverBinding(), null);
+ jPanelType3.add(jLabelDriverConfig, null);
+ jPanelType3.add(jLabelDriverDiag, null);
+ jPanelType3.add(getIComboBoxDriverDiag(), null);
+ jPanelType3.add(getIComboBoxDriverConfig(), null);
+ }
+ return jPanelType3;
+ }
+
+ /**
+ This method initializes jComboBoxComponentName
+
+ @return javax.swing.JComboBox iComboBoxComponentName
+
+ **/
+ private IComboBox getIComboBoxComponentName() {
+ if (iComboBoxComponentName == null) {
+ iComboBoxComponentName = new IComboBox();
+ iComboBoxComponentName.setBounds(new java.awt.Rectangle(160, 30, 320, 20));
+ }
+ return iComboBoxComponentName;
+ }
+
+ /**
+ This method initializes jComboBoxDriverBinding
+
+ @return javax.swing.JComboBox iComboBoxDriverBinding
+
+ **/
+ private IComboBox getIComboBoxDriverBinding() {
+ if (iComboBoxDriverBinding == null) {
+ iComboBoxDriverBinding = new IComboBox();
+ iComboBoxDriverBinding.setBounds(new java.awt.Rectangle(160, 5, 320, 20));
+ }
+ return iComboBoxDriverBinding;
+ }
+
+ /**
+ This method initializes jComboBoxDriverDiag
+
+ @return javax.swing.JComboBox iComboBoxDriverDiag
+
+ **/
+ private IComboBox getIComboBoxDriverDiag() {
+ if (iComboBoxDriverDiag == null) {
+ iComboBoxDriverDiag = new IComboBox();
+ iComboBoxDriverDiag.setBounds(new java.awt.Rectangle(160, 80, 320, 20));
+ }
+ return iComboBoxDriverDiag;
+ }
+
+ /**
+ This method initializes jComboBoxDriverConfig
+
+ @return javax.swing.JComboBox iComboBoxDriverConfig
+
+ */
+ private IComboBox getIComboBoxDriverConfig() {
+ if (iComboBoxDriverConfig == null) {
+ iComboBoxDriverConfig = new IComboBox();
+ iComboBoxDriverConfig.setBounds(new java.awt.Rectangle(160, 55, 320, 20));
+ }
+ return iComboBoxDriverConfig;
+ }
+
+ /**
+ This method initializes jPanelType4
+
+ @return javax.swing.JPanel jPanelType4
+
+ **/
+ private JPanel getJPanelType4() {
+ if (jPanelType4 == null) {
+ jLabelExitBootServicesCallBack = new JLabel();
+ jLabelExitBootServicesCallBack.setBounds(new java.awt.Rectangle(15, 30, 200, 20));
+ jLabelExitBootServicesCallBack.setText("Exit Boot Services Call Back");
+ jLabelSetVirtualAddressMapCallBack = new JLabel();
+ jLabelSetVirtualAddressMapCallBack.setBounds(new java.awt.Rectangle(15, 5, 200, 20));
+ jLabelSetVirtualAddressMapCallBack.setText("Set Virtual Address Map Call Back");
+ jPanelType4 = new JPanel();
+ jPanelType4.setLayout(null);
+ jPanelType4.setBounds(new java.awt.Rectangle(0, 105, 490, 55));
+ jPanelType4.add(jLabelSetVirtualAddressMapCallBack, null);
+ jPanelType4.add(getIComboBoxSetVirtualAddressMapCallBack(), null);
+ jPanelType4.add(jLabelExitBootServicesCallBack, null);
+ jPanelType4.add(getIComboBoxExitBootServicesCallBack(), null);
+ }
+ return jPanelType4;
+ }
+
+ /**
+ This method initializes jComboBoxSetVirtualAddressMapCallBack
+
+ @return javax.swing.JComboBox iComboBoxSetVirtualAddressMapCallBack
+
+ **/
+ private IComboBox getIComboBoxSetVirtualAddressMapCallBack() {
+ if (iComboBoxSetVirtualAddressMapCallBack == null) {
+ iComboBoxSetVirtualAddressMapCallBack = new IComboBox();
+ iComboBoxSetVirtualAddressMapCallBack.setBounds(new java.awt.Rectangle(220, 5, 260, 20));
+ }
+ return iComboBoxSetVirtualAddressMapCallBack;
+ }
+
+ /**
+ This method initializes jComboBoxExitBootServicesCallBack
+
+ @return javax.swing.JComboBox iComboBoxExitBootServicesCallBack
+
+ **/
+ private IComboBox getIComboBoxExitBootServicesCallBack() {
+ if (iComboBoxExitBootServicesCallBack == null) {
+ iComboBoxExitBootServicesCallBack = new IComboBox();
+ iComboBoxExitBootServicesCallBack.setBounds(new java.awt.Rectangle(220, 30, 260, 20));
+ }
+ return iComboBoxExitBootServicesCallBack;
+ }
+
+ /**
+ This method initializes jPanelType5
+
+ @return javax.swing.JPanel jPanelType5
+
+ **/
+ private JPanel getJPanelType5() {
+ if (jPanelType5 == null) {
+ jLabelUserDefined = new JLabel();
+ jLabelUserDefined.setBounds(new java.awt.Rectangle(15, 5, 140, 20));
+ jLabelUserDefined.setText("User Defined");
+ jPanelType5 = new JPanel();
+ jPanelType5.setLayout(null);
+ jPanelType5.setBounds(new java.awt.Rectangle(0, 105, 490, 30));
+ jPanelType5.add(jLabelUserDefined, null);
+ jPanelType5.add(getIComboBoxUserDefined(), null);
+ }
+ return jPanelType5;
+ }
+
+ /**
+ This method initializes jComboBoxUserDefined
+
+ @return javax.swing.JComboBox iComboBoxUserDefined
+
+ **/
+ private IComboBox getIComboBoxUserDefined() {
+ if (iComboBoxUserDefined == null) {
+ iComboBoxUserDefined = new IComboBox();
+ iComboBoxUserDefined.setBounds(new java.awt.Rectangle(160, 5, 320, 20));
+ }
+ return iComboBoxUserDefined;
+ }
+
+ public static void main(String[] args) {
+
+ }
+
+ /**
+ This is the default constructor
+
+ **/
+ public ModuleExterns() {
+ super();
+ init();
+ this.setVisible(true);
+ }
+
+ /**
+ This is the override edit constructor
+
+ @param inExterns The input data of ExternsDocument.Externs
+
+ **/
+ public ModuleExterns(ExternsDocument.Externs inExterns) {
+ super();
+ init(inExterns);
+ this.setVisible(true);
+ }
+
+ /**
+ This is the override edit constructor
+
+ @param inExterns The input data of ExternsDocument.Externs
+ @param type The input data of node type
+ @param index The input data of node index
+
+ **/
+ public ModuleExterns(ExternsDocument.Externs inExterns, int type, int index) {
+ super();
+ init(inExterns, type, index);
+ this.setVisible(true);
+ }
+
+ /**
+ This method initializes this
+
+ @param inExterns The input data of ExternsDocument.Externs
+
+ **/
+ private void init(ExternsDocument.Externs inExterns) {
+ init();
+ this.setExterns(inExterns);
+ }
+
+ /**
+ This method initializes this
+ Fill values to all fields if these values are not empty
+
+ @param inExterns The input data of ExternsDocument.Externs
+ @param type The input data of node type
+ @param index The input data of node index
+
+ **/
+ private void init(ExternsDocument.Externs inExterns, int type, int index) {
+ init(inExterns);
+ this.location = index;
+ if (this.externs.getExternList().size() > 0) {
+ //
+ //Get common fields
+ //
+ if (this.externs.getExternArray(index).getUsage() != null) {
+ this.jComboBoxUsage.setSelectedItem(this.externs.getExternArray(index).getUsage().toString());
+ }
+ this.jTextFieldOverrideID.setText(String.valueOf(this.externs.getExternArray(index).getOverrideID()));
+ //
+ //Type 1
+ //
+ if (this.externs.getExternArray(index).getModuleEntryPointList().size() > 0) {
+ this.jComboBoxType.setSelectedIndex(0);
+ for (int indexI = 0; indexI < this.externs.getExternArray(index).getModuleEntryPointList().size(); indexI++) {
+ this.iComboBoxModuleEntryPoint.addItem(this.externs.getExternArray(index)
+ .getModuleEntryPointArray(indexI));
+ }
+ }
+ if (this.externs.getExternArray(index).getModuleUnloadImageList().size() > 0) {
+ this.jComboBoxType.setSelectedIndex(0);
+ for (int indexI = 0; indexI < this.externs.getExternArray(index).getModuleUnloadImageList().size(); indexI++) {
+ this.iComboBoxModuleUnloadImage.addItem(this.externs.getExternArray(index)
+ .getModuleUnloadImageArray(indexI));
+ }
+ }
+
+ //
+ //Type 2
+ //
+ if (this.externs.getExternArray(index).getConstructor() != null) {
+ this.jComboBoxType.setSelectedIndex(1);
+ this.jTextFieldConstructor.setText(this.externs.getExternArray(index).getConstructor());
+ }
+ if (this.externs.getExternArray(index).getDestructor() != null) {
+ this.jComboBoxType.setSelectedIndex(1);
+ this.jTextFieldDestructor.setText(this.externs.getExternArray(index).getDestructor());
+ }
+
+ //
+ //Type 3
+ //
+ if (this.externs.getExternArray(index).getDriverBindingList().size() > 0) {
+ this.jComboBoxType.setSelectedIndex(2);
+ for (int indexI = 0; indexI < this.externs.getExternArray(index).getDriverBindingList().size(); indexI++) {
+ this.iComboBoxDriverBinding.addItem(this.externs.getExternArray(index)
+ .getDriverBindingArray(indexI));
+ }
+ }
+ if (this.externs.getExternArray(index).getComponentNameList().size() > 0) {
+ this.jComboBoxType.setSelectedIndex(2);
+ for (int indexI = 0; indexI < this.externs.getExternArray(index).getComponentNameList().size(); indexI++) {
+ this.iComboBoxComponentName.addItem(this.externs.getExternArray(index)
+ .getComponentNameArray(indexI));
+ }
+ }
+ if (this.externs.getExternArray(index).getDriverConfigList().size() > 0) {
+ this.jComboBoxType.setSelectedIndex(2);
+ for (int indexI = 0; indexI < this.externs.getExternArray(index).getDriverConfigList().size(); indexI++) {
+ this.iComboBoxDriverConfig.addItem(this.externs.getExternArray(index).getDriverConfigArray(indexI));
+ }
+ }
+ if (this.externs.getExternArray(index).getDriverDiagList().size() > 0) {
+ this.jComboBoxType.setSelectedIndex(2);
+ for (int indexI = 0; indexI < this.externs.getExternArray(index).getDriverDiagList().size(); indexI++) {
+ this.iComboBoxDriverDiag.addItem(this.externs.getExternArray(index).getDriverDiagArray(indexI));
+ }
+ }
+
+ //
+ //Type 4
+ //
+ if (this.externs.getExternArray(index).getSetVirtualAddressMapCallBackList().size() > 0) {
+ this.jComboBoxType.setSelectedIndex(3);
+ for (int indexI = 0; indexI < this.externs.getExternArray(index).getSetVirtualAddressMapCallBackList()
+ .size(); indexI++) {
+ this.iComboBoxSetVirtualAddressMapCallBack
+ .addItem(this.externs
+ .getExternArray(index)
+ .getSetVirtualAddressMapCallBackArray(
+ indexI));
+ }
+ }
+ if (this.externs.getExternArray(index).getExitBootServicesCallBackList().size() > 0) {
+ this.jComboBoxType.setSelectedIndex(3);
+ for (int indexI = 0; indexI < this.externs.getExternArray(index).getExitBootServicesCallBackList()
+ .size(); indexI++) {
+ this.iComboBoxExitBootServicesCallBack
+ .addItem(this.externs
+ .getExternArray(index)
+ .getExitBootServicesCallBackArray(indexI));
+ }
+ }
+
+ //
+ //Type 5
+ //
+ if (this.externs.getExternArray(index).getUserDefinedList().size() > 0) {
+ this.jComboBoxType.setSelectedIndex(4);
+ for (int indexI = 0; indexI < this.externs.getExternArray(index).getUserDefinedList().size(); indexI++) {
+ this.iComboBoxUserDefined.addItem(this.externs.getExternArray(index).getUserDefinedArray(indexI));
+ }
+ }
+
+ this.jComboBoxType.setEnabled(false);
+ switchType();
+ }
+ }
+
+ /**
+ This method initializes this
+
+ **/
+ private void init() {
+ this.setSize(500, 515);
+ this.setContentPane(getJContentPane());
+ this.setTitle("Externs");
+ initFrame();
+ this.setViewMode(false);
+ }
+
+ /**
+ Disable all components when the mode is view
+
+ @param isView true - The view mode; false - The non-view mode
+
+ **/
+ public void setViewMode(boolean isView) {
+ this.jButtonOk.setVisible(false);
+ this.jButtonCancel.setVisible(false);
+ if (isView) {
+ this.jComboBoxUsage.setEnabled(!isView);
+ this.jTextFieldOverrideID.setEnabled(!isView);
+ //
+ //Type 1
+ //
+ this.iComboBoxModuleEntryPoint.setEnabled(!isView);
+ this.iComboBoxModuleUnloadImage.setEnabled(!isView);
+
+ //
+ //Type 2
+ //
+ this.jTextFieldConstructor.setEnabled(!isView);
+ this.jTextFieldDestructor.setEnabled(!isView);
+
+ //
+ //Type 3
+ //
+ this.iComboBoxDriverBinding.setEnabled(!isView);
+ this.iComboBoxComponentName.setEnabled(!isView);
+ this.iComboBoxDriverConfig.setEnabled(!isView);
+ this.iComboBoxDriverDiag.setEnabled(!isView);
+
+ //
+ //Type 4
+ //
+ this.iComboBoxSetVirtualAddressMapCallBack.setEnabled(!isView);
+ this.iComboBoxExitBootServicesCallBack.setEnabled(!isView);
+
+ //
+ //Type 5
+ //
+ this.iComboBoxUserDefined.setEnabled(!isView);
+
+ this.jComboBoxType.setEnabled(!isView);
+ this.jButtonCancel.setEnabled(!isView);
+ this.jButtonOk.setEnabled(!isView);
+ }
+ }
+
+ /**
+ This method initializes jContentPane
+
+ @return javax.swing.JPanel jContentPane
+
+ **/
+ private JPanel getJContentPane() {
+ if (jContentPane == null) {
+ jLabelOverrideID = new JLabel();
+ jLabelOverrideID.setBounds(new java.awt.Rectangle(15, 60, 140, 20));
+ jLabelOverrideID.setText("Override ID");
+ jLabelUsage = new JLabel();
+ jLabelUsage.setText("Usage");
+ jLabelUsage.setBounds(new java.awt.Rectangle(15, 35, 140, 20));
+ jLabelName = new JLabel();
+ jLabelName.setText("Choose Type");
+ jLabelName.setBounds(new java.awt.Rectangle(15, 10, 140, 20));
+ jContentPane = new JPanel();
+ jContentPane.setLayout(null);
+ jContentPane.setSize(new java.awt.Dimension(490, 244));
+ jContentPane.add(getJPanelType2(), null);
+ jContentPane.add(jLabelName, null);
+ jContentPane.add(getJComboBoxType(), null);
+ jContentPane.add(getJPanelType3(), null);
+ jContentPane.add(getJPanelType4(), null);
+ jContentPane.add(getJPanelType5(), null);
+ jContentPane.add(jLabelUsage, null);
+ jContentPane.add(getJComboBoxUsage(), null);
+ jContentPane.add(getJButtonOk(), null);
+ jContentPane.add(getJButtonCancel(), null);
+ jContentPane.add(jLabelOverrideID, null);
+ jContentPane.add(getJTextFieldOverrideID(), null);
+
+ jContentPane.add(getJPanelType1(), null);
+ }
+ return jContentPane;
+ }
+
+ /**
+ This method initializes Usage type and Externs type
+
+ **/
+ private void initFrame() {
+ jComboBoxUsage.addItem("ALWAYS_CONSUMED");
+ jComboBoxUsage.addItem("ALWAYS_PRODUCED");
+
+ jComboBoxType.addItem("Type 1");
+ jComboBoxType.addItem("Type 2");
+ jComboBoxType.addItem("Type 3");
+ jComboBoxType.addItem("Type 4");
+ jComboBoxType.addItem("Type 5");
+
+ jPanelType1.setVisible(true);
+ jPanelType2.setVisible(false);
+ jPanelType3.setVisible(false);
+ jPanelType4.setVisible(false);
+ jPanelType5.setVisible(false);
+ }
+
+ /* (non-Javadoc)
+ * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
+ *
+ * Override actionPerformed to listen all actions
+ *
+ */
+ public void actionPerformed(ActionEvent arg0) {
+ if (arg0.getSource() == jButtonOk) {
+ this.setEdited(true);
+ this.save();
+ this.dispose();
+ }
+
+ if (arg0.getSource() == jButtonCancel) {
+ this.dispose();
+ }
+ }
+
+ public void itemStateChanged(ItemEvent arg0) {
+ if (arg0.getSource() == jComboBoxType) {
+ if (arg0.getStateChange() == ItemEvent.SELECTED) {
+ switchType();
+ }
+ }
+ }
+
+ /**
+ Show/Hide relevant fields via select different types
+
+ **/
+ private void switchType() {
+ if (jComboBoxType.getSelectedIndex() == 0) {
+ jPanelType1.setVisible(true);
+ jPanelType2.setVisible(false);
+ jPanelType3.setVisible(false);
+ jPanelType4.setVisible(false);
+ jPanelType5.setVisible(false);
+ }
+ if (jComboBoxType.getSelectedIndex() == 1) {
+ jPanelType1.setVisible(false);
+ jPanelType2.setVisible(true);
+ jPanelType3.setVisible(false);
+ jPanelType4.setVisible(false);
+ jPanelType5.setVisible(false);
+ }
+ if (jComboBoxType.getSelectedIndex() == 2) {
+ jPanelType1.setVisible(false);
+ jPanelType2.setVisible(false);
+ jPanelType3.setVisible(true);
+ jPanelType4.setVisible(false);
+ jPanelType5.setVisible(false);
+ }
+ if (jComboBoxType.getSelectedIndex() == 3) {
+ jPanelType1.setVisible(false);
+ jPanelType2.setVisible(false);
+ jPanelType3.setVisible(false);
+ jPanelType4.setVisible(true);
+ jPanelType5.setVisible(false);
+ }
+ if (jComboBoxType.getSelectedIndex() == 4) {
+ jPanelType1.setVisible(false);
+ jPanelType2.setVisible(false);
+ jPanelType3.setVisible(false);
+ jPanelType4.setVisible(false);
+ jPanelType5.setVisible(true);
+ }
+ }
+
+ /**
+ Set ExternsDocument.Externs
+
+ @return ExternsDocument.Externs
+
+
+ **/
+ public ExternsDocument.Externs getExterns() {
+ return externs;
+ }
+
+ /**
+ Get ExternsDocument.Externs
+
+ @param externs The input ExternsDocument.Externs
+
+ **/
+ public void setExterns(ExternsDocument.Externs externs) {
+ this.externs = externs;
+ }
+
+ /**
+ Data validation for all fields
+
+ @retval true - All datas are valid
+ @retval false - At least one data is invalid
+
+ **/
+ public boolean check() {
+ //
+ // Check if all fields have correct data types
+ //
+ if (this.jComboBoxType.getSelectedIndex() == 1) {
+ if (!isEmpty(this.jTextFieldConstructor.getText())
+ && !DataValidation.isConstructor(this.jTextFieldConstructor.getText())) {
+ Log.err("Incorrect data type for Constructor");
+ return false;
+ }
+ if (!isEmpty(this.jTextFieldDestructor.getText())
+ && !DataValidation.isDestructor(this.jTextFieldDestructor.getText())) {
+ Log.err("Incorrect data type for Destructor");
+ return false;
+ }
+ }
+
+ if (!isEmpty(this.jTextFieldOverrideID.getText())
+ && !DataValidation.isOverrideID(this.jTextFieldOverrideID.getText())) {
+ Log.err("Incorrect data type for Override ID");
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ Save all components of Externs
+ if exists externs, set the value directly
+ if not exists externs, new an instance first
+
+ **/
+ public void save() {
+ try {
+ if (this.externs == null) {
+ externs = ExternsDocument.Externs.Factory.newInstance();
+ }
+ ExternsDocument.Externs.Extern extern = ExternsDocument.Externs.Extern.Factory.newInstance();
+ //
+ //Save common fields
+ //
+ extern.setUsage(ExternUsage.Enum.forString(jComboBoxUsage.getSelectedItem().toString()));
+ if (!isEmpty(this.jTextFieldOverrideID.getText())) {
+ extern.setOverrideID(Integer.parseInt(this.jTextFieldOverrideID.getText()));
+ }
+
+ //
+ //Save type 1
+ //
+ if (this.jComboBoxType.getSelectedIndex() == 0) {
+ if (this.iComboBoxModuleEntryPoint.getItemCount() > 0) {
+ for (int index = 0; index < this.iComboBoxModuleEntryPoint.getItemCount(); index++) {
+ extern.addNewModuleEntryPoint();
+ extern.setModuleEntryPointArray(index, this.iComboBoxModuleEntryPoint.getItemAt(index)
+ .toString());
+ }
+ }
+ if (this.iComboBoxModuleEntryPoint.getItemCount() > 0) {
+ for (int index = 0; index < this.iComboBoxModuleUnloadImage.getItemCount(); index++) {
+ extern.addNewModuleUnloadImage();
+ extern.setModuleUnloadImageArray(index, this.iComboBoxModuleUnloadImage.getItemAt(index)
+ .toString());
+ }
+ }
+ }
+
+ //
+ //Save type 2
+ //
+ if (this.jComboBoxType.getSelectedIndex() == 1) {
+ if (!isEmpty(this.jTextFieldConstructor.getText())) {
+ extern.setConstructor(this.jTextFieldConstructor.getText());
+ }
+ if (!isEmpty(this.jTextFieldDestructor.getText())) {
+ extern.setDestructor(this.jTextFieldDestructor.getText());
+ }
+ }
+
+ //
+ //Save type 3
+ //
+ if (this.jComboBoxType.getSelectedIndex() == 2) {
+ if (this.iComboBoxDriverBinding.getItemCount() > 0) {
+ for (int index = 0; index < this.iComboBoxDriverBinding.getItemCount(); index++) {
+ extern.addNewDriverBinding();
+ extern.setDriverBindingArray(index, this.iComboBoxDriverBinding.getItemAt(index).toString());
+ }
+ }
+ if (this.iComboBoxComponentName.getItemCount() > 0) {
+ for (int index = 0; index < this.iComboBoxComponentName.getItemCount(); index++) {
+ extern.addNewComponentName();
+ extern.setComponentNameArray(index, this.iComboBoxComponentName.getItemAt(index).toString());
+ }
+ }
+ if (this.iComboBoxDriverConfig.getItemCount() > 0) {
+ for (int index = 0; index < this.iComboBoxDriverConfig.getItemCount(); index++) {
+ extern.addNewDriverConfig();
+ extern.setDriverConfigArray(index, this.iComboBoxDriverConfig.getItemAt(index).toString());
+ }
+ }
+ if (this.iComboBoxDriverDiag.getItemCount() > 0) {
+ for (int index = 0; index < this.iComboBoxDriverDiag.getItemCount(); index++) {
+ extern.addNewDriverDiag();
+ extern.setDriverDiagArray(index, this.iComboBoxDriverDiag.getItemAt(index).toString());
+ }
+ }
+ }
+
+ //
+ //Save type 4
+ //
+ if (this.jComboBoxType.getSelectedIndex() == 3) {
+ if (this.iComboBoxSetVirtualAddressMapCallBack.getItemCount() > 0) {
+ for (int index = 0; index < this.iComboBoxSetVirtualAddressMapCallBack.getItemCount(); index++) {
+ extern.addNewSetVirtualAddressMapCallBack();
+ extern
+ .setSetVirtualAddressMapCallBackArray(
+ index,
+ this.iComboBoxSetVirtualAddressMapCallBack
+ .getItemAt(
+ index)
+ .toString());
+ }
+ }
+ if (this.iComboBoxExitBootServicesCallBack.getItemCount() > 0) {
+ for (int index = 0; index < this.iComboBoxExitBootServicesCallBack.getItemCount(); index++) {
+ extern.addNewExitBootServicesCallBack();
+ extern.setExitBootServicesCallBackArray(index,
+ this.iComboBoxExitBootServicesCallBack.getItemAt(index)
+ .toString());
+ }
+ }
+ }
+ //
+ //Save type 5
+ //
+ if (this.jComboBoxType.getSelectedIndex() == 4) {
+ if (this.iComboBoxUserDefined.getItemCount() > 0) {
+ for (int index = 0; index < this.iComboBoxUserDefined.getItemCount(); index++) {
+ extern.addNewUserDefined();
+ extern.setUserDefinedArray(index, this.iComboBoxUserDefined.getItemAt(index).toString());
+ }
+ }
+ }
+
+ if (location > -1) {
+ externs.setExternArray(location, extern);
+ } else {
+ externs.addNewExtern();
+ externs.setExternArray(externs.getExternList().size() - 1, extern);
+ }
+ } catch (Exception e) {
+ Log.err("Update Externs", e.getMessage());
+ }
+ }
+}
diff --git a/Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/ModuleFormsets.java b/Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/ModuleFormsets.java
new file mode 100644
index 0000000000..f725379ca8
--- /dev/null
+++ b/Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/ModuleFormsets.java
@@ -0,0 +1,457 @@
+/** @file
+
+ The file is used to create, update Formset of MSA/MBD file
+
+ Copyright (c) 2006, Intel Corporation
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+ **/
+package org.tianocore.packaging.module.ui;
+
+import java.awt.event.ActionEvent;
+
+import javax.swing.JButton;
+import javax.swing.JComboBox;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JTextField;
+
+import org.tianocore.FormSetUsage;
+import org.tianocore.FormsetsDocument;
+import org.tianocore.common.DataValidation;
+import org.tianocore.common.Log;
+import org.tianocore.common.Tools;
+import org.tianocore.packaging.common.ui.IInternalFrame;
+import org.tianocore.packaging.common.ui.StarLabel;
+
+/**
+ The class is used to create, update Formset of MSA/MBD file
+ It extends IInternalFrame
+
+ @since ModuleEditor 1.0
+
+ **/
+public class ModuleFormsets extends IInternalFrame {
+
+ ///
+ /// Define class Serial Version UID
+ ///
+ private static final long serialVersionUID = -6851574146786158116L;
+
+ //
+ //Define class members
+ //
+ private FormsetsDocument.Formsets formsets = null;
+
+ private int location = -1;
+
+ private JPanel jContentPane = null;
+
+ private JLabel jLabelName = null;
+
+ private JTextField jTextFieldName = null;
+
+ private JLabel jLabelGuid = null;
+
+ private JTextField jTextFieldGuid = null;
+
+ private JLabel jLabelUsage = null;
+
+ private JButton jButtonOk = null;
+
+ private JButton jButtonCancel = null;
+
+ private JComboBox jComboBoxUsage = null;
+
+ private JButton jButtonGenerateGuid = null;
+
+ private JLabel jLabelOverrideID = null;
+
+ private JTextField jTextFieldOverrideID = null;
+
+ private StarLabel jStarLabel1 = null;
+
+ /**
+ This method initializes jTextFieldName
+
+ @return javax.swing.JTextField jTextFieldName
+
+ **/
+ private JTextField getJTextFieldName() {
+ if (jTextFieldName == null) {
+ jTextFieldName = new JTextField();
+ jTextFieldName.setBounds(new java.awt.Rectangle(160, 10, 320, 20));
+ }
+ return jTextFieldName;
+ }
+
+ /**
+ This method initializes jTextFieldGuid
+
+ @return javax.swing.JTextField jTextFieldGuid
+
+ **/
+ private JTextField getJTextFieldGuid() {
+ if (jTextFieldGuid == null) {
+ jTextFieldGuid = new JTextField();
+ jTextFieldGuid.setBounds(new java.awt.Rectangle(160, 35, 240, 20));
+ }
+ return jTextFieldGuid;
+ }
+
+ /**
+ This method initializes jButtonOk
+
+ @return javax.swing.JButton jButtonOk
+
+ **/
+ private JButton getJButtonOk() {
+ if (jButtonOk == null) {
+ jButtonOk = new JButton();
+ jButtonOk.setText("OK");
+ jButtonOk.setBounds(new java.awt.Rectangle(280, 115, 90, 20));
+ jButtonOk.addActionListener(this);
+ }
+ return jButtonOk;
+ }
+
+ /**
+ This method initializes jButtonCancel
+
+ @return javax.swing.JButton jButtonCancel
+
+ **/
+ private JButton getJButtonCancel() {
+ if (jButtonCancel == null) {
+ jButtonCancel = new JButton();
+ jButtonCancel.setText("Cancel");
+ jButtonCancel.setBounds(new java.awt.Rectangle(390, 115, 90, 20));
+ jButtonCancel.addActionListener(this);
+ }
+ return jButtonCancel;
+ }
+
+ /**
+ This method initializes jComboBoxUsage
+
+ @return javax.swing.JComboBox jComboBoxUsage
+
+ **/
+ private JComboBox getJComboBoxUsage() {
+ if (jComboBoxUsage == null) {
+ jComboBoxUsage = new JComboBox();
+ jComboBoxUsage.setBounds(new java.awt.Rectangle(160, 60, 320, 20));
+ }
+ return jComboBoxUsage;
+ }
+
+ /**
+ This method initializes jButtonGenerateGuid
+
+ @return javax.swing.JButton jButtonGenerateGuid
+
+ **/
+ private JButton getJButtonGenerateGuid() {
+ if (jButtonGenerateGuid == null) {
+ jButtonGenerateGuid = new JButton();
+ jButtonGenerateGuid.setBounds(new java.awt.Rectangle(405, 35, 75, 20));
+ jButtonGenerateGuid.setText("GEN");
+ jButtonGenerateGuid.addActionListener(this);
+ }
+ return jButtonGenerateGuid;
+ }
+
+ /**
+ This method initializes jTextFieldOverrideID
+
+ @return javax.swing.JTextField jTextFieldOverrideID
+
+ **/
+ private JTextField getJTextFieldOverrideID() {
+ if (jTextFieldOverrideID == null) {
+ jTextFieldOverrideID = new JTextField();
+ jTextFieldOverrideID.setBounds(new java.awt.Rectangle(160, 85, 320, 20));
+ }
+ return jTextFieldOverrideID;
+ }
+
+ public static void main(String[] args) {
+
+ }
+
+ /**
+ This is the default constructor
+
+ **/
+ public ModuleFormsets() {
+ super();
+ init();
+ this.setVisible(true);
+ }
+
+ /**
+ *
+ */
+ /**
+ This is the override edit constructor
+
+ @param inFormsets The input data of FormsetsDocument.Formsets
+
+ **/
+ public ModuleFormsets(FormsetsDocument.Formsets inFormsets) {
+ super();
+ init(inFormsets);
+ this.setVisible(true);
+ }
+
+ /**
+ This is the override edit constructor
+
+ @param inFormsets The input data of FormsetsDocument.Formsets
+ @param type The input data of node type
+ @param index The input data of node index
+
+ **/
+ public ModuleFormsets(FormsetsDocument.Formsets inFormsets, int type, int index) {
+ super();
+ init(inFormsets, type, index);
+ this.setVisible(true);
+ }
+
+ /**
+ This method initializes this
+
+ @param inFormsets The input data of FormsetsDocument.Formsets
+
+ **/
+ private void init(FormsetsDocument.Formsets inFormsets) {
+ init();
+ this.setFormsets(inFormsets);
+ }
+
+ /**
+ This method initializes this
+ Fill values to all fields if these values are not empty
+
+ @param inFormsets The input data of FormsetsDocument.Formsets
+ @param type The input data of node type
+ @param index The input data of node index
+
+ **/
+ private void init(FormsetsDocument.Formsets inFormsets, int type, int index) {
+ init(inFormsets);
+ this.location = index;
+ if (this.formsets.getFormsetList().size() > 0) {
+ if (this.formsets.getFormsetArray(index).getStringValue() != null) {
+ this.jTextFieldName.setText(this.formsets.getFormsetArray(index).getStringValue().toString());
+ }
+ if (this.formsets.getFormsetArray(index).getGuid() != null) {
+ this.jTextFieldGuid.setText(this.formsets.getFormsetArray(index).getGuid());
+ }
+ if (this.formsets.getFormsetArray(index).getUsage() != null) {
+ this.jComboBoxUsage.setSelectedItem(this.formsets.getFormsetArray(index).getUsage().toString());
+ }
+ this.jTextFieldOverrideID.setText(String.valueOf(this.formsets.getFormsetArray(index).getOverrideID()));
+ }
+ }
+
+ /**
+ This method initializes this
+
+ **/
+ private void init() {
+ this.setContentPane(getJContentPane());
+ this.setTitle("Form Sets");
+ this.setBounds(new java.awt.Rectangle(0, 0, 500, 515));
+ initFrame();
+ this.setViewMode(false);
+ }
+
+ /**
+ Disable all components when the mode is view
+
+ @param isView true - The view mode; false - The non-view mode
+
+ **/
+ public void setViewMode(boolean isView) {
+ this.jButtonOk.setVisible(false);
+ this.jButtonCancel.setVisible(false);
+ if (isView) {
+ this.jTextFieldName.setEnabled(!isView);
+ this.jTextFieldGuid.setEnabled(!isView);
+ this.jComboBoxUsage.setEnabled(!isView);
+ this.jTextFieldOverrideID.setEnabled(!isView);
+ this.jButtonCancel.setEnabled(!isView);
+ this.jButtonGenerateGuid.setEnabled(!isView);
+ this.jButtonOk.setEnabled(!isView);
+ }
+ }
+
+ /**
+ This method initializes jContentPane
+
+ @return javax.swing.JPanel jContentPane
+
+ **/
+ private JPanel getJContentPane() {
+ if (jContentPane == null) {
+ jLabelOverrideID = new JLabel();
+ jLabelOverrideID.setBounds(new java.awt.Rectangle(15, 85, 140, 20));
+ jLabelOverrideID.setText("Override ID");
+ jLabelUsage = new JLabel();
+ jLabelUsage.setText("Usage");
+ jLabelUsage.setBounds(new java.awt.Rectangle(15, 60, 140, 20));
+ jLabelGuid = new JLabel();
+ jLabelGuid.setText("Guid");
+ jLabelGuid.setBounds(new java.awt.Rectangle(15, 35, 140, 20));
+ jLabelName = new JLabel();
+ jLabelName.setText("Name");
+ jLabelName.setBounds(new java.awt.Rectangle(15, 10, 140, 20));
+ jContentPane = new JPanel();
+ jContentPane.setLayout(null);
+ jContentPane.add(jLabelName, null);
+ jContentPane.add(getJTextFieldName(), null);
+ jContentPane.add(jLabelGuid, null);
+ jContentPane.add(getJTextFieldGuid(), null);
+ jContentPane.add(jLabelUsage, null);
+ jContentPane.add(getJButtonOk(), null);
+ jContentPane.add(getJButtonCancel(), null);
+ jContentPane.add(getJComboBoxUsage(), null);
+ jContentPane.add(getJButtonGenerateGuid(), null);
+ jContentPane.add(jLabelOverrideID, null);
+ jContentPane.add(getJTextFieldOverrideID(), null);
+
+ jStarLabel1 = new StarLabel();
+ jStarLabel1.setLocation(new java.awt.Point(0, 10));
+
+ jContentPane.add(jStarLabel1, null);
+ }
+ return jContentPane;
+ }
+
+ /**
+ This method initializes Usage type
+
+ **/
+ private void initFrame() {
+ jComboBoxUsage.addItem("ALWAYS_PRODUCED");
+ jComboBoxUsage.addItem("SOMETIMES_PRODUCED");
+ jComboBoxUsage.addItem("PRIVATE");
+ }
+
+ /* (non-Javadoc)
+ * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
+ *
+ * Override actionPerformed to listen all actions
+ *
+ */
+ public void actionPerformed(ActionEvent arg0) {
+ if (arg0.getSource() == jButtonOk) {
+ this.setEdited(true);
+ this.save();
+ this.dispose();
+ }
+ if (arg0.getSource() == jButtonCancel) {
+ this.dispose();
+ }
+
+ if (arg0.getSource() == jButtonGenerateGuid) {
+ jTextFieldGuid.setText(Tools.generateUuidString());
+ }
+ }
+
+ /**
+ Set FormsetsDocument.Formsets
+
+ @return FormsetsDocument.Formsets
+
+ **/
+ public FormsetsDocument.Formsets getFormsets() {
+ return formsets;
+ }
+
+ /**
+ Get FormsetsDocument.Formsets
+
+ @param formsets The input FormsetsDocument.Formsets
+
+ **/
+ public void setFormsets(FormsetsDocument.Formsets formsets) {
+ this.formsets = formsets;
+ }
+
+ /**
+ Data validation for all fields
+
+ @retval true - All datas are valid
+ @retval false - At least one data is invalid
+
+ **/
+ public boolean check() {
+ //
+ // Check if all required fields are not empty
+ //
+ if (isEmpty(this.jTextFieldName.getText())) {
+ Log.err("Name couldn't be empty");
+ return false;
+ }
+
+ //
+ // Check if all fields have correct data types
+ //
+ if (!DataValidation.isCName(this.jTextFieldName.getText())) {
+ Log.err("Incorrect data type for Name");
+ return false;
+ }
+ if (!isEmpty(this.jTextFieldGuid.getText()) && !DataValidation.isGuid(this.jTextFieldGuid.getText())) {
+ Log.err("Incorrect data type for Guid");
+ return false;
+ }
+ if (!isEmpty(this.jTextFieldOverrideID.getText())
+ && !DataValidation.isOverrideID(this.jTextFieldOverrideID.getText())) {
+ Log.err("Incorrect data type for Override ID");
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ Save all components of Formsets
+ if exists formset, set the value directly
+ if not exists formset, new an instance first
+
+ **/
+ public void save() {
+ try {
+ if (this.formsets == null) {
+ formsets = FormsetsDocument.Formsets.Factory.newInstance();
+ }
+ FormsetsDocument.Formsets.Formset formset = FormsetsDocument.Formsets.Formset.Factory.newInstance();
+ if (!isEmpty(this.jTextFieldName.getText())) {
+ formset.setStringValue(this.jTextFieldName.getText());
+ }
+ if (!isEmpty(this.jTextFieldGuid.getText())) {
+ formset.setGuid(this.jTextFieldGuid.getText());
+ }
+ formset.setUsage(FormSetUsage.Enum.forString(jComboBoxUsage.getSelectedItem().toString()));
+ if (!isEmpty(this.jTextFieldOverrideID.getText())) {
+ formset.setOverrideID(Integer.parseInt(this.jTextFieldOverrideID.getText()));
+ }
+ if (location > -1) {
+ formsets.setFormsetArray(location, formset);
+ } else {
+ formsets.addNewFormset();
+ formsets.setFormsetArray(formsets.getFormsetList().size() - 1, formset);
+ }
+ } catch (Exception e) {
+ Log.err("Update Formsets", e.getMessage());
+ }
+ }
+}
diff --git a/Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/ModuleGuids.java b/Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/ModuleGuids.java
new file mode 100644
index 0000000000..186709644f
--- /dev/null
+++ b/Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/ModuleGuids.java
@@ -0,0 +1,675 @@
+/** @file
+
+ The file is used to create, update Guids of MSA/MBD file
+
+ Copyright (c) 2006, Intel Corporation
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+ **/
+package org.tianocore.packaging.module.ui;
+
+import java.awt.event.ActionEvent;
+
+import javax.swing.JButton;
+import javax.swing.JComboBox;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JRadioButton;
+import javax.swing.JTextField;
+
+import org.tianocore.ConditionalExpressionDocument;
+import org.tianocore.DefaultValueDocument;
+import org.tianocore.GuidUsage;
+import org.tianocore.GuidsDocument;
+import org.tianocore.common.DataValidation;
+import org.tianocore.common.Log;
+import org.tianocore.common.Tools;
+import org.tianocore.packaging.common.ui.IComboBox;
+import org.tianocore.packaging.common.ui.IInternalFrame;
+import org.tianocore.packaging.common.ui.StarLabel;
+
+/**
+ The class is used to create, update Guids of MSA/MBD file
+ It extends IInternalFrame
+
+ @since ModuleEditor 1.0
+
+ **/
+public class ModuleGuids extends IInternalFrame {
+
+ ///
+ /// Define class Serial Version UID
+ ///
+ private static final long serialVersionUID = 6710858997766979803L;
+
+ //
+ //Define class members
+ //
+ private GuidsDocument.Guids guids = null;
+
+ private int location = -1;
+
+ private JPanel jContentPane = null;
+
+ private JLabel jLabelC_Name = null;
+
+ private JTextField jTextFieldC_Name = null;
+
+ private JLabel jLabelGuidValue = null;
+
+ private JTextField jTextFieldGuidValue = null;
+
+ private JLabel jLabelFeatureFlag = null;
+
+ private IComboBox iComboBoxFeatureFlag = null;
+
+ private JLabel jLabelConditionalExpression = null;
+
+ private IComboBox iComboBoxConditionalExpression = null;
+
+ private JLabel jLabelDefault = null;
+
+ private JTextField jTextFieldDefaultValue = null;
+
+ private JLabel jLabelHelpText = null;
+
+ private JTextField jTextFieldHelpText = null;
+
+ private JLabel jLabelEnableFeature = null;
+
+ private JRadioButton jRadioButtonEnableFeature = null;
+
+ private JRadioButton jRadioButtonDisableFeature = null;
+
+ private JLabel jLabelUsage = null;
+
+ private JComboBox jComboBoxUsage = null;
+
+ private JButton jButtonOk = null;
+
+ private JButton jButtonCancel = null;
+
+ private JButton jButtonGenerateGuid = null;
+
+ private JLabel jLabelOverrideID = null;
+
+ private JTextField jTextFieldOverrideID = null;
+
+ /**
+ This method initializes jTextFieldC_Name
+
+ @return javax.swing.JTextField jTextFieldC_Name
+
+ **/
+ private JTextField getJTextFieldC_Name() {
+ if (jTextFieldC_Name == null) {
+ jTextFieldC_Name = new JTextField();
+ jTextFieldC_Name.setBounds(new java.awt.Rectangle(160, 10, 320, 20));
+ }
+ return jTextFieldC_Name;
+ }
+
+ /**
+ This method initializes jTextFieldGuidValsue
+
+ @return javax.swing.JTextField jTextFieldGuidValue
+
+ **/
+ private JTextField getJTextFieldGuidValsue() {
+ if (jTextFieldGuidValue == null) {
+ jTextFieldGuidValue = new JTextField();
+ jTextFieldGuidValue.setBounds(new java.awt.Rectangle(160, 35, 240, 20));
+ }
+ return jTextFieldGuidValue;
+ }
+
+ /**
+ This method initializes jTextFieldFeatureFlag
+
+ @return javax.swing.JTextField iComboBoxFeatureFlag
+
+ **/
+ private IComboBox getIComboBoxFeatureFlag() {
+ if (iComboBoxFeatureFlag == null) {
+ iComboBoxFeatureFlag = new IComboBox();
+ iComboBoxFeatureFlag.setBounds(new java.awt.Rectangle(160, 60, 320, 20));
+ }
+ return iComboBoxFeatureFlag;
+ }
+
+ /**
+ This method initializes jTextFieldConditionalExpression
+
+ @return javax.swing.JTextField iComboBoxConditionalExpression
+
+ **/
+ private IComboBox getIComboBoxConditionalExpression() {
+ if (iComboBoxConditionalExpression == null) {
+ iComboBoxConditionalExpression = new IComboBox();
+ iComboBoxConditionalExpression.setBounds(new java.awt.Rectangle(160, 85, 320, 20));
+ }
+ return iComboBoxConditionalExpression;
+ }
+
+ /**
+ This method initializes jTextFieldDefault
+
+ @return javax.swing.JTextField jTextFieldDefaultValue
+
+ **/
+ private JTextField getJTextFieldDefaultValue() {
+ if (jTextFieldDefaultValue == null) {
+ jTextFieldDefaultValue = new JTextField();
+ jTextFieldDefaultValue.setBounds(new java.awt.Rectangle(160, 110, 320, 20));
+ }
+ return jTextFieldDefaultValue;
+ }
+
+ /**
+ This method initializes jTextFieldHelpText
+
+ @return javax.swing.JTextField jTextFieldHelpText
+
+ **/
+ private JTextField getJTextFieldHelpText() {
+ if (jTextFieldHelpText == null) {
+ jTextFieldHelpText = new JTextField();
+ jTextFieldHelpText.setBounds(new java.awt.Rectangle(160, 135, 320, 20));
+ }
+ return jTextFieldHelpText;
+ }
+
+ /**
+ This method initializes jRadioButtonEnableFeature
+
+ @return javax.swing.JRadioButton jRadioButtonEnableFeature
+
+ **/
+ private JRadioButton getJRadioButtonEnableFeature() {
+ if (jRadioButtonEnableFeature == null) {
+ jRadioButtonEnableFeature = new JRadioButton();
+ jRadioButtonEnableFeature.setText("Enable");
+ jRadioButtonEnableFeature.setBounds(new java.awt.Rectangle(160, 160, 90, 20));
+ jRadioButtonEnableFeature.setSelected(true);
+ jRadioButtonEnableFeature.addActionListener(this);
+ }
+ return jRadioButtonEnableFeature;
+ }
+
+ /**
+ This method initializes jRadioButtonDisableFeature
+
+ @return javax.swing.JRadioButton jRadioButtonDisableFeature
+
+ **/
+ private JRadioButton getJRadioButtonDisableFeature() {
+ if (jRadioButtonDisableFeature == null) {
+ jRadioButtonDisableFeature = new JRadioButton();
+ jRadioButtonDisableFeature.setText("Disable");
+ jRadioButtonDisableFeature.setBounds(new java.awt.Rectangle(320, 160, 90, 20));
+ jRadioButtonDisableFeature.addActionListener(this);
+ }
+ return jRadioButtonDisableFeature;
+ }
+
+ /**
+ This method initializes jComboBoxUsage
+
+ @return javax.swing.JComboBox jComboBoxUsage
+
+ **/
+ private JComboBox getJComboBoxUsage() {
+ if (jComboBoxUsage == null) {
+ jComboBoxUsage = new JComboBox();
+ jComboBoxUsage.setBounds(new java.awt.Rectangle(160, 185, 320, 20));
+ }
+ return jComboBoxUsage;
+ }
+
+ /**
+ This method initializes jButtonOk
+
+ @return javax.swing.JButton jButtonOk
+
+ **/
+ private JButton getJButtonOk() {
+ if (jButtonOk == null) {
+ jButtonOk = new JButton();
+ jButtonOk.setText("OK");
+ jButtonOk.setBounds(new java.awt.Rectangle(290, 240, 90, 20));
+ jButtonOk.addActionListener(this);
+ }
+ return jButtonOk;
+ }
+
+ /**
+ This method initializes jButtonCancel
+
+ @return javax.swing.JButton jButtonCancel
+
+ **/
+ private JButton getJButtonCancel() {
+ if (jButtonCancel == null) {
+ jButtonCancel = new JButton();
+ jButtonCancel.setText("Cancel");
+ jButtonCancel.setBounds(new java.awt.Rectangle(390, 240, 90, 20));
+ jButtonCancel.addActionListener(this);
+ }
+ return jButtonCancel;
+ }
+
+ /**
+ This method initializes jButtonGenerateGuid
+
+ @return javax.swing.JButton jButtonGenerateGuid
+
+ **/
+ private JButton getJButtonGenerateGuid() {
+ if (jButtonGenerateGuid == null) {
+ jButtonGenerateGuid = new JButton();
+ jButtonGenerateGuid.setBounds(new java.awt.Rectangle(405, 35, 75, 20));
+ jButtonGenerateGuid.setText("GEN");
+ jButtonGenerateGuid.addActionListener(this);
+ }
+ return jButtonGenerateGuid;
+ }
+
+ /**
+ This method initializes jTextFieldOverrideID
+
+ @return javax.swing.JTextField jTextFieldOverrideID
+
+ **/
+ private JTextField getJTextFieldOverrideID() {
+ if (jTextFieldOverrideID == null) {
+ jTextFieldOverrideID = new JTextField();
+ jTextFieldOverrideID.setBounds(new java.awt.Rectangle(160, 210, 320, 20));
+ }
+ return jTextFieldOverrideID;
+ }
+
+ public static void main(String[] args) {
+
+ }
+
+ /**
+ This is the default constructor
+
+ **/
+ public ModuleGuids() {
+ super();
+ init();
+ this.setVisible(true);
+ }
+
+ /**
+ This is the override edit constructor
+
+ @param inGuids The input data of GuidsDocument.Guids
+
+ **/
+ public ModuleGuids(GuidsDocument.Guids inGuids) {
+ super();
+ init(inGuids);
+ this.setVisible(true);
+ }
+
+ /**
+ This is the override edit constructor
+
+ @param inGuids The input data of GuidsDocument.Guids
+ @param type The input data of node type
+ @param index The input data of node index
+
+ **/
+ public ModuleGuids(GuidsDocument.Guids inGuids, int type, int index) {
+ super();
+ init(inGuids, type, index);
+ this.setVisible(true);
+ }
+
+ /**
+ This method initializes this
+
+ @param inGuids The input data of GuidsDocument.Guids
+
+ **/
+ private void init(GuidsDocument.Guids inGuids) {
+ init();
+ this.setGuids(inGuids);
+ }
+
+ /**
+ This method initializes this
+ Fill values to all fields if these values are not empty
+
+ @param inGuids The input data of GuidsDocument.Guids
+ @param type The input data of node type
+ @param index The input data of node index
+
+ **/
+ private void init(GuidsDocument.Guids inGuids, int type, int index) {
+ init(inGuids);
+ this.location = index;
+ if (this.guids.getGuidEntryList().size() > 0) {
+ if (this.guids.getGuidEntryArray(index).getCName() != null) {
+ this.jTextFieldC_Name.setText(this.guids.getGuidEntryArray(index).getCName());
+ }
+ if (this.guids.getGuidEntryArray(index).getGuidValue() != null) {
+ this.jTextFieldGuidValue.setText(this.guids.getGuidEntryArray(index).getGuidValue());
+ }
+ if (this.guids.getGuidEntryArray(index).getFeatureFlagList().size() > 0) {
+ for (int indexI = 0; indexI < this.guids.getGuidEntryArray(index).getFeatureFlagList().size(); indexI++) {
+ this.iComboBoxFeatureFlag.addItem(this.guids.getGuidEntryArray(index).getFeatureFlagArray(indexI));
+ }
+ }
+ if (this.guids.getGuidEntryArray(index).getConditionalExpressionList().size() > 0) {
+ for (int indexI = 0; indexI < this.guids.getGuidEntryArray(index).getConditionalExpressionArray(0)
+ .getConditionList().size(); indexI++) {
+ this.iComboBoxConditionalExpression.addItem(this.guids.getGuidEntryArray(index)
+ .getConditionalExpressionArray(0)
+ .getConditionArray(indexI));
+ }
+ }
+ if (this.guids.getGuidEntryArray(index).getDefaultValue() != null) {
+ this.jTextFieldDefaultValue.setText(this.guids.getGuidEntryArray(index).getDefaultValue()
+ .getStringValue());
+ }
+ if (this.guids.getGuidEntryArray(index).getHelpText() != null) {
+ this.jTextFieldHelpText.setText(this.guids.getGuidEntryArray(index).getHelpText());
+ }
+ if (this.guids.getGuidEntryArray(index).getUsage() != null) {
+ this.jComboBoxUsage.setSelectedItem(this.guids.getGuidEntryArray(index).getUsage().toString());
+ }
+ this.jRadioButtonEnableFeature.setSelected(this.guids.getGuidEntryArray(index).getEnableFeature());
+ this.jRadioButtonDisableFeature.setSelected(!this.guids.getGuidEntryArray(index).getEnableFeature());
+ this.jTextFieldOverrideID.setText(String.valueOf(this.guids.getGuidEntryArray(index).getOverrideID()));
+ }
+ }
+
+ /**
+ This method initializes this
+
+ **/
+ private void init() {
+ this.setSize(500, 515);
+ this.setContentPane(getJContentPane());
+ this.setTitle("Guids");
+ initFrame();
+ this.setViewMode(false);
+ }
+
+ /**
+ Disable all components when the mode is view
+
+ @param isView true - The view mode; false - The non-view mode
+
+ **/
+ public void setViewMode(boolean isView) {
+ this.jButtonOk.setVisible(false);
+ this.jButtonCancel.setVisible(false);
+ if (isView) {
+ this.jTextFieldC_Name.setEnabled(!isView);
+ this.jTextFieldGuidValue.setEnabled(!isView);
+ this.iComboBoxFeatureFlag.setEnabled(!isView);
+ this.iComboBoxConditionalExpression.setEnabled(!isView);
+ this.jTextFieldDefaultValue.setEnabled(!isView);
+ this.jTextFieldHelpText.setEnabled(!isView);
+ this.jComboBoxUsage.setEnabled(!isView);
+ this.jRadioButtonEnableFeature.setEnabled(!isView);
+ this.jRadioButtonDisableFeature.setEnabled(!isView);
+ this.jTextFieldOverrideID.setEnabled(!isView);
+ this.jButtonCancel.setEnabled(!isView);
+ this.jButtonGenerateGuid.setEnabled(!isView);
+ this.jButtonOk.setEnabled(!isView);
+ }
+ }
+
+ /**
+ This method initializes jContentPane
+
+ @return javax.swing.JPanel jContentPane
+
+ **/
+ private JPanel getJContentPane() {
+ if (jContentPane == null) {
+ jLabelOverrideID = new JLabel();
+ jLabelOverrideID.setBounds(new java.awt.Rectangle(15, 210, 140, 20));
+ jLabelOverrideID.setText("Override ID");
+ jLabelUsage = new JLabel();
+ jLabelUsage.setText("Usage");
+ jLabelUsage.setBounds(new java.awt.Rectangle(15, 185, 140, 20));
+ jLabelEnableFeature = new JLabel();
+ jLabelEnableFeature.setText("Enable Feature");
+ jLabelEnableFeature.setBounds(new java.awt.Rectangle(15, 160, 140, 20));
+ jLabelHelpText = new JLabel();
+ jLabelHelpText.setText("Help Text");
+ jLabelHelpText.setBounds(new java.awt.Rectangle(15, 135, 140, 20));
+ jLabelDefault = new JLabel();
+ jLabelDefault.setText("Default Value");
+ jLabelDefault.setBounds(new java.awt.Rectangle(15, 110, 140, 20));
+ jLabelConditionalExpression = new JLabel();
+ jLabelConditionalExpression.setText("Conditional Expression");
+ jLabelConditionalExpression.setBounds(new java.awt.Rectangle(15, 85, 140, 20));
+ jLabelFeatureFlag = new JLabel();
+ jLabelFeatureFlag.setText("Feature Flag");
+ jLabelFeatureFlag.setBounds(new java.awt.Rectangle(15, 60, 140, 20));
+ jLabelGuidValue = new JLabel();
+ jLabelGuidValue.setText("Guid Value");
+ jLabelGuidValue.setBounds(new java.awt.Rectangle(15, 35, 140, 20));
+ jLabelC_Name = new JLabel();
+ jLabelC_Name.setText("C_Name");
+ jLabelC_Name.setBounds(new java.awt.Rectangle(15, 10, 140, 20));
+ jContentPane = new JPanel();
+ jContentPane.setLayout(null);
+ jContentPane.add(jLabelC_Name, null);
+ jContentPane.add(getJTextFieldC_Name(), null);
+ jContentPane.add(jLabelGuidValue, null);
+ jContentPane.add(getJTextFieldGuidValsue(), null);
+ jContentPane.add(jLabelFeatureFlag, null);
+ jContentPane.add(getIComboBoxFeatureFlag(), null);
+ jContentPane.add(jLabelConditionalExpression, null);
+ jContentPane.add(getIComboBoxConditionalExpression(), null);
+ jContentPane.add(jLabelDefault, null);
+ jContentPane.add(getJTextFieldDefaultValue(), null);
+ jContentPane.add(jLabelHelpText, null);
+ jContentPane.add(getJTextFieldHelpText(), null);
+ jContentPane.add(jLabelEnableFeature, null);
+ jContentPane.add(getJRadioButtonEnableFeature(), null);
+ jContentPane.add(getJRadioButtonDisableFeature(), null);
+ jContentPane.add(jLabelUsage, null);
+ jContentPane.add(getJComboBoxUsage(), null);
+ jContentPane.add(getJButtonOk(), null);
+ jContentPane.add(getJButtonCancel(), null);
+ jContentPane.add(getJButtonGenerateGuid(), null);
+ jContentPane.add(jLabelOverrideID, null);
+ jContentPane.add(getJTextFieldOverrideID(), null);
+
+ StarLabel jStarLabel1 = new StarLabel();
+ jStarLabel1.setLocation(new java.awt.Point(0, 10));
+
+ jContentPane.add(jStarLabel1, null);
+
+ initFrame();
+
+ }
+ return jContentPane;
+ }
+
+ /**
+ This method initializes Usage type
+
+ **/
+ private void initFrame() {
+ jComboBoxUsage.addItem("ALWAYS_CONSUMED");
+ jComboBoxUsage.addItem("SOMETIMES_CONSUMED");
+ jComboBoxUsage.addItem("ALWAYS_PRODUCED");
+ jComboBoxUsage.addItem("SOMETIMES_PRODUCED");
+ jComboBoxUsage.addItem("DEFAULT");
+ }
+
+ /* (non-Javadoc)
+ * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
+ *
+ * Override actionPerformed to listen all actions
+ *
+ */
+ public void actionPerformed(ActionEvent arg0) {
+ if (arg0.getSource() == jButtonOk) {
+ this.setEdited(true);
+ this.save();
+ this.dispose();
+ }
+ if (arg0.getSource() == jButtonCancel) {
+ this.dispose();
+ }
+
+ if (arg0.getSource() == jButtonGenerateGuid) {
+ jTextFieldGuidValue.setText(Tools.generateUuidString());
+ }
+
+ //
+ //Contorl the selected status when click RadionButton
+ //Do not use Radio Button Group
+ //
+ if (arg0.getSource() == jRadioButtonEnableFeature) {
+ if (jRadioButtonEnableFeature.isSelected()) {
+ jRadioButtonDisableFeature.setSelected(false);
+ }
+ if (!jRadioButtonDisableFeature.isSelected() && !jRadioButtonEnableFeature.isSelected()) {
+ jRadioButtonEnableFeature.setSelected(true);
+ }
+ }
+
+ if (arg0.getSource() == jRadioButtonDisableFeature) {
+ if (jRadioButtonDisableFeature.isSelected()) {
+ jRadioButtonEnableFeature.setSelected(false);
+ }
+ if (!jRadioButtonDisableFeature.isSelected() && !jRadioButtonEnableFeature.isSelected()) {
+ jRadioButtonDisableFeature.setSelected(true);
+ }
+ }
+ }
+
+ /**
+ Get GuidsDocument.Guids
+
+ @return GuidsDocument.Guids
+
+ **/
+ public GuidsDocument.Guids getGuids() {
+ return guids;
+ }
+
+ /**
+ Set GuidsDocument.Guids
+
+ @param guids The input GuidsDocument.Guids
+
+ **/
+ public void setGuids(GuidsDocument.Guids guids) {
+ this.guids = guids;
+ }
+
+ /**
+ Data validation for all fields
+
+ @retval true - All datas are valid
+ @retval false - At least one data is invalid
+
+ **/
+ public boolean check() {
+ //
+ // Check if all required fields are not empty
+ //
+ if (isEmpty(this.jTextFieldC_Name.getText())) {
+ Log.err("C_Name couldn't be empty");
+ return false;
+ }
+
+ //
+ // Check if all fields have correct data types
+ //
+ if (!DataValidation.isCName(this.jTextFieldC_Name.getText())) {
+ Log.err("Incorrect data type for C_Name");
+ return false;
+ }
+ if (!isEmpty(this.jTextFieldGuidValue.getText()) && !DataValidation.isGuid(this.jTextFieldGuidValue.getText())) {
+ Log.err("Incorrect data type for Guid Value");
+ return false;
+ }
+ if (!isEmpty(this.jTextFieldOverrideID.getText())
+ && !DataValidation.isOverrideID(this.jTextFieldOverrideID.getText())) {
+ Log.err("Incorrect data type for Override ID");
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ Save all components of Guids
+ if exists guids, set the value directly
+ if not exists guids, new an instance first
+
+ **/
+ public void save() {
+ try {
+ if (this.guids == null) {
+ guids = GuidsDocument.Guids.Factory.newInstance();
+ }
+ GuidsDocument.Guids.GuidEntry guid = GuidsDocument.Guids.GuidEntry.Factory.newInstance();
+ if (!isEmpty(this.jTextFieldC_Name.getText())) {
+ guid.setCName(this.jTextFieldC_Name.getText());
+ }
+ if (!isEmpty(this.jTextFieldGuidValue.getText())) {
+ guid.setGuidValue(this.jTextFieldGuidValue.getText());
+ }
+ if (this.iComboBoxFeatureFlag.getItemCount() > 0) {
+ for (int index = 0; index < this.iComboBoxFeatureFlag.getItemCount(); index++) {
+ guid.addNewFeatureFlag();
+ guid.setFeatureFlagArray(index, this.iComboBoxFeatureFlag.getItemAt(index).toString());
+ }
+ }
+ if (this.iComboBoxConditionalExpression.getItemCount() > 0) {
+ ConditionalExpressionDocument.ConditionalExpression ce = ConditionalExpressionDocument.ConditionalExpression.Factory
+ .newInstance();
+ for (int index = 0; index < this.iComboBoxConditionalExpression.getItemCount(); index++) {
+ ce.addCondition(this.iComboBoxConditionalExpression.getItemAt(index).toString());
+ }
+ if (guid.getConditionalExpressionList().size() < 1) {
+ guid.addNewConditionalExpression();
+ }
+ guid.setConditionalExpressionArray(0, ce);
+ }
+ if (!isEmpty(this.jTextFieldDefaultValue.getText())) {
+ DefaultValueDocument.DefaultValue dv = DefaultValueDocument.DefaultValue.Factory.newInstance();
+ dv.setStringValue(this.jTextFieldDefaultValue.getText());
+ guid.setDefaultValue(dv);
+ }
+ if (!isEmpty(this.jTextFieldHelpText.getText())) {
+ guid.setHelpText(this.jTextFieldHelpText.getText());
+ }
+ guid.setUsage(GuidUsage.Enum.forString(jComboBoxUsage.getSelectedItem().toString()));
+ guid.setEnableFeature(this.jRadioButtonEnableFeature.isSelected());
+ if (!isEmpty(this.jTextFieldOverrideID.getText())) {
+ guid.setOverrideID(Integer.parseInt(this.jTextFieldOverrideID.getText()));
+ }
+
+ if (location > -1) {
+ guids.setGuidEntryArray(location, guid);
+ } else {
+ guids.addNewGuidEntry();
+ guids.setGuidEntryArray(guids.getGuidEntryList().size() - 1, guid);
+ }
+ } catch (Exception e) {
+ Log.err("Update Guids", e.getMessage());
+ }
+ }
+}
diff --git a/Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/ModuleHobs.java b/Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/ModuleHobs.java
new file mode 100644
index 0000000000..3d209e5634
--- /dev/null
+++ b/Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/ModuleHobs.java
@@ -0,0 +1,596 @@
+/** @file
+
+ The file is used to create, update Hob of MSA/MBD file
+
+ Copyright (c) 2006, Intel Corporation
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+ **/
+package org.tianocore.packaging.module.ui;
+
+import java.awt.event.ActionEvent;
+
+import javax.swing.JButton;
+import javax.swing.JComboBox;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JRadioButton;
+import javax.swing.JTextField;
+
+import org.tianocore.GuidDocument;
+import org.tianocore.HobTypes;
+import org.tianocore.HobUsage;
+import org.tianocore.HobsDocument;
+import org.tianocore.common.DataValidation;
+import org.tianocore.common.Log;
+import org.tianocore.common.Tools;
+import org.tianocore.packaging.common.ui.IInternalFrame;
+import org.tianocore.packaging.common.ui.StarLabel;
+
+/**
+ The class is used to create, update Hob of MSA/MBD file
+ It extends IInternalFrame
+
+ @since ModuleEditor 1.0
+
+ **/
+public class ModuleHobs extends IInternalFrame {
+
+ ///
+ /// Define class Serial Version UID
+ ///
+ private static final long serialVersionUID = -553473437579358325L;
+
+ //
+ //Define class members
+ //
+ private HobsDocument.Hobs hobs = null;
+
+ private int location = -1;
+
+ private JPanel jContentPane = null;
+
+ private JLabel jLabel = null;
+
+ private JTextField jTextFieldC_Name = null;
+
+ private JLabel jLabelGuid = null;
+
+ private JTextField jTextFieldGuid = null;
+
+ private JLabel jLabelName = null;
+
+ private JTextField jTextFieldName = null;
+
+ private JLabel jLabelUsage = null;
+
+ private JLabel jLabelHobType = null;
+
+ private JComboBox jComboBoxUsage = null;
+
+ private JComboBox jComboBoxHobType = null;
+
+ private JLabel jLabelHobEnabled = null;
+
+ private JRadioButton jRadioButtonHobEnable = null;
+
+ private JRadioButton jRadioButtonHobDisable = null;
+
+ private JButton jButtonOk = null;
+
+ private JButton jButtonCancel = null;
+
+ private JButton jButtonGenerateGuid = null;
+
+ private JLabel jLabelOverrideID = null;
+
+ private JTextField jTextFieldOverrideID = null;
+
+ private StarLabel jStarLabel1 = null;
+
+ /**
+ This method initializes jTextField
+
+ @return javax.swing.JTextField jTextFieldC_Name
+
+ **/
+ private JTextField getJTextFieldC_Name() {
+ if (jTextFieldC_Name == null) {
+ jTextFieldC_Name = new JTextField();
+ jTextFieldC_Name.setBounds(new java.awt.Rectangle(160, 35, 320, 20));
+ }
+ return jTextFieldC_Name;
+ }
+
+ /**
+ This method initializes jTextField
+
+ @return javax.swing.JTextField jTextFieldGuid
+
+ **/
+ private JTextField getJTextFieldGuid() {
+ if (jTextFieldGuid == null) {
+ jTextFieldGuid = new JTextField();
+ jTextFieldGuid.setBounds(new java.awt.Rectangle(160, 60, 240, 20));
+ }
+ return jTextFieldGuid;
+ }
+
+ /**
+ This method initializes jTextFieldName
+
+ @return javax.swing.JTextField jTextFieldName
+
+ **/
+ private JTextField getJTextFieldName() {
+ if (jTextFieldName == null) {
+ jTextFieldName = new JTextField();
+ jTextFieldName.setBounds(new java.awt.Rectangle(160, 10, 320, 20));
+ }
+ return jTextFieldName;
+ }
+
+ /**
+ This method initializes jComboBoxUsage
+
+ @return javax.swing.JComboBox jComboBoxUsage
+
+ **/
+ private JComboBox getJComboBoxUsage() {
+ if (jComboBoxUsage == null) {
+ jComboBoxUsage = new JComboBox();
+ jComboBoxUsage.setBounds(new java.awt.Rectangle(160, 85, 320, 20));
+ }
+ return jComboBoxUsage;
+ }
+
+ /**
+ This method initializes jComboBoxHobType
+
+ @return javax.swing.JComboBox jComboBoxHobType
+
+ **/
+ private JComboBox getJComboBoxHobType() {
+ if (jComboBoxHobType == null) {
+ jComboBoxHobType = new JComboBox();
+ jComboBoxHobType.setBounds(new java.awt.Rectangle(160, 110, 320, 20));
+ }
+ return jComboBoxHobType;
+ }
+
+ /**
+ This method initializes jRadioButtonEnable
+
+ @return javax.swing.JRadioButton jRadioButtonHobEnable
+
+ **/
+ private JRadioButton getJRadioButtonHobEnable() {
+ if (jRadioButtonHobEnable == null) {
+ jRadioButtonHobEnable = new JRadioButton();
+ jRadioButtonHobEnable.setText("Enable");
+ jRadioButtonHobEnable.setBounds(new java.awt.Rectangle(160, 135, 90, 20));
+ jRadioButtonHobEnable.setSelected(true);
+ jRadioButtonHobEnable.addActionListener(this);
+ }
+ return jRadioButtonHobEnable;
+ }
+
+ /**
+ This method initializes jRadioButtonDisable
+
+ @return javax.swing.JRadioButton jRadioButtonHobDisable
+
+ **/
+ private JRadioButton getJRadioButtonHobDisable() {
+ if (jRadioButtonHobDisable == null) {
+ jRadioButtonHobDisable = new JRadioButton();
+ jRadioButtonHobDisable.setText("Disable");
+ jRadioButtonHobDisable.setBounds(new java.awt.Rectangle(320, 135, 90, 20));
+ jRadioButtonHobDisable.addActionListener(this);
+ }
+ return jRadioButtonHobDisable;
+ }
+
+ /**
+ This method initializes jButtonOk
+
+ @return javax.swing.JButton jButtonOk
+
+ **/
+ private JButton getJButtonOk() {
+ if (jButtonOk == null) {
+ jButtonOk = new JButton();
+ jButtonOk.setText("OK");
+ jButtonOk.setBounds(new java.awt.Rectangle(290, 190, 90, 20));
+ jButtonOk.addActionListener(this);
+ }
+ return jButtonOk;
+ }
+
+ /**
+ This method initializes jButtonCancel
+
+ @return javax.swing.JButton jButtonCancel
+
+ **/
+ private JButton getJButtonCancel() {
+ if (jButtonCancel == null) {
+ jButtonCancel = new JButton();
+ jButtonCancel.setText("Cancel");
+ jButtonCancel.setBounds(new java.awt.Rectangle(390, 190, 90, 20));
+ jButtonCancel.addActionListener(this);
+ }
+ return jButtonCancel;
+ }
+
+ /**
+ This method initializes jButtonGenerateGuid
+
+ @return javax.swing.JButton jButtonGenerateGuid
+
+ **/
+ private JButton getJButtonGenerateGuid() {
+ if (jButtonGenerateGuid == null) {
+ jButtonGenerateGuid = new JButton();
+ jButtonGenerateGuid.setBounds(new java.awt.Rectangle(405, 60, 75, 20));
+ jButtonGenerateGuid.setText("GEN");
+ jButtonGenerateGuid.addActionListener(this);
+ }
+ return jButtonGenerateGuid;
+ }
+
+ /**
+ This method initializes jTextFieldOverrideID
+
+ @return javax.swing.JTextField jTextFieldOverrideID
+
+ **/
+ private JTextField getJTextFieldOverrideID() {
+ if (jTextFieldOverrideID == null) {
+ jTextFieldOverrideID = new JTextField();
+ jTextFieldOverrideID.setBounds(new java.awt.Rectangle(160, 160, 320, 20));
+ }
+ return jTextFieldOverrideID;
+ }
+
+ public static void main(String[] args) {
+
+ }
+
+ /**
+ This is the default constructor
+
+ **/
+ public ModuleHobs() {
+ super();
+ init();
+ this.setVisible(true);
+ }
+
+ /**
+ This is the override edit constructor
+
+ @param inHobs The input data of HobsDocument.Hobs
+
+ **/
+ public ModuleHobs(HobsDocument.Hobs inHobs) {
+ super();
+ init(inHobs);
+ this.setVisible(true);
+ }
+
+ /**
+ This is the override edit constructor
+
+ @param inHobs The input data of HobsDocument.Hobs
+ @param type The input data of node type
+ @param index The input data of node index
+
+ **/
+ public ModuleHobs(HobsDocument.Hobs inHobs, int type, int index) {
+ super();
+ init(inHobs, type, index);
+ this.setVisible(true);
+ }
+
+ /**
+ This method initializes this
+
+ @param inHobs The input data of HobsDocument.Hobs
+
+ **/
+ private void init(HobsDocument.Hobs inHobs) {
+ init();
+ this.setHobs(inHobs);
+ }
+
+ /**
+ This method initializes this
+ Fill values to all fields if these values are not empty
+
+ @param inHobs The input data of HobsDocument.Hobs
+ @param type The input data of node type
+ @param index The input data of node index
+
+ **/
+ private void init(HobsDocument.Hobs inHobs, int type, int index) {
+ init(inHobs);
+ this.location = index;
+ if (this.hobs.getHobList().size() > 0) {
+ if (this.hobs.getHobArray(index).getName() != null) {
+ this.jTextFieldName.setText(this.hobs.getHobArray(index).getName());
+ }
+ if (this.hobs.getHobArray(index).getCName() != null) {
+ this.jTextFieldC_Name.setText(this.hobs.getHobArray(index).getCName());
+ }
+ if (this.hobs.getHobArray(index).getGuid() != null) {
+ this.jTextFieldGuid.setText(this.hobs.getHobArray(index).getGuid().getStringValue());
+ }
+ if (this.hobs.getHobArray(index).getUsage() != null) {
+ this.jComboBoxUsage.setSelectedItem(this.hobs.getHobArray(index).getUsage().toString());
+ }
+ this.jRadioButtonHobEnable.setSelected(this.hobs.getHobArray(index).getHobEnabled());
+ this.jRadioButtonHobDisable.setSelected(!this.hobs.getHobArray(index).getHobEnabled());
+ this.jTextFieldOverrideID.setText(String.valueOf(this.hobs.getHobArray(index).getOverrideID()));
+ }
+ }
+
+ /**
+ This method initializes this
+
+ **/
+ private void init() {
+ this.setSize(500, 515);
+ this.setContentPane(getJContentPane());
+ this.setTitle("Hobs");
+ initFrame();
+ this.setViewMode(false);
+ }
+
+ /**
+ Disable all components when the mode is view
+
+ @param isView true - The view mode; false - The non-view mode
+
+ **/
+ public void setViewMode(boolean isView) {
+ this.jButtonOk.setVisible(false);
+ this.jButtonCancel.setVisible(false);
+ if (isView) {
+ this.jTextFieldName.setEnabled(!isView);
+ this.jTextFieldC_Name.setEnabled(!isView);
+ this.jTextFieldGuid.setEnabled(!isView);
+ this.jComboBoxUsage.setEnabled(!isView);
+ this.jComboBoxHobType.setEnabled(!isView);
+ this.jRadioButtonHobEnable.setEnabled(!isView);
+ this.jRadioButtonHobDisable.setEnabled(!isView);
+ this.jTextFieldOverrideID.setEnabled(!isView);
+ this.jButtonCancel.setEnabled(!isView);
+ this.jButtonGenerateGuid.setEnabled(!isView);
+ this.jButtonOk.setEnabled(!isView);
+ }
+ }
+
+ /**
+ This method initializes jContentPane
+
+ @return javax.swing.JPanel jContentPane
+
+ **/
+ public JPanel getJContentPane() {
+ if (jContentPane == null) {
+ jLabelOverrideID = new JLabel();
+ jLabelOverrideID.setBounds(new java.awt.Rectangle(15, 160, 140, 20));
+ jLabelOverrideID.setText("Override ID");
+ jLabelHobEnabled = new JLabel();
+ jLabelHobEnabled.setText("Hob Enabled");
+ jLabelHobEnabled.setBounds(new java.awt.Rectangle(15, 135, 140, 20));
+ jLabelHobType = new JLabel();
+ jLabelHobType.setText("Hob Type");
+ jLabelHobType.setBounds(new java.awt.Rectangle(15, 110, 140, 20));
+ jLabelUsage = new JLabel();
+ jLabelUsage.setText("Usage");
+ jLabelUsage.setBounds(new java.awt.Rectangle(15, 85, 140, 20));
+ jLabelName = new JLabel();
+ jLabelName.setText("Name");
+ jLabelName.setBounds(new java.awt.Rectangle(15, 10, 140, 20));
+ jLabelGuid = new JLabel();
+ jLabelGuid.setText("Guid");
+ jLabelGuid.setBounds(new java.awt.Rectangle(15, 60, 140, 20));
+ jLabel = new JLabel();
+ jLabel.setText("C_Name");
+ jLabel.setBounds(new java.awt.Rectangle(15, 35, 140, 20));
+ jContentPane = new JPanel();
+ jContentPane.setLayout(null);
+ jContentPane.add(jLabel, null);
+ jContentPane.add(getJTextFieldC_Name(), null);
+ jContentPane.add(getJTextFieldGuid(), null);
+ jContentPane.add(jLabelUsage, null);
+ jContentPane.add(jLabelName, null);
+ jContentPane.add(getJTextFieldName(), null);
+ jContentPane.add(jLabelGuid, null);
+ jContentPane.add(jLabelHobType, null);
+ jContentPane.add(getJComboBoxUsage(), null);
+ jContentPane.add(getJComboBoxHobType(), null);
+ jContentPane.add(jLabelHobEnabled, null);
+ jContentPane.add(getJRadioButtonHobEnable(), null);
+ jContentPane.add(getJRadioButtonHobDisable(), null);
+ jContentPane.add(getJButtonOk(), null);
+ jContentPane.add(getJButtonCancel(), null);
+ jContentPane.add(getJButtonGenerateGuid(), null);
+ jContentPane.add(jLabelOverrideID, null);
+ jContentPane.add(getJTextFieldOverrideID(), null);
+
+ jStarLabel1 = new StarLabel();
+ jStarLabel1.setLocation(new java.awt.Point(0, 10));
+ jContentPane.add(jStarLabel1, null);
+ }
+ return jContentPane;
+ }
+
+ /**
+ This method initializes Usage type and Hob type
+
+ **/
+ private void initFrame() {
+ jComboBoxHobType.addItem("PHIT");
+ jComboBoxHobType.addItem("MEMORY_ALLOCATION");
+ jComboBoxHobType.addItem("RESOURCE_DESCRIPTOR");
+ jComboBoxHobType.addItem("GUID_EXTENSION");
+ jComboBoxHobType.addItem("FIRMWARE_VOLUME");
+ jComboBoxHobType.addItem("CPU");
+ jComboBoxHobType.addItem("POOL");
+ jComboBoxHobType.addItem("CAPSULE_VOLUME");
+
+ jComboBoxUsage.addItem("ALWAYS_CONSUMED");
+ jComboBoxUsage.addItem("SOMETIMES_CONSUMED");
+ jComboBoxUsage.addItem("ALWAYS_PRODUCED");
+ jComboBoxUsage.addItem("SOMETIMES_PRODUCED");
+ jComboBoxUsage.addItem("PRIVATE");
+ }
+
+ /* (non-Javadoc)
+ * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
+ *
+ * Override actionPerformed to listen all actions
+ *
+ */
+ public void actionPerformed(ActionEvent arg0) {
+ if (arg0.getSource() == jButtonOk) {
+ this.setEdited(true);
+ this.save();
+ this.dispose();
+ }
+ if (arg0.getSource() == jButtonCancel) {
+ this.dispose();
+ }
+
+ //
+ // Contorl the selected status when click RadionButton
+ // Do not use Radio Button Group
+ //
+ if (arg0.getSource() == jRadioButtonHobEnable) {
+ if (jRadioButtonHobEnable.isSelected()) {
+ jRadioButtonHobDisable.setSelected(false);
+ }
+ if (!jRadioButtonHobDisable.isSelected() && !jRadioButtonHobEnable.isSelected()) {
+ jRadioButtonHobEnable.setSelected(true);
+ }
+ }
+
+ if (arg0.getSource() == jRadioButtonHobDisable) {
+ if (jRadioButtonHobDisable.isSelected()) {
+ jRadioButtonHobEnable.setSelected(false);
+ }
+ if (!jRadioButtonHobDisable.isSelected() && !jRadioButtonHobEnable.isSelected()) {
+ jRadioButtonHobDisable.setSelected(true);
+ }
+ }
+
+ if (arg0.getSource() == jButtonGenerateGuid) {
+ jTextFieldGuid.setText(Tools.generateUuidString());
+ }
+ }
+
+ /**
+ Get HobsDocument.Hobs
+
+ @return HobsDocument.Hobs
+
+ **/
+ public HobsDocument.Hobs getHobs() {
+ return hobs;
+ }
+
+ /**
+ Set HobsDocument.Hobs
+
+ @param hobs The input data of HobsDocument.Hobs
+
+ **/
+ public void setHobs(HobsDocument.Hobs hobs) {
+ this.hobs = hobs;
+ }
+
+ /**
+ Data validation for all fields
+
+ @retval true - All datas are valid
+ @retval false - At least one data is invalid
+
+ **/
+ public boolean check() {
+ //
+ // Check if all required fields are not empty
+ //
+ if (isEmpty(this.jTextFieldName.getText())) {
+ Log.err("Name couldn't be empty");
+ return false;
+ }
+
+ //
+ // Check if all fields have correct data types
+ //
+ if (!DataValidation.isCName(this.jTextFieldC_Name.getText())) {
+ Log.err("Incorrect data type for C_Name");
+ return false;
+ }
+ if (!isEmpty(this.jTextFieldGuid.getText()) && !DataValidation.isGuid(this.jTextFieldGuid.getText())) {
+ Log.err("Incorrect data type for Guid");
+ return false;
+ }
+ if (!isEmpty(this.jTextFieldOverrideID.getText())
+ && !DataValidation.isOverrideID(this.jTextFieldOverrideID.getText())) {
+ Log.err("Incorrect data type for Override ID");
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ Save all components of Hobs
+ if exists hobs, set the value directly
+ if not exists hobs, new an instance first
+
+ **/
+ public void save() {
+ try {
+ if (this.hobs == null) {
+ hobs = HobsDocument.Hobs.Factory.newInstance();
+ }
+ HobsDocument.Hobs.Hob hob = HobsDocument.Hobs.Hob.Factory.newInstance();
+ if (!isEmpty(this.jTextFieldName.getText())) {
+ hob.setName(this.jTextFieldName.getText());
+ }
+ if (!isEmpty(this.jTextFieldC_Name.getText())) {
+ hob.setCName(this.jTextFieldC_Name.getText());
+ }
+ if (!isEmpty(this.jTextFieldGuid.getText())) {
+ GuidDocument.Guid guid = GuidDocument.Guid.Factory.newInstance();
+ guid.setStringValue(this.jTextFieldGuid.getText());
+ hob.setGuid(guid);
+ }
+ hob.setUsage(HobUsage.Enum.forString(jComboBoxUsage.getSelectedItem().toString()));
+ hob.setHobType(HobTypes.Enum.forString(jComboBoxHobType.getSelectedItem().toString()));
+ hob.setHobEnabled(this.jRadioButtonHobEnable.isSelected());
+ if (!isEmpty(this.jTextFieldOverrideID.getText())) {
+ hob.setOverrideID(Integer.parseInt(this.jTextFieldOverrideID.getText()));
+ }
+ if (location > -1) {
+ hobs.setHobArray(location, hob);
+ } else {
+ hobs.addNewHob();
+ hobs.setHobArray(hobs.getHobList().size() - 1, hob);
+ }
+ } catch (Exception e) {
+ Log.err("Update Hobs", e.getMessage());
+ }
+ }
+}
diff --git a/Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/ModuleIncludes.java b/Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/ModuleIncludes.java
new file mode 100644
index 0000000000..dccee3148a
--- /dev/null
+++ b/Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/ModuleIncludes.java
@@ -0,0 +1,867 @@
+/** @file
+
+ The file is used to create, update Include of MSA/MBD file
+
+ Copyright (c) 2006, Intel Corporation
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+ **/
+package org.tianocore.packaging.module.ui;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
+import java.util.Vector;
+
+import javax.swing.JButton;
+import javax.swing.JCheckBox;
+import javax.swing.JComboBox;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JTextField;
+
+import org.tianocore.IncludesDocument;
+import org.tianocore.PackageNameDocument;
+import org.tianocore.PackageType;
+import org.tianocore.PackageUsage;
+import org.tianocore.SupportedArchitectures;
+import org.tianocore.common.DataValidation;
+import org.tianocore.common.Log;
+import org.tianocore.packaging.common.ui.IDefaultMutableTreeNode;
+import org.tianocore.packaging.common.ui.IInternalFrame;
+import org.tianocore.packaging.common.ui.StarLabel;
+
+/**
+ The class is used to create, update Include of MSA/MBD file
+ It extends IInternalFrame
+
+ @since ModuleEditor 1.0
+
+ **/
+public class ModuleIncludes extends IInternalFrame implements ItemListener {
+
+ ///
+ /// Define class Serial Version UID
+ ///
+ private static final long serialVersionUID = 3465193035145152131L;
+
+ //
+ //Define class members
+ //
+ private IncludesDocument.Includes includes = null;
+
+ private int location = -1;
+
+ private int intSelectedItemId = 0;
+
+ //
+ // 1 - Add; 2 - Update
+ //
+ private int operation = -1;
+
+ private Vector vPackageName = new Vector