Restructure.

This commit is contained in:
Brad Nelson
2024-01-01 16:34:02 -08:00
parent a69961d90d
commit 8987068dac
5 changed files with 28 additions and 10 deletions

1
.gitignore vendored
View File

@ -1 +1,2 @@
out out
build.ninja

View File

@ -166,9 +166,10 @@ fast: posix esp32_sim esp32
targets: $(TARGETS) targets: $(TARGETS)
tests: $(TESTS) tests: $(TESTS)
n: build.ninja: ./configure.py
mkdir -p out $<
tools/configure.py >out/build.ninja
n: build.ninja
ninja ninja
clean-esp32: clean-esp32:

View File

@ -1,2 +0,0 @@
builddir = out
include out/build.ninja

View File

@ -13,6 +13,7 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
import argparse
import os import os
import sys import sys
import subprocess import subprocess
@ -22,7 +23,7 @@ STABLE_VERSION = '7.0.6.19'
OLD_STABLE_VERSION = '7.0.5.4' OLD_STABLE_VERSION = '7.0.5.4'
SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
ROOT_DIR = os.path.dirname(SCRIPT_DIR) ROOT_DIR = SCRIPT_DIR
REVISION = 'TODO' REVISION = 'TODO'
#REVISION=$(shell git rev-parse HEAD | head -c 20) #REVISION=$(shell git rev-parse HEAD | head -c 20)
@ -130,6 +131,7 @@ output = f"""
ninja_required_version = 1.1 ninja_required_version = 1.1
src = . src = .
dst = out dst = out
builddir = $dst
VERSION = {VERSION} VERSION = {VERSION}
REVISION = {REVISION} REVISION = {REVISION}
CFLAGS = {' '.join(CFLAGS)} CFLAGS = {' '.join(CFLAGS)}
@ -172,12 +174,12 @@ rule compile_sim
rule compile_win32 rule compile_win32
description = WIN_CL32 description = WIN_CL32
deps = msvc 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 rule compile_win64
description = WIN_CL64 description = WIN_CL64
deps = msvc 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 rule link_win32
description = WIN_LINK32 description = WIN_LINK32
@ -385,5 +387,16 @@ def Include(path):
exec(data) exec(data)
def Main():
parser = argparse.ArgumentParser(
prog='configure',
description='Generate ninja.build')
parser.add_argument('-o', default='build.ninja')
args = parser.parse_args()
Include('.') Include('.')
print(output) with open(args.o, 'w') as fh:
fh.write(output)
if __name__ == '__main__':
Main()

5
tools/posixify.py Executable file
View File

@ -0,0 +1,5 @@
#! /usr/bin/env python3
import sys
sys.stdout.write(sys.stdin.read().replace('\\', '/'))