def testPrintObject(self):
        obj = {"a": "varA", "b": [1, 2, 3], "c": {"c1": "FDDF6A571C68E5B100D7A645"}}
        dobj = PBXGenericObject().parse(obj)

        expected = "{\n\ta = varA;\n\tb = (\n\t\t1,\n\t\t2,\n\t\t3,\n\t);\n\tc = {\n\t\tc1 = FDDF6A571C68E5B100D7A645;\n\t};\n}"

        self.assertEqual(dobj.__repr__(), expected)
    def testPrintObject(self):
        obj = {"a": "varA", "b": [1, 2, 3], "c": {"c1": "FDDF6A571C68E5B100D7A645"}}
        dobj = PBXGenericObject().parse(obj)

        expected = '{\n\ta = varA;\n\tb = (\n\t\t1,\n\t\t2,\n\t\t3,\n\t);\n\tc = {\n\t\tc1 = FDDF6A571C68E5B100D7A645;\n\t};\n}'

        self.assertEqual(dobj.__repr__(), expected)
    def testResolveComment(self):
        obj = {"a": {"name": "A"}, "b": {"path": "B"}, "c": {"c1": "FDDF6A571C68E5B100D7A645"}}
        dobj = PBXGenericObject().parse(obj)

        self.assertEqual(dobj._resolve_comment('a'), 'A')
        self.assertEqual(dobj._resolve_comment('b'), 'B')
        self.assertEqual(dobj._resolve_comment('c'), None)
    def testResolveComment(self):
        obj = {"a": {"name": "A"}, "b": {"path": "B"}, "c": {"c1": "FDDF6A571C68E5B100D7A645"}}
        dobj = PBXGenericObject().parse(obj)

        self.assertEqual(dobj._resolve_comment("a"), "A")
        self.assertEqual(dobj._resolve_comment("b"), "B")
        self.assertEqual(dobj._resolve_comment("c"), None)
예제 #5
0
    def set_provisioning_style(self, provisioning_type, target):
        if 'attributes' not in self:
            self['attributes'] = PBXGenericObject()

        if 'TargetAttributes' not in self.attributes:
            self.attributes['TargetAttributes'] = PBXGenericObject()

        if target.get_id() not in self.attributes.TargetAttributes:
            self.attributes.TargetAttributes[
                target.get_id()] = PBXGenericObject()

        self.attributes.TargetAttributes[
            target.get_id()]['ProvisioningStyle'] = provisioning_type
예제 #6
0
    def testAddFilesWithHeadersScope(self):
        args = {
            '<project>': 'samplescli/test.pbxproj',
            '<path>': 'samples/dirA/dirB/fileB.h',
            '--target': None,
            '--tree': 'SOURCE_ROOT',
            '--parent': 'Samples',
            '--delete': False,
            '--weak': False,
            '--no-embed': False,
            '--sign-on-copy': False,
            '--ignore-unknown-types': False,
            '--no-create-build-files': False,
            '--header-scope': 'public'
        }
        project = open_project(args)

        self.assertListEqual(project.get_files_by_path(args['<path>']), [])
        result = pbxproj_file.execute(project, args)

        self.assertGreater(project.get_files_by_path(args['<path>']).__len__(), 0)
        self.assertEqual(result, 'File added to the project.\n3 PBXBuildFile sections created.')
        file = project.get_files_by_name('fileB.h')
        build_file = project.get_build_files_for_file(file[0].get_id())
        self.assertEqual(build_file[0].settings.__repr__(), PBXGenericObject().parse({"ATTRIBUTES": ['Public']}).__repr__())
예제 #7
0
    def testSetItemNone(self):
        obj = {}
        dobj = PBXGenericObject().parse(obj)

        self.assertIsNone(dobj['something'])

        dobj['something'] = None
        self.assertIsNone(dobj['something'])
예제 #8
0
    def testSetItemString(self):
        obj = {}
        dobj = PBXGenericObject().parse(obj)

        self.assertIsNone(dobj['something'])

        dobj['something'] = 'yes'
        self.assertEqual(dobj['something'], 'yes')
예제 #9
0
    def testSetItemListOfZero(self):
        obj = {}
        dobj = PBXGenericObject().parse(obj)

        self.assertIsNone(dobj['something'])

        dobj['something'] = []
        self.assertIsNone(dobj['something'])
    def set_flags(self, flag_name, flags):
        if 'buildSettings' not in self:
            self['buildSettings'] = PBXGenericObject()

        if not isinstance(flags, list):
            flags = [flags]

        self.buildSettings[flag_name] = list(OrderedDict.fromkeys(flags))
예제 #11
0
    def testSetItemListOfTwo(self):
        obj = {}
        dobj = PBXGenericObject().parse(obj)

        self.assertIsNone(dobj['something'])

        dobj['something'] = ['yes', 'yes']
        self.assertEqual(dobj['something'], ['yes', 'yes'])
예제 #12
0
 def testEscapeItem(self):
     self.assertEqual(PBXGenericObject._escape("/bin/sh"), "/bin/sh")
     self.assertEqual(PBXGenericObject._escape("abcdefghijklmnopqrstuvwyz0123456789"),
                      "abcdefghijklmnopqrstuvwyz0123456789")
     self.assertEqual(PBXGenericObject._escape("some spaces"), '"some spaces"')
     self.assertEqual(PBXGenericObject._escape("a.valid_id."), "a.valid_id.")
     self.assertEqual(PBXGenericObject._escape("a-invalid-id"), '"a-invalid-id"')
     self.assertEqual(PBXGenericObject._escape("<group>"), '"<group>"')
     self.assertEqual(PBXGenericObject._escape("script \\ continuation"), '"script \\\\ continuation"')
예제 #13
0
    def testGetItem(self):
        obj = {
            "a": "varA",
            "b": [1, 2, 3],
            "c": {
                "c1": "FDDF6A571C68E5B100D7A645"
            }
        }
        dobj = PBXGenericObject().parse(obj)

        self.assertIsInstance(dobj["c"]["c1"], PBXKey)
        self.assertIsNone(dobj['X'])
 def testEscapeItem(self):
     self.assertEqual(PBXGenericObject._escape("/bin/sh"), "/bin/sh")
     self.assertEqual(
         PBXGenericObject._escape("abcdefghijklmnopqrstuvwyz0123456789"), "abcdefghijklmnopqrstuvwyz0123456789"
     )
     self.assertEqual(PBXGenericObject._escape("some spaces"), '"some spaces"')
     self.assertEqual(PBXGenericObject._escape("a.valid_id."), "a.valid_id.")
     self.assertEqual(PBXGenericObject._escape("a-invalid-id"), '"a-invalid-id"')
     self.assertEqual(PBXGenericObject._escape("<group>"), '"<group>"')
예제 #15
0
    def add_flags(self, flag_name, flags):
        if u'buildSettings' not in self:
            self[u'buildSettings'] = PBXGenericObject()

        current_flags = self.buildSettings[flag_name]
        if current_flags is None:
            self.set_flags(flag_name, flags)
            return

        if not isinstance(current_flags, list):
            current_flags = [current_flags]

        if not isinstance(flags, list):
            flags = [flags]

        self.set_flags(flag_name, current_flags + flags)
예제 #16
0
 def testEscapeItem(self):
     self.assertEqual(PBXGenericObject._escape("/bin/sh"), "/bin/sh")
     self.assertEqual(
         PBXGenericObject._escape("abcdefghijklmnopqrstuvwyz0123456789"),
         "abcdefghijklmnopqrstuvwyz0123456789")
     self.assertEqual(PBXGenericObject._escape("some spaces"),
                      '"some spaces"')
     self.assertEqual(PBXGenericObject._escape("a.valid_id."),
                      "a.valid_id.")
     self.assertEqual(PBXGenericObject._escape("a-invalid-id"),
                      '"a-invalid-id"')
     self.assertEqual(PBXGenericObject._escape("<group>"), '"<group>"')
     self.assertEqual(PBXGenericObject._escape("script \\ continuation"),
                      '"script \\\\ continuation"')
     self.assertEqual(
         PBXGenericObject._escape("/bin/sh find .. -name '*.framework'",
                                  exclude=["\'"]),
         "\"/bin/sh find .. -name '*.framework'\"")
예제 #17
0
    def add_flags(self, flag_name, flags):
        if u'buildSettings' not in self:
            self[u'buildSettings'] = PBXGenericObject()

        current_flags = self.buildSettings[flag_name]
        if current_flags is None:
            self.set_flags(flag_name, flags)
            return

        if not isinstance(current_flags, list):
            current_flags = [current_flags]

        if not isinstance(flags, list):
            flags = [flags]

        used = set()
        uniq_flags = [
            x for x in current_flags + flags
            if x not in used and (used.add(x) or True)
        ]
        self.set_flags(flag_name, uniq_flags)
예제 #18
0
    def testAddFolderSuccessWithPublicHeaders(self):
        args = {
            '<project>': 'samplescli/test.pbxproj',
            '<path>': 'samples',
            '--target': None,
            '--tree': 'SOURCE_ROOT',
            '--delete': False,
            '--recursive': True,
            '--exclude': None,
            '--no-create-groups': False,
            '--weak': False,
            '--no-embed': False,
            '--sign-on-copy': False,
            '--ignore-unknown-types': False,
            '--no-create-build-files': False,
            '--header-scope': 'public'
        }
        project = open_project(args)

        self.assertListEqual(
            project.get_files_by_path(args['<path>'] +
                                      '/path with spaces/testLibrary.a',
                                      tree=TreeType.GROUP), [])
        result = pbxproj_folder.execute(project, args)

        self.assertGreater(
            project.get_files_by_path(args['<path>'] +
                                      '/path with spaces/testLibrary.a',
                                      tree=TreeType.GROUP).__len__(), 0)
        self.assertEqual(
            result,
            'Folder added to the project.\n18 PBXBuildFile sections created.')
        file = project.get_files_by_name('fileB.h')
        build_file = project.get_build_files_for_file(file[0].get_id())
        self.assertEqual(
            build_file[0].settings.__repr__(),
            PBXGenericObject().parse({
                "ATTRIBUTES": ['Public']
            }).__repr__())
예제 #19
0
    def set_flags(self, flag_name, flags):
        if u'buildSettings' not in self:
            self[u'buildSettings'] = PBXGenericObject()

        self.buildSettings[flag_name] = flags
예제 #20
0
 def testParseCreateAttributes(self):
     obj = {"a": "varA", "b": [1, 2, 3], "c": {"c1": "varC1"}}
     dobj = PBXGenericObject().parse(obj)
     self.assertEqual(dobj.a, "varA")
     self.assertEqual(dobj.b, [1, 2, 3])
     self.assertIsNotNone(dobj.c)
예제 #21
0
    def testParseKey(self):
        obj = "FDDF6A571C68E5B100D7A645"
        dobj = PBXGenericObject().parse(obj)

        self.assertIsInstance(dobj, PBXKey)
예제 #22
0
                             tree='<absolute>', file_options=file_options)
        else:
            new_parent = project.add_group(child, child, parent)
            my_add_folder(full_path, new_parent, excludes)

modules_group = project.add_group("modules")
for module in config_data["modules"]:
    moduleName = "global"
    if "name" in module:
        moduleName = module["name"]
    group = project.add_group(moduleName, parent=modules_group)
    apply_module_settings(module, group)

project.add_header_search_paths(header_search_paths)

if caps:
    sys_caps = PBXGenericObject()
    for cap in caps:
        sys_caps[cap] = PBXGenericObject()
        sys_caps[cap]["enabled"] = 1

    project.objects[project.rootObject].attributes.TargetAttributes[project_target.get_id()][
        'SystemCapabilities'] = sys_caps

#project.add_other_ldflags("$(inherited)")
#project.add_library_search_paths("$(inherited)")

project.add_other_cflags(compileDefines)

project.save()
예제 #23
0
    def testParseCreateObjectOfRightTypes(self):
        obj = {"objects": {"id": {"isa": "type"}}}
        dobj = PBXGenericObject().parse(obj)

        self.assertIsInstance(dobj.objects, objects)