+++ /dev/null
-/*\r
- * \r
- * Copyright 2002-2004 The Ant-Contrib project\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-package net.sf.antcontrib.cpptasks;\r
-import java.io.File;\r
-\r
-import net.sf.antcontrib.cpptasks.compiler.ProcessorConfiguration;\r
-/**\r
- * A description of a file built or to be built\r
- */\r
-public final class TargetInfo {\r
- private static final File[] emptyFileArray = new File[0];\r
- private/* final */ProcessorConfiguration config;\r
- private/* final */File output;\r
- private boolean rebuild;\r
- private/* final */File[] sources;\r
- private File[] sysSources;\r
- public TargetInfo(ProcessorConfiguration config, File[] sources,\r
- File[] sysSources, File output, boolean rebuild) {\r
- if (config == null) {\r
- throw new NullPointerException("config");\r
- }\r
- if (sources == null) {\r
- throw new NullPointerException("sources");\r
- }\r
- if (output == null) {\r
- throw new NullPointerException("output");\r
- }\r
- this.config = config;\r
- this.sources = (File[]) sources.clone();\r
- if (sysSources == null) {\r
- this.sysSources = emptyFileArray;\r
- } else {\r
- this.sysSources = (File[]) sysSources.clone();\r
- }\r
- this.output = output;\r
- this.rebuild = rebuild;\r
- //\r
- // if the output doesn't exist, must rebuild it\r
- //\r
- if (!output.exists()) {\r
- rebuild = true;\r
- }\r
- }\r
- public String[] getAllSourcePaths() {\r
- String[] paths = new String[sysSources.length + sources.length];\r
- for (int i = 0; i < sysSources.length; i++) {\r
- paths[i] = sysSources[i].toString();\r
- }\r
- int offset = sysSources.length;\r
- for (int i = 0; i < sources.length; i++) {\r
- paths[offset + i] = sources[i].toString();\r
- }\r
- return paths;\r
- }\r
- public File[] getAllSources() {\r
- File[] allSources = new File[sources.length + sysSources.length];\r
- for (int i = 0; i < sysSources.length; i++) {\r
- allSources[i] = sysSources[i];\r
- }\r
- int offset = sysSources.length;\r
- for (int i = 0; i < sources.length; i++) {\r
- allSources[i + offset] = sources[i];\r
- }\r
- return allSources;\r
- }\r
- public ProcessorConfiguration getConfiguration() {\r
- return config;\r
- }\r
- public File getOutput() {\r
- return output;\r
- }\r
- public boolean getRebuild() {\r
- return rebuild;\r
- }\r
- /**\r
- * Returns an array of SourceHistory objects (contains relative path and\r
- * last modified time) for the source[s] of this target\r
- */\r
- public SourceHistory[] getSourceHistories(String basePath) {\r
- SourceHistory[] histories = new SourceHistory[sources.length];\r
- for (int i = 0; i < sources.length; i++) {\r
- String relativeName = CUtil.getRelativePath(basePath, sources[i]);\r
- long lastModified = sources[i].lastModified();\r
- histories[i] = new SourceHistory(relativeName, lastModified);\r
- }\r
- return histories;\r
- }\r
- public String[] getSourcePaths() {\r
- String[] paths = new String[sources.length];\r
- for (int i = 0; i < sources.length; i++) {\r
- paths[i] = sources[i].toString();\r
- }\r
- return paths;\r
- }\r
- public File[] getSources() {\r
- File[] clone = (File[]) sources.clone();\r
- return clone;\r
- }\r
- public String[] getSysSourcePaths() {\r
- String[] paths = new String[sysSources.length];\r
- for (int i = 0; i < sysSources.length; i++) {\r
- paths[i] = sysSources[i].toString();\r
- }\r
- return paths;\r
- }\r
- public File[] getSysSources() {\r
- File[] clone = (File[]) sysSources.clone();\r
- return clone;\r
- }\r
- public void mustRebuild() {\r
- this.rebuild = true;\r
- }\r
-}\r