diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2021-04-04 19:26:54 +0300 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2021-04-04 19:26:54 +0300 |
commit | bf08bba3718e8109da2ea6d235976f53c5aa8a3e (patch) | |
tree | c7d6417ed3246f97dd37b6924636295568db83ce | |
parent | c43007408c653e4477c9d261aa0e5d048c168569 (diff) | |
download | meson-bf08bba3718e8109da2ea6d235976f53c5aa8a3e.zip meson-bf08bba3718e8109da2ea6d235976f53c5aa8a3e.tar.gz meson-bf08bba3718e8109da2ea6d235976f53c5aa8a3e.tar.bz2 |
Delete old implementation.
-rw-r--r-- | mesonbuild/backend/xcodebackend.py | 545 |
1 files changed, 47 insertions, 498 deletions
diff --git a/mesonbuild/backend/xcodebackend.py b/mesonbuild/backend/xcodebackend.py index 91fd0a0..b189429 100644 --- a/mesonbuild/backend/xcodebackend.py +++ b/mesonbuild/backend/xcodebackend.py @@ -145,8 +145,6 @@ class XCodeBackend(backends.Backend): self.name = 'xcode' self.project_uid = self.environment.coredata.lang_guids['default'].replace('-', '')[:24] self.project_conflist = self.gen_id() - self.indent = '\t' # Recent versions of Xcode uses tabs - self.indent_level = 0 self.xcodetypemap = {'c': 'sourcecode.c.c', 'a': 'archive.ar', 'cc': 'sourcecode.cpp.cpp', @@ -178,8 +176,7 @@ class XCodeBackend(backends.Backend): with open(ofilename, 'w') as ofile: ofile.write('// !$*UTF8*$!\n') top_level_dict.write(ofile, 0) - assert(self.indent_level == 0) - + def gen_id(self): return str(uuid.uuid4()).upper().replace('-', '')[:24] @@ -194,11 +191,6 @@ class XCodeBackend(backends.Backend): directories = os.path.normpath(self.get_target_dir(target)).split(os.sep) return os.sep.join(['..'] * len(directories)) - def write_line(self, text): - self.ofile.write(self.indent * self.indent_level + text) - if not text.endswith('\n'): - self.ofile.write('\n') - def generate(self): test_data = self.serialize_tests()[0] self.generate_filemap() @@ -219,52 +211,51 @@ class XCodeBackend(backends.Backend): self.proj_dir = os.path.join(self.environment.get_build_dir(), self.build.project_name + '.xcodeproj') os.makedirs(self.proj_dir, exist_ok=True) self.proj_file = os.path.join(self.proj_dir, 'project.pbxproj') - with open(self.proj_file, 'w') as self.ofile: - objects_dict = self.generate_prefix(self.top_level_dict) - objects_dict.add_comment(PbxComment('Begin PBXAggregateTarget section')) - self.generate_pbx_aggregate_target(objects_dict) - objects_dict.add_comment(PbxComment('End PBXAggregateTarget section')) - objects_dict.add_comment(PbxComment('Begin PBXBuildFile section')) - self.generate_pbx_build_file(objects_dict) - objects_dict.add_comment(PbxComment('End PBXBuildFile section')) - objects_dict.add_comment(PbxComment('Begin PBXBuildStyle section')) - self.generate_pbx_build_style(objects_dict) - objects_dict.add_comment(PbxComment('End PBXBuildStyle section')) - objects_dict.add_comment(PbxComment('Begin PBXContainerItemProxy section')) - self.generate_pbx_container_item_proxy(objects_dict) - objects_dict.add_comment(PbxComment('End PBXContainerItemProxy section')) - objects_dict.add_comment(PbxComment('Begin PBXFileReference section')) - self.generate_pbx_file_reference(objects_dict) - objects_dict.add_comment(PbxComment('End PBXFileReference section')) - objects_dict.add_comment(PbxComment('Begin PBXFrameworksBuildPhase section')) - self.generate_pbx_frameworks_buildphase(objects_dict) - objects_dict.add_comment(PbxComment('End PBXFrameworksBuildPhase section')) - objects_dict.add_comment(PbxComment('Begin PBXGroup section')) - self.generate_pbx_group(objects_dict) - objects_dict.add_comment(PbxComment('End PBXGroup section')) - objects_dict.add_comment(PbxComment('Begin PBXNativeTarget section')) - self.generate_pbx_native_target(objects_dict) - objects_dict.add_comment(PbxComment('End PBXNativeTarget section')) - objects_dict.add_comment(PbxComment('Begin PBXProject section')) - self.generate_pbx_project(objects_dict) - objects_dict.add_comment(PbxComment('End PBXProject section')) - objects_dict.add_comment(PbxComment('Begin PBXShellScriptBuildPhase section')) - self.generate_pbx_shell_build_phase(objects_dict, test_data) - objects_dict.add_comment(PbxComment('End PBXShellScriptBuildPhase section')) - objects_dict.add_comment(PbxComment('Begin PBXSourcesBuildPhase section')) - self.generate_pbx_sources_build_phase(objects_dict) - objects_dict.add_comment(PbxComment('End PBXSourcesBuildPhase section')) - objects_dict.add_comment(PbxComment('Begin PBXTargetDependency section')) - self.generate_pbx_target_dependency(objects_dict) - objects_dict.add_comment(PbxComment('End PBXTargetDependency section')) - objects_dict.add_comment(PbxComment('Begin XCBuildConfiguration section')) - self.generate_xc_build_configuration(objects_dict) - objects_dict.add_comment(PbxComment('End XCBuildConfiguration section')) - objects_dict.add_comment(PbxComment('Begin XCConfigurationList section')) - self.generate_xc_configurationList(objects_dict) - objects_dict.add_comment(PbxComment('End XCConfigurationList section')) - self.generate_suffix(self.top_level_dict) - self.write_pbxfile(self.top_level_dict, "temporary.pbxproj") + objects_dict = self.generate_prefix(self.top_level_dict) + objects_dict.add_comment(PbxComment('Begin PBXAggregateTarget section')) + self.generate_pbx_aggregate_target(objects_dict) + objects_dict.add_comment(PbxComment('End PBXAggregateTarget section')) + objects_dict.add_comment(PbxComment('Begin PBXBuildFile section')) + self.generate_pbx_build_file(objects_dict) + objects_dict.add_comment(PbxComment('End PBXBuildFile section')) + objects_dict.add_comment(PbxComment('Begin PBXBuildStyle section')) + self.generate_pbx_build_style(objects_dict) + objects_dict.add_comment(PbxComment('End PBXBuildStyle section')) + objects_dict.add_comment(PbxComment('Begin PBXContainerItemProxy section')) + self.generate_pbx_container_item_proxy(objects_dict) + objects_dict.add_comment(PbxComment('End PBXContainerItemProxy section')) + objects_dict.add_comment(PbxComment('Begin PBXFileReference section')) + self.generate_pbx_file_reference(objects_dict) + objects_dict.add_comment(PbxComment('End PBXFileReference section')) + objects_dict.add_comment(PbxComment('Begin PBXFrameworksBuildPhase section')) + self.generate_pbx_frameworks_buildphase(objects_dict) + objects_dict.add_comment(PbxComment('End PBXFrameworksBuildPhase section')) + objects_dict.add_comment(PbxComment('Begin PBXGroup section')) + self.generate_pbx_group(objects_dict) + objects_dict.add_comment(PbxComment('End PBXGroup section')) + objects_dict.add_comment(PbxComment('Begin PBXNativeTarget section')) + self.generate_pbx_native_target(objects_dict) + objects_dict.add_comment(PbxComment('End PBXNativeTarget section')) + objects_dict.add_comment(PbxComment('Begin PBXProject section')) + self.generate_pbx_project(objects_dict) + objects_dict.add_comment(PbxComment('End PBXProject section')) + objects_dict.add_comment(PbxComment('Begin PBXShellScriptBuildPhase section')) + self.generate_pbx_shell_build_phase(objects_dict, test_data) + objects_dict.add_comment(PbxComment('End PBXShellScriptBuildPhase section')) + objects_dict.add_comment(PbxComment('Begin PBXSourcesBuildPhase section')) + self.generate_pbx_sources_build_phase(objects_dict) + objects_dict.add_comment(PbxComment('End PBXSourcesBuildPhase section')) + objects_dict.add_comment(PbxComment('Begin PBXTargetDependency section')) + self.generate_pbx_target_dependency(objects_dict) + objects_dict.add_comment(PbxComment('End PBXTargetDependency section')) + objects_dict.add_comment(PbxComment('Begin XCBuildConfiguration section')) + self.generate_xc_build_configuration(objects_dict) + objects_dict.add_comment(PbxComment('End XCBuildConfiguration section')) + objects_dict.add_comment(PbxComment('Begin XCConfigurationList section')) + self.generate_xc_configurationList(objects_dict) + objects_dict.add_comment(PbxComment('End XCConfigurationList section')) + self.generate_suffix(self.top_level_dict) + self.write_pbxfile(self.top_level_dict, self.proj_file) def get_xcodetype(self, fname): xcodetype = self.xcodetypemap.get(fname.split('.')[-1].lower()) @@ -374,59 +365,33 @@ class XCodeBackend(backends.Backend): aggregated_targets.append((self.test_id, 'RUN_TESTS', self.test_buildconf_id, [self.test_command_id], [])) # Sort objects by ID before writing sorted_aggregated_targets = sorted(aggregated_targets, key=operator.itemgetter(0)) - self.ofile.write('\n/* Begin PBXAggregateTarget section */\n') for t in sorted_aggregated_targets: agt_dict = PbxDict() name = t[1] buildconf_id = t[2] build_phases = t[3] dependencies = t[4] - self.write_line('{} /* {} */ = {{'.format(t[0], name)) - self.indent_level += 1 - self.write_line('isa = PBXAggregateTarget;') agt_dict.add_item('isa', 'PBXAggregateTarget') - self.write_line(f'buildConfigurationList = {buildconf_id} /* Build configuration list for PBXAggregateTarget "{name}" */;') agt_dict.add_item('buildConfigurationList', buildconf_id, f'Build configuration list for PBXAggregateTarget "{name}"') - self.write_line('buildPhases = (') bp_arr = PbxArray() agt_dict.add_item('buildPhases', bp_arr) - self.indent_level += 1 for bp in build_phases: - self.write_line('%s /* ShellScript */,' % bp) bp_arr.add_item(bp, 'ShellScript') - self.indent_level -= 1 - self.write_line(');') - self.write_line('dependencies = (') dep_arr = PbxArray() agt_dict.add_item('dependencies', dep_arr) - self.indent_level += 1 for td in dependencies: - self.write_line('%s /* PBXTargetDependency */,' % td) dep_arr.add_item(td, 'PBXTargetDependency') - self.indent_level -= 1 - self.write_line(');') - self.write_line('name = %s;' % name) agt_dict.add_item('name', name) - self.write_line('productName = %s;' % name) agt_dict.add_item('productName', name) - self.indent_level -= 1 - self.write_line('};') objects_dict.add_item(t[0], agt_dict, name) - self.ofile.write('/* End PBXAggregateTarget section */\n') def generate_pbx_build_file(self, objects_dict): - self.ofile.write('\n/* Begin PBXBuildFile section */\n') - templ = '%s /* %s */ = { isa = PBXBuildFile; fileRef = %s /* %s */; settings = { COMPILER_FLAGS = "%s"; }; };\n' - otempl = '%s /* %s */ = { isa = PBXBuildFile; fileRef = %s /* %s */;};\n' - ftempl = '{} /* {}.framework in Frameworks */ = {{isa = PBXBuildFile; fileRef = {} /* {}.framework */; }};\n' - for t in self.build.get_build_targets().values(): for dep in t.get_external_deps(): if isinstance(dep, dependencies.AppleFrameworks): for f in dep.frameworks: fw_dict = PbxDict() objects_dict.add:item(self.native_frameworks[f], fw_dict, f'{f}.framework in Frameworks') - self.write_line(ftempl.format(self.native_frameworks[f], f, self.native_frameworks_fileref[f], f)) fw_dict.add_item('isa', 'PBXBuildFile') fw_dict.add_item('fileRef', self.native_frameworks_fileref[f], f) @@ -443,7 +408,6 @@ class XCodeBackend(backends.Backend): fileref = self.filemap[s] fullpath2 = fullpath compiler_args = '' - self.write_line(templ % (idval, fullpath, fileref, fullpath2, compiler_args)) sdict.add_item('isa', 'PBXBuildFile') sdict.add_item('fileRef', fileref, fullpath2) settingdict = PbxDict() @@ -459,58 +423,31 @@ class XCodeBackend(backends.Backend): fullpath2 = fullpath o_dict = PbxDict() objects_dict.add_item(idval, o_dict, fullpath) - self.write_line(otempl % (idval, fullpath, fileref, fullpath2)) o_dict.add_item('isa', 'PBXBuildFile') o_dict.add_item('fileRef', fileref, fullpath2) - self.ofile.write('/* End PBXBuildFile section */\n') def generate_pbx_build_style(self, objects_dict): # FIXME: Xcode 9 and later does not uses PBXBuildStyle and it gets removed. Maybe we can remove this part. - self.ofile.write('\n/* Begin PBXBuildStyle section */\n') for name, idval in self.buildstylemap.items(): styledict = PbxDict() - self.write_line(f'{idval} /* {name} */ = {{\n') objects_dict.add_item(idval, styledict, name) - self.indent_level += 1 - self.write_line('isa = PBXBuildStyle;\n') styledict.add_item('isa', 'PBXBuildStyle') settings_dict = PbxDict() - self.write_line('buildSettings = {\n') styledict.add_item('buildSettings', settings_dict) - self.indent_level += 1 - self.write_line('COPY_PHASE_STRIP = NO;\n') settings_dict.add_item('COPY_PHASE_STRIP', 'NO') - self.indent_level -= 1 - self.write_line('};\n') - self.write_line('name = "%s";\n' % name) styledict.add_item('name', f'"{name}"') - self.indent_level -= 1 - self.write_line('};\n') - self.ofile.write('/* End PBXBuildStyle section */\n') def generate_pbx_container_item_proxy(self, objects_dict): - self.ofile.write('\n/* Begin PBXContainerItemProxy section */\n') for t in self.build.get_build_targets(): proxy_dict = PbxDict() - self.write_line('%s /* PBXContainerItemProxy */ = {' % self.containerproxy_map[t]) objects_dict.add_item(self.containerproxy_map[t], proxy_dict, 'PBXContainerItemProxy') - self.indent_level += 1 - self.write_line('isa = PBXContainerItemProxy;') proxy_dict.add_item('isa', 'PBXContainerItemProxy') - self.write_line('containerPortal = %s /* Project object */;' % self.project_uid) proxy_dict.add_item('containerPortal', self.project_uid, 'Project object') - self.write_line('proxyType = 1;') proxy_dict.add_item('proxyType', '1') - self.write_line('remoteGlobalIDString = %s;' % self.native_targets[t]) proxy_dict.add_item('remoteGlobalIDString', self.native_targets[t]) - self.write_line('remoteInfo = "%s";' % t) proxy_dict.add_item('remoteInfo', '"' + t + '"') - self.indent_level -= 1 - self.write_line('};') - self.ofile.write('/* End PBXContainerItemProxy section */\n') def generate_pbx_file_reference(self, objects_dict): - self.ofile.write('\n/* Begin PBXFileReference section */\n') for t in self.build.get_build_targets().values(): for dep in t.get_external_deps(): if isinstance(dep, dependencies.AppleFrameworks): @@ -518,7 +455,6 @@ class XCodeBackend(backends.Backend): # FIXME not ported fw_dict = PbxDict() objects_dict.add_item(self.native_frameworks_fileref[f], fw_dict, f) - self.write_line('{} /* {}.framework */ = {{isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = {}.framework; path = System/Library/Frameworks/{}.framework; sourceTree = SDKROOT; }};\n'.format(self.native_frameworks_fileref[f], f, f, f)) fw_dict.add_item('isa', 'PBXFileReference') fw_dict.add_item('lastKnownFileType', 'wrapper.framework') fw_dict.add_item('name', f'{f}.framework') @@ -532,7 +468,6 @@ class XCodeBackend(backends.Backend): name = os.path.basename(fname) path = fname objects_dict.add_item(idval, src_dict, fullpath) - self.write_line(src_templ % (idval, fullpath, xcodetype, name, path)) src_dict.add_item('isa', 'PBXFileReference') src_dict.add_item('explicitFileType', '"' + xcodetype + '"') src_dict.add_item('fileEncoding', '4') @@ -555,41 +490,25 @@ class XCodeBackend(backends.Backend): else: typestr = self.get_xcodetype(fname) path = '"%s"' % t.get_filename() - self.write_line(target_templ % (idval, tname, typestr, path, reftype)) target_dict.add_item('isa', 'PBXFileReference') target_dict.add_item('explicitFileType', '"' + typestr + '"') target_dict.add_item('path', path) target_dict.add_item('refType', reftype) target_dict.add_item('sourceTree', 'BUILT_PRODUCTS_DIR') - self.ofile.write('/* End PBXFileReference section */\n') def generate_pbx_frameworks_buildphase(self, objects_dict): for t in self.build.get_build_targets().values(): bt_dict = PbxDict() - self.ofile.write('\n/* Begin PBXFrameworksBuildPhase section */\n') - self.write_line('{} /* {} */ = {{\n'.format(t.buildphasemap['Frameworks'], 'Frameworks')) objects_dict.add_item(t.buildphasemap['Frameworks'], bt_dict, 'Frameworks') - self.indent_level += 1 - self.write_line('isa = PBXFrameworksBuildPhase;\n') bt_dict.add_item('isa', 'PBXFrameworksBuildPhase') - self.write_line('buildActionMask = %s;\n' % (2147483647)) bt_dict.add_item('buildActionMask', 2147483647) - self.write_line('files = (\n') file_list = PbxArray() bt_dict.add_item('files', file_list) - self.indent_level += 1 for dep in t.get_external_deps(): if isinstance(dep, dependencies.AppleFrameworks): for f in dep.frameworks: - self.write_line('{} /* {}.framework in Frameworks */,\n'.format(self.native_frameworks[f], f)) file_list.add_item(self.native_frameworks[f], f'{f}.framework in Frameworks') - self.indent_level -= 1 - self.write_line(');\n') - self.write_line('runOnlyForDeploymentPostprocessing = 0;\n') bt_dict.add_item('runOnlyForDeploymentPostprocessing', 0) - self.indent_level -= 1 - self.write_line('};\n') - self.ofile.write('/* End PBXFrameworksBuildPhase section */\n') def generate_pbx_group(self, objects_dict): groupmap = {} @@ -597,221 +516,114 @@ class XCodeBackend(backends.Backend): for t in self.build.get_build_targets(): groupmap[t] = self.gen_id() target_src_map[t] = self.gen_id() - self.ofile.write('\n/* Begin PBXGroup section */\n') sources_id = self.gen_id() resources_id = self.gen_id() products_id = self.gen_id() frameworks_id = self.gen_id() - self.write_line('%s = {' % self.maingroup_id) main_dict = PbxDict() objects_dict.add_item(self.maingroup_id, main_dict) - self.indent_level += 1 - self.write_line('isa = PBXGroup;') main_dict.add_item('isa', 'PBXGroup') main_children = PbxArray() - self.write_line('children = (') main_dict.add_item('children', main_children) - self.indent_level += 1 - self.write_line('%s /* Sources */,' % sources_id) main_children.add_item(sources_id, 'Sources') - self.write_line('%s /* Resources */,' % resources_id) main_children.add_item(resources_id, 'Resources') - self.write_line('%s /* Products */,' % products_id) main_children.add_item(products_id, 'Products') - self.write_line('%s /* Frameworks */,' % frameworks_id) main_children.add_item(frameworks_id, 'Frameworks') - self.indent_level -= 1 - self.write_line(');') - self.write_line('sourceTree = "<group>";') main_dict.add_item('sourceTree', '"<group>"') - self.indent_level -= 1 - self.write_line('};') # Sources source_dict = PbxDict() - self.write_line('%s /* Sources */ = {' % sources_id) objects_dict.add_item(sources_id, source_dict, 'Sources') - self.indent_level += 1 - self.write_line('isa = PBXGroup;') source_dict.add_item('isa', 'PBXGroup') source_children = PbxArray() - self.write_line('children = (') source_dict.add_item('children', source_children) - self.indent_level += 1 for t in self.build.get_build_targets(): - self.write_line('{} /* {} */,'.format(groupmap[t], t)) source_children.add_item(groupmap[t], t) - self.indent_level -= 1 - self.write_line(');') - self.write_line('name = Sources;') source_dict.add_item('name', 'Sources') - self.write_line('sourceTree = "<group>";') source_dict.add_item('sourceTree', '"<group>"') - self.indent_level -= 1 - self.write_line('};') resource_dict = PbxDict() - self.write_line('%s /* Resources */ = {' % resources_id) objects_dict.add_item(resources_id, resource_dict, 'Resources') - self.indent_level += 1 - self.write_line('isa = PBXGroup;') resource_dict.add_item('isa', 'PBXGroup') resource_children = PbxArray() - self.write_line('children = (') resource_dict.add_item('children', resource_children) - self.write_line(');') - self.write_line('name = Resources;') resource_dict.add_item('name', 'Resources') - self.write_line('sourceTree = "<group>";') resource_dict.add_item('sourceTree', '"<group>"') - self.indent_level -= 1 - self.write_line('};') frameworks_dict = PbxDict() - self.write_line('%s /* Frameworks */ = {' % frameworks_id) objects_dict.add_item(frameworks_id, frameworks_dict, 'Frameworks') - self.indent_level += 1 - self.write_line('isa = PBXGroup;') frameworks_dict.add_item('isa', 'PBXGroup') frameworks_children = PbxArray() frameworks_dict.add_item('children', frameworks_children) - self.write_line('children = (') # write frameworks - self.indent_level += 1 for t in self.build.get_build_targets().values(): for dep in t.get_external_deps(): if isinstance(dep, dependencies.AppleFrameworks): for f in dep.frameworks: - self.write_line('{} /* {}.framework */,\n'.format(self.native_frameworks_fileref[f], f)) frameworks_children.add_item(self.native_frameworks_fileref[f], f) - self.indent_level -= 1 - self.write_line(');') - self.write_line('name = Frameworks;') frameworks_dict.add_item('name', 'Frameworks') - self.write_line('sourceTree = "<group>";') frameworks_dict.add_item('sourceTree', '"<group>"') - self.indent_level -= 1 - self.write_line('};') # Targets for t in self.build.get_build_targets(): target_dict = PbxDict() - self.write_line('{} /* {} */ = {{'.format(groupmap[t], t)) objects_dict.add_item(groupmap[t], target_dict, t) - self.indent_level += 1 - self.write_line('isa = PBXGroup;') target_dict.add_item('isa', 'PBXGroup') target_children = PbxArray() target_dict.add_item('children', target_children) - self.write_line('children = (') - self.indent_level += 1 - self.write_line('%s /* Source files */,' % target_src_map[t]) target_children.add_item(target_src_map[t], 'Source files') - self.indent_level -= 1 - self.write_line(');') - self.write_line('name = "%s";' % t) target_dict.add_item('name', f'"{t}"') - self.write_line('sourceTree = "<group>";') target_dict.add_item('sourceTree', '"<group>"') - self.indent_level -= 1 - self.write_line('};') source_files_dict = PbxDict() - self.write_line('%s /* Source files */ = {' % target_src_map[t]) objects_dict.add_item(target_src_map[t], source_files_dict, 'Source files') - self.indent_level += 1 - self.write_line('isa = PBXGroup;') source_files_dict.add_item('isa', 'PBXGroup') source_file_children = PbxArray() - self.write_line('children = (') source_files_dict.add_item('children', source_file_children) - self.indent_level += 1 for s in self.build.get_build_targets()[t].sources: s = os.path.join(s.subdir, s.fname) if isinstance(s, str): - self.write_line('{} /* {} */,'.format(self.filemap[s], s)) source_file_children.add_item(self.filemap[s], s) for o in self.build.get_build_targets()[t].objects: o = os.path.join(self.build.get_build_targets()[t].subdir, o) - self.write_line('{} /* {} */,'.format(self.filemap[o], o)) source_file_children.add_item(self.filemap[o], o) - self.indent_level -= 1 - self.write_line(');') - self.write_line('name = "Source files";') source_files_dict.add_item('name', '"Source files"') - self.write_line('sourceTree = "<group>";') source_files_dict.add_item('sourceTree', '"<group>"') - self.indent_level -= 1 - self.write_line('};') # And finally products product_dict = PbxDict() - self.write_line('%s /* Products */ = {' % products_id) objects_dict.add_item(products_id, product_dict, 'Products') - self.indent_level += 1 - self.write_line('isa = PBXGroup;') product_dict.add_item('isa', 'PBXGroup') - self.write_line('children = (') product_children = PbxArray() product_dict.add_item('children', product_children) - self.indent_level += 1 for t in self.build.get_build_targets(): - self.write_line('{} /* {} */,'.format(self.target_filemap[t], t)) product_children.add_item(self.target_filemap[t], t) - self.indent_level -= 1 - self.write_line(');') - self.write_line('name = Products;') product_dict.add_item('name', 'Products') - self.write_line('sourceTree = "<group>";') product_dict.add_item('sourceTree', '"<group>"') - self.indent_level -= 1 - self.write_line('};') - self.ofile.write('/* End PBXGroup section */\n') def generate_pbx_native_target(self, objects_dict): - self.ofile.write('\n/* Begin PBXNativeTarget section */\n') for tname, idval in self.native_targets.items(): ntarget_dict = PbxDict() t = self.build.get_build_targets()[tname] - self.write_line(f'{idval} /* {tname} */ = {{') objects_dict.add_item(idval, ntarget_dict, tname) - self.indent_level += 1 - self.write_line('isa = PBXNativeTarget;') ntarget_dict.add_item('isa', 'PBXNativeTarget') - self.write_line('buildConfigurationList = %s /* Build configuration list for PBXNativeTarget "%s" */;' - % (self.buildconflistmap[tname], tname)) ntarget_dict.add_item('buildConfigurationList', self.buildconflistmap[tname], f'Build configuration list for PBXNativeTarget "{tname}"') buildphases_array = PbxArray() - self.write_line('buildPhases = (') ntarget_dict.add_item('buildPhases', buildphases_array) - self.indent_level += 1 for bpname, bpval in t.buildphasemap.items(): - self.write_line(f'{bpval} /* {bpname} yyy */,') buildphases_array.add_item(bpval, f'{bpname} yyy') - self.indent_level -= 1 - self.write_line(');') - self.write_line('buildRules = (') - self.write_line(');') ntarget_dict.add_item('buildRules', PbxArray()) dep_array = PbxArray() - self.write_line('dependencies = (') ntarget_dict.add_item('dependencies', dep_array) - self.indent_level += 1 for lt in self.build.get_build_targets()[tname].link_targets: # NOT DOCUMENTED, may need to make different links # to same target have different targetdependency item. idval = self.pbx_dep_map[lt.get_id()] - self.write_line('%s /* PBXTargetDependency */,' % idval) dep_array.add_item(idval, 'PBXTargetDependency') - self.indent_level -= 1 - self.write_line(");") - self.write_line('name = "%s";' % tname) ntarget_dict.add_item('name', f'"{tname}"') - self.write_line('productName = "%s";' % tname) ntarget_dict.add_item('productName', f'"{tname}"') - self.write_line('productReference = {} /* {} */;'.format(self.target_filemap[tname], tname)) ntarget_dict.add_item('productReference', self.target_filemap[tname], tname) if isinstance(t, build.Executable): typestr = 'com.apple.product-type.tool' @@ -821,131 +633,63 @@ class XCodeBackend(backends.Backend): typestr = 'com.apple.product-type.library.dynamic' else: raise MesonException('Unknown target type for %s' % tname) - self.write_line('productType = "%s";' % typestr) ntarget_dict.add_item('productType', f'"{typestr}"') - self.indent_level -= 1 - self.write_line('};') - self.ofile.write('/* End PBXNativeTarget section */\n') def generate_pbx_project(self, objects_dict): project_dict = PbxDict() - self.ofile.write('\n/* Begin PBXProject section */\n') - self.write_line('%s /* Project object */ = {' % self.project_uid) objects_dict.add_item(self.project_uid, project_dict, 'Project object') - self.indent_level += 1 - self.write_line('isa = PBXProject;') project_dict.add_item('isa', 'PBXProject') attr_dict = PbxDict() - self.write_line('attributes = {') project_dict.add_item('attributes', attr_dict) - self.indent_level += 1 - self.write_line('BuildIndependentTargetsInParallel = YES;') attr_dict.add_item('BuildIndependentTargetsInParallel', 'YES') - self.indent_level -= 1 - self.write_line('};') conftempl = 'buildConfigurationList = %s /* Build configuration list for PBXProject "%s" */;' - self.write_line(conftempl % (self.project_conflist, self.build.project_name)) project_dict.add_item('buildConfigurationList', self.project_conflist, f'Build configuration list for PBXProject "{self.build.project_name}"') - self.write_line('buildSettings = {') - self.write_line('};') project_dict.add_item('buildSettings', PbxDict()) style_arr = PbxArray() - self.write_line('buildStyles = (') project_dict.add_item('buildStyles', style_arr) - self.indent_level += 1 for name, idval in self.buildstylemap.items(): - self.write_line(f'{idval} /* {name} */,') style_arr.add_item(idval, name) - self.indent_level -= 1 - self.write_line(');') - self.write_line('compatibilityVersion = "Xcode 3.2";') project_dict.add_item('compatibilityVersion', '"Xcode 3.2"') - self.write_line('hasScannedForEncodings = 0;') project_dict.add_item('hasScannedForEncodings', 0) - self.write_line('mainGroup = %s;' % self.maingroup_id) project_dict.add_item('mainGroup', self.maingroup_id) - self.write_line('projectDirPath = "%s";' % self.build_to_src) project_dict.add_item('projectDirPath', f'"{self.build_to_src}"') - self.write_line('projectRoot = "";') project_dict.add_item('projectRoot', '""') targets_arr = PbxArray() - self.write_line('targets = (') project_dict.add_item('targets', targets_arr) - self.indent_level += 1 - self.write_line('%s /* ALL_BUILD */,' % self.all_id) targets_arr.add_item(self.all_id, 'ALL_BUILD') - self.write_line('%s /* RUN_TESTS */,' % self.test_id) targets_arr.add_item(self.test_id, 'RUN_TESTS') for t in self.build.get_build_targets(): - self.write_line('{} /* {} */,'.format(self.native_targets[t], t)) targets_arr.add_item(self.native_targets[t], t) - self.indent_level -= 1 - self.write_line(');') - self.indent_level -= 1 - self.write_line('};') - self.ofile.write('/* End PBXProject section */\n') def generate_pbx_shell_build_phase(self, objects_dict, test_data): - self.ofile.write('\n/* Begin PBXShellScriptBuildPhase section */\n') shell_dict = PbxDict() - self.write_line('%s /* ShellScript */ = {' % self.test_command_id) objects_dict.add_item(self.test_command_id, shell_dict, 'ShellScript') - self.indent_level += 1 - self.write_line('isa = PBXShellScriptBuildPhase;') shell_dict.add_item('isa', 'PBXShellScriptBuildPhase') - self.write_line('buildActionMask = 2147483647;') shell_dict.add_item('buildActionMask', 2147483647) - self.write_line('files = (') - self.write_line(');') shell_dict.add_item('files', PbxArray()) - self.write_line('inputPaths = (') - self.write_line(');') shell_dict.add_item('inputPaths', PbxArray()) - self.write_line('outputPaths = (') shell_dict.add_item('outputPaths', PbxArray()) - self.write_line(');') - self.write_line('runOnlyForDeploymentPostprocessing = 0;') shell_dict.add_item('runOnlyForDeploymentPostprocessing', 0) - self.write_line('shellPath = /bin/sh;') shell_dict.add_item('shellPath', '/bin/sh') cmd = mesonlib.get_meson_command() + ['test', '--no-rebuild', '-C', self.environment.get_build_dir()] cmdstr = ' '.join(["'%s'" % i for i in cmd]) - self.write_line('shellScript = "%s";' % cmdstr) shell_dict.add_item('shellScript', f'"{cmdstr}"') - self.write_line('showEnvVarsInLog = 0;') shell_dict.add_item('showEnvVarsInLog', 0) - self.indent_level -= 1 - self.write_line('};') - self.ofile.write('/* End PBXShellScriptBuildPhase section */\n') def generate_pbx_sources_build_phase(self, objects_dict): - self.ofile.write('\n/* Begin PBXSourcesBuildPhase section */\n') for name in self.source_phase.keys(): phase_dict = PbxDict() t = self.build.get_build_targets()[name] - self.write_line('%s /* Sources */ = {' % (t.buildphasemap[name])) objects_dict.add_item(t.buildphasemap[name], phase_dict, 'Sources') - self.indent_level += 1 - self.write_line('isa = PBXSourcesBuildPhase;') phase_dict.add_item('isa', 'PBXSourcesBuildPhase') - self.write_line('buildActionMask = 2147483647;') phase_dict.add_item('buildActionMask', 2147483647) file_arr = PbxArray() - self.write_line('files = (') phase_dict.add_item('files', file_arr) - self.indent_level += 1 for s in self.build.get_build_targets()[name].sources: s = os.path.join(s.subdir, s.fname) if not self.environment.is_header(s): - self.write_line('{} /* {} */,'.format(self.buildmap[s], os.path.join(self.environment.get_source_dir(), s))) file_arr.add_item(self.buildmap[s], os.path.join(self.environment.get_source_dir(), s)) - self.indent_level -= 1 - self.write_line(');') - self.write_line('runOnlyForDeploymentPostprocessing = 0;') phase_dict.add_item('runOnlyForDeploymentPostprocessing', 0) - self.indent_level -= 1 - self.write_line('};') - self.ofile.write('/* End PBXSourcesBuildPhase section */\n') def generate_pbx_target_dependency(self, objects_dict): targets = [] @@ -955,157 +699,83 @@ class XCodeBackend(backends.Backend): # Sort object by ID sorted_targets = sorted(targets, key=operator.itemgetter(0)) - self.ofile.write('\n/* Begin PBXTargetDependency section */\n') for t in sorted_targets: t_dict = PbxDict() - self.write_line('%s /* PBXTargetDependency */ = {' % t[0]) objects_dict.add_item(t[0], t_dict, 'PBXTargetDependency') - self.indent_level += 1 - self.write_line('isa = PBXTargetDependency;') t_dict.add_item('isa', 'PBXTargetDependency') - self.write_line('target = {} /* {} */;'.format(t[1], t[2])) t_dict.add_item('target', t[1], t[2]) - self.write_line('targetProxy = %s /* PBXContainerItemProxy */;' % t[3]) t_dict.add_item('targetProxy', t[3], 'PBXContainerItemProxy') - self.indent_level -= 1 - self.write_line('};') - self.ofile.write('/* End PBXTargetDependency section */\n') def generate_xc_build_configuration(self, objects_dict): - self.ofile.write('\n/* Begin XCBuildConfiguration section */\n') # First the setup for the toplevel project. for buildtype in self.buildtypes: bt_dict = PbxDict() - self.write_line('{} /* {} */ = {{'.format(self.project_configurations[buildtype], buildtype)) objects_dict.add_item(self.project_configurations[buildtype], bt_dict, buildtype) - self.indent_level += 1 - self.write_line('isa = XCBuildConfiguration;') bt_dict.add_item('isa', 'XCBuildConfiguration') settings_dict = PbxDict() - self.write_line('buildSettings = {') bt_dict.add_item('buildSettings', settings_dict) - self.indent_level += 1 - self.write_line('ARCHS = "$(NATIVE_ARCH_ACTUAL)";') settings_dict.add_item('ARCHS', '"$(NATIVE_ARCH_ACTUAL)"') - self.write_line('ONLY_ACTIVE_ARCH = YES;') settings_dict.add_item('ONLY_ACTIVE_ARCH', 'YES') - self.write_line('SDKROOT = "macosx";') settings_dict.add_item('SDKROOT', '"macosx"') - self.write_line('SYMROOT = "%s/build";' % self.environment.get_build_dir()) settings_dict.add_item('SYMROOT', '"%s/build"' % self.environment.get_build_dir()) - self.indent_level -= 1 - self.write_line('};') - self.write_line('name = "%s";' % buildtype) bt_dict.add_item('name', f'"{buildtype}"') - self.indent_level -= 1 - self.write_line('};') # Then the all target. for buildtype in self.buildtypes: bt_dict = PbxDict() - self.write_line('{} /* {} */ = {{'.format(self.buildall_configurations[buildtype], buildtype)) objects_dict.add_item(self.buildall_configurations[buildtype], bt_dict, buildtype) - self.indent_level += 1 - self.write_line('isa = XCBuildConfiguration;') bt_dict.add_item('isa', 'XCBuildConfiguration') - self.write_line('buildSettings = {') settings_dict = PbxDict() bt_dict.add_item('buildSettings', settings_dict) - self.indent_level += 1 - self.write_line('COMBINE_HIDPI_IMAGES = YES;') settings_dict.add_item('COMBINE_HIDPI_IMAGES', 'YES') - self.write_line('GCC_GENERATE_DEBUGGING_SYMBOLS = NO;') settings_dict.add_item('GCC_GENERATE_DEBUGGING_SYMBOLS', 'NO') - self.write_line('GCC_INLINES_ARE_PRIVATE_EXTERN = NO;') settings_dict.add_item('GCC_INLINES_ARE_PRIVATE_EXTERN', 'NO') - self.write_line('GCC_OPTIMIZATION_LEVEL = 0;') settings_dict.add_item('GCC_OPTIMIZATION_LEVEL', 0) - self.write_line('GCC_PREPROCESSOR_DEFINITIONS = "";') settings_dict.add_item('GCC_PREPROCESSOR_DEFINITIONS', '""') - self.write_line('GCC_SYMBOLS_PRIVATE_EXTERN = NO;') settings_dict.add_item('GCC_SYMBOLS_PRIVATE_EXTERN', 'NO') - self.write_line('INSTALL_PATH = "";') settings_dict.add_item('INSTALL_PATH', '""') - self.write_line('OTHER_CFLAGS = " ";') settings_dict.add_item('OTHER_CFLAGS', '" "') - self.write_line('OTHER_LDFLAGS = " ";') settings_dict.add_item('OTHER_LDFLAGS', '" "') - self.write_line('OTHER_REZFLAGS = "";') settings_dict.add_item('OTHER_REZFLAGS', '""') - self.write_line('PRODUCT_NAME = ALL_BUILD;') settings_dict.add_item('PRODUCT_NAME', 'ALL_BUILD') - self.write_line('SECTORDER_FLAGS = "";') settings_dict.add_item('SECTORDER_FLAGS', '""') - self.write_line('SYMROOT = "%s";' % self.environment.get_build_dir()) settings_dict.add_item('SYMROOT', '"%s"' % self.environment.get_build_dir()) - self.write_line('USE_HEADERMAP = NO;') settings_dict.add_item('USE_HEADERMAP', 'NO') - self.write_build_setting_line('WARNING_CFLAGS', ['-Wmost', '-Wno-four-char-constants', '-Wno-unknown-pragmas']) warn_array = PbxArray() settings_dict.add_item('WARNING_CFLAGS', warn_array) warn_array.add_item('"-Wmost"') warn_array.add_item('"-Wno-four-char-constants"') warn_array.add_item('"-Wno-unknown-pragmas"') - self.indent_level -= 1 - self.write_line('};') - self.write_line('name = "%s";' % buildtype) bt_dict.add_item('name', f'"{buildtype}"') - self.indent_level -= 1 - self.write_line('};') # Then the test target. for buildtype in self.buildtypes: bt_dict = PbxDict() - self.write_line('{} /* {} */ = {{'.format(self.test_configurations[buildtype], buildtype)) objects_dict.add_item(self.test_configurations[buildtype], bt_dict, buildtype) - self.indent_level += 1 - self.write_line('isa = XCBuildConfiguration;') bt_dict.add_item('isa', 'XCBuildConfiguration') settings_dict = PbxDict() - self.write_line('buildSettings = {') bt_dict.add_item('buildSettings', settings_dict) - self.indent_level += 1 - self.write_line('COMBINE_HIDPI_IMAGES = YES;') settings_dict.add_item('COMBINE_HIDPI_IMAGES', 'YES') - self.write_line('GCC_GENERATE_DEBUGGING_SYMBOLS = NO;') settings_dict.add_item('GCC_GENERATE_DEBUGGING_SYMBOLS', 'NO') - self.write_line('GCC_INLINES_ARE_PRIVATE_EXTERN = NO;') settings_dict.add_item('GCC_INLINES_ARE_PRIVATE_EXTERN', 'NO') - self.write_line('GCC_OPTIMIZATION_LEVEL = 0;') settings_dict.add_item('GCC_OPTIMIZATION_LEVEL', 0) - self.write_line('GCC_PREPROCESSOR_DEFINITIONS = "";') settings_dict.add_item('GCC_PREPROCESSOR_DEFINITIONS', '""') - self.write_line('GCC_SYMBOLS_PRIVATE_EXTERN = NO;') settings_dict.add_item('GCC_SYMBOLS_PRIVATE_EXTERN', 'NO') - self.write_line('INSTALL_PATH = "";') settings_dict.add_item('INSTALL_PATH', '""') - self.write_line('OTHER_CFLAGS = " ";') settings_dict.add_item('OTHER_CFLAGS', '" "') - self.write_line('OTHER_LDFLAGS = " ";') settings_dict.add_item('OTHER_LDFLAGS', '" "') - self.write_line('OTHER_REZFLAGS = "";') settings_dict.add_item('OTHER_REZFLAGS', '""') - self.write_line('PRODUCT_NAME = RUN_TESTS;') settings_dict.add_item('PRODUCT_NAME', 'RUN_TESTS') - self.write_line('SECTORDER_FLAGS = "";') settings_dict.add_item('SECTORDER_FLAGS', '""') - self.write_line('SYMROOT = "%s";' % self.environment.get_build_dir()) settings_dict.add_item('SYMROOT', '"%s"' % self.environment.get_build_dir()) - self.write_line('USE_HEADERMAP = NO;') settings_dict.add_item('USE_HEADERMAP', 'NO') - self.write_build_setting_line('WARNING_CFLAGS', ['-Wmost', '-Wno-four-char-constants', '-Wno-unknown-pragmas']) warn_array = PbxArray() settings_dict.add_item('WARNING_CFLAGS', warn_array) warn_array.add_item('"-Wmost"') warn_array.add_item('"-Wno-four-char-constants"') warn_array.add_item('"-Wno-unknown-pragmas"') - self.indent_level -= 1 - self.write_line('};') - self.write_line('name = "%s";' % buildtype) bt_dict.add_item('name', f'"{buildtype}"') - self.indent_level -= 1 - self.write_line('};') # Now finally targets. langnamemap = {'c': 'C', 'cpp': 'CPLUSPLUS', 'objc': 'OBJC', 'objcpp': 'OBJCPLUSPLUS'} @@ -1170,33 +840,21 @@ class XCodeBackend(backends.Backend): langargs[langname] += lang_cargs symroot = os.path.join(self.environment.get_build_dir(), target.subdir) bt_dict = PbxDict() - self.write_line(f'{valid} /* {buildtype} */ = {{') objects_dict.add_item(valid, bt_dict, buildtype) - self.indent_level += 1 - self.write_line('isa = XCBuildConfiguration;') bt_dict.add_item('isa', 'XCBuildConfiguration') settings_dict = PbxDict() - self.write_line('buildSettings = {') bt_dict.add_item('buildSettings', settings_dict) - self.indent_level += 1 - self.write_line('COMBINE_HIDPI_IMAGES = YES;') settings_dict.add_item('COMBINE_HIDPI_IMAGES', 'YES') if dylib_version is not None: - self.write_line('DYLIB_CURRENT_VERSION = "%s";' % dylib_version) settings_dict.add_item('DYLIB_CURRENT_VERSION', f'"{dylib_version}') - self.write_line('EXECUTABLE_PREFIX = "%s";' % target.prefix) settings_dict.add_item('EXECUTABLE_PREFIX', f'"{target.prefix}"') if target.suffix == '': suffix = '' else: suffix = '.' + target.suffix - self.write_line('EXECUTABLE_SUFFIX = "%s";' % suffix) settings_dict.add_item('EXECUTABLE_SUFFIX', f'"{suffix}"') - self.write_line('GCC_GENERATE_DEBUGGING_SYMBOLS = YES;') settings_dict.add_item('GCC_GENERATE_DEBUGGING_SYMBOLS', 'YES') - self.write_line('GCC_INLINES_ARE_PRIVATE_EXTERN = NO;') settings_dict.add_item('GCC_INLINES_ARE_PRIVATE_EXTERN', 'NO') - self.write_line('GCC_OPTIMIZATION_LEVEL = 0;') settings_dict.add_item('GCC_OPTIMIZATION_LEVEL', 0) if target.has_pch: # Xcode uses GCC_PREFIX_HEADER which only allows one file per target/executable. Precompiling various header files and @@ -1209,198 +867,89 @@ class XCodeBackend(backends.Backend): if len(pchs) > 1: mlog.warning('Unsupported Xcode configuration: More than 1 precompiled header found "{}". Target "{}" might not compile correctly.'.format(str(pchs), target.name)) relative_pch_path = os.path.join(target.get_subdir(), pchs[0]) # Path relative to target so it can be used with "$(PROJECT_DIR)" - self.write_line('GCC_PRECOMPILE_PREFIX_HEADER = YES;') settings_dict.add_item('GCC_PRECOMPILE_PREFIX_HEADER', 'YES') - self.write_line('GCC_PREFIX_HEADER = "$(PROJECT_DIR)/%s";' % relative_pch_path) settings_dict.add_item('GCC_PREFIX_HEADER', f'"$(PROJECT_DIR)/{relative_pch_path}"') - self.write_line('GCC_PREPROCESSOR_DEFINITIONS = "";') settings_dict.add_item('GCC_PREPROCESSOR_DEFINITIONS', '""') - self.write_line('GCC_SYMBOLS_PRIVATE_EXTERN = NO;') settings_dict.add_item('GCC_SYMBOLS_PRIVATE_EXTERN', 'NO') if headerdirs: quotedh = ','.join(['"\\"%s\\""' % i for i in headerdirs]) - self.write_line('HEADER_SEARCH_PATHS=(%s);' % quotedh) settings_dict.add_item('HEADER_SEARCH_PATHS', f'({quotedh}') - self.write_line('INSTALL_PATH = "%s";' % install_path) settings_dict.add_item('INSTALL_PATH', f'"{install_path}"') - self.write_line('LIBRARY_SEARCH_PATHS = "";') settings_dict.add_item('LIBRARY_SEARCH_PATHS', '""') if isinstance(target, build.SharedLibrary): - self.write_line('LIBRARY_STYLE = DYNAMIC;') settings_dict.add_item('LIBRARY_STYLE', 'DYNAMIC') for langname, args in langargs.items(): - self.write_build_setting_line('OTHER_%sFLAGS' % langname, args) settings_dict.add_item(f'OTHER_{langname}FLAGS', args) - self.write_line('OTHER_LDFLAGS = "%s";' % ldstr) settings_dict.add_item('OTHER_LDFLAGS', f'"{ldstr}"') - self.write_line('OTHER_REZFLAGS = "";') settings_dict.add_item('OTHER_REZFLAGS', '""') - self.write_line('PRODUCT_NAME = %s;' % product_name) settings_dict.add_item('PRODUCT_NAME', product_name) - self.write_line('SECTORDER_FLAGS = "";') settings_dict.add_item('SECTORDER_FLAGS', '""') - self.write_line('SYMROOT = "%s";' % symroot) settings_dict.add_item('SYMROOT', f'"{symroot}"') - self.write_build_setting_line('SYSTEM_HEADER_SEARCH_PATHS', [self.environment.get_build_dir()]) settings_dict.add_item('SYSTEM_HEADER_SEARCH_PATHS', '"{}"'.format(self.environment.get_build_dir())) - self.write_line('USE_HEADERMAP = NO;') settings_dict.add_item('USE_HEADERMAP', 'NO') - self.write_build_setting_line('WARNING_CFLAGS', ['-Wmost', '-Wno-four-char-constants', '-Wno-unknown-pragmas']) warn_array = PbxArray() settings_dict.add_item('WARNING_CFLAGS', warn_array) warn_array.add_item('"-Wmost"') warn_array.add_item('"-Wno-four-char-constants"') warn_array.add_item('"-Wno-unknown-pragmas"') - self.indent_level -= 1 - self.write_line('};') - self.write_line('name = %s;' % buildtype) bt_dict.add_item('name', buildtype) - self.indent_level -= 1 - self.write_line('};') - self.ofile.write('/* End XCBuildConfiguration section */\n') def generate_xc_configurationList(self, objects_dict): # FIXME: sort items - self.ofile.write('\n/* Begin XCConfigurationList section */\n') conf_dict = PbxDict() - self.write_line(f'{self.project_conflist} /* Build configuration list for PBXProject "{self.build.project_name}" */ = {{') objects_dict.add_item(self.project_conflist, conf_dict, f'Build configuration list for PBXProject "{self.build.project_name}"') - self.indent_level += 1 - self.write_line('isa = XCConfigurationList;') conf_dict.add_item('isa', 'XCConfigurationList') confs_arr = PbxArray() - self.write_line('buildConfigurations = (') conf_dict.add_item('buildConfigurations', confs_arr) - self.indent_level += 1 for buildtype in self.buildtypes: - self.write_line('{} /* {} */,'.format(self.project_configurations[buildtype], buildtype)) confs_arr.add_item(self.project_configurations[buildtype], buildtype) - self.indent_level -= 1 - self.write_line(');') - self.write_line('defaultConfigurationIsVisible = 0;') conf_dict.add_item('defaultConfigurationIsVisible', 0) - self.write_line('defaultConfigurationName = debug;') conf_dict.add_item('defaultConfigurationName', 'debug') - self.indent_level -= 1 - self.write_line('};') # Now the all target all_dict = PbxDict() - self.write_line('%s /* Build configuration list for PBXAggregateTarget "ALL_BUILD" */ = {' % self.all_buildconf_id) objects_dict.add_item(self.all_buildconf_id, all_dict, 'Build configuration list for PBXAggregateTarget "ALL_BUILD"') - self.indent_level += 1 - self.write_line('isa = XCConfigurationList;') all_dict.add_item('isa', 'XCConfigurationList') conf_arr = PbxArray() - self.write_line('buildConfigurations = (') all_dict.add_item('buildConfigurations', conf_arr) - self.indent_level += 1 for buildtype in self.buildtypes: - self.write_line('{} /* {} */,'.format(self.buildall_configurations[buildtype], buildtype)) conf_arr.add_item(self.buildall_configurations[buildtype], buildtype) - self.indent_level -= 1 - self.write_line(');') - self.write_line('defaultConfigurationIsVisible = 0;') all_dict.add_item('defaultConfigurationIsVisible', 0) - self.write_line('defaultConfigurationName = debug;') all_dict.add_item('defaultConfigurationName', 'debug') - self.indent_level -= 1 - self.write_line('};') # Test target test_dict = PbxDict() - self.write_line('%s /* Build configuration list for PBXAggregateTarget "RUN_TEST" */ = {' % self.test_buildconf_id) objects_dict.add_item(self.test_buildconf_id, test_dict, 'Build configuration list for PBXAggregateTarget "RUN_TEST"') - self.indent_level += 1 - self.write_line('isa = XCConfigurationList;') test_dict.add_item('isa', 'XCConfigurationList') conf_arr = PbxArray() - self.write_line('buildConfigurations = (') test_dict.add_item('buildConfigurations', conf_arr) - self.indent_level += 1 for buildtype in self.buildtypes: - self.write_line('{} /* {} */,'.format(self.test_configurations[buildtype], buildtype)) conf_arr.add_item(self.test_configurations[buildtype], buildtype) - self.indent_level -= 1 - self.write_line(');') - self.write_line('defaultConfigurationIsVisible = 0;') test_dict.add_item('defaultConfigurationIsVisible', 0) - self.write_line('defaultConfigurationName = debug;') test_dict.add_item('defaultConfigurationName', 'debug') - self.indent_level -= 1 - self.write_line('};') for target_name in self.build.get_build_targets(): t_dict = PbxDict() listid = self.buildconflistmap[target_name] - self.write_line(f'{listid} /* Build configuration list for PBXNativeTarget "{target_name}" */ = {{') objects_dict.add_item(listid, t_dict, f'Build configuration list for PBXNativeTarget "{target_name}"') - self.indent_level += 1 - self.write_line('isa = XCConfigurationList;') t_dict.add_item('isa', 'XCConfigurationList') conf_arr = PbxArray() - self.write_line('buildConfigurations = (') t_dict.add_item('buildConfigurations', conf_arr) - self.indent_level += 1 typestr = 'debug' idval = self.buildconfmap[target_name][typestr] - self.write_line(f'{idval} /* {typestr} */,') conf_arr.add_item(idval, typestr) - self.indent_level -= 1 - self.write_line(');') - self.write_line('defaultConfigurationIsVisible = 0;') t_dict.add_item('defaultConfigurationIsVisible', 0) - self.write_line('defaultConfigurationName = %s;' % typestr) t_dict.add_item('defaultConfigurationName', typestr) - self.indent_level -= 1 - self.write_line('};') - self.ofile.write('/* End XCConfigurationList section */\n') - - def write_build_setting_line(self, flag_name, flag_values, explicit=False): - if flag_values: - if len(flag_values) == 1: - value = flag_values[0] - if (' ' in value): - # If path contains spaces surround it with double colon - self.write_line(f'{flag_name} = "\\"{value}\\"";') - else: - self.write_line(f'{flag_name} = "{value}";') - else: - self.write_line('%s = (' % flag_name) - self.indent_level += 1 - for value in flag_values: - if (' ' in value): - # If path contains spaces surround it with double colon - self.write_line('"\\"%s\\"",' % value) - else: - self.write_line('"%s",' % value) - self.indent_level -= 1 - self.write_line(');') - else: - if explicit: - self.write_line('%s = "";' % flag_name) + def generate_prefix(self, pbxdict): - self.ofile.write('// !$*UTF8*$!\n{\n') - self.indent_level += 1 - self.write_line('archiveVersion = 1;\n') pbxdict.add_item('archiveVersion', '1') - self.write_line('classes = {\n') - self.write_line('};\n') pbxdict.add_item('classes', PbxDict()) - self.write_line('objectVersion = 46;\n') pbxdict.add_item('objectVersion', '46') - self.write_line('objects = {\n') objects_dict = PbxDict() pbxdict.add_item('objects', objects_dict) - self.indent_level += 1 return objects_dict def generate_suffix(self, pbxdict): - self.indent_level -= 1 - self.write_line('};\n') - self.write_line('rootObject = ' + self.project_uid + ' /* Project object */;') pbxdict.add_item('rootObject', self.project_uid, 'Project object') - self.indent_level -= 1 - self.write_line('}\n') |