summaryrefslogtreecommitdiff
path: root/tools/build/src/contrib/tntnet.jam
blob: 0bd0ae5590440f5ed3c8dbe9f82782192dc90c2c (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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
# Copyright 2008 Eduardo Gurgel
#
# Distributed under the Boost Software License, Version 1.0. (See
# accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
#

# Support for creating components for the Tntnet web application
# server (http://tntnet.org)
#
# Example:
#
#   using tntnet : /usr ;
#   lib index : index.png index.js index.css index.ecpp otherclass.cpp
#   /tntnnet//tntnet /tntnet//cxxtools ;
#
#

import modules ;
import feature ;
import errors ;
import "class" : new ;
import generators ;
import project ;
import toolset : flags ;
import os ;
import virtual-target ;
import scanner ;
import type ;

type.register ECPP : ecpp ;
type.register JPEG : jpeg ;
type.register JPG : jpg ;
type.register PNG : png ;
type.register JS : js ;
type.register CSS : css ;
type.register GIF : gif ;

project.initialize $(__name__) ;
project tntnet ;

# Save the project so that we tolerate 'import + using' combo.
.project = [ project.current ] ;
# Initialized the Tntnet support module. The 'prefix' parameter 
# tells where Tntnet is installed.
rule init ( prefix : full_bin ? : full_inc ? : full_lib ? )
{
    project.push-current $(.project) ;

    # pre-build paths to detect reinitializations changes
    local inc_prefix lib_prefix bin_prefix ;
    if $(full_inc)
    {
        inc_prefix = $(full_inc) ; 
    }
    else
    {
        inc_prefix = $(prefix)/include ;
    }
    if $(full_lib)
    {
        lib_prefix = $(full_lib) ;
    }
    else
    {
        lib_prefix = $(prefix)/lib ;
    }
    if $(full_bin)
    {
        bin_prefix = $(full_bin) ;
    }
    else
    {
        bin_prefix = $(prefix)/bin ;
    }

    if $(.initialized)
    {
        if $(prefix) != $(.prefix)
        {
            errors.error
                "Attempt the reinitialize Tntnet with different installation prefix" ;
        }
        if $(inc_prefix) != $(.incprefix)
        {
            errors.error
                "Attempt the reinitialize Tntnet with different include path" ;
        }
        if $(lib_prefix) != $(.libprefix)
        {
            errors.error
                "Attempt the reinitialize Tntnet with different library path" ;
        }
        if $(bin_prefix) != $(.binprefix)
        {
            errors.error
                "Attempt the reinitialize Tntnet with different bin path" ;
        }
    }
    else
    {
        .initialized = true ;
        .prefix = $(prefix) ;

        # Setup prefixes for include, binaries and libs.
        .incprefix = $(.prefix)/include ;
        .libprefix = $(.prefix)/lib ;
        .binprefix = $(.prefix)/bin ;

        # Generates cpp files from ecpp files using "ecppc" tool
        generators.register-standard tntnet.ecpp : ECPP : CPP ;
        # Generates cpp files from jpeg files using "ecppc" tool
        generators.register-standard tntnet.jpeg : JPEG : CPP ;
        # Generates cpp files from jpg files using "ecppc" tool
        generators.register-standard tntnet.jpg : JPG : CPP ;
        # Generates cpp files from png files using "ecppc" tool
        generators.register-standard tntnet.png : PNG : CPP ;
        # Generates cpp files from js files using "ecppc" tool
        generators.register-standard tntnet.js : JS : CPP ;
        # Generates cpp files from gif files using "ecppc" tool
        generators.register-standard tntnet.gif : GIF : CPP ;
        # Generates cpp files from css files using "ecppc" tool
        generators.register-standard tntnet.css : CSS : CPP ;
      	# Scanner for ecpp includes
        type.set-scanner ECPP : ecpp-scanner ;

	
	local usage-requirements =
		<include>$(.incprefix)
		<library-path>$(.libprefix)
		<dll-path>$(.libprefix)
		<threading>multi
		<allow>tntnet ;
	lib cxxtools : $(main)
		:
		:
		: 
		<include>$(.incprefix)/cxxtools
		$(usage-requiriments) 
		;
	lib tntnet : $(main)
		:
		:
		: 
		<include>$(.incprefix)/tntnet
		$(usage-requiriments)
		;
		
    }
    project.pop-current ;

}

rule directory
{
    return $(.prefix) ;
}

rule initialized ( )
{
    return $(.initialized) ;
}

# Get <include> from current toolset.
flags tntnet.ecpp INCLUDES <include> ;

actions ecpp
{
	$(.binprefix)/ecppc -I " $(INCLUDES) " -o $(<) $(>)
}

actions jpeg
{
	$(.binprefix)/ecppc -b -m image/jpeg -o $(<) $(>)
}

actions jpg
{
	$(.binprefix)/ecppc -b -m image/jpeg -o $(<) $(>)
}

actions js
{
	$(.binprefix)/ecppc -b -m application/x-javascript -o $(<) $(>)
}

actions png
{
	$(.binprefix)/ecppc -b -m image/png -o $(<) $(>)
}
actions gif
{
	$(.binprefix)/ecppc -b -m image/gif -o $(<) $(>)
}
actions css
{
	$(.binprefix)/ecppc -b -m text/css -o $(<) $(>)
}

class ecpp-scanner : common-scanner
{
	rule pattern ( )
	{
		return  "<%include.*>(.*)</%include>" ;
	}
}

scanner.register ecpp-scanner : include ;