]>
Commit | Line | Data |
---|---|---|
878ddf1f | 1 | /** @file\r |
2 | This file is to define an ANT task to wrap setstamp.exe tool\r | |
3 | \r | |
4 | Copyright (c) 2006, Intel Corporation\r | |
5 | All rights reserved. This program and the accompanying materials\r | |
6 | are licensed and made available under the terms and conditions of the BSD License\r | |
7 | which accompanies this distribution. The full text of the license may be found at\r | |
8 | http://opensource.org/licenses/bsd-license.php\r | |
9 | \r | |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
12 | \r | |
13 | **/\r | |
14 | package org.tianocore.framework.tasks;\r | |
15 | \r | |
16 | import org.apache.tools.ant.BuildException;\r | |
17 | import org.apache.tools.ant.Project;\r | |
18 | import org.apache.tools.ant.Task;\r | |
19 | import org.apache.tools.ant.taskdefs.Execute;\r | |
20 | import org.apache.tools.ant.taskdefs.LogStreamHandler;\r | |
21 | import org.apache.tools.ant.types.Commandline;\r | |
22 | \r | |
23 | /**\r | |
24 | Class SetStampTask is a wrap class for setstamp.exe.\r | |
25 | **/\r | |
26 | public class SetStampTask extends Task implements EfiDefine {\r | |
27 | /**\r | |
28 | SetStamp Task Class\r | |
29 | class member\r | |
30 | -peFile : file of PE\r | |
31 | -timeFile: Txt file of time\r | |
32 | **/ \r | |
33 | \r | |
34 | private String peFile = "";\r | |
35 | \r | |
36 | private String timeFile = "";\r | |
37 | \r | |
38 | /**\r | |
39 | assemble tool command line & execute tool command line\r | |
40 | \r | |
41 | @throws BuildException\r | |
42 | **/\r | |
43 | public void execute() throws BuildException {\r | |
44 | \r | |
45 | Project project = this.getOwningTarget().getProject();\r | |
46 | ///\r | |
47 | /// absolute path of edk tools\r | |
48 | ///\r | |
2da8968b | 49 | String path = project.getProperty("env.FRAMEWORK_TOOLS_PATH");\r |
878ddf1f | 50 | String command;\r |
51 | if (path == null) {\r | |
52 | command = "setstamp";\r | |
53 | } else {\r | |
54 | command = path + "/" + "setstamp";\r | |
55 | }\r | |
56 | ///\r | |
57 | /// argument of SetStamp tool\r | |
58 | ///\r | |
59 | String argument = peFile + timeFile;\r | |
60 | ///\r | |
61 | /// reture value of SetStamp execution\r | |
62 | ///\r | |
63 | int returnVal = -1;\r | |
64 | \r | |
65 | try {\r | |
66 | Commandline commandLine = new Commandline();\r | |
67 | commandLine.setExecutable(command);\r | |
68 | commandLine.createArgument().setLine(argument);\r | |
69 | \r | |
70 | LogStreamHandler streamHandler = new LogStreamHandler(this,\r | |
71 | Project.MSG_INFO, Project.MSG_WARN);\r | |
72 | \r | |
73 | Execute runner = new Execute(streamHandler, null);\r | |
74 | runner.setAntRun(project);\r | |
75 | runner.setCommandline(commandLine.getCommandline());\r | |
76 | \r | |
77 | System.out.println(Commandline.toString(commandLine\r | |
78 | .getCommandline()));\r | |
79 | \r | |
80 | returnVal = runner.execute();\r | |
81 | if (EFI_SUCCESS == returnVal) {\r | |
82 | ///\r | |
83 | /// command execution success\r | |
84 | ///\r | |
2da8968b | 85 | System.out.println("SetStamp execute successed!");\r |
878ddf1f | 86 | } else {\r |
87 | ///\r | |
88 | /// command execution fail\r | |
89 | ///\r | |
90 | System.out.println("SetStamp failed. (error="\r | |
91 | + Integer.toHexString(returnVal) + ")");\r | |
92 | throw new BuildException("SetStamp failed. (error="\r | |
93 | + Integer.toHexString(returnVal) + ")");\r | |
94 | }\r | |
95 | } catch (Exception e) {\r | |
96 | throw new BuildException(e.getMessage());\r | |
97 | }\r | |
98 | }\r | |
99 | \r | |
100 | /**\r | |
101 | set operation of class member "peFile"\r | |
102 | \r | |
103 | @param peFile name of PE File\r | |
104 | **/\r | |
105 | public void setPeFile(String peFile) {\r | |
106 | this.peFile = " " + peFile;\r | |
107 | }\r | |
108 | \r | |
109 | /**\r | |
110 | get operation of class member "peFile"\r | |
111 | \r | |
112 | @return peFile name of PE file\r | |
113 | **/\r | |
114 | public String getPeFile() {\r | |
115 | return this.peFile;\r | |
116 | }\r | |
117 | \r | |
118 | /**\r | |
119 | set operation of class member "timeFile"\r | |
120 | \r | |
121 | @param timeFile name of time file\r | |
122 | **/\r | |
123 | public void setTimeFile(String timeFile) {\r | |
124 | this.timeFile = " " + timeFile;\r | |
125 | }\r | |
126 | \r | |
127 | /**\r | |
128 | get class member "timeFile"\r | |
129 | \r | |
130 | @returns name of time file\r | |
131 | **/\r | |
132 | public String getTimeFile() {\r | |
133 | return this.timeFile;\r | |
134 | }\r | |
135 | \r | |
2da8968b | 136 | } |