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 /buildscripts/make_vcxproj.py | |
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 'buildscripts/make_vcxproj.py')
-rw-r--r-- | buildscripts/make_vcxproj.py | 58 |
1 files changed, 30 insertions, 28 deletions
diff --git a/buildscripts/make_vcxproj.py b/buildscripts/make_vcxproj.py index c7aefcfc857..0e35df8097b 100644 --- a/buildscripts/make_vcxproj.py +++ b/buildscripts/make_vcxproj.py @@ -16,19 +16,19 @@ # this is easy and likely to change... # # (2) -# machine generated files (error_codes, action_types, ...) are, for now, copied by this script +# machine generated files (error_codes, action_types, ...) are, for now, copied by this script # into the source tree -- see note below in function pyth() as to why. # if those files need refreshing, run scons to generate them, and then run make_vcxproj.py again -# to copy them over. the rebuilding of the vcxproj file in that case should be moot, it is just +# to copy them over. the rebuilding of the vcxproj file in that case should be moot, it is just # the copying over of the updated files we really want to happen. -# -# (3) -# todo: i don't think the generated vcxproj perfectly handles switching from debug to release and +# +# (3) +# todo: i don't think the generated vcxproj perfectly handles switching from debug to release and # such yet. so for example: # # scons --clean all && scons --dd --win2008plus --64 mongod.exe && python ... # -# should generate a file that will work for building mongod.exe, *if* you pick win2008plus and +# should generate a file that will work for building mongod.exe, *if* you pick win2008plus and # Debug and 64 bit from the drop downs. The other variations so far, ymmv. # @@ -66,7 +66,7 @@ def get_defines(x): common_defines = get_defines(common_defines_str.split(' ')) f = open('buildscripts/vcxproj.header', 'r') -header = f.read().replace("_TARGET_", target) +header = f.read().replace("%_TARGET_%", target) print header print "<!-- common_defines -->" @@ -93,16 +93,19 @@ def add_globally(path): print "<ItemDefinitionGroup><ClCompile><AdditionalIncludeDirectories>" + machine_path + "</AdditionalIncludeDirectories></ClCompile></ItemDefinitionGroup>" print "<ItemGroup>\n" -def say(x,line): +def parse_line(x,line): # buildinfo.cpp is for scons only -- see version.cpp for more info if not "buildinfo.cpp" in x: - if x.startswith('build\\'): - #global machine_path - #if not machine_path: - # machine_path = x.split("mongo")[0] - #sys.stderr.write("todo: adding machine gen'd include path " + machine_path + " to vcxproj\n") - sys.stderr.write("adding machine gen'd file " + x + " to vcxproj\n") xtra = "" + if x.startswith('build\\'): + parts = x.split(os.sep) + if "mongo" in parts: + x = os.sep.join(parts[parts.index("mongo"):]) + elif "third_party" in parts: + x = os.sep.join(parts[parts.index("third_party"):]) + else: + raise NameError("Bad input string for source file") + x = "src" + os.sep + x if "v8\\src" in x: # or machine_path: xtra = "<AdditionalIncludeDirectories>" # it would be better to look at the command line inclusions comprehensively instead of hard code @@ -120,26 +123,25 @@ def say(x,line): defines += ';' if defines: xtra += "<PreprocessorDefinitions>" + defines + "%(PreprocessorDefinitions)</PreprocessorDefinitions>" - print " <ClCompile Include=\"" + x + "\">" + xtra + "</ClCompile>" + if xtra != "": + return " <ClCompile Include=\"" + x + "\">" + xtra + "</ClCompile>" + else: + return " <ClCompile Include=\"" + x + "\" />" from shutil import copyfile -# for the machine generated files we copy them into the src build tree locally. -# this is annoying but vstudio doesn't seem to like having parallel sets of -I include -# paths so had to do this to make it happy -def pyth(x): - for s in x: - if s.startswith("build") and s.endswith(".h"): - sys.stderr.write("copying " + s + " to src/ tree\n") - copyfile(s, 'src\mongo' + s.split("mongo")[1]) - def main (): + lines = set() for line in sys.stdin: x = line.split(' ') - if x[0] == "cl": - say(x[3],x) - elif "python" in x[0]: - pyth(x) + # Skip lines that use temp files as the argument to cl.exe + if x[0] == "cl" and len(x) > 3: + lines.add(parse_line(x[3],x)) + + for line in lines: + if line != None: + print line + print footer main() |