1
- # ![ Logo] ( https://github.com/aappleby/hancho/blob/main/docs/ hancho_small.png?raw=true ) Hancho
1
+ # ![ Logo] ( assets/ hancho_small.png) Hancho
2
2
3
3
"班長, hanchō - "Squad leader”, from 19th c. Mandarin 班長 (bānzhǎng, “team leader”)"
4
4
@@ -10,19 +10,16 @@ Hancho is inspired by Ninja (for speed and simplicity) and Bazel (for syntax and
10
10
11
11
Like Ninja, it knows nothing about your build tools and is only trying to assemble and run commands as fast as possible.
12
12
13
- Unlike Ninja, you can use glob(" * .cpp") and such to make things far less verbose.
13
+ Unlike Ninja, Hancho's build scripts are vastly less verbose.
14
14
15
- Like Bazel, you invoke build rules by calling them as if they were functions with keyword arguments .
15
+ Like Bazel, the build synax is simple and Pythonesque .
16
16
17
- Unlike Bazel, you can create build rules that call arbitary Python code (for better or worse).
17
+ Unlike Bazel, your build can call arbitrary Python code (for better or worse).
18
18
19
19
Hancho should suffice for small to medium sized projects.
20
20
21
- [ Tutorial Here] ( tutorial )
22
-
23
- [ Some Additional Documentation Here] ( docs )
24
-
25
21
## Updates
22
+ - 2024-11-02 - We're now on version v040 and the API has (hopefully) stabilized. Working on docs and tutorials now.
26
23
- 2024-10-06 - The main branch has been updated to v020, which is what I've been using for personal projects all year. It changes a _ lot_ of stuff compared to v010 and previous, and the documentation and tutorials are currently outdated.
27
24
28
25
## Installation
@@ -31,24 +28,28 @@ Hancho should suffice for small to medium sized projects.
31
28
user@host:~ $ wget https://raw.githubusercontent.com/aappleby/hancho/main/hancho.py
32
29
user@host:~ $ chmod +x hancho.py
33
30
user@host:~ $ ./hancho.py --help
34
- usage: hancho.py [-h] [-f ROOT_NAME] [-C ROOT_PATH] [-j JOBS] [-v] [-q] [-n] [-d] [--force] [-s] [-t] [target]
31
+ usage: hancho.py [-h] [-f ROOT_FILE] [-C ROOT_DIR] [-v] [-d] [--force] [--trace] [-j JOBS] [-q] [-n] [-s]
32
+ [--use_color]
33
+ [target]
35
34
36
35
positional arguments:
37
36
target A regex that selects the targets to build. Defaults to all targets.
38
37
39
38
options:
40
39
-h, --help show this help message and exit
41
- -f FILE, --file FILE The name of the .hancho file(s) to build
42
- -C ROOT_PATH, --chdir ROOT_PATH
40
+ -f ROOT_FILE, --root_file ROOT_FILE
41
+ The name of the .hancho file(s) to build
42
+ -C ROOT_DIR, --root_dir ROOT_DIR
43
43
Change directory before starting the build
44
- -j JOBS, --jobs JOBS Run N jobs in parallel (default = cpu_count)
45
44
-v, --verbose Print verbose build info
46
- -q, --quiet Mute all output
47
- -n, --dry_run Do not run commands
48
45
-d, --debug Print debugging information
49
46
--force Force rebuild of everything
47
+ --trace Trace all text expansion
48
+ -j JOBS, --jobs JOBS Run N jobs in parallel (default = cpu_count)
49
+ -q, --quiet Mute all output
50
+ -n, --dry_run Do not run commands
50
51
-s, --shuffle Shuffle task order to shake out dependency issues
51
- -t, --trace Trace all text expansion
52
+ --use_color Use color in the console output
52
53
```
53
54
54
55
## Simple Example
@@ -57,62 +58,51 @@ options:
57
58
# examples/hello_world/build.hancho
58
59
59
60
compile_cpp = hancho.Config(
60
- desc = " Compiling C++ {in_src} -> {out_obj} " ,
61
- command = " g++ -c {in_src} -o {out_obj} " ,
62
- in_src = None ,
63
- out_obj = " {swap_ext(in_src, '.o')}" ,
64
- in_depfile = " {swap_ext(in_src, '.d')}" ,
61
+ desc = " Compiling C++ {in_src} -> {out_obj} " ,
62
+ command = " g++ -c {in_src} -o {out_obj} " ,
63
+ out_obj = " {swap_ext(in_src, '.o')}" ,
64
+ in_depfile = " {swap_ext(in_src, '.d')}" ,
65
65
)
66
66
67
+ main_o = hancho(compile_cpp, in_src = " main.cpp" )
68
+ util_o = hancho(compile_cpp, in_src = " util.cpp" )
69
+
67
70
link_cpp_bin = hancho.Config(
68
- desc = " Linking C++ bin {out_bin} " ,
69
- command = " g++ {in_objs} -o {out_bin} " ,
70
- in_objs = None ,
71
- out_bin = None ,
71
+ desc = " Linking C++ bin {out_bin} " ,
72
+ command = " g++ {in_objs} -o {out_bin} " ,
72
73
)
73
74
74
- main_o = compile_cpp(in_src = " main.cpp" )
75
- util_o = compile_cpp(in_src = " util.cpp" )
76
-
77
- main_app = link_cpp_bin(
78
- in_objs = [main_o, util_o],
79
- out_bin = " hello_world" ,
75
+ main_app = hancho(
76
+ link_cpp_bin,
77
+ in_objs = [main_o, util_o],
78
+ out_bin = " hello_world" ,
80
79
)
81
80
```
82
81
83
- ``` cpp
84
- // examples/hello_world/main.cpp
85
-
86
- #include < stdio.h>
87
-
88
- int blah ();
89
-
90
- int main (int argc, char** argv) {
91
- printf("Hello World %d\n", blah());
92
- return 0;
93
- }
94
- ```
95
-
96
82
``` sh
97
83
user@host:~ /hancho/examples/hello_world$ ../../hancho.py --verbose
98
- Loading module /home/user/hancho/examples/hello_world/build.hancho
84
+ Loading /home/user/hancho/examples/hello_world/build.hancho
99
85
Loading .hancho files took 0.000 seconds
100
- [1/3] Compiling C++ /home/user/hancho/examples/hello_world/main.cpp -> /home/user/hancho/examples/hello_world/build/hello_world/main.o
101
- Reason: Rebuilding because /home/user/hancho/examples/hello_world/build/hello_world/main.o is missing
102
- .$ g++ -c /home/user/hancho/examples/hello_world/main.cpp -o /home/user/hancho/examples/hello_world/build/hello_world/main.o
103
- [2/3] Compiling C++ /home/user/hancho/examples/hello_world/util.cpp -> /home/user/hancho/examples/hello_world/build/hello_world/util.o
104
- Reason: Rebuilding because /home/user/hancho/examples/hello_world/build/hello_world/util.o is missing
105
- .$ g++ -c /home/user/hancho/examples/hello_world/util.cpp -o /home/user/hancho/examples/hello_world/build/hello_world/util.o
106
- [3/3] Linking C++ bin /home/user/hancho/examples/hello_world/build/hello_world/hello_world
107
- Reason: Rebuilding because /home/user/hancho/examples/hello_world/build/hello_world/hello_world is missing
108
- .$ 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
109
-
110
- Running 3 tasks took 0.042 seconds
111
- tasks total: 3
112
- tasks passed: 3
86
+ Queueing 3 tasks took 0.000 seconds
87
+ Reason: Rebuilding because /home/user/hancho/examples/hello_world/build/main.o is missing
88
+ [1/3] Compiling C++ /home/user/hancho/examples/hello_world/main.cpp -> /home/user/hancho/examples/hello_world/build/main.o
89
+ .$ g++ -c /home/user/hancho/examples/hello_world/main.cpp -o /home/user/hancho/examples/hello_world/build/main.o
90
+ Reason: Rebuilding because /home/user/hancho/examples/hello_world/build/util.o is missing
91
+ [2/3] Compiling C++ /home/user/hancho/examples/hello_world/util.cpp -> /home/user/hancho/examples/hello_world/build/util.o
92
+ .$ g++ -c /home/user/hancho/examples/hello_world/util.cpp -o /home/user/hancho/examples/hello_world/build/util.o
93
+ [2/3] Task passed - ' Compiling C++ /home/user/hancho/examples/hello_world/util.cpp -> /home/user/hancho/examples/hello_world/build/util.o'
94
+ [1/3] Task passed - ' Compiling C++ /home/user/hancho/examples/hello_world/main.cpp -> /home/user/hancho/examples/hello_world/build/main.o'
95
+ Reason: Rebuilding because /home/user/hancho/examples/hello_world/build/hello_world is missing
96
+ [3/3] Linking C++ bin /home/user/hancho/examples/hello_world/build/hello_world
97
+ .$ g++ /home/user/hancho/examples/hello_world/build/main.o /home/user/hancho/examples/hello_world/build/util.o -o /home/user/hancho/examples/hello_world/build/hello_world
98
+ [3/3] Task passed - ' Linking C++ bin /home/user/hancho/examples/hello_world/build/hello_world'
99
+ Running 3 tasks took 0.043 seconds
100
+ tasks started: 3
101
+ tasks finished: 3
113
102
tasks failed: 0
114
103
tasks skipped: 0
115
104
tasks cancelled: 0
105
+ tasks broken: 0
116
106
mtime calls: 0
117
107
hancho: BUILD PASSED
118
108
```
0 commit comments