diff options
| author | Omar Rizwan <omar@omar.website> | 2024-03-19 19:22:28 +0000 |
|---|---|---|
| committer | Omar Rizwan <omar@omar.website> | 2024-03-19 19:22:28 +0000 |
| commit | 3fc8f85c828d9dde9db826fdef8db0744ae674a3 (patch) | |
| tree | 20aa77d569a5c5b57d43d0916ce45368c6ec699c | |
| parent | folk0: Stick with 720p for now (diff) | |
| download | folk-3fc8f85c828d9dde9db826fdef8db0744ae674a3.tar.gz folk-3fc8f85c828d9dde9db826fdef8db0744ae674a3.zip | |
Make loadlibLd, filter by architecture if multiple candidates
Fixes https://discord.com/channels/956758212152025098/956758650700046366/1202431317971570728
| -rw-r--r-- | lib/c.tcl | 12 | ||||
| -rw-r--r-- | lib/terminal.tcl | 2 | ||||
| -rw-r--r-- | main.tcl | 2 | ||||
| -rw-r--r-- | pi/Camera.tcl | 8 | ||||
| -rw-r--r-- | pi/Gpu.tcl | 2 | ||||
| -rw-r--r-- | virtual-programs/images.folk | 7 |
6 files changed, 24 insertions, 9 deletions
@@ -524,9 +524,19 @@ namespace eval c { $loader compile proc loadlib {filename} { if {[loadlibImpl $filename] == "(void*) 0x0"} { - error "Failed to dlopen $filename: [loadlibError]" + error "c loadlib: Failed to dlopen $filename: [loadlibError]" } } + proc loadlibLd {libname} { + set candidates [split [exec /usr/sbin/ldconfig -p | grep $libname] "\n"] + if {[llength $candidates] == 0} { + error "c loadlibLd: Could not find library $libname" + } elseif {[llength $candidates] > 1} { + # Is it greater than 1? if so, filter by arch + set candidates [lsearch -all -inline $candidates *$::tcl_platform(machine)*] + } + loadlib [lindex $candidates 0 end] + } namespace export * namespace ensemble create diff --git a/lib/terminal.tcl b/lib/terminal.tcl index f81847e6..2ab8dd2d 100644 --- a/lib/terminal.tcl +++ b/lib/terminal.tcl @@ -63,7 +63,7 @@ set cc [c create] $cc cflags -I./vendor/libtmt ./vendor/libtmt/tmt.c if {$::tcl_platform(os) ne "Darwin"} { - c loadlib [lindex [exec /usr/sbin/ldconfig -p | grep libutil.so | head -1] end] + c loadlibLd libutil } $cc cflags -lutil @@ -468,7 +468,7 @@ namespace eval ::Heap { } if {$::tcl_platform(os) eq "Linux"} { $cc cflags -lrt - c loadlib [lindex [exec /usr/sbin/ldconfig -p | grep librt.so | head -1] end] + c loadlibLd librt.so } $cc compile folkHeapMount diff --git a/pi/Camera.tcl b/pi/Camera.tcl index 10c2812b..3532805c 100644 --- a/pi/Camera.tcl +++ b/pi/Camera.tcl @@ -272,9 +272,11 @@ namespace eval Camera { folkHeapFree(image.data); } - c loadlib [expr {$tcl_platform(os) eq "Darwin" ? - "/opt/homebrew/lib/libjpeg.dylib" : - [lindex [exec /usr/sbin/ldconfig -p | grep libjpeg] end]}] + if {$tcl_platform(os) eq "Darwin"} { + c loadlib "/opt/homebrew/lib/libjpeg.dylib" + } else { + c loadlibLd libjpeg.so + } camc compile variable camera @@ -1514,7 +1514,7 @@ Try doing `sudo chmod 666 $renderFile`." if {!$macos} { # Needed on Raspberry Pi 4: - c loadlib [lindex [exec /usr/sbin/ldconfig -p | grep libatomic.so | head -1] end] + c loadlibLd libatomic.so } dc compile diff --git a/virtual-programs/images.folk b/virtual-programs/images.folk index 1be51424..002760c0 100644 --- a/virtual-programs/images.folk +++ b/virtual-programs/images.folk @@ -23,10 +23,13 @@ namespace eval ::image { } set cc [c create] - c loadlib [expr {$tcl_platform(os) eq "Darwin" ? "/opt/homebrew/lib/libjpeg.dylib" : [lindex [exec /usr/sbin/ldconfig -p | grep libjpeg] end]}] - c loadlib [expr {$tcl_platform(os) eq "Darwin" ? "/opt/homebrew/lib/libpng.dylib" : [lindex [exec /usr/sbin/ldconfig -p | grep libpng] end]}] if {$tcl_platform(os) eq "Darwin"} { + c loadlib "/opt/homebrew/lib/libjpeg.dylib" + c loadlib "/opt/homebrew/lib/libpng.dylib" $cc cflags -I/opt/homebrew/include -L/opt/homebrew/lib + } else { + c loadlibLd libjpeg.so + c loadlibLd libpng } $cc cflags -ljpeg -lpng |
