]>
Commit | Line | Data |
---|---|---|
878ddf1f | 1 | /*\r |
2 | * \r | |
3 | * Copyright 2001-2005 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 | \r | |
19 | import java.io.File;\r | |
20 | \r | |
21 | import org.apache.tools.ant.BuildException;\r | |
22 | \r | |
23 | import net.sf.antcontrib.cpptasks.CCTask;\r | |
24 | import net.sf.antcontrib.cpptasks.ProcessorParam;\r | |
25 | \r | |
26 | /**\r | |
27 | * A configuration for an assember\r | |
28 | * \r | |
29 | */\r | |
30 | public final class CommandLineAssemblerConfiguration implements\r | |
31 | AssemblerConfiguration {\r | |
32 | \r | |
33 | private String[] args;\r | |
34 | \r | |
35 | private CommandLineAssembler assembler;\r | |
36 | \r | |
37 | private String[] endArgs;\r | |
38 | \r | |
39 | //\r | |
40 | // include path from environment variable\r | |
41 | // not explicitly stated in Ant script\r | |
42 | //\r | |
43 | private File[] envIncludePath;\r | |
44 | \r | |
45 | private String[] exceptFiles;\r | |
46 | \r | |
47 | private File[] includePath;\r | |
48 | \r | |
49 | private boolean rebuild;\r | |
50 | \r | |
51 | private File[] sysIncludePath;\r | |
52 | \r | |
53 | public CommandLineAssemblerConfiguration (CommandLineAssembler assembler,\r | |
54 | File[] includePath, File[] sysIncludePath,\r | |
55 | File[] envIncludePath, String[] args, boolean rebuild,\r | |
56 | String[] endArgs, String[] exceptFiles) {\r | |
57 | if (assembler == null) {\r | |
58 | throw new NullPointerException("assembler");\r | |
59 | }\r | |
60 | if (args == null) {\r | |
61 | this.args = new String[0];\r | |
62 | } else {\r | |
63 | this.args = (String[]) args.clone();\r | |
64 | }\r | |
65 | if (includePath == null) {\r | |
66 | this.includePath = new File[0];\r | |
67 | } else {\r | |
68 | this.includePath = (File[]) includePath.clone();\r | |
69 | }\r | |
70 | if (sysIncludePath == null) {\r | |
71 | this.sysIncludePath = new File[0];\r | |
72 | } else {\r | |
73 | this.sysIncludePath = (File[]) sysIncludePath.clone();\r | |
74 | }\r | |
75 | if (envIncludePath == null) {\r | |
76 | this.envIncludePath = new File[0];\r | |
77 | } else {\r | |
78 | this.envIncludePath = (File[]) envIncludePath.clone();\r | |
79 | }\r | |
80 | this.assembler = assembler;\r | |
81 | this.rebuild = rebuild;\r | |
82 | this.endArgs = (String[]) endArgs.clone();\r | |
83 | this.exceptFiles = (String[]) exceptFiles.clone();\r | |
84 | }\r | |
85 | \r | |
86 | public int bid(String inputFile) {\r | |
87 | int assembleBid = assembler.bid(inputFile);\r | |
88 | return assembleBid;\r | |
89 | }\r | |
90 | \r | |
91 | public void assembler(CCTask task, File outputDir, String[] sourceFiles)\r | |
92 | throws BuildException {\r | |
93 | try {\r | |
94 | assembler.assembler(task, outputDir, sourceFiles, args, endArgs);\r | |
95 | } catch (BuildException ex) {\r | |
96 | throw ex;\r | |
97 | }\r | |
98 | }\r | |
99 | \r | |
100 | public String getOutputFileName(String inputFile) {\r | |
101 | return assembler.getOutputFileName(inputFile);\r | |
102 | }\r | |
103 | \r | |
104 | public String getIdentifier() {\r | |
105 | return assembler.getCommand();\r | |
106 | }\r | |
107 | \r | |
108 | public ProcessorParam[] getParams() {\r | |
109 | return new ProcessorParam[0];\r | |
110 | }\r | |
111 | \r | |
112 | public boolean getRebuild() {\r | |
113 | return rebuild;\r | |
114 | }\r | |
115 | \r | |
116 | public String[] getPreArguments() {\r | |
117 | return (String[]) args.clone();\r | |
118 | }\r | |
119 | \r | |
120 | public String[] getEndArguments() {\r | |
121 | return (String[]) endArgs.clone();\r | |
122 | }\r | |
123 | }\r |