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.arm;
21  
22  import java.io.File;
23  import java.util.Vector;
24  
25  import com.github.maven_nar.cpptasks.CUtil;
26  import com.github.maven_nar.cpptasks.compiler.CommandLineLinker;
27  import com.github.maven_nar.cpptasks.compiler.LinkType;
28  import com.github.maven_nar.cpptasks.compiler.Linker;
29  import com.github.maven_nar.cpptasks.types.LibraryTypeEnum;
30  
31  /**
32   * Adapter for the ARM Linker
33   *
34   * @author CurtA
35   */
36  public class ADSLinker extends CommandLineLinker {
37    private static final ADSLinker dllInstance = new ADSLinker(".o");
38    private static final ADSLinker instance = new ADSLinker(".axf");
39  
40    public static ADSLinker getDllInstance() {
41      return dllInstance;
42    }
43  
44    public static ADSLinker getInstance() {
45      return instance;
46    }
47  
48    private ADSLinker(final String outputSuffix) {
49      super("armlink", "-vsn", new String[] {
50          ".o", ".lib", ".res"
51      }, new String[] {
52          ".map", ".pdb", ".lnk"
53      }, outputSuffix, false, null);
54    }
55  
56    protected void addBase(final long base, final Vector<String> args) {
57      // TODO Auto-generated method stub
58    }
59  
60    protected void addEntry(final String entry, final Vector<String> args) {
61      // TODO Auto-generated method stub
62  
63    }
64  
65    protected void addFixed(final Boolean fixed, final Vector<String> args) {
66      // TODO Auto-generated method stub
67    }
68  
69    protected void addImpliedArgs(final boolean debug, final LinkType linkType, final Vector<String> args) {
70      if (debug) {
71        args.addElement("-debug");
72      }
73    }
74  
75    protected void addIncremental(final boolean incremental, final Vector<String> args) {
76      // TODO Auto-generated method stub
77    }
78  
79    protected void addMap(final boolean map, final Vector<String> args) {
80      // TODO Auto-generated method stub
81    }
82  
83    protected void addStack(final int stack, final Vector<String> args) {
84      // TODO Auto-generated method stub
85    }
86  
87    /**
88     * May have to make this String array return
89     * 
90     * @see com.github.maven_nar.cpptasks.compiler.CommandLineLinker#getCommandFileSwitch(java.lang.String)
91     */
92    @Override
93    protected String getCommandFileSwitch(final String commandFile) {
94      return "-via" + commandFile;
95    }
96  
97    @Override
98    public File[] getLibraryPath() {
99      return CUtil.getPathFromEnvironment("ARMLIB", ";");
100   }
101 
102   @Override
103   public String[] getLibraryPatterns(final String[] libnames, final LibraryTypeEnum libType) {
104     //
105     // TODO: looks like bad extension
106     //
107     return new String[] {
108       ".o"
109     };
110   }
111 
112   @Override
113   public Linker getLinker(final LinkType linkType) {
114     return this;
115   }
116 
117   @Override
118   protected int getMaximumCommandLength() {
119     return 1024;
120   }
121 
122   @Override
123   protected String[] getOutputFileSwitch(final String outputFile) {
124     return new String[] {
125         "-output", outputFile
126     };
127   }
128 
129   @Override
130   public boolean isCaseSensitive() {
131     return false;
132   }
133 }