mirror of
https://github.com/mongodb/mongo.git
synced 2024-12-01 09:32:32 +01:00
30668e1c79
This patch is a reorganization of our build files, which brings them slightly closer in line with standard SCons organization. In particular, the SConstruct file sets up the various "build environment" objects, by examining the local system and command line parameters. Then, it delegates to some SConscript files, which describe build rules, like how to compile "mongod" from source. Typically, you would create several SConscript files for a project this large, after breaking the project into logical sub projects, such as "platform abstraction", "data manager", "query optimizer", etc. That will be future work. For now, we only separate out the special rules for executing smoke tests into SConscript.smoke. Pretty much all other build rules are in src/mongo/SConscript. "tools" are placed in site_scons/site_tools. This patch also includes better support for building and tracking dependencies among static libraries ("libdeps" and "MergeLibrary"), and some incumbent, minor restructuring. This patch introduces a "warning" message from SCons about framework.o having two rules that generate it. It is harmless, for now, and will be removed in future work. Future work also includes eliminating use of the SCons "Glob" utility, and restructuring the source code into sensible components.
54 lines
1.3 KiB
Python
54 lines
1.3 KiB
Python
import os
|
|
|
|
from SCons.Builder import Builder
|
|
|
|
def jsToH(target, source, env):
|
|
|
|
outFile = str( target[0] )
|
|
|
|
h = ['#include "bson/stringdata.h"'
|
|
,'namespace mongo {'
|
|
,'struct JSFile{ const char* name; const StringData& source; };'
|
|
,'namespace JSFiles{'
|
|
]
|
|
|
|
def cppEscape(s):
|
|
s = s.strip()
|
|
s = s.replace( '\\', '\\\\' )
|
|
s = s.replace( '"', r'\"' )
|
|
return s
|
|
|
|
for s in source:
|
|
filename = str(s)
|
|
objname = os.path.split(filename)[1].split('.')[0]
|
|
stringname = '_jscode_raw_' + objname
|
|
|
|
h.append('const StringData ' + stringname + " = ")
|
|
|
|
for l in open( filename, 'r' ):
|
|
h.append( '"' + cppEscape(l) + r'\n" ' )
|
|
|
|
h.append(";")
|
|
h.append('extern const JSFile %s;'%objname) #symbols aren't exported w/o this
|
|
h.append('const JSFile %s = { "%s", %s };'%(objname, filename.replace('\\', '/'), stringname))
|
|
|
|
h.append("} // namespace JSFiles")
|
|
h.append("} // namespace mongo")
|
|
h.append("")
|
|
|
|
text = '\n'.join(h);
|
|
|
|
out = open( outFile, 'wb' )
|
|
try:
|
|
out.write( text )
|
|
finally:
|
|
out.close()
|
|
|
|
jshBuilder = Builder( action=jsToH )
|
|
|
|
def generate(env, **kw):
|
|
env.Append( BUILDERS=dict( JSHeader=jshBuilder ) )
|
|
|
|
def exists(env):
|
|
return True
|