3 * Copyright 2001-2005 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
.compiler
;
21 import net
.sf
.antcontrib
.cpptasks
.AslcompilerDef
;
22 import net
.sf
.antcontrib
.cpptasks
.CCTask
;
23 import net
.sf
.antcontrib
.cpptasks
.ProcessorDef
;
24 import net
.sf
.antcontrib
.cpptasks
.TargetDef
;
27 * An abstract asl compiler implementation.
30 public abstract class AbstractAslcompiler
extends AbstractProcessor
31 implements Aslcompiler
{
32 private String outputSuffix
;
33 protected AbstractAslcompiler(String
[] sourceExtensions
,
34 String
[] headerExtensions
, String outputSuffix
) {
35 super(sourceExtensions
, headerExtensions
);
36 this.outputSuffix
= outputSuffix
;
38 abstract protected AslcompilerConfiguration
createConfiguration(CCTask task
,
39 LinkType linkType
, ProcessorDef
[] baseConfigs
,
40 AslcompilerDef specificConfig
, TargetDef targetPlatform
);
42 public ProcessorConfiguration
createConfiguration(CCTask task
,
43 LinkType linkType
, ProcessorDef
[] baseConfigs
,
44 ProcessorDef specificConfig
, TargetDef targetPlatform
) {
45 if (specificConfig
== null) {
46 throw new NullPointerException("specificConfig");
48 return createConfiguration(task
, linkType
, baseConfigs
,
49 (AslcompilerDef
) specificConfig
, targetPlatform
);
52 public String
getOutputFileName(String inputFile
) {
53 if (bid(inputFile
) > 1) {
54 String baseName
= getBaseOutputName(inputFile
);
55 return baseName
+ outputSuffix
;
59 protected String
getBaseOutputName(String inputFile
) {
60 int lastSlash
= inputFile
.lastIndexOf('/');
61 int lastReverse
= inputFile
.lastIndexOf('\\');
62 int lastSep
= inputFile
.lastIndexOf(File
.separatorChar
);
63 if (lastReverse
> lastSlash
) {
64 lastSlash
= lastReverse
;
66 if (lastSep
> lastSlash
) {
69 int lastPeriod
= inputFile
.lastIndexOf('.');
71 lastPeriod
= inputFile
.length();
73 return inputFile
.substring(lastSlash
+ 1, lastPeriod
);