Skip to content

Commit

Permalink
fix hancho build
Browse files Browse the repository at this point in the history
  • Loading branch information
aappleby committed Mar 3, 2024
1 parent 5d2e052 commit d5f4f72
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 26 deletions.
18 changes: 9 additions & 9 deletions build.hancho
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@

print("Building Matcheroni with Hancho")

hancho.config.set(
config.set(
build_type = "debug",
build_dir = "build/{build_type}",
toolchain = "x86_64-linux-gnu",
)

hancho.load("examples/c_lexer/c_lexer.hancho")
hancho.load("examples/c_parser/c_parser.hancho")
hancho.load("examples/ini/ini.hancho")
hancho.load("examples/json/json.hancho")
hancho.load("examples/regex/regex.hancho")
hancho.load("examples/toml/toml.hancho")
hancho.load("examples/tutorial/tutorial.hancho")
hancho.load("tests/tests.hancho")
load("examples/c_lexer/c_lexer.hancho")
load("examples/c_parser/c_parser.hancho")
load("examples/ini/ini.hancho")
load("examples/json/json.hancho")
load("examples/regex/regex.hancho")
load("examples/toml/toml.hancho")
load("examples/tutorial/tutorial.hancho")
load("tests/tests.hancho")
10 changes: 5 additions & 5 deletions config/rules.hancho
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#-------------------------------------------------------------------------------

compile_cpp = hancho.Rule(
compile_cpp = Rule(
desc = "Compiling {files_in} -> {files_out} ({build_type})",
command = "{toolchain}-g++ {cpp_std} {gcc_opt} {warnings} {includes} {defines} -c {files_in} -o {files_out}",
cpp_std = "-std=c++20",
Expand All @@ -13,19 +13,19 @@ compile_cpp = hancho.Rule(
depfile = "{swap_ext(files_out, '.d')}",
)

link_c_lib = hancho.Rule(
link_c_lib = Rule(
desc = "Bundling {files_out}",
command = "ar rcs {files_out} {files_in}",
)

link_c_bin = hancho.Rule(
link_c_bin = Rule(
desc = "Linking {files_out}",
command = "{toolchain}-g++ {ld_opt} {warnings} {files_in} {deps} {sys_libs} -o {files_out}",
ld_opt = "{'-O3' if build_type == 'release' else '-g -O0'}",
warnings = "-Wall",
)

test_rule = hancho.Rule(
test_rule = Rule(
desc = "Running test {files_in}",
command = "rm -f {files_out} && {files_in} {args} && touch {files_out}",
files_out = "{files_in}_pass",
Expand All @@ -34,7 +34,7 @@ test_rule = hancho.Rule(
#-------------------------------------------------------------------------------

def compile_srcs(files_in, **kwargs):
return [compile_cpp(f, **kwargs) for f in hancho.flatten(files_in)]
return [compile_cpp(f, **kwargs) for f in flatten(files_in)]

def c_binary(files_in, files_out, **kwargs):
return link_c_bin(compile_srcs(files_in, **kwargs), files_out, **kwargs)
Expand Down
2 changes: 1 addition & 1 deletion examples/c_lexer/c_lexer.hancho
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#-------------------------------------------------------------------------------
# Matcheroni C lexer demo

rules = hancho.load("config/rules.hancho")
rules = load("config/rules.hancho")

c_lexer_lib = rules.c_library(
["CLexer.cpp", "CToken.cpp"],
Expand Down
4 changes: 2 additions & 2 deletions examples/c_parser/c_parser.hancho
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#-------------------------------------------------------------------------------
# C parser example (not finished)

rules = hancho.load("config/rules.hancho")
c_lexer = hancho.load("../c_lexer/c_lexer.hancho")
rules = load("config/rules.hancho")
c_lexer = load("../c_lexer/c_lexer.hancho")

c_parser_lib = rules.c_library(
["CContext.cpp", "CNode.cpp", "CScope.cpp"],
Expand Down
2 changes: 1 addition & 1 deletion examples/ini/ini.hancho
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#-------------------------------------------------------------------------------
# INI parser example

rules = hancho.load("config/rules.hancho")
rules = load("config/rules.hancho")

ini_parser_lib = rules.c_library("ini_parser.cpp", "ini_parser.a")
2 changes: 1 addition & 1 deletion examples/json/json.hancho
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#-------------------------------------------------------------------------------
# Matcheroni JSON parser example

rules = hancho.load("config/rules.hancho")
rules = load("config/rules.hancho")

json_parser = rules.c_library(
["json_matcher.cpp", "json_parser.cpp"],
Expand Down
2 changes: 1 addition & 1 deletion examples/regex/regex.hancho
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#-------------------------------------------------------------------------------
# Matcheroni regex parsing example

rules = hancho.load("config/rules.hancho")
rules = load("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/.
Expand Down
2 changes: 1 addition & 1 deletion examples/toml/toml.hancho
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#-------------------------------------------------------------------------------
# TOML parser example

rules = hancho.load("config/rules.hancho")
rules = load("config/rules.hancho")

toml_lib = rules.c_library(
"toml_parser.cpp",
Expand Down
7 changes: 3 additions & 4 deletions examples/tutorial/tutorial.hancho
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
#-------------------------------------------------------------------------------
# Tutorial examples

rules = hancho.load("config/rules.hancho")

c_lexer = hancho.load("examples/c_lexer/c_lexer.hancho")
c_parser = hancho.load("examples/c_parser/c_parser.hancho")
rules = load("config/rules.hancho")
c_lexer = load("examples/c_lexer/c_lexer.hancho")
c_parser = load("examples/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)
Expand Down
2 changes: 1 addition & 1 deletion tests/tests.hancho
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#-------------------------------------------------------------------------------
# Tests

rules = hancho.load("config/rules.hancho")
rules = load("config/rules.hancho")

#build obj/matcheroni/Matcheroni.hpp.iwyu : iwyu matcheroni/Matcheroni.hpp
#build obj/matcheroni/Parseroni.hpp.iwyu : iwyu matcheroni/Parseroni.hpp
Expand Down

0 comments on commit d5f4f72

Please sign in to comment.