diff --git a/.flake8 b/.flake8 new file mode 100644 index 0000000..3dd31e6 --- /dev/null +++ b/.flake8 @@ -0,0 +1,4 @@ +[flake8] +# E203: whitespace before ':' +# E501: line too long +extend-ignore = E203,E501 diff --git a/tools/ninja_syntax.py b/tools/ninja_syntax.py index f5d75f7..97e71f2 100644 --- a/tools/ninja_syntax.py +++ b/tools/ninja_syntax.py @@ -21,10 +21,9 @@ use Python. import re import textwrap -from typing import Optional, Union, Tuple, Match, Dict, List from io import StringIO from pathlib import Path - +from typing import Dict, List, Match, Optional, Tuple, Union NinjaPath = Union[str, Path] NinjaPaths = Union[ @@ -125,17 +124,17 @@ class Writer(object): if implicit: implicit = [escape_path(x) for x in serialize_paths(implicit)] all_inputs.append("|") - all_inputs.extend(implicit) + all_inputs.extend(map(str, implicit)) if order_only: order_only = [escape_path(x) for x in serialize_paths(order_only)] all_inputs.append("||") - all_inputs.extend(order_only) + all_inputs.extend(map(str, order_only)) if implicit_outputs: implicit_outputs = [ escape_path(x) for x in serialize_paths(implicit_outputs) ] out_outputs.append("|") - out_outputs.extend(implicit_outputs) + out_outputs.extend(map(str, implicit_outputs)) self._line( "build %s: %s" % (" ".join(out_outputs), " ".join([rule] + all_inputs)) diff --git a/tools/project.py b/tools/project.py index 2bb07b2..333f63a 100644 --- a/tools/project.py +++ b/tools/project.py @@ -12,13 +12,13 @@ import io import json +import math import os import platform import sys -import math - -from typing import Optional, Union, Tuple, Dict, List, Set, Any from pathlib import Path +from typing import Any, Dict, List, Optional, Set, Tuple, Union + from . import ninja_syntax if sys.platform == "cygwin": @@ -204,6 +204,7 @@ def generate_build_ninja( n.comment("Tooling") build_path = config.out_path() + progress_path = build_path / "progress.json" build_tools_path = config.build_dir / "tools" download_tool = config.tools_dir / "download_tool.py" n.rule( @@ -417,8 +418,8 @@ def generate_build_ninja( self.entry = config["entry"] self.inputs: List[str] = [] - def add(self, obj: str) -> None: - self.inputs.append(obj) + def add(self, obj: os.PathLike) -> None: + self.inputs.append(str(obj)) def output(self) -> Path: if self.module_id == 0: @@ -460,7 +461,7 @@ def generate_build_ninja( else: preplf_path = build_path / self.name / f"{self.name}.preplf" plf_path = build_path / self.name / f"{self.name}.plf" - preplf_ldflags = f"$ldflags -sdata 0 -sdata2 0 -r" + preplf_ldflags = "$ldflags -sdata 0 -sdata2 0 -r" plf_ldflags = f"$ldflags -sdata 0 -sdata2 0 -r1 -lcf {self.ldscript}" if self.entry: plf_ldflags += f" -m {self.entry}" @@ -646,7 +647,7 @@ def generate_build_ninja( rels_to_generate = list( filter( lambda step: step.module_id != 0 - and not step.name in generated_rels, + and step.name not in generated_rels, link_steps_local, ) ) @@ -714,7 +715,6 @@ def generate_build_ninja( # Calculate progress ### n.comment("Calculate progress") - progress_path = build_path / "progress.json" n.rule( name="progress", command=f"$python {configure_script} $configure_args progress",