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 __get_version__(ctx):
|
|
|
|
import subprocess
|
|
|
|
process = subprocess.Popen(["sh", "./version.sh", "--print"],
|
|
|
|
stdout=subprocess.PIPE,
|
|
|
|
stderr=subprocess.PIPE,
|
|
|
|
cwd=ctx.srcnode.abspath())
|
|
|
|
(version, err) = process.communicate()
|
2014-06-13 18:12:06 +00:00
|
|
|
version = version.strip()
|
|
|
|
if not isinstance(version, str):
|
|
|
|
version = version.decode('utf-8')
|
|
|
|
return version
|
2013-07-16 11:28:28 +00:00
|
|
|
|
|
|
|
def __get_build_date__():
|
|
|
|
import time
|
|
|
|
return time.strftime("%Y-%m-%dT%H:%M:%S", time.gmtime())
|
|
|
|
|
|
|
|
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")
|
|
|
|
|
|
|
|
def __write_version_h__(ctx):
|
|
|
|
ctx.start_msg("Writing header:")
|
|
|
|
ctx.env.VERSION = __get_version__(ctx)
|
|
|
|
ctx.define("VERSION", ctx.env.VERSION)
|
|
|
|
ctx.define("BUILDDATE", __get_build_date__())
|
|
|
|
ctx.write_config_header("version.h")
|
2014-08-04 08:44:21 +00:00
|
|
|
__cp_to_variant__(ctx, ctx.options.variant, 'version.h')
|
2013-07-16 11:28:28 +00:00
|
|
|
ctx.end_msg("version.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-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-01-02 02:06:06 +00:00
|
|
|
ctx.define("FULLCONFIG", "\\n" + __escape_c_string(ctx.get_config_header()) + "\\n")
|
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)
|
|
|
|
__write_version_h__(ctx)
|