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.compiler;
21  
22  import com.github.maven_nar.cpptasks.OutputTypeEnum;
23  import com.github.maven_nar.cpptasks.SubsystemEnum;
24  
25  /**
26   * This class represents the target platform for the compile and link step. The
27   * name is an anachronism and should be changed.
28   *
29   * @author Curt Arnold
30   */
31  public class LinkType {
32    private OutputTypeEnum outputType = new OutputTypeEnum();
33    private boolean staticRuntime = false;
34    private SubsystemEnum subsystem = new SubsystemEnum();
35  
36    // BEGINFREEHEP
37    private boolean linkCPP = true;
38    private boolean linkFortran = false;
39    private boolean linkFortranMain = false;
40  
41    // ENDFREEHEP
42  
43    /**
44     * Constructor
45     * 
46     * By default, an gui executable with a dynamically linked runtime
47     * 
48     */
49    public LinkType() {
50    }
51  
52    /**
53     * Gets the output type.
54     * 
55     * @return output type
56     */
57    public String getOutputType() {
58      return this.outputType.getValue();
59    }
60  
61    /**
62     * Get subsystem name.
63     * 
64     * @return subsystem name
65     */
66    public String getSubsystem() {
67      return this.subsystem.getValue();
68    }
69  
70    /**
71     * Gets whether the link should produce an executable
72     * 
73     * @return boolean
74     */
75    public boolean isExecutable() {
76      final String value = this.outputType.getValue();
77      return value.equals("executable");
78    }
79  
80    public boolean isJNIModule() {
81      final String value = this.outputType.getValue();
82      return value.equals("jni");
83    }
84  
85    /**
86     * Gets whether the link should produce a plugin module.
87     * 
88     * @return boolean
89     */
90    public boolean isPluginModule() {
91      final String value = this.outputType.getValue();
92      return value.equals("plugin");
93    }
94  
95    /**
96     * Gets whether the link should produce a shared library.
97     * 
98     * @return boolean
99     */
100   public boolean isSharedLibrary() {
101     final String value = this.outputType.getValue();
102     // FREEHEP
103     return value.equals("shared") || value.equals("plugin") || value.equals("jni");
104   }
105 
106   /**
107    * Gets whether the link should produce a static library.
108    * 
109    * @return boolean
110    */
111   public boolean isStaticLibrary() {
112     final String value = this.outputType.getValue();
113     return value.equals("static");
114   }
115 
116   /**
117    * Gets whether the module should use a statically linked runtime library.
118    * 
119    * @return boolean
120    */
121   public boolean isStaticRuntime() {
122     return this.staticRuntime;
123   }
124 
125   /**
126    * Gets whether the link should produce a module for a console subsystem.
127    * 
128    * @return boolean
129    */
130   public boolean isSubsystemConsole() {
131     final String value = this.subsystem.getValue();
132     return value.equals("console");
133   }
134 
135   /**
136    * Gets whether the link should produce a module for a graphical user
137    * interface subsystem.
138    * 
139    * @return boolean
140    */
141   public boolean isSubsystemGUI() {
142     final String value = this.subsystem.getValue();
143     return value.equals("gui");
144   }
145 
146   public boolean linkCPP() {
147     return this.linkCPP;
148   }
149 
150   public boolean linkFortran() {
151     return this.linkFortran;
152   }
153 
154   public boolean linkFortranMain() {
155     return this.linkFortranMain;
156   }
157 
158   // ENDFREEHEP
159 
160   // BEGINFREEHEP
161   public void setLinkCPP(final boolean linkCPP) {
162     this.linkCPP = linkCPP;
163   }
164 
165   public void setLinkFortran(final boolean linkFortran) {
166     this.linkFortran = linkFortran;
167   }
168 
169   public void setLinkFortranMain(final boolean linkFortranMain) {
170     this.linkFortranMain = linkFortranMain;
171   }
172 
173   /**
174    * Sets the output type (execuable, shared, etc).
175    * 
176    * @param outputType
177    *          may not be null
178    */
179   public void setOutputType(final OutputTypeEnum outputType) {
180     if (outputType == null) {
181       throw new IllegalArgumentException("outputType");
182     }
183     this.outputType = outputType;
184   }
185 
186   /**
187    * Requests use of a static runtime library.
188    * 
189    * @param staticRuntime
190    *          if true, use static runtime library if possible.
191    */
192   public void setStaticRuntime(final boolean staticRuntime) {
193     this.staticRuntime = staticRuntime;
194   }
195 
196   /**
197    * Sets the subsystem (gui, console, etc).
198    * 
199    * @param subsystem
200    *          subsystem, may not be null
201    */
202   public void setSubsystem(final SubsystemEnum subsystem) {
203     if (subsystem == null) {
204       throw new IllegalArgumentException("subsystem");
205     }
206     this.subsystem = subsystem;
207   }
208 
209 }