diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml new file mode 100644 index 00000000..6665cdea --- /dev/null +++ b/.github/workflows/cmake.yml @@ -0,0 +1,32 @@ +name: CMake + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + build: + runs-on: ${{ matrix.os }} + strategy: + # Don't cancel the macOS build if the Linux build fails, etc. + fail-fast: false + matrix: + os: [ubuntu-18.04, macos-10.15] + + steps: + - uses: actions/checkout@v2 + with: + submodules: 'recursive' + + - name: Linux Build + if: runner.os == 'Linux' + run: | + sudo apt install -y groff + ./build-linux-64.sh + + - name: macOS Build + if: runner.os == 'macOS' + run: | + ./build-osx.sh diff --git a/bsputil/bsputil.cc b/bsputil/bsputil.cc index 4ce08b44..926b2c07 100644 --- a/bsputil/bsputil.cc +++ b/bsputil/bsputil.cc @@ -593,11 +593,12 @@ main(int argc, char **argv) WriteBSPFile(source, &bspdata); } else if (!strcmp(argv[i], "--extract-entities")) { + unsigned int crc = CRC_Block((unsigned char *)bsp->dentdata, bsp->entdatasize - 1); StripExtension(source); DefaultExtension(source, ".ent"); - printf("-> writing %s... ", source); + printf("-> writing %s [CRC: %04x]... ", source, crc); - f = fopen(source, "w"); + f = fopen(source, "wb"); if (!f) Error("couldn't open %s for writing\n", source); diff --git a/build-linux-64.sh b/build-linux-64.sh index b6dcdc08..5b0a9828 100755 --- a/build-linux-64.sh +++ b/build-linux-64.sh @@ -1,6 +1,6 @@ #!/bin/bash -BUILD_DIR=build +BUILD_DIR=build-linux if [ -d "$BUILD_DIR" ]; then echo "$BUILD_DIR already exists, remove it first" @@ -11,15 +11,20 @@ cmake --version mkdir "$BUILD_DIR" cd "$BUILD_DIR" -wget https://github.com/embree/embree/releases/download/v2.17.7/embree-2.17.7.x86_64.linux.tar.gz -O embree.tgz -wget https://github.com/intel/tbb/releases/download/2017_U7/tbb2017_20170604oss_lin.tgz -O tbb.tgz +wget -q https://github.com/embree/embree/releases/download/v3.13.1/embree-3.13.1.x86_64.linux.tar.gz -O embree.tgz +wget -q https://github.com/oneapi-src/oneTBB/releases/download/v2021.3.0/oneapi-tbb-2021.3.0-lin.tgz -O tbb.tgz + tar xf embree.tgz tar xf tbb.tgz -cmake .. -DCMAKE_BUILD_TYPE=Release -Dembree_DIR="$(pwd)/embree-2.17.7.x86_64.linux" -DTBB_DIR="$(pwd)/tbb2017_20170604oss/cmake" -make -j8 VERBOSE=1 -make -j8 VERBOSE=1 testlight -make -j8 VERBOSE=1 testqbsp -cpack + +EMBREE_CMAKE_DIR="$(pwd)/embree-3.13.1.x86_64.linux/lib/cmake/embree-3.13.1" +TBB_CMAKE_DIR="$(pwd)/oneapi-tbb-2021.3.0/lib/cmake" + +cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="$EMBREE_CMAKE_DIR;$TBB_CMAKE_DIR" +make -j8 VERBOSE=1 || exit 1 +make -j8 VERBOSE=1 testlight || exit 1 +make -j8 VERBOSE=1 testqbsp || exit 1 +cpack || exit 1 # run tests ./light/testlight || exit 1 diff --git a/build-osx.sh b/build-osx.sh index ebaa992f..f26104ed 100755 --- a/build-osx.sh +++ b/build-osx.sh @@ -1,14 +1,17 @@ #!/bin/bash BUILD_DIR=build-osx -EMBREE_TGZ="https://github.com/embree/embree/releases/download/v2.17.7/embree-2.17.7.x86_64.macosx.tar.gz" -EMBREE_TGZ_NAME=$(basename "$EMBREE_TGZ") -EMBREE_DIR_NAME=$(basename "$EMBREE_TGZ" ".tar.gz") -EMBREE_WITH_VERSION=$(basename "$EMBREE_TGZ" ".x86_64.macosx.tar.gz") +EMBREE_ZIP="https://github.com/embree/embree/releases/download/v3.13.0/embree-3.13.0.x86_64.macosx.zip" -TBB_TGZ="https://github.com/intel/tbb/releases/download/2017_U7/tbb2017_20170604oss_mac.tgz" +# embree-3.13.1.x86_64.macosx.zip +EMBREE_ZIP_NAME=$(basename "$EMBREE_ZIP") + +# embree-3.13.1.x86_64.macosx +EMBREE_DIR_NAME=$(basename "$EMBREE_ZIP_NAME" ".zip") + +TBB_TGZ="https://github.com/oneapi-src/oneTBB/releases/download/v2021.2.0/oneapi-tbb-2021.2.0-mac.tgz" TBB_TGZ_NAME=$(basename "$TBB_TGZ") -TBB_DIR_NAME="tbb2017_20170604oss" +TBB_DIR_NAME="oneapi-tbb-2021.2.0" if [ -d "$BUILD_DIR" ]; then echo "$BUILD_DIR already exists, remove it first" @@ -17,18 +20,27 @@ fi mkdir "$BUILD_DIR" cd "$BUILD_DIR" -wget "$EMBREE_TGZ" -wget "$TBB_TGZ" -tar xf "$EMBREE_TGZ_NAME" + +wget -q "$EMBREE_ZIP" +unzip -q "$EMBREE_ZIP_NAME" + +wget -q "$TBB_TGZ" tar xf "$TBB_TGZ_NAME" -EMBREE_CMAKE_DIR="$(pwd)/$EMBREE_DIR_NAME" -TBB_CMAKE_DIR="$(pwd)/${TBB_DIR_NAME}/cmake" -cmake .. -DCMAKE_BUILD_TYPE=Release -Dembree_DIR="$EMBREE_CMAKE_DIR" -DTBB_DIR="$TBB_CMAKE_DIR" -make -j8 -make -j8 testlight -make -j8 testqbsp -cpack +EMBREE_CMAKE_DIR="$(pwd)/$EMBREE_DIR_NAME/lib/cmake/embree-3.13.0" +TBB_CMAKE_DIR="$(pwd)/${TBB_DIR_NAME}/lib/cmake" +cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="$EMBREE_CMAKE_DIR;$TBB_CMAKE_DIR" +make -j8 || exit 1 +make -j8 testlight || exit 1 +make -j8 testqbsp || exit 1 +cpack || exit 1 + +# print shared libraries used +otool -L ./light/light +otool -L ./qbsp/qbsp +otool -L ./vis/vis +otool -L ./bspinfo/bspinfo +otool -L ./bsputil/bsputil # run tests ./light/testlight || exit 1 diff --git a/common/bspfile.cc b/common/bspfile.cc index f5b11e5f..14e7514e 100644 --- a/common/bspfile.cc +++ b/common/bspfile.cc @@ -22,6 +22,7 @@ #include #include +#include /* hexen2, quake2 */ const bspversion_t bspver_generic { NO_VERSION, NO_VERSION, "mbsp", "generic BSP", false, false }; @@ -3927,4 +3928,4 @@ DecompressRow (const uint8_t *in, const int numbytes, uint8_t *decompressed) c--; } } while (out - decompressed < row); -} \ No newline at end of file +} diff --git a/common/cmdlib.cc b/common/cmdlib.cc index d4817e3e..0ec46200 100644 --- a/common/cmdlib.cc +++ b/common/cmdlib.cc @@ -1116,6 +1116,15 @@ CRC_Value(unsigned short crcvalue) return crcvalue ^ CRC_XOR_VALUE; } +unsigned short CRC_Block (const unsigned char *start, int count) +{ + unsigned short crc; + CRC_Init (&crc); + while (count--) + crc = (crc << 8) ^ crctable[(crc >> 8) ^ *start++]; + return crc; +} + /* ========================================================================= */ /* diff --git a/include/common/cmdlib.hh b/include/common/cmdlib.hh index b2f203ec..763b90fe 100644 --- a/include/common/cmdlib.hh +++ b/include/common/cmdlib.hh @@ -125,6 +125,7 @@ char *copystring(const char *s); void CRC_Init(unsigned short *crcvalue); void CRC_ProcessByte(unsigned short *crcvalue, uint8_t data); unsigned short CRC_Value(unsigned short crcvalue); +unsigned short CRC_Block (const unsigned char *start, int count); void CreatePath(char *path); void Q_CopyFile(const char *from, char *to); diff --git a/light/CMakeLists.txt b/light/CMakeLists.txt index b8e129bd..cd62153c 100644 --- a/light/CMakeLists.txt +++ b/light/CMakeLists.txt @@ -60,57 +60,44 @@ target_link_libraries (light PRIVATE ${CMAKE_THREAD_LIBS_INIT}) if (embree_FOUND) target_link_libraries (light PRIVATE embree) add_definitions(-DHAVE_EMBREE) - + find_file(EMBREE_LICENSE LICENSE.txt "${embree_DIR}/doc" + "${embree_DIR}/../../../doc" "${embree_DIR}/../embree3/embree3" # vcpkg puts it here + "${embree_DIR}/../../.." # homebrew puts it here NO_DEFAULT_PATH) if (EMBREE_LICENSE STREQUAL EMBREE_LICENSE-NOTFOUND) - message(WARNING "Couldn't find embree license") + message(WARNING "Couldn't find embree license. embree_DIR is ${embree_DIR}") else() message(STATUS "Found embree license: ${EMBREE_LICENSE}") endif() - if(WIN32) - file(GLOB EMBREE_DLLS "${embree_DIR}/bin/*.dll") - foreach(EMBREE_DLL ${EMBREE_DLLS}) - add_custom_command(TARGET light POST_BUILD COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${EMBREE_DLL} $) - endforeach(EMBREE_DLL) - - add_custom_command(TARGET light POST_BUILD COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${EMBREE_LICENSE} $/LICENSE-embree.txt) + add_custom_command(TARGET light POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different "$" "$" + COMMAND ${CMAKE_COMMAND} -E copy_if_different "$" "$" + COMMAND ${CMAKE_COMMAND} -E copy_if_different "${EMBREE_LICENSE}" "$/LICENSE-embree.txt") - install(FILES ${EMBREE_DLLS} DESTINATION bin) + # so the executable will search for dylib's in the same directory as the executable + if(APPLE) + add_custom_command(TARGET light POST_BUILD + COMMAND bash ARGS -c \"install_name_tool -add_rpath @loader_path $ || true\") endif() + + install(FILES $ DESTINATION bin) + + # install TBB if(UNIX) - if (APPLE) - set(SHARED_LIB_EXT dylib) - elseif (${CMAKE_SYSTEM_NAME} MATCHES "Linux") - set(SHARED_LIB_EXT "so.*") - else () - message(FATAL_ERROR "only Linux and macOS currently supported") - endif() + # HACK: preferred method is installing the symlink instead of the actual .so + get_target_property(TBB_SO_FILE_SYMLINK TBB::tbb IMPORTED_LOCATION_RELEASE) + get_filename_component(TBB_SO_FILE "${TBB_SO_FILE_SYMLINK}" REALPATH) + message(STATUS "TBB .so file: ${TBB_SO_FILE}") - file(GLOB EMBREE_DYLIBS_WITH_SYMLINKS "${embree_DIR}/lib/*.${SHARED_LIB_EXT}") - - # Gather all .dylib's that are not symlinks - foreach(EMBREE_DYLIB ${EMBREE_DYLIBS_WITH_SYMLINKS}) - if(NOT IS_SYMLINK ${EMBREE_DYLIB}) - list(APPEND EMBREE_DYLIBS ${EMBREE_DYLIB}) - endif() - endforeach() - - foreach(EMBREE_DYLIB ${EMBREE_DYLIBS}) - message(STATUS "Copying dylib: ${EMBREE_DYLIB}") - add_custom_command(TARGET light POST_BUILD COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${EMBREE_DYLIB} $) - endforeach() - - # so the executable will search for dylib's in the same directory as the executable - if(APPLE) - add_custom_command(TARGET light POST_BUILD COMMAND bash ARGS -c \"install_name_tool -add_rpath @loader_path $ || true\") - endif() - - install(FILES ${EMBREE_DYLIBS} DESTINATION bin) + install(FILES ${TBB_SO_FILE} DESTINATION bin) + else() + # preferred method + install(FILES $ DESTINATION bin) endif() install(FILES ${EMBREE_LICENSE} DESTINATION bin RENAME LICENSE-embree.txt) diff --git a/lightpreview/CMakeLists.txt b/lightpreview/CMakeLists.txt index 5b371627..1cb7df55 100644 --- a/lightpreview/CMakeLists.txt +++ b/lightpreview/CMakeLists.txt @@ -1,4 +1,3 @@ -cmake_minimum_required (VERSION 3.0) project (lightpreview CXX) set(CMAKE_INCLUDE_CURRENT_DIR ON) diff --git a/man/CMakeLists.txt b/man/CMakeLists.txt index 6a54a3ae..b5f2b425 100644 --- a/man/CMakeLists.txt +++ b/man/CMakeLists.txt @@ -1,4 +1,3 @@ -cmake_minimum_required (VERSION 2.8) project (man) find_program (GROFF groff) diff --git a/qbsp/brush.cc b/qbsp/brush.cc index a951f3fe..00349908 100644 --- a/qbsp/brush.cc +++ b/qbsp/brush.cc @@ -945,7 +945,7 @@ brush_t *LoadBrush(const mapentity_t *src, const mapbrush_t *mapbrush, int conte facelist = CreateBrushFaces(src, &hullbrush, rotate_offset, rottype, hullnum); } else if (hullnum == 3) { - vec3_t size[2] = { {-16, -16, -12}, {16, 16, 16} }; + vec3_t size[2] = { {-16, -16, -16}, {16, 16, 12} }; ExpandBrush(&hullbrush, size, facelist); FreeBrushFaces(facelist); facelist = CreateBrushFaces(src, &hullbrush, rotate_offset, rottype, hullnum); @@ -967,10 +967,20 @@ brush_t *LoadBrush(const mapentity_t *src, const mapbrush_t *mapbrush, int conte } } else if (hullnum == 5) { +#if 0 + if (options.hexen2 == 1) { /*original game*/ vec3_t size[2] = { {-48, -48, -50}, {48, 48, 50} }; ExpandBrush(&hullbrush, size, facelist); FreeBrushFaces(facelist); facelist = CreateBrushFaces(src, &hullbrush, rotate_offset, rottype, hullnum); + } else +#endif + { + vec3_t size[2] = { {-28, -28, -40}, {28, 28, 40} }; + ExpandBrush(&hullbrush, size, facelist); + FreeBrushFaces(facelist); + facelist = CreateBrushFaces(src, &hullbrush, rotate_offset, rottype, hullnum); + } } } else diff --git a/testmaps/automatated_tests.sh b/testmaps/automatated_tests.sh index 532d31b7..58ce205d 100755 --- a/testmaps/automatated_tests.sh +++ b/testmaps/automatated_tests.sh @@ -2,6 +2,6 @@ set -x -qbsp invalid_texture_axes.map || exit 1 +qbsp -noverbose invalid_texture_axes.map || exit 1 light invalid_texture_axes.map || exit 1 diff --git a/testmaps/quake_map_source/leaktest.sh b/testmaps/quake_map_source/leaktest.sh index 3d8e264e..bcf384df 100755 --- a/testmaps/quake_map_source/leaktest.sh +++ b/testmaps/quake_map_source/leaktest.sh @@ -3,6 +3,6 @@ set -x for file in *.map; do - qbsp -leaktest "$file" || exit 1 + qbsp -leaktest -noverbose "$file" || exit 1 done diff --git a/vis/CMakeLists.txt b/vis/CMakeLists.txt index 4ec49686..8f0abb7c 100644 --- a/vis/CMakeLists.txt +++ b/vis/CMakeLists.txt @@ -1,4 +1,3 @@ -cmake_minimum_required (VERSION 2.8) project (vis CXX) set(VIS_INCLUDES