]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Java/Source/Cpptasks/net/sf/antcontrib/cpptasks/compiler/AbstractAslcompiler.java
Restructuring for better separation of Tool packages.
[mirror_edk2.git] / Tools / Java / Source / Cpptasks / net / sf / antcontrib / cpptasks / compiler / AbstractAslcompiler.java
1 /*
2 *
3 * Copyright 2001-2005 The Ant-Contrib project
4 *
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
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
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.
16 */
17 package net.sf.antcontrib.cpptasks.compiler;
18
19 import java.io.File;
20
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;
25
26 /**
27 * An abstract asl compiler implementation.
28 *
29 */
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;
37 }
38 abstract protected AslcompilerConfiguration createConfiguration(CCTask task,
39 LinkType linkType, ProcessorDef[] baseConfigs,
40 AslcompilerDef specificConfig, TargetDef targetPlatform);
41
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");
47 }
48 return createConfiguration(task, linkType, baseConfigs,
49 (AslcompilerDef) specificConfig, targetPlatform);
50 }
51
52 public String getOutputFileName(String inputFile) {
53 if (bid(inputFile) > 1) {
54 String baseName = getBaseOutputName(inputFile);
55 return baseName + outputSuffix;
56 }
57 return null;
58 }
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;
65 }
66 if (lastSep > lastSlash) {
67 lastSlash = lastSep;
68 }
69 int lastPeriod = inputFile.lastIndexOf('.');
70 if (lastPeriod < 0) {
71 lastPeriod = inputFile.length();
72 }
73 return inputFile.substring(lastSlash + 1, lastPeriod);
74 }
75 }