22set -euo pipefail
33IFS=$' \n\t '
44
5- # set git hooks
6- ln -s -f ../../githooks/pre-commit .git/hooks/pre-commit
7- # set blame ignore file
8- git config blame.ignorerevsfile .git-blame-ignore-revs
9-
105# Get number of CPU cores
116CPUS=$( getconf _NPROCESSORS_ONLN 2> /dev/null || getconf NPROCESSORS_ONLN 2> /dev/null || echo 1)
127
@@ -17,11 +12,12 @@ if [[ "$OSTYPE" == "linux-gnu"* ]]; then # Linux
1712 # sudo is present on the system, so use it
1813 SUDO=' sudo'
1914 fi
20- $SUDO apt-get update --yes
15+ echo " Installing apt packages "
2116 $SUDO apt-get install --yes cmake graphviz llvm clang pkg-config m4 unzip \
22- wget curl python3-distutils python3- dev
17+ wget curl python3-dev
2318 # Install Doxygen
2419 # the newest version in Ubuntu 20.04 repository is 1.8.17, but we need Doxygen 1.9 series
20+ echo " Installing doxygen"
2521 wget -c -q https://www.doxygen.nl/files/doxygen-1.9.7.linux.bin.tar.gz
2622 tar xf doxygen-1.9.7.linux.bin.tar.gz
2723 cd doxygen-1.9.7 && $SUDO make install && cd -
3632 exit 1
3733fi
3834# Install rust compiler
35+ echo " Installing rust compiler"
3936curl --proto ' =https' --tlsv1.2 https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain 1.76
4037cargo install cbindgen
4138# Setup Poetry
39+ echo " Installing poetry"
4240curl -sSL https://install.python-poetry.org | python3 - --version " 1.7.1"
4341if [[ " $OSTYPE " == " msys" * ]]; then # Windows
4442 POETRY_BIN=" $APPDATA /Python/Scripts/poetry"
4543else
4644 POETRY_BIN=` echo ~ /.local/bin/poetry` # expand tilde
4745fi
4846$POETRY_BIN self add ' poetry-dynamic-versioning[plugin]'
49- $POETRY_BIN run pip install autopep8
5047echo " Done installing dependencies"
5148
52- echo " Downloading uncrustify source code"
53- wget -c -q https://github.com/uncrustify/uncrustify/archive/refs/tags/uncrustify-0.78.1.tar.gz
54- mkdir -p uncrustify-source
55- tar -xzf uncrustify-0.78.1.tar.gz -C uncrustify-source --strip-components=1 # strip the root folder
56- echo " Done downloading uncrustify source code"
57-
58- echo " Building uncrustify"
59- cd uncrustify-source
60- mkdir -p build
61- cd build
62- if [[ " $OSTYPE " == " msys" * ]]; then # Windows
63- cmake ../
64- cmake --build . -j$CPUS --config Release
65- cp Release/uncrustify.exe ../../uncrustify.exe
66- else
67- cmake ../
68- make -j$CPUS
69- cp uncrustify ../../uncrustify
70- fi
71- cd ../..
72- echo " Done building uncrustify"
73-
7449echo " Downloading spidermonkey source code"
7550# Read the commit hash for mozilla-central from the `mozcentral.version` file
7651MOZCENTRAL_VERSION=$( cat mozcentral.version)
@@ -118,3 +93,35 @@ if [[ "$OSTYPE" == "darwin"* ]]; then # macOS
11893 install_name_tool -id @rpath/$( basename ./libmozjs* ) ./libmozjs* # making it work for whatever name the libmozjs dylib is called
11994fi
12095echo " Done installing spidermonkey"
96+
97+ # if this is being ran in the root directory of the PythonMonkey repo, then include dev configurations
98+ if test -f .git/hooks/pre-commit; then
99+ # set git hooks
100+ ln -s -f ../../githooks/pre-commit .git/hooks/pre-commit
101+ # set blame ignore file
102+ git config blame.ignorerevsfile .git-blame-ignore-revs
103+ # install autopep8
104+ $POETRY_BIN run pip install autopep8
105+ # install uncrustify
106+ echo " Downloading uncrustify source code"
107+ wget -c -q https://github.com/uncrustify/uncrustify/archive/refs/tags/uncrustify-0.78.1.tar.gz
108+ mkdir -p uncrustify-source
109+ tar -xzf uncrustify-0.78.1.tar.gz -C uncrustify-source --strip-components=1 # strip the root folder
110+ echo " Done downloading uncrustify source code"
111+
112+ echo " Building uncrustify"
113+ cd uncrustify-source
114+ mkdir -p build
115+ cd build
116+ if [[ " $OSTYPE " == " msys" * ]]; then # Windows
117+ cmake ../
118+ cmake --build . -j$CPUS --config Release
119+ cp Release/uncrustify.exe ../../uncrustify.exe
120+ else
121+ cmake ../
122+ make -j$CPUS
123+ cp uncrustify ../../uncrustify
124+ fi
125+ cd ../..
126+ echo " Done building uncrustify"
127+ fi
0 commit comments