Skip to content

Commit d7cf8ba

Browse files
committed
Initial commit
Signed-off-by: Juan Cruz Viotti <[email protected]>
0 parents  commit d7cf8ba

File tree

101 files changed

+32466
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+32466
-0
lines changed

.ackrc

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
--ignore-dir=build
2+
--ignore-dir=vendor

.editorconfig

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# editorconfig.org
2+
root = true
3+
4+
[*]
5+
indent_style = space
6+
indent_size = 2
7+
end_of_line = lf
8+
charset = utf-8
9+
trim_trailing_whitespace = true
10+
insert_final_newline = true
11+
12+
[Makefile]
13+
indent_style = tab
14+
15+
[*.mk]
16+
indent_style = tab
17+
18+
[*.uk]
19+
indent_style = tab

.gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/vendor/** linguist-generated=true

.github/workflows/ci.yml

+85
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
name: IncludeJS
2+
3+
on:
4+
push:
5+
6+
jobs:
7+
test:
8+
strategy:
9+
fail-fast: false
10+
matrix:
11+
platform:
12+
# TODO: Build on more platforms
13+
- os: macos-latest
14+
cc: clang
15+
cxx: clang++
16+
type: static
17+
- os: ubuntu-latest
18+
cc: clang
19+
cxx: clang++
20+
type: static
21+
22+
# TODO: Build with sanitizers
23+
24+
runs-on: ${{ matrix.platform.os }}
25+
env:
26+
CC: ${{ matrix.platform.cc }}
27+
CXX: ${{ matrix.platform.cxx }}
28+
steps:
29+
- name: Install dependencies (GNU/Linux)
30+
if: runner.os == 'linux'
31+
run: |
32+
sudo apt-get update --yes
33+
sudo apt-get install --yes clang-format libjavascriptcoregtk-4.0-dev
34+
35+
# See https://github.com/actions/runner-images/issues/8659
36+
- name: Workaround Clang issue (GNU/Linux)
37+
if: runner.os == 'linux' && matrix.platform.cc == 'clang'
38+
run: |
39+
sudo apt-get purge -y g++-13 gcc-13 libstdc++-13-dev
40+
sudo apt-get install -y --allow-downgrades libstdc++-12-dev libstdc++6=12.* libgcc-s1=12.*
41+
42+
- uses: actions/checkout@v4
43+
- name: Install dependencies (macOS)
44+
if: runner.os == 'macos'
45+
run: brew bundle
46+
env:
47+
HOMEBREW_NO_ANALYTICS: 1
48+
HOMEBREW_NO_AUTO_UPDATE: 1
49+
- run: cmake --version
50+
- name: Configure IncludeJS (static)
51+
if: matrix.platform.type == 'static'
52+
run: >
53+
cmake -S . -B ./build
54+
-DCMAKE_BUILD_TYPE:STRING=Release
55+
-DINCLUDEJS_TESTS:BOOL=ON
56+
-DINCLUDEJS_DOCS:BOOL=OFF
57+
-DBUILD_SHARED_LIBS:BOOL=OFF
58+
-DCMAKE_COMPILE_WARNING_AS_ERROR:BOOL=ON
59+
${{ matrix.platform.options }}
60+
- name: Configure IncludeJS (shared)
61+
if: matrix.platform.type == 'shared'
62+
run: >
63+
cmake -S . -B ./build
64+
-DCMAKE_BUILD_TYPE:STRING=Release
65+
-DINCLUDEJS_TESTS:BOOL=ON
66+
-DINCLUDEJS_DOCS:BOOL=OFF
67+
-DBUILD_SHARED_LIBS:BOOL=ON
68+
-DCMAKE_COMPILE_WARNING_AS_ERROR:BOOL=ON
69+
${{ matrix.platform.options }}
70+
- run: cmake --build ./build --config Release --target clang_format_test
71+
- run: cmake --build ./build --config Release --parallel 4
72+
- run: >
73+
cmake --install ./build --prefix ./build/dist --config Release --verbose
74+
--component sourcemeta_includejs
75+
- run: >
76+
cmake --install ./build --prefix ./build/dist --config Release --verbose
77+
--component sourcemeta_includejs_dev
78+
79+
# Not every CTest version supports the --test-dir option. If such option
80+
# is not recognized, `ctest` will successfully exit finding no tests.
81+
# Better to be sure and `cd` all the time here.
82+
- run: cd ./build && ctest --build-config Release --output-on-failure --parallel
83+
env:
84+
# See https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html
85+
UBSAN_OPTIONS: print_stacktrace=1

.github/workflows/website-build.yml

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: website
2+
on:
3+
push:
4+
branches-ignore:
5+
- main
6+
7+
concurrency:
8+
group: website-build-${{ github.ref }}
9+
cancel-in-progress: true
10+
11+
jobs:
12+
build:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v4
17+
- run: sudo apt update
18+
- run: sudo apt install -y doxygen
19+
- run: >
20+
cmake -S . -B ./build
21+
-DCMAKE_BUILD_TYPE:STRING=Release
22+
-DINCLUDEJS_ENGINE:BOOL=OFF
23+
-DINCLUDEJS_TESTS:BOOL=OFF
24+
-DINCLUDEJS_DOCS:BOOL=ON
25+
- run: cmake --build ./build --config Release --target doxygen

.github/workflows/website-deploy.yml

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: website
2+
on:
3+
push:
4+
branches: [ "main" ]
5+
workflow_dispatch:
6+
7+
permissions:
8+
contents: read
9+
pages: write
10+
id-token: write
11+
12+
concurrency:
13+
group: website-deploy-${{ github.ref }}
14+
cancel-in-progress: true
15+
16+
jobs:
17+
deploy:
18+
environment:
19+
name: github-pages
20+
url: ${{ steps.deployment.outputs.page_url }}
21+
runs-on: ubuntu-latest
22+
steps:
23+
- name: Checkout
24+
uses: actions/checkout@v4
25+
- run: sudo apt update
26+
- run: sudo apt install -y doxygen
27+
- run: >
28+
cmake -S . -B ./build
29+
-DCMAKE_BUILD_TYPE:STRING=Release
30+
-DINCLUDEJS_ENGINE:BOOL=OFF
31+
-DINCLUDEJS_TESTS:BOOL=OFF
32+
-DINCLUDEJS_DOCS:BOOL=ON
33+
- run: cmake --build ./build --config Release --target doxygen
34+
- name: Setup Pages
35+
uses: actions/configure-pages@v1
36+
- name: Upload artifact
37+
uses: actions/upload-pages-artifact@v1
38+
with:
39+
path: ./build/website
40+
- name: Deploy to GitHub Pages
41+
id: deployment
42+
uses: actions/deploy-pages@v2

.gitignore

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
CMakeLists.txt.user
2+
CMakeCache.txt
3+
CMakeFiles
4+
CMakeScripts
5+
Testing
6+
cmake_install.cmake
7+
install_manifest.txt
8+
compile_commands.json
9+
CTestTestfile.cmake
10+
_deps
11+
/build
12+
Brewfile.lock.json
13+
.DS_Store

Brewfile

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
brew "cmake"
2+
brew "clang-format"
3+
brew "doxygen"

CHANGELOG.markdown

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Changelog
2+
=========
3+
4+
This project adheres to [Semantic
5+
Versioning](https://semver.org/spec/v2.0.0.html).

CMakeLists.txt

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
cmake_minimum_required(VERSION 3.24)
2+
project(includejs VERSION 0.0.1 LANGUAGES C CXX
3+
DESCRIPTION "Build your own JavaScript runtime"
4+
HOMEPAGE_URL "https://www.includejs.org")
5+
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
6+
include(vendor/noa/cmake/noa.cmake)
7+
include(cmake/CompilerOptions.cmake)
8+
9+
# Options
10+
option(INCLUDEJS_ENGINE "Build the IncludeJS engine library" ON)
11+
option(INCLUDEJS_TESTS "Build the IncludeJS tests" OFF)
12+
option(INCLUDEJS_DOCS "Build the IncludeJS docs" OFF)
13+
option(INCLUDEJS_INSTALL "Install the IncludeJS library" ON)
14+
option(INCLUDEJS_ADDRESS_SANITIZER "Build IncludeJS with an address sanitizer" OFF)
15+
option(INCLUDEJS_UNDEFINED_SANITIZER "Build IncludeJS with an undefined behavior sanitizer" OFF)
16+
17+
include(GNUInstallDirs)
18+
include(CMakePackageConfigHelpers)
19+
configure_package_config_file(
20+
config.cmake.in
21+
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake"
22+
INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
23+
write_basic_package_version_file(
24+
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake"
25+
COMPATIBILITY SameMajorVersion)
26+
install(FILES
27+
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake"
28+
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake"
29+
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
30+
COMPONENT sourcemeta_includejs_dev)
31+
32+
if(INCLUDEJS_ENGINE)
33+
find_package(JavaScriptCore REQUIRED)
34+
add_subdirectory(src/engine)
35+
endif()
36+
37+
if(INCLUDEJS_ADDRESS_SANITIZER)
38+
noa_sanitizer(TYPE address)
39+
elseif(INCLUDEJS_UNDEFINED_SANITIZER)
40+
noa_sanitizer(TYPE undefined)
41+
endif()
42+
43+
if(INCLUDEJS_DOCS)
44+
noa_target_doxygen(CONFIG "${PROJECT_SOURCE_DIR}/doxygen/Doxyfile.in"
45+
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/website")
46+
endif()
47+
48+
if(PROJECT_IS_TOP_LEVEL)
49+
noa_target_clang_format(SOURCES
50+
src/*.h src/*.cc
51+
test/*.h test/*.cc)
52+
noa_target_clang_tidy(SOURCES
53+
src/*.h src/*.cc)
54+
endif()
55+
56+
# Testing
57+
if(INCLUDEJS_TESTS)
58+
find_package(GoogleTest REQUIRED)
59+
enable_testing()
60+
61+
if(INCLUDEJS_ENGINE)
62+
add_subdirectory(test/engine)
63+
endif()
64+
65+
# TODO: Add packaging tests
66+
endif()

DEPENDENCIES

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
vendorpull https://github.com/sourcemeta/vendorpull 70342aaf458e6cb80baeb5b718901075fc42ede6
2+
noa https://github.com/sourcemeta/noa 653bda26413812241e503fd0b550a66f2df4700f
3+
googletest https://github.com/google/googletest 987e225614755fec7253aa95bf959c09e0d380d7

0 commit comments

Comments
 (0)