Skip to content

Commit

Permalink
ok that's better
Browse files Browse the repository at this point in the history
  • Loading branch information
aappleby committed Oct 7, 2024
1 parent d5f099c commit e80b8a9
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 17 deletions.
27 changes: 14 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand All @@ -82,9 +83,9 @@ main_app = link_cpp_bin(
)
```

examples/hello_world/main.cpp
```cpp
// examples/hello_world/main.cpp

#include <stdio.h>

int blah();
Expand All @@ -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
Expand Down
10 changes: 6 additions & 4 deletions examples/hello_world/build.hancho
Original file line number Diff line number Diff line change
@@ -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,
)
Expand Down
1 change: 1 addition & 0 deletions examples/hello_world/main.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// examples/hello_world/main.cpp

#include <stdio.h>

int blah();
Expand Down

0 comments on commit e80b8a9

Please sign in to comment.