]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/compiler/AbstractAssembler.java
Changed spelling to manifest
[mirror_edk2.git] / Tools / Source / Cpptasks / net / sf / antcontrib / cpptasks / compiler / AbstractAssembler.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.AssemblerDef;
22 import net.sf.antcontrib.cpptasks.CCTask;
23 import net.sf.antcontrib.cpptasks.ProcessorDef;
24 import net.sf.antcontrib.cpptasks.TargetDef;
25 /**
26 * An abstract assembler implementation.
27 *
28 */
29 public abstract class AbstractAssembler extends AbstractProcessor
30 implements Assembler {
31 private String outputSuffix;
32 protected AbstractAssembler(String[] sourceExtensions,
33 String[] headerExtensions, String outputSuffix) {
34 super(sourceExtensions, headerExtensions);
35 this.outputSuffix = outputSuffix;
36 }
37 abstract protected AssemblerConfiguration createConfiguration(CCTask task,
38 LinkType linkType, ProcessorDef[] baseConfigs,
39 AssemblerDef specificConfig, TargetDef targetPlatform);
40 public ProcessorConfiguration createConfiguration(CCTask task,
41 LinkType linkType, ProcessorDef[] baseConfigs,
42 ProcessorDef specificConfig, TargetDef targetPlatform) {
43 if (specificConfig == null) {
44 throw new NullPointerException("specificConfig");
45 }
46 return createConfiguration(task, linkType, baseConfigs,
47 (AssemblerDef) specificConfig, targetPlatform);
48 }
49 public String getOutputFileName(String inputFile) {
50 if (bid(inputFile) > 1) {
51 String baseName = getBaseOutputName(inputFile);
52 return baseName + outputSuffix;
53 }
54 return null;
55 }
56 protected String getBaseOutputName(String inputFile) {
57 int lastSlash = inputFile.lastIndexOf('/');
58 int lastReverse = inputFile.lastIndexOf('\\');
59 int lastSep = inputFile.lastIndexOf(File.separatorChar);
60 if (lastReverse > lastSlash) {
61 lastSlash = lastReverse;
62 }
63 if (lastSep > lastSlash) {
64 lastSlash = lastSep;
65 }
66 int lastPeriod = inputFile.lastIndexOf('.');
67 if (lastPeriod < 0) {
68 lastPeriod = inputFile.length();
69 }
70 return inputFile.substring(lastSlash + 1, lastPeriod);
71 }
72 }