3 * Copyright 2002-2004 The Ant-Contrib project
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
9 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package net
.sf
.antcontrib
.cpptasks
;
20 import net
.sf
.antcontrib
.cpptasks
.compiler
.ProcessorConfiguration
;
22 * A description of a file built or to be built
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
) {
34 throw new NullPointerException("config");
36 if (sources
== null) {
37 throw new NullPointerException("sources");
40 throw new NullPointerException("output");
43 this.sources
= (File
[]) sources
.clone();
44 if (sysSources
== null) {
45 this.sysSources
= emptyFileArray
;
47 this.sysSources
= (File
[]) sysSources
.clone();
50 this.rebuild
= rebuild
;
52 // if the output doesn't exist, must rebuild it
54 if (!output
.exists()) {
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();
63 int offset
= sysSources
.length
;
64 for (int i
= 0; i
< sources
.length
; i
++) {
65 paths
[offset
+ i
] = sources
[i
].toString();
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
];
74 int offset
= sysSources
.length
;
75 for (int i
= 0; i
< sources
.length
; i
++) {
76 allSources
[i
+ offset
] = sources
[i
];
80 public ProcessorConfiguration
getConfiguration() {
83 public File
getOutput() {
86 public boolean getRebuild() {
90 * Returns an array of SourceHistory objects (contains relative path and
91 * last modified time) for the source[s] of this target
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
);
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();
109 public File
[] getSources() {
110 File
[] clone
= (File
[]) sources
.clone();
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();
120 public File
[] getSysSources() {
121 File
[] clone
= (File
[]) sysSources
.clone();
124 public void mustRebuild() {