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.util.Vector;
23  
24  /**
25   * A add-in class for Microsoft Developer Studio processors
26   *
27   * 
28   */
29  public class MsvcProcessor {
30    public static void addWarningSwitch(final Vector<String> args, final int level) {
31      switch (level) {
32        case 0:
33          args.addElement("/W0");
34          break;
35        case 1:
36          args.addElement("/W1");
37          break;
38        case 2:
39          break;
40        case 3:
41          args.addElement("/W3");
42          break;
43        case 4:
44          args.addElement("/W4");
45          break;
46        case 5:
47          args.addElement("/WX");
48          break;
49      }
50    }
51  
52    public static String getCommandFileSwitch(final String cmdFile) {
53      final StringBuffer buf = new StringBuffer("@");
54      if (cmdFile.indexOf(' ') >= 0) {
55        buf.append('\"');
56        buf.append(cmdFile.replace('/', '\\'));
57        buf.append('\"');
58      } else {
59        buf.append(cmdFile);
60      }
61      return buf.toString();
62    }
63  
64    public static void getDefineSwitch(final StringBuffer buffer, final String define, final String value) {
65      buffer.append("/D");
66      buffer.append(define);
67      if (value != null && value.length() > 0) {
68        buffer.append('=');
69        buffer.append(value);
70      }
71    }
72  
73    public static String getIncludeDirSwitch(final String includeDir) {
74      return "/I" + includeDir.replace('/', '\\');
75    }
76  
77    public static String[] getOutputFileSwitch(final String outPath) {
78      final StringBuffer buf = new StringBuffer("/Fo");
79      if (outPath.indexOf(' ') >= 0) {
80        buf.append('\"');
81        buf.append(outPath);
82        buf.append('\"');
83      } else {
84        buf.append(outPath);
85      }
86      final String[] retval = new String[] {
87        buf.toString()
88      };
89      return retval;
90    }
91  
92    public static void getUndefineSwitch(final StringBuffer buffer, final String define) {
93      buffer.append("/U");
94      buffer.append(define);
95    }
96  
97    public static boolean isCaseSensitive() {
98      return false;
99    }
100 
101   private MsvcProcessor() {
102   }
103 }