From 8987068dac066d08a92a5b48c445acf1f94235c0 Mon Sep 17 00:00:00 2001 From: Brad Nelson Date: Mon, 1 Jan 2024 16:34:02 -0800 Subject: [PATCH] Restructure. --- .gitignore | 1 + Makefile | 7 ++++--- build.ninja | 2 -- tools/configure.py => configure.py | 23 ++++++++++++++++++----- tools/posixify.py | 5 +++++ 5 files changed, 28 insertions(+), 10 deletions(-) delete mode 100644 build.ninja rename tools/configure.py => configure.py (95%) create mode 100755 tools/posixify.py diff --git a/.gitignore b/.gitignore index 1fcb152..ac12813 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ out +build.ninja diff --git a/Makefile b/Makefile index ab03a3c..703cdd3 100644 --- a/Makefile +++ b/Makefile @@ -166,9 +166,10 @@ fast: posix esp32_sim esp32 targets: $(TARGETS) tests: $(TESTS) -n: - mkdir -p out - tools/configure.py >out/build.ninja +build.ninja: ./configure.py + $< + +n: build.ninja ninja clean-esp32: diff --git a/build.ninja b/build.ninja deleted file mode 100644 index dd65e91..0000000 --- a/build.ninja +++ /dev/null @@ -1,2 +0,0 @@ -builddir = out -include out/build.ninja diff --git a/tools/configure.py b/configure.py similarity index 95% rename from tools/configure.py rename to configure.py index 351b5b7..a446fe8 100755 --- a/tools/configure.py +++ b/configure.py @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +import argparse import os import sys import subprocess @@ -22,7 +23,7 @@ STABLE_VERSION = '7.0.6.19' OLD_STABLE_VERSION = '7.0.5.4' SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -ROOT_DIR = os.path.dirname(SCRIPT_DIR) +ROOT_DIR = SCRIPT_DIR REVISION = 'TODO' #REVISION=$(shell git rev-parse HEAD | head -c 20) @@ -130,6 +131,7 @@ output = f""" ninja_required_version = 1.1 src = . dst = out +builddir = $dst VERSION = {VERSION} REVISION = {REVISION} CFLAGS = {' '.join(CFLAGS)} @@ -172,12 +174,12 @@ rule compile_sim rule compile_win32 description = WIN_CL32 deps = msvc - command = $WIN_CL32 /showIncludes /nologo /c /Fo$out $WIN_CFLAGS $in && touch $out + command = $WIN_CL32 /showIncludes /nologo /c /Fo$out $WIN_CFLAGS $in | $src/tools/posixify.py && touch $out rule compile_win64 description = WIN_CL64 deps = msvc - command = $WIN_CL64 /showIncludes /nologo /c /Fo$out $WIN_CFLAGS $in && touch $out + command = $WIN_CL64 /showIncludes /nologo /c /Fo$out $WIN_CFLAGS $in | $src/tools/posixify.py && touch $out rule link_win32 description = WIN_LINK32 @@ -385,5 +387,16 @@ def Include(path): exec(data) -Include('.') -print(output) +def Main(): + parser = argparse.ArgumentParser( + prog='configure', + description='Generate ninja.build') + parser.add_argument('-o', default='build.ninja') + args = parser.parse_args() + Include('.') + with open(args.o, 'w') as fh: + fh.write(output) + + +if __name__ == '__main__': + Main() diff --git a/tools/posixify.py b/tools/posixify.py new file mode 100755 index 0000000..5cd686b --- /dev/null +++ b/tools/posixify.py @@ -0,0 +1,5 @@ +#! /usr/bin/env python3 + +import sys + +sys.stdout.write(sys.stdin.read().replace('\\', '/'))