diff options
Diffstat (limited to 'SConstruct')
| -rw-r--r-- | SConstruct | 60 |
1 files changed, 54 insertions, 6 deletions
diff --git a/SConstruct b/SConstruct index e745d7bb15..4085f713b7 100644 --- a/SConstruct +++ b/SConstruct @@ -62,7 +62,7 @@ platform_arg = ARGUMENTS.get("platform", ARGUMENTS.get("p", False)) if (os.name == "posix"): pass elif (os.name == "nt"): - if (os.getenv("VCINSTALLDIR") == None or platform_arg == "android"): + if (os.getenv("VCINSTALLDIR") == None or platform_arg == "android" or platform_arg == "javascript"): custom_tools = ['mingw'] env_base = Environment(tools=custom_tools) @@ -87,6 +87,13 @@ env_base.disabled_modules = [] env_base.use_ptrcall = False env_base.split_drivers = False +# To decide whether to rebuild a file, use the MD5 sum only if the timestamp has changed. +# http://scons.org/doc/production/HTML/scons-user/ch06.html#idm139837621851792 +env_base.Decider('MD5-timestamp') +# Use cached implicit dependencies by default. Can be overridden by specifying `--implicit-deps-changed` in the command line. +# http://scons.org/doc/production/HTML/scons-user/ch06s04.html +env_base.SetOption('implicit_cache', 1) + env_base.__class__.android_add_maven_repository = methods.android_add_maven_repository env_base.__class__.android_add_dependency = methods.android_add_dependency @@ -143,9 +150,11 @@ 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('extra_suffix', "Custom extra suffix added to the base filename of all generated binary files", '') opts.Add('unix_global_settings_path', "UNIX-specific path to system-wide settings. Currently only used for templates", '') -opts.Add('verbose', "Enable verbose output for the compilation (yes/no)", 'yes') +opts.Add('verbose', "Enable verbose output for the compilation (yes/no)", 'no') opts.Add('vsproj', "Generate Visual Studio Project. (yes/no)", 'no') -opts.Add('warnings', "Set the level of warnings emitted during compilation (extra/all/moderate/no)", 'all') +opts.Add('warnings', "Set the level of warnings emitted during compilation (extra/all/moderate/no)", 'no') +opts.Add('progress', "Show a progress indicator during build (yes/no)", 'yes') +opts.Add('dev', "If yes, alias for verbose=yes warnings=all (yes/no)", 'no') # Thirdparty libraries opts.Add('builtin_enet', "Use the builtin enet library (yes/no)", 'yes') @@ -201,8 +210,8 @@ if (env_base['target'] == 'debug'): env_base.Append(CPPFLAGS=['-DDEBUG_MEMORY_ALLOC']) env_base.Append(CPPFLAGS=['-DSCI_NAMESPACE']) -if (env_base['deprecated'] != 'no'): - env_base.Append(CPPFLAGS=['-DENABLE_DEPRECATED']) +if (env_base['deprecated'] == 'no'): + env_base.Append(CPPFLAGS=['-DDISABLE_DEPRECATED']) env_base.platforms = {} @@ -224,6 +233,10 @@ if selected_platform in platform_list: env = detect.create(env_base) else: env = env_base.Clone() + + if (env["dev"] == "yes"): + env["warnings"] = "all" + env["verbose"] = "yes" if env['vsproj'] == "yes": env.vs_incs = [] @@ -275,7 +288,7 @@ if selected_platform in platform_list: if (env["warnings"] == 'yes'): print("WARNING: warnings=yes is deprecated; assuming warnings=all") - if (os.name == "nt" and os.getenv("VSINSTALLDIR")): # MSVC, needs to stand out of course + if (os.name == "nt" and os.getenv("VCINSTALLDIR") and (platform_arg == "windows" or platform_arg == "uwp")): # MSVC, needs to stand out of course disable_nonessential_warnings = ['/wd4267', '/wd4244', '/wd4305', '/wd4800'] # Truncations, narrowing conversions... if (env["warnings"] == 'extra'): env.Append(CCFLAGS=['/Wall']) # Implies /W4 @@ -442,3 +455,38 @@ else: for x in platform_list: print("\t" + x) print("\nPlease run scons again with argument: platform=<string>") + + +screen = sys.stdout +node_count = 0 +node_count_max = 0 +node_count_interval = 1 +node_count_fname = str(env.Dir('#')) + '/.scons_node_count' + +def progress_function(node): + global node_count, node_count_max, node_count_interval, node_count_fname + node_count += node_count_interval + if (node_count_max > 0 and node_count <= node_count_max): + screen.write('\r[%3d%%] ' % (node_count * 100 / node_count_max)) + screen.flush() + elif (node_count_max > 0 and node_count > node_count_max): + screen.write('\r[100%] ') + screen.flush() + else: + screen.write('\r[Initial build] ') + screen.flush() + +def progress_finish(target, source, env): + global node_count + with open(node_count_fname, 'w') as f: + f.write('%d\n' % node_count) + +if (env["progress"] == "yes"): + try: + with open(node_count_fname) as f: + node_count_max = int(f.readline()) + except: + pass + Progress(progress_function, interval = node_count_interval) + progress_finish_command = Command('progress_finish', [], progress_finish) + AlwaysBuild(progress_finish_command) |