Skip to content

Commit

Permalink
fix: code reorganized to divide embedded assets
Browse files Browse the repository at this point in the history
divide runtime libs from embedded assets made available to executed code
  • Loading branch information
jaromil committed Dec 22, 2024
1 parent a9d188b commit df2aa76
Show file tree
Hide file tree
Showing 35 changed files with 44 additions and 25 deletions.
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)
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.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions build/linux.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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 Down
4 changes: 2 additions & 2 deletions build/musl.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 3 additions & 3 deletions build/win-native.mk
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ embed: lib/tinycc/libtcc1.a
bash build/embed-path.sh lib/tinycc/libtcc1.a
bash build/embed-path.sh lib/tinycc/include
bash build/embed-path.sh lib/tinycc/win32/include tinycc_win32
bash build/embed-path.sh lib/win32ports
bash build/embed-path.sh lib/contrib_headers
bash build/embed-path.sh lib/stb
bash build/embed-path.sh assets/win32ports
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
6 changes: 3 additions & 3 deletions build/win-wsl.mk
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ embed: lib/tinycc/libtcc1.a
bash build/embed-path.sh lib/tinycc/libtcc1.a
bash build/embed-path.sh lib/tinycc/include
bash build/embed-path.sh lib/tinycc/win32/include tinycc_win32
bash build/embed-path.sh lib/win32ports
bash build/embed-path.sh lib/contrib_headers
bash build/embed-path.sh lib/stb
bash build/embed-path.sh assets/win32ports
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

0 comments on commit df2aa76

Please sign in to comment.