-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathjustfile
More file actions
121 lines (93 loc) · 2.95 KB
/
justfile
File metadata and controls
121 lines (93 loc) · 2.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
clang_bin := if os() == "macos" {
if path_exists("/opt/homebrew/opt/llvm/bin") == "true" {
"/opt/homebrew/opt/llvm/bin/"
} else {
error("Could not find path to LLVM Clang. Please specify when running `just`: eg, `just clang_bin=/opt/homebrew/opt/llvm/bin <target>`")
}
} else {
""
}
ld_preload := if os() == "macos" {
"DYLD_INSERT_LIBRARIES"
} else {
"LD_PRELOAD"
}
dsymutil_tgt := if os() == "macos" {
"_dsymutil"
} else {
"_noop"
}
lib_ext := if os() == "macos" { "dylib" } else { "so" }
clang_exe := join(clang_bin, 'clang')
clang_tidy := join(clang_bin, 'clang-tidy')
clang_cc := clang_exe
clang_cxx := clang_exe + '++'
install_dir := absolute_path("./install")
cwd := justfile_directory()
_noop *args:
_dsymutil *args:
dsymutil {{args}}
clang_path:
@echo "clang_cc={{clang_cc}}"
@echo "clang_cxx={{clang_cxx}}"
config-debug:
cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Debug
build-debug: config-debug
cmake --build build
config:
cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Release
build: config
cmake --build build
install: build
cmake --install build --prefix {{install_dir}}
run exe *args: config
cmake --build build --target {{exe}}
build/{{exe}} {{args}}
build_test_file test_file: build
mkdir -p build/test_files
{{clang_cxx}} \
-L build -rpath build -l mp_unwind_shared \
-Imp/types/include \
-Imp/unwind/include \
-Imp/core/include \
-Imp/hook_prelude/include \
--include={{cwd}}/mp/hook_prelude/include/mp_hook_prelude.h \
-fplugin=build/libmp_plugin.{{lib_ext}} \
-Xclang=-add-plugin \
-Xclang=mp_instrument_dtors \
-Og -g \
-o build/test_files/{{trim_end_match(test_file, ".cpp")}} \
etc/test_cpp_files/{{test_file}}
ast_dump *args:
{{clang_cxx}} -Xclang=-ast-dump -c {{args}}
clang-tidy *args:
{{clang_tidy}} {{args}}
build_example: install
cmake -S examples \
-G Ninja \
-B examples/build \
-DCMAKE_PREFIX_PATH={{install_dir}} \
-DCMAKE_CXX_COMPILER={{clang_cxx}} \
-DCMAKE_C_COMPILER={{clang_cc}} \
-DCMAKE_BUILD_TYPE=Release
cmake --build examples/build
@just {{dsymutil_tgt}} build/libmp_runtime.{{lib_ext}}
build_ex_target example_name: install
cmake -S examples \
-B examples/build \
-DCMAKE_PREFIX_PATH={{install_dir}} \
-DCMAKE_CXX_COMPILER={{clang_cxx}} \
-DCMAKE_C_COMPILER={{clang_cc}} \
-DCMAKE_BUILD_TYPE=Debug
cmake --build examples/build --target=clean
cmake --build examples/build --target={{example_name}}
@just {{dsymutil_tgt}} build/libmp_runtime.{{lib_ext}}
mp_run *args:
env {{ld_preload}}=build/libmp_runtime.{{lib_ext}} {{args}}
gen_test_files: build_example
mkdir -p etc/test_files/{{os()}}
bash etc/gen_test_files.sh
run_example example: build_example
examples/build/{{example}}
clean:
rm -rf build install examples/build