From 855b427ad24275939fb00042078891756eb9f8a3 Mon Sep 17 00:00:00 2001 From: Austin Appleby Date: Sat, 10 Aug 2024 18:12:16 -0700 Subject: [PATCH] trying to get everything working again at the same time --- build.hancho | 34 +++++++++++++++---------------- examples/c_lexer/c_lexer.hancho | 24 ++++++---------------- examples/c_parser/c_parser.hancho | 19 +++++------------ examples/json/json.hancho | 24 +++++----------------- examples/regex/regex.hancho | 22 +++++--------------- examples/toml/toml.hancho | 14 +++---------- examples/tutorial/tutorial.hancho | 26 +++++++++++------------ hancho.py | 1 - tests/tests.hancho | 10 ++------- 9 files changed, 55 insertions(+), 119 deletions(-) delete mode 120000 hancho.py diff --git a/build.hancho b/build.hancho index 9755c76..459e66a 100644 --- a/build.hancho +++ b/build.hancho @@ -2,22 +2,20 @@ import hancho -exports.config = hancho.Config( - build_tag = "debug", - includes = [".", "{repo_path}"], -) +hancho.Config.build_tag = "debug" + +rules = hancho.load("symlinks/hancho/rules.hancho", exports) +rules.compile_cpp.includes = [".", "{repo_path}"] -exports.rules = hancho.load("symlinks/hancho/rules.hancho", exports) -exports.c_lexer = hancho.load("examples/c_lexer/c_lexer.hancho", exports) -exports.c_parser = hancho.load("examples/c_parser/c_parser.hancho", exports) -exports.json = hancho.load("examples/json/json.hancho", exports) -exports.regex = hancho.load("examples/regex/regex.hancho", exports) -exports.toml = hancho.load("examples/toml/toml.hancho", exports) -#exports.tests = hancho.load("tests/tests.hancho", exports) -#exports.tutorial = hancho.load("examples/tutorial/tutorial.hancho", exports) -# -#exports.ini = exports.rules.c_library( -# exports.config, -# in_srcs = "examples/ini/ini_parser.cpp", -# out_lib = "examples/ini/ini_parser.a", -#) +c_lexer = hancho.load("examples/c_lexer/c_lexer.hancho", rules = rules) +c_parser = hancho.load("examples/c_parser/c_parser.hancho", rules = rules, c_lexer = c_lexer) +json = hancho.load("examples/json/json.hancho", rules = rules) +regex = hancho.load("examples/regex/regex.hancho", rules = rules) +toml = hancho.load("examples/toml/toml.hancho", rules = rules) +tests = hancho.load("tests/tests.hancho", rules = rules) +tutorial = hancho.load("examples/tutorial/tutorial.hancho", rules = rules, c_lexer = c_lexer, c_parser = c_parser) + +ini = rules.cpp_lib( + name = "ini_parser", + in_srcs = "examples/ini/ini_parser.cpp", +) diff --git a/examples/c_lexer/c_lexer.hancho b/examples/c_lexer/c_lexer.hancho index e806914..91f9904 100644 --- a/examples/c_lexer/c_lexer.hancho +++ b/examples/c_lexer/c_lexer.hancho @@ -1,33 +1,21 @@ #------------------------------------------------------------------------------- # Matcheroni C lexer demo -rules = imports.rules -config = imports.config - -c_lexer_lib = rules.cpp_lib( +c_lexer = imports.rules.cpp_lib( name = "c_lexer", in_srcs = ["CLexer.cpp", "CToken.cpp"], - out_lib = "c_lexer.a", - **config, ) -rules.c_test( +imports.rules.c_test( name = "c_lexer_test", in_srcs = "c_lexer_test.cpp", - in_libs = c_lexer_lib, - out_bin = "{name}", - quiet = True, - **config, - #debug = True, - #trace = True + in_libs = c_lexer, ) -rules.cpp_bin( +imports.rules.cpp_bin( name = "c_lexer_benchmark", in_srcs = "c_lexer_benchmark.cpp", - in_libs = c_lexer_lib, - out_bin = "c_lexer_benchmark", - **config, + in_libs = c_lexer, ) -exports.lib = c_lexer_lib +exports.lib = c_lexer diff --git a/examples/c_parser/c_parser.hancho b/examples/c_parser/c_parser.hancho index 21f458c..d192260 100644 --- a/examples/c_parser/c_parser.hancho +++ b/examples/c_parser/c_parser.hancho @@ -1,23 +1,15 @@ #------------------------------------------------------------------------------- # C parser example (not finished) -rules = imports.rules -config = imports.config -c_lexer = imports.c_lexer - -c_parser_lib = rules.cpp_lib( - name = "c_parser_lib", +c_parser = imports.rules.cpp_lib( + name = "c_parser", in_srcs = ["CContext.cpp", "CNode.cpp", "CScope.cpp"], - out_lib = "c_parser.a", - **config, ) -rules.cpp_bin( +imports.rules.cpp_bin( name = "c_parser_benchmark", in_srcs = "c_parser_benchmark.cpp", - in_libs = [c_lexer.lib, c_parser_lib], - out_bin = "c_parser_benchmark", - **config, + in_libs = [imports.c_lexer.lib, c_parser], ) # Broken? @@ -25,7 +17,6 @@ rules.cpp_bin( # "c_parser_test.cpp", # "c_parser_test", # libs = [c_lexer.c_lexer_lib, c_parser_lib], -# quiet = True #) -exports.lib = c_parser_lib +exports.lib = c_parser diff --git a/examples/json/json.hancho b/examples/json/json.hancho index 3c78a66..f954ff1 100644 --- a/examples/json/json.hancho +++ b/examples/json/json.hancho @@ -1,47 +1,33 @@ #------------------------------------------------------------------------------- # Matcheroni JSON parser example -rules = imports.rules -config = imports.config - -json_parser = rules.cpp_lib( +json_parser = imports.rules.cpp_lib( name = "json_parser", in_srcs = ["json_matcher.cpp", "json_parser.cpp"], - out_lib = "json_parser.a", - **config, ) -rules.cpp_bin( +imports.rules.cpp_bin( name = "json_conformance", in_srcs = "json_conformance.cpp", in_libs = json_parser, - out_bin = "json_conformance", - **config, ) -rules.cpp_bin( +imports.rules.cpp_bin( name = "json_benchmark", in_srcs = "json_benchmark.cpp", in_libs = json_parser, - out_bin = "json_benchmark", - **config, ) -rules.cpp_bin( +imports.rules.cpp_bin( name = "json_demo", in_srcs = "json_demo.cpp", in_libs = json_parser, - out_bin = "json_demo", - **config, ) -rules.c_test( +imports.rules.c_test( name = "json_test", in_srcs = "json_test.cpp", in_libs = json_parser, - out_bin = "json_test", - **config, - quiet = True ) exports.lib = json_parser diff --git a/examples/regex/regex.hancho b/examples/regex/regex.hancho index 4b86f81..85ceb66 100644 --- a/examples/regex/regex.hancho +++ b/examples/regex/regex.hancho @@ -11,40 +11,28 @@ #benchmark_defs = ${benchmark_defs} -DSRELL_NO_NAMEDCAPTURE #benchmark_defs = ${benchmark_defs} -DSRELL_NO_VMODE -rules = imports.rules -config = imports.config - -regex_parser = rules.cpp_lib( - name = "regex_parser_lib", +regex_parser = imports.rules.cpp_lib( + name = "regex_parser", in_srcs = "regex_parser.cpp", - out_lib = "regex_parser.a", - **config, ) -rules.cpp_bin( +imports.rules.cpp_bin( name = "regex_demo", in_srcs = "regex_demo.cpp", in_libs = regex_parser, - out_bin = "regex_demo", - **config, ) -rules.cpp_bin( +imports.rules.cpp_bin( name = "regex_benchmark", in_srcs = "regex_benchmark.cpp", - out_bin = "regex_benchmark", in_libs = regex_parser, sys_libs = ["boost_system", "boost_regex"], - **config, ) -rules.c_test( +imports.rules.c_test( name = "regex_test", in_srcs = "regex_test.cpp", - out_bin = "regex_test", libs = regex_parser, - quiet = True, - **config, ) exports.lib = regex_parser diff --git a/examples/toml/toml.hancho b/examples/toml/toml.hancho index 5823252..e122558 100644 --- a/examples/toml/toml.hancho +++ b/examples/toml/toml.hancho @@ -1,21 +1,13 @@ #------------------------------------------------------------------------------- # TOML parser example -rules = imports.rules -config = imports.config - -toml_lib = rules.cpp_lib( +toml_parser = imports.rules.cpp_lib( name = "toml_parser", in_srcs = "toml_parser.cpp", - out_lib = "toml_lib.a", - **config, ) -rules.c_test( +imports.rules.c_test( name = "toml_test", in_srcs = "toml_test.cpp", - in_libs = toml_lib, - out_bin = "toml_test", - quiet = True, - **config, + in_libs = toml_parser, ) diff --git a/examples/tutorial/tutorial.hancho b/examples/tutorial/tutorial.hancho index ca4a3e3..1b05cbc 100644 --- a/examples/tutorial/tutorial.hancho +++ b/examples/tutorial/tutorial.hancho @@ -1,22 +1,22 @@ #------------------------------------------------------------------------------- # Tutorial examples -rules = imports.rules -config = imports.config +import hancho -config.command_path = "{repo_path}" -config.quiet = True +config = hancho.Config( + command_path = "{repo_path}", +) -rules.c_test(config, in_srcs = "json_tut0a.cpp", out_bin = "json_tut0a") -rules.c_test(config, in_srcs = "json_tut1a.cpp", out_bin = "json_tut1a") -rules.c_test(config, in_srcs = "json_tut1b.cpp", out_bin = "json_tut1b") -rules.c_test(config, in_srcs = "json_tut1c.cpp", out_bin = "json_tut1c") -rules.c_test(config, in_srcs = "json_tut2a.cpp", out_bin = "json_tut2a") -rules.c_test(config, in_srcs = "json_tut2b.cpp", out_bin = "json_tut2b") +imports.rules.c_test(config, name = "json_tut0a", in_srcs = "json_tut0a.cpp") +imports.rules.c_test(config, name = "json_tut1a", in_srcs = "json_tut1a.cpp") +imports.rules.c_test(config, name = "json_tut1b", in_srcs = "json_tut1b.cpp") +imports.rules.c_test(config, name = "json_tut1c", in_srcs = "json_tut1c.cpp") +imports.rules.c_test(config, name = "json_tut2a", in_srcs = "json_tut2a.cpp") +imports.rules.c_test(config, name = "json_tut2b", in_srcs = "json_tut2b.cpp") -rules.c_binary( +imports.rules.cpp_bin( config, + name = "tiny_c_parser", in_srcs = "tiny_c_parser.cpp", - out_bin = "tiny_c_parser", - libs = [imports.c_lexer.lib, imports.c_parser.lib], + in_libs = [imports.c_lexer.lib, imports.c_parser.lib], ) diff --git a/hancho.py b/hancho.py deleted file mode 120000 index cb414d9..0000000 --- a/hancho.py +++ /dev/null @@ -1 +0,0 @@ -symlinks/hancho/hancho.py \ No newline at end of file diff --git a/tests/tests.hancho b/tests/tests.hancho index ee8273c..8ab4889 100644 --- a/tests/tests.hancho +++ b/tests/tests.hancho @@ -1,22 +1,16 @@ #------------------------------------------------------------------------------- # Tests -import hancho - #build obj/matcheroni/Matcheroni.hpp.iwyu : iwyu matcheroni/Matcheroni.hpp #build obj/matcheroni/Parseroni.hpp.iwyu : iwyu matcheroni/Parseroni.hpp #build obj/matcheroni/Utilities.hpp.iwyu : iwyu matcheroni/Utilities.hpp imports.rules.c_test( - imports.config, + name = "matcheroni_test", in_srcs = "matcheroni_test.cpp", - out_bin = "matcheroni_test", - quiet = True, ) imports.rules.c_test( - imports.config, + name = "parseroni_test", in_srcs = "parseroni_test.cpp", - out_bin = "parseroni_test", - quiet = True, )