mirror of https://github.com/acidanthera/audk.git
Added support for macro/property in tools_def.txt. Now you can define a property via environment variable and use it in tools_def.txt and target.txt in the form of ${name}
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@2094 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
a96f893c14
commit
2251a36013
|
@ -197,7 +197,7 @@ public class FrameworkBuildTask extends Task{
|
|||
//
|
||||
File workspacePath = new File(getProject().getProperty("WORKSPACE"));
|
||||
getProject().setProperty("WORKSPACE_DIR", workspacePath.getPath().replaceAll("(\\\\)", "/"));
|
||||
GlobalData.initInfo(dbFilename, workspacePath.getPath(), toolsDefFilename);
|
||||
GlobalData.initInfo(getProject(), dbFilename, workspacePath.getPath(), toolsDefFilename);
|
||||
|
||||
//
|
||||
// If find MSA file and ACTIVE_PLATFORM is set, build the module;
|
||||
|
@ -333,7 +333,7 @@ public class FrameworkBuildTask extends Task{
|
|||
private void readTargetFile() throws EdkException{
|
||||
String targetFile = getProject().getProperty("WORKSPACE_DIR") + File.separatorChar + targetFilename;
|
||||
|
||||
String[][] targetFileInfo = ConfigReader.parse(targetFile);
|
||||
String[][] targetFileInfo = ConfigReader.parse(getProject(), targetFile);
|
||||
|
||||
//
|
||||
// Get ToolChain Info from target.txt
|
||||
|
|
|
@ -28,6 +28,7 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.tools.ant.Project;
|
||||
import org.apache.xmlbeans.XmlException;
|
||||
import org.apache.xmlbeans.XmlObject;
|
||||
import org.apache.xmlbeans.XmlOptions;
|
||||
|
@ -146,7 +147,7 @@ public class GlobalData {
|
|||
@throws BuildException
|
||||
Framework Dababase or SPD or MSA file is not valid
|
||||
**/
|
||||
public synchronized static void initInfo(String workspaceDatabaseFile, String workspaceDir, String toolsDefFilename ) throws EdkException {
|
||||
public synchronized static void initInfo(Project prj, String workspaceDatabaseFile, String workspaceDir, String toolsDefFilename ) throws EdkException {
|
||||
//
|
||||
// ensure this method will be revoked only once
|
||||
//
|
||||
|
@ -169,7 +170,7 @@ public class GlobalData {
|
|||
//
|
||||
File toolsDefFile = new File(workspaceDir + File.separatorChar + toolsDefFilename);
|
||||
EdkLog.log("Init", EdkLog.EDK_ALWAYS, "Using tool definition file [" + toolsDefFile.getPath() + "].");
|
||||
toolsDef = new ToolChainConfig(toolsDefFile);
|
||||
toolsDef = new ToolChainConfig(prj, toolsDefFile);
|
||||
|
||||
//
|
||||
// Parse Framework Database
|
||||
|
|
|
@ -14,6 +14,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|||
**/
|
||||
package org.tianocore.build.toolchain;
|
||||
|
||||
import org.apache.tools.ant.Project;
|
||||
|
||||
import org.tianocore.build.exception.GenBuildException;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
|
@ -38,8 +40,8 @@ public class ConfigReader {
|
|||
|
||||
@return String[][] The definition array
|
||||
**/
|
||||
public static synchronized String[][] parse(String filename) throws GenBuildException {
|
||||
return parse(new File(filename));
|
||||
public static synchronized String[][] parse(Project prj, String filename) throws GenBuildException {
|
||||
return parse(prj, new File(filename));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -53,7 +55,7 @@ public class ConfigReader {
|
|||
@throws GenBuildException
|
||||
Config file's format is not valid
|
||||
**/
|
||||
public static synchronized String[][] parse(File configFile) throws GenBuildException {
|
||||
public static synchronized String[][] parse(Project prj, File configFile) throws GenBuildException {
|
||||
List<String> keyList = new ArrayList<String>(256);
|
||||
List<String> valueList = new ArrayList<String>(256);
|
||||
int lines = 0;
|
||||
|
@ -87,7 +89,11 @@ public class ConfigReader {
|
|||
// look as line "A = B"
|
||||
//
|
||||
keyList.add(str.substring(0, index).trim());
|
||||
valueList.add(str.substring(index + 1).trim());
|
||||
if (prj != null) {
|
||||
valueList.add(prj.replaceProperties(str.substring(index + 1).trim()));
|
||||
} else {
|
||||
valueList.add(str.substring(index + 1).trim());
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
GenBuildException e = new GenBuildException("ERROR Processing file ["
|
||||
|
|
|
@ -15,14 +15,15 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|||
**/
|
||||
package org.tianocore.build.toolchain;
|
||||
|
||||
import org.tianocore.build.exception.GenBuildException;
|
||||
import org.tianocore.build.toolchain.ToolChainKey;
|
||||
import org.tianocore.build.toolchain.ToolChainMap;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.tools.ant.Project;
|
||||
import org.tianocore.build.exception.GenBuildException;
|
||||
import org.tianocore.build.toolchain.ToolChainKey;
|
||||
import org.tianocore.build.toolchain.ToolChainMap;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
|
@ -44,8 +45,8 @@ public class ToolChainConfig {
|
|||
|
||||
@param toolChainFile File object representing the tool chain configuration file
|
||||
**/
|
||||
public ToolChainConfig (File toolChainFile) throws GenBuildException {
|
||||
config = getToolChainConfig(toolChainFile);
|
||||
public ToolChainConfig (Project prj, File toolChainFile) throws GenBuildException {
|
||||
config = getToolChainConfig(prj, toolChainFile);
|
||||
parseToolChainDefKey(config.keySet());
|
||||
}
|
||||
|
||||
|
@ -57,9 +58,9 @@ public class ToolChainConfig {
|
|||
|
||||
@return ToolChainMap
|
||||
**/
|
||||
private ToolChainMap getToolChainConfig(File ConfigFile) throws GenBuildException {
|
||||
private ToolChainMap getToolChainConfig(Project prj, File ConfigFile) throws GenBuildException {
|
||||
ToolChainMap map = new ToolChainMap();
|
||||
String[][] toolChainDef = ConfigReader.parse(ConfigFile);
|
||||
String[][] toolChainDef = ConfigReader.parse(prj, ConfigFile);
|
||||
|
||||
for (int i = 0; i < toolChainDef[0].length; ++i) {
|
||||
map.put(toolChainDef[0][i], toolChainDef[1][i]);
|
||||
|
|
Loading…
Reference in New Issue