├── LICENSE.TXT
├── README.md
├── _manifest.lua
├── _preload.lua
├── tests
├── _tests.lua
├── test_header_footer.lua
├── test_xcode4_project.lua
├── test_xcode4_workspace.lua
├── test_xcode_dependencies.lua
└── test_xcode_project.lua
├── xcode.lua
├── xcode4_workspace.lua
├── xcode_common.lua
└── xcode_project.lua
/LICENSE.TXT:
--------------------------------------------------------------------------------
1 | Copyright (c) 2003-2015 Jason Perkins, Mihai Sebea and individual contributors.
2 | All rights reserved.
3 |
4 | Redistribution and use in source and binary forms, with or without modification,
5 | are permitted provided that the following conditions are met:
6 |
7 | 1. Redistributions of source code must retain the above copyright notice,
8 | this list of conditions and the following disclaimer.
9 |
10 | 2. Redistributions in binary form must reproduce the above copyright notice,
11 | this list of conditions and the following disclaimer in the documentation
12 | and/or other materials provided with the distribution.
13 |
14 | 3. Neither the name of Premake nor the names of its contributors may be
15 | used to endorse or promote products derived from this software without
16 | specific prior written permission.
17 |
18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
22 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ### This repository is no longer active! ###
2 |
3 | This repository has been merged with the [main premake-core source code](https://github.com/premake/premake-core). It will be deleted once everyone has had a chance to get switched over to the new location (probably Jan 2017).
4 |
--------------------------------------------------------------------------------
/_manifest.lua:
--------------------------------------------------------------------------------
1 | return {
2 | "_preload.lua",
3 | "xcode.lua",
4 | "xcode4_workspace.lua",
5 | "xcode_common.lua",
6 | "xcode_project.lua",
7 | }
8 |
--------------------------------------------------------------------------------
/_preload.lua:
--------------------------------------------------------------------------------
1 | ---
2 | -- xcode/_preload.lua
3 | -- Define the Apple XCode actions and new APIs.
4 | -- Copyright (c) 2009-2015 Jason Perkins and the Premake project
5 | ---
6 |
7 | local p = premake
8 |
9 |
10 | --
11 | -- Register new Xcode-specific project fields.
12 | --
13 |
14 | p.api.register {
15 | name = "xcodebuildsettings",
16 | scope = "config",
17 | kind = "key-array",
18 | }
19 |
20 | p.api.register {
21 | name = "xcodebuildresources",
22 | scope = "config",
23 | kind = "list",
24 | }
25 |
26 |
27 | --
28 | -- Register the Xcode exporters.
29 | --
30 |
31 | newaction {
32 | trigger = "xcode4",
33 | shortname = "Apple Xcode 4",
34 | description = "Generate Apple Xcode 4 project files",
35 |
36 | -- Xcode always uses Mac OS X path and naming conventions
37 |
38 | os = "macosx",
39 |
40 | -- The capabilities of this action
41 |
42 | valid_kinds = { "ConsoleApp", "WindowedApp", "SharedLib", "StaticLib", "Makefile", "None" },
43 | valid_languages = { "C", "C++" },
44 | valid_tools = {
45 | cc = { "gcc", "clang" },
46 | },
47 |
48 | -- Workspace and project generation logic
49 |
50 | onWorkspace = function(wks)
51 | p.generate(wks, ".xcworkspace/contents.xcworkspacedata", p.modules.xcode.generateWorkspace)
52 | end,
53 |
54 | onProject = function(prj)
55 | p.generate(prj, ".xcodeproj/project.pbxproj", p.modules.xcode.generateProject)
56 | end,
57 | }
58 |
59 |
60 | --
61 | -- Decide when the full module should be loaded.
62 | --
63 |
64 | return function(cfg)
65 | return (_ACTION == "xcode4")
66 | end
67 |
--------------------------------------------------------------------------------
/tests/_tests.lua:
--------------------------------------------------------------------------------
1 | require ("xcode")
2 |
3 | return {
4 | "test_header_footer.lua",
5 | "test_xcode4_project.lua",
6 | "test_xcode4_workspace.lua",
7 | "test_xcode_dependencies.lua",
8 | "test_xcode_project.lua",
9 | }
10 |
--------------------------------------------------------------------------------
/tests/test_header_footer.lua:
--------------------------------------------------------------------------------
1 | ---
2 | -- xcode/tests/test_header.lua
3 | -- Validate generation for Xcode workspaces.
4 | -- Author Jason Perkins
5 | -- Copyright (c) 2009-2015 Jason Perkins and the Premake project
6 | ---
7 |
8 | local suite = test.declare("xcode_header")
9 | local xcode = premake.modules.xcode
10 |
11 |
12 | --
13 | -- Setup
14 | --
15 |
16 | local wks
17 |
18 | function suite.setup()
19 | wks = test.createWorkspace()
20 | end
21 |
22 | local function prepare()
23 | prj = test.getproject(wks, 1)
24 | xcode.header(prj)
25 | xcode.footer(prj)
26 | end
27 |
28 |
29 | --
30 | -- Check basic structure
31 | --
32 |
33 | function suite.onDefaults()
34 | prepare()
35 | test.capture [[
36 | // !$*UTF8*$!
37 | {
38 | archiveVersion = 1;
39 | classes = {
40 | };
41 | objectVersion = 46;
42 | objects = {
43 |
44 | };
45 | rootObject = 08FB7793FE84155DC02AAC07 /* Project object */;
46 | }
47 | ]]
48 | end
49 |
--------------------------------------------------------------------------------
/tests/test_xcode4_project.lua:
--------------------------------------------------------------------------------
1 | ---
2 | -- tests/actions/xcode/test_xcode4_project.lua
3 | -- Automated test suite for Xcode project generation.
4 | -- Copyright (c) 2011-2015 Jason Perkins and the Premake project
5 | ---
6 |
7 |
8 | local suite = test.declare("xcode4_proj")
9 | local xcode = premake.modules.xcode
10 |
11 |
12 | --
13 | -- Replacement for xcode.newid(). Creates a synthetic ID based on the node name,
14 | -- its intended usage (file ID, build ID, etc.) and its place in the tree. This
15 | -- makes it easier to tell if the right ID is being used in the right places.
16 | --
17 |
18 | xcode.used_ids = {}
19 |
20 | xcode.newid = function(node, usage)
21 | local name = node
22 | if usage then
23 | name = name .. ":" .. usage
24 | end
25 |
26 | if xcode.used_ids[name] then
27 | local count = xcode.used_ids[name] + 1
28 | xcode.used_ids[name] = count
29 | name = name .. "(" .. count .. ")"
30 | else
31 | xcode.used_ids[name] = 1
32 | end
33 |
34 | return "[" .. name .. "]"
35 | end
36 |
37 |
38 |
39 |
40 | ---------------------------------------------------------------------------
41 | -- Setup/Teardown
42 | ---------------------------------------------------------------------------
43 |
44 | local tr, wks
45 |
46 | function suite.teardown()
47 | tr = nil
48 | end
49 |
50 | function suite.setup()
51 | _OS = "macosx"
52 | _ACTION = "xcode4"
53 | io.eol = "\n"
54 | xcode.used_ids = { } -- reset the list of generated IDs
55 | wks = test.createWorkspace()
56 | end
57 |
58 | local function prepare()
59 | wks = premake.oven.bakeWorkspace(wks)
60 | xcode.prepareWorkspace(wks)
61 | local prj = premake.workspace.getproject(wks, 1)
62 | tr = xcode.buildprjtree(prj)
63 | end
64 |
65 | ---------------------------------------------------------------------------
66 | -- XCBuildConfiguration_Project tests
67 | ---------------------------------------------------------------------------
68 |
69 | function suite.XCBuildConfigurationProject_OnSymbols()
70 | symbols "On"
71 | prepare()
72 | xcode.XCBuildConfiguration_Project(tr, tr.configs[1])
73 | test.capture [[
74 | [MyProject:Debug(2)] /* Debug */ = {
75 | isa = XCBuildConfiguration;
76 | buildSettings = {
77 | ARCHS = "$(NATIVE_ARCH_ACTUAL)";
78 | CONFIGURATION_BUILD_DIR = "$(SYMROOT)";
79 | CONFIGURATION_TEMP_DIR = "$(OBJROOT)";
80 | COPY_PHASE_STRIP = NO;
81 | GCC_C_LANGUAGE_STANDARD = gnu99;
82 | GCC_ENABLE_FIX_AND_CONTINUE = YES;
83 | GCC_OPTIMIZATION_LEVEL = 0;
84 | GCC_SYMBOLS_PRIVATE_EXTERN = NO;
85 | GCC_WARN_ABOUT_RETURN_TYPE = YES;
86 | GCC_WARN_UNUSED_VARIABLE = YES;
87 | OBJROOT = obj/Debug;
88 | ONLY_ACTIVE_ARCH = YES;
89 | SYMROOT = bin/Debug;
90 | };
91 | name = Debug;
92 | };
93 | ]]
94 | end
95 |
--------------------------------------------------------------------------------
/tests/test_xcode4_workspace.lua:
--------------------------------------------------------------------------------
1 | ---
2 | -- xcode/tests/test_xcode4_workspace.lua
3 | -- Validate generation for Xcode workspaces.
4 | -- Author Mihai Sebea
5 | -- Modified by Jason Perkins
6 | -- Copyright (c) 2014-2015 Jason Perkins and the Premake project
7 | ---
8 |
9 | local suite = test.declare("xcode4_workspace")
10 | local xcode = premake.modules.xcode
11 |
12 |
13 | --
14 | -- Setup
15 | --
16 |
17 | local wks, prj
18 |
19 | function suite.setup()
20 | _ACTION = "xcode4"
21 | wks = test.createWorkspace()
22 | end
23 |
24 | local function prepare()
25 | wks = test.getWorkspace(wks)
26 | xcode.generateWorkspace(wks)
27 | end
28 |
29 |
30 | --
31 | -- Check the basic structure of a workspace.
32 | --
33 |
34 | function suite.onEmptyWorkspace()
35 | wks.projects = {}
36 | prepare()
37 | test.capture [[
38 |
39 |
41 |
42 | ]]
43 | end
44 |
45 |
46 | function suite.onDefaultWorkspace()
47 | prepare()
48 | test.capture [[
49 |
50 |
52 |
54 |
55 |
56 | ]]
57 | end
58 |
59 |
60 | function suite.onMultipleProjects()
61 | test.createproject(wks)
62 | prepare()
63 | test.capture [[
64 |
65 |
67 |
69 |
70 |
72 |
73 |
74 | ]]
75 | end
76 |
77 |
78 |
79 | --
80 | -- Projects should include relative path from workspace.
81 | --
82 |
83 | function suite.onNestedProjectPath()
84 | location "MyProject"
85 | prepare()
86 | test.capture [[
87 |
88 |
90 |
92 |
93 |
94 | ]]
95 | end
96 |
97 | function suite.onExternalProjectPath()
98 | location "../MyProject"
99 | prepare()
100 | test.capture [[
101 |
102 |
104 |
106 |
107 |
108 | ]]
109 | end
110 |
--------------------------------------------------------------------------------
/tests/test_xcode_dependencies.lua:
--------------------------------------------------------------------------------
1 | --
2 | -- tests/actions/xcode/test_xcode_dependencies.lua
3 | -- Automated test suite for Xcode project dependencies.
4 | -- Copyright (c) 2009-2011 Jason Perkins and the Premake project
5 | --
6 |
7 | local suite = test.declare("xcode_deps")
8 | local xcode = premake.modules.xcode
9 |
10 |
11 | ---------------------------------------------------------------------------
12 | -- Setup/Teardown
13 | ---------------------------------------------------------------------------
14 |
15 | local wks, prj, prj2, tr
16 |
17 | function suite.teardown()
18 | wks = nil
19 | prj = nil
20 | prj2 = nil
21 | tr = nil
22 | end
23 |
24 | function suite.setup()
25 | _ACTION = "xcode4"
26 | xcode.used_ids = { } -- reset the list of generated IDs
27 |
28 | wks, prj = test.createWorkspace()
29 | links { "MyProject2" }
30 |
31 | prj2 = test.createproject(wks)
32 | kind "StaticLib"
33 | configuration "Debug"
34 | targetsuffix "-d"
35 | end
36 |
37 | local function prepare()
38 | wks = premake.oven.bakeWorkspace(wks)
39 | xcode.prepareWorkspace(wks)
40 | local prj3 = premake.workspace.getproject(wks, 1)
41 | --prj2 = test.getproject(wks, 2)
42 | tr = xcode.buildprjtree(prj3)
43 | end
44 |
45 |
46 | ---------------------------------------------------------------------------
47 | -- PBXBuildFile tests
48 | ---------------------------------------------------------------------------
49 |
50 | function suite.PBXBuildFile_ListsDependencyTargets_OnStaticLib()
51 | prepare()
52 | xcode.PBXBuildFile(tr)
53 | test.capture [[
54 | /* Begin PBXBuildFile section */
55 | [libMyProject2-d.a:build] /* libMyProject2-d.a in Frameworks */ = {isa = PBXBuildFile; fileRef = [libMyProject2-d.a] /* libMyProject2-d.a */; };
56 | /* End PBXBuildFile section */
57 | ]]
58 | end
59 |
60 | function suite.PBXBuildFile_ListsDependencyTargets_OnSharedLib()
61 | kind "SharedLib"
62 | prepare()
63 | xcode.PBXBuildFile(tr)
64 | test.capture [[
65 | /* Begin PBXBuildFile section */
66 | [libMyProject2-d.dylib:build] /* libMyProject2-d.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = [libMyProject2-d.dylib] /* libMyProject2-d.dylib */; };
67 | /* End PBXBuildFile section */
68 | ]]
69 | end
70 |
71 |
72 | ---------------------------------------------------------------------------
73 | -- PBXContainerItemProxy tests
74 | ---------------------------------------------------------------------------
75 |
76 | function suite.PBXContainerItemProxy_ListsProjectConfigs()
77 | prepare()
78 | xcode.PBXContainerItemProxy(tr)
79 | test.capture [[
80 | /* Begin PBXContainerItemProxy section */
81 | [MyProject2.xcodeproj:prodprox] /* PBXContainerItemProxy */ = {
82 | isa = PBXContainerItemProxy;
83 | containerPortal = [MyProject2.xcodeproj] /* MyProject2.xcodeproj */;
84 | proxyType = 2;
85 | remoteGlobalIDString = [libMyProject2-d.a:product];
86 | remoteInfo = "libMyProject2-d.a";
87 | };
88 | [MyProject2.xcodeproj:targprox] /* PBXContainerItemProxy */ = {
89 | isa = PBXContainerItemProxy;
90 | containerPortal = [MyProject2.xcodeproj] /* MyProject2.xcodeproj */;
91 | proxyType = 1;
92 | remoteGlobalIDString = [libMyProject2-d.a:target];
93 | remoteInfo = "libMyProject2-d.a";
94 | };
95 | /* End PBXContainerItemProxy section */
96 | ]]
97 | end
98 |
99 |
100 | ---------------------------------------------------------------------------
101 | -- PBXFileReference tests
102 | ---------------------------------------------------------------------------
103 |
104 | function suite.PBXFileReference_ListsDependencies()
105 | prepare()
106 | xcode.PBXFileReference(tr)
107 | test.capture [[
108 | /* Begin PBXFileReference section */
109 | [MyProject2.xcodeproj] /* libMyProject2-d.a */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = "MyProject2.xcodeproj"; path = MyProject2.xcodeproj; sourceTree = SOURCE_ROOT; };
110 | [MyProject:product] /* MyProject */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; name = MyProject; path = MyProject; sourceTree = BUILT_PRODUCTS_DIR; };
111 | /* End PBXFileReference section */
112 | ]]
113 | end
114 |
115 | function suite.PBXFileReference_UsesRelativePaths()
116 | prj.location = "MyProject"
117 | prj2.location = "MyProject2"
118 | prepare()
119 | xcode.PBXFileReference(tr)
120 | test.capture [[
121 | /* Begin PBXFileReference section */
122 | [MyProject2.xcodeproj] /* libMyProject2-d.a */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = "MyProject2.xcodeproj"; path = ../MyProject2.xcodeproj; sourceTree = SOURCE_ROOT; };
123 | [MyProject:product] /* MyProject */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; name = MyProject; path = MyProject; sourceTree = BUILT_PRODUCTS_DIR; };
124 | /* End PBXFileReference section */
125 | ]]
126 | end
127 |
128 |
129 | ---------------------------------------------------------------------------
130 | -- PBXFrameworksBuildPhase tests
131 | ---------------------------------------------------------------------------
132 |
133 | function suite.PBXFrameworksBuildPhase_ListsDependencies_OnStaticLib()
134 | prepare()
135 | xcode.PBXFrameworksBuildPhase(tr)
136 | test.capture [[
137 | /* Begin PBXFrameworksBuildPhase section */
138 | [MyProject:fxs] /* Frameworks */ = {
139 | isa = PBXFrameworksBuildPhase;
140 | buildActionMask = 2147483647;
141 | files = (
142 | [libMyProject2-d.a:build] /* libMyProject2-d.a in Frameworks */,
143 | );
144 | runOnlyForDeploymentPostprocessing = 0;
145 | };
146 | /* End PBXFrameworksBuildPhase section */
147 | ]]
148 | end
149 |
150 | function suite.PBXFrameworksBuildPhase_ListsDependencies_OnSharedLib()
151 | kind "SharedLib"
152 | prepare()
153 | xcode.PBXFrameworksBuildPhase(tr)
154 | test.capture [[
155 | /* Begin PBXFrameworksBuildPhase section */
156 | [MyProject:fxs] /* Frameworks */ = {
157 | isa = PBXFrameworksBuildPhase;
158 | buildActionMask = 2147483647;
159 | files = (
160 | [libMyProject2-d.dylib:build] /* libMyProject2-d.dylib in Frameworks */,
161 | );
162 | runOnlyForDeploymentPostprocessing = 0;
163 | };
164 | /* End PBXFrameworksBuildPhase section */
165 | ]]
166 | end
167 |
168 | ---------------------------------------------------------------------------
169 | -- PBXGroup tests
170 | ---------------------------------------------------------------------------
171 |
172 | function suite.PBXGroup_ListsDependencies()
173 | prepare()
174 | xcode.PBXGroup(tr)
175 | test.capture [[
176 | /* Begin PBXGroup section */
177 | [MyProject2.xcodeproj:prodgrp] /* Products */ = {
178 | isa = PBXGroup;
179 | children = (
180 | [libMyProject2-d.a] /* libMyProject2-d.a */,
181 | );
182 | name = Products;
183 | sourceTree = "";
184 | };
185 | [MyProject] /* MyProject */ = {
186 | isa = PBXGroup;
187 | children = (
188 | [Products] /* Products */,
189 | [Projects] /* Projects */,
190 | );
191 | name = MyProject;
192 | sourceTree = "";
193 | };
194 | [Products] /* Products */ = {
195 | isa = PBXGroup;
196 | children = (
197 | [MyProject:product] /* MyProject */,
198 | );
199 | name = Products;
200 | sourceTree = "";
201 | };
202 | [Projects] /* Projects */ = {
203 | isa = PBXGroup;
204 | children = (
205 | [MyProject2.xcodeproj] /* MyProject2.xcodeproj */,
206 | );
207 | name = Projects;
208 | sourceTree = "";
209 | };
210 | /* End PBXGroup section */
211 | ]]
212 | end
213 |
214 |
215 | ---------------------------------------------------------------------------
216 | -- PBXNativeTarget tests
217 | ---------------------------------------------------------------------------
218 |
219 | function suite.PBXNativeTarget_ListsDependencies()
220 | prepare()
221 | xcode.PBXNativeTarget(tr)
222 | test.capture [[
223 | /* Begin PBXNativeTarget section */
224 | [MyProject:target] /* MyProject */ = {
225 | isa = PBXNativeTarget;
226 | buildConfigurationList = [MyProject:cfg] /* Build configuration list for PBXNativeTarget "MyProject" */;
227 | buildPhases = (
228 | [MyProject:rez] /* Resources */,
229 | [MyProject:src] /* Sources */,
230 | [MyProject:fxs] /* Frameworks */,
231 | );
232 | buildRules = (
233 | );
234 | dependencies = (
235 | [MyProject2.xcodeproj:targdep] /* PBXTargetDependency */,
236 | );
237 | name = MyProject;
238 | productInstallPath = "$(HOME)/bin";
239 | productName = MyProject;
240 | productReference = [MyProject:product] /* MyProject */;
241 | productType = "com.apple.product-type.tool";
242 | };
243 | /* End PBXNativeTarget section */
244 | ]]
245 | end
246 |
247 |
248 | ---------------------------------------------------------------------------
249 | -- PBXProject tests
250 | ---------------------------------------------------------------------------
251 |
252 | function suite.PBXProject_ListsDependencies()
253 | prepare()
254 | xcode.PBXProject(tr)
255 | test.capture [[
256 | /* Begin PBXProject section */
257 | 08FB7793FE84155DC02AAC07 /* Project object */ = {
258 | isa = PBXProject;
259 | buildConfigurationList = 1DEB928908733DD80010E9CD /* Build configuration list for PBXProject "MyProject" */;
260 | compatibilityVersion = "Xcode 3.2";
261 | hasScannedForEncodings = 1;
262 | mainGroup = [MyProject] /* MyProject */;
263 | projectDirPath = "";
264 | projectReferences = (
265 | {
266 | ProductGroup = [MyProject2.xcodeproj:prodgrp] /* Products */;
267 | ProjectRef = [MyProject2.xcodeproj] /* MyProject2.xcodeproj */;
268 | },
269 | );
270 | projectRoot = "";
271 | targets = (
272 | [MyProject:target] /* MyProject */,
273 | );
274 | };
275 | /* End PBXProject section */
276 | ]]
277 | end
278 |
279 |
280 | ---------------------------------------------------------------------------
281 | -- PBXReferenceProxy tests
282 | ---------------------------------------------------------------------------
283 |
284 | function suite.PBXReferenceProxy_ListsDependencies()
285 | prepare()
286 | xcode.PBXReferenceProxy(tr)
287 | test.capture [[
288 | /* Begin PBXReferenceProxy section */
289 | [libMyProject2-d.a] /* libMyProject2-d.a */ = {
290 | isa = PBXReferenceProxy;
291 | fileType = archive.ar;
292 | path = "libMyProject2-d.a";
293 | remoteRef = [MyProject2.xcodeproj:prodprox] /* PBXContainerItemProxy */;
294 | sourceTree = BUILT_PRODUCTS_DIR;
295 | };
296 | /* End PBXReferenceProxy section */
297 | ]]
298 | end
299 |
300 |
301 | ---------------------------------------------------------------------------
302 | -- PBXTargetDependency tests
303 | ---------------------------------------------------------------------------
304 |
305 | function suite.PBXTargetDependency_ListsDependencies()
306 | prepare()
307 | xcode.PBXTargetDependency(tr)
308 | test.capture [[
309 | /* Begin PBXTargetDependency section */
310 | [MyProject2.xcodeproj:targdep] /* PBXTargetDependency */ = {
311 | isa = PBXTargetDependency;
312 | name = "libMyProject2-d.a";
313 | targetProxy = [MyProject2.xcodeproj:targprox] /* PBXContainerItemProxy */;
314 | };
315 | /* End PBXTargetDependency section */
316 | ]]
317 | end
318 |
--------------------------------------------------------------------------------
/tests/test_xcode_project.lua:
--------------------------------------------------------------------------------
1 | --
2 | -- tests/actions/xcode/test_xcode_project.lua
3 | -- Automated test suite for Xcode project generation.
4 | -- Copyright (c) 2009-2011 Jason Perkins and the Premake project
5 | --
6 | local suite = test.declare("xcode_project")
7 | local xcode = premake.modules.xcode
8 |
9 |
10 |
11 | ---------------------------------------------------------------------------
12 | -- Setup/Teardown
13 | ---------------------------------------------------------------------------
14 |
15 | local tr, wks
16 |
17 | function suite.teardown()
18 | tr = nil
19 | end
20 |
21 | function suite.setup()
22 | _OS = "macosx"
23 | _ACTION = "xcode4"
24 | premake.eol("\n")
25 | xcode.used_ids = { } -- reset the list of generated IDs
26 | wks = test.createWorkspace()
27 | end
28 |
29 | local function prepare()
30 | wks = premake.oven.bakeWorkspace(wks)
31 | xcode.prepareWorkspace(wks)
32 | local prj = test.getproject(wks, 1)
33 | tr = xcode.buildprjtree(prj)
34 | end
35 |
36 | ---------------------------------------------------------------------------
37 | -- PBXBuildFile tests
38 | ---------------------------------------------------------------------------
39 |
40 | function suite.PBXBuildFile_ListsCppSources()
41 | files { "source.h", "source.c", "source.cpp", "Info.plist" }
42 | prepare()
43 | xcode.PBXBuildFile(tr)
44 | test.capture [[
45 | /* Begin PBXBuildFile section */
46 | [source.c:build] /* source.c in Sources */ = {isa = PBXBuildFile; fileRef = [source.c] /* source.c */; };
47 | [source.cpp:build] /* source.cpp in Sources */ = {isa = PBXBuildFile; fileRef = [source.cpp] /* source.cpp */; };
48 | /* End PBXBuildFile section */
49 | ]]
50 | end
51 |
52 | function suite.PBXBuildFile_ListsObjCSources()
53 | files { "source.h", "source.m", "source.mm", "Info.plist" }
54 | prepare()
55 | xcode.PBXBuildFile(tr)
56 | test.capture [[
57 | /* Begin PBXBuildFile section */
58 | [source.m:build] /* source.m in Sources */ = {isa = PBXBuildFile; fileRef = [source.m] /* source.m */; };
59 | [source.mm:build] /* source.mm in Sources */ = {isa = PBXBuildFile; fileRef = [source.mm] /* source.mm */; };
60 | /* End PBXBuildFile section */
61 | ]]
62 | end
63 |
64 | function suite.PBXBuildFile_ListsResourceFilesOnlyOnceWithGroupID()
65 | files { "English.lproj/MainMenu.xib", "French.lproj/MainMenu.xib" }
66 | prepare()
67 | xcode.PBXBuildFile(tr)
68 | test.capture [[
69 | /* Begin PBXBuildFile section */
70 | [MainMenu.xib:build] /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = [MainMenu.xib] /* MainMenu.xib */; };
71 | /* End PBXBuildFile section */
72 | ]]
73 | end
74 |
75 |
76 | function suite.PBXBuildFile_ListsFrameworks()
77 | links { "Cocoa.framework", "ldap" }
78 | prepare()
79 | xcode.PBXBuildFile(tr)
80 | test.capture [[
81 | /* Begin PBXBuildFile section */
82 | [Cocoa.framework:build] /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = [Cocoa.framework] /* Cocoa.framework */; };
83 | /* End PBXBuildFile section */
84 | ]]
85 | end
86 |
87 | function suite.PBXBuildFile_IgnoresVpaths()
88 | files { "source.h", "source.c", "source.cpp", "Info.plist" }
89 | vpaths { ["Source Files"] = { "**.c", "**.cpp" } }
90 | prepare()
91 | xcode.PBXBuildFile(tr)
92 | test.capture [[
93 | /* Begin PBXBuildFile section */
94 | [source.c:build] /* source.c in Sources */ = {isa = PBXBuildFile; fileRef = [source.c] /* source.c */; };
95 | [source.cpp:build] /* source.cpp in Sources */ = {isa = PBXBuildFile; fileRef = [source.cpp] /* source.cpp */; };
96 | /* End PBXBuildFile section */
97 | ]]
98 | end
99 |
100 |
101 | ---------------------------------------------------------------------------
102 | -- PBXFileReference tests
103 | ---------------------------------------------------------------------------
104 |
105 | function suite.PBXFileReference_ListsConsoleTarget()
106 | prepare()
107 | xcode.PBXFileReference(tr)
108 | test.capture [[
109 | /* Begin PBXFileReference section */
110 | [MyProject:product] /* MyProject */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; name = MyProject; path = MyProject; sourceTree = BUILT_PRODUCTS_DIR; };
111 | /* End PBXFileReference section */
112 | ]]
113 | end
114 |
115 |
116 | function suite.PBXFileReference_ListsWindowedTarget()
117 | kind "WindowedApp"
118 | prepare()
119 | xcode.PBXFileReference(tr)
120 | test.capture [[
121 | /* Begin PBXFileReference section */
122 | [MyProject.app:product] /* MyProject.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; name = MyProject.app; path = MyProject.app; sourceTree = BUILT_PRODUCTS_DIR; };
123 | /* End PBXFileReference section */
124 | ]]
125 | end
126 |
127 |
128 | function suite.PBXFileReference_ListsStaticLibTarget()
129 | kind "StaticLib"
130 | prepare()
131 | xcode.PBXFileReference(tr)
132 | test.capture [[
133 | /* Begin PBXFileReference section */
134 | [libMyProject.a:product] /* libMyProject.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; name = libMyProject.a; path = libMyProject.a; sourceTree = BUILT_PRODUCTS_DIR; };
135 | /* End PBXFileReference section */
136 | ]]
137 | end
138 |
139 |
140 | function suite.PBXFileReference_ListsSharedLibTarget()
141 | kind "SharedLib"
142 | prepare()
143 | xcode.PBXFileReference(tr)
144 | test.capture [[
145 | /* Begin PBXFileReference section */
146 | [libMyProject.dylib:product] /* libMyProject.dylib */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; name = libMyProject.dylib; path = libMyProject.dylib; sourceTree = BUILT_PRODUCTS_DIR; };
147 | /* End PBXFileReference section */
148 | ]]
149 | end
150 |
151 |
152 | function suite.PBXFileReference_ListsSourceFiles()
153 | files { "source.c" }
154 | prepare()
155 | xcode.PBXFileReference(tr)
156 | test.capture [[
157 | /* Begin PBXFileReference section */
158 | [MyProject:product] /* MyProject */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; name = MyProject; path = MyProject; sourceTree = BUILT_PRODUCTS_DIR; };
159 | [source.c] /* source.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = source.c; path = source.c; sourceTree = ""; };
160 | ]]
161 | end
162 |
163 |
164 | function suite.PBXFileReference_ListsXibCorrectly()
165 | files { "English.lproj/MainMenu.xib", "French.lproj/MainMenu.xib" }
166 | prepare()
167 | xcode.PBXFileReference(tr)
168 | test.capture [[
169 | /* Begin PBXFileReference section */
170 | [English] /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = English.lproj/MainMenu.xib; sourceTree = ""; };
171 | [French] /* French */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = French; path = French.lproj/MainMenu.xib; sourceTree = ""; };
172 | ]]
173 | end
174 |
175 |
176 | function suite.PBXFileReference_ListsStringsCorrectly()
177 | files { "English.lproj/InfoPlist.strings", "French.lproj/InfoPlist.strings" }
178 | prepare()
179 | xcode.PBXFileReference(tr)
180 | test.capture [[
181 | /* Begin PBXFileReference section */
182 | [English] /* English */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/InfoPlist.strings; sourceTree = ""; };
183 | [French] /* French */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = French; path = French.lproj/InfoPlist.strings; sourceTree = ""; };
184 | ]]
185 | end
186 |
187 |
188 | function suite.PBXFileReference_ListFrameworksCorrectly()
189 | links { "Cocoa.framework/" }
190 | prepare()
191 | xcode.PBXFileReference(tr)
192 | test.capture [[
193 | /* Begin PBXFileReference section */
194 | [Cocoa.framework] /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; };
195 | ]]
196 | end
197 |
198 |
199 | function suite.PBXFileReference_leavesFrameworkLocationsAsIsWhenSupplied_pathIsSetToInput()
200 | local inputFrameWork = 'somedir/Foo.framework'
201 | links(inputFrameWork)
202 | prepare()
203 |
204 | --io.capture()
205 | xcode.PBXFileReference(tr)
206 | --local str = io.captured()
207 | --test.istrue(str:find('path = "'..inputFrameWork..'"'))
208 |
209 | --ms check
210 | end
211 |
212 |
213 | function suite.PBXFileReference_relativeFrameworkPathSupplied_callsError()
214 | local inputFrameWork = '../somedir/Foo.framework'
215 | links(inputFrameWork)
216 | prepare()
217 | -- ms no longer and error
218 | -- valid case for linking relative frameworks
219 | --local error_called = false
220 | --local old_error = error
221 | --error = function( ... )error_called = true end
222 | xcode.PBXFileReference(tr)
223 | --error = old_error
224 | --test.istrue(error_called)
225 | end
226 |
227 | function suite.PBXFileReference_ListsIconFiles()
228 | files { "Icon.icns" }
229 | prepare()
230 | xcode.PBXFileReference(tr)
231 | test.capture [[
232 | /* Begin PBXFileReference section */
233 | [Icon.icns] /* Icon.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; name = Icon.icns; path = Icon.icns; sourceTree = ""; };
234 | ]]
235 | end
236 |
237 | function suite.PBXFileReference_IgnoresTargetDir()
238 | targetdir "bin"
239 | kind "WindowedApp"
240 | prepare()
241 | xcode.PBXFileReference(tr)
242 | test.capture [[
243 | /* Begin PBXFileReference section */
244 | [MyProject.app:product] /* MyProject.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; name = MyProject.app; path = MyProject.app; sourceTree = BUILT_PRODUCTS_DIR; };
245 | /* End PBXFileReference section */
246 | ]]
247 | end
248 |
249 |
250 | function suite.PBXFileReference_UsesTargetSuffix()
251 | targetsuffix "-d"
252 | kind "SharedLib"
253 | prepare()
254 | xcode.PBXFileReference(tr)
255 | test.capture [[
256 | /* Begin PBXFileReference section */
257 | [libMyProject-d.dylib:product] /* libMyProject-d.dylib */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; name = "libMyProject-d.dylib"; path = "libMyProject-d.dylib"; sourceTree = BUILT_PRODUCTS_DIR; };
258 | /* End PBXFileReference section */
259 | ]]
260 | end
261 |
262 |
263 | function suite.PBXFileReference_UsesFullPath_WhenParentIsVirtual()
264 | files { "src/source.c" }
265 | vpaths { ["Source Files"] = "**.c" }
266 | prepare()
267 | xcode.PBXFileReference(tr)
268 | test.capture [[
269 | /* Begin PBXFileReference section */
270 | [MyProject:product] /* MyProject */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; name = MyProject; path = MyProject; sourceTree = BUILT_PRODUCTS_DIR; };
271 | [source.c] /* source.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = source.c; path = src/source.c; sourceTree = ""; };
272 | ]]
273 | end
274 |
275 |
276 | ---------------------------------------------------------------------------
277 | -- PBXFrameworksBuildPhase tests
278 | ---------------------------------------------------------------------------
279 |
280 | function suite.PBXFrameworksBuildPhase_OnNoFiles()
281 | prepare()
282 | xcode.PBXFrameworksBuildPhase(tr)
283 | test.capture [[
284 | /* Begin PBXFrameworksBuildPhase section */
285 | [MyProject:fxs] /* Frameworks */ = {
286 | isa = PBXFrameworksBuildPhase;
287 | buildActionMask = 2147483647;
288 | files = (
289 | );
290 | runOnlyForDeploymentPostprocessing = 0;
291 | };
292 | /* End PBXFrameworksBuildPhase section */
293 | ]]
294 | end
295 |
296 |
297 | function suite.PBXFrameworksBuild_ListsFrameworksCorrectly()
298 | links { "Cocoa.framework" }
299 | prepare()
300 | xcode.PBXFrameworksBuildPhase(tr)
301 | test.capture [[
302 | /* Begin PBXFrameworksBuildPhase section */
303 | [MyProject:fxs] /* Frameworks */ = {
304 | isa = PBXFrameworksBuildPhase;
305 | buildActionMask = 2147483647;
306 | files = (
307 | [Cocoa.framework:build] /* Cocoa.framework in Frameworks */,
308 | );
309 | runOnlyForDeploymentPostprocessing = 0;
310 | };
311 | /* End PBXFrameworksBuildPhase section */
312 | ]]
313 | end
314 |
315 |
316 | ---------------------------------------------------------------------------
317 | -- PBXGroup tests
318 | ---------------------------------------------------------------------------
319 |
320 | function suite.PBXGroup_OnNoFiles()
321 | prepare()
322 | xcode.PBXGroup(tr)
323 | test.capture [[
324 | /* Begin PBXGroup section */
325 | [MyProject] /* MyProject */ = {
326 | isa = PBXGroup;
327 | children = (
328 | [Products] /* Products */,
329 | );
330 | name = MyProject;
331 | sourceTree = "";
332 | };
333 | [Products] /* Products */ = {
334 | isa = PBXGroup;
335 | children = (
336 | [MyProject:product] /* MyProject */,
337 | );
338 | name = Products;
339 | sourceTree = "";
340 | };
341 | /* End PBXGroup section */
342 | ]]
343 | end
344 |
345 |
346 | function suite.PBXGroup_OnSourceFiles()
347 | files { "source.h" }
348 | prepare()
349 | xcode.PBXGroup(tr)
350 | test.capture [[
351 | /* Begin PBXGroup section */
352 | [MyProject] /* MyProject */ = {
353 | isa = PBXGroup;
354 | children = (
355 | [source.h] /* source.h */,
356 | [Products] /* Products */,
357 | );
358 | name = MyProject;
359 | sourceTree = "";
360 | };
361 | [Products] /* Products */ = {
362 | isa = PBXGroup;
363 | children = (
364 | [MyProject:product] /* MyProject */,
365 | );
366 | name = Products;
367 | sourceTree = "";
368 | };
369 | /* End PBXGroup section */
370 | ]]
371 | end
372 |
373 |
374 | function suite.PBXGroup_OnSourceSubdirs()
375 | files { "include/premake/source.h" }
376 | prepare()
377 | xcode.PBXGroup(tr)
378 | test.capture [[
379 | /* Begin PBXGroup section */
380 | [MyProject] /* MyProject */ = {
381 | isa = PBXGroup;
382 | children = (
383 | [source.h] /* source.h */,
384 | [Products] /* Products */,
385 | );
386 | name = MyProject;
387 | sourceTree = "";
388 | };
389 | [Products] /* Products */ = {
390 | isa = PBXGroup;
391 | children = (
392 | [MyProject:product] /* MyProject */,
393 | );
394 | name = Products;
395 | sourceTree = "";
396 | };
397 | /* End PBXGroup section */
398 | ]]
399 | end
400 |
401 |
402 | function suite.PBXGroup_pathHasPlusPlus_PathIsQuoted()
403 | files { "RequiresQuoting++/h.h" }
404 | prepare()
405 | xcode.PBXGroup(tr)
406 |
407 | local str = premake.captured()
408 | --test.istrue(str:find('path = "RequiresQuoting%+%+";'))
409 |
410 | end
411 |
412 | function suite.PBXGroup_SortsFiles()
413 | files { "test.h", "source.h", "source.cpp" }
414 | prepare()
415 | xcode.PBXGroup(tr)
416 | test.capture [[
417 | /* Begin PBXGroup section */
418 | [MyProject] /* MyProject */ = {
419 | isa = PBXGroup;
420 | children = (
421 | [source.cpp] /* source.cpp */,
422 | [source.h] /* source.h */,
423 | [test.h] /* test.h */,
424 | [Products] /* Products */,
425 | );
426 | name = MyProject;
427 | sourceTree = "";
428 | };
429 | [Products] /* Products */ = {
430 | isa = PBXGroup;
431 | children = (
432 | [MyProject:product] /* MyProject */,
433 | );
434 | name = Products;
435 | sourceTree = "";
436 | };
437 | /* End PBXGroup section */
438 | ]]
439 | end
440 |
441 |
442 | function suite.PBXGroup_OnResourceFiles()
443 | files { "English.lproj/MainMenu.xib", "French.lproj/MainMenu.xib", "Info.plist" }
444 | prepare()
445 | xcode.PBXGroup(tr)
446 | test.capture [[
447 | /* Begin PBXGroup section */
448 | [MyProject] /* MyProject */ = {
449 | isa = PBXGroup;
450 | children = (
451 | [Info.plist] /* Info.plist */,
452 | [MainMenu.xib] /* MainMenu.xib */,
453 | [Products] /* Products */,
454 | );
455 | name = MyProject;
456 | sourceTree = "";
457 | };
458 | [Products] /* Products */ = {
459 | isa = PBXGroup;
460 | children = (
461 | [MyProject:product] /* MyProject */,
462 | );
463 | name = Products;
464 | sourceTree = "";
465 | };
466 | /* End PBXGroup section */
467 | ]]
468 | end
469 |
470 |
471 | function suite.PBXGroup_OnFrameworks()
472 | links { "Cocoa.framework" }
473 | prepare()
474 | xcode.PBXGroup(tr)
475 | test.capture [[
476 | /* Begin PBXGroup section */
477 | [Frameworks] /* Frameworks */ = {
478 | isa = PBXGroup;
479 | children = (
480 | [Cocoa.framework] /* Cocoa.framework */,
481 | );
482 | name = Frameworks;
483 | sourceTree = "";
484 | };
485 | [MyProject] /* MyProject */ = {
486 | isa = PBXGroup;
487 | children = (
488 | [Frameworks] /* Frameworks */,
489 | [Products] /* Products */,
490 | );
491 | name = MyProject;
492 | sourceTree = "";
493 | };
494 | ]]
495 | end
496 |
497 |
498 | function suite.PBXGroup_OnVpaths()
499 | files { "include/premake/source.h" }
500 | vpaths { ["Headers"] = "**.h" }
501 | prepare()
502 | xcode.PBXGroup(tr)
503 | test.capture [[
504 | /* Begin PBXGroup section */
505 | [Headers] /* Headers */ = {
506 | isa = PBXGroup;
507 | children = (
508 | [source.h] /* source.h */,
509 | );
510 | name = Headers;
511 | sourceTree = "";
512 | };
513 | [MyProject] /* MyProject */ = {
514 | isa = PBXGroup;
515 | children = (
516 | [Headers] /* Headers */,
517 | [Products] /* Products */,
518 | );
519 | name = MyProject;
520 | sourceTree = "";
521 | };
522 | ]]
523 | end
524 |
525 |
526 | ---------------------------------------------------------------------------
527 | -- PBXNativeTarget tests
528 | ---------------------------------------------------------------------------
529 |
530 | function suite.PBXNativeTarget_OnConsoleApp()
531 | prepare()
532 | xcode.PBXNativeTarget(tr)
533 | test.capture [[
534 | /* Begin PBXNativeTarget section */
535 | [MyProject:target] /* MyProject */ = {
536 | isa = PBXNativeTarget;
537 | buildConfigurationList = [MyProject:cfg] /* Build configuration list for PBXNativeTarget "MyProject" */;
538 | buildPhases = (
539 | [MyProject:rez] /* Resources */,
540 | [MyProject:src] /* Sources */,
541 | [MyProject:fxs] /* Frameworks */,
542 | );
543 | buildRules = (
544 | );
545 | dependencies = (
546 | );
547 | name = MyProject;
548 | productInstallPath = "$(HOME)/bin";
549 | productName = MyProject;
550 | productReference = [MyProject:product] /* MyProject */;
551 | productType = "com.apple.product-type.tool";
552 | };
553 | /* End PBXNativeTarget section */
554 | ]]
555 | end
556 |
557 |
558 | function suite.PBXNativeTarget_OnWindowedApp()
559 | kind "WindowedApp"
560 | prepare()
561 | xcode.PBXNativeTarget(tr)
562 | test.capture [[
563 | /* Begin PBXNativeTarget section */
564 | [MyProject.app:target] /* MyProject */ = {
565 | isa = PBXNativeTarget;
566 | buildConfigurationList = [MyProject.app:cfg] /* Build configuration list for PBXNativeTarget "MyProject" */;
567 | buildPhases = (
568 | [MyProject.app:rez] /* Resources */,
569 | [MyProject.app:src] /* Sources */,
570 | [MyProject.app:fxs] /* Frameworks */,
571 | );
572 | buildRules = (
573 | );
574 | dependencies = (
575 | );
576 | name = MyProject;
577 | productInstallPath = "$(HOME)/Applications";
578 | productName = MyProject;
579 | productReference = [MyProject.app:product] /* MyProject.app */;
580 | productType = "com.apple.product-type.application";
581 | };
582 | /* End PBXNativeTarget section */
583 | ]]
584 | end
585 |
586 |
587 | function suite.PBXNativeTarget_OnSharedLib()
588 | kind "SharedLib"
589 | prepare()
590 | xcode.PBXNativeTarget(tr)
591 | test.capture [[
592 | /* Begin PBXNativeTarget section */
593 | [libMyProject.dylib:target] /* MyProject */ = {
594 | isa = PBXNativeTarget;
595 | buildConfigurationList = [libMyProject.dylib:cfg] /* Build configuration list for PBXNativeTarget "MyProject" */;
596 | buildPhases = (
597 | [libMyProject.dylib:rez] /* Resources */,
598 | [libMyProject.dylib:src] /* Sources */,
599 | [libMyProject.dylib:fxs] /* Frameworks */,
600 | );
601 | buildRules = (
602 | );
603 | dependencies = (
604 | );
605 | name = MyProject;
606 | productName = MyProject;
607 | productReference = [libMyProject.dylib:product] /* libMyProject.dylib */;
608 | productType = "com.apple.product-type.library.dynamic";
609 | };
610 | /* End PBXNativeTarget section */
611 | ]]
612 | end
613 |
614 |
615 | function suite.PBXNativeTarget_OnBuildCommands()
616 | prebuildcommands { "prebuildcmd" }
617 | prelinkcommands { "prelinkcmd" }
618 | postbuildcommands { "postbuildcmd" }
619 | prepare()
620 | xcode.PBXNativeTarget(tr)
621 | test.capture [[
622 | /* Begin PBXNativeTarget section */
623 | [MyProject:target] /* MyProject */ = {
624 | isa = PBXNativeTarget;
625 | buildConfigurationList = [MyProject:cfg] /* Build configuration list for PBXNativeTarget "MyProject" */;
626 | buildPhases = (
627 | 9607AE1010C857E500CD1376 /* Prebuild */,
628 | [MyProject:rez] /* Resources */,
629 | [MyProject:src] /* Sources */,
630 | 9607AE3510C85E7E00CD1376 /* Prelink */,
631 | [MyProject:fxs] /* Frameworks */,
632 | 9607AE3710C85E8F00CD1376 /* Postbuild */,
633 | );
634 | buildRules = (
635 | );
636 | dependencies = (
637 | );
638 | name = MyProject;
639 | productInstallPath = "$(HOME)/bin";
640 | productName = MyProject;
641 | productReference = [MyProject:product] /* MyProject */;
642 | productType = "com.apple.product-type.tool";
643 | };
644 | /* End PBXNativeTarget section */
645 | ]]
646 | end
647 |
648 |
649 | ---------------------------------------------------------------------------
650 | -- PBXProject tests
651 | ---------------------------------------------------------------------------
652 |
653 | function suite.PBXProject_OnProject()
654 | prepare()
655 | xcode.PBXProject(tr)
656 | test.capture [[
657 | /* Begin PBXProject section */
658 | 08FB7793FE84155DC02AAC07 /* Project object */ = {
659 | isa = PBXProject;
660 | buildConfigurationList = 1DEB928908733DD80010E9CD /* Build configuration list for PBXProject "MyProject" */;
661 | compatibilityVersion = "Xcode 3.2";
662 | hasScannedForEncodings = 1;
663 | mainGroup = [MyProject] /* MyProject */;
664 | projectDirPath = "";
665 | projectRoot = "";
666 | targets = (
667 | [MyProject:target] /* MyProject */,
668 | );
669 | };
670 | /* End PBXProject section */
671 | ]]
672 | end
673 |
674 |
675 | ---------------------------------------------------------------------------
676 | -- PBXResourceBuildPhase tests
677 | ---------------------------------------------------------------------------
678 |
679 | function suite.PBXResourcesBuildPhase_OnNoResources()
680 | prepare()
681 | xcode.PBXResourcesBuildPhase(tr)
682 | test.capture [[
683 | /* Begin PBXResourcesBuildPhase section */
684 | [MyProject:rez] /* Resources */ = {
685 | isa = PBXResourcesBuildPhase;
686 | buildActionMask = 2147483647;
687 | files = (
688 | );
689 | runOnlyForDeploymentPostprocessing = 0;
690 | };
691 | /* End PBXResourcesBuildPhase section */
692 | ]]
693 | end
694 |
695 |
696 | function suite.PBXResourcesBuildPhase_OnResources()
697 | files { "English.lproj/MainMenu.xib", "French.lproj/MainMenu.xib", "Info.plist" }
698 | prepare()
699 | xcode.PBXResourcesBuildPhase(tr)
700 | test.capture [[
701 | /* Begin PBXResourcesBuildPhase section */
702 | [MyProject:rez] /* Resources */ = {
703 | isa = PBXResourcesBuildPhase;
704 | buildActionMask = 2147483647;
705 | files = (
706 | [MainMenu.xib:build] /* MainMenu.xib in Resources */,
707 | );
708 | runOnlyForDeploymentPostprocessing = 0;
709 | };
710 | /* End PBXResourcesBuildPhase section */
711 | ]]
712 | end
713 |
714 |
715 | ---------------------------------------------------------------------------
716 | -- PBXShellScriptBuildPhase tests
717 | ---------------------------------------------------------------------------
718 |
719 | function suite.PBXShellScriptBuildPhase_OnNoScripts()
720 | prepare()
721 | xcode.PBXShellScriptBuildPhase(tr)
722 | test.capture [[
723 | ]]
724 | end
725 |
726 |
727 | function suite.PBXShellScriptBuildPhase_OnPrebuildScripts()
728 | prebuildcommands { 'ls src', 'cp "a" "b"' }
729 | prepare()
730 | xcode.PBXShellScriptBuildPhase(tr)
731 | test.capture [[
732 | /* Begin PBXShellScriptBuildPhase section */
733 | 9607AE1010C857E500CD1376 /* Prebuild */ = {
734 | isa = PBXShellScriptBuildPhase;
735 | buildActionMask = 2147483647;
736 | files = (
737 | );
738 | inputPaths = (
739 | );
740 | name = Prebuild;
741 | outputPaths = (
742 | );
743 | runOnlyForDeploymentPostprocessing = 0;
744 | shellPath = /bin/sh;
745 | shellScript = "ls src\ncp \"a\" \"b\"";
746 | };
747 | /* End PBXShellScriptBuildPhase section */
748 | ]]
749 | end
750 |
751 |
752 | function suite.PBXShellScriptBuildPhase_OnPerConfigCmds()
753 | prebuildcommands { 'ls src' }
754 | configuration "Debug"
755 | prebuildcommands { 'cp a b' }
756 | prepare()
757 | xcode.PBXShellScriptBuildPhase(tr)
758 | test.capture [[
759 | /* Begin PBXShellScriptBuildPhase section */
760 | 9607AE1010C857E500CD1376 /* Prebuild */ = {
761 | isa = PBXShellScriptBuildPhase;
762 | buildActionMask = 2147483647;
763 | files = (
764 | );
765 | inputPaths = (
766 | );
767 | name = Prebuild;
768 | outputPaths = (
769 | );
770 | runOnlyForDeploymentPostprocessing = 0;
771 | shellPath = /bin/sh;
772 | shellScript = "ls src\nif [ \"${CONFIGURATION}\" = \"Debug\" ]; then\ncp a b\nfi";
773 | };
774 | /* End PBXShellScriptBuildPhase section */
775 | ]]
776 | end
777 |
778 |
779 | ---------------------------------------------------------------------------
780 | -- PBXSourcesBuildPhase tests
781 | ---------------------------------------------------------------------------
782 |
783 | function suite.PBXSourcesBuildPhase_OnNoSources()
784 | prepare()
785 | xcode.PBXSourcesBuildPhase(tr)
786 | test.capture [[
787 | /* Begin PBXSourcesBuildPhase section */
788 | [MyProject:src] /* Sources */ = {
789 | isa = PBXSourcesBuildPhase;
790 | buildActionMask = 2147483647;
791 | files = (
792 | );
793 | runOnlyForDeploymentPostprocessing = 0;
794 | };
795 | /* End PBXSourcesBuildPhase section */
796 | ]]
797 | end
798 |
799 |
800 | function suite.PBXSourcesBuildPhase_OnSources()
801 | files { "hello.cpp", "goodbye.cpp" }
802 | prepare()
803 | xcode.PBXSourcesBuildPhase(tr)
804 | test.capture [[
805 | /* Begin PBXSourcesBuildPhase section */
806 | [MyProject:src] /* Sources */ = {
807 | isa = PBXSourcesBuildPhase;
808 | buildActionMask = 2147483647;
809 | files = (
810 | [goodbye.cpp:build] /* goodbye.cpp in Sources */,
811 | [hello.cpp:build] /* hello.cpp in Sources */,
812 | );
813 | runOnlyForDeploymentPostprocessing = 0;
814 | };
815 | /* End PBXSourcesBuildPhase section */
816 | ]]
817 | end
818 |
819 |
820 | ---------------------------------------------------------------------------
821 | -- PBXVariantGroup tests
822 | ---------------------------------------------------------------------------
823 |
824 | function suite.PBXVariantGroup_OnNoGroups()
825 | prepare()
826 | xcode.PBXVariantGroup(tr)
827 | test.capture [[
828 | /* Begin PBXVariantGroup section */
829 | /* End PBXVariantGroup section */
830 | ]]
831 | end
832 |
833 |
834 | function suite.PBXVariantGroup_OnNoResourceGroups()
835 | files { "English.lproj/MainMenu.xib", "French.lproj/MainMenu.xib" }
836 | prepare()
837 | xcode.PBXVariantGroup(tr)
838 | test.capture [[
839 | /* Begin PBXVariantGroup section */
840 | [MainMenu.xib] /* MainMenu.xib */ = {
841 | isa = PBXVariantGroup;
842 | children = (
843 | [English] /* English */,
844 | [French] /* French */,
845 | );
846 | name = MainMenu.xib;
847 | sourceTree = "";
848 | };
849 | /* End PBXVariantGroup section */
850 | ]]
851 | end
852 |
853 |
854 | ---------------------------------------------------------------------------
855 | -- XCBuildConfiguration_Target tests
856 | ---------------------------------------------------------------------------
857 |
858 | function suite.XCBuildConfigurationTarget_OnConsoleApp()
859 | prepare()
860 | xcode.XCBuildConfiguration_Target(tr, tr.products.children[1], tr.configs[1])
861 | test.capture [[
862 | [MyProject:Debug] /* Debug */ = {
863 | isa = XCBuildConfiguration;
864 | buildSettings = {
865 | ALWAYS_SEARCH_USER_PATHS = NO;
866 | CONFIGURATION_BUILD_DIR = bin/Debug;
867 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
868 | GCC_DYNAMIC_NO_PIC = NO;
869 | INSTALL_PATH = /usr/local/bin;
870 | PRODUCT_NAME = MyProject;
871 | };
872 | name = Debug;
873 | };
874 | ]]
875 | end
876 |
877 |
878 | function suite.XCBuildConfigurationTarget_OnWindowedApp()
879 | kind "WindowedApp"
880 | prepare()
881 | xcode.XCBuildConfiguration_Target(tr, tr.products.children[1], tr.configs[1])
882 | test.capture [[
883 | [MyProject.app:Debug] /* Debug */ = {
884 | isa = XCBuildConfiguration;
885 | buildSettings = {
886 | ALWAYS_SEARCH_USER_PATHS = NO;
887 | CONFIGURATION_BUILD_DIR = bin/Debug;
888 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
889 | GCC_DYNAMIC_NO_PIC = NO;
890 | INSTALL_PATH = "\"$(HOME)/Applications\"";
891 | PRODUCT_NAME = MyProject;
892 | };
893 | name = Debug;
894 | };
895 | ]]
896 | end
897 |
898 |
899 | function suite.XCBuildConfigurationTarget_OnStaticLib()
900 | kind "StaticLib"
901 | prepare()
902 | xcode.XCBuildConfiguration_Target(tr, tr.products.children[1], tr.configs[1])
903 | test.capture [[
904 | [libMyProject.a:Debug] /* Debug */ = {
905 | isa = XCBuildConfiguration;
906 | buildSettings = {
907 | ALWAYS_SEARCH_USER_PATHS = NO;
908 | CONFIGURATION_BUILD_DIR = bin/Debug;
909 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
910 | GCC_DYNAMIC_NO_PIC = NO;
911 | INSTALL_PATH = /usr/local/lib;
912 | PRODUCT_NAME = MyProject;
913 | };
914 | name = Debug;
915 | };
916 | ]]
917 | end
918 |
919 |
920 | function suite.XCBuildConfigurationTarget_OnSharedLib()
921 | kind "SharedLib"
922 | prepare()
923 | xcode.XCBuildConfiguration_Target(tr, tr.products.children[1], tr.configs[1])
924 | test.capture [[
925 | [libMyProject.dylib:Debug] /* Debug */ = {
926 | isa = XCBuildConfiguration;
927 | buildSettings = {
928 | ALWAYS_SEARCH_USER_PATHS = NO;
929 | CONFIGURATION_BUILD_DIR = bin/Debug;
930 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
931 | EXECUTABLE_PREFIX = lib;
932 | GCC_DYNAMIC_NO_PIC = NO;
933 | INSTALL_PATH = /usr/local/lib;
934 | PRODUCT_NAME = MyProject;
935 | };
936 | name = Debug;
937 | };
938 | ]]
939 | end
940 |
941 |
942 | function suite.XCBuildConfigurationTarget_OnTargetPrefix()
943 | kind "SharedLib"
944 | targetprefix "xyz"
945 | prepare()
946 | xcode.XCBuildConfiguration_Target(tr, tr.products.children[1], tr.configs[1])
947 | test.capture [[
948 | [xyzMyProject.dylib:Debug] /* Debug */ = {
949 | isa = XCBuildConfiguration;
950 | buildSettings = {
951 | ALWAYS_SEARCH_USER_PATHS = NO;
952 | CONFIGURATION_BUILD_DIR = bin/Debug;
953 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
954 | EXECUTABLE_PREFIX = xyz;
955 | GCC_DYNAMIC_NO_PIC = NO;
956 | INSTALL_PATH = /usr/local/lib;
957 | PRODUCT_NAME = MyProject;
958 | };
959 | name = Debug;
960 | };
961 | ]]
962 | end
963 |
964 |
965 | function suite.XCBuildConfigurationTarget_OnTargetExtension()
966 | kind "SharedLib"
967 | targetextension ".xyz"
968 | prepare()
969 | xcode.XCBuildConfiguration_Target(tr, tr.products.children[1], tr.configs[1])
970 |
971 | --ms removed for now
972 | --EXECUTABLE_EXTENSION = xyz;
973 |
974 | test.capture [[
975 | [libMyProject.xyz:Debug] /* Debug */ = {
976 | isa = XCBuildConfiguration;
977 | buildSettings = {
978 | ALWAYS_SEARCH_USER_PATHS = NO;
979 | CONFIGURATION_BUILD_DIR = bin/Debug;
980 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
981 | EXECUTABLE_PREFIX = lib;
982 | GCC_DYNAMIC_NO_PIC = NO;
983 | INSTALL_PATH = /usr/local/lib;
984 | PRODUCT_NAME = MyProject;
985 | };
986 | name = Debug;
987 | };
988 | ]]
989 | end
990 |
991 |
992 | function suite.XCBuildConfigurationTarget_OnInfoPlist()
993 | files { "../../MyProject-Info.plist" }
994 | prepare()
995 | xcode.XCBuildConfiguration_Target(tr, tr.products.children[1], tr.configs[1])
996 | test.capture [[
997 | [MyProject:Debug] /* Debug */ = {
998 | isa = XCBuildConfiguration;
999 | buildSettings = {
1000 | ALWAYS_SEARCH_USER_PATHS = NO;
1001 | CONFIGURATION_BUILD_DIR = bin/Debug;
1002 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
1003 | GCC_DYNAMIC_NO_PIC = NO;
1004 | INFOPLIST_FILE = "../../MyProject-Info.plist";
1005 | INSTALL_PATH = /usr/local/bin;
1006 | PRODUCT_NAME = MyProject;
1007 | };
1008 | name = Debug;
1009 | };
1010 | ]]
1011 | end
1012 |
1013 |
1014 | function suite.XCBuildConfigurationTarget_OnSymbols()
1015 | symbols "On"
1016 | prepare()
1017 | xcode.XCBuildConfiguration_Target(tr, tr.products.children[1], tr.configs[1])
1018 | test.capture [[
1019 | [MyProject:Debug] /* Debug */ = {
1020 | isa = XCBuildConfiguration;
1021 | buildSettings = {
1022 | ALWAYS_SEARCH_USER_PATHS = NO;
1023 | CONFIGURATION_BUILD_DIR = bin/Debug;
1024 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
1025 | GCC_DYNAMIC_NO_PIC = NO;
1026 | INSTALL_PATH = /usr/local/bin;
1027 | PRODUCT_NAME = MyProject;
1028 | };
1029 | name = Debug;
1030 | };
1031 | ]]
1032 | end
1033 |
1034 |
1035 | function suite.XCBuildConfigurationTarget_OnTargetSuffix()
1036 | targetsuffix "-d"
1037 | prepare()
1038 | xcode.XCBuildConfiguration_Target(tr, tr.products.children[1], tr.configs[1])
1039 | test.capture [[
1040 | [MyProject-d:Debug] /* Debug */ = {
1041 | isa = XCBuildConfiguration;
1042 | buildSettings = {
1043 | ALWAYS_SEARCH_USER_PATHS = NO;
1044 | CONFIGURATION_BUILD_DIR = bin/Debug;
1045 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
1046 | GCC_DYNAMIC_NO_PIC = NO;
1047 | INSTALL_PATH = /usr/local/bin;
1048 | PRODUCT_NAME = "MyProject-d";
1049 | };
1050 | name = Debug;
1051 | };
1052 | ]]
1053 | end
1054 |
1055 |
1056 | function suite.XCBuildConfigurationTarget_OnSinglePlatform()
1057 | platforms { "Universal32" }
1058 | prepare()
1059 | xcode.XCBuildConfiguration_Target(tr, tr.products.children[1], tr.configs[1])
1060 | test.capture [[
1061 | [MyProject:Debug] /* Debug */ = {
1062 | isa = XCBuildConfiguration;
1063 | buildSettings = {
1064 | ALWAYS_SEARCH_USER_PATHS = NO;
1065 | CONFIGURATION_BUILD_DIR = bin/Universal32/Debug;
1066 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
1067 | GCC_DYNAMIC_NO_PIC = NO;
1068 | INSTALL_PATH = /usr/local/bin;
1069 | PRODUCT_NAME = MyProject;
1070 | };
1071 | name = Debug;
1072 | };
1073 | ]]
1074 | end
1075 |
1076 |
1077 | function suite.XCBuildConfigurationTarget_OnMultiplePlatforms()
1078 | workspace("MyWorkspace")
1079 | platforms { "Universal32", "Universal64" }
1080 | prepare()
1081 | xcode.XCBuildConfiguration_Target(tr, tr.products.children[1], tr.configs[1])
1082 | test.capture [[
1083 | [MyProject:Debug] /* Debug */ = {
1084 | isa = XCBuildConfiguration;
1085 | buildSettings = {
1086 | ALWAYS_SEARCH_USER_PATHS = NO;
1087 | CONFIGURATION_BUILD_DIR = bin/Universal32/Debug;
1088 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
1089 | GCC_DYNAMIC_NO_PIC = NO;
1090 | INSTALL_PATH = /usr/local/bin;
1091 | PRODUCT_NAME = MyProject;
1092 | };
1093 | name = Debug;
1094 | };
1095 | ]]
1096 | end
1097 |
1098 |
1099 | ---------------------------------------------------------------------------
1100 | -- XCBuildConfiguration_Project tests
1101 | ---------------------------------------------------------------------------
1102 |
1103 | function suite.XCBuildConfigurationProject_OnConsoleApp()
1104 | prepare()
1105 | xcode.XCBuildConfiguration_Project(tr, tr.configs[1])
1106 | test.capture [[
1107 | [MyProject:Debug(2)] /* Debug */ = {
1108 | isa = XCBuildConfiguration;
1109 | buildSettings = {
1110 | ARCHS = "$(NATIVE_ARCH_ACTUAL)";
1111 | CONFIGURATION_BUILD_DIR = "$(SYMROOT)";
1112 | CONFIGURATION_TEMP_DIR = "$(OBJROOT)";
1113 | GCC_C_LANGUAGE_STANDARD = gnu99;
1114 | GCC_OPTIMIZATION_LEVEL = 0;
1115 | GCC_SYMBOLS_PRIVATE_EXTERN = NO;
1116 | GCC_WARN_ABOUT_RETURN_TYPE = YES;
1117 | GCC_WARN_UNUSED_VARIABLE = YES;
1118 | OBJROOT = obj/Debug;
1119 | ONLY_ACTIVE_ARCH = NO;
1120 | SYMROOT = bin/Debug;
1121 | };
1122 | name = Debug;
1123 | };
1124 | ]]
1125 | end
1126 |
1127 |
1128 | function suite.XCBuildConfigurationProject_OnOptimize()
1129 | --flags { "Optimize" }
1130 | optimize "Size"
1131 | prepare()
1132 | xcode.XCBuildConfiguration_Project(tr, tr.configs[1])
1133 | test.capture [[
1134 | [MyProject:Debug(2)] /* Debug */ = {
1135 | isa = XCBuildConfiguration;
1136 | buildSettings = {
1137 | ARCHS = "$(NATIVE_ARCH_ACTUAL)";
1138 | CONFIGURATION_BUILD_DIR = "$(SYMROOT)";
1139 | CONFIGURATION_TEMP_DIR = "$(OBJROOT)";
1140 | GCC_C_LANGUAGE_STANDARD = gnu99;
1141 | GCC_OPTIMIZATION_LEVEL = s;
1142 | GCC_SYMBOLS_PRIVATE_EXTERN = NO;
1143 | GCC_WARN_ABOUT_RETURN_TYPE = YES;
1144 | GCC_WARN_UNUSED_VARIABLE = YES;
1145 | OBJROOT = obj/Debug;
1146 | ONLY_ACTIVE_ARCH = NO;
1147 | SYMROOT = bin/Debug;
1148 | };
1149 | name = Debug;
1150 | };
1151 | ]]
1152 | end
1153 |
1154 |
1155 | function suite.XCBuildConfigurationProject_OnOptimizeSpeed()
1156 | flags { "OptimizeSpeed" }
1157 | prepare()
1158 | xcode.XCBuildConfiguration_Project(tr, tr.configs[1])
1159 | test.capture [[
1160 | [MyProject:Debug(2)] /* Debug */ = {
1161 | isa = XCBuildConfiguration;
1162 | buildSettings = {
1163 | ARCHS = "$(NATIVE_ARCH_ACTUAL)";
1164 | CONFIGURATION_BUILD_DIR = "$(SYMROOT)";
1165 | CONFIGURATION_TEMP_DIR = "$(OBJROOT)";
1166 | GCC_C_LANGUAGE_STANDARD = gnu99;
1167 | GCC_OPTIMIZATION_LEVEL = 3;
1168 | GCC_SYMBOLS_PRIVATE_EXTERN = NO;
1169 | GCC_WARN_ABOUT_RETURN_TYPE = YES;
1170 | GCC_WARN_UNUSED_VARIABLE = YES;
1171 | OBJROOT = obj/Debug;
1172 | ONLY_ACTIVE_ARCH = NO;
1173 | SYMROOT = bin/Debug;
1174 | };
1175 | name = Debug;
1176 | };
1177 | ]]
1178 | end
1179 |
1180 |
1181 | function suite.XCBuildConfigurationProject_OnStaticRuntime()
1182 | flags { "StaticRuntime" }
1183 | prepare()
1184 | xcode.XCBuildConfiguration_Project(tr, tr.configs[1])
1185 | test.capture [[
1186 | [MyProject:Debug(2)] /* Debug */ = {
1187 | isa = XCBuildConfiguration;
1188 | buildSettings = {
1189 | ARCHS = "$(NATIVE_ARCH_ACTUAL)";
1190 | CONFIGURATION_BUILD_DIR = "$(SYMROOT)";
1191 | CONFIGURATION_TEMP_DIR = "$(OBJROOT)";
1192 | GCC_C_LANGUAGE_STANDARD = gnu99;
1193 | GCC_OPTIMIZATION_LEVEL = 0;
1194 | GCC_SYMBOLS_PRIVATE_EXTERN = NO;
1195 | GCC_WARN_ABOUT_RETURN_TYPE = YES;
1196 | GCC_WARN_UNUSED_VARIABLE = YES;
1197 | OBJROOT = obj/Debug;
1198 | ONLY_ACTIVE_ARCH = NO;
1199 | STANDARD_C_PLUS_PLUS_LIBRARY_TYPE = static;
1200 | SYMROOT = bin/Debug;
1201 | };
1202 | name = Debug;
1203 | };
1204 | ]]
1205 | end
1206 |
1207 |
1208 | function suite.XCBuildConfigurationProject_OnTargetDir()
1209 | targetdir "bin"
1210 | prepare()
1211 | xcode.XCBuildConfiguration_Project(tr, tr.configs[1])
1212 | test.capture [[
1213 | [MyProject:Debug(2)] /* Debug */ = {
1214 | isa = XCBuildConfiguration;
1215 | buildSettings = {
1216 | ARCHS = "$(NATIVE_ARCH_ACTUAL)";
1217 | CONFIGURATION_BUILD_DIR = "$(SYMROOT)";
1218 | CONFIGURATION_TEMP_DIR = "$(OBJROOT)";
1219 | GCC_C_LANGUAGE_STANDARD = gnu99;
1220 | GCC_OPTIMIZATION_LEVEL = 0;
1221 | GCC_SYMBOLS_PRIVATE_EXTERN = NO;
1222 | GCC_WARN_ABOUT_RETURN_TYPE = YES;
1223 | GCC_WARN_UNUSED_VARIABLE = YES;
1224 | OBJROOT = obj/Debug;
1225 | ONLY_ACTIVE_ARCH = NO;
1226 | SYMROOT = bin;
1227 | };
1228 | name = Debug;
1229 | };
1230 | ]]
1231 | end
1232 |
1233 |
1234 | function suite.XCBuildConfigurationProject_OnDefines()
1235 | defines { "_DEBUG", "DEBUG" }
1236 | prepare()
1237 | xcode.XCBuildConfiguration_Project(tr, tr.configs[1])
1238 | test.capture [[
1239 | [MyProject:Debug(2)] /* Debug */ = {
1240 | isa = XCBuildConfiguration;
1241 | buildSettings = {
1242 | ARCHS = "$(NATIVE_ARCH_ACTUAL)";
1243 | CONFIGURATION_BUILD_DIR = "$(SYMROOT)";
1244 | CONFIGURATION_TEMP_DIR = "$(OBJROOT)";
1245 | GCC_C_LANGUAGE_STANDARD = gnu99;
1246 | GCC_OPTIMIZATION_LEVEL = 0;
1247 | GCC_PREPROCESSOR_DEFINITIONS = (
1248 | _DEBUG,
1249 | DEBUG,
1250 | );
1251 | GCC_SYMBOLS_PRIVATE_EXTERN = NO;
1252 | GCC_WARN_ABOUT_RETURN_TYPE = YES;
1253 | GCC_WARN_UNUSED_VARIABLE = YES;
1254 | OBJROOT = obj/Debug;
1255 | ONLY_ACTIVE_ARCH = NO;
1256 | SYMROOT = bin/Debug;
1257 | };
1258 | name = Debug;
1259 | };
1260 | ]]
1261 | end
1262 |
1263 |
1264 | function suite.XCBuildConfigurationProject_OnIncludeDirs()
1265 | includedirs { "../include", "../libs", "../name with spaces" }
1266 | prepare()
1267 | xcode.XCBuildConfiguration_Project(tr, tr.configs[1])
1268 | test.capture [[
1269 | [MyProject:Debug(2)] /* Debug */ = {
1270 | isa = XCBuildConfiguration;
1271 | buildSettings = {
1272 | ARCHS = "$(NATIVE_ARCH_ACTUAL)";
1273 | CONFIGURATION_BUILD_DIR = "$(SYMROOT)";
1274 | CONFIGURATION_TEMP_DIR = "$(OBJROOT)";
1275 | GCC_C_LANGUAGE_STANDARD = gnu99;
1276 | GCC_OPTIMIZATION_LEVEL = 0;
1277 | GCC_SYMBOLS_PRIVATE_EXTERN = NO;
1278 | GCC_WARN_ABOUT_RETURN_TYPE = YES;
1279 | GCC_WARN_UNUSED_VARIABLE = YES;
1280 | OBJROOT = obj/Debug;
1281 | ONLY_ACTIVE_ARCH = NO;
1282 | SYMROOT = bin/Debug;
1283 | USER_HEADER_SEARCH_PATHS = (
1284 | ../include,
1285 | ../libs,
1286 | "\"../name with spaces\"",
1287 | );
1288 | };
1289 | name = Debug;
1290 | };
1291 | ]]
1292 | end
1293 |
1294 | function suite.XCBuildConfigurationProject_OnSysIncludeDirs()
1295 | sysincludedirs { "../include", "../libs", "../name with spaces" }
1296 | prepare()
1297 | xcode.XCBuildConfiguration_Project(tr, tr.configs[1])
1298 | test.capture [[
1299 | [MyProject:Debug(2)] /* Debug */ = {
1300 | isa = XCBuildConfiguration;
1301 | buildSettings = {
1302 | ARCHS = "$(NATIVE_ARCH_ACTUAL)";
1303 | CONFIGURATION_BUILD_DIR = "$(SYMROOT)";
1304 | CONFIGURATION_TEMP_DIR = "$(OBJROOT)";
1305 | GCC_C_LANGUAGE_STANDARD = gnu99;
1306 | GCC_OPTIMIZATION_LEVEL = 0;
1307 | GCC_SYMBOLS_PRIVATE_EXTERN = NO;
1308 | GCC_WARN_ABOUT_RETURN_TYPE = YES;
1309 | GCC_WARN_UNUSED_VARIABLE = YES;
1310 | HEADER_SEARCH_PATHS = (
1311 | ../include,
1312 | ../libs,
1313 | "\"../name with spaces\"",
1314 | "$(inherited)",
1315 | );
1316 | OBJROOT = obj/Debug;
1317 | ONLY_ACTIVE_ARCH = NO;
1318 | SYMROOT = bin/Debug;
1319 | };
1320 | name = Debug;
1321 | };
1322 | ]]
1323 | end
1324 |
1325 | function suite.XCBuildConfigurationProject_OnBuildOptions()
1326 | buildoptions { "build option 1", "build option 2" }
1327 | prepare()
1328 | xcode.XCBuildConfiguration_Project(tr, tr.configs[1])
1329 | test.capture [[
1330 | [MyProject:Debug(2)] /* Debug */ = {
1331 | isa = XCBuildConfiguration;
1332 | buildSettings = {
1333 | ARCHS = "$(NATIVE_ARCH_ACTUAL)";
1334 | CONFIGURATION_BUILD_DIR = "$(SYMROOT)";
1335 | CONFIGURATION_TEMP_DIR = "$(OBJROOT)";
1336 | GCC_C_LANGUAGE_STANDARD = gnu99;
1337 | GCC_OPTIMIZATION_LEVEL = 0;
1338 | GCC_SYMBOLS_PRIVATE_EXTERN = NO;
1339 | GCC_WARN_ABOUT_RETURN_TYPE = YES;
1340 | GCC_WARN_UNUSED_VARIABLE = YES;
1341 | OBJROOT = obj/Debug;
1342 | ONLY_ACTIVE_ARCH = NO;
1343 | OTHER_CFLAGS = (
1344 | "build option 1",
1345 | "build option 2",
1346 | );
1347 | SYMROOT = bin/Debug;
1348 | };
1349 | name = Debug;
1350 | };
1351 | ]]
1352 | end
1353 |
1354 |
1355 | function suite.XCBuildConfigurationProject_OnLinks()
1356 | links { "Cocoa.framework", "ldap" }
1357 | prepare()
1358 | xcode.XCBuildConfiguration_Project(tr, tr.configs[1])
1359 | test.capture [[
1360 | [MyProject:Debug(2)] /* Debug */ = {
1361 | isa = XCBuildConfiguration;
1362 | buildSettings = {
1363 | ARCHS = "$(NATIVE_ARCH_ACTUAL)";
1364 | CONFIGURATION_BUILD_DIR = "$(SYMROOT)";
1365 | CONFIGURATION_TEMP_DIR = "$(OBJROOT)";
1366 | GCC_C_LANGUAGE_STANDARD = gnu99;
1367 | GCC_OPTIMIZATION_LEVEL = 0;
1368 | GCC_SYMBOLS_PRIVATE_EXTERN = NO;
1369 | GCC_WARN_ABOUT_RETURN_TYPE = YES;
1370 | GCC_WARN_UNUSED_VARIABLE = YES;
1371 | OBJROOT = obj/Debug;
1372 | ONLY_ACTIVE_ARCH = NO;
1373 | OTHER_LDFLAGS = (
1374 | "-lldap",
1375 | );
1376 | SYMROOT = bin/Debug;
1377 | };
1378 | name = Debug;
1379 | };
1380 | ]]
1381 | end
1382 |
1383 | function suite.XCBuildConfigurationProject_OnLinkOptions()
1384 | linkoptions { "link option 1", "link option 2" }
1385 | prepare()
1386 | xcode.XCBuildConfiguration_Project(tr, tr.configs[1])
1387 | test.capture [[
1388 | [MyProject:Debug(2)] /* Debug */ = {
1389 | isa = XCBuildConfiguration;
1390 | buildSettings = {
1391 | ARCHS = "$(NATIVE_ARCH_ACTUAL)";
1392 | CONFIGURATION_BUILD_DIR = "$(SYMROOT)";
1393 | CONFIGURATION_TEMP_DIR = "$(OBJROOT)";
1394 | GCC_C_LANGUAGE_STANDARD = gnu99;
1395 | GCC_OPTIMIZATION_LEVEL = 0;
1396 | GCC_SYMBOLS_PRIVATE_EXTERN = NO;
1397 | GCC_WARN_ABOUT_RETURN_TYPE = YES;
1398 | GCC_WARN_UNUSED_VARIABLE = YES;
1399 | OBJROOT = obj/Debug;
1400 | ONLY_ACTIVE_ARCH = NO;
1401 | OTHER_LDFLAGS = (
1402 | "link option 1",
1403 | "link option 2",
1404 | );
1405 | SYMROOT = bin/Debug;
1406 | };
1407 | name = Debug;
1408 | };
1409 | ]]
1410 | end
1411 |
1412 |
1413 | function suite.XCBuildConfigurationProject_OnExtraWarnings()
1414 | --flags { "ExtraWarnings" }
1415 | warnings "Extra"
1416 | prepare()
1417 | xcode.XCBuildConfiguration_Project(tr, tr.configs[1])
1418 | test.capture [[
1419 | [MyProject:Debug(2)] /* Debug */ = {
1420 | isa = XCBuildConfiguration;
1421 | buildSettings = {
1422 | ARCHS = "$(NATIVE_ARCH_ACTUAL)";
1423 | CONFIGURATION_BUILD_DIR = "$(SYMROOT)";
1424 | CONFIGURATION_TEMP_DIR = "$(OBJROOT)";
1425 | GCC_C_LANGUAGE_STANDARD = gnu99;
1426 | GCC_OPTIMIZATION_LEVEL = 0;
1427 | GCC_SYMBOLS_PRIVATE_EXTERN = NO;
1428 | GCC_WARN_ABOUT_RETURN_TYPE = YES;
1429 | GCC_WARN_UNUSED_VARIABLE = YES;
1430 | OBJROOT = obj/Debug;
1431 | ONLY_ACTIVE_ARCH = NO;
1432 | SYMROOT = bin/Debug;
1433 | WARNING_CFLAGS = "-Wall -Wextra";
1434 | };
1435 | name = Debug;
1436 | };
1437 | ]]
1438 | end
1439 |
1440 |
1441 | function suite.XCBuildConfigurationProject_OnFatalWarnings()
1442 | flags { "FatalWarnings" }
1443 | prepare()
1444 | xcode.XCBuildConfiguration_Project(tr, tr.configs[1])
1445 | test.capture [[
1446 | [MyProject:Debug(2)] /* Debug */ = {
1447 | isa = XCBuildConfiguration;
1448 | buildSettings = {
1449 | ARCHS = "$(NATIVE_ARCH_ACTUAL)";
1450 | CONFIGURATION_BUILD_DIR = "$(SYMROOT)";
1451 | CONFIGURATION_TEMP_DIR = "$(OBJROOT)";
1452 | GCC_C_LANGUAGE_STANDARD = gnu99;
1453 | GCC_OPTIMIZATION_LEVEL = 0;
1454 | GCC_SYMBOLS_PRIVATE_EXTERN = NO;
1455 | GCC_TREAT_WARNINGS_AS_ERRORS = YES;
1456 | GCC_WARN_ABOUT_RETURN_TYPE = YES;
1457 | GCC_WARN_UNUSED_VARIABLE = YES;
1458 | OBJROOT = obj/Debug;
1459 | ONLY_ACTIVE_ARCH = NO;
1460 | SYMROOT = bin/Debug;
1461 | };
1462 | name = Debug;
1463 | };
1464 | ]]
1465 | end
1466 |
1467 |
1468 | function suite.XCBuildConfigurationProject_OnFloatFast()
1469 | flags { "FloatFast" }
1470 | prepare()
1471 | xcode.XCBuildConfiguration_Project(tr, tr.configs[1])
1472 | test.capture [[
1473 | [MyProject:Debug(2)] /* Debug */ = {
1474 | isa = XCBuildConfiguration;
1475 | buildSettings = {
1476 | ARCHS = "$(NATIVE_ARCH_ACTUAL)";
1477 | CONFIGURATION_BUILD_DIR = "$(SYMROOT)";
1478 | CONFIGURATION_TEMP_DIR = "$(OBJROOT)";
1479 | GCC_C_LANGUAGE_STANDARD = gnu99;
1480 | GCC_OPTIMIZATION_LEVEL = 0;
1481 | GCC_SYMBOLS_PRIVATE_EXTERN = NO;
1482 | GCC_WARN_ABOUT_RETURN_TYPE = YES;
1483 | GCC_WARN_UNUSED_VARIABLE = YES;
1484 | OBJROOT = obj/Debug;
1485 | ONLY_ACTIVE_ARCH = NO;
1486 | OTHER_CFLAGS = (
1487 | "-ffast-math",
1488 | );
1489 | SYMROOT = bin/Debug;
1490 | };
1491 | name = Debug;
1492 | };
1493 | ]]
1494 | end
1495 |
1496 |
1497 | function suite.XCBuildConfigurationProject_OnFloatStrict()
1498 | flags { "FloatStrict" }
1499 | prepare()
1500 | xcode.XCBuildConfiguration_Project(tr, tr.configs[1])
1501 | test.capture [[
1502 | [MyProject:Debug(2)] /* Debug */ = {
1503 | isa = XCBuildConfiguration;
1504 | buildSettings = {
1505 | ARCHS = "$(NATIVE_ARCH_ACTUAL)";
1506 | CONFIGURATION_BUILD_DIR = "$(SYMROOT)";
1507 | CONFIGURATION_TEMP_DIR = "$(OBJROOT)";
1508 | GCC_C_LANGUAGE_STANDARD = gnu99;
1509 | GCC_OPTIMIZATION_LEVEL = 0;
1510 | GCC_SYMBOLS_PRIVATE_EXTERN = NO;
1511 | GCC_WARN_ABOUT_RETURN_TYPE = YES;
1512 | GCC_WARN_UNUSED_VARIABLE = YES;
1513 | OBJROOT = obj/Debug;
1514 | ONLY_ACTIVE_ARCH = NO;
1515 | OTHER_CFLAGS = (
1516 | "-ffloat-store",
1517 | );
1518 | SYMROOT = bin/Debug;
1519 | };
1520 | name = Debug;
1521 | };
1522 | ]]
1523 | end
1524 |
1525 |
1526 | function suite.XCBuildConfigurationProject_OnNoEditAndContinue()
1527 | flags { "NoEditAndContinue" }
1528 | symbols "On"
1529 | prepare()
1530 | xcode.XCBuildConfiguration_Project(tr, tr.configs[1])
1531 | test.capture [[
1532 | [MyProject:Debug(2)] /* Debug */ = {
1533 | isa = XCBuildConfiguration;
1534 | buildSettings = {
1535 | ARCHS = "$(NATIVE_ARCH_ACTUAL)";
1536 | CONFIGURATION_BUILD_DIR = "$(SYMROOT)";
1537 | CONFIGURATION_TEMP_DIR = "$(OBJROOT)";
1538 | COPY_PHASE_STRIP = NO;
1539 | GCC_C_LANGUAGE_STANDARD = gnu99;
1540 | GCC_OPTIMIZATION_LEVEL = 0;
1541 | GCC_SYMBOLS_PRIVATE_EXTERN = NO;
1542 | GCC_WARN_ABOUT_RETURN_TYPE = YES;
1543 | GCC_WARN_UNUSED_VARIABLE = YES;
1544 | OBJROOT = obj/Debug;
1545 | ONLY_ACTIVE_ARCH = YES;
1546 | SYMROOT = bin/Debug;
1547 | };
1548 | name = Debug;
1549 | };
1550 | ]]
1551 | end
1552 |
1553 |
1554 | function suite.XCBuildConfigurationProject_OnNoExceptions()
1555 | exceptionhandling "Off"
1556 | prepare()
1557 | xcode.XCBuildConfiguration_Project(tr, tr.configs[1])
1558 | test.capture [[
1559 | [MyProject:Debug(2)] /* Debug */ = {
1560 | isa = XCBuildConfiguration;
1561 | buildSettings = {
1562 | ARCHS = "$(NATIVE_ARCH_ACTUAL)";
1563 | CONFIGURATION_BUILD_DIR = "$(SYMROOT)";
1564 | CONFIGURATION_TEMP_DIR = "$(OBJROOT)";
1565 | GCC_C_LANGUAGE_STANDARD = gnu99;
1566 | GCC_ENABLE_CPP_EXCEPTIONS = NO;
1567 | GCC_ENABLE_OBJC_EXCEPTIONS = NO;
1568 | GCC_OPTIMIZATION_LEVEL = 0;
1569 | GCC_SYMBOLS_PRIVATE_EXTERN = NO;
1570 | GCC_WARN_ABOUT_RETURN_TYPE = YES;
1571 | GCC_WARN_UNUSED_VARIABLE = YES;
1572 | OBJROOT = obj/Debug;
1573 | ONLY_ACTIVE_ARCH = NO;
1574 | SYMROOT = bin/Debug;
1575 | };
1576 | name = Debug;
1577 | };
1578 | ]]
1579 | end
1580 |
1581 |
1582 | function suite.XCBuildConfigurationProject_OnNoFramePointer()
1583 | flags { "NoFramePointer" }
1584 | prepare()
1585 | xcode.XCBuildConfiguration_Project(tr, tr.configs[1])
1586 | test.capture [[
1587 | [MyProject:Debug(2)] /* Debug */ = {
1588 | isa = XCBuildConfiguration;
1589 | buildSettings = {
1590 | ARCHS = "$(NATIVE_ARCH_ACTUAL)";
1591 | CONFIGURATION_BUILD_DIR = "$(SYMROOT)";
1592 | CONFIGURATION_TEMP_DIR = "$(OBJROOT)";
1593 | GCC_C_LANGUAGE_STANDARD = gnu99;
1594 | GCC_OPTIMIZATION_LEVEL = 0;
1595 | GCC_SYMBOLS_PRIVATE_EXTERN = NO;
1596 | GCC_WARN_ABOUT_RETURN_TYPE = YES;
1597 | GCC_WARN_UNUSED_VARIABLE = YES;
1598 | OBJROOT = obj/Debug;
1599 | ONLY_ACTIVE_ARCH = NO;
1600 | OTHER_CFLAGS = (
1601 | "-fomit-frame-pointer",
1602 | );
1603 | SYMROOT = bin/Debug;
1604 | };
1605 | name = Debug;
1606 | };
1607 | ]]
1608 | end
1609 |
1610 |
1611 | function suite.XCBuildConfigurationProject_OnNoPCH()
1612 | pchheader "MyProject_Prefix.pch"
1613 | flags { "NoPCH" }
1614 | prepare()
1615 | xcode.XCBuildConfiguration_Project(tr, tr.configs[1])
1616 | test.capture [[
1617 | [MyProject:Debug(2)] /* Debug */ = {
1618 | isa = XCBuildConfiguration;
1619 | buildSettings = {
1620 | ARCHS = "$(NATIVE_ARCH_ACTUAL)";
1621 | CONFIGURATION_BUILD_DIR = "$(SYMROOT)";
1622 | CONFIGURATION_TEMP_DIR = "$(OBJROOT)";
1623 | GCC_C_LANGUAGE_STANDARD = gnu99;
1624 | GCC_OPTIMIZATION_LEVEL = 0;
1625 | GCC_SYMBOLS_PRIVATE_EXTERN = NO;
1626 | GCC_WARN_ABOUT_RETURN_TYPE = YES;
1627 | GCC_WARN_UNUSED_VARIABLE = YES;
1628 | OBJROOT = obj/Debug;
1629 | ONLY_ACTIVE_ARCH = NO;
1630 | SYMROOT = bin/Debug;
1631 | };
1632 | name = Debug;
1633 | };
1634 | ]]
1635 | end
1636 |
1637 |
1638 | function suite.XCBuildConfigurationProject_OnNoRTTI()
1639 | rtti "Off"
1640 | prepare()
1641 | xcode.XCBuildConfiguration_Project(tr, tr.configs[1])
1642 | test.capture [[
1643 | [MyProject:Debug(2)] /* Debug */ = {
1644 | isa = XCBuildConfiguration;
1645 | buildSettings = {
1646 | ARCHS = "$(NATIVE_ARCH_ACTUAL)";
1647 | CONFIGURATION_BUILD_DIR = "$(SYMROOT)";
1648 | CONFIGURATION_TEMP_DIR = "$(OBJROOT)";
1649 | GCC_C_LANGUAGE_STANDARD = gnu99;
1650 | GCC_ENABLE_CPP_RTTI = NO;
1651 | GCC_OPTIMIZATION_LEVEL = 0;
1652 | GCC_SYMBOLS_PRIVATE_EXTERN = NO;
1653 | GCC_WARN_ABOUT_RETURN_TYPE = YES;
1654 | GCC_WARN_UNUSED_VARIABLE = YES;
1655 | OBJROOT = obj/Debug;
1656 | ONLY_ACTIVE_ARCH = NO;
1657 | SYMROOT = bin/Debug;
1658 | };
1659 | name = Debug;
1660 | };
1661 | ]]
1662 | end
1663 |
1664 |
1665 | function suite.XCBuildConfigurationProject_OnSymbols()
1666 | symbols "On"
1667 | prepare()
1668 | xcode.XCBuildConfiguration_Project(tr, tr.configs[1])
1669 | test.capture [[
1670 | [MyProject:Debug(2)] /* Debug */ = {
1671 | isa = XCBuildConfiguration;
1672 | buildSettings = {
1673 | ARCHS = "$(NATIVE_ARCH_ACTUAL)";
1674 | CONFIGURATION_BUILD_DIR = "$(SYMROOT)";
1675 | CONFIGURATION_TEMP_DIR = "$(OBJROOT)";
1676 | COPY_PHASE_STRIP = NO;
1677 | GCC_C_LANGUAGE_STANDARD = gnu99;
1678 | GCC_ENABLE_FIX_AND_CONTINUE = YES;
1679 | GCC_OPTIMIZATION_LEVEL = 0;
1680 | GCC_SYMBOLS_PRIVATE_EXTERN = NO;
1681 | GCC_WARN_ABOUT_RETURN_TYPE = YES;
1682 | GCC_WARN_UNUSED_VARIABLE = YES;
1683 | OBJROOT = obj/Debug;
1684 | ONLY_ACTIVE_ARCH = YES;
1685 | SYMROOT = bin/Debug;
1686 | };
1687 | name = Debug;
1688 | };
1689 | ]]
1690 | end
1691 |
1692 |
1693 | function suite.XCBuildConfigurationProject_OnLibDirs()
1694 | libdirs { "mylibs1", "mylibs2" }
1695 | prepare()
1696 | xcode.XCBuildConfiguration_Project(tr, tr.configs[1])
1697 | test.capture [[
1698 | [MyProject:Debug(2)] /* Debug */ = {
1699 | isa = XCBuildConfiguration;
1700 | buildSettings = {
1701 | ARCHS = "$(NATIVE_ARCH_ACTUAL)";
1702 | CONFIGURATION_BUILD_DIR = "$(SYMROOT)";
1703 | CONFIGURATION_TEMP_DIR = "$(OBJROOT)";
1704 | GCC_C_LANGUAGE_STANDARD = gnu99;
1705 | GCC_OPTIMIZATION_LEVEL = 0;
1706 | GCC_SYMBOLS_PRIVATE_EXTERN = NO;
1707 | GCC_WARN_ABOUT_RETURN_TYPE = YES;
1708 | GCC_WARN_UNUSED_VARIABLE = YES;
1709 | LIBRARY_SEARCH_PATHS = (
1710 | mylibs1,
1711 | mylibs2,
1712 | );
1713 | OBJROOT = obj/Debug;
1714 | ONLY_ACTIVE_ARCH = NO;
1715 | SYMROOT = bin/Debug;
1716 | };
1717 | name = Debug;
1718 | };
1719 | ]]
1720 | end
1721 |
1722 |
1723 | function suite.XCBuildConfigurationProject_OnPCH()
1724 | pchheader "MyProject_Prefix.pch"
1725 | prepare()
1726 | xcode.XCBuildConfiguration_Project(tr, tr.configs[1])
1727 | test.capture [[
1728 | [MyProject:Debug(2)] /* Debug */ = {
1729 | isa = XCBuildConfiguration;
1730 | buildSettings = {
1731 | ARCHS = "$(NATIVE_ARCH_ACTUAL)";
1732 | CONFIGURATION_BUILD_DIR = "$(SYMROOT)";
1733 | CONFIGURATION_TEMP_DIR = "$(OBJROOT)";
1734 | GCC_C_LANGUAGE_STANDARD = gnu99;
1735 | GCC_OPTIMIZATION_LEVEL = 0;
1736 | GCC_PRECOMPILE_PREFIX_HEADER = YES;
1737 | GCC_PREFIX_HEADER = MyProject_Prefix.pch;
1738 | GCC_SYMBOLS_PRIVATE_EXTERN = NO;
1739 | GCC_WARN_ABOUT_RETURN_TYPE = YES;
1740 | GCC_WARN_UNUSED_VARIABLE = YES;
1741 | OBJROOT = obj/Debug;
1742 | ONLY_ACTIVE_ARCH = NO;
1743 | SYMROOT = bin/Debug;
1744 | };
1745 | name = Debug;
1746 | };
1747 | ]]
1748 | end
1749 |
1750 |
1751 | function suite.XCBuildConfigurationProject_OnUniversal()
1752 | workspace("MyWorkspace")
1753 | platforms { "Universal" }
1754 | prepare()
1755 | xcode.XCBuildConfiguration_Project(tr, tr.configs[1])
1756 | test.capture [[
1757 | [MyProject:Debug(2)] /* Debug */ = {
1758 | isa = XCBuildConfiguration;
1759 | buildSettings = {
1760 | ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
1761 | CONFIGURATION_BUILD_DIR = "$(SYMROOT)";
1762 | CONFIGURATION_TEMP_DIR = "$(OBJROOT)";
1763 | GCC_C_LANGUAGE_STANDARD = gnu99;
1764 | GCC_OPTIMIZATION_LEVEL = 0;
1765 | GCC_SYMBOLS_PRIVATE_EXTERN = NO;
1766 | GCC_WARN_ABOUT_RETURN_TYPE = YES;
1767 | GCC_WARN_UNUSED_VARIABLE = YES;
1768 | OBJROOT = obj/Universal/Debug;
1769 | ONLY_ACTIVE_ARCH = NO;
1770 | SYMROOT = bin/Universal/Debug;
1771 | };
1772 | name = Debug;
1773 | };
1774 | ]]
1775 | end
1776 |
1777 |
1778 | function suite.XCBuildConfigurationProject_OnUniversal32()
1779 | workspace("MyWorkspace")
1780 | platforms { "Universal32" }
1781 | prepare()
1782 | xcode.XCBuildConfiguration_Project(tr, tr.configs[1])
1783 | test.capture [[
1784 | [MyProject:Debug(2)] /* Debug */ = {
1785 | isa = XCBuildConfiguration;
1786 | buildSettings = {
1787 | ARCHS = "$(ARCHS_STANDARD_32_BIT)";
1788 | CONFIGURATION_BUILD_DIR = "$(SYMROOT)";
1789 | CONFIGURATION_TEMP_DIR = "$(OBJROOT)";
1790 | GCC_C_LANGUAGE_STANDARD = gnu99;
1791 | GCC_OPTIMIZATION_LEVEL = 0;
1792 | GCC_SYMBOLS_PRIVATE_EXTERN = NO;
1793 | GCC_WARN_ABOUT_RETURN_TYPE = YES;
1794 | GCC_WARN_UNUSED_VARIABLE = YES;
1795 | OBJROOT = obj/Universal32/Debug;
1796 | ONLY_ACTIVE_ARCH = NO;
1797 | SYMROOT = bin/Universal32/Debug;
1798 | };
1799 | name = Debug;
1800 | };
1801 | ]]
1802 | end
1803 |
1804 |
1805 | function suite.XCBuildConfigurationProject_OnUniversal64()
1806 | workspace("MyWorkspace")
1807 | platforms { "Universal64" }
1808 | prepare()
1809 | xcode.XCBuildConfiguration_Project(tr, tr.configs[1])
1810 | test.capture [[
1811 | [MyProject:Debug(2)] /* Debug */ = {
1812 | isa = XCBuildConfiguration;
1813 | buildSettings = {
1814 | ARCHS = "$(ARCHS_STANDARD_64_BIT)";
1815 | CONFIGURATION_BUILD_DIR = "$(SYMROOT)";
1816 | CONFIGURATION_TEMP_DIR = "$(OBJROOT)";
1817 | GCC_C_LANGUAGE_STANDARD = gnu99;
1818 | GCC_OPTIMIZATION_LEVEL = 0;
1819 | GCC_SYMBOLS_PRIVATE_EXTERN = NO;
1820 | GCC_WARN_ABOUT_RETURN_TYPE = YES;
1821 | GCC_WARN_UNUSED_VARIABLE = YES;
1822 | OBJROOT = obj/Universal64/Debug;
1823 | ONLY_ACTIVE_ARCH = NO;
1824 | SYMROOT = bin/Universal64/Debug;
1825 | };
1826 | name = Debug;
1827 | };
1828 | ]]
1829 | end
1830 |
1831 |
1832 | function suite.XCBuildConfigurationProject_OnNative()
1833 | workspace("MyWorkspace")
1834 | platforms { "Native" }
1835 | prepare()
1836 | xcode.XCBuildConfiguration_Project(tr, tr.configs[1])
1837 | test.capture [[
1838 | [MyProject:Debug(2)] /* Debug */ = {
1839 | isa = XCBuildConfiguration;
1840 | buildSettings = {
1841 | ARCHS = "$(NATIVE_ARCH_ACTUAL)";
1842 | CONFIGURATION_BUILD_DIR = "$(SYMROOT)";
1843 | CONFIGURATION_TEMP_DIR = "$(OBJROOT)";
1844 | GCC_C_LANGUAGE_STANDARD = gnu99;
1845 | GCC_OPTIMIZATION_LEVEL = 0;
1846 | GCC_SYMBOLS_PRIVATE_EXTERN = NO;
1847 | GCC_WARN_ABOUT_RETURN_TYPE = YES;
1848 | GCC_WARN_UNUSED_VARIABLE = YES;
1849 | OBJROOT = obj/Native/Debug;
1850 | ONLY_ACTIVE_ARCH = NO;
1851 | SYMROOT = bin/Native/Debug;
1852 | };
1853 | name = Debug;
1854 | };
1855 | ]]
1856 | end
1857 |
1858 |
1859 | function suite.XCBuildConfigurationProject_OnX86()
1860 | workspace("MyWorkspace")
1861 | platforms { "x86" }
1862 | prepare()
1863 | xcode.XCBuildConfiguration_Project(tr, tr.configs[1])
1864 | test.capture [[
1865 | [MyProject:Debug(2)] /* Debug */ = {
1866 | isa = XCBuildConfiguration;
1867 | buildSettings = {
1868 | ARCHS = i386;
1869 | CONFIGURATION_BUILD_DIR = "$(SYMROOT)";
1870 | CONFIGURATION_TEMP_DIR = "$(OBJROOT)";
1871 | GCC_C_LANGUAGE_STANDARD = gnu99;
1872 | GCC_OPTIMIZATION_LEVEL = 0;
1873 | GCC_SYMBOLS_PRIVATE_EXTERN = NO;
1874 | GCC_WARN_ABOUT_RETURN_TYPE = YES;
1875 | GCC_WARN_UNUSED_VARIABLE = YES;
1876 | OBJROOT = obj/x86/Debug;
1877 | ONLY_ACTIVE_ARCH = NO;
1878 | SYMROOT = bin/x86/Debug;
1879 | };
1880 | name = Debug;
1881 | };
1882 | ]]
1883 | end
1884 |
1885 |
1886 | function suite.XCBuildConfigurationProject_OnX86_64()
1887 | workspace("MyWorkspace")
1888 | platforms { "x86_64" }
1889 | prepare()
1890 | xcode.XCBuildConfiguration_Project(tr, tr.configs[1])
1891 | test.capture [[
1892 | [MyProject:Debug(2)] /* Debug */ = {
1893 | isa = XCBuildConfiguration;
1894 | buildSettings = {
1895 | ARCHS = x86_64;
1896 | CONFIGURATION_BUILD_DIR = "$(SYMROOT)";
1897 | CONFIGURATION_TEMP_DIR = "$(OBJROOT)";
1898 | GCC_C_LANGUAGE_STANDARD = gnu99;
1899 | GCC_OPTIMIZATION_LEVEL = 0;
1900 | GCC_SYMBOLS_PRIVATE_EXTERN = NO;
1901 | GCC_WARN_ABOUT_RETURN_TYPE = YES;
1902 | GCC_WARN_UNUSED_VARIABLE = YES;
1903 | OBJROOT = obj/x86_64/Debug;
1904 | ONLY_ACTIVE_ARCH = NO;
1905 | SYMROOT = bin/x86_64/Debug;
1906 | };
1907 | name = Debug;
1908 | };
1909 | ]]
1910 | end
1911 |
1912 | function suite.XCBuildConfigurationProject_OnMultiplePlatforms()
1913 | workspace("MyWorkspace")
1914 | platforms { "Universal32", "Universal64" }
1915 | prepare()
1916 | xcode.XCBuildConfiguration_Project(tr, tr.configs[1])
1917 | test.capture [[
1918 | [MyProject:Debug(2)] /* Debug */ = {
1919 | isa = XCBuildConfiguration;
1920 | buildSettings = {
1921 | ARCHS = "$(ARCHS_STANDARD_32_BIT)";
1922 | CONFIGURATION_BUILD_DIR = "$(SYMROOT)";
1923 | CONFIGURATION_TEMP_DIR = "$(OBJROOT)";
1924 | GCC_C_LANGUAGE_STANDARD = gnu99;
1925 | GCC_OPTIMIZATION_LEVEL = 0;
1926 | GCC_SYMBOLS_PRIVATE_EXTERN = NO;
1927 | GCC_WARN_ABOUT_RETURN_TYPE = YES;
1928 | GCC_WARN_UNUSED_VARIABLE = YES;
1929 | OBJROOT = obj/Universal32/Debug;
1930 | ONLY_ACTIVE_ARCH = NO;
1931 | SYMROOT = bin/Universal32/Debug;
1932 | };
1933 | name = Debug;
1934 | };
1935 | ]]
1936 | end
1937 |
1938 |
1939 | ---------------------------------------------------------------------------
1940 | -- XCBuildConfigurationList tests
1941 | ---------------------------------------------------------------------------
1942 |
1943 | function suite.XCBuildConfigurationList_OnNoPlatforms()
1944 | prepare()
1945 | xcode.XCBuildConfigurationList(tr)
1946 | test.capture [[
1947 | /* Begin XCConfigurationList section */
1948 | 1DEB928908733DD80010E9CD /* Build configuration list for PBXProject "MyProject" */ = {
1949 | isa = XCConfigurationList;
1950 | buildConfigurations = (
1951 | [MyProject:Debug(2)] /* Debug */,
1952 | [MyProject:Release(2)] /* Release */,
1953 | );
1954 | defaultConfigurationIsVisible = 0;
1955 | defaultConfigurationName = Debug;
1956 | };
1957 | [MyProject:cfg] /* Build configuration list for PBXNativeTarget "MyProject" */ = {
1958 | isa = XCConfigurationList;
1959 | buildConfigurations = (
1960 | [MyProject:Debug] /* Debug */,
1961 | [MyProject:Release] /* Release */,
1962 | );
1963 | defaultConfigurationIsVisible = 0;
1964 | defaultConfigurationName = Debug;
1965 | };
1966 | /* End XCConfigurationList section */
1967 | ]]
1968 | end
1969 |
1970 |
1971 | function suite.XCBuildConfigurationList_OnSinglePlatforms()
1972 | platforms { "Universal32" }
1973 | prepare()
1974 | xcode.XCBuildConfigurationList(tr)
1975 | test.capture [[
1976 | /* Begin XCConfigurationList section */
1977 | 1DEB928908733DD80010E9CD /* Build configuration list for PBXProject "MyProject" */ = {
1978 | isa = XCConfigurationList;
1979 | buildConfigurations = (
1980 | [MyProject:Debug(2)] /* Debug */,
1981 | [MyProject:Release(2)] /* Release */,
1982 | );
1983 | defaultConfigurationIsVisible = 0;
1984 | defaultConfigurationName = Debug;
1985 | };
1986 | [MyProject:cfg] /* Build configuration list for PBXNativeTarget "MyProject" */ = {
1987 | isa = XCConfigurationList;
1988 | buildConfigurations = (
1989 | [MyProject:Debug] /* Debug */,
1990 | [MyProject:Release] /* Release */,
1991 | );
1992 | defaultConfigurationIsVisible = 0;
1993 | defaultConfigurationName = Debug;
1994 | };
1995 | /* End XCConfigurationList section */
1996 | ]]
1997 | end
1998 |
1999 |
2000 | function suite.XCBuildConfigurationList_OnMultiplePlatforms()
2001 | workspace("MyWorkspace")
2002 | platforms { "Universal32", "Universal64" }
2003 | prepare()
2004 | xcode.XCBuildConfigurationList(tr)
2005 | test.capture [[
2006 | /* Begin XCConfigurationList section */
2007 | 1DEB928908733DD80010E9CD /* Build configuration list for PBXProject "MyProject" */ = {
2008 | isa = XCConfigurationList;
2009 | buildConfigurations = (
2010 | [MyProject:Debug(2)] /* Debug */,
2011 | [MyProject:Debug(4)] /* Debug */,
2012 | [MyProject:Release(2)] /* Release */,
2013 | [MyProject:Release(4)] /* Release */,
2014 | );
2015 | defaultConfigurationIsVisible = 0;
2016 | defaultConfigurationName = Debug;
2017 | };
2018 | [MyProject:cfg] /* Build configuration list for PBXNativeTarget "MyProject" */ = {
2019 | isa = XCConfigurationList;
2020 | buildConfigurations = (
2021 | [MyProject:Debug] /* Debug */,
2022 | [MyProject:Debug(3)] /* Debug */,
2023 | [MyProject:Release] /* Release */,
2024 | [MyProject:Release(3)] /* Release */,
2025 | );
2026 | defaultConfigurationIsVisible = 0;
2027 | defaultConfigurationName = Debug;
2028 | };
2029 | /* End XCConfigurationList section */
2030 | ]]
2031 | end
2032 |
2033 | function suite.defaultVisibility_settingIsFound()
2034 | prepare()
2035 | xcode.XCBuildConfiguration(tr)
2036 | local str = premake.captured()
2037 | test.istrue(str:find('GCC_SYMBOLS_PRIVATE_EXTERN'))
2038 | end
2039 |
2040 |
2041 | function suite.defaultVisibilitySetting_setToNo()
2042 | prepare()
2043 | xcode.XCBuildConfiguration(tr)
2044 | local str = premake.captured()
2045 | test.istrue(str:find('GCC_SYMBOLS_PRIVATE_EXTERN = NO;'))
2046 | end
2047 |
2048 | function suite.releaseBuild_onlyDefaultArch_equalsNo()
2049 | flags { "Optimize" }
2050 | prepare()
2051 | xcode.XCBuildConfiguration_Project(tr, tr.configs[2])
2052 | local str = premake.captured()
2053 | test.istrue(str:find('ONLY_ACTIVE_ARCH = NO;'))
2054 | end
2055 |
2056 | function suite.debugBuild_onlyDefaultArch_equalsYes()
2057 | symbols "On"
2058 | prepare()
2059 | xcode.XCBuildConfiguration_Project(tr, tr.configs[1])
2060 |
2061 | local str = premake.captured()
2062 | test.istrue(str:find('ONLY_ACTIVE_ARCH = YES;'))
2063 | end
2064 |
--------------------------------------------------------------------------------
/xcode.lua:
--------------------------------------------------------------------------------
1 | ---
2 | -- xcode/xcode.lua
3 | -- Common support code for the Apple Xcode exporters.
4 | -- Copyright (c) 2009-2015 Jason Perkins and the Premake project
5 | ---
6 |
7 | local p = premake
8 |
9 | p.modules.xcode = {}
10 |
11 | local m = p.modules.xcode
12 | m._VERSION = p._VERSION
13 | m.elements = {}
14 |
15 | include("xcode_common.lua")
16 | include("xcode4_workspace.lua")
17 | include("xcode_project.lua")
18 |
19 | return m
20 |
--------------------------------------------------------------------------------
/xcode4_workspace.lua:
--------------------------------------------------------------------------------
1 | ---
2 | -- xcode/xcode4_workspace.lua
3 | -- Generate an Xcode workspace.
4 | -- Author Mihai Sebea
5 | -- Modified by Jason Perkins
6 | -- Copyright (c) 2014-2015 Jason Perkins and the Premake project
7 | ---
8 |
9 | local p = premake
10 | local m = p.modules.xcode
11 |
12 |
13 |
14 | ---
15 | -- Generate an Xcode contents.xcworkspacedata file.
16 | ---
17 |
18 | m.elements.workspace = function(wks)
19 | return {
20 | m.xmlDeclaration,
21 | m.workspace,
22 | m.workspaceFileRefs,
23 | m.workspaceTail,
24 | }
25 | end
26 |
27 | function m.generateWorkspace(wks)
28 | m.prepareWorkspace(wks)
29 | p.callArray(m.elements.workspace, wks)
30 | end
31 |
32 |
33 | function m.workspace()
34 | p.push('')
36 | end
37 |
38 |
39 | function m.workspaceTail()
40 | -- Don't output final newline. Xcode doesn't.
41 | premake.out('')
42 | end
43 |
44 |
45 | ---
46 | -- Generate the list of project references.
47 | ---
48 |
49 | m.elements.workspaceFileRef = function(prj)
50 | return {
51 | m.workspaceLocation,
52 | }
53 | end
54 |
55 | function m.workspaceFileRefs(wks)
56 | for prj in p.workspace.eachproject(wks) do
57 | p.push('")
62 | p.pop('')
63 | end
64 | end
65 |
66 |
67 |
68 | ---------------------------------------------------------------------------
69 | --
70 | -- Handlers for individual project elements
71 | --
72 | ---------------------------------------------------------------------------
73 |
74 |
75 | function m.workspaceLocation(prj)
76 | local fname = p.filename(prj, ".xcodeproj")
77 | fname = path.getrelative(prj.workspace.location, fname)
78 | p.w('location = "group:%s"', fname)
79 | end
80 |
81 |
82 | function m.xmlDeclaration()
83 | p.xmlUtf8(true)
84 | end
85 |
--------------------------------------------------------------------------------
/xcode_common.lua:
--------------------------------------------------------------------------------
1 | --
2 | -- xcode_common.lua
3 | -- Functions to generate the different sections of an Xcode project.
4 | -- Copyright (c) 2009-2015 Jason Perkins and the Premake project
5 | --
6 |
7 | local p = premake
8 | local xcode = p.modules.xcode
9 | local tree = p.tree
10 | local workspace = p.workspace
11 | local project = p.project
12 | local config = p.config
13 | local fileconfig = p.fileconfig
14 |
15 |
16 | --
17 | -- Return the Xcode build category for a given file, based on the file extension.
18 | --
19 | -- @param node
20 | -- The node to identify.
21 | -- @returns
22 | -- An Xcode build category, one of "Sources", "Resources", "Frameworks", or nil.
23 | --
24 |
25 | function xcode.getbuildcategory(node)
26 | local categories = {
27 | [".a"] = "Frameworks",
28 | [".c"] = "Sources",
29 | [".cc"] = "Sources",
30 | [".cpp"] = "Sources",
31 | [".cxx"] = "Sources",
32 | [".dylib"] = "Frameworks",
33 | [".framework"] = "Frameworks",
34 | [".m"] = "Sources",
35 | [".mm"] = "Sources",
36 | [".strings"] = "Resources",
37 | [".nib"] = "Resources",
38 | [".xib"] = "Resources",
39 | [".storyboard"] = "Resources",
40 | [".icns"] = "Resources",
41 | [".s"] = "Sources",
42 | [".S"] = "Sources",
43 | }
44 | if node.isResource then
45 | return "Resources"
46 | end
47 | return categories[path.getextension(node.name)]
48 | end
49 |
50 | function xcode.isItemResource(project, node)
51 |
52 | local res;
53 |
54 | if project and project.xcodebuildresources then
55 | if type(project.xcodebuildresources) == "table" then
56 | res = project.xcodebuildresources
57 | end
58 | end
59 |
60 | local function checkItemInList(item, list)
61 | if item then
62 | if list then
63 | if type(list) == "table" then
64 | for _,v in pairs(list) do
65 | if string.find(item, v) then
66 | return true
67 | end
68 | end
69 | end
70 | end
71 | end
72 | return false
73 | end
74 |
75 | --print (node.path, node.buildid, node.cfg, res)
76 | if (checkItemInList(node.path, res)) then
77 | return true
78 | end
79 |
80 | return false
81 | end
82 | --
83 | -- Return the Xcode type for a given file, based on the file extension.
84 | --
85 | -- @param fname
86 | -- The file name to identify.
87 | -- @returns
88 | -- An Xcode file type, string.
89 | --
90 |
91 | function xcode.getfiletype(node, cfg)
92 |
93 | if node.configs then
94 | local filecfg = fileconfig.getconfig(node, cfg)
95 | if filecfg then
96 | if filecfg.language == "ObjC" then
97 | return "sourcecode.c.objc"
98 | elseif filecfg.language == "ObjCpp" then
99 | return "sourcecode.cpp.objcpp"
100 | end
101 | end
102 | end
103 |
104 | local types = {
105 | [".c"] = "sourcecode.c.c",
106 | [".cc"] = "sourcecode.cpp.cpp",
107 | [".cpp"] = "sourcecode.cpp.cpp",
108 | [".css"] = "text.css",
109 | [".cxx"] = "sourcecode.cpp.cpp",
110 | [".S"] = "sourcecode.asm.asm",
111 | [".framework"] = "wrapper.framework",
112 | [".gif"] = "image.gif",
113 | [".h"] = "sourcecode.c.h",
114 | [".html"] = "text.html",
115 | [".lua"] = "sourcecode.lua",
116 | [".m"] = "sourcecode.c.objc",
117 | [".mm"] = "sourcecode.cpp.objc",
118 | [".nib"] = "wrapper.nib",
119 | [".storyboard"] = "file.storyboard",
120 | [".pch"] = "sourcecode.c.h",
121 | [".plist"] = "text.plist.xml",
122 | [".strings"] = "text.plist.strings",
123 | [".xib"] = "file.xib",
124 | [".icns"] = "image.icns",
125 | [".s"] = "sourcecode.asm",
126 | [".bmp"] = "image.bmp",
127 | [".wav"] = "audio.wav",
128 | [".xcassets"] = "folder.assetcatalog",
129 |
130 | }
131 | return types[path.getextension(node.path)] or "text"
132 | end
133 |
134 | --
135 | -- Print user configuration references contained in xcodeconfigreferences
136 | -- @param offset
137 | -- offset used by function _p
138 | -- @param cfg
139 | -- configuration
140 | --
141 |
142 | local function xcodePrintUserConfigReferences(offset, cfg, tr, kind)
143 | local referenceName
144 | if kind == "project" then
145 | referenceName = cfg.xcodeconfigreferenceproject
146 | elseif kind == "target" then
147 | referenceName = cfg.xcodeconfigreferencetarget
148 | end
149 | tree.traverse(tr, {
150 | onleaf = function(node)
151 | filename = node.name
152 | if node.id and path.getextension(filename) == ".xcconfig" then
153 | if filename == referenceName then
154 | _p(offset, 'baseConfigurationReference = %s /* %s */;', node.id, filename)
155 | return
156 | end
157 | end
158 | end
159 | }, false)
160 | end
161 |
162 |
163 |
164 | local escapeSpecialChars = {
165 | ['\n'] = '\\n',
166 | ['\r'] = '\\r',
167 | ['\t'] = '\\t',
168 | }
169 |
170 | local function escapeChar(c)
171 | return escapeSpecialChars[c] or '\\'..c
172 | end
173 |
174 | local function escapeArg(value)
175 | value = value:gsub('[\'"\\\n\r\t ]', escapeChar)
176 | return value
177 | end
178 |
179 | local function escapeSetting(value)
180 | value = value:gsub('["\\\n\r\t]', escapeChar)
181 | return value
182 | end
183 |
184 | local function stringifySetting(value)
185 | value = value..''
186 | if not value:match('^[%a%d_./]+$') then
187 | value = '"'..escapeSetting(value)..'"'
188 | end
189 | return value
190 | end
191 |
192 | local function customStringifySetting(value)
193 | value = value..''
194 |
195 | local test = value:match('^[%a%d_./%+]+$')
196 | if test then
197 | value = '"'..escapeSetting(value)..'"'
198 | end
199 | return value
200 | end
201 |
202 | local function printSetting(level, name, value)
203 | if type(value) == 'function' then
204 | value(level, name)
205 | elseif type(value) ~= 'table' then
206 | _p(level, '%s = %s;', stringifySetting(name), stringifySetting(value))
207 | --elseif #value == 1 then
208 | --_p(level, '%s = %s;', stringifySetting(name), stringifySetting(value[1]))
209 | elseif #value >= 1 then
210 | _p(level, '%s = (', stringifySetting(name))
211 | for _, item in ipairs(value) do
212 | _p(level + 1, '%s,', stringifySetting(item))
213 | end
214 | _p(level, ');')
215 | end
216 | end
217 |
218 | local function printSettingsTable(level, settings)
219 | -- Maintain alphabetic order to be consistent
220 | local keys = table.keys(settings)
221 | table.sort(keys)
222 | for _, k in ipairs(keys) do
223 | printSetting(level, k, settings[k])
224 | end
225 | end
226 |
227 | local function overrideSettings(settings, overrides)
228 | if type(overrides) == 'table' then
229 | for name, value in pairs(overrides) do
230 | -- Allow an override to remove a value by using false
231 | settings[name] = iif(value ~= false, value, nil)
232 | end
233 | end
234 | end
235 |
236 | --
237 | -- Return the Xcode product type, based target kind.
238 | --
239 | -- @param node
240 | -- The product node to identify.
241 | -- @returns
242 | -- An Xcode product type, string.
243 | --
244 |
245 | function xcode.getproducttype(node)
246 | local types = {
247 | ConsoleApp = "com.apple.product-type.tool",
248 | WindowedApp = "com.apple.product-type.application",
249 | StaticLib = "com.apple.product-type.library.static",
250 | SharedLib = "com.apple.product-type.library.dynamic",
251 | }
252 | return types[node.cfg.kind]
253 | end
254 |
255 |
256 | --
257 | -- Return the Xcode target type, based on the target file extension.
258 | --
259 | -- @param node
260 | -- The product node to identify.
261 | -- @returns
262 | -- An Xcode target type, string.
263 | --
264 |
265 | function xcode.gettargettype(node)
266 | local types = {
267 | ConsoleApp = "\"compiled.mach-o.executable\"",
268 | WindowedApp = "wrapper.application",
269 | StaticLib = "archive.ar",
270 | SharedLib = "\"compiled.mach-o.dylib\"",
271 | }
272 | return types[node.cfg.kind]
273 | end
274 |
275 |
276 | --
277 | -- Return a unique file name for a project. Since Xcode uses .xcodeproj's to
278 | -- represent both workspaces and projects there is a likely change of a name
279 | -- collision. Tack on a number to differentiate them.
280 | --
281 | -- @param prj
282 | -- The project being queried.
283 | -- @returns
284 | -- A uniqued file name
285 | --
286 |
287 | function xcode.getxcodeprojname(prj)
288 | -- if there is a workspace with matching name, then use "projectname1.xcodeproj"
289 | -- just get something working for now
290 | local fname = premake.filename(prj, ".xcodeproj")
291 | return fname
292 | end
293 |
294 |
295 | --
296 | -- Returns true if the file name represents a framework.
297 | --
298 | -- @param fname
299 | -- The name of the file to test.
300 | --
301 |
302 | function xcode.isframework(fname)
303 | return (path.getextension(fname) == ".framework")
304 | end
305 |
306 |
307 | --
308 | -- Retrieves a unique 12 byte ID for an object.
309 | -- This function accepts an array of parameters that will be used to generate the id.
310 | --
311 | -- @returns
312 | -- A 24-character string representing the 12 byte ID.
313 | --
314 |
315 | function xcode.newid(...)
316 | local name = ''
317 | local arg = {...}
318 | for i, v in pairs(arg) do
319 | name = name..v..'****'
320 | end
321 |
322 |
323 | return ("%08X%08X%08X"):format(name:hash(16777619), name:hash(2166136261), name:hash(46577619))
324 | end
325 |
326 |
327 | --
328 | -- Create a product tree node and all projects in a workspace; assigning IDs
329 | -- that are needed for inter-project dependencies.
330 | --
331 | -- @param wks
332 | -- The workspace to prepare.
333 | --
334 |
335 | function xcode.prepareWorkspace(wks)
336 | -- create and cache a list of supported platforms
337 | wks.xcode = { }
338 |
339 | for prj in premake.workspace.eachproject(wks) do
340 | -- need a configuration to get the target information
341 | local cfg = project.getconfig(prj, prj.configurations[1], prj.platforms[1])
342 |
343 | -- build the product tree node
344 | local bundlepath = cfg.buildtarget.bundlename ~= "" and cfg.buildtarget.bundlename or cfg.buildtarget.name;
345 | if (prj.external) then
346 | bundlepath = cfg.project.name
347 | end
348 |
349 | local node = premake.tree.new(path.getname(bundlepath))
350 |
351 | node.cfg = cfg
352 | node.id = xcode.newid(node.name, "product")
353 | node.targetid = xcode.newid(node.name, "target")
354 |
355 | -- attach it to the project
356 | prj.xcode = {}
357 | prj.xcode.projectnode = node
358 | end
359 | end
360 |
361 |
362 | ---------------------------------------------------------------------------
363 | -- Section generator functions, in the same order in which they appear
364 | -- in the .pbxproj file
365 | ---------------------------------------------------------------------------
366 |
367 | function xcode.PBXBuildFile(tr)
368 | local settings = {};
369 | tree.traverse(tr, {
370 | onnode = function(node)
371 | if node.buildid then
372 | settings[node.buildid] = function(level)
373 | _p(level,'%s /* %s in %s */ = {isa = PBXBuildFile; fileRef = %s /* %s */; };',
374 | node.buildid, node.name, xcode.getbuildcategory(node), node.id, node.name)
375 | end
376 | end
377 | end
378 | })
379 |
380 | if not table.isempty(settings) then
381 | _p('/* Begin PBXBuildFile section */')
382 | printSettingsTable(2, settings);
383 | _p('/* End PBXBuildFile section */')
384 | _p('')
385 | end
386 | end
387 |
388 |
389 | function xcode.PBXContainerItemProxy(tr)
390 | local settings = {}
391 | for _, node in ipairs(tr.projects.children) do
392 | settings[node.productproxyid] = function()
393 | _p(2,'%s /* PBXContainerItemProxy */ = {', node.productproxyid)
394 | _p(3,'isa = PBXContainerItemProxy;')
395 | _p(3,'containerPortal = %s /* %s */;', node.id, path.getrelative(node.parent.parent.project.location, node.path))
396 | _p(3,'proxyType = 2;')
397 | _p(3,'remoteGlobalIDString = %s;', node.project.xcode.projectnode.id)
398 | _p(3,'remoteInfo = %s;', stringifySetting(node.project.xcode.projectnode.name))
399 | _p(2,'};')
400 | end
401 | settings[node.targetproxyid] = function()
402 | _p(2,'%s /* PBXContainerItemProxy */ = {', node.targetproxyid)
403 | _p(3,'isa = PBXContainerItemProxy;')
404 | _p(3,'containerPortal = %s /* %s */;', node.id, path.getrelative(node.parent.parent.project.location, node.path))
405 | _p(3,'proxyType = 1;')
406 | _p(3,'remoteGlobalIDString = %s;', node.project.xcode.projectnode.targetid)
407 | _p(3,'remoteInfo = %s;', stringifySetting(node.project.xcode.projectnode.name))
408 | _p(2,'};')
409 | end
410 | end
411 |
412 | if not table.isempty(settings) then
413 | _p('/* Begin PBXContainerItemProxy section */')
414 | printSettingsTable(2, settings);
415 | _p('/* End PBXContainerItemProxy section */')
416 | _p('')
417 | end
418 | end
419 |
420 |
421 | function xcode.PBXFileReference(tr)
422 | local cfg = project.getfirstconfig(tr.project)
423 | local settings = {}
424 |
425 | tree.traverse(tr, {
426 | onleaf = function(node)
427 | -- I'm only listing files here, so ignore anything without a path
428 | if not node.path then
429 | return
430 | end
431 |
432 | -- is this the product node, describing the output target?
433 | if node.kind == "product" then
434 | settings[node.id] = function(level)
435 | _p(level,'%s /* %s */ = {isa = PBXFileReference; explicitFileType = %s; includeInIndex = 0; name = %s; path = %s; sourceTree = BUILT_PRODUCTS_DIR; };',
436 | node.id, node.name, xcode.gettargettype(node), stringifySetting(node.name), stringifySetting(path.getname(node.cfg.buildtarget.bundlename ~= "" and node.cfg.buildtarget.bundlename or node.cfg.buildtarget.relpath)))
437 | end
438 | -- is this a project dependency?
439 | elseif node.parent.parent == tr.projects then
440 | settings[node.parent.id] = function(level)
441 | -- ms Is there something wrong with path is relative ?
442 | -- if we have a and b without slashes get relative should assume the same parent folder and return ../
443 | -- this works if we put it like below
444 | local relpath = path.getrelative(path.getabsolute(tr.project.location), path.getabsolute(node.parent.project.location))
445 | _p(level,'%s /* %s */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = %s; path = %s; sourceTree = SOURCE_ROOT; };',
446 | node.parent.id, node.name, customStringifySetting(node.parent.name), stringifySetting(path.join(relpath, node.parent.name)))
447 | end
448 | -- something else
449 | else
450 | settings[node.id] = function(level)
451 | local pth, src
452 | if xcode.isframework(node.path) then
453 | --respect user supplied paths
454 | -- look for special variable-starting paths for different sources
455 | local nodePath = node.path
456 | local _, matchEnd, variable = string.find(nodePath, "^%$%((.+)%)/")
457 | if variable then
458 | -- by skipping the last '/' we support the same absolute/relative
459 | -- paths as before
460 | nodePath = string.sub(nodePath, matchEnd + 1)
461 | end
462 | if string.find(nodePath,'/') then
463 | if string.find(nodePath,'^%.')then
464 | --error('relative paths are not currently supported for frameworks')
465 | pth = path.getrelative(tr.project.location, node.path)
466 | --print(tr.project.location, node.path , pth)
467 | src = "SOURCE_ROOT"
468 | variable = src
469 | else
470 | pth = nodePath
471 | src = ""
472 | end
473 | end
474 | -- if it starts with a variable, use that as the src instead
475 | if variable then
476 | src = variable
477 | -- if we are using a different source tree, it has to be relative
478 | -- to that source tree, so get rid of any leading '/'
479 | if string.find(pth, '^/') then
480 | pth = string.sub(pth, 2)
481 | end
482 | else
483 | pth = "System/Library/Frameworks/" .. node.path
484 | src = "SDKROOT"
485 | end
486 | else
487 | -- something else; probably a source code file
488 | src = ""
489 |
490 | if node.abspath then
491 | pth = path.getrelative(tr.project.location, node.abspath)
492 | else
493 | pth = node.path
494 | end
495 | --end
496 | end
497 | _p(level,'%s /* %s */ = {isa = PBXFileReference; lastKnownFileType = %s; name = %s; path = %s; sourceTree = %s; };',
498 | node.id, node.name, xcode.getfiletype(node, cfg), stringifySetting(node.name), stringifySetting(pth), stringifySetting(src))
499 | end
500 | end
501 | end
502 | })
503 |
504 | if not table.isempty(settings) then
505 | _p('/* Begin PBXFileReference section */')
506 | printSettingsTable(2, settings)
507 | _p('/* End PBXFileReference section */')
508 | _p('')
509 | end
510 | end
511 |
512 |
513 | function xcode.PBXFrameworksBuildPhase(tr)
514 | _p('/* Begin PBXFrameworksBuildPhase section */')
515 | _p(2,'%s /* Frameworks */ = {', tr.products.children[1].fxstageid)
516 | _p(3,'isa = PBXFrameworksBuildPhase;')
517 | _p(3,'buildActionMask = 2147483647;')
518 | _p(3,'files = (')
519 |
520 | -- write out library dependencies
521 | tree.traverse(tr.frameworks, {
522 | onleaf = function(node)
523 | if node.buildid then
524 | _p(4,'%s /* %s in Frameworks */,', node.buildid, node.name)
525 | end
526 | end
527 | })
528 |
529 | -- write out project dependencies
530 | tree.traverse(tr.projects, {
531 | onleaf = function(node)
532 | if node.buildid then
533 | _p(4,'%s /* %s in Frameworks */,', node.buildid, node.name)
534 | end
535 | end
536 | })
537 |
538 | _p(3,');')
539 | _p(3,'runOnlyForDeploymentPostprocessing = 0;')
540 | _p(2,'};')
541 | _p('/* End PBXFrameworksBuildPhase section */')
542 | _p('')
543 | end
544 |
545 |
546 | function xcode.PBXGroup(tr)
547 | local settings = {}
548 |
549 | tree.traverse(tr, {
550 | onnode = function(node)
551 | -- Skip over anything that isn't a proper group
552 | if (node.path and #node.children == 0) or node.kind == "vgroup" then
553 | return
554 | end
555 |
556 | settings[node.productgroupid or node.id] = function()
557 | -- project references get special treatment
558 | if node.parent == tr.projects then
559 | _p(2,'%s /* Products */ = {', node.productgroupid)
560 | else
561 | _p(2,'%s /* %s */ = {', node.id, node.name)
562 | end
563 |
564 | _p(3,'isa = PBXGroup;')
565 | _p(3,'children = (')
566 | for _, childnode in ipairs(node.children) do
567 | _p(4,'%s /* %s */,', childnode.id, childnode.name)
568 | end
569 | _p(3,');')
570 |
571 | if node.parent == tr.projects then
572 | _p(3,'name = Products;')
573 | else
574 | _p(3,'name = %s;', stringifySetting(node.name))
575 |
576 | local vpath = project.getvpath(tr.project, node.name)
577 |
578 | if node.path and node.name ~= vpath then
579 | local p = node.path
580 | if node.parent.path then
581 | p = path.getrelative(node.parent.path, node.path)
582 | end
583 | _p(3,'path = %s;', stringifySetting(p))
584 | end
585 | end
586 |
587 | _p(3,'sourceTree = "";')
588 | _p(2,'};')
589 | end
590 | end
591 | }, true)
592 |
593 | if not table.isempty(settings) then
594 | _p('/* Begin PBXGroup section */')
595 | printSettingsTable(2, settings)
596 | _p('/* End PBXGroup section */')
597 | _p('')
598 | end
599 | end
600 |
601 |
602 | function xcode.PBXNativeTarget(tr)
603 | _p('/* Begin PBXNativeTarget section */')
604 | for _, node in ipairs(tr.products.children) do
605 | local name = tr.project.name
606 |
607 | -- This function checks whether there are build commands of a specific
608 | -- type to be executed; they will be generated correctly, but the project
609 | -- commands will not contain any per-configuration commands, so the logic
610 | -- has to be extended a bit to account for that.
611 | local function hasBuildCommands(which)
612 | -- standard check...this is what existed before
613 | if #tr.project[which] > 0 then
614 | return true
615 | end
616 | -- what if there are no project-level commands? check configs...
617 | for _, cfg in ipairs(tr.configs) do
618 | if #cfg[which] > 0 then
619 | return true
620 | end
621 | end
622 | end
623 |
624 | _p(2,'%s /* %s */ = {', node.targetid, name)
625 | _p(3,'isa = PBXNativeTarget;')
626 | _p(3,'buildConfigurationList = %s /* Build configuration list for PBXNativeTarget "%s" */;', node.cfgsection, escapeSetting(name))
627 | _p(3,'buildPhases = (')
628 | if hasBuildCommands('prebuildcommands') then
629 | _p(4,'9607AE1010C857E500CD1376 /* Prebuild */,')
630 | end
631 | _p(4,'%s /* Resources */,', node.resstageid)
632 | _p(4,'%s /* Sources */,', node.sourcesid)
633 | if hasBuildCommands('prelinkcommands') then
634 | _p(4,'9607AE3510C85E7E00CD1376 /* Prelink */,')
635 | end
636 | _p(4,'%s /* Frameworks */,', node.fxstageid)
637 | if hasBuildCommands('postbuildcommands') then
638 | _p(4,'9607AE3710C85E8F00CD1376 /* Postbuild */,')
639 | end
640 | _p(3,');')
641 | _p(3,'buildRules = (')
642 | _p(3,');')
643 |
644 | _p(3,'dependencies = (')
645 | for _, node in ipairs(tr.projects.children) do
646 | _p(4,'%s /* PBXTargetDependency */,', node.targetdependid)
647 | end
648 | _p(3,');')
649 |
650 | _p(3,'name = %s;', stringifySetting(name))
651 |
652 | local p
653 | if node.cfg.kind == "ConsoleApp" then
654 | p = "$(HOME)/bin"
655 | elseif node.cfg.kind == "WindowedApp" then
656 | p = "$(HOME)/Applications"
657 | end
658 | if p then
659 | _p(3,'productInstallPath = %s;', stringifySetting(p))
660 | end
661 |
662 | _p(3,'productName = %s;', stringifySetting(name))
663 | _p(3,'productReference = %s /* %s */;', node.id, node.name)
664 | _p(3,'productType = %s;', stringifySetting(xcode.getproducttype(node)))
665 | _p(2,'};')
666 | end
667 | _p('/* End PBXNativeTarget section */')
668 | _p('')
669 | end
670 |
671 |
672 | function xcode.PBXProject(tr)
673 | _p('/* Begin PBXProject section */')
674 | _p(2,'08FB7793FE84155DC02AAC07 /* Project object */ = {')
675 | _p(3,'isa = PBXProject;')
676 | _p(3,'buildConfigurationList = 1DEB928908733DD80010E9CD /* Build configuration list for PBXProject "%s" */;', tr.name)
677 | _p(3,'compatibilityVersion = "Xcode 3.2";')
678 | _p(3,'hasScannedForEncodings = 1;')
679 | _p(3,'mainGroup = %s /* %s */;', tr.id, tr.name)
680 | _p(3,'projectDirPath = "";')
681 |
682 | if #tr.projects.children > 0 then
683 | _p(3,'projectReferences = (')
684 | for _, node in ipairs(tr.projects.children) do
685 | _p(4,'{')
686 | _p(5,'ProductGroup = %s /* Products */;', node.productgroupid)
687 | _p(5,'ProjectRef = %s /* %s */;', node.id, path.getname(node.path))
688 | _p(4,'},')
689 | end
690 | _p(3,');')
691 | end
692 |
693 | _p(3,'projectRoot = "";')
694 | _p(3,'targets = (')
695 | for _, node in ipairs(tr.products.children) do
696 | _p(4,'%s /* %s */,', node.targetid, node.name)
697 | end
698 | _p(3,');')
699 | _p(2,'};')
700 | _p('/* End PBXProject section */')
701 | _p('')
702 | end
703 |
704 |
705 | function xcode.PBXReferenceProxy(tr)
706 | local settings = {}
707 |
708 | tree.traverse(tr.projects, {
709 | onleaf = function(node)
710 | settings[node.id] = function()
711 | _p(2,'%s /* %s */ = {', node.id, node.name)
712 | _p(3,'isa = PBXReferenceProxy;')
713 | _p(3,'fileType = %s;', xcode.gettargettype(node))
714 | _p(3,'path = %s;', stringifySetting(node.name))
715 | _p(3,'remoteRef = %s /* PBXContainerItemProxy */;', node.parent.productproxyid)
716 | _p(3,'sourceTree = BUILT_PRODUCTS_DIR;')
717 | _p(2,'};')
718 | end
719 | end
720 | })
721 |
722 | if not table.isempty(settings) then
723 | _p('/* Begin PBXReferenceProxy section */')
724 | printSettingsTable(2, settings)
725 | _p('/* End PBXReferenceProxy section */')
726 | _p('')
727 | end
728 | end
729 |
730 |
731 | function xcode.PBXResourcesBuildPhase(tr)
732 | _p('/* Begin PBXResourcesBuildPhase section */')
733 | for _, target in ipairs(tr.products.children) do
734 | _p(2,'%s /* Resources */ = {', target.resstageid)
735 | _p(3,'isa = PBXResourcesBuildPhase;')
736 | _p(3,'buildActionMask = 2147483647;')
737 | _p(3,'files = (')
738 | tree.traverse(tr, {
739 | onnode = function(node)
740 | if xcode.getbuildcategory(node) == "Resources" then
741 | _p(4,'%s /* %s in Resources */,', node.buildid, node.name)
742 | end
743 | end
744 | })
745 | _p(3,');')
746 | _p(3,'runOnlyForDeploymentPostprocessing = 0;')
747 | _p(2,'};')
748 | end
749 | _p('/* End PBXResourcesBuildPhase section */')
750 | _p('')
751 | end
752 |
753 | function xcode.PBXShellScriptBuildPhase(tr)
754 | local wrapperWritten = false
755 |
756 | local function doblock(id, name, which)
757 | -- start with the project-level commands (most common)
758 | local prjcmds = tr.project[which]
759 | local commands = table.join(prjcmds, {})
760 |
761 | -- see if there are any config-specific commands to add
762 | for _, cfg in ipairs(tr.configs) do
763 | local cfgcmds = cfg[which]
764 | if #cfgcmds > #prjcmds then
765 | table.insert(commands, 'if [ "${CONFIGURATION}" = "' .. cfg.buildcfg .. '" ]; then')
766 | for i = #prjcmds + 1, #cfgcmds do
767 | table.insert(commands, cfgcmds[i])
768 | end
769 | table.insert(commands, 'fi')
770 | end
771 | end
772 |
773 | if #commands > 0 then
774 | commands = os.translateCommands(commands, p.MACOSX)
775 | if not wrapperWritten then
776 | _p('/* Begin PBXShellScriptBuildPhase section */')
777 | wrapperWritten = true
778 | end
779 | _p(2,'%s /* %s */ = {', id, name)
780 | _p(3,'isa = PBXShellScriptBuildPhase;')
781 | _p(3,'buildActionMask = 2147483647;')
782 | _p(3,'files = (')
783 | _p(3,');')
784 | _p(3,'inputPaths = (');
785 | _p(3,');');
786 | _p(3,'name = %s;', name);
787 | _p(3,'outputPaths = (');
788 | _p(3,');');
789 | _p(3,'runOnlyForDeploymentPostprocessing = 0;');
790 | _p(3,'shellPath = /bin/sh;');
791 | _p(3,'shellScript = %s;', stringifySetting(table.concat(commands, '\n')))
792 | _p(2,'};')
793 | end
794 | end
795 |
796 | doblock("9607AE1010C857E500CD1376", "Prebuild", "prebuildcommands")
797 | doblock("9607AE3510C85E7E00CD1376", "Prelink", "prelinkcommands")
798 | doblock("9607AE3710C85E8F00CD1376", "Postbuild", "postbuildcommands")
799 |
800 | if wrapperWritten then
801 | _p('/* End PBXShellScriptBuildPhase section */')
802 | end
803 | end
804 |
805 |
806 | function xcode.PBXSourcesBuildPhase(tr)
807 | _p('/* Begin PBXSourcesBuildPhase section */')
808 | for _, target in ipairs(tr.products.children) do
809 | _p(2,'%s /* Sources */ = {', target.sourcesid)
810 | _p(3,'isa = PBXSourcesBuildPhase;')
811 | _p(3,'buildActionMask = 2147483647;')
812 | _p(3,'files = (')
813 | tree.traverse(tr, {
814 | onleaf = function(node)
815 | if xcode.getbuildcategory(node) == "Sources" then
816 | _p(4,'%s /* %s in Sources */,', node.buildid, node.name)
817 | end
818 | end
819 | })
820 | _p(3,');')
821 | _p(3,'runOnlyForDeploymentPostprocessing = 0;')
822 | _p(2,'};')
823 | end
824 | _p('/* End PBXSourcesBuildPhase section */')
825 | _p('')
826 | end
827 |
828 |
829 | function xcode.PBXVariantGroup(tr)
830 | local settings = {}
831 | tree.traverse(tr, {
832 | onbranch = function(node)
833 | settings[node.id] = function()
834 | if node.kind == "vgroup" then
835 | _p(2,'%s /* %s */ = {', node.id, node.name)
836 | _p(3,'isa = PBXVariantGroup;')
837 | _p(3,'children = (')
838 | for _, lang in ipairs(node.children) do
839 | _p(4,'%s /* %s */,', lang.id, lang.name)
840 | end
841 | _p(3,');')
842 | _p(3,'name = %s;', node.name)
843 | _p(3,'sourceTree = "";')
844 | _p(2,'};')
845 | end
846 | end
847 | end
848 | })
849 |
850 | if not table.isempty(settings) then
851 | _p('/* Begin PBXVariantGroup section */')
852 | printSettingsTable(2, settings)
853 | _p('/* End PBXVariantGroup section */')
854 | _p('')
855 | end
856 | end
857 |
858 |
859 | function xcode.PBXTargetDependency(tr)
860 | local settings = {}
861 | tree.traverse(tr.projects, {
862 | onleaf = function(node)
863 | settings[node.parent.targetdependid] = function()
864 | _p(2,'%s /* PBXTargetDependency */ = {', node.parent.targetdependid)
865 | _p(3,'isa = PBXTargetDependency;')
866 | _p(3,'name = %s;', stringifySetting(node.name))
867 | _p(3,'targetProxy = %s /* PBXContainerItemProxy */;', node.parent.targetproxyid)
868 | _p(2,'};')
869 | end
870 | end
871 | })
872 |
873 | if not table.isempty(settings) then
874 | _p('/* Begin PBXTargetDependency section */')
875 | printSettingsTable(2, settings)
876 | _p('/* End PBXTargetDependency section */')
877 | _p('')
878 | end
879 | end
880 |
881 |
882 | function xcode.XCBuildConfiguration_Target(tr, target, cfg)
883 | local settings = {}
884 |
885 | settings['ALWAYS_SEARCH_USER_PATHS'] = 'NO'
886 |
887 | if cfg.symbols ~= p.OFF then
888 | settings['DEBUG_INFORMATION_FORMAT'] = 'dwarf-with-dsym'
889 | end
890 |
891 | if cfg.kind ~= "StaticLib" and cfg.buildtarget.prefix ~= '' then
892 | settings['EXECUTABLE_PREFIX'] = cfg.buildtarget.prefix
893 | end
894 |
895 | --[[if cfg.targetextension then
896 | local ext = cfg.targetextension
897 | ext = iif(ext:startswith('.'), ext:sub(2), ext)
898 | settings['EXECUTABLE_EXTENSION'] = ext
899 | end]]
900 |
901 | local outdir = path.getrelative(tr.project.location, path.getdirectory(cfg.buildtarget.relpath))
902 | if outdir ~= "." then
903 | settings['CONFIGURATION_BUILD_DIR'] = outdir
904 | end
905 |
906 | settings['GCC_DYNAMIC_NO_PIC'] = 'NO'
907 |
908 | if tr.infoplist then
909 | settings['INFOPLIST_FILE'] = config.findfile(cfg, path.getextension(tr.infoplist.name))
910 | end
911 |
912 | installpaths = {
913 | ConsoleApp = '/usr/local/bin',
914 | WindowedApp = '"$(HOME)/Applications"',
915 | SharedLib = '/usr/local/lib',
916 | StaticLib = '/usr/local/lib',
917 | }
918 | settings['INSTALL_PATH'] = installpaths[cfg.kind]
919 |
920 | local fileNameList = {}
921 | local file_tree = project.getsourcetree(tr.project)
922 | tree.traverse(tr, {
923 | onnode = function(node)
924 | if node.buildid and not node.isResource and node.abspath then
925 | -- ms this seems to work on visual studio !!!
926 | -- why not in xcode ??
927 | local filecfg = fileconfig.getconfig(node, cfg)
928 | if filecfg and filecfg.flags.ExcludeFromBuild then
929 | --fileNameList = fileNameList .. " " ..filecfg.name
930 | table.insert(fileNameList, escapeArg(node.name))
931 | end
932 |
933 | --ms new way
934 | -- if the file is not in this config file list excluded it from build !!!
935 | --if not cfg.files[node.abspath] then
936 | -- table.insert(fileNameList, escapeArg(node.name))
937 | --end
938 | end
939 | end
940 | })
941 |
942 | if not table.isempty(fileNameList) then
943 | settings['EXCLUDED_SOURCE_FILE_NAMES'] = fileNameList
944 | end
945 | settings['PRODUCT_NAME'] = cfg.buildtarget.basename
946 |
947 | --ms not by default ...add it manually if you need it
948 | --settings['COMBINE_HIDPI_IMAGES'] = 'YES'
949 |
950 | overrideSettings(settings, cfg.xcodebuildsettings)
951 |
952 | _p(2,'%s /* %s */ = {', cfg.xcode.targetid, cfg.buildcfg)
953 | _p(3,'isa = XCBuildConfiguration;')
954 | _p(3,'buildSettings = {')
955 | printSettingsTable(4, settings)
956 | _p(3,'};')
957 | printSetting(3, 'name', cfg.buildcfg);
958 | _p(2,'};')
959 | end
960 |
961 |
962 | function xcode.XCBuildConfiguration_Project(tr, cfg)
963 | local settings = {}
964 |
965 | local archs = {
966 | Native = "$(NATIVE_ARCH_ACTUAL)",
967 | x86 = "i386",
968 | x86_64 = "x86_64",
969 | Universal32 = "$(ARCHS_STANDARD_32_BIT)",
970 | Universal64 = "$(ARCHS_STANDARD_64_BIT)",
971 | Universal = "$(ARCHS_STANDARD_32_64_BIT)",
972 | }
973 |
974 | settings['ARCHS'] = archs[cfg.platform or "Native"]
975 |
976 | --ms This is the default so don;t write it
977 | --settings['SDKROOT'] = 'macosx'
978 |
979 | local targetdir = path.getdirectory(cfg.buildtarget.relpath)
980 | if targetdir ~= "." then
981 | settings['CONFIGURATION_BUILD_DIR'] = '$(SYMROOT)'
982 | end
983 |
984 | settings['CONFIGURATION_TEMP_DIR'] = '$(OBJROOT)'
985 |
986 | if config.isDebugBuild(cfg) then
987 | settings['COPY_PHASE_STRIP'] = 'NO'
988 | end
989 |
990 | settings['GCC_C_LANGUAGE_STANDARD'] = 'gnu99'
991 |
992 | if cfg.flags['C++14'] then
993 | settings['CLANG_CXX_LANGUAGE_STANDARD'] = 'c++14'
994 | elseif cfg.flags['C++11'] then
995 | settings['CLANG_CXX_LANGUAGE_STANDARD'] = 'c++0x'
996 | end
997 |
998 | if cfg.exceptionhandling == p.OFF then
999 | settings['GCC_ENABLE_CPP_EXCEPTIONS'] = 'NO'
1000 | end
1001 |
1002 | if cfg.rtti == p.OFF then
1003 | settings['GCC_ENABLE_CPP_RTTI'] = 'NO'
1004 | end
1005 |
1006 | if cfg.symbols == p.ON and not cfg.flags.NoEditAndContinue then
1007 | settings['GCC_ENABLE_FIX_AND_CONTINUE'] = 'YES'
1008 | end
1009 |
1010 | if cfg.exceptionhandling == p.OFF then
1011 | settings['GCC_ENABLE_OBJC_EXCEPTIONS'] = 'NO'
1012 | end
1013 |
1014 | local optimizeMap = { On = 3, Size = 's', Speed = 3, Full = 'fast', Debug = 1 }
1015 | settings['GCC_OPTIMIZATION_LEVEL'] = optimizeMap[cfg.optimize] or 0
1016 |
1017 | if cfg.pchheader and not cfg.flags.NoPCH then
1018 | settings['GCC_PRECOMPILE_PREFIX_HEADER'] = 'YES'
1019 | settings['GCC_PREFIX_HEADER'] = cfg.pchheader
1020 | end
1021 |
1022 | settings['GCC_PREPROCESSOR_DEFINITIONS'] = cfg.defines
1023 |
1024 | settings["GCC_SYMBOLS_PRIVATE_EXTERN"] = 'NO'
1025 |
1026 | if cfg.flags.FatalWarnings then
1027 | settings['GCC_TREAT_WARNINGS_AS_ERRORS'] = 'YES'
1028 | end
1029 |
1030 | settings['GCC_WARN_ABOUT_RETURN_TYPE'] = 'YES'
1031 | settings['GCC_WARN_UNUSED_VARIABLE'] = 'YES'
1032 |
1033 | local includedirs = project.getrelative(cfg.project, cfg.includedirs)
1034 | for i,v in ipairs(includedirs) do
1035 | cfg.includedirs[i] = premake.quoted(v)
1036 | end
1037 | settings['USER_HEADER_SEARCH_PATHS'] = cfg.includedirs
1038 |
1039 | local sysincludedirs = project.getrelative(cfg.project, cfg.sysincludedirs)
1040 | for i,v in ipairs(sysincludedirs) do
1041 | cfg.sysincludedirs[i] = premake.quoted(v)
1042 | end
1043 | if not table.isempty(cfg.sysincludedirs) then
1044 | table.insert(cfg.sysincludedirs, "$(inherited)")
1045 | end
1046 | settings['HEADER_SEARCH_PATHS'] = cfg.sysincludedirs
1047 |
1048 | for i,v in ipairs(cfg.libdirs) do
1049 | cfg.libdirs[i] = premake.project.getrelative(cfg.project, cfg.libdirs[i])
1050 | end
1051 | settings['LIBRARY_SEARCH_PATHS'] = cfg.libdirs
1052 |
1053 | for i,v in ipairs(cfg.frameworkdirs) do
1054 | cfg.frameworkdirs[i] = premake.project.getrelative(cfg.project, cfg.frameworkdirs[i])
1055 | end
1056 | settings['FRAMEWORK_SEARCH_PATHS'] = cfg.frameworkdirs
1057 |
1058 | local objDir = path.getrelative(tr.project.location, cfg.objdir)
1059 | settings['OBJROOT'] = objDir
1060 |
1061 | settings['ONLY_ACTIVE_ARCH'] = iif(premake.config.isDebugBuild(cfg), 'YES', 'NO')
1062 |
1063 | -- build list of "other" C/C++ flags
1064 | local checks = {
1065 | ["-ffast-math"] = cfg.flags.FloatFast,
1066 | ["-ffloat-store"] = cfg.flags.FloatStrict,
1067 | ["-fomit-frame-pointer"] = cfg.flags.NoFramePointer,
1068 | }
1069 |
1070 | local flags = { }
1071 | for flag, check in pairs(checks) do
1072 | if check then
1073 | table.insert(flags, flag)
1074 | end
1075 | end
1076 |
1077 |
1078 | --[[if (type(cfg.buildoptions) == "table") then
1079 | for k,v in pairs(cfg.buildoptions) do
1080 | table.insertflat(flags, string.explode(v," -"))
1081 | end
1082 | end
1083 | ]]
1084 |
1085 | settings['OTHER_CFLAGS'] = table.join(flags, cfg.buildoptions)
1086 |
1087 | -- build list of "other" linked flags. All libraries that aren't frameworks
1088 | -- are listed here, so I don't have to try and figure out if they are ".a"
1089 | -- or ".dylib", which Xcode requires to list in the Frameworks section
1090 | flags = { }
1091 | for _, lib in ipairs(config.getlinks(cfg, "system")) do
1092 | if not xcode.isframework(lib) then
1093 | table.insert(flags, "-l" .. lib)
1094 | end
1095 | end
1096 |
1097 | --ms this step is for reference projects only
1098 | for _, lib in ipairs(config.getlinks(cfg, "dependencies", "object")) do
1099 | if (lib.external) then
1100 | if not xcode.isframework(lib.linktarget.basename) then
1101 | table.insert(flags, "-l" .. escapeArg(lib.linktarget.basename))
1102 | end
1103 | end
1104 | end
1105 |
1106 | settings['OTHER_LDFLAGS'] = table.join(flags, cfg.linkoptions)
1107 |
1108 | if cfg.flags.StaticRuntime then
1109 | settings['STANDARD_C_PLUS_PLUS_LIBRARY_TYPE'] = 'static'
1110 | end
1111 |
1112 | if targetdir ~= "." then
1113 | settings['SYMROOT'] = path.getrelative(tr.project.location, targetdir)
1114 | end
1115 |
1116 | if cfg.warnings == "Extra" then
1117 | settings['WARNING_CFLAGS'] = '-Wall -Wextra'
1118 | end
1119 |
1120 | overrideSettings(settings, cfg.xcodebuildsettings)
1121 |
1122 | _p(2,'%s /* %s */ = {', cfg.xcode.projectid, cfg.buildcfg)
1123 | _p(3,'isa = XCBuildConfiguration;')
1124 | _p(3,'buildSettings = {')
1125 | printSettingsTable(4, settings)
1126 | _p(3,'};')
1127 | printSetting(3, 'name', cfg.buildcfg);
1128 | _p(2,'};')
1129 | end
1130 |
1131 |
1132 | function xcode.XCBuildConfiguration(tr)
1133 | local settings = {}
1134 |
1135 | for _, target in ipairs(tr.products.children) do
1136 | for _, cfg in ipairs(tr.configs) do
1137 | settings[cfg.xcode.targetid] = function()
1138 | xcode.XCBuildConfiguration_Target(tr, target, cfg)
1139 | end
1140 | end
1141 | end
1142 | for _, cfg in ipairs(tr.configs) do
1143 | settings[cfg.xcode.projectid] = function()
1144 | xcode.XCBuildConfiguration_Project(tr, cfg)
1145 | end
1146 | end
1147 |
1148 | if not table.isempty(settings) then
1149 | _p('/* Begin XCBuildConfiguration section */')
1150 | printSettingsTable(0, settings)
1151 | _p('/* End XCBuildConfiguration section */')
1152 | _p('')
1153 | end
1154 | end
1155 |
1156 |
1157 | function xcode.XCBuildConfigurationList(tr)
1158 | local wks = tr.project.workspace
1159 | local defaultCfgName = stringifySetting(tr.configs[1].buildcfg)
1160 | local settings = {}
1161 |
1162 | for _, target in ipairs(tr.products.children) do
1163 | settings[target.cfgsection] = function()
1164 | _p(2,'%s /* Build configuration list for PBXNativeTarget "%s" */ = {', target.cfgsection, target.name)
1165 | _p(3,'isa = XCConfigurationList;')
1166 | _p(3,'buildConfigurations = (')
1167 | for _, cfg in ipairs(tr.configs) do
1168 | _p(4,'%s /* %s */,', cfg.xcode.targetid, cfg.buildcfg)
1169 | end
1170 | _p(3,');')
1171 | _p(3,'defaultConfigurationIsVisible = 0;')
1172 | _p(3,'defaultConfigurationName = %s;', defaultCfgName)
1173 | _p(2,'};')
1174 | end
1175 | end
1176 | settings['1DEB928908733DD80010E9CD'] = function()
1177 | _p(2,'1DEB928908733DD80010E9CD /* Build configuration list for PBXProject "%s" */ = {', tr.name)
1178 | _p(3,'isa = XCConfigurationList;')
1179 | _p(3,'buildConfigurations = (')
1180 | for _, cfg in ipairs(tr.configs) do
1181 | _p(4,'%s /* %s */,', cfg.xcode.projectid, cfg.buildcfg)
1182 | end
1183 | _p(3,');')
1184 | _p(3,'defaultConfigurationIsVisible = 0;')
1185 | _p(3,'defaultConfigurationName = %s;', defaultCfgName)
1186 | _p(2,'};')
1187 | end
1188 |
1189 | _p('/* Begin XCConfigurationList section */')
1190 | printSettingsTable(2, settings)
1191 | _p('/* End XCConfigurationList section */')
1192 | end
1193 |
--------------------------------------------------------------------------------
/xcode_project.lua:
--------------------------------------------------------------------------------
1 | ---
2 | -- xcode/xcode4_project.lua
3 | -- Generate an Xcode project file.
4 | -- Author Jason Perkins
5 | -- Modified by Mihai Sebea
6 | -- Copyright (c) 2009-2015 Jason Perkins and the Premake project
7 | ---
8 |
9 | local p = premake
10 | local m = p.modules.xcode
11 |
12 | local xcode = p.modules.xcode
13 | local project = p.project
14 | local config = p.config
15 | local fileconfig = p.fileconfig
16 | local tree = p.tree
17 |
18 | --
19 | -- Create a tree corresponding to what is shown in the Xcode project browser
20 | -- pane, with nodes for files and folders, resources, frameworks, and products.
21 | --
22 | -- @param prj
23 | -- The project being generated.
24 | -- @returns
25 | -- A tree, loaded with metadata, which mirrors Xcode's view of the project.
26 | --
27 |
28 | function xcode.buildprjtree(prj)
29 | local tr = project.getsourcetree(prj, nil , false)
30 | tr.project = prj
31 |
32 | -- create a list of build configurations and assign IDs
33 | tr.configs = {}
34 |
35 | for cfg in project.eachconfig(prj) do
36 | cfg.xcode = {}
37 | cfg.xcode.targetid = xcode.newid(prj.xcode.projectnode.name, cfg.buildcfg, "target")
38 | cfg.xcode.projectid = xcode.newid(tr.name, cfg.buildcfg)
39 | table.insert(tr.configs, cfg)
40 | end
41 |
42 | -- convert localized resources from their filesystem layout (English.lproj/MainMenu.xib)
43 | -- to Xcode's display layout (MainMenu.xib/English).
44 | tree.traverse(tr, {
45 | onbranch = function(node)
46 | if path.getextension(node.name) == ".lproj" then
47 | local lang = path.getbasename(node.name) -- "English", "French", etc.
48 |
49 | -- create a new language group for each file it contains
50 | for _, filenode in ipairs(node.children) do
51 | local grpnode = node.parent.children[filenode.name]
52 | if not grpnode then
53 | grpnode = tree.insert(node.parent, tree.new(filenode.name))
54 | grpnode.kind = "vgroup"
55 | end
56 |
57 | -- convert the file node to a language node and add to the group
58 | filenode.name = path.getbasename(lang)
59 | tree.insert(grpnode, filenode)
60 | end
61 |
62 | -- remove this directory from the tree
63 | tree.remove(node)
64 | end
65 | end
66 | })
67 |
68 | -- the special folder "Frameworks" lists all linked frameworks
69 | tr.frameworks = tree.new("Frameworks")
70 | for cfg in project.eachconfig(prj) do
71 | for _, link in ipairs(config.getlinks(cfg, "system", "fullpath")) do
72 | local name = path.getname(link)
73 | if xcode.isframework(name) and not tr.frameworks.children[name] then
74 | node = tree.insert(tr.frameworks, tree.new(name))
75 | node.path = link
76 | end
77 | end
78 | end
79 |
80 | -- only add it to the tree if there are frameworks to link
81 | if #tr.frameworks.children > 0 then
82 | tree.insert(tr, tr.frameworks)
83 | end
84 |
85 | -- the special folder "Products" holds the target produced by the project; this
86 | -- is populated below
87 | tr.products = tree.insert(tr, tree.new("Products"))
88 |
89 | -- the special folder "Projects" lists sibling project dependencies
90 | tr.projects = tree.new("Projects")
91 | for _, dep in ipairs(project.getdependencies(prj, "sibling", "object")) do
92 | -- create a child node for the dependency's xcodeproj
93 | local xcpath = xcode.getxcodeprojname(dep)
94 | local xcnode = tree.insert(tr.projects, tree.new(path.getname(xcpath)))
95 | xcnode.path = xcpath
96 | xcnode.project = dep
97 | xcnode.productgroupid = xcode.newid(xcnode.name, "prodgrp")
98 | xcnode.productproxyid = xcode.newid(xcnode.name, "prodprox")
99 | xcnode.targetproxyid = xcode.newid(xcnode.name, "targprox")
100 | xcnode.targetdependid = xcode.newid(xcnode.name, "targdep")
101 |
102 | -- create a grandchild node for the dependency's link target
103 | local lprj = premake.workspace.findproject(prj.workspace, dep.name)
104 | local cfg = project.findClosestMatch(lprj, prj.configurations[1])
105 | node = tree.insert(xcnode, tree.new(cfg.linktarget.name))
106 | node.path = cfg.linktarget.fullpath
107 | node.cfg = cfg
108 | end
109 |
110 | if #tr.projects.children > 0 then
111 | tree.insert(tr, tr.projects)
112 | end
113 |
114 | -- Final setup
115 | tree.traverse(tr, {
116 | onnode = function(node)
117 | -- assign IDs to every node in the tree
118 | node.id = xcode.newid(node.name, nil, node.path)
119 |
120 | node.isResource = xcode.isItemResource(prj, node)
121 |
122 | -- assign build IDs to buildable files
123 | if xcode.getbuildcategory(node) then
124 | node.buildid = xcode.newid(node.name, "build", node.path)
125 | end
126 |
127 | -- remember key files that are needed elsewhere
128 | if string.endswith(node.name, "Info.plist") then
129 | tr.infoplist = node
130 | end
131 | end
132 | }, true)
133 |
134 | -- Plug in the product node into the Products folder in the tree. The node
135 | -- was built in xcode.prepareWorkspace() in xcode_common.lua; it contains IDs
136 | -- that are necessary for inter-project dependencies
137 | node = tree.insert(tr.products, prj.xcode.projectnode)
138 | node.kind = "product"
139 | node.path = node.cfg.buildtarget.fullpath
140 | node.cfgsection = xcode.newid(node.name, "cfg")
141 | node.resstageid = xcode.newid(node.name, "rez")
142 | node.sourcesid = xcode.newid(node.name, "src")
143 | node.fxstageid = xcode.newid(node.name, "fxs")
144 |
145 | return tr
146 | end
147 |
148 |
149 | ---
150 | -- Generate an Xcode .xcodeproj for a Premake project.
151 | ---
152 |
153 | m.elements.project = function(prj)
154 | return {
155 | m.header,
156 | }
157 | end
158 |
159 | function m.generateProject(prj)
160 | local tr = xcode.buildprjtree(prj)
161 | p.callArray(m.elements.project, prj)
162 | xcode.PBXBuildFile(tr)
163 | xcode.PBXContainerItemProxy(tr)
164 | xcode.PBXFileReference(tr)
165 | xcode.PBXFrameworksBuildPhase(tr)
166 | xcode.PBXGroup(tr)
167 | xcode.PBXNativeTarget(tr)
168 | xcode.PBXProject(tr)
169 | xcode.PBXReferenceProxy(tr)
170 | xcode.PBXResourcesBuildPhase(tr)
171 | xcode.PBXShellScriptBuildPhase(tr)
172 | xcode.PBXSourcesBuildPhase(tr)
173 | xcode.PBXTargetDependency(tr)
174 | xcode.PBXVariantGroup(tr)
175 | xcode.XCBuildConfiguration(tr)
176 | xcode.XCBuildConfigurationList(tr)
177 | xcode.footer(prj)
178 | end
179 |
180 |
181 |
182 | function m.header(prj)
183 | p.w('// !$*UTF8*$!')
184 | p.push('{')
185 | p.w('archiveVersion = 1;')
186 | p.w('classes = {')
187 | p.w('};')
188 | p.w('objectVersion = 46;')
189 | p.push('objects = {')
190 | p.w()
191 | end
192 |
193 |
194 |
195 | function xcode.footer(prj)
196 | p.pop('};')
197 | p.w('rootObject = 08FB7793FE84155DC02AAC07 /* Project object */;')
198 | p.pop('}')
199 | end
200 |
201 |
--------------------------------------------------------------------------------