From ab974b6d999a78d16be0696b58382f5c52b1d509 Mon Sep 17 00:00:00 2001 From: Jaromil Date: Tue, 17 Dec 2024 15:09:29 +0100 Subject: [PATCH] fix: reuse compliance and build improvements more reuse info on builtins small improvements on build saved leftover experiment embedding glfw and glew ci: try vt action fix --- .github/workflows/main.yml | 2 +- .gitignore | 1 + GNUmakefile | 3 +++ LICENSES/MIT-0.txt | 16 +++++++++++++++ REUSE.toml | 40 ++++++++++++++++++++++++++++++++++++-- build/deps.mk | 21 ++++++++++++++++++++ build/export-symbols.sh | 28 ++++++++++++++++++++++++++ build/init-embeddings.sh | 1 - build/update-libs.sh | 20 +++++++++++-------- src/muntar.c | 2 +- 10 files changed, 121 insertions(+), 13 deletions(-) create mode 100644 LICENSES/MIT-0.txt create mode 100755 build/export-symbols.sh diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 55aada1..8e98bf8 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -257,7 +257,7 @@ jobs: uses: crazy-max/ghaction-virustotal@v4 with: vt_api_key: ${{ secrets.VIRUSTOTAL_API_KEY }} - update_release: true + update_release_body: true files: | cjit-bin/release-win-native-x86_64/* cjit-bin/release-osx-native/* diff --git a/.gitignore b/.gitignore index 389dcd1..77e80cb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ cjit *.o src/embed* +.build_done* diff --git a/GNUmakefile b/GNUmakefile index 0e6aa72..6b88cc8 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -1,3 +1,6 @@ +# SPDX-FileCopyrightText: 2024 Dyne.org +# SPDX-License-Identifier: GPL-3.0-or-later + # Copyright (C) 2024 Dyne.org Foundation # # This source code is free software; you can redistribute it and/or diff --git a/LICENSES/MIT-0.txt b/LICENSES/MIT-0.txt new file mode 100644 index 0000000..a4e9dc9 --- /dev/null +++ b/LICENSES/MIT-0.txt @@ -0,0 +1,16 @@ +MIT No Attribution + +Copyright + +Permission is hereby granted, free of charge, to any person obtaining a copy of this +software and associated documentation files (the "Software"), to deal in the Software +without restriction, including without limitation the rights to use, copy, modify, +merge, publish, distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/REUSE.toml b/REUSE.toml index 635013e..87174f0 100644 --- a/REUSE.toml +++ b/REUSE.toml @@ -4,7 +4,13 @@ SPDX-PackageSupplier = "Denis Roio " SPDX-PackageDownloadLocation = "https://github.com/dyne/cjit" [[annotations]] -path = ["src/**", "**"] +path = ["src/**", "build/**", "test/**", "examples/**", "REUSE.toml"] +precedence = "aggregate" +SPDX-FileCopyrightText = "2024 Dyne.org foundation" +SPDX-License-Identifier = "GPL-3.0-or-later" + +[[annotations]] +path = [".*", ".github/**"] precedence = "aggregate" SPDX-FileCopyrightText = "2024 Dyne.org foundation" SPDX-License-Identifier = "GPL-3.0-or-later" @@ -24,9 +30,39 @@ SPDX-License-Identifier = "LGPL-2.1-or-later" [[annotations]] path = "lib/contrib_headers/dmon.h" precedence = "aggregate" -SPDX-FileCopyrightText = " 2019-2023, Sepehr Taghdisian" +SPDX-FileCopyrightText = " 2019-2023 Sepehr Taghdisian" SPDX-License-Identifier = "BSD-2-Clause" +[[annotations]] +path = "lib/contrib_headers/miniaudio.h" +precedence = "aggregate" +SPDX-FileCopyrightText = " 2023 David Reid" +SPDX-License-Identifier = "MIT-0" + +[[annotations]] +path = "lib/contrib_headers/nuklear.h" +precedence = "aggregate" +SPDX-FileCopyrightText = "2017 Micha Mettke" +SPDX-License-Identifier = "MIT-0" + +[[annotations]] +path = "lib/stb/**" +precedence = "aggregate" +SPDX-FileCopyrightText = " 2009-2021 Sean Barrett" +SPDX-License-Identifier = "MIT-0" + +[[annotations]] +path = "lib/win32ports/**" +precedence = "aggregate" +SPDX-FileCopyrightText = " 2019 win32ports" +SPDX-License-Identifier = "MIT-0" + +[[annotations]] +path = "lib/contrib_headers/termbox2.h" +precedence = "aggregate" +SPDX-FileCopyrightText = " 2010-2020 nsf, 2015-2024 Adam Saponara" +SPDX-License-Identifier = "MIT-0" + [[annotations]] path = ["docs/**", "**.md"] precedence = "aggregate" diff --git a/build/deps.mk b/build/deps.mk index 22d3278..32ac008 100644 --- a/build/deps.mk +++ b/build/deps.mk @@ -14,3 +14,24 @@ lib/tinycc/libtcc.a lib/tinycc/libtcc1.a: clean: ${MAKE} -C lib/tinycc clean distclean ${MAKE} -C src clean + +# UNUSED EXPERIMENTS: +lib/glfw/src/libglfw3.a: + cd lib/glfw \ + && cmake . + -DGLFW_BUILD_EXAMPLES=NO \ + -DGLFW_BUILD_TESTS=NO \ + -DGLFW_BUILD_DOCS=NO + ${MAKE} -C lib/glfw + cp lib/glfw/deps/linmath.h lib/glfw/include/GLFW/ + cp lib/glfw/deps/tinycthread.h lib/glfw/include/GLFW/ + cp lib/glfw/deps/nuklear_glfw* lib/glfw/include/GLFW/ + cp -r lib/glfw/deps/glad lib/glfw/include/GLFW/ + +lib/glew/lib/libGLEW.a: + ${MAKE} -C lib/glew/auto + ${MAKE} -C lib/glew + +# ${MAKE} -C lib/glfw clean +# ${MAKE} -C lib/glew/auto clean +# ${MAKE} -C lib/glew clean diff --git a/build/export-symbols.sh b/build/export-symbols.sh new file mode 100755 index 0000000..b713deb --- /dev/null +++ b/build/export-symbols.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env zsh +# +# extract external symbols from library files on linux + +lib=$1 +[ -r "$lib" ] || { + >&2 echo "Lib not found: $lib" + exit 1 +} + +syms=`nm -WUg ${lib} | awk '$2 ~ T {if($3)print $3}' | grep -v '^_' | grep -v '.0$'` +name=`basename $lib | sed 's/\./_/g' | sed 's/-/_/g' | sed 's/_a$//g'` +cat < src/${name}.c +// Generated by cjit/build/export-symbols.sh +// `date` + +#include +// TODO: fill in needed includes here + +void tcc_add_${name}_symbols(TCCState *TCC) { +EOF +for sym in ${(f)syms}; do + # >&2 echo "+ ($name) $sym" + echo "tcc_add_symbol(TCC, \"${sym}\", &${sym});" >> src/${name}.c +done +echo "}" >> src/${name}.c + +>&2 echo "Generated symbol declaration: src/${name}.c" diff --git a/build/init-embeddings.sh b/build/init-embeddings.sh index cd0febf..dc9fa73 100644 --- a/build/init-embeddings.sh +++ b/build/init-embeddings.sh @@ -24,7 +24,6 @@ cat < ${code} // from file.c extern bool cjit_mkdtemp(CJITState *CJIT); -extern int muntar_to_path(const char *path, const uint8_t *buf, const unsigned int len); extern int muntargz_to_path(const char *path, const uint8_t *buf, const unsigned int len); // main function diff --git a/build/update-libs.sh b/build/update-libs.sh index 2fc61d8..133131a 100755 --- a/build/update-libs.sh +++ b/build/update-libs.sh @@ -1,5 +1,7 @@ #!/bin/bash +set -e + odir=lib/contrib_headers function fetch() { @@ -41,12 +43,14 @@ odir="lib/win32ports/sys" fetch time.h https://raw.githubusercontent.com/win32ports/sys_time_h/refs/heads/master/sys/time.h fetch wait.h https://raw.githubusercontent.com/win32ports/sys_wait_h/refs/heads/master/sys/wait.h - -[ "$1" = "stb" ] && { -# std headers - if [ -d stb ]; then cd stb && git pull --rebase; cd - - else git clone https://github.com/nothings/stb.git - fi - mkdir -p lib/stb - cp stb/*.h lib/stb/ +function clone() { + name=$1 + repo=$2 + >&2 echo "update $name headers from $repo" + git clone --depth 1 $repo /tmp/$name + mkdir -p lib/$name } + +clone stb https://github.com/nothings/stb.git +cp /tmp/stb/*.h lib/stb +rm -rf /tmp/stb diff --git a/src/muntar.c b/src/muntar.c index 874cc33..e90d3b5 100644 --- a/src/muntar.c +++ b/src/muntar.c @@ -240,7 +240,7 @@ int muntar_to_path(const char *path, const uint8_t *buf, #if !defined(NOGUNZIP) // gunzip and untar all in one #include -#define DECOMPRESSED_SIZE_RATIO 8 // raise this on errors +#define DECOMPRESSED_SIZE_RATIO 10 // raise this on errors int muntargz_to_path(const char *path, const uint8_t *buf, const unsigned int len) { if(!buf) {