Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
  • Loading branch information
jviotti committed Feb 15, 2024
0 parents commit 1b174b3
Show file tree
Hide file tree
Showing 101 changed files with 32,378 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .ackrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
--ignore-dir=build
--ignore-dir=vendor
19 changes: 19 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# editorconfig.org
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[Makefile]
indent_style = tab

[*.mk]
indent_style = tab

[*.uk]
indent_style = tab
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/vendor/** linguist-generated=true
85 changes: 85 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: IncludeJS

on:
push:

jobs:
test:
strategy:
fail-fast: false
matrix:
platform:
# TODO: Build on more platforms
- os: macos-latest
cc: clang
cxx: clang++
type: static
- os: ubuntu-latest
cc: clang
cxx: clang++
type: static

# TODO: Build with sanitizers

runs-on: ${{ matrix.platform.os }}
env:
CC: ${{ matrix.platform.cc }}
CXX: ${{ matrix.platform.cxx }}
steps:
- name: Install dependencies (GNU/Linux)
if: runner.os == 'linux'
run: |
sudo apt-get update --yes
sudo apt-get install --yes clang-format libjavascriptcoregtk-4.0-dev
# See https://github.com/actions/runner-images/issues/8659
- name: Workaround Clang issue (GNU/Linux)
if: runner.os == 'linux' && matrix.platform.cc == 'clang'
run: |
sudo apt-get purge -y g++-13 gcc-13 libstdc++-13-dev
sudo apt-get install -y --allow-downgrades libstdc++-12-dev libstdc++6=12.* libgcc-s1=12.*
- uses: actions/checkout@v4
- name: Install dependencies (macOS)
if: runner.os == 'macos'
run: brew bundle
env:
HOMEBREW_NO_ANALYTICS: 1
HOMEBREW_NO_AUTO_UPDATE: 1
- run: cmake --version
- name: Configure IncludeJS (static)
if: matrix.platform.type == 'static'
run: >
cmake -S . -B ./build
-DCMAKE_BUILD_TYPE:STRING=Release
-DINCLUDEJS_TESTS:BOOL=ON
-DINCLUDEJS_DOCS:BOOL=OFF
-DBUILD_SHARED_LIBS:BOOL=OFF
-DCMAKE_COMPILE_WARNING_AS_ERROR:BOOL=ON
${{ matrix.platform.options }}
- name: Configure IncludeJS (shared)
if: matrix.platform.type == 'shared'
run: >
cmake -S . -B ./build
-DCMAKE_BUILD_TYPE:STRING=Release
-DINCLUDEJS_TESTS:BOOL=ON
-DINCLUDEJS_DOCS:BOOL=OFF
-DBUILD_SHARED_LIBS:BOOL=ON
-DCMAKE_COMPILE_WARNING_AS_ERROR:BOOL=ON
${{ matrix.platform.options }}
- run: cmake --build ./build --config Release --target clang_format_test
- run: cmake --build ./build --config Release --parallel 4
- run: >
cmake --install ./build --prefix ./build/dist --config Release --verbose
--component sourcemeta_includejs
- run: >
cmake --install ./build --prefix ./build/dist --config Release --verbose
--component sourcemeta_includejs_dev
# Not every CTest version supports the --test-dir option. If such option
# is not recognized, `ctest` will successfully exit finding no tests.
# Better to be sure and `cd` all the time here.
- run: cd ./build && ctest --build-config Release --output-on-failure --parallel
env:
# See https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html
UBSAN_OPTIONS: print_stacktrace=1
25 changes: 25 additions & 0 deletions .github/workflows/website-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: website
on:
push:
branches-ignore:
- main

concurrency:
group: website-build-${{ github.ref }}
cancel-in-progress: true

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- run: sudo apt update
- run: sudo apt install -y doxygen
- run: >
cmake -S . -B ./build
-DCMAKE_BUILD_TYPE:STRING=Release
-DINCLUDEJS_ENGINE:BOOL=OFF
-DINCLUDEJS_TESTS:BOOL=OFF
-DINCLUDEJS_DOCS:BOOL=ON
- run: cmake --build ./build --config Release --target doxygen
42 changes: 42 additions & 0 deletions .github/workflows/website-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: website
on:
push:
branches: [ "main" ]
workflow_dispatch:

permissions:
contents: read
pages: write
id-token: write

concurrency:
group: website-deploy-${{ github.ref }}
cancel-in-progress: true

jobs:
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- run: sudo apt update
- run: sudo apt install -y doxygen
- run: >
cmake -S . -B ./build
-DCMAKE_BUILD_TYPE:STRING=Release
-DINCLUDEJS_ENGINE:BOOL=OFF
-DINCLUDEJS_TESTS:BOOL=OFF
-DINCLUDEJS_DOCS:BOOL=ON
- run: cmake --build ./build --config Release --target doxygen
- name: Setup Pages
uses: actions/configure-pages@v1
- name: Upload artifact
uses: actions/upload-pages-artifact@v1
with:
path: ./build/website
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2
13 changes: 13 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
CMakeLists.txt.user
CMakeCache.txt
CMakeFiles
CMakeScripts
Testing
cmake_install.cmake
install_manifest.txt
compile_commands.json
CTestTestfile.cmake
_deps
/build
Brewfile.lock.json
.DS_Store
3 changes: 3 additions & 0 deletions Brewfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
brew "cmake"
brew "clang-format"
brew "doxygen"
5 changes: 5 additions & 0 deletions CHANGELOG.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Changelog
=========

This project adheres to [Semantic
Versioning](https://semver.org/spec/v2.0.0.html).
66 changes: 66 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
cmake_minimum_required(VERSION 3.24)
project(includejs VERSION 0.0.1 LANGUAGES C CXX
DESCRIPTION "Build your own JavaScript runtime"
HOMEPAGE_URL "https://www.includejs.org")
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
include(vendor/noa/cmake/noa.cmake)
include(cmake/CompilerOptions.cmake)

# Options
option(INCLUDEJS_ENGINE "Build the IncludeJS engine library" ON)
option(INCLUDEJS_TESTS "Build the IncludeJS tests" OFF)
option(INCLUDEJS_DOCS "Build the IncludeJS docs" OFF)
option(INCLUDEJS_INSTALL "Install the IncludeJS library" ON)
option(INCLUDEJS_ADDRESS_SANITIZER "Build IncludeJS with an address sanitizer" OFF)
option(INCLUDEJS_UNDEFINED_SANITIZER "Build IncludeJS with an undefined behavior sanitizer" OFF)

include(GNUInstallDirs)
include(CMakePackageConfigHelpers)
configure_package_config_file(
config.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake"
INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake"
COMPATIBILITY SameMajorVersion)
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)

if(INCLUDEJS_ENGINE)
find_package(JavaScriptCore REQUIRED)
add_subdirectory(src/engine)
endif()

if(INCLUDEJS_ADDRESS_SANITIZER)
noa_sanitizer(TYPE address)
elseif(INCLUDEJS_UNDEFINED_SANITIZER)
noa_sanitizer(TYPE undefined)
endif()

if(INCLUDEJS_DOCS)
noa_target_doxygen(CONFIG "${PROJECT_SOURCE_DIR}/doxygen/Doxyfile.in"
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/website")
endif()

if(PROJECT_IS_TOP_LEVEL)
noa_target_clang_format(SOURCES
src/*.h src/*.cc
test/*.h test/*.cc)
noa_target_clang_tidy(SOURCES
src/*.h src/*.cc)
endif()

# Testing
if(INCLUDEJS_TESTS)
find_package(GoogleTest REQUIRED)
enable_testing()

if(INCLUDEJS_ENGINE)
add_subdirectory(test/engine)
endif()

# TODO: Add packaging tests
endif()
3 changes: 3 additions & 0 deletions DEPENDENCIES
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
vendorpull https://github.com/sourcemeta/vendorpull 70342aaf458e6cb80baeb5b718901075fc42ede6
noa https://github.com/sourcemeta/noa 653bda26413812241e503fd0b550a66f2df4700f
googletest https://github.com/google/googletest 987e225614755fec7253aa95bf959c09e0d380d7
Loading

0 comments on commit 1b174b3

Please sign in to comment.