From e80b8a98802a8c206b745394da6bc71be8a65f62 Mon Sep 17 00:00:00 2001 From: Austin Appleby Date: Sun, 6 Oct 2024 18:46:22 -0700 Subject: [PATCH] ok that's better --- README.md | 27 ++++++++++++++------------- examples/hello_world/build.hancho | 10 ++++++---- examples/hello_world/main.cpp | 1 + 3 files changed, 21 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 5160d3c..e56edaf 100644 --- a/README.md +++ b/README.md @@ -54,21 +54,22 @@ options: ## Simple Example -examples/hello_world/build.hancho ```python +# examples/hello_world/build.hancho + import hancho compile_cpp = hancho.Command( - desc = "Compiling C++ {rel(in_src)} -> {rel(out_obj)}", - command = "g++ -c {rel(in_src)} -o {rel(out_obj)}", + desc = "Compiling C++ {in_src} -> {out_obj}", + command = "g++ -c {in_src} -o {out_obj}", in_src = None, out_obj = "{swap_ext(in_src, '.o')}", depfile = "{swap_ext(in_src, '.d')}", ) link_cpp_bin = hancho.Command( - desc = "Linking C++ bin {rel(out_bin)}", - command = "g++ {rel(in_objs)} -o {rel(out_bin)}", + desc = "Linking C++ bin {out_bin}", + command = "g++ {in_objs} -o {out_bin}", in_objs = None, out_bin = None, ) @@ -82,9 +83,9 @@ main_app = link_cpp_bin( ) ``` -examples/hello_world/main.cpp ```cpp // examples/hello_world/main.cpp + #include int blah(); @@ -99,17 +100,17 @@ int main(int argc, char** argv) { user@host:~/hancho/examples/hello_world$ ../../hancho.py --verbose Loading module /home/user/hancho/examples/hello_world/build.hancho Loading .hancho files took 0.000 seconds -[1/3] Compiling C++ main.cpp -> build/hello_world/main.o +[1/3] Compiling C++ /home/user/hancho/examples/hello_world/main.cpp -> /home/user/hancho/examples/hello_world/build/hello_world/main.o Reason: Rebuilding because /home/user/hancho/examples/hello_world/build/hello_world/main.o is missing -.$ g++ -c main.cpp -o build/hello_world/main.o -[2/3] Compiling C++ util.cpp -> build/hello_world/util.o +.$ g++ -c /home/user/hancho/examples/hello_world/main.cpp -o /home/user/hancho/examples/hello_world/build/hello_world/main.o +[2/3] Compiling C++ /home/user/hancho/examples/hello_world/util.cpp -> /home/user/hancho/examples/hello_world/build/hello_world/util.o Reason: Rebuilding because /home/user/hancho/examples/hello_world/build/hello_world/util.o is missing -.$ g++ -c util.cpp -o build/hello_world/util.o -[3/3] Linking C++ bin build/hello_world/hello_world +.$ g++ -c /home/user/hancho/examples/hello_world/util.cpp -o /home/user/hancho/examples/hello_world/build/hello_world/util.o +[3/3] Linking C++ bin /home/user/hancho/examples/hello_world/build/hello_world/hello_world Reason: Rebuilding because /home/user/hancho/examples/hello_world/build/hello_world/hello_world is missing -.$ g++ build/hello_world/main.o build/hello_world/util.o -o build/hello_world/hello_world +.$ g++ /home/user/hancho/examples/hello_world/build/hello_world/main.o /home/user/hancho/examples/hello_world/build/hello_world/util.o -o /home/user/hancho/examples/hello_world/build/hello_world/hello_world -Running 3 tasks took 0.044 seconds +Running 3 tasks took 0.042 seconds tasks total: 3 tasks passed: 3 tasks failed: 0 diff --git a/examples/hello_world/build.hancho b/examples/hello_world/build.hancho index 704a63d..099dbcb 100644 --- a/examples/hello_world/build.hancho +++ b/examples/hello_world/build.hancho @@ -1,16 +1,18 @@ +# examples/hello_world/build.hancho + import hancho compile_cpp = hancho.Command( - desc = "Compiling C++ {rel(in_src)} -> {rel(out_obj)}", - command = "g++ -c {rel(in_src)} -o {rel(out_obj)}", + desc = "Compiling C++ {in_src} -> {out_obj}", + command = "g++ -c {in_src} -o {out_obj}", in_src = None, out_obj = "{swap_ext(in_src, '.o')}", depfile = "{swap_ext(in_src, '.d')}", ) link_cpp_bin = hancho.Command( - desc = "Linking C++ bin {rel(out_bin)}", - command = "g++ {rel(in_objs)} -o {rel(out_bin)}", + desc = "Linking C++ bin {out_bin}", + command = "g++ {in_objs} -o {out_bin}", in_objs = None, out_bin = None, ) diff --git a/examples/hello_world/main.cpp b/examples/hello_world/main.cpp index 47cf3ba..34eb5ba 100644 --- a/examples/hello_world/main.cpp +++ b/examples/hello_world/main.cpp @@ -1,4 +1,5 @@ // examples/hello_world/main.cpp + #include int blah();