Add a bunch of tools for bundling/unbundling fennel-ls

This commit is contained in:
XeroOl 2024-06-08 00:00:45 -05:00
parent 8dc4f3d0f8
commit 083383cfa4
5 changed files with 69 additions and 24 deletions

View File

@ -1,4 +1,4 @@
"Language
"Analyzer
This module is for searching through the data provided by compiler.fnl.
It searches through a file to find information about symbols that appear
in the file.

View File

@ -1,26 +1,5 @@
"Script to generate /src/fennel-ls/docs/lua54.fnl and friends automatically"
(fn sh [...]
"run a shell command."
(let [command (table.concat
(icollect [_ arg (ipairs [...])]
(if
;; table skips escaping
(= (type arg) :table)
(. arg 1)
;; simple string skips escaping
(arg:find "^[a-zA-Z0-9/_-]+$")
arg
;; full escaping
(.. "'"
(string.gsub arg "'" "\\'")
"'")))
" ")]
(print (.. "tools/gen-docs: " command))
(os.execute command)))
(fn mkdir-p [dirname]
(sh "mkdir" "-p" dirname))
(local {: sh} (require :tools.util.sh))
(fn curl-cached [url]
(let [filename (.. "build/" (url:gsub "[/:]" "_"))
@ -41,7 +20,7 @@
result "\n"))))
(fn main []
(mkdir-p "build/")
(sh :mkdir :-p "build/")
(let [{:convert lua-manual} (require :tools.gen-docs.lua-manual)
{:convert tic-manual} (require :tools.gen-docs.tic80)]
(derive-docs-from-url "https://www.lua.org/manual/5.1/manual.html" "lua51.fnl" lua-manual)

16
tools/unvendor.fnl Normal file
View File

@ -0,0 +1,16 @@
(local {: sh} (require :tools.util.sh))
(sh :rm :-f
;; delete vendored "fennel"
"src/fennel.lua"
;; delete vendored "fennel" (build dependency)
"fennel"
;; delete vendored "faith" (build dependency)
"test/faith/faith.fnl"
;; delete vendored "penlight" (build dependency)
"test/pl/stringio.lua")
;; write a dummy file to forward to the installation of penlight on LUA_PATH
(doto (io.open "test/pl/stringio.lua")
(: :write "(require :pl.stringio)")
(: :close))

20
tools/util/sh.fnl Normal file
View File

@ -0,0 +1,20 @@
(fn sh [...]
"run a shell command."
(let [command (table.concat
(icollect [_ arg (ipairs [...])]
(if
;; table skips escaping
(= (type arg) :table)
(. arg 1)
;; simple string skips escaping
(arg:find "^[a-zA-Z0-9/_-%.]+$")
arg
;; full escaping
(.. "'"
(string.gsub arg "'" "\\'")
"'")))
" ")]
(print (.. "tools/gen-docs: " command))
(os.execute command)))
{: sh}

30
tools/vendor.fnl Normal file
View File

@ -0,0 +1,30 @@
(local {: sh} (require :tools.util.sh))
(fn git-clone [location url tag]
(if tag
(sh :git :clone :-c :advice.detachedHead=false :--depth=1 :--branch tag url location)
(sh :git :clone :-c :advice.detachedHead=false :--depth=1 url location)))
(local fennel-version "1.4.2")
(local faith-version "0.1.2")
(local penlight-version "1.14.0")
;; get && build fennel
(sh :mkdir :-p "build")
(when (not (io.open "build/fennel/fennel"))
(git-clone "build/fennel"
"https://git.sr.ht/~technomancy/fennel"
fennel-version)
(sh :make :-C "build/fennel"))
sh :cp "build/fennel/fennel" "."
(sh :cp "build/fennel/fennel.lua" "src")
;; get faith
(when (not (io.open "build/fennel/faith.fnl"))
(git-clone "build/faith" "https://git.sr.ht/~technomancy/faith" faith-version))
(sh :cp "build/faith/faith.fnl" "test/faith/faith.fnl")
;; get penlight.stringio
(when (not (io.open "build/pl/stringio.lua"))
(git-clone "build/penlight" "https://github.com/lunarmodules/Penlight" penlight-version))
(sh :cp "build/penlight/lua/pl/stringio.lua" "test/pl/stringio.lua")