Skip to content
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
32 changes: 3 additions & 29 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,40 +30,14 @@ jobs:
path: |
./build/*
./firefox-102.2.0/*
./_spidermonkey_install/*
key: ${{ runner.os }}-spidermonkey
- name: Build-Library
if: ${{ steps.cache-spidermonkey.outputs.cache-hit != 'true' }}
run: |
# Get number of CPU cores
CPUS=$(getconf _NPROCESSORS_ONLN 2>/dev/null || getconf NPROCESSORS_ONLN 2>/dev/null || echo 1)
echo "Building SpiderMonkey"
#install rust compiler
curl --proto '=https' --tlsv1.3 https://sh.rustup.rs -sSf | sh -s -- -y
wget -q https://ftp.mozilla.org/pub/firefox/releases/102.2.0esr/source/firefox-102.2.0esr.source.tar.xz
tar xf firefox-102.2.0esr.source.tar.xz
cd firefox-102.2.0/js
sed -i 's/bool Unbox/JS_PUBLIC_API bool Unbox/g' ./public/Class.h # need to manually add JS_PUBLIC_API to js::Unbox until it gets fixed in Spidermonkey
sed -i 's/bool js::Unbox/JS_PUBLIC_API bool js::Unbox/g' ./src/vm/JSObject.cpp # same here
cd src
cp ./configure.in ./configure
chmod +x ./configure
mkdir _build
cd _build
../configure --disable-jemalloc --with-system-zlib --with-intl-api --enable-optimize
make -j$CPUS
sudo make install
cd ../../../..
echo "Building the library"
mkdir build
cd build
cmake ..
cmake --build . -j$CPUS
echo "Build complete"
run: ./setup.sh && ./build_script.sh
- name: google-tests
run: |
cd firefox-102.2.0/js/src/_build
sudo make install
cd ../../../../build
cd build
make && make tests
gcovr --xml-pretty --exclude-unreachable-branches --print-summary -o coverage.xml
cd tests && ctest
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ firefox-*/
tests/__pycache__/*
tests/python/__pycache__/*
Testing/Temporary
_spidermonkey_install
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
elseif(WIN32)
find_package(PythonInterp 3.9...3.11 REQUIRED)
find_package(PythonLibs 3.9...3.11 REQUIRED)
find_package(SpiderMonkey REQUIRED)
find_package(SpiderMonkey REQUIRED)
set(PYTHONLIBS_VERSION_STRING $ENV{PY_VERSION})
endif()
include_directories(${PYTHON_INCLUDE_DIRS})
Expand All @@ -94,4 +94,4 @@ add_subdirectory(src)

pythonmonkey_add_external("uncrustify")
pythonmonkey_add_external("autopep8")
add_subdirectory(format)
add_subdirectory(format)
17 changes: 10 additions & 7 deletions cmake/modules/FindSpiderMonkey.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ endif()

# SpiderMonkey search paths
set(SPIDERMONKEY_PATHS
${SPIDERMONKEY_ROOT}
"${CMAKE_CURRENT_SOURCE_DIR}/_spidermonkey_install"
"${CMAKE_CURRENT_SOURCE_DIR}/_spidermonkey_install/lib"
${SPIDERMONKEY_ROOT}
$ENV{SPIDERMONKEY_ROOT}
~/Library/Frameworks
/Library/Frameworks
Expand All @@ -60,11 +62,12 @@ set(SPIDERMONKEY_HEADERS jsapi.h js/RequiredDefines.h)
set(SPIDERMONKEY_INCLUDE_SUFFIX_PATHS dist/include js/src include include/js include/mozjs-48a1 include/mozjs-102/)

# Find SpiderMonkey include path
find_path(SPIDERMONKEY_INCLUDE_DIR ${SPIDERMONKEY_HEADERS}
PATHS ${SPIDERMONKEY_PATHS}
PATH_SUFFIXES ${SPIDERMONKEY_INCLUDE_SUFFIX_PATHS}
DOC "Mozilla SpiderMonkey JavaScript Engine Headers"
)
find_path(SPIDERMONKEY_INCLUDE_DIR ${SPIDERMONKEY_HEADERS}
PATHS ${SPIDERMONKEY_PATHS}
PATH_SUFFIXES ${SPIDERMONKEY_INCLUDE_SUFFIX_PATHS}
DOC "Mozilla SpiderMonkey JavaScript Engine Headers"
NO_DEFAULT_PATH
)

# SpiderMonkey libs
set(SPIDERMONKEY_LIBRARY_NAMES mozjs-107a1.lib libmozjs-102.so mozjs185 mozjs-1.9.2 mozjs-48a1 mozjs js185 js js32 js3250)
Expand Down Expand Up @@ -154,4 +157,4 @@ list(REMOVE_ITEM CMAKE_REQUIRED_LIBRARIES ${SPIDERMONKEY_LIBRARY})
list(REMOVE_DUPLICATES CMAKE_REQUIRED_LIBRARIES)

mark_as_advanced(SPIDERMONKEY_INCLUDE_DIR SPIDERMONKEY_LIBRARY)
mark_as_advanced(SPIDERMONKEY_JS_CONFIG_HEADER_PATH)
mark_as_advanced(SPIDERMONKEY_JS_CONFIG_HEADER_PATH)
25 changes: 21 additions & 4 deletions setup.sh
Original file line number Diff line number Diff line change
@@ -1,20 +1,37 @@
#!/bin/bash
set -euo pipefail
IFS=$'\n\t'


# Get number of CPU cores
CPUS=$(getconf _NPROCESSORS_ONLN 2>/dev/null || getconf NPROCESSORS_ONLN 2>/dev/null || echo 1)

echo "Installing dependencies"
sudo apt-get update --yes
sudo apt-get upgrade --yes
sudo apt-get install cmake python3-dev python3-pytest doxygen graphviz gcovr llvm g++ pkg-config m4 --yes
sudo curl --proto '=https' --tlsv1.3 https://sh.rustup.rs -sSf | sh -s -- -y #install rust compiler
wget -q https://ftp.mozilla.org/pub/firefox/releases/102.2.0esr/source/firefox-102.2.0esr.source.tar.xz
echo "Done installing dependencies"

echo "Downloading spidermonkey source code"
wget -c -q https://ftp.mozilla.org/pub/firefox/releases/102.2.0esr/source/firefox-102.2.0esr.source.tar.xz
tar xf firefox-102.2.0esr.source.tar.xz
echo "Done downloading spidermonkey source code"

echo "Building spidermonkey"
cd firefox-102.2.0/js
sed -i 's/bool Unbox/JS_PUBLIC_API bool Unbox/g' ./public/Class.h # need to manually add JS_PUBLIC_API to js::Unbox until it gets fixed in Spidermonkey
sed -i 's/bool js::Unbox/JS_PUBLIC_API bool js::Unbox/g' ./src/vm/JSObject.cpp # same here
cd src
cp ./configure.in ./configure
chmod +x ./configure
mkdir _build
mkdir -p _build
cd _build
../configure --disable-jemalloc --with-system-zlib --with-intl-api --enable-optimize
../configure --disable-jemalloc --with-system-zlib --with-intl-api --enable-optimize --prefix=$(realpath $PWD/../../../../_spidermonkey_install)
make -j$CPUS
sudo make install
echo "Done building spidermonkey"

echo "Installing spidermonkey"
mkdir -p ../../../../_spidermonkey_install/
make install
echo "Done installing spidermonkey"