Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/winheaders #87

Merged
merged 13 commits into from
Dec 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 28 additions & 29 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -210,26 +210,6 @@ jobs:
path: |
cjit-Darwin-arm64

# virustotal:
# name: 🦠 Virus scan of released binaries
# needs: [osx-native-release, win-native-release]
# runs-on: ubuntu-latest
# if: ${{ needs.semantic-release.outputs.new_release_published == 'true' }}
# steps:
# - name: download binary artifacts
# uses: actions/download-artifact@v4
# with:
# path: |
# cjit-bin
# - name: VirusTotal Scan
# uses: crazy-max/ghaction-virustotal@v4
# with:
# vt_api_key: ${{ secrets.VIRUSTOTAL_API_KEY }}
# update_release: true
# files: |
# cjit-bin/release-win-native-x86_64/*
# cjit-bin/release-osx-native/*

binary-release:
name: 📢 Public release
needs: [semantic-release, osx-native-release, musl-release, linux-release, win-native-release]
Expand All @@ -243,14 +223,10 @@ jobs:
with:
path: |
cjit-bin
- name: zip the tutorial archive
- name: pack the cjit-demo archive
run: |
mkdir -p cjit-tutorial
cp -ra cjit-bin/release* cjit-tutorial/
cp -ra examples cjit-tutorial/
tar cvfz cjit-tutorial.tar.gz cjit-tutorial
mkdir -p cjit-bin/release-tutorial
mv cjit-tutorial.tar.gz cjit-bin/release-tutorial/
bash build/pack-examples.sh
mv cjit-demo.tar.gz cjit-bin/release-tutorial/
- name: show release directory structure
run: tree -dL 3
- name: relase all binary artifacts
Expand All @@ -265,15 +241,38 @@ jobs:
prerelease: false
fail_on_unmatched_files: true
generate_release_notes: true
# - name: VirusTotal Scan
# uses: crazy-max/ghaction-virustotal@v4
# with:
# vt_api_key: ${{ secrets.VIRUSTOTAL_API_KEY }}
# update_release_body: true
# files: |
# cjit-bin/release-osx-native/*
# cjit-bin/release-win-native-x86_64/*
# cjit-bin/release-shared-linux-x86_64/*
# cjit-bin/release-musl-linux-x86_64/*

virustotal:
name: 🦠 Virus scan of released binaries
needs: [binary-release]
runs-on: ubuntu-latest
if: ${{ needs.semantic-release.outputs.new_release_published == 'true' }}
steps:
- name: download binary artifacts
uses: actions/download-artifact@v4
with:
path: |
cjit-bin
- name: VirusTotal Scan
uses: crazy-max/ghaction-virustotal@v4
with:
vt_api_key: ${{ secrets.VIRUSTOTAL_API_KEY }}
update_release_body: true
files: |
cjit-bin/release-win-native-x86_64/*
cjit-bin/release-osx-native/*
cjit-bin/release-tutorial/cjit-tutorial.tar.gz
cjit-bin/release-win-native-x86_64/*
cjit-bin/release-shared-linux-x86_64/*
cjit-bin/release-musl-linux-x86_64/*

remove-tag-on-fail:
name: 🧻 Remove tag on fail
Expand Down
43 changes: 31 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,32 @@ CJIT is a C interpreter based on tinyCC that compiles C code in-memory and runs

More info on [Dyne.org/CJIT](https://dyne.org/cjit).

## Downloads
## 🚀 Quick start

We provide ready to execute binary builds on [github releases](https://github.com/dyne/cjit/releases).

Beware windows defender will warn you that there is a virus in the file.
Download the CJIT executable for your system

There isn't, this is the [0.6.2 release analysis on VirusTotal](https://www.virustotal.com/gui/file/77054b14b5960eaa655bb5c3d5f4f1ddd3ddbd9756136f029074bbef83e168fd/).
- Windows x86 64bit: [cjit.exe](https://github.com/dyne/cjit/releases/latest/download/cjit.exe)
- Apple/OSX: [cjit-Darwin-arm64](https://github.com/dyne/cjit/releases/download/v0.10.5/cjit-Darwin-arm64)
- GNU/Linux: [cjit-Linux-x86_64-static](https://github.com/dyne/cjit/releases/download/v0.10.5/cjit-Linux-x86_64-static)

## Quick start

Just download the CJIT executable for your system and run it with c source files as well dynamic libraries as arguments:
and run it with c source files as well dynamic libraries as arguments:

```
./cjit.exe mysource.c mylib.dll
```

### [Read the CJIT Manual](https://dyne.org/docs/cjit)
CJIT can do a lot more! continue reading its tutorial for a hands-on introduction.

### 📖 [The CJIT tutorial](https://dyne.org/docs/cjit)

## 💾 Downloads

We provide ready to execute binary builds on [github releases](https://github.com/dyne/cjit/releases).

## Build from source
Some systems may warn you about a virus in the file. There isn't, we submit each built executable to Virustotal via [github actions](https://github.com/dyne/cjit/actions).


## ⚙️ Build from source

There are various build targets, just type `make` to have a list:
```
Expand All @@ -46,7 +53,19 @@ There are various build targets, just type `make` to have a list:
clean 🧹 Clean the source from all built objects
```

## License
## 🔬 Internals

CJIT is a bit complex inside.

1. It relies on [tinycc](https://bellard.org/tcc/) to compile C code in-memory and run it immediately.
2. It detects automatically the system on which its running and auto-configures to support most features.
3. It embeds all C code and headers in [cjit/assets](https://github.com/dyne/cjit/tree/main/assets) making them available to all running code.
4. To embed them creates a `tar.gz` of assets at build-time and decompresses them at run-time in a temporary dir.
5. It ships a non-exclusive, opinionated selection of libraries useful to quickly script advanced applications in C.

The [CJIT's Frequently Asked Questions](https://dyne.org/docs/cjit/faq/) page may provide more information.

## 📑 License

CJIT is copyright (C) 2024 by the Dyne.org foundation

Expand All @@ -57,6 +76,6 @@ TinyCC is copyright (C) 2001-2004 by Fabrice Bellard
TinyCC is distributed under the GNU Lesser General Public License

For more information on licensing please refer to the Reuse report and
license texts included in LICENSES/.
license texts included in [LICENSES](https://github.com/dyne/cjit/tree/main/LICENSES).

[![software by Dyne.org](https://files.dyne.org/software_by_dyne.png)](http://www.dyne.org)
24 changes: 18 additions & 6 deletions REUSE.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,18 @@ precedence = "aggregate"
SPDX-FileCopyrightText = "2024 Dyne.org foundation"
SPDX-License-Identifier = "GPL-3.0-or-later"

[[annotations]]
path = ["examples/tinyc.games/**", "examples/tetris/**"]
precedence = "aggregate"
SPDX-FileCopyrightText = "Copyright (c) 2016 Jer Wilson"
SPDX-License-Identifier = "MIT"

[[annotations]]
path = "examples/tinyc.games/res/PixelatedEleganceRegular.ttf"
precedence = "aggregate"
SPDX-FileCopyrightText = " 2024 GGBotNet"
SPDX-License-Identifier = "MIT-0"

[[annotations]]
path = [".*", ".github/**"]
precedence = "aggregate"
Expand All @@ -28,37 +40,37 @@ SPDX-FileCopyrightText = "2001-2004 Fabrice Bellard"
SPDX-License-Identifier = "LGPL-2.1-or-later"

[[annotations]]
path = "lib/contrib_headers/dmon.h"
path = "assets/misc/dmon.h"
precedence = "aggregate"
SPDX-FileCopyrightText = " 2019-2023 Sepehr Taghdisian"
SPDX-License-Identifier = "BSD-2-Clause"

[[annotations]]
path = "lib/contrib_headers/miniaudio.h"
path = "assets/misc/miniaudio.h"
precedence = "aggregate"
SPDX-FileCopyrightText = " 2023 David Reid"
SPDX-License-Identifier = "MIT-0"

[[annotations]]
path = "lib/contrib_headers/nuklear.h"
path = "assets/misc/nuklear.h"
precedence = "aggregate"
SPDX-FileCopyrightText = "2017 Micha Mettke"
SPDX-License-Identifier = "MIT-0"

[[annotations]]
path = "lib/stb/**"
path = "assets/stb/**"
precedence = "aggregate"
SPDX-FileCopyrightText = " 2009-2021 Sean Barrett"
SPDX-License-Identifier = "MIT-0"

[[annotations]]
path = "lib/win32ports/**"
path = "assets/win32ports/**"
precedence = "aggregate"
SPDX-FileCopyrightText = " 2019 win32ports"
SPDX-License-Identifier = "MIT-0"

[[annotations]]
path = "lib/contrib_headers/termbox2.h"
path = "assets/misc/termbox2.h"
precedence = "aggregate"
SPDX-FileCopyrightText = " 2010-2020 nsf, 2015-2024 Adam Saponara"
SPDX-License-Identifier = "MIT-0"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
18 changes: 10 additions & 8 deletions build/embed-path.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ rm -f ${name}.tar.gz
prevpwd=`pwd`
cd ${parent}
[ "$pathname" != "$name" ] && cp -ra "$pathname" "$name"
tar --format ustar -cvzf ${prevpwd}/${name}.tar.gz "$name"
>&2 echo "Embed ${prevpwd}/${name}.tar.gz"
tar --format ustar -czf ${prevpwd}/${name}.tar.gz "$name"
[ "$pathname" != "$name" ] && rm -rf "$name"
cd -

Expand All @@ -57,18 +58,19 @@ fi
varname=`echo $name | sed 's/\./_/g'`

# generate embeddings in source for extract_embeddings(char *tmpdir)
echo >> src/embedded.h
echo "extern char *${varname};" >> src/embedded.h
echo "extern unsigned int ${varname}_len;" >> src/embedded.h
echo >> src/embedded.h

cat <<EOF >> src/embedded.c

// vv ${name} vv
snprintf(incpath,511,"%s/%s",CJIT->tmpdir,"${name}");
if(fresh) {
res = muntargz_to_path(CJIT->tmpdir,(char*)&${varname},${varname}_len);
}
if(res!=0) { // muntar returns 0 on success
_err("Error extracting %s",incpath);
return(false);
}
if(fresh) res = muntargz_to_path(CJIT->tmpdir,(char*)&${varname},${varname}_len);
if(res!=0) { _err("Error extracting %s",incpath); return(false); }
tcc_add_include_path(CJIT->TCC, incpath);
// ^^ ${name} ^^

EOF
exit 0
15 changes: 9 additions & 6 deletions build/linux.mk
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ SOURCES += \
src/kilo.o \
src/embed_libtcc1.a.o \
src/embed_include.o \
src/embed_contrib_headers.o \
src/embed_misc.o \
src/embed_stb.o

all: embed cjit
Expand All @@ -20,8 +20,8 @@ embed: lib/tinycc/libtcc1.a
bash build/init-embeddings.sh
bash build/embed-path.sh lib/tinycc/libtcc1.a
bash build/embed-path.sh lib/tinycc/include
bash build/embed-path.sh lib/contrib_headers
bash build/embed-path.sh lib/stb
bash build/embed-path.sh assets/misc
bash build/embed-path.sh assets/stb
@echo >> src/embedded.c
@echo "return(true);" >> src/embedded.c
@echo "}" >> src/embedded.c
Expand All @@ -34,11 +34,14 @@ tinycc_config += --with-selinux
endif

ifdef ASAN
cflags := -Og -ggdb -DDEBUG=1 -fno-omit-frame-pointer -fsanitize=address
ASAN_FLAGS := -fsanitize=address -fsanitize=leak
ASAN_FLAGS += -fsanitize=float-divide-by-zero
ASAN_FLAGS += -fsanitize=float-cast-overflow
cflags := -g -DDEBUG=1 -Wall -fno-omit-frame-pointer
cflags += ${ASAN_FLAGS} -DMEM_DEBUG
cflags += ${cflags_includes} ${cflags_gnu} -DKILO_SUPPORTED
cflags += -DCJIT_BUILD_LINUX
ldflags := -fsanitize=address -static-libasan
# tinycc_config += --extra-ldflags="${ldflags}"
ldflags := ${ASAN_FLAGS} -static-libasan
endif

ifdef GDB
Expand Down
6 changes: 3 additions & 3 deletions build/musl.mk
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ SOURCES += \
src/kilo.o \
src/embed_libtcc1.a.o \
src/embed_include.o \
src/embed_contrib_headers.o \
src/embed_misc.o \
src/embed_libc.so.o \
src/musl-symbols.o \
src/embed_stb.o
Expand All @@ -31,9 +31,9 @@ embed: lib/tinycc/libtcc1.a
bash build/init-embeddings.sh
bash build/embed-path.sh lib/tinycc/libtcc1.a
bash build/embed-path.sh lib/tinycc/include
bash build/embed-path.sh lib/contrib_headers
bash build/embed-path.sh assets/misc
bash build/embed-path.sh /lib/x86_64-linux-musl/libc.so
bash build/embed-path.sh lib/stb
bash build/embed-path.sh assets/stb
@echo >> src/embedded.c
@echo "return(true);" >> src/embedded.c
@echo "}" >> src/embedded.c
Expand Down
6 changes: 3 additions & 3 deletions build/osx.mk
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ SOURCES += \
src/kilo.o \
src/embed_libtcc1.a.o \
src/embed_include.o \
src/embed_contrib_headers.o \
src/embed_misc.o \
src/embed_stb.o

all: embed cjit.command
Expand All @@ -17,8 +17,8 @@ embed: lib/tinycc/libtcc1.a
bash build/init-embeddings.sh
bash build/embed-path.sh lib/tinycc/libtcc1.a
bash build/embed-path.sh lib/tinycc/include
bash build/embed-path.sh lib/contrib_headers
bash build/embed-path.sh lib/stb
bash build/embed-path.sh assets/misc
bash build/embed-path.sh assets/stb
@echo >> src/embedded.c
@echo "return(true);" >> src/embedded.c
@echo "}" >> src/embedded.c
Expand Down
Loading
Loading