From 269124ec2624ee9185391e7529ec7eaa4173d8e7 Mon Sep 17 00:00:00 2001 From: Bruno de Oliveira Abinader Date: Tue, 7 Jun 2016 14:56:04 +0300 Subject: [core] Include type in #pragmas Part of https://github.com/mapbox/mapbox-gl-shaders/pull/13. --- scripts/build-shaders.py | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) (limited to 'scripts') diff --git a/scripts/build-shaders.py b/scripts/build-shaders.py index d94a8cdd58..3b02cdc886 100755 --- a/scripts/build-shaders.py +++ b/scripts/build-shaders.py @@ -20,27 +20,21 @@ with open(input_file, "r") as f: # Replace uniform pragmas -pragma_mapbox_regex = re.compile("(\s*)\#pragma \mapbox\: (initialize|define) (.*) (lowp|mediump|highp)") -color_regex = re.compile("(.*)color") +pragma_mapbox_regex = re.compile("(\s*)\#pragma \mapbox\: (define|initialize) (low|medium|high)p (float|vec(2|3|4)) (.*)") def replace_uniform_pragmas(line): - # FIXME We should obtain these from the source code. if pragma_mapbox_regex.match(line): params = line.split() - u_method = params[2] - u_name = params[3] - u_precision = params[4] - u_type = "vec4" if color_regex.match(u_name) else "float" - if u_method == "define": - return """uniform {precision} {type_} u_{name};""".format( - precision = u_precision, - type_ = u_type, - name = u_name) + if params[2] == "define": + return """uniform {u_precision} {u_type} u_{u_name};""".format( + u_precision = params[3], + u_type = params[4], + u_name = params[5]) else: - return """ {precision} {type_} {name} = u_{name};""".format( - precision = u_precision, - type_ = u_type, - name = u_name) + return """ {u_precision} {u_type} {u_name} = u_{u_name};""".format( + u_precision = params[3], + u_type = params[4], + u_name = params[5]) else: return line -- cgit v1.2.1