env.Program(target = 'foo', source = ['foo.o', 'bar.c', 'baz.f'])
.EE
+.IP RES
+Builds a Microsoft Visual C++ resource file. This builder is only
+provided when Microsoft Visual C++ is being used as the compiler. The
+.I .res
+suffix is added to the target name if no other suffix is given. The source
+file is scanned for implicit dependencies as though it were a C file. Example:
+
+.ES
+env.RES('resource.rc')
+.EE
+
.IP StaticLibrary
Builds a static library given one or more object files
or C, C++ or Fortran source files.
env['PCHSTOP'] = 'StdAfx.h'
.EE
-
-
.IP PDB
The Microsoft Visual C++ PDB file that will store debugging information for
object files, shared libraries, and programs. This variable is ignored by
.IP RANLIBFLAGS
General options passed to the archive indexer.
+.IP RC
+The resource compiler used by the RES builder.
+
+.IP RCCOM
+The command line used by the RES builder.
+
+.IP RCFLAGS
+The flags passed to the resource compiler by the RES builder.
+
.IP RDirs
A function that converts a file name into a list of Dir instances by
searching the repositories.
- Add an Options() object for friendlier accomodation of command-
line arguments.
- - Add support for Microsoft VC++ precompiled header (.pch)
- and debugger (.pdb) files.
+ - Add support for Microsoft VC++ precompiled header (.pch) files,
+ debugger (.pdb) files, and resource (.rc) files.
- Don't compute the $_CPPINCFLAGS, $_F77INCFLAGS, $_LIBFLAGS and
$_LIBDIRFLAGS variables each time a command is executed, define
return (target, source)
pch_builder = SCons.Builder.Builder(action='$PCHCOM', suffix='.pch', emitter=pch_emitter)
+res_builder = SCons.Builder.Builder(action='$RCCOM', suffix='.res')
def generate(env, platform):
"""Add Builders and construction variables for MSVC++ to an Environment."""
env['INCSUFFIX'] = ''
env['OBJEMITTER'] = object_emitter
+ env['RC'] = 'rc'
+ env['RCFLAGS'] = ''
+ env['RCCOM'] = '$RC $_CPPINCFLAGS $RCFLAGS /fo$TARGET $SOURCES'
+ env.CScan.add_skey('.rc')
+ env['BUILDERS']['RES'] = res_builder
+
include_path, lib_path, exe_path = get_msdev_paths()
env['ENV']['INCLUDE'] = include_path
env['ENV']['PATH'] = exe_path
env['PCH'] = env.PCH('StdAfx.cpp')[0]
env['PDB'] = File('test.pdb')
env['PCHSTOP'] = 'StdAfx.h'
-env.Program('test', 'test.cpp')
+env.Program('test', ['test.cpp', env.RES('test.rc')], LIBS=['user32'])
env.Object('fast', 'foo.cpp')
env.Object('slow', 'foo.cpp', PCH=0)
test.write('test.cpp', '''
#include "StdAfx.h"
+#include "resource.h"
int main(void)
{
- return 1;
+ char test[1024];
+ LoadString(GetModuleHandle(NULL), IDS_TEST, test, sizeof(test));
+ printf("%d %s\\n", IDS_TEST, test);
+ return 0;
}
''')
+test.write('test.rc', '''
+#include "resource.h"
+
+STRINGTABLE DISCARDABLE
+BEGIN
+ IDS_TEST "test 1"
+END
+''')
+
+test.write('resource.h', '''
+#define IDS_TEST 2001
+''')
+
+
test.write('foo.cpp', '''
#include "StdAfx.h"
''')
test.write('StdAfx.h', '''
#include <windows.h>
+#include <stdio.h>
''')
test.write('StdAfx.cpp', '''
test.run(arguments='test.exe')
+test.fail_test(not os.path.exists(test.workpath('test.exe')))
+test.fail_test(not os.path.exists(test.workpath('test.res')))
test.fail_test(not os.path.exists(test.workpath('test.pdb')))
test.fail_test(not os.path.exists(test.workpath('StdAfx.pch')))
test.fail_test(not os.path.exists(test.workpath('StdAfx.obj')))
+test.run(program=test.workpath('test.exe'), stdout='2001 test 1\n')
+
+test.write('resource.h', '''
+#define IDS_TEST 2002
+''')
+test.run(arguments='test.exe')
+test.run(program=test.workpath('test.exe'), stdout='2002 test 1\n')
+
+test.write('test.rc', '''
+#include "resource.h"
+
+STRINGTABLE DISCARDABLE
+BEGIN
+ IDS_TEST "test 2"
+END
+''')
+test.run(arguments='test.exe')
+test.run(program=test.workpath('test.exe'), stdout='2002 test 2\n')
+
test.run(arguments='-c .')
+test.fail_test(os.path.exists(test.workpath('test.exe')))
test.fail_test(os.path.exists(test.workpath('test.pdb')))
+test.fail_test(os.path.exists(test.workpath('test.res')))
test.fail_test(os.path.exists(test.workpath('StdAfx.pch')))
test.fail_test(os.path.exists(test.workpath('StdAfx.obj')))