From: jjin9 Date: Tue, 24 Oct 2006 01:02:59 +0000 (+0000) Subject: 1.add code to support friendly output message. X-Git-Tag: edk2-stable201903~24043 X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=commitdiff_plain;h=c81f5d4433eaa8f0eaaa7d2c73cd193a6ca9a230 1.add code to support friendly output message. 2.fix the bug, and support "ContextTool /?" git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1831 6f19259b-4bc3-4df7-8a09-765794883524 --- diff --git a/Tools/Java/Source/ContextTool/org/tianocore/context/ContextMain.java b/Tools/Java/Source/ContextTool/org/tianocore/context/ContextMain.java index 7ee7d6c7c9..e96bb07fe0 100644 --- a/Tools/Java/Source/ContextTool/org/tianocore/context/ContextMain.java +++ b/Tools/Java/Source/ContextTool/org/tianocore/context/ContextMain.java @@ -17,7 +17,8 @@ public class ContextMain { public static void main(String[] args) { if (TargetFile.validateFilename("target.txt") == false) { - System.out.printf("%n%s", "Target.txt can't be found in WorkSpace. Please check it!"); + 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); } @@ -41,6 +42,7 @@ public class ContextMain { System.exit(0); } - System.out.printf("%n%s", "Target.txt generate successfully!"); + String workspacePath = System.getenv("WORKSPACE"); + System.out.printf("%n%s%n", workspacePath + "\\Tool\\Conf\\target.txt is generated successfully!"); } } diff --git a/Tools/Java/Source/ContextTool/org/tianocore/context/HelpInfo.java b/Tools/Java/Source/ContextTool/org/tianocore/context/HelpInfo.java index ca9b099883..af2b653016 100644 --- a/Tools/Java/Source/ContextTool/org/tianocore/context/HelpInfo.java +++ b/Tools/Java/Source/ContextTool/org/tianocore/context/HelpInfo.java @@ -33,6 +33,10 @@ public class HelpInfo { } 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); } /** @@ -96,6 +100,14 @@ public class HelpInfo { 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"; diff --git a/Tools/Java/Source/ContextTool/org/tianocore/context/ParseParameter.java b/Tools/Java/Source/ContextTool/org/tianocore/context/ParseParameter.java index 6b210ec1af..d58d28b010 100644 --- a/Tools/Java/Source/ContextTool/org/tianocore/context/ParseParameter.java +++ b/Tools/Java/Source/ContextTool/org/tianocore/context/ParseParameter.java @@ -35,7 +35,7 @@ public class ParseParameter { return false; } if( args[0].charAt(0) != '-' ){ - System.out.printf("%s\n", "Error arguments! Please type \"ContextTool -h\" for helpinfo."); + System.out.printf("%s\n", "Error Parameters! Please type \"ContextTool -h\" for helpinfo."); return false; } for(int i=0; i 2){ - System.out.printf( "%s\n", "The number of ACTIVE_PLATFORM can not more than 1."); + 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)); @@ -110,7 +111,7 @@ public class ParseParameter { 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" ); + 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'){ @@ -126,7 +127,7 @@ public class ParseParameter { 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" ); + 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'){ @@ -142,7 +143,8 @@ public class ParseParameter { return 1; } if(argstr.length() < 6 && argstr.charAt(3) == '?'){ - System.out.printf( "%s\n", "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/" ); + 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'){ @@ -152,7 +154,7 @@ public class ParseParameter { } String[] S = argstr.split(" "); if(S.length > 2){ - System.out.printf( "%s\n", "The number of TOOL_CHAIN_CONF can not more than 1."); + 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)); @@ -163,7 +165,7 @@ public class ParseParameter { return 1; } if(argstr.length() < 6 && argstr.charAt(3) == '?'){ - System.out.printf( "%s\n", "Specify the TagName, such as GCC, MSFT" ); + System.out.printf( "%s\n", "Specify the TagName, such as GCC, MSFT." ); return 2; } if(argstr.length() < 6 && argstr.charAt(3) == '0'){ @@ -184,7 +186,7 @@ public class ParseParameter { } String[] S = argstr.split(" "); if(S.length > 2){ - System.out.printf( "%s\n", "The format of number is wrong."); + System.out.printf( "%s\n", "There should be one and only one integer, which doesn't include space."); return 3; } mstr += argstr.substring(2); @@ -259,8 +261,7 @@ public class ParseParameter { return true; } - - public static int length = 0; + public static String pstr = new String("ACTIVE_PLATFORM = "); public static String tstr = new String("TARGET = "); public static String astr = new String("TARGET_ARCH = "); @@ -277,14 +278,6 @@ public class ParseParameter { public static String curmstr = null; public static String curmestr = null; - public static int plength = 0; - public static int tlength = 0; - public static int alength = 0; - public static int clength = 0; - public static int nlength = 0; - public static int mlength = 0; - public static int melength = 0; - public static boolean npflag = false; public static boolean ntflag = false; public static boolean naflag = false; diff --git a/Tools/Java/Source/ContextTool/org/tianocore/context/TargetFile.java b/Tools/Java/Source/ContextTool/org/tianocore/context/TargetFile.java index 06a031c8bb..122adf03ce 100644 --- a/Tools/Java/Source/ContextTool/org/tianocore/context/TargetFile.java +++ b/Tools/Java/Source/ContextTool/org/tianocore/context/TargetFile.java @@ -16,46 +16,13 @@ import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; import java.io.FileNotFoundException; -import java.io.FileOutputStream; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; -import java.nio.ByteBuffer; -import java.nio.channels.FileChannel; public class TargetFile { - /** - * check the validity of path and file - * @param String filename : the name of target file - * @return true or false - **/ - public static boolean setFile(String filename) { - - String workspacePath = System.getenv("WORKSPACE"); - - Fd = new File(workspacePath + File.separator + "Tools" + File.separator + "Conf" + File.separator + filename); - - if (Fd.exists() == true) { - if (createTempFile(filename + "tmp") == false) { - return false; - } - if (readwriteFile() == false) { - return false; - } - return true; - } else { - try { - Fd.createNewFile(); - } catch (IOException e) { - System.out.printf("%n%s", "Create the file:target.txt failed!"); - return false; - } - } - TargetFile.writeFile(Fd); - return true; - } - + /** * validate the filename @@ -89,15 +56,14 @@ public class TargetFile { if (TempFd.exists() == true) { if (TempFd.delete() == false) { - System.out.println("\n# delete file failed !"); + 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", - "Create the temp file:target.txttmp failed!"); + System.out.printf("%n%s%n", "Failed in creation of the temp file:target.txttmp!"); return false; } @@ -122,13 +88,13 @@ public class TargetFile { br = new BufferedReader(new FileReader(Fd)); } catch (FileNotFoundException e) { System.out - .println("\n# create the BufferedReader failed, because can't find the file:target.txt!"); + .println("\n# Creating BufferedReader fail!"); return false; } try { bw = new BufferedWriter(new FileWriter(TempFd)); } catch (IOException e) { - System.out.println("\n# create the BufferedWriter failed!"); + System.out.println("\n# Creating the BufferedWriter fail!"); return false; } @@ -323,7 +289,7 @@ public class TargetFile { bw.newLine(); } } catch (IOException e) { - System.out.println("\n# read or write file error!"); + System.out.println("\n# Reading or Writing file fail!"); return false; } @@ -332,16 +298,16 @@ public class TargetFile { bw.close(); } catch (IOException e) { System.out - .println("\n# close BufferedReader&BufferedWriter error"); + .println("\n# Closing BufferedReader&BufferedWriter fail!"); return false; } if (Fd.delete() == false) { - System.out.println("\n# delete file failed !"); + System.out.println("\n# Deleting file fail!"); return false; } if (TempFd.renameTo(Fd) == false) { - System.out.println("\n# rename file failed !"); + System.out.println("\n# Renaming file failed!"); return false; } @@ -362,7 +328,7 @@ public class TargetFile { br = new BufferedReader(new FileReader(Fd)); } catch (FileNotFoundException e) { System.out - .println("\n# create the BufferedReader failed, because can't find the file:target.txt!"); + .println("\n# Creating BufferedReader fail!"); return false; } try { @@ -381,30 +347,23 @@ public class TargetFile { } else { if (textLine.indexOf("ACTIVE_PLATFORM") != -1) { ParseParameter.curpstr = textLine; - ParseParameter.plength = textLine.indexOf('='); } else if (textLine.indexOf("TARGET_ARCH") != -1) { ParseParameter.curastr = textLine; - ParseParameter.alength = textLine.indexOf('='); } else if (textLine.indexOf("TARGET") != -1) { ParseParameter.curtstr = textLine; - ParseParameter.tlength = textLine.indexOf('='); } else if (textLine.indexOf("TOOL_CHAIN_CONF") != -1) { ParseParameter.curcstr = textLine; - ParseParameter.clength = textLine.indexOf('='); } else if (textLine.indexOf("TOOL_CHAIN_TAG") != -1) { ParseParameter.curnstr = textLine; - ParseParameter.nlength = textLine.indexOf('='); } else if (textLine.indexOf("MAX_CONCURRENT_THREAD_NUMBER") != -1) { ParseParameter.curmstr = textLine; - ParseParameter.mlength = textLine.indexOf('='); } else if (textLine.indexOf("MULTIPLE_THREAD") != -1) { ParseParameter.curmestr = textLine; - ParseParameter.melength = textLine.indexOf('='); } } } } catch (IOException e) { - System.out.println("\n# read file error!"); + System.out.println("\n# Reading file fail!"); return false; } @@ -412,102 +371,13 @@ public class TargetFile { br.close(); } catch (IOException e) { System.out - .println("\n# close BufferedReader error"); + .println("\n# Closing BufferedReader fail!"); return false; } return true; } - /** - * according to user's input args, write the file directly - * @param File fd : the File of the target file - * @return true or false - **/ - private static boolean writeFile(File fd) { - - if (fd.canWrite() != true) - return false; - - FileOutputStream outputFile = null; - try { - outputFile = new FileOutputStream(fd); - } catch (FileNotFoundException e) { - System.out - .println("\n# can't find the file when open the output stream !"); - return false; - } - FileChannel outputChannel = outputFile.getChannel(); - - ByteBuffer[] buffers = new ByteBuffer[7]; - buffers[0] = ByteBuffer.allocate(ParseParameter.pstr.toString().length()); - buffers[1] = ByteBuffer.allocate(ParseParameter.tstr.toString().length()); - buffers[2] = ByteBuffer.allocate(ParseParameter.astr.toString().length()); - buffers[3] = ByteBuffer.allocate(ParseParameter.cstr.toString().length()); - buffers[4] = ByteBuffer.allocate(ParseParameter.nstr.toString().length()); - buffers[5] = ByteBuffer.allocate(ParseParameter.mestr.toString().length()); - buffers[6] = ByteBuffer.allocate(ParseParameter.mstr.toString().length()); - - buffers[0].put(ParseParameter.pstr.toString().getBytes()).flip(); - buffers[1].put(ParseParameter.tstr.toString().getBytes()).flip(); - buffers[2].put(ParseParameter.astr.toString().getBytes()).flip(); - buffers[3].put(ParseParameter.cstr.toString().getBytes()).flip(); - buffers[4].put(ParseParameter.nstr.toString().getBytes()).flip(); - buffers[5].put(ParseParameter.mestr.toString().getBytes()).flip(); - buffers[6].put(ParseParameter.mstr.toString().getBytes()).flip(); - - try { - ByteBuffer bufofCP = ByteBuffer.allocate(Copyright.length()); - bufofCP.put(Copyright.getBytes()).flip(); - outputChannel.write(bufofCP); - - ByteBuffer bufofFI = ByteBuffer.allocate(Fileinfo.length()); - bufofFI.put(Fileinfo.getBytes()).flip(); - outputChannel.write(bufofFI); - - ByteBuffer buffer0 = ByteBuffer.allocate(pusage.length()); - buffer0.put(pusage.getBytes()).flip(); - outputChannel.write(buffer0); - outputChannel.write(buffers[0]); - - ByteBuffer buffer1 = ByteBuffer.allocate(tusage.length()); - buffer1.put(tusage.getBytes()).flip(); - outputChannel.write(buffer1); - outputChannel.write(buffers[1]); - - ByteBuffer buffer2 = ByteBuffer.allocate(ausage.length()); - buffer2.put(ausage.getBytes()).flip(); - outputChannel.write(buffer2); - outputChannel.write(buffers[2]); - - ByteBuffer buffer3 = ByteBuffer.allocate(cusage.length()); - buffer3.put(cusage.getBytes()).flip(); - outputChannel.write(buffer3); - outputChannel.write(buffers[3]); - - ByteBuffer buffer4 = ByteBuffer.allocate(nusage.length()); - buffer4.put(nusage.getBytes()).flip(); - outputChannel.write(buffer4); - outputChannel.write(buffers[4]); - - ByteBuffer buffer5 = ByteBuffer.allocate(meusage.length()); - buffer4.put(meusage.getBytes()).flip(); - outputChannel.write(buffer5); - outputChannel.write(buffers[5]); - - ByteBuffer buffer6 = ByteBuffer.allocate(musage.length()); - buffer4.put(musage.getBytes()).flip(); - outputChannel.write(buffer6); - outputChannel.write(buffers[6]); - - outputFile.close(); - } catch (IOException e) { - System.out.println("\n# The operations of file failed !"); - return false; - } - return true; - } - /// /// point to target.txttmp, a temp file, which is created and deleted during the tool's runtime. /// @@ -529,74 +399,5 @@ public class TargetFile { private static boolean mflag = true; private static boolean meflag = true; - private static final String Copyright = "#\n" - + "# Copyright (c) 2006, Intel Corporation\n" - + "#\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.\n"; - private static final String Fileinfo = "#\n" - + "# Filename: target.template\n" - + "#\n" - + "# ALL Paths are Relative to WORKSPACE\n" - + "\n" - + "# Separate multiple LIST entries with a SINGLE SPACE character, do not use comma characters.\n" - + "# Un-set an option by either commenting out the line, or not setting a value.\n"; - - private static final String pusage = "#\n" - + "# PROPERTY Type Use Description\n" - + "# ---------------- -------- -------- -----------------------------------------------------------\n" - + "# ACTIVE_PLATFORM Filename Recommended Specify the WORKSPACE relative Path and Filename\n" - + "# of the platform FPD file that will be used for the build\n" - + "# This line is required if and only if the current working\n" - + "# directory does not contain one or more FPD files.\n"; - - private static final String tusage = "\n\n" - + "# TARGET List Optional Zero or more of the following: DEBUG, RELEASE, \n" - + "# UserDefined; separated by a space character. \n" - + "# If the line is missing or no value is specified, all\n" - + "# valid targets specified in the FPD file will attempt \n" - + "# to be built. The following line will build all platform\n" - + "# targets.\n"; - - private static final String ausage = "\n\n" - + "# TARGET_ARCH List Optional What kind of architecture is the binary being target for.\n" - + "# One, or more, of the following, IA32, IA64, X64, EBC or ARM.\n" - + "# Multiple values can be specified on a single line, using \n" - + "# space charaters to separate the values. These are used \n" - + "# during the parsing of an FPD file, restricting the build\n" - + "# output target(s.)\n" - + "# The Build Target ARCH is determined by a logical AND of:\n" - + "# FPD BuildOptions: tag\n" - + "# If not specified, then all valid architectures specified \n" - + "# in the FPD file, for which tools are available, will be \n" - + "# built.\n"; - - private static final String cusage = "\n\n" - + "# TOOL_DEFINITION_FILE Filename Optional Specify the name of the filename to use for specifying \n" - + "# the tools to use for the build. If not specified, \n" - + "# tools_def.txt will be used for the build. This file \n" - + "# MUST be located in the WORKSPACE/Tools/Conf directory.\n"; - - private static final String nusage = "\n\n" - + "# TAGNAME List Optional Specify the name(s) of the tools_def.txt TagName to use.\n" - + "# If not specified, all applicable TagName tools will be \n" - + "# used for the build. The list uses space character separation.\n"; - - private static final String musage = "\n\n" - + "# MULTIPLE_THREAD FLAG Optional Flag to enable multi-thread build. If not specified, default\n" - + "# is \"Disable\". If your computer is multi-core or multiple CPUs,\n" - + "# enabling this feature will bring much benefit. For multi-thread\n" - + "# built, the log will write to ${BUILD_DIR}/build.log.\n" - + "# This feature is only for PLATFORM build, and clean, cleanall or\n" - + "# stand-alone module build is still using the normal way.\n"; - private static final String meusage = "\n\n" - + "# MAX_CONCURRENT_THREAD_NUMBER NUMBER Optional The number of concurrent threads. Default is 2. Recommend to\n" - + "# set this value to one more than the number of your compurter\n" - + "# cores or CPUs.\n"; } diff --git a/Tools/bin/ContextTool.bat b/Tools/bin/ContextTool.bat index cdd685e6e3..407c2e76a1 100644 --- a/Tools/bin/ContextTool.bat +++ b/Tools/bin/ContextTool.bat @@ -29,7 +29,7 @@ if not exist %WORKSPACE%\Tools\Jars\ContextTool.jar ( ) @REM Run Framework Wizard -call "java" -cp "%WORKSPACE%\Tools\Jars\ContextTool.jar" org.tianocore.context.ContextMain %* +java -cp %WORKSPACE%\Tools\Jars\ContextTool.jar org.tianocore.context.ContextMain %* goto end