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.msvc;
21  
22  import java.io.File;
23  import java.util.Vector;
24  
25  import com.github.maven_nar.cpptasks.CCTask;
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.types.LibraryTypeEnum;
29  
30  /**
31   * Abstract base adapter for librarians with command line options compatible
32   * with the Microsoft(r) Library Manager
33   *
34   * @author Curt Arnold
35   */
36  public abstract class MsvcCompatibleLibrarian extends CommandLineLinker {
37    public MsvcCompatibleLibrarian(final String command, final String identifierArg) {
38      super(command, identifierArg, new String[] {
39        ".obj"
40      }, new String[] {
41          ".map", ".pdb", ".lnk", ".dll", ".tlb", ".rc", ".h"
42      }, ".lib", false, null);
43    }
44  
45    @Override
46    protected void addImpliedArgs(final CCTask task, final boolean debug, final LinkType linkType,
47        final Vector<String> args) {
48      args.addElement("/nologo");
49    }
50  
51    @Override
52    protected String getCommandFileSwitch(final String cmdFile) {
53      return "@" + cmdFile;
54    }
55  
56    @Override
57    public File[] getLibraryPath() {
58      return new File[0];
59    }
60  
61    @Override
62    public String[] getLibraryPatterns(final String[] libnames, final LibraryTypeEnum libType) {
63      return new String[0];
64    }
65  
66    @Override
67    public int getMaximumCommandLength() {
68      // FREEHEP stay on the safe side
69      return 32000; // 32767;
70    }
71  
72    @Override
73    public String[] getOutputFileSwitch(final String outFile) {
74      final StringBuffer buf = new StringBuffer("/OUT:");
75      if (outFile.indexOf(' ') >= 0) {
76        buf.append('"');
77        buf.append(outFile);
78        buf.append('"');
79      } else {
80        buf.append(outFile);
81      }
82      return new String[] {
83        buf.toString()
84      };
85    }
86  
87    @Override
88    public boolean isCaseSensitive() {
89      return false;
90    }
91  }