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