Menu

[r129]: / APIInterface / Docs / build-settings.html  Maximize  Restore  History

Download this file

312 lines (270 with data), 17.1 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
<html>
<head>
<title>Xcode's Plugin Interface : Build Settings</title>
<link rel="stylesheet" href="doc.css" />
</head>
<body>
<h1>Xcode's Plugin Interface : Build Settings</h1>
<p>You'll find some official informations about build setting variables here :</p>
<ul>
<li><a href="http://developer.apple.com/documentation/DeveloperTools/Conceptual/XcodeUserGuide20/Contents/Resources/en.lproj/bs_build_settings/chapter_31_section_1.html">Apple's chapter about the build setting system</a></li>
<li><a href="http://developer.apple.com/documentation/DeveloperTools/Conceptual/XcodeUserGuide20/Contents/Resources/en.lproj/bs_build_settings/chapter_31_section_5.html">Build Setting Evaluation</a></li>
<li><a href="http://developer.apple.com/documentation/DeveloperTools/Conceptual/XcodeUserGuide20/Contents/Resources/en.lproj/bs_build_settings/chapter_31_section_8.html">Some build setting variables and their short description</a></li>
</ul>
<!-- --- --- --- --- -->
<h2>Table of Contents</h2>
<div class="toc">
<div class="toc1"><a href="index.html">UP</a> <small>(Xcode's Plugin Interface)</small></div>
<div class="toc1"><a href="#buildsettings">1. Adding Build Settings in the GUI (<code>.pbbsetspec</code>)</a></div>
<div class="toc1"><a href="#api">2. Environment API</a></div>
<div class="toc1"><a href="#variables">3. Useful Environment Variables</a></div>
</div>
<!-- --- --- --- --- -->
<h2><a name="buildsettings">1. Adding Build Settings in the GUI (<code>.pbbsetspec</code>)</a></h2>
<p>The GUI settings are defined either in a dedicated <code>.pbbsetspec</code> file or in the
specification file of a compiler (<code>.pbcompspec</code>) or a linker (<code>.pblinkspec</code>).
The explainations are illustrated with a compiler specification file.</p>
<p>Some sample compiler/linker definitions with GUI build settings (the syntax may be slightly
different from the one defined below because there're several equivalent syntaxes to define options):</p>
<p class="object"><code><a href="file:///Developer/Library/PrivateFrameworks/DevToolsCore.framework/Resources/GCC.xcspec">/Developer/Library/PrivateFrameworks/DevToolsCore.framework/Resources/GCC.xcspec</a></code></p>
<p class="object"><code><a href="file:///Developer/Library/PrivateFrameworks/DevToolsCore.framework/Resources/Built-in%20linkers.pblinkspec">/Developer/Library/PrivateFrameworks/DevToolsCore.framework/Resources/Built-in linkers.pblinkspec</a></code></p>
<p class="object"><code><a href="file:///Developer/Library/PrivateFrameworks/DevToolsCore.framework/Resources/Built-in%20build%20settings.pbbsetspec">/Developer/Library/PrivateFrameworks/DevToolsCore.framework/Resources/Built-in build settings.pbbsetspec</a></code></p>
<p>The build settings are defined by a property list like the following one :</p>
<pre>(
{
Identifier = com.domain.me.compilers;
Name = "My compiler";
&hellip;
Options = (
{
<strong>// Bool options can have only two values : NO or YES.</strong>
Name = OPTION_1;
Type = bool;
DefaultValue = NO;
<strong>// You may define how an option must be translated to an argument(s) for the
// compiler compand line:</strong>
CommandLineArgs = {
NO = (); // expand to nothing
YES = ("-with-opt1") // expand to one argument : -with-opt1
};
Category = "My Category";
},
{
<strong>// A stringlist is a string containing many string value, separated by space,
// like command line arguments in shells.</strong>
Name = OPTION_2;
Type = stringlist; // replace with "pathlist" if the strings in the list are paths
UIType = ??; // not documented
DefaultValue = "";
<strong>// if the option value is «aa bb», Xcode will issue «-I aa -I bb» on the
// command line:</strong>
CommandLineArgs = ("-I", "$(value)");
<strong>// will appear after OPTION_1 in the build setting window:</strong>
AppearsAfter = OPTION_1;
<strong>// will appear after OPTION_3 on the command line:</strong>
AppearsOnCommandLineAfter = OPTION_3;
<strong>// will appear on the command if this value expands to YES:</strong>
CommandLineCondition = "$(OPTION_1)";
Category = "My Category"; // put option into this group
},
{
<strong>// A string.</strong>
Name = OPTION_3;
Type = string; // replace with "path" if the string represent a path
DefaultValue = "I'm the default string";
AvoidEmptyValue = YES; <strong>// Show the default value if the user put an empty value</strong>
CommandLineArgs = ("$(value)");
<strong>// option will appear on the command line args only for these architectures:</strong>
<strong>// (only works with compilers, no with linkers)</strong>
Architectures = (ppc, ppc64);
<strong>// option will appear on the command line args only for these source file types:</strong>
FileTypes = (sourcecode.me, sourcode.mebis);
Category = "My Other Category";
},
{
<strong>// Option with predefined choices.</strong>
Name = OPTION_4;
Type = enum;
AllowedValues = (VAL1, VAL2, VAL3, VAL4, VAL5);
DefaultValue = VAL3;
<strong>// in this case, $(value) will be VAL3 or VAL4 or VAL5:</strong>
CommandLineArgs = { VAL1 = (-a); VAL2 = (-b); "&lt;&lt;otherwise&gt;&gt;" = (-custom, "$(value)") };
Category = "My Other Category";
CommonOption = YES; // ??
AdditionalArgsForFixBundlizing = (&hellip;); // ??
AdditionalLinkerArgs = (&hellip;); // ??
},
);
OptionCategories = (
{ Name = "My Category";
IconName = "PBX-option-build";
// or PBX-option-warning PBX-option-language-c PBX-option-language-r
},
{ Name = "My Other Category";
IconName = "PBX-option-build";
},
);
};</pre>
<p>The <code>CommandLineArgs</code> , <code>Architectures</code>, <code>FileTypes</code> keys are
only useful in compiler or linker specification.</p>
<p>If you don't set the <code>Category</code> key, the option won't appear in the GUI.</p>
<p>If you don't set the <code>CommandLineArgs</code> key, the option won't be automatically
translated into command line arguments. However, you may treat it in your plugin code (for instance
to do custom stuff) : all options are added to the build environment. You may get the value of the
option <code>OPTION_1</code> with the following code :</p>
<pre>[context expandedValueForString:@"$(OPTION_1)"]</pre>
<p>In Xcode 2.0 to 2.2, the build settings defined in the specification of all used compiler/linker
will be added to the GUI target inspector. In Xcode 2.3 and later, only settings of used compilers
will be shown, and not those of used linkers :-( (it's really annoying !!!).</p>
<p>If you put the option definitions in a <code>.pbbsetspec</code>, you must define the
<code>specificationToShowInUserInterface</code> method of your compiler class to inform which
specification should be shown when your compiler is used:</p>
<pre>- (XCPropertyDomainSpecification*) specificationToShowInUserInterface
{
XCPropertyDomainSpecification* spec = [[XCPropertyDomainSpecification specificationRegistry] objectForKey:@"com.domain.buildsettings.mycomp"];
return (XCPropertyDomainSpecification*)[spec loadedSpecification];
}</pre>
<p>Be carefull : if you do this (using pbbsetspec files), command line arguments won't be
automatically issued.</p>
<p>The human readable names are defined in a <code>.strings</code> file (in order to be localizable)
named <code>«identifier».strings</code> (<code>com.domain.me.compilers.strings</code> for the above
sample):</p>
<pre>"[OPTION_1]-name" = "Option 1";
"[OPTION_1]-description" = "Description&hellip; [OPTION_1, -with-opt1]";
"[OPTION_2]-name" = "Option 2";
"[OPTION_2]-description" = "Description&hellip; [OPTION_2, -I]";
"[OPTION_3]-name" = "Option 3";
"[OPTION_3]-description" = "Description&hellip; [OPTION_3]";
"[OPTION_4]-name" = "Option 4";
"[OPTION_4]-value-[VAL1]" = "Value 1";
"[OPTION_4]-value-[VAL2]" = "Value 2";
"[OPTION_4]-value-[VAL3]" = "Value 3";
"[OPTION_4]-value-[VAL4]" = "Value 4";
"[OPTION_4]-value-[VAL5]" = "Value 5";
"[OPTION_4]-description" = "Description&hellip; [OPTION_4, -a, -b, -custom]";</pre>
<!-- --- --- --- --- -->
<h2><a name="api">2. Environment API</a></h2>
<p>Expand variables :</p>
<ul>
<li>Expand as a string : <code>[PBXBuildSetting expandedValueForString:]</code></li>
<li>Expand as a path : <code>[PBXBuildSetting absoluteExpandedPathForString:]</code></li>
<li>Expand as a boolean value : <code>[PBXBuildSetting expandedBooleanValueForString:]</code> (Xcode &gt;= 2.2)</li>
<li>Test if the variable expands to a non-empty string : <code>[PBXBuildSetting expandedValueIsNonEmptyForString:]</code> (Xcode &gt;= 2.2)</li>
<li><strike>Find if there is a variable to expand : <code>[PBXBuildSetting expandedValueExistsForString:]</code></strike> (Xcode &lt; 2.2)</li>
<li><strike>Expand a string : <code>[PBXBuildSetting expandedValueForString:getRecursiveSettingName:options:]</code><br />
(the two last parameters should be respectively <code>nil</code> and <code>1</code>)</strike> (Xcode &lt; 2.2)</li>
</ul>
<p>Modify string variables :</p>
<ul>
<li>Set : <code>[PBXBuildSetting setStringValue:forDynamicSetting:]</code></li>
<li>Delete : <code>[PBXBuildSetting removeDynamicSetting:]</code></li>
</ul>
<p>Modify string list variables :</p>
<ul>
<li>Insert a string at the beginnig : <code>[PBXBuildSetting prependStringOrStringListValue:toDynamicSetting:]</code></li>
<li>Insert a string at the end : <code>[PBXBuildSetting appendStringOrStringListValue:toDynamicSetting:]</code></li>
<li>Remove an string from the list : <code>[PBXBuildSetting removeStringOrStringListValue:]</code></li>
</ul>
<p>Some useful tasks :</p>
<ul>
<li>Convert a string to a boolean value : <code>[NSString boolValue]</code></li>
<li>Convert a space separated string list to a string array : <code>[NSString arrayByParsingAsStringList]</code></li>
</ul>
<p>Compute command line arguments from build settings :</p>
<ul>
<li>Defined in the <code>Options</code> key :<br />
<code>[XCCommandLineToolSpecification commandLineForAutogeneratedOptionsInTargetBuildContext:]</code></li>
<li>Defined in a custom key :<br />
<code>[XCCommandLineToolSpecification commandLineForAutogeneratedOptionsForKey:inTargetBuildContext:]</code></li>
</ul>
<p>For more informations, see the <code>XCPBuildSystem.h</code>n <code>XCPSpecifications.h</code>
and <code>XCPSupport.h</code> header files available <a href="xcode-plugin-headers.zip">here</a>.</p>
<!-- --- --- --- --- -->
<h2><a name="variables">3. Useful Environment Variables</a></h2>
<p>In many case, it's possible to provide different values when compiling to different architectures
or different variant : <code>MYSETTING_ppc</code>, <code>MYSETTING_x86</code>,
<code>MYSETTING_normal</code>, <code>MYSETTING_debug</code>, <code>MYSETTING_normal_ppc</code>.</p>
<p>Variables containing useful paths :</p>
<ul>
<li>Local applications folder : <code>LOCAL_APPS_DIR</code> <small>(defaults to <code>/Applications</code>)</small></li>
<li>Local utilities folder : <code>LOCAL_ADMIN_APPS_DIR</code> <small>(defaults to <code>/Applications/Utilities</code>)</small></li>
<li>Local library folder : <code>LOCAL_LIBRARY_DIR</code> <small>(defaults to <code>/Library</code>)</small></li>
<li>User folder : <code>HOME</code> <small>(defaults to <code>~</code>)</small></li>
<li>User applications folder : <code>USER_APPS_DIR</code> <small>(defaults to <code>~/Applications</code>)</small></li>
<li>User library folder : <code>USER_LIBRARY_DIR</code> <small>(defaults to <code>~/Library</code>)</small></li>
<li>Developer folder : <code>DEVELOPER_DIR</code> <small>(defaults to <code>/Developer</code>)</small></li>
<li>Project base : <code>PROJECT_DIR</code></li>
<li>Target output folder (for final product) : <code>TARGET_BUILD_DIR</code> (or <code>BUILT_PRODUCTS_DIR</code>)</li>
<li>Project output folder (global for all targets) : <code>BUILD_ROOT</code> (or <code>BUILD_DIR</code>)</li>
<li>Target objects folder (for .o files) : <code>OBJECTS_DIR</code> (<code>OBJECT_FILE_DIR</code>, <code>OBJECT_FILE_DIR_$(variant)</code>, <code>$(OBJFILES_DIR_$(variant))/$(arch)</code>)</li>
<li>Target derived files folder (for yacc, lex output) : <code>DERIVED_FILES_DIR</code> (or <code>DERIVED_FILE_DIR</code> or <code>DERIVED_SOURCES_DIR</code>)</li>
<li>Temporary folder for one target : <code>TEMP_DIR</code></li>
<li>Temporary folder for the whole project : <code>PROJECT_TEMP_DIR</code></li>
<li>Temporary folder for the one configuration : <code>CONFIGURATION_TEMP_DIR</code></li>
</ul>
<p>Variables used to defined the product :</p>
<ul>
<li>Installation path : <code>INSTALL_PATH</code>. A good value is : <code>$(HOME)/bin</code> for
command line tools, <code>$(HOME)/Applications</code> for applications, <code>$(HOME)/Library/Frameworks</code> for frameworks&hellip;</li>
<li>Installation path for headers : <code>PUBLIC_HEADERS_FOLDER_PATH</code></li>
<li>Product name : <code>PRODUCT_NAME</code></li>
<li>Project file name : <code>PROJECT_NAME</code></li>
<li>Executable name : <code>EXECUTABLE_NAME</code>. A good value is :<br />
<code>$(EXECUTABLE_PREFIX)$(PRODUCT_NAME)$(EXECUTABLE_VARIANT_SUFFIX)$(EXECUTABLE_SUFFIX)</code>.</li>
<li>Architectures : <code>ARCHS</code> (see <code>arch</code>)</li>
<li>Build variants : <code>BUILD_VARIANTS</code> (see <code>variant</code>)</li>
</ul>
<p>Variables containing compilation/linking directives :</p>
<ul>
<li>Header paths : <code>HEADER_SEARCH_PATHS</code></li>
<li>Library paths : <code>LIBRARY_SEARCH_PATHS</code></li>
<li>Framework paths : <code>FRAMEWORK_SEARCH_PATHS</code></li>
<li>Should generate profiling code : <code>GENERATE_PROFILING_CODE</code></li>
<li>Type of libary : <code>LIBRARY_STYLE</code> (= <code>STATIC</code>, <code>DYNAMIC</code> or <code>BUNDLE</code>)</li>
</ul>
<p>Variables used in compiler specification files (Xcode >= 2.3) :</p>
<ul>
<li>Input file path : <code>InputFile</code></li>
<li>Output file path : <code>OutputFile</code></li>
<li>String added to ouput file name, if two source files have the same basename : <code>SourceBaseNameUniquefier</code></li>
<li>Output file destination : <code>ObjectsDir</code></li>
</ul>
<p>Variables used during dependency graph creation (lowercase) :</p>
<ul>
<li>Current variant being processed : <code>variant</code> (or <code>CURRENT_VARIANT</code>)</li>
<li>Current architecture being processed : <code>arch</code> (or <code>CURRENT_ARCH</code>)</li>
<li><strike>Object files sent to the linker : <code>object_files_$(variant)_$(arch)</code></strike>
(Xcode &lt; 2.3)</li>
<li>Object files sent to the linker : <code>object_files</code> (Xcode &gt;= 2.3)</li>
<li>?? : <code>non_master_object_files</code></li>
<li>?? : <code>dylib_files</code></li>
<li>?? : <code>sab_binaries</code></li>
<li>?? : <code>strippable_linked_product_$(variant)</code></li>
<li>File specific build flags : <code>build_file_compiler_flags</code></li>
<li>?? : <code>build_file_attributes</code></li>
<li>Force to use the given linker : <code>compiler_mandated_linker</code> and <code>compiler_mandated_linker_priority</code>
(use a custom product specification or <code>RequiredLinker</code> instead)</li>
<li>?? : <code>compiler_mandated_librarian</code> and <code>compiler_mandated_librarian_priority</code></li>
</ul>
<p>Other available variables :</p>
<ul>
<li>Current configuration : <code>CONFIGURATION</code> (or <code>BUILD_STYLE</code>)</li>
<li>Current user ID : <code>UID</code></li>
<li>Current user name : <code>USER</code></li>
<li>Current user group : <code>GROUP</code></li>
<li>Current action : <code>BUILD_ACTION</code></li>
<li>Previous definition : <code>inherited</code></li>
</ul>
<!-- --- --- --- --- -->
<p class="footer">
Copyright © 2005-2006 Damien Bobillot,
E-Mail : <a href="mailto:damien.bobillot.2002_xcodeplugin CHEZ m4x.org?Subject=%5BXcode Plugins%5D%20">damien.bobillot.2002_xcodeplugin CHEZ m4x.org</a>
</p>
<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
_uacct = "UA-445657-1";
urchinTracker();
</script>
</body>
</html>
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.