diff options
Diffstat (limited to 'SCons/Tool/ninja')
-rw-r--r-- | SCons/Tool/ninja/Methods.py | 12 | ||||
-rw-r--r-- | SCons/Tool/ninja/NinjaState.py | 10 | ||||
-rw-r--r-- | SCons/Tool/ninja/Overrides.py | 8 | ||||
-rw-r--r-- | SCons/Tool/ninja/Utils.py | 12 | ||||
-rw-r--r-- | SCons/Tool/ninja/__init__.py | 8 | ||||
-rw-r--r-- | SCons/Tool/ninja/ninja_daemon_build.py | 2 | ||||
-rw-r--r-- | SCons/Tool/ninja/ninja_run_daemon.py | 2 | ||||
-rw-r--r-- | SCons/Tool/ninja/ninja_scons_daemon.py | 18 |
8 files changed, 36 insertions, 36 deletions
diff --git a/SCons/Tool/ninja/Methods.py b/SCons/Tool/ninja/Methods.py index c0afab80b..7259475b0 100644 --- a/SCons/Tool/ninja/Methods.py +++ b/SCons/Tool/ninja/Methods.py @@ -33,17 +33,17 @@ from SCons.Tool.ninja.Utils import get_targets_sources, get_dependencies, get_or get_rule, get_path, generate_command, get_command_env, get_comstr -def register_custom_handler(env, name, handler): +def register_custom_handler(env, name, handler) -> None: """Register a custom handler for SCons function actions.""" env[NINJA_CUSTOM_HANDLERS][name] = handler -def register_custom_rule_mapping(env, pre_subst_string, rule): +def register_custom_rule_mapping(env, pre_subst_string, rule) -> None: """Register a function to call for a given rule.""" SCons.Tool.ninja.Globals.__NINJA_RULE_MAPPING[pre_subst_string] = rule -def register_custom_rule(env, rule, command, description="", deps=None, pool=None, use_depfile=False, use_response_file=False, response_file_content="$rspc"): +def register_custom_rule(env, rule, command, description: str="", deps=None, pool=None, use_depfile: bool=False, use_response_file: bool=False, response_file_content: str="$rspc") -> None: """Allows specification of Ninja rules from inside SCons files.""" rule_obj = { "command": command, @@ -66,12 +66,12 @@ def register_custom_rule(env, rule, command, description="", deps=None, pool=Non env[NINJA_RULES][rule] = rule_obj -def register_custom_pool(env, pool, size): +def register_custom_pool(env, pool, size) -> None: """Allows the creation of custom Ninja pools""" env[NINJA_POOLS][pool] = size -def set_build_node_callback(env, node, callback): +def set_build_node_callback(env, node, callback) -> None: if not node.is_conftest(): node.attributes.ninja_build_callback = callback @@ -215,7 +215,7 @@ def get_command(env, node, action): # pylint: disable=too-many-branches return ninja_build -def gen_get_response_file_command(env, rule, tool, tool_is_dynamic=False, custom_env={}): +def gen_get_response_file_command(env, rule, tool, tool_is_dynamic: bool=False, custom_env={}): """Generate a response file command provider for rule name.""" # If win32 using the environment with a response file command will cause diff --git a/SCons/Tool/ninja/NinjaState.py b/SCons/Tool/ninja/NinjaState.py index 5e7c28919..707a9e20d 100644 --- a/SCons/Tool/ninja/NinjaState.py +++ b/SCons/Tool/ninja/NinjaState.py @@ -52,7 +52,7 @@ from .Methods import get_command class NinjaState: """Maintains state of Ninja build system as it's translated from SCons.""" - def __init__(self, env, ninja_file, ninja_syntax): + def __init__(self, env, ninja_file, ninja_syntax) -> None: self.env = env self.ninja_file = ninja_file @@ -303,7 +303,7 @@ class NinjaState: } self.pools = {"scons_pool": 1} - def add_build(self, node): + def add_build(self, node) -> bool: if not node.has_builder(): return False @@ -348,12 +348,12 @@ class NinjaState: # TODO: rely on SCons to tell us what is generated source # or some form of user scanner maybe (Github Issue #3624) - def is_generated_source(self, output): + def is_generated_source(self, output) -> bool: """Check if output ends with a known generated suffix.""" _, suffix = splitext(output) return suffix in self.generated_suffixes - def has_generated_sources(self, output): + def has_generated_sources(self, output) -> bool: """ Determine if output indicates this is a generated header file. """ @@ -710,7 +710,7 @@ class NinjaState: class SConsToNinjaTranslator: """Translates SCons Actions into Ninja build objects.""" - def __init__(self, env): + def __init__(self, env) -> None: self.env = env self.func_handlers = { # Skip conftest builders diff --git a/SCons/Tool/ninja/Overrides.py b/SCons/Tool/ninja/Overrides.py index e98ec4036..83d2efb11 100644 --- a/SCons/Tool/ninja/Overrides.py +++ b/SCons/Tool/ninja/Overrides.py @@ -27,7 +27,7 @@ ninja file generation import SCons -def ninja_hack_linkcom(env): +def ninja_hack_linkcom(env) -> None: # TODO: change LINKCOM and SHLINKCOM to handle embedding manifest exe checks # without relying on the SCons hacks that SCons uses by default. if env["PLATFORM"] == "win32": @@ -42,7 +42,7 @@ def ninja_hack_linkcom(env): ] = '${TEMPFILE("$SHLINK $SHLINKFLAGS $_SHLINK_TARGETS $_LIBDIRFLAGS $_LIBFLAGS $_PDB $_SHLINK_SOURCES", "$SHLINKCOMSTR")}' -def ninja_hack_arcom(env): +def ninja_hack_arcom(env) -> None: """ Force ARCOM so use 's' flag on ar instead of separately running ranlib """ @@ -68,12 +68,12 @@ class NinjaNoResponseFiles(SCons.Platform.TempFileMunge): def __call__(self, target, source, env, for_signature): return self.cmd - def _print_cmd_str(*_args, **_kwargs): + def _print_cmd_str(*_args, **_kwargs) -> None: """Disable this method""" pass -def ninja_always_serial(self, num, taskmaster): +def ninja_always_serial(self, num, taskmaster) -> None: """Replacement for SCons.Job.Jobs constructor which always uses the Serial Job class.""" # We still set self.num_jobs to num even though it's a lie. The # only consumer of this attribute is the Parallel Job class AND diff --git a/SCons/Tool/ninja/Utils.py b/SCons/Tool/ninja/Utils.py index 7269fb2e5..eb09daf4e 100644 --- a/SCons/Tool/ninja/Utils.py +++ b/SCons/Tool/ninja/Utils.py @@ -34,7 +34,7 @@ class NinjaExperimentalWarning(SCons.Warnings.WarningOnByDefault): pass -def ninja_add_command_line_options(): +def ninja_add_command_line_options() -> None: """ Add additional command line arguments to SCons specific to the ninja tool """ @@ -92,7 +92,7 @@ def alias_to_ninja_build(node): } -def check_invalid_ninja_node(node): +def check_invalid_ninja_node(node) -> bool: return not isinstance(node, (SCons.Node.FS.Base, SCons.Node.Alias.Alias)) @@ -129,7 +129,7 @@ def get_order_only(node): return [get_path(src_file(prereq)) for prereq in filter_ninja_nodes(node.prerequisites)] -def get_dependencies(node, skip_sources=False): +def get_dependencies(node, skip_sources: bool=False): """Return a list of dependencies for node.""" if skip_sources: return [ @@ -236,7 +236,7 @@ def to_escaped_list(env, lst): return sorted([dep.escape(env.get("ESCAPE", lambda x: x)) for dep in deps_list]) -def generate_depfile(env, node, dependencies): +def generate_depfile(env, node, dependencies) -> None: """ Ninja tool function for writing a depfile. The depfile should include the node path followed by all the dependent files in a makefile format. @@ -281,7 +281,7 @@ def ninja_recursive_sorted_dict(build): return sorted_dict -def ninja_sorted_build(ninja, **build): +def ninja_sorted_build(ninja, **build) -> None: sorted_dict = ninja_recursive_sorted_dict(build) ninja.build(**sorted_dict) @@ -437,7 +437,7 @@ def ninja_whereis(thing, *_args, **_kwargs): return path -def ninja_print_conf_log(s, target, source, env): +def ninja_print_conf_log(s, target, source, env) -> None: """Command line print only for conftest to generate a correct conf log.""" if target and target[0].is_conftest(): action = SCons.Action._ActionAction() diff --git a/SCons/Tool/ninja/__init__.py b/SCons/Tool/ninja/__init__.py index 2622641d9..0ee72d2cf 100644 --- a/SCons/Tool/ninja/__init__.py +++ b/SCons/Tool/ninja/__init__.py @@ -136,7 +136,7 @@ def ninja_builder(env, target, source): sys.stdout.write("\n") -def options(opts): +def options(opts) -> None: """ Add command line Variables for Ninja builder. """ @@ -302,7 +302,7 @@ def generate(env): # instead return something that looks more expanded. So to # continue working even if a user has done this we map both the # "bracketted" and semi-expanded versions. - def robust_rule_mapping(var, rule, tool): + def robust_rule_mapping(var, rule, tool) -> None: provider = gen_get_response_file_command(env, rule, tool) env.NinjaRuleMapping("${" + var + "}", provider) @@ -459,7 +459,7 @@ def generate(env): # In the future we may be able to use this to actually cache the build.ninja # file once we have the upstream support for referencing SConscripts as File # nodes. - def ninja_execute(self): + def ninja_execute(self) -> None: target = self.targets[0] if target.get_env().get('NINJA_SKIP'): @@ -475,7 +475,7 @@ def generate(env): # date-ness. SCons.Script.Main.BuildTask.needs_execute = lambda x: True - def ninja_Set_Default_Targets(env, tlist): + def ninja_Set_Default_Targets(env, tlist) -> None: """ Record the default targets if they were ever set by the user. Ninja will need to write the default targets and make sure not to include diff --git a/SCons/Tool/ninja/ninja_daemon_build.py b/SCons/Tool/ninja/ninja_daemon_build.py index 32c375dfd..f198d773c 100644 --- a/SCons/Tool/ninja/ninja_daemon_build.py +++ b/SCons/Tool/ninja/ninja_daemon_build.py @@ -55,7 +55,7 @@ logging.basicConfig( ) -def log_error(msg): +def log_error(msg) -> None: logging.debug(msg) sys.stderr.write(msg) diff --git a/SCons/Tool/ninja/ninja_run_daemon.py b/SCons/Tool/ninja/ninja_run_daemon.py index 08029a29f..666be0f71 100644 --- a/SCons/Tool/ninja/ninja_run_daemon.py +++ b/SCons/Tool/ninja/ninja_run_daemon.py @@ -61,7 +61,7 @@ logging.basicConfig( level=logging.DEBUG, ) -def log_error(msg): +def log_error(msg) -> None: logging.debug(msg) sys.stderr.write(msg) diff --git a/SCons/Tool/ninja/ninja_scons_daemon.py b/SCons/Tool/ninja/ninja_scons_daemon.py index 6802af293..2084097fc 100644 --- a/SCons/Tool/ninja/ninja_scons_daemon.py +++ b/SCons/Tool/ninja/ninja_scons_daemon.py @@ -77,11 +77,11 @@ logging.basicConfig( ) -def daemon_log(message): +def daemon_log(message) -> None: logging.debug(message) -def custom_readlines(handle, line_separator="\n", chunk_size=1): +def custom_readlines(handle, line_separator: str="\n", chunk_size: int=1): buf = "" while not handle.closed: data = handle.read(chunk_size) @@ -98,7 +98,7 @@ def custom_readlines(handle, line_separator="\n", chunk_size=1): buf = "" -def custom_readerr(handle, line_separator="\n", chunk_size=1): +def custom_readerr(handle, line_separator: str="\n", chunk_size: int=1): buf = "" while not handle.closed: data = handle.read(chunk_size) @@ -112,13 +112,13 @@ def custom_readerr(handle, line_separator="\n", chunk_size=1): yield chunk + line_separator -def enqueue_output(out, queue): +def enqueue_output(out, queue) -> None: for line in iter(custom_readlines(out)): queue.put(line) out.close() -def enqueue_error(err, queue): +def enqueue_error(err, queue) -> None: for line in iter(custom_readerr(err)): queue.put(line) err.close() @@ -143,7 +143,7 @@ class StateInfo: shared_state = StateInfo() -def sigint_func(signum, frame): +def sigint_func(signum, frame) -> None: global shared_state shared_state.daemon_needs_to_shutdown = True @@ -264,7 +264,7 @@ logging.debug( keep_alive_timer = timer() -def server_thread_func(): +def server_thread_func() -> None: global shared_state class S(http.server.BaseHTTPRequestHandler): def do_GET(self): @@ -284,7 +284,7 @@ def server_thread_func(): daemon_log(f"Got request: {build[0]}") input_q.put(build[0]) - def pred(): + def pred() -> bool: return build[0] in shared_state.finished_building with building_cv: @@ -329,7 +329,7 @@ def server_thread_func(): daemon_log("SERVER ERROR: " + traceback.format_exc()) raise - def log_message(self, format, *args): + def log_message(self, format, *args) -> None: return socketserver.TCPServer.allow_reuse_address = True |