aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mesonbuild/backend/xcodebackend.py72
1 files changed, 36 insertions, 36 deletions
diff --git a/mesonbuild/backend/xcodebackend.py b/mesonbuild/backend/xcodebackend.py
index 523f842..582826a 100644
--- a/mesonbuild/backend/xcodebackend.py
+++ b/mesonbuild/backend/xcodebackend.py
@@ -65,7 +65,7 @@ LINKABLE_EXTENSIONS = {'.o', '.a', '.obj', '.so', '.dylib'}
class FileTreeEntry:
- def __init__(self):
+ def __init__(self) -> None:
self.subdirs = {}
self.targets = []
@@ -75,16 +75,16 @@ class PbxItem:
self.comment = comment
class PbxArray:
- def __init__(self):
+ def __init__(self) -> None:
self.items = []
- def add_item(self, item, comment=''):
+ def add_item(self, item: T.Union[PbxArrayItem, str], comment: str = '') -> None:
if isinstance(item, PbxArrayItem):
self.items.append(item)
else:
self.items.append(PbxArrayItem(item, comment))
- def write(self, ofile, indent_level):
+ def write(self, ofile: T.TextIO, indent_level: int) -> None:
ofile.write('(\n')
indent_level += 1
for i in self.items:
@@ -96,7 +96,7 @@ class PbxArray:
ofile.write(indent_level*INDENT + ');\n')
class PbxArrayItem:
- def __init__(self, value, comment = ''):
+ def __init__(self, value: str, comment: str = ''):
self.value = value
if comment:
if '/*' in comment:
@@ -107,16 +107,16 @@ class PbxArrayItem:
self.comment = comment
class PbxComment:
- def __init__(self, text):
+ def __init__(self, text: str):
assert isinstance(text, str)
assert '/*' not in text
self.text = f'/* {text} */'
- def write(self, ofile, indent_level):
+ def write(self, ofile: T.TextIO, indent_level: int) -> None:
ofile.write(f'\n{self.text}\n')
class PbxDictItem:
- def __init__(self, key, value, comment = ''):
+ def __init__(self, key: str, value: T.Union[PbxArray, PbxDict, str, int], comment: str = ''):
self.key = key
self.value = value
if comment:
@@ -128,13 +128,13 @@ class PbxDictItem:
self.comment = comment
class PbxDict:
- def __init__(self):
+ def __init__(self) -> None:
# This class is a bit weird, because we want to write PBX dicts in
# defined order _and_ we want to write intermediate comments also in order.
self.keys = set()
self.items = []
- def add_item(self, key, value, comment=''):
+ def add_item(self, key: str, value: T.Union[PbxArray, PbxDict, str, int], comment: str = '') -> None:
assert key not in self.keys
item = PbxDictItem(key, value, comment)
self.keys.add(key)
@@ -143,14 +143,14 @@ class PbxDict:
def has_item(self, key):
return key in self.keys
- def add_comment(self, comment):
+ def add_comment(self, comment: T.Union[str, PbxComment]) -> None:
if isinstance(comment, str):
self.items.append(PbxComment(str))
else:
assert isinstance(comment, PbxComment)
self.items.append(comment)
- def write(self, ofile, indent_level):
+ def write(self, ofile: T.TextIO, indent_level: int) -> None:
ofile.write('{\n')
indent_level += 1
for i in self.items:
@@ -197,7 +197,7 @@ class XCodeBackend(backends.Backend):
def __init__(self, build: T.Optional[build.Build], interpreter: T.Optional[Interpreter]):
super().__init__(build, interpreter)
self.project_uid = self.environment.coredata.lang_guids['default'].replace('-', '')[:24]
- self.buildtype = self.environment.coredata.get_option(OptionKey('buildtype'))
+ self.buildtype = T.cast('str', self.environment.coredata.get_option(OptionKey('buildtype')))
self.project_conflist = self.gen_id()
self.maingroup_id = self.gen_id()
self.all_id = self.gen_id()
@@ -230,11 +230,11 @@ class XCodeBackend(backends.Backend):
top_level_dict.write(ofile, 0)
os.replace(tmpname, ofilename)
- def gen_id(self):
+ def gen_id(self) -> str:
return str(uuid.uuid4()).upper().replace('-', '')[:24]
def get_target_dir(self, target):
- dirname = os.path.join(target.get_subdir(), self.environment.coredata.get_option(OptionKey('buildtype')))
+ dirname = os.path.join(target.get_subdir(), T.cast('str', self.environment.coredata.get_option(OptionKey('buildtype'))))
#os.makedirs(os.path.join(self.environment.get_build_dir(), dirname), exist_ok=True)
return dirname
@@ -344,7 +344,7 @@ class XCodeBackend(backends.Backend):
xcodetype = 'sourcecode.unknown'
return xcodetype
- def generate_filemap(self):
+ def generate_filemap(self) -> None:
self.filemap = {} # Key is source file relative to src root.
self.target_filemap = {}
for name, t in self.build_targets.items():
@@ -358,10 +358,10 @@ class XCodeBackend(backends.Backend):
self.filemap[o] = self.gen_id()
self.target_filemap[name] = self.gen_id()
- def generate_buildstylemap(self):
+ def generate_buildstylemap(self) -> None:
self.buildstylemap = {self.buildtype: self.gen_id()}
- def generate_build_phase_map(self):
+ def generate_build_phase_map(self) -> None:
for tname, t in self.build_targets.items():
# generate id for our own target-name
t.buildphasemap = {}
@@ -371,7 +371,7 @@ class XCodeBackend(backends.Backend):
t.buildphasemap['Resources'] = self.gen_id()
t.buildphasemap['Sources'] = self.gen_id()
- def generate_build_configuration_map(self):
+ def generate_build_configuration_map(self) -> None:
self.buildconfmap = {}
for t in self.build_targets:
bconfs = {self.buildtype: self.gen_id()}
@@ -380,28 +380,28 @@ class XCodeBackend(backends.Backend):
bconfs = {self.buildtype: self.gen_id()}
self.buildconfmap[t] = bconfs
- def generate_project_configurations_map(self):
+ def generate_project_configurations_map(self) -> None:
self.project_configurations = {self.buildtype: self.gen_id()}
- def generate_buildall_configurations_map(self):
+ def generate_buildall_configurations_map(self) -> None:
self.buildall_configurations = {self.buildtype: self.gen_id()}
- def generate_test_configurations_map(self):
+ def generate_test_configurations_map(self) -> None:
self.test_configurations = {self.buildtype: self.gen_id()}
- def generate_build_configurationlist_map(self):
+ def generate_build_configurationlist_map(self) -> None:
self.buildconflistmap = {}
for t in self.build_targets:
self.buildconflistmap[t] = self.gen_id()
for t in self.custom_targets:
self.buildconflistmap[t] = self.gen_id()
- def generate_native_target_map(self):
+ def generate_native_target_map(self) -> None:
self.native_targets = {}
for t in self.build_targets:
self.native_targets[t] = self.gen_id()
- def generate_custom_target_map(self):
+ def generate_custom_target_map(self) -> None:
self.shell_targets = {}
self.custom_target_output_buildfile = {}
self.custom_target_output_fileref = {}
@@ -414,7 +414,7 @@ class XCodeBackend(backends.Backend):
self.custom_target_output_buildfile[o] = self.gen_id()
self.custom_target_output_fileref[o] = self.gen_id()
- def generate_generator_target_map(self):
+ def generate_generator_target_map(self) -> None:
# Generator objects do not have natural unique ids
# so use a counter.
self.generator_fileref_ids = {}
@@ -454,7 +454,7 @@ class XCodeBackend(backends.Backend):
self.generator_buildfile_ids[k] = buildfile_ids
self.generator_fileref_ids[k] = fileref_ids
- def generate_native_frameworks_map(self):
+ def generate_native_frameworks_map(self) -> None:
self.native_frameworks = {}
self.native_frameworks_fileref = {}
for t in self.build_targets.values():
@@ -464,7 +464,7 @@ class XCodeBackend(backends.Backend):
self.native_frameworks[f] = self.gen_id()
self.native_frameworks_fileref[f] = self.gen_id()
- def generate_target_dependency_map(self):
+ def generate_target_dependency_map(self) -> None:
self.target_dependency_map = {}
for tname, t in self.build_targets.items():
for target in t.link_targets:
@@ -481,7 +481,7 @@ class XCodeBackend(backends.Backend):
assert k not in self.target_dependency_map
self.target_dependency_map[k] = self.gen_id()
- def generate_pbxdep_map(self):
+ def generate_pbxdep_map(self) -> None:
self.pbx_dep_map = {}
self.pbx_custom_dep_map = {}
for t in self.build_targets:
@@ -489,12 +489,12 @@ class XCodeBackend(backends.Backend):
for t in self.custom_targets:
self.pbx_custom_dep_map[t] = self.gen_id()
- def generate_containerproxy_map(self):
+ def generate_containerproxy_map(self) -> None:
self.containerproxy_map = {}
for t in self.build_targets:
self.containerproxy_map[t] = self.gen_id()
- def generate_target_file_maps(self):
+ def generate_target_file_maps(self) -> None:
self.generate_target_file_maps_impl(self.build_targets)
self.generate_target_file_maps_impl(self.custom_targets)
@@ -528,13 +528,13 @@ class XCodeBackend(backends.Backend):
else:
raise RuntimeError('Unknown input type ' + str(o))
- def generate_build_file_maps(self):
+ def generate_build_file_maps(self) -> None:
for buildfile in self.interpreter.get_build_def_files():
assert isinstance(buildfile, str)
self.buildfile_ids[buildfile] = self.gen_id()
self.fileref_ids[buildfile] = self.gen_id()
- def generate_source_phase_map(self):
+ def generate_source_phase_map(self) -> None:
self.source_phase = {}
for t in self.build_targets:
self.source_phase[t] = self.gen_id()
@@ -1640,7 +1640,7 @@ class XCodeBackend(backends.Backend):
quoted_args.append(a)
settings_dict.add_item(f'OTHER_{langname}FLAGS', '"' + ' '.join(quoted_args) + '"')
- def generate_xc_configurationList(self, objects_dict):
+ def generate_xc_configurationList(self, objects_dict: PbxDict) -> None:
# FIXME: sort items
conf_dict = PbxDict()
objects_dict.add_item(self.project_conflist, conf_dict, f'Build configuration list for PBXProject "{self.build.project_name}"')
@@ -1709,7 +1709,7 @@ class XCodeBackend(backends.Backend):
t_dict.add_item('defaultConfigurationIsVisible', 0)
t_dict.add_item('defaultConfigurationName', self.buildtype)
- def generate_prefix(self, pbxdict):
+ def generate_prefix(self, pbxdict: PbxDict) -> PbxDict:
pbxdict.add_item('archiveVersion', '1')
pbxdict.add_item('classes', PbxDict())
pbxdict.add_item('objectVersion', '46')
@@ -1718,5 +1718,5 @@ class XCodeBackend(backends.Backend):
return objects_dict
- def generate_suffix(self, pbxdict):
+ def generate_suffix(self, pbxdict: PbxDict) -> None:
pbxdict.add_item('rootObject', self.project_uid, 'Project object')