Welcome to mirror list, hosted at ThFree Co, Russian Federation.

SConstruct « dist « verse « extern - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: ac6f6031b99e85fc67529e8b4cc2e2e32646d3f1 (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
#
# SConstruct for Verse
#
# This file is still quite crude, but it does it's job, and
# is geared towards future extensions.
#
# I did this only on Windows so people should look into the
# if...elif...
# construction about the platform specific stuff.
#
# I think it is quite straight-forward to add new platforms,
# just look at the old makefile and at the existing platforms.
#
# This SConstruct creates a configuration file which can be
# used for tweaking a build.
#
# For more about SConstruct, see <http://www.scons.org/>.
#

import os
import sys
import time
import string
from distutils import sysconfig

root_build_dir = '..' + os.sep + 'build' + os.sep

config_file = 'config.opts'
version = '1.0'

env = Environment ()

defines = []
cflags = []
debug_flags = []
extra_flags = []
release_flags = []
warn_flags = []
platform_libs = []
platform_libpath = []
platform_linkflags = []

if sys.platform == 'win32':
    print "Building on win32"
    defines += ['_WIN32']
    warn_flags = ['/Wall']
    platform_libs = ['ws2_32']
elif sys.platform == 'linux2':
    print "Building on linux2"
elif sys.platform == 'openbsd3':
    print "Building on openbsd3"

if os.path.exists (config_file):
    print "Using config file: " + config_file
else:
    print "Creating new config file: " + config_file
    env_dict = env.Dictionary()
    config = open (config_file, 'w')
    config.write ("#Configuration file for verse SCons user definable options.\n")
    config.write ("BUILD_BINARY = 'release'\n")
    config.write ("REGEN_PROTO = 'yes'\n")
    config.write ("\n# Compiler information.\n")
    config.write ("HOST_CC = %r\n"%(env_dict['CC']))
    config.write ("HOST_CXX = %r\n"%(env_dict['CXX']))
    config.write ("TARGET_CC = %r\n"%(env_dict['CC']))
    config.write ("TARGET_CXX = %r\n"%(env_dict['CXX']))
    config.write ("TARGET_AR = %r\n"%(env_dict['AR']))
    config.write ("PATH = %r\n"%(os.environ['PATH']))

user_options_env = Environment()
user_options = Options (config_file)
user_options.AddOptions(
    (EnumOption ('BUILD_BINARY', 'release',
        'Build a release or debug binary.',
        allowed_values = ('release', 'debug'))),
    ('BUILD_DIR', 'Target directory for intermediate files.',
        root_build_dir),
    (EnumOption ('REGEN_PROTO', 'yes',
        'Whether to regenerate the protocol files',
        allowed_values = ('yes', 'no'))),
    ('HOST_CC', 'C compiler for the host platfor. This is the same as target platform when not cross compiling.'),
    ('HOST_CXX', 'C++ compiler for the host platform. This is the same as target platform when not cross compiling.'),
    ('TARGET_CC', 'C compiler for the target platform.'),
    ('TARGET_CXX', 'C++ compiler for the target platform.'),
    ('TARGET_AR', 'Linker command for linking libraries.'),
    ('PATH', 'Standard search path')
)
user_options.Update (user_options_env)
user_options_dict = user_options_env.Dictionary()

root_build_dir = user_options_dict['BUILD_DIR']

if user_options_dict['BUILD_BINARY'] == 'release':
    cflags = extra_flags + release_flags + warn_flags
    if sys.platform == 'win32':
        defines += ['NDEBUG']
else:
    cflags = extra_flags + debug_flags + warn_flags
    if sys.platform == 'win32':
        #defines += ['_DEBUG'] specifying this makes msvc want to link to python22_d.lib??
        platform_linkflags += ['/DEBUG','/PDB:verse.pdb']

library_env = Environment()
library_env.Replace (CC = user_options_dict['TARGET_CC'])
library_env.Replace (CXX = user_options_dict['TARGET_CXX'])
library_env.Replace (PATH = user_options_dict['PATH'])
library_env.Replace (AR = user_options_dict['TARGET_AR'])

cmd_gen_files = (['v_cmd_gen.c',
				  'v_cmd_def_a.c',
				  'v_cmd_def_b.c',
				  'v_cmd_def_c.c',
				  'v_cmd_def_g.c',
				  'v_cmd_def_m.c',
				  'v_cmd_def_o.c',
				  'v_cmd_def_s.c',
				  'v_cmd_def_t.c'
				  ])

cmd_gen_deps = (['v_gen_pack_init.c',
				 'v_gen_pack_a_node.c',
				 'v_gen_pack_b_node.c',
				 'v_gen_pack_c_node.c',
				 'v_gen_pack_g_node.c',
				 'v_gen_pack_m_node.c',
				 'v_gen_pack_o_node.c',
				 'v_gen_pack_s_node.c',
				 'v_gen_pack_t_node.c',
				])

if user_options_dict['REGEN_PROTO']=='yes':
    cmd_gen_env = library_env.Copy()
    cmd_gen_env.Append(CPPDEFINES=['V_GENERATE_FUNC_MODE'])
    mkprot = cmd_gen_env.Program(target='mkprot', source=cmd_gen_files)
    cmd_gen_env.Command('regen', '' , './mkprot')

lib_source_files = (['v_cmd_buf.c',
					 'v_connect.c',
					 'v_connection.c',
					 'v_encryption.c',
					 'v_func_storage.c',
					 'v_man_pack_node.c',
					 'v_network.c',
					 'v_network_in_que.c',
					 'v_network_out_que.c',
					 'v_pack.c',
					 'v_pack_method.c',
					 'v_prime.c',
					 'v_randgen.c',
					 'v_util.c',
					 'v_bignum.c'
					 ])
lib_source_files += cmd_gen_deps

server_source_files = (['vs_connection.c',
                        'vs_main.c',
						'vs_node_audio.c',
                        'vs_node_bitmap.c',
                        'vs_node_curve.c',
                        'vs_node_geometry.c',
                        'vs_node_head.c',
                        'vs_node_material.c',
                        'vs_node_object.c',
                        'vs_node_particle.c',
                        'vs_node_storage.c',
                        'vs_node_text.c'
                        ])

verse_example_sources = (['examples/list-nodes.c'])

verselib_env = library_env.Copy()
verselib_env.Append(CPPDEFINES = defines)

verseserver_env = library_env.Copy()
verseserver_env.Append(CPPDEFINES = defines)
verseserver_env.Append (LIBS=['libverse'])
verseserver_env.Append (LIBPATH = ['.'])
verseserver_env.Append (LIBS= platform_libs)

verseexample_env = library_env.Copy()
verseexample_env.Append(CPPDEFINES = defines)
verseexample_env.Append (LIBS=['libverse'])
verseexample_env.Append (LIBPATH = ['.'])
verseexample_env.Append (LIBS= platform_libs)
verseexample_env.Append (CPPPATH = ['.'])

verselib = verselib_env.Library(target='libverse', source=lib_source_files)
if user_options_dict['REGEN_PROTO']=='yes':
    verselib_env.Depends(verselib, mkprot)
verseserver_env.Program(target='verse', source=server_source_files)
verseexample_env.Program(target='list-nodes', source=verse_example_sources)