]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/types/CommandLineArgument.java
Initial import.
[mirror_edk2.git] / Tools / Source / Cpptasks / net / sf / antcontrib / cpptasks / types / CommandLineArgument.java
1 /*
2 *
3 * Copyright 2001-2004 The Ant-Contrib project
4 *
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
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
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.
16 */
17 package net.sf.antcontrib.cpptasks.types;
18
19 import org.apache.tools.ant.types.EnumeratedAttribute;
20 import java.io.File;
21 /**
22 * An compiler/linker command line flag.
23 */
24 public class CommandLineArgument {
25 /**
26 * Enumerated attribute with the values "start", "mid" and "end",
27 */
28 public static class LocationEnum extends EnumeratedAttribute {
29 public String[] getValues() {
30 return new String[]{"start", "mid", "end"};
31 }
32 }
33 private String ifCond;
34 private int location;
35 private String unlessCond;
36 private String value;
37 private File file;
38 public CommandLineArgument() {
39 }
40 public int getLocation() {
41 return location;
42 }
43 public String getValue() {
44 return value;
45 }
46 public File getFile() {
47 return file;
48 }
49 /**
50 * Returns true if the define's if and unless conditions (if any) are
51 * satisfied.
52 */
53 public boolean isActive(org.apache.tools.ant.Project p) {
54 if (value == null) {
55 return false;
56 }
57 if (ifCond != null && p.getProperty(ifCond) == null) {
58 return false;
59 } else if (unlessCond != null && p.getProperty(unlessCond) != null) {
60 return false;
61 }
62 return true;
63 }
64 /**
65 * Sets the property name for the 'if' condition.
66 *
67 * The argument will be ignored unless the property is defined.
68 *
69 * The value of the property is insignificant, but values that would imply
70 * misinterpretation ("false", "no") will throw an exception when
71 * evaluated.
72 */
73 public void setIf(String propName) {
74 ifCond = propName;
75 }
76 /**
77 * Specifies relative location of argument on command line. "start" will
78 * place argument at start of command line, "mid" will place argument after
79 * all "start" arguments but before filenames, "end" will place argument
80 * after filenames.
81 *
82 */
83 public void setLocation(LocationEnum location) {
84 this.location = location.getIndex();
85 }
86 /**
87 * Set the property name for the 'unless' condition.
88 *
89 * If named property is set, the argument will be ignored.
90 *
91 * The value of the property is insignificant, but values that would imply
92 * misinterpretation ("false", "no") of the behavior will throw an
93 * exception when evaluated.
94 *
95 * @param propName
96 * name of property
97 */
98 public void setUnless(String propName) {
99 unlessCond = propName;
100 }
101 /**
102 * Specifies the string that should appear on the command line. The
103 * argument will be quoted if it contains embedded blanks. Use multiple
104 * arguments to avoid quoting.
105 *
106 */
107 public void setValue(String value) {
108 this.value = value;
109 }
110 /**
111 * Specifies the file which lists many strings that should appear on
112 * the command line. Each line is one argument. The argument will be
113 * quated if it contains embedded blanks. Use multiple arguments in
114 * file to avoid quating.
115 *
116 * @param file
117 * name of the file
118 */
119 public void setFile(File file) {
120 this.file = file;
121 }
122 }