Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
1299 commits
Select commit Hold shift + click to select a range
20d16f5
music: Init SuperDirt with custom config; works more reliably
osnr Aug 29, 2025
d647e30
title: Hacky impl of title so errors work
osnr Aug 29, 2025
90a8801
image: Fix external image loading
osnr Aug 30, 2025
4fe5145
canvases: Add helper to make a canvas for synthetic obj
osnr Aug 30, 2025
b860f20
Fix calibrate and ws Hold! usage
osnr Aug 30, 2025
fcdede6
programs: Make gadget fault to folk0
osnr Aug 30, 2025
4a07432
Makefile: Allow FOLK_REMOTE_NODE to be overridden
subelsky Sep 1, 2025
ebee2bd
Fix GPU pipeline error handling
osnr Sep 2, 2025
4308723
lib/c: Build with -O2
osnr Sep 2, 2025
ae7d47f
web/new: Make synthetic quad for web editor program
osnr Sep 2, 2025
cbd02e6
Add Assert shim and ::isLaptop
osnr Sep 2, 2025
c4389a6
Makefile: Use the folk service to start normally if it exists
osnr Sep 3, 2025
82b5bc2
unix-commands: Change pipe creation from chan to socket (bugfix)
subelsky Sep 3, 2025
e84e81c
dashed-line: Support `onto`, make interface match line
osnr Sep 3, 2025
51d1985
Merge commit 'refs/pullreqs/227' into osnr/folk2
osnr Sep 3, 2025
dea97de
lib/c: Don't print newline spam for every compile
osnr Sep 4, 2025
717e3ff
lib/c: Include Tracy header
osnr Sep 4, 2025
cbec123
textures: WIP: On copy, wait on fence instead of device
osnr Sep 4, 2025
809db45
gpu/textures: Simplify copyImageToTexture to not allocate
osnr Sep 4, 2025
b07bfe4
gpu/textures: Fix bug with canvas creation not fencing commandBuffer
osnr Sep 4, 2025
188b140
Makefile: Delete files on sync, excluding .o and other ignored files
osnr Sep 5, 2025
a749c4a
Makefile: Fix tracy-remote by running without systemd if CFLAGS
osnr Sep 5, 2025
e729c73
WIP: Start moving to quad changer, not (slow) inline per-point query
osnr Sep 5, 2025
a612f73
tags-to-quads: WIP: Fix quad changer. Basically works
osnr Sep 5, 2025
838e028
tags-to-quads: WIP: Make quadLib buffer work in any space
osnr Sep 8, 2025
e905cd4
tags-to-quads: Fix quadLib scale and quadLib move. points-at works
osnr Sep 8, 2025
42b4573
points-at: Operate directly on points; fixes the non-up directions
osnr Sep 8, 2025
144c3eb
web/new: Fix x-y flip
osnr Sep 8, 2025
231a62c
Implement sub/pub
smj-edison Sep 9, 2025
80e930e
Port editor
smj-edison Sep 10, 2025
38c5097
Get edge cases working with tcl parser
smj-edison Jun 12, 2025
89d9f95
Set PGID for all descendant processes; kill them on Folk startup
osnr Sep 10, 2025
4aa9b62
folk: setpgrp compatibility for macOS
osnr Sep 10, 2025
08cb1f6
Makefile: Kill Folk before running Tracy on remote
osnr Sep 10, 2025
1229b09
WIP: fix keyboards
smj-edison Sep 10, 2025
7560564
Fix ws.watch
smj-edison Sep 10, 2025
153eed2
Port printing to sub/pub
smj-edison Sep 10, 2025
5962c94
Throw error if using Say in a Subscription
smj-edison Sep 10, 2025
e814dc2
Publish -> Notify: and Subscribe -> Subscribe:
smj-edison Sep 10, 2025
d4af6ec
Remove `Every time` and change docs to `Subscribe:`
smj-edison Sep 11, 2025
e00d7c2
WIP: Implement skeleton of Atomically/AtomicallyVersion
osnr Sep 12, 2025
6354d21
Don't use DB matches for subscriptions
smj-edison Sep 12, 2025
09eaa61
Fix very minor merge conflict
smj-edison Sep 12, 2025
f030d2e
WIP: Draft test, use hyphen syntax
osnr Sep 12, 2025
b0c1ec2
boot: Catch setpgrp because it EPERM on laptop
osnr Sep 15, 2025
1139083
Makefile: Fix passwordless sudo check
osnr Sep 15, 2025
3ee12d7
Makefile: Fix debug-test targets to work on Linux
osnr Sep 15, 2025
c1b2224
Implement naive version of Hold! -deeply
smj-edison Sep 16, 2025
90bd677
Remove debugging
smj-edison Sep 16, 2025
d71e62d
WIP: Add -atomically to Query!. Add inflight count. Passes test
osnr Sep 16, 2025
964df2f
folk: Handle release when stmt/when are NULL
osnr Sep 16, 2025
c53098e
Makefile: rebuild when workqueue.h changes
osnr Sep 17, 2025
71c9863
Create a unique file for each programs' saved holds
smj-edison Sep 17, 2025
ede9a0a
Remove Hold pair if statement is empty
smj-edison Sep 17, 2025
9a78f07
Remove debugging
smj-edison Sep 17, 2025
7a4e87f
Add general serde framework
smj-edison Sep 17, 2025
bd667d9
Add directory for serde stuff
smj-edison Sep 17, 2025
2775b3b
Revamp unix-commands for folk2 and remove global variables
subelsky Sep 18, 2025
70f260a
WIP: port file usage to new system
smj-edison Sep 18, 2025
7305cf8
Small bugfixes
smj-edison Sep 18, 2025
aca17e4
Update old program directories
smj-edison Sep 18, 2025
7b4fd37
Use clearer naming for saving code
smj-edison Sep 18, 2025
3a14474
Add migration script
smj-edison Sep 18, 2025
061abab
Update unix-commands.folk to bind 'wisher' instead of 'someone'
subelsky Sep 18, 2025
306a7e5
Merge commit 'refs/pullreqs/230' into osnr/folk2
osnr Sep 19, 2025
22a041a
saved-holds: Cleaner printout
osnr Sep 19, 2025
4cb5e95
Merge pull request #231 from subelsky/improved-unix-commands
osnr Sep 19, 2025
23907df
prelude: Re-add error printout (useful for transient errors)
osnr Sep 19, 2025
8db00c9
web/new: Clean up the program on tab close again
osnr Sep 19, 2025
782e5d4
tags-to-quads: Add inverse changer
osnr Sep 19, 2025
1d4563a
Merge branch 'osnr/folk2' into osnr/folk2-atomically
osnr Sep 19, 2025
93fda95
web/index: Match QuerySimple! signature
osnr Sep 19, 2025
7b6a656
db: Turn off printouts to avoid spam
osnr Sep 19, 2025
fbf03f9
collect: WIP: Hack: make settle collects also respect -atomically
osnr Sep 19, 2025
15b8a7f
calibrate: Hack: Don't restart camera if crop is set
osnr Sep 19, 2025
65d29d0
prelude: Add proper number of arguments to fix Subscribe:
osnr Sep 22, 2025
697bb6d
test/atomically2: WIP: Implement basic test
osnr Sep 22, 2025
fdde49f
WIP: Maintain remove list on AtomicallyVersion
osnr Sep 22, 2025
378ee89
Make migration non-destructive
smj-edison Sep 22, 2025
15cf08a
Delete hold file if empty
smj-edison Sep 22, 2025
3de3a27
Merge branch 'osnr/folk2' into potential-hold-approach
smj-edison Sep 22, 2025
17649a4
Merge branch 'osnr/folk2' into potential-hold-approach
smj-edison Sep 22, 2025
889408b
WIP: implement -non-atomically for test
osnr Sep 22, 2025
48bbc2b
Normalize -flags to be consistent with Tcl style
osnr Sep 22, 2025
6199ff0
db: Fix fresh AtomicallyVersion generation
osnr Sep 22, 2025
d33b443
WIP: Make -nonatomically block inheritance & decr first. Fixes test.
osnr Sep 22, 2025
cf3c51c
WIP: Redesign to try to use -atomically directly on the matcher When
osnr Sep 23, 2025
889acb0
Start AtomicallyVersion unconverged; fix type mistake w/ fresh incr
osnr Sep 23, 2025
2c81e4c
Clean up inflight/atomically log messages
osnr Sep 23, 2025
1a108f7
db: WIP: Reap older AtomicallyVersion's stmts when newer converges
osnr Sep 24, 2025
55ae7b4
prelude: $this-scope -atomically key
osnr Sep 24, 2025
d1f7502
db-lib: Fix header
osnr Sep 24, 2025
6594302
db: Fix AtomicallyVersion reap exchange logic?
osnr Sep 24, 2025
0721faf
folk: Decr on early return in runWhenBlock
osnr Sep 24, 2025
9e39d5c
Migrate the next program id
smj-edison Sep 25, 2025
33a9270
Revert programs being stored as statements
smj-edison Sep 25, 2025
bbd963e
Don't hardcode data directory
smj-edison Sep 25, 2025
763b9b0
exec mkdir -> file mkdir
smj-edison Sep 25, 2025
33ccc55
editor: Make font size smaller by default
osnr Sep 26, 2025
4960297
draw/image: Fix http*:// images (exec doesn't want -ignorestderr)
osnr Oct 1, 2025
dd9efab
calibrate: Keep last-seen-poses local and clean it up
osnr Oct 1, 2025
d9a47b8
calibrate: Fix boot calibration from poses
osnr Oct 1, 2025
2cc7938
Fix folders being created with wrong permissions
smj-edison Oct 1, 2025
45675a3
Remove dead var
smj-edison Oct 1, 2025
7e19841
load-calibration: Fix onscreen calibration warning
osnr Oct 2, 2025
1c4ba1d
Update README.md
osnr Oct 2, 2025
286d874
canvases: Turn off settlement for display
osnr Oct 3, 2025
c23918a
canvases: Allow canvas customization
osnr Oct 3, 2025
a8a21bb
folk,sysmon: Clean up boot workerReactivateOrSpawn printouts
osnr Oct 3, 2025
415c099
sysmon: Try to fix race that leads to program Claim repeating?
osnr Oct 3, 2025
b44988f
editor: Remove the 12ms keep; seems to help with bugs
osnr Oct 3, 2025
b762bdd
editor: Separate program code into separate Hold!
osnr Oct 3, 2025
c2510d0
Integrates miniaudio for sound file playback (WAV, MP3, & FLAC), adds…
subelsky Oct 3, 2025
76cbb04
audio: Fix absolute path handling
osnr Oct 6, 2025
86b2ced
audio: Rename sound library -> audio. FOLK_ERROR after freeing
osnr Oct 6, 2025
5242cde
audio: Hack to force JACK use on folk0
osnr Oct 6, 2025
a01b084
canvases: Fix options bug
osnr Oct 6, 2025
5a303b8
c: Don't print error on typedef with missing struct
osnr Oct 6, 2025
313afaa
Return JIM_OK from Notify
osnr Oct 7, 2025
be710d9
Merge branch 'osnr/folk2' into osnr/folk2-atomically
osnr Oct 7, 2025
60afbc6
Deserialize at a per-directory level, not per-file
smj-edison Oct 8, 2025
e586845
Handle a fresh folk2 boot correctly
smj-edison Oct 8, 2025
09448f6
Handle `Hold! {}` correctly
smj-edison Oct 8, 2025
9891210
Merge commit 'refs/pullreqs/232' into osnr/folk2
osnr Oct 8, 2025
d46b9ca
calibrate: Disable debug print that doesn't work
osnr Oct 8, 2025
591b832
draw/image: Add width customization support
osnr Oct 8, 2025
60d86aa
draw/image: Hack to fix doubling + error
osnr Oct 8, 2025
ac55305
calibrate: Dynamic pose count; end calibrate on tab close
osnr Oct 8, 2025
8e3a683
editor: Fix printing message
osnr Oct 8, 2025
0ef5fd0
fswatch: Use folk-data/
osnr Oct 8, 2025
108d1f5
test/fn3: Fix
osnr Oct 8, 2025
d156234
test/options: Make succeed once fixed
osnr Oct 8, 2025
5b7eb66
test/options: Stagger failure so it always errors if bad
osnr Oct 8, 2025
6f2b0e6
Merge branch 'osnr/folk2' into osnr/folk2-atomically
osnr Oct 9, 2025
2e8e04a
WIP: Reap statements immediately if newer than latest converged
osnr Oct 13, 2025
dc6d152
db: WIP: Maintain a full list of statements in AtomicallyVersion.
osnr Oct 14, 2025
34c7e41
Slight cleanup.
osnr Oct 14, 2025
d1d7bbb
WIP: Don't remove new/same version on converge
osnr Oct 15, 2025
57f52d7
db: WIP: Don't throw away versions that we aren't reaping
osnr Oct 15, 2025
e3b9953
db: WIP: Try to not throw away versions during clear (race)
osnr Oct 15, 2025
65b64d3
db: Fix version-clearing race. Still leaks...
osnr Oct 15, 2025
9bb951c
db: WIP: Fix bug where we were corrupting tail in loop
osnr Oct 15, 2025
b5ce614
prelude: More generic atomically patterns; dedupe w/ sourceInfo
osnr Oct 16, 2025
0bd1c03
web/new: Better error display
osnr Oct 16, 2025
da80874
editor: Persist code across reboots
osnr Oct 16, 2025
5a95969
Fix keyboard shortcuts
cwervo Oct 16, 2025
8b7606e
prelude: Fix bug that broke keyboard on this branch?
osnr Oct 16, 2025
f6efa82
Merge branch 'osnr/folk2' into osnr/folk2-atomically
osnr Oct 17, 2025
eebf5f6
db: Don't add statements to already-cleared version
osnr Oct 20, 2025
9f4e30b
db: Fix not using right atomicallyVersion
osnr Oct 20, 2025
e7c38fd
Fix Tracy
osnr Oct 21, 2025
b9670ee
db: Fix horrible atomicallyVersion reuse bug
osnr Oct 21, 2025
9aaa2f3
prelude: Remove printouts
osnr Oct 21, 2025
1f095d8
Update note in setup.folk.default
osnr Oct 21, 2025
438ae47
apriltags: Hack: Remove tmutex since we're already using -serially
osnr Oct 22, 2025
3d70367
textures: Don't feed Vulkan size = 0 (that causes a crash)
osnr Oct 22, 2025
e9c35cf
folk: Complete the match even if an error (kill) happens
osnr Oct 22, 2025
926086a
Update README.md
osnr Oct 22, 2025
53265d8
Update README.md instructions
osnr Oct 23, 2025
72e0c0c
README.md: More updates
osnr Oct 23, 2025
4ec3131
README.md: nvidia
osnr Oct 23, 2025
59c481c
More nvidia / remove live-build for now
osnr Oct 23, 2025
71c565e
vendor libwslay
osnr Oct 23, 2025
4619dd5
README.md automake
osnr Oct 23, 2025
4b874fa
README.md: libtool as well as automake
osnr Oct 23, 2025
fb08c91
README.md: install autoconf-archive to fix wslay finally
osnr Oct 23, 2025
38144ae
Makefile: Use ~/folk instead of ~/folk2
osnr Oct 23, 2025
130ef26
ws: Use libwslay.a statically to fix Linux; use -lcrypto
osnr Oct 23, 2025
a08493f
Update systemd script
cwervo Oct 23, 2025
a854c39
Use swapchainImageFormat to represent images (fix Nvidia complaint)
osnr Oct 23, 2025
acaa4e6
README.md: Make folk.service world-readable to help Makefile
osnr Oct 23, 2025
b1657e9
Makefile: allow sudo password input
osnr Oct 23, 2025
b2e3fc8
WIP: bring in type system
smj-edison Sep 25, 2025
746e8a7
Make each type have its own namespace
smj-edison Sep 25, 2025
1ffe451
Add editor utils from code-view branch
smj-edison Sep 25, 2025
cb76258
Port editor over to editor utils
smj-edison Sep 26, 2025
0710c63
Port code-view
smj-edison Sep 26, 2025
514bb12
Code view tweaks and fixes
smj-edison Sep 26, 2025
98545d4
Get resetting to work correctly
smj-edison Oct 8, 2025
30c4c4b
Fix compiling with tracy
smj-edison Oct 8, 2025
899ca1c
WIP: easier dimension stuff
smj-edison Oct 8, 2025
5768f7e
Save code view scale
smj-edison Oct 24, 2025
74f47a6
Remove type aliases
smj-edison Oct 24, 2025
6fb54a5
Save and load ".edited" programs
smj-edison Oct 28, 2025
f1990e7
This file shouldn't have been touched
smj-edison Oct 28, 2025
7532311
Add simple type conversion and compact boxing
smj-edison Oct 29, 2025
379d4fc
Add pre-loaded programs to programs.folk and update sync
brianshl007 Oct 29, 2025
92c3a89
Moved demo programs from programs.folk to new folder demos.folk. Upda…
brianshl007 Oct 29, 2025
7801b31
gpu: Find 60Hz mode
osnr Oct 30, 2025
6dac9ce
Fault to folk-hex
osnr Oct 30, 2025
2bdd1f8
music: GPU sound card
osnr Oct 30, 2025
0415b10
Merge pull request #236 from brianshl007/osnr/folk2
osnr Oct 31, 2025
425b8db
rename location of folk-baltimore sounds
subelsky Oct 10, 2025
2a32d74
Adds display saver when no programs are running
subelsky Oct 17, 2025
ff7cc50
display-saver: Fix display query
osnr Oct 31, 2025
b720588
Fix demo slice program & tag cutoff
cwervo Nov 7, 2025
950175c
textures: Fix web/textures endpoint concurrency
osnr Nov 11, 2025
dbae48b
WIP: Reap old converged AtomicallyVersions if it's been a long time
osnr Nov 11, 2025
e13290a
Remove types for now
smj-edison Nov 12, 2025
b526662
Add code to print blanks
smj-edison Nov 12, 2025
ad7dd1f
Give the user feedback on code view, not keyboard
smj-edison Nov 12, 2025
ce8c714
Merge branch 'osnr/folk2' into folk2-code-views
smj-edison Nov 12, 2025
07966c9
Replace (keep 10ms) with -keep 10ms for consistency
osnr Nov 12, 2025
aff8c3d
label: Auto-shrink long labels
osnr Nov 12, 2025
22c0d41
Makefile: Don't sync the whole vendor/tracy/ tree (slow)
osnr Nov 12, 2025
6066a19
Implement /new rotation
cwervo Nov 12, 2025
7eb320c
Re-add /new explanations
cwervo Nov 12, 2025
cc91a25
Fix maxCursorX calculation
smj-edison Nov 13, 2025
6ff49cf
Fix code view ctrl+t
smj-edison Nov 13, 2025
29e9cc6
apriltags: Set decimation explicitly
osnr Nov 12, 2025
d81c678
Makefile: Fix tracy sync
osnr Nov 12, 2025
98657b7
apriltags: Less decimation
osnr Nov 17, 2025
91604e6
README.md: Clarify instructions further
osnr Nov 17, 2025
17f3c3b
music: Fix audio device for folk-hex
osnr Nov 17, 2025
58441c1
prelude: Nicer ForEach! error reporting (throw to caller)
osnr Nov 18, 2025
2da1bba
WIP: Early return support in ForEach!, clean up print
osnr Nov 19, 2025
3df83c1
prelude: Fix error stack trace in ForEach!
osnr Nov 19, 2025
999bf77
print: Fix out-of-date comment
osnr Nov 19, 2025
bfba3ab
db: Increase timeout on atomically reap to fix blinking
osnr Nov 19, 2025
d62e327
Update README.md
osnr Nov 19, 2025
1a6671c
WIP: Fix Enter key. But other keypresses broken?
osnr Nov 19, 2025
1bf45dc
Merge branch 'osnr/folk2' into folk2-new-editor
osnr Nov 19, 2025
51ff8d5
editor: Fix typing
osnr Nov 19, 2025
dab037e
Use code-view for everything; rename it to editor
osnr Nov 19, 2025
d0a1dbb
Tweak editor margins; edited timestamp and -atomically stabilize
osnr Nov 19, 2025
db8245a
Make sure code fully resets by deleting the edited file
smj-edison Nov 20, 2025
a80b2bf
points-at: WIP: Remove keeps to remove doubling. Fill when pointing
osnr Nov 19, 2025
b03126e
editor: Re-stabilize
osnr Nov 19, 2025
13128c9
canvases: Retry to fix titles (and display canvas generally) blink
osnr Nov 20, 2025
189769e
editor: Fix activity outline
osnr Nov 20, 2025
db894f0
programs: Hack to try to stop stmt re-add; omit secs from edit time
osnr Nov 20, 2025
5b8a886
editor: Hack to suppress error on partial match
osnr Nov 20, 2025
ea04fa9
points-at: Hack: Use Hold! to keep pointers from blinking
osnr Nov 20, 2025
0378ea0
points-at: Use a keep time on the Hold!
osnr Nov 20, 2025
2d1aca0
editor: Persist edits
osnr Nov 20, 2025
b4fb91f
music: Fix for new hdmi usage?
osnr Nov 25, 2025
e687f19
README.md: easier input
osnr Nov 26, 2025
a10edd1
label: move label off-center to not overlap tag
osnr Nov 26, 2025
f8c0e59
sysmon: Tracy zones for sysmon
osnr Nov 26, 2025
28fd71c
Update README.md
osnr Nov 26, 2025
db00710
Slightly clarify borrowed clause freeing
osnr Nov 26, 2025
7489e76
camera-slice: Don't need keep since we have -atomically?
osnr Nov 26, 2025
3f7faa1
folk: Clean up clause on Say failure
osnr Nov 26, 2025
ac285cb
db: Free clause on dbInsertOrReuseStatement abort. Fixes major leak!
osnr Nov 26, 2025
0fe697b
web/index: Autogenerate nav
osnr Nov 26, 2025
f943e47
Hide editor-control from web nav
osnr Nov 26, 2025
df169cd
web: Simplify/generalize nav generation a bit
osnr Nov 26, 2025
fd7b636
web: WIP: Autofill regexp match into $0, $1, etc in handler
osnr Nov 26, 2025
77492e4
web: Pretty good nav filter and url rewrite for now
osnr Nov 26, 2025
8a4f745
web: Clean up some filenames
osnr Nov 26, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
14 changes: 9 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
folk
folk.pid
*.o
folk.dSYM
CFLAGS
.DS_Store
statements.pdf
statements.dot
trie.pdf
trie.dot

play
.vscode/settings.json
vendor/jimtcl/conftest__.dSYM/Contents/Info.plist
vendor/jimtcl/conftest__.dSYM/Contents/Resources/Relocations/aarch64/conftest__.yml
6 changes: 3 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "live-build/config/includes.chroot_after_packages/etc/skel/apriltag"]
path = live-build/config/includes.chroot_after_packages/home/folk/apriltag
url = https://github.com/FolkComputer/apriltag
[submodule "vendor/tracy"]
path = vendor/tracy
url = https://github.com/wolfpld/tracy.git
207 changes: 165 additions & 42 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,61 +1,184 @@
start:
tclsh8.6 main.tcl
debug:
gdb --args tclsh8.6 main.tcl
remote-debug: sync
ssh -tt folk@$(FOLK_SHARE_NODE) -- 'sudo systemctl stop folk && make -C /home/folk/folk debug'
remote-valgrind: sync
ssh -tt folk@$(FOLK_SHARE_NODE) -- 'cd folk; sudo systemctl stop folk && valgrind --leak-check=yes tclsh8.6 main.tcl'
ifeq ($(shell uname -s),Linux)
override BUILTIN_CFLAGS += -Wl,--export-dynamic
endif

FOLK_SHARE_NODE := $(shell tclsh8.6 hosts.tcl shareNode)
ifneq (,$(filter -DTRACY_ENABLE,$(CFLAGS)))
# Tracy is enabled
TRACY_TARGET = vendor/tracy/public/TracyClient.o
override CPPFLAGS += -std=c++20 -DTRACY_ENABLE
LINKER := c++
else
LINKER := cc
endif

sync:
rsync --delete --timeout=5 -e "ssh -o StrictHostKeyChecking=no" -a --no-links . folk@$(FOLK_SHARE_NODE):/home/folk/folk
folk: workqueue.o db.o trie.o sysmon.o epoch.o cache.o folk.o \
vendor/c11-queues/mpmc_queue.o vendor/c11-queues/memory.o \
vendor/jimtcl/libjim.a $(TRACY_TARGET) CFLAGS

$(LINKER) -g -fno-omit-frame-pointer $(if $(ASAN_ENABLE),-fsanitize=address -fsanitize-recover=address,) -o$@ \
$(CFLAGS) $(BUILTIN_CFLAGS) \
-L./vendor/jimtcl \
$(filter %.o %.a,$^) \
-ljim -lm -lssl -lcrypto -lz
if [ "$$(uname)" = "Darwin" ]; then \
dsymutil $@; \
fi
# Hack for the gadget trigger button.
if [ "$$(uname)" = "Linux" ]; then \
(sudo -n true 2>/dev/null && sudo setcap cap_sys_rawio+ep $@) || true; \
fi

sync-restart: sync
ssh -tt folk@$(FOLK_SHARE_NODE) -- 'sudo systemctl restart folk'
%.o: %.c trie.h workqueue.h CFLAGS
cc -c -O2 -g -fno-omit-frame-pointer $(if $(ASAN_ENABLE),-fsanitize=address -fsanitize-recover=address,) -o$@ \
-D_GNU_SOURCE $(CFLAGS) $(BUILTIN_CFLAGS) \
$< -I./vendor/jimtcl -I./vendor/tracy/public

test:
for testfile in test/*.tcl; do echo; echo $${testfile}; echo --------; make FOLK_ENTRY=$${testfile}; done
.PHONY: test clean deps
test: folk
@count=1; \
total=$$(ls test/*.folk | wc -l | tr -d ' '); \
for test in test/*.folk; do \
echo "Running test: $$test ($${count}/$$total)"; \
echo "--------------------"; \
./folk $$test; \
result=$$?; \
if [ $$result -eq 0 ]; then \
echo "Ran test: $$test ($${count}/$$total): ✅ passed"; \
else \
echo "Ran test: $$test ($${count}/$$total): ❌ failed"; \
fi; \
echo ""; \
count=$$((count + 1)); \
done
test/%: test/%.folk folk
./folk $<
debug-test/%: test/%.folk folk
if [ "$$(uname)" = "Darwin" ]; then \
lldb -o "process handle -p true -s false SIGUSR1" -- ./folk $<; \
else \
gdb -ex "handle SIGUSR1 nostop" -ex "handle SIGPIPE nostop" --args ./folk $<; \
fi

test/%.debug:
FOLK_ENTRY=test/$*.tcl lldb -- tclsh8.6 main.tcl
debug: folk
if [ "$$(uname)" = "Darwin" ]; then \
lldb -o "process handle -p true -s false SIGUSR1" -- ./folk; \
else \
gdb -ex "handle SIGUSR1 nostop" -ex "handle SIGPIPE nostop" ./folk; \
fi

test/%:
make [email protected]
clean:
rm -f folk *.o vendor/tracy/public/TracyClient.o vendor/c11-queues/*.o
distclean: clean
make -C vendor/jimtcl distclean
make -C vendor/apriltag clean

repl:
tclsh8.6 replmain.tcl
remote-clean: sync
ssh $(FOLK_REMOTE_NODE) -- 'cd folk; make clean'
remote-distclean: sync
ssh $(FOLK_REMOTE_NODE) -- 'cd folk; make distclean'
deps:
if [ ! -f vendor/jimtcl/Makefile ]; then \
cd vendor/jimtcl && ./configure CFLAGS='-g -fno-omit-frame-pointer'; \
fi
make -C vendor/jimtcl
make -C vendor/apriltag libapriltag.so
if [ ! -f vendor/wslay/Makefile ]; then \
cd vendor/wslay && autoreconf -i && automake && autoconf && ./configure; \
fi
make -C vendor/wslay
if [ "$$(uname)" = "Darwin" ]; then \
install_name_tool -id @executable_path/vendor/apriltag/libapriltag.so vendor/apriltag/libapriltag.so; \
install_name_tool -id @executable_path/vendor/wslay/lib/.libs/libwslay.0.dylib vendor/wslay/lib/.libs/libwslay.0.dylib; \
fi

journal:
ssh folk@$(FOLK_SHARE_NODE) -- journalctl -f -n 100 -u folk
kill-folk:
sudo systemctl stop folk
if [ -f folk.pid ]; then \
OLD_PID=`cat folk.pid`; \
sudo pkill -9 --pgroup $$OLD_PID; \
while sudo pkill -0 --pgroup $$OLD_PID; do sleep 0.2; done; \
fi

ssh:
ssh folk@$(FOLK_SHARE_NODE)
FOLK_REMOTE_NODE ?= folk-live

sync:
ssh $(FOLK_REMOTE_NODE) -t \
'cd ~/folk && git init > /dev/null && git ls-files --exclude-standard -oi --directory' \
> .git/ignores.tmp || true
git ls-files --exclude-standard -oi --directory >> .git/ignores.tmp
rsync --timeout=15 -e "ssh -o StrictHostKeyChecking=no" \
--archive --delete --itemize-changes \
--exclude='/.git' \
--exclude-from='.git/ignores.tmp' \
--include='vendor/tracy/public/***' \
--exclude='vendor/tracy/*' \
./ $(FOLK_REMOTE_NODE):~/folk/

remote-setup:
ssh-copy-id $(FOLK_REMOTE_NODE)
make sync
ssh $(FOLK_REMOTE_NODE) -- 'sudo usermod -a -G tty folk && chmod +rwx ~/folk-calibration-poses; sudo apt update && sudo apt install libssl-dev gdb libwslay-dev google-perftools libgoogle-perftools-dev linux-perf && cd folk/vendor/jimtcl && make distclean; ./configure CFLAGS="-g -fno-omit-frame-pointer"'

remote: sync
ssh $(FOLK_REMOTE_NODE) -- 'cd folk; make kill-folk; make deps && make start CFLAGS="$(CFLAGS)" ASAN_ENABLE=$(ASAN_ENABLE)'
sudo-remote: sync
ssh -tt $(FOLK_REMOTE_NODE) -- 'cd folk; make kill-folk; make deps && make CFLAGS="$(CFLAGS)" && sudo HOME=/home/folk TRACY_SAMPLING_HZ=31000 ./folk'
debug-remote: sync
ssh $(FOLK_REMOTE_NODE) -- 'cd folk; make kill-folk; make deps && make CFLAGS="$(CFLAGS)" && gdb -ex "handle SIGUSR1 nostop" -ex "handle SIGPIPE nostop" ./folk'
debug-sudo-remote: sync
ssh -tt $(FOLK_REMOTE_NODE) -- 'cd folk; make kill-folk; make deps && make CFLAGS="$(CFLAGS)" && sudo HOME=/home/folk TRACY_SAMPLING_HZ=31000 gdb -ex "handle SIGUSR1 nostop" -ex "handle SIGPIPE nostop" ./folk'
valgrind-remote: sync
ssh $(FOLK_REMOTE_NODE) -- 'cd folk; make kill-folk; make deps && make && valgrind --leak-check=yes ./folk'
heapprofile-remote: sync
ssh $(FOLK_REMOTE_NODE) -- 'cd folk; make kill-folk; make deps && make CFLAGS="$(CFLAGS)" && env LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libtcmalloc.so HEAPPROFILE=/tmp/folk.hprof PERFTOOLS_VERBOSE=-1 ./folk'
debug-heapprofile-remote: sync
ssh $(FOLK_REMOTE_NODE) -- 'cd folk; make kill-folk; make deps && make CFLAGS="$(CFLAGS)" && env LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libtcmalloc.so HEAPPROFILE=/tmp/folk.hprof PERFTOOLS_VERBOSE=-1 gdb -ex "handle SIGUSR1 nostop" ./folk'
heapprofile-remote-show:
ssh $(FOLK_REMOTE_NODE) -- 'cd folk; google-pprof --text folk $(HEAPPROFILE)'
heapprofile-remote-svg:
ssh $(FOLK_REMOTE_NODE) -- 'cd folk; google-pprof --svg folk $(HEAPPROFILE)' > out.svg

FLAMEGRAPH_TID := $(shell pgrep tclsh8.6 | head -1)
flamegraph:
sudo perf record -F 997 --tid=$(FLAMEGRAPH_TID) -g -- sleep 30
sudo perf record --freq=997 --call-graph lbr --pid=$(shell cat folk.pid) -g -- sleep 30
sudo perf script -f > out.perf
~/FlameGraph/stackcollapse-perf.pl out.perf > out.folded
~/FlameGraph/flamegraph.pl out.folded > out.svg

# You can use the Web server to check the pid of display.folk,
# apriltags.folk, camera.folk, etc.
remote-flamegraph:
ssh -t folk@$(FOLK_SHARE_NODE) -- make -C /home/folk/folk flamegraph $(if $(REMOTE_FLAMEGRAPH_TID),FLAMEGRAPH_TID=$(REMOTE_FLAMEGRAPH_TID),)
scp folk@$(FOLK_SHARE_NODE):~/folk/out.svg .
scp folk@$(FOLK_SHARE_NODE):~/folk/out.perf .

backup-printed-programs:
cd ~/folk-printed-programs && timestamp=$$(date '+%Y-%m-%d_%H-%M-%S%z') && tar -zcvf ~/"folk-printed-programs_$$timestamp.tar.gz" . && echo "Saved to: ~/folk-printed-programs_$$timestamp.tar.gz"
ssh -t $(FOLK_REMOTE_NODE) -- make -C folk flamegraph
scp $(FOLK_REMOTE_NODE):~/folk/out.svg .
scp $(FOLK_REMOTE_NODE):~/folk/out.perf .

.PHONY: test sync start journal repl enable-pubkey install-deps
start: folk
@if [ -n "$$(systemctl list-unit-files | grep folk.service)" ] && \
[ -n "$$(systemctl cat folk.service | grep "ExecStart.*$$(pwd)")" ] && \
[ -z "$(ENABLE_ASAN)" ] && \
[ -z "$$INVOCATION_ID" ] && \
[ -z "$(CFLAGS)" ] ; then \
sudo systemctl start folk.service; \
journalctl -f -u folk.service; \
else \
$(if $(ENABLE_ASAN),ASAN_OPTIONS=detect_leaks=1:halt_on_error=0,) ./folk; \
fi

enable-pubkey:
ssh folk-live -- 'sudo sed -i "s/.*PubkeyAuthentication.*/PubkeyAuthentication yes/g" /etc/ssh/sshd_config && sudo systemctl restart ssh'
sleep 1
ssh-copy-id folk-live
run-tracy:
vendor/tracy/profiler/build/tracy-profiler
tracy-remote:
ssh $(FOLK_REMOTE_NODE) -- 'cd folk; make kill-folk'
vendor/tracy/profiler/build/tracy-profiler -a `ssh -G $(FOLK_REMOTE_NODE) | awk '$$1 == "hostname" { print $$2 }'` & \
make remote CFLAGS=-DTRACY_ENABLE FOLK_REMOTE_NODE=$(FOLK_REMOTE_NODE)
sudo-tracy-remote:
ssh $(FOLK_REMOTE_NODE) -- 'cd folk; make kill-folk'
vendor/tracy/profiler/build/tracy-profiler -a `ssh -G $(FOLK_REMOTE_NODE) | awk '$$1 == "hostname" { print $$2 }'` & \
make sudo-remote CFLAGS=-DTRACY_ENABLE FOLK_REMOTE_NODE=$(FOLK_REMOTE_NODE)

install-deps:
sudo apt install console-data
# From https://stackoverflow.com/a/26147844 to force rebuild if CFLAGS
# changes (in particular, so we rebuild if we want to use Tracy)
define DEPENDABLE_VAR
.PHONY: phony
$1: phony
@if [ "`cat $1 2>&1`" != '$($1)' ]; then \
/bin/echo -n $($1) > $1 ; \
fi
endef
$(eval $(call DEPENDABLE_VAR,CFLAGS))
Loading