summaryrefslogtreecommitdiff
path: root/glsl.jam
blob: 20ef180a71e4bcd5f41c488943301bca9005f700 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import type : register ;
import type : type ;
import generators : register-standard ;
import scanner : register ;

type.register GL_VERTEX_SHADER : vs ;
type.register GL_TESS_CONTROL_SHADER : tcs ;
type.register GL_TESS_EVALUATION_SHADER : tes ;
type.register GL_GEOMETRY_SHADER : gs ;
type.register GL_FRAGMENT_SHADER : fs ;

generators.register-standard glsl.embed : GL_VERTEX_SHADER : CPP(vs-%) H(vs-%) ;
generators.register-standard glsl.embed : GL_TESS_CONTROL_SHADER : CPP(tcs-%) H(tcs-%) ;
generators.register-standard glsl.embed : GL_TESS_EVALUATION_SHADER : CPP(tes-%) H(tes-%) ;
generators.register-standard glsl.embed : GL_GEOMETRY_SHADER : CPP(gs-%) H(gs-%) ;
generators.register-standard glsl.embed : GL_FRAGMENT_SHADER : CPP(fs-%) H(fs-%) ;

class m4-scanner : common-scanner {
    rule pattern ( ) {
        return "s?include\\(`([^']*)'\\)" ;
    }
}

scanner.register m4-scanner : include ;

type.set-scanner GL_VERTEX_SHADER : m4-scanner ;
type.set-scanner GL_TESS_CONTROL_SHADER : m4-scanner ;
type.set-scanner GL_TESS_EVALUATION_SHADER : m4-scanner ;
type.set-scanner GL_GEOMETRY_SHADER : m4-scanner ;
type.set-scanner GL_FRAGMENT_SHADER : m4-scanner ;

actions glsl.embed
{
	m4 -I$(2:D) -DNAME=$(2:B) -DTYPE=$(2:S) > $(1[2]) lib/embed-glsl.h.m4
	m4 -I$(2:D) -DSOURCE=$(2) -DNAME=$(2:B) -DTYPE=$(2:S) -DGLTYPE=$(OPTIONS) > $(1[1]) lib/embed-glsl.cpp.m4
}

rule glsl.embed ( targets * : sources * : properties * )
{
	NOUPDATE $(targets[2]) ;
	DEPENDS $(targets[2]) : lib/embed-glsl.h.m4 ;
	DEPENDS $(targets[1]) $(targets[3]) : lib/embed-glsl.cpp.m4 ;
	OPTIONS on $(targets) = [ type.type $(sources) ] ;
}