make: replace Makefile with make.vsh

This commit is contained in:
ge
2025-05-29 23:28:49 +03:00
parent 480a407b9e
commit 718665e520
2 changed files with 25 additions and 22 deletions

View File

@ -1,22 +0,0 @@
DOC_DIR = doc
SPDX_LICENSE_LIST_FILE = licenses.json
SPDX_LICENSE_LIST_FILE_MIN = licenses.min.json
SPDX_LICENSE_LIST_FILE_TMP = /tmp/licenses.json.new
SPDX_LICENSE_LIST_JSON_URL = https://spdx.org/licenses/licenses.json
licenses:
wget -q -O $(SPDX_LICENSE_LIST_FILE_TMP) $(SPDX_LICENSE_LIST_JSON_URL)
if ! diff $(SPDX_LICENSE_LIST_FILE) $(SPDX_LICENSE_LIST_FILE_TMP) >/dev/null 2>&1; \
then mv -v $(SPDX_LICENSE_LIST_FILE_TMP) $(SPDX_LICENSE_LIST_FILE); \
fi
jq -c . < $(SPDX_LICENSE_LIST_FILE) > $(SPDX_LICENSE_LIST_FILE_MIN)
doc:
v doc -f html -m . -o $(DOC_DIR)
serve: clean doc
v -e "import net.http.file; file.serve(folder: '$(DOC_DIR)')"
clean:
rm -r $(DOC_DIR) || true

25
make.vsh Executable file
View File

@ -0,0 +1,25 @@
#!/usr/bin/env -S v run
import build
import net.http
const source_url = 'https://spdx.org/licenses/licenses.json'
mut context := build.context(default: 'licenses.min.json')
context.artifact(
name: 'licenses.json'
help: 'SPDX licenses list in JSON format'
should_run: |self| true
run: |self| http.download_file(source_url, self.name)!
)
context.artifact(
name: 'licenses.min.json'
help: 'The minified licenses.json ready for embedding (requires jq util)'
depends: ['licenses.json']
should_run: |self| true
run: |self| system('jq -c . < licenses.json > ${self.name}')
)
context.run()