Skip to content

Commit 2453e7b

Browse files
committed
big mess, don't use this cl
1 parent 1c48cc3 commit 2453e7b

37 files changed

+1460
-1484
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ build
55
dist
66
__pycache__
77
scratch
8-
8+
htmlcov

.vscode/launch.json

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,6 @@
44
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
55
"version": "0.2.0",
66
"configurations": [
7-
{
8-
"name": "Scratch",
9-
"type": "debugpy",
10-
"request": "launch",
11-
"program": "${workspaceFolder}/hancho.py",
12-
"cwd": "${workspaceFolder}/scratch",
13-
//"args": ["--force", "-j1"],
14-
"console": "integratedTerminal",
15-
"justMyCode": false,
16-
"preLaunchTask": "Wipe build",
17-
},
187
{
198
"name": "Debug hancho.py",
209
"type": "debugpy",
@@ -43,7 +32,7 @@
4332
"request": "launch",
4433
"program": "run_tests.py",
4534
"cwd": "${workspaceFolder}/tests",
46-
//"args": ["TestHancho.test_raw_task"],
35+
"args": ["TestHancho.test_header_changed"],
4736
"console": "integratedTerminal",
4837
"justMyCode": false,
4938
},
@@ -60,14 +49,25 @@
6049
},
6150

6251
{
63-
"name": "Debug Scratch",
52+
"name": "Debug scratch/scratch.py",
6453
"type": "debugpy",
6554
"request": "launch",
66-
"program": "${workspaceFolder}/scratch.py",
67-
"cwd": "${workspaceFolder}/..",
55+
"program": "${workspaceFolder}/scratch/scratch.py",
56+
"cwd": "${workspaceFolder}/scratch",
6857
"console": "integratedTerminal",
6958
"justMyCode": false,
59+
"preLaunchTask": "Wipe build",
60+
},
61+
{
62+
"name": "Debug hancho.py in scratch/",
63+
"type": "debugpy",
64+
"request": "launch",
65+
"program": "${workspaceFolder}/hancho.py",
66+
"cwd": "${workspaceFolder}/scratch",
67+
//"args": ["--force", "-j1"],
68+
"console": "integratedTerminal",
69+
"justMyCode": false,
70+
"preLaunchTask": "Wipe build",
7071
},
71-
7272
]
7373
}

.vscode/tasks.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
{
1717
"label": "Wipe build",
1818
"type": "shell",
19-
"command": "rm -rf build tutorial/build",
19+
"command": "rm -rf build tutorial/build scratch/build",
2020
}
2121
]
2222
}

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,15 @@ compile_cpp = task(
4848
out_obj = "{ext(in_src, '.o')}",
4949
)
5050

51-
# To make Hancho do some work, we pass tasks, configs and key-value pairs to hancho().
51+
# To make Hancho do some work, we pass tasks, configs and key-value pairs to hancho.task().
5252
# It merges tasks and configs, expands templates, and queues an asynchronous task to run
5353
# the command.
5454

55-
# The hancho() function returns a Task object, which is like a promise that
55+
# The hancho.task() function returns a Task object, which is like a promise that
5656
# resolves to a list of output files when the task is complete.
5757

58-
main_o = hancho(compile_cpp, in_src = "main.cpp")
59-
util_o = hancho(compile_cpp, in_src = "util.cpp")
58+
main_o = hancho.task(compile_cpp, in_src = "main.cpp")
59+
util_o = hancho.task(compile_cpp, in_src = "util.cpp")
6060

6161
# This task defines how to link objects into a binary file. Instead of passing
6262
# filenames to 'in_objs', we can provide the task objects created above.
@@ -71,7 +71,7 @@ link_cpp_bin = task(
7171
# Hancho will automatically parallelize independent tasks. Here, main.cpp and
7272
# util.cpp will be compiled in parallel before the link task starts.
7373

74-
main_app = hancho(
74+
main_app = hancho.task(
7575
link_cpp_bin,
7676
in_objs = [main_o, util_o],
7777
out_bin = "hello_world",
@@ -81,7 +81,7 @@ main_app = hancho(
8181
# same directory.
8282
```
8383

84-
More documentation (still a work in progress) can be found at [docs/README.md](docs/README.md). The currently-broken step-by-step tutorial is in [tutorial](tutorial). Working examples are in [examples](examples). There are also sample build rules for [C++](base_rules.hancho), [WASM](wasm_rules.hancho), and [FPGA synthesis](fpga_rules.hancho).
84+
More documentation (still a work in progress) can be found at [docs/README.md](docs/README.md). The currently-broken step-by-step tutorial is in [tutorial](tutorial). Working examples are in [examples](examples). There are also sample build tools for [C++](base_tools.hancho), [WASM](wasm_tools.hancho), and [FPGA synthesis](fpga_tools.hancho).
8585

8686
## Updates
8787
- 2024-11-03 - I'm stripping out obsolete documentation and trimming the tutorials down to the essentials.
Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ import os
33
####################################################################################################
44
# C++
55

6-
default_toolchain = config(
6+
default_toolchain = hancho.config(
77
arch = "x86-64",
88
compiler = "x86_64-linux-gnu-g++",
99
linker = "x86_64-linux-gnu-g++",
1010
)
1111

1212
# ----------------------------------------
1313

14-
check_cpp = task(
14+
check_cpp = hancho.Tool(
1515
desc="Checking C++ syntax of {in_src}",
1616
command="{toolchain.compiler} {flags} {joined_warnings} {joined_defines} {joined_includes} -c {in_src} && touch {out_ok}",
1717

@@ -30,7 +30,7 @@ check_cpp = task(
3030

3131
# ----------------------------------------
3232

33-
compile_cpp = task(
33+
compile_cpp = hancho.Tool(
3434
desc="Compiling C++ {in_src} -> {out_obj} ({build_tag})",
3535
command="{toolchain.compiler} {flags} {joined_warnings} {joined_defines} {joined_includes} -c {in_src} -o {out_obj}",
3636
toolchain=default_toolchain,
@@ -54,20 +54,21 @@ compile_cpp = task(
5454
joined_warnings="{join('-W', warnings)}",
5555
joined_defines ="{join('-D', defines)}",
5656
joined_includes="{join('-I', includes)}",
57+
debug = True,
5758
)
5859

5960
if os.name == "nt":
6061
compile_cpp.command = "cl.exe /c {in_src} /sourceDependencies {depfile} /Fo:{out_obj}"
6162
compile_cpp.depformat = "msvc"
6263

6364

64-
link_cpp_lib = task(
65+
link_cpp_lib = hancho.Tool(
6566
desc="Bundling C++ lib {out_lib}",
6667
command="ar rcs {out_lib} {in_objs}",
6768
)
6869

6970

70-
link_cpp_bin = task(
71+
link_cpp_bin = hancho.Tool(
7172
desc = "Linking C++ bin {out_bin}",
7273
toolchain = default_toolchain,
7374
command = "{toolchain.linker} {flags} -Wl,--start-group {in_objs} {in_libs} {sys_libs} -Wl,--end-group -o {out_bin}",
@@ -79,19 +80,19 @@ link_cpp_bin = task(
7980

8081

8182
def cpp_lib(hancho, *, in_srcs=None, in_objs=None, in_libs=None, out_lib, **kwargs):
82-
in_objs = flatten(in_objs)
83-
for file in flatten(in_srcs):
84-
obj = hancho(compile_cpp, in_src=file, **kwargs)
83+
in_objs = hancho.flatten(in_objs)
84+
for file in hancho.flatten(in_srcs):
85+
obj = hancho.task(compile_cpp, in_src=file, **kwargs)
8586
in_objs.append(obj)
86-
return hancho(link_cpp_lib, in_objs=[in_objs, in_libs], out_lib=out_lib, **kwargs)
87+
return hancho.task(link_cpp_lib, in_objs=[in_objs, in_libs], out_lib=out_lib, **kwargs)
8788

8889

8990
def cpp_bin(hancho, *, in_srcs=None, in_objs=None, in_libs=None, out_bin, **kwargs):
90-
in_objs = flatten(in_objs)
91-
for file in flatten(in_srcs):
92-
obj = hancho(compile_cpp, in_src=file, **kwargs)
91+
in_objs = hancho.flatten(in_objs)
92+
for file in hancho.flatten(in_srcs):
93+
obj = hancho.task(compile_cpp, in_src=file, **kwargs)
9394
in_objs.append(obj)
94-
return hancho(
95+
return hancho.task(
9596
link_cpp_bin,
9697
in_objs=[in_objs, in_libs],
9798
out_bin=out_bin,
@@ -103,34 +104,34 @@ def cpp_bin(hancho, *, in_srcs=None, in_objs=None, in_libs=None, out_bin, **kwar
103104
# Makefiles
104105

105106
def make(hancho, *, in_makefile, **kwargs):
106-
cmd = task(
107+
cmd = hancho.Tool(
107108
desc="Run makefile {in_makefile}",
108109
command="make -C {make_dir} -f {make_file} {flags}", # > /dev/null
109110
make_dir="{path.dirname(in_makefile)}",
110111
make_file="{path.basename(in_makefile)}",
111112
flags="--quiet",
112113
)
113-
return hancho(cmd, in_makefile=in_makefile, **kwargs)
114+
return hancho.task(cmd, in_makefile=in_makefile, **kwargs)
114115

115116

116117
####################################################################################################
117118
# Tests
118119

119-
run_test = task(
120+
run_test = hancho.Tool(
120121
desc="Running test {in_test}",
121122
command="{in_test} {args} && touch {out_pass}",
122123
task_dir="{test_dir}",
123-
test_dir="{mod_dir}",
124+
test_dir="{source_dir}",
124125
args="",
125126
out_pass="{in_test}.pass",
126127
)
127128

128129
def cpp_test(hancho, *, in_srcs=None, in_objs=None, in_libs=None, out_bin, **kwargs):
129-
objs = [hancho(compile_cpp, in_src=src, **kwargs) for src in flatten(in_srcs)]
130-
test_bin = hancho(
130+
objs = [hancho.task(compile_cpp, in_src=src, **kwargs) for src in hancho.flatten(in_srcs)]
131+
test_bin = hancho.task(
131132
link_cpp_bin,
132133
in_objs=[objs, in_objs, in_libs],
133134
out_bin=out_bin,
134135
**kwargs
135136
)
136-
return hancho(run_test, in_test=test_bin, **kwargs)
137+
return hancho.task(run_test, in_test=test_bin, **kwargs)

build.hancho

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
base_rules = hancho.repo("{hancho_dir}/base_rules.hancho")
2-
fpga_rules = hancho.repo("{hancho_dir}/fpga_rules.hancho")
3-
riscv_rules = hancho.repo("{hancho_dir}/riscv_rules.hancho")
4-
wasm_rules = hancho.repo("{hancho_dir}/wasm_rules.hancho")
1+
#base_tools = hancho.repo("{hancho_dir}/base_tools.hancho")
2+
#fpga_tools = hancho.repo("{hancho_dir}/fpga_tools.hancho")
3+
#riscv_tools = hancho.repo("{hancho_dir}/riscv_tools.hancho")
4+
#wasm_tools = hancho.repo("{hancho_dir}/wasm_tools.hancho")

build.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/usr/bin/python3
2+
3+
print("---------- start ----------")
4+
import hancho
5+
6+
#print(hancho)
7+
#print(dir(hancho))
8+
9+
print("---------- done ----------")

0 commit comments

Comments
 (0)