From f91877089b8f1afbfc23ec84c77a96d17d71ad10 Mon Sep 17 00:00:00 2001 From: Nathan DECHER Date: Sun, 13 Sep 2020 01:04:41 +0200 Subject: [PATCH] added findclib and used it in Build.moon --- Build.moon | 2 +- util.moon | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Build.moon b/Build.moon index 87a52df..84ab70f 100644 --- a/Build.moon +++ b/Build.moon @@ -24,7 +24,7 @@ public target 'info', fn: => #echo "Binary:", BINARY default target BINARY, out: {BINARY, OUT_C}, from: OUT_LUA, fn: => - -luastatic MAIN_LUA, OUT_LUA, '-I/usr/include/lua5.3', '-llua5.3' + -luastatic MAIN_LUA, OUT_LUA, (findclib 'lua5.3', 'all') target '%.lua', in: '%.moon', out: '%.lua', fn: => -moonc @infile diff --git a/util.moon b/util.moon index d0e9ef3..d9ab3d7 100644 --- a/util.moon +++ b/util.moon @@ -85,6 +85,12 @@ calccdeps= (infile, includesys=false) -> rawdeps=data\gsub('\\\n', '')\match ':(.+)' [dep for dep in rawdeps\gmatch '%S+' when dep!=infile] +findclib= (name, mode='all') -> + args={name} + insert args, '--cflags' if mode=='all' or mode=='cc' + insert args, '--libs' if mode=='all' or mode=='ld' + [arg for arg in (popen 'pkg-config', args)\read('*a')\gmatch '%S+'] + -- file matcher wildcard= (pattern) -> prefix, suffix=pattern\match '^(.*)%*%*(.*)$' @@ -169,7 +175,7 @@ sortedpairs= (table, cmp) -> -- command functions :run, :popen - :calccdeps + :calccdeps, :findclib -- string functions :patsubst, :match, :isglob