diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..7e72430 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,155 @@ +name: C/C++ CI + +on: + push: + branches: [master] + paths-ignore: + - '**.md' + + pull_request: + types: [opened, reopened, synchronize] + release: + types: [published] + +jobs: + windows: + name: 'Windows' + runs-on: windows-latest + + env: + solution: 'msvc/reapi.sln' + buildPlatform: 'Win32' + buildRelease: 'Release' + + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Setup MSBuild + uses: microsoft/setup-msbuild@v1.0.2 + + - name: Build + run: | + msbuild ${{ env.solution }} -p:Configuration="${{ env.buildRelease }}" /t:Clean,Build /p:Platform=${{ env.buildPlatform }} /p:PlatformToolset=v140_xp /p:XPDeprecationWarning=false + + - name: Move files + run: | + mkdir publish\debug + mkdir publish\addons\amxmodx\modules + + move msvc\${{ env.buildRelease }}\reapi_amxx.dll publish\addons\amxmodx\modules\reapi_amxx.dll + move msvc\${{ env.buildRelease }}\reapi_amxx.pdb publish\debug\reapi_amxx.pdb + + - name: Deploy artifacts + uses: actions/upload-artifact@v2 + with: + name: win32 + path: publish/* + + linux: + name: 'Linux' + runs-on: ubuntu-latest + container: s1lentq/linux86buildtools:latest + + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Build using Intel C++ Compiler 19.0 + run: | + rm -rf build && CC=icc CXX=icpc cmake -B build && cmake --build build -j8 + + - name: Prepare AMXX + run: | + mkdir -p publish/addons/amxmodx/modules + rsync -a reapi/extra/amxmodx/ publish/addons/amxmodx/ + rsync -a reapi/version/reapi_version.inc publish/addons/amxmodx/scripting/include/ + + - name: Move files + run: | + mv build/reapi/reapi_amxx_i386.so publish/addons/amxmodx/modules/reapi_amxx_i386.so + mv reapi/version/appversion.h publish/appversion.h + + - name: Run GLIBC/ABI version compat test + run: | + binaries=( + "publish/addons/amxmodx/modules/reapi_amxx_i386.so" + ) + bash ./reapi/version/glibc_test.sh ${binaries[@]} + if [[ $? -ne 0 ]]; then + exit 1 # Assertion failed + fi + shell: bash + + - name: Deploy artifacts + uses: actions/upload-artifact@v2 + id: upload-job + with: + name: linux32 + path: publish/* + + - name: Cleanup temporary artifacts + if: success() && steps.upload-job.outcome == 'success' + run: | + rm -f appversion.h + + publish: + name: 'Publish' + runs-on: ubuntu-latest + needs: [windows, linux] + + steps: + - name: Deploying linux artifacts + uses: actions/download-artifact@v2 + with: + name: linux32 + + - name: Deploying windows artifacts + uses: actions/download-artifact@v2 + with: + name: win32 + + - name: Reading appversion.h + run: | + if [ -e appversion.h ]; then + APP_VERSION=$(cat appversion.h | grep -wi '#define APP_VERSION_STRD' | sed -e 's/#define APP_VERSION_STRD[ \t\r\n\v\f]\+\(.*\)/\1/i' -e 's/\r//g') + if [ $? -ne 0 ]; then + APP_VERSION="" + else + # Remove quotes + APP_VERSION=$(echo $APP_VERSION | xargs) + echo "APP_VERSION=${APP_VERSION}" >> $GITHUB_ENV + fi + fi + rm -f appversion.h + + - name: Packaging binaries + id: packaging-job + if: | + github.event_name == 'release' && + github.event.action == 'published' && + startsWith(github.ref, 'refs/tags/') + run: | + 7z a -tzip reapi-bin-${{ env.APP_VERSION }}.zip addons/ + + - name: Publish artifacts + uses: softprops/action-gh-release@v1 + id: publish-job + if: | + startsWith(github.ref, 'refs/tags/') && + steps.packaging-job.outcome == 'success' + with: + files: | + *.zip + env: + GITHUB_TOKEN: ${{ secrets.API_TOKEN }} + + - name: Cleanup temporary artifacts + if: success() && steps.publish-job.outcome == 'success' + run: | + rm -rf addons debug + rm -f *.zip appversion.h diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..fd7694a --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.1) +project(reapi CXX) + +if (WIN32) + message(FATAL_ERROR "CMakeLists.txt Windows platform isn't supported yet. Use msvc/reapi.sln instead it!") +endif() + + +add_custom_target(appversion DEPENDS + COMMAND "${PROJECT_SOURCE_DIR}/reapi/version/appversion.sh" "${PROJECT_SOURCE_DIR}" "reapi" +) + +add_subdirectory(reapi) diff --git a/README.md b/README.md index 93dc5b5..5a8dd98 100644 --- a/README.md +++ b/README.md @@ -1,45 +1,74 @@ -# Reapi [![Build Status](http://teamcity.rehlds.org/app/rest/builds/buildType:(id:Reapi_Publish)/statusIcon)](http://teamcity.rehlds.org/viewType.html?buildTypeId=Reapi_Publish&guest=1) [![Download](https://camo.githubusercontent.com/1e445db0afba4545403a7600f1d51624c50cefc9be27417125a4eddfb6099f24/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f73316c656e74712f72656170692e737667)](https://github.com/s1lentq/reapi/releases/latest) [![Percentage of issues still open](http://isitmaintained.com/badge/open/s1lentq/reapi.svg)](http://isitmaintained.com/project/s1lentq/reapi "Percentage of issues still open") [![License: GPL v3](https://img.shields.io/badge/License-GPL%20v3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0) +# Reapi [![Download](https://camo.githubusercontent.com/131d02663845c3c56678ac169696fa702504c4534453ced50f4935d762a3b814/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f73316c656e74712f72656170692e737667)](https://github.com/s1lentq/reapi/releases/latest) [![Downloads](https://camo.githubusercontent.com/1f2c6ef35aa9a7e845ca73cb4bba4b29730e30d1056917758a501d7497739519/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f646f776e6c6f6164732f73316c656e74712f72656170692f746f74616c3f636f6c6f723d696d706f7274616e74)]() [![Percentage of issues still open](http://isitmaintained.com/badge/open/s1lentq/reapi.svg)](http://isitmaintained.com/project/s1lentq/reapi "Percentage of issues still open") [![License: GPL v3](https://img.shields.io/badge/License-GPL%20v3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0) AMX Mod X module, using API regamedll & rehlds ## Build instructions -There are several software requirements for building ReAPI: -
    -
  1. Java Development Kit (JDK) 7+ (http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html)
  2. -
  3. For Windows: Visual Studio 2015 and later
  4. -
  5. For Linux: Intel C++ Compiler 15 and later
  6. -
- ### Checking requirements -#### JDK version -Windows
> %JAVA_HOME%\bin\javac -version
-javac 1.8.0_25
+There are several software requirements for building ReAPI:
+
+#### Windows
+
+Visual Studio 2015 (C++14 standard) and later
 
-Linux -
$ javac -version
-javac 1.7.0_65
-
- -#### Visual Studio -Help -> About - -#### ICC -
$ icc --version
-icc (ICC) 15.0.1 20141023
+#### Linux
+
+git >= 1.8.5
+cmake >= 3.10
+GCC >= 4.9.2 (Optional)
+ICC >= 15.0.1 20141023 (Optional)
+LLVM (Clang) >= 6.0 (Optional)
 
### Building -On Windows: -
gradlew clean buildRelease
-On Linux (ICC): -
./gradlew clean buildRelease
+#### Windows +Use `Visual Studio` to build, open `msvc/reapi.sln` and just select from the solution configurations list `Release` or `Debug` -On Linux (GCC): -
./gradlew clean -PuseGcc buildRelease
+#### Linux -Compiled binaries will be placed in the build/binaries/ directory +* Optional options using `build.sh --compiler=[gcc] --jobs=[N] -D[option]=[ON or OFF]` (without square brackets) + +
+-c=|--compiler=[icc|gcc|clang]  - Select preferred C/C++ compiler to build
+-j=|--jobs=[N]                  - Specifies the number of jobs (commands) to run simultaneously (For faster building)
+
+Definitions (-D)
+DEBUG                           - Enables debugging mode
+USE_STATIC_LIBSTDC              - Enables static linking library libstdc++
+
+ +* ICC
./build.sh --compiler=intel
+* LLVM (Clang)
./build.sh --compiler=clang
+* GCC
./build.sh --compiler=gcc
+ +##### Checking build environment (Debian / Ubuntu) + +
+Click to expand + +
    +
  • +Installing required packages +
    +sudo dpkg --add-architecture i386
    +sudo apt-get update
    +sudo apt-get install -y gcc-multilib g++-multilib
    +sudo apt-get install -y build-essential
    +sudo apt-get install -y libc6-dev libc6-dev-i386
    +
    +
  • + +
  • +Select the preferred C/C++ Compiler installation +
    +1) sudo apt-get install -y gcc g++
    +2) sudo apt-get install -y clang
    +
    +
  • +
+ +
## How can I help the project? Just install it on your game server and report problems you faced.
diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..876b458 --- /dev/null +++ b/build.sh @@ -0,0 +1,60 @@ +#!/bin/bash + +main() +{ + CC=gcc + CXX=g++ + + if [[ "$*" =~ "--help" ]]; then + help + exit 0; + fi + + n=0 + args=() + for i in "$@" + do + case $i in + -j=*|--jobs=*) + jobs="-j${i#*=}" + shift + ;; + -c=*|--compiler=*) + C="${i#*=}" + shift + ;; + *) + args[$n]="$i" + ((++n)) + ;; + esac + done + + case "$C" in + ("intel"|"icc") CC=icc CXX=icpc ;; + ("gcc"|"g++") CC=gcc CXX=g++ ;; + ("clang|llvm") CC=clang CXX=clang++ ;; + *) + ;; + esac + + rm -rf build + mkdir build + pushd build &> /dev/null + CC=$CC CXX=$CXX cmake ${args[@]} .. + make ${jobs} + popd > /dev/null +} + +help() +{ + printf "Usage: ./build.sh \n\n" + printf " -c= | --compiler= - Select preferred C/C++ compiler to build\n" + printf " -j= | --jobs= - Specifies the number of jobs (commands) to run simultaneously (For faster building)\n\n" +} + +# Initialize +main $* + +# Exit normally +exit 0 diff --git a/msvc/reapi.sln b/msvc/reapi.sln index 0febdbb..f361022 100644 --- a/msvc/reapi.sln +++ b/msvc/reapi.sln @@ -1,10 +1,12 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2013 -VisualStudioVersion = 12.0.21005.1 +# Visual Studio Version 14 +VisualStudioVersion = 14.0.25420.1 MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "reapi", "..\reapi\msvc\reapi.vcxproj", "{74E2532F-BE55-4B2B-8C34-C9A4B5EC11AC}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "version", "..\reapi\version\msvc\version.vcxproj", "{8520B2EC-8DE2-4B76-8FA7-02F156C79C04}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -15,8 +17,15 @@ Global {74E2532F-BE55-4B2B-8C34-C9A4B5EC11AC}.Debug|Win32.Build.0 = Debug|Win32 {74E2532F-BE55-4B2B-8C34-C9A4B5EC11AC}.Release|Win32.ActiveCfg = Release|Win32 {74E2532F-BE55-4B2B-8C34-C9A4B5EC11AC}.Release|Win32.Build.0 = Release|Win32 + {8520B2EC-8DE2-4B76-8FA7-02F156C79C04}.Debug|Win32.ActiveCfg = Debug|Win32 + {8520B2EC-8DE2-4B76-8FA7-02F156C79C04}.Debug|Win32.Build.0 = Debug|Win32 + {8520B2EC-8DE2-4B76-8FA7-02F156C79C04}.Release|Win32.ActiveCfg = Release|Win32 + {8520B2EC-8DE2-4B76-8FA7-02F156C79C04}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {ED60E017-84B1-4D63-8802-644D7E6B4EA8} + EndGlobalSection EndGlobal diff --git a/reapi/CMakeLists.txt b/reapi/CMakeLists.txt new file mode 100644 index 0000000..5e06407 --- /dev/null +++ b/reapi/CMakeLists.txt @@ -0,0 +1,198 @@ +#---------------------------------------- +# 1. Preparing build: +# rm -rf build +# mkdir build && cd build +# +# 2. Select compiler and build it +# - Compile with Clang: +# CC="clang" CXX="clang++" cmake .. +# make +# +# - Compile with Intel C++ Compiler: +# CC="icc" CXX="icpc" cmake .. +# make +# +# - Compile with GCC Compiler: +# cmake .. +# make +#---------------------------------------- + +cmake_minimum_required(VERSION 3.1) +project(reapi CXX) + +option(DEBUG "Build with debug information." OFF) +option(USE_STATIC_LIBSTDC "Enables static linking libstdc++." OFF) + +set(CMAKE_CXX_STANDARD 14) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +# Avoid -fPIC option +set(CMAKE_SHARED_LIBRARY_CXX_FLAGS "") + +set(COMPILE_FLAGS "-m32 -U_FORTIFY_SOURCE") +set(LINK_FLAGS "-m32 -s") + +set(COMPILE_FLAGS "${COMPILE_FLAGS} -Wall -fno-exceptions -fno-builtin -Wno-unknown-pragmas") + +# Remove noxref code and data +set(COMPILE_FLAGS "${COMPILE_FLAGS} -ffunction-sections -fdata-sections") + +if (DEBUG) + set(COMPILE_FLAGS "${COMPILE_FLAGS} -g3 -O3 -ggdb") +else() + set(COMPILE_FLAGS "${COMPILE_FLAGS} -g0 -O3 -fno-stack-protector") +endif() + +# Check Intel C++ compiler +if ("$ENV{CXX}" MATCHES "icpc") + # + # -fp-model=precise + # ICC uses -fp-model fast=1 by default for more aggressive optimizations on floating-point calculations + # https://software.intel.com/content/www/us/en/develop/documentation/cpp-compiler-developer-guide-and-reference/top/compiler-reference/compiler-options/compiler-option-details/floating-point-options/fp-model-fp.html#fp-model-fp_GUID-99936BBA-1508-4E9F-AC09-FA98613CE2F5 + # + set(COMPILE_FLAGS "${COMPILE_FLAGS} \ + -fp-model=precise\ + -Qoption,cpp,--treat_func_as_string_literal_cpp\ + -inline-forceinline\ + -no-ansi-alias") + + set(LINK_FLAGS "${LINK_FLAGS} \ + -static-intel\ + -no-intel-extensions") + + if (NOT DEBUG) + set(COMPILE_FLAGS "${COMPILE_FLAGS} -ipo") + set(LINK_FLAGS "${LINK_FLAGS} -ipo") + endif() +else() + # Produce code optimized for the most common IA32/AMD64/EM64T processors. + # As new processors are deployed in the marketplace, the behavior of this option will change. + set(COMPILE_FLAGS "${COMPILE_FLAGS} \ + -mtune=generic -msse3\ + -fno-sized-deallocation -Wno-strict-aliasing") +endif() + +# GCC >= 8.3 +if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 8.0) + set(COMPILE_FLAGS "${COMPILE_FLAGS} -fcf-protection=none") +endif() + +if (NOT DEBUG) + set(LINK_FLAGS "${LINK_FLAGS} \ + -Wl,-gc-sections -Wl,--version-script=\"${PROJECT_SOURCE_DIR}/../version_script.lds\"") +endif() + +set(PROJECT_SRC_DIR + "${PROJECT_SOURCE_DIR}" + "${PROJECT_SOURCE_DIR}/src" + "${PROJECT_SOURCE_DIR}/common" + "${PROJECT_SOURCE_DIR}/src/mods" + "${PROJECT_SOURCE_DIR}/src/natives" + "${PROJECT_SOURCE_DIR}/include" + "${PROJECT_SOURCE_DIR}/version" +) + +set(PROJECT_CSSDK_DIR + "${PROJECT_SOURCE_DIR}/include/cssdk/common" + "${PROJECT_SOURCE_DIR}/include/cssdk/dlls" + "${PROJECT_SOURCE_DIR}/include/cssdk/engine" + "${PROJECT_SOURCE_DIR}/include/cssdk/game_shared" + "${PROJECT_SOURCE_DIR}/include/cssdk/pm_shared" + "${PROJECT_SOURCE_DIR}/include/cssdk/public" +) + +set(PROJECT_METAMOD_DIR + "${PROJECT_SOURCE_DIR}/include/metamod" +) + +set(REAPI_SRCS + "src/main.cpp" + "src/amx_hook.cpp" + "src/amxxmodule.cpp" + "src/h_export.cpp" + "src/dllapi.cpp" + "src/entity_callback.cpp" + "src/hook_callback.cpp" + "src/hook_list.cpp" + "src/hook_manager.cpp" + "src/api_config.cpp" + "src/member_list.cpp" + "src/meta_api.cpp" + "src/reapi_utils.cpp" + "src/sdk_util.cpp" + "src/natives/natives_common.cpp" + "src/natives/natives_hookchains.cpp" + "src/natives/natives_members.cpp" + "src/natives/natives_misc.cpp" + "src/natives/natives_rechecker.cpp" + "src/natives/natives_reunion.cpp" + "src/natives/natives_vtc.cpp" + "src/mods/mod_rechecker_api.cpp" + "src/mods/mod_regamedll_api.cpp" + "src/mods/mod_rehlds_api.cpp" + "src/mods/mod_reunion_api.cpp" + "src/mods/mod_vtc_api.cpp" + "src/mods/queryfile_handler.cpp" +) + +set(COMMON_SRCS + "common/info.cpp" + "common/stdc++compat.cpp" +) + +set(PUBLIC_SRCS + "include/cssdk/public/interface.cpp" +) + +add_library(reapi SHARED ${appversion.sh}) + +if (NOT TARGET appversion) + add_custom_target(appversion DEPENDS COMMAND "${PROJECT_SOURCE_DIR}/version/appversion.sh" "${PROJECT_SOURCE_DIR}/.." "reapi") +endif() + +add_dependencies(reapi appversion) + +target_include_directories(reapi PRIVATE + ${PROJECT_SRC_DIR} + ${PROJECT_CSSDK_DIR} + ${PROJECT_METAMOD_DIR} +) + +target_compile_definitions(reapi PRIVATE + _LINUX + LINUX + NDEBUG + _GLIBCXX_USE_CXX11_ABI=0 + HAVE_STRONG_TYPEDEF + _stricmp=strcasecmp + _strnicmp=strncasecmp + _vsnprintf=vsnprintf + _snprintf=snprintf +) + +target_sources(reapi PRIVATE + ${REAPI_SRCS} + ${COMMON_SRCS} + ${PUBLIC_SRCS} +) + +target_link_libraries(reapi PRIVATE + dl +) + +if (USE_STATIC_LIBSTDC) + target_compile_definitions(reapi PRIVATE BUILD_STATIC_LIBSTDC) + set(LINK_FLAGS "${LINK_FLAGS} -static-libgcc -static-libstdc++") +endif() + +set(LINK_FLAGS "${LINK_FLAGS} \ + -Wl,-rpath,'$ORIGIN/.' \ + -L${PROJECT_SOURCE_DIR}/lib/linux32") + +set_target_properties(reapi PROPERTIES + OUTPUT_NAME reapi_amxx_i386 + PREFIX "" + COMPILE_FLAGS ${COMPILE_FLAGS} + LINK_FLAGS ${LINK_FLAGS} + POSITION_INDEPENDENT_CODE OFF +) diff --git a/reapi/common/stdc++compat.cpp b/reapi/common/stdc++compat.cpp new file mode 100644 index 0000000..1937b9b --- /dev/null +++ b/reapi/common/stdc++compat.cpp @@ -0,0 +1,68 @@ +#include +#include + +#if !defined(_WIN32) && !defined(BUILD_STATIC_LIBSTDC) // if build with static libstdc++ then ignore + +// This file adds the necessary compatibility tricks to avoid symbols with +// version GLIBCXX_3.4.16 and bigger, keeping binary compatibility with libstdc++ 4.6.1. +namespace std +{ + +#if __cpp_exceptions + logic_error::logic_error(const char *__arg) : exception(), _M_msg(__arg) {} + out_of_range::out_of_range(const char *__arg) : logic_error(__arg) {} + out_of_range::~out_of_range() _GLIBCXX_USE_NOEXCEPT {} +#endif // #if __cpp_exceptions + + // We shouldn't be throwing exceptions at all, but it sadly turns out we call STL (inline) functions that do. + void __throw_out_of_range_fmt(const char *fmt, ...) + { + #if __cpp_exceptions + va_list ap; + char buf[1024]; // That should be big enough. + + va_start(ap, fmt); + vsnprintf(buf, sizeof(buf), fmt, ap); + buf[sizeof(buf) - 1] = '\0'; + va_end(ap); + + throw std::out_of_range(buf); + #else + abort(); + #endif + } +}; // namespace std + +// Was added in GCC 4.9 +// Technically, this symbol is not in GLIBCXX_3.4.20, but in CXXABI_1.3.8, but that's equivalent, version-wise. +// Those calls are added by the compiler +// itself on `new Class[n]` calls. +extern "C" +void __cxa_throw_bad_array_new_length() +{ +#if __cpp_exceptions + throw std::bad_array_new_length(); +#else + abort(); +#endif +} + +#if defined(__INTEL_COMPILER) && __cplusplus >= 201402L +// This operator delete sized deallocations was added in c++14 +// and required at least not less than CXXABI_1.3.9 +// we should to keep CXXABI_1.3.8 for binary compatibility with oldest libstdc++. +// GCC and Clang allow to compile C++14 code with -fno-sized-deallocation to disable the new feature, but ICC isn't allow +// so that our C++14 library code would never call that version of operator delete, +// for ICC compiler we must override those operators for static linking to the library. +void operator delete[](void *ptr, std::size_t size) noexcept +{ + ::operator delete(ptr); +} + +void operator delete(void *ptr, std::size_t size) noexcept +{ + ::operator delete(ptr); +} +#endif + +#endif // !defined(_WIN32) diff --git a/reapi/include/cssdk/dlls/util.h b/reapi/include/cssdk/dlls/util.h index 91e0b9f..7874cfb 100644 --- a/reapi/include/cssdk/dlls/util.h +++ b/reapi/include/cssdk/dlls/util.h @@ -40,12 +40,6 @@ #define GROUP_OP_AND 0 #define GROUP_OP_NAND 1 -extern globalvars_t *gpGlobals; - -// Use this instead of ALLOC_STRING on constant strings -#define STRING(offset) ((const char *)(gpGlobals->pStringBase + (unsigned int)(offset))) -#define MAKE_STRING(str) ((uint64)(str) - (uint64)(STRING(0))) - // Dot products for view cone checking #define VIEW_FIELD_FULL -1.0 // +-180 degrees #define VIEW_FIELD_WIDE -0.7 // +-135 degrees 0.1 // +-85 degrees, used for full FOV checks diff --git a/reapi/lib/linux32/libgcc_s.so.1 b/reapi/lib/linux32/libgcc_s.so.1 new file mode 100644 index 0000000..b61f9e5 Binary files /dev/null and b/reapi/lib/linux32/libgcc_s.so.1 differ diff --git a/reapi/lib/linux32/libm.so b/reapi/lib/linux32/libm.so new file mode 100644 index 0000000..b0430eb Binary files /dev/null and b/reapi/lib/linux32/libm.so differ diff --git a/reapi/lib/linux32/librt.so b/reapi/lib/linux32/librt.so new file mode 100644 index 0000000..4b39fa4 Binary files /dev/null and b/reapi/lib/linux32/librt.so differ diff --git a/reapi/lib/linux32/libstdc++.so.6 b/reapi/lib/linux32/libstdc++.so.6 new file mode 100644 index 0000000..fa12047 Binary files /dev/null and b/reapi/lib/linux32/libstdc++.so.6 differ diff --git a/reapi/msvc/reapi.vcxproj b/reapi/msvc/reapi.vcxproj index 7a94535..0877c6b 100644 --- a/reapi/msvc/reapi.vcxproj +++ b/reapi/msvc/reapi.vcxproj @@ -285,7 +285,6 @@ - @@ -305,6 +304,11 @@ + + + {8520b2ec-8de2-4b76-8fa7-02f156c79c04} + + {74E2532F-BE55-4B2B-8C34-C9A4B5EC11AC} Win32Proj diff --git a/reapi/msvc/reapi.vcxproj.filters b/reapi/msvc/reapi.vcxproj.filters index 62fb42f..99cf6ff 100644 --- a/reapi/msvc/reapi.vcxproj.filters +++ b/reapi/msvc/reapi.vcxproj.filters @@ -800,9 +800,6 @@ src\mods - - version - src\natives diff --git a/reapi/src/amxxmodule.h b/reapi/src/amxxmodule.h index c3b0a4f..1c7499b 100644 --- a/reapi/src/amxxmodule.h +++ b/reapi/src/amxxmodule.h @@ -93,7 +93,7 @@ typedef int64 cell; #define UNLIMITED (~1u >> 1) struct tagAMX; -typedef cell(AMX_NATIVE_CALL *AMX_NATIVE)(struct tagAMX *amx, cell *params); +typedef cell(/*AMX_NATIVE_CALL*/ *AMX_NATIVE)(struct tagAMX *amx, cell *params); typedef int (AMXAPI *AMX_CALLBACK)(struct tagAMX *amx, cell index, cell *result, cell *params); typedef int (AMXAPI *AMX_DEBUG)(struct tagAMX *amx); #if !defined _FAR diff --git a/reapi/src/hook_callback.h b/reapi/src/hook_callback.h index 348a50a..e329529 100644 --- a/reapi/src/hook_callback.h +++ b/reapi/src/hook_callback.h @@ -141,7 +141,7 @@ struct hookctx_t }; size_t args_count = 0; - args_t args[MAX_HOOKCHAIN_ARGS] = {0u, ATYPE_INTEGER}; + args_t args[MAX_HOOKCHAIN_ARGS] = {}; static CTempStrings s_temp_strings; }; @@ -282,7 +282,7 @@ NOINLINE R DLLEXPORT _callForward(hook_t* hook, original_t original, f_args&&... break; } } - + hook->wasCalled = false; return *(R *)&hookCtx->retVal._integer; diff --git a/reapi/src/mods/queryfile_handler.h b/reapi/src/mods/queryfile_handler.h index 314d82f..bd3b463 100644 --- a/reapi/src/mods/queryfile_handler.h +++ b/reapi/src/mods/queryfile_handler.h @@ -15,8 +15,8 @@ private: CQueryFileHandler(AMX *amx, const char *funcname); ~CQueryFileHandler(); - const int GetAmxxID() const { return m_amxId; }; - const int GetUniqueID() const { return m_uniqueId; }; + int GetAmxxID() const { return m_amxId; }; + int GetUniqueID() const { return m_uniqueId; }; private: int m_amxId; diff --git a/reapi/src/natives/natives_helper.h b/reapi/src/natives/natives_helper.h index 02b36c0..bde9a09 100644 --- a/reapi/src/natives/natives_helper.h +++ b/reapi/src/natives/natives_helper.h @@ -117,7 +117,7 @@ string_t getAmxStringAlloc(AMX* amx, cell addr, char (&dest)[N], size_t* len = n return (pszDest && pszDest[0] != '\0') ? ALLOC_STRING(pszDest) : iStringNull; } -inline void fillNatives(AMX_NATIVE_INFO* table, cell (AMX_NATIVE_CALL with)(AMX *, cell *)) +inline void fillNatives(AMX_NATIVE_INFO* table, cell (with)(AMX *, cell *)) { for (size_t i = 0; table[i].name; i++) table[i].func = with; diff --git a/reapi/src/natives/natives_members.cpp b/reapi/src/natives/natives_members.cpp index c968837..a356f8a 100644 --- a/reapi/src/natives/natives_members.cpp +++ b/reapi/src/natives/natives_members.cpp @@ -359,7 +359,7 @@ cell AMX_NATIVE_CALL get_entvar(AMX *amx, cell *params) CHECK_ISENTITY(arg_index); edict_t *pEdict = edictByIndexAmx(params[arg_index]); - if (unlikely(pEdict == nullptr || &pEdict->v == nullptr)) { + if (unlikely(pEdict == nullptr)) { AMXX_LogError(amx, AMX_ERR_NATIVE, "%s: invalid or uninitialized entity", __FUNCTION__); return FALSE; } diff --git a/reapi/src/natives/natives_misc.cpp b/reapi/src/natives/natives_misc.cpp index 6003178..e741955 100644 --- a/reapi/src/natives/natives_misc.cpp +++ b/reapi/src/natives/natives_misc.cpp @@ -1055,7 +1055,7 @@ cell AMX_NATIVE_CALL rg_set_user_bpammo(AMX *amx, cell *params) return FALSE; } - auto pWeapon = pPlayer->ForEachItem([pPlayer, pInfo](CBasePlayerWeapon *pWeapon) { + auto pWeapon = pPlayer->ForEachItem([pInfo](CBasePlayerWeapon *pWeapon) { return (pWeapon->IsWeapon() && pWeapon->m_iId == pInfo->id); }); @@ -1091,7 +1091,7 @@ cell AMX_NATIVE_CALL rg_get_user_bpammo(AMX *amx, cell *params) return FALSE; } - auto pWeapon = pPlayer->ForEachItem([pPlayer, pInfo](CBasePlayerWeapon *pWeapon) { + auto pWeapon = pPlayer->ForEachItem([pInfo](CBasePlayerWeapon *pWeapon) { return (pWeapon->IsWeapon() && pWeapon->m_iId == pInfo->id); }); @@ -1127,7 +1127,7 @@ cell AMX_NATIVE_CALL rg_set_user_ammo(AMX *amx, cell *params) return FALSE; } - auto pWeapon = pPlayer->ForEachItem(pInfo->slot, [pPlayer, pInfo](CBasePlayerWeapon *pWeapon) { + auto pWeapon = pPlayer->ForEachItem(pInfo->slot, [pInfo](CBasePlayerWeapon *pWeapon) { return (pWeapon->IsWeapon() && pWeapon->m_iId == pInfo->id); }); @@ -1163,7 +1163,7 @@ cell AMX_NATIVE_CALL rg_get_user_ammo(AMX *amx, cell *params) return FALSE; } - auto pWeapon = pPlayer->ForEachItem(pInfo->slot, [pPlayer, pInfo](CBasePlayerWeapon *pWeapon) { + auto pWeapon = pPlayer->ForEachItem(pInfo->slot, [pInfo](CBasePlayerWeapon *pWeapon) { return (pWeapon->IsWeapon() && pWeapon->m_iId == pInfo->id); }); diff --git a/reapi/src/sdk_util.cpp b/reapi/src/sdk_util.cpp index 1df65c7..9df28b9 100644 --- a/reapi/src/sdk_util.cpp +++ b/reapi/src/sdk_util.cpp @@ -13,8 +13,9 @@ void NORETURN UTIL_SysError(const char *fmt, ...) //TerminateProcess(GetCurrentProcess(), 1); - *((int *)NULL) = 0; - while (true); + volatile int *null = 0; + *null = 0; + exit(-1); } char *UTIL_VarArgs(char *format, ...) diff --git a/reapi/version/appversion.bat b/reapi/version/appversion.bat new file mode 100644 index 0000000..0b80dfd --- /dev/null +++ b/reapi/version/appversion.bat @@ -0,0 +1,275 @@ +@setlocal enableextensions enabledelayedexpansion +@echo off +:: +:: Pre-build auto-versioning script +:: + +chcp 65001 + +set srcdir=%~1 +set repodir=%~2 +set fileinc=%~3 + +set old_version= +set old_version_inc= +set version_major=0 +set version_minor=0 +set version_maintenance=0 +set version_modifed= +set genereate_inc=0 + +set commitSHA= +set commitURL= +set commitCount=0 +set branch_name=master + +for /f "delims=" %%a in ('wmic OS Get localdatetime ^| find "."') do set "dt=%%a" +set "YYYY=%dt:~0,4%" +set "MM=%dt:~4,2%" +set "DD=%dt:~6,2%" +set "hour=%dt:~8,2%" +set "min=%dt:~10,2%" +set "sec=%dt:~12,2%" + +:: +:: Remove leading zero from MM (e.g 09 > 9) +:: +for /f "tokens=* delims=0" %%I in ("%MM%") do set MM=%%I + +:: +:: Index into array to get month name +:: +for /f "tokens=%MM%" %%I in ("Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec") do set "month=%%I" + +:: +:: Check for git.exe presence +:: +CALL git.exe describe >NUL 2>&1 +set errlvl="%ERRORLEVEL%" + +:: +:: Read old appversion.h, if present +:: +IF EXIST "%srcdir%\appversion.h" ( + FOR /F "usebackq tokens=1,2,3" %%i in ("%srcdir%\appversion.h") do ( + IF %%i==#define ( + IF %%j==APP_VERSION ( + :: Remove quotes + set v=%%k + set old_version=!v:"=! + ) + ) + ) +) + +:: +:: Check %fileinc% if present to generate +:: +IF NOT [%fileinc%]==[] ( + set genereate_inc=1 +) + +:: +:: Read old %fileinc%, if present +:: +IF [%genereate_inc%]==[1] ( + IF EXIST "%srcdir%\%fileinc%" ( + FOR /F "usebackq tokens=1,2,3" %%i in ("%srcdir%\%fileinc%") do ( + IF %%i==#define ( + IF %%j==REAPI_VERSION ( + :: Remove quotes + set v=%%k + set old_version_inc=!v:"=! + ) + ) + ) + ) +) + +IF %errlvl% == "1" ( + echo can't locate git.exe - auto-versioning step won't be performed + + :: if we haven't appversion.h, we need to create it + IF NOT "%old_version%" == "" ( + set commitCount=0 + ) +) + +:: +:: Read major, minor and maintenance version components from Version.h +:: +IF EXIST "%srcdir%\version.h" ( + FOR /F "usebackq tokens=1,2,3" %%i in ("%srcdir%\version.h") do ( + IF %%i==#define ( + IF %%j==VERSION_MAJOR set version_major=%%k + IF %%j==VERSION_MINOR set version_minor=%%k + IF %%j==VERSION_MAINTENANCE set version_maintenance=%%k + ) + ) +) + +:: +:: Read revision and release date from it +:: +IF NOT %errlvl% == "1" ( + :: Get current branch + FOR /F "tokens=*" %%i IN ('"git -C "%repodir%\." rev-parse --abbrev-ref HEAD"') DO ( + set branch_name=%%i + ) + + FOR /F "tokens=*" %%i IN ('"git -C "%repodir%\." rev-list --count !branch_name!"') DO ( + IF NOT [%%i] == [] ( + set commitCount=%%i + ) + ) +) + +:: +:: Get remote url repository +:: +IF NOT %errlvl% == "1" ( + + set branch_remote=origin + :: Get remote name by current branch + FOR /F "tokens=*" %%i IN ('"git -C "%repodir%\." config branch.!branch_name!.remote"') DO ( + set branch_remote=%%i + ) + :: Get remote url + FOR /F "tokens=2 delims=@" %%i IN ('"git -C "%repodir%\." config remote.!branch_remote!.url"') DO ( + set commitURL=%%i + ) + :: Get commit id + FOR /F "tokens=*" %%i IN ('"git -C "%repodir%\." rev-parse --verify HEAD"') DO ( + set shafull=%%i + set commitSHA=!shafull:~0,+7! + ) + + IF [!commitURL!] == [] ( + + FOR /F "tokens=1" %%i IN ('"git -C "%repodir%\." config remote.!branch_remote!.url"') DO ( + set commitURL=%%i + ) + + :: strip .git + if "x!commitURL:~-4!"=="x.git" ( + set commitURL=!commitURL:~0,-4! + ) + + :: append extra string + If NOT "!commitURL!"=="!commitURL:bitbucket.org=!" ( + set commitURL=!commitURL!/commits/ + ) ELSE ( + set commitURL=!commitURL!/commit/ + ) + + ) ELSE ( + :: strip .git + if "x!commitURL:~-4!"=="x.git" ( + set commitURL=!commitURL:~0,-4! + ) + :: replace : to / + set commitURL=!commitURL::=/! + + :: append extra string + If NOT "!commitURL!"=="!commitURL:bitbucket.org=!" ( + set commitURL=https://!commitURL!/commit/ + ) ELSE ( + set commitURL=https://!commitURL!/commits/ + ) + ) +) + +:: +:: Detect local modifications +:: +set localChanged=0 +IF NOT %errlvl% == "1" ( + FOR /F "tokens=*" %%i IN ('"git -C "%repodir%\." ls-files -m"') DO ( + set localChanged=1 + ) +) + +IF [%localChanged%]==[1] ( + set version_modifed=+m +) + +:: +:: Now form full version string like 1.0.0.1 +:: + +set new_version_inc=%version_major%%version_minor%%commitCount% +set new_version=%version_major%.%version_minor%.%version_maintenance%.%commitCount%-dev%version_modifed% + +:: +:: Update appversion.h if version has changed or modifications/mixed revisions detected +:: +IF NOT "%new_version%"=="%old_version%" ( + goto _update +) + +:: +:: Update %fileinc% if version has changed or modifications/mixed revisions detected +:: + +IF [%genereate_inc%]==[1] ( + IF NOT "%new_version_inc%"=="%old_version_inc%" ( + goto _update + ) +) + +goto _exit + +:_update + +:: +:: Write %fileinc% +:: +IF [%genereate_inc%]==[1] ( + echo Updating %fileinc%, new version is "%new_version_inc%", the old one was %old_version_inc% + + echo #if defined _reapi_version_included>"%srcdir%\%fileinc%" + echo #endinput>>"%srcdir%\%fileinc%" + echo #endif>>"%srcdir%\%fileinc%" + echo #define _reapi_version_included>>"%srcdir%\%fileinc%" + + echo.>>"%srcdir%\%fileinc%" + >>"%srcdir%\%fileinc%" echo // REAPI version + >>"%srcdir%\%fileinc%" echo #define REAPI_VERSION %version_major%%version_minor%%commitCount% + >>"%srcdir%\%fileinc%" echo #define REAPI_VERSION_MAJOR %version_major% + >>"%srcdir%\%fileinc%" echo #define REAPI_VERSION_MINOR %version_minor% +) + +:: +:: Write appversion.h +:: +echo Updating appversion.h, new version is "%new_version%", the old one was %old_version% + +echo #ifndef __APPVERSION_H__>"%srcdir%\appversion.h" +echo #define __APPVERSION_H__>>"%srcdir%\appversion.h" +echo.>>"%srcdir%\appversion.h" +echo //>>"%srcdir%\appversion.h" +echo // This file is generated automatically.>>"%srcdir%\appversion.h" +echo // Don't edit it.>>"%srcdir%\appversion.h" +echo //>>"%srcdir%\appversion.h" +echo.>>"%srcdir%\appversion.h" +echo // Version defines>>"%srcdir%\appversion.h" +echo #define APP_VERSION "%new_version%">>"%srcdir%\appversion.h" + +>>"%srcdir%\appversion.h" echo #define APP_VERSION_C %version_major%,%version_minor%,%version_maintenance%,%commitCount% +echo #define APP_VERSION_STRD "%version_major%.%version_minor%.%version_maintenance%.%commitCount%">>"%srcdir%\appversion.h" +echo #define APP_VERSION_FLAGS 0x0L>>"%srcdir%\appversion.h" + +echo.>>"%srcdir%\appversion.h" +echo #define APP_COMMIT_DATE "%month% %DD% %YYYY%">>"%srcdir%\appversion.h" +echo #define APP_COMMIT_TIME "%hour%:%min%:%sec%">>"%srcdir%\appversion.h" + +echo.>>"%srcdir%\appversion.h" +echo #define APP_COMMIT_SHA "%commitSHA%">>"%srcdir%\appversion.h" +echo #define APP_COMMIT_URL "%commitURL%">>"%srcdir%\appversion.h" +echo.>>"%srcdir%\appversion.h" + +echo #endif //__APPVERSION_H__>>"%srcdir%\appversion.h" +echo.>>"%srcdir%\appversion.h" + +:_exit +exit /B 0 diff --git a/reapi/version/appversion.sh b/reapi/version/appversion.sh new file mode 100755 index 0000000..33b1c96 --- /dev/null +++ b/reapi/version/appversion.sh @@ -0,0 +1,202 @@ +#!/bin/bash + +init() +{ + SOURCE_DIR=$1 + GIT_DIR=$SOURCE_DIR + VERSION_FILE=$SOURCE_DIR/reapi/version/version.h + APPVERSION_FILE=$SOURCE_DIR/reapi/version/appversion.h + APPVERSION_FILE_INC=$2 + GENERATE_INC=0 + + PREFIX_INC_LOWER=${APPVERSION_FILE_INC,,} + PREFIX_INC_UPPER=${APPVERSION_FILE_INC^^} + DEFINE_PREFIXINC="#define ${PREFIX_INC_UPPER}_VERSION" + + if test -z "`git --version`"; then + echo "Please install git client" + echo "sudo apt-get install git" + exit -1 + fi + + # + # Read old version from $APPVERSION_FILE_INC, if present + # + if [ $? -ne 0 -o "$APPVERSION_FILE_INC" != "" ] && [ $? -ne 0 -o "$PREFIX_INC_UPPER" != "" ]; then + APPVERSION_FILE_INC=$SOURCE_DIR/reapi/version/${APPVERSION_FILE_INC}_version.inc + + if [ $? -ne 0 -o "$APPVERSION_FILE_INC" != "" ] && [ $? -ne 0 -o "$PREFIX_INC_UPPER" != "" ]; then + if test -f $APPVERSION_FILE_INC ; then + OLD_VERSION_INC=$(cat $APPVERSION_FILE_INC | grep -wi "$DEFINE_PREFIXINC" | sed -e "s/$DEFINE_PREFIXINC.*[^0-9]\([0-9][0-9]*\).*/\1/i" -e "s/\r//g") + fi + + GENERATE_INC=1 + fi + fi + + # Read old version + if [ -e $APPVERSION_FILE ]; then + OLD_VERSION=$(cat $APPVERSION_FILE | grep -wi '#define APP_VERSION' | sed -e 's/#define APP_VERSION[ \t\r\n\v\f]\+\(.*\)/\1/i' -e 's/\r//g') + if [ $? -ne 0 ]; then + OLD_VERSION="" + else + # Remove quotes + OLD_VERSION=$(echo $OLD_VERSION | xargs) + fi + fi + + # Get major, minor and maintenance information from gradle.properties + MAJOR=$(cat "$VERSION_FILE" | grep -wi 'VERSION_MAJOR' | sed -e 's/.*VERSION_MAJOR.*[^0-9]\([0-9][0-9]*\).*/\1/i' -e 's/\r//g') + if [ $? -ne 0 -o "$MAJOR" = "" ]; then + MAJOR=0 + fi + + MINOR=$(cat "$VERSION_FILE" | grep -wi 'VERSION_MINOR' | sed -e 's/.*VERSION_MINOR.*[^0-9]\([0-9][0-9]*\).*/\1/i' -e 's/\r//g') + if [ $? -ne 0 -o "$MINOR" = "" ]; then + MINOR=0 + fi + + MAINTENANCE=$(cat "$VERSION_FILE" | grep -i 'VERSION_MAINTENANCE' | sed -e 's/.*VERSION_MAINTENANCE.*[^0-9]\([0-9][0-9]*\).*/\1/i' -e 's/\r//g') + if [ $? -ne 0 -o "$MAINTENANCE" = "" ]; then + MAINTENANCE=0 + fi + + BRANCH_NAME=$(git -C "$GIT_DIR/" rev-parse --abbrev-ref HEAD) + if [ $? -ne 0 -o "$BRANCH_NAME" = "" ]; then + BRANCH_NAME=master + fi + + COMMIT_COUNT=$(git -C "$GIT_DIR/" rev-list --count $BRANCH_NAME) + if [ $? -ne 0 -o "$COMMIT_COUNT" = "" ]; then + COMMIT_COUNT=0 + fi + + # + # Configure remote url repository + # + # Get remote name by current branch + BRANCH_REMOTE=$(git -C "$GIT_DIR/" config branch.$BRANCH_NAME.remote) + if [ $? -ne 0 -o "$BRANCH_REMOTE" = "" ]; then + BRANCH_REMOTE=origin + fi + + # Get commit id + COMMIT_SHA=$(git -C "$GIT_DIR/" rev-parse --verify HEAD) + COMMIT_SHA=${COMMIT_SHA:0:7} + + # Get remote url + COMMIT_URL=$(git -C "$GIT_DIR/" config remote.$BRANCH_REMOTE.url) + + URL_CONSTRUCT=0 + + if [[ "$COMMIT_URL" == *"git@"* ]]; then + + URL_CONSTRUCT=1 + + # Strip prefix 'git@' + COMMIT_URL=${COMMIT_URL#git@} + + # Strip postfix '.git' + COMMIT_URL=${COMMIT_URL%.git} + + # Replace ':' to '/' + COMMIT_URL=${COMMIT_URL/:/\/} + + elif [[ "$COMMIT_URL" == *"https://"* ]]; then + + URL_CONSTRUCT=1 + + # Strip prefix 'https://' + COMMIT_URL=${COMMIT_URL#https://} + + # Strip postfix '.git' + COMMIT_URL=${COMMIT_URL%.git} + + fi + + if test "$URL_CONSTRUCT" -eq 1; then + # Append extra string + if [[ "$COMMIT_URL" == *"bitbucket.org"* ]]; then + COMMIT_URL=$(echo https://$COMMIT_URL/commits/) + else + COMMIT_URL=$(echo https://$COMMIT_URL/commit/) + fi + fi + + # + # Detect local modifications + # + if [ `git -C "$GIT_DIR/" ls-files -m | wc -l` = 0 ]; then + MODIFIED= + else + MODIFIED=+m + fi + + NEW_VERSION_INC="$MAJOR$MINOR$COMMIT_COUNT" + NEW_VERSION="$MAJOR.$MINOR.$MAINTENANCE.$COMMIT_COUNT-dev$MODIFIED" + + # Update appversion.h if version has changed or modifications/mixed revisions detected + if [ "$NEW_VERSION" != "$OLD_VERSION" ] || [ "$NEW_VERSION_INC" != "$OLD_VERSION_INC" ]; then + update_appversion + fi +} + +update_appversion() +{ + if test "$GENERATE_INC" -eq 1; then + update_appversion_inc + fi + + day=$(date +%d) + year=$(date +%Y) + hours=$(date +%H:%M:%S) + month=$(LANG=en_us_88591; date +"%b") + + # Write appversion.h + echo Updating appversion.h, new version is '"'$NEW_VERSION'"', the old one was $OLD_VERSION + + echo -e "#ifndef __APPVERSION_H__\r">$APPVERSION_FILE + echo -e "#define __APPVERSION_H__\r">>$APPVERSION_FILE + echo -e "\r">>$APPVERSION_FILE + echo -e "//\r">>$APPVERSION_FILE + echo -e "// This file is generated automatically.\r">>$APPVERSION_FILE + echo -e "// Don't edit it.\r">>$APPVERSION_FILE + echo -e "//\r">>$APPVERSION_FILE + echo -e "\r">>$APPVERSION_FILE + echo -e "// Version defines\r">>$APPVERSION_FILE + echo -e '#define APP_VERSION "'$NEW_VERSION'"\r'>>$APPVERSION_FILE + + echo -e "#define APP_VERSION_C $MAJOR,$MINOR,$MAINTENANCE,$COMMIT_COUNT\r">>$APPVERSION_FILE + echo -e '#define APP_VERSION_STRD "'$MAJOR.$MINOR.$MAINTENANCE.$COMMIT_COUNT'"\r'>>$APPVERSION_FILE + echo -e "#define APP_VERSION_FLAGS 0x0L\r">>$APPVERSION_FILE + echo -e "\r">>$APPVERSION_FILE + echo -e '#define APP_COMMIT_DATE "'$month $day $year'"\r'>>$APPVERSION_FILE + echo -e '#define APP_COMMIT_TIME "'$hours'"\r'>>$APPVERSION_FILE + echo -e "\r">>$APPVERSION_FILE + + echo -e '#define APP_COMMIT_SHA "'$COMMIT_SHA'"\r'>>$APPVERSION_FILE + echo -e '#define APP_COMMIT_URL "'$COMMIT_URL'"\r'>>$APPVERSION_FILE + echo -e "\r">>$APPVERSION_FILE + echo -e "#endif //__APPVERSION_H__\r">>$APPVERSION_FILE +} + +update_appversion_inc() +{ + echo Updating $APPVERSION_FILE_INC, new version is '"'$NEW_VERSION_INC'"', the old one was $OLD_VERSION_INC + + echo -e "#if defined _${PREFIX_INC_LOWER}_version_included\r">$APPVERSION_FILE_INC + echo -e " #endinput\r">>$APPVERSION_FILE_INC + echo -e "#endif\r">>$APPVERSION_FILE_INC + echo -e "#define _${PREFIX_INC_LOWER}_version_included\r">>$APPVERSION_FILE_INC + echo -e "\r">>$APPVERSION_FILE_INC + echo -e "// $PREFIX_INC_LOWER version\r">>$APPVERSION_FILE_INC + echo -e "#define ${PREFIX_INC_UPPER}_VERSION $NEW_VERSION_INC\r">>$APPVERSION_FILE_INC + echo -e "#define ${PREFIX_INC_UPPER}_VERSION_MAJOR $MAJOR\r">>$APPVERSION_FILE_INC + echo -e "#define ${PREFIX_INC_UPPER}_VERSION_MINOR $MINOR\r">>$APPVERSION_FILE_INC +} + +# Initialise +init $* + +# Exit normally +exit 0 diff --git a/reapi/version/glibc_test.sh b/reapi/version/glibc_test.sh new file mode 100755 index 0000000..74d41d2 --- /dev/null +++ b/reapi/version/glibc_test.sh @@ -0,0 +1,83 @@ +#!/bin/bash + +main() +{ + files=($@) + + declare -A threshold_version + threshold_version[CXXABI]="1.3.5" + threshold_version[GLIBCXX]="3.4.15" + threshold_version[GLIBC]="2.11" + + for k in "${!threshold_version[@]}"; do + for f in "${files[@]}" + do + : + version=$(readelf -sV $f | sed -n 's/.*@'$k'_//p' | sort -u -V | tail -1 | cut -d ' ' -f 1) + + # version no present - skipped + if [[ -z "$version" ]]; then + version="UND" + # version is private - skipped + elif [ "$version" = "PRIVATE" ]; then + version="PRV" + # ensure numeric + elif [[ $version =~ ^([0-9]+\.){0,2}(\*|[0-9]+)$ ]]; then + check_version_greater $version ${threshold_version[$k]} + if [[ $? -eq 1 ]]; then + echo -e "\033[0;31mAssertion failed:\033[0m Binary \033[0;32m${f}\033[0m has ${k}_\033[0;33m$version\033[0m greater than max version ${k}_\033[0;33m${threshold_version[$k]}\033[0m" + exit -1 + fi + fi + done + + if [[ "$version" = "PRV" || "$version" = "UND" ]]; then + echo -e "[\033[0;90mSKIP\033[0m] \033[0;33m${version}\033[0m < ${k}_\033[0;33m${threshold_version[$k]}\033[0m" + else + echo -e "[\033[0;32mOK\033[0m] \033[0;33m${version}\033[0m < ${k}_\033[0;33m${threshold_version[$k]}\033[0m" + fi + done +} + +check_version_greater() +{ + if [[ -z "$1" || $1 == $2 ]]; then + return 0 + fi + + local IFS=. + local i ver1=($1) ver2=($2) + + # fill empty fields in ver1 with zeros + for ((i = ${#ver1[@]}; i < ${#ver2[@]}; i++)) + do + ver1[i]=0 + done + + for ((i = 0; i < ${#ver1[@]}; i++)) + do + if [[ -z ${ver2[i]} ]] + then + # fill empty fields in ver2 with zeros + ver2[i]=0 + fi + + if ((10#${ver1[i]} > 10#${ver2[i]})) + then + return 1 + fi + + if ((10#${ver1[i]} < 10#${ver2[i]})) + then + break + fi + done + + return 0 +} + +# Initialize +main $* + +# Exit normally +exit 0 diff --git a/reapi/version/msvc/version.vcxproj b/reapi/version/msvc/version.vcxproj new file mode 100644 index 0000000..380fd87 --- /dev/null +++ b/reapi/version/msvc/version.vcxproj @@ -0,0 +1,84 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + + + + + + + + {8520B2EC-8DE2-4B76-8FA7-02F156C79C04} + MakeFileProj + version + version + + + + Makefile + true + v120 + v140 + v141 + v142 + + + Makefile + false + v120 + v140 + v141 + v142 + + + + + + + + + + + + + + + ECHO Setup version from Git revision +IF EXIST "$(ProjectDir)..\..\version\appversion.bat" (CALL "$(ProjectDir)..\..\version\appversion.bat" "$(ProjectDir)..\..\version\" "$(SolutionDir)..\" "reapi_version.inc") + + + WIN32;_DEBUG;$(NMakePreprocessorDefinitions) + echo ON + +del /s "$(ProjectDir)..\appversion.h" "$(ProjectDir)..\reapi_version.inc" >nul 2>&1 + ECHO Setup version from Git revision +IF EXIST "$(ProjectDir)..\..\version\appversion.bat" (CALL "$(ProjectDir)..\..\version\appversion.bat" "$(ProjectDir)..\..\version\" "$(SolutionDir)..\" "reapi_version.inc") + + + ECHO Setup version from Git revision +IF EXIST "$(ProjectDir)..\..\version\appversion.bat" (CALL "$(ProjectDir)..\..\version\appversion.bat" "$(ProjectDir)..\..\version\" "$(SolutionDir)..\" "reapi_version.inc") + + + WIN32;NDEBUG;$(NMakePreprocessorDefinitions) + echo ON + +del /s "$(ProjectDir)..\appversion.h" "$(ProjectDir)..\reapi_version.inc" >nul 2>&1 + ECHO Setup version from Git revision +IF EXIST "$(ProjectDir)..\..\version\appversion.bat" (CALL "$(ProjectDir)..\..\version\appversion.bat" "$(ProjectDir)..\..\version\" "$(SolutionDir)..\" "reapi_version.inc") + + + + + + + diff --git a/reapi/version/msvc/version.vcxproj.filters b/reapi/version/msvc/version.vcxproj.filters new file mode 100644 index 0000000..3344fb3 --- /dev/null +++ b/reapi/version/msvc/version.vcxproj.filters @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/reapi/version/version.h b/reapi/version/version.h new file mode 100644 index 0000000..b68b0f3 --- /dev/null +++ b/reapi/version/version.h @@ -0,0 +1,10 @@ +/* +* Version declaration dependency file +* +*/ + +#pragma once + +#define VERSION_MAJOR 5 +#define VERSION_MINOR 19 +#define VERSION_MAINTENANCE 0