|
| 1 | +#!/bin/bash -eu |
| 2 | +# Copyright 2025 Google LLC |
| 3 | +# |
| 4 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +# you may not use this file except in compliance with the License. |
| 6 | +# You may obtain a copy of the License at |
| 7 | +# |
| 8 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +# |
| 10 | +# Unless required by applicable law or agreed to in writing, software |
| 11 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +# See the License for the specific language governing permissions and |
| 14 | +# limitations under the License. |
| 15 | +# |
| 16 | +################################################################################ |
| 17 | + |
| 18 | +apt-get update |
| 19 | +apt-get install -y build-essential ninja-build cmake make \ |
| 20 | + zlib1g-dev libreadline-dev libunwind-dev |
| 21 | + |
| 22 | +: ${LD:="${CXX}"} |
| 23 | +: ${LDFLAGS:="${CXXFLAGS}"} # to make sure we link with sanitizer runtime |
| 24 | + |
| 25 | +patch -p1 < lua-c-api-tests/patches/luajit-v2.1.patch |
| 26 | + |
| 27 | +# Build the target project. |
| 28 | +make CC="${CC}" CFLAGS="${CFLAGS} -DLUAJIT_USE_ASAN -DLUA_USE_ASSERT -DLUA_USE_APICHECK" \ |
| 29 | + LDFLAGS="${LDFLAGS}" HOST_CFLAGS=-fno-sanitize=undefined -C src |
| 30 | +LUA_LIBRARIES=$(realpath ./src/libluajit.a) |
| 31 | +LUA_INCLUDE_DIR=$(realpath ./src/) |
| 32 | +LUA_EXECUTABLE=$(realpath ./src/luajit) |
| 33 | + |
| 34 | +# Build the tests. |
| 35 | +cd lua-c-api-tests |
| 36 | +cmake -S . -B build -DCMAKE_C_COMPILER="${CC}" \ |
| 37 | + -DCMAKE_CXX_COMPILER="${CXX}" \ |
| 38 | + -DIS_LUAJIT=TRUE \ |
| 39 | + -DLUA_INCLUDE_DIR="${LUA_INCLUDE_DIR}" \ |
| 40 | + -DLUA_LIBRARIES="${LUA_LIBRARIES}" \ |
| 41 | + -DLUA_EXECUTABLE="${LUA_EXECUTABLE}" \ |
| 42 | + -DLUA_VERSION_STRING=\"luajit2\" |
| 43 | +cmake --build build --parallel |
| 44 | + |
| 45 | +for f in $(find build/tests/ -name '*_test' -type f); |
| 46 | +do |
| 47 | + cp $f $OUT/ |
| 48 | +done |
0 commit comments