From 2a4da03f103448a69c48ee66e415f8dd2d617f58 Mon Sep 17 00:00:00 2001 From: Antony Jones Date: Sun, 3 May 2015 15:18:56 -0600 Subject: [PATCH] Added Visual Studio project generation. Use "vsproj=yes" in command line. This does not set up NMAKE properly. --- SConstruct | 46 ++++++++++ drivers/SCsub | 185 +++++++++++++++++++++-------------------- platform/windows/SCsub | 6 ++ 3 files changed, 146 insertions(+), 91 deletions(-) diff --git a/SConstruct b/SConstruct index 537bb0e395..11b35e0b4b 100644 --- a/SConstruct +++ b/SConstruct @@ -123,6 +123,7 @@ opts.Add('disable_3d', 'Disable 3D nodes for smaller executable (yes/no)', "no") opts.Add('disable_advanced_gui', 'Disable advance 3D gui nodes and behaviors (yes/no)', "no") opts.Add('colored', 'Enable colored output for the compilation (yes/no)', 'no') opts.Add('extra_suffix', 'Custom extra suffix added to the base filename of all generated binary files.', '') +opts.Add('vsproj', 'Generate Visual Studio Project. (yes/no)', 'no') # add platform specific options @@ -177,6 +178,25 @@ if selected_platform in platform_list: else: env = env_base.Clone() + if env['vsproj']=="yes": + env.vs_incs = [] + env.vs_srcs = [] + + def AddToVSProject( sources ): + for x in sources: + if type(x) == type(""): + fname = env.File(x).path + else: + fname = env.File(x)[0].path + pieces = fname.split(".") + if len(pieces)>0: + basename = pieces[0] + basename = basename.replace('\\\\','/') + env.vs_srcs = env.vs_srcs + [basename + ".cpp"] + env.vs_incs = env.vs_incs + [basename + ".h"] + #print basename + env.AddToVSProject = AddToVSProject + env.extra_suffix="" if env["extra_suffix"] != '' : @@ -330,6 +350,32 @@ if selected_platform in platform_list: SConscript("main/SCsub") SConscript("platform/"+selected_platform+"/SCsub"); # build selected platform + + # Microsoft Visual Studio Project Generation + if (env['vsproj'])=="yes": + + AddToVSProject(env.core_sources) + AddToVSProject(env.main_sources) + AddToVSProject(env.modules_sources) + AddToVSProject(env.scene_sources) + AddToVSProject(env.servers_sources) + AddToVSProject(env.tool_sources) + + debug_variants = ['Debug|Win32']+['Debug|x64'] + release_variants = ['Release|Win32']+['Release|x64'] + release_debug_variants = ['Release_Debug|Win32']+['Release_Debug|x64'] + variants = debug_variants + release_variants + release_debug_variants + debug_targets = ['Debug']+['Debug'] + release_targets = ['Release']+['Release'] + release_debug_targets = ['ReleaseDebug']+['ReleaseDebug'] + targets = debug_targets + release_targets + release_debug_targets + msvproj = env.MSVSProject(target = ['#godot' + env['MSVSPROJECTSUFFIX'] ], + incs = env.vs_incs, + srcs = env.vs_srcs, + runfile = targets, + buildtarget = targets, + auto_build_solution=1, + variant = variants) else: diff --git a/drivers/SCsub b/drivers/SCsub index a1a2191cbc..6ab0973625 100644 --- a/drivers/SCsub +++ b/drivers/SCsub @@ -1,91 +1,94 @@ -Import('env') - -env.drivers_sources=[] -#env.add_source_files(env.drivers_sources,"*.cpp") -env.Append(CPPPATH=["vorbis"]) -Export('env') - -SConscript('unix/SCsub'); -SConscript('alsa/SCsub'); -SConscript('pulseaudio/SCsub'); -SConscript('windows/SCsub'); -SConscript('gles2/SCsub'); -SConscript('gl_context/SCsub'); -SConscript('openssl/SCsub'); - -if (env["png"]=="yes"): - SConscript("png/SCsub"); -if (env["jpg"]=="yes"): - SConscript("jpg/SCsub"); -if (env["webp"]=="yes"): - SConscript("webp/SCsub"); -SConscript("dds/SCsub"); -SConscript("pvr/SCsub"); -SConscript("etc1/SCsub") -if (env["builtin_zlib"]=="yes"): - SConscript("builtin_zlib/SCsub"); -if (env["openssl"]=="builtin"): - SConscript("builtin_openssl2/SCsub"); - -SConscript("rtaudio/SCsub"); -SConscript("nedmalloc/SCsub"); -SConscript("trex/SCsub"); -SConscript("chibi/SCsub"); -if (env["vorbis"]=="yes" or env["speex"]=="yes" or env["theora"]=="yes"): - SConscript("ogg/SCsub"); -if (env["vorbis"]=="yes"): - SConscript("vorbis/SCsub"); -if (env["tools"]=="yes"): - SConscript("convex_decomp/SCsub"); - -if env["theora"]=="yes": - SConscript("theoraplayer/SCsub") -if (env["theora"]=="yes"): - SConscript("theora/SCsub"); -if (env['speex']=='yes'): - SConscript("speex/SCsub"); -if (env['musepack']=='yes'): - SConscript("mpc/SCsub"); -if (env["squish"]=="yes" and env["tools"]=="yes"): - SConscript("squish/SCsub"); - -num = 0 -cur_base = "" -total = len(env.drivers_sources) -max_src = 64 -list = [] -lib_list = [] - -import string - -for f in env.drivers_sources: - fname = "" - if type(f) == type(""): - fname = env.File(f).path - else: - fname = env.File(f)[0].path - #base = string.join(fname.split("/")[:-1], "/") - fname = fname.replace("\\", "/") - base = string.join(fname.split("/")[:2], "/") - if base != cur_base and len(list) > max_src: - lib = env.Library("drivers"+str(num), list) - lib_list.append(lib) - list = [] - num = num+1 - cur_base = base - list.append(f) - -if len(list) > 0: - lib = env.Library("drivers"+str(num), list) - lib_list.append(lib) - - -drivers_base=[] -env.add_source_files(drivers_base,"*.cpp") -lib_list.insert(0, env.Library("drivers", drivers_base)) - -env.Prepend(LIBS=lib_list) - -#lib = env.Library("drivers",env.drivers_sources) -#env.Prepend(LIBS=[lib]) - +Import('env') + +env.drivers_sources=[] +#env.add_source_files(env.drivers_sources,"*.cpp") +env.Append(CPPPATH=["vorbis"]) +Export('env') + +SConscript('unix/SCsub'); +SConscript('alsa/SCsub'); +SConscript('pulseaudio/SCsub'); +SConscript('windows/SCsub'); +SConscript('gles2/SCsub'); +SConscript('gl_context/SCsub'); +SConscript('openssl/SCsub'); + +if (env["png"]=="yes"): + SConscript("png/SCsub"); +if (env["jpg"]=="yes"): + SConscript("jpg/SCsub"); +if (env["webp"]=="yes"): + SConscript("webp/SCsub"); +SConscript("dds/SCsub"); +SConscript("pvr/SCsub"); +SConscript("etc1/SCsub") +if (env["builtin_zlib"]=="yes"): + SConscript("builtin_zlib/SCsub"); +if (env["openssl"]=="builtin"): + SConscript("builtin_openssl2/SCsub"); + +SConscript("rtaudio/SCsub"); +SConscript("nedmalloc/SCsub"); +SConscript("trex/SCsub"); +SConscript("chibi/SCsub"); +if (env["vorbis"]=="yes" or env["speex"]=="yes" or env["theora"]=="yes"): + SConscript("ogg/SCsub"); +if (env["vorbis"]=="yes"): + SConscript("vorbis/SCsub"); +if (env["tools"]=="yes"): + SConscript("convex_decomp/SCsub"); + +if env["theora"]=="yes": + SConscript("theoraplayer/SCsub") +if (env["theora"]=="yes"): + SConscript("theora/SCsub"); +if (env['speex']=='yes'): + SConscript("speex/SCsub"); +if (env['musepack']=='yes'): + SConscript("mpc/SCsub"); +if (env["squish"]=="yes" and env["tools"]=="yes"): + SConscript("squish/SCsub"); + +num = 0 +cur_base = "" +total = len(env.drivers_sources) +max_src = 64 +list = [] +lib_list = [] + +import string + +if env['vsproj']=="yes": + env.AddToVSProject(env.drivers_sources) + +for f in env.drivers_sources: + fname = "" + if type(f) == type(""): + fname = env.File(f).path + else: + fname = env.File(f)[0].path + #base = string.join(fname.split("/")[:-1], "/") + fname = fname.replace("\\", "/") + base = string.join(fname.split("/")[:2], "/") + if base != cur_base and len(list) > max_src: + lib = env.Library("drivers"+str(num), list) + lib_list.append(lib) + list = [] + num = num+1 + cur_base = base + list.append(f) + +if len(list) > 0: + lib = env.Library("drivers"+str(num), list) + lib_list.append(lib) + + +drivers_base=[] +env.add_source_files(drivers_base,"*.cpp") +lib_list.insert(0, env.Library("drivers", drivers_base)) + +env.Prepend(LIBS=lib_list) + +#lib = env.Library("drivers",env.drivers_sources) +#env.Prepend(LIBS=[lib]) + diff --git a/platform/windows/SCsub b/platform/windows/SCsub index a77428e954..1ad32e7989 100644 --- a/platform/windows/SCsub +++ b/platform/windows/SCsub @@ -12,3 +12,9 @@ common_win=[ ] env.Program('#bin/godot',['godot_win.cpp']+common_win,PROGSUFFIX=env["PROGSUFFIX"]) + +# Microsoft Visual Studio Project Generation +if (env['vsproj'])=="yes": + env.vs_srcs = env.vs_srcs + ["platform/windows/godot_win.cpp"] + for x in common_win: + env.vs_srcs = env.vs_srcs + ["platform/windows/" + x]