summaryrefslogtreecommitdiff
path: root/Tools/Java/Source/ContextTool
diff options
context:
space:
mode:
Diffstat (limited to 'Tools/Java/Source/ContextTool')
-rw-r--r--Tools/Java/Source/ContextTool/ContextTool.msa31
-rw-r--r--Tools/Java/Source/ContextTool/build.xml55
-rw-r--r--Tools/Java/Source/ContextTool/org/tianocore/context/ContextMain.java48
-rw-r--r--Tools/Java/Source/ContextTool/org/tianocore/context/HelpInfo.java144
-rw-r--r--Tools/Java/Source/ContextTool/org/tianocore/context/ParseParameter.java276
-rw-r--r--Tools/Java/Source/ContextTool/org/tianocore/context/TargetFile.java403
6 files changed, 0 insertions, 957 deletions
diff --git a/Tools/Java/Source/ContextTool/ContextTool.msa b/Tools/Java/Source/ContextTool/ContextTool.msa
deleted file mode 100644
index 6135d21431..0000000000
--- a/Tools/Java/Source/ContextTool/ContextTool.msa
+++ /dev/null
@@ -1,31 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <MsaHeader>
- <ModuleName>Context Tool</ModuleName>
- <ModuleType>TOOL</ModuleType>
- <GuidValue>893c2f79-1d84-495a-a9c5-f7c1e8a58b31</GuidValue>
- <Version>0.1</Version>
- <Abstract>The tool manipulates the Tools/Conf/target.txt file.</Abstract>
- <Description>This tool is used to manipulate the target.txt file attributes from the command line.
-USAGE:
-ContextTool [-option1] [args] [-option2] [args] ...</Description>
- <Copyright>Copyright (c) 2006, Intel Corporation All rights reserved.</Copyright>
- <License URL="http://opensource.org/licenses/bsd-license.php">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.</License>
- <Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052</Specification>
- </MsaHeader>
- <ModuleDefinitions>
- <SupportedArchitectures>IA32 X64 IPF</SupportedArchitectures>
- <BinaryModule>false</BinaryModule>
- <OutputFileBasename>ContextTool</OutputFileBasename>
- </ModuleDefinitions>
- <SourceFiles>
- <Filename>org/tianocore/context/ContextMain.java</Filename>
- <Filename>org/tianocore/context/HelpInfo.java</Filename>
- <Filename>org/tianocore/context/ParseParameter.java</Filename>
- <Filename>org/tianocore/context/TargetFile.java</Filename>
- <Filename>build.xml</Filename>
- </SourceFiles>
-</ModuleSurfaceArea>
diff --git a/Tools/Java/Source/ContextTool/build.xml b/Tools/Java/Source/ContextTool/build.xml
deleted file mode 100644
index 3779dbe257..0000000000
--- a/Tools/Java/Source/ContextTool/build.xml
+++ /dev/null
@@ -1,55 +0,0 @@
-<?xml version="1.0"?>
-<!--
-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.
--->
-<project name="ContextTool" default="ContextTool" basedir=".">
-
- <taskdef resource="net/sf/antcontrib/antlib.xml"/>
- <property environment="env"/>
- <property name="WORKSPACE" value="${env.WORKSPACE}"/>
- <path id="classpath">
- <fileset dir="${WORKSPACE}/Tools/Jars" includes="SurfaceArea.jar"/>
- <fileset dir="${WORKSPACE}/Tools/Jars" includes="Common.jar"/>
- <fileset dir="${env.XMLBEANS_HOME}/lib" includes="*.jar"/>
- </path>
- <property name="buildDir" value="build"/>
- <property name="installLocation" value="${WORKSPACE}/Tools/Jars"/>
- <target name="ContextTool" depends="install"/>
- <target name="source">
- <mkdir dir="${buildDir}"/>
- <javac srcdir="." destdir="${buildDir}">
- <classpath refid="classpath"/>
- <compilerarg value="-Xlint"/>
- </javac>
- </target>
- <target name="clean">
- <delete includeemptydirs="true" failonerror="false" quiet="true">
- <fileset dir="${WORKSPACE}/Tools/Java/Source/ContextTool" includes="${buildDir}"/>
- </delete>
- </target>
- <target name="cleanall" depends="clean">
- <echo message="Removing Class Files and the Java Archive: ContextTool.jar"/>
- <delete file="${installLocation}/ContextTool.jar"/>
- <if>
- <available file="${installLocation}/ContextTool.jar"/>
- <then>
- <echo message="You must manually remove the file: ${installLocation}/ContextTool.jar"/>
- <echo message="Java has already loaded the file, and cannot remove it within ANT!"/>
- </then>
- </if>
- </target>
- <target name="install" depends="source">
- <jar destfile="${installLocation}/ContextTool.jar"
- basedir="${buildDir}"
- includes="**"
- />
- </target>
-</project>
-
diff --git a/Tools/Java/Source/ContextTool/org/tianocore/context/ContextMain.java b/Tools/Java/Source/ContextTool/org/tianocore/context/ContextMain.java
deleted file mode 100644
index 94ea56a5c7..0000000000
--- a/Tools/Java/Source/ContextTool/org/tianocore/context/ContextMain.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/** @file
- File is ContextMain 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.context;
-
-public class ContextMain {
-
- public static void main(String[] args) {
-
- if (TargetFile.validateFilename("target.txt") == false) {
- String workspacePath = System.getenv("WORKSPACE");
- System.out.printf("%n%s%n", "target.txt can't be found. Please check it in " + workspacePath + "\\Tool\\Conf");
- System.exit(0);
- }
-
- if(ParseParameter.checkParameter(args) == false){
- System.exit(0);
- }
-
- if (TargetFile.readFile() == false){
- System.exit(0);
- }
-
- if (ParseParameter.standardizeParameter(args) > 0){
- System.exit(0);
- }
-
- if (TargetFile.createTempFile("target.txt") == false){
- System.exit(0);
- }
-
- if (TargetFile.readwriteFile() == false){
- System.exit(0);
- }
-
- String workspacePath = System.getenv("WORKSPACE");
- System.out.printf("%n%s%n", workspacePath + "\\Tool\\Conf\\target.txt is updated successfully!");
- }
-}
diff --git a/Tools/Java/Source/ContextTool/org/tianocore/context/HelpInfo.java b/Tools/Java/Source/ContextTool/org/tianocore/context/HelpInfo.java
deleted file mode 100644
index af2b653016..0000000000
--- a/Tools/Java/Source/ContextTool/org/tianocore/context/HelpInfo.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/** @file
- File is HelpInfo class which is used to output the usage info.
-
-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.context;
-
-import java.util.LinkedList;
-
-public class HelpInfo {
-
-
- /**
- * output the tools usage guide
- * @param no input parameter
- * @return no return value
- **/
- public static void outputUsageInfo() {
- System.out.printf("\n%s", DescripationString);
- System.out.printf("\n%s", UsageInfoString);
- System.out.printf("\n%s", DetailOfOptionString);
-
- for (int i = 0; i < settingnum; i++) {
- outputSubUsageInfo(UsageString[i], UsageStringInfo[i]);
- }
-
- System.out.printf("\n%s", ExampleString);
- System.out.printf("\n%s", str1);
- System.out.printf("\n%s", str2);
- System.out.printf("\n%s", str3);
- System.out.printf("\n%s", str4);
- }
-
- /**
- * output the usage info which bases on cmd option
- * @param String str1 : the cmd option
- * String str2 : the detail of cmd option
- * @return no return value
- **/
- private static void outputSubUsageInfo(String str1, String str2) {
-
- splitString(str2);
- System.out.printf("\n%4s %-30s %s", "", str1, List.get(0));
- for (int i=1; i<List.size(); i++){
- System.out.printf("\n%4s %-30s %s", "", "", List.get(i));
- }
- List.clear();
- }
-
- /**
- * according to the output width, split the detail info
- * @param String str :the detail info
- * @return no return value
- **/
- private static void splitString(String str) {
- int strlength = str.length();
- if (strlength > MaxSrtingLength) {
- String[] tokens = str.split("[ ]", 0);
- String tempstr = null;
- int templength = 0;
- int start = 0;
- int end = 0;
- for (int i = 0; i < tokens.length; i++) {
- if ((templength = end + tokens[i].length() + 1) < (MaxSrtingLength + start)) {
- end = templength;
- } else {
- tempstr = str.substring(start, end);
- List.add(tempstr);
- start = end;
- i = i - 1;
- }
- }
- tempstr = str.substring(start, end - 1);
- List.add(tempstr);
- } else {
- List.add(str);
- }
- }
-
-
- private static LinkedList<String> List = new LinkedList<String>();
-
- private static final int MaxSrtingLength = 40;
-
- private static final int settingnum = 7;
-
- private static final String DescripationString = "The purpose of this tool is modifying the settings in target.txt";
-
- private static final String UsageInfoString = "Usage: ContextTool [-option1] [args] [-option2] [args] ...";
-
- private static final String DetailOfOptionString = "Where options include:";
-
- private static final String ExampleString = "Example: ContextTool -a IA32 IA64 EBC -c Tools/Conf/tools_def.txt -t DEBUG -n GCC -p EdkNt32Pkg/Nt32.fpd -m 2\n";
-
- private static final String str1 = "show current sub setting: ContextTool -x";
-
- private static final String str2 = "show possible sub setting: ContextTool -x ?";
-
- private static final String str3 = "clean current sub setting: ContextTool -x 0";
-
- private static final String str4 = "x is the sub setting option, such as p, a, n, m, t, c.\n";
-
- private static final String HString = "-h";
-
- private static final String HStringInfo = "print usage info";
-
- private static final String AString = "-a <list of Arch>";
-
- private static final String AStringInfo = "What kind of architechure is the binary target, such as IA32, IA64, X64, EBC, or ARM. Multiple values can be specified on a single line, using space to separate the values.";
-
- private static final String CString = "-c <tool_definition_file.txt>";
-
- private static final String CStringInfo = "Assign a txt file with the relative path to WORKSPACE, which specify the tools to use for the build and must be located in the path: WORKSPACE/Tools/Conf/. If no file is specified, the default filename is \"tools_def.txt\"";
-
- private static final String NString = "-n <list of TagNames>";
-
- private static final String NStringInfo = "Specify the TagName, such as GCC, MSFT, which are defined in the \"tool_definition_file.txt\"";
-
- private static final String PString = "-p <*.fpd>";
-
- private static final String PStringInfo = "Specify the WORKSPACE relative Path and Filename of platform FPD file that will be used for the build.";
-
- private static final String TString = "-t <list of Build Targets>";
-
- private static final String TStringInfo = "What kind of the version is the binary target, such as DEBUG, RELEASE. Multiple values can be specified on a single line, using space to separate the values.";
-
- private static final String MString = "-m <num of Threads>";
-
- private static final String MStringInfo = "The number of concurrent threads. Default is 2. Recommend to set this value to one more than the number of your compurter cores or CPUs. 0 will disable MULTIPLE_THREAD and clean MAX_CONCURRENT_THREAD_NUMBER.";
-
- private static final String[] UsageString = { HString, AString, CString,
- NString, PString, TString, MString };
-
- private static final String[] UsageStringInfo = { HStringInfo, AStringInfo,
- CStringInfo, NStringInfo, PStringInfo, TStringInfo, MStringInfo };
-}
diff --git a/Tools/Java/Source/ContextTool/org/tianocore/context/ParseParameter.java b/Tools/Java/Source/ContextTool/org/tianocore/context/ParseParameter.java
deleted file mode 100644
index 4d9c6de3a0..0000000000
--- a/Tools/Java/Source/ContextTool/org/tianocore/context/ParseParameter.java
+++ /dev/null
@@ -1,276 +0,0 @@
-/** @file
- File is ParseParameter class which is used to parse the validity of user's input args
- and standardize them.
-
-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.context;
-
-public class ParseParameter {
-
-
- /**
- * check the validity of user's input args
- * @param args -- user's input
- * @return true or false
- **/
- public static boolean checkParameter(String[] args) {
-
- if(args.length == 0){
- TargetFile.readFile();
- outputCurSetting();
- return false;
- } else {
- if( (args[0].compareToIgnoreCase("-h") == 0) || (args[0].compareToIgnoreCase("/h") == 0) ||
- (args[0].compareToIgnoreCase("--help") == 0) || (args[0].compareToIgnoreCase("/help") == 0) ){
- HelpInfo.outputUsageInfo();
- return false;
- }
- if( args[0].charAt(0) != '-' ){
- System.out.printf("%s\n", "Error Parameters! Please type \"ContextTool -h\" for helpinfo.");
- return false;
- }
- for(int i=0; i<args.length; i++){
- if( (args[i].startsWith("-") &&
- ((args[i].compareTo("-a") != 0) && (args[i].compareTo("-c") != 0) &&
- (args[i].compareTo("-n") != 0) && (args[i].compareTo("-p") != 0) &&
- (args[i].compareTo("-t") != 0) && (args[i].compareTo("-m") != 0)))){
- System.out.printf("%s\n", "Error Parameters! Please type \"ContextTool -h\" for helpinfo.");
- return false;
- }
- }
- }
-
- return true;
- }
-
- /**
- * standardize user's input args
- * @param args -- user's input
- * @return no return value
- **/
- public static int standardizeParameter(String[] args) {
-
-
- StringBuffer InputData = new StringBuffer();
- for (int i = 0; i < args.length; i++) {
- InputData.append(args[i]);
- InputData.append(" ");
- }
-
- int i = 0;
- while (i < InputData.length()) {
- int j = InputData.indexOf("-", i + 1);
- if (j == -1)
- j = InputData.length();
-
- String argstr = InputData.substring(i, j);
- i = j;
- if (argstr.charAt(1) == 'p') {
- //
- // argstr is "-p ", display current setting
- //
- if(argstr.length() < 4 && argstr.charAt(2) == ' '){
- if (curpstr != null) {
- System.out.printf("%s\n", curpstr);
- } else {
- System.out.printf("No ACTIVE_PLATFORM defined \n");
- }
- return 1;
- }
- //
- //argstr is "-p ? ", display possible setting
- //
- if(argstr.length() < 6 && argstr.charAt(3) == '?'){
- String workspacePath = System.getenv("WORKSPACE");
- System.out.printf( "%s\n", "Assign a platform FPD file with relative path to " + workspacePath);
- return 2;
- }
- //
- //argstr is "-p 0 ", clean current setting
- //
- if(argstr.length() < 6 && argstr.charAt(3) == '0'){
- curpstr = pstr;
- npflag = true;
- continue;
- }
- String[] S = argstr.split(" ");
- if(S.length > 2){
- System.out.printf( "%s\n", "There should be none or only one ACTIVE_PLATFORM. Please check the number of value which follow \"-p\".");
- return 3;
- }
- curpstr = pstr.concat(argstr.substring(2));
- npflag = true;
- } else if (argstr.charAt(1) == 't') {
- if(argstr.length() < 4 && argstr.charAt(2) == ' '){
- if (curtstr != null) {
- System.out.printf("%s\n", curtstr);
- } else {
- System.out.printf("No TARGET defined\n");
- }
- return 1;
- }
- if(argstr.length() < 6 && argstr.charAt(3) == '?'){
- System.out.printf( "%s\n", "What kind of the version is the binary target, such as DEBUG, RELEASE." );
- return 2;
- }
- if(argstr.length() < 6 && argstr.charAt(3) == '0'){
- curtstr = tstr;
- ntflag = true;
- continue;
- }
- curtstr = tstr.concat(argstr.substring(2));
- ntflag = true;
- } else if (argstr.charAt(1) == 'a') {
- if(argstr.length() < 4 && argstr.charAt(2) == ' '){
- if (curastr != null) {
- System.out.printf("%s\n", curastr);
- } else {
- System.out.printf("No TARGET_ARCH defined\n");
- }
- return 1;
- }
- if(argstr.length() < 6 && argstr.charAt(3) == '?'){
- System.out.printf( "%s\n", "What kind of architechure is the binary target, such as IA32, IA64, X64, EBC, or ARM." );
- return 2;
- }
- if(argstr.length() < 6 && argstr.charAt(3) == '0'){
- curastr = astr;
- naflag = true;
- continue;
- }
- curastr = astr.concat(argstr.substring(2));
- naflag = true;
- } else if (argstr.charAt(1) == 'c') {
- if(argstr.length() < 4 && argstr.charAt(2) == ' '){
- if (curcstr != null) {
- System.out.printf("%s\n", curcstr);
- } else {
- System.out.printf("No TOOL_CHAIN_CONF defined\n");
- }
- return 1;
- }
- if(argstr.length() < 6 && argstr.charAt(3) == '?'){
- String workspacePath = System.getenv("WORKSPACE");
- System.out.printf( "%s\n", "Assign a txt file with relative path to " + workspacePath + ", which specify the tools to use for the build and must be located in the path:" + workspacePath + "\\Tools\\Conf" );
- return 2;
- }
- if(argstr.length() < 6 && argstr.charAt(3) == '0'){
- curcstr = cstr;
- ncflag = true;
- continue;
- }
- String[] S = argstr.split(" ");
- if(S.length > 2){
- System.out.printf( "%s\n", "There should be one and only one TOOL_CHAIN_CONF. Please check the number of value which follow \"-c\".");
- return 3;
- }
- curcstr = cstr.concat(argstr.substring(2));
- ncflag = true;
- } else if (argstr.charAt(1) == 'n') {
- if(argstr.length() < 4 && argstr.charAt(2) == ' '){
- if (curnstr != null) {
- System.out.printf("%s\n", curnstr);
- } else {
- System.out.printf("No TOOL_CHAIN_TAG defined\n");
- }
- return 1;
- }
- if(argstr.length() < 6 && argstr.charAt(3) == '?'){
- System.out.printf( "%s\n", "Specify the TagName, such as GCC, MSFT." );
- return 2;
- }
- if(argstr.length() < 6 && argstr.charAt(3) == '0'){
- curnstr = nstr;
- nnflag = true;
- continue;
- }
- curnstr = nstr.concat(argstr.substring(2));
- nnflag = true;
- } else if (argstr.charAt(1) == 'm') {
- if(argstr.length() < 4 && argstr.charAt(2) == ' '){
- if (curmstr != null) {
- System.out.printf("%s\n", curmstr);
- } else {
- System.out.printf("No MAX_CONCURRENT_THREAD_NUMBER defined\n");
- }
- return 1;
- }
- if(argstr.length() < 6 && argstr.charAt(3) == '?'){
- System.out.printf( "%s\n", "The number of concurrent threads. Default is 2. Recommend to set this value to one more than the number of your compurter cores or CPUs." );
- return 2;
- }
- String[] S = argstr.split(" ");
- if(S.length > 2){
- System.out.printf( "%s\n", "There should be one and only one integer, which doesn't include space.");
- return 3;
- }
- mstr += argstr.substring(2);
- curmstr = mstr;
- nmflag = true;
- if (argstr.charAt(3) == '0'){
- mestr += " Disable";
- } else {
- mestr += " Enable";
- }
- curmestr = mestr;
- nmeflag = true;
- }
-
- }
- return 0;
- }
-
-
- public static boolean outputCurSetting(){
-
- System.out.printf( "%s\n", "The current setting is:" );
- String[] A = { pstr, tstr, astr, cstr, nstr, mstr, mestr };
- String[] B = { curpstr, curtstr, curastr, curcstr, curnstr, curmstr, curmestr };
-
- for(int i=0; i<A.length; i++){
- if(B[i] != null){
- System.out.printf( "%s\n", B[i] );
- }
- else{
- System.out.printf( "%s\n", A[i] );
- }
-
- }
-
- return true;
- }
-
-
- public static String pstr = new String("ACTIVE_PLATFORM = ");
- public static String tstr = new String("TARGET = ");
- public static String astr = new String("TARGET_ARCH = ");
- public static String cstr = new String("TOOL_CHAIN_CONF = ");
- public static String nstr = new String("TOOL_CHAIN_TAG = ");
- public static String mstr = new String("MAX_CONCURRENT_THREAD_NUMBER = ");
- public static String mestr = new String("MULTIPLE_THREAD = ");
-
- public static String curpstr = null;
- public static String curtstr = null;
- public static String curastr = null;
- public static String curcstr = null;
- public static String curnstr = null;
- public static String curmstr = null;
- public static String curmestr = null;
-
- public static boolean npflag = false;
- public static boolean ntflag = false;
- public static boolean naflag = false;
- public static boolean ncflag = false;
- public static boolean nnflag = false;
- public static boolean nmflag = false;
- public static boolean nmeflag = false;
-
-}
diff --git a/Tools/Java/Source/ContextTool/org/tianocore/context/TargetFile.java b/Tools/Java/Source/ContextTool/org/tianocore/context/TargetFile.java
deleted file mode 100644
index 122adf03ce..0000000000
--- a/Tools/Java/Source/ContextTool/org/tianocore/context/TargetFile.java
+++ /dev/null
@@ -1,403 +0,0 @@
-/** @file
- File is TargetFile class which is used to generate the new target.txt.
-
-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.context;
-
-import java.io.BufferedReader;
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileReader;
-import java.io.FileWriter;
-import java.io.IOException;
-
-public class TargetFile {
-
-
-
- /**
- * validate the filename
- * @param String filename : the name of target file
- *
- * @return true or false
- **/
- public static boolean validateFilename(String filename) {
-
- String workspacePath = System.getenv("WORKSPACE");
-
- Fd = new File(workspacePath + File.separator + "Tools" + File.separator + "Conf" + File.separator + filename);
-
- if (Fd.exists() == true && Fd.canRead() == true)
- return true;
- else
- return false;
- }
-
-
- /**
- * create a empty temp file, which is located at the same directory with target file
- * @param String filename : the name of target temp file
- * @return true or false
- **/
- public static boolean createTempFile(String filename) {
-
- String workspacePath = System.getenv("WORKSPACE");
-
- TempFd = new File(workspacePath + File.separator + "Tools" + File.separator + "Conf" + File.separator + filename + "tmp");
-
- if (TempFd.exists() == true) {
- if (TempFd.delete() == false) {
- System.out.printf("%n%s%n", "target.txttmp has been existed, and failed in deletion!");
- return false;
- }
- }
- try {
- TempFd.createNewFile();
- } catch (IOException e) {
- System.out.printf("%n%s%n", "Failed in creation of the temp file:target.txttmp!");
- return false;
- }
-
- return true;
- }
-
- /**
- * read from target.txt and write to target.txttmp, del target.txt, rename
- * @param no paremeter
- * @return true or false
- **/
- public static boolean readwriteFile() {
-
- if (Fd.canRead() != true)
- return false;
-
- BufferedReader br = null;
- BufferedWriter bw = null;
- String textLine = null;
-
- try {
- br = new BufferedReader(new FileReader(Fd));
- } catch (FileNotFoundException e) {
- System.out
- .println("\n# Creating BufferedReader fail!");
- return false;
- }
- try {
- bw = new BufferedWriter(new FileWriter(TempFd));
- } catch (IOException e) {
- System.out.println("\n# Creating the BufferedWriter fail!");
- return false;
- }
-
- //
- //TARGET_ARCH must be in front of TARGET!!! according to the target.txt
- //
- try {
- while ((textLine = br.readLine()) != null) {
- //
- // the line is composed of Space
- //
- if (textLine.trim().compareToIgnoreCase("") == 0) {
- bw.write(textLine);
- bw.newLine();
- }
- //
- // the line starts with "#", and no "="
- //
- else if ((textLine.trim().charAt(0) == '#') && (textLine.indexOf("=") == -1)){
- bw.write(textLine);
- bw.newLine();
- } else {
- //
- //modify at the first time, and there should be "*ACTIVE_PLATFORM*=*" in the line
- //
- if (textLine.indexOf("ACTIVE_PLATFORM") != -1) {
- if(pflag == true){
- if(textLine.trim().charAt(0) == '#'){
- if(ParseParameter.npflag == true) {
- bw.write(ParseParameter.curpstr);
- }else{
- bw.write(textLine);
- }
- bw.newLine();
- pflag = false;
- continue;
- }
- if(ParseParameter.npflag == true) {
- bw.write(ParseParameter.curpstr);
- } else {
- bw.write(textLine);
- }
- bw.newLine();
- pflag = false;
- }
- } else if (textLine.indexOf("TARGET_ARCH") != -1) {
- if(aflag == true){
- if(textLine.trim().charAt(0) == '#'){
- if(ParseParameter.naflag == true) {
- bw.write(ParseParameter.curastr);
- }else{
- bw.write(textLine);
- }
- bw.newLine();
- aflag = false;
- continue;
- }
- if(ParseParameter.naflag == true) {
- bw.write(ParseParameter.curastr);
- } else {
- bw.write(textLine);
- }
- bw.newLine();
- aflag = false;
- }
- } else if (textLine.indexOf("TARGET") != -1) {
- if(tflag == true){
- if(textLine.trim().charAt(0) == '#'){
- if(ParseParameter.ntflag == true) {
- bw.write(ParseParameter.curtstr);
- }else{
- bw.write(textLine);
- }
- bw.newLine();
- tflag = false;
- continue;
- }
- if(ParseParameter.ntflag == true) {
- bw.write(ParseParameter.curtstr);
- } else {
- bw.write(textLine);
- }
- bw.newLine();
- tflag = false;
- }
- } else if (textLine.indexOf("TOOL_CHAIN_CONF") != -1) {
- if(cflag == true){
- if(textLine.trim().charAt(0) == '#'){
- if(ParseParameter.ncflag == true) {
- bw.write(ParseParameter.curcstr);
- }else{
- bw.write(textLine);
- }
- bw.newLine();
- cflag = false;
- continue;
- }
- if(ParseParameter.ncflag == true) {
- bw.write(ParseParameter.curcstr);
- } else {
- bw.write(textLine);
- }
- bw.newLine();
- cflag = false;
- }
- } else if (textLine.indexOf("TOOL_CHAIN_TAG") != -1) {
- if(nflag == true){
- if(textLine.trim().charAt(0) == '#'){
- if(ParseParameter.nnflag == true) {
- bw.write(ParseParameter.curnstr);
- }else{
- bw.write(textLine);
- }
- bw.newLine();
- nflag = false;
- continue;
- }
- if(ParseParameter.nnflag == true) {
- bw.write(ParseParameter.curnstr);
- } else {
- bw.write(textLine);
- }
- bw.newLine();
- nflag = false;
- }
- } else if (textLine.indexOf("MAX_CONCURRENT_THREAD_NUMBER") != -1) {
- if(mflag == true){
- if(textLine.trim().charAt(0) == '#'){
- if(ParseParameter.nmflag == true) {
- bw.write(ParseParameter.curmstr);
- }else{
- bw.write(textLine);
- }
- bw.newLine();
- mflag = false;
- continue;
- }
- if(ParseParameter.nmflag == true) {
- bw.write(ParseParameter.curmstr);
- } else {
- bw.write(textLine);
- }
- bw.newLine();
- mflag = false;
- }
- }else if (textLine.indexOf("MULTIPLE_THREAD") != -1) {
- if(meflag == true){
- if(textLine.trim().charAt(0) == '#'){
- if(ParseParameter.nmeflag == true) {
- bw.write(ParseParameter.curmestr);
- }else{
- bw.write(textLine);
- }
- bw.newLine();
- meflag = false;
- continue;
- }
- if(ParseParameter.nmeflag == true) {
- bw.write(ParseParameter.curmestr);
- } else {
- bw.write(textLine);
- }
- bw.newLine();
- meflag = false;
- }
- }
- }
- }
- //
- //user maybe delete the line *ACTIVE_PLATFORM*=*
- //
- if( (pflag == true) && (ParseParameter.npflag == true) ){
- bw.write(ParseParameter.curpstr);
- bw.newLine();
- } else if ( (tflag == true) && (ParseParameter.ntflag == true) ){
- bw.write(ParseParameter.curtstr);
- bw.newLine();
- } else if ( (aflag == true) && (ParseParameter.naflag == true) ){
- bw.write(ParseParameter.curastr);
- bw.newLine();
- } else if ( (cflag == true) && (ParseParameter.ncflag == true) ){
- bw.write(ParseParameter.curcstr);
- bw.newLine();
- } else if ( (nflag == true) && (ParseParameter.nnflag == true) ){
- bw.write(ParseParameter.curnstr);
- bw.newLine();
- } else if ( (meflag == true) && (ParseParameter.nmeflag == true) ){
- bw.write(ParseParameter.curmestr);
- bw.newLine();
- } else if ( (mflag == true) && (ParseParameter.nmflag == true) ){
- bw.write(ParseParameter.curmstr);
- bw.newLine();
- }
- } catch (IOException e) {
- System.out.println("\n# Reading or Writing file fail!");
- return false;
- }
-
- try {
- br.close();
- bw.close();
- } catch (IOException e) {
- System.out
- .println("\n# Closing BufferedReader&BufferedWriter fail!");
- return false;
- }
-
- if (Fd.delete() == false) {
- System.out.println("\n# Deleting file fail!");
- return false;
- }
- if (TempFd.renameTo(Fd) == false) {
- System.out.println("\n# Renaming file failed!");
- return false;
- }
-
- return true;
- }
-
- /**
- * read the file and output the lines which include setting
- * @param File fd : the File of the target file
- * @return String: the current setting
- **/
- public static boolean readFile() {
-
- BufferedReader br = null;
- String textLine = null;
-
- try {
- br = new BufferedReader(new FileReader(Fd));
- } catch (FileNotFoundException e) {
- System.out
- .println("\n# Creating BufferedReader fail!");
- return false;
- }
- try {
- while ((textLine = br.readLine()) != null) {
- //
- // the line is composed of Space
- //
- if (textLine.trim().compareToIgnoreCase("") == 0) {
- continue;
- }
- //
- // the line starts with "#"
- //
- else if ((textLine.trim().charAt(0) == '#')){
- continue;
- } else {
- if (textLine.indexOf("ACTIVE_PLATFORM") != -1) {
- ParseParameter.curpstr = textLine;
- } else if (textLine.indexOf("TARGET_ARCH") != -1) {
- ParseParameter.curastr = textLine;
- } else if (textLine.indexOf("TARGET") != -1) {
- ParseParameter.curtstr = textLine;
- } else if (textLine.indexOf("TOOL_CHAIN_CONF") != -1) {
- ParseParameter.curcstr = textLine;
- } else if (textLine.indexOf("TOOL_CHAIN_TAG") != -1) {
- ParseParameter.curnstr = textLine;
- } else if (textLine.indexOf("MAX_CONCURRENT_THREAD_NUMBER") != -1) {
- ParseParameter.curmstr = textLine;
- } else if (textLine.indexOf("MULTIPLE_THREAD") != -1) {
- ParseParameter.curmestr = textLine;
- }
- }
- }
- } catch (IOException e) {
- System.out.println("\n# Reading file fail!");
- return false;
- }
-
- try {
- br.close();
- } catch (IOException e) {
- System.out
- .println("\n# Closing BufferedReader fail!");
- return false;
- }
- return true;
- }
-
-
- ///
- /// point to target.txttmp, a temp file, which is created and deleted during the tool's runtime.
- ///
- private static File TempFd;
-
- ///
- /// point to target.txt.
- ///
- private static File Fd;
-
- ///
- /// when the flag is true, the corresponding str should be add at the end of file.
- ///
- private static boolean pflag = true;
- private static boolean tflag = true;
- private static boolean aflag = true;
- private static boolean cflag = true;
- private static boolean nflag = true;
- private static boolean mflag = true;
- private static boolean meflag = true;
-
-
-}