Skip to content

Commit

Permalink
update hancho build
Browse files Browse the repository at this point in the history
  • Loading branch information
aappleby committed Apr 5, 2024
1 parent 31d1205 commit 290cc98
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 31 deletions.
18 changes: 8 additions & 10 deletions build.hancho
Original file line number Diff line number Diff line change
@@ -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")
3 changes: 1 addition & 2 deletions config/rules.hancho
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# matcheroni/config/rules.hancho
from hancho import *

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

Expand Down Expand Up @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions examples/c_lexer/c_lexer.hancho
Original file line number Diff line number Diff line change
@@ -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"],
Expand Down
5 changes: 2 additions & 3 deletions examples/c_parser/c_parser.hancho
Original file line number Diff line number Diff line change
@@ -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"],
Expand Down
3 changes: 1 addition & 2 deletions examples/ini/ini.hancho
Original file line number Diff line number Diff line change
@@ -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")
3 changes: 1 addition & 2 deletions examples/json/json.hancho
Original file line number Diff line number Diff line change
@@ -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"],
Expand Down
3 changes: 1 addition & 2 deletions examples/regex/regex.hancho
Original file line number Diff line number Diff line change
@@ -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/.
Expand Down
3 changes: 1 addition & 2 deletions examples/toml/toml.hancho
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
8 changes: 4 additions & 4 deletions examples/tutorial/tutorial.hancho
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
3 changes: 1 addition & 2 deletions tests/tests.hancho
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 290cc98

Please sign in to comment.