Skip to content

Commit

Permalink
trying to get everything working again at the same time
Browse files Browse the repository at this point in the history
  • Loading branch information
aappleby committed Aug 11, 2024
1 parent f39ada7 commit 855b427
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 119 deletions.
34 changes: 16 additions & 18 deletions build.hancho
Original file line number Diff line number Diff line change
Expand Up @@ -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",
)
24 changes: 6 additions & 18 deletions examples/c_lexer/c_lexer.hancho
Original file line number Diff line number Diff line change
@@ -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
19 changes: 5 additions & 14 deletions examples/c_parser/c_parser.hancho
Original file line number Diff line number Diff line change
@@ -1,31 +1,22 @@
#-------------------------------------------------------------------------------
# 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?
#rules.c_test(
# "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
24 changes: 5 additions & 19 deletions examples/json/json.hancho
Original file line number Diff line number Diff line change
@@ -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
22 changes: 5 additions & 17 deletions examples/regex/regex.hancho
Original file line number Diff line number Diff line change
Expand Up @@ -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
14 changes: 3 additions & 11 deletions examples/toml/toml.hancho
Original file line number Diff line number Diff line change
@@ -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,
)
26 changes: 13 additions & 13 deletions examples/tutorial/tutorial.hancho
Original file line number Diff line number Diff line change
@@ -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],
)
1 change: 0 additions & 1 deletion hancho.py

This file was deleted.

10 changes: 2 additions & 8 deletions tests/tests.hancho
Original file line number Diff line number Diff line change
@@ -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,
)

0 comments on commit 855b427

Please sign in to comment.