Exemplo n.º 1
0
def enable_support(cc, cxx):
    if cxx or not cc:
        make_cxx_batch = TaskGen.extension(".cpp", ".cc", ".cxx", ".C", ".c++")(make_batch_fun("cxx"))
    if cc:
        make_c_batch = TaskGen.extension(".c")(make_batch_fun("c"))
    else:
        TaskGen.task_gen.mappings[".c"] = TaskGen.task_gen.mappings[".cpp"]
Exemplo n.º 2
0
Arquivo: errcheck.py Projeto: SjB/waf
def enhance_lib():
	"""
	modify existing classes and methods
	"""
	for m in meths_typos:
		replace(m)

	# catch '..' in ant_glob patterns
	old_ant_glob = Node.Node.ant_glob
	def ant_glob(self, *k, **kw):
		for x in k[0].split('/'):
			if x == '..':
				Logs.error("In ant_glob pattern %r: '..' means 'two dots', not 'parent directory'" % k[0])
		return old_ant_glob(self, *k, **kw)
	Node.Node.ant_glob = ant_glob

	# catch conflicting ext_in/ext_out/before/after declarations
	old = Task.is_before
	def is_before(t1, t2):
		ret = old(t1, t2)
		if ret and old(t2, t1):
			Logs.error('Contradictory order constraints in classes %r %r' % (t1, t2))
		return ret
	Task.is_before = is_before

	# check for bld(feature='cshlib') where no 'c' is given - this can be either a mistake or on purpose
	# so we only issue a warning
	def check_err_features(self):
		lst = self.to_list(self.features)
		if 'shlib' in lst:
			Logs.error('feature shlib -> cshlib, dshlib or cxxshlib')
		for x in ('c', 'cxx', 'd', 'fc'):
			if not x in lst and lst and lst[0] in [x+y for y in ('program', 'shlib', 'stlib')]:
				Logs.error('%r features is probably missing %r' % (self, x))
	TaskGen.feature('*')(check_err_features)
Exemplo n.º 3
0
def _build_pdf(ctx):
    from waflib import TaskGen

    TaskGen.declare_chain(
        name    = 'rst2latex',
        rule    = '${RST2LATEX} ${RST2LATEX_FLAGS} ${SRC} ${TGT}',
        ext_in  = '.rst',
        ext_out = '.tex' )

    TaskGen.declare_chain(
        name    = 'pdflatex',
        rule    = '${PDFLATEX} ${PDFLATEX_FLAGS} ${SRC}; ' * 2,
        ext_in  = '.tex',
        ext_out = '.pdf',
        shell   = True )

    ctx.env.RST2LATEX_FLAGS = [
        '--config=' + ctx.srcnode.abspath() + '/DOCS/man/docutils.conf'
    ]

    ctx.env.PDFLATEX_FLAGS = [
        '--interaction=batchmode',
        '--output-directory=DOCS/man/en/',
        '--jobname=mpv'
    ]

    ctx(source = 'DOCS/man/en/mpv.rst')
    _add_rst_manual_dependencies(ctx)
    ctx.install_files(ctx.env.DOCDIR, ['DOCS/man/en/mpv.pdf'])
Exemplo n.º 4
0
def enhance_lib():
	for m in meths_typos:
		replace(m)
	old_ant_glob=Node.Node.ant_glob
	def ant_glob(self,*k,**kw):
		for x in k[0].split('/'):
			if x=='..':
				Logs.error("In ant_glob pattern %r: '..' means 'two dots', not 'parent directory'"%k[0])
		return old_ant_glob(self,*k,**kw)
	Node.Node.ant_glob=ant_glob
	old=Task.is_before
	def is_before(t1,t2):
		ret=old(t1,t2)
		if ret and old(t2,t1):
			Logs.error('Contradictory order constraints in classes %r %r'%(t1,t2))
		return ret
	Task.is_before=is_before
	def check_err_features(self):
		lst=self.to_list(self.features)
		if'shlib'in lst:
			Logs.error('feature shlib -> cshlib, dshlib or cxxshlib')
		for x in('c','cxx','d','fc'):
			if not x in lst and lst and lst[0]in[x+y for y in('program','shlib','stlib')]:
				Logs.error('%r features is probably missing %r'%(self,x))
	TaskGen.feature('*')(check_err_features)
Exemplo n.º 5
0
def enable_support(cc, cxx):
	if cxx or not cc:
		TaskGen.extension('.cpp', '.cc', '.cxx', '.C', '.c++')(make_batch_fun('cxx'))
	if cc:
		TaskGen.extension('.c')(make_batch_fun('c'))
	else:
		TaskGen.task_gen.mappings['.c'] = TaskGen.task_gen.mappings['.cpp']
Exemplo n.º 6
0
def enable_support(cc, cxx):
    if cxx or not cc:
        TaskGen.extension('.cpp', '.cc', '.cxx', '.C',
                          '.c++')(make_batch_fun('cxx'))
    if cc:
        TaskGen.extension('.c')(make_batch_fun('c'))
    else:
        TaskGen.task_gen.mappings['.c'] = TaskGen.task_gen.mappings['.cpp']
Exemplo n.º 7
0
def enhance_lib():
	for m in meths_typos:
		replace(m)
	old_ant_glob=Node.Node.ant_glob
	def ant_glob(self,*k,**kw):
		if k:
			lst=Utils.to_list(k[0])
			for pat in lst:
				if'..'in pat.split('/'):
					Logs.error("In ant_glob pattern %r: '..' means 'two dots', not 'parent directory'"%k[0])
		return old_ant_glob(self,*k,**kw)
	Node.Node.ant_glob=ant_glob
	old=Task.is_before
	def is_before(t1,t2):
		ret=old(t1,t2)
		if ret and old(t2,t1):
			Logs.error('Contradictory order constraints in classes %r %r'%(t1,t2))
		return ret
	Task.is_before=is_before
	def check_err_features(self):
		lst=self.to_list(self.features)
		if'shlib'in lst:
			Logs.error('feature shlib -> cshlib, dshlib or cxxshlib')
		for x in('c','cxx','d','fc'):
			if not x in lst and lst and lst[0]in[x+y for y in('program','shlib','stlib')]:
				Logs.error('%r features is probably missing %r'%(self,x))
	TaskGen.feature('*')(check_err_features)
	def check_err_order(self):
		if not hasattr(self,'rule'):
			for x in('before','after','ext_in','ext_out'):
				if hasattr(self,x):
					Logs.warn('Erroneous order constraint %r on non-rule based task generator %r'%(x,self))
		else:
			for x in('before','after'):
				for y in self.to_list(getattr(self,x,[])):
					if not Task.classes.get(y,None):
						Logs.error('Erroneous order constraint %s=%r on %r'%(x,y,self))
	TaskGen.feature('*')(check_err_order)
	old_compile=Build.BuildContext.compile
	def check_compile(self):
		check_invalid_constraints(self)
		try:
			ret=old_compile(self)
		finally:
			check_same_targets(self)
		return ret
	Build.BuildContext.compile=check_compile
	def getattri(self,name,default=None):
		if name=='append'or name=='add':
			raise Errors.WafError('env.append and env.add do not exist: use env.append_value/env.append_unique')
		elif name=='prepend':
			raise Errors.WafError('env.prepend does not exist: use env.prepend_value')
		if name in self.__slots__:
			return object.__getattr__(self,name,default)
		else:
			return self[name]
	ConfigSet.ConfigSet.__getattr__=getattri
Exemplo n.º 8
0
def enhance_lib():
	"""
	modify existing classes and methods
	"""
	for m in meths_typos:
		replace(m)

	# catch '..' in ant_glob patterns
	old_ant_glob = Node.Node.ant_glob
	def ant_glob(self, *k, **kw):
		for x in k[0].split('/'):
			if x == '..':
				Logs.error("In ant_glob pattern %r: '..' means 'two dots', not 'parent directory'" % k[0])
		return old_ant_glob(self, *k, **kw)
	Node.Node.ant_glob = ant_glob

	# catch conflicting ext_in/ext_out/before/after declarations
	old = Task.is_before
	def is_before(t1, t2):
		ret = old(t1, t2)
		if ret and old(t2, t1):
			Logs.error('Contradictory order constraints in classes %r %r' % (t1, t2))
		return ret
	Task.is_before = is_before

	# check for bld(feature='cshlib') where no 'c' is given - this can be either a mistake or on purpose
	# so we only issue a warning
	def check_err_features(self):
		lst = self.to_list(self.features)
		if 'shlib' in lst:
			Logs.error('feature shlib -> cshlib, dshlib or cxxshlib')
		for x in ('c', 'cxx', 'd', 'fc'):
			if not x in lst and lst and lst[0] in [x+y for y in ('program', 'shlib', 'stlib')]:
				Logs.error('%r features is probably missing %r' % (self, x))
	TaskGen.feature('*')(check_err_features)

	# check for @extension used with @feature/@before/@after
	old_compile = Build.BuildContext.compile
	def check_compile(self):
		feat = set([])
		for x in list(TaskGen.feats.values()):
			feat.union(set(x))
		for (x, y) in TaskGen.task_gen.prec.items():
			feat.add(x)
			feat.union(set(y))
		ext = set([])
		for x in TaskGen.task_gen.mappings.values():
			ext.add(x.__name__)
		invalid = ext & feat
		if invalid:
			Logs.error('The methods %r have invalid annotations:  @extension <-> @feature/@before/@after' % list(invalid))

		return old_compile(self)
	Build.BuildContext.compile = check_compile
Exemplo n.º 9
0
def enhance_lib():
	for m in meths_typos:
		replace(m)
	old_ant_glob=Node.Node.ant_glob
	def ant_glob(self,*k,**kw):
		if k:
			for x in k[0].split('/'):
				if x=='..':
					Logs.error("In ant_glob pattern %r: '..' means 'two dots', not 'parent directory'"%k[0])
		return old_ant_glob(self,*k,**kw)
	Node.Node.ant_glob=ant_glob
	old=Task.is_before
	def is_before(t1,t2):
		ret=old(t1,t2)
		if ret and old(t2,t1):
			Logs.error('Contradictory order constraints in classes %r %r'%(t1,t2))
		return ret
	Task.is_before=is_before
	def check_err_features(self):
		lst=self.to_list(self.features)
		if'shlib'in lst:
			Logs.error('feature shlib -> cshlib, dshlib or cxxshlib')
		for x in('c','cxx','d','fc'):
			if not x in lst and lst and lst[0]in[x+y for y in('program','shlib','stlib')]:
				Logs.error('%r features is probably missing %r'%(self,x))
	TaskGen.feature('*')(check_err_features)
	old_compile=Build.BuildContext.compile
	def check_compile(self):
		feat=set([])
		for x in list(TaskGen.feats.values()):
			feat.union(set(x))
		for(x,y)in TaskGen.task_gen.prec.items():
			feat.add(x)
			feat.union(set(y))
		ext=set([])
		for x in TaskGen.task_gen.mappings.values():
			ext.add(x.__name__)
		invalid=ext&feat
		if invalid:
			Logs.error('The methods %r have invalid annotations:  @extension <-> @feature/@before/@after'%list(invalid))
		return old_compile(self)
	Build.BuildContext.compile=check_compile
	def getattr(self,name):
		if name=='append'or name=='add':
			raise Errors.WafError('env.append and env.add do not exist: use env.append_value/env.append_unique')
		elif name=='prepend':
			raise Errors.WafError('env.prepend does not exist: use env.prepend_value')
		if name in self.__slots__:
			return object.__getattr__(self,name)
		else:
			return self[name]
	ConfigSet.ConfigSet.__getattr__=getattr
Exemplo n.º 10
0
def build_app(bld, appname, viewname, scriptname=None):
    "build gui"
    name = appname if scriptname is None else scriptname
    build_startupscripts(bld, name, appname + '.' + viewname)
    build_bokehjs(bld, appname + '.' + viewname, scriptname)
    build_doc(bld, scriptname)
    if bld.env.PANDOC:
        TaskGen.declare_chain(name='markdowns',
                              rule='${PANDOC} --toc -s ${SRC} -o ${TGT}',
                              ext_in='.md',
                              ext_out='.html',
                              shell=False,
                              reentrant=False,
                              **bld.installpath())
Exemplo n.º 11
0
def before(*k):
	for key, val in repl.items():
		if key in k:
			if Logs.verbose > 1:
				Logs.info('before %s -> %s' % (key, val))
			k.replace(key, val)
	return TaskGen.before_method(*k)
Exemplo n.º 12
0
Arquivo: Build.py Projeto: zsx/waf
	def __call__(self, *k, **kw):
		"""Creates a task generator"""
		kw['bld'] = self
		ret = TaskGen.task_gen(*k, **kw)
		self.task_gen_cache_names = {} # reset the cache, each time
		self.add_to_group(ret, group=kw.get('group', None))
		return ret
Exemplo n.º 13
0
def after(*k):
	for key, val in repl.items():
		if key in k:
			if Logs.verbose > 1:
				Logs.error('after %s -> %s' % (key, val))
			k.replace(key, val)
	return TaskGen.after_method(*k)
Exemplo n.º 14
0
	def __call__(self, *k, **kw):
		# this is one way of doing it, one could use a task generator method too
		bld = kw['bld'] = bld_proxy(self)
		ret = TaskGen.task_gen(*k, **kw)
		self.task_gen_cache_names = {}
		self.add_to_group(ret, group=kw.get('group'))
		ret.bld = bld
		bld.set_key(ret.path.abspath().replace(os.sep, '') + str(ret.idx))
		return ret
Exemplo n.º 15
0
def _build_pdf(ctx):
    from waflib import TaskGen

    TaskGen.declare_chain(
        name="rst2latex", rule="${RST2LATEX} ${RST2LATEX_FLAGS} ${SRC} ${TGT}", ext_in=".rst", ext_out=".tex"
    )

    TaskGen.declare_chain(
        name="pdflatex", rule="${PDFLATEX} ${PDFLATEX_FLAGS} ${SRC}; " * 2, ext_in=".tex", ext_out=".pdf", shell=True
    )

    ctx.env.RST2LATEX_FLAGS = ["--config=" + ctx.srcnode.abspath() + "/DOCS/man/docutils.conf"]

    ctx.env.PDFLATEX_FLAGS = ["--interaction=batchmode", "--output-directory=DOCS/man/en/", "--jobname=mpv"]

    ctx(source="DOCS/man/en/mpv.rst")
    _add_rst_manual_dependencies(ctx)
    ctx.install_files(ctx.env.DOCDIR, ["DOCS/man/en/mpv.pdf"])
Exemplo n.º 16
0
 def __call__(self, *k, **kw):
     # this is one way of doing it, one could use a task generator method too
     bld = kw['bld'] = bld_proxy(self)
     ret = TaskGen.task_gen(*k, **kw)
     self.task_gen_cache_names = {}
     self.add_to_group(ret, group=kw.get('group'))
     ret.bld = bld
     bld.set_key(ret.path.abspath().replace(os.sep, '') + str(ret.idx))
     return ret
Exemplo n.º 17
0
def enhance_lib():
    for m in meths_typos:
        replace(m)
    old_ant_glob = Node.Node.ant_glob

    def ant_glob(self, *k, **kw):
        for x in k[0].split('/'):
            if x == '..':
                Logs.error(
                    "In ant_glob pattern %r: '..' means 'two dots', not 'parent directory'"
                    % k[0])
        return old_ant_glob(self, *k, **kw)

    Node.Node.ant_glob = ant_glob
    old = Task.is_before

    def is_before(t1, t2):
        ret = old(t1, t2)
        if ret and old(t2, t1):
            Logs.error('Contradictory order constraints in classes %r %r' %
                       (t1, t2))
        return ret

    Task.is_before = is_before

    def check_err_features(self):
        lst = self.to_list(self.features)
        if 'shlib' in lst:
            Logs.error('feature shlib -> cshlib, dshlib or cxxshlib')
        for x in ('c', 'cxx', 'd', 'fc'):
            if not x in lst and lst and lst[0] in [
                    x + y for y in ('program', 'shlib', 'stlib')
            ]:
                Logs.error('%r features is probably missing %r' % (self, x))

    TaskGen.feature('*')(check_err_features)
Exemplo n.º 18
0
Arquivo: Build.py Projeto: SjB/waf
	def __call__(self, *k, **kw):
		"""
		Create a task generator, adding it to the current build group. The following forms are equivalent::

			def build(bld):
				tg = bld(a=1, b=2)

			def build(bld):
				tg = bld()
				tg.a = 1
				tg.b = 2
		"""
		kw['bld'] = self
		ret = TaskGen.task_gen(*k, **kw)
		self.task_gen_cache_names = {} # reset the cache, each time
		self.add_to_group(ret, group=kw.get('group', None))
		return ret
Exemplo n.º 19
0
	def __call__(self, *k, **kw):
		"""
		Create a task generator and add it to the current build group. The following forms are equivalent::

			def build(bld):
				tg = bld(a=1, b=2)

			def build(bld):
				tg = bld()
				tg.a = 1
				tg.b = 2

			def build(bld):
				tg = TaskGen.task_gen(a=1, b=2)
				bld.add_to_group(tg, None)

		:param group: group name to add the task generator to
		:type group: string
		"""
		kw['bld'] = self
		ret = TaskGen.task_gen(*k, **kw)
		self.task_gen_cache_names = {} # reset the cache, each time
		self.add_to_group(ret, group=kw.get('group'))
		return ret
Exemplo n.º 20
0
    def __call__(self, *k, **kw):
        """
		Create a task generator and add it to the current build group. The following forms are equivalent::

			def build(bld):
				tg = bld(a=1, b=2)

			def build(bld):
				tg = bld()
				tg.a = 1
				tg.b = 2

			def build(bld):
				tg = TaskGen.task_gen(a=1, b=2)
				bld.add_to_group(tg, None)

		:param group: group name to add the task generator to
		:type group: string
		"""
        kw['bld'] = self
        ret = TaskGen.task_gen(*k, **kw)
        self.task_gen_cache_names = {}  # reset the cache, each time
        self.add_to_group(ret, group=kw.get('group'))
        return ret
Exemplo n.º 21
0
def build(ctx):
    ctx.load('waf_customizations')
    ctx.load('generators.sources')

    ctx(
        features="file2string",
        source="TOOLS/osxbundle/mpv.app/Contents/Resources/icon.icns",
        target="osdep/macosx_icon.inc",
    )

    ctx(
        features="file2string",
        source="etc/mpv-icon-8bit-16x16.png",
        target="video/out/x11_icon_16.inc",
    )

    ctx(
        features="file2string",
        source="etc/mpv-icon-8bit-32x32.png",
        target="video/out/x11_icon_32.inc",
    )

    ctx(
        features="file2string",
        source="etc/mpv-icon-8bit-64x64.png",
        target="video/out/x11_icon_64.inc",
    )

    ctx(
        features="file2string",
        source="etc/mpv-icon-8bit-128x128.png",
        target="video/out/x11_icon_128.inc",
    )

    ctx(
        features="file2string",
        source="etc/input.conf",
        target="input/input_conf.h",
    )

    ctx(
        features="file2string",
        source="etc/builtin.conf",
        target="player/builtin_conf.inc",
    )

    ctx(
        features="file2string",
        source="sub/osd_font.otf",
        target="sub/osd_font.h",
    )

    lua_files = [
        "defaults.lua", "assdraw.lua", "options.lua", "osc.lua",
        "ytdl_hook.lua", "stats.lua"
    ]

    for fn in lua_files:
        fn = "player/lua/" + fn
        ctx(
            features="file2string",
            source=fn,
            target=os.path.splitext(fn)[0] + ".inc",
        )

    ctx(
        features="file2string",
        source="player/javascript/defaults.js",
        target="player/javascript/defaults.js.inc",
    )

    if ctx.dependency_satisfied('wayland'):
        ctx.wayland_protocol_code(proto_dir=ctx.env.WL_PROTO_DIR,
                                  protocol="stable/xdg-shell/xdg-shell",
                                  target="video/out/wayland/xdg-shell.c")
        ctx.wayland_protocol_header(proto_dir=ctx.env.WL_PROTO_DIR,
                                    protocol="stable/xdg-shell/xdg-shell",
                                    target="video/out/wayland/xdg-shell.h")
        ctx.wayland_protocol_code(
            proto_dir=ctx.env.WL_PROTO_DIR,
            protocol="unstable/idle-inhibit/idle-inhibit-unstable-v1",
            target="video/out/wayland/idle-inhibit-v1.c")
        ctx.wayland_protocol_header(
            proto_dir=ctx.env.WL_PROTO_DIR,
            protocol="unstable/idle-inhibit/idle-inhibit-unstable-v1",
            target="video/out/wayland/idle-inhibit-v1.h")
        ctx.wayland_protocol_code(proto_dir="video/out/wayland",
                                  protocol="server-decoration",
                                  vendored_protocol=True,
                                  target="video/out/wayland/srv-decor.c")
        ctx.wayland_protocol_header(proto_dir="video/out/wayland",
                                    protocol="server-decoration",
                                    vendored_protocol=True,
                                    target="video/out/wayland/srv-decor.h")

    ctx(features="ebml_header", target="ebml_types.h")
    ctx(features="ebml_definitions", target="ebml_defs.c")

    def swift(task):
        src = ' '.join([x.abspath() for x in task.inputs])
        bridge = ctx.path.find_node("osdep/macOS_swift_bridge.h").abspath()
        tgt = task.outputs[0].abspath()
        header = task.outputs[1].abspath()
        module = task.outputs[2].abspath()

        cmd = ('%s %s -module-name macOS_swift -emit-module-path %s '
               '-import-objc-header %s -emit-objc-header-path %s -o %s %s '
               '-I. -I%s') % (ctx.env.SWIFT, ctx.env.SWIFT_FLAGS, module,
                              bridge, header, tgt, src, ctx.srcnode.abspath())
        return task.exec_command(cmd)

    if ctx.dependency_satisfied('macos-cocoa-cb'):
        swift_source = [
            ("osdep/macOS_mpv_helper.swift"),
            ("video/out/cocoa-cb/events_view.swift"),
            ("video/out/cocoa-cb/video_layer.swift"),
            ("video/out/cocoa-cb/window.swift"),
            ("video/out/cocoa_cb_common.swift"),
        ]

        ctx(
            rule=swift,
            source=ctx.filtered_sources(swift_source),
            target=('osdep/macOS_swift.o '
                    'osdep/macOS_swift.h '
                    'osdep/macOS_swift.swiftmodule'),
            before='c',
        )

        ctx.env.append_value('LINKFLAGS', [
            '-Xlinker', '-add_ast_path', '-Xlinker',
            '%s' % ctx.path.find_or_declare(
                "osdep/macOS_swift.swiftmodule").abspath()
        ])

    if ctx.dependency_satisfied('cplayer'):
        main_fn_c = ctx.pick_first_matching_dep([
            ("osdep/main-fn-cocoa.c", "cocoa"),
            ("osdep/main-fn-unix.c", "posix"),
            ("osdep/main-fn-win.c", "win32-desktop"),
        ])

    getch2_c = ctx.pick_first_matching_dep([
        ("osdep/terminal-unix.c", "posix"),
        ("osdep/terminal-win.c", "win32-desktop"),
        ("osdep/terminal-dummy.c"),
    ])

    timer_c = ctx.pick_first_matching_dep([
        ("osdep/timer-win2.c", "os-win32"),
        ("osdep/timer-darwin.c", "os-darwin"),
        ("osdep/timer-linux.c", "posix"),
    ])

    ipc_c = ctx.pick_first_matching_dep([
        ("input/ipc-unix.c", "posix"),
        ("input/ipc-win.c", "win32-desktop"),
        ("input/ipc-dummy.c"),
    ])

    subprocess_c = ctx.pick_first_matching_dep([
        ("osdep/subprocess-posix.c", "posix-spawn"),
        ("osdep/subprocess-win.c", "win32-desktop"),
        ("osdep/subprocess-dummy.c"),
    ])

    sources = [
        ## Audio
        ("audio/aframe.c"),
        ("audio/audio_buffer.c"),
        ("audio/chmap.c"),
        ("audio/chmap_sel.c"),
        ("audio/decode/ad_lavc.c"),
        ("audio/decode/ad_spdif.c"),
        ("audio/filter/af_format.c"),
        ("audio/filter/af_lavcac3enc.c"),
        ("audio/filter/af_lavrresample.c"),
        ("audio/filter/af_rubberband.c", "rubberband"),
        ("audio/filter/af_scaletempo.c"),
        ("audio/fmt-conversion.c"),
        ("audio/format.c"),
        ("audio/out/ao.c"),
        ("audio/out/ao_alsa.c", "alsa"),
        ("audio/out/ao_audiounit.m", "audiounit"),
        ("audio/out/ao_coreaudio.c", "coreaudio"),
        ("audio/out/ao_coreaudio_chmap.c", "audiounit"),
        ("audio/out/ao_coreaudio_chmap.c", "coreaudio"),
        ("audio/out/ao_coreaudio_exclusive.c", "coreaudio"),
        ("audio/out/ao_coreaudio_properties.c", "coreaudio"),
        ("audio/out/ao_coreaudio_utils.c", "audiounit"),
        ("audio/out/ao_coreaudio_utils.c", "coreaudio"),
        ("audio/out/ao_jack.c", "jack"),
        ("audio/out/ao_lavc.c"),
        ("audio/out/ao_null.c"),
        ("audio/out/ao_openal.c", "openal"),
        ("audio/out/ao_opensles.c", "opensles"),
        ("audio/out/ao_oss.c", "oss-audio"),
        ("audio/out/ao_pcm.c"),
        ("audio/out/ao_pulse.c", "pulse"),
        ("audio/out/ao_rsound.c", "rsound"),
        ("audio/out/ao_sdl.c", "sdl2"),
        ("audio/out/ao_sndio.c", "sndio"),
        ("audio/out/ao_wasapi.c", "wasapi"),
        ("audio/out/ao_wasapi_changenotify.c", "wasapi"),
        ("audio/out/ao_wasapi_utils.c", "wasapi"),
        ("audio/out/pull.c"),
        ("audio/out/push.c"),

        ## Core
        ("common/av_common.c"),
        ("common/av_log.c"),
        ("common/codecs.c"),
        ("common/common.c"),
        ("common/encode_lavc.c"),
        ("common/msg.c"),
        ("common/playlist.c"),
        ("common/recorder.c"),
        ("common/tags.c"),
        ("common/version.c"),

        ## Demuxers
        ("demux/codec_tags.c"),
        ("demux/cue.c"),
        ("demux/demux.c"),
        ("demux/demux_cue.c"),
        ("demux/demux_disc.c"),
        ("demux/demux_edl.c"),
        ("demux/demux_lavf.c"),
        ("demux/demux_libarchive.c", "libarchive"),
        ("demux/demux_mf.c"),
        ("demux/demux_mkv.c"),
        ("demux/demux_mkv_timeline.c"),
        ("demux/demux_null.c"),
        ("demux/demux_playlist.c"),
        ("demux/demux_rar.c"),
        ("demux/demux_raw.c"),
        ("demux/demux_timeline.c"),
        ("demux/demux_tv.c", "tv"),
        ("demux/ebml.c"),
        ("demux/packet.c"),
        ("demux/timeline.c"),
        ("filters/f_autoconvert.c"),
        ("filters/f_auto_filters.c"),
        ("filters/f_decoder_wrapper.c"),
        ("filters/f_demux_in.c"),
        ("filters/f_hwtransfer.c"),
        ("filters/f_lavfi.c"),
        ("filters/f_output_chain.c"),
        ("filters/f_swresample.c"),
        ("filters/f_swscale.c"),
        ("filters/f_utils.c"),
        ("filters/filter.c"),
        ("filters/frame.c"),
        ("filters/user_filters.c"),

        ## Input
        ("input/cmd.c"),
        ("input/event.c"),
        ("input/input.c"),
        ("input/ipc.c"),
        (ipc_c),
        ("input/keycodes.c"),
        ("input/pipe-win32.c", "win32-pipes"),

        ## Misc
        ("misc/bstr.c"),
        ("misc/charset_conv.c"),
        ("misc/dispatch.c"),
        ("misc/json.c"),
        ("misc/node.c"),
        ("misc/rendezvous.c"),
        ("misc/ring.c"),
        ("misc/thread_pool.c"),

        ## Options
        ("options/m_config.c"),
        ("options/m_option.c"),
        ("options/m_property.c"),
        ("options/options.c"),
        ("options/parse_commandline.c"),
        ("options/parse_configfile.c"),
        ("options/path.c"),

        ## Player
        ("player/audio.c"),
        ("player/client.c"),
        ("player/command.c"),
        ("player/configfiles.c"),
        ("player/external_files.c"),
        ("player/javascript.c", "javascript"),
        ("player/loadfile.c"),
        ("player/lua.c", "lua"),
        ("player/main.c"),
        ("player/misc.c"),
        ("player/osd.c"),
        ("player/playloop.c"),
        ("player/screenshot.c"),
        ("player/scripting.c"),
        ("player/sub.c"),
        ("player/video.c"),

        ## Streams
        ("stream/ai_alsa1x.c", "alsa && audio-input"),
        ("stream/ai_oss.c", "oss-audio && audio-input"),
        ("stream/ai_sndio.c", "sndio && audio-input"),
        ("stream/audio_in.c", "audio-input"),
        ("stream/cache.c"),
        ("stream/cache_file.c"),
        ("stream/cookies.c"),
        ("stream/dvb_tune.c", "dvbin"),
        ("stream/frequencies.c", "tv"),
        ("stream/rar.c"),
        ("stream/stream.c"),
        ("stream/stream_avdevice.c"),
        ("stream/stream_bluray.c", "libbluray"),
        ("stream/stream_cb.c"),
        ("stream/stream_cdda.c", "cdda"),
        ("stream/stream_dvb.c", "dvbin"),
        ("stream/stream_dvd.c", "dvdread-common"),
        ("stream/stream_dvd_common.c", "dvdread-common"),
        ("stream/stream_dvdnav.c", "dvdnav"),
        ("stream/stream_edl.c"),
        ("stream/stream_file.c"),
        ("stream/stream_lavf.c"),
        ("stream/stream_libarchive.c", "libarchive"),
        ("stream/stream_memory.c"),
        ("stream/stream_mf.c"),
        ("stream/stream_null.c"),
        ("stream/stream_rar.c"),
        ("stream/stream_smb.c", "libsmbclient"),
        ("stream/stream_tv.c", "tv"),
        ("stream/tv.c", "tv"),
        ("stream/tvi_dummy.c", "tv"),
        ("stream/tvi_v4l2.c", "tv-v4l2"),

        ## Subtitles
        ("sub/ass_mp.c", "libass"),
        ("sub/dec_sub.c"),
        ("sub/draw_bmp.c"),
        ("sub/filter_sdh.c"),
        ("sub/img_convert.c"),
        ("sub/lavc_conv.c"),
        ("sub/osd.c"),
        ("sub/osd_dummy.c", "dummy-osd"),
        ("sub/osd_libass.c", "libass-osd"),
        ("sub/sd_ass.c", "libass"),
        ("sub/sd_lavc.c"),

        ## Video
        ("video/csputils.c"),
        ("video/d3d.c", "d3d-hwaccel"),
        ("video/decode/vd_lavc.c"),
        #( "video/filter/vf_canny.c",             "opencv" ),
        ("video/filter/vf_vector.c", "opencv"),
        ("video/filter/vf_vectorraster.c"),
        ("video/filter/refqueue.c"),
        ("video/filter/vf_d3d11vpp.c", "d3d-hwaccel"),
        ("video/filter/vf_format.c"),
        ("video/filter/vf_sub.c"),
        ("video/filter/vf_vapoursynth.c", "vapoursynth-core"),
        ("video/filter/vf_vavpp.c", "vaapi"),
        ("video/filter/vf_vdpaupp.c", "vdpau"),
        ("video/fmt-conversion.c"),
        ("video/hwdec.c"),
        ("video/image_loader.c"),
        ("video/image_writer.c"),
        ("video/img_format.c"),
        ("video/mp_image.c"),
        ("video/mp_image_pool.c"),
        ("video/out/aspect.c"),
        ("video/out/bitmap_packer.c"),
        ("video/out/cocoa/events_view.m", "cocoa"),
        ("video/out/cocoa/video_view.m", "cocoa"),
        ("video/out/cocoa/window.m", "cocoa"),
        ("video/out/cocoa_common.m", "cocoa"),
        ("video/out/d3d11/context.c", "d3d11"),
        ("video/out/d3d11/hwdec_d3d11va.c", "d3d11 && d3d-hwaccel"),
        ("video/out/d3d11/hwdec_dxva2dxgi.c", "d3d11 && d3d9-hwaccel"),
        ("video/out/d3d11/ra_d3d11.c", "d3d11"),
        ("video/out/dither.c"),
        ("video/out/dr_helper.c"),
        ("video/out/drm_atomic.c", "drm"),
        ("video/out/drm_common.c", "drm"),
        ("video/out/drm_prime.c", "drm && drmprime"),
        ("video/out/filter_kernels.c"),
        ("video/out/gpu/context.c"),
        ("video/out/gpu/d3d11_helpers.c", "d3d11 || egl-angle-win32"),
        ("video/out/gpu/hwdec.c"),
        ("video/out/gpu/lcms.c"),
        ("video/out/gpu/libmpv_gpu.c"),
        ("video/out/gpu/osd.c"),
        ("video/out/gpu/ra.c"),
        ("video/out/gpu/shader_cache.c"),
        ("video/out/gpu/spirv.c"),
        ("video/out/gpu/spirv_shaderc.c", "shaderc"),
        ("video/out/gpu/user_shaders.c"),
        ("video/out/gpu/utils.c"),
        ("video/out/gpu/video.c"),
        ("video/out/gpu/video_shaders.c"),
        ("video/out/opengl/angle_dynamic.c", "egl-angle"),
        ("video/out/opengl/common.c", "gl"),
        ("video/out/opengl/context.c", "gl"),
        ("video/out/opengl/context_android.c", "egl-android"),
        ("video/out/opengl/context_angle.c", "egl-angle-win32"),
        ("video/out/opengl/context_cocoa.c", "gl-cocoa"),
        ("video/out/opengl/context_drm_egl.c", "egl-drm"),
        ("video/out/opengl/context_dxinterop.c", "gl-dxinterop"),
        ("video/out/opengl/context_glx.c", "gl-x11"),
        ("video/out/opengl/context_mali_fbdev.c", "mali-fbdev"),
        ("video/out/opengl/context_rpi.c", "rpi"),
        ("video/out/opengl/context_vdpau.c", "vdpau-gl-x11"),
        ("video/out/opengl/context_wayland.c", "gl-wayland"),
        ("video/out/opengl/context_win.c", "gl-win32"),
        ("video/out/opengl/context_x11egl.c", "egl-x11"),
        ("video/out/opengl/egl_helpers.c", "egl-helpers"),
        ("video/out/opengl/formats.c", "gl"),
        ("video/out/opengl/hwdec_cuda.c", "cuda-hwaccel"),
        ("video/out/opengl/hwdec_d3d11egl.c", "d3d-hwaccel && egl-angle"),
        ("video/out/opengl/hwdec_d3d11eglrgb.c", "d3d-hwaccel && egl-angle"),
        ("video/out/opengl/hwdec_drmprime_drm.c", "drmprime && drm"),
        ("video/out/opengl/hwdec_dxva2egl.c", "d3d9-hwaccel && egl-angle"),
        ("video/out/opengl/hwdec_dxva2gldx.c", "gl-dxinterop-d3d9"),
        ("video/out/opengl/hwdec_ios.m", "ios-gl"),
        ("video/out/opengl/hwdec_osx.c", "videotoolbox-gl"),
        ("video/out/opengl/hwdec_rpi.c", "rpi"),
        ("video/out/opengl/hwdec_vaegl.c", "vaapi-egl"),
        ("video/out/opengl/hwdec_vdpau.c", "vdpau-gl-x11"),
        ("video/out/opengl/libmpv_gl.c", "gl"),
        ("video/out/opengl/ra_gl.c", "gl"),
        ("video/out/opengl/utils.c", "gl"),
        ("video/out/vo.c"),
        ("video/out/vo_caca.c", "caca"),
        ("video/out/vo_direct3d.c", "direct3d"),
        ("video/out/vo_drm.c", "drm"),
        ("video/out/vo_gpu.c"),
        ("video/out/vo_image.c"),
        ("video/out/vo_lavc.c"),
        ("video/out/vo_libmpv.c"),
        ("video/out/vo_mediacodec_embed.c", "android"),
        ("video/out/vo_null.c"),
        ("video/out/vo_rpi.c", "rpi"),
        ("video/out/vo_sdl.c", "sdl2"),
        ("video/out/vo_tct.c"),
        ("video/out/vo_vaapi.c", "vaapi-x11 && gpl"),
        ("video/out/vo_vdpau.c", "vdpau"),
        ("video/out/vo_x11.c", "x11"),
        ("video/out/vo_xv.c", "xv"),
        ("video/out/vo_pixelflut.c"),
        ("video/out/vo_pixelflut2.c"),
        ("video/out/vo_pixelflutudp.c"),
        ("video/out/vo_pixelfluteth0.c"),
        ("video/out/vo_pixelflutentropia.c"),
        ("video/out/vo_matelight.c"),
        ("video/out/vulkan/context.c", "vulkan"),
        ("video/out/vulkan/context_wayland.c", "vulkan && wayland"),
        ("video/out/vulkan/context_win.c", "vulkan && win32-desktop"),
        ("video/out/vulkan/context_xlib.c", "vulkan && x11"),
        ("video/out/vulkan/formats.c", "vulkan"),
        ("video/out/vulkan/malloc.c", "vulkan"),
        ("video/out/vulkan/ra_vk.c", "vulkan"),
        ("video/out/vulkan/spirv_nvidia.c", "vulkan"),
        ("video/out/vulkan/utils.c", "vulkan"),
        ("video/out/w32_common.c", "win32-desktop"),
        ("video/out/wayland/idle-inhibit-v1.c", "wayland"),
        ("video/out/wayland/srv-decor.c", "wayland"),
        ("video/out/wayland/xdg-shell.c", "wayland"),
        ("video/out/wayland_common.c", "wayland"),
        ("video/out/win32/displayconfig.c", "win32-desktop"),
        ("video/out/win32/droptarget.c", "win32-desktop"),
        ("video/out/win_state.c"),
        ("video/out/x11_common.c", "x11"),
        ("video/sws_utils.c"),
        ("video/vaapi.c", "vaapi"),
        ("video/vdpau.c", "vdpau"),
        ("video/vdpau_mixer.c", "vdpau"),

        ## osdep
        (getch2_c),
        ("osdep/io.c"),
        ("osdep/threads.c"),
        ("osdep/timer.c"),
        (timer_c),
        ("osdep/polldev.c", "posix"),
        ("osdep/android/posix-spawn.c", "android"),
        ("osdep/android/strnlen.c", "android"),
        ("osdep/ar/HIDRemote.m", "apple-remote"),
        ("osdep/glob-win.c", "glob-win32"),
        ("osdep/macosx_application.m", "cocoa"),
        ("osdep/macosx_events.m", "cocoa"),
        ("osdep/macosx_menubar.m", "cocoa"),
        ("osdep/macosx_touchbar.m", "macos-touchbar"),
        ("osdep/mpv.rc", "win32-executable"),
        ("osdep/path-macosx.m", "cocoa"),
        ("osdep/path-unix.c"),
        ("osdep/path-uwp.c", "uwp"),
        ("osdep/path-win.c", "win32-desktop"),
        ("osdep/semaphore_osx.c"),
        ("osdep/subprocess.c"),
        (subprocess_c),
        ("osdep/w32_keyboard.c", "os-cygwin"),
        ("osdep/w32_keyboard.c", "os-win32"),
        ("osdep/win32/pthread.c", "win32-internal-pthreads"),
        ("osdep/windows_utils.c", "os-cygwin"),
        ("osdep/windows_utils.c", "os-win32"),

        ## tree_allocator
        "ta/ta.c",
        "ta/ta_talloc.c",
        "ta/ta_utils.c"
    ]

    if ctx.dependency_satisfied('win32-executable'):
        from waflib import TaskGen

        TaskGen.declare_chain(name='windres',
                              rule='${WINDRES} ${WINDRES_FLAGS} ${SRC} ${TGT}',
                              ext_in='.rc',
                              ext_out='-rc.o',
                              color='PINK')

        ctx.env.WINDRES_FLAGS = [
            '--include-dir={0}'.format(ctx.bldnode.abspath()),
            '--include-dir={0}'.format(ctx.srcnode.abspath()),
            '--codepage=65001'  # Unicode codepage
        ]

        for node in 'osdep/mpv.exe.manifest etc/mpv-icon.ico'.split():
            ctx.add_manual_dependency(ctx.path.find_node('osdep/mpv.rc'),
                                      ctx.path.find_node(node))

        version = ctx.bldnode.find_node('version.h')
        if version:
            ctx.add_manual_dependency(ctx.path.find_node('osdep/mpv.rc'),
                                      version)

    if ctx.dependency_satisfied('cplayer') or ctx.dependency_satisfied('test'):
        ctx(
            target="objects",
            source=ctx.filtered_sources(sources),
            use=ctx.dependencies_use(),
            includes=_all_includes(ctx),
            features="c",
        )

    syms = False
    if ctx.dependency_satisfied('cplugins'):
        syms = True
        ctx.load("syms")

    if ctx.dependency_satisfied('cplayer'):
        ctx(
            target="mpv",
            source=main_fn_c,
            use=ctx.dependencies_use() + ['objects'],
            add_object="osdep/macOS_swift.o",
            includes=_all_includes(ctx),
            features="c cprogram" + (" syms" if syms else ""),
            export_symbols_def="libmpv/mpv.def",  # for syms=True
            install_path=ctx.env.BINDIR)
        for f in ['mpv.conf', 'input.conf', 'mplayer-input.conf', \
                  'restore-old-bindings.conf']:
            ctx.install_as(os.path.join(ctx.env.DOCDIR, f),
                           os.path.join('etc/', f))

        if ctx.env.DEST_OS == 'win32':
            wrapctx = ctx(target="mpv",
                          source=['osdep/win32-console-wrapper.c'],
                          features="c cprogram",
                          install_path=ctx.env.BINDIR)

            wrapctx.env.cprogram_PATTERN = "%s.com"
            wrapflags = ['-municode', '-mconsole']
            wrapctx.env.CFLAGS = ctx.env.CFLAGS + wrapflags
            wrapctx.env.LAST_LINKFLAGS = ctx.env.LAST_LINKFLAGS + wrapflags

    if ctx.dependency_satisfied('test'):
        for test in ctx.path.ant_glob("test/*.c"):
            ctx(
                target=os.path.splitext(test.srcpath())[0],
                source=test.srcpath(),
                use=ctx.dependencies_use() + ['objects'],
                includes=_all_includes(ctx),
                features="c cprogram",
                install_path=None,
            )

    build_shared = ctx.dependency_satisfied('libmpv-shared')
    build_static = ctx.dependency_satisfied('libmpv-static')
    if build_shared or build_static:
        if build_shared:
            waftoolsdir = os.path.join(os.path.dirname(__file__), "waftools")
            ctx.load("syms", tooldir=waftoolsdir)
        vre = '#define MPV_CLIENT_API_VERSION MPV_MAKE_VERSION\((.*), (.*)\)'
        libmpv_header = ctx.path.find_node("libmpv/client.h").read()
        major, minor = re.search(vre, libmpv_header).groups()
        libversion = major + '.' + minor + '.0'

        def _build_libmpv(shared):
            features = "c "
            if shared:
                features += "cshlib syms"
            else:
                features += "cstlib"

            libmpv_kwargs = {
                "target": "mpv",
                "source":   ctx.filtered_sources(sources),
                "use":      ctx.dependencies_use(),
                "add_object": "osdep/macOS_swift.o",
                "includes": [ctx.bldnode.abspath(), ctx.srcnode.abspath()] + \
                             ctx.dependencies_includes(),
                "features": features,
                "export_symbols_def": "libmpv/mpv.def",
                "install_path": ctx.env.LIBDIR,
                "install_path_implib": ctx.env.LIBDIR,
            }

            if shared and ctx.dependency_satisfied('android'):
                # for Android we just add the linker flag without version
                # as we still need the SONAME for proper linkage.
                # (LINKFLAGS logic taken from waf's apply_vnum in ccroot.py)
                v = ctx.env.SONAME_ST % 'libmpv.so'
                ctx.env.append_value('LINKFLAGS', v.split())
            else:
                # for all other configurations we want SONAME to be used
                libmpv_kwargs["vnum"] = libversion

            if shared and ctx.env.DEST_OS == 'win32':
                libmpv_kwargs["install_path"] = ctx.env.BINDIR

            ctx(**libmpv_kwargs)

        if build_shared:
            _build_libmpv(True)
        if build_static:
            _build_libmpv(False)

        def get_deps():
            res = []
            for k in ctx.env.keys():
                if (k.startswith("LIB_") and k != "LIB_ST") \
                or (k.startswith("STLIB_") and k != "STLIB_ST" and k != "STLIB_MARKER"):
                    for l in ctx.env[k]:
                        if l in res:
                            res.remove(l)
                        res.append(l)
            return " ".join(["-l" + l for l in res])

        ctx(
            target='libmpv/mpv.pc',
            source='libmpv/mpv.pc.in',
            features='subst',
            PREFIX=ctx.env.PREFIX,
            LIBDIR=ctx.env.LIBDIR,
            INCDIR=ctx.env.INCLUDEDIR,
            VERSION=libversion,
            PRIV_LIBS=get_deps(),
        )

        headers = [
            "client.h", "qthelper.hpp", "opengl_cb.h", "render.h",
            "render_gl.h", "stream_cb.h"
        ]
        for f in headers:
            ctx.install_as(ctx.env.INCLUDEDIR + '/mpv/' + f, 'libmpv/' + f)

        ctx.install_as(ctx.env.LIBDIR + '/pkgconfig/mpv.pc', 'libmpv/mpv.pc')

    if ctx.dependency_satisfied('html-build'):
        _build_html(ctx)

    if ctx.dependency_satisfied('manpage-build'):
        _build_man(ctx)

    if ctx.dependency_satisfied('pdf-build'):
        _build_pdf(ctx)

    if ctx.dependency_satisfied('cplayer'):

        if ctx.dependency_satisfied('zsh-comp'):
            ctx.zshcomp(target="etc/_mpv", source="TOOLS/zsh.pl")
            ctx.install_files(ctx.env.ZSHDIR, ['etc/_mpv'])

        ctx.install_files(ctx.env.DATADIR + '/applications',
                          ['etc/mpv.desktop'])

        ctx.install_files(ctx.env.CONFDIR, ['etc/encoding-profiles.conf'])

        for size in '16x16 32x32 64x64'.split():
            ctx.install_as(
                ctx.env.DATADIR + '/icons/hicolor/' + size + '/apps/mpv.png',
                'etc/mpv-icon-8bit-' + size + '.png')

        ctx.install_as(
            ctx.env.DATADIR + '/icons/hicolor/scalable/apps/mpv.svg',
            'etc/mpv-gradient.svg')

        ctx.install_files(ctx.env.DATADIR + '/icons/hicolor/symbolic/apps',
                          ['etc/mpv-symbolic.svg'])
Exemplo n.º 22
0
            tool.process_file(infile, outfile)
        except fypp.FyppError as err:
            msg = ("%s [%s:%d]" % (err.msg, err.fname, err.span[0] + 1))
            raise FyppPreprocError(msg)
        return 0

    def scan(self):
        parser = FyppIncludeParser(self.generator.includes_nodes)
        nodes, names = parser.parse(self.inputs[0])
        if Logs.verbose:
            Logs.debug('deps: deps for %r: %r; unresolved: %r' %
                       (self.inputs, nodes, names))
        return (nodes, names)


TaskGen.feature('fypp')(Tools.ccroot.propagate_uselib_vars)
TaskGen.feature('fypp')(Tools.ccroot.apply_incpaths)

################################################################################
# Helper routines
################################################################################


class FyppIncludeParser(object):
    '''Parser for include directives in files preprocessed by Fypp.

	It can not handle conditional includes.
	'''

    # Include file pattern, opening and closing quoute must be replaced inside.
    INCLUDE_PATTERN = re.compile(r'^\s*#:include\s*(["\'])(?P<incfile>.+?)\1',
    if not env.PROC_TNS_ADMIN:
        env.PROC_TNS_ADMIN = cnf.options.tns_admin
    if not env.PROC_CONNECTION:
        env.PROC_CONNECTION = cnf.options.connection
    cnf.find_program("proc", var="PROC", path_list=env.PROC_ORACLE + path.sep + "bin")


def proc(tsk):
    env = tsk.env
    gen = tsk.generator
    bld = gen.bld
    inc_nodes = gen.to_incnodes(Utils.to_list(getattr(gen, "includes", [])) + env["INCLUDES"])

    # FIXME the if-else construct will not work in python 2
    cmd = (
        [env.PROC]
        + ["SQLCHECK=SEMANTICS"]
        + (["SYS_INCLUDE=(" + ",".join(env.PROC_INCLUDES) + ")"] if env.PROC_INCLUDES else [])
        + ["INCLUDE=(" + ",".join([i.bldpath() for i in inc_nodes]) + ")"]
        + ["userid=" + env.PROC_CONNECTION]
        + ["INAME=" + tsk.inputs[0].bldpath()]
        + ["ONAME=" + tsk.outputs[0].bldpath()]
    )
    exec_env = {"ORACLE_HOME": env.PROC_ORACLE, "LD_LIBRARY_PATH": env.PROC_ORACLE + path.sep + "lib"}
    if env.PROC_TNS_ADMIN:
        exec_env["TNS_ADMIN"] = env.PROC_TNS_ADMIN
    return tsk.exec_command(cmd, env=exec_env)


TaskGen.declare_chain(name="proc", rule=proc, ext_in=".pc", ext_out=".c")
Exemplo n.º 24
0
Arquivo: c.py Projeto: Gear61/cs118
    return self.create_compiled_task('c', node)


class c(Task.Task):
    run_str = '${CC} ${ARCH_ST:ARCH} ${CFLAGS} ${CPPFLAGS} ${FRAMEWORKPATH_ST:FRAMEWORKPATH} ${CPPPATH_ST:INCPATHS} ${DEFINES_ST:DEFINES} ${CC_SRC_F}${SRC} ${CC_TGT_F}${TGT}'
    vars = ['CCDEPS']
    ext_in = ['.h']
    scan = c_preproc.scan


Task.classes['cc'] = cc = c


class cprogram(link_task):
    run_str = '${LINK_CC} ${LINKFLAGS} ${CCLNK_SRC_F}${SRC} ${CCLNK_TGT_F}${TGT[0].abspath()} ${RPATH_ST:RPATH} ${FRAMEWORKPATH_ST:FRAMEWORKPATH} ${FRAMEWORK_ST:FRAMEWORK} ${ARCH_ST:ARCH} ${STLIB_MARKER} ${STLIBPATH_ST:STLIBPATH} ${STLIB_ST:STLIB} ${SHLIB_MARKER} ${LIBPATH_ST:LIBPATH} ${LIB_ST:LIB}'
    ext_out = ['.bin']
    vars = ['LINKDEPS']
    inst_to = '${BINDIR}'
    chmod = Utils.O755


class cshlib(cprogram):
    inst_to = '${LIBDIR}'


class cstlib(stlink_task):
    pass


TaskGen.extension('.c')(c_hook)
Exemplo n.º 25
0
    def declare_chain(self, *k, **kw):
        """
		Wraps :py:func:`waflib.TaskGen.declare_chain` for convenience
		"""
        return TaskGen.declare_chain(*k, **kw)
Exemplo n.º 26
0
def build(ctx):
    ctx.load('waf_customizations')
    ctx.load('generators.sources')

    ctx.file2string(
        source="TOOLS/osxbundle/mpv.app/Contents/Resources/icon.icns",
        target="osdep/macosx_icon.inc")

    ctx.file2string(source="video/out/x11_icon.bin",
                    target="video/out/x11_icon.inc")

    ctx.file2string(source="etc/input.conf", target="input/input_conf.h")

    ctx.file2string(source="sub/osd_font.otf", target="sub/osd_font.h")

    ctx.file2string(source="video/out/opengl/nnedi3_weights.bin",
                    target="video/out/opengl/nnedi3_weights.inc")

    lua_files = [
        "defaults.lua", "assdraw.lua", "options.lua", "osc.lua",
        "ytdl_hook.lua"
    ]
    for fn in lua_files:
        fn = "player/lua/" + fn
        ctx.file2string(source=fn, target=os.path.splitext(fn)[0] + ".inc")

    ctx.matroska_header(source="demux/ebml.c demux/demux_mkv.c",
                        target="ebml_types.h")

    ctx.matroska_definitions(source="demux/ebml.c", target="ebml_defs.c")

    if ctx.env.DEST_OS == 'win32':
        main_fn_c = 'osdep/main-fn-win.c'
    elif ctx.dependency_satisfied('cocoa'):
        main_fn_c = 'osdep/main-fn-cocoa.c'
    else:
        main_fn_c = 'osdep/main-fn-unix.c'

    getch2_c = {
        'win32': 'osdep/terminal-win.c',
    }.get(ctx.env.DEST_OS, "osdep/terminal-unix.c")

    timer_c = {
        'win32': 'osdep/timer-win2.c',
        'darwin': 'osdep/timer-darwin.c',
    }.get(ctx.env.DEST_OS, "osdep/timer-linux.c")

    sources = [
        ## Audio
        ("audio/audio.c"),
        ("audio/audio_buffer.c"),
        ("audio/chmap.c"),
        ("audio/chmap_sel.c"),
        ("audio/fmt-conversion.c"),
        ("audio/format.c"),
        ("audio/mixer.c"),
        ("audio/decode/ad_lavc.c"),
        ("audio/decode/ad_spdif.c"),
        ("audio/decode/dec_audio.c"),
        ("audio/filter/af.c"),
        ("audio/filter/af_channels.c"),
        ("audio/filter/af_delay.c"),
        ("audio/filter/af_drc.c"),
        ("audio/filter/af_equalizer.c"),
        ("audio/filter/af_format.c"),
        ("audio/filter/af_lavcac3enc.c"),
        ("audio/filter/af_lavfi.c"),
        ("audio/filter/af_lavrresample.c"),
        ("audio/filter/af_pan.c"),
        ("audio/filter/af_rubberband.c", "rubberband"),
        ("audio/filter/af_scaletempo.c"),
        ("audio/filter/af_volume.c"),
        ("audio/filter/tools.c"),
        ("audio/out/ao.c"),
        ("audio/out/ao_alsa.c", "alsa"),
        ("audio/out/ao_coreaudio.c", "coreaudio"),
        ("audio/out/ao_coreaudio_chmap.c", "coreaudio"),
        ("audio/out/ao_coreaudio_exclusive.c", "coreaudio"),
        ("audio/out/ao_coreaudio_properties.c", "coreaudio"),
        ("audio/out/ao_coreaudio_utils.c", "coreaudio"),
        ("audio/out/ao_jack.c", "jack"),
        ("audio/out/ao_lavc.c", "encoding"),
        ("audio/out/ao_null.c"),
        ("audio/out/ao_openal.c", "openal"),
        ("audio/out/ao_oss.c", "oss-audio"),
        ("audio/out/ao_pcm.c"),
        ("audio/out/ao_pulse.c", "pulse"),
        ("audio/out/ao_rsound.c", "rsound"),
        ("audio/out/ao_sdl.c", "sdl1"),
        ("audio/out/ao_sdl.c", "sdl2"),
        ("audio/out/ao_sndio.c", "sndio"),
        ("audio/out/ao_wasapi.c", "wasapi"),
        ("audio/out/ao_wasapi_utils.c", "wasapi"),
        ("audio/out/ao_wasapi_changenotify.c", "wasapi"),
        ("audio/out/pull.c"),
        ("audio/out/push.c"),

        ## Core
        ("common/av_common.c"),
        ("common/av_log.c"),
        ("common/codecs.c"),
        ("common/encode_lavc.c", "encoding"),
        ("common/common.c"),
        ("common/tags.c"),
        ("common/msg.c"),
        ("common/playlist.c"),
        ("common/version.c"),

        ## Demuxers
        ("demux/codec_tags.c"),
        ("demux/cue.c"),
        ("demux/demux.c"),
        ("demux/demux_cue.c"),
        ("demux/demux_disc.c"),
        ("demux/demux_edl.c"),
        ("demux/demux_lavf.c"),
        ("demux/demux_libarchive.c", "libarchive"),
        ("demux/demux_mf.c"),
        ("demux/demux_mkv.c"),
        ("demux/demux_mkv_timeline.c"),
        ("demux/demux_playlist.c"),
        ("demux/demux_raw.c"),
        ("demux/demux_rar.c"),
        ("demux/demux_timeline.c"),
        ("demux/demux_tv.c", "tv"),
        ("demux/ebml.c"),
        ("demux/packet.c"),
        ("demux/timeline.c"),

        ## Input
        ("input/cmd_list.c"),
        ("input/cmd_parse.c"),
        ("input/event.c"),
        ("input/input.c"),
        ("input/ipc.c", "!mingw"),
        ("input/keycodes.c"),
        ("input/pipe-win32.c", "mingw"),

        ## Misc
        ("misc/bstr.c"),
        ("misc/charset_conv.c"),
        ("misc/dispatch.c"),
        ("misc/json.c"),
        ("misc/ring.c"),
        ("misc/rendezvous.c"),

        ## Options
        ("options/m_config.c"),
        ("options/m_option.c"),
        ("options/m_property.c"),
        ("options/options.c"),
        ("options/parse_commandline.c"),
        ("options/parse_configfile.c"),
        ("options/path.c"),

        ## Player
        ("player/audio.c"),
        ("player/client.c"),
        ("player/command.c"),
        ("player/configfiles.c"),
        ("player/external_files.c"),
        ("player/loadfile.c"),
        ("player/main.c"),
        ("player/misc.c"),
        ("player/lavfi.c"),
        ("player/lua.c", "lua"),
        ("player/osd.c"),
        ("player/playloop.c"),
        ("player/screenshot.c"),
        ("player/scripting.c"),
        ("player/sub.c"),
        ("player/video.c"),

        ## Streams
        ("stream/ai_alsa1x.c", "alsa"),
        ("stream/ai_oss.c", "oss-audio"),
        ("stream/ai_sndio.c", "sndio"),
        ("stream/audio_in.c", "audio-input"),
        ("stream/cache.c"),
        ("stream/cache_file.c"),
        ("stream/cookies.c"),
        ("stream/dvb_tune.c", "dvbin"),
        ("stream/frequencies.c", "tv"),
        ("stream/rar.c"),
        ("stream/stream.c"),
        ("stream/stream_avdevice.c"),
        ("stream/stream_bluray.c", "libbluray"),
        ("stream/stream_cdda.c", "cdda"),
        ("stream/stream_dvb.c", "dvbin"),
        ("stream/stream_dvd.c", "dvdread"),
        ("stream/stream_dvd_common.c", "dvdread"),
        ("stream/stream_dvdnav.c", "dvdnav"),
        ("stream/stream_edl.c"),
        ("stream/stream_file.c"),
        ("stream/stream_lavf.c"),
        ("stream/stream_libarchive.c", "libarchive"),
        ("stream/stream_memory.c"),
        ("stream/stream_mf.c"),
        ("stream/stream_null.c"),
        ("stream/stream_rar.c"),
        ("stream/stream_smb.c", "libsmbclient"),
        ("stream/stream_tv.c", "tv"),
        ("stream/tv.c", "tv"),
        ("stream/tvi_dummy.c", "tv"),
        ("stream/tvi_v4l2.c", "tv-v4l2"),

        ## Subtitles
        ("sub/ass_mp.c", "libass"),
        ("sub/dec_sub.c"),
        ("sub/draw_bmp.c"),
        ("sub/img_convert.c"),
        ("sub/lavc_conv.c"),
        ("sub/osd.c"),
        ("sub/osd_dummy.c", "dummy-osd"),
        ("sub/osd_libass.c", "libass-osd"),
        ("sub/sd_ass.c", "libass"),
        ("sub/sd_lavc.c"),

        ## Video
        ("video/csputils.c"),
        ("video/fmt-conversion.c"),
        ("video/gpu_memcpy.c", "sse4-intrinsics"),
        ("video/image_writer.c"),
        ("video/img_format.c"),
        ("video/mp_image.c"),
        ("video/mp_image_pool.c"),
        ("video/sws_utils.c"),
        ("video/dxva2.c", "dxva2-hwaccel"),
        ("video/vaapi.c", "vaapi"),
        ("video/vdpau.c", "vdpau"),
        ("video/vdpau_mixer.c", "vdpau"),
        ("video/decode/dec_video.c"),
        ("video/decode/dxva2.c", "dxva2-hwaccel"),
        ("video/decode/rpi.c", "rpi"),
        ("video/decode/vaapi.c", "vaapi-hwaccel"),
        ("video/decode/vd_lavc.c"),
        ("video/decode/videotoolbox.c", "videotoolbox-hwaccel"),
        ("video/decode/vdpau.c", "vdpau-hwaccel"),
        ("video/filter/vf.c"),
        ("video/filter/vf_buffer.c"),
        ("video/filter/vf_crop.c"),
        ("video/filter/vf_dlopen.c", "dlopen"),
        ("video/filter/vf_dsize.c"),
        ("video/filter/vf_eq.c"),
        ("video/filter/vf_expand.c"),
        ("video/filter/vf_flip.c"),
        ("video/filter/vf_format.c"),
        ("video/filter/vf_gradfun.c"),
        ("video/filter/vf_lavfi.c"),
        ("video/filter/vf_mirror.c"),
        ("video/filter/vf_noformat.c"),
        ("video/filter/vf_pullup.c"),
        ("video/filter/vf_rotate.c"),
        ("video/filter/vf_scale.c"),
        ("video/filter/vf_stereo3d.c"),
        ("video/filter/vf_sub.c"),
        ("video/filter/vf_vapoursynth.c", "vapoursynth-core"),
        ("video/filter/vf_vavpp.c", "vaapi"),
        ("video/filter/vf_vdpaupp.c", "vdpau"),
        ("video/filter/vf_vdpaurb.c", "vdpau"),
        ("video/filter/vf_yadif.c"),
        ("video/out/aspect.c"),
        ("video/out/bitmap_packer.c"),
        ("video/out/cocoa/video_view.m", "cocoa"),
        ("video/out/cocoa/events_view.m", "cocoa"),
        ("video/out/cocoa/window.m", "cocoa"),
        ("video/out/cocoa_common.m", "cocoa"),
        ("video/out/dither.c"),
        ("video/out/filter_kernels.c"),
        ("video/out/opengl/common.c", "gl"),
        ("video/out/opengl/context.c", "gl"),
        ("video/out/opengl/context_angle.c", "egl-angle"),
        ("video/out/opengl/context_cocoa.c", "gl-cocoa"),
        ("video/out/opengl/context_drm_egl.c", "egl-drm"),
        ("video/out/opengl/context_dxinterop.c", "gl-dxinterop"),
        ("video/out/opengl/context_rpi.c", "rpi"),
        ("video/out/opengl/context_wayland.c", "gl-wayland"),
        ("video/out/opengl/context_w32.c", "gl-win32"),
        ("video/out/opengl/context_x11.c", "gl-x11"),
        ("video/out/opengl/context_x11egl.c", "egl-x11"),
        ("video/out/opengl/egl_helpers.c", "egl-helpers"),
        ("video/out/opengl/hwdec.c", "gl"),
        ("video/out/opengl/hwdec_dxva2.c", "gl-win32"),
        ("video/out/opengl/hwdec_dxva2gldx.c", "gl-dxinterop"),
        ("video/out/opengl/hwdec_vaegl.c", "vaapi-egl"),
        ("video/out/opengl/hwdec_vaglx.c", "vaapi-glx"),
        ("video/out/opengl/hwdec_osx.c", "videotoolbox-gl"),
        ("video/out/opengl/hwdec_vdpau.c", "vdpau-gl-x11"),
        ("video/out/opengl/lcms.c", "gl"),
        ("video/out/opengl/nnedi3.c", "gl"),
        ("video/out/opengl/osd.c", "gl"),
        ("video/out/opengl/superxbr.c", "gl"),
        ("video/out/opengl/utils.c", "gl"),
        ("video/out/opengl/video.c", "gl"),
        ("video/out/opengl/video_shaders.c", "gl"),
        ("video/out/vo.c"),
        ("video/out/vo_caca.c", "caca"),
        ("video/out/vo_drm.c", "drm"),
        ("video/out/vo_direct3d.c", "direct3d"),
        ("video/out/vo_image.c"),
        ("video/out/vo_lavc.c", "encoding"),
        ("video/out/vo_rpi.c", "rpi"),
        ("video/out/vo_null.c"),
        ("video/out/vo_opengl.c", "gl"),
        ("video/out/vo_opengl_cb.c", "gl"),
        ("video/out/vo_sdl.c", "sdl2"),
        ("video/out/vo_vaapi.c", "vaapi-x11"),
        ("video/out/vo_vdpau.c", "vdpau"),
        ("video/out/vo_wayland.c", "wayland"),
        ("video/out/vo_x11.c", "x11"),
        ("video/out/vo_xv.c", "xv"),
        ("video/out/w32_common.c", "win32"),
        ("video/out/win32/displayconfig.c", "win32"),
        ("video/out/win32/exclusive_hack.c", "gl-win32"),
        ("video/out/wayland_common.c", "wayland"),
        ("video/out/wayland/buffer.c", "wayland"),
        ("video/out/wayland/memfile.c", "wayland"),
        ("video/out/win_state.c"),
        ("video/out/x11_common.c", "x11"),
        ("video/out/drm_common.c", "drm"),

        ## osdep
        (getch2_c),
        ("osdep/io.c"),
        ("osdep/timer.c"),
        (timer_c),
        ("osdep/threads.c"),
        ("osdep/ar/HIDRemote.m", "apple-remote"),
        ("osdep/macosx_application.m", "cocoa"),
        ("osdep/macosx_events.m", "cocoa"),
        ("osdep/semaphore_osx.c"),
        ("osdep/subprocess.c"),
        ("osdep/subprocess-posix.c", "posix-spawn"),
        ("osdep/subprocess-win.c", "os-win32"),
        ("osdep/path-macosx.m", "cocoa"),
        ("osdep/path-unix.c"),
        ("osdep/path-win.c", "os-win32"),
        ("osdep/path-win.c", "os-cygwin"),
        ("osdep/glob-win.c", "glob-win32-replacement"),
        ("osdep/w32_keyboard.c", "os-win32"),
        ("osdep/w32_keyboard.c", "os-cygwin"),
        ("osdep/windows_utils.c", "win32"),
        ("osdep/mpv.rc", "win32-executable"),
        ("osdep/win32/pthread.c", "win32-internal-pthreads"),
        ("osdep/android/strnlen.c", "android"),

        ## tree_allocator
        "ta/ta.c",
        "ta/ta_talloc.c",
        "ta/ta_utils.c"
    ]

    if ctx.dependency_satisfied('win32-executable'):
        from waflib import TaskGen

        TaskGen.declare_chain(name='windres',
                              rule='${WINDRES} ${WINDRES_FLAGS} ${SRC} ${TGT}',
                              ext_in='.rc',
                              ext_out='-rc.o',
                              color='PINK')

        ctx.env.WINDRES_FLAGS = [
            '--include-dir={0}'.format(ctx.bldnode.abspath()),
            '--include-dir={0}'.format(ctx.srcnode.abspath())
        ]

        for node in 'osdep/mpv.exe.manifest etc/mpv-icon.ico'.split():
            ctx.add_manual_dependency(ctx.path.find_node('osdep/mpv.rc'),
                                      ctx.path.find_node(node))

        version = ctx.bldnode.find_node('version.h')
        if version:
            ctx.add_manual_dependency(ctx.path.find_node('osdep/mpv.rc'),
                                      version)

    if ctx.dependency_satisfied('cplayer') or ctx.dependency_satisfied('test'):
        ctx(
            target="objects",
            source=ctx.filtered_sources(sources),
            use=ctx.dependencies_use(),
            includes=_all_includes(ctx),
            features="c",
        )

    if ctx.dependency_satisfied('cplayer'):
        ctx(target="mpv",
            source=main_fn_c,
            use=ctx.dependencies_use() + ['objects'],
            includes=_all_includes(ctx),
            features="c cprogram",
            install_path=ctx.env.BINDIR)
        for f in ['mpv.conf', 'input.conf', 'mplayer-input.conf', \
                  'restore-old-bindings.conf']:
            ctx.install_as(os.path.join(ctx.env.DOCDIR, f),
                           os.path.join('etc/', f))

        if ctx.env.DEST_OS == 'win32':
            wrapctx = ctx(target="mpv",
                          source=['osdep/win32-console-wrapper.c'],
                          features="c cprogram",
                          install_path=ctx.env.BINDIR)

            wrapctx.env.cprogram_PATTERN = "%s.com"
            wrapflags = ['-municode', '-mconsole']
            wrapctx.env.CFLAGS = wrapflags
            wrapctx.env.LAST_LINKFLAGS = wrapflags

    if ctx.dependency_satisfied('test'):
        for test in ctx.path.ant_glob("test/*.c"):
            ctx(
                target=os.path.splitext(test.srcpath())[0],
                source=test.srcpath(),
                use=ctx.dependencies_use() + ['objects'],
                includes=_all_includes(ctx),
                features="c cprogram",
            )

    build_shared = ctx.dependency_satisfied('libmpv-shared')
    build_static = ctx.dependency_satisfied('libmpv-static')
    if build_shared or build_static:
        if build_shared:
            waftoolsdir = os.path.join(os.path.dirname(__file__), "waftools")
            ctx.load("syms", tooldir=waftoolsdir)
        vre = '^#define MPV_CLIENT_API_VERSION MPV_MAKE_VERSION\((.*), (.*)\)$'
        libmpv_header = ctx.path.find_node("libmpv/client.h").read()
        major, minor = re.search(vre, libmpv_header, re.M).groups()
        libversion = major + '.' + minor + '.0'

        def _build_libmpv(shared):
            features = "c "
            if shared:
                features += "cshlib syms"
            else:
                features += "cstlib"

            libmpv_kwargs = {
                "target": "mpv",
                "source":   ctx.filtered_sources(sources),
                "use":      ctx.dependencies_use(),
                "includes": [ctx.bldnode.abspath(), ctx.srcnode.abspath()] + \
                             ctx.dependencies_includes(),
                "features": features,
                "export_symbols_def": "libmpv/mpv.def",
                "install_path": ctx.env.LIBDIR,
            }

            if not ctx.dependency_satisfied('android'):
                # for all other configurations we want SONAME to be used
                libmpv_kwargs["vnum"] = libversion

            ctx(**libmpv_kwargs)

        if build_shared:
            _build_libmpv(True)
        if build_static:
            _build_libmpv(False)

        def get_deps():
            res = ""
            for k in ctx.env.keys():
                if k.startswith("LIB_") and k != "LIB_ST":
                    res += " ".join(["-l" + x for x in ctx.env[k]]) + " "
            return res

        ctx(
            target='libmpv/mpv.pc',
            source='libmpv/mpv.pc.in',
            features='subst',
            PREFIX=ctx.env.PREFIX,
            LIBDIR=ctx.env.LIBDIR,
            INCDIR=ctx.env.INCDIR,
            VERSION=libversion,
            PRIV_LIBS=get_deps(),
        )

        headers = ["client.h", "qthelper.hpp", "opengl_cb.h"]
        for f in headers:
            ctx.install_as(ctx.env.INCDIR + '/mpv/' + f, 'libmpv/' + f)

        ctx.install_as(ctx.env.LIBDIR + '/pkgconfig/mpv.pc', 'libmpv/mpv.pc')

    if ctx.dependency_satisfied("vf-dlopen-filters"):
        dlfilters = "telecine tile rectangle framestep ildetect".split()
        for dlfilter in dlfilters:
            ctx(target=dlfilter,
                source=[
                    'TOOLS/vf_dlopen/' + dlfilter + '.c',
                    'TOOLS/vf_dlopen/filterutils.c'
                ],
                includes=[ctx.srcnode.abspath() + '/video/filter'],
                features='c cshlib',
                install_path=ctx.env.LIBDIR + '/mpv')

    if ctx.dependency_satisfied('html-build'):
        _build_html(ctx)

    if ctx.dependency_satisfied('manpage-build'):
        _build_man(ctx)

    if ctx.dependency_satisfied('pdf-build'):
        _build_pdf(ctx)

    if ctx.dependency_satisfied('cplayer'):

        if ctx.dependency_satisfied('zsh-comp'):
            ctx.zshcomp(target="etc/_mpv")
            ctx.install_files(ctx.env.ZSHDIR, ['etc/_mpv'])

        ctx.install_files(ctx.env.DATADIR + '/applications',
                          ['etc/mpv.desktop'])

        if ctx.dependency_satisfied('encoding'):
            ctx.install_files(ctx.env.CONFDIR, ['etc/encoding-profiles.conf'])

        for size in '16x16 32x32 64x64'.split():
            ctx.install_as(
                ctx.env.DATADIR + '/icons/hicolor/' + size + '/apps/mpv.png',
                'etc/mpv-icon-8bit-' + size + '.png')

        ctx.install_as(
            ctx.env.DATADIR + '/icons/hicolor/scalable/apps/mpv.svg',
            'etc/mpv-gradient.svg')
Exemplo n.º 27
0
	def declare_chain(self, *k, **kw):
		"""
		Wrapper for :py:func:`waflib.TaskGen.declare_chain` provided for convenience
		"""
		return TaskGen.declare_chain(*k, **kw)
Exemplo n.º 28
0
 def __call__(self, *k, **kw):
     kw['bld'] = self
     ret = TaskGen.task_gen(*k, **kw)
     self.task_gen_cache_names = {}
     self.add_to_group(ret, group=kw.get('group', None))
     return ret
Exemplo n.º 29
0
 def declare_chain(self, *k, **kw):
     return TaskGen.declare_chain(*k, **kw)
Exemplo n.º 30
0
                  name=targetName,
                  target=targetName,
                  basedir='classes',
                  outdir='classes',
                  destfile=libName,
                  compat=compat,
                  dir=bld.path.get_bld(),
                  files=[libName])

        jar.install_path = installPath or '${PREFIX}/lib'

        if have_native_sourcedir:
            lib = bld(features='%s %sshlib' % (nlang, nlang),
                      includes='%s/include' % native_sourcedir,
                      target='%s.jni-%s' % (modArgs['name'], nlang),
                      env=env.derive(),
                      uselib=uselib,
                      use=uselib_local,
                      source=bld.path.find_dir(native_sourcedir).ant_glob(
                          'source/*%s' % nsourceExt))

            jar.targets_to_add.append(lib)

            lib.install_path = installPath or '${PREFIX}/lib'

        return jar


# Tell waf to ignore any build.xml files, the 'ant' feature will take care of them.
TaskGen.extension('build.xml')(Utils.nada)
Exemplo n.º 31
0
Arquivo: cxx.py Projeto: Gear61/cs118
#! /usr/bin/env python
# encoding: utf-8
# WARNING! Do not edit! http://waf.googlecode.com/git/docs/wafbook/single.html#_obtaining_the_waf_file

from waflib import TaskGen, Task, Utils
from waflib.Tools import c_preproc
from waflib.Tools.ccroot import link_task, stlink_task


def cxx_hook(self, node):
    return self.create_compiled_task('cxx', node)


TaskGen.extension('.cpp', '.cc', '.cxx', '.C', '.c++')(cxx_hook)
if not '.c' in TaskGen.task_gen.mappings:
    TaskGen.task_gen.mappings['.c'] = TaskGen.task_gen.mappings['.cpp']


class cxx(Task.Task):
    run_str = '${CXX} ${ARCH_ST:ARCH} ${CXXFLAGS} ${CPPFLAGS} ${FRAMEWORKPATH_ST:FRAMEWORKPATH} ${CPPPATH_ST:INCPATHS} ${DEFINES_ST:DEFINES} ${CXX_SRC_F}${SRC} ${CXX_TGT_F}${TGT}'
    vars = ['CXXDEPS']
    ext_in = ['.h']
    scan = c_preproc.scan


class cxxprogram(link_task):
    run_str = '${LINK_CXX} ${LINKFLAGS} ${CXXLNK_SRC_F}${SRC} ${CXXLNK_TGT_F}${TGT[0].abspath()} ${RPATH_ST:RPATH} ${FRAMEWORKPATH_ST:FRAMEWORKPATH} ${FRAMEWORK_ST:FRAMEWORK} ${ARCH_ST:ARCH} ${STLIB_MARKER} ${STLIBPATH_ST:STLIBPATH} ${STLIB_ST:STLIB} ${SHLIB_MARKER} ${LIBPATH_ST:LIBPATH} ${LIB_ST:LIB}'
    vars = ['LINKDEPS']
    ext_out = ['.bin']
    inst_to = '${BINDIR}'
    chmod = Utils.O755
Exemplo n.º 32
0
#!/usr/bin/env python
# encoding: utf-8
# Thomas Nagy, 2010 (ita)

"""
Erlang support
"""

from waflib import TaskGen

TaskGen.declare_chain(name = 'erlc',
	rule      = '${ERLC} ${ERLC_FLAGS} ${SRC[0].abspath()} -o ${TGT[0].name}',
	reentrant = False,
	ext_in    = '.erl',
	ext_out   = '.beam')

def configure(conf):
	conf.find_program('erlc', var='ERLC')
	conf.env.ERLC_FLAGS = []

Exemplo n.º 33
0
		set_def('GO_PLATFORM', platform.machine())

	if conf.env.GO_PLATFORM == 'x86_64':
		set_def('GO_COMPILER', '6g')
		set_def('GO_LINKER', '6l')
	elif conf.env.GO_PLATFORM in ('i386', 'i486', 'i586', 'i686'):
		set_def('GO_COMPILER', '8g')
		set_def('GO_LINKER', '8l')
	elif conf.env.GO_PLATFORM == 'arm':
		set_def('GO_COMPILER', '5g')
		set_def('GO_LINKER', '5l')
		set_def('GO_EXTENSION', '.5')

	if not (conf.env.GO_COMPILER or conf.env.GO_LINKER):
		raise conf.fatal('Unsupported platform ' + platform.machine())

	set_def('GO_PACK', 'gopack')
	set_def('gopackage_PATTERN', '%s.a')
	set_def('CPPPATH_ST', '-I%s')

	set_def('GOMAKE_FLAGS', ['--quiet'])
	conf.find_program(conf.env.GO_COMPILER, var='GOC')
	conf.find_program(conf.env.GO_LINKER,   var='GOL')
	conf.find_program(conf.env.GO_PACK,     var='GOP')

	conf.find_program('cgo',                var='CGO')

TaskGen.feature('go')(process_use)
TaskGen.feature('go')(propagate_uselib_vars)

Exemplo n.º 34
0
Arquivo: gob2.py Projeto: afeldman/waf
#!/usr/bin/env python
# encoding: utf-8
# Ali Sabil, 2007

from waflib import TaskGen

TaskGen.declare_chain(
    name='gob2',
    rule='${GOB2} -o ${TGT[0].bld_dir()} ${GOB2FLAGS} ${SRC}',
    ext_in='.gob',
    ext_out='.c')


def configure(conf):
    conf.find_program('gob2', var='GOB2')
    conf.env['GOB2FLAGS'] = ''
Exemplo n.º 35
0
def build(ctx):
    ctx.load('waf_customizations')
    ctx.load('generators.sources')

    ctx.file2string(
        source = "TOOLS/osxbundle/mpv.app/Contents/Resources/icon.icns",
        target = "osdep/macosx_icon.inc")

    ctx.file2string(
        source = "video/out/x11_icon.bin",
        target = "video/out/x11_icon.inc")

    ctx.file2string(
        source = "etc/input.conf",
        target = "input/input_conf.h")

    ctx.file2string(
        source = "sub/osd_font.otf",
        target = "sub/osd_font.h")

    ctx.file2string(
        source = "video/out/opengl/nnedi3_weights.bin",
        target = "video/out/opengl/nnedi3_weights.inc")

    lua_files = ["defaults.lua", "assdraw.lua", "options.lua", "osc.lua",
                 "ytdl_hook.lua"]
    for fn in lua_files:
        fn = "player/lua/" + fn
        ctx.file2string(source = fn, target = os.path.splitext(fn)[0] + ".inc")

    ctx.matroska_header(
        source = "demux/ebml.c demux/demux_mkv.c",
        target = "ebml_types.h")

    ctx.matroska_definitions(
        source = "demux/ebml.c",
        target = "ebml_defs.c")

    if ctx.env.DEST_OS == 'win32':
        main_fn_c = 'osdep/main-fn-win.c'
    elif ctx.dependency_satisfied('cocoa'):
        main_fn_c = 'osdep/main-fn-cocoa.c'
    else:
        main_fn_c = 'osdep/main-fn-unix.c'

    getch2_c = {
        'win32':  'osdep/terminal-win.c',
    }.get(ctx.env.DEST_OS, "osdep/terminal-unix.c")

    timer_c = {
        'win32':  'osdep/timer-win2.c',
        'darwin': 'osdep/timer-darwin.c',
    }.get(ctx.env.DEST_OS, "osdep/timer-linux.c")

    sources = [
        ## Audio
        ( "audio/audio.c" ),
        ( "audio/audio_buffer.c" ),
        ( "audio/chmap.c" ),
        ( "audio/chmap_sel.c" ),
        ( "audio/fmt-conversion.c" ),
        ( "audio/format.c" ),
        ( "audio/mixer.c" ),
        ( "audio/decode/ad_lavc.c" ),
        ( "audio/decode/ad_spdif.c" ),
        ( "audio/decode/dec_audio.c" ),
        ( "audio/filter/af.c" ),
        ( "audio/filter/af_channels.c" ),
        ( "audio/filter/af_delay.c" ),
        ( "audio/filter/af_drc.c" ),
        ( "audio/filter/af_equalizer.c" ),
        ( "audio/filter/af_format.c" ),
        ( "audio/filter/af_lavcac3enc.c" ),
        ( "audio/filter/af_lavfi.c",             "libavfilter" ),
        ( "audio/filter/af_lavrresample.c" ),
        ( "audio/filter/af_pan.c" ),
        ( "audio/filter/af_rubberband.c",        "rubberband" ),
        ( "audio/filter/af_scaletempo.c" ),
        ( "audio/filter/af_volume.c" ),
        ( "audio/filter/tools.c" ),
        ( "audio/out/ao.c" ),
        ( "audio/out/ao_alsa.c",                 "alsa" ),
        ( "audio/out/ao_coreaudio.c",            "coreaudio" ),
        ( "audio/out/ao_coreaudio_chmap.c",      "coreaudio" ),
        ( "audio/out/ao_coreaudio_exclusive.c",  "coreaudio" ),
        ( "audio/out/ao_coreaudio_properties.c", "coreaudio" ),
        ( "audio/out/ao_coreaudio_utils.c",      "coreaudio" ),
        ( "audio/out/ao_dsound.c",               "dsound" ),
        ( "audio/out/ao_jack.c",                 "jack" ),
        ( "audio/out/ao_lavc.c",                 "encoding" ),
        ( "audio/out/ao_null.c" ),
        ( "audio/out/ao_openal.c",               "openal" ),
        ( "audio/out/ao_oss.c",                  "oss-audio" ),
        ( "audio/out/ao_pcm.c" ),
        ( "audio/out/ao_pulse.c",                "pulse" ),
        ( "audio/out/ao_rsound.c",               "rsound" ),
        ( "audio/out/ao_sdl.c",                  "sdl1" ),
        ( "audio/out/ao_sdl.c",                  "sdl2" ),
        ( "audio/out/ao_sndio.c",                "sndio" ),
        ( "audio/out/ao_wasapi.c",               "wasapi" ),
        ( "audio/out/ao_wasapi_utils.c",         "wasapi" ),
        ( "audio/out/ao_wasapi_changenotify.c",  "wasapi" ),
        ( "audio/out/pull.c" ),
        ( "audio/out/push.c" ),

        ## Core
        ( "common/av_common.c" ),
        ( "common/av_log.c" ),
        ( "common/codecs.c" ),
        ( "common/encode_lavc.c",                "encoding" ),
        ( "common/common.c" ),
        ( "common/tags.c" ),
        ( "common/msg.c" ),
        ( "common/playlist.c" ),
        ( "common/version.c" ),

        ## Demuxers
        ( "demux/codec_tags.c" ),
        ( "demux/cue.c" ),
        ( "demux/demux.c" ),
        ( "demux/demux_cue.c" ),
        ( "demux/demux_disc.c" ),
        ( "demux/demux_edl.c" ),
        ( "demux/demux_lavf.c" ),
        ( "demux/demux_libarchive.c",            "libarchive" ),
        ( "demux/demux_mf.c" ),
        ( "demux/demux_mkv.c" ),
        ( "demux/demux_mkv_timeline.c" ),
        ( "demux/demux_playlist.c" ),
        ( "demux/demux_raw.c" ),
        ( "demux/demux_rar.c" ),
        ( "demux/demux_subreader.c" ),
        ( "demux/demux_tv.c",                    "tv" ),
        ( "demux/ebml.c" ),
        ( "demux/packet.c" ),
        ( "demux/timeline.c" ),

        ## Input
        ( "input/cmd_list.c" ),
        ( "input/cmd_parse.c" ),
        ( "input/event.c" ),
        ( "input/input.c" ),
        ( "input/ipc.c",                         "!mingw" ),
        ( "input/keycodes.c" ),
        ( "input/pipe-win32.c",                  "waio" ),

        ## Misc
        ( "misc/bstr.c" ),
        ( "misc/charset_conv.c" ),
        ( "misc/dispatch.c" ),
        ( "misc/json.c" ),
        ( "misc/ring.c" ),
        ( "misc/rendezvous.c" ),

        ## Options
        ( "options/m_config.c" ),
        ( "options/m_option.c" ),
        ( "options/m_property.c" ),
        ( "options/options.c" ),
        ( "options/parse_commandline.c" ),
        ( "options/parse_configfile.c" ),
        ( "options/path.c" ),

        ## Player
        ( "player/audio.c" ),
        ( "player/client.c" ),
        ( "player/command.c" ),
        ( "player/configfiles.c" ),
        ( "player/external_files.c" ),
        ( "player/loadfile.c" ),
        ( "player/main.c" ),
        ( "player/misc.c" ),
        ( "player/lua.c",                        "lua" ),
        ( "player/osd.c" ),
        ( "player/playloop.c" ),
        ( "player/screenshot.c" ),
        ( "player/scripting.c" ),
        ( "player/sub.c" ),
        ( "player/video.c" ),

        ## Streams
        ( "stream/ai_alsa1x.c",                  "alsa" ),
        ( "stream/ai_oss.c",                     "oss-audio" ),
        ( "stream/ai_sndio.c",                   "sndio" ),
        ( "stream/audio_in.c",                   "audio-input" ),
        ( "stream/cache.c" ),
        ( "stream/cache_file.c" ),
        ( "stream/cookies.c" ),
        ( "stream/dvb_tune.c",                   "dvbin" ),
        ( "stream/frequencies.c",                "tv" ),
        ( "stream/rar.c" ),
        ( "stream/stream.c" ),
        ( "stream/stream_avdevice.c" ),
        ( "stream/stream_bluray.c",              "libbluray" ),
        ( "stream/stream_cdda.c",                "cdda" ),
        ( "stream/stream_dvb.c",                 "dvbin" ),
        ( "stream/stream_dvd.c",                 "dvdread" ),
        ( "stream/stream_dvd_common.c",          "dvdread" ),
        ( "stream/stream_dvdnav.c",              "dvdnav" ),
        ( "stream/stream_edl.c" ),
        ( "stream/stream_file.c" ),
        ( "stream/stream_lavf.c" ),
        ( "stream/stream_libarchive.c",          "libarchive" ),
        ( "stream/stream_memory.c" ),
        ( "stream/stream_mf.c" ),
        ( "stream/stream_null.c" ),
        ( "stream/stream_pvr.c",                 "pvr" ),
        ( "stream/stream_rar.c" ),
        ( "stream/stream_smb.c",                 "libsmbclient" ),
        ( "stream/stream_tv.c",                  "tv" ),
        ( "stream/tv.c",                         "tv" ),
        ( "stream/tvi_dummy.c",                  "tv" ),
        ( "stream/tvi_v4l2.c",                   "tv-v4l2"),

        ## Subtitles
        ( "sub/ass_mp.c",                        "libass"),
        ( "sub/dec_sub.c" ),
        ( "sub/draw_bmp.c" ),
        ( "sub/img_convert.c" ),
        ( "sub/osd.c" ),
        ( "sub/osd_dummy.c",                     "dummy-osd" ),
        ( "sub/osd_libass.c",                    "libass-osd" ),
        ( "sub/sd_ass.c",                        "libass" ),
        ( "sub/sd_lavc.c" ),
        ( "sub/sd_lavc_conv.c" ),
        ( "sub/sd_lavf_srt.c" ),
        ( "sub/sd_microdvd.c" ),
        ( "sub/sd_movtext.c" ),
        ( "sub/sd_srt.c" ),

        ## Video
        ( "video/csputils.c" ),
        ( "video/fmt-conversion.c" ),
        ( "video/gpu_memcpy.c",                  "sse4-intrinsics" ),
        ( "video/image_writer.c" ),
        ( "video/img_format.c" ),
        ( "video/mp_image.c" ),
        ( "video/mp_image_pool.c" ),
        ( "video/sws_utils.c" ),
        ( "video/vaapi.c",                       "vaapi" ),
        ( "video/vdpau.c",                       "vdpau" ),
        ( "video/vdpau_mixer.c",                 "vdpau" ),
        ( "video/decode/dec_video.c"),
        ( "video/decode/dxva2.c",                "dxva2-hwaccel" ),
        ( "video/decode/rpi.c",                  "rpi" ),
        ( "video/decode/vaapi.c",                "vaapi-hwaccel" ),
        ( "video/decode/vd_lavc.c" ),
        ( "video/decode/videotoolbox.c",         "videotoolbox-hwaccel" ),
        ( "video/decode/vdpau.c",                "vdpau-hwaccel" ),
        ( "video/filter/vf.c" ),
        ( "video/filter/vf_buffer.c" ),
        ( "video/filter/vf_crop.c" ),
        ( "video/filter/vf_canny.c",             "opencv" ),
        ( "video/filter/vf_vector.c",            "opencv" ),
        ( "video/filter/vf_vectorraster.c" ),
        ( "video/filter/vf_dlopen.c",            "dlopen" ),
        ( "video/filter/vf_dsize.c" ),
        ( "video/filter/vf_eq.c" ),
        ( "video/filter/vf_expand.c" ),
        ( "video/filter/vf_flip.c" ),
        ( "video/filter/vf_format.c" ),
        ( "video/filter/vf_gradfun.c",           "libavfilter"),
        ( "video/filter/vf_lavfi.c",             "libavfilter"),
        ( "video/filter/vf_mirror.c",            "libavfilter"),
        ( "video/filter/vf_noformat.c" ),
        ( "video/filter/vf_pullup.c",            "libavfilter"),
        ( "video/filter/vf_rotate.c",            "libavfilter"),
        ( "video/filter/vf_scale.c" ),
        ( "video/filter/vf_stereo3d.c",          "libavfilter"),
        ( "video/filter/vf_sub.c" ),
        ( "video/filter/vf_vapoursynth.c",       "vapoursynth-core" ),
        ( "video/filter/vf_vavpp.c",             "vaapi"),
        ( "video/filter/vf_vdpaupp.c",           "vdpau" ),
        ( "video/filter/vf_vdpaurb.c",           "vdpau" ),
        ( "video/filter/vf_yadif.c",             "libavfilter"),
        ( "video/out/aspect.c" ),
        ( "video/out/bitmap_packer.c" ),
        ( "video/out/cocoa/video_view.m",        "cocoa" ),
        ( "video/out/cocoa/events_view.m",       "cocoa" ),
        ( "video/out/cocoa/window.m",            "cocoa" ),
        ( "video/out/cocoa_common.m",            "cocoa" ),
        ( "video/out/dither.c" ),
        ( "video/out/filter_kernels.c" ),
        ( "video/out/opengl/cocoa.c",            "gl-cocoa" ),
        ( "video/out/opengl/common.c",           "gl" ),
        ( "video/out/opengl/rpi.c",              "rpi" ),
        ( "video/out/opengl/hwdec.c",            "gl" ),
        ( "video/out/opengl/hwdec_dxva2.c",      "gl-win32" ),
        ( "video/out/opengl/hwdec_vaegl.c",      "vaapi-egl" ),
        ( "video/out/opengl/hwdec_vaglx.c",      "vaapi-glx" ),
        ( "video/out/opengl/hwdec_osx.c",        "videotoolbox-gl" ),
        ( "video/out/opengl/hwdec_vdpau.c",      "vdpau-gl-x11" ),
        ( "video/out/opengl/lcms.c",             "gl" ),
        ( "video/out/opengl/nnedi3.c",           "gl" ),
        ( "video/out/opengl/osd.c",              "gl" ),
        ( "video/out/opengl/superxbr.c",         "gl" ),
        ( "video/out/opengl/utils.c",            "gl" ),
        ( "video/out/opengl/video.c",            "gl" ),
        ( "video/out/opengl/video_shaders.c",    "gl" ),
        ( "video/out/opengl/w32.c",              "gl-win32" ),
        ( "video/out/opengl/wayland.c",          "gl-wayland" ),
        ( "video/out/opengl/x11.c",              "gl-x11" ),
        ( "video/out/opengl/x11egl.c",           "egl-x11" ),
        ( "video/out/opengl/drm_egl.c",          "egl-drm" ),
        ( "video/out/vo.c" ),
        ( "video/out/vo_caca.c",                 "caca" ),
        ( "video/out/vo_drm.c",                  "drm" ),
        ( "video/out/vo_direct3d.c",             "direct3d" ),
        ( "video/out/vo_image.c" ),
        ( "video/out/vo_lavc.c",                 "encoding" ),
        ( "video/out/vo_rpi.c",                  "rpi" ),
        ( "video/out/vo_null.c" ),
        ( "video/out/vo_opengl.c",               "gl" ),
        ( "video/out/vo_opengl_cb.c",            "gl" ),
        ( "video/out/vo_sdl.c",                  "sdl2" ),
        ( "video/out/vo_vaapi.c",                "vaapi-x11" ),
        ( "video/out/vo_vdpau.c",                "vdpau" ),
        ( "video/out/vo_wayland.c",              "wayland" ),
        ( "video/out/vo_x11.c" ,                 "x11" ),
        ( "video/out/vo_xv.c",                   "xv" ),
        ( "video/out/vo_tkkr.c" ),
        ( "video/out/w32_common.c",              "win32" ),
        ( "video/out/win32/displayconfig.c",     "win32" ),
        ( "video/out/wayland_common.c",          "wayland" ),
        ( "video/out/wayland/buffer.c",          "wayland" ),
        ( "video/out/wayland/memfile.c",         "wayland" ),
        ( "video/out/win_state.c"),
        ( "video/out/x11_common.c",              "x11" ),
        ( "video/out/drm_common.c",              "drm" ),

        ## osdep
        ( getch2_c ),
        ( "osdep/io.c" ),
        ( "osdep/timer.c" ),
        ( timer_c ),
        ( "osdep/threads.c" ),

        ( "osdep/ar/HIDRemote.m",                "apple-remote" ),
        ( "osdep/macosx_application.m",          "cocoa" ),
        ( "osdep/macosx_events.m",               "cocoa" ),
        ( "osdep/semaphore_osx.c" ),
        ( "osdep/subprocess.c" ),
        ( "osdep/subprocess-posix.c",            "posix-spawn" ),
        ( "osdep/subprocess-win.c",              "os-win32" ),
        ( "osdep/path-macosx.m",                 "cocoa" ),
        ( "osdep/path-unix.c"),
        ( "osdep/path-win.c",                    "os-win32" ),
        ( "osdep/path-win.c",                    "os-cygwin" ),
        ( "osdep/glob-win.c",                    "glob-win32-replacement" ),
        ( "osdep/w32_keyboard.c",                "os-win32" ),
        ( "osdep/w32_keyboard.c",                "os-cygwin" ),
        ( "osdep/mpv.rc",                        "win32-executable" ),
        ( "osdep/win32/pthread.c",               "win32-internal-pthreads"),

        ## tree_allocator
        "ta/ta.c", "ta/ta_talloc.c", "ta/ta_utils.c"
    ]

    if ctx.dependency_satisfied('win32-executable'):
        from waflib import TaskGen

        TaskGen.declare_chain(
            name    = 'windres',
            rule    = '${WINDRES} ${WINDRES_FLAGS} ${SRC} ${TGT}',
            ext_in  = '.rc',
            ext_out = '-rc.o',
            color   = 'PINK')

        ctx.env.WINDRES_FLAGS = [
            '--include-dir={0}'.format(ctx.bldnode.abspath()),
            '--include-dir={0}'.format(ctx.srcnode.abspath())
        ]

        for node in 'osdep/mpv.exe.manifest etc/mpv-icon.ico'.split():
            ctx.add_manual_dependency(
                ctx.path.find_node('osdep/mpv.rc'),
                ctx.path.find_node(node))

        version = ctx.bldnode.find_node('version.h')
        if version:
            ctx.add_manual_dependency(
                ctx.path.find_node('osdep/mpv.rc'),
                version)

    if ctx.dependency_satisfied('cplayer') or ctx.dependency_satisfied('test'):
        ctx(
            target       = "objects",
            source       = ctx.filtered_sources(sources),
            use          = ctx.dependencies_use(),
            includes     = _all_includes(ctx),
            features     = "c",
        )

    if ctx.dependency_satisfied('cplayer'):
        ctx(
            target       = "mpv",
            source       = main_fn_c,
            use          = ctx.dependencies_use() + ['objects'],
            includes     = _all_includes(ctx),
            features     = "c cprogram",
            install_path = ctx.env.BINDIR
        )
        for f in ['example.conf', 'input.conf', 'mplayer-input.conf', \
                  'restore-old-bindings.conf']:
            ctx.install_as(os.path.join(ctx.env.DOCDIR, f),
                           os.path.join('etc/', f))

        if ctx.env.DEST_OS == 'win32':
            wrapctx = ctx(
                target       = "mpv",
                source       = ['osdep/win32-console-wrapper.c'],
                features     = "c cprogram",
                install_path = ctx.env.BINDIR
            )

            wrapctx.env.cprogram_PATTERN = "%s.com"
            wrapflags = ['-municode', '-mconsole']
            wrapctx.env.CFLAGS = wrapflags
            wrapctx.env.LAST_LINKFLAGS = wrapflags

    if ctx.dependency_satisfied('test'):
        for test in ctx.path.ant_glob("test/*.c"):
            ctx(
                target   = os.path.splitext(test.srcpath())[0],
                source   = test.srcpath(),
                use      = ctx.dependencies_use() + ['objects'],
                includes = _all_includes(ctx),
                features = "c cprogram",
            )

    build_shared = ctx.dependency_satisfied('libmpv-shared')
    build_static = ctx.dependency_satisfied('libmpv-static')
    if build_shared or build_static:
        if build_shared:
            waftoolsdir = os.path.join(os.path.dirname(__file__), "waftools")
            ctx.load("syms", tooldir=waftoolsdir)
        vre = '^#define MPV_CLIENT_API_VERSION MPV_MAKE_VERSION\((.*), (.*)\)$'
        libmpv_header = ctx.path.find_node("libmpv/client.h").read()
        major, minor = re.search(vre, libmpv_header, re.M).groups()
        libversion = major + '.' + minor + '.0'

        def _build_libmpv(shared):
            features = "c "
            if shared:
                features += "cshlib syms"
            else:
                features += "cstlib"
            ctx(
                target       = "mpv",
                source       = ctx.filtered_sources(sources),
                use          = ctx.dependencies_use(),
                includes     = [ctx.bldnode.abspath(), ctx.srcnode.abspath()] + \
                                ctx.dependencies_includes(),
                features     = features,
                export_symbols_def = "libmpv/mpv.def",
                install_path = ctx.env.LIBDIR,
                vnum         = libversion,
            )
        if build_shared:
            _build_libmpv(True)
        if build_static:
            _build_libmpv(False)

        def get_deps():
            res = ""
            for k in ctx.env.keys():
                if k.startswith("LIB_") and k != "LIB_ST":
                    res += " ".join(["-l" + x for x in ctx.env[k]]) + " "
            return res

        ctx(
            target       = 'libmpv/mpv.pc',
            source       = 'libmpv/mpv.pc.in',
            features     = 'subst',
            PREFIX       = ctx.env.PREFIX,
            LIBDIR       = ctx.env.LIBDIR,
            INCDIR       = ctx.env.INCDIR,
            VERSION      = libversion,
            PRIV_LIBS    = get_deps(),
        )

        headers = ["client.h", "qthelper.hpp", "opengl_cb.h"]
        for f in headers:
            ctx.install_as(ctx.env.INCDIR + '/mpv/' + f, 'libmpv/' + f)

        ctx.install_as(ctx.env.LIBDIR + '/pkgconfig/mpv.pc', 'libmpv/mpv.pc')

    if ctx.dependency_satisfied("vf-dlopen-filters"):
        dlfilters = "telecine tile rectangle framestep ildetect".split()
        for dlfilter in dlfilters:
            ctx(
                target       = dlfilter,
                source       = ['TOOLS/vf_dlopen/'+dlfilter+'.c',
                                'TOOLS/vf_dlopen/filterutils.c'],
                includes     = [ctx.srcnode.abspath() + '/video/filter'],
                features     = 'c cshlib',
                install_path = ctx.env.LIBDIR + '/mpv' )

    if ctx.dependency_satisfied('manpage-build'):
        _build_man(ctx)

    if ctx.dependency_satisfied('pdf-build'):
        _build_pdf(ctx)

    if ctx.dependency_satisfied('cplayer'):

        if ctx.dependency_satisfied('zsh-comp'):
            ctx.zshcomp(target = "etc/_mpv")
            ctx.install_files(
                ctx.env.ZSHDIR,
                ['etc/_mpv'])

        ctx.install_files(
            ctx.env.DATADIR + '/applications',
            ['etc/mpv.desktop'] )

        ctx.install_files(ctx.env.CONFDIR, ['etc/encoding-profiles.conf'] )

        for size in '16x16 32x32 64x64'.split():
            ctx.install_as(
                ctx.env.DATADIR + '/icons/hicolor/' + size + '/apps/mpv.png',
                'etc/mpv-icon-8bit-' + size + '.png')
Exemplo n.º 36
0

def proc(tsk):
    env = tsk.env
    gen = tsk.generator
    inc_nodes = gen.to_incnodes(
        Utils.to_list(getattr(gen, "includes", [])) + env["INCLUDES"])

    cmd = ([env.PROC] + ["SQLCHECK=SEMANTICS"] +
           (["SYS_INCLUDE=(" + ",".join(env.PROC_INCLUDES) +
             ")"] if env.PROC_INCLUDES else []) +
           ["INCLUDE=(" + ",".join([i.bldpath() for i in inc_nodes]) + ")"] +
           ["userid=" + env.PROC_CONNECTION] +
           ["INAME=" + tsk.inputs[0].bldpath()] +
           ["ONAME=" + tsk.outputs[0].bldpath()])
    exec_env = {
        "ORACLE_HOME": env.PROC_ORACLE,
        "LD_LIBRARY_PATH": env.PROC_ORACLE + path.sep + "lib",
    }
    if env.PROC_TNS_ADMIN:
        exec_env["TNS_ADMIN"] = env.PROC_TNS_ADMIN
    return tsk.exec_command(cmd, env=exec_env)


TaskGen.declare_chain(
    name="proc",
    rule=proc,
    ext_in=".pc",
    ext_out=".c",
)
Exemplo n.º 37
0
	def declare_chain(self, *k, **kw):
		"""
		Wraps :py:func:`waflib.TaskGen.declare_chain` for convenience
		"""
		return TaskGen.declare_chain(*k, **kw)
Exemplo n.º 38
0
		set_def('GO_PLATFORM', platform.machine())

	if conf.env.GO_PLATFORM == 'x86_64':
		set_def('GO_COMPILER', '6g')
		set_def('GO_LINKER', '6l')
	elif conf.env.GO_PLATFORM in ('i386', 'i486', 'i586', 'i686'):
		set_def('GO_COMPILER', '8g')
		set_def('GO_LINKER', '8l')
	elif conf.env.GO_PLATFORM == 'arm':
		set_def('GO_COMPILER', '5g')
		set_def('GO_LINKER', '5l')
		set_def('GO_EXTENSION', '.5')

	if not (conf.env.GO_COMPILER or conf.env.GO_LINKER):
		raise conf.fatal('Unsupported platform ' + platform.machine())

	set_def('GO_PACK', 'gopack')
	set_def('gopackage_PATTERN', '%s.a')
	set_def('CPPPATH_ST', '-I%s')

	set_def('GOMAKE_FLAGS', ['--quiet'])
	conf.find_program(conf.env.GO_COMPILER, var='GOC')
	conf.find_program(conf.env.GO_LINKER,   var='GOL')
	conf.find_program(conf.env.GO_PACK,     var='GOP')

	conf.find_program('cgo',                var='CGO')

TaskGen.feature('go')(process_use)
TaskGen.feature('go')(propagate_uselib_vars)

Exemplo n.º 39
0
def proc(tsk):
    env = tsk.env
    gen = tsk.generator
    inc_nodes = gen.to_incnodes(
        Utils.to_list(getattr(gen, 'includes', [])) + env['INCLUDES'])

    # FIXME the if-else construct will not work in python 2
    cmd = ([env.PROC] + ['SQLCHECK=SEMANTICS'] +
           (['SYS_INCLUDE=(' + ','.join(env.PROC_INCLUDES) +
             ')'] if env.PROC_INCLUDES else []) +
           ['INCLUDE=(' + ','.join([i.bldpath() for i in inc_nodes]) + ')'] +
           ['userid=' + env.PROC_CONNECTION] +
           ['INAME=' + tsk.inputs[0].bldpath()] +
           ['ONAME=' + tsk.outputs[0].bldpath()])
    exec_env = {
        'ORACLE_HOME': env.PROC_ORACLE,
        'LD_LIBRARY_PATH': env.PROC_ORACLE + path.sep + 'lib',
    }
    if env.PROC_TNS_ADMIN:
        exec_env['TNS_ADMIN'] = env.PROC_TNS_ADMIN
    return tsk.exec_command(cmd, env=exec_env)


TaskGen.declare_chain(
    name='proc',
    rule=proc,
    ext_in='.pc',
    ext_out='.c',
)
Exemplo n.º 40
0
 def __call__(self, *k, **kw):
     kw["bld"] = self
     ret = TaskGen.task_gen(*k, **kw)
     self.task_gen_cache_names = {}
     self.add_to_group(ret, group=kw.get("group", None))
     return ret
Exemplo n.º 41
0
def after(*k):
	k = [repl.get(key, key) for key in k]
	return TaskGen.after_method(*k)
Exemplo n.º 42
0
#! /usr/bin/env python
# encoding: utf-8
# WARNING! All changes made to this file will be lost!

from waflib import TaskGen,Utils
TaskGen.declare_chain(name='luac',rule='${LUAC} -s -o ${TGT} ${SRC}',ext_in='.lua',ext_out='.luac',reentrant=False)
def init_lua(self):
	self.default_chmod=Utils.O755
def configure(conf):
	conf.find_program('luac',var='LUAC')

TaskGen.feature('lua')(init_lua)
Exemplo n.º 43
0
def enhance_lib():
    """
	Modifies existing classes and methods to enable error verification
	"""
    for m in meths_typos:
        replace(m)

    # catch '..' in ant_glob patterns
    def ant_glob(self, *k, **kw):
        if k:
            lst = Utils.to_list(k[0])
            for pat in lst:
                sp = pat.split('/')
                if '..' in sp:
                    Logs.error(
                        "In ant_glob pattern %r: '..' means 'two dots', not 'parent directory'",
                        k[0])
                if '.' in sp:
                    Logs.error(
                        "In ant_glob pattern %r: '.' means 'one dot', not 'current directory'",
                        k[0])
        if kw.get('remove', True):
            try:
                if self.is_child_of(self.ctx.bldnode) and not kw.get('quiet'):
                    Logs.error(
                        'Using ant_glob on the build folder (%r) is dangerous (quiet=True to disable this warning)',
                        self)
            except AttributeError:
                pass
        return self.old_ant_glob(*k, **kw)

    Node.Node.old_ant_glob = Node.Node.ant_glob
    Node.Node.ant_glob = ant_glob

    # catch conflicting ext_in/ext_out/before/after declarations
    old = Task.is_before

    def is_before(t1, t2):
        ret = old(t1, t2)
        if ret and old(t2, t1):
            Logs.error('Contradictory order constraints in classes %r %r', t1,
                       t2)
        return ret

    Task.is_before = is_before

    # check for bld(feature='cshlib') where no 'c' is given - this can be either a mistake or on purpose
    # so we only issue a warning
    def check_err_features(self):
        lst = self.to_list(self.features)
        if 'shlib' in lst:
            Logs.error('feature shlib -> cshlib, dshlib or cxxshlib')
        for x in ('c', 'cxx', 'd', 'fc'):
            if not x in lst and lst and lst[0] in [
                    x + y for y in ('program', 'shlib', 'stlib')
            ]:
                Logs.error('%r features is probably missing %r', self, x)

    TaskGen.feature('*')(check_err_features)

    # check for erroneous order constraints
    def check_err_order(self):
        if not hasattr(self, 'rule') and not 'subst' in Utils.to_list(
                self.features):
            for x in ('before', 'after', 'ext_in', 'ext_out'):
                if hasattr(self, x):
                    Logs.warn(
                        'Erroneous order constraint %r on non-rule based task generator %r',
                        x, self)
        else:
            for x in ('before', 'after'):
                for y in self.to_list(getattr(self, x, [])):
                    if not Task.classes.get(y):
                        Logs.error(
                            'Erroneous order constraint %s=%r on %r (no such class)',
                            x, y, self)

    TaskGen.feature('*')(check_err_order)

    # check for @extension used with @feature/@before_method/@after_method
    def check_compile(self):
        check_invalid_constraints(self)
        try:
            ret = self.orig_compile()
        finally:
            check_same_targets(self)
        return ret

    Build.BuildContext.orig_compile = Build.BuildContext.compile
    Build.BuildContext.compile = check_compile

    # check for invalid build groups #914
    def use_rec(self, name, **kw):
        try:
            y = self.bld.get_tgen_by_name(name)
        except Errors.WafError:
            pass
        else:
            idx = self.bld.get_group_idx(self)
            odx = self.bld.get_group_idx(y)
            if odx > idx:
                msg = "Invalid 'use' across build groups:"
                if Logs.verbose > 1:
                    msg += '\n  target %r\n  uses:\n  %r' % (self, y)
                else:
                    msg += " %r uses %r (try 'waf -v -v' for the full error)" % (
                        self.name, name)
                raise Errors.WafError(msg)
        self.orig_use_rec(name, **kw)

    TaskGen.task_gen.orig_use_rec = TaskGen.task_gen.use_rec
    TaskGen.task_gen.use_rec = use_rec

    # check for env.append
    def _getattr(self, name, default=None):
        if name == 'append' or name == 'add':
            raise Errors.WafError(
                'env.append and env.add do not exist: use env.append_value/env.append_unique'
            )
        elif name == 'prepend':
            raise Errors.WafError(
                'env.prepend does not exist: use env.prepend_value')
        if name in self.__slots__:
            return super(ConfigSet.ConfigSet, self).__getattr__(name, default)
        else:
            return self[name]

    ConfigSet.ConfigSet.__getattr__ = _getattr
Exemplo n.º 44
0
 def declare_chain(self, *k, **kw):
     return TaskGen.declare_chain(*k, **kw)
Exemplo n.º 45
0
#! /usr/bin/env python
# encoding: utf-8
# WARNING! Do not edit! http://waf.googlecode.com/svn/docs/wafbook/single.html#_obtaining_the_waf_file

from waflib import TaskGen,Task,Utils
from waflib.Tools import c_preproc
from waflib.Tools.ccroot import link_task,stlink_task
def c_hook(self,node):
	return self.create_compiled_task('c',node)
class c(Task.Task):
	run_str='${CC} ${ARCH_ST:ARCH} ${CFLAGS} ${CPPFLAGS} ${FRAMEWORKPATH_ST:FRAMEWORKPATH} ${CPPPATH_ST:INCPATHS} ${DEFINES_ST:DEFINES} ${CC_SRC_F}${SRC} ${CC_TGT_F}${TGT}'
	vars=['CCDEPS']
	ext_in=['.h']
	scan=c_preproc.scan
Task.classes['cc']=cc=c
class cprogram(link_task):
	run_str='${LINK_CC} ${CCLNK_SRC_F}${SRC} ${CCLNK_TGT_F}${TGT[0].abspath()} ${RPATH_ST:RPATH} ${FRAMEWORKPATH_ST:FRAMEWORKPATH} ${FRAMEWORK_ST:FRAMEWORK} ${ARCH_ST:ARCH} ${STLIB_MARKER} ${STLIBPATH_ST:STLIBPATH} ${STLIB_ST:STLIB} ${SHLIB_MARKER} ${LIBPATH_ST:LIBPATH} ${LIB_ST:LIB} ${LINKFLAGS}'
	ext_out=['.bin']
	vars=['LINKDEPS']
	inst_to='${BINDIR}'
	chmod=Utils.O755
class cshlib(cprogram):
	inst_to='${LIBDIR}'
class cstlib(stlink_task):
	pass

TaskGen.extension('.c')(c_hook)
Exemplo n.º 46
0
def enhance_lib():
    for m in meths_typos:
        replace(m)

    def ant_glob(self, *k, **kw):
        if k:
            lst = Utils.to_list(k[0])
            for pat in lst:
                if '..' in pat.split('/'):
                    Logs.error(
                        "In ant_glob pattern %r: '..' means 'two dots', not 'parent directory'"
                        % k[0])
        if kw.get('remove', True):
            try:
                if self.is_child_of(
                        self.ctx.bldnode) and not kw.get('quiet', False):
                    Logs.error(
                        'Using ant_glob on the build folder (%r) is dangerous (quiet=True to disable this warning)'
                        % self)
            except AttributeError:
                pass
        return self.old_ant_glob(*k, **kw)

    Node.Node.old_ant_glob = Node.Node.ant_glob
    Node.Node.ant_glob = ant_glob
    old = Task.is_before

    def is_before(t1, t2):
        ret = old(t1, t2)
        if ret and old(t2, t1):
            Logs.error('Contradictory order constraints in classes %r %r' %
                       (t1, t2))
        return ret

    Task.is_before = is_before

    def check_err_features(self):
        lst = self.to_list(self.features)
        if 'shlib' in lst:
            Logs.error('feature shlib -> cshlib, dshlib or cxxshlib')
        for x in ('c', 'cxx', 'd', 'fc'):
            if not x in lst and lst and lst[0] in [
                    x + y for y in ('program', 'shlib', 'stlib')
            ]:
                Logs.error('%r features is probably missing %r' % (self, x))

    TaskGen.feature('*')(check_err_features)

    def check_err_order(self):
        if not hasattr(self, 'rule') and not 'subst' in Utils.to_list(
                self.features):
            for x in ('before', 'after', 'ext_in', 'ext_out'):
                if hasattr(self, x):
                    Logs.warn(
                        'Erroneous order constraint %r on non-rule based task generator %r'
                        % (x, self))
        else:
            for x in ('before', 'after'):
                for y in self.to_list(getattr(self, x, [])):
                    if not Task.classes.get(y, None):
                        Logs.error(
                            'Erroneous order constraint %s=%r on %r (no such class)'
                            % (x, y, self))

    TaskGen.feature('*')(check_err_order)

    def check_compile(self):
        check_invalid_constraints(self)
        try:
            ret = self.orig_compile()
        finally:
            check_same_targets(self)
        return ret

    Build.BuildContext.orig_compile = Build.BuildContext.compile
    Build.BuildContext.compile = check_compile

    def use_rec(self, name, **kw):
        try:
            y = self.bld.get_tgen_by_name(name)
        except Errors.WafError:
            pass
        else:
            idx = self.bld.get_group_idx(self)
            odx = self.bld.get_group_idx(y)
            if odx > idx:
                msg = "Invalid 'use' across build groups:"
                if Logs.verbose > 1:
                    msg += '\n  target %r\n  uses:\n  %r' % (self, y)
                else:
                    msg += " %r uses %r (try 'waf -v -v' for the full error)" % (
                        self.name, name)
                raise Errors.WafError(msg)
        self.orig_use_rec(name, **kw)

    TaskGen.task_gen.orig_use_rec = TaskGen.task_gen.use_rec
    TaskGen.task_gen.use_rec = use_rec

    def getattri(self, name, default=None):
        if name == 'append' or name == 'add':
            raise Errors.WafError(
                'env.append and env.add do not exist: use env.append_value/env.append_unique'
            )
        elif name == 'prepend':
            raise Errors.WafError(
                'env.prepend does not exist: use env.prepend_value')
        if name in self.__slots__:
            return object.__getattr__(self, name, default)
        else:
            return self[name]

    ConfigSet.ConfigSet.__getattr__ = getattri
Exemplo n.º 47
0
    tsk.last_cmd = lst = []
    lst.extend(to_list(env.FLEX))
    lst.extend(to_list(env.FLEXFLAGS))
    inputs = [a.path_from(tsk.get_cwd()) for a in tsk.inputs]
    if env.FLEX_MSYS:
        inputs = [x.replace(os.sep, '/') for x in inputs]
    lst.extend(inputs)
    lst = [x for x in lst if x]
    txt = bld.cmd_and_log(lst, cwd=tsk.get_cwd(), env=env.env or None, quiet=0)
    tsk.outputs[0].write(txt.replace('\r\n',
                                     '\n').replace('\r', '\n'))  # issue #1207


TaskGen.declare_chain(
    name='flex',
    rule=flexfun,  # issue #854
    ext_in='.l',
    decider=decide_ext,
)

for y in (Build.BuildContext, Build.CleanContext, Build.InstallContext,
          Build.UninstallContext, Build.ListContext):

    class tmp(y):
        variant = 'default'


def abspath(self, env=None):
    if env and hasattr(self, 'children'):
        return self.get_bld().abspath()
    return self.old_abspath()
Exemplo n.º 48
0
def before(*k):
	k = [repl.get(key, key) for key in k]
	return TaskGen.before_method(*k)
Exemplo n.º 49
0
def after(*k):
    k = [repl.get(key, key) for key in k]
    return TaskGen.after_method(*k)
Exemplo n.º 50
0
def enhance_lib():
	"""
	modify existing classes and methods
	"""
	for m in meths_typos:
		replace(m)

	# catch '..' in ant_glob patterns
	def ant_glob(self, *k, **kw):
		if k:
			lst=Utils.to_list(k[0])
			for pat in lst:
				if '..' in pat.split('/'):
					Logs.error("In ant_glob pattern %r: '..' means 'two dots', not 'parent directory'" % k[0])
		if kw.get('remove', True):
			try:
				if self.is_child_of(self.ctx.bldnode) and not kw.get('quiet', False):
					Logs.error('Using ant_glob on the build folder (%r) is dangerous (quiet=True to disable this warning)' % self)
			except AttributeError:
				pass
		return self.old_ant_glob(*k, **kw)
	Node.Node.old_ant_glob = Node.Node.ant_glob
	Node.Node.ant_glob = ant_glob

	# catch conflicting ext_in/ext_out/before/after declarations
	old = Task.is_before
	def is_before(t1, t2):
		ret = old(t1, t2)
		if ret and old(t2, t1):
			Logs.error('Contradictory order constraints in classes %r %r' % (t1, t2))
		return ret
	Task.is_before = is_before

	# check for bld(feature='cshlib') where no 'c' is given - this can be either a mistake or on purpose
	# so we only issue a warning
	def check_err_features(self):
		lst = self.to_list(self.features)
		if 'shlib' in lst:
			Logs.error('feature shlib -> cshlib, dshlib or cxxshlib')
		for x in ('c', 'cxx', 'd', 'fc'):
			if not x in lst and lst and lst[0] in [x+y for y in ('program', 'shlib', 'stlib')]:
				Logs.error('%r features is probably missing %r' % (self, x))
	TaskGen.feature('*')(check_err_features)

	# check for erroneous order constraints
	def check_err_order(self):
		if not hasattr(self, 'rule') and not 'subst' in Utils.to_list(self.features):
			for x in ('before', 'after', 'ext_in', 'ext_out'):
				if hasattr(self, x):
					Logs.warn('Erroneous order constraint %r on non-rule based task generator %r' % (x, self))
		else:
			for x in ('before', 'after'):
				for y in self.to_list(getattr(self, x, [])):
					if not Task.classes.get(y, None):
						Logs.error('Erroneous order constraint %s=%r on %r (no such class)' % (x, y, self))
	TaskGen.feature('*')(check_err_order)

	# check for @extension used with @feature/@before_method/@after_method
	def check_compile(self):
		check_invalid_constraints(self)
		try:
			ret = self.orig_compile()
		finally:
			check_same_targets(self)
		return ret
	Build.BuildContext.orig_compile = Build.BuildContext.compile
	Build.BuildContext.compile = check_compile

	# check for invalid build groups #914
	def use_rec(self, name, **kw):
		try:
			y = self.bld.get_tgen_by_name(name)
		except Errors.WafError:
			pass
		else:
			idx = self.bld.get_group_idx(self)
			odx = self.bld.get_group_idx(y)
			if odx > idx:
				msg = "Invalid 'use' across build groups:"
				if Logs.verbose > 1:
					msg += '\n  target %r\n  uses:\n  %r' % (self, y)
				else:
					msg += " %r uses %r (try 'waf -v -v' for the full error)" % (self.name, name)
				raise Errors.WafError(msg)
		self.orig_use_rec(name, **kw)
	TaskGen.task_gen.orig_use_rec = TaskGen.task_gen.use_rec
	TaskGen.task_gen.use_rec = use_rec

	# check for env.append
	def getattri(self, name, default=None):
		if name == 'append' or name == 'add':
			raise Errors.WafError('env.append and env.add do not exist: use env.append_value/env.append_unique')
		elif name == 'prepend':
			raise Errors.WafError('env.prepend does not exist: use env.prepend_value')
		if name in self.__slots__:
			return object.__getattr__(self, name, default)
		else:
			return self[name]
	ConfigSet.ConfigSet.__getattr__ = getattri
Exemplo n.º 51
0
def before(*k):
    k = [repl.get(key, key) for key in k]
    return TaskGen.before_method(*k)
Exemplo n.º 52
0
        setattr(task_gen, func.__name__, func)
        for fun_name in k:
            if not fun_name in task_gen.prec[func.__name__]:
                task_gen.prec[func.__name__].append(fun_name)
        fix_fun_doc(func)
        append_doc(func, 'after', k)
        return func

    return deco


after.__doc__ = TaskGen.after.__doc__
TaskGen.after = after

# replay existing methods
TaskGen.taskgen_method(TaskGen.to_nodes)
TaskGen.feature('*')(TaskGen.process_source)
TaskGen.feature('*')(TaskGen.process_rule)
TaskGen.before('process_source')(TaskGen.process_rule)
TaskGen.feature('seq')(TaskGen.sequence_order)
TaskGen.extension('.pc.in')(TaskGen.add_pcfile)
TaskGen.feature('subst')(TaskGen.process_subst)
TaskGen.before('process_source', 'process_rule')(TaskGen.process_subst)

from waflib.Task import Task

Task.__dict__[
    'post_run'].__doc__ = "Update the cache files (executed by threads). Override in subclasses."

from waflib import Configure, Build
confmeths = []
Exemplo n.º 53
0
        test.atstr = atstr
        test.filename = filename
        test.ut_exec = exec_list + param


from waflib.TaskGen import feature, after_method, before_method, task_gen
feature('systest')(make_systest)
after_method('apply_link')(make_systest)


# ASM hooks for the gcc compiler
def s_hook(self, node):
    return self.create_compiled_task('c', node)


TaskGen.extension('.S')(s_hook)

MKPROM = Task.task_factory('MKPROM',
                           func='${MKPROM} ${_MKPROMFLAGS} -o ${TGT} ${SRC}',
                           color='YELLOW')

MKPROM_TSKS = list()


def make_prom(self):
    """Create mkprom task"""
    elf = self.target
    if hasattr(self, 'promflags'):
        promflags = Utils.to_list(self.promflags)
    if hasattr(self, 'prom'):
        promname = self.prom
Exemplo n.º 54
0
def enhance_lib():
    """
    Modifies existing classes and methods to enable error verification
    """
    for m in meths_typos:
        replace(m)

    # catch '..' in ant_glob patterns
    def ant_glob(self, *k, **kw):
        if k:
            lst = Utils.to_list(k[0])
            for pat in lst:
                sp = pat.split("/")
                if ".." in sp:
                    Logs.error(
                        "In ant_glob pattern %r: '..' means 'two dots', not 'parent directory'",
                        k[0],
                    )
                if "." in sp:
                    Logs.error(
                        "In ant_glob pattern %r: '.' means 'one dot', not 'current directory'",
                        k[0],
                    )
        return self.old_ant_glob(*k, **kw)

    Node.Node.old_ant_glob = Node.Node.ant_glob
    Node.Node.ant_glob = ant_glob

    # catch ant_glob on build folders
    def ant_iter(
        self,
        accept=None,
        maxdepth=25,
        pats=[],
        dir=False,
        src=True,
        remove=True,
        quiet=False,
    ):
        if remove:
            try:
                if self.is_child_of(self.ctx.bldnode) and not quiet:
                    quiet = True
                    Logs.error(
                        "Calling ant_glob on build folders (%r) is dangerous: add quiet=True / remove=False",
                        self,
                    )
            except AttributeError:
                pass
        return self.old_ant_iter(accept, maxdepth, pats, dir, src, remove,
                                 quiet)

    Node.Node.old_ant_iter = Node.Node.ant_iter
    Node.Node.ant_iter = ant_iter

    # catch conflicting ext_in/ext_out/before/after declarations
    old = Task.is_before

    def is_before(t1, t2):
        ret = old(t1, t2)
        if ret and old(t2, t1):
            Logs.error("Contradictory order constraints in classes %r %r", t1,
                       t2)
        return ret

    Task.is_before = is_before

    # check for bld(feature='cshlib') where no 'c' is given - this can be either a mistake or on purpose
    # so we only issue a warning
    def check_err_features(self):
        lst = self.to_list(self.features)
        if "shlib" in lst:
            Logs.error("feature shlib -> cshlib, dshlib or cxxshlib")
        for x in ("c", "cxx", "d", "fc"):
            if (not x in lst and lst and lst[0]
                    in [x + y for y in ("program", "shlib", "stlib")]):
                Logs.error("%r features is probably missing %r", self, x)

    TaskGen.feature("*")(check_err_features)

    # check for erroneous order constraints
    def check_err_order(self):
        if not hasattr(self, "rule") and not "subst" in Utils.to_list(
                self.features):
            for x in ("before", "after", "ext_in", "ext_out"):
                if hasattr(self, x):
                    Logs.warn(
                        "Erroneous order constraint %r on non-rule based task generator %r",
                        x,
                        self,
                    )
        else:
            for x in ("before", "after"):
                for y in self.to_list(getattr(self, x, [])):
                    if not Task.classes.get(y):
                        Logs.error(
                            "Erroneous order constraint %s=%r on %r (no such class)",
                            x,
                            y,
                            self,
                        )

    TaskGen.feature("*")(check_err_order)

    # check for @extension used with @feature/@before_method/@after_method
    def check_compile(self):
        check_invalid_constraints(self)
        try:
            ret = self.orig_compile()
        finally:
            check_same_targets(self)
        return ret

    Build.BuildContext.orig_compile = Build.BuildContext.compile
    Build.BuildContext.compile = check_compile

    # check for invalid build groups #914
    def use_rec(self, name, **kw):
        try:
            y = self.bld.get_tgen_by_name(name)
        except Errors.WafError:
            pass
        else:
            idx = self.bld.get_group_idx(self)
            odx = self.bld.get_group_idx(y)
            if odx > idx:
                msg = "Invalid 'use' across build groups:"
                if Logs.verbose > 1:
                    msg += f"\n  target {self!r}\n  uses:\n  {y!r}"
                else:
                    msg += f" {self.name!r} uses {name!r} (try 'waf -v -v' for the full error)"
                raise Errors.WafError(msg)
        self.orig_use_rec(name, **kw)

    TaskGen.task_gen.orig_use_rec = TaskGen.task_gen.use_rec
    TaskGen.task_gen.use_rec = use_rec

    # check for env.append
    def _getattr(self, name, default=None):
        if name == "append" or name == "add":
            raise Errors.WafError(
                "env.append and env.add do not exist: use env.append_value/env.append_unique"
            )
        elif name == "prepend":
            raise Errors.WafError(
                "env.prepend does not exist: use env.prepend_value")
        if name in self.__slots__:
            return super(ConfigSet.ConfigSet, self).__getattr__(name, default)
        else:
            return self[name]

    ConfigSet.ConfigSet.__getattr__ = _getattr
Exemplo n.º 55
0
	shaderFile = open(src, "r")
	headerFile = open(tgt, "w")
	
	headerFile.write("namespace oak {\n")
	
	# deduce variable name from filename
	split = os.path.splitext(os.path.basename(src))
	variableName = split[0] + split[1].upper()[1:]
	
	headerFile.write("const char *" + variableName + "String = \"")
	for line in shaderFile:
		# escape '\' and '"'
		line = line.replace("\\", "\\\\")
		line = line.replace("\"", "\\\"")
		
		# content, with \n between lines
		headerFile.write(line.strip() + "\\n")
	
	headerFile.write("\";\n")
	
	headerFile.write("} // oak namespace\n")
	
	shaderFile.close()
	headerFile.close()
	
	return 0

from waflib import TaskGen
TaskGen.declare_chain(name = "vertex_shader", rule = build_shader, ext_in = ".vs", ext_out = ".vs.h")
TaskGen.declare_chain(name = "fragment_shader", rule = build_shader, ext_in = ".fs", ext_out = ".fs.h")
Exemplo n.º 56
0
    def declare_chain(self, *k, **kw):
        """
		Wrapper for :py:func:`waflib.TaskGen.declare_chain` provided for convenience
		"""
        return TaskGen.declare_chain(*k, **kw)
Exemplo n.º 57
0
    env = tsk.env
    gen = tsk.generator
    bld = gen.bld
    inc_nodes = gen.to_incnodes(
        Utils.to_list(getattr(gen, 'includes', [])) + env['INCLUDES'])

    # FIXME the if-else construct will not work in python 2
    cmd = ([env.PROC] + ['SQLCHECK=SEMANTICS'] +
           (['SYS_INCLUDE=(' + ','.join(env.PROC_INCLUDES) +
             ')'] if env.PROC_INCLUDES else []) +
           ['INCLUDE=(' + ','.join([i.bldpath() for i in inc_nodes]) + ')'] +
           ['userid=' + env.PROC_CONNECTION] +
           ['INAME=' + tsk.inputs[0].bldpath()] +
           ['ONAME=' + tsk.outputs[0].bldpath()])
    exec_env = {
        'ORACLE_HOME': env.PROC_ORACLE,
        'LD_LIBRARY_PATH': env.PROC_ORACLE + path.sep + 'lib',
    }
    if env.PROC_TNS_ADMIN:
        exec_env['TNS_ADMIN'] = env.PROC_TNS_ADMIN
    return tsk.exec_command(cmd, env=exec_env)


TaskGen.declare_chain(
    name='proc',
    rule=proc,
    ext_in='.pc',
    ext_out='.c',
    reentrant=True,
)
Exemplo n.º 58
0
def build(ctx):
    ctx.load('waf_customizations')
    ctx.load('generators.sources')

    ctx.file2string(
        source = "TOOLS/osxbundle/mpv.app/Contents/Resources/icon.icns",
        target = "osdep/macosx_icon.inc")

    ctx.file2string(
        source = "video/out/x11_icon.bin",
        target = "video/out/x11_icon.inc")

    ctx.file2string(
        source = "etc/input.conf",
        target = "input/input_conf.h")

    ctx.file2string(
        source = "video/out/gl_video_shaders.glsl",
        target = "video/out/gl_video_shaders.h")

    ctx.file2string(
        source = "sub/osd_font.otf",
        target = "sub/osd_font.h")

    ctx.file2string(
        source = "player/lua/defaults.lua",
        target = "player/lua/defaults.inc")

    ctx.file2string(
        source = "player/lua/assdraw.lua",
        target = "player/lua/assdraw.inc")

    ctx.file2string(
        source = "player/lua/osc.lua",
        target = "player/lua/osc.inc")

    ctx.matroska_header(
        source = "demux/ebml.c demux/demux_mkv.c",
        target = "ebml_types.h")

    ctx.matroska_definitions(
        source = "demux/ebml.c",
        target = "ebml_defs.c")

    getch2_c = {
        'win32':  'osdep/terminal-win.c',
    }.get(ctx.env.DEST_OS, "osdep/terminal-unix.c")

    timer_c = {
        'win32':  'osdep/timer-win2.c',
        'darwin': 'osdep/timer-darwin.c',
    }.get(ctx.env.DEST_OS, "osdep/timer-linux.c")

    sources = [
        ## Audio
        ( "audio/audio.c" ),
        ( "audio/audio_buffer.c" ),
        ( "audio/chmap.c" ),
        ( "audio/chmap_sel.c" ),
        ( "audio/fmt-conversion.c" ),
        ( "audio/format.c" ),
        ( "audio/mixer.c" ),
        ( "audio/decode/ad_lavc.c" ),
        ( "audio/decode/ad_mpg123.c",            "mpg123" ),
        ( "audio/decode/ad_spdif.c" ),
        ( "audio/decode/dec_audio.c" ),
        ( "audio/filter/af.c" ),
        ( "audio/filter/af_bs2b.c",              "libbs2b" ),
        ( "audio/filter/af_center.c" ),
        ( "audio/filter/af_channels.c" ),
        ( "audio/filter/af_convert24.c" ),
        ( "audio/filter/af_convertsignendian.c" ),
        ( "audio/filter/af_delay.c" ),
        ( "audio/filter/af_drc.c" ),
        ( "audio/filter/af_dummy.c" ),
        ( "audio/filter/af_equalizer.c" ),
        ( "audio/filter/af_export.c",            "sys-mman-h" ),
        ( "audio/filter/af_extrastereo.c" ),
        ( "audio/filter/af_format.c" ),
        ( "audio/filter/af_hrtf.c" ),
        ( "audio/filter/af_karaoke.c" ),
        ( "audio/filter/af_ladspa.c",            "ladspa" ),
        ( "audio/filter/af_lavcac3enc.c" ),
        ( "audio/filter/af_lavfi.c",             "libavfilter" ),
        ( "audio/filter/af_lavrresample.c" ),
        ( "audio/filter/af_pan.c" ),
        ( "audio/filter/af_scaletempo.c" ),
        ( "audio/filter/af_sinesuppress.c" ),
        ( "audio/filter/af_sub.c" ),
        ( "audio/filter/af_surround.c" ),
        ( "audio/filter/af_sweep.c" ),
        ( "audio/filter/af_volume.c" ),
        ( "audio/filter/filter.c" ),
        ( "audio/filter/tools.c" ),
        ( "audio/filter/window.c" ),
        ( "audio/out/ao.c" ),
        ( "audio/out/ao_alsa.c",                 "alsa" ),
        ( "audio/out/ao_coreaudio.c",            "coreaudio" ),
        ( "audio/out/ao_coreaudio_properties.c", "coreaudio" ),
        ( "audio/out/ao_coreaudio_utils.c",      "coreaudio" ),
        ( "audio/out/ao_dsound.c",               "dsound" ),
        ( "audio/out/ao_jack.c",                 "jack" ),
        ( "audio/out/ao_lavc.c",                 "encoding" ),
        ( "audio/out/ao_null.c" ),
        ( "audio/out/ao_openal.c",               "openal" ),
        ( "audio/out/ao_oss.c",                  "oss-audio" ),
        ( "audio/out/ao_pcm.c" ),
        ( "audio/out/ao_portaudio.c",            "portaudio" ),
        ( "audio/out/ao_pulse.c",                "pulse" ),
        ( "audio/out/ao_rsound.c",               "rsound" ),
        ( "audio/out/ao_sdl.c",                  "sdl1" ),
        ( "audio/out/ao_sdl.c",                  "sdl2" ),
        ( "audio/out/ao_sndio.c",                "sndio" ),
        ( "audio/out/ao_wasapi.c",               "wasapi" ),
        ( "audio/out/ao_wasapi_utils.c",         "wasapi" ),
        ( "audio/out/pull.c" ),
        ( "audio/out/push.c" ),

        ## Bstr
        ( "bstr/bstr.c" ),

        ## Core
        ( "common/av_common.c" ),
        ( "common/av_log.c" ),
        ( "common/av_opts.c" ),
        ( "common/codecs.c" ),
        ( "common/encode_lavc.c",                "encoding" ),
        ( "common/common.c" ),
        ( "common/tags.c" ),
        ( "common/msg.c" ),
        ( "common/playlist.c" ),
        ( "common/version.c" ),

        ## Demuxers
        ( "demux/codec_tags.c" ),
        ( "demux/demux.c" ),
        ( "demux/demux_cue.c" ),
        ( "demux/demux_edl.c" ),
        ( "demux/demux_lavf.c" ),
        ( "demux/demux_libass.c",                "libass"),
        ( "demux/demux_mf.c" ),
        ( "demux/demux_mkv.c" ),
        ( "demux/demux_playlist.c" ),
        ( "demux/demux_raw.c" ),
        ( "demux/demux_subreader.c" ),
        ( "demux/ebml.c" ),
        ( "demux/mf.c" ),

        ## Input
        ( "input/cmd_list.c" ),
        ( "input/cmd_parse.c" ),
        ( "input/event.c" ),
        ( "input/input.c" ),
        ( "input/keycodes.c" ),
        ( "input/joystick.c",                    "joystick" ),
        ( "input/lirc.c",                        "lirc" ),

        ## Misc
        ( "misc/charset_conv.c" ),
        ( "misc/dispatch.c" ),
        ( "misc/ring.c" ),

        ## Options
        ( "options/m_config.c" ),
        ( "options/m_option.c" ),
        ( "options/m_property.c" ),
        ( "options/options.c" ),
        ( "options/parse_commandline.c" ),
        ( "options/parse_configfile.c" ),
        ( "options/path.c" ),

        ## Player
        ( "player/audio.c" ),
        ( "player/client.c" ),
        ( "player/command.c" ),
        ( "player/configfiles.c" ),
        ( "player/discnav.c" ),
        ( "player/loadfile.c" ),
        ( "player/main.c" ),
        ( "player/misc.c" ),
        ( "player/lua.c",                        "lua" ),
        ( "player/osd.c" ),
        ( "player/playloop.c" ),
        ( "player/screenshot.c" ),
        ( "player/sub.c" ),
        ( "player/timeline/tl_cue.c" ),
        ( "player/timeline/tl_mpv_edl.c" ),
        ( "player/timeline/tl_matroska.c" ),
        ( "player/video.c" ),

        ## Streams
        ( "stream/ai_alsa1x.c",                  "alsa" ),
        ( "stream/ai_oss.c",                     "oss-audio" ),
        ( "stream/ai_sndio.c",                   "sndio" ),
        ( "stream/audio_in.c",                   "audio-input" ),
        ( "stream/cache.c" ),
        ( "stream/cookies.c" ),
        ( "stream/dvb_tune.c",                   "dvbin" ),
        ( "stream/frequencies.c",                "tv" ),
        ( "stream/rar.c" ),
        ( "stream/stream.c" ),
        ( "stream/stream_avdevice.c" ),
        ( "stream/stream_bluray.c",              "libbluray" ),
        ( "stream/stream_cdda.c",                "cdda" ),
        ( "stream/stream_dvb.c",                 "dvbin" ),
        ( "stream/stream_dvd.c",                 "dvdread" ),
        ( "stream/stream_dvd_common.c",          "dvdread" ),
        ( "stream/stream_dvdnav.c",              "dvdnav" ),
        ( "stream/stream_edl.c" ),
        ( "stream/stream_file.c" ),
        ( "stream/stream_lavf.c" ),
        ( "stream/stream_memory.c" ),
        ( "stream/stream_mf.c" ),
        ( "stream/stream_null.c" ),
        ( "stream/stream_pvr.c",                 "pvr" ),
        ( "stream/stream_rar.c" ),
        ( "stream/stream_smb.c",                 "libsmbclient" ),
        ( "stream/stream_tv.c",                  "tv" ),
        ( "stream/stream_vcd.c",                 "vcd" ),
        ( "stream/tv.c",                         "tv" ),
        ( "stream/tvi_dummy.c",                  "tv" ),
        ( "stream/tvi_v4l2.c",                   "tv-v4l2"),
        ( "stream/resolve/resolve_quvi.c",       "libquvi4" ),
        ( "stream/resolve/resolve_quvi9.c",      "libquvi9" ),

        ## Subtitles
        ( "sub/ass_mp.c",                        "libass"),
        ( "sub/dec_sub.c" ),
        ( "sub/draw_bmp.c" ),
        ( "sub/find_subfiles.c" ),
        ( "sub/img_convert.c" ),
        ( "sub/osd.c" ),
        ( "sub/osd_dummy.c",                     "dummy-osd" ),
        ( "sub/osd_libass.c",                    "libass-osd" ),
        ( "sub/sd_ass.c",                        "libass" ),
        ( "sub/sd_lavc.c" ),
        ( "sub/sd_lavc_conv.c" ),
        ( "sub/sd_lavf_srt.c" ),
        ( "sub/sd_microdvd.c" ),
        ( "sub/sd_movtext.c" ),
        ( "sub/sd_srt.c" ),

        ## Video
        ( "video/csputils.c" ),
        ( "video/fmt-conversion.c" ),
        ( "video/image_writer.c" ),
        ( "video/img_format.c" ),
        ( "video/mp_image.c" ),
        ( "video/mp_image_pool.c" ),
        ( "video/sws_utils.c" ),
        ( "video/vaapi.c",                       "vaapi" ),
        ( "video/vdpau.c",                       "vdpau" ),
        ( "video/vdpau_mixer.c",                 "vdpau" ),
        ( "video/decode/dec_video.c"),
        ( "video/decode/vaapi.c",                "vaapi-hwaccel" ),
        ( "video/decode/vd_lavc.c" ),
        ( "video/decode/vda.c",                  "vda-hwaccel" ),
        ( "video/decode/vdpau.c",                "vdpau-hwaccel" ),
        ( "video/filter/pullup.c" ),
        ( "video/filter/vf.c" ),
        ( "video/filter/vf_crop.c" ),
        ( "video/filter/vf_delogo.c" ),
        ( "video/filter/vf_divtc.c" ),
        ( "video/filter/vf_dlopen.c",            "dlopen" ),
        ( "video/filter/vf_dsize.c" ),
        ( "video/filter/vf_eq.c" ),
        ( "video/filter/vf_expand.c" ),
        ( "video/filter/vf_flip.c" ),
        ( "video/filter/vf_format.c" ),
        ( "video/filter/vf_gradfun.c" ),
        ( "video/filter/vf_hqdn3d.c" ),
        ( "video/filter/vf_ilpack.c" ),
        ( "video/filter/vf_lavfi.c",             "libavfilter"),
        ( "video/filter/vf_mirror.c" ),
        ( "video/filter/vf_noformat.c" ),
        ( "video/filter/vf_noise.c" ),
        ( "video/filter/vf_phase.c" ),
        ( "video/filter/vf_pp.c",                "libpostproc" ),
        ( "video/filter/vf_pullup.c" ),
        ( "video/filter/vf_rotate.c" ),
        ( "video/filter/vf_scale.c" ),
        ( "video/filter/vf_screenshot.c" ),
        ( "video/filter/vf_softpulldown.c" ),
        ( "video/filter/vf_stereo3d.c" ),
        ( "video/filter/vf_sub.c" ),
        ( "video/filter/vf_swapuv.c" ),
        ( "video/filter/vf_unsharp.c" ),
        ( "video/filter/vf_vapoursynth.c",       "vapoursynth" ),
        ( "video/filter/vf_vavpp.c",             "vaapi-vpp"),
        ( "video/filter/vf_vdpaupp.c",           "vdpau" ),
        ( "video/filter/vf_yadif.c" ),
        ( "video/out/aspect.c" ),
        ( "video/out/bitmap_packer.c" ),
        ( "video/out/cocoa/additions.m",         "cocoa" ),
        ( "video/out/cocoa/view.m",              "cocoa" ),
        ( "video/out/cocoa/window.m",            "cocoa" ),
        ( "video/out/cocoa_common.m",            "cocoa" ),
        ( "video/out/dither.c" ),
        ( "video/out/filter_kernels.c" ),
        ( "video/out/gl_cocoa.c",                "gl-cocoa" ),
        ( "video/out/gl_common.c",               "gl" ),
        ( "video/out/gl_hwdec_vaglx.c",          "vaapi-glx" ),
        ( "video/out/gl_hwdec_vda.c",            "vda-gl" ),
        ( "video/out/gl_hwdec_vdpau.c",          "vdpau-gl-x11" ),
        ( "video/out/gl_lcms.c",                 "gl" ),
        ( "video/out/gl_osd.c",                  "gl" ),
        ( "video/out/gl_video.c",                "gl" ),
        ( "video/out/gl_w32.c",                  "gl-win32" ),
        ( "video/out/gl_wayland.c",              "gl-wayland" ),
        ( "video/out/gl_x11.c",                  "gl-x11" ),
        ( "video/out/pnm_loader.c",              "gl" ),
        ( "video/out/vo.c" ),
        ( "video/out/vo_caca.c",                 "caca" ),
        ( "video/out/vo_corevideo.c",            "corevideo"),
        ( "video/out/vo_direct3d.c",             "direct3d" ),
        ( "video/out/vo_image.c" ),
        ( "video/out/vo_lavc.c",                 "encoding" ),
        ( "video/out/vo_null.c" ),
        ( "video/out/vo_opengl.c",               "gl" ),
        ( "video/out/vo_opengl_old.c",           "gl" ),
        ( "video/out/vo_sdl.c",                  "sdl2" ),
        ( "video/out/vo_vaapi.c",                "vaapi" ),
        ( "video/out/vo_vdpau.c",                "vdpau" ),
        ( "video/out/vo_wayland.c",              "wayland" ),
        ( "video/out/vo_x11.c" ,                 "x11" ),
        ( "video/out/vo_xv.c",                   "xv" ),
        ( "video/out/w32_common.c",              "gdi" ),
        ( "video/out/wayland_common.c",          "wayland" ),
        ( "video/out/win_state.c"),
        ( "video/out/x11_common.c",              "x11" ),

        ## osdep
        ( getch2_c ),
        ( "osdep/io.c" ),
        ( "osdep/numcores.c"),
        ( "osdep/timer.c" ),
        ( timer_c ),
        ( "osdep/threads.c" ),

        ( "osdep/ar/HIDRemote.m",                "cocoa" ),
        ( "osdep/macosx_application.m",          "cocoa" ),
        ( "osdep/macosx_events.m",               "cocoa" ),
        ( "osdep/path-macosx.m",                 "cocoa" ),

        ( "osdep/path-win.c",                    "os-win32" ),
        ( "osdep/path-win.c",                    "os-cygwin" ),
        ( "osdep/glob-win.c",                    "glob-win32-replacement" ),
        ( "osdep/priority.c",                    "priority" ),
        ( "osdep/w32_keyboard.c",                "os-win32" ),
        ( "osdep/w32_keyboard.c",                "os-cygwin" ),
        ( "osdep/mpv.rc",                        "win32-executable" ),

        ## tree_allocator
        "ta/ta.c", "ta/ta_talloc.c", "ta/ta_utils.c"
    ]

    if ctx.dependency_satisfied('win32-executable'):
        from waflib import TaskGen

        TaskGen.declare_chain(
            name    = 'windres',
            rule    = '${WINDRES} ${WINDRES_FLAGS} ${SRC} ${TGT}',
            ext_in  = '.rc',
            ext_out = '-rc.o',
            color   = 'PINK')

        ctx.env.WINDRES_FLAGS = [
            '--include-dir={0}'.format(ctx.bldnode.abspath()),
            '--include-dir={0}'.format(ctx.srcnode.abspath())
        ]

        for node in 'osdep/mpv.exe.manifest etc/mpv-icon.ico'.split():
            ctx.add_manual_dependency(
                ctx.path.find_node('osdep/mpv.rc'),
                ctx.path.find_node(node))

    cprog_kwargs = {}
    if ctx.dependency_satisfied('macosx-bundle'):
        import os
        basepath = 'TOOLS/osxbundle/mpv.app/Contents'
        cprog_kwargs['mac_app']   = True
        cprog_kwargs['mac_plist'] = os.path.join(basepath, 'Info.plist')

        resources_glob  = os.path.join(basepath, 'Resources', '*')
        resources_nodes = ctx.srcnode.ant_glob(resources_glob)
        resources       = [node.srcpath() for node in resources_nodes]
        cprog_kwargs['mac_resources'] = resources

        for resource in resources:
            res_basename = os.path.basename(resource)
            install_name = '/mpv.app/Contents/Resources/' + res_basename
            ctx.install_as(ctx.env.BINDIR + install_name, resource)

    ctx(
        target       = "mpv",
        source       = ctx.filtered_sources(sources) + ["player/main_fn.c"],
        use          = ctx.dependencies_use(),
        includes     = [ctx.bldnode.abspath(), ctx.srcnode.abspath()] + \
                       ctx.dependencies_includes(),
        features     = "c cprogram",
        install_path = ctx.env.BINDIR,
        **cprog_kwargs
    )

    if ctx.dependency_satisfied('libmpv-shared'):
        ctx.load("syms")
        vnum = int(re.search('^#define MPV_CLIENT_API_VERSION 0x(.*)UL$',
                             ctx.path.find_node("libmpv/client.h").read(),
                             re.M)
                   .group(1), 16)
        libversion = (str(vnum >> 24) + '.' +
                      str((vnum >> 16) & 0xff) + '.' +
                      str(vnum & 0xffff))
        ctx(
            target       = "mpv",
            source       = ctx.filtered_sources(sources),
            use          = ctx.dependencies_use(),
            includes     = [ctx.bldnode.abspath(), ctx.srcnode.abspath()] + \
                            ctx.dependencies_includes(),
            features     = "c cshlib syms",
            export_symbols_regex = 'mpv_.*',
            install_path = ctx.env.LIBDIR,
            vnum         = libversion,
        )

        ctx(
            target       = 'libmpv/mpv.pc',
            source       = 'libmpv/mpv.pc.in',
            features     = 'subst',
            PREFIX       = ctx.env.PREFIX,
            LIBDIR       = ctx.env.LIBDIR,
            INCDIR       = ctx.env.INCDIR,
            VERSION      = libversion,
        )

        headers = ["client.h"]
        for f in headers:
            ctx.install_as(ctx.env.INCDIR + '/mpv/' + f, 'libmpv/' + f)

        ctx.install_as(ctx.env.LIBDIR + '/pkgconfig/mpv.pc', 'libmpv/mpv.pc')

    if ctx.dependency_satisfied('client-api-examples'):
        # This assumes all examples are single-file (as examples should be)
        for f in ["simple"]:
            ctx(
                target       = f,
                source       = "DOCS/client_api_examples/" + f + ".c",
                includes     = [ctx.bldnode.abspath(), ctx.srcnode.abspath()],
                use          = "mpv",
                features     = "c cprogram",
            )

    if ctx.env.DEST_OS == 'win32':
        wrapctx = ctx(
            target       = "mpv",
            source       = ['osdep/win32-console-wrapper.c'],
            features     = "c cprogram",
            install_path = ctx.env.BINDIR
        )

        wrapctx.env.cprogram_PATTERN = "%s.com"
        wrapflags = ['-municode', '-mconsole']
        wrapctx.env.CFLAGS = wrapflags
        wrapctx.env.LAST_LINKFLAGS = wrapflags

    if ctx.dependency_satisfied('macosx-bundle'):
        from waflib import Utils
        ctx.install_files(ctx.env.BINDIR, 'mpv', chmod=Utils.O755)

    if ctx.dependency_satisfied("vf-dlopen-filters"):
        dlfilters = "showqscale telecine tile rectangle framestep \
                     ildetect".split()
        for dlfilter in dlfilters:
            ctx(
                target       = dlfilter,
                source       = ['TOOLS/vf_dlopen/'+dlfilter+'.c',
                                'TOOLS/vf_dlopen/filterutils.c'],
                includes     = [ctx.srcnode.abspath() + '/video/filter'],
                features     = 'c cshlib',
                install_path = ctx.env.LIBDIR + '/mpv' )

    if ctx.dependency_satisfied('manpage-build'):
        _build_man(ctx)

    if ctx.dependency_satisfied('pdf-build'):
        _build_pdf(ctx)

    ctx.install_files(
        ctx.env.DATADIR + '/applications',
        ['etc/mpv.desktop'] )

    ctx.install_files(ctx.env.CONFDIR, ['etc/encoding-profiles.conf'] )

    for size in '16x16 32x32 64x64'.split():
        ctx.install_as(
            ctx.env.DATADIR + '/icons/hicolor/' + size + '/apps/mpv.png',
            'etc/mpv-icon-8bit-' + size + '.png')
Exemplo n.º 59
0
def build(ctx):
    ctx.load("waf_customizations")
    ctx.load("generators.sources")

    ctx.file2string(source="video/out/x11_icon.bin", target="video/out/x11_icon.inc")

    ctx.file2string(source="etc/input.conf", target="input/input_conf.h")

    ctx.file2string(source="video/out/gl_video_shaders.glsl", target="video/out/gl_video_shaders.h")

    ctx.file2string(source="sub/osd_font.otf", target="sub/osd_font.h")

    ctx.file2string(source="player/lua/defaults.lua", target="player/lua/defaults.inc")

    ctx.file2string(source="player/lua/assdraw.lua", target="player/lua/assdraw.inc")

    ctx.file2string(source="player/lua/osc.lua", target="player/lua/osc.inc")

    ctx.matroska_header(source="demux/ebml.c demux/demux_mkv.c", target="ebml_types.h")

    ctx.matroska_definitions(source="demux/ebml.c", target="ebml_defs.c")

    getch2_c = {"win32": "osdep/terminal-win.c"}.get(ctx.env.DEST_OS, "osdep/terminal-unix.c")

    timer_c = {"win32": "osdep/timer-win2.c", "darwin": "osdep/timer-darwin.c"}.get(
        ctx.env.DEST_OS, "osdep/timer-linux.c"
    )

    sources = [
        ## Audio
        ("audio/audio.c"),
        ("audio/audio_buffer.c"),
        ("audio/chmap.c"),
        ("audio/chmap_sel.c"),
        ("audio/fmt-conversion.c"),
        ("audio/format.c"),
        ("audio/mixer.c"),
        ("audio/reorder_ch.c"),
        ("audio/decode/ad_lavc.c"),
        ("audio/decode/ad_mpg123.c", "mpg123"),
        ("audio/decode/ad_spdif.c"),
        ("audio/decode/dec_audio.c"),
        ("audio/filter/af.c"),
        ("audio/filter/af_bs2b.c", "libbs2b"),
        ("audio/filter/af_center.c"),
        ("audio/filter/af_channels.c"),
        ("audio/filter/af_convert24.c"),
        ("audio/filter/af_convertsignendian.c"),
        ("audio/filter/af_delay.c"),
        ("audio/filter/af_drc.c"),
        ("audio/filter/af_dummy.c"),
        ("audio/filter/af_equalizer.c"),
        ("audio/filter/af_export.c", "sys-mman-h"),
        ("audio/filter/af_extrastereo.c"),
        ("audio/filter/af_format.c"),
        ("audio/filter/af_hrtf.c"),
        ("audio/filter/af_karaoke.c"),
        ("audio/filter/af_ladspa.c", "ladspa"),
        ("audio/filter/af_lavcac3enc.c"),
        ("audio/filter/af_lavfi.c", "af-lavfi"),
        ("audio/filter/af_lavrresample.c"),
        ("audio/filter/af_pan.c"),
        ("audio/filter/af_scaletempo.c"),
        ("audio/filter/af_sinesuppress.c"),
        ("audio/filter/af_sub.c"),
        ("audio/filter/af_surround.c"),
        ("audio/filter/af_sweep.c"),
        ("audio/filter/af_volume.c"),
        ("audio/filter/filter.c"),
        ("audio/filter/tools.c"),
        ("audio/filter/window.c"),
        ("audio/out/ao.c"),
        ("audio/out/ao_alsa.c", "alsa"),
        ("audio/out/ao_coreaudio.c", "coreaudio"),
        ("audio/out/ao_coreaudio_properties.c", "coreaudio"),
        ("audio/out/ao_coreaudio_utils.c", "coreaudio"),
        ("audio/out/ao_dsound.c", "dsound"),
        ("audio/out/ao_jack.c", "jack"),
        ("audio/out/ao_lavc.c", "encoding"),
        ("audio/out/ao_null.c"),
        ("audio/out/ao_openal.c", "openal"),
        ("audio/out/ao_oss.c", "oss-audio"),
        ("audio/out/ao_pcm.c"),
        ("audio/out/ao_portaudio.c", "portaudio"),
        ("audio/out/ao_pulse.c", "pulse"),
        ("audio/out/ao_rsound.c", "rsound"),
        ("audio/out/ao_sdl.c", "sdl"),
        ("audio/out/ao_sdl.c", "sdl2"),
        ("audio/out/ao_sndio.c", "sndio"),
        ("audio/out/ao_wasapi.c", "wasapi"),
        ## Bstr
        ("bstr/bstr.c"),
        ## Core
        ("common/asxparser.c"),
        ("common/av_common.c"),
        ("common/av_log.c"),
        ("common/av_opts.c"),
        ("common/codecs.c"),
        ("common/cpudetect.c"),
        ("common/encode_lavc.c", "encoding"),
        ("common/common.c"),
        ("common/msg.c"),
        ("common/playlist.c"),
        ("common/playlist_parser.c"),
        ("common/version.c"),
        ## Demuxers
        ("demux/codec_tags.c"),
        ("demux/demux.c"),
        ("demux/demux_cue.c"),
        ("demux/demux_edl.c"),
        ("demux/demux_lavf.c"),
        ("demux/demux_libass.c", "libass"),
        ("demux/demux_mf.c"),
        ("demux/demux_mkv.c"),
        ("demux/demux_playlist.c"),
        ("demux/demux_raw.c"),
        ("demux/demux_subreader.c"),
        ("demux/ebml.c"),
        ("demux/mf.c"),
        ## Input
        ("input/cmd_list.c"),
        ("input/cmd_parse.c"),
        ("input/input.c"),
        ("input/keycodes.c"),
        ("input/joystick.c", "joystick"),
        ("input/lirc.c", "lirc"),
        ## Misc
        ("misc/ring.c"),
        ("misc/charset_conv.c"),
        ## Options
        ("options/m_config.c"),
        ("options/m_option.c"),
        ("options/m_property.c"),
        ("options/options.c"),
        ("options/parse_commandline.c"),
        ("options/parse_configfile.c"),
        ("options/path.c"),
        ## Player
        ("player/audio.c"),
        ("player/command.c"),
        ("player/configfiles.c"),
        ("player/dvdnav.c"),
        ("player/loadfile.c"),
        ("player/main.c"),
        ("player/misc.c"),
        ("player/lua.c", "lua"),
        ("player/osd.c"),
        ("player/playloop.c"),
        ("player/screenshot.c"),
        ("player/sub.c"),
        ("player/timeline/tl_cue.c"),
        ("player/timeline/tl_mpv_edl.c"),
        ("player/timeline/tl_matroska.c"),
        ("player/video.c"),
        ## Streams
        ("stream/ai_alsa1x.c", "alsa"),
        ("stream/ai_oss.c", "oss-audio"),
        ("stream/ai_sndio.c", "sndio"),
        ("stream/audio_in.c", "audio-input"),
        ("stream/cache.c"),
        ("stream/cdinfo.c", "cdda"),
        ("stream/cookies.c"),
        ("stream/dvb_tune.c", "dvbin"),
        ("stream/frequencies.c", "tv"),
        ("stream/rar.c"),
        ("stream/stream.c"),
        ("stream/stream_avdevice.c"),
        ("stream/stream_bluray.c", "libbluray"),
        ("stream/stream_cdda.c", "cdda"),
        ("stream/stream_dvb.c", "dvbin"),
        ("stream/stream_dvd.c", "dvdread"),
        ("stream/stream_dvd_common.c", "dvdread"),
        ("stream/stream_dvdnav.c", "dvdnav"),
        ("stream/stream_edl.c"),
        ("stream/stream_file.c"),
        ("stream/stream_lavf.c"),
        ("stream/stream_memory.c"),
        ("stream/stream_mf.c"),
        ("stream/stream_null.c"),
        ("stream/stream_pvr.c", "pvr"),
        ("stream/stream_radio.c", "radio"),
        ("stream/stream_rar.c"),
        ("stream/stream_smb.c", "libsmbclient"),
        ("stream/stream_tv.c", "tv"),
        ("stream/stream_vcd.c", "vcd"),
        ("stream/tv.c", "tv"),
        ("stream/tvi_dummy.c", "tv"),
        ("stream/tvi_v4l2.c", "tv-v4l2"),
        ("stream/resolve/resolve_quvi.c", "libquvi4"),
        ("stream/resolve/resolve_quvi9.c", "libquvi9"),
        ## Subtitles
        ("sub/ass_mp.c", "libass"),
        ("sub/dec_sub.c"),
        ("sub/draw_bmp.c"),
        ("sub/find_subfiles.c"),
        ("sub/img_convert.c"),
        ("sub/osd.c"),
        ("sub/osd_dummy.c", "dummy-osd"),
        ("sub/osd_libass.c", "libass-osd"),
        ("sub/sd_ass.c", "libass"),
        ("sub/sd_lavc.c"),
        ("sub/sd_lavc_conv.c"),
        ("sub/sd_lavf_srt.c"),
        ("sub/sd_microdvd.c"),
        ("sub/sd_movtext.c"),
        ("sub/sd_spu.c"),
        ("sub/sd_srt.c"),
        ("sub/spudec.c"),
        ## Video
        ("video/csputils.c"),
        ("video/fmt-conversion.c"),
        ("video/image_writer.c"),
        ("video/img_format.c"),
        ("video/mp_image.c"),
        ("video/mp_image_pool.c"),
        ("video/sws_utils.c"),
        ("video/vaapi.c", "vaapi"),
        ("video/vdpau.c", "vdpau"),
        ("video/decode/dec_video.c"),
        ("video/decode/lavc_dr1.c", "!avutil-refcounting"),
        ("video/decode/vaapi.c", "vaapi-hwaccel"),
        ("video/decode/vd_lavc.c"),
        ("video/decode/vda.c", "vda-hwaccel"),
        ("video/decode/vdpau.c", "vdpau-hwaccel"),
        ("video/decode/vdpau_old.c", "vdpau-decoder"),
        ("video/filter/pullup.c"),
        ("video/filter/vf.c"),
        ("video/filter/vf_crop.c"),
        ("video/filter/vf_delogo.c"),
        ("video/filter/vf_divtc.c"),
        ("video/filter/vf_dlopen.c", "dlopen"),
        ("video/filter/vf_dsize.c"),
        ("video/filter/vf_eq.c"),
        ("video/filter/vf_expand.c"),
        ("video/filter/vf_flip.c"),
        ("video/filter/vf_format.c"),
        ("video/filter/vf_gradfun.c"),
        ("video/filter/vf_hqdn3d.c"),
        ("video/filter/vf_ilpack.c"),
        ("video/filter/vf_lavfi.c", "vf-lavfi"),
        ("video/filter/vf_mirror.c"),
        ("video/filter/vf_noformat.c"),
        ("video/filter/vf_noise.c"),
        ("video/filter/vf_phase.c"),
        ("video/filter/vf_pp.c", "libpostproc"),
        ("video/filter/vf_pullup.c"),
        ("video/filter/vf_rotate.c"),
        ("video/filter/vf_scale.c"),
        ("video/filter/vf_screenshot.c"),
        ("video/filter/vf_softpulldown.c"),
        ("video/filter/vf_stereo3d.c"),
        ("video/filter/vf_sub.c"),
        ("video/filter/vf_swapuv.c"),
        ("video/filter/vf_unsharp.c"),
        ("video/filter/vf_vavpp.c", "vaapi-vpp"),
        ("video/filter/vf_yadif.c"),
        ("video/out/aspect.c"),
        ("video/out/bitmap_packer.c"),
        ("video/out/cocoa/additions.m", "cocoa"),
        ("video/out/cocoa/view.m", "cocoa"),
        ("video/out/cocoa/window.m", "cocoa"),
        ("video/out/cocoa_common.m", "cocoa"),
        ("video/out/dither.c"),
        ("video/out/filter_kernels.c"),
        ("video/out/gl_cocoa.c", "gl-cocoa"),
        ("video/out/gl_common.c", "gl"),
        ("video/out/gl_hwdec_vaglx.c", "vaapi-glx"),
        ("video/out/gl_hwdec_vda.c", "vda-gl"),
        ("video/out/gl_hwdec_vdpau.c", "vdpau-gl-x11"),
        ("video/out/gl_lcms.c", "gl"),
        ("video/out/gl_osd.c", "gl"),
        ("video/out/gl_video.c", "gl"),
        ("video/out/gl_w32.c", "gl-win32"),
        ("video/out/gl_wayland.c", "gl-wayland"),
        ("video/out/gl_x11.c", "gl-x11"),
        ("video/out/pnm_loader.c", "gl"),
        ("video/out/vo.c"),
        ("video/out/vo_caca.c", "caca"),
        ("video/out/vo_corevideo.c", "corevideo"),
        ("video/out/vo_direct3d.c", "direct3d"),
        ("video/out/vo_image.c"),
        ("video/out/vo_lavc.c", "encoding"),
        ("video/out/vo_null.c"),
        ("video/out/vo_opengl.c", "gl"),
        ("video/out/vo_opengl_old.c", "gl"),
        ("video/out/vo_sdl.c", "sdl2"),
        ("video/out/vo_vaapi.c", "vaapi"),
        ("video/out/vo_vdpau.c", "vdpau"),
        ("video/out/vo_wayland.c", "wayland"),
        ("video/out/vo_x11.c", "x11"),
        ("video/out/vo_xv.c", "xv"),
        ("video/out/w32_common.c", "gdi"),
        ("video/out/wayland_common.c", "wayland"),
        ("video/out/x11_common.c", "x11"),
        ## osdep
        (getch2_c),
        ("osdep/io.c"),
        ("osdep/numcores.c"),
        ("osdep/timer.c"),
        (timer_c),
        ("osdep/threads.c"),
        ("osdep/ar/HIDRemote.m", "cocoa"),
        ("osdep/macosx_application.m", "cocoa"),
        ("osdep/macosx_events.m", "cocoa"),
        ("osdep/path-macosx.m", "cocoa"),
        ("osdep/path-win.c", "os-win32"),
        ("osdep/path-win.c", "os-cygwin"),
        ("osdep/glob-win.c", "glob-win32-replacement"),
        ("osdep/priority.c", "priority"),
        ("osdep/mpv.rc", "win32-executable"),
        ## tree_allocator
        "ta/ta.c",
        "ta/ta_talloc.c",
        "ta/ta_utils.c",
    ]

    if ctx.dependency_satisfied("win32-executable"):
        from waflib import TaskGen

        TaskGen.declare_chain(
            name="windres",
            rule="${WINDRES} ${WINDRES_FLAGS} ${SRC} ${TGT}",
            ext_in=".rc",
            ext_out="-rc.o",
            color="PINK",
        )

        ctx.env.WINDRES_FLAGS = [
            "--include-dir={0}".format(ctx.bldnode.abspath()),
            "--include-dir={0}".format(ctx.srcnode.abspath()),
        ]

        for node in "osdep/mpv.exe.manifest etc/mpv-icon.ico".split():
            ctx.add_manual_dependency(ctx.path.find_node("osdep/mpv.rc"), ctx.path.find_node(node))

    cprog_kwargs = {}
    if ctx.dependency_satisfied("macosx-bundle"):
        import os

        basepath = "TOOLS/osxbundle/mpv.app/Contents"
        cprog_kwargs["mac_app"] = True
        cprog_kwargs["mac_plist"] = os.path.join(basepath, "Info.plist")

        resources_glob = os.path.join(basepath, "Resources", "*")
        resources_nodes = ctx.srcnode.ant_glob(resources_glob)
        resources = [node.srcpath() for node in resources_nodes]
        cprog_kwargs["mac_resources"] = resources

        for resource in resources:
            res_basename = os.path.basename(resource)
            install_name = "/mpv.app/Contents/Resources/" + res_basename
            ctx.install_as(ctx.env.BINDIR + install_name, resource)

    ctx(
        target="mpv",
        source=ctx.filtered_sources(sources),
        use=ctx.dependencies_use(),
        includes=[ctx.bldnode.abspath(), ctx.srcnode.abspath()] + ctx.dependencies_includes(),
        features="c cprogram",
        install_path=ctx.env.BINDIR,
        **cprog_kwargs
    )

    if ctx.dependency_satisfied("macosx-bundle"):
        from waflib import Utils

        ctx.install_files(ctx.env.BINDIR, "mpv", chmod=Utils.O755)

    if ctx.dependency_satisfied("vf-dlopen-filters"):
        dlfilters = "showqscale telecine tile rectangle framestep \
                     ildetect".split()
        for dlfilter in dlfilters:
            ctx(
                target=dlfilter,
                source=["TOOLS/vf_dlopen/" + dlfilter + ".c", "TOOLS/vf_dlopen/filterutils.c"],
                includes=[ctx.srcnode.abspath() + "/video/filter"],
                features="c cshlib",
                install_path=ctx.env.LIBDIR + "/mpv",
            )

    if ctx.dependency_satisfied("manpage-build"):
        _build_man(ctx)

    if ctx.dependency_satisfied("pdf-build"):
        _build_pdf(ctx)

    ctx.install_files(ctx.env.DATADIR + "/applications", ["etc/mpv.desktop"])

    ctx.install_files(ctx.env.CONFDIR, ["etc/encoding-profiles.conf"])

    for size in "16x16 32x32 64x64".split():
        ctx.install_as(
            ctx.env.DATADIR + "/icons/hicolor/" + size + "/apps/mpv.png", "etc/mpv-icon-8bit-" + size + ".png"
        )