3 * Copyright 2002-2006 The Ant-Contrib project
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 package net
.sf
.antcontrib
.cpptasks
.userdefine
;
19 import org
.apache
.tools
.ant
.Project
;
21 import net
.sf
.antcontrib
.cpptasks
.CCTask
;
22 import org
.tianocore
.build
.toolchain
.*;
24 public class UserDefineCompiler
extends CommandLineUserDefine
{
26 public UserDefineCompiler(CCTask cctask
, UserDefineDef userdefineDef
) {
30 String commandType
= null;
31 Project project
= cctask
.getProject();
33 if (cctask
.getArch() == null) {
34 arch
= project
.getProperty("ARCH");
36 arch
= System
.getProperty("os.arch");
39 arch
= cctask
.getArch();
41 arch
= arch
.toUpperCase();
42 if (cctask
.getOs() == null) {
43 os
= project
.getProperty("OS");
45 os
= System
.getProperty("os.name");
51 commandType
= userdefineDef
.getType();
53 if (commandType
!= null) {
54 if (ToolChainFactory
.getValue(arch
+ "_" + commandType
+ "_VENDOR") != null
55 && ToolChainFactory
.getValue(
56 arch
+ "_" + commandType
+ "_VENDOR").trim()
58 vendor
= ToolChainFactory
.getValue(arch
+ "_" + commandType
60 } else if (ToolChainFactory
.getValue(arch
+ "_VENDOR") != null) {
61 vendor
= ToolChainFactory
.getValue(arch
+ "_VENDOR");
65 // look if ARCH_VENDOR_OS_COMMANDTYPE is existed
66 if (arch
!= null && vendor
!= null && os
!= null && commandType
!= null) {
67 command
= project
.getProperty(arch
+ "_" + vendor
+ "_" + os
+ "_"
70 // look if ARCH_VENDOR_COMMANDTYPE is existed
71 if (command
== null) {
72 if (arch
!= null && vendor
!= null && commandType
!= null) {
73 command
= project
.getProperty(arch
+ "_" + vendor
+ "_"
77 // look if ARCH_COMMANDTYPE is existed
78 if (command
== null) {
79 if (arch
!= null && commandType
!= null) {
80 command
= project
.getProperty(arch
+ "_" + commandType
);
83 // look if COMMANDTYPE is existed
84 if (command
== null) {
85 if (commandType
!= null) {
86 command
= project
.getProperty(commandType
);
89 // using the default value from VENDOR_OS_COMMANDTYPE or
91 if (command
== null) {
92 if (vendor
!= null && os
!= null && commandType
!= null) {
93 String str
= vendor
+ "_" + os
+ "_" + commandType
;
94 command
= UserDefineMapping
.getDefaultCommand(str
);
98 if (command
== null) {
99 if (vendor
!= null && commandType
!= null) {
100 String str
= vendor
+ "_" + commandType
;
101 command
= UserDefineMapping
.getDefaultCommand(str
);
104 // just give the name whatever
105 if (command
== null) {
109 // initialize the includePathDelimiter
110 if (userdefineDef
.getIncludepathDelimiter() != null) {
111 includePathDelimiter
= userdefineDef
.getIncludepathDelimiter();
115 if (vendor
!= null) {
116 includePathDelimiter
= UserDefineMapping
117 .getIncludePathDelimiter(vendor
, commandType
);
120 if (includePathDelimiter
== null) {
121 includePathDelimiter
= "-I";
126 if (userdefineDef
.getLibSet() != null
127 && userdefineDef
.getLibSet().size() > 0) {
129 if (vendor
.equalsIgnoreCase("GCC")) {
130 libSetList
.add("-(");
131 for (int i
= 0; i
< userdefineDef
.getLibSet().size(); i
++) {
132 libList
= userdefineDef
.getLibSet().get(i
).getLibs();
133 for (int j
= 0; j
< libList
.length
; j
++) {
134 libSetList
.add(libList
[j
]);
137 libSetList
.add("-)");
139 for (int i
= 0; i
< userdefineDef
.getLibSet().size(); i
++) {
140 libList
= userdefineDef
.getLibSet().get(i
).getLibs();
141 for (int j
= 0; j
< libList
.length
; j
++) {
142 libSetList
.add(libList
[j
]);
148 * set includeFileFlag
150 if (userdefineDef
.getIncludeFile() != null) {
151 if (userdefineDef
.getIncludeFileFlag() != null) {
152 includeFileFlag
= userdefineDef
.getIncludeFileFlag();
154 includeFileFlag
= UserDefineMapping
.getCompellingIncFileFlag(
155 vendor
, commandType
);
161 if (userdefineDef
.getEntryPointvalue() != null) {
162 if (userdefineDef
.getEntryPointFlag() != null) {
163 entryPointFlag
= userdefineDef
.getEntryPointFlag();
165 entryPointFlag
= UserDefineMapping
.getEntryPointFlag(vendor
,
172 if (userdefineDef
.getSubSystemvalue() != null) {
173 if (userdefineDef
.getSubSystemFlag() != null) {
174 subSystemFlag
= userdefineDef
.getSubSystemFlag();
176 subSystemFlag
= UserDefineMapping
.getSubSystemFlag(vendor
,
183 if (userdefineDef
.getMapvalue() != null) {
184 if (userdefineDef
.getMapFlag() != null) {
185 mapFlag
= userdefineDef
.getMapFlag();
187 mapFlag
= UserDefineMapping
.getMapFlag(vendor
, commandType
);
193 if (userdefineDef
.getPdbvalue() != null) {
194 if (userdefineDef
.getPdbFlag() != null) {
195 pdbFlag
= userdefineDef
.getPdbFlag();
197 pdbFlag
= UserDefineMapping
.getPdbFlag(vendor
, commandType
);
203 if (userdefineDef
.getOutputFile() != null) {
204 if (userdefineDef
.getOutPutFlag() != null) {
205 outputFileFlag
= userdefineDef
.getOutPutFlag();
207 outputFileFlag
= UserDefineMapping
.getOutputFileFlag(vendor
,
215 if (userdefineDef
.getFileList() != null) {
216 fileList
= userdefineDef
.getFileList();