Exemplo n.º 1
0
def create_task_macapp(self):
    if self.env['MACAPP'] or getattr(self, 'mac_app', False):
        out = self.link_task.outputs[0]
        name = bundle_name_for_output(out)
        dir = self.create_bundle_dirs(name, out)
        n1 = dir.find_or_declare(['Contents', 'MacOS', out.name])
        self.apptask = self.create_task('macapp', self.link_task.outputs, n1)
        inst_to = getattr(self, 'install_path',
                          '/Applications') + '/%s/Contents/MacOS/' % name
        self.bld.install_files(inst_to, n1, chmod=Utils.O755)
        if getattr(self, 'mac_resources', None):
            res_dir = n1.parent.parent.make_node('Resources')
            inst_to = getattr(self, 'install_path',
                              '/Applications') + '/%s/Resources' % name
            for x in self.to_list(self.mac_resources):
                node = self.path.find_node(x)
                if not node:
                    raise Errors.WafError('Missing mac_resource %r in %r' %
                                          (x, self))
                parent = node.parent
                if os.path.isdir(node.abspath()):
                    nodes = node.ant_glob('**')
                else:
                    nodes = [node]
                for node in nodes:
                    rel = node.path_from(parent)
                    tsk = self.create_task('macapp', node,
                                           res_dir.make_node(rel))
                    self.bld.install_as(inst_to + '/%s' % rel, node)
        if getattr(self, 'mac_frameworks', None):
            frameworks_dir = n1.parent.parent.make_node('Frameworks')
            inst_to = getattr(self, 'install_path',
                              '/Applications') + '/%s/Frameworks' % name
            for x in self.to_list(self.mac_frameworks):
                node = self.path.find_node(x)
                if not node:
                    raise Errors.WafError('Missing mac_frameworks %r in %r' %
                                          (x, self))
                parent = node.parent
                if not os.path.isdir(node.abspath()):
                    raise Errors.WafErorr(
                        'mac_frameworks need to specify framework directory')
                rel = node.path_from(parent)
                nodes = [
                    i for i in node.ant_glob('**')
                    if not os.path.islink(i.abspath())
                ]
                tsk = self.create_task('macframework', nodes,
                                       frameworks_dir.make_node(rel))
                tsk.framework = node
                tsk.inst_to = inst_to
        if getattr(self.bld, 'is_install', None):
            self.install_task.hasrun = Task.SKIP_ME
Exemplo n.º 2
0
def create_task_macapp(self):
    """
	To compile an executable into a Mac application (a .app), set its *mac_app* attribute::

		def build(bld):
			bld.shlib(source='a.c', target='foo', mac_app = True)

	To force *all* executables to be transformed into Mac applications::

		def build(bld):
			bld.env.MACAPP = True
			bld.shlib(source='a.c', target='foo')
	"""
    if self.env['MACAPP'] or getattr(self, 'mac_app', False):
        out = self.link_task.outputs[0]

        name = bundle_name_for_output(out)
        dir = self.create_bundle_dirs(name, out)

        n1 = dir.find_or_declare(['Contents', 'MacOS', out.name])

        self.apptask = self.create_task('macapp', self.link_task.outputs, n1)
        inst_to = getattr(self, 'install_path',
                          '/Applications') + '/%s/Contents/MacOS/' % name
        self.bld.install_files(inst_to, n1, chmod=Utils.O755)

        if getattr(self, 'mac_resources', None):
            res_dir = n1.parent.parent.make_node('Resources')
            inst_to = getattr(self, 'install_path',
                              '/Applications') + '/%s/Resources' % name
            for x in self.to_list(self.mac_resources):
                node = self.path.find_node(x)
                if not node:
                    raise Errors.WafError('Missing mac_resource %r in %r' %
                                          (x, self))

                parent = node.parent
                if os.path.isdir(node.abspath()):
                    nodes = node.ant_glob('**')
                else:
                    nodes = [node]
                for node in nodes:
                    rel = node.path_from(parent)
                    tsk = self.create_task('macapp', node,
                                           res_dir.make_node(rel))
                    self.bld.install_as(inst_to + '/%s' % rel, node)

        if getattr(self, 'mac_frameworks', None):
            frameworks_dir = n1.parent.parent.make_node('Frameworks')
            inst_to = getattr(self, 'install_path',
                              '/Applications') + '/%s/Frameworks' % name
            for x in self.to_list(self.mac_frameworks):
                node = self.path.find_node(x)
                if not node:
                    raise Errors.WafError('Missing mac_frameworks %r in %r' %
                                          (x, self))
                parent = node.parent
                if not os.path.isdir(node.abspath()):
                    raise Errors.WafErorr(
                        'mac_frameworks need to specify framework directory')

                rel = node.path_from(parent)
                nodes = [
                    i for i in node.ant_glob('**')
                    if not os.path.islink(i.abspath())
                ]
                tsk = self.create_task('macframework', nodes,
                                       frameworks_dir.make_node(rel))
                tsk.framework = node
                tsk.inst_to = inst_to

        if getattr(self.bld, 'is_install', None):
            # disable the normal binary installation
            self.install_task.hasrun = Task.SKIP_ME