From 290cc98b9dfbba5bea6d38689fa11751ccdecad0 Mon Sep 17 00:00:00 2001 From: Austin Appleby Date: Thu, 4 Apr 2024 21:46:57 -0700 Subject: [PATCH] update hancho build --- build.hancho | 18 ++++++++---------- config/rules.hancho | 3 +-- examples/c_lexer/c_lexer.hancho | 3 +-- examples/c_parser/c_parser.hancho | 5 ++--- examples/ini/ini.hancho | 3 +-- examples/json/json.hancho | 3 +-- examples/regex/regex.hancho | 3 +-- examples/toml/toml.hancho | 3 +-- examples/tutorial/tutorial.hancho | 8 ++++---- tests/tests.hancho | 3 +-- 10 files changed, 21 insertions(+), 31 deletions(-) diff --git a/build.hancho b/build.hancho index 368c24d..cb975a5 100644 --- a/build.hancho +++ b/build.hancho @@ -1,16 +1,14 @@ # matcheroni/build.hancho -from hancho import * print("Building Matcheroni with Hancho") build_config.build_tag = "debug" -build_config.rules_path = Path("config").absolute() -load("examples/c_lexer/c_lexer.hancho", build_config) -load("examples/c_parser/c_parser.hancho", build_config) -load("examples/ini/ini.hancho", build_config) -load("examples/json/json.hancho", build_config) -load("examples/regex/regex.hancho", build_config) -load("examples/toml/toml.hancho", build_config) -load("examples/tutorial/tutorial.hancho", build_config) -load("tests/tests.hancho", build_config) +build_config.load("examples/c_lexer/c_lexer.hancho") +build_config.load("examples/c_parser/c_parser.hancho") +build_config.load("examples/ini/ini.hancho") +build_config.load("examples/json/json.hancho") +build_config.load("examples/regex/regex.hancho") +build_config.load("examples/toml/toml.hancho") +build_config.load("examples/tutorial/tutorial.hancho") +build_config.load("tests/tests.hancho") diff --git a/config/rules.hancho b/config/rules.hancho index 2495b1b..5082dca 100644 --- a/config/rules.hancho +++ b/config/rules.hancho @@ -1,5 +1,4 @@ # matcheroni/config/rules.hancho -from hancho import * #------------------------------------------------------------------------------- @@ -39,7 +38,7 @@ test_rule = build_config.rule( #------------------------------------------------------------------------------- def compile_srcs(source_files, **kwargs): - return [compile_cpp(f, **kwargs) for f in flatten(source_files)] + return [compile_cpp(f, **kwargs) for f in hancho.flatten(source_files)] def c_binary(source_files, build_files, **kwargs): return link_c_bin(compile_srcs(source_files, **kwargs), build_files, **kwargs) diff --git a/examples/c_lexer/c_lexer.hancho b/examples/c_lexer/c_lexer.hancho index d03862f..94d956f 100644 --- a/examples/c_lexer/c_lexer.hancho +++ b/examples/c_lexer/c_lexer.hancho @@ -1,8 +1,7 @@ #------------------------------------------------------------------------------- # Matcheroni C lexer demo -from hancho import * -rules = include("{rules_path}/rules.hancho", build_config) +rules = build_config.include("{repo_path}/config/rules.hancho") c_lexer_lib = rules.c_library( ["CLexer.cpp", "CToken.cpp"], diff --git a/examples/c_parser/c_parser.hancho b/examples/c_parser/c_parser.hancho index 4418a79..3ce4549 100644 --- a/examples/c_parser/c_parser.hancho +++ b/examples/c_parser/c_parser.hancho @@ -1,10 +1,9 @@ #------------------------------------------------------------------------------- # C parser example (not finished) -from hancho import * -rules = include("{rules_path}/rules.hancho", build_config) +rules = build_config.include("{repo_path}/config/rules.hancho") -c_lexer = load("../c_lexer/c_lexer.hancho") +c_lexer = build_config.load("../c_lexer/c_lexer.hancho") c_parser_lib = rules.c_library( ["CContext.cpp", "CNode.cpp", "CScope.cpp"], diff --git a/examples/ini/ini.hancho b/examples/ini/ini.hancho index 4a82081..155c507 100644 --- a/examples/ini/ini.hancho +++ b/examples/ini/ini.hancho @@ -1,7 +1,6 @@ #------------------------------------------------------------------------------- # INI parser example -from hancho import * -rules = include("{rules_path}/rules.hancho", build_config) +rules = build_config.include("{repo_path}/config/rules.hancho") ini_parser_lib = rules.c_library("ini_parser.cpp", "ini_parser.a") diff --git a/examples/json/json.hancho b/examples/json/json.hancho index b511496..e62117c 100644 --- a/examples/json/json.hancho +++ b/examples/json/json.hancho @@ -1,8 +1,7 @@ #------------------------------------------------------------------------------- # Matcheroni JSON parser example -from hancho import * -rules = include("{rules_path}/rules.hancho", build_config) +rules = build_config.include("{repo_path}/config/rules.hancho") json_parser = rules.c_library( ["json_matcher.cpp", "json_parser.cpp"], diff --git a/examples/regex/regex.hancho b/examples/regex/regex.hancho index 3cd4a94..9a12f2b 100644 --- a/examples/regex/regex.hancho +++ b/examples/regex/regex.hancho @@ -1,8 +1,7 @@ #------------------------------------------------------------------------------- # Matcheroni regex parsing example -from hancho import * -rules = include("{rules_path}/rules.hancho", build_config) +rules = build_config.include("{repo_path}/config/rules.hancho") # These are the various regex libraries that Matcheroni can be benchmarked # against. CTRE and SRELL require that you copy their header into matcheroni/. diff --git a/examples/toml/toml.hancho b/examples/toml/toml.hancho index f0923ad..1bd76f8 100644 --- a/examples/toml/toml.hancho +++ b/examples/toml/toml.hancho @@ -1,8 +1,7 @@ #------------------------------------------------------------------------------- # TOML parser example -from hancho import * -rules = include("{rules_path}/rules.hancho", build_config) +rules = build_config.include("{repo_path}/config/rules.hancho") toml_lib = rules.c_library( "toml_parser.cpp", diff --git a/examples/tutorial/tutorial.hancho b/examples/tutorial/tutorial.hancho index 386f8f6..c2787d7 100644 --- a/examples/tutorial/tutorial.hancho +++ b/examples/tutorial/tutorial.hancho @@ -1,10 +1,10 @@ #------------------------------------------------------------------------------- # Tutorial examples -from hancho import * -rules = include("{rules_path}/rules.hancho", build_config) -c_lexer = load("../c_lexer/c_lexer.hancho") -c_parser = load("../c_parser/c_parser.hancho") +rules = build_config.include("{repo_path}/config/rules.hancho") + +c_lexer = build_config.load("../c_lexer/c_lexer.hancho") +c_parser = build_config.load("../c_parser/c_parser.hancho") rules.c_test("json_tut0a.cpp", "json_tut0a", quiet = True) rules.c_test("json_tut1a.cpp", "json_tut1a", quiet = True) diff --git a/tests/tests.hancho b/tests/tests.hancho index 2db762c..39d128e 100644 --- a/tests/tests.hancho +++ b/tests/tests.hancho @@ -1,8 +1,7 @@ #------------------------------------------------------------------------------- # Tests -from hancho import * -rules = include("{rules_path}/rules.hancho", build_config) +rules = build_config.include("{repo_path}/config/rules.hancho") #build obj/matcheroni/Matcheroni.hpp.iwyu : iwyu matcheroni/Matcheroni.hpp #build obj/matcheroni/Parseroni.hpp.iwyu : iwyu matcheroni/Parseroni.hpp