View Javadoc

1   /*
2    * #%L
3    * Native ARchive plugin for Maven
4    * %%
5    * Copyright (C) 2002 - 2014 NAR Maven Plugin developers.
6    * %%
7    * Licensed under the Apache License, Version 2.0 (the "License");
8    * you may not use this file except in compliance with the License.
9    * You may obtain a copy of the License at
10   * 
11   * http://www.apache.org/licenses/LICENSE-2.0
12   * 
13   * Unless required by applicable law or agreed to in writing, software
14   * distributed under the License is distributed on an "AS IS" BASIS,
15   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16   * See the License for the specific language governing permissions and
17   * limitations under the License.
18   * #L%
19   */
20  package com.github.maven_nar.cpptasks.openwatcom;
21  
22  import java.io.File;
23  
24  import org.apache.tools.ant.types.Environment;
25  
26  import com.github.maven_nar.cpptasks.compiler.LinkType;
27  import com.github.maven_nar.cpptasks.compiler.Linker;
28  import com.github.maven_nar.cpptasks.parser.CParser;
29  import com.github.maven_nar.cpptasks.parser.Parser;
30  
31  /**
32   * Adapter for the OpenWatcom C Compiler.
33   *
34   * @author Curt Arnold
35   */
36  public final class OpenWatcomCCompiler extends OpenWatcomCompiler {
37    /**
38     * Singleton.
39     */
40    private static final OpenWatcomCCompiler INSTANCE = new OpenWatcomCCompiler("wcl386", false, null);
41  
42    /**
43     * Get compiler.
44     * 
45     * @return OpenWatcomCCompiler compiler
46     */
47    public static OpenWatcomCCompiler getInstance() {
48      return INSTANCE;
49    }
50  
51    /**
52     * Constructor.
53     * 
54     * @param command
55     *          String command
56     * @param newEnvironment
57     *          boolean use new environment
58     * @param env
59     *          Environment environment
60     */
61    private OpenWatcomCCompiler(final String command, final boolean newEnvironment, final Environment env) {
62      super(command, "/?", new String[] {
63          ".c", ".cc", ".cpp", ".cxx", ".c++"
64      }, new String[] {
65          ".h", ".hpp", ".inl"
66      }, newEnvironment, env);
67    }
68  
69    /**
70     * Create parser.
71     * 
72     * @param source
73     *          File file to be parsed.
74     * @return Parser parser
75     */
76    @Override
77    public Parser createParser(final File source) {
78      return new CParser();
79    }
80  
81    /**
82     * Get linker.
83     * 
84     * @param type
85     *          link type
86     * @return linker
87     */
88    @Override
89    public Linker getLinker(final LinkType type) {
90      return OpenWatcomCLinker.getInstance().getLinker(type);
91    }
92  }