2014-08-04 08:44:21 +00:00
|
|
|
def __cp_to_variant__(ctx, variant, basename):
|
2014-10-11 18:35:10 +00:00
|
|
|
src = ctx.bldnode.search_node(basename).read()
|
2014-08-04 08:44:21 +00:00
|
|
|
node = ctx.bldnode.make_node("{0}/{1}".format(variant, basename))
|
|
|
|
node.parent.mkdir()
|
|
|
|
node.write(src)
|
|
|
|
|
2013-07-16 11:28:28 +00:00
|
|
|
def __write_config_h__(ctx):
|
|
|
|
ctx.start_msg("Writing configuration header:")
|
|
|
|
ctx.write_config_header('config.h')
|
2014-08-04 08:44:21 +00:00
|
|
|
__cp_to_variant__(ctx, ctx.options.variant, 'config.h')
|
2013-07-16 11:28:28 +00:00
|
|
|
ctx.end_msg("config.h", "PINK")
|
|
|
|
|
2015-01-02 02:06:06 +00:00
|
|
|
# Approximately escape the string as C string literal
|
|
|
|
def __escape_c_string(s):
|
|
|
|
return s.replace("\"", "\\\"").replace("\n", "\\n")
|
|
|
|
|
2015-03-11 22:33:05 +00:00
|
|
|
def __get_features_string__(ctx):
|
2015-07-26 13:00:47 +00:00
|
|
|
import inflector
|
2015-03-11 22:33:05 +00:00
|
|
|
stuff = []
|
|
|
|
for dependency_identifier in ctx.satisfied_deps:
|
2015-07-26 13:00:47 +00:00
|
|
|
defkey = inflector.define_key(dependency_identifier)
|
2015-03-11 22:33:05 +00:00
|
|
|
if ctx.is_defined(defkey) and ctx.get_define(defkey) == "1":
|
|
|
|
stuff.append(dependency_identifier)
|
|
|
|
stuff.sort()
|
|
|
|
return " ".join(stuff)
|
|
|
|
|
2015-01-02 02:18:16 +00:00
|
|
|
def __add_mpv_defines__(ctx):
|
2013-07-16 11:28:28 +00:00
|
|
|
from sys import argv
|
|
|
|
ctx.define("CONFIGURATION", " ".join(argv))
|
2015-01-02 02:18:16 +00:00
|
|
|
ctx.define("MPV_CONFDIR", ctx.env.CONFDIR)
|
2015-03-11 22:33:05 +00:00
|
|
|
ctx.define("FULLCONFIG", __escape_c_string(__get_features_string__(ctx)))
|
2013-07-16 11:28:28 +00:00
|
|
|
|
|
|
|
def configure(ctx):
|
2015-01-02 02:18:16 +00:00
|
|
|
__add_mpv_defines__(ctx)
|
2013-07-16 11:28:28 +00:00
|
|
|
__write_config_h__(ctx)
|