From 2a48664afc5f634157d9c383f605d0d2541ca1d9 Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Tue, 30 Apr 2019 22:37:29 +0200 Subject: ninja: Generate everything to 'ee.ninja', generate 'build.ninja' only if it is missing. A stub build.ninja which includes ee.ninja will be generated once. This makes it easier for the user to do custom stuff in the standard Ninja file. --- src/ee/tools/ninja.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/ee') diff --git a/src/ee/tools/ninja.py b/src/ee/tools/ninja.py index 2c8a88a..ffc80c9 100644 --- a/src/ee/tools/ninja.py +++ b/src/ee/tools/ninja.py @@ -86,6 +86,7 @@ def generate(project: Project): # ee_dir = sch_path.parent / "ee" build_ninja = project.project_dir / "build.ninja" + ee_ninja = project.project_dir / "ee.ninja" parts_yaml_files = [path for path in project.project_dir.iterdir() if str(path).endswith("-parts.yaml")] params["parts_yaml_files"] = parts_yaml_files @@ -94,7 +95,15 @@ def generate(project: Project): part_dbs.extend([parent_dir_filter(p) / noext_filter(p) for p in parts_yaml_files]) part_dbs.extend([Path("ee") / d / "parts" for d in distributors]) - with build_ninja.open("w") as f: + if not build_ninja.exists(): + with build_ninja.open("w") as f: + f.writelines(["# This file was generated by eetools. Add your own rules and build commands\n", + "# here, but keep the include line as we'll update ee.ninja for you when your\n", + "# configuration changes\n", + "\n", + "include ee.ninja\n"]) + + with ee_ninja.open("w") as f: env = _create_env() template = env.get_template("build.ninja.j2") f.write(template.render(**params)) -- cgit v1.2.3