Skip to content

Commit

Permalink
Merge branch 'main' into enable-asan-on-macos
Browse files Browse the repository at this point in the history
  • Loading branch information
tony-go authored Feb 28, 2024
2 parents df309ed + 04ebfbe commit 5b8aa1e
Show file tree
Hide file tree
Showing 41 changed files with 891 additions and 283 deletions.
26 changes: 21 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,53 +9,69 @@ jobs:
fail-fast: false
matrix:
platform:
# TODO: Build on more platforms
- os: macos-latest
cc: clang
cxx: clang++
type: static
backend: JavaScriptCore
- os: macos-latest
cc: clang
cxx: clang++
type: shared
backend: JavaScriptCore
# TODO(RaisinTen): Support other OSs and static configuration for
# the V8 backend.
- os: macos-latest
cc: clang
cxx: clang++
type: shared
backend: V8
- os: ubuntu-latest
cc: clang
cxx: clang++
type: static
backend: JavaScriptCore
- os: ubuntu-latest
cc: gcc
cxx: g++
type: static
backend: JavaScriptCore
- os: ubuntu-latest
cc: clang
cxx: clang++
type: shared
backend: JavaScriptCore
- os: ubuntu-latest
cc: gcc
cxx: g++
type: shared
backend: JavaScriptCore

# Sanitizers
- os: ubuntu-latest
cc: clang
cxx: clang++
type: static
options: -DINCLUDEJS_ADDRESS_SANITIZER:BOOL=ON
backend: JavaScriptCore
- os: ubuntu-latest
cc: clang
cxx: clang++
type: static
options: -DINCLUDEJS_UNDEFINED_SANITIZER:BOOL=ON
backend: JavaScriptCore
- os: macos-latest
cc: clang
cxx: clang++
type: static
options: -DINCLUDEJS_ADDRESS_SANITIZER:BOOL=ON
backend: JavaScriptCore
- os: macos-latest
cc: clang
cxx: clang++
type: static
options: -DINCLUDEJS_UNDEFINED_SANITIZER:BOOL=ON
backend: JavaScriptCore

runs-on: ${{ matrix.platform.os }}
env:
Expand Down Expand Up @@ -88,7 +104,7 @@ jobs:
run: >
cmake -S . -B ./build
-DCMAKE_BUILD_TYPE:STRING=Release
-DINCLUDE_BACKEND:STRING=JavaScriptCore
-DINCLUDEJS_BACKEND:STRING=${{ matrix.platform.backend }}
-DINCLUDEJS_TESTS:BOOL=ON
-DINCLUDEJS_DOCS:BOOL=OFF
-DBUILD_SHARED_LIBS:BOOL=OFF
Expand All @@ -99,7 +115,7 @@ jobs:
run: >
cmake -S . -B ./build
-DCMAKE_BUILD_TYPE:STRING=Release
-DINCLUDE_BACKEND:STRING=JavaScriptCore
-DINCLUDEJS_BACKEND:STRING=${{ matrix.platform.backend }}
-DINCLUDEJS_TESTS:BOOL=ON
-DINCLUDEJS_DOCS:BOOL=OFF
-DBUILD_SHARED_LIBS:BOOL=ON
Expand All @@ -109,10 +125,10 @@ jobs:
- run: cmake --build ./build --config Release --parallel 4
- run: >
cmake --install ./build --prefix ./build/dist --config Release --verbose
--component sourcemeta_includejs
--component includejs
- run: >
cmake --install ./build --prefix ./build/dist --config Release --verbose
--component sourcemeta_includejs_dev
--component includejs_dev
# Not every CTest version supports the --test-dir option. If such option
# is not recognized, `ctest` will successfully exit finding no tests.
Expand Down
1 change: 1 addition & 0 deletions Brewfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
brew "cmake"
brew "clang-format"
brew "doxygen"
brew "v8"
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
COMPONENT sourcemeta_includejs_dev)
COMPONENT includejs_dev)

if(INCLUDEJS_ENGINE)
add_subdirectory(src/engine)
Expand Down
2 changes: 1 addition & 1 deletion DEPENDENCIES
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
vendorpull https://github.com/sourcemeta/vendorpull 70342aaf458e6cb80baeb5b718901075fc42ede6
noa https://github.com/sourcemeta/noa 653bda26413812241e503fd0b550a66f2df4700f
noa https://github.com/sourcemeta/noa 9da0f1877859f60e439e31856cd4ef5fd4ca6063
googletest https://github.com/google/googletest 987e225614755fec7253aa95bf959c09e0d380d7
7 changes: 4 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ CTEST = ctest
# Options
PRESET = Debug
SHARED = OFF
BACKEND = JavaScriptCore

all: configure compile test

configure: .always
$(CMAKE) -S . -B ./build \
-DCMAKE_BUILD_TYPE:STRING=$(PRESET) \
-DCMAKE_COMPILE_WARNING_AS_ERROR:BOOL=ON \
-DINCLUDE_BACKEND:STRING=JavaScriptCore \
-DINCLUDEJS_BACKEND:STRING=$(BACKEND) \
-DINCLUDEJS_ENGINE:BOOL=ON \
-DINCLUDEJS_TESTS:BOOL=ON \
-DINCLUDEJS_DOCS:BOOL=ON \
Expand All @@ -22,9 +23,9 @@ compile: .always
$(CMAKE) --build ./build --config $(PRESET) --target clang_format
$(CMAKE) --build ./build --config $(PRESET) --parallel 4
$(CMAKE) --install ./build --prefix ./build/dist --config $(PRESET) --verbose \
--component sourcemeta_includejs
--component includejs
$(CMAKE) --install ./build --prefix ./build/dist --config $(PRESET) --verbose \
--component sourcemeta_includejs_dev
--component includejs_dev

lint: .always
$(CMAKE) --build ./build --config $(PRESET) --target clang_tidy
Expand Down
91 changes: 90 additions & 1 deletion README.markdown
Original file line number Diff line number Diff line change
@@ -1 +1,90 @@
![IncludeJS](./assets/banner.png)
<p align="center"><img src="./assets/banner.png" alt="includejs logo"/></p>
<h1 align="center">includejs</h1>
<h3 align="center">Build your own JavasScript runtime</h3>
<p align="center">
<a href="https://github.com/crossnx/includejs/actions/workflows/ci.yml"><img src="https://github.com/crossnx/includejs/actions/workflows/ci.yml/badge.svg" alt="github action build"></a>
</p>

<p align="center">
<img referrerpolicy="no-referrer-when-downgrade" src="https://static.scarf.sh/a.png?x-pxid=8107db3b-fcee-4af8-81f0-14e29ec04430" />
<a href="www.includejs.org/">📖 Documentation</a>
</p>

`includejs` offers a unified API for building your own JavaScript runtime, bridging multiple engines and platforms with ease.

## Example

In our journey to enhance `includejs`, we've also developed small - a minimalist, experimental runtime
aimed to provide ground for concepts and features we're considering for it.

Hosted on GitHub at [`crossnx/small`](https://github.com/crossnx/small).

## Features

- Multiple runtime support: `JavascriptCore`, `v8` (more in the furture)
- Cross platform support
- Direclty consumable from `CMake`

> 🤙 Stay tuned as we continue to expand our feature set.
### JavasScript

| Feature | JavaScriptCore | V8 |
|----------------|-------------------|------------------|
| Boolean | ✅ Supported | ❌ Not Supported |
| Number | ✅ Supported | ❌ Not Supported |
| String | ✅ Supported | ❌ Not Supported |
| Object | ✅ Supported | ❌ Not Supported |
| Array | ✅ Supported | ❌ Not Supported |
| Promise | ✅ Supported | ❌ Not Supported |
| Function | ✅ Supported | ❌ Not Supported |
| Error | ✅ Supported | ❌ Not Supported |
| Class | ❌ Not Supported | ❌ Not Supported |
| Set | ❌ Not Supported | ❌ Not Supported |
| Map | ❌ Not Supported | ❌ Not Supported |
| BigInt | ❌ Not Supported | ❌ Not Supported |
| Symbol | ❌ Not Supported | ❌ Not Supported |
| ArrayBuffer | ❌ Not Supported | ❌ Not Supported |
| TypedArray | ❌ Not Supported | ❌ Not Supported |

### WHATWG APIs

- [ ] Timers
- [ ] Console

### Platform support

| Platform | JavaScriptCore | V8 |
|-----------|-------------------|------------------|
| macOS | ✅ Supported | ✅ Supported |
| Linux | ✅ Supported | ✅ Supported |
| Windows | ❌ Not Supported | ❌ Not Supported |

## Dependencies

- C++
- CMake
- JavascriptCore
- Brew (macOS)

## Usage

You can consume `includejs` just with CMake:

```cmake
cmake_minimum_required(VERSION 3.18)
project(your_runtime VERSION 0.0.1 LANGUAGES CXX)
include(FetchContent)
FetchContent_Declare(
includejs
GIT_REPOSITORY https://github.com/crossnx/includejs
GIT_TAG main
DOWNLOAD_EXTRACT_TIMESTAMP NO)
FetchContent_MakeAvailable(includejs)
add_executable(your_runtime main.cc)
target_link_libraries(your_runtime PRIVATE includejs::engine)
```

Binary file modified assets/banner.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/logo.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 5b8aa1e

Please sign in to comment.