]>
Commit | Line | Data |
---|---|---|
1 | /*\r | |
2 | * \r | |
3 | * Copyright 2001-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 | |
17 | package net.sf.antcontrib.cpptasks.compiler;\r | |
18 | import java.io.File;\r | |
19 | \r | |
20 | import net.sf.antcontrib.cpptasks.CCTask;\r | |
21 | import net.sf.antcontrib.cpptasks.LinkerDef;\r | |
22 | import net.sf.antcontrib.cpptasks.ProcessorDef;\r | |
23 | import net.sf.antcontrib.cpptasks.TargetDef;\r | |
24 | \r | |
25 | \r | |
26 | import org.apache.tools.ant.types.Environment;\r | |
27 | /**\r | |
28 | * An abstract Linker implementation.\r | |
29 | * \r | |
30 | * @author Adam Murdoch\r | |
31 | */\r | |
32 | public abstract class AbstractLinker extends AbstractProcessor\r | |
33 | implements\r | |
34 | Linker {\r | |
35 | public AbstractLinker(String[] objExtensions, String[] ignoredExtensions) {\r | |
36 | super(objExtensions, ignoredExtensions);\r | |
37 | }\r | |
38 | /**\r | |
39 | * Returns the bid of the processor for the file.\r | |
40 | * \r | |
41 | * A linker will bid 1 on any unrecognized file type.\r | |
42 | * \r | |
43 | * @param inputFile\r | |
44 | * filename of input file\r | |
45 | * @return bid for the file, 0 indicates no interest, 1 indicates that the\r | |
46 | * processor recognizes the file but doesn't process it (header\r | |
47 | * files, for example), 100 indicates strong interest\r | |
48 | */\r | |
49 | public int bid(String inputFile) {\r | |
50 | int bid = super.bid(inputFile);\r | |
51 | switch (bid) {\r | |
52 | //\r | |
53 | // unrecognized extension, take the file\r | |
54 | //\r | |
55 | case 0 :\r | |
56 | return 1;\r | |
57 | //\r | |
58 | // discard the ignored extensions\r | |
59 | //\r | |
60 | case 1 :\r | |
61 | return 0;\r | |
62 | }\r | |
63 | return bid;\r | |
64 | }\r | |
65 | public Processor changeEnvironment(boolean newEnvironment, Environment env) {\r | |
66 | return this;\r | |
67 | }\r | |
68 | abstract protected LinkerConfiguration createConfiguration(CCTask task,\r | |
69 | LinkType linkType, ProcessorDef[] baseConfigs,\r | |
70 | LinkerDef specificConfig, TargetDef targetPlatform);\r | |
71 | public ProcessorConfiguration createConfiguration(CCTask task,\r | |
72 | LinkType linkType, ProcessorDef[] baseConfigs,\r | |
73 | ProcessorDef specificConfig,\r | |
74 | TargetDef targetPlatform) {\r | |
75 | if (specificConfig == null) {\r | |
76 | throw new NullPointerException("specificConfig");\r | |
77 | }\r | |
78 | return createConfiguration(task, linkType, baseConfigs,\r | |
79 | (LinkerDef) specificConfig, targetPlatform);\r | |
80 | }\r | |
81 | public String getLibraryKey(File libfile) {\r | |
82 | return libfile.getName();\r | |
83 | }\r | |
84 | public abstract String getOutputFileName(String fileName);\r | |
85 | }\r |