Revamp the build system.

This achieves several goals:

 * Less reliance on scripts so we have better portability to Windows
   (though we still have a ways to go for proper Windows support).
   Luajit, luarocks, moonscript, and busted are all installed via CMake
   now.
 * Trying to make use of pkg-config to get the correct libraries.  The
   latest libuv is still broken in this regard, but we'll at least be in
   a position to use it.
 * Allow the use of Ninja or make.  The former runs faster in many
   environments, and automatically makes use of parallel builds.

This also allows for system installed dependencies--though not through
the Makefile just yet--and adds support for FreeBSD.

This also make us build libuv and luajit as static libraries only, since
we're only concerned about having static libraries for our bundled
dependencies.
This commit is contained in:
John Szakmeister
2014-03-03 10:09:06 -05:00
parent 5dd0ce4263
commit 0b2f6a0cf4
449 changed files with 391 additions and 182056 deletions

View File

@@ -1,65 +0,0 @@
platform='unknown'
unameval=`uname`
if [ "$unameval" = 'Linux' ]; then
platform='linux'
elif [ "$unameval" = 'FreeBSD' ]; then
platform='freebsd'
elif [ "$unameval" = 'Darwin' ]; then
platform='darwin'
fi
sha1sumcmd='sha1sum'
if [ "$platform" = 'freebsd' ]; then
sha1sumcmd='shasum'
elif [ "$platform" = 'darwin' ]; then
sha1sumcmd='shasum'
fi
pkgroot="$(pwd)"
deps="$pkgroot/.deps"
prefix="$deps/usr"
export PATH="$prefix/bin:$PATH"
download() {
local url=$1
local tgt=$2
local sha1=$3
if [ ! -d "$tgt" ]; then
mkdir -p "$tgt"
local download_command=""
if which wget > /dev/null 2>&1; then
# -O - to send output to stdout
download_command="wget --no-verbose $url -O -"
elif which curl >/dev/null 2>&1; then
# -L to follow the redirects that github will send us
# -sS to supress the progress bar, but show errors
# curl sends output to stdout by default
download_command="curl -L -sS $url"
else
echo "Missing wget utility and curl utility"
exit 1
fi
local tmp_dir=$(mktemp -d "/tmp/download_sha1check_XXXXXXX")
local fifo="$tmp_dir/fifo"
mkfifo "$fifo"
echo "Downloading $url..."
# download, untar and calculate sha1 sum in one pass
($download_command | tee "$fifo" | \
(cd "$tgt"; tar --strip-components=1 -xzf -)) &
local sum=$("$sha1sumcmd" < "$fifo" | cut -d ' ' -f1)
rm -rf "$tmp_dir"
if [ "$sum" != "$sha1" ]; then
echo "SHA1 sum doesn't match, expected '$sha1' got '$sum'"
exit 1
else
echo "Download complete."
fi
fi
}
github_download() {
local repo=$1
local ver=$2
download "https://github.com/${repo}/archive/${ver}.tar.gz" "$3" "$4"
}

View File

@@ -1,10 +0,0 @@
. scripts/common.sh
uv_dir="third-party/libuv"
cd "$uv_dir"
sh autogen.sh
./configure --prefix="$prefix" --with-pic
make
make install
rm "$prefix/lib/"libuv*.{so,dylib} "$prefix/lib/"libuv*.{so,dylib}.* || true

View File

@@ -1,6 +0,0 @@
. scripts/common.sh
lua_dir="$pkgroot/third-party/luajit"
cd "$lua_dir"
make PREFIX="$prefix" install

View File

@@ -1,26 +0,0 @@
. scripts/common.sh
luarocks_ver=v2.1.2
luarocks_repo=keplerproject/luarocks
luarocks_sha1=69ea9b641a5066b1f316847494d8c63a4693977d
luarocks_dir="$pkgroot/third-party/luarocks"
github_download "$luarocks_repo" "$luarocks_ver" "$luarocks_dir" \
"$luarocks_sha1"
cd "$luarocks_dir"
./configure --prefix="$prefix" --force-config --with-lua="$prefix" \
--with-lua-include="$prefix/include/luajit-2.0" \
--lua-suffix="jit"
make bootstrap
echo 'rocks_servers = {
"http://luarocks.giga.puc-rio.br/";
}' >> "$prefix/etc/luarocks/config-5.1.lua"
# install tools for testing
luarocks install moonrocks --server=http://rocks.moonscript.org
moonrocks install moonscript
moonrocks install busted

View File

@@ -17,6 +17,14 @@ check_and_report() {
)
}
# Travis reports back that it has 32-cores via /proc/cpuinfo, but it's not
# what we really have available. According to their documentation, it only has
# 1.5 virtual cores.
# See:
# http://docs.travis-ci.com/user/speeding-up-the-build/#Paralellizing-your-build-on-one-VM
# for more information.
alias make="make -j2"
if [ "$CC" = "clang" ]; then
# force using the version installed by 'travis-setup.sh'
export CC=/usr/bin/clang
@@ -46,9 +54,8 @@ if [ "$CC" = "clang" ]; then
check_and_report
make install
else
export BUSTED_OUTPUT_TYPE="TAP"
export SKIP_EXEC=1
make CMAKE_EXTRA_FLAGS="-DBUSTED_OUTPUT_TYPE=TAP"
make cmake
make unittest
fi

View File

@@ -1,10 +0,0 @@
. scripts/common.sh
(cd "$pkgroot/build" && make) || exit 1
eval "$(luarocks path)"
if [ -z "$BUSTED_OUTPUT_TYPE" ]; then
export BUSTED_OUTPUT_TYPE="utf_terminal"
fi
make -C ./test/includes
busted --pattern=.moon -o $BUSTED_OUTPUT_TYPE ./test