]> git.proxmox.com Git - mirror_edk2.git/blame - Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/TargetInfo.java
Changed spelling to manifest
[mirror_edk2.git] / Tools / Source / Cpptasks / net / sf / antcontrib / cpptasks / TargetInfo.java
CommitLineData
878ddf1f 1/*\r
2 * \r
3 * Copyright 2002-2004 The Ant-Contrib project\r
4 *\r
5 * Licensed under the Apache License, Version 2.0 (the "License");\r
6 * you may not use this file except in compliance with the License.\r
7 * You may obtain a copy of the License at\r
8 *\r
9 * http://www.apache.org/licenses/LICENSE-2.0\r
10 *\r
11 * Unless required by applicable law or agreed to in writing, software\r
12 * distributed under the License is distributed on an "AS IS" BASIS,\r
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
14 * See the License for the specific language governing permissions and\r
15 * limitations under the License.\r
16 */\r
17package net.sf.antcontrib.cpptasks;\r
18import java.io.File;\r
19\r
20import net.sf.antcontrib.cpptasks.compiler.ProcessorConfiguration;\r
21/**\r
22 * A description of a file built or to be built\r
23 */\r
24public final class TargetInfo {\r
25 private static final File[] emptyFileArray = new File[0];\r
26 private/* final */ProcessorConfiguration config;\r
27 private/* final */File output;\r
28 private boolean rebuild;\r
29 private/* final */File[] sources;\r
30 private File[] sysSources;\r
31 public TargetInfo(ProcessorConfiguration config, File[] sources,\r
32 File[] sysSources, File output, boolean rebuild) {\r
33 if (config == null) {\r
34 throw new NullPointerException("config");\r
35 }\r
36 if (sources == null) {\r
37 throw new NullPointerException("sources");\r
38 }\r
39 if (output == null) {\r
40 throw new NullPointerException("output");\r
41 }\r
42 this.config = config;\r
43 this.sources = (File[]) sources.clone();\r
44 if (sysSources == null) {\r
45 this.sysSources = emptyFileArray;\r
46 } else {\r
47 this.sysSources = (File[]) sysSources.clone();\r
48 }\r
49 this.output = output;\r
50 this.rebuild = rebuild;\r
51 //\r
52 // if the output doesn't exist, must rebuild it\r
53 //\r
54 if (!output.exists()) {\r
55 rebuild = true;\r
56 }\r
57 }\r
58 public String[] getAllSourcePaths() {\r
59 String[] paths = new String[sysSources.length + sources.length];\r
60 for (int i = 0; i < sysSources.length; i++) {\r
61 paths[i] = sysSources[i].toString();\r
62 }\r
63 int offset = sysSources.length;\r
64 for (int i = 0; i < sources.length; i++) {\r
65 paths[offset + i] = sources[i].toString();\r
66 }\r
67 return paths;\r
68 }\r
69 public File[] getAllSources() {\r
70 File[] allSources = new File[sources.length + sysSources.length];\r
71 for (int i = 0; i < sysSources.length; i++) {\r
72 allSources[i] = sysSources[i];\r
73 }\r
74 int offset = sysSources.length;\r
75 for (int i = 0; i < sources.length; i++) {\r
76 allSources[i + offset] = sources[i];\r
77 }\r
78 return allSources;\r
79 }\r
80 public ProcessorConfiguration getConfiguration() {\r
81 return config;\r
82 }\r
83 public File getOutput() {\r
84 return output;\r
85 }\r
86 public boolean getRebuild() {\r
87 return rebuild;\r
88 }\r
89 /**\r
90 * Returns an array of SourceHistory objects (contains relative path and\r
91 * last modified time) for the source[s] of this target\r
92 */\r
93 public SourceHistory[] getSourceHistories(String basePath) {\r
94 SourceHistory[] histories = new SourceHistory[sources.length];\r
95 for (int i = 0; i < sources.length; i++) {\r
96 String relativeName = CUtil.getRelativePath(basePath, sources[i]);\r
97 long lastModified = sources[i].lastModified();\r
98 histories[i] = new SourceHistory(relativeName, lastModified);\r
99 }\r
100 return histories;\r
101 }\r
102 public String[] getSourcePaths() {\r
103 String[] paths = new String[sources.length];\r
104 for (int i = 0; i < sources.length; i++) {\r
105 paths[i] = sources[i].toString();\r
106 }\r
107 return paths;\r
108 }\r
109 public File[] getSources() {\r
110 File[] clone = (File[]) sources.clone();\r
111 return clone;\r
112 }\r
113 public String[] getSysSourcePaths() {\r
114 String[] paths = new String[sysSources.length];\r
115 for (int i = 0; i < sysSources.length; i++) {\r
116 paths[i] = sysSources[i].toString();\r
117 }\r
118 return paths;\r
119 }\r
120 public File[] getSysSources() {\r
121 File[] clone = (File[]) sysSources.clone();\r
122 return clone;\r
123 }\r
124 public void mustRebuild() {\r
125 this.rebuild = true;\r
126 }\r
127}\r