-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathjustfile
More file actions
152 lines (125 loc) · 4.9 KB
/
justfile
File metadata and controls
152 lines (125 loc) · 4.9 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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
# set to non-empty string to disable use of resvg for SVG support.
#
# e.g:
# just disableResvg=yes build
disableResvg := ''
# set to non-empty string to disable use of the resource bundle.
#
# e.g:
# just disableBundle=yes build
disableBundle := ''
# set to the C compiler used to build native libraries (e.g raylib CC, and lake LEAN_CC)
native_compiler := if os() == "macos" { "/usr/bin/clang" } else { "clang" }
lake_bundle_config_opt := if disableBundle == "" { "-K bundle=on" } else { "" }
lake_resvg_config_opt := if disableResvg == "" { "" } else { "-K resvg=disable" }
# Flags used to configure the lake build
lake_config_opts := lake_bundle_config_opt + " " + lake_resvg_config_opt
# Raylib CUSTOM_FLAGS tailed for the current os
#
# The macos differ from the raylib release workflow.
# We require `-fno-objc-msgsend-selector-stubs` to be set.
#
# If this is not set then the clang 15 linker bundled with lean gives the
# following error:
#
# ld64.lld: error: undefined symbol: _objc_msgSend$update
#
# See https://stackoverflow.com/a/74054943
#
raylib_os_custom_cflags := if os() == "macos" { "-target arm64-apple-macos11 -DGL_SILENCE_DEPRECATION -fno-objc-msgsend-selector-stubs" } else { "" }
# Enable extra raylib configuration flags
raylib_config_flags := ""
# Raylib CUSTOM_CFLAGS make parameter
raylib_custom_cflags := raylib_config_flags + " " + raylib_os_custom_cflags
# Raylib extra Makefile variables
#
# e.g add "USE_WAYLAND_DISPLAY=TRUE" to build Raylib with Wayland support.
raylib_extra_make_variables := ""
# The path to the GMP library root
#
# On macOS use `brew install gmp` to install it
gmp_prefix := if os() == "macos" { shell("brew --prefix gmp") } else { "" }
# The path to libuv root
#
# On macOS use `brew install libuv` to install it
libuv_prefix := if os() == "macos" { shell("brew --prefix libuv") } else { "" }
# The value of LIBRARY_PATH used when running `just build`. This is passed to
# the C compiler when lake builds native objects.
library_path := if gmp_prefix == "" { "" } else if libuv_prefix == "" { "" } else {gmp_prefix + "/lib:" + libuv_prefix + "/lib"}
static_lib_path := join(justfile_directory(), "lib")
raylib_src_path := join(justfile_directory(), "raylib-5.5", "src")
resource_dir := join(justfile_directory(), "resources")
bundle_h_path := join(justfile_directory(), "c", "include", "bundle.h")
makebundle_src_path := join(justfile_directory(), "scripts", "makeBundle.lean")
makebundle_output_path := join(justfile_directory(), "build", "makeBundle")
resvg_c_api_path := join(justfile_directory(), "resvg-0.43.0", "crates", "c-api")
[private]
default:
@just --list
check_cargo:
#!/usr/bin/env bash
set -euo pipefail
if [ -z "{{disableResvg}}" ]; then
if ! command -v cargo &> /dev/null
then
echo "cargo was not found. Please install rust: https://rustup.rs"
exit 1
fi
fi
# build only the resvg static library
build_resvg: check_cargo
#!/usr/bin/env bash
if [ -z "{{disableResvg}}" ]; then
set -euo pipefail
cd {{resvg_c_api_path}}
cargo build --release
mkdir -p {{static_lib_path}}
cp {{resvg_c_api_path}}/../../target/release/libresvg.a {{static_lib_path}}
fi
# build only the raylib static library
build_raylib:
#!/usr/bin/env bash
set -euo pipefail
if [ ! -f "{{static_lib_path}}/libraylib.a" ]; then
mkdir -p {{static_lib_path}}
make -C {{raylib_src_path}} \
CC={{native_compiler}} \
PLATFORM=PLATFORM_DESKTOP \
RAYLIB_LIBTYPE=STATIC \
RAYLIB_RELEASE_PATH={{static_lib_path}} \
{{raylib_extra_make_variables}} \
CUSTOM_CFLAGS="{{raylib_custom_cflags}}"
fi
# build both the raylib library and the Lake project
build: build_resvg build_raylib bundler
LIBRARY_PATH={{library_path}} LEAN_CC={{native_compiler}} lake -R {{lake_config_opts}} build
# clean only the Lake project
clean:
lake clean
clean_static_lib:
rm -rf {{static_lib_path}}
# clean only the raylib build
clean_raylib:
make -C {{raylib_src_path}} clean
rm -rf {{static_lib_path}}/libraylib.a
clean_bundler:
rm -rf {{parent_directory(bundle_h_path)}}
rm -rf {{parent_directory(makebundle_output_path)}}
clean_resvg:
#!/usr/bin/env bash
set -euo pipefail
cd {{resvg_c_api_path}}
cargo clean
# clean both the raylib build and the Lake project
clean_all: clean clean_raylib clean_bundler clean_resvg clean_static_lib
# run the demo executable
run *demoName: build
.lake/build/bin/raylean {{demoName}}
build-bundler:
mkdir -p {{parent_directory(makebundle_output_path)}}
lean -c {{makebundle_output_path}}.c {{makebundle_src_path}}
leanc {{makebundle_output_path}}.c -o {{makebundle_output_path}}
# run the bundler
bundler: build-bundler
mkdir -p {{parent_directory(bundle_h_path)}}
{{makebundle_output_path}} {{justfile_directory()}} {{resource_dir}} {{bundle_h_path}}