diff options
author | Mark Benvenuto <mark.benvenuto@mongodb.com> | 2014-06-12 16:02:41 -0400 |
---|---|---|
committer | Mark Benvenuto <mark.benvenuto@mongodb.com> | 2014-06-12 16:03:38 -0400 |
commit | 4a97f4cff374897178798724a0a26172d0450828 (patch) | |
tree | 81f70c39025dd6f0b72775232a8cba463648e0af /site_scons/site_tools | |
parent | 5f9a4b0850954fb2c4f5775fbe84237bf0bf5168 (diff) | |
download | mongo-4a97f4cff374897178798724a0a26172d0450828.tar.gz |
SERVER-13759: vcxproj generator improvements
1. VCXProj now builds all .cpp files itself
2. Moved obj files to Build/ to keep repo clean
3. Split jstoh so that it can be called by vcxproj file
4. Make_Vcxproj - fixed to handle cl temp files, fixes now that vcxproj builds
generated files, and fix _TARGET_ search and replace
Note: Depends on python installation
Diffstat (limited to 'site_scons/site_tools')
-rw-r--r-- | site_scons/site_tools/jsheader.py | 42 | ||||
-rw-r--r-- | site_scons/site_tools/jstoh.py | 55 |
2 files changed, 57 insertions, 40 deletions
diff --git a/site_scons/site_tools/jsheader.py b/site_scons/site_tools/jsheader.py index 813928bf14e..284ed239d5a 100644 --- a/site_scons/site_tools/jsheader.py +++ b/site_scons/site_tools/jsheader.py @@ -1,48 +1,10 @@ import os +from jstoh import jsToHeader from SCons.Builder import Builder def jsToH(target, source, env): - - outFile = str( target[0] ) - - h = ['#include "mongo/base/string_data.h"' - ,'namespace mongo {' - ,'struct JSFile{ const char* name; const StringData& source; };' - ,'namespace JSFiles{' - ] - - def cppEscape(s): - s = s.rstrip() - 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() + jsToHeader(str(target[0]), source) jshBuilder = Builder( action=jsToH ) diff --git a/site_scons/site_tools/jstoh.py b/site_scons/site_tools/jstoh.py new file mode 100644 index 00000000000..5ae9471f108 --- /dev/null +++ b/site_scons/site_tools/jstoh.py @@ -0,0 +1,55 @@ +import os +import sys + +def jsToHeader(target, source): + + outFile = target + + h = ['#include "mongo/base/string_data.h"' + ,'namespace mongo {' + ,'struct JSFile{ const char* name; const StringData& source; };' + ,'namespace JSFiles{' + ] + + def cppEscape(s): + s = s.rstrip() + 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); + + print "writing: %s" % outFile + out = open( outFile, 'wb' ) + try: + out.write( text ) + finally: + out.close() + + +if __name__ == "__main__": + if len(sys.argv) < 3: + print "Must specify [target] [source] " + sys.exit(1); + + jsToHeader(sys.argv[1], sys.argv[2:]) + + |