* make verse compile with new verse release

* added -src/-dst patch from Emil (on my request - is already in verse CVS)
This commit is contained in:
Nathan Letwory
2006-10-03 11:33:41 +00:00
parent 9726cdc493
commit 859ea2fc01
3 changed files with 84 additions and 79 deletions

View File

@@ -116,6 +116,7 @@ if not env:
print "Could not create a build environment"
Exit()
env.SConscriptChdir(0)
cc = B.arguments.get('CC', None)
cxx = B.arguments.get('CXX', None)
if cc:

View File

@@ -10,18 +10,14 @@
#
import os
import os.path
import sys
import re
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 ()
Import('env')
defines = []
cflags = []
@@ -33,72 +29,34 @@ platform_libs = []
platform_libpath = []
platform_linkflags = []
if sys.platform == 'win32':
ourplatform = env['OURPLATFORM']
if ourplatform == 'win32-vc':
print "Building on win32"
defines += ['_WIN32']
warn_flags = ['/Wall']
platform_libs = ['ws2_32']
elif sys.platform == 'linux2':
elif ourplatform == 'win32-mingw':
defines += ['_WIN32', 'WIN32']
platform_libs = ['shell32', 'kernel32', 'gdi32', 'user32', 'ws2_32']
elif ourplatform == 'linux2':
print "Building on linux2"
elif sys.platform == 'openbsd3':
elif ourplatform == 'openbsd3':
print "Building on openbsd3"
root_build_dir = env['BF_BUILDDIR']
env_dict = env.Dictionary()
if os.path.exists (config_file):
print "Using config file: " + config_file
else:
print "Creating new config file: " + config_file
config = open (config_file, 'w')
config.write ("#Configuration file for verse SCons user definable options.\n")
config.write ("BUILD_BINARY = 'release'\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',
'Build a release or debug binary.', 'release',
allowed_values = ('release', 'debug'))),
('BUILD_DIR', 'Target directory for intermediate files.',
root_build_dir),
(EnumOption ('REGEN_PROTO',
'Whether to regenerate the protocol files', 'no',
allowed_values = ('yes', 'no'))),
('HOST_CC', 'C compiler for the host platfor. This is the same as target platform when not cross compiling.', env_dict['CC']),
('HOST_CXX', 'C++ compiler for the host platform. This is the same as target platform when not cross compiling.', env_dict['CXX']),
('TARGET_CC', 'C compiler for the target platform.', env_dict['CC']),
('TARGET_CXX', 'C++ compiler for the target platform.', env_dict['CXX']),
('TARGET_AR', 'Linker command for linking libraries.', env_dict['AR']),
('PATH', 'Standard search path', os.environ['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':
if env['VERSE_BUILD_BINARY'] == 'release':
cflags = extra_flags + release_flags + warn_flags
if sys.platform == 'win32':
if ourplatform == 'win32-vc':
defines += ['NDEBUG']
else:
cflags = extra_flags + debug_flags + warn_flags
if sys.platform == 'win32':
if ourplatform == 'win32-vc':
#defines += ['_DEBUG'] specifying this makes msvc want to link to python22_d.lib??
platform_linkflags += ['/DEBUG','/PDB:verse.pdb']
env = Environment()
env.Replace (CC = user_options_dict['TARGET_CC'])
env.Replace (CXX = user_options_dict['TARGET_CXX'])
env.Replace (PATH = user_options_dict['PATH'])
env.Replace (AR = user_options_dict['TARGET_AR'])
verse_env = env.Copy()
cmd_gen_files = (['v_cmd_gen.c',
'v_cmd_def_a.c',
@@ -117,23 +75,32 @@ proto_env = env.Copy()
proto_env.Append(CPPDEFINES=['V_GENERATE_FUNC_MODE'])
mkprot_tool = proto_env.Program(target = 'mkprot', source = cmd_gen_files)
print os.getcwd()
mkprot_re = re.compile('v_cmd_def_([a-z]{1}).c')
def mkprot_emitter(target = None, source = None, env = None):
newtargets = list()
for s in source:
m = mkprot_re.match(str(s))
p, f = os.path.split(str(s))
m = mkprot_re.match(f)
if m:
newtargets.append("v_gen_pack_"+m.group(1)+"_node.c")
newtargets.extend(['verse.h'])
env.Depends(newtargets, mkprot_tool)
return (newtargets, source)
mkprot_bld = Builder(action = "\"" + mkprot_tool[0].abspath + "\"",
mkprot_bld = Builder(action = "\"" + mkprot_tool[0].abspath + "\" -src=\""+os.getcwd()+os.sep+"extern"+os.sep+"verse"+os.sep+"dist"+os.sep+os.sep+"\" -dst=\""+os.path.abspath(env['BF_BUILDDIR'])+os.sep+"extern"+os.sep+"verse"+os.sep+"dist"+os.sep+os.sep+"\"",
emitter = mkprot_emitter)
env['BUILDERS']['Protocol'] = mkprot_bld
verse_env['BUILDERS']['Protocol'] = mkprot_bld
cmd_gen_deps.extend(env.Protocol('do_mkprot', cmd_gen_files))
cmd_gen_deps.extend(verse_env.Protocol('do_mkprot', cmd_gen_files))
print "XXXXXXXXXXXXXXXXX"
for i in cmd_gen_deps:
print i
print "XXXXXXXXXXXXXXXXX"
cmd_gen_deps.pop()
lib_source_files = (['v_cmd_buf.c',
@@ -169,25 +136,18 @@ server_source_files = (['vs_connection.c',
'vs_node_text.c'
])
verse_example_sources = (['examples/list-nodes.c'])
verselib_env = env.Copy()
verselib_env = verse_env.Copy()
verselib_env.Append(CPPDEFINES = defines)
verseserver_env = env.Copy()
verseserver_env = verse_env.Copy()
verseserver_env.Append(CPPDEFINES = defines)
verseserver_env.Append (LIBS=['libverse'])
verseserver_env.Append (LIBPATH = ['.'])
verseserver_env.Append (LIBS= platform_libs)
verseexample_env = 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.BlenderLib(libname='verse', sources=lib_source_files, includes=["."], defines = defines, libtype=['core', 'intern'], priority = [5, 5])
verseserver_env.BlenderProg(builddir="#"+root_build_dir, progname='verse', sources=server_source_files, libs=['verse'],
libpath='#'+env['BF_BUILDDIR']+'/lib')
verselib = verselib_env.Library(target='libverse', source=lib_source_files)
verseserver_env.Program(target='verse', source=server_source_files)
verseexample_env.Program(target='list-nodes', source=verse_example_sources)

View File

@@ -10,6 +10,11 @@
#include "v_cmd_gen.h"
#if defined _WIN32
#define chdir _chdir
#define snprintf _snprintf
#endif
#if defined V_GENERATE_FUNC_MODE
#define MAX_PARAMS_PER_CMD 32
@@ -43,8 +48,9 @@ extern void v_gen_text_cmd_def(void);
extern void v_gen_curve_cmd_def(void);
extern void v_gen_audio_cmd_def(void);
static void v_cg_init(void)
static int v_cg_init(const char *src_path)
{
char buf[1024];
int i;
FILE *f;
@@ -105,11 +111,21 @@ static void v_cg_init(void)
"#endif\n\n"
"#define\tVERSE_H\n\n");
/* Copy contents of "verse_header.h" into output "verse.h". */
f = fopen("verse_header.h", "r");
while((i = fgetc(f)) != EOF)
fputc(i, VCGData.verse_h);
fclose(f);
snprintf(buf, sizeof buf, "%sverse_header.h", src_path);
f = fopen(buf, "r");
if(f != NULL)
{
while((i = fgetc(f)) != EOF)
fputc(i, VCGData.verse_h);
fclose(f);
}
else
{
fprintf(stderr, "mkprot: Couldn't find \"%s\" input file\n", buf);
return 0;
}
fprintf(VCGData.verse_h, "\n/* Command sending functions begin. ----------------------------------------- */\n\n");
return 1;
}
static void v_cg_close(void)
@@ -865,8 +881,36 @@ void v_cg_end_cmd(void)
int main(int argc, char *argv[])
{
const char *src = "";
int i;
for(i = 1; argv[i] != NULL; i++)
{
if(strcmp(argv[i], "-h") == 0)
{
printf("Verse protocol generation tool.\nUsage:\n");
printf(" -h\t\tPrint this usage information, and exit.\n");
printf(" -src=PATH\tSets source path prefix to PATH. It must be possible to find\n");
printf("\t\tthe \"verse_header.h\" input file by appending that name to PATH.\n");
printf("\t\tThus, PATH must end with a proper directory separator character.\n");
printf(" -dst=PATH\tSets output directory, where all output files are written.\n");
printf("\t\tIf used, use -src to point to where \"verse_header.h\" is.\n");
return EXIT_SUCCESS;
}
else if(strncmp(argv[i], "-src=", 5) == 0)
src = argv[i] + 5;
else if(strncmp(argv[i], "-dst=", 5) == 0)
{
if(chdir(argv[i] + 5) != 0)
fprintf(stderr, "%s: Couldn't set output directory to \"%s\"\n", argv[0], argv[i]+5);
}
else
fprintf(stderr, "%s: Ignoring unknown uption \"%s\"\n", argv[0], argv[i]);
}
printf("start\n");
v_cg_init();
if(!v_cg_init(src))
return EXIT_FAILURE;
v_gen_system_cmd_def();
fprintf(VCGData.verse_h, "\n");
v_gen_object_cmd_def();