raster@16367
|
1 |
/*
|
raster@16367
|
2 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
|
raster@16367
|
3 |
*
|
raster@16367
|
4 |
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
|
raster@16367
|
5 |
*
|
raster@16367
|
6 |
* The contents of this file are subject to the terms of either the GNU
|
raster@16367
|
7 |
* General Public License Version 2 only ("GPL") or the Common
|
raster@16367
|
8 |
* Development and Distribution License("CDDL") (collectively, the
|
raster@16367
|
9 |
* "License"). You may not use this file except in compliance with the
|
raster@16367
|
10 |
* License. You can obtain a copy of the License at
|
raster@16367
|
11 |
* http://www.netbeans.org/cddl-gplv2.html
|
raster@16367
|
12 |
* or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
|
raster@16367
|
13 |
* specific language governing permissions and limitations under the
|
raster@16367
|
14 |
* License. When distributing the software, include this License Header
|
raster@16367
|
15 |
* Notice in each file and include the License file at
|
raster@16367
|
16 |
* nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
|
raster@16367
|
17 |
* particular file as subject to the "Classpath" exception as provided
|
raster@16367
|
18 |
* by Sun in the GPL Version 2 section of the License file that
|
raster@16367
|
19 |
* accompanied this code. If applicable, add the following below the
|
raster@16367
|
20 |
* License Header, with the fields enclosed by brackets [] replaced by
|
raster@16367
|
21 |
* your own identifying information:
|
raster@16367
|
22 |
* "Portions Copyrighted [year] [name of copyright owner]"
|
raster@16367
|
23 |
*
|
raster@16367
|
24 |
* If you wish your version of this file to be governed by only the CDDL
|
raster@16367
|
25 |
* or only the GPL Version 2, indicate your decision by adding
|
raster@16367
|
26 |
* "[Contributor] elects to include this software in this distribution
|
raster@16367
|
27 |
* under the [CDDL or GPL Version 2] license." If you do not indicate a
|
raster@16367
|
28 |
* single choice of license, a recipient has the option to distribute
|
raster@16367
|
29 |
* your version of this file under either the CDDL, the GPL Version 2 or
|
raster@16367
|
30 |
* to extend the choice of license to its licensees as provided above.
|
raster@16367
|
31 |
* However, if you add GPL Version 2 code and therefore, elected the GPL
|
raster@16367
|
32 |
* Version 2 license, then the option applies only if the new code is
|
raster@16367
|
33 |
* made subject to such option by the copyright holder.
|
raster@16367
|
34 |
*
|
raster@16367
|
35 |
* Contributor(s):
|
raster@16367
|
36 |
*
|
raster@16367
|
37 |
* Portions Copyrighted 2009 Sun Microsystems, Inc.
|
raster@16367
|
38 |
*/
|
raster@16367
|
39 |
package org.netbeans.modules.ada.project.ui.actions;
|
raster@16367
|
40 |
|
raster@16367
|
41 |
import java.util.ArrayList;
|
raster@16367
|
42 |
import org.netbeans.api.ada.platform.AdaPlatform;
|
raster@16367
|
43 |
import org.netbeans.modules.ada.platform.compiler.gnat.GnatCompiler;
|
raster@16367
|
44 |
import org.netbeans.modules.ada.platform.compiler.jgnat.JGnatCompiler;
|
raster@16367
|
45 |
import org.netbeans.modules.ada.project.AdaProject;
|
raster@16367
|
46 |
import org.netbeans.modules.ada.project.AdaProjectUtil;
|
raster@16367
|
47 |
import org.netbeans.modules.ada.project.options.AdaOptions;
|
raster@16367
|
48 |
import org.netbeans.modules.ada.project.ui.properties.AdaProjectProperties;
|
raster@16367
|
49 |
import org.openide.filesystems.FileObject;
|
raster@16367
|
50 |
import org.openide.filesystems.FileUtil;
|
raster@16367
|
51 |
|
raster@16367
|
52 |
/**
|
raster@16367
|
53 |
*
|
raster@16367
|
54 |
* @author alucarelli
|
raster@16367
|
55 |
*/
|
raster@16367
|
56 |
public class ActionsUtil {
|
raster@16367
|
57 |
|
raster@16367
|
58 |
public static org.netbeans.spi.ada.platform.Compiler getCompilerFactory(AdaProject project, String displayTitle) {
|
raster@16367
|
59 |
org.netbeans.spi.ada.platform.Compiler compiler = null;
|
raster@16367
|
60 |
|
raster@16367
|
61 |
// Retrieve project and platform
|
raster@16367
|
62 |
AdaPlatform platform = AdaProjectUtil.getActivePlatform(project);
|
raster@16367
|
63 |
assert platform != null;
|
raster@16367
|
64 |
|
raster@16367
|
65 |
ArrayList<String> sources = new ArrayList<String>();
|
raster@16367
|
66 |
FileObject[] files;
|
raster@16367
|
67 |
|
raster@16367
|
68 |
// Retrieve main file
|
raster@16367
|
69 |
String mainFile = project.getEvaluator().getProperty(AdaProjectProperties.MAIN_FILE);
|
raster@16367
|
70 |
assert mainFile != null;
|
raster@16367
|
71 |
|
raster@16367
|
72 |
files = project.getSourcesDirectory();
|
raster@16367
|
73 |
for (int index = 0; index < files.length; index++) {
|
raster@16367
|
74 |
sources.add(FileUtil.toFile(files[index]).getAbsolutePath());
|
raster@16367
|
75 |
}
|
raster@16367
|
76 |
|
raster@16367
|
77 |
// Init compiler factory
|
raster@16367
|
78 |
if (project.getEvaluator().getProperty(AdaProjectProperties.OUTPUT_BUILD_FORMAT).equalsIgnoreCase(AdaProjectProperties.NATIVE_FORMAT)) {
|
raster@16367
|
79 |
compiler = new GnatCompiler(
|
raster@16367
|
80 |
platform,
|
raster@16367
|
81 |
project.getName(), // project name
|
raster@16367
|
82 |
FileUtil.toFile(project.getProjectDirectory()).getAbsolutePath(), // project location
|
raster@16367
|
83 |
sources, // sources location
|
raster@16367
|
84 |
mainFile, // main file
|
raster@16367
|
85 |
project.getName(), // executable file
|
raster@16367
|
86 |
displayTitle, // display name
|
raster@16367
|
87 |
project.getEvaluator().getProperty(AdaOptions.PKG_SPEC_POSTFIX),
|
raster@16367
|
88 |
project.getEvaluator().getProperty(AdaOptions.PKG_BODY_POSTFIX),
|
raster@16367
|
89 |
project.getEvaluator().getProperty(AdaOptions.SEPARATE_POSTFIX),
|
raster@16367
|
90 |
project.getEvaluator().getProperty(AdaOptions.PKG_SPEC_EXT),
|
raster@16367
|
91 |
project.getEvaluator().getProperty(AdaOptions.PKG_BODY_EXT),
|
raster@16367
|
92 |
project.getEvaluator().getProperty(AdaOptions.SEPARATE_EXT));
|
raster@16367
|
93 |
} else if (project.getEvaluator().getProperty(AdaProjectProperties.OUTPUT_BUILD_FORMAT).equalsIgnoreCase(AdaProjectProperties.JVM_FORMAT)) {
|
raster@16367
|
94 |
compiler = new JGnatCompiler(
|
raster@16367
|
95 |
platform,
|
raster@16367
|
96 |
project.getName(), // project name
|
raster@16367
|
97 |
FileUtil.toFile(project.getProjectDirectory()).getAbsolutePath(), // project location
|
raster@16367
|
98 |
sources, // sources location
|
raster@16367
|
99 |
mainFile, // main file
|
raster@16367
|
100 |
project.getName(), // executable file
|
raster@16367
|
101 |
displayTitle, // display name
|
raster@16367
|
102 |
project.getEvaluator().getProperty(AdaOptions.PKG_SPEC_POSTFIX),
|
raster@16367
|
103 |
project.getEvaluator().getProperty(AdaOptions.PKG_BODY_POSTFIX),
|
raster@16367
|
104 |
project.getEvaluator().getProperty(AdaOptions.SEPARATE_POSTFIX),
|
raster@16367
|
105 |
project.getEvaluator().getProperty(AdaOptions.PKG_SPEC_EXT),
|
raster@16367
|
106 |
project.getEvaluator().getProperty(AdaOptions.PKG_BODY_EXT),
|
raster@16367
|
107 |
project.getEvaluator().getProperty(AdaOptions.SEPARATE_EXT));
|
raster@16367
|
108 |
}
|
raster@16367
|
109 |
|
raster@16367
|
110 |
return compiler;
|
raster@16367
|
111 |
}
|
raster@16367
|
112 |
}
|