]>
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 | |
219e2247 | 16 | import java.io.File;\r |
17 | \r | |
878ddf1f | 18 | import org.apache.tools.ant.BuildException;\r |
19 | import org.apache.tools.ant.Project;\r | |
20 | import org.apache.tools.ant.Task;\r | |
21 | import org.apache.tools.ant.taskdefs.Execute;\r | |
22 | import org.apache.tools.ant.taskdefs.LogStreamHandler;\r | |
23 | import org.apache.tools.ant.types.Commandline;\r | |
24 | \r | |
25 | /**\r | |
26 | Class SetStampTask is a wrap class for setstamp.exe.\r | |
27 | **/\r | |
28 | public class SetStampTask extends Task implements EfiDefine {\r | |
29 | /**\r | |
30 | SetStamp Task Class\r | |
31 | class member\r | |
32 | -peFile : file of PE\r | |
33 | -timeFile: Txt file of time\r | |
34 | **/ \r | |
35 | \r | |
36 | private String peFile = "";\r | |
37 | \r | |
38 | private String timeFile = "";\r | |
39 | \r | |
40 | /**\r | |
41 | assemble tool command line & execute tool command line\r | |
42 | \r | |
43 | @throws BuildException\r | |
44 | **/\r | |
45 | public void execute() throws BuildException {\r | |
46 | \r | |
47 | Project project = this.getOwningTarget().getProject();\r | |
48 | ///\r | |
49 | /// absolute path of edk tools\r | |
50 | ///\r | |
2da8968b | 51 | String path = project.getProperty("env.FRAMEWORK_TOOLS_PATH");\r |
878ddf1f | 52 | String command;\r |
53 | if (path == null) {\r | |
fad77353 | 54 | command = "SetStamp";\r |
878ddf1f | 55 | } else {\r |
fad77353 | 56 | command = path + "/" + "SetStamp";\r |
878ddf1f | 57 | }\r |
58 | ///\r | |
59 | /// argument of SetStamp tool\r | |
60 | ///\r | |
61 | String argument = peFile + timeFile;\r | |
62 | ///\r | |
63 | /// reture value of SetStamp execution\r | |
64 | ///\r | |
65 | int returnVal = -1;\r | |
66 | \r | |
67 | try {\r | |
68 | Commandline commandLine = new Commandline();\r | |
69 | commandLine.setExecutable(command);\r | |
70 | commandLine.createArgument().setLine(argument);\r | |
71 | \r | |
72 | LogStreamHandler streamHandler = new LogStreamHandler(this,\r | |
73 | Project.MSG_INFO, Project.MSG_WARN);\r | |
74 | \r | |
75 | Execute runner = new Execute(streamHandler, null);\r | |
76 | runner.setAntRun(project);\r | |
77 | runner.setCommandline(commandLine.getCommandline());\r | |
78 | \r | |
219e2247 | 79 | log(Commandline.toString(commandLine.getCommandline()), Project.MSG_VERBOSE);\r |
80 | log((new File(this.peFile)).getName());\r | |
878ddf1f | 81 | \r |
82 | returnVal = runner.execute();\r | |
83 | if (EFI_SUCCESS == returnVal) {\r | |
219e2247 | 84 | log("SetStamp succeeded!", Project.MSG_VERBOSE);\r |
878ddf1f | 85 | } else {\r |
86 | ///\r | |
87 | /// command execution fail\r | |
88 | ///\r | |
219e2247 | 89 | log("ERROR = " + Integer.toHexString(returnVal));\r |
90 | throw new BuildException("SetStamp failed!");\r | |
878ddf1f | 91 | }\r |
92 | } catch (Exception e) {\r | |
93 | throw new BuildException(e.getMessage());\r | |
94 | }\r | |
95 | }\r | |
96 | \r | |
97 | /**\r | |
98 | set operation of class member "peFile"\r | |
99 | \r | |
100 | @param peFile name of PE File\r | |
101 | **/\r | |
102 | public void setPeFile(String peFile) {\r | |
103 | this.peFile = " " + peFile;\r | |
104 | }\r | |
105 | \r | |
106 | /**\r | |
107 | get operation of class member "peFile"\r | |
108 | \r | |
109 | @return peFile name of PE file\r | |
110 | **/\r | |
111 | public String getPeFile() {\r | |
112 | return this.peFile;\r | |
113 | }\r | |
114 | \r | |
115 | /**\r | |
116 | set operation of class member "timeFile"\r | |
117 | \r | |
118 | @param timeFile name of time file\r | |
119 | **/\r | |
120 | public void setTimeFile(String timeFile) {\r | |
121 | this.timeFile = " " + timeFile;\r | |
122 | }\r | |
123 | \r | |
124 | /**\r | |
125 | get class member "timeFile"\r | |
126 | \r | |
127 | @returns name of time file\r | |
128 | **/\r | |
129 | public String getTimeFile() {\r | |
130 | return this.timeFile;\r | |
131 | }\r | |
132 | \r | |
fad77353 | 133 | }\r |