From 86df5ac80958da43834ec07cfee5a310fca011c4 Mon Sep 17 00:00:00 2001 From: Austin Appleby Date: Wed, 29 May 2024 18:57:26 -0700 Subject: [PATCH] consolidating hancho rules --- config/rules.hancho | 74 --------------------------------------------- 1 file changed, 74 deletions(-) delete mode 100644 config/rules.hancho diff --git a/config/rules.hancho b/config/rules.hancho deleted file mode 100644 index b46a2fc..0000000 --- a/config/rules.hancho +++ /dev/null @@ -1,74 +0,0 @@ -# matcheroni/config/rules.hancho - -import hancho - -#------------------------------------------------------------------------------- - -def link_c_lib(in_objs, out_lib, *args, **kwargs): - config = hancho.Config(*args, **kwargs) - command = hancho.Config( - desc = "Bundling {rel(out_lib)}", - command = "ar rcs {rel(out_lib)} {rel(in_objs)}", - ) - return command(config, in_objs = in_objs, out_lib = out_lib) - - -def link_c_bin(in_objs, out_bin, *args, **kwargs): - config = hancho.Config(*args, **kwargs) - command = hancho.Config( - desc = "Linking {rel(out_bin)}", - command = "g++ {ld_opt} {warnings} {rel(in_objs)} {libs} {sys_libs} -o {rel(out_bin)}", - ld_opt = "{'-O3' if build_tag == 'release' else '-g -O0'}", - libs = "", - sys_libs = "", - warnings = "-Wall", - ) - return command(config, in_objs = in_objs, out_bin = out_bin) - -#------------------------------------------------------------------------------- - -def compile_srcs(*args, in_srcs, **kwargs): - config = hancho.Config(*args, **kwargs) - command = hancho.Config( - desc = "Compiling {rel(in_src)} -> {rel(out_obj)} ({build_tag})", - command = "g++ {cpp_std} {gcc_opt} {warnings} {includes} {defines} -c {rel(in_src)} -o {rel(out_obj)}", - cpp_std = "-std=c++20", - gcc_opt = "{'-O3' if build_tag == 'release' else '-g -O0'} -MMD", - warnings = "-Wall -Werror -Wno-unused-variable -Wno-unused-local-typedefs -Wno-unused-but-set-variable", - includes = "-I{repo_path}", - defines = "", - out_obj = "{swap_ext(in_src, '.o')}", - depfile = "{swap_ext(in_src, '.d')}", - ) - return [command(config, in_src = file) for file in hancho.flatten(in_srcs)] - -def c_binary(*args, in_srcs = [], in_objs = [], out_bin, **kwargs): - config = hancho.Config(*args, **kwargs) - objs = compile_srcs(config, in_srcs = in_srcs) - return link_c_bin(objs + in_objs, out_bin, config) - -def c_library(*args, in_srcs = [], in_objs = [], out_lib, **kwargs): - config = hancho.Config(*args, **kwargs) - objs = compile_srcs(config, in_srcs=in_srcs) - return link_c_lib(objs + in_objs, out_lib, config) - -def c_test(*args, in_srcs = [], in_objs = [], out_bin, **kwargs): - config = hancho.Config(*args, **kwargs) - objs = compile_srcs(config, in_srcs = in_srcs) - bin = link_c_bin(objs + in_objs, out_bin, config) - result = hancho.Task( - config, - desc = "Running test {rel(in_test)}", - command = "{in_test} {args}", - in_test = bin, - out_log = "{in_test}.test", - args = "", - is_test = True - ) - return result - -#------------------------------------------------------------------------------- - -exports.c_binary = c_binary -exports.c_library = c_library -exports.c_test = c_test