mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-03-07 14:30:40 +00:00
Merge pull request #1065 from marauder2k9-torque/cmakeoverhaulunittests-10commits
Same as previous
This commit is contained in:
commit
047ac7f085
5283 changed files with 2219619 additions and 23667 deletions
23
.github/actions/test-results/action.yml
vendored
Normal file
23
.github/actions/test-results/action.yml
vendored
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
name: Build Torque Test Report
|
||||
description: Upload Torques unit test artifact.
|
||||
inputs:
|
||||
name:
|
||||
description: The name of the unit test.
|
||||
default: "${{github.job}}"
|
||||
artifact-name:
|
||||
description: The name of the artifact.
|
||||
required: true
|
||||
path:
|
||||
description: The path to the upload.
|
||||
required: true
|
||||
default: "**/My Projects/Torque3D/game/test_detail.xml"
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- name: Test Reporter
|
||||
uses: phoenix-actions/test-reporting@v12
|
||||
with:
|
||||
artifact: ${{inputs.artifact-name}}
|
||||
name: ${{inputs.name}}
|
||||
path: ${{inputs.path}}
|
||||
reporter: java-junit
|
||||
19
.github/actions/upload-artifact/action.yml
vendored
Normal file
19
.github/actions/upload-artifact/action.yml
vendored
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
name: Upload Torque Test Report
|
||||
description: Upload Torques unit test artifact.
|
||||
inputs:
|
||||
name:
|
||||
description: The name of the unit test.
|
||||
default: "${{github.job}}"
|
||||
path:
|
||||
description: The path to the upload.
|
||||
required: true
|
||||
default: "**/My Projects/Torque3D/game/test_detail.xml"
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- name: Upload Torque Test Report
|
||||
uses: actions/upload-artifact@v3.1.2
|
||||
with:
|
||||
name: ${{inputs.name}}
|
||||
path: ${{inputs.path}}
|
||||
retention-days: 1
|
||||
87
.github/workflows/build-linux-gcc.yml
vendored
Normal file
87
.github/workflows/build-linux-gcc.yml
vendored
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
name: Linux Build
|
||||
on:
|
||||
push:
|
||||
branches: [development]
|
||||
pull_request:
|
||||
branches: [development]
|
||||
env:
|
||||
build_type: "Release"
|
||||
cc: "gcc"
|
||||
cxx: "g++"
|
||||
|
||||
concurrency:
|
||||
group: ci-${{github.actor}}-${{github.head_ref || github.run_number}}-${{github.ref}}-linux
|
||||
cancel-in-progress: true
|
||||
jobs:
|
||||
build-linux:
|
||||
if: github.repository == 'TorqueGameEngines/Torque3D'
|
||||
name: ${{matrix.config.name}}
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
config:
|
||||
- {
|
||||
name: "Ubuntu Latest GCC",
|
||||
build_type: "Release",
|
||||
cc: "gcc",
|
||||
cxx: "g++",
|
||||
generator: "Ninja"
|
||||
}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Print env
|
||||
run: |
|
||||
echo github.event.action: ${{ github.event.action }}
|
||||
echo github.event_name: ${{ github.event_name }}
|
||||
|
||||
- name: Setup GCC problem matcher
|
||||
uses: ammaraskar/gcc-problem-matcher@master
|
||||
|
||||
- name: Install Linux Dependencies
|
||||
run: |
|
||||
sudo apt-get install ninja-build
|
||||
ninja --version
|
||||
cmake --version
|
||||
gcc --version
|
||||
sudo apt-get update && \
|
||||
sudo apt-get install -y \
|
||||
build-essential \
|
||||
nasm \
|
||||
libogg-dev \
|
||||
libxft-dev \
|
||||
libx11-dev \
|
||||
libxxf86vm-dev \
|
||||
libopenal-dev \
|
||||
libfreetype6-dev \
|
||||
libxcursor-dev \
|
||||
libxinerama-dev \
|
||||
libxi-dev \
|
||||
libxrandr-dev \
|
||||
libxss-dev \
|
||||
libglu1-mesa-dev \
|
||||
libgtk-3-dev
|
||||
|
||||
|
||||
- name: Configure, Build & Install
|
||||
uses: threeal/cmake-action@v1.2.0
|
||||
with:
|
||||
source-dir: ${{github.workspace}}
|
||||
build-dir: ${{github.workspace}}/build
|
||||
c-compiler: ${{matrix.config.cc}}
|
||||
cxx-compiler: ${{matrix.config.cxx}}
|
||||
generator: ${{matrix.config.generator}}
|
||||
options: CMAKE_BUILD_TYPE=${{matrix.config.build_type}} TORQUE_APP_NAME=Torque3D TORQUE_TESTING=ON
|
||||
run-build: true
|
||||
build-args: --config ${{matrix.config.build_type}} --target install
|
||||
|
||||
- name: Unit Tests
|
||||
run: |
|
||||
cd "${{github.workspace}}/My Projects/Torque3D/game"
|
||||
./Torque3D runTests.tscript
|
||||
|
||||
- name: Upload Artifact
|
||||
uses: ./.github/actions/upload-artifact
|
||||
with:
|
||||
name: torque3dLinuxGCCUnitTest
|
||||
68
.github/workflows/build-macos-clang.yml
vendored
Normal file
68
.github/workflows/build-macos-clang.yml
vendored
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
name: MacOSX Build
|
||||
on:
|
||||
push:
|
||||
branches: [development]
|
||||
pull_request:
|
||||
branches: [development]
|
||||
env:
|
||||
build_type: "Release"
|
||||
cc: "clang"
|
||||
cxx: "clang++"
|
||||
|
||||
concurrency:
|
||||
group: ci-${{github.actor}}-${{github.head_ref || github.run_number}}-${{github.ref}}-macosx
|
||||
cancel-in-progress: true
|
||||
jobs:
|
||||
build-linux:
|
||||
if: github.repository == 'TorqueGameEngines/Torque3D'
|
||||
name: ${{matrix.config.name}}
|
||||
runs-on: macos-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
config:
|
||||
- {
|
||||
name: "MacOSX Latest Clang",
|
||||
build_type: "Release",
|
||||
cc: "clang",
|
||||
cxx: "clang++",
|
||||
generator: "Ninja"
|
||||
}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Print env
|
||||
run: |
|
||||
echo github.event.action: ${{ github.event.action }}
|
||||
echo github.event_name: ${{ github.event_name }}
|
||||
|
||||
- name: Setup GCC problem matcher
|
||||
uses: ammaraskar/gcc-problem-matcher@master
|
||||
|
||||
- name: Install MacOSX Dependencies
|
||||
run: |
|
||||
brew install ninja
|
||||
ninja --version
|
||||
cmake --version
|
||||
|
||||
- name: Configure, Build & Install
|
||||
uses: threeal/cmake-action@v1.2.0
|
||||
with:
|
||||
source-dir: ${{github.workspace}}
|
||||
build-dir: ${{github.workspace}}/build
|
||||
c-compiler: ${{matrix.config.cc}}
|
||||
cxx-compiler: ${{matrix.config.cxx}}
|
||||
generator: ${{matrix.config.generator}}
|
||||
options: CMAKE_BUILD_TYPE=${{matrix.config.build_type}} TORQUE_APP_NAME=Torque3D TORQUE_TESTING=ON
|
||||
run-build: true
|
||||
build-args: --config ${{matrix.config.build_type}} --target install
|
||||
|
||||
- name: Unit Tests
|
||||
run: |
|
||||
cd "${{github.workspace}}/My Projects/Torque3D/game"
|
||||
./Torque3D.app/Contents/MacOS/Torque3D runTests.tscript
|
||||
|
||||
- name: Upload Artifact
|
||||
uses: ./.github/actions/upload-artifact
|
||||
with:
|
||||
name: torque3dMacOSXCLANGUnitTest
|
||||
64
.github/workflows/build-windows-msvc.yml
vendored
Normal file
64
.github/workflows/build-windows-msvc.yml
vendored
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
name: Windows Build
|
||||
on:
|
||||
push:
|
||||
branches: [development]
|
||||
pull_request:
|
||||
branches: [development]
|
||||
concurrency:
|
||||
group: ci-${{github.actor}}-${{github.head_ref || github.run_number}}-${{github.ref}}-windows
|
||||
cancel-in-progress: true
|
||||
jobs:
|
||||
build-windows:
|
||||
if: github.repository == 'TorqueGameEngines/Torque3D'
|
||||
name: ${{matrix.config.name}}
|
||||
runs-on: windows-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
config:
|
||||
- {
|
||||
name: "Windows Latest MSVC",
|
||||
build_type: "Release",
|
||||
cc: "cl",
|
||||
cxx: "cl",
|
||||
environment_script: "C:/Program Files (x86)/Microsoft Visual Studio/2022/Enterprise/VC/Auxiliary/Build/vcvars64.bat",
|
||||
generator: "Visual Studio 17 2022"
|
||||
}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: ilammy/msvc-dev-cmd@v1
|
||||
- name: Print env
|
||||
run: |
|
||||
echo github.event.action: ${{ github.event.action }}
|
||||
echo github.event_name: ${{ github.event_name }}
|
||||
|
||||
- name: Setup MSVC problem matcher
|
||||
uses: ammaraskar/msvc-problem-matcher@master
|
||||
|
||||
- name: Install Dependencies For ${{matrix.config.name}}
|
||||
run: |
|
||||
cmake --version
|
||||
cmd "${{matrix.config.environment_script}}"
|
||||
|
||||
- name: Configure, Build & Install
|
||||
uses: threeal/cmake-action@v1.2.0
|
||||
with:
|
||||
source-dir: ${{github.workspace}}
|
||||
build-dir: ${{github.workspace}}/build
|
||||
c-compiler: ${{matrix.config.cc}}
|
||||
cxx-compiler: ${{matrix.config.cxx}}
|
||||
generator: ${{matrix.config.generator}}
|
||||
options: CMAKE_BUILD_TYPE=${{matrix.config.build_type}} TORQUE_APP_NAME=Torque3D TORQUE_TESTING=ON
|
||||
run-build: true
|
||||
build-args: --config ${{matrix.config.build_type}} --target install
|
||||
|
||||
- name: Unit Tests
|
||||
run: |
|
||||
cd "${{github.workspace}}/My Projects/Torque3D/game"
|
||||
./Torque3D.exe runTests.tscript
|
||||
|
||||
- name: Upload Artifact
|
||||
uses: ./.github/actions/upload-artifact
|
||||
with:
|
||||
name: torque3dWindowsMSVCUnitTest
|
||||
94
.github/workflows/cmake.yml
vendored
94
.github/workflows/cmake.yml
vendored
|
|
@ -1,94 +0,0 @@
|
|||
name: CMake
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ development ]
|
||||
pull_request:
|
||||
branches: [ development ]
|
||||
|
||||
env:
|
||||
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
|
||||
BUILD_TYPE: Release
|
||||
|
||||
jobs:
|
||||
build:
|
||||
if: github.repository == 'TorqueGameEngines/Torque3D'
|
||||
# The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac.
|
||||
# You can convert this to a matrix build if you need cross-platform coverage.
|
||||
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
|
||||
runs-on: ${{matrix.os}}
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ ubuntu-latest, macos-latest, windows-latest ]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: seanmiddleditch/gha-setup-ninja@master
|
||||
- uses: ilammy/msvc-dev-cmd@v1
|
||||
- name: Setup Environment
|
||||
run: |
|
||||
if [ "$RUNNER_OS" == "Linux" ]; then
|
||||
sudo apt-get update && \
|
||||
sudo apt-get install -y \
|
||||
build-essential \
|
||||
nasm \
|
||||
libogg-dev \
|
||||
libxft-dev \
|
||||
libx11-dev \
|
||||
libxxf86vm-dev \
|
||||
libopenal-dev \
|
||||
libfreetype6-dev \
|
||||
libxcursor-dev \
|
||||
libxinerama-dev \
|
||||
libxi-dev \
|
||||
libxrandr-dev \
|
||||
libxss-dev \
|
||||
libglu1-mesa-dev \
|
||||
libgtk-3-dev
|
||||
fi
|
||||
shell: bash
|
||||
- name: Configure CMake
|
||||
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
|
||||
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
|
||||
run: cmake -B ${{github.workspace}}/build -G Ninja -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DTORQUE_APP_NAME=Torque3D -DTORQUE_TESTING=ON
|
||||
|
||||
- name: Build
|
||||
# Build your program with the given configuration
|
||||
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} --target install
|
||||
|
||||
- name: Test
|
||||
run: |
|
||||
cd "${{github.workspace}}/My Projects/Torque3D/game"
|
||||
if [ "$RUNNER_OS" == "macOS" ]; then
|
||||
./Torque3D.app/Contents/MacOS/Torque3D runTests.tscript
|
||||
else
|
||||
./Torque3D runTests.tscript
|
||||
fi
|
||||
shell: bash
|
||||
|
||||
# Make all paths conform to the Unix runner setup:
|
||||
- name: Replace Absolute Paths In Test Report
|
||||
run: |
|
||||
import os
|
||||
dir = os.environ["WorkspaceDirectory"]
|
||||
filePath = dir + "/My Projects/Torque3D/game/test_detail.xml"
|
||||
f = open(filePath, 'r')
|
||||
filedata = f.read()
|
||||
f.close()
|
||||
|
||||
filedata = filedata.replace(dir, "/home/runner/work/Torque3D/Torque3D").replace("\\", "/")
|
||||
|
||||
f = open(filePath, 'w')
|
||||
f.write(filedata)
|
||||
f.close()
|
||||
shell: python
|
||||
env:
|
||||
WorkspaceDirectory: ${{github.workspace}}
|
||||
|
||||
- name: Upload Test Report
|
||||
uses: actions/upload-artifact@v3
|
||||
if: always() # always run even if the previous step fails
|
||||
with:
|
||||
name: junit-test-results-${{ runner.os }}
|
||||
path: '**/My Projects/Torque3D/game/test_detail.xml'
|
||||
retention-days: 1
|
||||
70
.github/workflows/test-results.yml
vendored
70
.github/workflows/test-results.yml
vendored
|
|
@ -1,44 +1,40 @@
|
|||
name: Report Test Results
|
||||
on:
|
||||
workflow_run:
|
||||
workflows: [ "CMake" ]
|
||||
types: [ completed ]
|
||||
workflows: ["Windows Build", "Linux Build", "MacOSX Build"]
|
||||
types:
|
||||
- completed
|
||||
|
||||
permissions:
|
||||
checks: write
|
||||
checks: write
|
||||
|
||||
jobs:
|
||||
checks:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
# See https://docs.github.com/en/actions/learn-github-actions/variables#default-environment-variables
|
||||
# for a list of possible values
|
||||
- name: Download Windows Test Report
|
||||
uses: dawidd6/action-download-artifact@v2
|
||||
with:
|
||||
path: Windows
|
||||
name: junit-test-results-Windows
|
||||
workflow: ${{ github.event.workflow.id }}
|
||||
run_id: ${{ github.event.workflow_run.id }}
|
||||
|
||||
- name: Download Linux Test Report
|
||||
uses: dawidd6/action-download-artifact@v2
|
||||
with:
|
||||
path: Linux
|
||||
name: junit-test-results-Linux
|
||||
workflow: ${{ github.event.workflow.id }}
|
||||
run_id: ${{ github.event.workflow_run.id }}
|
||||
|
||||
- name: Download Mac Test Report
|
||||
uses: dawidd6/action-download-artifact@v2
|
||||
with:
|
||||
path: macOS
|
||||
name: junit-test-results-macOS
|
||||
workflow: ${{ github.event.workflow.id }}
|
||||
run_id: ${{ github.event.workflow_run.id }}
|
||||
|
||||
- name: Publish Test Report
|
||||
uses: mikepenz/action-junit-report@v3
|
||||
with:
|
||||
commit: ${{github.event.workflow_run.head_sha}}
|
||||
report_paths: '**/My Projects/Torque3D/game/test_detail.xml'
|
||||
checks:
|
||||
name: ${{matrix.config.name}}
|
||||
runs-on: ${{matrix.config.runos}}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
config:
|
||||
- {
|
||||
name: "Windows Test Results",
|
||||
runos: windows-latest,
|
||||
artifact-name: "torque3dLinuxGCCUnitTest"
|
||||
}
|
||||
- {
|
||||
name: "Linux Test Results",
|
||||
artifact-name: "torque3dLinuxGCCUnitTest"
|
||||
}
|
||||
- {
|
||||
name: "Mac Test Results",
|
||||
artifact-name: "torque3dMacOSXCLANGUnitTest"
|
||||
}
|
||||
|
||||
steps:
|
||||
- name: Test Reporter
|
||||
uses: phoenix-actions/test-reporting@v12
|
||||
with:
|
||||
artifact: ${{matrix.config.artifact-name}}
|
||||
name: ${{matrix.config.name}}
|
||||
path: "**/My Projects/Torque3D/game/test_detail.xml"
|
||||
reporter: java-junit
|
||||
|
|
|
|||
|
|
@ -1,15 +1,66 @@
|
|||
cmake_minimum_required (VERSION 3.10.2)
|
||||
include("${CMAKE_SOURCE_DIR}/Tools/CMake/torque_macros.cmake")
|
||||
include("${CMAKE_SOURCE_DIR}/Tools/CMake/torque_configs.cmake")
|
||||
cmake_minimum_required (VERSION 3.21.0)
|
||||
set (CMAKE_CXX_STANDARD 17)
|
||||
|
||||
set_property(GLOBAL PROPERTY USE_FOLDERS TRUE)
|
||||
set(TORQUE_LIBS_FOLDER_NAME "Libs" CACHE STRING "The solution folder name to place all libs under")
|
||||
# Ensure multi-core compilation is enabled for everything
|
||||
add_compile_options($<$<CXX_COMPILER_ID:MSVC>:/MP>)
|
||||
|
||||
project(${TORQUE_APP_NAME})
|
||||
|
||||
# An application name must be set first
|
||||
set(TORQUE_APP_NAME "" CACHE STRING "the app name")
|
||||
|
||||
set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/temp" CACHE PATH "default install path" FORCE )
|
||||
|
||||
if("${TORQUE_APP_NAME}" STREQUAL "")
|
||||
message(FATAL_ERROR "Please set TORQUE_APP_NAME first")
|
||||
endif()
|
||||
|
||||
project(${TORQUE_APP_NAME})
|
||||
# Once an app name is determined, we know what our project pathing structure should look like
|
||||
set(TORQUE_APP_ROOT_DIRECTORY "${CMAKE_SOURCE_DIR}/My Projects/${TORQUE_APP_NAME}")
|
||||
set(TORQUE_APP_GAME_DIRECTORY "${TORQUE_APP_ROOT_DIRECTORY}/game")
|
||||
|
||||
add_subdirectory(Tools/CMake)
|
||||
# Ensure all possible configurations end up in the project directory
|
||||
set(CMAKE_INSTALL_PREFIX "${TORQUE_APP_ROOT_DIRECTORY}")
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${TORQUE_APP_GAME_DIRECTORY}")
|
||||
foreach( OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES} )
|
||||
string( TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIG )
|
||||
set( CMAKE_RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG} "${TORQUE_APP_GAME_DIRECTORY}" )
|
||||
endforeach( OUTPUTCONFIG CMAKE_CONFIGURATION_TYPES )
|
||||
|
||||
# Detect CPU Information
|
||||
if (CMAKE_SYSTEM_PROCESSOR MATCHES "arm")
|
||||
if( CMAKE_CXX_SIZEOF_DATA_PTR EQUAL 8 )
|
||||
set( TORQUE_CPU_ARM64 ON )
|
||||
elseif( CMAKE_CXX_SIZEOF_DATA_PTR EQUAL 4 )
|
||||
set( TORQUE_CPU_ARM32 ON )
|
||||
endif()
|
||||
else()
|
||||
if( CMAKE_CXX_SIZEOF_DATA_PTR EQUAL 8 )
|
||||
set( TORQUE_CPU_X64 ON )
|
||||
elseif( CMAKE_CXX_SIZEOF_DATA_PTR EQUAL 4 )
|
||||
set( TORQUE_CPU_X32 ON )
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NOT TORQUE_SCRIPT_EXTENSION)
|
||||
set(TORQUE_SCRIPT_EXTENSION "tscript" CACHE STRING "The default script extension to use for TorqueScript files")
|
||||
endif()
|
||||
mark_as_advanced(TORQUE_SCRIPT_EXTENSION)
|
||||
|
||||
set(TORQUE_MODULE_USER_PATH "" CACHE PATH "Additional search path for modules aside from the default Tools/CMake/modules.")
|
||||
mark_as_advanced(TORQUE_MODULE_USER_PATH)
|
||||
|
||||
|
||||
# Install Torque template
|
||||
if(NOT TORQUE_TEMPLATE)
|
||||
set(TORQUE_TEMPLATE "BaseGame" CACHE STRING "the template to use")
|
||||
endif()
|
||||
|
||||
if (NOT TORQUE_INSTALLED_TEMPLATE)
|
||||
installTemplate(${TORQUE_TEMPLATE})
|
||||
set(TORQUE_INSTALLED_TEMPLATE TRUE CACHE BOOL "Whether or not the game template is installed. This may be reset to false (or removed) to force a reinstall.")
|
||||
endif(NOT TORQUE_INSTALLED_TEMPLATE)
|
||||
|
||||
# Generate torqueConfig.h in our temp directory
|
||||
configure_file("${CMAKE_SOURCE_DIR}/Tools/CMake/torqueConfig.h.in" "${CMAKE_BINARY_DIR}/temp/torqueConfig.h")
|
||||
|
||||
add_subdirectory(Engine)
|
||||
|
|
|
|||
5
Engine/CMakeLists.txt
Normal file
5
Engine/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
# Add engine libs first
|
||||
add_subdirectory(lib)
|
||||
|
||||
# Handle engine sources
|
||||
add_subdirectory(source)
|
||||
261
Engine/lib/CMakeLists.txt
Normal file
261
Engine/lib/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,261 @@
|
|||
# Ask CMake to perform builds in a temporary directory for all of these.
|
||||
# We also use EXCLUDE_FROM_ALL to ensure we only build and install what we want
|
||||
#ZLIB
|
||||
get_filename_component(ZLIB_ROOT "zlib" REALPATH BASE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
set(ZLIB_ROOT "${ZLIB_ROOT}" CACHE STRING "ZLib root location" FORCE)
|
||||
mark_as_advanced(ZLIB_ROOT)
|
||||
# Png depends on zlib
|
||||
add_subdirectory(zlib ${CMAKE_BINARY_DIR}/temp/zlib EXCLUDE_FROM_ALL)
|
||||
|
||||
if(APPLE)
|
||||
enable_language(OBJC)
|
||||
advanced_option(AL_ALEXT_PROTOTYPES "Use Extended OpenAL options" OFF)
|
||||
else()
|
||||
advanced_option(AL_ALEXT_PROTOTYPES "Use Extended OpenAL options" ON)
|
||||
endif()
|
||||
|
||||
if(AL_ALEXT_PROTOTYPES)
|
||||
addDef( "AL_ALEXT_PROTOTYPES" )
|
||||
endif()
|
||||
|
||||
#SDL
|
||||
set(SDL_SHARED ON CACHE BOOL "Build a shared version of the library" FORCE)
|
||||
set(SDL_STATIC OFF CACHE BOOL "Build a static version of the library" FORCE)
|
||||
mark_as_advanced(SDL2MAIN_LIBRARY)
|
||||
mark_as_advanced(SDL2_CORE_LIBRARY)
|
||||
mark_as_advanced(SDL2_INCLUDE_DIR)
|
||||
mark_as_advanced(SDL2_DISABLE_INSTALL)
|
||||
mark_as_advanced(SDL2_DISABLE_SDL2MAIN)
|
||||
mark_as_advanced(SDL2_DISABLE_UNINSTALL)
|
||||
mark_as_advanced(SDL_3DNOW)
|
||||
mark_as_advanced(SDL_ALSA)
|
||||
mark_as_advanced(SDL_ALTIVEC)
|
||||
mark_as_advanced(SDL_ARMNEON)
|
||||
mark_as_advanced(SDL_ARMSIMD)
|
||||
mark_as_advanced(SDL_ARTS)
|
||||
mark_as_advanced(SDL_ASAN)
|
||||
mark_as_advanced(SDL_ASSEMBLY)
|
||||
mark_as_advanced(SDL_ASSERTIONS)
|
||||
mark_as_advanced(SDL_ATOMIC)
|
||||
mark_as_advanced(SDL_AUDIO)
|
||||
mark_as_advanced(SDL_BACKGROUNDING_SIGNAL)
|
||||
mark_as_advanced(SDL_CCACHE)
|
||||
mark_as_advanced(SDL_CLOCK_GETTIME)
|
||||
mark_as_advanced(SDL_COCOA)
|
||||
mark_as_advanced(SDL_CPUINFO)
|
||||
mark_as_advanced(SDL_DIRECTFB)
|
||||
mark_as_advanced(SDL_DIRECTX)
|
||||
mark_as_advanced(SDL_DISKAUDIO)
|
||||
mark_as_advanced(SDL_DUMMYAUDIO)
|
||||
mark_as_advanced(SDL_DUMMYVIDEO)
|
||||
mark_as_advanced(SDL_ESD)
|
||||
mark_as_advanced(SDL_EVENTS)
|
||||
mark_as_advanced(SDL_FILE)
|
||||
mark_as_advanced(SDL_FILESYSTEM)
|
||||
mark_as_advanced(SDL_FORCE_STATIC_VCRT)
|
||||
mark_as_advanced(SDL_FOREGROUNDING_SIGNAL)
|
||||
mark_as_advanced(SDL_FUSIONSOUND)
|
||||
mark_as_advanced(SDL_GCC_ATOMICS)
|
||||
mark_as_advanced(SDL_HAPTIC)
|
||||
mark_as_advanced(SDL_HIDAPI)
|
||||
mark_as_advanced(SDL_HIDAPI_JOYSTICK)
|
||||
mark_as_advanced(SDL_HIDAPI_LIBUSB)
|
||||
mark_as_advanced(SDL_INSTALL_TESTS)
|
||||
mark_as_advanced(SDL_JACK)
|
||||
mark_as_advanced(SDL_JOYSTICK)
|
||||
mark_as_advanced(SDL_KMSDRM)
|
||||
mark_as_advanced(SDL_LIBC)
|
||||
mark_as_advanced(SDL_LIBSAMPLERATE)
|
||||
mark_as_advanced(SDL_LOADSO)
|
||||
mark_as_advanced(SDL_LOCALE)
|
||||
mark_as_advanced(SDL_METAL)
|
||||
mark_as_advanced(SDL_MISC)
|
||||
mark_as_advanced(SDL_MMX)
|
||||
mark_as_advanced(SDL_NAS)
|
||||
mark_as_advanced(SDL_OFFSCREEN)
|
||||
mark_as_advanced(SDL_OPENGL)
|
||||
mark_as_advanced(SDL_OPENGLES)
|
||||
mark_as_advanced(SDL_PIPEWIRE)
|
||||
mark_as_advanced(SDL_POWER)
|
||||
mark_as_advanced(SDL_PTHREADS)
|
||||
mark_as_advanced(SDL_PULSEAUDIO)
|
||||
mark_as_advanced(SDL_RENDER)
|
||||
mark_as_advanced(SDL_RENDER_D3D)
|
||||
mark_as_advanced(SDL_RENDER_METAL)
|
||||
mark_as_advanced(SDL_RPATH)
|
||||
mark_as_advanced(SDL_RPI)
|
||||
mark_as_advanced(SDL_SENSOR)
|
||||
mark_as_advanced(SDL_SHARED)
|
||||
mark_as_advanced(SDL_SNDIO)
|
||||
mark_as_advanced(SDL_SSE)
|
||||
mark_as_advanced(SDL_SSE2)
|
||||
mark_as_advanced(SDL_SSE3)
|
||||
mark_as_advanced(SDL_SSEMATH)
|
||||
mark_as_advanced(SDL_STATIC)
|
||||
mark_as_advanced(SDL_SYSTEM_ICONV)
|
||||
mark_as_advanced(SDL_TEST)
|
||||
mark_as_advanced(SDL_TESTS)
|
||||
mark_as_advanced(SDL_THREADS)
|
||||
mark_as_advanced(SDL_TIMERS)
|
||||
mark_as_advanced(SDL_TIMERS)
|
||||
mark_as_advanced(SDL_VENDOR_INFO)
|
||||
mark_as_advanced(SDL_VIDEO)
|
||||
mark_as_advanced(SDL_VIRTUAL_JOYSTICK)
|
||||
mark_as_advanced(SDL_VIVANTE)
|
||||
mark_as_advanced(SDL_VULKAN)
|
||||
mark_as_advanced(SDL_WASAPI)
|
||||
mark_as_advanced(SDL_WAYLAND)
|
||||
mark_as_advanced(SDL_WERROR)
|
||||
mark_as_advanced(SDL_X11)
|
||||
mark_as_advanced(SDL_XINPUT)
|
||||
|
||||
add_subdirectory(sdl ${CMAKE_BINARY_DIR}/temp/sdl2 EXCLUDE_FROM_ALL)
|
||||
add_subdirectory(nativeFileDialogs ${CMAKE_BINARY_DIR}/temp/nfd EXCLUDE_FROM_ALL)
|
||||
|
||||
# Assimp
|
||||
advanced_option(ASSIMP_HUNTER_ENABLED "Enable Hunter package manager support" OFF)
|
||||
set(ASSIMP_BUILD_NO_OWN_ZLIB ON CACHE BOOL "" FORCE)
|
||||
mark_as_advanced(ASSIMP_BUILD_NO_OWN_ZLIB)
|
||||
advanced_option(BUILD_SHARED_LIBS "Build package with shared libraries." OFF )
|
||||
advanced_option(ASSIMP_BUILD_FRAMEWORK "Build package as Mac OS X Framework bundle." OFF )
|
||||
advanced_option(ASSIMP_DOUBLE_PRECISION "Set to ON to enable double precision processing" OFF )
|
||||
advanced_option(ASSIMP_OPT_BUILD_PACKAGES "Set to ON to generate CPack configuration files and packaging targets" OFF )
|
||||
advanced_option(ASSIMP_ANDROID_JNIIOSYSTEM "Android JNI IOSystem support is active" OFF )
|
||||
advanced_option(ASSIMP_NO_EXPORT "Disable Assimp's export functionality." OFF )
|
||||
advanced_option(ASSIMP_BUILD_ASSIMP_TOOLS "If the supplementary tools for Assimp are built in addition to the library." OFF )
|
||||
advanced_option(ASSIMP_BUILD_SAMPLES "If the official samples are built as well (needs Glut)." OFF )
|
||||
advanced_option(ASSIMP_BUILD_TESTS "If the test suite for Assimp is built in addition to the library." OFF )
|
||||
advanced_option(ASSIMP_COVERALLS "Enable this to measure test coverage." OFF )
|
||||
advanced_option(ASSIMP_INSTALL "Disable this if you want to use assimp as a submodule." OFF )
|
||||
advanced_option(ASSIMP_WARNINGS_AS_ERRORS "Treat all warnings as errors." OFF )
|
||||
advanced_option(ASSIMP_ASAN "Enable AddressSanitizer." OFF )
|
||||
advanced_option(ASSIMP_UBSAN "Enable Undefined Behavior sanitizer." OFF )
|
||||
advanced_option(ASSIMP_BUILD_DOCS "Build documentation using Doxygen." OFF )
|
||||
advanced_option(ASSIMP_INJECT_DEBUG_POSTFIX "Inject debug postfix in .a/.so/.dll lib names" ON )
|
||||
advanced_option(ASSIMP_IGNORE_GIT_HASH "Don't call git to get the hash." ON )
|
||||
advanced_option(ASSIMP_BUILD_ZLIB "Build your own zlib" OFF )
|
||||
advanced_option(ASSIMP_ANDROID_JNIIOSYSTEM "Android JNI IOSystem support is active" ON)
|
||||
advanced_option(ASSIMP_BUILD_DRACO "If the Draco libraries are to be built. Primarily for glTF" OFF )
|
||||
advanced_option(ASSIMP_BUILD_NONFREE_C4D_IMPORTER "Build the C4D importer, which relies on the non-free Cineware SDK." OFF)
|
||||
IF(MSVC)
|
||||
advanced_option( ASSIMP_INSTALL_PDB "Install MSVC debug files." ON )
|
||||
endif()
|
||||
advanced_option(ASSIMP_RAPIDJSON_NO_MEMBER_ITERATOR "Suppress rapidjson warning on MSVC (NOTE: breaks android build)" ON )
|
||||
advanced_option(ASSIMP_BUILD_ALL_IMPORTERS_BY_DEFAULT "default value of all ASSIMP_BUILD_XXX_IMPORTER values" ON)
|
||||
advanced_option(ASSIMP_BUILD_ALL_EXPORTERS_BY_DEFAULT "default value of all ASSIMP_BUILD_XXX_EXPORTER values" ON)
|
||||
mark_as_advanced(ASSIMP_ARCHIVE_OUTPUT_DIRECTORY)
|
||||
mark_as_advanced(ASSIMP_BIN_INSTALL_DIR)
|
||||
mark_as_advanced(ASSIMP_LIB_INSTALL_DIR)
|
||||
mark_as_advanced(ASSIMP_INCLUDE_INSTALL_DIR)
|
||||
mark_as_advanced(ASSIMP_LIBRARY_OUTPUT_DIRECTORY)
|
||||
mark_as_advanced(ASSIMP_LIBRARY_SUFFIX)
|
||||
mark_as_advanced(ASSIMP_PACKAGE_VERSION)
|
||||
mark_as_advanced(ASSIMP_RUNTIME_OUTPUT_DIRECTORY)
|
||||
add_subdirectory(assimp ${CMAKE_BINARY_DIR}/temp/assimp EXCLUDE_FROM_ALL)
|
||||
target_compile_definitions(assimp PUBLIC ASSIMP_BUILD_NO_OWN_ZLIB)
|
||||
if (TORQUE_CPU_ARM32 OR TORQUE_CPU_ARM64)
|
||||
set(PNG_ARM_NEON on CACHE BOOL "" FORCE)
|
||||
endif (TORQUE_CPU_ARM32 OR TORQUE_CPU_ARM64)
|
||||
|
||||
#PNG
|
||||
set(PNG_STATIC on CACHE BOOL "" FORCE)
|
||||
mark_as_advanced(PNG_STATIC)
|
||||
set(PNG_SHARED off CACHE BOOL "" FORCE)
|
||||
mark_as_advanced(PNG_SHARED)
|
||||
set(PNG_BUILD_ZLIB on CACHE BOOL "" FORCE)
|
||||
mark_as_advanced(PNG_BUILD_ZLIB)
|
||||
set(PNG_TESTS off CACHE BOOL "" FORCE)
|
||||
mark_as_advanced(PNG_TESTS)
|
||||
set(PNG_HARDWARE_OPTIMIZATIONS on CACHE BOOL "" FORCE)
|
||||
mark_as_advanced(PNG_HARDWARE_OPTIMIZATIONS)
|
||||
if(APPLE)
|
||||
set(PNG_FRAMEWORK on CACHE BOOL "" FORCE)
|
||||
addDef(PNG_DEBUG Debug)
|
||||
endif()
|
||||
mark_as_advanced(PNG_DEBUG)
|
||||
mark_as_advanced(PNG_FRAMEWORK)
|
||||
mark_as_advanced(PNG_PREFIX)
|
||||
add_subdirectory(lpng ${CMAKE_BINARY_DIR}/temp/lpng EXCLUDE_FROM_ALL)
|
||||
|
||||
|
||||
add_subdirectory(ljpeg ${CMAKE_BINARY_DIR}/temp/ljpeg EXCLUDE_FROM_ALL)
|
||||
add_subdirectory(tinyxml ${CMAKE_BINARY_DIR}/temp/tinyxml EXCLUDE_FROM_ALL)
|
||||
add_subdirectory(opcode ${CMAKE_BINARY_DIR}/temp/opcode EXCLUDE_FROM_ALL)
|
||||
add_subdirectory(pcre ${CMAKE_BINARY_DIR}/temp/pcre EXCLUDE_FROM_ALL)
|
||||
add_subdirectory(convexDecomp ${CMAKE_BINARY_DIR}/temp/convexDecomp EXCLUDE_FROM_ALL)
|
||||
add_subdirectory(squish ${CMAKE_BINARY_DIR}/temp/squish EXCLUDE_FROM_ALL)
|
||||
add_subdirectory(collada ${CMAKE_BINARY_DIR}/temp/collada EXCLUDE_FROM_ALL)
|
||||
add_subdirectory(glad ${CMAKE_BINARY_DIR}/temp/glad EXCLUDE_FROM_ALL)
|
||||
|
||||
#hidden options
|
||||
if(TORQUE_SFX_OPENAL)
|
||||
advanced_option(TORQUE_OGGVORBIS "Enable OGG Vorbis" ON)
|
||||
advanced_option(ALSOFT_EAX "Enable legacy EAX extensions" ${WIN32})
|
||||
advanced_option(ALSOFT_INSTALL_EXAMPLES "Install example programs (alplay, alstream, ...)" ON)
|
||||
advanced_option(ALSOFT_INSTALL_UTILS "Install utility programs (openal-info, alsoft-config, ...)" ON)
|
||||
advanced_option(ALSOFT_UPDATE_BUILD_VERSION "Update git build version info" ON)
|
||||
mark_as_advanced(ALSOFT_REQUIRE_OBOE)
|
||||
mark_as_advanced(ALSOFT_REQUIRE_PIPEWIRE)
|
||||
mark_as_advanced(ALSOFT_REQUIRE_RTKIT)
|
||||
mark_as_advanced(ALSOFT_REQUIRE_SSE3)
|
||||
#Hide some unnecessary fields as advanced
|
||||
mark_as_advanced(ALSOFT_INSTALL_AMBDEC_PRESETS)
|
||||
mark_as_advanced(ALSOFT_BACKEND_DSOUND)
|
||||
mark_as_advanced(ALSOFT_BACKEND_MMDEVAPI)
|
||||
mark_as_advanced(ALSOFT_BACKEND_WAVE)
|
||||
mark_as_advanced(ALSOFT_BACKEND_WINMM)
|
||||
mark_as_advanced(ALSOFT_INSTALL_CONFIG)
|
||||
mark_as_advanced(ALSOFT_CPUEXT_SSE)
|
||||
mark_as_advanced(ALSOFT_CPUEXT_SSE2)
|
||||
mark_as_advanced(ALSOFT_CPUEXT_SSE3)
|
||||
mark_as_advanced(ALSOFT_CPUEXT_SSE4_1)
|
||||
mark_as_advanced(ALSOFT_DLOPEN)
|
||||
mark_as_advanced(ALSOFT_EMBED_HRTF_DATA)
|
||||
mark_as_advanced(ALSOFT_EXAMPLES)
|
||||
mark_as_advanced(ALSOFT_INSTALL_HRTF_DATA)
|
||||
mark_as_advanced(ALSOFT_INSTALL)
|
||||
mark_as_advanced(ALSOFT_NO_CONFIG_UTIL)
|
||||
mark_as_advanced(ALSOFT_NO_UID_DEFS)
|
||||
mark_as_advanced(ALSOFT_REQUIRE_ALSA)
|
||||
mark_as_advanced(ALSOFT_REQUIRE_COREAUDIO)
|
||||
mark_as_advanced(ALSOFT_REQUIRE_DSOUND)
|
||||
mark_as_advanced(ALSOFT_REQUIRE_JACK)
|
||||
mark_as_advanced(ALSOFT_REQUIRE_MMDEVAPI)
|
||||
mark_as_advanced(ALSOFT_REQUIRE_NEON)
|
||||
mark_as_advanced(ALSOFT_REQUIRE_OPENSL)
|
||||
mark_as_advanced(ALSOFT_REQUIRE_OSS)
|
||||
mark_as_advanced(ALSOFT_REQUIRE_PORTAUDIO)
|
||||
mark_as_advanced(ALSOFT_REQUIRE_PULSEAUDIO)
|
||||
mark_as_advanced(ALSOFT_REQUIRE_QSA)
|
||||
mark_as_advanced(ALSOFT_REQUIRE_SNDIO)
|
||||
mark_as_advanced(ALSOFT_REQUIRE_SOLARIS)
|
||||
mark_as_advanced(ALSOFT_REQUIRE_SSE)
|
||||
mark_as_advanced(ALSOFT_REQUIRE_SSE2)
|
||||
mark_as_advanced(ALSOFT_REQUIRE_SSE4_1)
|
||||
mark_as_advanced(ALSOFT_REQUIRE_WINMM)
|
||||
mark_as_advanced(ALSOFT_TESTS)
|
||||
mark_as_advanced(ALSOFT_UTILS)
|
||||
mark_as_advanced(ALSOFT_WERROR)
|
||||
mark_as_advanced(COREAUDIO_FRAMEWORK)
|
||||
mark_as_advanced(CMAKE_DEBUG_POSTFIX)
|
||||
mark_as_advanced(FORCE_STATIC_VCRT)
|
||||
mark_as_advanced(ALSOFT_BACKEND_WASAPI)
|
||||
mark_as_advanced(ALSOFT_BUILD_ROUTER)
|
||||
mark_as_advanced(ALSOFT_REQUIRE_SDL2)
|
||||
mark_as_advanced(ALSOFT_REQUIRE_WASAPI)
|
||||
mark_as_advanced(ALSOFT_BACKEND_COREAUDIO)
|
||||
mark_as_advanced(ALSOFT_OSX_FRAMEWORK)
|
||||
mark_as_advanced(ALSOFT_STATIC_LIBGCC)
|
||||
mark_as_advanced(ALSOFT_STATIC_STDCXX)
|
||||
mark_as_advanced(AUDIOTOOLBOX_LIBRARY)
|
||||
mark_as_advanced(AUDIOUNIT_INCLUDE_DIR)
|
||||
endif()
|
||||
|
||||
add_subdirectory(libvorbis ${CMAKE_BINARY_DIR}/temp/libvorbis EXCLUDE_FROM_ALL)
|
||||
add_subdirectory(libogg ${CMAKE_BINARY_DIR}/temp/libogg EXCLUDE_FROM_ALL)
|
||||
add_subdirectory(libtheora ${CMAKE_BINARY_DIR}/temp/libtheora EXCLUDE_FROM_ALL)
|
||||
|
||||
if(TORQUE_TESTING)
|
||||
add_subdirectory(gtest ${CMAKE_BINARY_DIR}/temp/gtest EXCLUDE_FROM_ALL)
|
||||
endif()
|
||||
#endif()
|
||||
43
Engine/lib/Torque_postBuild.cmake
Normal file
43
Engine/lib/Torque_postBuild.cmake
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
################# Set Engine Linkages ###################
|
||||
|
||||
# When on Windows, we need to link against winsock and windows codecs
|
||||
if (WIN32)
|
||||
set(TORQUE_LINK_LIBRARIES ${TORQUE_LINK_LIBRARIES} WS2_32.LIB windowscodecs.lib)
|
||||
if (TORQUE_D3D11)
|
||||
set(TORQUE_LINK_LIBRARIES ${TORQUE_LINK_LIBRARIES} dxguid.lib)
|
||||
endif (TORQUE_D3D11)
|
||||
endif (WIN32)
|
||||
|
||||
# Only link Apple frameworks when on an Apple platform
|
||||
if (APPLE)
|
||||
addFramework("Cocoa")
|
||||
addFramework("AppKit")
|
||||
addFramework("CoreData")
|
||||
addFramework("Foundation")
|
||||
#These are needed by sdl2 static lib
|
||||
addFramework("ForceFeedback")
|
||||
addFramework("IOKit")
|
||||
#grrr damn you sdl!
|
||||
addFramework("Carbon")
|
||||
set(TORQUE_LINK_LIBRARIES ${TORQUE_LINK_LIBRARIES} iconv)
|
||||
if(NOT TORQUE_DEDICATED)
|
||||
addFramework("OpenGL")
|
||||
addFramework("CoreVideo")
|
||||
if(TORQUE_SFX_OPENAL)
|
||||
addFramework("OpenAL")
|
||||
addFramework("CoreAudio")
|
||||
addFramework("AudioUnit")
|
||||
addFramework("AudioToolbox")
|
||||
endif(TORQUE_SFX_OPENAL)
|
||||
endif()
|
||||
endif (APPLE)
|
||||
|
||||
set(TORQUE_LINK_LIBRARIES ${TORQUE_LINK_LIBRARIES} nativeFileDialogs)
|
||||
|
||||
# Linux requires X11 & freetype
|
||||
if (UNIX AND NOT APPLE)
|
||||
set(TORQUE_LINK_LIBRARIES ${TORQUE_LINK_LIBRARIES} "X11" "Xft" "dl" "pthread")
|
||||
find_package(Freetype REQUIRED)
|
||||
set(TORQUE_INCLUDE_DIRECTORIES ${TORQUE_INCLUDE_DIRECTORIES} ${FREETYPE_INCLUDE_DIRS})
|
||||
set(TORQUE_LINK_LIBRARIES ${TORQUE_LINK_LIBRARIES} ${FREETYPE_LIBRARIES})
|
||||
endif (UNIX AND NOT APPLE)
|
||||
127
Engine/lib/assimp/.clang-format
Normal file
127
Engine/lib/assimp/.clang-format
Normal file
|
|
@ -0,0 +1,127 @@
|
|||
# Commented out parameters are those with the same value as base LLVM style
|
||||
# We can uncomment them if we want to change their value, or enforce the
|
||||
# chosen value in case the base style changes (last sync: Clang 6.0.1).
|
||||
---
|
||||
### General config, applies to all languages ###
|
||||
BasedOnStyle: LLVM
|
||||
AccessModifierOffset: -4
|
||||
AlignAfterOpenBracket: DontAlign
|
||||
# AlignConsecutiveAssignments: false
|
||||
# AlignConsecutiveDeclarations: false
|
||||
# AlignEscapedNewlines: Right
|
||||
# AlignOperands: true
|
||||
AlignTrailingComments: false
|
||||
AllowAllParametersOfDeclarationOnNextLine: false
|
||||
# AllowShortBlocksOnASingleLine: false
|
||||
AllowShortCaseLabelsOnASingleLine: true
|
||||
AllowShortFunctionsOnASingleLine: Inline
|
||||
AllowShortIfStatementsOnASingleLine: true
|
||||
# AllowShortLoopsOnASingleLine: false
|
||||
# AlwaysBreakAfterDefinitionReturnType: None
|
||||
# AlwaysBreakAfterReturnType: None
|
||||
# AlwaysBreakBeforeMultilineStrings: false
|
||||
# AlwaysBreakTemplateDeclarations: false
|
||||
# BinPackArguments: true
|
||||
# BinPackParameters: true
|
||||
# BraceWrapping:
|
||||
# AfterClass: false
|
||||
# AfterControlStatement: false
|
||||
# AfterEnum: false
|
||||
# AfterFunction: false
|
||||
# AfterNamespace: false
|
||||
# AfterObjCDeclaration: false
|
||||
# AfterStruct: false
|
||||
# AfterUnion: false
|
||||
# AfterExternBlock: false
|
||||
# BeforeCatch: false
|
||||
# BeforeElse: false
|
||||
# IndentBraces: false
|
||||
# SplitEmptyFunction: true
|
||||
# SplitEmptyRecord: true
|
||||
# SplitEmptyNamespace: true
|
||||
# BreakBeforeBinaryOperators: None
|
||||
# BreakBeforeBraces: Attach
|
||||
# BreakBeforeInheritanceComma: false
|
||||
BreakBeforeTernaryOperators: false
|
||||
# BreakConstructorInitializersBeforeComma: false
|
||||
BreakConstructorInitializers: AfterColon
|
||||
# BreakStringLiterals: true
|
||||
ColumnLimit: 0
|
||||
# CommentPragmas: '^ IWYU pragma:'
|
||||
# CompactNamespaces: false
|
||||
ConstructorInitializerAllOnOneLineOrOnePerLine: true
|
||||
ConstructorInitializerIndentWidth: 8
|
||||
ContinuationIndentWidth: 8
|
||||
Cpp11BracedListStyle: false
|
||||
# DerivePointerAlignment: false
|
||||
# DisableFormat: false
|
||||
# ExperimentalAutoDetectBinPacking: false
|
||||
# FixNamespaceComments: true
|
||||
# ForEachMacros:
|
||||
# - foreach
|
||||
# - Q_FOREACH
|
||||
# - BOOST_FOREACH
|
||||
# IncludeBlocks: Preserve
|
||||
IncludeCategories:
|
||||
- Regex: '".*"'
|
||||
Priority: 1
|
||||
- Regex: '^<.*\.h>'
|
||||
Priority: 2
|
||||
- Regex: '^<.*'
|
||||
Priority: 3
|
||||
# IncludeIsMainRegex: '(Test)?$'
|
||||
IndentCaseLabels: false
|
||||
#IndentPPDirectives: AfterHash
|
||||
IndentWidth: 4
|
||||
# IndentWrappedFunctionNames: false
|
||||
# JavaScriptQuotes: Leave
|
||||
# JavaScriptWrapImports: true
|
||||
# KeepEmptyLinesAtTheStartOfBlocks: true
|
||||
# MacroBlockBegin: ''
|
||||
# MacroBlockEnd: ''
|
||||
# MaxEmptyLinesToKeep: 1
|
||||
# NamespaceIndentation: None
|
||||
# PenaltyBreakAssignment: 2
|
||||
# PenaltyBreakBeforeFirstCallParameter: 19
|
||||
# PenaltyBreakComment: 300
|
||||
# PenaltyBreakFirstLessLess: 120
|
||||
# PenaltyBreakString: 1000
|
||||
# PenaltyExcessCharacter: 1000000
|
||||
# PenaltyReturnTypeOnItsOwnLine: 60
|
||||
# PointerAlignment: Right
|
||||
# RawStringFormats:
|
||||
# - Delimiter: pb
|
||||
# Language: TextProto
|
||||
# BasedOnStyle: google
|
||||
# ReflowComments: true
|
||||
# SortIncludes: true
|
||||
# SortUsingDeclarations: true
|
||||
# SpaceAfterCStyleCast: false
|
||||
# SpaceAfterTemplateKeyword: true
|
||||
# SpaceBeforeAssignmentOperators: true
|
||||
# SpaceBeforeParens: ControlStatements
|
||||
# SpaceInEmptyParentheses: false
|
||||
# SpacesBeforeTrailingComments: 1
|
||||
# SpacesInAngles: false
|
||||
# SpacesInContainerLiterals: true
|
||||
# SpacesInCStyleCastParentheses: false
|
||||
# SpacesInParentheses: false
|
||||
# SpacesInSquareBrackets: false
|
||||
TabWidth: 4
|
||||
UseTab: Never
|
||||
---
|
||||
### C++ specific config ###
|
||||
Language: Cpp
|
||||
Standard: Cpp11
|
||||
---
|
||||
### ObjC specific config ###
|
||||
Language: ObjC
|
||||
Standard: Cpp11
|
||||
ObjCBlockIndentWidth: 4
|
||||
# ObjCSpaceAfterProperty: false
|
||||
# ObjCSpaceBeforeProtocolList: true
|
||||
---
|
||||
### Java specific config ###
|
||||
Language: Java
|
||||
# BreakAfterJavaFieldAnnotations: false
|
||||
...
|
||||
22
Engine/lib/assimp/.editorconfig
Normal file
22
Engine/lib/assimp/.editorconfig
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
# See <http://EditorConfig.org> for details
|
||||
|
||||
root = true
|
||||
|
||||
[CMakeLists.txt,*.cmake{,.in}]
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
indent_size = 2
|
||||
indent_style = space
|
||||
|
||||
[*.h.in]
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
indent_size = 4
|
||||
indent_style = space
|
||||
|
||||
[*.txt]
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
25
Engine/lib/assimp/BUILDBINARIES_EXAMPLE.bat
Normal file
25
Engine/lib/assimp/BUILDBINARIES_EXAMPLE.bat
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
:: This is an example file to generate binaries using Windows Operating System
|
||||
:: This script is configured to be executed from the source directory
|
||||
|
||||
:: Compiled binaries will be placed in BINARIES_DIR\code\CONFIG
|
||||
|
||||
:: NOTE
|
||||
:: The build process will generate a config.h file that is placed in BINARIES_DIR\include
|
||||
:: This file must be merged with SOURCE_DIR\include
|
||||
:: You should write yourself a script that copies the files where you want them.
|
||||
:: Also see: https://github.com/assimp/assimp/pull/2646
|
||||
|
||||
SET SOURCE_DIR=.
|
||||
SET GENERATOR=Visual Studio 16 2019
|
||||
|
||||
SET BINARIES_DIR="./build/Win32"
|
||||
cmake . -G "%GENERATOR%" -A Win32 -S %SOURCE_DIR% -B %BINARIES_DIR%
|
||||
cmake --build %BINARIES_DIR% --config debug
|
||||
cmake --build %BINARIES_DIR% --config release
|
||||
|
||||
SET BINARIES_DIR="./build/x64"
|
||||
cmake . -G "%GENERATOR%" -A x64 -S %SOURCE_DIR% -B %BINARIES_DIR%
|
||||
cmake --build %BINARIES_DIR% --config debug
|
||||
cmake --build %BINARIES_DIR% --config release
|
||||
|
||||
PAUSE
|
||||
112
Engine/lib/assimp/Build.md
Normal file
112
Engine/lib/assimp/Build.md
Normal file
|
|
@ -0,0 +1,112 @@
|
|||
# Build / Install Instructions
|
||||
|
||||
## Install on all platforms using vcpkg
|
||||
You can download and install assimp using the [vcpkg](https://github.com/Microsoft/vcpkg/) dependency manager:
|
||||
```bash
|
||||
git clone https://github.com/Microsoft/vcpkg.git
|
||||
cd vcpkg
|
||||
./bootstrap-vcpkg.sh
|
||||
./vcpkg integrate install
|
||||
vcpkg install assimp
|
||||
```
|
||||
The assimp port in vcpkg is kept up to date by Microsoft team members and community contributors. If the version is out of date, please [create an issue or pull request](https://github.com/Microsoft/vcpkg) on the vcpkg repository.
|
||||
|
||||
## Install on Ubuntu
|
||||
You can install the Asset-Importer-Lib via apt:
|
||||
```
|
||||
sudo apt-get update
|
||||
sudo apt-get install libassimp-dev
|
||||
```
|
||||
|
||||
## Install pyassimp
|
||||
You need to have pip installed:
|
||||
```
|
||||
pip install pyassimp
|
||||
```
|
||||
|
||||
## Manual build instructions
|
||||
|
||||
### Install CMake
|
||||
Asset-Importer-Lib can be build for a lot of different platforms. We are using cmake to generate the build environment for these via cmake. So you have to make sure that you have a working cmake-installation on your system. You can download it at https://cmake.org/ or for linux install it via
|
||||
```bash
|
||||
sudo apt-get install cmake
|
||||
```
|
||||
|
||||
### Get the source
|
||||
Make sure you have a working git-installation. Open a command prompt and clone the Asset-Importer-Lib via:
|
||||
```bash
|
||||
git clone https://github.com/assimp/assimp.git
|
||||
```
|
||||
### Build from source:
|
||||
```bash
|
||||
cd assimp
|
||||
cmake CMakeLists.txt
|
||||
cmake --build .
|
||||
```
|
||||
|
||||
### Build instructions for Windows with Visual-Studio
|
||||
|
||||
First you have to install Visual-Studio on your windows-system. You can get the Community-Version for free here: https://visualstudio.microsoft.com/de/downloads/
|
||||
To generate the build environment for your IDE open a command prompt, navigate to your repo and type:
|
||||
```bash
|
||||
cmake CMakeLists.txt
|
||||
```
|
||||
This will generate the project files for the visual studio. All dependencies used to build Asset-IMporter-Lib shall be part of the repo. If you want to use you own zlib.installation this is possible as well. Check the options for it.
|
||||
|
||||
### Build instructions for Windows with UWP
|
||||
See <https://stackoverflow.com/questions/40803170/cmake-uwp-using-cmake-to-build-universal-windows-app>
|
||||
|
||||
### Build instructions for Linux / Unix
|
||||
Open a terminal and got to your repository. You can generate the makefiles and build the library via:
|
||||
|
||||
```bash
|
||||
cmake CMakeLists.txt
|
||||
make -j4
|
||||
```
|
||||
The option -j descripes the number of parallel processes for the build. In this case make will try to use 4 cores for the build.
|
||||
|
||||
If you want to use a IDE for linux you can try QTCreator for instance.
|
||||
|
||||
### Build instructions for MinGW
|
||||
Older versions of MinGW's compiler (e.g. 5.1.0) do not support the -mbig_obj flag
|
||||
required to compile some of assimp's files, especially for debug builds.
|
||||
Version 7.3.0 of g++-mingw-w64 & gcc-mingw-w64 appears to work.
|
||||
|
||||
Please see [CMake Cross Compiling](https://cmake.org/cmake/help/latest/manual/cmake-toolchains.7.html#cross-compiling) for general information on CMake Toolchains.
|
||||
|
||||
Some users have had success building assimp using MinGW on Linux using [polly](https://github.com/ruslo/polly/).
|
||||
|
||||
The following toolchain, which is not maintained by assimp, seems to work on Linux: [linux-mingw-w64-gnuxx11.cmake](https://github.com/ruslo/polly/blob/master/linux-mingw-w64-gnuxx11.cmake)
|
||||
|
||||
The following toolchain may or may not be helpful for building assimp using MinGW on Windows (untested):
|
||||
[mingw-cxx17.cmake](https://github.com/ruslo/polly/blob/master/mingw-cxx17.cmake)
|
||||
|
||||
Besides the toolchain, compilation should be the same as for Linux / Unix.
|
||||
|
||||
### CMake build options
|
||||
The cmake-build-environment provides options to configure the build. The following options can be used:
|
||||
- **ASSIMP_HUNTER_ENABLED (default OFF)**: Enable Hunter package manager support.
|
||||
- **BUILD_SHARED_LIBS (default ON)**: Generation of shared libs (dll for windows, so for Linux). Set this to OFF to get a static lib.
|
||||
- **ASSIMP_BUILD_FRAMEWORK (default OFF, MacOnly)**: Build package as Mac OS X Framework bundle.
|
||||
- **ASSIMP_DOUBLE_PRECISION (default OFF)**: All data will be stored as double values.
|
||||
- **ASSIMP_OPT_BUILD_PACKAGES (default OFF)**: Set to ON to generate CPack configuration files and packaging targets.
|
||||
- **ASSIMP_ANDROID_JNIIOSYSTEM (default OFF)**: Android JNI IOSystem support is active.
|
||||
- **ASSIMP_NO_EXPORT (default OFF)**: Disable Assimp's export functionality.
|
||||
- **ASSIMP_BUILD_ZLIB (default OFF)**: Build our own zlib.
|
||||
- **ASSIMP_BUILD_ALL_EXPORTERS_BY_DEFAULT (default ON)**: Build Assimp with all exporter senabled.
|
||||
- **ASSIMP_BUILD_ALL_IMPORTERS_BY_DEFAULT (default ON)**: Build Assimp with all importer senabled.
|
||||
- **ASSIMP_BUILD_ASSIMP_TOOLS (default ON)**: If the supplementary tools for Assimp are built in addition to the library.
|
||||
- **ASSIMP_BUILD_SAMPLES (default OFF)**: If the official samples are built as well (needs Glut).
|
||||
- **ASSIMP_BUILD_TESTS (default ON)**: If the test suite for Assimp is built in addition to the library.
|
||||
- **ASSIMP_COVERALLS (default OFF)**: Enable this to measure test coverage.
|
||||
- **ASSIMP_INSTALL (default ON)**: Install Assimp library. Disable this if you want to use Assimp as a submodule.
|
||||
- **ASSIMP_WARNINGS_AS_ERRORS (default ON)**: Treat all warnings as errors.
|
||||
- **ASSIMP_ASAN (default OFF)**: Enable AddressSanitizer.
|
||||
- **ASSIMP_UBSAN (default OFF)**: Enable Undefined Behavior sanitizer.
|
||||
- **ASSIMP_BUILD_DOCS (default OFF)**: Build documentation using Doxygen. OBSOLETE, see https://github.com/assimp/assimp-docs
|
||||
- **ASSIMP_INJECT_DEBUG_POSTFIX (default ON)**: Inject debug postfix in .a/.so/.lib/.dll lib names
|
||||
- **ASSIMP_IGNORE_GIT_HASH (default OFF)**: Don't call git to get the hash.
|
||||
- **ASSIMP_INSTALL_PDB (default ON)**: Install MSVC debug files.
|
||||
- **USE_STATIC_CRT (default OFF)**: Link against the static MSVC runtime libraries.
|
||||
- **ASSIMP_BUILD_DRACO (default OFF)**: Build Draco libraries. Primarily for glTF.
|
||||
- **ASSIMP_BUILD_ASSIMP_VIEW (default ON, if DirectX found, OFF otherwise)**: Build Assimp view tool (requires DirectX).
|
||||
833
Engine/lib/assimp/CMakeLists.txt
Normal file
833
Engine/lib/assimp/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,833 @@
|
|||
# Open Asset Import Library (assimp)
|
||||
# ----------------------------------------------------------------------
|
||||
# Copyright (c) 2006-2022, assimp team
|
||||
#
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use of this software in source and binary forms,
|
||||
# with or without modification, are permitted provided that the
|
||||
# following conditions are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above
|
||||
# copyright notice, this list of conditions and the
|
||||
# following disclaimer.
|
||||
#
|
||||
# * Redistributions in binary form must reproduce the above
|
||||
# copyright notice, this list of conditions and the
|
||||
# following disclaimer in the documentation and/or other
|
||||
# materials provided with the distribution.
|
||||
#
|
||||
# * Neither the name of the assimp team, nor the names of its
|
||||
# contributors may be used to endorse or promote products
|
||||
# derived from this software without specific prior
|
||||
# written permission of the assimp team.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#----------------------------------------------------------------------
|
||||
SET(CMAKE_POLICY_DEFAULT_CMP0012 NEW)
|
||||
SET(CMAKE_POLICY_DEFAULT_CMP0074 NEW)
|
||||
SET(CMAKE_POLICY_DEFAULT_CMP0092 NEW)
|
||||
|
||||
CMAKE_MINIMUM_REQUIRED( VERSION 3.10 )
|
||||
|
||||
# Disabled importers: m3d for 5.1
|
||||
ADD_DEFINITIONS( -DASSIMP_BUILD_NO_M3D_IMPORTER)
|
||||
ADD_DEFINITIONS( -DASSIMP_BUILD_NO_M3D_EXPORTER)
|
||||
# Toggles the use of the hunter package manager
|
||||
option(ASSIMP_HUNTER_ENABLED "Enable Hunter package manager support" OFF)
|
||||
|
||||
IF(ASSIMP_HUNTER_ENABLED)
|
||||
include("cmake-modules/HunterGate.cmake")
|
||||
HunterGate(
|
||||
URL "https://github.com/cpp-pm/hunter/archive/v0.24.0.tar.gz"
|
||||
SHA1 "a3d7f4372b1dcd52faa6ff4a3bd5358e1d0e5efd"
|
||||
)
|
||||
|
||||
add_definitions(-DASSIMP_USE_HUNTER)
|
||||
ENDIF()
|
||||
|
||||
PROJECT(Assimp VERSION 5.2.4)
|
||||
|
||||
# All supported options ###############################################
|
||||
|
||||
OPTION( BUILD_SHARED_LIBS
|
||||
"Build package with shared libraries."
|
||||
ON
|
||||
)
|
||||
OPTION( ASSIMP_BUILD_FRAMEWORK
|
||||
"Build package as Mac OS X Framework bundle."
|
||||
OFF
|
||||
)
|
||||
OPTION( ASSIMP_DOUBLE_PRECISION
|
||||
"Set to ON to enable double precision processing"
|
||||
OFF
|
||||
)
|
||||
OPTION( ASSIMP_OPT_BUILD_PACKAGES
|
||||
"Set to ON to generate CPack configuration files and packaging targets"
|
||||
OFF
|
||||
)
|
||||
OPTION( ASSIMP_ANDROID_JNIIOSYSTEM
|
||||
"Android JNI IOSystem support is active"
|
||||
OFF
|
||||
)
|
||||
OPTION( ASSIMP_NO_EXPORT
|
||||
"Disable Assimp's export functionality."
|
||||
OFF
|
||||
)
|
||||
OPTION( ASSIMP_BUILD_ZLIB
|
||||
"Build your own zlib"
|
||||
OFF
|
||||
)
|
||||
OPTION( ASSIMP_BUILD_ASSIMP_TOOLS
|
||||
"If the supplementary tools for Assimp are built in addition to the library."
|
||||
OFF
|
||||
)
|
||||
OPTION ( ASSIMP_BUILD_SAMPLES
|
||||
"If the official samples are built as well (needs Glut)."
|
||||
OFF
|
||||
)
|
||||
OPTION ( ASSIMP_BUILD_TESTS
|
||||
"If the test suite for Assimp is built in addition to the library."
|
||||
ON
|
||||
)
|
||||
OPTION ( ASSIMP_COVERALLS
|
||||
"Enable this to measure test coverage."
|
||||
OFF
|
||||
)
|
||||
OPTION( ASSIMP_INSTALL
|
||||
"Disable this if you want to use assimp as a submodule."
|
||||
ON
|
||||
)
|
||||
OPTION ( ASSIMP_WARNINGS_AS_ERRORS
|
||||
"Treat all warnings as errors."
|
||||
ON
|
||||
)
|
||||
OPTION ( ASSIMP_ASAN
|
||||
"Enable AddressSanitizer."
|
||||
OFF
|
||||
)
|
||||
OPTION ( ASSIMP_UBSAN
|
||||
"Enable Undefined Behavior sanitizer."
|
||||
OFF
|
||||
)
|
||||
OPTION ( ASSIMP_BUILD_DOCS
|
||||
"Build documentation using Doxygen."
|
||||
OFF
|
||||
)
|
||||
OPTION( ASSIMP_INJECT_DEBUG_POSTFIX
|
||||
"Inject debug postfix in .a/.so/.dll lib names"
|
||||
ON
|
||||
)
|
||||
|
||||
OPTION ( ASSIMP_IGNORE_GIT_HASH
|
||||
"Don't call git to get the hash."
|
||||
OFF
|
||||
)
|
||||
|
||||
IF (WIN32)
|
||||
# Use subset of Windows.h
|
||||
ADD_DEFINITIONS( -DWIN32_LEAN_AND_MEAN )
|
||||
|
||||
IF(MSVC)
|
||||
OPTION( ASSIMP_INSTALL_PDB
|
||||
"Install MSVC debug files."
|
||||
ON )
|
||||
IF(NOT (MSVC_VERSION LESS 1900))
|
||||
# Multibyte character set is deprecated since at least MSVC2015 (possibly earlier)
|
||||
ADD_DEFINITIONS( -DUNICODE -D_UNICODE )
|
||||
ENDIF()
|
||||
|
||||
# Link statically against c/c++ lib to avoid missing redistriburable such as
|
||||
# "VCRUNTIME140.dll not found. Try reinstalling the app.", but give users
|
||||
# a choice to opt for the shared runtime if they want.
|
||||
option(USE_STATIC_CRT "Link against the static runtime libraries." OFF)
|
||||
|
||||
# The CMAKE_CXX_FLAGS vars can be overriden by some Visual Studio generators, so we use an alternative
|
||||
# global method here:
|
||||
if (${USE_STATIC_CRT})
|
||||
add_compile_options(
|
||||
$<$<CONFIG:>:/MT>
|
||||
$<$<CONFIG:Debug>:/MTd>
|
||||
$<$<CONFIG:Release>:/MT>
|
||||
)
|
||||
endif()
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
IF (IOS AND NOT ASSIMP_HUNTER_ENABLED)
|
||||
IF (NOT CMAKE_BUILD_TYPE)
|
||||
SET(CMAKE_BUILD_TYPE "Release")
|
||||
ENDIF ()
|
||||
ADD_DEFINITIONS(-DENABLE_BITCODE)
|
||||
ENDIF ()
|
||||
|
||||
|
||||
IF (ASSIMP_BUILD_FRAMEWORK)
|
||||
SET (BUILD_SHARED_LIBS ON)
|
||||
MESSAGE(STATUS "Framework bundle building enabled")
|
||||
ENDIF()
|
||||
|
||||
IF(NOT BUILD_SHARED_LIBS)
|
||||
MESSAGE(STATUS "Shared libraries disabled")
|
||||
SET(LINK_SEARCH_START_STATIC TRUE)
|
||||
SET(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_STATIC_LIBRARY_SUFFIX} ${CMAKE_FIND_LIBRARY_SUFFIXES})
|
||||
ELSE()
|
||||
MESSAGE(STATUS "Shared libraries enabled")
|
||||
ENDIF()
|
||||
|
||||
# Define here the needed parameters
|
||||
SET (ASSIMP_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
|
||||
SET (ASSIMP_VERSION_MINOR ${PROJECT_VERSION_MINOR})
|
||||
SET (ASSIMP_VERSION_PATCH ${PROJECT_VERSION_PATCH})
|
||||
SET (ASSIMP_VERSION ${ASSIMP_VERSION_MAJOR}.${ASSIMP_VERSION_MINOR}.${ASSIMP_VERSION_PATCH})
|
||||
SET (ASSIMP_SOVERSION 5)
|
||||
|
||||
SET( ASSIMP_PACKAGE_VERSION "0" CACHE STRING "the package-specific version used for uploading the sources" )
|
||||
if(NOT ASSIMP_HUNTER_ENABLED)
|
||||
# Enable C++17 support globally
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_C_STANDARD 99)
|
||||
endif()
|
||||
|
||||
IF(NOT ASSIMP_IGNORE_GIT_HASH)
|
||||
# Get the current working branch
|
||||
EXECUTE_PROCESS(
|
||||
COMMAND git rev-parse --abbrev-ref HEAD
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
OUTPUT_VARIABLE GIT_BRANCH
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
ERROR_QUIET
|
||||
)
|
||||
|
||||
# Get the latest abbreviated commit hash of the working branch
|
||||
EXECUTE_PROCESS(
|
||||
COMMAND git rev-parse --short=8 HEAD
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
OUTPUT_VARIABLE GIT_COMMIT_HASH
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
ERROR_QUIET
|
||||
)
|
||||
ENDIF()
|
||||
|
||||
IF(NOT GIT_COMMIT_HASH)
|
||||
SET(GIT_COMMIT_HASH 0)
|
||||
ENDIF()
|
||||
|
||||
IF(ASSIMP_DOUBLE_PRECISION)
|
||||
ADD_DEFINITIONS(-DASSIMP_DOUBLE_PRECISION)
|
||||
ENDIF()
|
||||
|
||||
INCLUDE_DIRECTORIES( BEFORE
|
||||
./
|
||||
code/
|
||||
include
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
${CMAKE_CURRENT_BINARY_DIR}/include
|
||||
)
|
||||
|
||||
LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake-modules" )
|
||||
SET(LIBASSIMP_COMPONENT "libassimp${ASSIMP_VERSION_MAJOR}.${ASSIMP_VERSION_MINOR}.${ASSIMP_VERSION_PATCH}" )
|
||||
SET(LIBASSIMP-DEV_COMPONENT "libassimp${ASSIMP_VERSION_MAJOR}.${ASSIMP_VERSION_MINOR}.${ASSIMP_VERSION_PATCH}-dev" )
|
||||
SET(CPACK_COMPONENTS_ALL assimp-bin ${LIBASSIMP_COMPONENT} ${LIBASSIMP-DEV_COMPONENT} assimp-dev)
|
||||
SET(ASSIMP_LIBRARY_SUFFIX "" CACHE STRING "Suffix to append to library names")
|
||||
|
||||
IF( UNIX )
|
||||
# Use GNUInstallDirs for Unix predefined directories
|
||||
INCLUDE(GNUInstallDirs)
|
||||
# Ensure that we do not run into issues like http://www.tcm.phy.cam.ac.uk/sw/inodes64.html on 32 bit linux
|
||||
IF( ${OPERATING_SYSTEM} MATCHES "Android")
|
||||
ELSE()
|
||||
IF ( CMAKE_SIZEOF_VOID_P EQUAL 4) # only necessary for 32-bit linux
|
||||
ADD_DEFINITIONS(-D_FILE_OFFSET_BITS=64 )
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
# Grouped compiler settings ########################################
|
||||
IF ((CMAKE_C_COMPILER_ID MATCHES "GNU") AND NOT MINGW)
|
||||
IF(NOT ASSIMP_HUNTER_ENABLED)
|
||||
SET(CMAKE_CXX_STANDARD 17)
|
||||
SET(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||
ENDIF()
|
||||
# hide all not-exported symbols
|
||||
IF(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "mips64" )
|
||||
SET(CMAKE_CXX_FLAGS "-mxgot -fvisibility=hidden -fno-strict-aliasing -Wall ${CMAKE_CXX_FLAGS}")
|
||||
SET(CMAKE_C_FLAGS "-fno-strict-aliasing ${CMAKE_C_FLAGS}")
|
||||
SET(LIBSTDC++_LIBRARIES -lstdc++)
|
||||
ELSE()
|
||||
SET(CMAKE_CXX_FLAGS "-fvisibility=hidden -fno-strict-aliasing -Wall ${CMAKE_CXX_FLAGS}")
|
||||
SET(CMAKE_C_FLAGS "-fno-strict-aliasing ${CMAKE_C_FLAGS}")
|
||||
SET(LIBSTDC++_LIBRARIES -lstdc++)
|
||||
ENDIF()
|
||||
ELSEIF(MSVC)
|
||||
# enable multi-core compilation with MSVC
|
||||
IF(CMAKE_CXX_COMPILER_ID MATCHES "Clang" ) # clang-cl
|
||||
ADD_COMPILE_OPTIONS(/bigobj /W4 /WX )
|
||||
ELSE() # msvc
|
||||
ADD_COMPILE_OPTIONS(/MP /bigobj /W4 /WX)
|
||||
ENDIF()
|
||||
# disable "elements of array '' will be default initialized" warning on MSVC2013
|
||||
IF(MSVC12)
|
||||
ADD_COMPILE_OPTIONS(/wd4351)
|
||||
ENDIF()
|
||||
ADD_COMPILE_OPTIONS(/wd4244) #supress warning for double to float conversion if Double precission is activated
|
||||
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /D_DEBUG /Zi /Od")
|
||||
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Zi")
|
||||
SET(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /DEBUG:FULL /PDBALTPATH:%_PDB% /OPT:REF /OPT:ICF")
|
||||
ELSEIF (CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
|
||||
IF(NOT ASSIMP_HUNTER_ENABLED)
|
||||
SET(CMAKE_CXX_STANDARD 17)
|
||||
SET(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||
ENDIF()
|
||||
SET(CMAKE_CXX_FLAGS "-fvisibility=hidden -fno-strict-aliasing -Wall -Wno-long-long ${CMAKE_CXX_FLAGS}" )
|
||||
SET(CMAKE_C_FLAGS "-fno-strict-aliasing ${CMAKE_C_FLAGS}")
|
||||
ELSEIF( MINGW )
|
||||
IF (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.0)
|
||||
message(FATAL_ERROR "MinGW is too old to be supported. Please update MinGW and try again.")
|
||||
ELSEIF(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.3)
|
||||
message(WARNING "MinGW is old, if you experience errors, update MinGW.")
|
||||
ENDIF()
|
||||
IF(NOT ASSIMP_HUNTER_ENABLED)
|
||||
SET(CMAKE_CXX_FLAGS "-std=gnu++17 ${CMAKE_CXX_FLAGS}")
|
||||
SET(CMAKE_C_FLAGS "-fPIC ${CMAKE_C_FLAGS}")
|
||||
ENDIF()
|
||||
IF (CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
SET(CMAKE_CXX_FLAGS "-fvisibility=hidden -fno-strict-aliasing -Wall -Wno-long-long -Wa,-mbig-obj -g ${CMAKE_CXX_FLAGS}")
|
||||
ELSE()
|
||||
SET(CMAKE_CXX_FLAGS "-fvisibility=hidden -fno-strict-aliasing -Wall -Wno-long-long -Wa,-mbig-obj -O3 ${CMAKE_CXX_FLAGS}")
|
||||
ENDIF()
|
||||
SET(CMAKE_C_FLAGS "-fno-strict-aliasing ${CMAKE_C_FLAGS}")
|
||||
ENDIF()
|
||||
|
||||
IF ( IOS AND NOT ASSIMP_HUNTER_ENABLED)
|
||||
IF (CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fembed-bitcode -Og")
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fembed-bitcode -Og")
|
||||
ELSE()
|
||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fembed-bitcode -O3")
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fembed-bitcode -O3")
|
||||
# Experimental for pdb generation
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
IF (ASSIMP_COVERALLS)
|
||||
MESSAGE(STATUS "Coveralls enabled")
|
||||
INCLUDE(Coveralls)
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0 -fprofile-arcs -ftest-coverage")
|
||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O0 -fprofile-arcs -ftest-coverage")
|
||||
ENDIF()
|
||||
|
||||
IF (ASSIMP_ASAN)
|
||||
MESSAGE(STATUS "AddressSanitizer enabled")
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address")
|
||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address")
|
||||
ENDIF()
|
||||
|
||||
IF (ASSIMP_UBSAN)
|
||||
MESSAGE(STATUS "Undefined Behavior sanitizer enabled")
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=undefined,shift,shift-exponent,integer-divide-by-zero,unreachable,vla-bound,null,return,signed-integer-overflow,bounds,float-divide-by-zero,float-cast-overflow,nonnull-attribute,returns-nonnull-attribute,bool,enum,vptr,pointer-overflow,builtin -fno-sanitize-recover=all")
|
||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=undefined,shift,shift-exponent,integer-divide-by-zero,unreachable,vla-bound,null,return,signed-integer-overflow,bounds,float-divide-by-zero,float-cast-overflow,nonnull-attribute,returns-nonnull-attribute,bool,enum,vptr,pointer-overflow,builtin -fno-sanitize-recover=all")
|
||||
ENDIF()
|
||||
|
||||
INCLUDE (FindPkgMacros)
|
||||
INCLUDE (PrecompiledHeader)
|
||||
|
||||
# Set Assimp project output directory variables.
|
||||
# Will respect top-level CMAKE_*_OUTPUT_DIRECTORY variables if any are set.
|
||||
IF(NOT DEFINED CMAKE_RUNTIME_OUTPUT_DIRECTORY)
|
||||
SET(ASSIMP_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin" CACHE STRING "Path for runtime output files")
|
||||
ELSE()
|
||||
SET(ASSIMP_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} CACHE STRING "Path for runtime output files")
|
||||
ENDIF()
|
||||
|
||||
IF(NOT DEFINED CMAKE_LIBRARY_OUTPUT_DIRECTORY)
|
||||
SET(ASSIMP_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin" CACHE STRING "Path for library output files")
|
||||
ELSE()
|
||||
SET(ASSIMP_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY} CACHE STRING "Path for runtime output files")
|
||||
ENDIF()
|
||||
|
||||
IF(NOT DEFINED CMAKE_ARCHIVE_OUTPUT_DIRECTORY)
|
||||
SET(ASSIMP_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/lib" CACHE STRING "Path for library output files")
|
||||
ELSE()
|
||||
SET(ASSIMP_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY} CACHE STRING "Path for runtime output files")
|
||||
ENDIF()
|
||||
|
||||
# Macro used to set the output directories of a target to the
|
||||
# respective Assimp output directories.
|
||||
MACRO(TARGET_USE_COMMON_OUTPUT_DIRECTORY target)
|
||||
set_target_properties(${target} PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY ${ASSIMP_RUNTIME_OUTPUT_DIRECTORY}
|
||||
LIBRARY_OUTPUT_DIRECTORY ${ASSIMP_LIBRARY_OUTPUT_DIRECTORY}
|
||||
ARCHIVE_OUTPUT_DIRECTORY ${ASSIMP_ARCHIVE_OUTPUT_DIRECTORY}
|
||||
)
|
||||
ENDMACRO()
|
||||
|
||||
get_cmake_property(is_multi_config GENERATOR_IS_MULTI_CONFIG)
|
||||
|
||||
IF (ASSIMP_INJECT_DEBUG_POSTFIX AND (is_multi_config OR CMAKE_BUILD_TYPE STREQUAL "Debug"))
|
||||
SET(CMAKE_DEBUG_POSTFIX "d" CACHE STRING "Debug Postfix for lib, samples and tools")
|
||||
ELSE()
|
||||
SET(CMAKE_DEBUG_POSTFIX "" CACHE STRING "Debug Postfix for lib, samples and tools")
|
||||
ENDIF()
|
||||
|
||||
# Only generate this target if no higher-level project already has
|
||||
IF (NOT TARGET uninstall AND ASSIMP_INSTALL)
|
||||
# add make uninstall capability
|
||||
CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/cmake-modules/cmake_uninstall.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" IMMEDIATE @ONLY)
|
||||
ADD_CUSTOM_TARGET(uninstall "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")
|
||||
ENDIF()
|
||||
|
||||
# cmake configuration files
|
||||
if(${BUILD_SHARED_LIBS})
|
||||
set(BUILD_LIB_TYPE SHARED)
|
||||
else()
|
||||
set(BUILD_LIB_TYPE STATIC)
|
||||
endif()
|
||||
|
||||
IF( UNIX )
|
||||
# Use GNUInstallDirs for Unix predefined directories
|
||||
INCLUDE(GNUInstallDirs)
|
||||
|
||||
SET( ASSIMP_LIB_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR})
|
||||
SET( ASSIMP_INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_INCLUDEDIR})
|
||||
SET( ASSIMP_BIN_INSTALL_DIR ${CMAKE_INSTALL_BINDIR})
|
||||
ELSE()
|
||||
# Cache these to allow the user to override them on non-Unix platforms
|
||||
SET( ASSIMP_LIB_INSTALL_DIR "lib" CACHE STRING
|
||||
"Path the built library files are installed to." )
|
||||
SET( ASSIMP_INCLUDE_INSTALL_DIR "include" CACHE STRING
|
||||
"Path the header files are installed to." )
|
||||
SET( ASSIMP_BIN_INSTALL_DIR "bin" CACHE STRING
|
||||
"Path the tool executables are installed to." )
|
||||
|
||||
SET(CMAKE_INSTALL_FULL_INCLUDEDIR ${CMAKE_INSTALL_PREFIX}/${ASSIMP_INCLUDE_INSTALL_DIR})
|
||||
SET(CMAKE_INSTALL_FULL_LIBDIR ${CMAKE_INSTALL_PREFIX}/${ASSIMP_LIB_INSTALL_DIR})
|
||||
SET(CMAKE_INSTALL_FULL_BINDIR ${CMAKE_INSTALL_PREFIX}/${ASSIMP_BIN_INSTALL_DIR})
|
||||
ENDIF()
|
||||
|
||||
set(GENERATED_DIR "${CMAKE_CURRENT_BINARY_DIR}/generated")
|
||||
|
||||
IF(ASSIMP_HUNTER_ENABLED)
|
||||
set(CONFIG_INSTALL_DIR "lib/cmake/${PROJECT_NAME}")
|
||||
set(CMAKE_CONFIG_TEMPLATE_FILE "cmake-modules/assimp-hunter-config.cmake.in")
|
||||
set(NAMESPACE "${PROJECT_NAME}::")
|
||||
set(TARGETS_EXPORT_NAME "${PROJECT_NAME}Targets")
|
||||
set(VERSION_CONFIG "${GENERATED_DIR}/${PROJECT_NAME}ConfigVersion.cmake")
|
||||
set(PROJECT_CONFIG "${GENERATED_DIR}/${PROJECT_NAME}Config.cmake")
|
||||
ELSE()
|
||||
set(CONFIG_INSTALL_DIR "${ASSIMP_LIB_INSTALL_DIR}/cmake/assimp-${ASSIMP_VERSION_MAJOR}.${ASSIMP_VERSION_MINOR}")
|
||||
set(CMAKE_CONFIG_TEMPLATE_FILE "cmake-modules/assimp-plain-config.cmake.in")
|
||||
string(TOLOWER ${PROJECT_NAME} PROJECT_NAME_LOWERCASE)
|
||||
set(NAMESPACE "${PROJECT_NAME_LOWERCASE}::")
|
||||
set(TARGETS_EXPORT_NAME "${PROJECT_NAME_LOWERCASE}Targets")
|
||||
set(VERSION_CONFIG "${GENERATED_DIR}/${PROJECT_NAME_LOWERCASE}ConfigVersion.cmake")
|
||||
set(PROJECT_CONFIG "${GENERATED_DIR}/${PROJECT_NAME_LOWERCASE}Config.cmake")
|
||||
ENDIF()
|
||||
|
||||
set(INCLUDE_INSTALL_DIR "include")
|
||||
|
||||
# Include module with fuction 'write_basic_package_version_file'
|
||||
include(CMakePackageConfigHelpers)
|
||||
|
||||
# Note: PROJECT_VERSION is used as a VERSION
|
||||
write_basic_package_version_file("${VERSION_CONFIG}" COMPATIBILITY SameMajorVersion)
|
||||
|
||||
configure_package_config_file(
|
||||
${CMAKE_CONFIG_TEMPLATE_FILE}
|
||||
"${PROJECT_CONFIG}"
|
||||
INSTALL_DESTINATION "${CONFIG_INSTALL_DIR}"
|
||||
)
|
||||
|
||||
install(
|
||||
FILES "${PROJECT_CONFIG}" "${VERSION_CONFIG}"
|
||||
DESTINATION "${CONFIG_INSTALL_DIR}"
|
||||
COMPONENT ${LIBASSIMP-DEV_COMPONENT}
|
||||
)
|
||||
|
||||
install(
|
||||
EXPORT "${TARGETS_EXPORT_NAME}"
|
||||
NAMESPACE "${NAMESPACE}"
|
||||
DESTINATION "${CONFIG_INSTALL_DIR}"
|
||||
COMPONENT ${LIBASSIMP-DEV_COMPONENT}
|
||||
)
|
||||
|
||||
IF( ASSIMP_BUILD_DOCS )
|
||||
ADD_SUBDIRECTORY(doc)
|
||||
ENDIF()
|
||||
|
||||
# Search for external dependencies, and build them from source if not found
|
||||
# Search for zlib
|
||||
IF(ASSIMP_HUNTER_ENABLED)
|
||||
hunter_add_package(ZLIB)
|
||||
find_package(ZLIB CONFIG REQUIRED)
|
||||
|
||||
add_definitions(-DASSIMP_BUILD_NO_OWN_ZLIB)
|
||||
set(ZLIB_FOUND TRUE)
|
||||
set(ZLIB_LIBRARIES ZLIB::zlib)
|
||||
set(ASSIMP_BUILD_MINIZIP TRUE)
|
||||
ELSE()
|
||||
# If the zlib is already found outside, add an export in case assimpTargets can't find it.
|
||||
IF( ZLIB_FOUND )
|
||||
INSTALL( TARGETS zlib zlibstatic
|
||||
EXPORT "${TARGETS_EXPORT_NAME}")
|
||||
ENDIF()
|
||||
|
||||
IF ( NOT ASSIMP_BUILD_ZLIB )
|
||||
FIND_PACKAGE(ZLIB)
|
||||
ENDIF()
|
||||
|
||||
IF( NOT ZLIB_FOUND )
|
||||
MESSAGE(STATUS "compiling zlib from sources")
|
||||
INCLUDE(CheckIncludeFile)
|
||||
INCLUDE(CheckTypeSize)
|
||||
INCLUDE(CheckFunctionExists)
|
||||
|
||||
# Explicitly turn off ASM686 and AMD64 cmake options.
|
||||
# The AMD64 option causes a build failure on MSVC and the ASM builds seem to have problems:
|
||||
# https://github.com/madler/zlib/issues/41#issuecomment-125848075
|
||||
# Also prevents these options from "polluting" the cmake options if assimp is being
|
||||
# included as a submodule.
|
||||
set( ASM686 FALSE CACHE INTERNAL "Override ZLIB flag to turn off assembly" FORCE )
|
||||
set( AMD64 FALSE CACHE INTERNAL "Override ZLIB flag to turn off assembly" FORCE )
|
||||
|
||||
# compile from sources
|
||||
ADD_SUBDIRECTORY(contrib/zlib)
|
||||
SET(ZLIB_FOUND 1)
|
||||
SET(ZLIB_LIBRARIES zlibstatic)
|
||||
SET(ZLIB_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/contrib/zlib ${CMAKE_CURRENT_BINARY_DIR}/contrib/zlib)
|
||||
# need to ensure we don't link with system zlib or minizip as well.
|
||||
SET(ASSIMP_BUILD_MINIZIP 1)
|
||||
ELSE()
|
||||
ADD_DEFINITIONS(-DASSIMP_BUILD_NO_OWN_ZLIB)
|
||||
SET(ZLIB_LIBRARIES_LINKED -lz)
|
||||
ENDIF()
|
||||
INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR})
|
||||
ENDIF()
|
||||
|
||||
IF( NOT IOS )
|
||||
IF( NOT ASSIMP_BUILD_MINIZIP )
|
||||
use_pkgconfig(UNZIP minizip)
|
||||
ENDIF()
|
||||
ELSE ()
|
||||
IF( NOT BUILD_SHARED_LIBS )
|
||||
IF( NOT ASSIMP_BUILD_MINIZIP )
|
||||
use_pkgconfig(UNZIP minizip)
|
||||
ENDIF()
|
||||
ENDIF ()
|
||||
ENDIF ()
|
||||
|
||||
IF ( ASSIMP_NO_EXPORT )
|
||||
ADD_DEFINITIONS( -DASSIMP_BUILD_NO_EXPORT)
|
||||
MESSAGE( STATUS "Build an import-only version of Assimp." )
|
||||
ENDIF()
|
||||
|
||||
SET ( ASSIMP_BUILD_ARCHITECTURE "" CACHE STRING
|
||||
"describe the current architecture."
|
||||
)
|
||||
IF( ASSIMP_BUILD_ARCHITECTURE STREQUAL "")
|
||||
ELSE()
|
||||
ADD_DEFINITIONS ( -D'ASSIMP_BUILD_ARCHITECTURE="${ASSIMP_BUILD_ARCHITECTURE}"' )
|
||||
ENDIF()
|
||||
|
||||
# ${CMAKE_GENERATOR}
|
||||
SET ( ASSIMP_BUILD_COMPILER "" CACHE STRING
|
||||
"describe the current compiler."
|
||||
)
|
||||
IF( ASSIMP_BUILD_COMPILER STREQUAL "")
|
||||
ELSE()
|
||||
ADD_DEFINITIONS ( -D'ASSIMP_BUILD_COMPILER="${ASSIMP_BUILD_COMPILER}"' )
|
||||
ENDIF()
|
||||
|
||||
MARK_AS_ADVANCED ( ASSIMP_BUILD_ARCHITECTURE ASSIMP_BUILD_COMPILER )
|
||||
|
||||
SET ( ASSIMP_BUILD_NONFREE_C4D_IMPORTER OFF CACHE BOOL
|
||||
"Build the C4D importer, which relies on the non-free Cineware SDK."
|
||||
)
|
||||
|
||||
IF (ASSIMP_BUILD_NONFREE_C4D_IMPORTER)
|
||||
IF ( MSVC )
|
||||
SET(C4D_INCLUDES "${CMAKE_CURRENT_SOURCE_DIR}/contrib/Cineware/includes")
|
||||
|
||||
# pick the correct prebuilt library
|
||||
IF(MSVC15)
|
||||
SET(C4D_LIB_POSTFIX "_2017")
|
||||
ELSEIF(MSVC14)
|
||||
SET(C4D_LIB_POSTFIX "_2015")
|
||||
ELSEIF(MSVC12)
|
||||
SET(C4D_LIB_POSTFIX "_2013")
|
||||
ELSEIF(MSVC11)
|
||||
SET(C4D_LIB_POSTFIX "_2012")
|
||||
ELSEIF(MSVC10)
|
||||
SET(C4D_LIB_POSTFIX "_2010")
|
||||
ELSE()
|
||||
MESSAGE( FATAL_ERROR
|
||||
"C4D is currently only supported with MSVC 10, 11, 12, 14"
|
||||
)
|
||||
ENDIF()
|
||||
|
||||
SET(C4D_LIB_BASE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/contrib/Cineware/libraries/win")
|
||||
|
||||
SET(C4D_DEBUG_LIBRARIES
|
||||
"${C4D_LIB_BASE_PATH}/cinewarelib${C4D_LIB_POSTFIX}/cinewarelib_debug.lib"
|
||||
"${C4D_LIB_BASE_PATH}/jpeglib${C4D_LIB_POSTFIX}/jpeglib_debug.lib"
|
||||
)
|
||||
SET(C4D_RELEASE_LIBRARIES
|
||||
"${C4D_LIB_BASE_PATH}/cinewarelib${C4D_LIB_POSTFIX}/cinewarelib_release.lib"
|
||||
"${C4D_LIB_BASE_PATH}/jpeglib${C4D_LIB_POSTFIX}/jpeglib_release.lib"
|
||||
)
|
||||
|
||||
# winsock and winmm are necessary (and undocumented) dependencies of Cineware SDK because
|
||||
# it can be used to communicate with a running Cinema 4D instance
|
||||
SET(C4D_EXTRA_LIBRARIES WSock32.lib Winmm.lib)
|
||||
ELSE ()
|
||||
MESSAGE( FATAL_ERROR
|
||||
"C4D is currently only available on Windows with Cineware SDK installed in contrib/Cineware"
|
||||
)
|
||||
ENDIF ()
|
||||
ELSE ()
|
||||
ADD_DEFINITIONS( -DASSIMP_BUILD_NO_C4D_IMPORTER )
|
||||
ENDIF ()
|
||||
|
||||
# Draco requires cmake 3.12
|
||||
IF (DEFINED CMAKE_VERSION AND "${CMAKE_VERSION}" VERSION_LESS "3.12")
|
||||
message(NOTICE "draco requires cmake 3.12 or newer, cmake is ${CMAKE_VERSION} . Draco is disabled")
|
||||
SET ( ASSIMP_BUILD_DRACO OFF CACHE BOOL "Disabled: Draco requires newer cmake" FORCE )
|
||||
ELSE()
|
||||
OPTION ( ASSIMP_BUILD_DRACO "If the Draco libraries are to be built. Primarily for glTF" OFF )
|
||||
IF ( ASSIMP_BUILD_DRACO )
|
||||
# Primarily for glTF v2
|
||||
# Enable Draco glTF feature set
|
||||
set(DRACO_GLTF ON CACHE BOOL "" FORCE)
|
||||
# Disable unnecessary or omitted components
|
||||
set(DRACO_JS_GLUE OFF CACHE BOOL "" FORCE)
|
||||
set(DRACO_WASM OFF CACHE BOOL "" FORCE)
|
||||
set(DRACO_MAYA_PLUGIN OFF CACHE BOOL "" FORCE)
|
||||
set(DRACO_UNITY_PLUGIN OFF CACHE BOOL "" FORCE)
|
||||
set(DRACO_TESTS OFF CACHE BOOL "" FORCE)
|
||||
|
||||
IF(ASSIMP_HUNTER_ENABLED)
|
||||
hunter_add_package(draco)
|
||||
find_package(draco CONFIG REQUIRED)
|
||||
set(draco_LIBRARIES draco::draco)
|
||||
ELSE()
|
||||
# Draco 1.4.1 has many warnings and will not build with /WX or -Werror
|
||||
# See https://github.com/google/draco/issues/672
|
||||
# and https://github.com/google/draco/issues/673
|
||||
IF(MSVC)
|
||||
set(DRACO_CXX_FLAGS "/W0")
|
||||
ELSE()
|
||||
list(APPEND DRACO_CXX_FLAGS
|
||||
"-Wno-bool-compare"
|
||||
"-Wno-comment"
|
||||
"-Wno-maybe-uninitialized"
|
||||
"-Wno-sign-compare"
|
||||
"-Wno-unused-local-typedefs"
|
||||
)
|
||||
# Draco 1.4.1 does not explicitly export any symbols under GCC/clang
|
||||
list(APPEND DRACO_CXX_FLAGS
|
||||
"-fvisibility=default"
|
||||
)
|
||||
ENDIF()
|
||||
|
||||
# Don't build or install all of Draco by default
|
||||
ADD_SUBDIRECTORY( "contrib/draco" EXCLUDE_FROM_ALL )
|
||||
|
||||
if(MSVC OR WIN32)
|
||||
set(draco_LIBRARIES "draco")
|
||||
else()
|
||||
if(BUILD_SHARED_LIBS)
|
||||
set(draco_LIBRARIES "draco_shared")
|
||||
else()
|
||||
set(draco_LIBRARIES "draco_static")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Don't build the draco command-line tools by default
|
||||
set_target_properties(draco_encoder draco_decoder PROPERTIES
|
||||
EXCLUDE_FROM_ALL TRUE
|
||||
EXCLUDE_FROM_DEFAULT_BUILD TRUE
|
||||
)
|
||||
|
||||
# Do build the draco shared library
|
||||
set_target_properties(${draco_LIBRARIES} PROPERTIES
|
||||
EXCLUDE_FROM_ALL FALSE
|
||||
EXCLUDE_FROM_DEFAULT_BUILD FALSE
|
||||
)
|
||||
|
||||
TARGET_USE_COMMON_OUTPUT_DIRECTORY(${draco_LIBRARIES})
|
||||
TARGET_USE_COMMON_OUTPUT_DIRECTORY(draco_encoder)
|
||||
TARGET_USE_COMMON_OUTPUT_DIRECTORY(draco_decoder)
|
||||
|
||||
set(draco_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/contrib/draco/src")
|
||||
|
||||
# This is probably wrong
|
||||
INSTALL( TARGETS ${draco_LIBRARIES}
|
||||
EXPORT "${TARGETS_EXPORT_NAME}"
|
||||
LIBRARY DESTINATION ${ASSIMP_LIB_INSTALL_DIR}
|
||||
ARCHIVE DESTINATION ${ASSIMP_LIB_INSTALL_DIR}
|
||||
RUNTIME DESTINATION ${ASSIMP_BIN_INSTALL_DIR}
|
||||
FRAMEWORK DESTINATION ${ASSIMP_LIB_INSTALL_DIR}
|
||||
COMPONENT ${LIBASSIMP_COMPONENT}
|
||||
INCLUDES DESTINATION include
|
||||
)
|
||||
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
# Main assimp code
|
||||
ADD_SUBDIRECTORY( code/ )
|
||||
|
||||
IF ( ASSIMP_BUILD_ASSIMP_TOOLS )
|
||||
# The viewer for windows only
|
||||
IF (WIN32)
|
||||
FIND_PACKAGE(DirectX)
|
||||
OPTION ( ASSIMP_BUILD_ASSIMP_VIEW "If the Assimp view tool is built. (requires DirectX)" ${DirectX_FOUND} )
|
||||
IF ( ASSIMP_BUILD_ASSIMP_VIEW )
|
||||
ADD_SUBDIRECTORY( tools/assimp_view/ )
|
||||
ENDIF ()
|
||||
ELSE()
|
||||
MESSAGE("Building Assimp Viewer only supported on Windows.")
|
||||
ENDIF ()
|
||||
# The command line tool
|
||||
ADD_SUBDIRECTORY( tools/assimp_cmd/ )
|
||||
ENDIF ()
|
||||
|
||||
IF ( ASSIMP_BUILD_SAMPLES )
|
||||
SET( SAMPLES_DIR ${CMAKE_CURRENT_SOURCE_DIR}/samples )
|
||||
SET( SAMPLES_SHARED_CODE_DIR ${SAMPLES_DIR}/SharedCode )
|
||||
IF ( WIN32 )
|
||||
ADD_SUBDIRECTORY( samples/SimpleTexturedOpenGL/ )
|
||||
ADD_SUBDIRECTORY( samples/SimpleTexturedDirectx11 )
|
||||
ENDIF ()
|
||||
ADD_SUBDIRECTORY( samples/SimpleOpenGL/ )
|
||||
ENDIF ()
|
||||
|
||||
IF ( ASSIMP_BUILD_TESTS )
|
||||
ADD_SUBDIRECTORY( test/ )
|
||||
ENDIF ()
|
||||
|
||||
# Generate a pkg-config .pc, revision.h, and config.h for the Assimp library.
|
||||
CONFIGURE_FILE( "${PROJECT_SOURCE_DIR}/assimp.pc.in" "${PROJECT_BINARY_DIR}/assimp.pc" @ONLY )
|
||||
IF ( ASSIMP_INSTALL )
|
||||
INSTALL( FILES "${PROJECT_BINARY_DIR}/assimp.pc" DESTINATION ${ASSIMP_LIB_INSTALL_DIR}/pkgconfig/ COMPONENT ${LIBASSIMP-DEV_COMPONENT})
|
||||
ENDIF()
|
||||
|
||||
CONFIGURE_FILE(
|
||||
${CMAKE_CURRENT_LIST_DIR}/revision.h.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/revision.h
|
||||
)
|
||||
|
||||
CONFIGURE_FILE(
|
||||
${CMAKE_CURRENT_LIST_DIR}/include/assimp/config.h.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/include/assimp/config.h
|
||||
)
|
||||
|
||||
IF ( ASSIMP_INSTALL )
|
||||
IF(CMAKE_CPACK_COMMAND AND UNIX AND ASSIMP_OPT_BUILD_PACKAGES)
|
||||
# Packing information
|
||||
SET(CPACK_PACKAGE_NAME "assimp{ASSIMP_VERSION_MAJOR}.{ASSIMP_VERSION_MINOR}")
|
||||
SET(CPACK_PACKAGE_CONTACT "" CACHE STRING "Package maintainer and PGP signer.")
|
||||
SET(CPACK_PACKAGE_VENDOR "https://github.com/assimp")
|
||||
SET(CPACK_PACKAGE_DISPLAY_NAME "Assimp ${ASSIMP_VERSION}")
|
||||
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY " - Open Asset Import Library ${ASSIMP_VERSION}")
|
||||
SET(CPACK_PACKAGE_VERSION "${ASSIMP_VERSION}.${ASSIMP_PACKAGE_VERSION}" )
|
||||
SET(CPACK_PACKAGE_VERSION_MAJOR "${ASSIMP_VERSION_MAJOR}")
|
||||
SET(CPACK_PACKAGE_VERSION_MINOR "${ASSIMP_VERSION_MINOR}")
|
||||
SET(CPACK_PACKAGE_VERSION_PATCH "${ASSIMP_VERSION_PATCH}")
|
||||
SET(CPACK_PACKAGE_INSTALL_DIRECTORY "assimp${ASSIMP_VERSION_MAJOR}.${ASSIMP_VERSION_MINOR}")
|
||||
SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
|
||||
|
||||
STRING(TOUPPER ${LIBASSIMP_COMPONENT} "LIBASSIMP_COMPONENT_UPPER")
|
||||
STRING(TOUPPER ${LIBASSIMP-DEV_COMPONENT} "LIBASSIMP-DEV_COMPONENT_UPPER")
|
||||
|
||||
SET(CPACK_COMPONENT_ASSIMP-BIN_DISPLAY_NAME "tools")
|
||||
SET(CPACK_COMPONENT_ASSIMP-BIN_DEPENDS "${LIBASSIMP_COMPONENT}" )
|
||||
SET(CPACK_COMPONENT_${LIBASSIMP_COMPONENT_UPPER}_DISPLAY_NAME "libraries")
|
||||
SET(CPACK_COMPONENT_${LIBASSIMP-DEV_COMPONENT_UPPER}_DISPLAY_NAME "common headers and installs")
|
||||
SET(CPACK_COMPONENT_${LIBASSIMP-DEV_COMPONENT_UPPER}_DEPENDS $ "{LIBASSIMP_COMPONENT}" )
|
||||
SET(CPACK_COMPONENT_ASSIMP-DEV_DISPLAY_NAME "${CPACK_COMPONENT_${LIBASSIMP-DEV_COMPONENT}_DISPLAY_NAME}" )
|
||||
SET(CPACK_COMPONENT_ASSIMP-DEV_DEPENDS "${LIBASSIMP-DEV_COMPONENT}" )
|
||||
SET(CPACK_DEBIAN_BUILD_DEPENDS debhelper cmake zlib1g-dev pkg-config)
|
||||
|
||||
# debian
|
||||
SET(CPACK_DEBIAN_PACKAGE_PRIORITY "optional")
|
||||
SET(CPACK_DEBIAN_CMAKE_OPTIONS "-DBUILD_ASSIMP_SAMPLES:BOOL=${ASSIMP_BUILD_SAMPLES}")
|
||||
SET(CPACK_DEBIAN_PACKAGE_SECTION "libs" )
|
||||
SET(CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_COMPONENTS_ALL}")
|
||||
SET(CPACK_DEBIAN_PACKAGE_SUGGESTS)
|
||||
SET(cPACK_DEBIAN_PACKAGE_NAME "assimp")
|
||||
SET(CPACK_DEBIAN_PACKAGE_REMOVE_SOURCE_FILES contrib/gtest contrib/zlib workspaces test doc obj samples packaging)
|
||||
SET(CPACK_DEBIAN_PACKAGE_SOURCE_COPY svn export --force)
|
||||
SET(CPACK_DEBIAN_CHANGELOG)
|
||||
execute_process(COMMAND lsb_release -is
|
||||
OUTPUT_VARIABLE _lsb_distribution OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
RESULT_VARIABLE _lsb_release_failed)
|
||||
SET(CPACK_DEBIAN_DISTRIBUTION_NAME ${_lsb_distribution} CACHE STRING "Name of the distrubiton")
|
||||
STRING(TOLOWER ${CPACK_DEBIAN_DISTRIBUTION_NAME} CPACK_DEBIAN_DISTRIBUTION_NAME)
|
||||
IF( ${CPACK_DEBIAN_DISTRIBUTION_NAME} STREQUAL "ubuntu" )
|
||||
SET(CPACK_DEBIAN_DISTRIBUTION_RELEASES lucid maverick natty oneiric precise CACHE STRING "Release code-names of the distrubiton release")
|
||||
ENDIF()
|
||||
SET(DPUT_HOST "" CACHE STRING "PPA repository to upload the debian sources")
|
||||
INCLUDE(CPack)
|
||||
INCLUDE(DebSourcePPA)
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
if(WIN32)
|
||||
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
SET(BIN_DIR "${PROJECT_SOURCE_DIR}/bin64/")
|
||||
SET(LIB_DIR "${PROJECT_SOURCE_DIR}/lib64/")
|
||||
else()
|
||||
SET(BIN_DIR "${PROJECT_SOURCE_DIR}/bin32/")
|
||||
SET(LIB_DIR "${PROJECT_SOURCE_DIR}/lib32/")
|
||||
ENDIF()
|
||||
|
||||
IF(MSVC_TOOLSET_VERSION)
|
||||
SET(MSVC_PREFIX "vc${MSVC_TOOLSET_VERSION}")
|
||||
SET(ASSIMP_MSVC_VERSION ${MSVC_PREFIX})
|
||||
ELSE()
|
||||
IF(MSVC12)
|
||||
SET(ASSIMP_MSVC_VERSION "vc120")
|
||||
ELSEIF(MSVC14)
|
||||
SET(ASSIMP_MSVC_VERSION "vc140")
|
||||
ELSEIF(MSVC15)
|
||||
SET(ASSIMP_MSVC_VERSION "vc141")
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
IF(MSVC12 OR MSVC14 OR MSVC15 )
|
||||
ADD_CUSTOM_TARGET(UpdateAssimpLibsDebugSymbolsAndDLLs COMMENT "Copying Assimp Libraries ..." VERBATIM)
|
||||
IF(CMAKE_GENERATOR MATCHES "^Visual Studio")
|
||||
ADD_CUSTOM_COMMAND(TARGET UpdateAssimpLibsDebugSymbolsAndDLLs COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/code/Release/assimp-${ASSIMP_MSVC_VERSION}-mt.dll ${BIN_DIR}assimp-${ASSIMP_MSVC_VERSION}-mt.dll VERBATIM)
|
||||
ADD_CUSTOM_COMMAND(TARGET UpdateAssimpLibsDebugSymbolsAndDLLs COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/code/Release/assimp-${ASSIMP_MSVC_VERSION}-mt.exp ${LIB_DIR}assimp-${ASSIMP_MSVC_VERSION}-mt.exp VERBATIM)
|
||||
ADD_CUSTOM_COMMAND(TARGET UpdateAssimpLibsDebugSymbolsAndDLLs COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/code/Release/assimp-${ASSIMP_MSVC_VERSION}-mt.lib ${LIB_DIR}assimp-${ASSIMP_MSVC_VERSION}-mt.lib VERBATIM)
|
||||
ADD_CUSTOM_COMMAND(TARGET UpdateAssimpLibsDebugSymbolsAndDLLs COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/code/Debug/assimp-${ASSIMP_MSVC_VERSION}-mtd.dll ${BIN_DIR}assimp-${ASSIMP_MSVC_VERSION}-mtd.dll VERBATIM)
|
||||
ADD_CUSTOM_COMMAND(TARGET UpdateAssimpLibsDebugSymbolsAndDLLs COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/code/Debug/assimp-${ASSIMP_MSVC_VERSION}-mtd.exp ${LIB_DIR}assimp-${ASSIMP_MSVC_VERSION}-mtd.exp VERBATIM)
|
||||
ADD_CUSTOM_COMMAND(TARGET UpdateAssimpLibsDebugSymbolsAndDLLs COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/code/Debug/assimp-${ASSIMP_MSVC_VERSION}-mtd.ilk ${LIB_DIR}assimp-${ASSIMP_MSVC_VERSION}-mtd.ilk VERBATIM)
|
||||
ADD_CUSTOM_COMMAND(TARGET UpdateAssimpLibsDebugSymbolsAndDLLs COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/code/Debug/assimp-${ASSIMP_MSVC_VERSION}-mtd.lib ${LIB_DIR}assimp-${ASSIMP_MSVC_VERSION}-mtd.lib VERBATIM)
|
||||
ADD_CUSTOM_COMMAND(TARGET UpdateAssimpLibsDebugSymbolsAndDLLs COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/code/Debug/assimp-${ASSIMP_MSVC_VERSION}-mtd.pdb ${LIB_DIR}assimp-${ASSIMP_MSVC_VERSION}-mtd.pdb VERBATIM)
|
||||
ELSE()
|
||||
ADD_CUSTOM_COMMAND(TARGET UpdateAssimpLibsDebugSymbolsAndDLLs COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/code/assimp-${ASSIMP_MSVC_VERSION}-mt.dll ${BIN_DIR}assimp-${ASSIMP_MSVC_VERSION}-mt.dll VERBATIM)
|
||||
ADD_CUSTOM_COMMAND(TARGET UpdateAssimpLibsDebugSymbolsAndDLLs COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/code/assimp-${ASSIMP_MSVC_VERSION}-mt.exp ${LIB_DIR}assimp-${ASSIMP_MSVC_VERSION}-mt.exp VERBATIM)
|
||||
ADD_CUSTOM_COMMAND(TARGET UpdateAssimpLibsDebugSymbolsAndDLLs COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/code/assimp-${ASSIMP_MSVC_VERSION}-mt.lib ${LIB_DIR}assimp-${ASSIMP_MSVC_VERSION}-mt.lib VERBATIM)
|
||||
ADD_CUSTOM_COMMAND(TARGET UpdateAssimpLibsDebugSymbolsAndDLLs COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/code/assimp-${ASSIMP_MSVC_VERSION}-mtd.dll ${BIN_DIR}assimp-${ASSIMP_MSVC_VERSION}-mtd.dll VERBATIM)
|
||||
ADD_CUSTOM_COMMAND(TARGET UpdateAssimpLibsDebugSymbolsAndDLLs COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/code/assimp-${ASSIMP_MSVC_VERSION}-mtd.exp ${LIB_DIR}assimp-${ASSIMP_MSVC_VERSION}-mtd.exp VERBATIM)
|
||||
ADD_CUSTOM_COMMAND(TARGET UpdateAssimpLibsDebugSymbolsAndDLLs COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/code/assimp-${ASSIMP_MSVC_VERSION}-mtd.ilk ${LIB_DIR}assimp-${ASSIMP_MSVC_VERSION}-mtd.ilk VERBATIM)
|
||||
ADD_CUSTOM_COMMAND(TARGET UpdateAssimpLibsDebugSymbolsAndDLLs COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/code/assimp-${ASSIMP_MSVC_VERSION}-mtd.lib ${LIB_DIR}assimp-${ASSIMP_MSVC_VERSION}-mtd.lib VERBATIM)
|
||||
ADD_CUSTOM_COMMAND(TARGET UpdateAssimpLibsDebugSymbolsAndDLLs COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/code/assimp-${ASSIMP_MSVC_VERSION}-mtd.pdb ${LIB_DIR}assimp-${ASSIMP_MSVC_VERSION}-mtd.pdb VERBATIM)
|
||||
ADD_CUSTOM_COMMAND(TARGET UpdateAssimpLibsDebugSymbolsAndDLLs COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/code/assimp-${ASSIMP_MSVC_VERSION}-mtd.pdb ${LIB_DIR}assimp-${ASSIMP_MSVC_VERSION}-mtd.pdb VERBATIM)
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
ENDIF ()
|
||||
10
Engine/lib/assimp/CONTRIBUTING.md
Normal file
10
Engine/lib/assimp/CONTRIBUTING.md
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
# How to contribute
|
||||
|
||||
If you want to contribute, follow these steps:
|
||||
|
||||
- First, create your own clone of assimp.
|
||||
- When you want to fix a bug or add a new feature, create a branch on your own fork following [these instructions](https://help.github.com/articles/creating-a-pull-request-from-a-fork/).
|
||||
- Push it to your fork of the repository and open a pull request.
|
||||
- A pull request will start our continuous integration service, which checks if the build works for Linux and Windows.
|
||||
It will check for memory leaks, compiler warnings and memory alignment issues. If any of these tests fail, fix it and the tests will be restarted automatically.
|
||||
- At the end, we will perform a code review and merge your branch to the master branch.
|
||||
12
Engine/lib/assimp/CodeConventions.md
Normal file
12
Engine/lib/assimp/CodeConventions.md
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
|
||||
Open Asset Import Library Coding Conventions
|
||||
==
|
||||
|
||||
If you want to participate as a developer in the **Open Asset Import Library** please read and respect the following coding conventions. This will ensure consistency throughout the codebase and help all the Open Asset Import Library users.
|
||||
|
||||
Spacing
|
||||
==
|
||||
|
||||
* Use UNIX-style line endings (LF)
|
||||
* Remove any trailing whitespace
|
||||
* Expand tabs to 4 spaces
|
||||
25
Engine/lib/assimp/Dockerfile
Normal file
25
Engine/lib/assimp/Dockerfile
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
FROM ubuntu:14.04
|
||||
|
||||
RUN apt-get update && apt-get install -y \
|
||||
git cmake build-essential software-properties-common
|
||||
|
||||
RUN add-apt-repository ppa:ubuntu-toolchain-r/test && apt-get update && apt-get install -y gcc-4.9 g++-4.9 && \
|
||||
cd /usr/bin && \
|
||||
rm gcc g++ cpp && \
|
||||
ln -s gcc-4.9 gcc && \
|
||||
ln -s g++-4.9 g++ && \
|
||||
ln -s cpp-4.9 cpp
|
||||
|
||||
WORKDIR /opt
|
||||
|
||||
# Build Assimp
|
||||
RUN git clone https://github.com/assimp/assimp.git /opt/assimp
|
||||
|
||||
WORKDIR /opt/assimp
|
||||
|
||||
RUN git checkout master \
|
||||
&& mkdir build && cd build && \
|
||||
cmake \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
.. && \
|
||||
make && make install
|
||||
16
Engine/lib/assimp/SECURITY.md
Normal file
16
Engine/lib/assimp/SECURITY.md
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
# Security Policy
|
||||
|
||||
## Supported Versions
|
||||
|
||||
Use this section to tell people about which versions of your project are
|
||||
currently being supported with security updates.
|
||||
|
||||
| Version | Supported |
|
||||
| ------- | ------------------ |
|
||||
| 5.2.4 | :white_check_mark: |
|
||||
|
||||
## Reporting a Vulnerability
|
||||
|
||||
If you have found any security vulnerability you can contact us via
|
||||
kim.kulling@googlemail.com
|
||||
|
||||
9
Engine/lib/assimp/assimp.pc.in
Normal file
9
Engine/lib/assimp/assimp.pc.in
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
libdir=@CMAKE_INSTALL_FULL_LIBDIR@
|
||||
includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@
|
||||
|
||||
Name: @CMAKE_PROJECT_NAME@
|
||||
Description: Import various well-known 3D model formats in an uniform manner.
|
||||
Version: @PROJECT_VERSION@
|
||||
Libs: -L${libdir} -lassimp@ASSIMP_LIBRARY_SUFFIX@
|
||||
Libs.private: @LIBSTDC++_LIBRARIES@ @ZLIB_LIBRARIES_LINKED@
|
||||
Cflags: -I${includedir}
|
||||
126
Engine/lib/assimp/cmake-modules/Coveralls.cmake
Normal file
126
Engine/lib/assimp/cmake-modules/Coveralls.cmake
Normal file
|
|
@ -0,0 +1,126 @@
|
|||
#
|
||||
# The MIT License (MIT)
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in all
|
||||
# copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
# SOFTWARE.
|
||||
#
|
||||
# Copyright (C) 2014 Joakim Söderberg <joakim.soderberg@gmail.com>
|
||||
#
|
||||
|
||||
set(_CMAKE_SCRIPT_PATH ${CMAKE_CURRENT_LIST_DIR}) # must be outside coveralls_setup() to get correct path
|
||||
|
||||
#
|
||||
# Param _COVERAGE_SRCS A list of source files that coverage should be collected for.
|
||||
# Param _COVERALLS_UPLOAD Upload the result to coveralls?
|
||||
#
|
||||
|
||||
function(coveralls_setup _COVERAGE_SRCS _COVERALLS_UPLOAD)
|
||||
|
||||
if (ARGC GREATER 2)
|
||||
set(_CMAKE_SCRIPT_PATH ${ARGN})
|
||||
message(STATUS "Coveralls: Using alternate CMake script dir: ${_CMAKE_SCRIPT_PATH}")
|
||||
endif()
|
||||
|
||||
if (NOT EXISTS "${_CMAKE_SCRIPT_PATH}/CoverallsClear.cmake")
|
||||
message(FATAL_ERROR "Coveralls: Missing ${_CMAKE_SCRIPT_PATH}/CoverallsClear.cmake")
|
||||
endif()
|
||||
|
||||
if (NOT EXISTS "${_CMAKE_SCRIPT_PATH}/CoverallsGenerateGcov.cmake")
|
||||
message(FATAL_ERROR "Coveralls: Missing ${_CMAKE_SCRIPT_PATH}/CoverallsGenerateGcov.cmake")
|
||||
endif()
|
||||
|
||||
# When passing a CMake list to an external process, the list
|
||||
# will be converted from the format "1;2;3" to "1 2 3".
|
||||
# This means the script we're calling won't see it as a list
|
||||
# of sources, but rather just one long path. We remedy this
|
||||
# by replacing ";" with "*" and then reversing that in the script
|
||||
# that we're calling.
|
||||
# http://cmake.3232098.n2.nabble.com/Passing-a-CMake-list-quot-as-is-quot-to-a-custom-target-td6505681.html
|
||||
set(COVERAGE_SRCS_TMP ${_COVERAGE_SRCS})
|
||||
set(COVERAGE_SRCS "")
|
||||
foreach (COVERAGE_SRC ${COVERAGE_SRCS_TMP})
|
||||
set(COVERAGE_SRCS "${COVERAGE_SRCS}*${COVERAGE_SRC}")
|
||||
endforeach()
|
||||
|
||||
#message("Coverage sources: ${COVERAGE_SRCS}")
|
||||
set(COVERALLS_FILE ${PROJECT_BINARY_DIR}/coveralls.json)
|
||||
|
||||
add_custom_target(coveralls_generate
|
||||
|
||||
# Zero the coverage counters.
|
||||
COMMAND ${CMAKE_COMMAND} -DPROJECT_BINARY_DIR="${PROJECT_BINARY_DIR}" -P "${_CMAKE_SCRIPT_PATH}/CoverallsClear.cmake"
|
||||
|
||||
# Run regress tests.
|
||||
COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure
|
||||
|
||||
# Generate Gcov and translate it into coveralls JSON.
|
||||
# We do this by executing an external CMake script.
|
||||
# (We don't want this to run at CMake generation time, but after compilation and everything has run).
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
-DCOVERAGE_SRCS="${COVERAGE_SRCS}" # TODO: This is passed like: "a b c", not "a;b;c"
|
||||
-DCOVERALLS_OUTPUT_FILE="${COVERALLS_FILE}"
|
||||
-DCOV_PATH="${PROJECT_BINARY_DIR}"
|
||||
-DPROJECT_ROOT="${PROJECT_SOURCE_DIR}"
|
||||
-P "${_CMAKE_SCRIPT_PATH}/CoverallsGenerateGcov.cmake"
|
||||
|
||||
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
|
||||
COMMENT "Generating coveralls output..."
|
||||
)
|
||||
|
||||
if (_COVERALLS_UPLOAD)
|
||||
message("COVERALLS UPLOAD: ON")
|
||||
|
||||
find_program(CURL_EXECUTABLE curl)
|
||||
|
||||
if (NOT CURL_EXECUTABLE)
|
||||
message(FATAL_ERROR "Coveralls: curl not found! Aborting")
|
||||
endif()
|
||||
|
||||
add_custom_target(coveralls_upload
|
||||
# Upload the JSON to coveralls.
|
||||
COMMAND ${CURL_EXECUTABLE}
|
||||
-S -F json_file=@${COVERALLS_FILE}
|
||||
https://coveralls.io/api/v1/jobs
|
||||
|
||||
DEPENDS coveralls_generate
|
||||
|
||||
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
|
||||
COMMENT "Uploading coveralls output...")
|
||||
|
||||
add_custom_target(coveralls DEPENDS coveralls_upload)
|
||||
else()
|
||||
message("COVERALLS UPLOAD: OFF")
|
||||
add_custom_target(coveralls DEPENDS coveralls_generate)
|
||||
endif()
|
||||
|
||||
endfunction()
|
||||
|
||||
macro(coveralls_turn_on_coverage)
|
||||
if(NOT (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
|
||||
AND (NOT "${CMAKE_C_COMPILER_ID}" STREQUAL "Clang"))
|
||||
message(FATAL_ERROR "Coveralls: Compiler ${CMAKE_C_COMPILER_ID} is not GNU gcc! Aborting... You can set this on the command line using CC=/usr/bin/gcc CXX=/usr/bin/g++ cmake <options> ..")
|
||||
endif()
|
||||
|
||||
if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
message(FATAL_ERROR "Coveralls: Code coverage results with an optimised (non-Debug) build may be misleading! Add -DCMAKE_BUILD_TYPE=Debug")
|
||||
endif()
|
||||
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0 -fprofile-arcs -ftest-coverage")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O0 -fprofile-arcs -ftest-coverage")
|
||||
endmacro()
|
||||
|
||||
31
Engine/lib/assimp/cmake-modules/CoverallsClear.cmake
Normal file
31
Engine/lib/assimp/cmake-modules/CoverallsClear.cmake
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
#
|
||||
# The MIT License (MIT)
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in all
|
||||
# copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
# SOFTWARE.
|
||||
#
|
||||
# Copyright (C) 2014 Joakim Söderberg <joakim.soderberg@gmail.com>
|
||||
#
|
||||
|
||||
# do not follow symlinks in file(GLOB_RECURSE ...)
|
||||
cmake_policy(SET CMP0009 NEW)
|
||||
|
||||
file(GLOB_RECURSE GCDA_FILES "${PROJECT_BINARY_DIR}/*.gcda")
|
||||
if(NOT GCDA_FILES STREQUAL "")
|
||||
file(REMOVE ${GCDA_FILES})
|
||||
endif()
|
||||
482
Engine/lib/assimp/cmake-modules/CoverallsGenerateGcov.cmake
Normal file
482
Engine/lib/assimp/cmake-modules/CoverallsGenerateGcov.cmake
Normal file
|
|
@ -0,0 +1,482 @@
|
|||
#
|
||||
# The MIT License (MIT)
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in all
|
||||
# copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
# SOFTWARE.
|
||||
#
|
||||
# Copyright (C) 2014 Joakim Söderberg <joakim.soderberg@gmail.com>
|
||||
#
|
||||
# This is intended to be run by a custom target in a CMake project like this.
|
||||
# 0. Compile program with coverage support.
|
||||
# 1. Clear coverage data. (Recursively delete *.gcda in build dir)
|
||||
# 2. Run the unit tests.
|
||||
# 3. Run this script specifying which source files the coverage should be performed on.
|
||||
#
|
||||
# This script will then use gcov to generate .gcov files in the directory specified
|
||||
# via the COV_PATH var. This should probably be the same as your cmake build dir.
|
||||
#
|
||||
# It then parses the .gcov files to convert them into the Coveralls JSON format:
|
||||
# https://coveralls.io/docs/api
|
||||
#
|
||||
# Example for running as standalone CMake script from the command line:
|
||||
# (Note it is important the -P is at the end...)
|
||||
# $ cmake -DCOV_PATH=$(pwd)
|
||||
# -DCOVERAGE_SRCS="catcierge_rfid.c;catcierge_timer.c"
|
||||
# -P ../cmake/CoverallsGcovUpload.cmake
|
||||
#
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
|
||||
|
||||
|
||||
#
|
||||
# Make sure we have the needed arguments.
|
||||
#
|
||||
if (NOT COVERALLS_OUTPUT_FILE)
|
||||
message(FATAL_ERROR "Coveralls: No coveralls output file specified. Please set COVERALLS_OUTPUT_FILE")
|
||||
endif()
|
||||
|
||||
if (NOT COV_PATH)
|
||||
message(FATAL_ERROR "Coveralls: Missing coverage directory path where gcov files will be generated. Please set COV_PATH")
|
||||
endif()
|
||||
|
||||
if (NOT COVERAGE_SRCS)
|
||||
message(FATAL_ERROR "Coveralls: Missing the list of source files that we should get the coverage data for COVERAGE_SRCS")
|
||||
endif()
|
||||
|
||||
if (NOT PROJECT_ROOT)
|
||||
message(FATAL_ERROR "Coveralls: Missing PROJECT_ROOT.")
|
||||
endif()
|
||||
|
||||
# Since it's not possible to pass a CMake list properly in the
|
||||
# "1;2;3" format to an external process, we have replaced the
|
||||
# ";" with "*", so reverse that here so we get it back into the
|
||||
# CMake list format.
|
||||
string(REGEX REPLACE "\\*" ";" COVERAGE_SRCS ${COVERAGE_SRCS})
|
||||
|
||||
if (NOT DEFINED ENV{GCOV})
|
||||
find_program(GCOV_EXECUTABLE gcov)
|
||||
else()
|
||||
find_program(GCOV_EXECUTABLE $ENV{GCOV})
|
||||
endif()
|
||||
|
||||
# convert all paths in COVERAGE_SRCS to absolute paths
|
||||
set(COVERAGE_SRCS_TMP "")
|
||||
foreach (COVERAGE_SRC ${COVERAGE_SRCS})
|
||||
if (NOT "${COVERAGE_SRC}" MATCHES "^/")
|
||||
set(COVERAGE_SRC ${PROJECT_ROOT}/${COVERAGE_SRC})
|
||||
endif()
|
||||
list(APPEND COVERAGE_SRCS_TMP ${COVERAGE_SRC})
|
||||
endforeach()
|
||||
set(COVERAGE_SRCS ${COVERAGE_SRCS_TMP})
|
||||
unset(COVERAGE_SRCS_TMP)
|
||||
|
||||
if (NOT GCOV_EXECUTABLE)
|
||||
message(FATAL_ERROR "gcov not found! Aborting...")
|
||||
endif()
|
||||
|
||||
find_package(Git)
|
||||
|
||||
set(JSON_REPO_TEMPLATE
|
||||
"{
|
||||
\"head\": {
|
||||
\"id\": \"\@GIT_COMMIT_HASH\@\",
|
||||
\"author_name\": \"\@GIT_AUTHOR_NAME\@\",
|
||||
\"author_email\": \"\@GIT_AUTHOR_EMAIL\@\",
|
||||
\"committer_name\": \"\@GIT_COMMITTER_NAME\@\",
|
||||
\"committer_email\": \"\@GIT_COMMITTER_EMAIL\@\",
|
||||
\"message\": \"\@GIT_COMMIT_MESSAGE\@\"
|
||||
},
|
||||
\"branch\": \"@GIT_BRANCH@\",
|
||||
\"remotes\": []
|
||||
}"
|
||||
)
|
||||
|
||||
# TODO: Fill in git remote data
|
||||
if (GIT_FOUND)
|
||||
# Branch.
|
||||
execute_process(
|
||||
COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||
OUTPUT_VARIABLE GIT_BRANCH
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
|
||||
macro (git_log_format FORMAT_CHARS VAR_NAME)
|
||||
execute_process(
|
||||
COMMAND ${GIT_EXECUTABLE} log -1 --pretty=format:%${FORMAT_CHARS}
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||
OUTPUT_VARIABLE ${VAR_NAME}
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
endmacro()
|
||||
|
||||
git_log_format(an GIT_AUTHOR_NAME)
|
||||
git_log_format(ae GIT_AUTHOR_EMAIL)
|
||||
git_log_format(cn GIT_COMMITTER_NAME)
|
||||
git_log_format(ce GIT_COMMITTER_EMAIL)
|
||||
git_log_format(B GIT_COMMIT_MESSAGE)
|
||||
git_log_format(H GIT_COMMIT_HASH)
|
||||
|
||||
if(GIT_COMMIT_MESSAGE)
|
||||
string(REPLACE "\n" "\\n" GIT_COMMIT_MESSAGE ${GIT_COMMIT_MESSAGE})
|
||||
endif()
|
||||
|
||||
message("Git exe: ${GIT_EXECUTABLE}")
|
||||
message("Git branch: ${GIT_BRANCH}")
|
||||
message("Git author: ${GIT_AUTHOR_NAME}")
|
||||
message("Git e-mail: ${GIT_AUTHOR_EMAIL}")
|
||||
message("Git commiter name: ${GIT_COMMITTER_NAME}")
|
||||
message("Git commiter e-mail: ${GIT_COMMITTER_EMAIL}")
|
||||
message("Git commit hash: ${GIT_COMMIT_HASH}")
|
||||
message("Git commit message: ${GIT_COMMIT_MESSAGE}")
|
||||
|
||||
string(CONFIGURE ${JSON_REPO_TEMPLATE} JSON_REPO_DATA)
|
||||
else()
|
||||
set(JSON_REPO_DATA "{}")
|
||||
endif()
|
||||
|
||||
############################# Macros #########################################
|
||||
|
||||
#
|
||||
# This macro converts from the full path format gcov outputs:
|
||||
#
|
||||
# /path/to/project/root/build/#path#to#project#root#subdir#the_file.c.gcov
|
||||
#
|
||||
# to the original source file path the .gcov is for:
|
||||
#
|
||||
# /path/to/project/root/subdir/the_file.c
|
||||
#
|
||||
macro(get_source_path_from_gcov_filename _SRC_FILENAME _GCOV_FILENAME)
|
||||
|
||||
# /path/to/project/root/build/#path#to#project#root#subdir#the_file.c.gcov
|
||||
# ->
|
||||
# #path#to#project#root#subdir#the_file.c.gcov
|
||||
get_filename_component(_GCOV_FILENAME_WEXT ${_GCOV_FILENAME} NAME)
|
||||
|
||||
# #path#to#project#root#subdir#the_file.c.gcov -> /path/to/project/root/subdir/the_file.c
|
||||
string(REGEX REPLACE "\\.gcov$" "" SRC_FILENAME_TMP ${_GCOV_FILENAME_WEXT})
|
||||
string(REGEX REPLACE "\#" "/" SRC_FILENAME_TMP ${SRC_FILENAME_TMP})
|
||||
set(${_SRC_FILENAME} "${SRC_FILENAME_TMP}")
|
||||
endmacro()
|
||||
|
||||
##############################################################################
|
||||
|
||||
# Get the coverage data.
|
||||
file(GLOB_RECURSE GCDA_FILES "${COV_PATH}/*.gcda")
|
||||
message("GCDA files:")
|
||||
|
||||
# Get a list of all the object directories needed by gcov
|
||||
# (The directories the .gcda files and .o files are found in)
|
||||
# and run gcov on those.
|
||||
foreach(GCDA ${GCDA_FILES})
|
||||
message("Process: ${GCDA}")
|
||||
message("------------------------------------------------------------------------------")
|
||||
get_filename_component(GCDA_DIR ${GCDA} PATH)
|
||||
|
||||
#
|
||||
# The -p below refers to "Preserve path components",
|
||||
# This means that the generated gcov filename of a source file will
|
||||
# keep the original files entire filepath, but / is replaced with #.
|
||||
# Example:
|
||||
#
|
||||
# /path/to/project/root/build/CMakeFiles/the_file.dir/subdir/the_file.c.gcda
|
||||
# ------------------------------------------------------------------------------
|
||||
# File '/path/to/project/root/subdir/the_file.c'
|
||||
# Lines executed:68.34% of 199
|
||||
# /path/to/project/root/subdir/the_file.c:creating '#path#to#project#root#subdir#the_file.c.gcov'
|
||||
#
|
||||
# If -p is not specified then the file is named only "the_file.c.gcov"
|
||||
#
|
||||
execute_process(
|
||||
COMMAND ${GCOV_EXECUTABLE} -p -o ${GCDA_DIR} ${GCDA}
|
||||
WORKING_DIRECTORY ${COV_PATH}
|
||||
)
|
||||
endforeach()
|
||||
|
||||
# TODO: Make these be absolute path
|
||||
file(GLOB ALL_GCOV_FILES ${COV_PATH}/*.gcov)
|
||||
|
||||
# Get only the filenames to use for filtering.
|
||||
#set(COVERAGE_SRCS_NAMES "")
|
||||
#foreach (COVSRC ${COVERAGE_SRCS})
|
||||
# get_filename_component(COVSRC_NAME ${COVSRC} NAME)
|
||||
# message("${COVSRC} -> ${COVSRC_NAME}")
|
||||
# list(APPEND COVERAGE_SRCS_NAMES "${COVSRC_NAME}")
|
||||
#endforeach()
|
||||
|
||||
#
|
||||
# Filter out all but the gcov files we want.
|
||||
#
|
||||
# We do this by comparing the list of COVERAGE_SRCS filepaths that the
|
||||
# user wants the coverage data for with the paths of the generated .gcov files,
|
||||
# so that we only keep the relevant gcov files.
|
||||
#
|
||||
# Example:
|
||||
# COVERAGE_SRCS =
|
||||
# /path/to/project/root/subdir/the_file.c
|
||||
#
|
||||
# ALL_GCOV_FILES =
|
||||
# /path/to/project/root/build/#path#to#project#root#subdir#the_file.c.gcov
|
||||
# /path/to/project/root/build/#path#to#project#root#subdir#other_file.c.gcov
|
||||
#
|
||||
# Result should be:
|
||||
# GCOV_FILES =
|
||||
# /path/to/project/root/build/#path#to#project#root#subdir#the_file.c.gcov
|
||||
#
|
||||
set(GCOV_FILES "")
|
||||
#message("Look in coverage sources: ${COVERAGE_SRCS}")
|
||||
message("\nFilter out unwanted GCOV files:")
|
||||
message("===============================")
|
||||
|
||||
set(COVERAGE_SRCS_REMAINING ${COVERAGE_SRCS})
|
||||
|
||||
foreach (GCOV_FILE ${ALL_GCOV_FILES})
|
||||
|
||||
#
|
||||
# /path/to/project/root/build/#path#to#project#root#subdir#the_file.c.gcov
|
||||
# ->
|
||||
# /path/to/project/root/subdir/the_file.c
|
||||
get_source_path_from_gcov_filename(GCOV_SRC_PATH ${GCOV_FILE})
|
||||
file(RELATIVE_PATH GCOV_SRC_REL_PATH "${PROJECT_ROOT}" "${GCOV_SRC_PATH}")
|
||||
|
||||
# Is this in the list of source files?
|
||||
# TODO: We want to match against relative path filenames from the source file root...
|
||||
list(FIND COVERAGE_SRCS ${GCOV_SRC_PATH} WAS_FOUND)
|
||||
|
||||
if (NOT WAS_FOUND EQUAL -1)
|
||||
message("YES: ${GCOV_FILE}")
|
||||
list(APPEND GCOV_FILES ${GCOV_FILE})
|
||||
|
||||
# We remove it from the list, so we don't bother searching for it again.
|
||||
# Also files left in COVERAGE_SRCS_REMAINING after this loop ends should
|
||||
# have coverage data generated from them (no lines are covered).
|
||||
list(REMOVE_ITEM COVERAGE_SRCS_REMAINING ${GCOV_SRC_PATH})
|
||||
else()
|
||||
message("NO: ${GCOV_FILE}")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
# TODO: Enable setting these
|
||||
set(JSON_SERVICE_NAME "travis-ci")
|
||||
set(JSON_SERVICE_JOB_ID $ENV{TRAVIS_JOB_ID})
|
||||
set(JSON_REPO_TOKEN $ENV{COVERALLS_REPO_TOKEN})
|
||||
|
||||
set(JSON_TEMPLATE
|
||||
"{
|
||||
\"repo_token\": \"\@JSON_REPO_TOKEN\@\",
|
||||
\"service_name\": \"\@JSON_SERVICE_NAME\@\",
|
||||
\"service_job_id\": \"\@JSON_SERVICE_JOB_ID\@\",
|
||||
\"source_files\": \@JSON_GCOV_FILES\@,
|
||||
\"git\": \@JSON_REPO_DATA\@
|
||||
}"
|
||||
)
|
||||
|
||||
set(SRC_FILE_TEMPLATE
|
||||
"{
|
||||
\"name\": \"\@GCOV_SRC_REL_PATH\@\",
|
||||
\"source_digest\": \"\@GCOV_CONTENTS_MD5\@\",
|
||||
\"coverage\": \@GCOV_FILE_COVERAGE\@
|
||||
}"
|
||||
)
|
||||
|
||||
message("\nGenerate JSON for files:")
|
||||
message("=========================")
|
||||
|
||||
set(JSON_GCOV_FILES "[")
|
||||
|
||||
# Read the GCOV files line by line and get the coverage data.
|
||||
foreach (GCOV_FILE ${GCOV_FILES})
|
||||
|
||||
get_source_path_from_gcov_filename(GCOV_SRC_PATH ${GCOV_FILE})
|
||||
file(RELATIVE_PATH GCOV_SRC_REL_PATH "${PROJECT_ROOT}" "${GCOV_SRC_PATH}")
|
||||
|
||||
# The new coveralls API doesn't need the entire source (Yay!)
|
||||
# However, still keeping that part for now. Will cleanup in the future.
|
||||
file(MD5 "${GCOV_SRC_PATH}" GCOV_CONTENTS_MD5)
|
||||
message("MD5: ${GCOV_SRC_PATH} = ${GCOV_CONTENTS_MD5}")
|
||||
|
||||
# Loads the gcov file as a list of lines.
|
||||
# (We first open the file and replace all occurrences of [] with _
|
||||
# because CMake will fail to parse a line containing unmatched brackets...
|
||||
# also the \ to escaped \n in macros screws up things.)
|
||||
# https://public.kitware.com/Bug/view.php?id=15369
|
||||
file(READ ${GCOV_FILE} GCOV_CONTENTS)
|
||||
string(REPLACE "[" "_" GCOV_CONTENTS "${GCOV_CONTENTS}")
|
||||
string(REPLACE "]" "_" GCOV_CONTENTS "${GCOV_CONTENTS}")
|
||||
string(REPLACE "\\" "_" GCOV_CONTENTS "${GCOV_CONTENTS}")
|
||||
|
||||
# Remove file contents to avoid encoding issues (cmake 2.8 has no ENCODING option)
|
||||
string(REGEX REPLACE "([^:]*):([^:]*):([^\n]*)\n" "\\1:\\2: \n" GCOV_CONTENTS "${GCOV_CONTENTS}")
|
||||
file(WRITE ${GCOV_FILE}_tmp "${GCOV_CONTENTS}")
|
||||
|
||||
file(STRINGS ${GCOV_FILE}_tmp GCOV_LINES)
|
||||
list(LENGTH GCOV_LINES LINE_COUNT)
|
||||
|
||||
# Instead of trying to parse the source from the
|
||||
# gcov file, simply read the file contents from the source file.
|
||||
# (Parsing it from the gcov is hard because C-code uses ; in many places
|
||||
# which also happens to be the same as the CMake list delimiter).
|
||||
file(READ ${GCOV_SRC_PATH} GCOV_FILE_SOURCE)
|
||||
|
||||
string(REPLACE "\\" "\\\\" GCOV_FILE_SOURCE "${GCOV_FILE_SOURCE}")
|
||||
string(REGEX REPLACE "\"" "\\\\\"" GCOV_FILE_SOURCE "${GCOV_FILE_SOURCE}")
|
||||
string(REPLACE "\t" "\\\\t" GCOV_FILE_SOURCE "${GCOV_FILE_SOURCE}")
|
||||
string(REPLACE "\r" "\\\\r" GCOV_FILE_SOURCE "${GCOV_FILE_SOURCE}")
|
||||
string(REPLACE "\n" "\\\\n" GCOV_FILE_SOURCE "${GCOV_FILE_SOURCE}")
|
||||
# According to http://json.org/ these should be escaped as well.
|
||||
# Don't know how to do that in CMake however...
|
||||
#string(REPLACE "\b" "\\\\b" GCOV_FILE_SOURCE "${GCOV_FILE_SOURCE}")
|
||||
#string(REPLACE "\f" "\\\\f" GCOV_FILE_SOURCE "${GCOV_FILE_SOURCE}")
|
||||
#string(REGEX REPLACE "\u([a-fA-F0-9]{4})" "\\\\u\\1" GCOV_FILE_SOURCE "${GCOV_FILE_SOURCE}")
|
||||
|
||||
# We want a json array of coverage data as a single string
|
||||
# start building them from the contents of the .gcov
|
||||
set(GCOV_FILE_COVERAGE "[")
|
||||
|
||||
set(GCOV_LINE_COUNT 1) # Line number for the .gcov.
|
||||
set(DO_SKIP 0)
|
||||
foreach (GCOV_LINE ${GCOV_LINES})
|
||||
#message("${GCOV_LINE}")
|
||||
# Example of what we're parsing:
|
||||
# Hitcount |Line | Source
|
||||
# " 8: 26: if (!allowed || (strlen(allowed) == 0))"
|
||||
string(REGEX REPLACE
|
||||
"^([^:]*):([^:]*):(.*)$"
|
||||
"\\1;\\2;\\3"
|
||||
RES
|
||||
"${GCOV_LINE}")
|
||||
|
||||
# Check if we should exclude lines using the Lcov syntax.
|
||||
string(REGEX MATCH "LCOV_EXCL_START" START_SKIP "${GCOV_LINE}")
|
||||
string(REGEX MATCH "LCOV_EXCL_END" END_SKIP "${GCOV_LINE}")
|
||||
string(REGEX MATCH "LCOV_EXCL_LINE" LINE_SKIP "${GCOV_LINE}")
|
||||
|
||||
set(RESET_SKIP 0)
|
||||
if (LINE_SKIP AND NOT DO_SKIP)
|
||||
set(DO_SKIP 1)
|
||||
set(RESET_SKIP 1)
|
||||
endif()
|
||||
|
||||
if (START_SKIP)
|
||||
set(DO_SKIP 1)
|
||||
message("${GCOV_LINE_COUNT}: Start skip")
|
||||
endif()
|
||||
|
||||
if (END_SKIP)
|
||||
set(DO_SKIP 0)
|
||||
endif()
|
||||
|
||||
list(LENGTH RES RES_COUNT)
|
||||
|
||||
if (RES_COUNT GREATER 2)
|
||||
list(GET RES 0 HITCOUNT)
|
||||
list(GET RES 1 LINE)
|
||||
list(GET RES 2 SOURCE)
|
||||
|
||||
string(STRIP ${HITCOUNT} HITCOUNT)
|
||||
string(STRIP ${LINE} LINE)
|
||||
|
||||
# Lines with 0 line numbers are metadata and can be ignored.
|
||||
if (NOT ${LINE} EQUAL 0)
|
||||
|
||||
if (DO_SKIP)
|
||||
set(GCOV_FILE_COVERAGE "${GCOV_FILE_COVERAGE}null, ")
|
||||
else()
|
||||
# Translate the hitcount into valid JSON values.
|
||||
if (${HITCOUNT} STREQUAL "#####" OR ${HITCOUNT} STREQUAL "=====")
|
||||
set(GCOV_FILE_COVERAGE "${GCOV_FILE_COVERAGE}0, ")
|
||||
elseif (${HITCOUNT} STREQUAL "-")
|
||||
set(GCOV_FILE_COVERAGE "${GCOV_FILE_COVERAGE}null, ")
|
||||
else()
|
||||
set(GCOV_FILE_COVERAGE "${GCOV_FILE_COVERAGE}${HITCOUNT}, ")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
else()
|
||||
message(WARNING "Failed to properly parse line (RES_COUNT = ${RES_COUNT}) ${GCOV_FILE}:${GCOV_LINE_COUNT}\n-->${GCOV_LINE}")
|
||||
endif()
|
||||
|
||||
if (RESET_SKIP)
|
||||
set(DO_SKIP 0)
|
||||
endif()
|
||||
math(EXPR GCOV_LINE_COUNT "${GCOV_LINE_COUNT}+1")
|
||||
endforeach()
|
||||
|
||||
message("${GCOV_LINE_COUNT} of ${LINE_COUNT} lines read!")
|
||||
|
||||
# Advanced way of removing the trailing comma in the JSON array.
|
||||
# "[1, 2, 3, " -> "[1, 2, 3"
|
||||
string(REGEX REPLACE ",[ ]*$" "" GCOV_FILE_COVERAGE ${GCOV_FILE_COVERAGE})
|
||||
|
||||
# Append the trailing ] to complete the JSON array.
|
||||
set(GCOV_FILE_COVERAGE "${GCOV_FILE_COVERAGE}]")
|
||||
|
||||
# Generate the final JSON for this file.
|
||||
message("Generate JSON for file: ${GCOV_SRC_REL_PATH}...")
|
||||
string(CONFIGURE ${SRC_FILE_TEMPLATE} FILE_JSON)
|
||||
|
||||
set(JSON_GCOV_FILES "${JSON_GCOV_FILES}${FILE_JSON}, ")
|
||||
endforeach()
|
||||
|
||||
# Loop through all files we couldn't find any coverage for
|
||||
# as well, and generate JSON for those as well with 0% coverage.
|
||||
foreach(NOT_COVERED_SRC ${COVERAGE_SRCS_REMAINING})
|
||||
|
||||
# Set variables for json replacement
|
||||
set(GCOV_SRC_PATH ${NOT_COVERED_SRC})
|
||||
file(MD5 "${GCOV_SRC_PATH}" GCOV_CONTENTS_MD5)
|
||||
file(RELATIVE_PATH GCOV_SRC_REL_PATH "${PROJECT_ROOT}" "${GCOV_SRC_PATH}")
|
||||
|
||||
# Loads the source file as a list of lines.
|
||||
file(STRINGS ${NOT_COVERED_SRC} SRC_LINES)
|
||||
|
||||
set(GCOV_FILE_COVERAGE "[")
|
||||
set(GCOV_FILE_SOURCE "")
|
||||
|
||||
foreach (SOURCE ${SRC_LINES})
|
||||
set(GCOV_FILE_COVERAGE "${GCOV_FILE_COVERAGE}null, ")
|
||||
|
||||
string(REPLACE "\\" "\\\\" SOURCE "${SOURCE}")
|
||||
string(REGEX REPLACE "\"" "\\\\\"" SOURCE "${SOURCE}")
|
||||
string(REPLACE "\t" "\\\\t" SOURCE "${SOURCE}")
|
||||
string(REPLACE "\r" "\\\\r" SOURCE "${SOURCE}")
|
||||
set(GCOV_FILE_SOURCE "${GCOV_FILE_SOURCE}${SOURCE}\\n")
|
||||
endforeach()
|
||||
|
||||
# Remove trailing comma, and complete JSON array with ]
|
||||
string(REGEX REPLACE ",[ ]*$" "" GCOV_FILE_COVERAGE ${GCOV_FILE_COVERAGE})
|
||||
set(GCOV_FILE_COVERAGE "${GCOV_FILE_COVERAGE}]")
|
||||
|
||||
# Generate the final JSON for this file.
|
||||
message("Generate JSON for non-gcov file: ${NOT_COVERED_SRC}...")
|
||||
string(CONFIGURE ${SRC_FILE_TEMPLATE} FILE_JSON)
|
||||
set(JSON_GCOV_FILES "${JSON_GCOV_FILES}${FILE_JSON}, ")
|
||||
endforeach()
|
||||
|
||||
# Get rid of trailing comma.
|
||||
string(REGEX REPLACE ",[ ]*$" "" JSON_GCOV_FILES ${JSON_GCOV_FILES})
|
||||
set(JSON_GCOV_FILES "${JSON_GCOV_FILES}]")
|
||||
|
||||
# Generate the final complete JSON!
|
||||
message("Generate final JSON...")
|
||||
string(CONFIGURE ${JSON_TEMPLATE} JSON)
|
||||
|
||||
file(WRITE "${COVERALLS_OUTPUT_FILE}" "${JSON}")
|
||||
message("###########################################################################")
|
||||
message("Generated coveralls JSON containing coverage data:")
|
||||
message("${COVERALLS_OUTPUT_FILE}")
|
||||
message("###########################################################################")
|
||||
347
Engine/lib/assimp/cmake-modules/DebSourcePPA.cmake
Normal file
347
Engine/lib/assimp/cmake-modules/DebSourcePPA.cmake
Normal file
|
|
@ -0,0 +1,347 @@
|
|||
## Debian Source Package Generator
|
||||
#
|
||||
# Copyright (c) 2010 Daniel Pfeifer <daniel@pfeifer-mail.de>
|
||||
# Many modifications by Rosen Diankov <rosen.diankov@gmail.com>
|
||||
#
|
||||
# Creates source debian files and manages library dependencies
|
||||
#
|
||||
# Features:
|
||||
#
|
||||
# - Automatically generates symbols and run-time dependencies from the build dependencies
|
||||
# - Custom copy of source directory via CPACK_DEBIAN_PACKAGE_SOURCE_COPY
|
||||
# - Simultaneous output of multiple debian source packages for each distribution
|
||||
# - Can specificy distribution-specific dependencies by suffixing DEPENDS with _${DISTRO_NAME}, for example: CPACK_DEBIAN_PACKAGE_DEPENDS_LUCID, CPACK_COMPONENT_MYCOMP0_DEPENDS_LUCID
|
||||
#
|
||||
# Usage:
|
||||
#
|
||||
# set(CPACK_DEBIAN_BUILD_DEPENDS debhelper cmake)
|
||||
# set(CPACK_DEBIAN_PACKAGE_PRIORITY optional)
|
||||
# set(CPACK_DEBIAN_PACKAGE_SECTION devel)
|
||||
# set(CPACK_DEBIAN_CMAKE_OPTIONS "-DMYOPTION=myvalue")
|
||||
# set(CPACK_DEBIAN_PACKAGE_DEPENDS mycomp0 mycomp1 some_ubuntu_package)
|
||||
# set(CPACK_DEBIAN_PACKAGE_DEPENDS_UBUNTU_LUCID mycomp0 mycomp1 lucid_specific_package)
|
||||
# set(CPACK_DEBIAN_PACKAGE_NAME mypackage)
|
||||
# set(CPACK_DEBIAN_PACKAGE_REMOVE_SOURCE_FILES unnecessary_file unnecessary_dir/file0)
|
||||
# set(CPACK_DEBIAN_PACKAGE_SOURCE_COPY svn export --force) # if using subversion
|
||||
# set(CPACK_DEBIAN_DISTRIBUTION_NAME ubuntu)
|
||||
# set(CPACK_DEBIAN_DISTRIBUTION_RELEASES karmic lucid maverick natty)
|
||||
# set(CPACK_DEBIAN_CHANGELOG " * Extra change log lines")
|
||||
# set(CPACK_DEBIAN_PACKAGE_SUGGESTS "ipython")
|
||||
# set(CPACK_COMPONENT_X_RECOMMENDS "recommended-package")
|
||||
##
|
||||
|
||||
find_program(DEBUILD_EXECUTABLE debuild)
|
||||
find_program(DPUT_EXECUTABLE dput)
|
||||
|
||||
if(NOT DEBUILD_EXECUTABLE OR NOT DPUT_EXECUTABLE)
|
||||
return()
|
||||
endif(NOT DEBUILD_EXECUTABLE OR NOT DPUT_EXECUTABLE)
|
||||
|
||||
# DEBIAN/control
|
||||
# debian policy enforce lower case for package name
|
||||
# Package: (mandatory)
|
||||
IF(NOT CPACK_DEBIAN_PACKAGE_NAME)
|
||||
STRING(TOLOWER "${CPACK_PACKAGE_NAME}" CPACK_DEBIAN_PACKAGE_NAME)
|
||||
ENDIF(NOT CPACK_DEBIAN_PACKAGE_NAME)
|
||||
|
||||
# Section: (recommended)
|
||||
IF(NOT CPACK_DEBIAN_PACKAGE_SECTION)
|
||||
SET(CPACK_DEBIAN_PACKAGE_SECTION "devel")
|
||||
ENDIF(NOT CPACK_DEBIAN_PACKAGE_SECTION)
|
||||
|
||||
# Priority: (recommended)
|
||||
IF(NOT CPACK_DEBIAN_PACKAGE_PRIORITY)
|
||||
SET(CPACK_DEBIAN_PACKAGE_PRIORITY "optional")
|
||||
ENDIF(NOT CPACK_DEBIAN_PACKAGE_PRIORITY)
|
||||
|
||||
file(STRINGS ${CPACK_PACKAGE_DESCRIPTION_FILE} DESC_LINES)
|
||||
foreach(LINE ${DESC_LINES})
|
||||
set(DEB_LONG_DESCRIPTION "${DEB_LONG_DESCRIPTION} ${LINE}\n")
|
||||
endforeach(LINE ${DESC_LINES})
|
||||
|
||||
file(REMOVE_RECURSE "${CMAKE_BINARY_DIR}/Debian")
|
||||
file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/Debian")
|
||||
set(DEBIAN_SOURCE_ORIG_DIR "${CMAKE_BINARY_DIR}/Debian/${CPACK_DEBIAN_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}")
|
||||
|
||||
if( CPACK_DEBIAN_PACKAGE_SOURCE_COPY )
|
||||
execute_process(COMMAND ${CPACK_DEBIAN_PACKAGE_SOURCE_COPY} "${CMAKE_SOURCE_DIR}" "${DEBIAN_SOURCE_ORIG_DIR}.orig")
|
||||
else()
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR} "${DEBIAN_SOURCE_ORIG_DIR}.orig")
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E remove_directory "${DEBIAN_SOURCE_ORIG_DIR}.orig/.git")
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E remove_directory "${DEBIAN_SOURCE_ORIG_DIR}.orig/.svn")
|
||||
endif()
|
||||
|
||||
# remove unnecessary folders
|
||||
foreach(REMOVE_DIR ${CPACK_DEBIAN_PACKAGE_REMOVE_SOURCE_FILES})
|
||||
file(REMOVE_RECURSE ${DEBIAN_SOURCE_ORIG_DIR}.orig/${REMOVE_DIR})
|
||||
endforeach()
|
||||
|
||||
# create the original source tar
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E tar czf "${CPACK_DEBIAN_PACKAGE_NAME}_${CPACK_PACKAGE_VERSION}.orig.tar.gz" "${CPACK_DEBIAN_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}.orig" WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/Debian)
|
||||
|
||||
set(DEB_SOURCE_CHANGES)
|
||||
foreach(RELEASE ${CPACK_DEBIAN_DISTRIBUTION_RELEASES})
|
||||
set(DEBIAN_SOURCE_DIR "${DEBIAN_SOURCE_ORIG_DIR}-${CPACK_DEBIAN_DISTRIBUTION_NAME}1~${RELEASE}1")
|
||||
set(RELEASE_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION}-${CPACK_DEBIAN_DISTRIBUTION_NAME}1~${RELEASE}1")
|
||||
string(TOUPPER ${RELEASE} RELEASE_UPPER)
|
||||
string(TOUPPER ${CPACK_DEBIAN_DISTRIBUTION_NAME} DISTRIBUTION_NAME_UPPER)
|
||||
file(MAKE_DIRECTORY ${DEBIAN_SOURCE_DIR}/debian)
|
||||
##############################################################################
|
||||
# debian/control
|
||||
set(DEBIAN_CONTROL ${DEBIAN_SOURCE_DIR}/debian/control)
|
||||
file(WRITE ${DEBIAN_CONTROL}
|
||||
"Source: ${CPACK_DEBIAN_PACKAGE_NAME}\n"
|
||||
"Section: ${CPACK_DEBIAN_PACKAGE_SECTION}\n"
|
||||
"Priority: ${CPACK_DEBIAN_PACKAGE_PRIORITY}\n"
|
||||
"DM-Upload-Allowed: yes\n"
|
||||
"Maintainer: ${CPACK_PACKAGE_CONTACT}\n"
|
||||
"Build-Depends: "
|
||||
)
|
||||
|
||||
if( CPACK_DEBIAN_BUILD_DEPENDS_${DISTRIBUTION_NAME_UPPER}_${RELEASE_UPPER} )
|
||||
foreach(DEP ${CPACK_DEBIAN_BUILD_DEPENDS_${DISTRIBUTION_NAME_UPPER}_${RELEASE_UPPER}})
|
||||
file(APPEND ${DEBIAN_CONTROL} "${DEP}, ")
|
||||
endforeach(DEP ${CPACK_DEBIAN_BUILD_DEPENDS_${DISTRIBUTION_NAME_UPPER}_${RELEASE_UPPER}})
|
||||
else( CPACK_DEBIAN_BUILD_DEPENDS_${DISTRIBUTION_NAME_UPPER}_${RELEASE_UPPER} )
|
||||
if( CPACK_DEBIAN_BUILD_DEPENDS_${DISTRIBUTION_NAME_UPPER} )
|
||||
foreach(DEP ${CPACK_DEBIAN_BUILD_DEPENDS_${DISTRIBUTION_NAME_UPPER}})
|
||||
file(APPEND ${DEBIAN_CONTROL} "${DEP}, ")
|
||||
endforeach(DEP ${CPACK_DEBIAN_BUILD_DEPENDS_${DISTRIBUTION_NAME_UPPER}})
|
||||
else( CPACK_DEBIAN_BUILD_DEPENDS_${DISTRIBUTION_NAME_UPPER} )
|
||||
foreach(DEP ${CPACK_DEBIAN_BUILD_DEPENDS})
|
||||
file(APPEND ${DEBIAN_CONTROL} "${DEP}, ")
|
||||
endforeach(DEP ${CPACK_DEBIAN_BUILD_DEPENDS})
|
||||
endif( CPACK_DEBIAN_BUILD_DEPENDS_${DISTRIBUTION_NAME_UPPER} )
|
||||
endif( CPACK_DEBIAN_BUILD_DEPENDS_${DISTRIBUTION_NAME_UPPER}_${RELEASE_UPPER} )
|
||||
|
||||
|
||||
file(APPEND ${DEBIAN_CONTROL} "\n"
|
||||
"Standards-Version: 3.8.4\n"
|
||||
"Homepage: ${CPACK_PACKAGE_VENDOR}\n"
|
||||
"\n"
|
||||
"Package: ${CPACK_DEBIAN_PACKAGE_NAME}\n"
|
||||
"Architecture: any\n"
|
||||
"Depends: "
|
||||
)
|
||||
|
||||
if( CPACK_DEBIAN_PACKAGE_DEPENDS_${DISTRIBUTION_NAME_UPPER}_${RELEASE_UPPER} )
|
||||
foreach(DEP ${CPACK_DEBIAN_PACKAGE_DEPENDS_${DISTRIBUTION_NAME_UPPER}_${RELEASE_UPPER}})
|
||||
file(APPEND ${DEBIAN_CONTROL} "${DEP}, ")
|
||||
endforeach(DEP ${CPACK_DEBIAN_PACKAGE_DEPENDS_${DISTRIBUTION_NAME_UPPER}_${RELEASE_UPPER}})
|
||||
else( CPACK_DEBIAN_PACKAGE_DEPENDS_${DISTRIBUTION_NAME_UPPER}_${RELEASE_UPPER} )
|
||||
if( CPACK_DEBIAN_PACKAGE_DEPENDS_${DISTRIBUTION_NAME_UPPER} )
|
||||
foreach(DEP ${CPACK_DEBIAN_PACKAGE_DEPENDS_${DISTRIBUTION_NAME_UPPER}})
|
||||
file(APPEND ${DEBIAN_CONTROL} "${DEP}, ")
|
||||
endforeach(DEP ${CPACK_DEBIAN_PACKAGE_DEPENDS_${DISTRIBUTION_NAME_UPPER}})
|
||||
else( CPACK_DEBIAN_PACKAGE_DEPENDS_${DISTRIBUTION_NAME_UPPER} )
|
||||
foreach(DEP ${CPACK_DEBIAN_PACKAGE_DEPENDS})
|
||||
file(APPEND ${DEBIAN_CONTROL} "${DEP}, ")
|
||||
endforeach(DEP ${CPACK_DEBIAN_PACKAGE_DEPENDS})
|
||||
endif( CPACK_DEBIAN_PACKAGE_DEPENDS_${DISTRIBUTION_NAME_UPPER} )
|
||||
endif( CPACK_DEBIAN_PACKAGE_DEPENDS_${DISTRIBUTION_NAME_UPPER}_${RELEASE_UPPER} )
|
||||
|
||||
file(APPEND ${DEBIAN_CONTROL} "\nRecommends: ")
|
||||
if( CPACK_DEBIAN_PACKAGE_RECOMMENDS_${DISTRIBUTION_NAME_UPPER}_${RELEASE_UPPER} )
|
||||
foreach(DEP ${CPACK_DEBIAN_PACKAGE_RECOMMENDS_${DISTRIBUTION_NAME_UPPER}_${RELEASE_UPPER}})
|
||||
file(APPEND ${DEBIAN_CONTROL} "${DEP}, ")
|
||||
endforeach(DEP ${CPACK_DEBIAN_PACKAGE_RECOMMENDS_${DISTRIBUTION_NAME_UPPER}_${RELEASE_UPPER}})
|
||||
else( CPACK_DEBIAN_PACKAGE_RECOMMENDS_${DISTRIBUTION_NAME_UPPER}_${RELEASE_UPPER} )
|
||||
if( CPACK_DEBIAN_PACKAGE_RECOMMENDS_${DISTRIBUTION_NAME_UPPER} )
|
||||
foreach(DEP ${CPACK_DEBIAN_PACKAGE_RECOMMENDS_${DISTRIBUTION_NAME_UPPER}})
|
||||
file(APPEND ${DEBIAN_CONTROL} "${DEP}, ")
|
||||
endforeach(DEP ${CPACK_DEBIAN_PACKAGE_RECOMMENDS_${DISTRIBUTION_NAME_UPPER}})
|
||||
else( CPACK_DEBIAN_PACKAGE_RECOMMENDS_${DISTRIBUTION_NAME_UPPER} )
|
||||
foreach(DEP ${CPACK_DEBIAN_PACKAGE_RECOMMENDS})
|
||||
file(APPEND ${DEBIAN_CONTROL} "${DEP}, ")
|
||||
endforeach(DEP ${CPACK_DEBIAN_PACKAGE_RECOMMENDS})
|
||||
endif( CPACK_DEBIAN_PACKAGE_RECOMMENDS_${DISTRIBUTION_NAME_UPPER} )
|
||||
endif( CPACK_DEBIAN_PACKAGE_RECOMMENDS_${DISTRIBUTION_NAME_UPPER}_${RELEASE_UPPER} )
|
||||
|
||||
file(APPEND ${DEBIAN_CONTROL} "\nSuggests: ")
|
||||
if( CPACK_DEBIAN_PACKAGE_SUGGESTS_${DISTRIBUTION_NAME_UPPER}_${RELEASE_UPPER} )
|
||||
foreach(DEP ${CPACK_DEBIAN_PACKAGE_SUGGESTS_${DISTRIBUTION_NAME_UPPER}_${RELEASE_UPPER}})
|
||||
file(APPEND ${DEBIAN_CONTROL} "${DEP}, ")
|
||||
endforeach(DEP ${CPACK_DEBIAN_PACKAGE_SUGGESTS_${DISTRIBUTION_NAME_UPPER}_${RELEASE_UPPER}})
|
||||
else( CPACK_DEBIAN_PACKAGE_SUGGESTS_${DISTRIBUTION_NAME_UPPER}_${RELEASE_UPPER} )
|
||||
if( CPACK_DEBIAN_PACKAGE_SUGGESTS_${DISTRIBUTION_NAME_UPPER} )
|
||||
foreach(DEP ${CPACK_DEBIAN_PACKAGE_SUGGESTS_${DISTRIBUTION_NAME_UPPER}})
|
||||
file(APPEND ${DEBIAN_CONTROL} "${DEP}, ")
|
||||
endforeach(DEP ${CPACK_DEBIAN_PACKAGE_SUGGESTS_${DISTRIBUTION_NAME_UPPER}})
|
||||
else( CPACK_DEBIAN_PACKAGE_SUGGESTS_${DISTRIBUTION_NAME_UPPER} )
|
||||
foreach(DEP ${CPACK_DEBIAN_PACKAGE_SUGGESTS})
|
||||
file(APPEND ${DEBIAN_CONTROL} "${DEP}, ")
|
||||
endforeach(DEP ${CPACK_DEBIAN_PACKAGE_SUGGESTS})
|
||||
endif( CPACK_DEBIAN_PACKAGE_SUGGESTS_${DISTRIBUTION_NAME_UPPER} )
|
||||
endif( CPACK_DEBIAN_PACKAGE_SUGGESTS_${DISTRIBUTION_NAME_UPPER}_${RELEASE_UPPER} )
|
||||
|
||||
file(APPEND ${DEBIAN_CONTROL} "\n"
|
||||
"Description: ${CPACK_PACKAGE_DISPLAY_NAME} ${CPACK_PACKAGE_DESCRIPTION_SUMMARY}\n"
|
||||
"${DEB_LONG_DESCRIPTION}"
|
||||
)
|
||||
|
||||
foreach(COMPONENT ${CPACK_COMPONENTS_ALL})
|
||||
string(TOUPPER ${COMPONENT} UPPER_COMPONENT)
|
||||
set(DEPENDS "\${shlibs:Depends}")
|
||||
if( CPACK_COMPONENT_${UPPER_COMPONENT}_DEPENDS_${DISTRIBUTION_NAME_UPPER}_${RELEASE_UPPER} )
|
||||
foreach(DEP ${CPACK_COMPONENT_${UPPER_COMPONENT}_DEPENDS_${DISTRIBUTION_NAME_UPPER}_${RELEASE_UPPER}})
|
||||
set(DEPENDS "${DEPENDS}, ${DEP}")
|
||||
endforeach(DEP ${CPACK_COMPONENT_${UPPER_COMPONENT}_DEPENDS_${DISTRIBUTION_NAME_UPPER}_${RELEASE_UPPER}})
|
||||
else( CPACK_COMPONENT_${UPPER_COMPONENT}_DEPENDS_${DISTRIBUTION_NAME_UPPER}_${RELEASE_UPPER} )
|
||||
if( CPACK_COMPONENT_${UPPER_COMPONENT}_DEPENDS_${DISTRIBUTION_NAME_UPPER} )
|
||||
foreach(DEP ${CPACK_COMPONENT_${UPPER_COMPONENT}_DEPENDS_${DISTRIBUTION_NAME_UPPER}})
|
||||
set(DEPENDS "${DEPENDS}, ${DEP}")
|
||||
endforeach(DEP ${CPACK_COMPONENT_${UPPER_COMPONENT}_DEPENDS_${DISTRIBUTION_NAME_UPPER}})
|
||||
else( CPACK_COMPONENT_${UPPER_COMPONENT}_DEPENDS_${DISTRIBUTION_NAME_UPPER} )
|
||||
foreach(DEP ${CPACK_COMPONENT_${UPPER_COMPONENT}_DEPENDS})
|
||||
set(DEPENDS "${DEPENDS}, ${DEP}")
|
||||
endforeach(DEP ${CPACK_COMPONENT_${UPPER_COMPONENT}_DEPENDS})
|
||||
endif( CPACK_COMPONENT_${UPPER_COMPONENT}_DEPENDS_${DISTRIBUTION_NAME_UPPER} )
|
||||
endif( CPACK_COMPONENT_${UPPER_COMPONENT}_DEPENDS_${DISTRIBUTION_NAME_UPPER}_${RELEASE_UPPER} )
|
||||
|
||||
set(RECOMMENDS)
|
||||
if( CPACK_COMPONENT_${UPPER_COMPONENT}_RECOMMENDS_${DISTRIBUTION_NAME_UPPER}_${RELEASE_UPPER} )
|
||||
foreach(DEP ${CPACK_COMPONENT_${UPPER_COMPONENT}_RECOMMENDS_${DISTRIBUTION_NAME_UPPER}_${RELEASE_UPPER}})
|
||||
set(RECOMMENDS "${RECOMMENDS} ${DEP}, ")
|
||||
endforeach(DEP ${CPACK_COMPONENT_${UPPER_COMPONENT}_RECOMMENDS_${DISTRIBUTION_NAME_UPPER}_${RELEASE_UPPER}})
|
||||
else( CPACK_COMPONENT_${UPPER_COMPONENT}_RECOMMENDS_${DISTRIBUTION_NAME_UPPER}_${RELEASE_UPPER} )
|
||||
if( CPACK_COMPONENT_${UPPER_COMPONENT}_RECOMMENDS_${DISTRIBUTION_NAME_UPPER} )
|
||||
foreach(DEP ${CPACK_COMPONENT_${UPPER_COMPONENT}_RECOMMENDS_${DISTRIBUTION_NAME_UPPER}})
|
||||
set(RECOMMENDS "${RECOMMENDS} ${DEP}, ")
|
||||
endforeach(DEP ${CPACK_COMPONENT_${UPPER_COMPONENT}_RECOMMENDS_${DISTRIBUTION_NAME_UPPER}})
|
||||
else( CPACK_COMPONENT_${UPPER_COMPONENT}_RECOMMENDS_${DISTRIBUTION_NAME_UPPER} )
|
||||
foreach(DEP ${CPACK_COMPONENT_${UPPER_COMPONENT}_RECOMMENDS})
|
||||
set(RECOMMENDS "${RECOMMENDS} ${DEP}, ")
|
||||
endforeach(DEP ${CPACK_COMPONENT_${UPPER_COMPONENT}_RECOMMENDS})
|
||||
endif( CPACK_COMPONENT_${UPPER_COMPONENT}_RECOMMENDS_${DISTRIBUTION_NAME_UPPER} )
|
||||
endif( CPACK_COMPONENT_${UPPER_COMPONENT}_RECOMMENDS_${DISTRIBUTION_NAME_UPPER}_${RELEASE_UPPER} )
|
||||
|
||||
set(SUGGESTS)
|
||||
if( CPACK_COMPONENT_${UPPER_COMPONENT}_SUGGESTS_${DISTRIBUTION_NAME_UPPER}_${RELEASE_UPPER} )
|
||||
foreach(DEP ${CPACK_COMPONENT_${UPPER_COMPONENT}_SUGGESTS_${DISTRIBUTION_NAME_UPPER}_${RELEASE_UPPER}})
|
||||
set(SUGGESTS "${SUGGESTS} ${DEP}, ")
|
||||
endforeach(DEP ${CPACK_COMPONENT_${UPPER_COMPONENT}_SUGGESTS_${DISTRIBUTION_NAME_UPPER}_${RELEASE_UPPER}})
|
||||
else( CPACK_COMPONENT_${UPPER_COMPONENT}_SUGGESTS_${DISTRIBUTION_NAME_UPPER}_${RELEASE_UPPER} )
|
||||
if( CPACK_COMPONENT_${UPPER_COMPONENT}_SUGGESTS_${DISTRIBUTION_NAME_UPPER} )
|
||||
foreach(DEP ${CPACK_COMPONENT_${UPPER_COMPONENT}_SUGGESTS_${DISTRIBUTION_NAME_UPPER}})
|
||||
set(SUGGESTS "${SUGGESTS} ${DEP}, ")
|
||||
endforeach(DEP ${CPACK_COMPONENT_${UPPER_COMPONENT}_SUGGESTS_${DISTRIBUTION_NAME_UPPER}})
|
||||
else( CPACK_COMPONENT_${UPPER_COMPONENT}_SUGGESTS_${DISTRIBUTION_NAME_UPPER} )
|
||||
foreach(DEP ${CPACK_COMPONENT_${UPPER_COMPONENT}_SUGGESTS})
|
||||
set(SUGGESTS "${SUGGESTS} ${DEP}, ")
|
||||
endforeach(DEP ${CPACK_COMPONENT_${UPPER_COMPONENT}_SUGGESTS})
|
||||
endif( CPACK_COMPONENT_${UPPER_COMPONENT}_SUGGESTS_${DISTRIBUTION_NAME_UPPER} )
|
||||
endif( CPACK_COMPONENT_${UPPER_COMPONENT}_SUGGESTS_${DISTRIBUTION_NAME_UPPER}_${RELEASE_UPPER} )
|
||||
|
||||
file(APPEND ${DEBIAN_CONTROL} "\n"
|
||||
"Package: ${COMPONENT}\n"
|
||||
"Architecture: any\n"
|
||||
"Depends: ${DEPENDS}\n"
|
||||
"Recommends: ${RECOMMENDS}\n"
|
||||
"Suggests: ${SUGGESTS}\n"
|
||||
"Description: ${CPACK_PACKAGE_DISPLAY_NAME} ${CPACK_COMPONENT_${UPPER_COMPONENT}_DISPLAY_NAME}\n"
|
||||
"${DEB_LONG_DESCRIPTION}"
|
||||
" .\n"
|
||||
" ${CPACK_COMPONENT_${UPPER_COMPONENT}_DESCRIPTION}\n"
|
||||
)
|
||||
endforeach(COMPONENT ${CPACK_COMPONENTS_ALL})
|
||||
|
||||
##############################################################################
|
||||
# debian/copyright
|
||||
set(DEBIAN_COPYRIGHT ${DEBIAN_SOURCE_DIR}/debian/copyright)
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E
|
||||
copy ${CPACK_RESOURCE_FILE_LICENSE} ${DEBIAN_COPYRIGHT}
|
||||
)
|
||||
|
||||
##############################################################################
|
||||
# debian/rules
|
||||
set(DEBIAN_RULES ${DEBIAN_SOURCE_DIR}/debian/rules)
|
||||
file(WRITE ${DEBIAN_RULES}
|
||||
"#!/usr/bin/make -f\n"
|
||||
"\n"
|
||||
"BUILDDIR = build_dir\n"
|
||||
"\n"
|
||||
"build:\n"
|
||||
" mkdir $(BUILDDIR)\n"
|
||||
" cd $(BUILDDIR); cmake -DCMAKE_BUILD_TYPE=Release ${CPACK_DEBIAN_CMAKE_OPTIONS} -DCMAKE_INSTALL_PREFIX=/usr ..\n"
|
||||
" $(MAKE) -C $(BUILDDIR) preinstall\n"
|
||||
" touch build\n"
|
||||
"\n"
|
||||
"binary: binary-indep binary-arch\n"
|
||||
"\n"
|
||||
"binary-indep: build\n"
|
||||
"\n"
|
||||
"binary-arch: build\n"
|
||||
" cd $(BUILDDIR); cmake -DCOMPONENT=Unspecified -DCMAKE_INSTALL_PREFIX=../debian/tmp/usr -P cmake_install.cmake\n"
|
||||
" mkdir -p debian/tmp/DEBIAN\n"
|
||||
" dpkg-gensymbols -p${CPACK_DEBIAN_PACKAGE_NAME}\n"
|
||||
)
|
||||
|
||||
foreach(COMPONENT ${CPACK_COMPONENTS_ALL})
|
||||
set(PATH debian/${COMPONENT})
|
||||
file(APPEND ${DEBIAN_RULES}
|
||||
" cd $(BUILDDIR); cmake -DCOMPONENT=${COMPONENT} -DCMAKE_INSTALL_PREFIX=../${PATH}/usr -P cmake_install.cmake\n"
|
||||
" mkdir -p ${PATH}/DEBIAN\n"
|
||||
" dpkg-gensymbols -p${COMPONENT} -P${PATH}\n"
|
||||
)
|
||||
endforeach(COMPONENT ${CPACK_COMPONENTS_ALL})
|
||||
|
||||
file(APPEND ${DEBIAN_RULES}
|
||||
" dh_shlibdeps\n"
|
||||
" dh_strip\n" # for reducing size
|
||||
" dpkg-gencontrol -p${CPACK_DEBIAN_PACKAGE_NAME}\n"
|
||||
" dpkg --build debian/tmp ..\n"
|
||||
)
|
||||
|
||||
foreach(COMPONENT ${CPACK_COMPONENTS_ALL})
|
||||
set(PATH debian/${COMPONENT})
|
||||
file(APPEND ${DEBIAN_RULES}
|
||||
" dpkg-gencontrol -p${COMPONENT} -P${PATH} -Tdebian/${COMPONENT}.substvars\n"
|
||||
" dpkg --build ${PATH} ..\n"
|
||||
)
|
||||
endforeach(COMPONENT ${CPACK_COMPONENTS_ALL})
|
||||
|
||||
file(APPEND ${DEBIAN_RULES}
|
||||
"\n"
|
||||
"clean:\n"
|
||||
" rm -f build\n"
|
||||
" rm -rf $(BUILDDIR)\n"
|
||||
"\n"
|
||||
".PHONY: binary binary-arch binary-indep clean\n"
|
||||
)
|
||||
|
||||
execute_process(COMMAND chmod +x ${DEBIAN_RULES})
|
||||
|
||||
##############################################################################
|
||||
# debian/compat
|
||||
file(WRITE ${DEBIAN_SOURCE_DIR}/debian/compat "7")
|
||||
|
||||
##############################################################################
|
||||
# debian/source/format
|
||||
file(WRITE ${DEBIAN_SOURCE_DIR}/debian/source/format "3.0 (quilt)")
|
||||
|
||||
##############################################################################
|
||||
# debian/changelog
|
||||
set(DEBIAN_CHANGELOG ${DEBIAN_SOURCE_DIR}/debian/changelog)
|
||||
execute_process(COMMAND date -R OUTPUT_VARIABLE DATE_TIME)
|
||||
file(WRITE ${DEBIAN_CHANGELOG}
|
||||
"${CPACK_DEBIAN_PACKAGE_NAME} (${RELEASE_PACKAGE_VERSION}) ${RELEASE}; urgency=medium\n\n"
|
||||
" * Package built with CMake\n\n"
|
||||
"${CPACK_DEBIAN_CHANGELOG}"
|
||||
" -- ${CPACK_PACKAGE_CONTACT} ${DATE_TIME}"
|
||||
)
|
||||
|
||||
##############################################################################
|
||||
# debuild -S
|
||||
if( DEB_SOURCE_CHANGES )
|
||||
set(DEBUILD_OPTIONS "-sd")
|
||||
else()
|
||||
set(DEBUILD_OPTIONS "-sa")
|
||||
endif()
|
||||
set(SOURCE_CHANGES_FILE "${CPACK_DEBIAN_PACKAGE_NAME}_${RELEASE_PACKAGE_VERSION}_source.changes")
|
||||
set(DEB_SOURCE_CHANGES ${DEB_SOURCE_CHANGES} "${SOURCE_CHANGES_FILE}")
|
||||
add_custom_command(OUTPUT "${SOURCE_CHANGES_FILE}" COMMAND ${DEBUILD_EXECUTABLE} -S ${DEBUILD_OPTIONS} WORKING_DIRECTORY ${DEBIAN_SOURCE_DIR})
|
||||
endforeach(RELEASE ${CPACK_DEBIAN_DISTRIBUTION_RELEASES})
|
||||
|
||||
##############################################################################
|
||||
# dput ppa:your-lp-id/ppa <source.changes>
|
||||
add_custom_target(dput ${DPUT_EXECUTABLE} ${DPUT_HOST} ${DEB_SOURCE_CHANGES} DEPENDS ${DEB_SOURCE_CHANGES} WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/Debian)
|
||||
72
Engine/lib/assimp/cmake-modules/FindDevIL.cmake
Normal file
72
Engine/lib/assimp/cmake-modules/FindDevIL.cmake
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
||||
# file Copyright.txt or https://cmake.org/licensing for details.
|
||||
|
||||
#.rst:
|
||||
# FindDevIL
|
||||
# ---------
|
||||
#
|
||||
#
|
||||
#
|
||||
# This module locates the developer's image library.
|
||||
# http://openil.sourceforge.net/
|
||||
#
|
||||
# This module sets:
|
||||
#
|
||||
# ::
|
||||
#
|
||||
# IL_LIBRARIES - the name of the IL library. These include the full path to
|
||||
# the core DevIL library. This one has to be linked into the
|
||||
# application.
|
||||
# ILU_LIBRARIES - the name of the ILU library. Again, the full path. This
|
||||
# library is for filters and effects, not actual loading. It
|
||||
# doesn't have to be linked if the functionality it provides
|
||||
# is not used.
|
||||
# ILUT_LIBRARIES - the name of the ILUT library. Full path. This part of the
|
||||
# library interfaces with OpenGL. It is not strictly needed
|
||||
# in applications.
|
||||
# IL_INCLUDE_DIR - where to find the il.h, ilu.h and ilut.h files.
|
||||
# IL_FOUND - this is set to TRUE if all the above variables were set.
|
||||
# This will be set to false if ILU or ILUT are not found,
|
||||
# even if they are not needed. In most systems, if one
|
||||
# library is found all the others are as well. That's the
|
||||
# way the DevIL developers release it.
|
||||
|
||||
# TODO: Add version support.
|
||||
# Tested under Linux and Windows (MSVC)
|
||||
|
||||
#include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
find_path(IL_INCLUDE_DIR il.h
|
||||
PATH_SUFFIXES include IL
|
||||
DOC "The path to the directory that contains il.h"
|
||||
)
|
||||
|
||||
#message("IL_INCLUDE_DIR is ${IL_INCLUDE_DIR}")
|
||||
|
||||
find_library(IL_LIBRARIES
|
||||
NAMES IL DEVIL
|
||||
PATH_SUFFIXES lib64 lib lib32
|
||||
DOC "The file that corresponds to the base il library."
|
||||
)
|
||||
|
||||
#message("IL_LIBRARIES is ${IL_LIBRARIES}")
|
||||
|
||||
find_library(ILUT_LIBRARIES
|
||||
NAMES ILUT
|
||||
PATH_SUFFIXES lib64 lib lib32
|
||||
DOC "The file that corresponds to the il (system?) utility library."
|
||||
)
|
||||
|
||||
#message("ILUT_LIBRARIES is ${ILUT_LIBRARIES}")
|
||||
|
||||
find_library(ILU_LIBRARIES
|
||||
NAMES ILU
|
||||
PATH_SUFFIXES lib64 lib lib32
|
||||
DOC "The file that corresponds to the il utility library."
|
||||
)
|
||||
|
||||
#message("ILU_LIBRARIES is ${ILU_LIBRARIES}")
|
||||
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(IL DEFAULT_MSG
|
||||
IL_LIBRARIES IL_INCLUDE_DIR)
|
||||
101
Engine/lib/assimp/cmake-modules/FindDirectX.cmake
Normal file
101
Engine/lib/assimp/cmake-modules/FindDirectX.cmake
Normal file
|
|
@ -0,0 +1,101 @@
|
|||
#-------------------------------------------------------------------
|
||||
# This file is part of the CMake build system for OGRE
|
||||
# (Object-oriented Graphics Rendering Engine)
|
||||
# For the latest info, see http://www.ogre3d.org/
|
||||
#
|
||||
# The contents of this file are placed in the public domain. Feel
|
||||
# free to make use of it in any way you like.
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Find DirectX SDK
|
||||
# Define:
|
||||
# DirectX_FOUND
|
||||
# DirectX_INCLUDE_DIR
|
||||
# DirectX_LIBRARY
|
||||
# DirectX_ROOT_DIR
|
||||
|
||||
if(WIN32) # The only platform it makes sense to check for DirectX SDK
|
||||
include(FindPkgMacros)
|
||||
findpkg_begin(DirectX)
|
||||
|
||||
# Get path, convert backslashes as ${ENV_DXSDK_DIR}
|
||||
getenv_path(DXSDK_DIR)
|
||||
getenv_path(DIRECTX_HOME)
|
||||
getenv_path(DIRECTX_ROOT)
|
||||
getenv_path(DIRECTX_BASE)
|
||||
|
||||
# construct search paths
|
||||
set(DirectX_PREFIX_PATH
|
||||
"${DXSDK_DIR}" "${ENV_DXSDK_DIR}"
|
||||
"${DIRECTX_HOME}" "${ENV_DIRECTX_HOME}"
|
||||
"${DIRECTX_ROOT}" "${ENV_DIRECTX_ROOT}"
|
||||
"${DIRECTX_BASE}" "${ENV_DIRECTX_BASE}"
|
||||
"C:/apps_x86/Microsoft DirectX SDK*"
|
||||
"C:/Program Files (x86)/Microsoft DirectX SDK*"
|
||||
"C:/apps/Microsoft DirectX SDK*"
|
||||
"C:/Program Files/Microsoft DirectX SDK*"
|
||||
"C:/Program Files (x86)/Windows Kits/8.1"
|
||||
"$ENV{ProgramFiles}/Microsoft DirectX SDK*"
|
||||
)
|
||||
create_search_paths(DirectX)
|
||||
# redo search if prefix path changed
|
||||
clear_if_changed(DirectX_PREFIX_PATH
|
||||
DirectX_LIBRARY
|
||||
DirectX_INCLUDE_DIR
|
||||
)
|
||||
|
||||
find_path(DirectX_INCLUDE_DIR NAMES d3d9.h HINTS ${DirectX_INC_SEARCH_PATH})
|
||||
# dlls are in DirectX_ROOT_DIR/Developer Runtime/x64|x86
|
||||
# lib files are in DirectX_ROOT_DIR/Lib/x64|x86
|
||||
if(CMAKE_CL_64)
|
||||
set(DirectX_LIBPATH_SUFFIX "x64")
|
||||
else(CMAKE_CL_64)
|
||||
set(DirectX_LIBPATH_SUFFIX "x86")
|
||||
endif(CMAKE_CL_64)
|
||||
find_library(DirectX_LIBRARY NAMES d3d9 HINTS ${DirectX_LIB_SEARCH_PATH} PATH_SUFFIXES ${DirectX_LIBPATH_SUFFIX})
|
||||
find_library(DirectX_D3DX9_LIBRARY NAMES d3dx9 HINTS ${DirectX_LIB_SEARCH_PATH} PATH_SUFFIXES ${DirectX_LIBPATH_SUFFIX})
|
||||
find_library(DirectX_DXERR_LIBRARY NAMES DxErr DxErr9 HINTS ${DirectX_LIB_SEARCH_PATH} PATH_SUFFIXES ${DirectX_LIBPATH_SUFFIX})
|
||||
find_library(DirectX_DXGUID_LIBRARY NAMES dxguid HINTS ${DirectX_LIB_SEARCH_PATH} PATH_SUFFIXES ${DirectX_LIBPATH_SUFFIX})
|
||||
|
||||
|
||||
# look for dxgi (needed by both 10 and 11)
|
||||
find_library(DirectX_DXGI_LIBRARY NAMES dxgi HINTS ${DirectX_LIB_SEARCH_PATH} PATH_SUFFIXES ${DirectX_LIBPATH_SUFFIX})
|
||||
|
||||
# look for d3dcompiler (needed by 11)
|
||||
find_library(DirectX_D3DCOMPILER_LIBRARY NAMES d3dcompiler HINTS ${DirectX_LIB_SEARCH_PATH} PATH_SUFFIXES ${DirectX_LIBPATH_SUFFIX})
|
||||
|
||||
findpkg_finish(DirectX)
|
||||
set(DirectX_LIBRARIES ${DirectX_LIBRARIES}
|
||||
${DirectX_D3DX9_LIBRARY}
|
||||
${DirectX_DXERR_LIBRARY}
|
||||
${DirectX_DXGUID_LIBRARY}
|
||||
)
|
||||
|
||||
mark_as_advanced(DirectX_D3DX9_LIBRARY DirectX_DXERR_LIBRARY DirectX_DXGUID_LIBRARY
|
||||
DirectX_DXGI_LIBRARY DirectX_D3DCOMPILER_LIBRARY)
|
||||
|
||||
|
||||
# look for D3D11 components
|
||||
if (DirectX_FOUND)
|
||||
find_path(DirectX_D3D11_INCLUDE_DIR NAMES D3D11Shader.h HINTS ${DirectX_INC_SEARCH_PATH})
|
||||
get_filename_component(DirectX_LIBRARY_DIR "${DirectX_LIBRARY}" PATH)
|
||||
message(STATUS "DX lib dir: ${DirectX_LIBRARY_DIR}")
|
||||
find_library(DirectX_D3D11_LIBRARY NAMES d3d11 HINTS ${DirectX_LIB_SEARCH_PATH} PATH_SUFFIXES ${DirectX_LIBPATH_SUFFIX})
|
||||
find_library(DirectX_D3DX11_LIBRARY NAMES d3dx11 HINTS ${DirectX_LIB_SEARCH_PATH} PATH_SUFFIXES ${DirectX_LIBPATH_SUFFIX})
|
||||
if (DirectX_D3D11_INCLUDE_DIR AND DirectX_D3D11_LIBRARY)
|
||||
set(DirectX_D3D11_FOUND TRUE)
|
||||
set(DirectX_D3D11_INCLUDE_DIR ${DirectX_D3D11_INCLUDE_DIR})
|
||||
set(DirectX_D3D11_LIBRARIES ${DirectX_D3D11_LIBRARIES}
|
||||
${DirectX_D3D11_LIBRARY}
|
||||
${DirectX_D3DX11_LIBRARY}
|
||||
${DirectX_DXGI_LIBRARY}
|
||||
${DirectX_DXERR_LIBRARY}
|
||||
${DirectX_DXGUID_LIBRARY}
|
||||
${DirectX_D3DCOMPILER_LIBRARY}
|
||||
)
|
||||
endif ()
|
||||
mark_as_advanced(DirectX_D3D11_INCLUDE_DIR DirectX_D3D11_LIBRARY DirectX_D3DX11_LIBRARY)
|
||||
endif ()
|
||||
|
||||
endif(WIN32)
|
||||
146
Engine/lib/assimp/cmake-modules/FindPkgMacros.cmake
Normal file
146
Engine/lib/assimp/cmake-modules/FindPkgMacros.cmake
Normal file
|
|
@ -0,0 +1,146 @@
|
|||
#-------------------------------------------------------------------
|
||||
# This file is part of the CMake build system for OGRE
|
||||
# (Object-oriented Graphics Rendering Engine)
|
||||
# For the latest info, see http://www.ogre3d.org/
|
||||
#
|
||||
# The contents of this file are placed in the public domain. Feel
|
||||
# free to make use of it in any way you like.
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
##################################################################
|
||||
# Provides some common functionality for the FindPackage modules
|
||||
##################################################################
|
||||
|
||||
# Begin processing of package
|
||||
macro(findpkg_begin PREFIX)
|
||||
if (NOT ${PREFIX}_FIND_QUIETLY)
|
||||
message(STATUS "Looking for ${PREFIX}...")
|
||||
endif ()
|
||||
endmacro(findpkg_begin)
|
||||
|
||||
# Display a status message unless FIND_QUIETLY is set
|
||||
macro(pkg_message PREFIX)
|
||||
if (NOT ${PREFIX}_FIND_QUIETLY)
|
||||
message(STATUS ${ARGN})
|
||||
endif ()
|
||||
endmacro(pkg_message)
|
||||
|
||||
# Get environment variable, define it as ENV_$var and make sure backslashes are converted to forward slashes
|
||||
macro(getenv_path VAR)
|
||||
set(ENV_${VAR} $ENV{${VAR}})
|
||||
# replace won't work if var is blank
|
||||
if (ENV_${VAR})
|
||||
string( REGEX REPLACE "\\\\" "/" ENV_${VAR} ${ENV_${VAR}} )
|
||||
endif ()
|
||||
endmacro(getenv_path)
|
||||
|
||||
# Construct search paths for includes and libraries from a PREFIX_PATH
|
||||
macro(create_search_paths PREFIX)
|
||||
foreach(dir ${${PREFIX}_PREFIX_PATH})
|
||||
set(${PREFIX}_INC_SEARCH_PATH ${${PREFIX}_INC_SEARCH_PATH}
|
||||
${dir}/include ${dir}/include/${PREFIX} ${dir}/Headers)
|
||||
set(${PREFIX}_LIB_SEARCH_PATH ${${PREFIX}_LIB_SEARCH_PATH}
|
||||
${dir}/lib ${dir}/lib/${PREFIX} ${dir}/Libs)
|
||||
endforeach(dir)
|
||||
set(${PREFIX}_FRAMEWORK_SEARCH_PATH ${${PREFIX}_PREFIX_PATH})
|
||||
endmacro(create_search_paths)
|
||||
|
||||
# clear cache variables if a certain variable changed
|
||||
macro(clear_if_changed TESTVAR)
|
||||
# test against internal check variable
|
||||
if (NOT "${${TESTVAR}}" STREQUAL "${${TESTVAR}_INT_CHECK}")
|
||||
message(STATUS "${TESTVAR} changed.")
|
||||
foreach(var ${ARGN})
|
||||
set(${var} "NOTFOUND" CACHE STRING "x" FORCE)
|
||||
endforeach(var)
|
||||
endif ()
|
||||
set(${TESTVAR}_INT_CHECK "${${TESTVAR}}" CACHE INTERNAL "x" FORCE)
|
||||
endmacro(clear_if_changed)
|
||||
|
||||
# Try to get some hints from pkg-config, if available
|
||||
macro(use_pkgconfig PREFIX PKGNAME)
|
||||
# Android does not support PKG_CONFIG so we disable it
|
||||
IF ( NOT ANDROID )
|
||||
find_package(PkgConfig)
|
||||
if (PKG_CONFIG_FOUND)
|
||||
pkg_check_modules(${PREFIX} ${PKGNAME})
|
||||
endif ()
|
||||
ENDIF ( NOT ANDROID )
|
||||
endmacro (use_pkgconfig)
|
||||
|
||||
# Couple a set of release AND debug libraries (or frameworks)
|
||||
macro(make_library_set PREFIX)
|
||||
if (${PREFIX}_FWK)
|
||||
set(${PREFIX} ${${PREFIX}_FWK})
|
||||
elseif (${PREFIX}_REL AND ${PREFIX}_DBG)
|
||||
set(${PREFIX} optimized ${${PREFIX}_REL} debug ${${PREFIX}_DBG})
|
||||
elseif (${PREFIX}_REL)
|
||||
set(${PREFIX} ${${PREFIX}_REL})
|
||||
elseif (${PREFIX}_DBG)
|
||||
set(${PREFIX} ${${PREFIX}_DBG})
|
||||
endif ()
|
||||
endmacro(make_library_set)
|
||||
|
||||
# Generate debug names from given release names
|
||||
macro(get_debug_names PREFIX)
|
||||
foreach(i ${${PREFIX}})
|
||||
set(${PREFIX}_DBG ${${PREFIX}_DBG} ${i}d ${i}D ${i}_d ${i}_D ${i}_debug ${i})
|
||||
endforeach(i)
|
||||
endmacro(get_debug_names)
|
||||
|
||||
# Add the parent dir from DIR to VAR
|
||||
macro(add_parent_dir VAR DIR)
|
||||
get_filename_component(${DIR}_TEMP "${${DIR}}/.." ABSOLUTE)
|
||||
set(${VAR} ${${VAR}} ${${DIR}_TEMP})
|
||||
endmacro(add_parent_dir)
|
||||
|
||||
# Do the final processing for the package find.
|
||||
macro(findpkg_finish PREFIX)
|
||||
# skip if already processed during this run
|
||||
if (NOT ${PREFIX}_FOUND)
|
||||
if (${PREFIX}_INCLUDE_DIR AND ${PREFIX}_LIBRARY)
|
||||
set(${PREFIX}_FOUND TRUE)
|
||||
set(${PREFIX}_INCLUDE_DIRS ${${PREFIX}_INCLUDE_DIR})
|
||||
set(${PREFIX}_LIBRARIES ${${PREFIX}_LIBRARY})
|
||||
if (NOT ${PREFIX}_FIND_QUIETLY)
|
||||
message(STATUS "Found ${PREFIX}: ${${PREFIX}_LIBRARIES}")
|
||||
endif ()
|
||||
else ()
|
||||
if (NOT ${PREFIX}_FIND_QUIETLY)
|
||||
message(STATUS "Could not locate ${PREFIX}")
|
||||
endif ()
|
||||
if (${PREFIX}_FIND_REQUIRED)
|
||||
message(FATAL_ERROR "Required library ${PREFIX} not found! Install the library (including dev packages) and try again. If the library is already installed, set the missing variables manually in cmake.")
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
mark_as_advanced(${PREFIX}_INCLUDE_DIR ${PREFIX}_LIBRARY ${PREFIX}_LIBRARY_REL ${PREFIX}_LIBRARY_DBG ${PREFIX}_LIBRARY_FWK)
|
||||
endif ()
|
||||
endmacro(findpkg_finish)
|
||||
|
||||
|
||||
# Slightly customised framework finder
|
||||
MACRO(findpkg_framework fwk)
|
||||
IF(APPLE)
|
||||
SET(${fwk}_FRAMEWORK_PATH
|
||||
${${fwk}_FRAMEWORK_SEARCH_PATH}
|
||||
${CMAKE_FRAMEWORK_PATH}
|
||||
~/Library/Frameworks
|
||||
/Library/Frameworks
|
||||
/System/Library/Frameworks
|
||||
/Network/Library/Frameworks
|
||||
/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.0.sdk/System/Library/Frameworks/
|
||||
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.0.sdk/System/Library/Frameworks/
|
||||
)
|
||||
FOREACH(dir ${${fwk}_FRAMEWORK_PATH})
|
||||
SET(fwkpath ${dir}/${fwk}.framework)
|
||||
IF(EXISTS ${fwkpath})
|
||||
SET(${fwk}_FRAMEWORK_INCLUDES ${${fwk}_FRAMEWORK_INCLUDES}
|
||||
${fwkpath}/Headers ${fwkpath}/PrivateHeaders)
|
||||
if (NOT ${fwk}_LIBRARY_FWK)
|
||||
SET(${fwk}_LIBRARY_FWK "-framework ${fwk}")
|
||||
endif ()
|
||||
ENDIF(EXISTS ${fwkpath})
|
||||
ENDFOREACH(dir)
|
||||
ENDIF(APPLE)
|
||||
ENDMACRO(findpkg_framework)
|
||||
20
Engine/lib/assimp/cmake-modules/FindRT.cmake
Normal file
20
Engine/lib/assimp/cmake-modules/FindRT.cmake
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
# Try to find real time libraries
|
||||
# Once done, this will define
|
||||
#
|
||||
# RT_FOUND - system has rt library
|
||||
# RT_LIBRARIES - rt libraries directory
|
||||
#
|
||||
# Source: https://gitlab.cern.ch/dss/eos/commit/44070e575faaa46bd998708ef03eedb381506ff0
|
||||
#
|
||||
|
||||
if(RT_LIBRARIES)
|
||||
set(RT_FIND_QUIETLY TRUE)
|
||||
endif(RT_LIBRARIES)
|
||||
|
||||
find_library(RT_LIBRARY rt)
|
||||
set(RT_LIBRARIES ${RT_LIBRARY})
|
||||
# handle the QUIETLY and REQUIRED arguments and set
|
||||
# RT_FOUND to TRUE if all listed variables are TRUE
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(RT DEFAULT_MSG RT_LIBRARY)
|
||||
mark_as_advanced(RT_LIBRARY)
|
||||
48
Engine/lib/assimp/cmake-modules/FindZLIB.cmake
Normal file
48
Engine/lib/assimp/cmake-modules/FindZLIB.cmake
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
#-------------------------------------------------------------------
|
||||
# This file is part of the CMake build system for OGRE
|
||||
# (Object-oriented Graphics Rendering Engine)
|
||||
# For the latest info, see http://www.ogre3d.org/
|
||||
#
|
||||
# The contents of this file are placed in the public domain. Feel
|
||||
# free to make use of it in any way you like.
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
# - Try to find ZLIB
|
||||
# Once done, this will define
|
||||
#
|
||||
# ZLIB_FOUND - system has ZLIB
|
||||
# ZLIB_INCLUDE_DIRS - the ZLIB include directories
|
||||
# ZLIB_LIBRARIES - link these to use ZLIB
|
||||
|
||||
include(FindPkgMacros)
|
||||
findpkg_begin(ZLIB)
|
||||
|
||||
# Get path, convert backslashes as ${ENV_${var}}
|
||||
getenv_path(ZLIB_HOME)
|
||||
|
||||
# construct search paths
|
||||
set(ZLIB_PREFIX_PATH ${ZLIB_HOME} ${ENV_ZLIB_HOME})
|
||||
create_search_paths(ZLIB)
|
||||
# redo search if prefix path changed
|
||||
clear_if_changed(ZLIB_PREFIX_PATH
|
||||
ZLIB_LIBRARY_FWK
|
||||
ZLIB_LIBRARY_REL
|
||||
ZLIB_LIBRARY_DBG
|
||||
ZLIB_INCLUDE_DIR
|
||||
)
|
||||
|
||||
set(ZLIB_LIBRARY_NAMES z zlib zdll)
|
||||
get_debug_names(ZLIB_LIBRARY_NAMES)
|
||||
|
||||
use_pkgconfig(ZLIB_PKGC zzip-zlib-config)
|
||||
|
||||
findpkg_framework(ZLIB)
|
||||
|
||||
find_path(ZLIB_INCLUDE_DIR NAMES zlib.h HINTS ${ZLIB_INC_SEARCH_PATH} ${ZLIB_PKGC_INCLUDE_DIRS})
|
||||
find_library(ZLIB_LIBRARY_REL NAMES ${ZLIB_LIBRARY_NAMES} HINTS ${ZLIB_LIB_SEARCH_PATH} ${ZLIB_PKGC_LIBRARY_DIRS} PATH_SUFFIXES "" release relwithdebinfo minsizerel)
|
||||
find_library(ZLIB_LIBRARY_DBG NAMES ${ZLIB_LIBRARY_NAMES_DBG} HINTS ${ZLIB_LIB_SEARCH_PATH} ${ZLIB_PKGC_LIBRARY_DIRS} PATH_SUFFIXES "" debug)
|
||||
|
||||
make_library_set(ZLIB_LIBRARY)
|
||||
|
||||
findpkg_finish(ZLIB)
|
||||
|
||||
85
Engine/lib/assimp/cmake-modules/Findassimp.cmake
Normal file
85
Engine/lib/assimp/cmake-modules/Findassimp.cmake
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
set(ASSIMP_ARCHITECTURE "64")
|
||||
elseif(CMAKE_SIZEOF_VOID_P EQUAL 4)
|
||||
set(ASSIMP_ARCHITECTURE "32")
|
||||
endif(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
|
||||
if(WIN32)
|
||||
set(ASSIMP_ROOT_DIR CACHE PATH "ASSIMP root directory")
|
||||
|
||||
# Find path of each library
|
||||
find_path(ASSIMP_INCLUDE_DIR
|
||||
NAMES
|
||||
assimp/anim.h
|
||||
HINTS
|
||||
${ASSIMP_ROOT_DIR}/include
|
||||
)
|
||||
|
||||
if(MSVC12)
|
||||
set(ASSIMP_MSVC_VERSION "vc120")
|
||||
elseif(MSVC14)
|
||||
set(ASSIMP_MSVC_VERSION "vc140")
|
||||
endif(MSVC12)
|
||||
|
||||
if(MSVC12 OR MSVC14)
|
||||
|
||||
find_path(ASSIMP_LIBRARY_DIR
|
||||
NAMES
|
||||
assimp-${ASSIMP_MSVC_VERSION}-mt.lib
|
||||
HINTS
|
||||
${ASSIMP_ROOT_DIR}/lib${ASSIMP_ARCHITECTURE}
|
||||
)
|
||||
|
||||
find_library(ASSIMP_LIBRARY_RELEASE assimp-${ASSIMP_MSVC_VERSION}-mt.lib PATHS ${ASSIMP_LIBRARY_DIR})
|
||||
find_library(ASSIMP_LIBRARY_DEBUG assimp-${ASSIMP_MSVC_VERSION}-mtd.lib PATHS ${ASSIMP_LIBRARY_DIR})
|
||||
|
||||
set(ASSIMP_LIBRARY
|
||||
optimized ${ASSIMP_LIBRARY_RELEASE}
|
||||
debug ${ASSIMP_LIBRARY_DEBUG}
|
||||
)
|
||||
|
||||
set(ASSIMP_LIBRARIES "ASSIMP_LIBRARY_RELEASE" "ASSIMP_LIBRARY_DEBUG")
|
||||
|
||||
FUNCTION(ASSIMP_COPY_BINARIES TargetDirectory)
|
||||
ADD_CUSTOM_TARGET(AssimpCopyBinaries
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ${ASSIMP_ROOT_DIR}/bin${ASSIMP_ARCHITECTURE}/assimp-${ASSIMP_MSVC_VERSION}-mtd.dll ${TargetDirectory}/Debug/assimp-${ASSIMP_MSVC_VERSION}-mtd.dll
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ${ASSIMP_ROOT_DIR}/bin${ASSIMP_ARCHITECTURE}/assimp-${ASSIMP_MSVC_VERSION}-mt.dll ${TargetDirectory}/Release/assimp-${ASSIMP_MSVC_VERSION}-mt.dll
|
||||
COMMENT "Copying Assimp binaries to '${TargetDirectory}'"
|
||||
VERBATIM)
|
||||
ENDFUNCTION(ASSIMP_COPY_BINARIES)
|
||||
|
||||
endif()
|
||||
|
||||
else(WIN32)
|
||||
|
||||
find_path(
|
||||
assimp_INCLUDE_DIRS
|
||||
NAMES assimp/postprocess.h assimp/scene.h assimp/version.h assimp/config.h assimp/cimport.h
|
||||
PATHS /usr/local/include
|
||||
PATHS /usr/include/
|
||||
|
||||
)
|
||||
|
||||
find_library(
|
||||
assimp_LIBRARIES
|
||||
NAMES assimp
|
||||
PATHS /usr/local/lib/
|
||||
PATHS /usr/lib64/
|
||||
PATHS /usr/lib/
|
||||
)
|
||||
|
||||
if (assimp_INCLUDE_DIRS AND assimp_LIBRARIES)
|
||||
SET(assimp_FOUND TRUE)
|
||||
ENDIF (assimp_INCLUDE_DIRS AND assimp_LIBRARIES)
|
||||
|
||||
if (assimp_FOUND)
|
||||
if (NOT assimp_FIND_QUIETLY)
|
||||
message(STATUS "Found asset importer library: ${assimp_LIBRARIES}")
|
||||
endif (NOT assimp_FIND_QUIETLY)
|
||||
else (assimp_FOUND)
|
||||
if (assimp_FIND_REQUIRED)
|
||||
message(FATAL_ERROR "Could not find asset importer library")
|
||||
endif (assimp_FIND_REQUIRED)
|
||||
endif (assimp_FOUND)
|
||||
|
||||
endif(WIN32)
|
||||
539
Engine/lib/assimp/cmake-modules/HunterGate.cmake
Normal file
539
Engine/lib/assimp/cmake-modules/HunterGate.cmake
Normal file
|
|
@ -0,0 +1,539 @@
|
|||
# Copyright (c) 2013-2019, Ruslan Baratov
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright notice, this
|
||||
# list of conditions and the following disclaimer.
|
||||
#
|
||||
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions and the following disclaimer in the documentation
|
||||
# and/or other materials provided with the distribution.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
# This is a gate file to Hunter package manager.
|
||||
# Include this file using `include` command and add package you need, example:
|
||||
#
|
||||
# cmake_minimum_required(VERSION 3.2)
|
||||
#
|
||||
# include("cmake/HunterGate.cmake")
|
||||
# HunterGate(
|
||||
# URL "https://github.com/path/to/hunter/archive.tar.gz"
|
||||
# SHA1 "798501e983f14b28b10cda16afa4de69eee1da1d"
|
||||
# )
|
||||
#
|
||||
# project(MyProject)
|
||||
#
|
||||
# hunter_add_package(Foo)
|
||||
# hunter_add_package(Boo COMPONENTS Bar Baz)
|
||||
#
|
||||
# Projects:
|
||||
# * https://github.com/hunter-packages/gate/
|
||||
# * https://github.com/ruslo/hunter
|
||||
|
||||
option(HUNTER_ENABLED "Enable Hunter package manager support" ON)
|
||||
|
||||
if(HUNTER_ENABLED)
|
||||
if(CMAKE_VERSION VERSION_LESS "3.2")
|
||||
message(
|
||||
FATAL_ERROR
|
||||
"At least CMake version 3.2 required for Hunter dependency management."
|
||||
" Update CMake or set HUNTER_ENABLED to OFF."
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
include(CMakeParseArguments) # cmake_parse_arguments
|
||||
|
||||
option(HUNTER_STATUS_PRINT "Print working status" ON)
|
||||
option(HUNTER_STATUS_DEBUG "Print a lot info" OFF)
|
||||
option(HUNTER_TLS_VERIFY "Enable/disable TLS certificate checking on downloads" ON)
|
||||
|
||||
set(HUNTER_ERROR_PAGE "https://docs.hunter.sh/en/latest/reference/errors")
|
||||
|
||||
function(hunter_gate_status_print)
|
||||
if(HUNTER_STATUS_PRINT OR HUNTER_STATUS_DEBUG)
|
||||
foreach(print_message ${ARGV})
|
||||
message(STATUS "[hunter] ${print_message}")
|
||||
endforeach()
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
function(hunter_gate_status_debug)
|
||||
if(HUNTER_STATUS_DEBUG)
|
||||
foreach(print_message ${ARGV})
|
||||
string(TIMESTAMP timestamp)
|
||||
message(STATUS "[hunter *** DEBUG *** ${timestamp}] ${print_message}")
|
||||
endforeach()
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
function(hunter_gate_error_page error_page)
|
||||
message("------------------------------ ERROR ------------------------------")
|
||||
message(" ${HUNTER_ERROR_PAGE}/${error_page}.html")
|
||||
message("-------------------------------------------------------------------")
|
||||
message("")
|
||||
message(FATAL_ERROR "")
|
||||
endfunction()
|
||||
|
||||
function(hunter_gate_internal_error)
|
||||
message("")
|
||||
foreach(print_message ${ARGV})
|
||||
message("[hunter ** INTERNAL **] ${print_message}")
|
||||
endforeach()
|
||||
message("[hunter ** INTERNAL **] [Directory:${CMAKE_CURRENT_LIST_DIR}]")
|
||||
message("")
|
||||
hunter_gate_error_page("error.internal")
|
||||
endfunction()
|
||||
|
||||
function(hunter_gate_fatal_error)
|
||||
cmake_parse_arguments(hunter "" "ERROR_PAGE" "" "${ARGV}")
|
||||
if("${hunter_ERROR_PAGE}" STREQUAL "")
|
||||
hunter_gate_internal_error("Expected ERROR_PAGE")
|
||||
endif()
|
||||
message("")
|
||||
foreach(x ${hunter_UNPARSED_ARGUMENTS})
|
||||
message("[hunter ** FATAL ERROR **] ${x}")
|
||||
endforeach()
|
||||
message("[hunter ** FATAL ERROR **] [Directory:${CMAKE_CURRENT_LIST_DIR}]")
|
||||
message("")
|
||||
hunter_gate_error_page("${hunter_ERROR_PAGE}")
|
||||
endfunction()
|
||||
|
||||
function(hunter_gate_user_error)
|
||||
hunter_gate_fatal_error(${ARGV} ERROR_PAGE "error.incorrect.input.data")
|
||||
endfunction()
|
||||
|
||||
function(hunter_gate_self root version sha1 result)
|
||||
string(COMPARE EQUAL "${root}" "" is_bad)
|
||||
if(is_bad)
|
||||
hunter_gate_internal_error("root is empty")
|
||||
endif()
|
||||
|
||||
string(COMPARE EQUAL "${version}" "" is_bad)
|
||||
if(is_bad)
|
||||
hunter_gate_internal_error("version is empty")
|
||||
endif()
|
||||
|
||||
string(COMPARE EQUAL "${sha1}" "" is_bad)
|
||||
if(is_bad)
|
||||
hunter_gate_internal_error("sha1 is empty")
|
||||
endif()
|
||||
|
||||
string(SUBSTRING "${sha1}" 0 7 archive_id)
|
||||
|
||||
if(EXISTS "${root}/cmake/Hunter")
|
||||
set(hunter_self "${root}")
|
||||
else()
|
||||
set(
|
||||
hunter_self
|
||||
"${root}/_Base/Download/Hunter/${version}/${archive_id}/Unpacked"
|
||||
)
|
||||
endif()
|
||||
|
||||
set("${result}" "${hunter_self}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
# Set HUNTER_GATE_ROOT cmake variable to suitable value.
|
||||
function(hunter_gate_detect_root)
|
||||
# Check CMake variable
|
||||
string(COMPARE NOTEQUAL "${HUNTER_ROOT}" "" not_empty)
|
||||
if(not_empty)
|
||||
set(HUNTER_GATE_ROOT "${HUNTER_ROOT}" PARENT_SCOPE)
|
||||
hunter_gate_status_debug("HUNTER_ROOT detected by cmake variable")
|
||||
return()
|
||||
endif()
|
||||
|
||||
# Check environment variable
|
||||
string(COMPARE NOTEQUAL "$ENV{HUNTER_ROOT}" "" not_empty)
|
||||
if(not_empty)
|
||||
set(HUNTER_GATE_ROOT "$ENV{HUNTER_ROOT}" PARENT_SCOPE)
|
||||
hunter_gate_status_debug("HUNTER_ROOT detected by environment variable")
|
||||
return()
|
||||
endif()
|
||||
|
||||
# Check HOME environment variable
|
||||
string(COMPARE NOTEQUAL "$ENV{HOME}" "" result)
|
||||
if(result)
|
||||
set(HUNTER_GATE_ROOT "$ENV{HOME}/.hunter" PARENT_SCOPE)
|
||||
hunter_gate_status_debug("HUNTER_ROOT set using HOME environment variable")
|
||||
return()
|
||||
endif()
|
||||
|
||||
# Check SYSTEMDRIVE and USERPROFILE environment variable (windows only)
|
||||
if(WIN32)
|
||||
string(COMPARE NOTEQUAL "$ENV{SYSTEMDRIVE}" "" result)
|
||||
if(result)
|
||||
set(HUNTER_GATE_ROOT "$ENV{SYSTEMDRIVE}/.hunter" PARENT_SCOPE)
|
||||
hunter_gate_status_debug(
|
||||
"HUNTER_ROOT set using SYSTEMDRIVE environment variable"
|
||||
)
|
||||
return()
|
||||
endif()
|
||||
|
||||
string(COMPARE NOTEQUAL "$ENV{USERPROFILE}" "" result)
|
||||
if(result)
|
||||
set(HUNTER_GATE_ROOT "$ENV{USERPROFILE}/.hunter" PARENT_SCOPE)
|
||||
hunter_gate_status_debug(
|
||||
"HUNTER_ROOT set using USERPROFILE environment variable"
|
||||
)
|
||||
return()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
hunter_gate_fatal_error(
|
||||
"Can't detect HUNTER_ROOT"
|
||||
ERROR_PAGE "error.detect.hunter.root"
|
||||
)
|
||||
endfunction()
|
||||
|
||||
function(hunter_gate_download dir)
|
||||
string(
|
||||
COMPARE
|
||||
NOTEQUAL
|
||||
"$ENV{HUNTER_DISABLE_AUTOINSTALL}"
|
||||
""
|
||||
disable_autoinstall
|
||||
)
|
||||
if(disable_autoinstall AND NOT HUNTER_RUN_INSTALL)
|
||||
hunter_gate_fatal_error(
|
||||
"Hunter not found in '${dir}'"
|
||||
"Set HUNTER_RUN_INSTALL=ON to auto-install it from '${HUNTER_GATE_URL}'"
|
||||
"Settings:"
|
||||
" HUNTER_ROOT: ${HUNTER_GATE_ROOT}"
|
||||
" HUNTER_SHA1: ${HUNTER_GATE_SHA1}"
|
||||
ERROR_PAGE "error.run.install"
|
||||
)
|
||||
endif()
|
||||
string(COMPARE EQUAL "${dir}" "" is_bad)
|
||||
if(is_bad)
|
||||
hunter_gate_internal_error("Empty 'dir' argument")
|
||||
endif()
|
||||
|
||||
string(COMPARE EQUAL "${HUNTER_GATE_SHA1}" "" is_bad)
|
||||
if(is_bad)
|
||||
hunter_gate_internal_error("HUNTER_GATE_SHA1 empty")
|
||||
endif()
|
||||
|
||||
string(COMPARE EQUAL "${HUNTER_GATE_URL}" "" is_bad)
|
||||
if(is_bad)
|
||||
hunter_gate_internal_error("HUNTER_GATE_URL empty")
|
||||
endif()
|
||||
|
||||
set(done_location "${dir}/DONE")
|
||||
set(sha1_location "${dir}/SHA1")
|
||||
|
||||
set(build_dir "${dir}/Build")
|
||||
set(cmakelists "${dir}/CMakeLists.txt")
|
||||
|
||||
hunter_gate_status_debug("Locking directory: ${dir}")
|
||||
file(LOCK "${dir}" DIRECTORY GUARD FUNCTION)
|
||||
hunter_gate_status_debug("Lock done")
|
||||
|
||||
if(EXISTS "${done_location}")
|
||||
# while waiting for lock other instance can do all the job
|
||||
hunter_gate_status_debug("File '${done_location}' found, skip install")
|
||||
return()
|
||||
endif()
|
||||
|
||||
file(REMOVE_RECURSE "${build_dir}")
|
||||
file(REMOVE_RECURSE "${cmakelists}")
|
||||
|
||||
file(MAKE_DIRECTORY "${build_dir}") # check directory permissions
|
||||
|
||||
# Disabling languages speeds up a little bit, reduces noise in the output
|
||||
# and avoids path too long windows error
|
||||
file(
|
||||
WRITE
|
||||
"${cmakelists}"
|
||||
"cmake_minimum_required(VERSION 3.2)\n"
|
||||
"project(HunterDownload LANGUAGES NONE)\n"
|
||||
"include(ExternalProject)\n"
|
||||
"ExternalProject_Add(\n"
|
||||
" Hunter\n"
|
||||
" URL\n"
|
||||
" \"${HUNTER_GATE_URL}\"\n"
|
||||
" URL_HASH\n"
|
||||
" SHA1=${HUNTER_GATE_SHA1}\n"
|
||||
" DOWNLOAD_DIR\n"
|
||||
" \"${dir}\"\n"
|
||||
" TLS_VERIFY\n"
|
||||
" ${HUNTER_TLS_VERIFY}\n"
|
||||
" SOURCE_DIR\n"
|
||||
" \"${dir}/Unpacked\"\n"
|
||||
" CONFIGURE_COMMAND\n"
|
||||
" \"\"\n"
|
||||
" BUILD_COMMAND\n"
|
||||
" \"\"\n"
|
||||
" INSTALL_COMMAND\n"
|
||||
" \"\"\n"
|
||||
")\n"
|
||||
)
|
||||
|
||||
if(HUNTER_STATUS_DEBUG)
|
||||
set(logging_params "")
|
||||
else()
|
||||
set(logging_params OUTPUT_QUIET)
|
||||
endif()
|
||||
|
||||
hunter_gate_status_debug("Run generate")
|
||||
|
||||
# Need to add toolchain file too.
|
||||
# Otherwise on Visual Studio + MDD this will fail with error:
|
||||
# "Could not find an appropriate version of the Windows 10 SDK installed on this machine"
|
||||
if(EXISTS "${CMAKE_TOOLCHAIN_FILE}")
|
||||
get_filename_component(absolute_CMAKE_TOOLCHAIN_FILE "${CMAKE_TOOLCHAIN_FILE}" ABSOLUTE)
|
||||
set(toolchain_arg "-DCMAKE_TOOLCHAIN_FILE=${absolute_CMAKE_TOOLCHAIN_FILE}")
|
||||
else()
|
||||
# 'toolchain_arg' can't be empty
|
||||
set(toolchain_arg "-DCMAKE_TOOLCHAIN_FILE=")
|
||||
endif()
|
||||
|
||||
string(COMPARE EQUAL "${CMAKE_MAKE_PROGRAM}" "" no_make)
|
||||
if(no_make)
|
||||
set(make_arg "")
|
||||
else()
|
||||
# Test case: remove Ninja from PATH but set it via CMAKE_MAKE_PROGRAM
|
||||
set(make_arg "-DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}")
|
||||
endif()
|
||||
|
||||
execute_process(
|
||||
COMMAND
|
||||
"${CMAKE_COMMAND}"
|
||||
"-H${dir}"
|
||||
"-B${build_dir}"
|
||||
"-G${CMAKE_GENERATOR}"
|
||||
"${toolchain_arg}"
|
||||
${make_arg}
|
||||
WORKING_DIRECTORY "${dir}"
|
||||
RESULT_VARIABLE download_result
|
||||
${logging_params}
|
||||
)
|
||||
|
||||
if(NOT download_result EQUAL 0)
|
||||
hunter_gate_internal_error(
|
||||
"Configure project failed."
|
||||
"To reproduce the error run: ${CMAKE_COMMAND} -H${dir} -B${build_dir} -G${CMAKE_GENERATOR} ${toolchain_arg} ${make_arg}"
|
||||
"In directory ${dir}"
|
||||
)
|
||||
endif()
|
||||
|
||||
hunter_gate_status_print(
|
||||
"Initializing Hunter workspace (${HUNTER_GATE_SHA1})"
|
||||
" ${HUNTER_GATE_URL}"
|
||||
" -> ${dir}"
|
||||
)
|
||||
execute_process(
|
||||
COMMAND "${CMAKE_COMMAND}" --build "${build_dir}"
|
||||
WORKING_DIRECTORY "${dir}"
|
||||
RESULT_VARIABLE download_result
|
||||
${logging_params}
|
||||
)
|
||||
|
||||
if(NOT download_result EQUAL 0)
|
||||
hunter_gate_internal_error("Build project failed")
|
||||
endif()
|
||||
|
||||
file(REMOVE_RECURSE "${build_dir}")
|
||||
file(REMOVE_RECURSE "${cmakelists}")
|
||||
|
||||
file(WRITE "${sha1_location}" "${HUNTER_GATE_SHA1}")
|
||||
file(WRITE "${done_location}" "DONE")
|
||||
|
||||
hunter_gate_status_debug("Finished")
|
||||
endfunction()
|
||||
|
||||
# Must be a macro so master file 'cmake/Hunter' can
|
||||
# apply all variables easily just by 'include' command
|
||||
# (otherwise PARENT_SCOPE magic needed)
|
||||
macro(HunterGate)
|
||||
if(HUNTER_GATE_DONE)
|
||||
# variable HUNTER_GATE_DONE set explicitly for external project
|
||||
# (see `hunter_download`)
|
||||
set_property(GLOBAL PROPERTY HUNTER_GATE_DONE YES)
|
||||
endif()
|
||||
|
||||
# First HunterGate command will init Hunter, others will be ignored
|
||||
get_property(_hunter_gate_done GLOBAL PROPERTY HUNTER_GATE_DONE SET)
|
||||
|
||||
if(NOT HUNTER_ENABLED)
|
||||
# Empty function to avoid error "unknown function"
|
||||
function(hunter_add_package)
|
||||
endfunction()
|
||||
|
||||
set(
|
||||
_hunter_gate_disabled_mode_dir
|
||||
"${CMAKE_CURRENT_LIST_DIR}/cmake/Hunter/disabled-mode"
|
||||
)
|
||||
if(EXISTS "${_hunter_gate_disabled_mode_dir}")
|
||||
hunter_gate_status_debug(
|
||||
"Adding \"disabled-mode\" modules: ${_hunter_gate_disabled_mode_dir}"
|
||||
)
|
||||
list(APPEND CMAKE_PREFIX_PATH "${_hunter_gate_disabled_mode_dir}")
|
||||
endif()
|
||||
elseif(_hunter_gate_done)
|
||||
hunter_gate_status_debug("Secondary HunterGate (use old settings)")
|
||||
hunter_gate_self(
|
||||
"${HUNTER_CACHED_ROOT}"
|
||||
"${HUNTER_VERSION}"
|
||||
"${HUNTER_SHA1}"
|
||||
_hunter_self
|
||||
)
|
||||
include("${_hunter_self}/cmake/Hunter")
|
||||
else()
|
||||
set(HUNTER_GATE_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
|
||||
string(COMPARE NOTEQUAL "${PROJECT_NAME}" "" _have_project_name)
|
||||
if(_have_project_name)
|
||||
hunter_gate_fatal_error(
|
||||
"Please set HunterGate *before* 'project' command. "
|
||||
"Detected project: ${PROJECT_NAME}"
|
||||
ERROR_PAGE "error.huntergate.before.project"
|
||||
)
|
||||
endif()
|
||||
|
||||
cmake_parse_arguments(
|
||||
HUNTER_GATE "LOCAL" "URL;SHA1;GLOBAL;FILEPATH" "" ${ARGV}
|
||||
)
|
||||
|
||||
string(COMPARE EQUAL "${HUNTER_GATE_SHA1}" "" _empty_sha1)
|
||||
string(COMPARE EQUAL "${HUNTER_GATE_URL}" "" _empty_url)
|
||||
string(
|
||||
COMPARE
|
||||
NOTEQUAL
|
||||
"${HUNTER_GATE_UNPARSED_ARGUMENTS}"
|
||||
""
|
||||
_have_unparsed
|
||||
)
|
||||
string(COMPARE NOTEQUAL "${HUNTER_GATE_GLOBAL}" "" _have_global)
|
||||
string(COMPARE NOTEQUAL "${HUNTER_GATE_FILEPATH}" "" _have_filepath)
|
||||
|
||||
if(_have_unparsed)
|
||||
hunter_gate_user_error(
|
||||
"HunterGate unparsed arguments: ${HUNTER_GATE_UNPARSED_ARGUMENTS}"
|
||||
)
|
||||
endif()
|
||||
if(_empty_sha1)
|
||||
hunter_gate_user_error("SHA1 suboption of HunterGate is mandatory")
|
||||
endif()
|
||||
if(_empty_url)
|
||||
hunter_gate_user_error("URL suboption of HunterGate is mandatory")
|
||||
endif()
|
||||
if(_have_global)
|
||||
if(HUNTER_GATE_LOCAL)
|
||||
hunter_gate_user_error("Unexpected LOCAL (already has GLOBAL)")
|
||||
endif()
|
||||
if(_have_filepath)
|
||||
hunter_gate_user_error("Unexpected FILEPATH (already has GLOBAL)")
|
||||
endif()
|
||||
endif()
|
||||
if(HUNTER_GATE_LOCAL)
|
||||
if(_have_global)
|
||||
hunter_gate_user_error("Unexpected GLOBAL (already has LOCAL)")
|
||||
endif()
|
||||
if(_have_filepath)
|
||||
hunter_gate_user_error("Unexpected FILEPATH (already has LOCAL)")
|
||||
endif()
|
||||
endif()
|
||||
if(_have_filepath)
|
||||
if(_have_global)
|
||||
hunter_gate_user_error("Unexpected GLOBAL (already has FILEPATH)")
|
||||
endif()
|
||||
if(HUNTER_GATE_LOCAL)
|
||||
hunter_gate_user_error("Unexpected LOCAL (already has FILEPATH)")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
hunter_gate_detect_root() # set HUNTER_GATE_ROOT
|
||||
|
||||
# Beautify path, fix probable problems with windows path slashes
|
||||
get_filename_component(
|
||||
HUNTER_GATE_ROOT "${HUNTER_GATE_ROOT}" ABSOLUTE
|
||||
)
|
||||
hunter_gate_status_debug("HUNTER_ROOT: ${HUNTER_GATE_ROOT}")
|
||||
if(NOT HUNTER_ALLOW_SPACES_IN_PATH)
|
||||
string(FIND "${HUNTER_GATE_ROOT}" " " _contain_spaces)
|
||||
if(NOT _contain_spaces EQUAL -1)
|
||||
hunter_gate_fatal_error(
|
||||
"HUNTER_ROOT (${HUNTER_GATE_ROOT}) contains spaces."
|
||||
"Set HUNTER_ALLOW_SPACES_IN_PATH=ON to skip this error"
|
||||
"(Use at your own risk!)"
|
||||
ERROR_PAGE "error.spaces.in.hunter.root"
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
string(
|
||||
REGEX
|
||||
MATCH
|
||||
"[0-9]+\\.[0-9]+\\.[0-9]+[-_a-z0-9]*"
|
||||
HUNTER_GATE_VERSION
|
||||
"${HUNTER_GATE_URL}"
|
||||
)
|
||||
string(COMPARE EQUAL "${HUNTER_GATE_VERSION}" "" _is_empty)
|
||||
if(_is_empty)
|
||||
set(HUNTER_GATE_VERSION "unknown")
|
||||
endif()
|
||||
|
||||
hunter_gate_self(
|
||||
"${HUNTER_GATE_ROOT}"
|
||||
"${HUNTER_GATE_VERSION}"
|
||||
"${HUNTER_GATE_SHA1}"
|
||||
_hunter_self
|
||||
)
|
||||
|
||||
set(_master_location "${_hunter_self}/cmake/Hunter")
|
||||
if(EXISTS "${HUNTER_GATE_ROOT}/cmake/Hunter")
|
||||
# Hunter downloaded manually (e.g. by 'git clone')
|
||||
set(_unused "xxxxxxxxxx")
|
||||
set(HUNTER_GATE_SHA1 "${_unused}")
|
||||
set(HUNTER_GATE_VERSION "${_unused}")
|
||||
else()
|
||||
get_filename_component(_archive_id_location "${_hunter_self}/.." ABSOLUTE)
|
||||
set(_done_location "${_archive_id_location}/DONE")
|
||||
set(_sha1_location "${_archive_id_location}/SHA1")
|
||||
|
||||
# Check Hunter already downloaded by HunterGate
|
||||
if(NOT EXISTS "${_done_location}")
|
||||
hunter_gate_download("${_archive_id_location}")
|
||||
endif()
|
||||
|
||||
if(NOT EXISTS "${_done_location}")
|
||||
hunter_gate_internal_error("hunter_gate_download failed")
|
||||
endif()
|
||||
|
||||
if(NOT EXISTS "${_sha1_location}")
|
||||
hunter_gate_internal_error("${_sha1_location} not found")
|
||||
endif()
|
||||
file(READ "${_sha1_location}" _sha1_value)
|
||||
string(COMPARE EQUAL "${_sha1_value}" "${HUNTER_GATE_SHA1}" _is_equal)
|
||||
if(NOT _is_equal)
|
||||
hunter_gate_internal_error(
|
||||
"Short SHA1 collision:"
|
||||
" ${_sha1_value} (from ${_sha1_location})"
|
||||
" ${HUNTER_GATE_SHA1} (HunterGate)"
|
||||
)
|
||||
endif()
|
||||
if(NOT EXISTS "${_master_location}")
|
||||
hunter_gate_user_error(
|
||||
"Master file not found:"
|
||||
" ${_master_location}"
|
||||
"try to update Hunter/HunterGate"
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
include("${_master_location}")
|
||||
set_property(GLOBAL PROPERTY HUNTER_GATE_DONE YES)
|
||||
endif()
|
||||
endmacro()
|
||||
16
Engine/lib/assimp/cmake-modules/MinGW_x86_64.cmake
Normal file
16
Engine/lib/assimp/cmake-modules/MinGW_x86_64.cmake
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
# this one sets internal to crosscompile (in theory)
|
||||
SET(CMAKE_SYSTEM_NAME Windows)
|
||||
|
||||
# the minimalistic settings
|
||||
SET(CMAKE_C_COMPILER "/usr/bin/x86_64-w64-mingw32-gcc")
|
||||
SET(CMAKE_CXX_COMPILER "/usr/bin/x86_64-w64-mingw32-g++")
|
||||
SET(CMAKE_RC_COMPILER "/usr/bin/x86_64-w64-mingw32-windres")
|
||||
|
||||
# where is the target (so called staging) environment
|
||||
SET(CMAKE_FIND_ROOT_PATH /usr/x86_64-w64-mingw32)
|
||||
|
||||
# search for programs in the build host directories (default BOTH)
|
||||
#SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
||||
# for libraries and headers in the target directories
|
||||
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||
25
Engine/lib/assimp/cmake-modules/PrecompiledHeader.cmake
Normal file
25
Engine/lib/assimp/cmake-modules/PrecompiledHeader.cmake
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
MACRO(ADD_MSVC_PRECOMPILED_HEADER PrecompiledHeader PrecompiledSource SourcesVar)
|
||||
IF(MSVC)
|
||||
GET_FILENAME_COMPONENT(PrecompiledBasename ${PrecompiledHeader} NAME_WE)
|
||||
SET(PrecompiledBinary "${CMAKE_CFG_INTDIR}/${PrecompiledBasename}.pch")
|
||||
SET(Sources ${${SourcesVar}})
|
||||
|
||||
SET_SOURCE_FILES_PROPERTIES(${PrecompiledSource}
|
||||
PROPERTIES COMPILE_FLAGS "/Yc\"${PrecompiledHeader}\" /Fp\"${PrecompiledBinary}\""
|
||||
OBJECT_OUTPUTS "${PrecompiledBinary}")
|
||||
|
||||
# Do not consider .c files
|
||||
foreach(fname ${Sources})
|
||||
GET_FILENAME_COMPONENT(fext ${fname} EXT)
|
||||
if(fext STREQUAL ".cpp")
|
||||
SET_SOURCE_FILES_PROPERTIES(${fname}
|
||||
PROPERTIES COMPILE_FLAGS "/Yu\"${PrecompiledBinary}\" /FI\"${PrecompiledBinary}\" /Fp\"${PrecompiledBinary}\""
|
||||
OBJECT_DEPENDS "${PrecompiledBinary}")
|
||||
endif(fext STREQUAL ".cpp")
|
||||
endforeach(fname)
|
||||
|
||||
ENDIF(MSVC)
|
||||
# Add precompiled header to SourcesVar
|
||||
LIST(APPEND ${SourcesVar} ${PrecompiledSource})
|
||||
|
||||
ENDMACRO(ADD_MSVC_PRECOMPILED_HEADER)
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
@PACKAGE_INIT@
|
||||
|
||||
find_package(RapidJSON CONFIG REQUIRED)
|
||||
find_package(ZLIB CONFIG REQUIRED)
|
||||
find_package(utf8cpp CONFIG REQUIRED)
|
||||
find_package(minizip CONFIG REQUIRED)
|
||||
find_package(openddlparser CONFIG REQUIRED)
|
||||
find_package(poly2tri CONFIG REQUIRED)
|
||||
find_package(polyclipping CONFIG REQUIRED)
|
||||
find_package(zip CONFIG REQUIRED)
|
||||
find_package(pugixml CONFIG REQUIRED)
|
||||
find_package(stb CONFIG REQUIRED)
|
||||
|
||||
if(@ASSIMP_BUILD_DRACO@)
|
||||
find_package(draco CONFIG REQUIRED)
|
||||
endif()
|
||||
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/@TARGETS_EXPORT_NAME@.cmake")
|
||||
check_required_components("@PROJECT_NAME@")
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
@PACKAGE_INIT@
|
||||
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/@TARGETS_EXPORT_NAME@.cmake")
|
||||
|
||||
set(ASSIMP_ROOT_DIR ${PACKAGE_PREFIX_DIR})
|
||||
set(ASSIMP_LIBRARIES assimp::assimp)
|
||||
set(ASSIMP_BUILD_SHARED_LIBS @BUILD_SHARED_LIBS@)
|
||||
get_property(ASSIMP_INCLUDE_DIRS TARGET assimp::assimp PROPERTY INTERFACE_INCLUDE_DIRECTORIES)
|
||||
set(ASSIMP_LIBRARY_DIRS "")
|
||||
17
Engine/lib/assimp/cmake-modules/cmake_uninstall.cmake.in
Normal file
17
Engine/lib/assimp/cmake-modules/cmake_uninstall.cmake.in
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
IF(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
|
||||
MESSAGE(FATAL_ERROR "Cannot find install manifest: \"@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt\"")
|
||||
ENDIF(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
|
||||
|
||||
FILE(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files)
|
||||
STRING(REGEX REPLACE "\n" ";" files "${files}")
|
||||
FOREACH(file ${files})
|
||||
MESSAGE(STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"")
|
||||
EXEC_PROGRAM(
|
||||
"@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\""
|
||||
OUTPUT_VARIABLE rm_out
|
||||
RETURN_VALUE rm_retval
|
||||
)
|
||||
IF(NOT "${rm_retval}" STREQUAL 0)
|
||||
MESSAGE(FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${file}\"")
|
||||
ENDIF(NOT "${rm_retval}" STREQUAL 0)
|
||||
ENDFOREACH(file)
|
||||
|
|
@ -305,16 +305,19 @@ void FBXConverter::ConvertNodes(uint64_t id, aiNode *parent, aiNode *root_node)
|
|||
}
|
||||
}
|
||||
|
||||
if (nodes.empty()) {
|
||||
if (nodes.size()) {
|
||||
parent->mChildren = new aiNode *[nodes.size()]();
|
||||
parent->mNumChildren = static_cast<unsigned int>(nodes.size());
|
||||
|
||||
for (unsigned int i = 0; i < nodes.size(); ++i)
|
||||
{
|
||||
parent->mChildren[i] = nodes[i].mOwnership.release();
|
||||
}
|
||||
nodes.clear();
|
||||
} else {
|
||||
parent->mNumChildren = 0;
|
||||
parent->mChildren = nullptr;
|
||||
}
|
||||
|
||||
parent->mChildren = new aiNode *[nodes.size()]();
|
||||
parent->mNumChildren = static_cast<unsigned int>(nodes.size());
|
||||
for (unsigned int i = 0; i < nodes.size(); ++i) {
|
||||
parent->mChildren[i] = nodes[i].mOwnership.release();
|
||||
}
|
||||
}
|
||||
|
||||
void FBXConverter::ConvertLights(const Model &model, const std::string &orig_name) {
|
||||
|
|
|
|||
|
|
@ -415,11 +415,9 @@ void ResolveVertexDataArray(std::vector<T>& data_out, const Scope& source,
|
|||
{
|
||||
bool isDirect = ReferenceInformationType == "Direct";
|
||||
bool isIndexToDirect = ReferenceInformationType == "IndexToDirect";
|
||||
const bool hasDataElement = HasElement(source, dataElementName);
|
||||
const bool hasIndexDataElement = HasElement(source, indexDataElementName);
|
||||
|
||||
// fall-back to direct data if there is no index data element
|
||||
if (isIndexToDirect && !hasIndexDataElement) {
|
||||
if ( isIndexToDirect && !HasElement( source, indexDataElementName ) ) {
|
||||
isDirect = true;
|
||||
isIndexToDirect = false;
|
||||
}
|
||||
|
|
@ -428,8 +426,7 @@ void ResolveVertexDataArray(std::vector<T>& data_out, const Scope& source,
|
|||
// deal with this more elegantly and with less redundancy, but right
|
||||
// now it seems unavoidable.
|
||||
if (MappingInformationType == "ByVertice" && isDirect) {
|
||||
if (!hasDataElement) {
|
||||
FBXImporter::LogWarn("missing data element: ", dataElementName);
|
||||
if (!HasElement(source, dataElementName)) {
|
||||
return;
|
||||
}
|
||||
std::vector<T> tempData;
|
||||
|
|
@ -451,15 +448,7 @@ void ResolveVertexDataArray(std::vector<T>& data_out, const Scope& source,
|
|||
}
|
||||
else if (MappingInformationType == "ByVertice" && isIndexToDirect) {
|
||||
std::vector<T> tempData;
|
||||
if (!hasDataElement || !hasIndexDataElement) {
|
||||
if (!hasDataElement)
|
||||
FBXImporter::LogWarn("missing data element: ", dataElementName);
|
||||
if (!hasIndexDataElement)
|
||||
FBXImporter::LogWarn("missing index data element: ", indexDataElementName);
|
||||
return;
|
||||
}
|
||||
|
||||
ParseVectorDataArray(tempData, GetRequiredElement(source, dataElementName));
|
||||
ParseVectorDataArray(tempData, GetRequiredElement(source, dataElementName));
|
||||
|
||||
std::vector<int> uvIndices;
|
||||
ParseVectorDataArray(uvIndices,GetRequiredElement(source,indexDataElementName));
|
||||
|
|
@ -484,11 +473,6 @@ void ResolveVertexDataArray(std::vector<T>& data_out, const Scope& source,
|
|||
}
|
||||
}
|
||||
else if (MappingInformationType == "ByPolygonVertex" && isDirect) {
|
||||
if (!hasDataElement) {
|
||||
FBXImporter::LogWarn("missing data element: ", dataElementName);
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector<T> tempData;
|
||||
ParseVectorDataArray(tempData, GetRequiredElement(source, dataElementName));
|
||||
|
||||
|
|
@ -503,14 +487,7 @@ void ResolveVertexDataArray(std::vector<T>& data_out, const Scope& source,
|
|||
}
|
||||
else if (MappingInformationType == "ByPolygonVertex" && isIndexToDirect) {
|
||||
std::vector<T> tempData;
|
||||
if (!hasDataElement || !hasIndexDataElement) {
|
||||
if (!hasDataElement)
|
||||
FBXImporter::LogWarn("missing data element: ", dataElementName);
|
||||
if (!hasIndexDataElement)
|
||||
FBXImporter::LogWarn("missing index data element: ", indexDataElementName);
|
||||
return;
|
||||
}
|
||||
ParseVectorDataArray(tempData, GetRequiredElement(source, dataElementName));
|
||||
ParseVectorDataArray(tempData, GetRequiredElement(source, dataElementName));
|
||||
|
||||
std::vector<int> uvIndices;
|
||||
ParseVectorDataArray(uvIndices,GetRequiredElement(source,indexDataElementName));
|
||||
|
|
|
|||
|
|
@ -60,11 +60,14 @@ using namespace Assimp::MD5;
|
|||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Parse the segment structure for an MD5 file
|
||||
MD5Parser::MD5Parser(char *_buffer, unsigned int _fileSize) : buffer(_buffer), bufferEnd(nullptr), fileSize(_fileSize), lineNumber(0) {
|
||||
MD5Parser::MD5Parser(char *_buffer, unsigned int _fileSize) {
|
||||
ai_assert(nullptr != _buffer);
|
||||
ai_assert(0 != _fileSize);
|
||||
|
||||
bufferEnd = buffer + fileSize;
|
||||
buffer = _buffer;
|
||||
fileSize = _fileSize;
|
||||
lineNumber = 0;
|
||||
|
||||
ASSIMP_LOG_DEBUG("MD5Parser begin");
|
||||
|
||||
// parse the file header
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
----------------------------------------------------------------------
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
|
||||
/** @file MD5Parser.h
|
||||
* @brief Definition of the .MD5 parser class.
|
||||
|
|
@ -51,19 +51,20 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#include <assimp/types.h>
|
||||
#include <assimp/ParsingUtils.h>
|
||||
#include <vector>
|
||||
#include <cstdint>
|
||||
#include <stdint.h>
|
||||
|
||||
struct aiFace;
|
||||
|
||||
namespace Assimp {
|
||||
namespace MD5 {
|
||||
namespace Assimp {
|
||||
namespace MD5 {
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** Represents a single element in a MD5 file
|
||||
*
|
||||
* Elements are always contained in sections.
|
||||
*/
|
||||
struct Element {
|
||||
struct Element
|
||||
{
|
||||
//! Points to the starting point of the element
|
||||
//! Whitespace at the beginning and at the end have been removed,
|
||||
//! Elements are terminated with \0
|
||||
|
|
@ -74,14 +75,15 @@ struct Element {
|
|||
unsigned int iLineNumber;
|
||||
};
|
||||
|
||||
using ElementList = std::vector<Element>;
|
||||
typedef std::vector< Element > ElementList;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** Represents a section of a MD5 file (such as the mesh or the joints section)
|
||||
*
|
||||
* A section is always enclosed in { and } brackets.
|
||||
*/
|
||||
struct Section {
|
||||
struct Section
|
||||
{
|
||||
//! Original line number (can be used in error messages
|
||||
//! if a parsing error occurs)
|
||||
unsigned int iLineNumber;
|
||||
|
|
@ -97,12 +99,13 @@ struct Section {
|
|||
std::string mGlobalValue;
|
||||
};
|
||||
|
||||
using SectionList = std::vector<Section>;
|
||||
typedef std::vector< Section> SectionList;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** Basic information about a joint
|
||||
*/
|
||||
struct BaseJointDescription {
|
||||
struct BaseJointDescription
|
||||
{
|
||||
//! Name of the bone
|
||||
aiString mName;
|
||||
|
||||
|
|
@ -113,7 +116,8 @@ struct BaseJointDescription {
|
|||
// ---------------------------------------------------------------------------
|
||||
/** Represents a bone (joint) descriptor in a MD5Mesh file
|
||||
*/
|
||||
struct BoneDesc : BaseJointDescription {
|
||||
struct BoneDesc : BaseJointDescription
|
||||
{
|
||||
//! Absolute position of the bone
|
||||
aiVector3D mPositionXYZ;
|
||||
|
||||
|
|
@ -133,12 +137,13 @@ struct BoneDesc : BaseJointDescription {
|
|||
unsigned int mMap;
|
||||
};
|
||||
|
||||
using BoneList = std::vector<BoneDesc>;
|
||||
typedef std::vector< BoneDesc > BoneList;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** Represents a bone (joint) descriptor in a MD5Anim file
|
||||
*/
|
||||
struct AnimBoneDesc : BaseJointDescription {
|
||||
struct AnimBoneDesc : BaseJointDescription
|
||||
{
|
||||
//! Flags (AI_MD5_ANIMATION_FLAG_xxx)
|
||||
unsigned int iFlags;
|
||||
|
||||
|
|
@ -146,31 +151,35 @@ struct AnimBoneDesc : BaseJointDescription {
|
|||
unsigned int iFirstKeyIndex;
|
||||
};
|
||||
|
||||
using AnimBoneList = std::vector< AnimBoneDesc >;
|
||||
typedef std::vector< AnimBoneDesc > AnimBoneList;
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** Represents a base frame descriptor in a MD5Anim file
|
||||
*/
|
||||
struct BaseFrameDesc {
|
||||
struct BaseFrameDesc
|
||||
{
|
||||
aiVector3D vPositionXYZ;
|
||||
aiVector3D vRotationQuat;
|
||||
};
|
||||
|
||||
using BaseFrameList = std::vector<BaseFrameDesc>;
|
||||
typedef std::vector< BaseFrameDesc > BaseFrameList;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** Represents a camera animation frame in a MDCamera file
|
||||
*/
|
||||
struct CameraAnimFrameDesc : BaseFrameDesc {
|
||||
struct CameraAnimFrameDesc : BaseFrameDesc
|
||||
{
|
||||
float fFOV;
|
||||
};
|
||||
|
||||
using CameraFrameList = std::vector<CameraAnimFrameDesc>;
|
||||
typedef std::vector< CameraAnimFrameDesc > CameraFrameList;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** Represents a frame descriptor in a MD5Anim file
|
||||
*/
|
||||
struct FrameDesc {
|
||||
struct FrameDesc
|
||||
{
|
||||
//! Index of the frame
|
||||
unsigned int iIndex;
|
||||
|
||||
|
|
@ -178,14 +187,15 @@ struct FrameDesc {
|
|||
std::vector< float > mValues;
|
||||
};
|
||||
|
||||
using FrameList = std::vector<FrameDesc>;
|
||||
typedef std::vector< FrameDesc > FrameList;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** Represents a vertex descriptor in a MD5 file
|
||||
*/
|
||||
struct VertexDesc {
|
||||
VertexDesc() AI_NO_EXCEPT
|
||||
: mFirstWeight(0), mNumWeights(0) {
|
||||
: mFirstWeight(0)
|
||||
, mNumWeights(0) {
|
||||
// empty
|
||||
}
|
||||
|
||||
|
|
@ -200,12 +210,13 @@ struct VertexDesc {
|
|||
unsigned int mNumWeights;
|
||||
};
|
||||
|
||||
using VertexList = std::vector<VertexDesc>;
|
||||
typedef std::vector< VertexDesc > VertexList;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** Represents a vertex weight descriptor in a MD5 file
|
||||
*/
|
||||
struct WeightDesc {
|
||||
struct WeightDesc
|
||||
{
|
||||
//! Index of the bone to which this weight refers
|
||||
unsigned int mBone;
|
||||
|
||||
|
|
@ -217,13 +228,14 @@ struct WeightDesc {
|
|||
aiVector3D vOffsetPosition;
|
||||
};
|
||||
|
||||
using WeightList = std::vector<WeightDesc>;
|
||||
using FaceList = std::vector<aiFace>;
|
||||
typedef std::vector< WeightDesc > WeightList;
|
||||
typedef std::vector< aiFace > FaceList;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** Represents a mesh in a MD5 file
|
||||
*/
|
||||
struct MeshDesc {
|
||||
struct MeshDesc
|
||||
{
|
||||
//! Weights of the mesh
|
||||
WeightList mWeights;
|
||||
|
||||
|
|
@ -237,7 +249,7 @@ struct MeshDesc {
|
|||
aiString mShader;
|
||||
};
|
||||
|
||||
using MeshList = std::vector<MeshDesc>;
|
||||
typedef std::vector< MeshDesc > MeshList;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Convert a quaternion to its usual representation
|
||||
|
|
@ -249,11 +261,9 @@ inline void ConvertQuaternion (const aiVector3D& in, aiQuaternion& out) {
|
|||
|
||||
const float t = 1.0f - (in.x*in.x) - (in.y*in.y) - (in.z*in.z);
|
||||
|
||||
if (t < 0.0f) {
|
||||
if (t < 0.0f)
|
||||
out.w = 0.0f;
|
||||
} else {
|
||||
out.w = std::sqrt (t);
|
||||
}
|
||||
else out.w = std::sqrt (t);
|
||||
|
||||
// Assimp convention.
|
||||
out.w *= -1.f;
|
||||
|
|
@ -262,8 +272,10 @@ inline void ConvertQuaternion (const aiVector3D& in, aiQuaternion& out) {
|
|||
// ---------------------------------------------------------------------------
|
||||
/** Parses the data sections of a MD5 mesh file
|
||||
*/
|
||||
class MD5MeshParser {
|
||||
class MD5MeshParser
|
||||
{
|
||||
public:
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Constructs a new MD5MeshParser instance from an existing
|
||||
* preparsed list of file sections.
|
||||
|
|
@ -285,8 +297,10 @@ public:
|
|||
// ---------------------------------------------------------------------------
|
||||
/** Parses the data sections of a MD5 animation file
|
||||
*/
|
||||
class MD5AnimParser {
|
||||
class MD5AnimParser
|
||||
{
|
||||
public:
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Constructs a new MD5AnimParser instance from an existing
|
||||
* preparsed list of file sections.
|
||||
|
|
@ -315,8 +329,10 @@ public:
|
|||
// ---------------------------------------------------------------------------
|
||||
/** Parses the data sections of a MD5 camera animation file
|
||||
*/
|
||||
class MD5CameraParser {
|
||||
class MD5CameraParser
|
||||
{
|
||||
public:
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Constructs a new MD5CameraParser instance from an existing
|
||||
* preparsed list of file sections.
|
||||
|
|
@ -325,6 +341,7 @@ public:
|
|||
*/
|
||||
explicit MD5CameraParser(SectionList& mSections);
|
||||
|
||||
|
||||
//! Output frame rate
|
||||
float fFrameRate;
|
||||
|
||||
|
|
@ -339,8 +356,10 @@ public:
|
|||
/** Parses the block structure of MD5MESH and MD5ANIM files (but does no
|
||||
* further processing)
|
||||
*/
|
||||
class MD5Parser {
|
||||
class MD5Parser
|
||||
{
|
||||
public:
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Constructs a new MD5Parser instance from an existing buffer.
|
||||
*
|
||||
|
|
@ -373,10 +392,13 @@ public:
|
|||
return ReportWarning(warn, lineNumber);
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
//! List of all sections which have been read
|
||||
SectionList mSections;
|
||||
|
||||
private:
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Parses a file section. The current file pointer must be outside
|
||||
* of a section.
|
||||
|
|
@ -392,63 +414,54 @@ private:
|
|||
*/
|
||||
void ParseHeader();
|
||||
|
||||
bool SkipLine(const char* in, const char** out);
|
||||
bool SkipLine( );
|
||||
bool SkipSpacesAndLineEnd( const char* in, const char** out);
|
||||
bool SkipSpacesAndLineEnd();
|
||||
bool SkipSpaces();
|
||||
|
||||
// override these functions to make sure the line counter gets incremented
|
||||
// -------------------------------------------------------------------
|
||||
bool SkipLine( const char* in, const char** out)
|
||||
{
|
||||
++lineNumber;
|
||||
return Assimp::SkipLine(in,out);
|
||||
}
|
||||
// -------------------------------------------------------------------
|
||||
bool SkipLine( )
|
||||
{
|
||||
return SkipLine(buffer,(const char**)&buffer);
|
||||
}
|
||||
// -------------------------------------------------------------------
|
||||
bool SkipSpacesAndLineEnd( const char* in, const char** out)
|
||||
{
|
||||
bool bHad = false;
|
||||
bool running = true;
|
||||
while (running) {
|
||||
if( *in == '\r' || *in == '\n') {
|
||||
// we open files in binary mode, so there could be \r\n sequences ...
|
||||
if (!bHad) {
|
||||
bHad = true;
|
||||
++lineNumber;
|
||||
}
|
||||
}
|
||||
else if (*in == '\t' || *in == ' ')bHad = false;
|
||||
else break;
|
||||
in++;
|
||||
}
|
||||
*out = in;
|
||||
return *in != '\0';
|
||||
}
|
||||
// -------------------------------------------------------------------
|
||||
bool SkipSpacesAndLineEnd( )
|
||||
{
|
||||
return SkipSpacesAndLineEnd(buffer,(const char**)&buffer);
|
||||
}
|
||||
// -------------------------------------------------------------------
|
||||
bool SkipSpaces( )
|
||||
{
|
||||
return Assimp::SkipSpaces((const char**)&buffer);
|
||||
}
|
||||
|
||||
char* buffer;
|
||||
char* bufferEnd;
|
||||
unsigned int fileSize;
|
||||
unsigned int lineNumber;
|
||||
};
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
inline bool MD5Parser::SkipLine(const char* in, const char** out) {
|
||||
++lineNumber;
|
||||
return Assimp::SkipLine(in ,out);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
inline bool MD5Parser::SkipLine( ) {
|
||||
return SkipLine(buffer,(const char**)&buffer);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
inline bool MD5Parser::SkipSpacesAndLineEnd( const char* in, const char** out) {
|
||||
bool bHad = false;
|
||||
bool running = true;
|
||||
while (running) {
|
||||
if( *in == '\r' || *in == '\n') {
|
||||
// we open files in binary mode, so there could be \r\n sequences ...
|
||||
if (!bHad) {
|
||||
bHad = true;
|
||||
++lineNumber;
|
||||
}
|
||||
}
|
||||
else if (*in == '\t' || *in == ' ')bHad = false;
|
||||
else break;
|
||||
++in;
|
||||
if (in == bufferEnd) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
*out = in;
|
||||
return *in != '\0';
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
inline bool MD5Parser::SkipSpacesAndLineEnd() {
|
||||
return SkipSpacesAndLineEnd(buffer,(const char**)&buffer);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
inline bool MD5Parser::SkipSpaces() {
|
||||
return Assimp::SkipSpaces((const char**)&buffer);
|
||||
}
|
||||
|
||||
} // namespace Assimp
|
||||
} // namespace MD5
|
||||
}}
|
||||
|
||||
#endif // AI_MD5PARSER_H_INCLUDED
|
||||
|
|
|
|||
|
|
@ -75,10 +75,15 @@ static const aiImporterDesc desc = {
|
|||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Constructor to be privately used by Importer
|
||||
XFileImporter::XFileImporter() : mBuffer() {
|
||||
XFileImporter::XFileImporter()
|
||||
: mBuffer() {
|
||||
// empty
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Destructor, private as well
|
||||
XFileImporter::~XFileImporter() = default;
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Returns whether the class can handle the format of the given file.
|
||||
bool XFileImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool /*checkSig*/) const {
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ namespace XFile {
|
|||
class XFileImporter : public BaseImporter {
|
||||
public:
|
||||
XFileImporter();
|
||||
~XFileImporter() override = default;
|
||||
~XFileImporter() override;
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Returns whether the class can handle the format of the given file.
|
||||
|
|
|
|||
|
|
@ -1273,13 +1273,11 @@ ASSIMP_API void aiQuaternionInterpolate(
|
|||
#define ASSIMP_HAS_PBRT_EXPORT (!ASSIMP_BUILD_NO_EXPORT && !ASSIMP_BUILD_NO_PBRT_EXPORTER)
|
||||
#define ASSIMP_HAS_M3D ((!ASSIMP_BUILD_NO_EXPORT && !ASSIMP_BUILD_NO_M3D_EXPORTER) || !ASSIMP_BUILD_NO_M3D_IMPORTER)
|
||||
|
||||
#ifndef STB_USE_HUNTER
|
||||
# if ASSIMP_HAS_PBRT_EXPORT
|
||||
# define ASSIMP_NEEDS_STB_IMAGE 1
|
||||
# elif ASSIMP_HAS_M3D
|
||||
# define ASSIMP_NEEDS_STB_IMAGE 1
|
||||
# define STBI_ONLY_PNG
|
||||
# endif
|
||||
#if ASSIMP_HAS_PBRT_EXPORT
|
||||
# define ASSIMP_NEEDS_STB_IMAGE 1
|
||||
#elif ASSIMP_HAS_M3D
|
||||
# define ASSIMP_NEEDS_STB_IMAGE 1
|
||||
# define STBI_ONLY_PNG
|
||||
#endif
|
||||
|
||||
// Ensure all symbols are linked correctly
|
||||
|
|
|
|||
|
|
@ -42,9 +42,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#pragma once
|
||||
|
||||
#ifdef ASSIMP_BUILD_NO_OWN_ZLIB
|
||||
# include <zlib.h>
|
||||
#include <zlib.h>
|
||||
#else
|
||||
# include "../contrib/zlib/zlib.h"
|
||||
#include "../contrib/zlib/zlib.h"
|
||||
#endif
|
||||
|
||||
#include <vector>
|
||||
|
|
|
|||
|
|
@ -41,7 +41,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#pragma once
|
||||
|
||||
#include <assimp/ai_assert.h>
|
||||
#include <utility>
|
||||
|
||||
namespace Assimp {
|
||||
|
||||
|
|
@ -49,14 +48,13 @@ namespace Assimp {
|
|||
/// @tparam T The type to store.
|
||||
template <typename T>
|
||||
struct Maybe {
|
||||
/// @brief
|
||||
/// @brief
|
||||
Maybe() = default;
|
||||
|
||||
/// @brief
|
||||
/// @param val
|
||||
template <typename U>
|
||||
explicit Maybe(U &&val) :
|
||||
_val(std::forward<U>(val)), _valid(true) {}
|
||||
/// @brief
|
||||
/// @param val
|
||||
explicit Maybe(const T &val) :
|
||||
_val(val), _valid(true) {}
|
||||
|
||||
/// @brief Validate the value
|
||||
/// @return true if valid.
|
||||
|
|
@ -66,12 +64,11 @@ struct Maybe {
|
|||
|
||||
/// @brief Will assign a value.
|
||||
/// @param v The new valid value.
|
||||
template <typename U>
|
||||
void Set(U &&v) {
|
||||
void Set(T &v) {
|
||||
ai_assert(!_valid);
|
||||
|
||||
_valid = true;
|
||||
_val = std::forward<U>(v);
|
||||
_val = v;
|
||||
}
|
||||
|
||||
/// @brief Will return the value when it is valid.
|
||||
|
|
|
|||
|
|
@ -48,64 +48,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#pragma GCC diagnostic ignored "-Wunused-function"
|
||||
#endif
|
||||
|
||||
#ifndef STB_USE_HUNTER
|
||||
/* Use prefixed names for the symbols from stb_image as it is a very commonly embedded library.
|
||||
Including vanilla stb_image symbols causes duplicate symbol problems if assimp is linked
|
||||
statically together with another library or executable that also embeds stb_image.
|
||||
|
||||
Symbols are not prefixed if using Hunter because in such case there exists a single true
|
||||
stb_image library on the system that is used by assimp and can be used by all the other
|
||||
libraries and executables.
|
||||
|
||||
The list can be regenerated using the following:
|
||||
|
||||
cat <path/to/stb/stb_image.h> | fgrep STBIDEF | fgrep '(' | sed -E 's/\*|\(.+//g' | \
|
||||
awk '{print "#define " $(NF) " assimp_" $(NF) }' | sort | uniq"
|
||||
*/
|
||||
#define stbi_convert_iphone_png_to_rgb assimp_stbi_convert_iphone_png_to_rgb
|
||||
#define stbi_convert_wchar_to_utf8 assimp_stbi_convert_wchar_to_utf8
|
||||
#define stbi_failure_reason assimp_stbi_failure_reason
|
||||
#define stbi_hdr_to_ldr_gamma assimp_stbi_hdr_to_ldr_gamma
|
||||
#define stbi_hdr_to_ldr_scale assimp_stbi_hdr_to_ldr_scale
|
||||
#define stbi_image_free assimp_stbi_image_free
|
||||
#define stbi_info assimp_stbi_info
|
||||
#define stbi_info_from_callbacks assimp_stbi_info_from_callbacks
|
||||
#define stbi_info_from_file assimp_stbi_info_from_file
|
||||
#define stbi_info_from_memory assimp_stbi_info_from_memory
|
||||
#define stbi_is_16_bit assimp_stbi_is_16_bit
|
||||
#define stbi_is_16_bit_from_callbacks assimp_stbi_is_16_bit_from_callbacks
|
||||
#define stbi_is_16_bit_from_file assimp_stbi_is_16_bit_from_file
|
||||
#define stbi_is_16_bit_from_memory assimp_stbi_is_16_bit_from_memory
|
||||
#define stbi_is_hdr assimp_stbi_is_hdr
|
||||
#define stbi_is_hdr_from_callbacks assimp_stbi_is_hdr_from_callbacks
|
||||
#define stbi_is_hdr_from_file assimp_stbi_is_hdr_from_file
|
||||
#define stbi_is_hdr_from_memory assimp_stbi_is_hdr_from_memory
|
||||
#define stbi_ldr_to_hdr_gamma assimp_stbi_ldr_to_hdr_gamma
|
||||
#define stbi_ldr_to_hdr_scale assimp_stbi_ldr_to_hdr_scale
|
||||
#define stbi_load_16 assimp_stbi_load_16
|
||||
#define stbi_load_16_from_callbacks assimp_stbi_load_16_from_callbacks
|
||||
#define stbi_load_16_from_memory assimp_stbi_load_16_from_memory
|
||||
#define stbi_load assimp_stbi_load
|
||||
#define stbi_loadf assimp_stbi_loadf
|
||||
#define stbi_loadf_from_callbacks assimp_stbi_loadf_from_callbacks
|
||||
#define stbi_loadf_from_file assimp_stbi_loadf_from_file
|
||||
#define stbi_loadf_from_memory assimp_stbi_loadf_from_memory
|
||||
#define stbi_load_from_callbacks assimp_stbi_load_from_callbacks
|
||||
#define stbi_load_from_file_16 assimp_stbi_load_from_file_16
|
||||
#define stbi_load_from_file assimp_stbi_load_from_file
|
||||
#define stbi_load_from_memory assimp_stbi_load_from_memory
|
||||
#define stbi_load_gif_from_memory assimp_stbi_load_gif_from_memory
|
||||
#define stbi_set_flip_vertically_on_load assimp_stbi_set_flip_vertically_on_load
|
||||
#define stbi_set_flip_vertically_on_load_thread assimp_stbi_set_flip_vertically_on_load_thread
|
||||
#define stbi_set_unpremultiply_on_load assimp_stbi_set_unpremultiply_on_load
|
||||
#define stbi_zlib_decode_buffer assimp_stbi_zlib_decode_buffer
|
||||
#define stbi_zlib_decode_malloc assimp_stbi_zlib_decode_malloc
|
||||
#define stbi_zlib_decode_malloc_guesssize assimp_stbi_zlib_decode_malloc_guesssize
|
||||
#define stbi_zlib_decode_malloc_guesssize_headerflag assimp_stbi_zlib_decode_malloc_guesssize_headerflag
|
||||
#define stbi_zlib_decode_noheader_buffer assimp_stbi_zlib_decode_noheader_buffer
|
||||
#define stbi_zlib_decode_noheader_malloc assimp_stbi_zlib_decode_noheader_malloc
|
||||
#endif
|
||||
|
||||
#include "stb/stb_image.h"
|
||||
|
||||
#if _MSC_VER
|
||||
|
|
|
|||
1
Engine/lib/assimp/contrib/draco/.gitignore
vendored
1
Engine/lib/assimp/contrib/draco/.gitignore
vendored
|
|
@ -1 +0,0 @@
|
|||
docs/_site
|
||||
2
Engine/lib/assimp/contrib/gtest/.gitignore
vendored
2
Engine/lib/assimp/contrib/gtest/.gitignore
vendored
|
|
@ -1,2 +0,0 @@
|
|||
# python
|
||||
*.pyc
|
||||
|
|
@ -46,9 +46,14 @@ endif()
|
|||
|
||||
# Project version:
|
||||
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
cmake_policy(SET CMP0048 NEW)
|
||||
project(gtest VERSION ${GOOGLETEST_VERSION} LANGUAGES CXX C)
|
||||
if (CMAKE_VERSION VERSION_LESS 3.0)
|
||||
project(gtest CXX C)
|
||||
set(PROJECT_VERSION ${GOOGLETEST_VERSION})
|
||||
else()
|
||||
cmake_policy(SET CMP0048 NEW)
|
||||
project(gtest VERSION ${GOOGLETEST_VERSION} LANGUAGES CXX C)
|
||||
endif()
|
||||
cmake_minimum_required(VERSION 2.8.12)
|
||||
|
||||
if (POLICY CMP0063) # Visibility
|
||||
cmake_policy(SET CMP0063 NEW)
|
||||
|
|
@ -131,17 +136,13 @@ set_target_properties(gtest_main PROPERTIES VERSION ${GOOGLETEST_VERSION})
|
|||
# to the targets for when we are part of a parent build (ie being pulled
|
||||
# in via add_subdirectory() rather than being a standalone build).
|
||||
if (DEFINED CMAKE_VERSION AND NOT "${CMAKE_VERSION}" VERSION_LESS "2.8.11")
|
||||
string(REPLACE ";" "$<SEMICOLON>" dirs "${gtest_build_include_dirs}")
|
||||
target_include_directories(gtest SYSTEM INTERFACE
|
||||
"$<BUILD_INTERFACE:${dirs}>"
|
||||
"$<BUILD_INTERFACE:${gtest_build_include_dirs}>"
|
||||
"$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/${CMAKE_INSTALL_INCLUDEDIR}>")
|
||||
target_include_directories(gtest_main SYSTEM INTERFACE
|
||||
"$<BUILD_INTERFACE:${dirs}>"
|
||||
"$<BUILD_INTERFACE:${gtest_build_include_dirs}>"
|
||||
"$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/${CMAKE_INSTALL_INCLUDEDIR}>")
|
||||
endif()
|
||||
if(CMAKE_SYSTEM_NAME MATCHES "QNX")
|
||||
target_link_libraries(gtest PUBLIC regex)
|
||||
endif()
|
||||
target_link_libraries(gtest_main PUBLIC gtest)
|
||||
|
||||
########################################################################
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ When building GoogleTest as a standalone project, the typical workflow starts
|
|||
with
|
||||
|
||||
```
|
||||
git clone https://github.com/google/googletest.git -b release-1.11.0
|
||||
git clone https://github.com/google/googletest.git -b release-1.10.0
|
||||
cd googletest # Main directory of the cloned repository.
|
||||
mkdir build # Create a directory to hold the build output.
|
||||
cd build
|
||||
|
|
@ -94,7 +94,7 @@ include(FetchContent)
|
|||
FetchContent_Declare(
|
||||
googletest
|
||||
# Specify the commit you depend on and update it regularly.
|
||||
URL https://github.com/google/googletest/archive/e2239ee6043f73722e7aa812a459f54a28552929.zip
|
||||
URL https://github.com/google/googletest/archive/609281088cfefc76f9d0ce82e1ff6c30cc3591e5.zip
|
||||
)
|
||||
# For Windows: Prevent overriding the parent project's compiler/linker settings
|
||||
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
|
||||
|
|
@ -203,9 +203,7 @@ add
|
|||
-DGTEST_DONT_DEFINE_FOO=1
|
||||
|
||||
to the compiler flags to tell GoogleTest to change the macro's name from `FOO`
|
||||
to `GTEST_FOO`. Currently `FOO` can be `ASSERT_EQ`, `ASSERT_FALSE`, `ASSERT_GE`,
|
||||
`ASSERT_GT`, `ASSERT_LE`, `ASSERT_LT`, `ASSERT_NE`, `ASSERT_TRUE`,
|
||||
`EXPECT_FALSE`, `EXPECT_TRUE`, `FAIL`, `SUCCEED`, `TEST`, or `TEST_F`. For
|
||||
to `GTEST_FOO`. Currently `FOO` can be `FAIL`, `SUCCEED`, or `TEST`. For
|
||||
example, with `-DGTEST_DONT_DEFINE_TEST=1`, you'll need to write
|
||||
|
||||
GTEST_TEST(SomeTest, DoesThis) { ... }
|
||||
|
|
|
|||
|
|
@ -84,13 +84,13 @@ macro(config_compiler_and_linker)
|
|||
# Ensure MSVC treats source files as UTF-8 encoded.
|
||||
set(cxx_base_flags "${cxx_base_flags} -utf-8")
|
||||
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
||||
set(cxx_base_flags "-Wall -Wshadow -Wconversion")
|
||||
set(cxx_base_flags "-Wall -Wshadow -Werror -Wconversion")
|
||||
set(cxx_exception_flags "-fexceptions")
|
||||
set(cxx_no_exception_flags "-fno-exceptions")
|
||||
set(cxx_strict_flags "-W -Wpointer-arith -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch -Wunused-parameter -Wcast-align -Wchar-subscripts -Winline -Wredundant-decls")
|
||||
set(cxx_no_rtti_flags "-fno-rtti")
|
||||
elseif (CMAKE_COMPILER_IS_GNUCXX)
|
||||
set(cxx_base_flags "-Wall -Wshadow")
|
||||
set(cxx_base_flags "-Wall -Wshadow -Werror")
|
||||
if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.0.0)
|
||||
set(cxx_base_flags "${cxx_base_flags} -Wno-error=dangling-else")
|
||||
endif()
|
||||
|
|
@ -154,6 +154,10 @@ function(cxx_library_with_type name type cxx_flags)
|
|||
set_target_properties(${name}
|
||||
PROPERTIES
|
||||
COMPILE_FLAGS "${cxx_flags}")
|
||||
# Generate debug library name with a postfix.
|
||||
set_target_properties(${name}
|
||||
PROPERTIES
|
||||
DEBUG_POSTFIX "d")
|
||||
# Set the output directory for build artifacts
|
||||
set_target_properties(${name}
|
||||
PROPERTIES
|
||||
|
|
@ -300,8 +304,6 @@ function(py_test name)
|
|||
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test/${name}.py
|
||||
--build_dir=${CMAKE_CURRENT_BINARY_DIR}/\${CTEST_CONFIGURATION_TYPE} ${ARGN})
|
||||
endif()
|
||||
# Make the Python import path consistent between Bazel and CMake.
|
||||
set_tests_properties(${name} PROPERTIES ENVIRONMENT PYTHONPATH=${CMAKE_SOURCE_DIR})
|
||||
endif(PYTHONINTERP_FOUND)
|
||||
endfunction()
|
||||
|
||||
|
|
|
|||
|
|
@ -27,21 +27,21 @@
|
|||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
//
|
||||
// The Google C++ Testing and Mocking Framework (Google Test)
|
||||
//
|
||||
// This header file defines the public API for death tests. It is
|
||||
// #included by gtest.h so a user doesn't need to include this
|
||||
// directly.
|
||||
|
||||
// IWYU pragma: private, include "gtest/gtest.h"
|
||||
// IWYU pragma: friend gtest/.*
|
||||
// IWYU pragma: friend gmock/.*
|
||||
// GOOGLETEST_CM0001 DO NOT DELETE
|
||||
|
||||
#ifndef GOOGLETEST_INCLUDE_GTEST_GTEST_DEATH_TEST_H_
|
||||
#define GOOGLETEST_INCLUDE_GTEST_GTEST_DEATH_TEST_H_
|
||||
|
||||
#include "gtest/internal/gtest-death-test-internal.h"
|
||||
|
||||
namespace testing {
|
||||
|
||||
// This flag controls the style of death tests. Valid values are "threadsafe",
|
||||
// meaning that the death test child process will re-execute the test binary
|
||||
// from the start, running only a single death test, or "fast",
|
||||
|
|
@ -49,8 +49,6 @@
|
|||
// after forking.
|
||||
GTEST_DECLARE_string_(death_test_style);
|
||||
|
||||
namespace testing {
|
||||
|
||||
#if GTEST_HAS_DEATH_TEST
|
||||
|
||||
namespace internal {
|
||||
|
|
@ -105,6 +103,7 @@ GTEST_API_ bool InDeathTestChild();
|
|||
//
|
||||
// On the regular expressions used in death tests:
|
||||
//
|
||||
// GOOGLETEST_CM0005 DO NOT DELETE
|
||||
// On POSIX-compliant systems (*nix), we use the <regex.h> library,
|
||||
// which uses the POSIX extended regex syntax.
|
||||
//
|
||||
|
|
@ -170,24 +169,24 @@ GTEST_API_ bool InDeathTestChild();
|
|||
// Asserts that a given `statement` causes the program to exit, with an
|
||||
// integer exit status that satisfies `predicate`, and emitting error output
|
||||
// that matches `matcher`.
|
||||
#define ASSERT_EXIT(statement, predicate, matcher) \
|
||||
GTEST_DEATH_TEST_(statement, predicate, matcher, GTEST_FATAL_FAILURE_)
|
||||
# define ASSERT_EXIT(statement, predicate, matcher) \
|
||||
GTEST_DEATH_TEST_(statement, predicate, matcher, GTEST_FATAL_FAILURE_)
|
||||
|
||||
// Like `ASSERT_EXIT`, but continues on to successive tests in the
|
||||
// test suite, if any:
|
||||
#define EXPECT_EXIT(statement, predicate, matcher) \
|
||||
GTEST_DEATH_TEST_(statement, predicate, matcher, GTEST_NONFATAL_FAILURE_)
|
||||
# define EXPECT_EXIT(statement, predicate, matcher) \
|
||||
GTEST_DEATH_TEST_(statement, predicate, matcher, GTEST_NONFATAL_FAILURE_)
|
||||
|
||||
// Asserts that a given `statement` causes the program to exit, either by
|
||||
// explicitly exiting with a nonzero exit code or being killed by a
|
||||
// signal, and emitting error output that matches `matcher`.
|
||||
#define ASSERT_DEATH(statement, matcher) \
|
||||
ASSERT_EXIT(statement, ::testing::internal::ExitedUnsuccessfully, matcher)
|
||||
# define ASSERT_DEATH(statement, matcher) \
|
||||
ASSERT_EXIT(statement, ::testing::internal::ExitedUnsuccessfully, matcher)
|
||||
|
||||
// Like `ASSERT_DEATH`, but continues on to successive tests in the
|
||||
// test suite, if any:
|
||||
#define EXPECT_DEATH(statement, matcher) \
|
||||
EXPECT_EXIT(statement, ::testing::internal::ExitedUnsuccessfully, matcher)
|
||||
# define EXPECT_DEATH(statement, matcher) \
|
||||
EXPECT_EXIT(statement, ::testing::internal::ExitedUnsuccessfully, matcher)
|
||||
|
||||
// Two predicate classes that can be used in {ASSERT,EXPECT}_EXIT*:
|
||||
|
||||
|
|
@ -198,23 +197,22 @@ class GTEST_API_ ExitedWithCode {
|
|||
ExitedWithCode(const ExitedWithCode&) = default;
|
||||
void operator=(const ExitedWithCode& other) = delete;
|
||||
bool operator()(int exit_status) const;
|
||||
|
||||
private:
|
||||
const int exit_code_;
|
||||
};
|
||||
|
||||
#if !GTEST_OS_WINDOWS && !GTEST_OS_FUCHSIA
|
||||
# if !GTEST_OS_WINDOWS && !GTEST_OS_FUCHSIA
|
||||
// Tests that an exit code describes an exit due to termination by a
|
||||
// given signal.
|
||||
// GOOGLETEST_CM0006 DO NOT DELETE
|
||||
class GTEST_API_ KilledBySignal {
|
||||
public:
|
||||
explicit KilledBySignal(int signum);
|
||||
bool operator()(int exit_status) const;
|
||||
|
||||
private:
|
||||
const int signum_;
|
||||
};
|
||||
#endif // !GTEST_OS_WINDOWS
|
||||
# endif // !GTEST_OS_WINDOWS
|
||||
|
||||
// EXPECT_DEBUG_DEATH asserts that the given statements die in debug mode.
|
||||
// The death testing framework causes this to have interesting semantics,
|
||||
|
|
@ -259,21 +257,23 @@ class GTEST_API_ KilledBySignal {
|
|||
// EXPECT_EQ(12, DieInDebugOr12(&sideeffect));
|
||||
// }, "death");
|
||||
//
|
||||
#ifdef NDEBUG
|
||||
# ifdef NDEBUG
|
||||
|
||||
#define EXPECT_DEBUG_DEATH(statement, regex) \
|
||||
# define EXPECT_DEBUG_DEATH(statement, regex) \
|
||||
GTEST_EXECUTE_STATEMENT_(statement, regex)
|
||||
|
||||
#define ASSERT_DEBUG_DEATH(statement, regex) \
|
||||
# define ASSERT_DEBUG_DEATH(statement, regex) \
|
||||
GTEST_EXECUTE_STATEMENT_(statement, regex)
|
||||
|
||||
#else
|
||||
# else
|
||||
|
||||
#define EXPECT_DEBUG_DEATH(statement, regex) EXPECT_DEATH(statement, regex)
|
||||
# define EXPECT_DEBUG_DEATH(statement, regex) \
|
||||
EXPECT_DEATH(statement, regex)
|
||||
|
||||
#define ASSERT_DEBUG_DEATH(statement, regex) ASSERT_DEATH(statement, regex)
|
||||
# define ASSERT_DEBUG_DEATH(statement, regex) \
|
||||
ASSERT_DEATH(statement, regex)
|
||||
|
||||
#endif // NDEBUG for EXPECT_DEBUG_DEATH
|
||||
# endif // NDEBUG for EXPECT_DEBUG_DEATH
|
||||
#endif // GTEST_HAS_DEATH_TEST
|
||||
|
||||
// This macro is used for implementing macros such as
|
||||
|
|
@ -311,17 +311,18 @@ class GTEST_API_ KilledBySignal {
|
|||
// statement unconditionally returns or throws. The Message constructor at
|
||||
// the end allows the syntax of streaming additional messages into the
|
||||
// macro, for compilational compatibility with EXPECT_DEATH/ASSERT_DEATH.
|
||||
#define GTEST_UNSUPPORTED_DEATH_TEST(statement, regex, terminator) \
|
||||
GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
|
||||
if (::testing::internal::AlwaysTrue()) { \
|
||||
GTEST_LOG_(WARNING) << "Death tests are not supported on this platform.\n" \
|
||||
<< "Statement '" #statement "' cannot be verified."; \
|
||||
} else if (::testing::internal::AlwaysFalse()) { \
|
||||
::testing::internal::RE::PartialMatch(".*", (regex)); \
|
||||
GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
|
||||
terminator; \
|
||||
} else \
|
||||
::testing::Message()
|
||||
# define GTEST_UNSUPPORTED_DEATH_TEST(statement, regex, terminator) \
|
||||
GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
|
||||
if (::testing::internal::AlwaysTrue()) { \
|
||||
GTEST_LOG_(WARNING) \
|
||||
<< "Death tests are not supported on this platform.\n" \
|
||||
<< "Statement '" #statement "' cannot be verified."; \
|
||||
} else if (::testing::internal::AlwaysFalse()) { \
|
||||
::testing::internal::RE::PartialMatch(".*", (regex)); \
|
||||
GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
|
||||
terminator; \
|
||||
} else \
|
||||
::testing::Message()
|
||||
|
||||
// EXPECT_DEATH_IF_SUPPORTED(statement, regex) and
|
||||
// ASSERT_DEATH_IF_SUPPORTED(statement, regex) expand to real death tests if
|
||||
|
|
@ -329,15 +330,15 @@ class GTEST_API_ KilledBySignal {
|
|||
// useful when you are combining death test assertions with normal test
|
||||
// assertions in one test.
|
||||
#if GTEST_HAS_DEATH_TEST
|
||||
#define EXPECT_DEATH_IF_SUPPORTED(statement, regex) \
|
||||
EXPECT_DEATH(statement, regex)
|
||||
#define ASSERT_DEATH_IF_SUPPORTED(statement, regex) \
|
||||
ASSERT_DEATH(statement, regex)
|
||||
# define EXPECT_DEATH_IF_SUPPORTED(statement, regex) \
|
||||
EXPECT_DEATH(statement, regex)
|
||||
# define ASSERT_DEATH_IF_SUPPORTED(statement, regex) \
|
||||
ASSERT_DEATH(statement, regex)
|
||||
#else
|
||||
#define EXPECT_DEATH_IF_SUPPORTED(statement, regex) \
|
||||
GTEST_UNSUPPORTED_DEATH_TEST(statement, regex, )
|
||||
#define ASSERT_DEATH_IF_SUPPORTED(statement, regex) \
|
||||
GTEST_UNSUPPORTED_DEATH_TEST(statement, regex, return)
|
||||
# define EXPECT_DEATH_IF_SUPPORTED(statement, regex) \
|
||||
GTEST_UNSUPPORTED_DEATH_TEST(statement, regex, )
|
||||
# define ASSERT_DEATH_IF_SUPPORTED(statement, regex) \
|
||||
GTEST_UNSUPPORTED_DEATH_TEST(statement, regex, return)
|
||||
#endif
|
||||
|
||||
} // namespace testing
|
||||
|
|
|
|||
|
|
@ -32,10 +32,6 @@
|
|||
// This file implements just enough of the matcher interface to allow
|
||||
// EXPECT_DEATH and friends to accept a matcher argument.
|
||||
|
||||
// IWYU pragma: private, include "gtest/gtest.h"
|
||||
// IWYU pragma: friend gtest/.*
|
||||
// IWYU pragma: friend gmock/.*
|
||||
|
||||
#ifndef GOOGLETEST_INCLUDE_GTEST_GTEST_MATCHERS_H_
|
||||
#define GOOGLETEST_INCLUDE_GTEST_GTEST_MATCHERS_H_
|
||||
|
||||
|
|
@ -102,11 +98,11 @@ class MatchResultListener {
|
|||
private:
|
||||
::std::ostream* const stream_;
|
||||
|
||||
MatchResultListener(const MatchResultListener&) = delete;
|
||||
MatchResultListener& operator=(const MatchResultListener&) = delete;
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(MatchResultListener);
|
||||
};
|
||||
|
||||
inline MatchResultListener::~MatchResultListener() {}
|
||||
inline MatchResultListener::~MatchResultListener() {
|
||||
}
|
||||
|
||||
// An instance of a subclass of this knows how to describe itself as a
|
||||
// matcher.
|
||||
|
|
@ -180,39 +176,27 @@ namespace internal {
|
|||
|
||||
struct AnyEq {
|
||||
template <typename A, typename B>
|
||||
bool operator()(const A& a, const B& b) const {
|
||||
return a == b;
|
||||
}
|
||||
bool operator()(const A& a, const B& b) const { return a == b; }
|
||||
};
|
||||
struct AnyNe {
|
||||
template <typename A, typename B>
|
||||
bool operator()(const A& a, const B& b) const {
|
||||
return a != b;
|
||||
}
|
||||
bool operator()(const A& a, const B& b) const { return a != b; }
|
||||
};
|
||||
struct AnyLt {
|
||||
template <typename A, typename B>
|
||||
bool operator()(const A& a, const B& b) const {
|
||||
return a < b;
|
||||
}
|
||||
bool operator()(const A& a, const B& b) const { return a < b; }
|
||||
};
|
||||
struct AnyGt {
|
||||
template <typename A, typename B>
|
||||
bool operator()(const A& a, const B& b) const {
|
||||
return a > b;
|
||||
}
|
||||
bool operator()(const A& a, const B& b) const { return a > b; }
|
||||
};
|
||||
struct AnyLe {
|
||||
template <typename A, typename B>
|
||||
bool operator()(const A& a, const B& b) const {
|
||||
return a <= b;
|
||||
}
|
||||
bool operator()(const A& a, const B& b) const { return a <= b; }
|
||||
};
|
||||
struct AnyGe {
|
||||
template <typename A, typename B>
|
||||
bool operator()(const A& a, const B& b) const {
|
||||
return a >= b;
|
||||
}
|
||||
bool operator()(const A& a, const B& b) const { return a >= b; }
|
||||
};
|
||||
|
||||
// A match result listener that ignores the explanation.
|
||||
|
|
@ -221,8 +205,7 @@ class DummyMatchResultListener : public MatchResultListener {
|
|||
DummyMatchResultListener() : MatchResultListener(nullptr) {}
|
||||
|
||||
private:
|
||||
DummyMatchResultListener(const DummyMatchResultListener&) = delete;
|
||||
DummyMatchResultListener& operator=(const DummyMatchResultListener&) = delete;
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(DummyMatchResultListener);
|
||||
};
|
||||
|
||||
// A match result listener that forwards the explanation to a given
|
||||
|
|
@ -234,9 +217,7 @@ class StreamMatchResultListener : public MatchResultListener {
|
|||
: MatchResultListener(os) {}
|
||||
|
||||
private:
|
||||
StreamMatchResultListener(const StreamMatchResultListener&) = delete;
|
||||
StreamMatchResultListener& operator=(const StreamMatchResultListener&) =
|
||||
delete;
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(StreamMatchResultListener);
|
||||
};
|
||||
|
||||
struct SharedPayloadBase {
|
||||
|
|
@ -303,18 +284,17 @@ class MatcherBase : private MatcherDescriberInterface {
|
|||
}
|
||||
|
||||
protected:
|
||||
MatcherBase() : vtable_(nullptr), buffer_() {}
|
||||
MatcherBase() : vtable_(nullptr) {}
|
||||
|
||||
// Constructs a matcher from its implementation.
|
||||
template <typename U>
|
||||
explicit MatcherBase(const MatcherInterface<U>* impl)
|
||||
: vtable_(nullptr), buffer_() {
|
||||
explicit MatcherBase(const MatcherInterface<U>* impl) {
|
||||
Init(impl);
|
||||
}
|
||||
|
||||
template <typename M, typename = typename std::remove_reference<
|
||||
M>::type::is_gtest_matcher>
|
||||
MatcherBase(M&& m) : vtable_(nullptr), buffer_() { // NOLINT
|
||||
MatcherBase(M&& m) { // NOLINT
|
||||
Init(std::forward<M>(m));
|
||||
}
|
||||
|
||||
|
|
@ -440,8 +420,8 @@ class MatcherBase : private MatcherDescriberInterface {
|
|||
static const M& Get(const MatcherBase& m) {
|
||||
// When inlined along with Init, need to be explicit to avoid violating
|
||||
// strict aliasing rules.
|
||||
const M* ptr =
|
||||
static_cast<const M*>(static_cast<const void*>(&m.buffer_));
|
||||
const M *ptr = static_cast<const M*>(
|
||||
static_cast<const void*>(&m.buffer_));
|
||||
return *ptr;
|
||||
}
|
||||
static void Init(MatcherBase& m, M impl) {
|
||||
|
|
@ -761,7 +741,7 @@ template <typename Rhs>
|
|||
class EqMatcher : public ComparisonBase<EqMatcher<Rhs>, Rhs, AnyEq> {
|
||||
public:
|
||||
explicit EqMatcher(const Rhs& rhs)
|
||||
: ComparisonBase<EqMatcher<Rhs>, Rhs, AnyEq>(rhs) {}
|
||||
: ComparisonBase<EqMatcher<Rhs>, Rhs, AnyEq>(rhs) { }
|
||||
static const char* Desc() { return "is equal to"; }
|
||||
static const char* NegatedDesc() { return "isn't equal to"; }
|
||||
};
|
||||
|
|
@ -769,7 +749,7 @@ template <typename Rhs>
|
|||
class NeMatcher : public ComparisonBase<NeMatcher<Rhs>, Rhs, AnyNe> {
|
||||
public:
|
||||
explicit NeMatcher(const Rhs& rhs)
|
||||
: ComparisonBase<NeMatcher<Rhs>, Rhs, AnyNe>(rhs) {}
|
||||
: ComparisonBase<NeMatcher<Rhs>, Rhs, AnyNe>(rhs) { }
|
||||
static const char* Desc() { return "isn't equal to"; }
|
||||
static const char* NegatedDesc() { return "is equal to"; }
|
||||
};
|
||||
|
|
@ -777,7 +757,7 @@ template <typename Rhs>
|
|||
class LtMatcher : public ComparisonBase<LtMatcher<Rhs>, Rhs, AnyLt> {
|
||||
public:
|
||||
explicit LtMatcher(const Rhs& rhs)
|
||||
: ComparisonBase<LtMatcher<Rhs>, Rhs, AnyLt>(rhs) {}
|
||||
: ComparisonBase<LtMatcher<Rhs>, Rhs, AnyLt>(rhs) { }
|
||||
static const char* Desc() { return "is <"; }
|
||||
static const char* NegatedDesc() { return "isn't <"; }
|
||||
};
|
||||
|
|
@ -785,7 +765,7 @@ template <typename Rhs>
|
|||
class GtMatcher : public ComparisonBase<GtMatcher<Rhs>, Rhs, AnyGt> {
|
||||
public:
|
||||
explicit GtMatcher(const Rhs& rhs)
|
||||
: ComparisonBase<GtMatcher<Rhs>, Rhs, AnyGt>(rhs) {}
|
||||
: ComparisonBase<GtMatcher<Rhs>, Rhs, AnyGt>(rhs) { }
|
||||
static const char* Desc() { return "is >"; }
|
||||
static const char* NegatedDesc() { return "isn't >"; }
|
||||
};
|
||||
|
|
@ -793,7 +773,7 @@ template <typename Rhs>
|
|||
class LeMatcher : public ComparisonBase<LeMatcher<Rhs>, Rhs, AnyLe> {
|
||||
public:
|
||||
explicit LeMatcher(const Rhs& rhs)
|
||||
: ComparisonBase<LeMatcher<Rhs>, Rhs, AnyLe>(rhs) {}
|
||||
: ComparisonBase<LeMatcher<Rhs>, Rhs, AnyLe>(rhs) { }
|
||||
static const char* Desc() { return "is <="; }
|
||||
static const char* NegatedDesc() { return "isn't <="; }
|
||||
};
|
||||
|
|
@ -801,7 +781,7 @@ template <typename Rhs>
|
|||
class GeMatcher : public ComparisonBase<GeMatcher<Rhs>, Rhs, AnyGe> {
|
||||
public:
|
||||
explicit GeMatcher(const Rhs& rhs)
|
||||
: ComparisonBase<GeMatcher<Rhs>, Rhs, AnyGe>(rhs) {}
|
||||
: ComparisonBase<GeMatcher<Rhs>, Rhs, AnyGe>(rhs) { }
|
||||
static const char* Desc() { return "is >="; }
|
||||
static const char* NegatedDesc() { return "isn't >="; }
|
||||
};
|
||||
|
|
@ -892,16 +872,12 @@ PolymorphicMatcher<internal::MatchesRegexMatcher> ContainsRegex(
|
|||
// Note: if the parameter of Eq() were declared as const T&, Eq("foo")
|
||||
// wouldn't compile.
|
||||
template <typename T>
|
||||
inline internal::EqMatcher<T> Eq(T x) {
|
||||
return internal::EqMatcher<T>(x);
|
||||
}
|
||||
inline internal::EqMatcher<T> Eq(T x) { return internal::EqMatcher<T>(x); }
|
||||
|
||||
// Constructs a Matcher<T> from a 'value' of type T. The constructed
|
||||
// matcher matches any value that's equal to 'value'.
|
||||
template <typename T>
|
||||
Matcher<T>::Matcher(T value) {
|
||||
*this = Eq(value);
|
||||
}
|
||||
Matcher<T>::Matcher(T value) { *this = Eq(value); }
|
||||
|
||||
// Creates a monomorphic matcher that matches anything with type Lhs
|
||||
// and equal to rhs. A user may need to use this instead of Eq(...)
|
||||
|
|
@ -916,9 +892,7 @@ Matcher<T>::Matcher(T value) {
|
|||
// can always write Matcher<T>(Lt(5)) to be explicit about the type,
|
||||
// for example.
|
||||
template <typename Lhs, typename Rhs>
|
||||
inline Matcher<Lhs> TypedEq(const Rhs& rhs) {
|
||||
return Eq(rhs);
|
||||
}
|
||||
inline Matcher<Lhs> TypedEq(const Rhs& rhs) { return Eq(rhs); }
|
||||
|
||||
// Creates a polymorphic matcher that matches anything >= x.
|
||||
template <typename Rhs>
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@
|
|||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
//
|
||||
// The Google C++ Testing and Mocking Framework (Google Test)
|
||||
//
|
||||
// This header file defines the Message class.
|
||||
|
|
@ -41,9 +42,7 @@
|
|||
// to CHANGE WITHOUT NOTICE. Therefore DO NOT DEPEND ON IT in a user
|
||||
// program!
|
||||
|
||||
// IWYU pragma: private, include "gtest/gtest.h"
|
||||
// IWYU pragma: friend gtest/.*
|
||||
// IWYU pragma: friend gmock/.*
|
||||
// GOOGLETEST_CM0001 DO NOT DELETE
|
||||
|
||||
#ifndef GOOGLETEST_INCLUDE_GTEST_GTEST_MESSAGE_H_
|
||||
#define GOOGLETEST_INCLUDE_GTEST_GTEST_MESSAGE_H_
|
||||
|
|
@ -111,8 +110,8 @@ class GTEST_API_ Message {
|
|||
|
||||
// Streams a non-pointer value to this object.
|
||||
template <typename T>
|
||||
inline Message& operator<<(const T& val) {
|
||||
// Some libraries overload << for STL containers. These
|
||||
inline Message& operator <<(const T& val) {
|
||||
// Some libraries overload << for STL containers. These
|
||||
// overloads are defined in the global namespace instead of ::std.
|
||||
//
|
||||
// C++'s symbol lookup rule (i.e. Koenig lookup) says that these
|
||||
|
|
@ -126,7 +125,7 @@ class GTEST_API_ Message {
|
|||
// from the global namespace. With this using declaration,
|
||||
// overloads of << defined in the global namespace and those
|
||||
// visible via Koenig lookup are both exposed in this function.
|
||||
using ::operator<<;
|
||||
using ::operator <<;
|
||||
*ss_ << val;
|
||||
return *this;
|
||||
}
|
||||
|
|
@ -145,7 +144,7 @@ class GTEST_API_ Message {
|
|||
// ensure consistent result across compilers, we always treat NULL
|
||||
// as "(null)".
|
||||
template <typename T>
|
||||
inline Message& operator<<(T* const& pointer) { // NOLINT
|
||||
inline Message& operator <<(T* const& pointer) { // NOLINT
|
||||
if (pointer == nullptr) {
|
||||
*ss_ << "(null)";
|
||||
} else {
|
||||
|
|
@ -160,23 +159,25 @@ class GTEST_API_ Message {
|
|||
// templatized version above. Without this definition, streaming
|
||||
// endl or other basic IO manipulators to Message will confuse the
|
||||
// compiler.
|
||||
Message& operator<<(BasicNarrowIoManip val) {
|
||||
Message& operator <<(BasicNarrowIoManip val) {
|
||||
*ss_ << val;
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Instead of 1/0, we want to see true/false for bool values.
|
||||
Message& operator<<(bool b) { return *this << (b ? "true" : "false"); }
|
||||
Message& operator <<(bool b) {
|
||||
return *this << (b ? "true" : "false");
|
||||
}
|
||||
|
||||
// These two overloads allow streaming a wide C string to a Message
|
||||
// using the UTF-8 encoding.
|
||||
Message& operator<<(const wchar_t* wide_c_str);
|
||||
Message& operator<<(wchar_t* wide_c_str);
|
||||
Message& operator <<(const wchar_t* wide_c_str);
|
||||
Message& operator <<(wchar_t* wide_c_str);
|
||||
|
||||
#if GTEST_HAS_STD_WSTRING
|
||||
// Converts the given wide string to a narrow string using the UTF-8
|
||||
// encoding, and streams the result to this Message object.
|
||||
Message& operator<<(const ::std::wstring& wstr);
|
||||
Message& operator <<(const ::std::wstring& wstr);
|
||||
#endif // GTEST_HAS_STD_WSTRING
|
||||
|
||||
// Gets the text streamed to this object so far as an std::string.
|
||||
|
|
@ -195,7 +196,7 @@ class GTEST_API_ Message {
|
|||
};
|
||||
|
||||
// Streams a Message to an ostream.
|
||||
inline std::ostream& operator<<(std::ostream& os, const Message& sb) {
|
||||
inline std::ostream& operator <<(std::ostream& os, const Message& sb) {
|
||||
return os << sb.GetString();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -26,14 +26,11 @@
|
|||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
//
|
||||
// Macros and functions for implementing parameterized tests
|
||||
// in Google C++ Testing and Mocking Framework (Google Test)
|
||||
|
||||
// IWYU pragma: private, include "gtest/gtest.h"
|
||||
// IWYU pragma: friend gtest/.*
|
||||
// IWYU pragma: friend gmock/.*
|
||||
|
||||
//
|
||||
// GOOGLETEST_CM0001 DO NOT DELETE
|
||||
#ifndef GOOGLETEST_INCLUDE_GTEST_GTEST_PARAM_TEST_H_
|
||||
#define GOOGLETEST_INCLUDE_GTEST_GTEST_PARAM_TEST_H_
|
||||
|
||||
|
|
@ -356,7 +353,9 @@ internal::ValueArray<T...> Values(T... v) {
|
|||
// }
|
||||
// INSTANTIATE_TEST_SUITE_P(BoolSequence, FlagDependentTest, Bool());
|
||||
//
|
||||
inline internal::ParamGenerator<bool> Bool() { return Values(false, true); }
|
||||
inline internal::ParamGenerator<bool> Bool() {
|
||||
return Values(false, true);
|
||||
}
|
||||
|
||||
// Combine() allows the user to combine two or more sequences to produce
|
||||
// values of a Cartesian product of those sequences' elements.
|
||||
|
|
@ -429,11 +428,8 @@ internal::CartesianProductHolder<Generator...> Combine(const Generator&... g) {
|
|||
return 0; \
|
||||
} \
|
||||
static int gtest_registering_dummy_ GTEST_ATTRIBUTE_UNUSED_; \
|
||||
GTEST_TEST_CLASS_NAME_(test_suite_name, test_name) \
|
||||
(const GTEST_TEST_CLASS_NAME_(test_suite_name, test_name) &) = delete; \
|
||||
GTEST_TEST_CLASS_NAME_(test_suite_name, test_name) & operator=( \
|
||||
const GTEST_TEST_CLASS_NAME_(test_suite_name, \
|
||||
test_name) &) = delete; /* NOLINT */ \
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(GTEST_TEST_CLASS_NAME_(test_suite_name, \
|
||||
test_name)); \
|
||||
}; \
|
||||
int GTEST_TEST_CLASS_NAME_(test_suite_name, \
|
||||
test_name)::gtest_registering_dummy_ = \
|
||||
|
|
@ -457,42 +453,43 @@ internal::CartesianProductHolder<Generator...> Combine(const Generator&... g) {
|
|||
#define GTEST_GET_FIRST_(first, ...) first
|
||||
#define GTEST_GET_SECOND_(first, second, ...) second
|
||||
|
||||
#define INSTANTIATE_TEST_SUITE_P(prefix, test_suite_name, ...) \
|
||||
static ::testing::internal::ParamGenerator<test_suite_name::ParamType> \
|
||||
gtest_##prefix##test_suite_name##_EvalGenerator_() { \
|
||||
return GTEST_EXPAND_(GTEST_GET_FIRST_(__VA_ARGS__, DUMMY_PARAM_)); \
|
||||
} \
|
||||
static ::std::string gtest_##prefix##test_suite_name##_EvalGenerateName_( \
|
||||
const ::testing::TestParamInfo<test_suite_name::ParamType>& info) { \
|
||||
if (::testing::internal::AlwaysFalse()) { \
|
||||
::testing::internal::TestNotEmpty(GTEST_EXPAND_(GTEST_GET_SECOND_( \
|
||||
__VA_ARGS__, \
|
||||
::testing::internal::DefaultParamName<test_suite_name::ParamType>, \
|
||||
DUMMY_PARAM_))); \
|
||||
auto t = std::make_tuple(__VA_ARGS__); \
|
||||
static_assert(std::tuple_size<decltype(t)>::value <= 2, \
|
||||
"Too Many Args!"); \
|
||||
} \
|
||||
return ((GTEST_EXPAND_(GTEST_GET_SECOND_( \
|
||||
__VA_ARGS__, \
|
||||
::testing::internal::DefaultParamName<test_suite_name::ParamType>, \
|
||||
DUMMY_PARAM_))))(info); \
|
||||
} \
|
||||
static int gtest_##prefix##test_suite_name##_dummy_ \
|
||||
GTEST_ATTRIBUTE_UNUSED_ = \
|
||||
::testing::UnitTest::GetInstance() \
|
||||
->parameterized_test_registry() \
|
||||
.GetTestSuitePatternHolder<test_suite_name>( \
|
||||
GTEST_STRINGIFY_(test_suite_name), \
|
||||
::testing::internal::CodeLocation(__FILE__, __LINE__)) \
|
||||
->AddTestSuiteInstantiation( \
|
||||
GTEST_STRINGIFY_(prefix), \
|
||||
>est_##prefix##test_suite_name##_EvalGenerator_, \
|
||||
>est_##prefix##test_suite_name##_EvalGenerateName_, \
|
||||
#define INSTANTIATE_TEST_SUITE_P(prefix, test_suite_name, ...) \
|
||||
static ::testing::internal::ParamGenerator<test_suite_name::ParamType> \
|
||||
gtest_##prefix##test_suite_name##_EvalGenerator_() { \
|
||||
return GTEST_EXPAND_(GTEST_GET_FIRST_(__VA_ARGS__, DUMMY_PARAM_)); \
|
||||
} \
|
||||
static ::std::string gtest_##prefix##test_suite_name##_EvalGenerateName_( \
|
||||
const ::testing::TestParamInfo<test_suite_name::ParamType>& info) { \
|
||||
if (::testing::internal::AlwaysFalse()) { \
|
||||
::testing::internal::TestNotEmpty(GTEST_EXPAND_(GTEST_GET_SECOND_( \
|
||||
__VA_ARGS__, \
|
||||
::testing::internal::DefaultParamName<test_suite_name::ParamType>, \
|
||||
DUMMY_PARAM_))); \
|
||||
auto t = std::make_tuple(__VA_ARGS__); \
|
||||
static_assert(std::tuple_size<decltype(t)>::value <= 2, \
|
||||
"Too Many Args!"); \
|
||||
} \
|
||||
return ((GTEST_EXPAND_(GTEST_GET_SECOND_( \
|
||||
__VA_ARGS__, \
|
||||
::testing::internal::DefaultParamName<test_suite_name::ParamType>, \
|
||||
DUMMY_PARAM_))))(info); \
|
||||
} \
|
||||
static int gtest_##prefix##test_suite_name##_dummy_ \
|
||||
GTEST_ATTRIBUTE_UNUSED_ = \
|
||||
::testing::UnitTest::GetInstance() \
|
||||
->parameterized_test_registry() \
|
||||
.GetTestSuitePatternHolder<test_suite_name>( \
|
||||
GTEST_STRINGIFY_(test_suite_name), \
|
||||
::testing::internal::CodeLocation(__FILE__, __LINE__)) \
|
||||
->AddTestSuiteInstantiation( \
|
||||
GTEST_STRINGIFY_(prefix), \
|
||||
>est_##prefix##test_suite_name##_EvalGenerator_, \
|
||||
>est_##prefix##test_suite_name##_EvalGenerateName_, \
|
||||
__FILE__, __LINE__)
|
||||
|
||||
|
||||
// Allow Marking a Parameterized test class as not needing to be instantiated.
|
||||
#define GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(T) \
|
||||
#define GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(T) \
|
||||
namespace gtest_do_not_use_outside_namespace_scope {} \
|
||||
static const ::testing::internal::MarkAsIgnored gtest_allow_ignore_##T( \
|
||||
GTEST_STRINGIFY_(T))
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@
|
|||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
// Google Test - The Google C++ Testing and Mocking Framework
|
||||
//
|
||||
// This file implements a universal value printer that can print a
|
||||
|
|
@ -94,9 +95,7 @@
|
|||
// being defined as many user-defined container types don't have
|
||||
// value_type.
|
||||
|
||||
// IWYU pragma: private, include "gtest/gtest.h"
|
||||
// IWYU pragma: friend gtest/.*
|
||||
// IWYU pragma: friend gmock/.*
|
||||
// GOOGLETEST_CM0001 DO NOT DELETE
|
||||
|
||||
#ifndef GOOGLETEST_INCLUDE_GTEST_GTEST_PRINTERS_H_
|
||||
#define GOOGLETEST_INCLUDE_GTEST_GTEST_PRINTERS_H_
|
||||
|
|
@ -258,10 +257,12 @@ struct ConvertibleToStringViewPrinter {
|
|||
#endif
|
||||
};
|
||||
|
||||
|
||||
// Prints the given number of bytes in the given object to the given
|
||||
// ostream.
|
||||
GTEST_API_ void PrintBytesInObjectTo(const unsigned char* obj_bytes,
|
||||
size_t count, ::std::ostream* os);
|
||||
size_t count,
|
||||
::std::ostream* os);
|
||||
struct RawBytesPrinter {
|
||||
// SFINAE on `sizeof` to make sure we have a complete type.
|
||||
template <typename T, size_t = sizeof(T)>
|
||||
|
|
@ -359,7 +360,7 @@ GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(char);
|
|||
GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(const char);
|
||||
GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(wchar_t);
|
||||
GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(const wchar_t);
|
||||
#ifdef __cpp_lib_char8_t
|
||||
#ifdef __cpp_char8_t
|
||||
GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(char8_t);
|
||||
GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(const char8_t);
|
||||
#endif
|
||||
|
|
@ -374,12 +375,12 @@ GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(const char32_t);
|
|||
// to point to a NUL-terminated string, and thus can print it as a string.
|
||||
|
||||
#define GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(CharType, OtherStringType) \
|
||||
template <> \
|
||||
class FormatForComparison<CharType*, OtherStringType> { \
|
||||
public: \
|
||||
static ::std::string Format(CharType* value) { \
|
||||
return ::testing::PrintToString(value); \
|
||||
} \
|
||||
template <> \
|
||||
class FormatForComparison<CharType*, OtherStringType> { \
|
||||
public: \
|
||||
static ::std::string Format(CharType* value) { \
|
||||
return ::testing::PrintToString(value); \
|
||||
} \
|
||||
}
|
||||
|
||||
GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(char, ::std::string);
|
||||
|
|
@ -409,8 +410,8 @@ GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(const wchar_t, ::std::wstring);
|
|||
//
|
||||
// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
|
||||
template <typename T1, typename T2>
|
||||
std::string FormatForComparisonFailureMessage(const T1& value,
|
||||
const T2& /* other_operand */) {
|
||||
std::string FormatForComparisonFailureMessage(
|
||||
const T1& value, const T2& /* other_operand */) {
|
||||
return FormatForComparison<T1, T2>::Format(value);
|
||||
}
|
||||
|
||||
|
|
@ -478,12 +479,6 @@ inline void PrintTo(char8_t c, ::std::ostream* os) {
|
|||
}
|
||||
#endif
|
||||
|
||||
// gcc/clang __{u,}int128_t
|
||||
#if defined(__SIZEOF_INT128__)
|
||||
GTEST_API_ void PrintTo(__uint128_t v, ::std::ostream* os);
|
||||
GTEST_API_ void PrintTo(__int128_t v, ::std::ostream* os);
|
||||
#endif // __SIZEOF_INT128__
|
||||
|
||||
// Overloads for C strings.
|
||||
GTEST_API_ void PrintTo(const char* s, ::std::ostream* os);
|
||||
inline void PrintTo(char* s, ::std::ostream* os) {
|
||||
|
|
@ -550,7 +545,7 @@ void PrintRawArrayTo(const T a[], size_t count, ::std::ostream* os) {
|
|||
}
|
||||
|
||||
// Overloads for ::std::string.
|
||||
GTEST_API_ void PrintStringTo(const ::std::string& s, ::std::ostream* os);
|
||||
GTEST_API_ void PrintStringTo(const ::std::string&s, ::std::ostream* os);
|
||||
inline void PrintTo(const ::std::string& s, ::std::ostream* os) {
|
||||
PrintStringTo(s, os);
|
||||
}
|
||||
|
|
@ -577,7 +572,7 @@ inline void PrintTo(const ::std::u32string& s, ::std::ostream* os) {
|
|||
|
||||
// Overloads for ::std::wstring.
|
||||
#if GTEST_HAS_STD_WSTRING
|
||||
GTEST_API_ void PrintWideStringTo(const ::std::wstring& s, ::std::ostream* os);
|
||||
GTEST_API_ void PrintWideStringTo(const ::std::wstring&s, ::std::ostream* os);
|
||||
inline void PrintTo(const ::std::wstring& s, ::std::ostream* os) {
|
||||
PrintWideStringTo(s, os);
|
||||
}
|
||||
|
|
@ -592,12 +587,6 @@ inline void PrintTo(internal::StringView sp, ::std::ostream* os) {
|
|||
|
||||
inline void PrintTo(std::nullptr_t, ::std::ostream* os) { *os << "(nullptr)"; }
|
||||
|
||||
#if GTEST_HAS_RTTI
|
||||
inline void PrintTo(const std::type_info& info, std::ostream* os) {
|
||||
*os << internal::GetTypeName(info);
|
||||
}
|
||||
#endif // GTEST_HAS_RTTI
|
||||
|
||||
template <typename T>
|
||||
void PrintTo(std::reference_wrapper<T> ref, ::std::ostream* os) {
|
||||
UniversalPrinter<T&>::Print(ref.get(), os);
|
||||
|
|
@ -755,14 +744,6 @@ class UniversalPrinter<Optional<T>> {
|
|||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
class UniversalPrinter<decltype(Nullopt())> {
|
||||
public:
|
||||
static void Print(decltype(Nullopt()), ::std::ostream* os) {
|
||||
*os << "(nullopt)";
|
||||
}
|
||||
};
|
||||
|
||||
#endif // GTEST_INTERNAL_HAS_OPTIONAL
|
||||
|
||||
#if GTEST_INTERNAL_HAS_VARIANT
|
||||
|
|
@ -821,8 +802,8 @@ void UniversalPrintArray(const T* begin, size_t len, ::std::ostream* os) {
|
|||
}
|
||||
}
|
||||
// This overload prints a (const) char array compactly.
|
||||
GTEST_API_ void UniversalPrintArray(const char* begin, size_t len,
|
||||
::std::ostream* os);
|
||||
GTEST_API_ void UniversalPrintArray(
|
||||
const char* begin, size_t len, ::std::ostream* os);
|
||||
|
||||
#ifdef __cpp_char8_t
|
||||
// This overload prints a (const) char8_t array compactly.
|
||||
|
|
@ -839,8 +820,8 @@ GTEST_API_ void UniversalPrintArray(const char32_t* begin, size_t len,
|
|||
::std::ostream* os);
|
||||
|
||||
// This overload prints a (const) wchar_t array compactly.
|
||||
GTEST_API_ void UniversalPrintArray(const wchar_t* begin, size_t len,
|
||||
::std::ostream* os);
|
||||
GTEST_API_ void UniversalPrintArray(
|
||||
const wchar_t* begin, size_t len, ::std::ostream* os);
|
||||
|
||||
// Implements printing an array type T[N].
|
||||
template <typename T, size_t N>
|
||||
|
|
@ -999,10 +980,10 @@ void UniversalPrint(const T& value, ::std::ostream* os) {
|
|||
UniversalPrinter<T1>::Print(value, os);
|
||||
}
|
||||
|
||||
typedef ::std::vector<::std::string> Strings;
|
||||
typedef ::std::vector< ::std::string> Strings;
|
||||
|
||||
// Tersely prints the first N fields of a tuple to a string vector,
|
||||
// one element for each field.
|
||||
// Tersely prints the first N fields of a tuple to a string vector,
|
||||
// one element for each field.
|
||||
template <typename Tuple>
|
||||
void TersePrintPrefixToStrings(const Tuple&, std::integral_constant<size_t, 0>,
|
||||
Strings*) {}
|
||||
|
|
|
|||
|
|
@ -27,9 +27,12 @@
|
|||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
//
|
||||
// Utilities for testing Google Test itself and code that uses Google Test
|
||||
// (e.g. frameworks built on top of Google Test).
|
||||
|
||||
// GOOGLETEST_CM0004 DO NOT DELETE
|
||||
|
||||
#ifndef GOOGLETEST_INCLUDE_GTEST_GTEST_SPI_H_
|
||||
#define GOOGLETEST_INCLUDE_GTEST_GTEST_SPI_H_
|
||||
|
||||
|
|
@ -85,10 +88,7 @@ class GTEST_API_ ScopedFakeTestPartResultReporter
|
|||
TestPartResultReporterInterface* old_reporter_;
|
||||
TestPartResultArray* const result_;
|
||||
|
||||
ScopedFakeTestPartResultReporter(const ScopedFakeTestPartResultReporter&) =
|
||||
delete;
|
||||
ScopedFakeTestPartResultReporter& operator=(
|
||||
const ScopedFakeTestPartResultReporter&) = delete;
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(ScopedFakeTestPartResultReporter);
|
||||
};
|
||||
|
||||
namespace internal {
|
||||
|
|
@ -104,14 +104,12 @@ class GTEST_API_ SingleFailureChecker {
|
|||
SingleFailureChecker(const TestPartResultArray* results,
|
||||
TestPartResult::Type type, const std::string& substr);
|
||||
~SingleFailureChecker();
|
||||
|
||||
private:
|
||||
const TestPartResultArray* const results_;
|
||||
const TestPartResult::Type type_;
|
||||
const std::string substr_;
|
||||
|
||||
SingleFailureChecker(const SingleFailureChecker&) = delete;
|
||||
SingleFailureChecker& operator=(const SingleFailureChecker&) = delete;
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(SingleFailureChecker);
|
||||
};
|
||||
|
||||
} // namespace internal
|
||||
|
|
@ -121,8 +119,7 @@ class GTEST_API_ SingleFailureChecker {
|
|||
GTEST_DISABLE_MSC_WARNINGS_POP_() // 4251
|
||||
|
||||
// A set of macros for testing Google Test assertions or code that's expected
|
||||
// to generate Google Test fatal failures (e.g. a failure from an ASSERT_EQ, but
|
||||
// not a non-fatal failure, as from EXPECT_EQ). It verifies that the given
|
||||
// to generate Google Test fatal failures. It verifies that the given
|
||||
// statement will cause exactly one fatal Google Test failure with 'substr'
|
||||
// being part of the failure message.
|
||||
//
|
||||
|
|
@ -144,46 +141,44 @@ GTEST_DISABLE_MSC_WARNINGS_POP_() // 4251
|
|||
// helper macro, due to some peculiarity in how the preprocessor
|
||||
// works. The AcceptsMacroThatExpandsToUnprotectedComma test in
|
||||
// gtest_unittest.cc will fail to compile if we do that.
|
||||
#define EXPECT_FATAL_FAILURE(statement, substr) \
|
||||
do { \
|
||||
class GTestExpectFatalFailureHelper { \
|
||||
public: \
|
||||
static void Execute() { statement; } \
|
||||
}; \
|
||||
::testing::TestPartResultArray gtest_failures; \
|
||||
::testing::internal::SingleFailureChecker gtest_checker( \
|
||||
>est_failures, ::testing::TestPartResult::kFatalFailure, (substr)); \
|
||||
{ \
|
||||
::testing::ScopedFakeTestPartResultReporter gtest_reporter( \
|
||||
::testing::ScopedFakeTestPartResultReporter:: \
|
||||
INTERCEPT_ONLY_CURRENT_THREAD, \
|
||||
>est_failures); \
|
||||
GTestExpectFatalFailureHelper::Execute(); \
|
||||
} \
|
||||
#define EXPECT_FATAL_FAILURE(statement, substr) \
|
||||
do { \
|
||||
class GTestExpectFatalFailureHelper {\
|
||||
public:\
|
||||
static void Execute() { statement; }\
|
||||
};\
|
||||
::testing::TestPartResultArray gtest_failures;\
|
||||
::testing::internal::SingleFailureChecker gtest_checker(\
|
||||
>est_failures, ::testing::TestPartResult::kFatalFailure, (substr));\
|
||||
{\
|
||||
::testing::ScopedFakeTestPartResultReporter gtest_reporter(\
|
||||
::testing::ScopedFakeTestPartResultReporter:: \
|
||||
INTERCEPT_ONLY_CURRENT_THREAD, >est_failures);\
|
||||
GTestExpectFatalFailureHelper::Execute();\
|
||||
}\
|
||||
} while (::testing::internal::AlwaysFalse())
|
||||
|
||||
#define EXPECT_FATAL_FAILURE_ON_ALL_THREADS(statement, substr) \
|
||||
do { \
|
||||
class GTestExpectFatalFailureHelper { \
|
||||
public: \
|
||||
static void Execute() { statement; } \
|
||||
}; \
|
||||
::testing::TestPartResultArray gtest_failures; \
|
||||
::testing::internal::SingleFailureChecker gtest_checker( \
|
||||
>est_failures, ::testing::TestPartResult::kFatalFailure, (substr)); \
|
||||
{ \
|
||||
::testing::ScopedFakeTestPartResultReporter gtest_reporter( \
|
||||
::testing::ScopedFakeTestPartResultReporter::INTERCEPT_ALL_THREADS, \
|
||||
>est_failures); \
|
||||
GTestExpectFatalFailureHelper::Execute(); \
|
||||
} \
|
||||
#define EXPECT_FATAL_FAILURE_ON_ALL_THREADS(statement, substr) \
|
||||
do { \
|
||||
class GTestExpectFatalFailureHelper {\
|
||||
public:\
|
||||
static void Execute() { statement; }\
|
||||
};\
|
||||
::testing::TestPartResultArray gtest_failures;\
|
||||
::testing::internal::SingleFailureChecker gtest_checker(\
|
||||
>est_failures, ::testing::TestPartResult::kFatalFailure, (substr));\
|
||||
{\
|
||||
::testing::ScopedFakeTestPartResultReporter gtest_reporter(\
|
||||
::testing::ScopedFakeTestPartResultReporter:: \
|
||||
INTERCEPT_ALL_THREADS, >est_failures);\
|
||||
GTestExpectFatalFailureHelper::Execute();\
|
||||
}\
|
||||
} while (::testing::internal::AlwaysFalse())
|
||||
|
||||
// A macro for testing Google Test assertions or code that's expected to
|
||||
// generate Google Test non-fatal failures (e.g. a failure from an EXPECT_EQ,
|
||||
// but not from an ASSERT_EQ). It asserts that the given statement will cause
|
||||
// exactly one non-fatal Google Test failure with 'substr' being part of the
|
||||
// failure message.
|
||||
// generate Google Test non-fatal failures. It asserts that the given
|
||||
// statement will cause exactly one non-fatal Google Test failure with 'substr'
|
||||
// being part of the failure message.
|
||||
//
|
||||
// There are two different versions of this macro. EXPECT_NONFATAL_FAILURE only
|
||||
// affects and considers failures generated in the current thread and
|
||||
|
|
@ -212,37 +207,32 @@ GTEST_DISABLE_MSC_WARNINGS_POP_() // 4251
|
|||
// instead of
|
||||
// GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement)
|
||||
// to avoid an MSVC warning on unreachable code.
|
||||
#define EXPECT_NONFATAL_FAILURE(statement, substr) \
|
||||
do { \
|
||||
::testing::TestPartResultArray gtest_failures; \
|
||||
::testing::internal::SingleFailureChecker gtest_checker( \
|
||||
#define EXPECT_NONFATAL_FAILURE(statement, substr) \
|
||||
do {\
|
||||
::testing::TestPartResultArray gtest_failures;\
|
||||
::testing::internal::SingleFailureChecker gtest_checker(\
|
||||
>est_failures, ::testing::TestPartResult::kNonFatalFailure, \
|
||||
(substr)); \
|
||||
{ \
|
||||
::testing::ScopedFakeTestPartResultReporter gtest_reporter( \
|
||||
::testing::ScopedFakeTestPartResultReporter:: \
|
||||
INTERCEPT_ONLY_CURRENT_THREAD, \
|
||||
>est_failures); \
|
||||
if (::testing::internal::AlwaysTrue()) { \
|
||||
statement; \
|
||||
} \
|
||||
} \
|
||||
(substr));\
|
||||
{\
|
||||
::testing::ScopedFakeTestPartResultReporter gtest_reporter(\
|
||||
::testing::ScopedFakeTestPartResultReporter:: \
|
||||
INTERCEPT_ONLY_CURRENT_THREAD, >est_failures);\
|
||||
if (::testing::internal::AlwaysTrue()) { statement; }\
|
||||
}\
|
||||
} while (::testing::internal::AlwaysFalse())
|
||||
|
||||
#define EXPECT_NONFATAL_FAILURE_ON_ALL_THREADS(statement, substr) \
|
||||
do { \
|
||||
::testing::TestPartResultArray gtest_failures; \
|
||||
::testing::internal::SingleFailureChecker gtest_checker( \
|
||||
>est_failures, ::testing::TestPartResult::kNonFatalFailure, \
|
||||
(substr)); \
|
||||
{ \
|
||||
::testing::ScopedFakeTestPartResultReporter gtest_reporter( \
|
||||
#define EXPECT_NONFATAL_FAILURE_ON_ALL_THREADS(statement, substr) \
|
||||
do {\
|
||||
::testing::TestPartResultArray gtest_failures;\
|
||||
::testing::internal::SingleFailureChecker gtest_checker(\
|
||||
>est_failures, ::testing::TestPartResult::kNonFatalFailure, \
|
||||
(substr));\
|
||||
{\
|
||||
::testing::ScopedFakeTestPartResultReporter gtest_reporter(\
|
||||
::testing::ScopedFakeTestPartResultReporter::INTERCEPT_ALL_THREADS, \
|
||||
>est_failures); \
|
||||
if (::testing::internal::AlwaysTrue()) { \
|
||||
statement; \
|
||||
} \
|
||||
} \
|
||||
>est_failures);\
|
||||
if (::testing::internal::AlwaysTrue()) { statement; }\
|
||||
}\
|
||||
} while (::testing::internal::AlwaysFalse())
|
||||
|
||||
#endif // GOOGLETEST_INCLUDE_GTEST_GTEST_SPI_H_
|
||||
|
|
|
|||
|
|
@ -26,17 +26,14 @@
|
|||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// IWYU pragma: private, include "gtest/gtest.h"
|
||||
// IWYU pragma: friend gtest/.*
|
||||
// IWYU pragma: friend gmock/.*
|
||||
//
|
||||
// GOOGLETEST_CM0001 DO NOT DELETE
|
||||
|
||||
#ifndef GOOGLETEST_INCLUDE_GTEST_GTEST_TEST_PART_H_
|
||||
#define GOOGLETEST_INCLUDE_GTEST_GTEST_TEST_PART_H_
|
||||
|
||||
#include <iosfwd>
|
||||
#include <vector>
|
||||
|
||||
#include "gtest/internal/gtest-internal.h"
|
||||
#include "gtest/internal/gtest-string.h"
|
||||
|
||||
|
|
@ -145,8 +142,7 @@ class GTEST_API_ TestPartResultArray {
|
|||
private:
|
||||
std::vector<TestPartResult> array_;
|
||||
|
||||
TestPartResultArray(const TestPartResultArray&) = delete;
|
||||
TestPartResultArray& operator=(const TestPartResultArray&) = delete;
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(TestPartResultArray);
|
||||
};
|
||||
|
||||
// This interface knows how to report a test part result.
|
||||
|
|
@ -172,13 +168,11 @@ class GTEST_API_ HasNewFatalFailureHelper
|
|||
~HasNewFatalFailureHelper() override;
|
||||
void ReportTestPartResult(const TestPartResult& result) override;
|
||||
bool has_new_fatal_failure() const { return has_new_fatal_failure_; }
|
||||
|
||||
private:
|
||||
bool has_new_fatal_failure_;
|
||||
TestPartResultReporterInterface* original_reporter_;
|
||||
|
||||
HasNewFatalFailureHelper(const HasNewFatalFailureHelper&) = delete;
|
||||
HasNewFatalFailureHelper& operator=(const HasNewFatalFailureHelper&) = delete;
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(HasNewFatalFailureHelper);
|
||||
};
|
||||
|
||||
} // namespace internal
|
||||
|
|
|
|||
|
|
@ -27,9 +27,7 @@
|
|||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// IWYU pragma: private, include "gtest/gtest.h"
|
||||
// IWYU pragma: friend gtest/.*
|
||||
// IWYU pragma: friend gmock/.*
|
||||
// GOOGLETEST_CM0001 DO NOT DELETE
|
||||
|
||||
#ifndef GOOGLETEST_INCLUDE_GTEST_GTEST_TYPED_TEST_H_
|
||||
#define GOOGLETEST_INCLUDE_GTEST_GTEST_TYPED_TEST_H_
|
||||
|
|
@ -192,7 +190,7 @@ INSTANTIATE_TYPED_TEST_SUITE_P(My, FooTest, MyTypes);
|
|||
typedef ::testing::internal::GenerateTypeList<Types>::type \
|
||||
GTEST_TYPE_PARAMS_(CaseName); \
|
||||
typedef ::testing::internal::NameGeneratorSelector<__VA_ARGS__>::type \
|
||||
GTEST_NAME_GENERATOR_(CaseName)
|
||||
GTEST_NAME_GENERATOR_(CaseName)
|
||||
|
||||
#define TYPED_TEST(CaseName, TestName) \
|
||||
static_assert(sizeof(GTEST_STRINGIFY_(TestName)) > 1, \
|
||||
|
|
@ -258,7 +256,7 @@ INSTANTIATE_TYPED_TEST_SUITE_P(My, FooTest, MyTypes);
|
|||
// #included in multiple translation units linked together.
|
||||
#define TYPED_TEST_SUITE_P(SuiteName) \
|
||||
static ::testing::internal::TypedTestSuitePState \
|
||||
GTEST_TYPED_TEST_SUITE_P_STATE_(SuiteName)
|
||||
GTEST_TYPED_TEST_SUITE_P_STATE_(SuiteName)
|
||||
|
||||
// Legacy API is deprecated but still available
|
||||
#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
|
||||
|
|
@ -303,21 +301,21 @@ INSTANTIATE_TYPED_TEST_SUITE_P(My, FooTest, MyTypes);
|
|||
REGISTER_TYPED_TEST_SUITE_P
|
||||
#endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_
|
||||
|
||||
#define INSTANTIATE_TYPED_TEST_SUITE_P(Prefix, SuiteName, Types, ...) \
|
||||
static_assert(sizeof(GTEST_STRINGIFY_(Prefix)) > 1, \
|
||||
"test-suit-prefix must not be empty"); \
|
||||
static bool gtest_##Prefix##_##SuiteName GTEST_ATTRIBUTE_UNUSED_ = \
|
||||
::testing::internal::TypeParameterizedTestSuite< \
|
||||
SuiteName, GTEST_SUITE_NAMESPACE_(SuiteName)::gtest_AllTests_, \
|
||||
::testing::internal::GenerateTypeList<Types>::type>:: \
|
||||
Register(GTEST_STRINGIFY_(Prefix), \
|
||||
::testing::internal::CodeLocation(__FILE__, __LINE__), \
|
||||
>EST_TYPED_TEST_SUITE_P_STATE_(SuiteName), \
|
||||
GTEST_STRINGIFY_(SuiteName), \
|
||||
GTEST_REGISTERED_TEST_NAMES_(SuiteName), \
|
||||
::testing::internal::GenerateNames< \
|
||||
::testing::internal::NameGeneratorSelector< \
|
||||
__VA_ARGS__>::type, \
|
||||
#define INSTANTIATE_TYPED_TEST_SUITE_P(Prefix, SuiteName, Types, ...) \
|
||||
static_assert(sizeof(GTEST_STRINGIFY_(Prefix)) > 1, \
|
||||
"test-suit-prefix must not be empty"); \
|
||||
static bool gtest_##Prefix##_##SuiteName GTEST_ATTRIBUTE_UNUSED_ = \
|
||||
::testing::internal::TypeParameterizedTestSuite< \
|
||||
SuiteName, GTEST_SUITE_NAMESPACE_(SuiteName)::gtest_AllTests_, \
|
||||
::testing::internal::GenerateTypeList<Types>::type>:: \
|
||||
Register(GTEST_STRINGIFY_(Prefix), \
|
||||
::testing::internal::CodeLocation(__FILE__, __LINE__), \
|
||||
>EST_TYPED_TEST_SUITE_P_STATE_(SuiteName), \
|
||||
GTEST_STRINGIFY_(SuiteName), \
|
||||
GTEST_REGISTERED_TEST_NAMES_(SuiteName), \
|
||||
::testing::internal::GenerateNames< \
|
||||
::testing::internal::NameGeneratorSelector< \
|
||||
__VA_ARGS__>::type, \
|
||||
::testing::internal::GenerateTypeList<Types>::type>())
|
||||
|
||||
// Legacy API is deprecated but still available
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@
|
|||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
//
|
||||
// The Google C++ Testing and Mocking Framework (Google Test)
|
||||
//
|
||||
// This header file defines the public API for Google Test. It should be
|
||||
|
|
@ -46,6 +47,8 @@
|
|||
// registration from Barthelemy Dagenais' (barthelemy@prologique.com)
|
||||
// easyUnit framework.
|
||||
|
||||
// GOOGLETEST_CM0001 DO NOT DELETE
|
||||
|
||||
#ifndef GOOGLETEST_INCLUDE_GTEST_GTEST_H_
|
||||
#define GOOGLETEST_INCLUDE_GTEST_GTEST_H_
|
||||
|
||||
|
|
@ -56,22 +59,31 @@
|
|||
#include <type_traits>
|
||||
#include <vector>
|
||||
|
||||
#include "gtest/gtest-assertion-result.h"
|
||||
#include "gtest/internal/gtest-internal.h"
|
||||
#include "gtest/internal/gtest-string.h"
|
||||
#include "gtest/gtest-death-test.h"
|
||||
#include "gtest/gtest-matchers.h"
|
||||
#include "gtest/gtest-message.h"
|
||||
#include "gtest/gtest-param-test.h"
|
||||
#include "gtest/gtest-printers.h"
|
||||
#include "gtest/gtest_prod.h"
|
||||
#include "gtest/gtest-test-part.h"
|
||||
#include "gtest/gtest-typed-test.h"
|
||||
#include "gtest/gtest_pred_impl.h"
|
||||
#include "gtest/gtest_prod.h"
|
||||
#include "gtest/internal/gtest-internal.h"
|
||||
#include "gtest/internal/gtest-string.h"
|
||||
|
||||
GTEST_DISABLE_MSC_WARNINGS_PUSH_(4251 \
|
||||
/* class A needs to have dll-interface to be used by clients of class B */)
|
||||
|
||||
namespace testing {
|
||||
|
||||
// Silence C4100 (unreferenced formal parameter) and 4805
|
||||
// unsafe mix of type 'const int' and type 'const bool'
|
||||
#ifdef _MSC_VER
|
||||
# pragma warning(push)
|
||||
# pragma warning(disable:4805)
|
||||
# pragma warning(disable:4100)
|
||||
#endif
|
||||
|
||||
|
||||
// Declares the flags.
|
||||
|
||||
// This flag temporary enables the disabled tests.
|
||||
|
|
@ -126,12 +138,6 @@ GTEST_DECLARE_int32_(random_seed);
|
|||
// is 1. If the value is -1 the tests are repeating forever.
|
||||
GTEST_DECLARE_int32_(repeat);
|
||||
|
||||
// This flag controls whether Google Test Environments are recreated for each
|
||||
// repeat of the tests. The default value is true. If set to false the global
|
||||
// test Environment objects are only set up once, for the first iteration, and
|
||||
// only torn down once, for the last.
|
||||
GTEST_DECLARE_bool_(recreate_environments_when_repeating);
|
||||
|
||||
// This flag controls whether Google Test includes Google Test internal
|
||||
// stack frames in failure stack traces.
|
||||
GTEST_DECLARE_bool_(show_internal_stack_frames);
|
||||
|
|
@ -157,16 +163,6 @@ GTEST_DECLARE_string_(stream_result_to);
|
|||
GTEST_DECLARE_string_(flagfile);
|
||||
#endif // GTEST_USE_OWN_FLAGFILE_FLAG_
|
||||
|
||||
namespace testing {
|
||||
|
||||
// Silence C4100 (unreferenced formal parameter) and 4805
|
||||
// unsafe mix of type 'const int' and type 'const bool'
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 4805)
|
||||
#pragma warning(disable : 4100)
|
||||
#endif
|
||||
|
||||
// The upper limit for valid stack trace depths.
|
||||
const int kMaxStackTraceDepth = 100;
|
||||
|
||||
|
|
@ -205,6 +201,193 @@ using TestCase = TestSuite;
|
|||
class TestInfo;
|
||||
class UnitTest;
|
||||
|
||||
// A class for indicating whether an assertion was successful. When
|
||||
// the assertion wasn't successful, the AssertionResult object
|
||||
// remembers a non-empty message that describes how it failed.
|
||||
//
|
||||
// To create an instance of this class, use one of the factory functions
|
||||
// (AssertionSuccess() and AssertionFailure()).
|
||||
//
|
||||
// This class is useful for two purposes:
|
||||
// 1. Defining predicate functions to be used with Boolean test assertions
|
||||
// EXPECT_TRUE/EXPECT_FALSE and their ASSERT_ counterparts
|
||||
// 2. Defining predicate-format functions to be
|
||||
// used with predicate assertions (ASSERT_PRED_FORMAT*, etc).
|
||||
//
|
||||
// For example, if you define IsEven predicate:
|
||||
//
|
||||
// testing::AssertionResult IsEven(int n) {
|
||||
// if ((n % 2) == 0)
|
||||
// return testing::AssertionSuccess();
|
||||
// else
|
||||
// return testing::AssertionFailure() << n << " is odd";
|
||||
// }
|
||||
//
|
||||
// Then the failed expectation EXPECT_TRUE(IsEven(Fib(5)))
|
||||
// will print the message
|
||||
//
|
||||
// Value of: IsEven(Fib(5))
|
||||
// Actual: false (5 is odd)
|
||||
// Expected: true
|
||||
//
|
||||
// instead of a more opaque
|
||||
//
|
||||
// Value of: IsEven(Fib(5))
|
||||
// Actual: false
|
||||
// Expected: true
|
||||
//
|
||||
// in case IsEven is a simple Boolean predicate.
|
||||
//
|
||||
// If you expect your predicate to be reused and want to support informative
|
||||
// messages in EXPECT_FALSE and ASSERT_FALSE (negative assertions show up
|
||||
// about half as often as positive ones in our tests), supply messages for
|
||||
// both success and failure cases:
|
||||
//
|
||||
// testing::AssertionResult IsEven(int n) {
|
||||
// if ((n % 2) == 0)
|
||||
// return testing::AssertionSuccess() << n << " is even";
|
||||
// else
|
||||
// return testing::AssertionFailure() << n << " is odd";
|
||||
// }
|
||||
//
|
||||
// Then a statement EXPECT_FALSE(IsEven(Fib(6))) will print
|
||||
//
|
||||
// Value of: IsEven(Fib(6))
|
||||
// Actual: true (8 is even)
|
||||
// Expected: false
|
||||
//
|
||||
// NB: Predicates that support negative Boolean assertions have reduced
|
||||
// performance in positive ones so be careful not to use them in tests
|
||||
// that have lots (tens of thousands) of positive Boolean assertions.
|
||||
//
|
||||
// To use this class with EXPECT_PRED_FORMAT assertions such as:
|
||||
//
|
||||
// // Verifies that Foo() returns an even number.
|
||||
// EXPECT_PRED_FORMAT1(IsEven, Foo());
|
||||
//
|
||||
// you need to define:
|
||||
//
|
||||
// testing::AssertionResult IsEven(const char* expr, int n) {
|
||||
// if ((n % 2) == 0)
|
||||
// return testing::AssertionSuccess();
|
||||
// else
|
||||
// return testing::AssertionFailure()
|
||||
// << "Expected: " << expr << " is even\n Actual: it's " << n;
|
||||
// }
|
||||
//
|
||||
// If Foo() returns 5, you will see the following message:
|
||||
//
|
||||
// Expected: Foo() is even
|
||||
// Actual: it's 5
|
||||
//
|
||||
class GTEST_API_ AssertionResult {
|
||||
public:
|
||||
// Copy constructor.
|
||||
// Used in EXPECT_TRUE/FALSE(assertion_result).
|
||||
AssertionResult(const AssertionResult& other);
|
||||
|
||||
// C4800 is a level 3 warning in Visual Studio 2015 and earlier.
|
||||
// This warning is not emitted in Visual Studio 2017.
|
||||
// This warning is off by default starting in Visual Studio 2019 but can be
|
||||
// enabled with command-line options.
|
||||
#if defined(_MSC_VER) && (_MSC_VER < 1910 || _MSC_VER >= 1920)
|
||||
GTEST_DISABLE_MSC_WARNINGS_PUSH_(4800 /* forcing value to bool */)
|
||||
#endif
|
||||
|
||||
// Used in the EXPECT_TRUE/FALSE(bool_expression).
|
||||
//
|
||||
// T must be contextually convertible to bool.
|
||||
//
|
||||
// The second parameter prevents this overload from being considered if
|
||||
// the argument is implicitly convertible to AssertionResult. In that case
|
||||
// we want AssertionResult's copy constructor to be used.
|
||||
template <typename T>
|
||||
explicit AssertionResult(
|
||||
const T& success,
|
||||
typename std::enable_if<
|
||||
!std::is_convertible<T, AssertionResult>::value>::type*
|
||||
/*enabler*/
|
||||
= nullptr)
|
||||
: success_(success) {}
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER < 1910 || _MSC_VER >= 1920)
|
||||
GTEST_DISABLE_MSC_WARNINGS_POP_()
|
||||
#endif
|
||||
|
||||
// Assignment operator.
|
||||
AssertionResult& operator=(AssertionResult other) {
|
||||
swap(other);
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Returns true if and only if the assertion succeeded.
|
||||
operator bool() const { return success_; } // NOLINT
|
||||
|
||||
// Returns the assertion's negation. Used with EXPECT/ASSERT_FALSE.
|
||||
AssertionResult operator!() const;
|
||||
|
||||
// Returns the text streamed into this AssertionResult. Test assertions
|
||||
// use it when they fail (i.e., the predicate's outcome doesn't match the
|
||||
// assertion's expectation). When nothing has been streamed into the
|
||||
// object, returns an empty string.
|
||||
const char* message() const {
|
||||
return message_.get() != nullptr ? message_->c_str() : "";
|
||||
}
|
||||
// Deprecated; please use message() instead.
|
||||
const char* failure_message() const { return message(); }
|
||||
|
||||
// Streams a custom failure message into this object.
|
||||
template <typename T> AssertionResult& operator<<(const T& value) {
|
||||
AppendMessage(Message() << value);
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Allows streaming basic output manipulators such as endl or flush into
|
||||
// this object.
|
||||
AssertionResult& operator<<(
|
||||
::std::ostream& (*basic_manipulator)(::std::ostream& stream)) {
|
||||
AppendMessage(Message() << basic_manipulator);
|
||||
return *this;
|
||||
}
|
||||
|
||||
private:
|
||||
// Appends the contents of message to message_.
|
||||
void AppendMessage(const Message& a_message) {
|
||||
if (message_.get() == nullptr) message_.reset(new ::std::string);
|
||||
message_->append(a_message.GetString().c_str());
|
||||
}
|
||||
|
||||
// Swap the contents of this AssertionResult with other.
|
||||
void swap(AssertionResult& other);
|
||||
|
||||
// Stores result of the assertion predicate.
|
||||
bool success_;
|
||||
// Stores the message describing the condition in case the expectation
|
||||
// construct is not satisfied with the predicate's outcome.
|
||||
// Referenced via a pointer to avoid taking too much stack frame space
|
||||
// with test assertions.
|
||||
std::unique_ptr< ::std::string> message_;
|
||||
};
|
||||
|
||||
// Makes a successful assertion result.
|
||||
GTEST_API_ AssertionResult AssertionSuccess();
|
||||
|
||||
// Makes a failed assertion result.
|
||||
GTEST_API_ AssertionResult AssertionFailure();
|
||||
|
||||
// Makes a failed assertion result with the given failure message.
|
||||
// Deprecated; use AssertionFailure() << msg.
|
||||
GTEST_API_ AssertionResult AssertionFailure(const Message& msg);
|
||||
|
||||
} // namespace testing
|
||||
|
||||
// Includes the auto-generated header that implements a family of generic
|
||||
// predicate assertion macros. This include comes late because it relies on
|
||||
// APIs declared above.
|
||||
#include "gtest/gtest_pred_impl.h"
|
||||
|
||||
namespace testing {
|
||||
|
||||
// The abstract class that all tests inherit from.
|
||||
//
|
||||
// In Google Test, a unit test program contains one or many TestSuites, and
|
||||
|
|
@ -339,8 +522,7 @@ class GTEST_API_ Test {
|
|||
virtual Setup_should_be_spelled_SetUp* Setup() { return nullptr; }
|
||||
|
||||
// We disallow copying Tests.
|
||||
Test(const Test&) = delete;
|
||||
Test& operator=(const Test&) = delete;
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(Test);
|
||||
};
|
||||
|
||||
typedef internal::TimeInMillis TimeInMillis;
|
||||
|
|
@ -354,17 +536,24 @@ class TestProperty {
|
|||
// C'tor. TestProperty does NOT have a default constructor.
|
||||
// Always use this constructor (with parameters) to create a
|
||||
// TestProperty object.
|
||||
TestProperty(const std::string& a_key, const std::string& a_value)
|
||||
: key_(a_key), value_(a_value) {}
|
||||
TestProperty(const std::string& a_key, const std::string& a_value) :
|
||||
key_(a_key), value_(a_value) {
|
||||
}
|
||||
|
||||
// Gets the user supplied key.
|
||||
const char* key() const { return key_.c_str(); }
|
||||
const char* key() const {
|
||||
return key_.c_str();
|
||||
}
|
||||
|
||||
// Gets the user supplied value.
|
||||
const char* value() const { return value_.c_str(); }
|
||||
const char* value() const {
|
||||
return value_.c_str();
|
||||
}
|
||||
|
||||
// Sets a new value, overriding the one supplied in the constructor.
|
||||
void SetValue(const std::string& new_value) { value_ = new_value; }
|
||||
void SetValue(const std::string& new_value) {
|
||||
value_ = new_value;
|
||||
}
|
||||
|
||||
private:
|
||||
// The key supplied by the user.
|
||||
|
|
@ -498,8 +687,7 @@ class GTEST_API_ TestResult {
|
|||
TimeInMillis elapsed_time_;
|
||||
|
||||
// We disallow copying TestResult.
|
||||
TestResult(const TestResult&) = delete;
|
||||
TestResult& operator=(const TestResult&) = delete;
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(TestResult);
|
||||
}; // class TestResult
|
||||
|
||||
// A TestInfo object stores the following information about a test:
|
||||
|
|
@ -623,8 +811,8 @@ class GTEST_API_ TestInfo {
|
|||
}
|
||||
|
||||
// These fields are immutable properties of the test.
|
||||
const std::string test_suite_name_; // test suite name
|
||||
const std::string name_; // Test name
|
||||
const std::string test_suite_name_; // test suite name
|
||||
const std::string name_; // Test name
|
||||
// Name of the parameter type, or NULL if this is not a typed or a
|
||||
// type-parameterized test.
|
||||
const std::unique_ptr<const ::std::string> type_param_;
|
||||
|
|
@ -645,8 +833,7 @@ class GTEST_API_ TestInfo {
|
|||
// test for the second time.
|
||||
TestResult result_;
|
||||
|
||||
TestInfo(const TestInfo&) = delete;
|
||||
TestInfo& operator=(const TestInfo&) = delete;
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(TestInfo);
|
||||
};
|
||||
|
||||
// A test suite, which consists of a vector of TestInfos.
|
||||
|
|
@ -754,7 +941,7 @@ class GTEST_API_ TestSuite {
|
|||
|
||||
// Adds a TestInfo to this test suite. Will delete the TestInfo upon
|
||||
// destruction of the TestSuite object.
|
||||
void AddTestInfo(TestInfo* test_info);
|
||||
void AddTestInfo(TestInfo * test_info);
|
||||
|
||||
// Clears the results of all tests in this test suite.
|
||||
void ClearResult();
|
||||
|
|
@ -855,8 +1042,7 @@ class GTEST_API_ TestSuite {
|
|||
TestResult ad_hoc_test_result_;
|
||||
|
||||
// We disallow copying TestSuites.
|
||||
TestSuite(const TestSuite&) = delete;
|
||||
TestSuite& operator=(const TestSuite&) = delete;
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(TestSuite);
|
||||
};
|
||||
|
||||
// An Environment object is capable of setting up and tearing down an
|
||||
|
|
@ -883,7 +1069,6 @@ class Environment {
|
|||
|
||||
// Override this to define how to tear down the environment.
|
||||
virtual void TearDown() {}
|
||||
|
||||
private:
|
||||
// If you see an error about overriding the following function or
|
||||
// about it being private, you have mis-spelled SetUp() as Setup().
|
||||
|
|
@ -935,9 +1120,6 @@ class TestEventListener {
|
|||
// Fired before the test starts.
|
||||
virtual void OnTestStart(const TestInfo& test_info) = 0;
|
||||
|
||||
// Fired when a test is disabled
|
||||
virtual void OnTestDisabled(const TestInfo& /*test_info*/) {}
|
||||
|
||||
// Fired after a failed assertion or a SUCCEED() invocation.
|
||||
// If you want to throw an exception from this function to skip to the next
|
||||
// TEST, it must be AssertionException defined above, or inherited from it.
|
||||
|
|
@ -961,7 +1143,8 @@ class TestEventListener {
|
|||
virtual void OnEnvironmentsTearDownEnd(const UnitTest& unit_test) = 0;
|
||||
|
||||
// Fired after each iteration of tests finishes.
|
||||
virtual void OnTestIterationEnd(const UnitTest& unit_test, int iteration) = 0;
|
||||
virtual void OnTestIterationEnd(const UnitTest& unit_test,
|
||||
int iteration) = 0;
|
||||
|
||||
// Fired after all test activities have ended.
|
||||
virtual void OnTestProgramEnd(const UnitTest& unit_test) = 0;
|
||||
|
|
@ -986,7 +1169,6 @@ class EmptyTestEventListener : public TestEventListener {
|
|||
#endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_
|
||||
|
||||
void OnTestStart(const TestInfo& /*test_info*/) override {}
|
||||
void OnTestDisabled(const TestInfo& /*test_info*/) override {}
|
||||
void OnTestPartResult(const TestPartResult& /*test_part_result*/) override {}
|
||||
void OnTestEnd(const TestInfo& /*test_info*/) override {}
|
||||
void OnTestSuiteEnd(const TestSuite& /*test_suite*/) override {}
|
||||
|
|
@ -1076,8 +1258,7 @@ class GTEST_API_ TestEventListeners {
|
|||
TestEventListener* default_xml_generator_;
|
||||
|
||||
// We disallow copying TestEventListeners.
|
||||
TestEventListeners(const TestEventListeners&) = delete;
|
||||
TestEventListeners& operator=(const TestEventListeners&) = delete;
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(TestEventListeners);
|
||||
};
|
||||
|
||||
// A UnitTest consists of a vector of TestSuites.
|
||||
|
|
@ -1120,7 +1301,8 @@ class GTEST_API_ UnitTest {
|
|||
|
||||
// Returns the TestInfo object for the test that's currently running,
|
||||
// or NULL if no test is running.
|
||||
const TestInfo* current_test_info() const GTEST_LOCK_EXCLUDED_(mutex_);
|
||||
const TestInfo* current_test_info() const
|
||||
GTEST_LOCK_EXCLUDED_(mutex_);
|
||||
|
||||
// Returns the random seed used at the start of the current test run.
|
||||
int random_seed() const;
|
||||
|
|
@ -1226,7 +1408,8 @@ class GTEST_API_ UnitTest {
|
|||
// eventually call this to report their results. The user code
|
||||
// should use the assertion macros instead of calling this directly.
|
||||
void AddTestPartResult(TestPartResult::Type result_type,
|
||||
const char* file_name, int line_number,
|
||||
const char* file_name,
|
||||
int line_number,
|
||||
const std::string& message,
|
||||
const std::string& os_stack_trace)
|
||||
GTEST_LOCK_EXCLUDED_(mutex_);
|
||||
|
|
@ -1257,7 +1440,8 @@ class GTEST_API_ UnitTest {
|
|||
friend std::set<std::string>* internal::GetIgnoredParameterizedTestSuites();
|
||||
friend internal::UnitTestImpl* internal::GetUnitTestImpl();
|
||||
friend void internal::ReportFailureInUnknownLocation(
|
||||
TestPartResult::Type result_type, const std::string& message);
|
||||
TestPartResult::Type result_type,
|
||||
const std::string& message);
|
||||
|
||||
// Creates an empty UnitTest.
|
||||
UnitTest();
|
||||
|
|
@ -1271,7 +1455,8 @@ class GTEST_API_ UnitTest {
|
|||
GTEST_LOCK_EXCLUDED_(mutex_);
|
||||
|
||||
// Pops a trace from the per-thread Google Test trace stack.
|
||||
void PopGTestTrace() GTEST_LOCK_EXCLUDED_(mutex_);
|
||||
void PopGTestTrace()
|
||||
GTEST_LOCK_EXCLUDED_(mutex_);
|
||||
|
||||
// Protects mutable state in *impl_. This is mutable as some const
|
||||
// methods need to lock it too.
|
||||
|
|
@ -1284,8 +1469,7 @@ class GTEST_API_ UnitTest {
|
|||
internal::UnitTestImpl* impl_;
|
||||
|
||||
// We disallow copying UnitTest.
|
||||
UnitTest(const UnitTest&) = delete;
|
||||
UnitTest& operator=(const UnitTest&) = delete;
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(UnitTest);
|
||||
};
|
||||
|
||||
// A convenient wrapper for adding an environment for the test
|
||||
|
|
@ -1336,11 +1520,13 @@ namespace internal {
|
|||
// when calling EXPECT_* in a tight loop.
|
||||
template <typename T1, typename T2>
|
||||
AssertionResult CmpHelperEQFailure(const char* lhs_expression,
|
||||
const char* rhs_expression, const T1& lhs,
|
||||
const T2& rhs) {
|
||||
return EqFailure(lhs_expression, rhs_expression,
|
||||
const char* rhs_expression,
|
||||
const T1& lhs, const T2& rhs) {
|
||||
return EqFailure(lhs_expression,
|
||||
rhs_expression,
|
||||
FormatForComparisonFailureMessage(lhs, rhs),
|
||||
FormatForComparisonFailureMessage(rhs, lhs), false);
|
||||
FormatForComparisonFailureMessage(rhs, lhs),
|
||||
false);
|
||||
}
|
||||
|
||||
// This block of code defines operator==/!=
|
||||
|
|
@ -1353,7 +1539,8 @@ inline bool operator!=(faketype, faketype) { return false; }
|
|||
// The helper function for {ASSERT|EXPECT}_EQ.
|
||||
template <typename T1, typename T2>
|
||||
AssertionResult CmpHelperEQ(const char* lhs_expression,
|
||||
const char* rhs_expression, const T1& lhs,
|
||||
const char* rhs_expression,
|
||||
const T1& lhs,
|
||||
const T2& rhs) {
|
||||
if (lhs == rhs) {
|
||||
return AssertionSuccess();
|
||||
|
|
@ -1384,7 +1571,8 @@ class EqHelper {
|
|||
// Even though its body looks the same as the above version, we
|
||||
// cannot merge the two, as it will make anonymous enums unhappy.
|
||||
static AssertionResult Compare(const char* lhs_expression,
|
||||
const char* rhs_expression, BiggestInt lhs,
|
||||
const char* rhs_expression,
|
||||
BiggestInt lhs,
|
||||
BiggestInt rhs) {
|
||||
return CmpHelperEQ(lhs_expression, rhs_expression, lhs, rhs);
|
||||
}
|
||||
|
|
@ -1419,16 +1607,16 @@ AssertionResult CmpHelperOpFailure(const char* expr1, const char* expr2,
|
|||
//
|
||||
// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
|
||||
|
||||
#define GTEST_IMPL_CMP_HELPER_(op_name, op) \
|
||||
template <typename T1, typename T2> \
|
||||
AssertionResult CmpHelper##op_name(const char* expr1, const char* expr2, \
|
||||
const T1& val1, const T2& val2) { \
|
||||
if (val1 op val2) { \
|
||||
return AssertionSuccess(); \
|
||||
} else { \
|
||||
return CmpHelperOpFailure(expr1, expr2, val1, val2, #op); \
|
||||
} \
|
||||
}
|
||||
#define GTEST_IMPL_CMP_HELPER_(op_name, op)\
|
||||
template <typename T1, typename T2>\
|
||||
AssertionResult CmpHelper##op_name(const char* expr1, const char* expr2, \
|
||||
const T1& val1, const T2& val2) {\
|
||||
if (val1 op val2) {\
|
||||
return AssertionSuccess();\
|
||||
} else {\
|
||||
return CmpHelperOpFailure(expr1, expr2, val1, val2, #op);\
|
||||
}\
|
||||
}
|
||||
|
||||
// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
|
||||
|
||||
|
|
@ -1450,42 +1638,49 @@ GTEST_IMPL_CMP_HELPER_(GT, >)
|
|||
// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
|
||||
GTEST_API_ AssertionResult CmpHelperSTREQ(const char* s1_expression,
|
||||
const char* s2_expression,
|
||||
const char* s1, const char* s2);
|
||||
const char* s1,
|
||||
const char* s2);
|
||||
|
||||
// The helper function for {ASSERT|EXPECT}_STRCASEEQ.
|
||||
//
|
||||
// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
|
||||
GTEST_API_ AssertionResult CmpHelperSTRCASEEQ(const char* s1_expression,
|
||||
const char* s2_expression,
|
||||
const char* s1, const char* s2);
|
||||
const char* s1,
|
||||
const char* s2);
|
||||
|
||||
// The helper function for {ASSERT|EXPECT}_STRNE.
|
||||
//
|
||||
// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
|
||||
GTEST_API_ AssertionResult CmpHelperSTRNE(const char* s1_expression,
|
||||
const char* s2_expression,
|
||||
const char* s1, const char* s2);
|
||||
const char* s1,
|
||||
const char* s2);
|
||||
|
||||
// The helper function for {ASSERT|EXPECT}_STRCASENE.
|
||||
//
|
||||
// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
|
||||
GTEST_API_ AssertionResult CmpHelperSTRCASENE(const char* s1_expression,
|
||||
const char* s2_expression,
|
||||
const char* s1, const char* s2);
|
||||
const char* s1,
|
||||
const char* s2);
|
||||
|
||||
|
||||
// Helper function for *_STREQ on wide strings.
|
||||
//
|
||||
// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
|
||||
GTEST_API_ AssertionResult CmpHelperSTREQ(const char* s1_expression,
|
||||
const char* s2_expression,
|
||||
const wchar_t* s1, const wchar_t* s2);
|
||||
const wchar_t* s1,
|
||||
const wchar_t* s2);
|
||||
|
||||
// Helper function for *_STRNE on wide strings.
|
||||
//
|
||||
// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
|
||||
GTEST_API_ AssertionResult CmpHelperSTRNE(const char* s1_expression,
|
||||
const char* s2_expression,
|
||||
const wchar_t* s1, const wchar_t* s2);
|
||||
const wchar_t* s1,
|
||||
const wchar_t* s2);
|
||||
|
||||
} // namespace internal
|
||||
|
||||
|
|
@ -1497,40 +1692,32 @@ GTEST_API_ AssertionResult CmpHelperSTRNE(const char* s1_expression,
|
|||
//
|
||||
// The {needle,haystack}_expr arguments are the stringified
|
||||
// expressions that generated the two real arguments.
|
||||
GTEST_API_ AssertionResult IsSubstring(const char* needle_expr,
|
||||
const char* haystack_expr,
|
||||
const char* needle,
|
||||
const char* haystack);
|
||||
GTEST_API_ AssertionResult IsSubstring(const char* needle_expr,
|
||||
const char* haystack_expr,
|
||||
const wchar_t* needle,
|
||||
const wchar_t* haystack);
|
||||
GTEST_API_ AssertionResult IsNotSubstring(const char* needle_expr,
|
||||
const char* haystack_expr,
|
||||
const char* needle,
|
||||
const char* haystack);
|
||||
GTEST_API_ AssertionResult IsNotSubstring(const char* needle_expr,
|
||||
const char* haystack_expr,
|
||||
const wchar_t* needle,
|
||||
const wchar_t* haystack);
|
||||
GTEST_API_ AssertionResult IsSubstring(const char* needle_expr,
|
||||
const char* haystack_expr,
|
||||
const ::std::string& needle,
|
||||
const ::std::string& haystack);
|
||||
GTEST_API_ AssertionResult IsNotSubstring(const char* needle_expr,
|
||||
const char* haystack_expr,
|
||||
const ::std::string& needle,
|
||||
const ::std::string& haystack);
|
||||
GTEST_API_ AssertionResult IsSubstring(
|
||||
const char* needle_expr, const char* haystack_expr,
|
||||
const char* needle, const char* haystack);
|
||||
GTEST_API_ AssertionResult IsSubstring(
|
||||
const char* needle_expr, const char* haystack_expr,
|
||||
const wchar_t* needle, const wchar_t* haystack);
|
||||
GTEST_API_ AssertionResult IsNotSubstring(
|
||||
const char* needle_expr, const char* haystack_expr,
|
||||
const char* needle, const char* haystack);
|
||||
GTEST_API_ AssertionResult IsNotSubstring(
|
||||
const char* needle_expr, const char* haystack_expr,
|
||||
const wchar_t* needle, const wchar_t* haystack);
|
||||
GTEST_API_ AssertionResult IsSubstring(
|
||||
const char* needle_expr, const char* haystack_expr,
|
||||
const ::std::string& needle, const ::std::string& haystack);
|
||||
GTEST_API_ AssertionResult IsNotSubstring(
|
||||
const char* needle_expr, const char* haystack_expr,
|
||||
const ::std::string& needle, const ::std::string& haystack);
|
||||
|
||||
#if GTEST_HAS_STD_WSTRING
|
||||
GTEST_API_ AssertionResult IsSubstring(const char* needle_expr,
|
||||
const char* haystack_expr,
|
||||
const ::std::wstring& needle,
|
||||
const ::std::wstring& haystack);
|
||||
GTEST_API_ AssertionResult IsNotSubstring(const char* needle_expr,
|
||||
const char* haystack_expr,
|
||||
const ::std::wstring& needle,
|
||||
const ::std::wstring& haystack);
|
||||
GTEST_API_ AssertionResult IsSubstring(
|
||||
const char* needle_expr, const char* haystack_expr,
|
||||
const ::std::wstring& needle, const ::std::wstring& haystack);
|
||||
GTEST_API_ AssertionResult IsNotSubstring(
|
||||
const char* needle_expr, const char* haystack_expr,
|
||||
const ::std::wstring& needle, const ::std::wstring& haystack);
|
||||
#endif // GTEST_HAS_STD_WSTRING
|
||||
|
||||
namespace internal {
|
||||
|
|
@ -1545,7 +1732,8 @@ namespace internal {
|
|||
template <typename RawType>
|
||||
AssertionResult CmpHelperFloatingPointEQ(const char* lhs_expression,
|
||||
const char* rhs_expression,
|
||||
RawType lhs_value, RawType rhs_value) {
|
||||
RawType lhs_value,
|
||||
RawType rhs_value) {
|
||||
const FloatingPoint<RawType> lhs(lhs_value), rhs(rhs_value);
|
||||
|
||||
if (lhs.AlmostEquals(rhs)) {
|
||||
|
|
@ -1560,8 +1748,10 @@ AssertionResult CmpHelperFloatingPointEQ(const char* lhs_expression,
|
|||
rhs_ss << std::setprecision(std::numeric_limits<RawType>::digits10 + 2)
|
||||
<< rhs_value;
|
||||
|
||||
return EqFailure(lhs_expression, rhs_expression,
|
||||
StringStreamToString(&lhs_ss), StringStreamToString(&rhs_ss),
|
||||
return EqFailure(lhs_expression,
|
||||
rhs_expression,
|
||||
StringStreamToString(&lhs_ss),
|
||||
StringStreamToString(&rhs_ss),
|
||||
false);
|
||||
}
|
||||
|
||||
|
|
@ -1571,7 +1761,8 @@ AssertionResult CmpHelperFloatingPointEQ(const char* lhs_expression,
|
|||
GTEST_API_ AssertionResult DoubleNearPredFormat(const char* expr1,
|
||||
const char* expr2,
|
||||
const char* abs_error_expr,
|
||||
double val1, double val2,
|
||||
double val1,
|
||||
double val2,
|
||||
double abs_error);
|
||||
|
||||
// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
|
||||
|
|
@ -1579,7 +1770,9 @@ GTEST_API_ AssertionResult DoubleNearPredFormat(const char* expr1,
|
|||
class GTEST_API_ AssertHelper {
|
||||
public:
|
||||
// Constructor.
|
||||
AssertHelper(TestPartResult::Type type, const char* file, int line,
|
||||
AssertHelper(TestPartResult::Type type,
|
||||
const char* file,
|
||||
int line,
|
||||
const char* message);
|
||||
~AssertHelper();
|
||||
|
||||
|
|
@ -1593,9 +1786,11 @@ class GTEST_API_ AssertHelper {
|
|||
// re-using stack space even for temporary variables, so every EXPECT_EQ
|
||||
// reserves stack space for another AssertHelper.
|
||||
struct AssertHelperData {
|
||||
AssertHelperData(TestPartResult::Type t, const char* srcfile, int line_num,
|
||||
AssertHelperData(TestPartResult::Type t,
|
||||
const char* srcfile,
|
||||
int line_num,
|
||||
const char* msg)
|
||||
: type(t), file(srcfile), line(line_num), message(msg) {}
|
||||
: type(t), file(srcfile), line(line_num), message(msg) { }
|
||||
|
||||
TestPartResult::Type const type;
|
||||
const char* const file;
|
||||
|
|
@ -1603,14 +1798,12 @@ class GTEST_API_ AssertHelper {
|
|||
std::string const message;
|
||||
|
||||
private:
|
||||
AssertHelperData(const AssertHelperData&) = delete;
|
||||
AssertHelperData& operator=(const AssertHelperData&) = delete;
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(AssertHelperData);
|
||||
};
|
||||
|
||||
AssertHelperData* const data_;
|
||||
|
||||
AssertHelper(const AssertHelper&) = delete;
|
||||
AssertHelper& operator=(const AssertHelper&) = delete;
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(AssertHelper);
|
||||
};
|
||||
|
||||
} // namespace internal
|
||||
|
|
@ -1667,14 +1860,15 @@ class WithParamInterface {
|
|||
private:
|
||||
// Sets parameter value. The caller is responsible for making sure the value
|
||||
// remains alive and unchanged throughout the current test.
|
||||
static void SetParam(const ParamType* parameter) { parameter_ = parameter; }
|
||||
static void SetParam(const ParamType* parameter) {
|
||||
parameter_ = parameter;
|
||||
}
|
||||
|
||||
// Static value used for accessing parameter during a test lifetime.
|
||||
static const ParamType* parameter_;
|
||||
|
||||
// TestClass must be a subclass of WithParamInterface<T> and Test.
|
||||
template <class TestClass>
|
||||
friend class internal::ParameterizedTestFactory;
|
||||
template <class TestClass> friend class internal::ParameterizedTestFactory;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
|
|
@ -1684,7 +1878,8 @@ const T* WithParamInterface<T>::parameter_ = nullptr;
|
|||
// WithParamInterface, and can just inherit from ::testing::TestWithParam.
|
||||
|
||||
template <typename T>
|
||||
class TestWithParam : public Test, public WithParamInterface<T> {};
|
||||
class TestWithParam : public Test, public WithParamInterface<T> {
|
||||
};
|
||||
|
||||
// Macros for indicating success/failure in test code.
|
||||
|
||||
|
|
@ -1715,7 +1910,7 @@ class TestWithParam : public Test, public WithParamInterface<T> {};
|
|||
|
||||
// Generates a nonfatal failure at the given source file location with
|
||||
// a generic message.
|
||||
#define ADD_FAILURE_AT(file, line) \
|
||||
#define ADD_FAILURE_AT(file, line) \
|
||||
GTEST_MESSAGE_AT_(file, line, "Failed", \
|
||||
::testing::TestPartResult::kNonFatalFailure)
|
||||
|
||||
|
|
@ -1730,7 +1925,7 @@ class TestWithParam : public Test, public WithParamInterface<T> {};
|
|||
// Define this macro to 1 to omit the definition of FAIL(), which is a
|
||||
// generic name and clashes with some other libraries.
|
||||
#if !GTEST_DONT_DEFINE_FAIL
|
||||
#define FAIL() GTEST_FAIL()
|
||||
# define FAIL() GTEST_FAIL()
|
||||
#endif
|
||||
|
||||
// Generates a success with a generic message.
|
||||
|
|
@ -1739,7 +1934,7 @@ class TestWithParam : public Test, public WithParamInterface<T> {};
|
|||
// Define this macro to 1 to omit the definition of SUCCEED(), which
|
||||
// is a generic name and clashes with some other libraries.
|
||||
#if !GTEST_DONT_DEFINE_SUCCEED
|
||||
#define SUCCEED() GTEST_SUCCEED()
|
||||
# define SUCCEED() GTEST_SUCCEED()
|
||||
#endif
|
||||
|
||||
// Macros for testing exceptions.
|
||||
|
|
@ -1767,15 +1962,16 @@ class TestWithParam : public Test, public WithParamInterface<T> {};
|
|||
// Boolean assertions. Condition can be either a Boolean expression or an
|
||||
// AssertionResult. For more information on how to use AssertionResult with
|
||||
// these macros see comments on that class.
|
||||
#define GTEST_EXPECT_TRUE(condition) \
|
||||
#define GTEST_EXPECT_TRUE(condition) \
|
||||
GTEST_TEST_BOOLEAN_(condition, #condition, false, true, \
|
||||
GTEST_NONFATAL_FAILURE_)
|
||||
#define GTEST_EXPECT_FALSE(condition) \
|
||||
#define GTEST_EXPECT_FALSE(condition) \
|
||||
GTEST_TEST_BOOLEAN_(!(condition), #condition, true, false, \
|
||||
GTEST_NONFATAL_FAILURE_)
|
||||
#define GTEST_ASSERT_TRUE(condition) \
|
||||
GTEST_TEST_BOOLEAN_(condition, #condition, false, true, GTEST_FATAL_FAILURE_)
|
||||
#define GTEST_ASSERT_FALSE(condition) \
|
||||
GTEST_TEST_BOOLEAN_(condition, #condition, false, true, \
|
||||
GTEST_FATAL_FAILURE_)
|
||||
#define GTEST_ASSERT_FALSE(condition) \
|
||||
GTEST_TEST_BOOLEAN_(!(condition), #condition, true, false, \
|
||||
GTEST_FATAL_FAILURE_)
|
||||
|
||||
|
|
@ -1874,27 +2070,27 @@ class TestWithParam : public Test, public WithParamInterface<T> {};
|
|||
// ASSERT_XY(), which clashes with some users' own code.
|
||||
|
||||
#if !GTEST_DONT_DEFINE_ASSERT_EQ
|
||||
#define ASSERT_EQ(val1, val2) GTEST_ASSERT_EQ(val1, val2)
|
||||
# define ASSERT_EQ(val1, val2) GTEST_ASSERT_EQ(val1, val2)
|
||||
#endif
|
||||
|
||||
#if !GTEST_DONT_DEFINE_ASSERT_NE
|
||||
#define ASSERT_NE(val1, val2) GTEST_ASSERT_NE(val1, val2)
|
||||
# define ASSERT_NE(val1, val2) GTEST_ASSERT_NE(val1, val2)
|
||||
#endif
|
||||
|
||||
#if !GTEST_DONT_DEFINE_ASSERT_LE
|
||||
#define ASSERT_LE(val1, val2) GTEST_ASSERT_LE(val1, val2)
|
||||
# define ASSERT_LE(val1, val2) GTEST_ASSERT_LE(val1, val2)
|
||||
#endif
|
||||
|
||||
#if !GTEST_DONT_DEFINE_ASSERT_LT
|
||||
#define ASSERT_LT(val1, val2) GTEST_ASSERT_LT(val1, val2)
|
||||
# define ASSERT_LT(val1, val2) GTEST_ASSERT_LT(val1, val2)
|
||||
#endif
|
||||
|
||||
#if !GTEST_DONT_DEFINE_ASSERT_GE
|
||||
#define ASSERT_GE(val1, val2) GTEST_ASSERT_GE(val1, val2)
|
||||
# define ASSERT_GE(val1, val2) GTEST_ASSERT_GE(val1, val2)
|
||||
#endif
|
||||
|
||||
#if !GTEST_DONT_DEFINE_ASSERT_GT
|
||||
#define ASSERT_GT(val1, val2) GTEST_ASSERT_GT(val1, val2)
|
||||
# define ASSERT_GT(val1, val2) GTEST_ASSERT_GT(val1, val2)
|
||||
#endif
|
||||
|
||||
// C-string Comparisons. All tests treat NULL and any non-NULL string
|
||||
|
|
@ -1919,7 +2115,7 @@ class TestWithParam : public Test, public WithParamInterface<T> {};
|
|||
EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperSTRNE, s1, s2)
|
||||
#define EXPECT_STRCASEEQ(s1, s2) \
|
||||
EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperSTRCASEEQ, s1, s2)
|
||||
#define EXPECT_STRCASENE(s1, s2) \
|
||||
#define EXPECT_STRCASENE(s1, s2)\
|
||||
EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperSTRCASENE, s1, s2)
|
||||
|
||||
#define ASSERT_STREQ(s1, s2) \
|
||||
|
|
@ -1928,7 +2124,7 @@ class TestWithParam : public Test, public WithParamInterface<T> {};
|
|||
ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperSTRNE, s1, s2)
|
||||
#define ASSERT_STRCASEEQ(s1, s2) \
|
||||
ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperSTRCASEEQ, s1, s2)
|
||||
#define ASSERT_STRCASENE(s1, s2) \
|
||||
#define ASSERT_STRCASENE(s1, s2)\
|
||||
ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperSTRCASENE, s1, s2)
|
||||
|
||||
// Macros for comparing floating-point numbers.
|
||||
|
|
@ -1945,29 +2141,29 @@ class TestWithParam : public Test, public WithParamInterface<T> {};
|
|||
// FloatingPoint template class in gtest-internal.h if you are
|
||||
// interested in the implementation details.
|
||||
|
||||
#define EXPECT_FLOAT_EQ(val1, val2) \
|
||||
#define EXPECT_FLOAT_EQ(val1, val2)\
|
||||
EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperFloatingPointEQ<float>, \
|
||||
val1, val2)
|
||||
|
||||
#define EXPECT_DOUBLE_EQ(val1, val2) \
|
||||
#define EXPECT_DOUBLE_EQ(val1, val2)\
|
||||
EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperFloatingPointEQ<double>, \
|
||||
val1, val2)
|
||||
|
||||
#define ASSERT_FLOAT_EQ(val1, val2) \
|
||||
#define ASSERT_FLOAT_EQ(val1, val2)\
|
||||
ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperFloatingPointEQ<float>, \
|
||||
val1, val2)
|
||||
|
||||
#define ASSERT_DOUBLE_EQ(val1, val2) \
|
||||
#define ASSERT_DOUBLE_EQ(val1, val2)\
|
||||
ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperFloatingPointEQ<double>, \
|
||||
val1, val2)
|
||||
|
||||
#define EXPECT_NEAR(val1, val2, abs_error) \
|
||||
EXPECT_PRED_FORMAT3(::testing::internal::DoubleNearPredFormat, val1, val2, \
|
||||
abs_error)
|
||||
#define EXPECT_NEAR(val1, val2, abs_error)\
|
||||
EXPECT_PRED_FORMAT3(::testing::internal::DoubleNearPredFormat, \
|
||||
val1, val2, abs_error)
|
||||
|
||||
#define ASSERT_NEAR(val1, val2, abs_error) \
|
||||
ASSERT_PRED_FORMAT3(::testing::internal::DoubleNearPredFormat, val1, val2, \
|
||||
abs_error)
|
||||
#define ASSERT_NEAR(val1, val2, abs_error)\
|
||||
ASSERT_PRED_FORMAT3(::testing::internal::DoubleNearPredFormat, \
|
||||
val1, val2, abs_error)
|
||||
|
||||
// These predicate format functions work on floating-point values, and
|
||||
// can be used in {ASSERT|EXPECT}_PRED_FORMAT2*(), e.g.
|
||||
|
|
@ -1981,6 +2177,7 @@ GTEST_API_ AssertionResult FloatLE(const char* expr1, const char* expr2,
|
|||
GTEST_API_ AssertionResult DoubleLE(const char* expr1, const char* expr2,
|
||||
double val1, double val2);
|
||||
|
||||
|
||||
#if GTEST_OS_WINDOWS
|
||||
|
||||
// Macros that test for HRESULT failure and success, these are only useful
|
||||
|
|
@ -1992,17 +2189,17 @@ GTEST_API_ AssertionResult DoubleLE(const char* expr1, const char* expr2,
|
|||
// expected result and the actual result with both a human-readable
|
||||
// string representation of the error, if available, as well as the
|
||||
// hex result code.
|
||||
#define EXPECT_HRESULT_SUCCEEDED(expr) \
|
||||
EXPECT_PRED_FORMAT1(::testing::internal::IsHRESULTSuccess, (expr))
|
||||
# define EXPECT_HRESULT_SUCCEEDED(expr) \
|
||||
EXPECT_PRED_FORMAT1(::testing::internal::IsHRESULTSuccess, (expr))
|
||||
|
||||
#define ASSERT_HRESULT_SUCCEEDED(expr) \
|
||||
ASSERT_PRED_FORMAT1(::testing::internal::IsHRESULTSuccess, (expr))
|
||||
# define ASSERT_HRESULT_SUCCEEDED(expr) \
|
||||
ASSERT_PRED_FORMAT1(::testing::internal::IsHRESULTSuccess, (expr))
|
||||
|
||||
#define EXPECT_HRESULT_FAILED(expr) \
|
||||
EXPECT_PRED_FORMAT1(::testing::internal::IsHRESULTFailure, (expr))
|
||||
# define EXPECT_HRESULT_FAILED(expr) \
|
||||
EXPECT_PRED_FORMAT1(::testing::internal::IsHRESULTFailure, (expr))
|
||||
|
||||
#define ASSERT_HRESULT_FAILED(expr) \
|
||||
ASSERT_PRED_FORMAT1(::testing::internal::IsHRESULTFailure, (expr))
|
||||
# define ASSERT_HRESULT_FAILED(expr) \
|
||||
ASSERT_PRED_FORMAT1(::testing::internal::IsHRESULTFailure, (expr))
|
||||
|
||||
#endif // GTEST_OS_WINDOWS
|
||||
|
||||
|
|
@ -2017,9 +2214,9 @@ GTEST_API_ AssertionResult DoubleLE(const char* expr1, const char* expr2,
|
|||
// ASSERT_NO_FATAL_FAILURE(Process()) << "Process() failed";
|
||||
//
|
||||
#define ASSERT_NO_FATAL_FAILURE(statement) \
|
||||
GTEST_TEST_NO_FATAL_FAILURE_(statement, GTEST_FATAL_FAILURE_)
|
||||
GTEST_TEST_NO_FATAL_FAILURE_(statement, GTEST_FATAL_FAILURE_)
|
||||
#define EXPECT_NO_FATAL_FAILURE(statement) \
|
||||
GTEST_TEST_NO_FATAL_FAILURE_(statement, GTEST_NONFATAL_FAILURE_)
|
||||
GTEST_TEST_NO_FATAL_FAILURE_(statement, GTEST_NONFATAL_FAILURE_)
|
||||
|
||||
// Causes a trace (including the given source file path and line number,
|
||||
// and the given message) to be included in every test failure message generated
|
||||
|
|
@ -2061,8 +2258,7 @@ class GTEST_API_ ScopedTrace {
|
|||
private:
|
||||
void PushTrace(const char* file, int line, std::string message);
|
||||
|
||||
ScopedTrace(const ScopedTrace&) = delete;
|
||||
ScopedTrace& operator=(const ScopedTrace&) = delete;
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(ScopedTrace);
|
||||
} GTEST_ATTRIBUTE_UNUSED_; // A ScopedTrace object does its job in its
|
||||
// c'tor and d'tor. Therefore it doesn't
|
||||
// need to be used otherwise.
|
||||
|
|
@ -2082,9 +2278,9 @@ class GTEST_API_ ScopedTrace {
|
|||
// Assuming that each thread maintains its own stack of traces.
|
||||
// Therefore, a SCOPED_TRACE() would (correctly) only affect the
|
||||
// assertions in its own thread.
|
||||
#define SCOPED_TRACE(message) \
|
||||
::testing::ScopedTrace GTEST_CONCAT_TOKEN_(gtest_trace_, __LINE__)( \
|
||||
__FILE__, __LINE__, (message))
|
||||
#define SCOPED_TRACE(message) \
|
||||
::testing::ScopedTrace GTEST_CONCAT_TOKEN_(gtest_trace_, __LINE__)(\
|
||||
__FILE__, __LINE__, (message))
|
||||
|
||||
// Compile-time assertion for type equality.
|
||||
// StaticAssertTypeEq<type1, type2>() compiles if and only if type1 and type2
|
||||
|
|
@ -2182,19 +2378,20 @@ constexpr bool StaticAssertTypeEq() noexcept {
|
|||
// EXPECT_EQ(a_.size(), 0);
|
||||
// EXPECT_EQ(b_.size(), 1);
|
||||
// }
|
||||
#define GTEST_TEST_F(test_fixture, test_name) \
|
||||
//
|
||||
// GOOGLETEST_CM0011 DO NOT DELETE
|
||||
#if !GTEST_DONT_DEFINE_TEST
|
||||
#define TEST_F(test_fixture, test_name)\
|
||||
GTEST_TEST_(test_fixture, test_name, test_fixture, \
|
||||
::testing::internal::GetTypeId<test_fixture>())
|
||||
#if !GTEST_DONT_DEFINE_TEST_F
|
||||
#define TEST_F(test_fixture, test_name) GTEST_TEST_F(test_fixture, test_name)
|
||||
#endif
|
||||
#endif // !GTEST_DONT_DEFINE_TEST
|
||||
|
||||
// Returns a path to temporary directory.
|
||||
// Tries to determine an appropriate directory for the platform.
|
||||
GTEST_API_ std::string TempDir();
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(pop)
|
||||
# pragma warning(pop)
|
||||
#endif
|
||||
|
||||
// Dynamically registers a test with the framework.
|
||||
|
|
@ -2248,7 +2445,6 @@ GTEST_API_ std::string TempDir();
|
|||
// }
|
||||
// ...
|
||||
// int main(int argc, char** argv) {
|
||||
// ::testing::InitGoogleTest(&argc, argv);
|
||||
// std::vector<int> values_to_test = LoadValuesFromConfig();
|
||||
// RegisterMyTests(values_to_test);
|
||||
// ...
|
||||
|
|
@ -2290,7 +2486,9 @@ TestInfo* RegisterTest(const char* test_suite_name, const char* test_name,
|
|||
// namespace and has an all-caps name.
|
||||
int RUN_ALL_TESTS() GTEST_MUST_USE_RESULT_;
|
||||
|
||||
inline int RUN_ALL_TESTS() { return ::testing::UnitTest::GetInstance()->Run(); }
|
||||
inline int RUN_ALL_TESTS() {
|
||||
return ::testing::UnitTest::GetInstance()->Run();
|
||||
}
|
||||
|
||||
GTEST_DISABLE_MSC_WARNINGS_POP_() // 4251
|
||||
|
||||
|
|
|
|||
|
|
@ -26,19 +26,17 @@
|
|||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// This file is AUTOMATICALLY GENERATED on 01/02/2019 by command
|
||||
// 'gen_gtest_pred_impl.py 5'. DO NOT EDIT BY HAND!
|
||||
//
|
||||
// Implements a family of generic predicate assertion macros.
|
||||
|
||||
// IWYU pragma: private, include "gtest/gtest.h"
|
||||
// IWYU pragma: friend gtest/.*
|
||||
// IWYU pragma: friend gmock/.*
|
||||
// GOOGLETEST_CM0001 DO NOT DELETE
|
||||
|
||||
#ifndef GOOGLETEST_INCLUDE_GTEST_GTEST_PRED_IMPL_H_
|
||||
#define GOOGLETEST_INCLUDE_GTEST_GTEST_PRED_IMPL_H_
|
||||
|
||||
#include "gtest/gtest-assertion-result.h"
|
||||
#include "gtest/internal/gtest-internal.h"
|
||||
#include "gtest/internal/gtest-port.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
namespace testing {
|
||||
|
||||
|
|
@ -74,18 +72,22 @@ namespace testing {
|
|||
// GTEST_ASSERT_ is the basic statement to which all of the assertions
|
||||
// in this file reduce. Don't use this in your code.
|
||||
|
||||
#define GTEST_ASSERT_(expression, on_failure) \
|
||||
GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
|
||||
#define GTEST_ASSERT_(expression, on_failure) \
|
||||
GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
|
||||
if (const ::testing::AssertionResult gtest_ar = (expression)) \
|
||||
; \
|
||||
else \
|
||||
; \
|
||||
else \
|
||||
on_failure(gtest_ar.failure_message())
|
||||
|
||||
|
||||
// Helper function for implementing {EXPECT|ASSERT}_PRED1. Don't use
|
||||
// this in your code.
|
||||
template <typename Pred, typename T1>
|
||||
AssertionResult AssertPred1Helper(const char* pred_text, const char* e1,
|
||||
Pred pred, const T1& v1) {
|
||||
template <typename Pred,
|
||||
typename T1>
|
||||
AssertionResult AssertPred1Helper(const char* pred_text,
|
||||
const char* e1,
|
||||
Pred pred,
|
||||
const T1& v1) {
|
||||
if (pred(v1)) return AssertionSuccess();
|
||||
|
||||
return AssertionFailure()
|
||||
|
|
@ -96,27 +98,40 @@ AssertionResult AssertPred1Helper(const char* pred_text, const char* e1,
|
|||
|
||||
// Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT1.
|
||||
// Don't use this in your code.
|
||||
#define GTEST_PRED_FORMAT1_(pred_format, v1, on_failure) \
|
||||
GTEST_ASSERT_(pred_format(#v1, v1), on_failure)
|
||||
#define GTEST_PRED_FORMAT1_(pred_format, v1, on_failure)\
|
||||
GTEST_ASSERT_(pred_format(#v1, v1), \
|
||||
on_failure)
|
||||
|
||||
// Internal macro for implementing {EXPECT|ASSERT}_PRED1. Don't use
|
||||
// this in your code.
|
||||
#define GTEST_PRED1_(pred, v1, on_failure) \
|
||||
GTEST_ASSERT_(::testing::AssertPred1Helper(#pred, #v1, pred, v1), on_failure)
|
||||
#define GTEST_PRED1_(pred, v1, on_failure)\
|
||||
GTEST_ASSERT_(::testing::AssertPred1Helper(#pred, \
|
||||
#v1, \
|
||||
pred, \
|
||||
v1), on_failure)
|
||||
|
||||
// Unary predicate assertion macros.
|
||||
#define EXPECT_PRED_FORMAT1(pred_format, v1) \
|
||||
GTEST_PRED_FORMAT1_(pred_format, v1, GTEST_NONFATAL_FAILURE_)
|
||||
#define EXPECT_PRED1(pred, v1) GTEST_PRED1_(pred, v1, GTEST_NONFATAL_FAILURE_)
|
||||
#define EXPECT_PRED1(pred, v1) \
|
||||
GTEST_PRED1_(pred, v1, GTEST_NONFATAL_FAILURE_)
|
||||
#define ASSERT_PRED_FORMAT1(pred_format, v1) \
|
||||
GTEST_PRED_FORMAT1_(pred_format, v1, GTEST_FATAL_FAILURE_)
|
||||
#define ASSERT_PRED1(pred, v1) GTEST_PRED1_(pred, v1, GTEST_FATAL_FAILURE_)
|
||||
#define ASSERT_PRED1(pred, v1) \
|
||||
GTEST_PRED1_(pred, v1, GTEST_FATAL_FAILURE_)
|
||||
|
||||
|
||||
|
||||
// Helper function for implementing {EXPECT|ASSERT}_PRED2. Don't use
|
||||
// this in your code.
|
||||
template <typename Pred, typename T1, typename T2>
|
||||
AssertionResult AssertPred2Helper(const char* pred_text, const char* e1,
|
||||
const char* e2, Pred pred, const T1& v1,
|
||||
template <typename Pred,
|
||||
typename T1,
|
||||
typename T2>
|
||||
AssertionResult AssertPred2Helper(const char* pred_text,
|
||||
const char* e1,
|
||||
const char* e2,
|
||||
Pred pred,
|
||||
const T1& v1,
|
||||
const T2& v2) {
|
||||
if (pred(v1, v2)) return AssertionSuccess();
|
||||
|
||||
|
|
@ -130,14 +145,19 @@ AssertionResult AssertPred2Helper(const char* pred_text, const char* e1,
|
|||
|
||||
// Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT2.
|
||||
// Don't use this in your code.
|
||||
#define GTEST_PRED_FORMAT2_(pred_format, v1, v2, on_failure) \
|
||||
GTEST_ASSERT_(pred_format(#v1, #v2, v1, v2), on_failure)
|
||||
#define GTEST_PRED_FORMAT2_(pred_format, v1, v2, on_failure)\
|
||||
GTEST_ASSERT_(pred_format(#v1, #v2, v1, v2), \
|
||||
on_failure)
|
||||
|
||||
// Internal macro for implementing {EXPECT|ASSERT}_PRED2. Don't use
|
||||
// this in your code.
|
||||
#define GTEST_PRED2_(pred, v1, v2, on_failure) \
|
||||
GTEST_ASSERT_(::testing::AssertPred2Helper(#pred, #v1, #v2, pred, v1, v2), \
|
||||
on_failure)
|
||||
#define GTEST_PRED2_(pred, v1, v2, on_failure)\
|
||||
GTEST_ASSERT_(::testing::AssertPred2Helper(#pred, \
|
||||
#v1, \
|
||||
#v2, \
|
||||
pred, \
|
||||
v1, \
|
||||
v2), on_failure)
|
||||
|
||||
// Binary predicate assertion macros.
|
||||
#define EXPECT_PRED_FORMAT2(pred_format, v1, v2) \
|
||||
|
|
@ -149,12 +169,22 @@ AssertionResult AssertPred2Helper(const char* pred_text, const char* e1,
|
|||
#define ASSERT_PRED2(pred, v1, v2) \
|
||||
GTEST_PRED2_(pred, v1, v2, GTEST_FATAL_FAILURE_)
|
||||
|
||||
|
||||
|
||||
// Helper function for implementing {EXPECT|ASSERT}_PRED3. Don't use
|
||||
// this in your code.
|
||||
template <typename Pred, typename T1, typename T2, typename T3>
|
||||
AssertionResult AssertPred3Helper(const char* pred_text, const char* e1,
|
||||
const char* e2, const char* e3, Pred pred,
|
||||
const T1& v1, const T2& v2, const T3& v3) {
|
||||
template <typename Pred,
|
||||
typename T1,
|
||||
typename T2,
|
||||
typename T3>
|
||||
AssertionResult AssertPred3Helper(const char* pred_text,
|
||||
const char* e1,
|
||||
const char* e2,
|
||||
const char* e3,
|
||||
Pred pred,
|
||||
const T1& v1,
|
||||
const T2& v2,
|
||||
const T3& v3) {
|
||||
if (pred(v1, v2, v3)) return AssertionSuccess();
|
||||
|
||||
return AssertionFailure()
|
||||
|
|
@ -168,15 +198,21 @@ AssertionResult AssertPred3Helper(const char* pred_text, const char* e1,
|
|||
|
||||
// Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT3.
|
||||
// Don't use this in your code.
|
||||
#define GTEST_PRED_FORMAT3_(pred_format, v1, v2, v3, on_failure) \
|
||||
GTEST_ASSERT_(pred_format(#v1, #v2, #v3, v1, v2, v3), on_failure)
|
||||
#define GTEST_PRED_FORMAT3_(pred_format, v1, v2, v3, on_failure)\
|
||||
GTEST_ASSERT_(pred_format(#v1, #v2, #v3, v1, v2, v3), \
|
||||
on_failure)
|
||||
|
||||
// Internal macro for implementing {EXPECT|ASSERT}_PRED3. Don't use
|
||||
// this in your code.
|
||||
#define GTEST_PRED3_(pred, v1, v2, v3, on_failure) \
|
||||
GTEST_ASSERT_( \
|
||||
::testing::AssertPred3Helper(#pred, #v1, #v2, #v3, pred, v1, v2, v3), \
|
||||
on_failure)
|
||||
#define GTEST_PRED3_(pred, v1, v2, v3, on_failure)\
|
||||
GTEST_ASSERT_(::testing::AssertPred3Helper(#pred, \
|
||||
#v1, \
|
||||
#v2, \
|
||||
#v3, \
|
||||
pred, \
|
||||
v1, \
|
||||
v2, \
|
||||
v3), on_failure)
|
||||
|
||||
// Ternary predicate assertion macros.
|
||||
#define EXPECT_PRED_FORMAT3(pred_format, v1, v2, v3) \
|
||||
|
|
@ -188,13 +224,25 @@ AssertionResult AssertPred3Helper(const char* pred_text, const char* e1,
|
|||
#define ASSERT_PRED3(pred, v1, v2, v3) \
|
||||
GTEST_PRED3_(pred, v1, v2, v3, GTEST_FATAL_FAILURE_)
|
||||
|
||||
|
||||
|
||||
// Helper function for implementing {EXPECT|ASSERT}_PRED4. Don't use
|
||||
// this in your code.
|
||||
template <typename Pred, typename T1, typename T2, typename T3, typename T4>
|
||||
AssertionResult AssertPred4Helper(const char* pred_text, const char* e1,
|
||||
const char* e2, const char* e3,
|
||||
const char* e4, Pred pred, const T1& v1,
|
||||
const T2& v2, const T3& v3, const T4& v4) {
|
||||
template <typename Pred,
|
||||
typename T1,
|
||||
typename T2,
|
||||
typename T3,
|
||||
typename T4>
|
||||
AssertionResult AssertPred4Helper(const char* pred_text,
|
||||
const char* e1,
|
||||
const char* e2,
|
||||
const char* e3,
|
||||
const char* e4,
|
||||
Pred pred,
|
||||
const T1& v1,
|
||||
const T2& v2,
|
||||
const T3& v3,
|
||||
const T4& v4) {
|
||||
if (pred(v1, v2, v3, v4)) return AssertionSuccess();
|
||||
|
||||
return AssertionFailure()
|
||||
|
|
@ -209,15 +257,23 @@ AssertionResult AssertPred4Helper(const char* pred_text, const char* e1,
|
|||
|
||||
// Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT4.
|
||||
// Don't use this in your code.
|
||||
#define GTEST_PRED_FORMAT4_(pred_format, v1, v2, v3, v4, on_failure) \
|
||||
GTEST_ASSERT_(pred_format(#v1, #v2, #v3, #v4, v1, v2, v3, v4), on_failure)
|
||||
#define GTEST_PRED_FORMAT4_(pred_format, v1, v2, v3, v4, on_failure)\
|
||||
GTEST_ASSERT_(pred_format(#v1, #v2, #v3, #v4, v1, v2, v3, v4), \
|
||||
on_failure)
|
||||
|
||||
// Internal macro for implementing {EXPECT|ASSERT}_PRED4. Don't use
|
||||
// this in your code.
|
||||
#define GTEST_PRED4_(pred, v1, v2, v3, v4, on_failure) \
|
||||
GTEST_ASSERT_(::testing::AssertPred4Helper(#pred, #v1, #v2, #v3, #v4, pred, \
|
||||
v1, v2, v3, v4), \
|
||||
on_failure)
|
||||
#define GTEST_PRED4_(pred, v1, v2, v3, v4, on_failure)\
|
||||
GTEST_ASSERT_(::testing::AssertPred4Helper(#pred, \
|
||||
#v1, \
|
||||
#v2, \
|
||||
#v3, \
|
||||
#v4, \
|
||||
pred, \
|
||||
v1, \
|
||||
v2, \
|
||||
v3, \
|
||||
v4), on_failure)
|
||||
|
||||
// 4-ary predicate assertion macros.
|
||||
#define EXPECT_PRED_FORMAT4(pred_format, v1, v2, v3, v4) \
|
||||
|
|
@ -229,15 +285,28 @@ AssertionResult AssertPred4Helper(const char* pred_text, const char* e1,
|
|||
#define ASSERT_PRED4(pred, v1, v2, v3, v4) \
|
||||
GTEST_PRED4_(pred, v1, v2, v3, v4, GTEST_FATAL_FAILURE_)
|
||||
|
||||
|
||||
|
||||
// Helper function for implementing {EXPECT|ASSERT}_PRED5. Don't use
|
||||
// this in your code.
|
||||
template <typename Pred, typename T1, typename T2, typename T3, typename T4,
|
||||
template <typename Pred,
|
||||
typename T1,
|
||||
typename T2,
|
||||
typename T3,
|
||||
typename T4,
|
||||
typename T5>
|
||||
AssertionResult AssertPred5Helper(const char* pred_text, const char* e1,
|
||||
const char* e2, const char* e3,
|
||||
const char* e4, const char* e5, Pred pred,
|
||||
const T1& v1, const T2& v2, const T3& v3,
|
||||
const T4& v4, const T5& v5) {
|
||||
AssertionResult AssertPred5Helper(const char* pred_text,
|
||||
const char* e1,
|
||||
const char* e2,
|
||||
const char* e3,
|
||||
const char* e4,
|
||||
const char* e5,
|
||||
Pred pred,
|
||||
const T1& v1,
|
||||
const T2& v2,
|
||||
const T3& v3,
|
||||
const T4& v4,
|
||||
const T5& v5) {
|
||||
if (pred(v1, v2, v3, v4, v5)) return AssertionSuccess();
|
||||
|
||||
return AssertionFailure()
|
||||
|
|
@ -253,16 +322,25 @@ AssertionResult AssertPred5Helper(const char* pred_text, const char* e1,
|
|||
|
||||
// Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT5.
|
||||
// Don't use this in your code.
|
||||
#define GTEST_PRED_FORMAT5_(pred_format, v1, v2, v3, v4, v5, on_failure) \
|
||||
#define GTEST_PRED_FORMAT5_(pred_format, v1, v2, v3, v4, v5, on_failure)\
|
||||
GTEST_ASSERT_(pred_format(#v1, #v2, #v3, #v4, #v5, v1, v2, v3, v4, v5), \
|
||||
on_failure)
|
||||
|
||||
// Internal macro for implementing {EXPECT|ASSERT}_PRED5. Don't use
|
||||
// this in your code.
|
||||
#define GTEST_PRED5_(pred, v1, v2, v3, v4, v5, on_failure) \
|
||||
GTEST_ASSERT_(::testing::AssertPred5Helper(#pred, #v1, #v2, #v3, #v4, #v5, \
|
||||
pred, v1, v2, v3, v4, v5), \
|
||||
on_failure)
|
||||
#define GTEST_PRED5_(pred, v1, v2, v3, v4, v5, on_failure)\
|
||||
GTEST_ASSERT_(::testing::AssertPred5Helper(#pred, \
|
||||
#v1, \
|
||||
#v2, \
|
||||
#v3, \
|
||||
#v4, \
|
||||
#v5, \
|
||||
pred, \
|
||||
v1, \
|
||||
v2, \
|
||||
v3, \
|
||||
v4, \
|
||||
v5), on_failure)
|
||||
|
||||
// 5-ary predicate assertion macros.
|
||||
#define EXPECT_PRED_FORMAT5(pred_format, v1, v2, v3, v4, v5) \
|
||||
|
|
@ -274,6 +352,8 @@ AssertionResult AssertPred5Helper(const char* pred_text, const char* e1,
|
|||
#define ASSERT_PRED5(pred, v1, v2, v3, v4, v5) \
|
||||
GTEST_PRED5_(pred, v1, v2, v3, v4, v5, GTEST_FATAL_FAILURE_)
|
||||
|
||||
|
||||
|
||||
} // namespace testing
|
||||
|
||||
#endif // GOOGLETEST_INCLUDE_GTEST_GTEST_PRED_IMPL_H_
|
||||
|
|
|
|||
|
|
@ -27,8 +27,9 @@
|
|||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// Google C++ Testing and Mocking Framework definitions useful in production
|
||||
// code.
|
||||
//
|
||||
// Google C++ Testing and Mocking Framework definitions useful in production code.
|
||||
// GOOGLETEST_CM0003 DO NOT DELETE
|
||||
|
||||
#ifndef GOOGLETEST_INCLUDE_GTEST_GTEST_PROD_H_
|
||||
#define GOOGLETEST_INCLUDE_GTEST_GTEST_PROD_H_
|
||||
|
|
@ -54,7 +55,7 @@
|
|||
// Note: The test class must be in the same namespace as the class being tested.
|
||||
// For example, putting MyClassTest in an anonymous namespace will not work.
|
||||
|
||||
#define FRIEND_TEST(test_case_name, test_name) \
|
||||
friend class test_case_name##_##test_name##_Test
|
||||
#define FRIEND_TEST(test_case_name, test_name)\
|
||||
friend class test_case_name##_##test_name##_Test
|
||||
|
||||
#endif // GOOGLETEST_INCLUDE_GTEST_GTEST_PROD_H_
|
||||
|
|
|
|||
|
|
@ -15,6 +15,18 @@ The custom directory is an injection point for custom user configurations.
|
|||
|
||||
The following macros can be defined:
|
||||
|
||||
### Flag related macros:
|
||||
|
||||
* `GTEST_FLAG(flag_name)`
|
||||
* `GTEST_USE_OWN_FLAGFILE_FLAG_` - Define to 0 when the system provides its
|
||||
own flagfile flag parsing.
|
||||
* `GTEST_DECLARE_bool_(name)`
|
||||
* `GTEST_DECLARE_int32_(name)`
|
||||
* `GTEST_DECLARE_string_(name)`
|
||||
* `GTEST_DEFINE_bool_(name, default_val, doc)`
|
||||
* `GTEST_DEFINE_int32_(name, default_val, doc)`
|
||||
* `GTEST_DEFINE_string_(name, default_val, doc)`
|
||||
|
||||
### Logging:
|
||||
|
||||
* `GTEST_LOG_(severity)`
|
||||
|
|
|
|||
|
|
@ -26,31 +26,27 @@
|
|||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
//
|
||||
// The Google C++ Testing and Mocking Framework (Google Test)
|
||||
//
|
||||
// This header file defines internal utilities needed for implementing
|
||||
// death tests. They are subject to change without notice.
|
||||
|
||||
// IWYU pragma: private, include "gtest/gtest.h"
|
||||
// IWYU pragma: friend gtest/.*
|
||||
// IWYU pragma: friend gmock/.*
|
||||
// GOOGLETEST_CM0001 DO NOT DELETE
|
||||
|
||||
#ifndef GOOGLETEST_INCLUDE_GTEST_INTERNAL_GTEST_DEATH_TEST_INTERNAL_H_
|
||||
#define GOOGLETEST_INCLUDE_GTEST_INTERNAL_GTEST_DEATH_TEST_INTERNAL_H_
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "gtest/gtest-matchers.h"
|
||||
#include "gtest/internal/gtest-internal.h"
|
||||
|
||||
GTEST_DECLARE_string_(internal_run_death_test);
|
||||
#include <stdio.h>
|
||||
#include <memory>
|
||||
|
||||
namespace testing {
|
||||
namespace internal {
|
||||
|
||||
GTEST_DECLARE_string_(internal_run_death_test);
|
||||
|
||||
// Names of the flags (needed for parsing Google Test flags).
|
||||
const char kDeathTestStyleFlag[] = "death_test_style";
|
||||
const char kDeathTestUseFork[] = "death_test_use_fork";
|
||||
|
|
@ -87,18 +83,16 @@ class GTEST_API_ DeathTest {
|
|||
static bool Create(const char* statement, Matcher<const std::string&> matcher,
|
||||
const char* file, int line, DeathTest** test);
|
||||
DeathTest();
|
||||
virtual ~DeathTest() {}
|
||||
virtual ~DeathTest() { }
|
||||
|
||||
// A helper class that aborts a death test when it's deleted.
|
||||
class ReturnSentinel {
|
||||
public:
|
||||
explicit ReturnSentinel(DeathTest* test) : test_(test) {}
|
||||
explicit ReturnSentinel(DeathTest* test) : test_(test) { }
|
||||
~ReturnSentinel() { test_->Abort(TEST_ENCOUNTERED_RETURN_STATEMENT); }
|
||||
|
||||
private:
|
||||
DeathTest* const test_;
|
||||
ReturnSentinel(const ReturnSentinel&) = delete;
|
||||
ReturnSentinel& operator=(const ReturnSentinel&) = delete;
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(ReturnSentinel);
|
||||
} GTEST_ATTRIBUTE_UNUSED_;
|
||||
|
||||
// An enumeration of possible roles that may be taken when a death
|
||||
|
|
@ -143,8 +137,7 @@ class GTEST_API_ DeathTest {
|
|||
// A string containing a description of the outcome of the last death test.
|
||||
static std::string last_death_test_message_;
|
||||
|
||||
DeathTest(const DeathTest&) = delete;
|
||||
DeathTest& operator=(const DeathTest&) = delete;
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(DeathTest);
|
||||
};
|
||||
|
||||
GTEST_DISABLE_MSC_WARNINGS_POP_() // 4251
|
||||
|
|
@ -152,7 +145,7 @@ GTEST_DISABLE_MSC_WARNINGS_POP_() // 4251
|
|||
// Factory interface for death tests. May be mocked out for testing.
|
||||
class DeathTestFactory {
|
||||
public:
|
||||
virtual ~DeathTestFactory() {}
|
||||
virtual ~DeathTestFactory() { }
|
||||
virtual bool Create(const char* statement,
|
||||
Matcher<const std::string&> matcher, const char* file,
|
||||
int line, DeathTest** test) = 0;
|
||||
|
|
@ -193,28 +186,28 @@ inline Matcher<const ::std::string&> MakeDeathTestMatcher(
|
|||
|
||||
// Traps C++ exceptions escaping statement and reports them as test
|
||||
// failures. Note that trapping SEH exceptions is not implemented here.
|
||||
#if GTEST_HAS_EXCEPTIONS
|
||||
#define GTEST_EXECUTE_DEATH_TEST_STATEMENT_(statement, death_test) \
|
||||
try { \
|
||||
GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
|
||||
} catch (const ::std::exception& gtest_exception) { \
|
||||
fprintf( \
|
||||
stderr, \
|
||||
"\n%s: Caught std::exception-derived exception escaping the " \
|
||||
"death test statement. Exception message: %s\n", \
|
||||
# if GTEST_HAS_EXCEPTIONS
|
||||
# define GTEST_EXECUTE_DEATH_TEST_STATEMENT_(statement, death_test) \
|
||||
try { \
|
||||
GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
|
||||
} catch (const ::std::exception& gtest_exception) { \
|
||||
fprintf(\
|
||||
stderr, \
|
||||
"\n%s: Caught std::exception-derived exception escaping the " \
|
||||
"death test statement. Exception message: %s\n", \
|
||||
::testing::internal::FormatFileLocation(__FILE__, __LINE__).c_str(), \
|
||||
gtest_exception.what()); \
|
||||
fflush(stderr); \
|
||||
gtest_exception.what()); \
|
||||
fflush(stderr); \
|
||||
death_test->Abort(::testing::internal::DeathTest::TEST_THREW_EXCEPTION); \
|
||||
} catch (...) { \
|
||||
} catch (...) { \
|
||||
death_test->Abort(::testing::internal::DeathTest::TEST_THREW_EXCEPTION); \
|
||||
}
|
||||
|
||||
#else
|
||||
#define GTEST_EXECUTE_DEATH_TEST_STATEMENT_(statement, death_test) \
|
||||
# else
|
||||
# define GTEST_EXECUTE_DEATH_TEST_STATEMENT_(statement, death_test) \
|
||||
GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement)
|
||||
|
||||
#endif
|
||||
# endif
|
||||
|
||||
// This macro is for implementing ASSERT_DEATH*, EXPECT_DEATH*,
|
||||
// ASSERT_EXIT*, and EXPECT_EXIT*.
|
||||
|
|
@ -243,6 +236,8 @@ inline Matcher<const ::std::string&> MakeDeathTestMatcher(
|
|||
gtest_dt->Abort(::testing::internal::DeathTest::TEST_DID_NOT_DIE); \
|
||||
break; \
|
||||
} \
|
||||
default: \
|
||||
break; \
|
||||
} \
|
||||
} \
|
||||
} else \
|
||||
|
|
@ -270,12 +265,16 @@ inline Matcher<const ::std::string&> MakeDeathTestMatcher(
|
|||
// RUN_ALL_TESTS was called.
|
||||
class InternalRunDeathTestFlag {
|
||||
public:
|
||||
InternalRunDeathTestFlag(const std::string& a_file, int a_line, int an_index,
|
||||
InternalRunDeathTestFlag(const std::string& a_file,
|
||||
int a_line,
|
||||
int an_index,
|
||||
int a_write_fd)
|
||||
: file_(a_file), line_(a_line), index_(an_index), write_fd_(a_write_fd) {}
|
||||
: file_(a_file), line_(a_line), index_(an_index),
|
||||
write_fd_(a_write_fd) {}
|
||||
|
||||
~InternalRunDeathTestFlag() {
|
||||
if (write_fd_ >= 0) posix::Close(write_fd_);
|
||||
if (write_fd_ >= 0)
|
||||
posix::Close(write_fd_);
|
||||
}
|
||||
|
||||
const std::string& file() const { return file_; }
|
||||
|
|
@ -289,8 +288,7 @@ class InternalRunDeathTestFlag {
|
|||
int index_;
|
||||
int write_fd_;
|
||||
|
||||
InternalRunDeathTestFlag(const InternalRunDeathTestFlag&) = delete;
|
||||
InternalRunDeathTestFlag& operator=(const InternalRunDeathTestFlag&) = delete;
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(InternalRunDeathTestFlag);
|
||||
};
|
||||
|
||||
// Returns a newly created InternalRunDeathTestFlag object with fields
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@
|
|||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
//
|
||||
// Google Test filepath utilities
|
||||
//
|
||||
// This header file declares classes and functions used internally by
|
||||
|
|
@ -35,9 +35,7 @@
|
|||
// This file is #included in gtest/internal/gtest-internal.h.
|
||||
// Do not include this header file separately!
|
||||
|
||||
// IWYU pragma: private, include "gtest/gtest.h"
|
||||
// IWYU pragma: friend gtest/.*
|
||||
// IWYU pragma: friend gmock/.*
|
||||
// GOOGLETEST_CM0001 DO NOT DELETE
|
||||
|
||||
#ifndef GOOGLETEST_INCLUDE_GTEST_INTERNAL_GTEST_FILEPATH_H_
|
||||
#define GOOGLETEST_INCLUDE_GTEST_INTERNAL_GTEST_FILEPATH_H_
|
||||
|
|
@ -63,8 +61,8 @@ namespace internal {
|
|||
|
||||
class GTEST_API_ FilePath {
|
||||
public:
|
||||
FilePath() : pathname_("") {}
|
||||
FilePath(const FilePath& rhs) : pathname_(rhs.pathname_) {}
|
||||
FilePath() : pathname_("") { }
|
||||
FilePath(const FilePath& rhs) : pathname_(rhs.pathname_) { }
|
||||
|
||||
explicit FilePath(const std::string& pathname) : pathname_(pathname) {
|
||||
Normalize();
|
||||
|
|
@ -75,7 +73,9 @@ class GTEST_API_ FilePath {
|
|||
return *this;
|
||||
}
|
||||
|
||||
void Set(const FilePath& rhs) { pathname_ = rhs.pathname_; }
|
||||
void Set(const FilePath& rhs) {
|
||||
pathname_ = rhs.pathname_;
|
||||
}
|
||||
|
||||
const std::string& string() const { return pathname_; }
|
||||
const char* c_str() const { return pathname_.c_str(); }
|
||||
|
|
@ -88,7 +88,8 @@ class GTEST_API_ FilePath {
|
|||
// than zero (e.g., 12), returns "dir/test_12.xml".
|
||||
// On Windows platform, uses \ as the separator rather than /.
|
||||
static FilePath MakeFileName(const FilePath& directory,
|
||||
const FilePath& base_name, int number,
|
||||
const FilePath& base_name,
|
||||
int number,
|
||||
const char* extension);
|
||||
|
||||
// Given directory = "dir", relative_path = "test.xml",
|
||||
|
|
|
|||
|
|
@ -26,15 +26,13 @@
|
|||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
//
|
||||
// The Google C++ Testing and Mocking Framework (Google Test)
|
||||
//
|
||||
// This header file declares functions and macros used internally by
|
||||
// Google Test. They are subject to change without notice.
|
||||
|
||||
// IWYU pragma: private, include "gtest/gtest.h"
|
||||
// IWYU pragma: friend gtest/.*
|
||||
// IWYU pragma: friend gmock/.*
|
||||
// GOOGLETEST_CM0001 DO NOT DELETE
|
||||
|
||||
#ifndef GOOGLETEST_INCLUDE_GTEST_INTERNAL_GTEST_INTERNAL_H_
|
||||
#define GOOGLETEST_INCLUDE_GTEST_INTERNAL_GTEST_INTERNAL_H_
|
||||
|
|
@ -42,20 +40,19 @@
|
|||
#include "gtest/internal/gtest-port.h"
|
||||
|
||||
#if GTEST_OS_LINUX
|
||||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/wait.h>
|
||||
#include <unistd.h>
|
||||
# include <stdlib.h>
|
||||
# include <sys/types.h>
|
||||
# include <sys/wait.h>
|
||||
# include <unistd.h>
|
||||
#endif // GTEST_OS_LINUX
|
||||
|
||||
#if GTEST_HAS_EXCEPTIONS
|
||||
#include <stdexcept>
|
||||
# include <stdexcept>
|
||||
#endif
|
||||
|
||||
#include <ctype.h>
|
||||
#include <float.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <iomanip>
|
||||
#include <limits>
|
||||
|
|
@ -79,7 +76,7 @@
|
|||
// the current line number. For more details, see
|
||||
// http://www.parashift.com/c++-faq-lite/misc-technical-issues.html#faq-39.6
|
||||
#define GTEST_CONCAT_TOKEN_(foo, bar) GTEST_CONCAT_TOKEN_IMPL_(foo, bar)
|
||||
#define GTEST_CONCAT_TOKEN_IMPL_(foo, bar) foo##bar
|
||||
#define GTEST_CONCAT_TOKEN_IMPL_(foo, bar) foo ## bar
|
||||
|
||||
// Stringifies its argument.
|
||||
// Work around a bug in visual studio which doesn't accept code like this:
|
||||
|
|
@ -101,21 +98,21 @@ namespace testing {
|
|||
|
||||
// Forward declarations.
|
||||
|
||||
class AssertionResult; // Result of an assertion.
|
||||
class Message; // Represents a failure message.
|
||||
class Test; // Represents a test.
|
||||
class TestInfo; // Information about a test.
|
||||
class TestPartResult; // Result of a test part.
|
||||
class UnitTest; // A collection of test suites.
|
||||
class AssertionResult; // Result of an assertion.
|
||||
class Message; // Represents a failure message.
|
||||
class Test; // Represents a test.
|
||||
class TestInfo; // Information about a test.
|
||||
class TestPartResult; // Result of a test part.
|
||||
class UnitTest; // A collection of test suites.
|
||||
|
||||
template <typename T>
|
||||
::std::string PrintToString(const T& value);
|
||||
|
||||
namespace internal {
|
||||
|
||||
struct TraceInfo; // Information about a trace point.
|
||||
class TestInfoImpl; // Opaque implementation of TestInfo
|
||||
class UnitTestImpl; // Opaque implementation of UnitTest
|
||||
struct TraceInfo; // Information about a trace point.
|
||||
class TestInfoImpl; // Opaque implementation of TestInfo
|
||||
class UnitTestImpl; // Opaque implementation of UnitTest
|
||||
|
||||
// The text used in failure messages to indicate the start of the
|
||||
// stack trace.
|
||||
|
|
@ -124,7 +121,6 @@ GTEST_API_ extern const char kStackTraceMarker[];
|
|||
// An IgnoredValue object can be implicitly constructed from ANY value.
|
||||
class IgnoredValue {
|
||||
struct Sink {};
|
||||
|
||||
public:
|
||||
// This constructor template allows any value to be implicitly
|
||||
// converted to IgnoredValue. The object has no data member and
|
||||
|
|
@ -140,13 +136,13 @@ class IgnoredValue {
|
|||
};
|
||||
|
||||
// Appends the user-supplied message to the Google-Test-generated message.
|
||||
GTEST_API_ std::string AppendUserMessage(const std::string& gtest_msg,
|
||||
const Message& user_msg);
|
||||
GTEST_API_ std::string AppendUserMessage(
|
||||
const std::string& gtest_msg, const Message& user_msg);
|
||||
|
||||
#if GTEST_HAS_EXCEPTIONS
|
||||
|
||||
GTEST_DISABLE_MSC_WARNINGS_PUSH_(
|
||||
4275 /* an exported class was derived from a class that was not exported */)
|
||||
GTEST_DISABLE_MSC_WARNINGS_PUSH_(4275 \
|
||||
/* an exported class was derived from a class that was not exported */)
|
||||
|
||||
// This exception is thrown by (and only by) a failed Google Test
|
||||
// assertion when GTEST_FLAG(throw_on_failure) is true (if exceptions
|
||||
|
|
@ -185,6 +181,14 @@ GTEST_API_ std::string CreateUnifiedDiff(const std::vector<std::string>& left,
|
|||
|
||||
} // namespace edit_distance
|
||||
|
||||
// Calculate the diff between 'left' and 'right' and return it in unified diff
|
||||
// format.
|
||||
// If not null, stores in 'total_line_count' the total number of lines found
|
||||
// in left + right.
|
||||
GTEST_API_ std::string DiffStrings(const std::string& left,
|
||||
const std::string& right,
|
||||
size_t* total_line_count);
|
||||
|
||||
// Constructs and returns the message for an equality assertion
|
||||
// (e.g. ASSERT_EQ, EXPECT_STREQ, etc) failure.
|
||||
//
|
||||
|
|
@ -208,8 +212,10 @@ GTEST_API_ AssertionResult EqFailure(const char* expected_expression,
|
|||
|
||||
// Constructs a failure message for Boolean assertions such as EXPECT_TRUE.
|
||||
GTEST_API_ std::string GetBoolAssertionFailureMessage(
|
||||
const AssertionResult& assertion_result, const char* expression_text,
|
||||
const char* actual_predicate_value, const char* expected_predicate_value);
|
||||
const AssertionResult& assertion_result,
|
||||
const char* expression_text,
|
||||
const char* actual_predicate_value,
|
||||
const char* expected_predicate_value);
|
||||
|
||||
// This template class represents an IEEE floating-point number
|
||||
// (either single-precision or double-precision, depending on the
|
||||
|
|
@ -250,11 +256,11 @@ class FloatingPoint {
|
|||
// Constants.
|
||||
|
||||
// # of bits in a number.
|
||||
static const size_t kBitCount = 8 * sizeof(RawType);
|
||||
static const size_t kBitCount = 8*sizeof(RawType);
|
||||
|
||||
// # of fraction bits in a number.
|
||||
static const size_t kFractionBitCount =
|
||||
std::numeric_limits<RawType>::digits - 1;
|
||||
std::numeric_limits<RawType>::digits - 1;
|
||||
|
||||
// # of exponent bits in a number.
|
||||
static const size_t kExponentBitCount = kBitCount - 1 - kFractionBitCount;
|
||||
|
|
@ -263,8 +269,8 @@ class FloatingPoint {
|
|||
static const Bits kSignBitMask = static_cast<Bits>(1) << (kBitCount - 1);
|
||||
|
||||
// The mask for the fraction bits.
|
||||
static const Bits kFractionBitMask = ~static_cast<Bits>(0) >>
|
||||
(kExponentBitCount + 1);
|
||||
static const Bits kFractionBitMask =
|
||||
~static_cast<Bits>(0) >> (kExponentBitCount + 1);
|
||||
|
||||
// The mask for the exponent bits.
|
||||
static const Bits kExponentBitMask = ~(kSignBitMask | kFractionBitMask);
|
||||
|
|
@ -303,7 +309,9 @@ class FloatingPoint {
|
|||
}
|
||||
|
||||
// Returns the floating-point number that represent positive infinity.
|
||||
static RawType Infinity() { return ReinterpretBits(kExponentBitMask); }
|
||||
static RawType Infinity() {
|
||||
return ReinterpretBits(kExponentBitMask);
|
||||
}
|
||||
|
||||
// Returns the maximum representable finite floating-point number.
|
||||
static RawType Max();
|
||||
|
|
@ -311,7 +319,7 @@ class FloatingPoint {
|
|||
// Non-static methods
|
||||
|
||||
// Returns the bits that represents this number.
|
||||
const Bits& bits() const { return u_.bits_; }
|
||||
const Bits &bits() const { return u_.bits_; }
|
||||
|
||||
// Returns the exponent bits of this number.
|
||||
Bits exponent_bits() const { return kExponentBitMask & u_.bits_; }
|
||||
|
|
@ -340,8 +348,8 @@ class FloatingPoint {
|
|||
// a NAN must return false.
|
||||
if (is_nan() || rhs.is_nan()) return false;
|
||||
|
||||
return DistanceBetweenSignAndMagnitudeNumbers(u_.bits_, rhs.u_.bits_) <=
|
||||
kMaxUlps;
|
||||
return DistanceBetweenSignAndMagnitudeNumbers(u_.bits_, rhs.u_.bits_)
|
||||
<= kMaxUlps;
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
@ -366,7 +374,7 @@ class FloatingPoint {
|
|||
//
|
||||
// Read http://en.wikipedia.org/wiki/Signed_number_representations
|
||||
// for more details on signed number representations.
|
||||
static Bits SignAndMagnitudeToBiased(const Bits& sam) {
|
||||
static Bits SignAndMagnitudeToBiased(const Bits &sam) {
|
||||
if (kSignBitMask & sam) {
|
||||
// sam represents a negative number.
|
||||
return ~sam + 1;
|
||||
|
|
@ -378,8 +386,8 @@ class FloatingPoint {
|
|||
|
||||
// Given two numbers in the sign-and-magnitude representation,
|
||||
// returns the distance between them as an unsigned number.
|
||||
static Bits DistanceBetweenSignAndMagnitudeNumbers(const Bits& sam1,
|
||||
const Bits& sam2) {
|
||||
static Bits DistanceBetweenSignAndMagnitudeNumbers(const Bits &sam1,
|
||||
const Bits &sam2) {
|
||||
const Bits biased1 = SignAndMagnitudeToBiased(sam1);
|
||||
const Bits biased2 = SignAndMagnitudeToBiased(sam2);
|
||||
return (biased1 >= biased2) ? (biased1 - biased2) : (biased2 - biased1);
|
||||
|
|
@ -391,13 +399,9 @@ class FloatingPoint {
|
|||
// We cannot use std::numeric_limits<T>::max() as it clashes with the max()
|
||||
// macro defined by <windows.h>.
|
||||
template <>
|
||||
inline float FloatingPoint<float>::Max() {
|
||||
return FLT_MAX;
|
||||
}
|
||||
inline float FloatingPoint<float>::Max() { return FLT_MAX; }
|
||||
template <>
|
||||
inline double FloatingPoint<double>::Max() {
|
||||
return DBL_MAX;
|
||||
}
|
||||
inline double FloatingPoint<double>::Max() { return DBL_MAX; }
|
||||
|
||||
// Typedefs the instances of the FloatingPoint template class that we
|
||||
// care to use.
|
||||
|
|
@ -457,8 +461,7 @@ class TestFactoryBase {
|
|||
TestFactoryBase() {}
|
||||
|
||||
private:
|
||||
TestFactoryBase(const TestFactoryBase&) = delete;
|
||||
TestFactoryBase& operator=(const TestFactoryBase&) = delete;
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(TestFactoryBase);
|
||||
};
|
||||
|
||||
// This class provides implementation of TeastFactoryBase interface.
|
||||
|
|
@ -507,11 +510,11 @@ inline SetUpTearDownSuiteFuncType GetNotDefaultOrNull(
|
|||
|
||||
template <typename T>
|
||||
// Note that SuiteApiResolver inherits from T because
|
||||
// SetUpTestSuite()/TearDownTestSuite() could be protected. This way
|
||||
// SetUpTestSuite()/TearDownTestSuite() could be protected. Ths way
|
||||
// SuiteApiResolver can access them.
|
||||
struct SuiteApiResolver : T {
|
||||
// testing::Test is only forward declared at this point. So we make it a
|
||||
// dependent class for the compiler to be OK with it.
|
||||
// dependend class for the compiler to be OK with it.
|
||||
using Test =
|
||||
typename std::conditional<sizeof(T) != 0, ::testing::Test, void>::type;
|
||||
|
||||
|
|
@ -651,8 +654,7 @@ inline const char* SkipComma(const char* str) {
|
|||
if (comma == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
while (IsSpace(*(++comma))) {
|
||||
}
|
||||
while (IsSpace(*(++comma))) {}
|
||||
return comma;
|
||||
}
|
||||
|
||||
|
|
@ -666,7 +668,7 @@ inline std::string GetPrefixUntilComma(const char* str) {
|
|||
// Splits a given string on a given delimiter, populating a given
|
||||
// vector with the fields.
|
||||
void SplitString(const ::std::string& str, char delimiter,
|
||||
::std::vector<::std::string>* dest);
|
||||
::std::vector< ::std::string>* dest);
|
||||
|
||||
// The default argument to the template below for the case when the user does
|
||||
// not provide a name generator.
|
||||
|
|
@ -779,13 +781,13 @@ class TypeParameterizedTestSuite {
|
|||
const std::vector<std::string>& type_names =
|
||||
GenerateNames<DefaultNameGenerator, Types>()) {
|
||||
RegisterTypeParameterizedTestSuiteInstantiation(case_name);
|
||||
std::string test_name =
|
||||
StripTrailingSpaces(GetPrefixUntilComma(test_names));
|
||||
std::string test_name = StripTrailingSpaces(
|
||||
GetPrefixUntilComma(test_names));
|
||||
if (!state->TestExists(test_name)) {
|
||||
fprintf(stderr, "Failed to get code location for test %s.%s at %s.",
|
||||
case_name, test_name.c_str(),
|
||||
FormatFileLocation(code_location.file.c_str(), code_location.line)
|
||||
.c_str());
|
||||
FormatFileLocation(code_location.file.c_str(),
|
||||
code_location.line).c_str());
|
||||
fflush(stderr);
|
||||
posix::Abort();
|
||||
}
|
||||
|
|
@ -829,8 +831,8 @@ class TypeParameterizedTestSuite<Fixture, internal::None, Types> {
|
|||
// For example, if Foo() calls Bar(), which in turn calls
|
||||
// GetCurrentOsStackTraceExceptTop(..., 1), Foo() will be included in
|
||||
// the trace but Bar() and GetCurrentOsStackTraceExceptTop() won't.
|
||||
GTEST_API_ std::string GetCurrentOsStackTraceExceptTop(UnitTest* unit_test,
|
||||
int skip_count);
|
||||
GTEST_API_ std::string GetCurrentOsStackTraceExceptTop(
|
||||
UnitTest* unit_test, int skip_count);
|
||||
|
||||
// Helpers for suppressing warnings on unreachable code or constant
|
||||
// condition.
|
||||
|
|
@ -879,8 +881,7 @@ class GTEST_API_ Random {
|
|||
|
||||
private:
|
||||
uint32_t state_;
|
||||
Random(const Random&) = delete;
|
||||
Random& operator=(const Random&) = delete;
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(Random);
|
||||
};
|
||||
|
||||
// Turns const U&, U&, const U, and U all into U.
|
||||
|
|
@ -953,9 +954,7 @@ IsContainer IsContainerTest(int /* dummy */) {
|
|||
|
||||
typedef char IsNotContainer;
|
||||
template <class C>
|
||||
IsNotContainer IsContainerTest(long /* dummy */) {
|
||||
return '\0';
|
||||
}
|
||||
IsNotContainer IsContainerTest(long /* dummy */) { return '\0'; }
|
||||
|
||||
// Trait to detect whether a type T is a hash table.
|
||||
// The heuristic used is that the type contains an inner type `hasher` and does
|
||||
|
|
@ -1018,13 +1017,11 @@ bool ArrayEq(const T* lhs, size_t size, const U* rhs);
|
|||
|
||||
// This generic version is used when k is 0.
|
||||
template <typename T, typename U>
|
||||
inline bool ArrayEq(const T& lhs, const U& rhs) {
|
||||
return lhs == rhs;
|
||||
}
|
||||
inline bool ArrayEq(const T& lhs, const U& rhs) { return lhs == rhs; }
|
||||
|
||||
// This overload is used when k >= 1.
|
||||
template <typename T, typename U, size_t N>
|
||||
inline bool ArrayEq(const T (&lhs)[N], const U (&rhs)[N]) {
|
||||
inline bool ArrayEq(const T(&lhs)[N], const U(&rhs)[N]) {
|
||||
return internal::ArrayEq(lhs, N, rhs);
|
||||
}
|
||||
|
||||
|
|
@ -1034,7 +1031,8 @@ inline bool ArrayEq(const T (&lhs)[N], const U (&rhs)[N]) {
|
|||
template <typename T, typename U>
|
||||
bool ArrayEq(const T* lhs, size_t size, const U* rhs) {
|
||||
for (size_t i = 0; i != size; i++) {
|
||||
if (!internal::ArrayEq(lhs[i], rhs[i])) return false;
|
||||
if (!internal::ArrayEq(lhs[i], rhs[i]))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
@ -1044,7 +1042,8 @@ bool ArrayEq(const T* lhs, size_t size, const U* rhs) {
|
|||
template <typename Iter, typename Element>
|
||||
Iter ArrayAwareFind(Iter begin, Iter end, const Element& elem) {
|
||||
for (Iter it = begin; it != end; ++it) {
|
||||
if (internal::ArrayEq(*it, elem)) return it;
|
||||
if (internal::ArrayEq(*it, elem))
|
||||
return it;
|
||||
}
|
||||
return end;
|
||||
}
|
||||
|
|
@ -1058,13 +1057,11 @@ void CopyArray(const T* from, size_t size, U* to);
|
|||
|
||||
// This generic version is used when k is 0.
|
||||
template <typename T, typename U>
|
||||
inline void CopyArray(const T& from, U* to) {
|
||||
*to = from;
|
||||
}
|
||||
inline void CopyArray(const T& from, U* to) { *to = from; }
|
||||
|
||||
// This overload is used when k >= 1.
|
||||
template <typename T, typename U, size_t N>
|
||||
inline void CopyArray(const T (&from)[N], U (*to)[N]) {
|
||||
inline void CopyArray(const T(&from)[N], U(*to)[N]) {
|
||||
internal::CopyArray(from, N, *to);
|
||||
}
|
||||
|
||||
|
|
@ -1117,7 +1114,8 @@ class NativeArray {
|
|||
}
|
||||
|
||||
~NativeArray() {
|
||||
if (clone_ != &NativeArray::InitRef) delete[] array_;
|
||||
if (clone_ != &NativeArray::InitRef)
|
||||
delete[] array_;
|
||||
}
|
||||
|
||||
// STL-style container methods.
|
||||
|
|
@ -1125,7 +1123,8 @@ class NativeArray {
|
|||
const_iterator begin() const { return array_; }
|
||||
const_iterator end() const { return array_ + size_; }
|
||||
bool operator==(const NativeArray& rhs) const {
|
||||
return size() == rhs.size() && ArrayEq(begin(), size(), rhs.begin());
|
||||
return size() == rhs.size() &&
|
||||
ArrayEq(begin(), size(), rhs.begin());
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
@ -1336,9 +1335,9 @@ struct tuple_size<testing::internal::FlatTuple<Ts...>>
|
|||
#endif
|
||||
} // namespace std
|
||||
|
||||
#define GTEST_MESSAGE_AT_(file, line, message, result_type) \
|
||||
::testing::internal::AssertHelper(result_type, file, line, message) = \
|
||||
::testing::Message()
|
||||
#define GTEST_MESSAGE_AT_(file, line, message, result_type) \
|
||||
::testing::internal::AssertHelper(result_type, file, line, message) \
|
||||
= ::testing::Message()
|
||||
|
||||
#define GTEST_MESSAGE_(message, result_type) \
|
||||
GTEST_MESSAGE_AT_(__FILE__, __LINE__, message, result_type)
|
||||
|
|
@ -1459,112 +1458,103 @@ class NeverThrown {
|
|||
|
||||
#endif // GTEST_HAS_EXCEPTIONS
|
||||
|
||||
#define GTEST_TEST_NO_THROW_(statement, fail) \
|
||||
GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
|
||||
if (::testing::internal::TrueWithString gtest_msg{}) { \
|
||||
try { \
|
||||
GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
|
||||
} \
|
||||
GTEST_TEST_NO_THROW_CATCH_STD_EXCEPTION_() \
|
||||
catch (...) { \
|
||||
gtest_msg.value = "it throws."; \
|
||||
goto GTEST_CONCAT_TOKEN_(gtest_label_testnothrow_, __LINE__); \
|
||||
} \
|
||||
} else \
|
||||
GTEST_CONCAT_TOKEN_(gtest_label_testnothrow_, __LINE__) \
|
||||
: fail(("Expected: " #statement " doesn't throw an exception.\n" \
|
||||
" Actual: " + \
|
||||
gtest_msg.value) \
|
||||
.c_str())
|
||||
#define GTEST_TEST_NO_THROW_(statement, fail) \
|
||||
GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
|
||||
if (::testing::internal::TrueWithString gtest_msg{}) { \
|
||||
try { \
|
||||
GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
|
||||
} \
|
||||
GTEST_TEST_NO_THROW_CATCH_STD_EXCEPTION_() \
|
||||
catch (...) { \
|
||||
gtest_msg.value = "it throws."; \
|
||||
goto GTEST_CONCAT_TOKEN_(gtest_label_testnothrow_, __LINE__); \
|
||||
} \
|
||||
} else \
|
||||
GTEST_CONCAT_TOKEN_(gtest_label_testnothrow_, __LINE__): \
|
||||
fail(("Expected: " #statement " doesn't throw an exception.\n" \
|
||||
" Actual: " + gtest_msg.value).c_str())
|
||||
|
||||
#define GTEST_TEST_ANY_THROW_(statement, fail) \
|
||||
GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
|
||||
if (::testing::internal::AlwaysTrue()) { \
|
||||
bool gtest_caught_any = false; \
|
||||
try { \
|
||||
GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
|
||||
} catch (...) { \
|
||||
gtest_caught_any = true; \
|
||||
} \
|
||||
if (!gtest_caught_any) { \
|
||||
#define GTEST_TEST_ANY_THROW_(statement, fail) \
|
||||
GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
|
||||
if (::testing::internal::AlwaysTrue()) { \
|
||||
bool gtest_caught_any = false; \
|
||||
try { \
|
||||
GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
|
||||
} \
|
||||
catch (...) { \
|
||||
gtest_caught_any = true; \
|
||||
} \
|
||||
if (!gtest_caught_any) { \
|
||||
goto GTEST_CONCAT_TOKEN_(gtest_label_testanythrow_, __LINE__); \
|
||||
} \
|
||||
} else \
|
||||
GTEST_CONCAT_TOKEN_(gtest_label_testanythrow_, __LINE__) \
|
||||
: fail("Expected: " #statement \
|
||||
" throws an exception.\n" \
|
||||
" Actual: it doesn't.")
|
||||
} \
|
||||
} else \
|
||||
GTEST_CONCAT_TOKEN_(gtest_label_testanythrow_, __LINE__): \
|
||||
fail("Expected: " #statement " throws an exception.\n" \
|
||||
" Actual: it doesn't.")
|
||||
|
||||
|
||||
// Implements Boolean test assertions such as EXPECT_TRUE. expression can be
|
||||
// either a boolean expression or an AssertionResult. text is a textual
|
||||
// representation of expression as it was passed into the EXPECT_TRUE.
|
||||
#define GTEST_TEST_BOOLEAN_(expression, text, actual, expected, fail) \
|
||||
GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
|
||||
if (const ::testing::AssertionResult gtest_ar_ = \
|
||||
::testing::AssertionResult(expression)) \
|
||||
; \
|
||||
else \
|
||||
fail(::testing::internal::GetBoolAssertionFailureMessage( \
|
||||
gtest_ar_, text, #actual, #expected) \
|
||||
.c_str())
|
||||
GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
|
||||
if (const ::testing::AssertionResult gtest_ar_ = \
|
||||
::testing::AssertionResult(expression)) \
|
||||
; \
|
||||
else \
|
||||
fail(::testing::internal::GetBoolAssertionFailureMessage(\
|
||||
gtest_ar_, text, #actual, #expected).c_str())
|
||||
|
||||
#define GTEST_TEST_NO_FATAL_FAILURE_(statement, fail) \
|
||||
GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
|
||||
if (::testing::internal::AlwaysTrue()) { \
|
||||
#define GTEST_TEST_NO_FATAL_FAILURE_(statement, fail) \
|
||||
GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
|
||||
if (::testing::internal::AlwaysTrue()) { \
|
||||
::testing::internal::HasNewFatalFailureHelper gtest_fatal_failure_checker; \
|
||||
GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
|
||||
if (gtest_fatal_failure_checker.has_new_fatal_failure()) { \
|
||||
goto GTEST_CONCAT_TOKEN_(gtest_label_testnofatal_, __LINE__); \
|
||||
} \
|
||||
} else \
|
||||
GTEST_CONCAT_TOKEN_(gtest_label_testnofatal_, __LINE__) \
|
||||
: fail("Expected: " #statement \
|
||||
" doesn't generate new fatal " \
|
||||
"failures in the current thread.\n" \
|
||||
" Actual: it does.")
|
||||
GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
|
||||
if (gtest_fatal_failure_checker.has_new_fatal_failure()) { \
|
||||
goto GTEST_CONCAT_TOKEN_(gtest_label_testnofatal_, __LINE__); \
|
||||
} \
|
||||
} else \
|
||||
GTEST_CONCAT_TOKEN_(gtest_label_testnofatal_, __LINE__): \
|
||||
fail("Expected: " #statement " doesn't generate new fatal " \
|
||||
"failures in the current thread.\n" \
|
||||
" Actual: it does.")
|
||||
|
||||
// Expands to the name of the class that implements the given test.
|
||||
#define GTEST_TEST_CLASS_NAME_(test_suite_name, test_name) \
|
||||
test_suite_name##_##test_name##_Test
|
||||
|
||||
// Helper macro for defining tests.
|
||||
#define GTEST_TEST_(test_suite_name, test_name, parent_class, parent_id) \
|
||||
static_assert(sizeof(GTEST_STRINGIFY_(test_suite_name)) > 1, \
|
||||
"test_suite_name must not be empty"); \
|
||||
static_assert(sizeof(GTEST_STRINGIFY_(test_name)) > 1, \
|
||||
"test_name must not be empty"); \
|
||||
class GTEST_TEST_CLASS_NAME_(test_suite_name, test_name) \
|
||||
: public parent_class { \
|
||||
public: \
|
||||
GTEST_TEST_CLASS_NAME_(test_suite_name, test_name)() = default; \
|
||||
~GTEST_TEST_CLASS_NAME_(test_suite_name, test_name)() override = default; \
|
||||
GTEST_TEST_CLASS_NAME_(test_suite_name, test_name) \
|
||||
(const GTEST_TEST_CLASS_NAME_(test_suite_name, test_name) &) = delete; \
|
||||
GTEST_TEST_CLASS_NAME_(test_suite_name, test_name) & operator=( \
|
||||
const GTEST_TEST_CLASS_NAME_(test_suite_name, \
|
||||
test_name) &) = delete; /* NOLINT */ \
|
||||
GTEST_TEST_CLASS_NAME_(test_suite_name, test_name) \
|
||||
(GTEST_TEST_CLASS_NAME_(test_suite_name, test_name) &&) noexcept = delete; \
|
||||
GTEST_TEST_CLASS_NAME_(test_suite_name, test_name) & operator=( \
|
||||
GTEST_TEST_CLASS_NAME_(test_suite_name, \
|
||||
test_name) &&) noexcept = delete; /* NOLINT */ \
|
||||
\
|
||||
private: \
|
||||
void TestBody() override; \
|
||||
static ::testing::TestInfo* const test_info_ GTEST_ATTRIBUTE_UNUSED_; \
|
||||
}; \
|
||||
\
|
||||
::testing::TestInfo* const GTEST_TEST_CLASS_NAME_(test_suite_name, \
|
||||
test_name)::test_info_ = \
|
||||
::testing::internal::MakeAndRegisterTestInfo( \
|
||||
#test_suite_name, #test_name, nullptr, nullptr, \
|
||||
::testing::internal::CodeLocation(__FILE__, __LINE__), (parent_id), \
|
||||
::testing::internal::SuiteApiResolver< \
|
||||
parent_class>::GetSetUpCaseOrSuite(__FILE__, __LINE__), \
|
||||
::testing::internal::SuiteApiResolver< \
|
||||
parent_class>::GetTearDownCaseOrSuite(__FILE__, __LINE__), \
|
||||
new ::testing::internal::TestFactoryImpl<GTEST_TEST_CLASS_NAME_( \
|
||||
test_suite_name, test_name)>); \
|
||||
#define GTEST_TEST_(test_suite_name, test_name, parent_class, parent_id) \
|
||||
static_assert(sizeof(GTEST_STRINGIFY_(test_suite_name)) > 1, \
|
||||
"test_suite_name must not be empty"); \
|
||||
static_assert(sizeof(GTEST_STRINGIFY_(test_name)) > 1, \
|
||||
"test_name must not be empty"); \
|
||||
class GTEST_TEST_CLASS_NAME_(test_suite_name, test_name) \
|
||||
: public parent_class { \
|
||||
public: \
|
||||
GTEST_TEST_CLASS_NAME_(test_suite_name, test_name)() = default; \
|
||||
~GTEST_TEST_CLASS_NAME_(test_suite_name, test_name)() override = default; \
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(GTEST_TEST_CLASS_NAME_(test_suite_name, \
|
||||
test_name)); \
|
||||
GTEST_DISALLOW_MOVE_AND_ASSIGN_(GTEST_TEST_CLASS_NAME_(test_suite_name, \
|
||||
test_name)); \
|
||||
\
|
||||
private: \
|
||||
void TestBody() override; \
|
||||
static ::testing::TestInfo* const test_info_ GTEST_ATTRIBUTE_UNUSED_; \
|
||||
}; \
|
||||
\
|
||||
::testing::TestInfo* const GTEST_TEST_CLASS_NAME_(test_suite_name, \
|
||||
test_name)::test_info_ = \
|
||||
::testing::internal::MakeAndRegisterTestInfo( \
|
||||
#test_suite_name, #test_name, nullptr, nullptr, \
|
||||
::testing::internal::CodeLocation(__FILE__, __LINE__), (parent_id), \
|
||||
::testing::internal::SuiteApiResolver< \
|
||||
parent_class>::GetSetUpCaseOrSuite(__FILE__, __LINE__), \
|
||||
::testing::internal::SuiteApiResolver< \
|
||||
parent_class>::GetTearDownCaseOrSuite(__FILE__, __LINE__), \
|
||||
new ::testing::internal::TestFactoryImpl<GTEST_TEST_CLASS_NAME_( \
|
||||
test_suite_name, test_name)>); \
|
||||
void GTEST_TEST_CLASS_NAME_(test_suite_name, test_name)::TestBody()
|
||||
|
||||
#endif // GOOGLETEST_INCLUDE_GTEST_INTERNAL_GTEST_INTERNAL_H_
|
||||
|
|
|
|||
|
|
@ -27,11 +27,10 @@
|
|||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
// Type and function utilities for implementing parameterized tests.
|
||||
|
||||
// IWYU pragma: private, include "gtest/gtest.h"
|
||||
// IWYU pragma: friend gtest/.*
|
||||
// IWYU pragma: friend gmock/.*
|
||||
// GOOGLETEST_CM0001 DO NOT DELETE
|
||||
|
||||
#ifndef GOOGLETEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_H_
|
||||
#define GOOGLETEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_H_
|
||||
|
|
@ -47,18 +46,19 @@
|
|||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "gtest/gtest-printers.h"
|
||||
#include "gtest/gtest-test-part.h"
|
||||
#include "gtest/internal/gtest-internal.h"
|
||||
#include "gtest/internal/gtest-port.h"
|
||||
#include "gtest/gtest-printers.h"
|
||||
#include "gtest/gtest-test-part.h"
|
||||
|
||||
namespace testing {
|
||||
// Input to a parameterized test name generator, describing a test parameter.
|
||||
// Consists of the parameter value and the integer parameter index.
|
||||
template <class ParamType>
|
||||
struct TestParamInfo {
|
||||
TestParamInfo(const ParamType& a_param, size_t an_index)
|
||||
: param(a_param), index(an_index) {}
|
||||
TestParamInfo(const ParamType& a_param, size_t an_index) :
|
||||
param(a_param),
|
||||
index(an_index) {}
|
||||
ParamType param;
|
||||
size_t index;
|
||||
};
|
||||
|
|
@ -84,10 +84,8 @@ namespace internal {
|
|||
GTEST_API_ void ReportInvalidTestSuiteType(const char* test_suite_name,
|
||||
CodeLocation code_location);
|
||||
|
||||
template <typename>
|
||||
class ParamGeneratorInterface;
|
||||
template <typename>
|
||||
class ParamGenerator;
|
||||
template <typename> class ParamGeneratorInterface;
|
||||
template <typename> class ParamGenerator;
|
||||
|
||||
// Interface for iterating over elements provided by an implementation
|
||||
// of ParamGeneratorInterface<T>.
|
||||
|
|
@ -131,7 +129,8 @@ class ParamIterator {
|
|||
// ParamIterator assumes ownership of the impl_ pointer.
|
||||
ParamIterator(const ParamIterator& other) : impl_(other.impl_->Clone()) {}
|
||||
ParamIterator& operator=(const ParamIterator& other) {
|
||||
if (this != &other) impl_.reset(other.impl_->Clone());
|
||||
if (this != &other)
|
||||
impl_.reset(other.impl_->Clone());
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
|
@ -158,7 +157,7 @@ class ParamIterator {
|
|||
private:
|
||||
friend class ParamGenerator<T>;
|
||||
explicit ParamIterator(ParamIteratorInterface<T>* impl) : impl_(impl) {}
|
||||
std::unique_ptr<ParamIteratorInterface<T>> impl_;
|
||||
std::unique_ptr<ParamIteratorInterface<T> > impl_;
|
||||
};
|
||||
|
||||
// ParamGeneratorInterface<T> is the binary interface to access generators
|
||||
|
|
@ -180,7 +179,7 @@ class ParamGeneratorInterface {
|
|||
// This class implements copy initialization semantics and the contained
|
||||
// ParamGeneratorInterface<T> instance is shared among all copies
|
||||
// of the original object. This is possible because that instance is immutable.
|
||||
template <typename T>
|
||||
template<typename T>
|
||||
class ParamGenerator {
|
||||
public:
|
||||
typedef ParamIterator<T> iterator;
|
||||
|
|
@ -197,7 +196,7 @@ class ParamGenerator {
|
|||
iterator end() const { return iterator(impl_->End()); }
|
||||
|
||||
private:
|
||||
std::shared_ptr<const ParamGeneratorInterface<T>> impl_;
|
||||
std::shared_ptr<const ParamGeneratorInterface<T> > impl_;
|
||||
};
|
||||
|
||||
// Generates values from a range of two comparable values. Can be used to
|
||||
|
|
@ -208,10 +207,8 @@ template <typename T, typename IncrementT>
|
|||
class RangeGenerator : public ParamGeneratorInterface<T> {
|
||||
public:
|
||||
RangeGenerator(T begin, T end, IncrementT step)
|
||||
: begin_(begin),
|
||||
end_(end),
|
||||
step_(step),
|
||||
end_index_(CalculateEndIndex(begin, end, step)) {}
|
||||
: begin_(begin), end_(end),
|
||||
step_(step), end_index_(CalculateEndIndex(begin, end, step)) {}
|
||||
~RangeGenerator() override {}
|
||||
|
||||
ParamIteratorInterface<T>* Begin() const override {
|
||||
|
|
@ -254,9 +251,7 @@ class RangeGenerator : public ParamGeneratorInterface<T> {
|
|||
private:
|
||||
Iterator(const Iterator& other)
|
||||
: ParamIteratorInterface<T>(),
|
||||
base_(other.base_),
|
||||
value_(other.value_),
|
||||
index_(other.index_),
|
||||
base_(other.base_), value_(other.value_), index_(other.index_),
|
||||
step_(other.step_) {}
|
||||
|
||||
// No implementation - assignment is unsupported.
|
||||
|
|
@ -268,10 +263,12 @@ class RangeGenerator : public ParamGeneratorInterface<T> {
|
|||
const IncrementT step_;
|
||||
}; // class RangeGenerator::Iterator
|
||||
|
||||
static int CalculateEndIndex(const T& begin, const T& end,
|
||||
static int CalculateEndIndex(const T& begin,
|
||||
const T& end,
|
||||
const IncrementT& step) {
|
||||
int end_index = 0;
|
||||
for (T i = begin; i < end; i = static_cast<T>(i + step)) end_index++;
|
||||
for (T i = begin; i < end; i = static_cast<T>(i + step))
|
||||
end_index++;
|
||||
return end_index;
|
||||
}
|
||||
|
||||
|
|
@ -286,6 +283,7 @@ class RangeGenerator : public ParamGeneratorInterface<T> {
|
|||
const int end_index_;
|
||||
}; // class RangeGenerator
|
||||
|
||||
|
||||
// Generates values from a pair of STL-style iterators. Used in the
|
||||
// ValuesIn() function. The elements are copied from the source range
|
||||
// since the source can be located on the stack, and the generator
|
||||
|
|
@ -343,13 +341,13 @@ class ValuesInIteratorRangeGenerator : public ParamGeneratorInterface<T> {
|
|||
<< "The program attempted to compare iterators "
|
||||
<< "from different generators." << std::endl;
|
||||
return iterator_ ==
|
||||
CheckedDowncastToActualType<const Iterator>(&other)->iterator_;
|
||||
CheckedDowncastToActualType<const Iterator>(&other)->iterator_;
|
||||
}
|
||||
|
||||
private:
|
||||
Iterator(const Iterator& other)
|
||||
// The explicit constructor call suppresses a false warning
|
||||
// emitted by gcc when supplied with the -Wextra option.
|
||||
// The explicit constructor call suppresses a false warning
|
||||
// emitted by gcc when supplied with the -Wextra option.
|
||||
: ParamIteratorInterface<T>(),
|
||||
base_(other.base_),
|
||||
iterator_(other.iterator_) {}
|
||||
|
|
@ -396,8 +394,8 @@ template <class TestClass>
|
|||
class ParameterizedTestFactory : public TestFactoryBase {
|
||||
public:
|
||||
typedef typename TestClass::ParamType ParamType;
|
||||
explicit ParameterizedTestFactory(ParamType parameter)
|
||||
: parameter_(parameter) {}
|
||||
explicit ParameterizedTestFactory(ParamType parameter) :
|
||||
parameter_(parameter) {}
|
||||
Test* CreateTest() override {
|
||||
TestClass::SetParam(¶meter_);
|
||||
return new TestClass();
|
||||
|
|
@ -406,8 +404,7 @@ class ParameterizedTestFactory : public TestFactoryBase {
|
|||
private:
|
||||
const ParamType parameter_;
|
||||
|
||||
ParameterizedTestFactory(const ParameterizedTestFactory&) = delete;
|
||||
ParameterizedTestFactory& operator=(const ParameterizedTestFactory&) = delete;
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(ParameterizedTestFactory);
|
||||
};
|
||||
|
||||
// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
|
||||
|
|
@ -443,8 +440,7 @@ class TestMetaFactory
|
|||
}
|
||||
|
||||
private:
|
||||
TestMetaFactory(const TestMetaFactory&) = delete;
|
||||
TestMetaFactory& operator=(const TestMetaFactory&) = delete;
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(TestMetaFactory);
|
||||
};
|
||||
|
||||
// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
|
||||
|
|
@ -475,10 +471,7 @@ class ParameterizedTestSuiteInfoBase {
|
|||
ParameterizedTestSuiteInfoBase() {}
|
||||
|
||||
private:
|
||||
ParameterizedTestSuiteInfoBase(const ParameterizedTestSuiteInfoBase&) =
|
||||
delete;
|
||||
ParameterizedTestSuiteInfoBase& operator=(
|
||||
const ParameterizedTestSuiteInfoBase&) = delete;
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(ParameterizedTestSuiteInfoBase);
|
||||
};
|
||||
|
||||
// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
|
||||
|
|
@ -554,8 +547,8 @@ class ParameterizedTestSuiteInfo : public ParameterizedTestSuiteInfoBase {
|
|||
test_it != tests_.end(); ++test_it) {
|
||||
std::shared_ptr<TestInfo> test_info = *test_it;
|
||||
for (typename InstantiationContainer::iterator gen_it =
|
||||
instantiations_.begin();
|
||||
gen_it != instantiations_.end(); ++gen_it) {
|
||||
instantiations_.begin(); gen_it != instantiations_.end();
|
||||
++gen_it) {
|
||||
const std::string& instantiation_name = gen_it->name;
|
||||
ParamGenerator<ParamType> generator((*gen_it->generator)());
|
||||
ParamNameGeneratorFunc* name_func = gen_it->name_func;
|
||||
|
|
@ -563,7 +556,7 @@ class ParameterizedTestSuiteInfo : public ParameterizedTestSuiteInfoBase {
|
|||
int line = gen_it->line;
|
||||
|
||||
std::string test_suite_name;
|
||||
if (!instantiation_name.empty())
|
||||
if ( !instantiation_name.empty() )
|
||||
test_suite_name = instantiation_name + "/";
|
||||
test_suite_name += test_info->test_suite_base_name;
|
||||
|
||||
|
|
@ -576,16 +569,17 @@ class ParameterizedTestSuiteInfo : public ParameterizedTestSuiteInfoBase {
|
|||
|
||||
Message test_name_stream;
|
||||
|
||||
std::string param_name =
|
||||
name_func(TestParamInfo<ParamType>(*param_it, i));
|
||||
std::string param_name = name_func(
|
||||
TestParamInfo<ParamType>(*param_it, i));
|
||||
|
||||
GTEST_CHECK_(IsValidParamName(param_name))
|
||||
<< "Parameterized test name '" << param_name
|
||||
<< "' is invalid, in " << file << " line " << line << std::endl;
|
||||
<< "' is invalid, in " << file
|
||||
<< " line " << line << std::endl;
|
||||
|
||||
GTEST_CHECK_(test_param_names.count(param_name) == 0)
|
||||
<< "Duplicate parameterized test name '" << param_name << "', in "
|
||||
<< file << " line " << line << std::endl;
|
||||
<< "Duplicate parameterized test name '" << param_name
|
||||
<< "', in " << file << " line " << line << std::endl;
|
||||
|
||||
test_param_names.insert(param_name);
|
||||
|
||||
|
|
@ -602,15 +596,15 @@ class ParameterizedTestSuiteInfo : public ParameterizedTestSuiteInfoBase {
|
|||
SuiteApiResolver<TestSuite>::GetTearDownCaseOrSuite(file, line),
|
||||
test_info->test_meta_factory->CreateTestFactory(*param_it));
|
||||
} // for param_it
|
||||
} // for gen_it
|
||||
} // for test_it
|
||||
} // for gen_it
|
||||
} // for test_it
|
||||
|
||||
if (!generated_instantiations) {
|
||||
// There are no generaotrs, or they all generate nothing ...
|
||||
InsertSyntheticTestCase(GetTestSuiteName(), code_location_,
|
||||
!tests_.empty());
|
||||
}
|
||||
} // RegisterTests
|
||||
} // RegisterTests
|
||||
|
||||
private:
|
||||
// LocalTestInfo structure keeps information about a single test registered
|
||||
|
|
@ -626,39 +620,42 @@ class ParameterizedTestSuiteInfo : public ParameterizedTestSuiteInfoBase {
|
|||
|
||||
const std::string test_suite_base_name;
|
||||
const std::string test_base_name;
|
||||
const std::unique_ptr<TestMetaFactoryBase<ParamType>> test_meta_factory;
|
||||
const std::unique_ptr<TestMetaFactoryBase<ParamType> > test_meta_factory;
|
||||
const CodeLocation code_location;
|
||||
};
|
||||
using TestInfoContainer = ::std::vector<std::shared_ptr<TestInfo>>;
|
||||
using TestInfoContainer = ::std::vector<std::shared_ptr<TestInfo> >;
|
||||
// Records data received from INSTANTIATE_TEST_SUITE_P macros:
|
||||
// <Instantiation name, Sequence generator creation function,
|
||||
// Name generator function, Source file, Source line>
|
||||
struct InstantiationInfo {
|
||||
InstantiationInfo(const std::string& name_in,
|
||||
GeneratorCreationFunc* generator_in,
|
||||
ParamNameGeneratorFunc* name_func_in, const char* file_in,
|
||||
int line_in)
|
||||
: name(name_in),
|
||||
generator(generator_in),
|
||||
name_func(name_func_in),
|
||||
file(file_in),
|
||||
line(line_in) {}
|
||||
InstantiationInfo(const std::string &name_in,
|
||||
GeneratorCreationFunc* generator_in,
|
||||
ParamNameGeneratorFunc* name_func_in,
|
||||
const char* file_in,
|
||||
int line_in)
|
||||
: name(name_in),
|
||||
generator(generator_in),
|
||||
name_func(name_func_in),
|
||||
file(file_in),
|
||||
line(line_in) {}
|
||||
|
||||
std::string name;
|
||||
GeneratorCreationFunc* generator;
|
||||
ParamNameGeneratorFunc* name_func;
|
||||
const char* file;
|
||||
int line;
|
||||
std::string name;
|
||||
GeneratorCreationFunc* generator;
|
||||
ParamNameGeneratorFunc* name_func;
|
||||
const char* file;
|
||||
int line;
|
||||
};
|
||||
typedef ::std::vector<InstantiationInfo> InstantiationContainer;
|
||||
|
||||
static bool IsValidParamName(const std::string& name) {
|
||||
// Check for empty string
|
||||
if (name.empty()) return false;
|
||||
if (name.empty())
|
||||
return false;
|
||||
|
||||
// Check for invalid characters
|
||||
for (std::string::size_type index = 0; index < name.size(); ++index) {
|
||||
if (!IsAlNum(name[index]) && name[index] != '_') return false;
|
||||
if (!IsAlNum(name[index]) && name[index] != '_')
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
@ -669,9 +666,7 @@ class ParameterizedTestSuiteInfo : public ParameterizedTestSuiteInfoBase {
|
|||
TestInfoContainer tests_;
|
||||
InstantiationContainer instantiations_;
|
||||
|
||||
ParameterizedTestSuiteInfo(const ParameterizedTestSuiteInfo&) = delete;
|
||||
ParameterizedTestSuiteInfo& operator=(const ParameterizedTestSuiteInfo&) =
|
||||
delete;
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(ParameterizedTestSuiteInfo);
|
||||
}; // class ParameterizedTestSuiteInfo
|
||||
|
||||
// Legacy API is deprecated but still available
|
||||
|
|
@ -714,7 +709,7 @@ class ParameterizedTestSuiteRegistry {
|
|||
// type we are looking for, so we downcast it to that type
|
||||
// without further checks.
|
||||
typed_test_info = CheckedDowncastToActualType<
|
||||
ParameterizedTestSuiteInfo<TestSuite>>(test_suite_info);
|
||||
ParameterizedTestSuiteInfo<TestSuite> >(test_suite_info);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
@ -746,10 +741,7 @@ class ParameterizedTestSuiteRegistry {
|
|||
|
||||
TestSuiteInfoContainer test_suite_infos_;
|
||||
|
||||
ParameterizedTestSuiteRegistry(const ParameterizedTestSuiteRegistry&) =
|
||||
delete;
|
||||
ParameterizedTestSuiteRegistry& operator=(
|
||||
const ParameterizedTestSuiteRegistry&) = delete;
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(ParameterizedTestSuiteRegistry);
|
||||
};
|
||||
|
||||
// Keep track of what type-parameterized test suite are defined and
|
||||
|
|
@ -844,8 +836,7 @@ class CartesianProductGenerator
|
|||
: public ParamIteratorInterface<ParamType> {
|
||||
public:
|
||||
IteratorImpl(const ParamGeneratorInterface<ParamType>* base,
|
||||
const std::tuple<ParamGenerator<T>...>& generators,
|
||||
bool is_end)
|
||||
const std::tuple<ParamGenerator<T>...>& generators, bool is_end)
|
||||
: base_(base),
|
||||
begin_(std::get<I>(generators).begin()...),
|
||||
end_(std::get<I>(generators).end()...),
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@
|
|||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
//
|
||||
// The Google C++ Testing and Mocking Framework (Google Test)
|
||||
//
|
||||
// This header file defines the GTEST_OS_* macro.
|
||||
|
|
@ -37,72 +37,70 @@
|
|||
|
||||
// Determines the platform on which Google Test is compiled.
|
||||
#ifdef __CYGWIN__
|
||||
#define GTEST_OS_CYGWIN 1
|
||||
#elif defined(__MINGW__) || defined(__MINGW32__) || defined(__MINGW64__)
|
||||
#define GTEST_OS_WINDOWS_MINGW 1
|
||||
#define GTEST_OS_WINDOWS 1
|
||||
# define GTEST_OS_CYGWIN 1
|
||||
# elif defined(__MINGW__) || defined(__MINGW32__) || defined(__MINGW64__)
|
||||
# define GTEST_OS_WINDOWS_MINGW 1
|
||||
# define GTEST_OS_WINDOWS 1
|
||||
#elif defined _WIN32
|
||||
#define GTEST_OS_WINDOWS 1
|
||||
#ifdef _WIN32_WCE
|
||||
#define GTEST_OS_WINDOWS_MOBILE 1
|
||||
#elif defined(WINAPI_FAMILY)
|
||||
#include <winapifamily.h>
|
||||
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
|
||||
#define GTEST_OS_WINDOWS_DESKTOP 1
|
||||
#elif WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_PHONE_APP)
|
||||
#define GTEST_OS_WINDOWS_PHONE 1
|
||||
#elif WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)
|
||||
#define GTEST_OS_WINDOWS_RT 1
|
||||
#elif WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_TV_TITLE)
|
||||
#define GTEST_OS_WINDOWS_PHONE 1
|
||||
#define GTEST_OS_WINDOWS_TV_TITLE 1
|
||||
#else
|
||||
// WINAPI_FAMILY defined but no known partition matched.
|
||||
// Default to desktop.
|
||||
#define GTEST_OS_WINDOWS_DESKTOP 1
|
||||
#endif
|
||||
#else
|
||||
#define GTEST_OS_WINDOWS_DESKTOP 1
|
||||
#endif // _WIN32_WCE
|
||||
# define GTEST_OS_WINDOWS 1
|
||||
# ifdef _WIN32_WCE
|
||||
# define GTEST_OS_WINDOWS_MOBILE 1
|
||||
# elif defined(WINAPI_FAMILY)
|
||||
# include <winapifamily.h>
|
||||
# if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
|
||||
# define GTEST_OS_WINDOWS_DESKTOP 1
|
||||
# elif WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_PHONE_APP)
|
||||
# define GTEST_OS_WINDOWS_PHONE 1
|
||||
# elif WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)
|
||||
# define GTEST_OS_WINDOWS_RT 1
|
||||
# elif WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_TV_TITLE)
|
||||
# define GTEST_OS_WINDOWS_PHONE 1
|
||||
# define GTEST_OS_WINDOWS_TV_TITLE 1
|
||||
# else
|
||||
// WINAPI_FAMILY defined but no known partition matched.
|
||||
// Default to desktop.
|
||||
# define GTEST_OS_WINDOWS_DESKTOP 1
|
||||
# endif
|
||||
# else
|
||||
# define GTEST_OS_WINDOWS_DESKTOP 1
|
||||
# endif // _WIN32_WCE
|
||||
#elif defined __OS2__
|
||||
#define GTEST_OS_OS2 1
|
||||
# define GTEST_OS_OS2 1
|
||||
#elif defined __APPLE__
|
||||
#define GTEST_OS_MAC 1
|
||||
#include <TargetConditionals.h>
|
||||
#if TARGET_OS_IPHONE
|
||||
#define GTEST_OS_IOS 1
|
||||
#endif
|
||||
# define GTEST_OS_MAC 1
|
||||
# include <TargetConditionals.h>
|
||||
# if TARGET_OS_IPHONE
|
||||
# define GTEST_OS_IOS 1
|
||||
# endif
|
||||
#elif defined __DragonFly__
|
||||
#define GTEST_OS_DRAGONFLY 1
|
||||
# define GTEST_OS_DRAGONFLY 1
|
||||
#elif defined __FreeBSD__
|
||||
#define GTEST_OS_FREEBSD 1
|
||||
# define GTEST_OS_FREEBSD 1
|
||||
#elif defined __Fuchsia__
|
||||
#define GTEST_OS_FUCHSIA 1
|
||||
#elif defined(__GNU__)
|
||||
#define GTEST_OS_GNU_HURD 1
|
||||
# define GTEST_OS_FUCHSIA 1
|
||||
#elif defined(__GLIBC__) && defined(__FreeBSD_kernel__)
|
||||
#define GTEST_OS_GNU_KFREEBSD 1
|
||||
# define GTEST_OS_GNU_KFREEBSD 1
|
||||
#elif defined __linux__
|
||||
#define GTEST_OS_LINUX 1
|
||||
#if defined __ANDROID__
|
||||
#define GTEST_OS_LINUX_ANDROID 1
|
||||
#endif
|
||||
# define GTEST_OS_LINUX 1
|
||||
# if defined __ANDROID__
|
||||
# define GTEST_OS_LINUX_ANDROID 1
|
||||
# endif
|
||||
#elif defined __MVS__
|
||||
#define GTEST_OS_ZOS 1
|
||||
# define GTEST_OS_ZOS 1
|
||||
#elif defined(__sun) && defined(__SVR4)
|
||||
#define GTEST_OS_SOLARIS 1
|
||||
# define GTEST_OS_SOLARIS 1
|
||||
#elif defined(_AIX)
|
||||
#define GTEST_OS_AIX 1
|
||||
# define GTEST_OS_AIX 1
|
||||
#elif defined(__hpux)
|
||||
#define GTEST_OS_HPUX 1
|
||||
# define GTEST_OS_HPUX 1
|
||||
#elif defined __native_client__
|
||||
#define GTEST_OS_NACL 1
|
||||
# define GTEST_OS_NACL 1
|
||||
#elif defined __NetBSD__
|
||||
#define GTEST_OS_NETBSD 1
|
||||
# define GTEST_OS_NETBSD 1
|
||||
#elif defined __OpenBSD__
|
||||
#define GTEST_OS_OPENBSD 1
|
||||
# define GTEST_OS_OPENBSD 1
|
||||
#elif defined __QNX__
|
||||
#define GTEST_OS_QNX 1
|
||||
# define GTEST_OS_QNX 1
|
||||
#elif defined(__HAIKU__)
|
||||
#define GTEST_OS_HAIKU 1
|
||||
#elif defined ESP8266
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -26,7 +26,7 @@
|
|||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
//
|
||||
// The Google C++ Testing and Mocking Framework (Google Test)
|
||||
//
|
||||
// This header file declares the String class and functions used internally by
|
||||
|
|
@ -36,20 +36,17 @@
|
|||
// This header file is #included by gtest-internal.h.
|
||||
// It should not be #included by other files.
|
||||
|
||||
// IWYU pragma: private, include "gtest/gtest.h"
|
||||
// IWYU pragma: friend gtest/.*
|
||||
// IWYU pragma: friend gmock/.*
|
||||
// GOOGLETEST_CM0001 DO NOT DELETE
|
||||
|
||||
#ifndef GOOGLETEST_INCLUDE_GTEST_INTERNAL_GTEST_STRING_H_
|
||||
#define GOOGLETEST_INCLUDE_GTEST_INTERNAL_GTEST_STRING_H_
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
// string.h is not guaranteed to provide strcpy on C++ Builder.
|
||||
#include <mem.h>
|
||||
# include <mem.h>
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
|
|
@ -126,7 +123,8 @@ class GTEST_API_ String {
|
|||
// Unlike strcasecmp(), this function can handle NULL argument(s).
|
||||
// A NULL C string is considered different to any non-NULL C string,
|
||||
// including the empty string.
|
||||
static bool CaseInsensitiveCStringEquals(const char* lhs, const char* rhs);
|
||||
static bool CaseInsensitiveCStringEquals(const char* lhs,
|
||||
const char* rhs);
|
||||
|
||||
// Compares two wide C strings, ignoring case. Returns true if and only if
|
||||
// they have the same content.
|
||||
|
|
@ -145,8 +143,8 @@ class GTEST_API_ String {
|
|||
|
||||
// Returns true if and only if the given string ends with the given suffix,
|
||||
// ignoring case. Any string is considered to end with an empty suffix.
|
||||
static bool EndsWithCaseInsensitive(const std::string& str,
|
||||
const std::string& suffix);
|
||||
static bool EndsWithCaseInsensitive(
|
||||
const std::string& str, const std::string& suffix);
|
||||
|
||||
// Formats an int value as "%02d".
|
||||
static std::string FormatIntWidth2(int value); // "%02d" for width == 2
|
||||
|
|
@ -165,7 +163,7 @@ class GTEST_API_ String {
|
|||
|
||||
private:
|
||||
String(); // Not meant to be instantiated.
|
||||
}; // class String
|
||||
}; // class String
|
||||
|
||||
// Gets the content of the stringstream's buffer as an std::string. Each '\0'
|
||||
// character in the buffer is replaced with "\\0".
|
||||
|
|
|
|||
|
|
@ -30,9 +30,7 @@
|
|||
// Type utilities needed for implementing typed and type-parameterized
|
||||
// tests.
|
||||
|
||||
// IWYU pragma: private, include "gtest/gtest.h"
|
||||
// IWYU pragma: friend gtest/.*
|
||||
// IWYU pragma: friend gmock/.*
|
||||
// GOOGLETEST_CM0001 DO NOT DELETE
|
||||
|
||||
#ifndef GOOGLETEST_INCLUDE_GTEST_INTERNAL_GTEST_TYPE_UTIL_H_
|
||||
#define GOOGLETEST_INCLUDE_GTEST_INTERNAL_GTEST_TYPE_UTIL_H_
|
||||
|
|
@ -41,11 +39,11 @@
|
|||
|
||||
// #ifdef __GNUC__ is too general here. It is possible to use gcc without using
|
||||
// libstdc++ (which is where cxxabi.h comes from).
|
||||
#if GTEST_HAS_CXXABI_H_
|
||||
#include <cxxabi.h>
|
||||
#elif defined(__HP_aCC)
|
||||
#include <acxx_demangle.h>
|
||||
#endif // GTEST_HASH_CXXABI_H_
|
||||
# if GTEST_HAS_CXXABI_H_
|
||||
# include <cxxabi.h>
|
||||
# elif defined(__HP_aCC)
|
||||
# include <acxx_demangle.h>
|
||||
# endif // GTEST_HASH_CXXABI_H_
|
||||
|
||||
namespace testing {
|
||||
namespace internal {
|
||||
|
|
@ -103,9 +101,7 @@ std::string GetTypeName() {
|
|||
// A unique type indicating an empty node
|
||||
struct None {};
|
||||
|
||||
#define GTEST_TEMPLATE_ \
|
||||
template <typename T> \
|
||||
class
|
||||
# define GTEST_TEMPLATE_ template <typename T> class
|
||||
|
||||
// The template "selector" struct TemplateSel<Tmpl> is used to
|
||||
// represent Tmpl, which must be a class template with one type
|
||||
|
|
@ -123,7 +119,8 @@ struct TemplateSel {
|
|||
};
|
||||
};
|
||||
|
||||
#define GTEST_BIND_(TmplSel, T) TmplSel::template Bind<T>::type
|
||||
# define GTEST_BIND_(TmplSel, T) \
|
||||
TmplSel::template Bind<T>::type
|
||||
|
||||
template <GTEST_TEMPLATE_ Head_, GTEST_TEMPLATE_... Tail_>
|
||||
struct Templates {
|
||||
|
|
|
|||
|
|
@ -27,6 +27,8 @@
|
|||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
|
||||
// This provides interface PrimeTable that determines whether a number is a
|
||||
// prime and determines a next prime number. This interface is used
|
||||
// in Google Test samples demonstrating use of parameterized tests.
|
||||
|
|
@ -55,7 +57,7 @@ class OnTheFlyPrimeTable : public PrimeTable {
|
|||
bool IsPrime(int n) const override {
|
||||
if (n <= 1) return false;
|
||||
|
||||
for (int i = 2; i * i <= n; i++) {
|
||||
for (int i = 2; i*i <= n; i++) {
|
||||
// n is divisible by an integer other than 1 and itself.
|
||||
if ((n % i) == 0) return false;
|
||||
}
|
||||
|
|
@ -102,13 +104,13 @@ class PreCalculatedPrimeTable : public PrimeTable {
|
|||
|
||||
// Checks every candidate for prime number (we know that 2 is the only even
|
||||
// prime).
|
||||
for (int i = 2; i * i <= max; i += i % 2 + 1) {
|
||||
for (int i = 2; i*i <= max; i += i%2+1) {
|
||||
if (!is_prime_[i]) continue;
|
||||
|
||||
// Marks all multiples of i (except i itself) as non-prime.
|
||||
// We are starting here from i-th multiplier, because all smaller
|
||||
// complex numbers were already marked.
|
||||
for (int j = i * i; j <= max; j += i) {
|
||||
for (int j = i*i; j <= max; j += i) {
|
||||
is_prime_[j] = false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,9 +52,9 @@ bool IsPrime(int n) {
|
|||
// Now, we have that n is odd and n >= 3.
|
||||
|
||||
// Try to divide n by every odd number i, starting from 3
|
||||
for (int i = 3;; i += 2) {
|
||||
for (int i = 3; ; i += 2) {
|
||||
// We only have to try i up to the square root of n
|
||||
if (i > n / i) break;
|
||||
if (i > n/i) break;
|
||||
|
||||
// Now, we have i <= n/i < n.
|
||||
// If n is divisible by i, n is not prime.
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@
|
|||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
// This sample shows how to use Google Test listener API to implement
|
||||
// a primitive leak checker.
|
||||
|
||||
|
|
@ -103,15 +104,14 @@ TEST(ListenersTest, LeaksWater) {
|
|||
}
|
||||
} // namespace
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
int main(int argc, char **argv) {
|
||||
InitGoogleTest(&argc, argv);
|
||||
|
||||
bool check_for_leaks = false;
|
||||
if (argc > 1 && strcmp(argv[1], "--check_for_leaks") == 0)
|
||||
if (argc > 1 && strcmp(argv[1], "--check_for_leaks") == 0 )
|
||||
check_for_leaks = true;
|
||||
else
|
||||
printf("%s\n",
|
||||
"Run this program with --check_for_leaks to enable "
|
||||
printf("%s\n", "Run this program with --check_for_leaks to enable "
|
||||
"custom leak checking in the tests.");
|
||||
|
||||
// If we are given the --check_for_leaks command line flag, installs the
|
||||
|
|
|
|||
|
|
@ -34,15 +34,14 @@
|
|||
//
|
||||
// Writing a unit test using Google C++ testing framework is easy as 1-2-3:
|
||||
|
||||
|
||||
// Step 1. Include necessary header files such that the stuff your
|
||||
// test logic needs is declared.
|
||||
//
|
||||
// Don't forget gtest.h, which declares the testing framework.
|
||||
|
||||
#include "sample1.h"
|
||||
|
||||
#include <limits.h>
|
||||
|
||||
#include "sample1.h"
|
||||
#include "gtest/gtest.h"
|
||||
namespace {
|
||||
|
||||
|
|
@ -70,6 +69,7 @@ namespace {
|
|||
//
|
||||
// </TechnicalDetails>
|
||||
|
||||
|
||||
// Tests Factorial().
|
||||
|
||||
// Tests factorial of negative numbers.
|
||||
|
|
@ -97,7 +97,9 @@ TEST(FactorialTest, Negative) {
|
|||
}
|
||||
|
||||
// Tests factorial of 0.
|
||||
TEST(FactorialTest, Zero) { EXPECT_EQ(1, Factorial(0)); }
|
||||
TEST(FactorialTest, Zero) {
|
||||
EXPECT_EQ(1, Factorial(0));
|
||||
}
|
||||
|
||||
// Tests factorial of positive numbers.
|
||||
TEST(FactorialTest, Positive) {
|
||||
|
|
@ -107,6 +109,7 @@ TEST(FactorialTest, Positive) {
|
|||
EXPECT_EQ(40320, Factorial(8));
|
||||
}
|
||||
|
||||
|
||||
// Tests IsPrime()
|
||||
|
||||
// Tests negative input.
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ const char* MyString::CloneCString(const char* a_c_string) {
|
|||
if (a_c_string == nullptr) return nullptr;
|
||||
|
||||
const size_t len = strlen(a_c_string);
|
||||
char* const clone = new char[len + 1];
|
||||
char* const clone = new char[ len + 1 ];
|
||||
memcpy(clone, a_c_string, len + 1);
|
||||
|
||||
return clone;
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@
|
|||
|
||||
#include <string.h>
|
||||
|
||||
|
||||
// A simple string class.
|
||||
class MyString {
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -38,7 +38,6 @@
|
|||
// needed.
|
||||
|
||||
#include "sample2.h"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
namespace {
|
||||
// In this example, we test the MyString class (a simple string).
|
||||
|
|
@ -78,7 +77,8 @@ const char kHelloString[] = "Hello, world!";
|
|||
TEST(MyString, ConstructorFromCString) {
|
||||
const MyString s(kHelloString);
|
||||
EXPECT_EQ(0, strcmp(s.c_string(), kHelloString));
|
||||
EXPECT_EQ(sizeof(kHelloString) / sizeof(kHelloString[0]) - 1, s.Length());
|
||||
EXPECT_EQ(sizeof(kHelloString)/sizeof(kHelloString[0]) - 1,
|
||||
s.Length());
|
||||
}
|
||||
|
||||
// Tests the copy c'tor.
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@
|
|||
|
||||
#include <stddef.h>
|
||||
|
||||
|
||||
// Queue is a simple queue implemented as a singled-linked list.
|
||||
//
|
||||
// The element type must support copy constructor.
|
||||
|
|
@ -61,7 +62,7 @@ class QueueNode {
|
|||
: element_(an_element), next_(nullptr) {}
|
||||
|
||||
// We disable the default assignment operator and copy c'tor.
|
||||
const QueueNode& operator=(const QueueNode&);
|
||||
const QueueNode& operator = (const QueueNode&);
|
||||
QueueNode(const QueueNode&);
|
||||
|
||||
E element_;
|
||||
|
|
@ -83,7 +84,7 @@ class Queue {
|
|||
// 1. Deletes every node.
|
||||
QueueNode<E>* node = head_;
|
||||
QueueNode<E>* next = node->next();
|
||||
for (;;) {
|
||||
for (; ;) {
|
||||
delete node;
|
||||
node = next;
|
||||
if (node == nullptr) break;
|
||||
|
|
@ -161,11 +162,11 @@ class Queue {
|
|||
private:
|
||||
QueueNode<E>* head_; // The first node of the queue.
|
||||
QueueNode<E>* last_; // The last node of the queue.
|
||||
size_t size_; // The number of elements in the queue.
|
||||
size_t size_; // The number of elements in the queue.
|
||||
|
||||
// We disallow copying a queue.
|
||||
Queue(const Queue&);
|
||||
const Queue& operator=(const Queue&);
|
||||
const Queue& operator = (const Queue&);
|
||||
};
|
||||
|
||||
#endif // GOOGLETEST_SAMPLES_SAMPLE3_INL_H_
|
||||
|
|
|
|||
|
|
@ -67,6 +67,7 @@ namespace {
|
|||
class QueueTestSmpl3 : public testing::Test {
|
||||
protected: // You should make the members protected s.t. they can be
|
||||
// accessed from sub-classes.
|
||||
|
||||
// virtual void SetUp() will be called before each test is run. You
|
||||
// should define it if you need to initialize the variables.
|
||||
// Otherwise, this can be skipped.
|
||||
|
|
@ -84,13 +85,15 @@ class QueueTestSmpl3 : public testing::Test {
|
|||
// }
|
||||
|
||||
// A helper function that some test uses.
|
||||
static int Double(int n) { return 2 * n; }
|
||||
static int Double(int n) {
|
||||
return 2*n;
|
||||
}
|
||||
|
||||
// A helper function for testing Queue::Map().
|
||||
void MapTester(const Queue<int>* q) {
|
||||
void MapTester(const Queue<int> * q) {
|
||||
// Creates a new queue, where each element is twice as big as the
|
||||
// corresponding one in q.
|
||||
const Queue<int>* const new_q = q->Map(Double);
|
||||
const Queue<int> * const new_q = q->Map(Double);
|
||||
|
||||
// Verifies that the new queue has the same size as q.
|
||||
ASSERT_EQ(q->Size(), new_q->Size());
|
||||
|
|
@ -121,7 +124,7 @@ TEST_F(QueueTestSmpl3, DefaultConstructor) {
|
|||
|
||||
// Tests Dequeue().
|
||||
TEST_F(QueueTestSmpl3, Dequeue) {
|
||||
int* n = q0_.Dequeue();
|
||||
int * n = q0_.Dequeue();
|
||||
EXPECT_TRUE(n == nullptr);
|
||||
|
||||
n = q1_.Dequeue();
|
||||
|
|
|
|||
|
|
@ -29,22 +29,26 @@
|
|||
|
||||
// A sample program demonstrating using Google C++ testing framework.
|
||||
|
||||
#include "sample4.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "sample4.h"
|
||||
|
||||
// Returns the current counter value, and increments it.
|
||||
int Counter::Increment() { return counter_++; }
|
||||
int Counter::Increment() {
|
||||
return counter_++;
|
||||
}
|
||||
|
||||
// Returns the current counter value, and decrements it.
|
||||
// counter can not be less than 0, return 0 in this case
|
||||
int Counter::Decrement() {
|
||||
if (counter_ == 0) {
|
||||
return counter_;
|
||||
} else {
|
||||
} else {
|
||||
return counter_--;
|
||||
}
|
||||
}
|
||||
|
||||
// Prints the current counter value to STDOUT.
|
||||
void Counter::Print() const { printf("%d", counter_); }
|
||||
void Counter::Print() const {
|
||||
printf("%d", counter_);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,8 +27,8 @@
|
|||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#include "sample4.h"
|
||||
|
||||
#include "sample4.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
namespace {
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@
|
|||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
// This sample teaches how to reuse a test fixture in multiple test
|
||||
// cases by deriving sub-fixtures from it.
|
||||
//
|
||||
|
|
@ -44,10 +45,9 @@
|
|||
|
||||
#include <limits.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
#include "sample1.h"
|
||||
#include "sample3-inl.h"
|
||||
#include "gtest/gtest.h"
|
||||
namespace {
|
||||
// In this sample, we want to ensure that every test finishes within
|
||||
// ~5 seconds. If a test takes longer to run, we consider it a
|
||||
|
|
@ -81,6 +81,7 @@ class QuickTest : public testing::Test {
|
|||
time_t start_time_;
|
||||
};
|
||||
|
||||
|
||||
// We derive a fixture named IntegerFunctionTest from the QuickTest
|
||||
// fixture. All tests using this fixture will be automatically
|
||||
// required to be quick.
|
||||
|
|
@ -89,6 +90,7 @@ class IntegerFunctionTest : public QuickTest {
|
|||
// Therefore the body is empty.
|
||||
};
|
||||
|
||||
|
||||
// Now we can write tests in the IntegerFunctionTest test case.
|
||||
|
||||
// Tests Factorial()
|
||||
|
|
@ -108,6 +110,7 @@ TEST_F(IntegerFunctionTest, Factorial) {
|
|||
EXPECT_EQ(40320, Factorial(8));
|
||||
}
|
||||
|
||||
|
||||
// Tests IsPrime()
|
||||
TEST_F(IntegerFunctionTest, IsPrime) {
|
||||
// Tests negative input.
|
||||
|
|
@ -128,6 +131,7 @@ TEST_F(IntegerFunctionTest, IsPrime) {
|
|||
EXPECT_TRUE(IsPrime(23));
|
||||
}
|
||||
|
||||
|
||||
// The next test case (named "QueueTest") also needs to be quick, so
|
||||
// we derive another fixture from QuickTest.
|
||||
//
|
||||
|
|
@ -159,10 +163,13 @@ class QueueTest : public QuickTest {
|
|||
Queue<int> q2_;
|
||||
};
|
||||
|
||||
|
||||
// Now, let's write tests using the QueueTest fixture.
|
||||
|
||||
// Tests the default constructor.
|
||||
TEST_F(QueueTest, DefaultConstructor) { EXPECT_EQ(0u, q0_.Size()); }
|
||||
TEST_F(QueueTest, DefaultConstructor) {
|
||||
EXPECT_EQ(0u, q0_.Size());
|
||||
}
|
||||
|
||||
// Tests Dequeue().
|
||||
TEST_F(QueueTest, Dequeue) {
|
||||
|
|
|
|||
|
|
@ -27,11 +27,13 @@
|
|||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
// This sample shows how to test common properties of multiple
|
||||
// implementations of the same interface (aka interface tests).
|
||||
|
||||
// The interface and its implementations are in this header.
|
||||
#include "prime_tables.h"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
namespace {
|
||||
// First, we define some factory functions for creating instances of
|
||||
|
|
@ -149,7 +151,8 @@ using testing::Types;
|
|||
// the PrimeTableTest fixture defined earlier:
|
||||
|
||||
template <class T>
|
||||
class PrimeTableTest2 : public PrimeTableTest<T> {};
|
||||
class PrimeTableTest2 : public PrimeTableTest<T> {
|
||||
};
|
||||
|
||||
// Then, declare the test case. The argument is the name of the test
|
||||
// fixture, and also the name of the test case (as usual). The _P
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@
|
|||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
// This sample shows how to test common properties of multiple
|
||||
// implementations of an interface (aka interface tests) using
|
||||
// value-parameterized tests. Each test in the test case has
|
||||
|
|
@ -35,6 +36,7 @@
|
|||
|
||||
// The interface and its implementations are in this header.
|
||||
#include "prime_tables.h"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
namespace {
|
||||
|
||||
|
|
@ -48,7 +50,9 @@ using ::testing::Values;
|
|||
// SetUp() method and delete them in TearDown() method.
|
||||
typedef PrimeTable* CreatePrimeTableFunc();
|
||||
|
||||
PrimeTable* CreateOnTheFlyPrimeTable() { return new OnTheFlyPrimeTable(); }
|
||||
PrimeTable* CreateOnTheFlyPrimeTable() {
|
||||
return new OnTheFlyPrimeTable();
|
||||
}
|
||||
|
||||
template <size_t max_precalculated>
|
||||
PrimeTable* CreatePreCalculatedPrimeTable() {
|
||||
|
|
|
|||
|
|
@ -27,12 +27,14 @@
|
|||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
// This sample shows how to test code relying on some global flag variables.
|
||||
// Combine() helps with generating all possible combinations of such flags,
|
||||
// and each test is given one combination as a parameter.
|
||||
|
||||
// Use class definitions to test from this header.
|
||||
#include "prime_tables.h"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
namespace {
|
||||
|
||||
|
|
@ -77,10 +79,10 @@ class HybridPrimeTable : public PrimeTable {
|
|||
int max_precalculated_;
|
||||
};
|
||||
|
||||
using ::testing::Bool;
|
||||
using ::testing::Combine;
|
||||
using ::testing::TestWithParam;
|
||||
using ::testing::Bool;
|
||||
using ::testing::Values;
|
||||
using ::testing::Combine;
|
||||
|
||||
// To test all code paths for HybridPrimeTable we must test it with numbers
|
||||
// both within and outside PreCalculatedPrimeTable's capacity and also with
|
||||
|
|
|
|||
|
|
@ -26,9 +26,10 @@
|
|||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
// This sample shows how to use Google Test listener API to implement
|
||||
// an alternative console output and how to use the UnitTest reflection API
|
||||
// to enumerate test suites and tests and to inspect their results.
|
||||
// to enumerate test cases and tests and to inspect their results.
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
|
|
@ -37,10 +38,10 @@
|
|||
using ::testing::EmptyTestEventListener;
|
||||
using ::testing::InitGoogleTest;
|
||||
using ::testing::Test;
|
||||
using ::testing::TestCase;
|
||||
using ::testing::TestEventListeners;
|
||||
using ::testing::TestInfo;
|
||||
using ::testing::TestPartResult;
|
||||
using ::testing::TestSuite;
|
||||
using ::testing::UnitTest;
|
||||
namespace {
|
||||
// Provides alternative output mode which produces minimal amount of
|
||||
|
|
@ -58,23 +59,29 @@ class TersePrinter : public EmptyTestEventListener {
|
|||
|
||||
// Called before a test starts.
|
||||
void OnTestStart(const TestInfo& test_info) override {
|
||||
fprintf(stdout, "*** Test %s.%s starting.\n", test_info.test_suite_name(),
|
||||
fprintf(stdout,
|
||||
"*** Test %s.%s starting.\n",
|
||||
test_info.test_case_name(),
|
||||
test_info.name());
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
// Called after a failed assertion or a SUCCEED() invocation.
|
||||
void OnTestPartResult(const TestPartResult& test_part_result) override {
|
||||
fprintf(stdout, "%s in %s:%d\n%s\n",
|
||||
fprintf(stdout,
|
||||
"%s in %s:%d\n%s\n",
|
||||
test_part_result.failed() ? "*** Failure" : "Success",
|
||||
test_part_result.file_name(), test_part_result.line_number(),
|
||||
test_part_result.file_name(),
|
||||
test_part_result.line_number(),
|
||||
test_part_result.summary());
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
// Called after a test ends.
|
||||
void OnTestEnd(const TestInfo& test_info) override {
|
||||
fprintf(stdout, "*** Test %s.%s ending.\n", test_info.test_suite_name(),
|
||||
fprintf(stdout,
|
||||
"*** Test %s.%s ending.\n",
|
||||
test_info.test_case_name(),
|
||||
test_info.name());
|
||||
fflush(stdout);
|
||||
}
|
||||
|
|
@ -94,15 +101,14 @@ TEST(CustomOutputTest, Fails) {
|
|||
}
|
||||
} // namespace
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
int main(int argc, char **argv) {
|
||||
InitGoogleTest(&argc, argv);
|
||||
|
||||
bool terse_output = false;
|
||||
if (argc > 1 && strcmp(argv[1], "--terse_output") == 0)
|
||||
if (argc > 1 && strcmp(argv[1], "--terse_output") == 0 )
|
||||
terse_output = true;
|
||||
else
|
||||
printf("%s\n",
|
||||
"Run this program with --terse_output to change the way "
|
||||
printf("%s\n", "Run this program with --terse_output to change the way "
|
||||
"it prints its output.");
|
||||
|
||||
UnitTest& unit_test = *UnitTest::GetInstance();
|
||||
|
|
@ -143,7 +149,8 @@ int main(int argc, char** argv) {
|
|||
}
|
||||
|
||||
// Test that were meant to fail should not affect the test program outcome.
|
||||
if (unexpectedly_failed_tests == 0) ret_val = 0;
|
||||
if (unexpectedly_failed_tests == 0)
|
||||
ret_val = 0;
|
||||
|
||||
return ret_val;
|
||||
}
|
||||
|
|
|
|||
5
Engine/lib/assimp/contrib/gtest/scripts/README.md
Normal file
5
Engine/lib/assimp/contrib/gtest/scripts/README.md
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
# Please Note:
|
||||
|
||||
Files in this directory are no longer supported by the maintainers. They
|
||||
represent mosty historical artifacts and supported by the community only. There
|
||||
is no guarantee whatsoever that these scripts still work.
|
||||
83
Engine/lib/assimp/contrib/gtest/scripts/common.py
Normal file
83
Engine/lib/assimp/contrib/gtest/scripts/common.py
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
# Copyright 2013 Google Inc. All Rights Reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are
|
||||
# met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above
|
||||
# copyright notice, this list of conditions and the following disclaimer
|
||||
# in the documentation and/or other materials provided with the
|
||||
# distribution.
|
||||
# * Neither the name of Google Inc. nor the names of its
|
||||
# contributors may be used to endorse or promote products derived from
|
||||
# this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
"""Shared utilities for writing scripts for Google Test/Mock."""
|
||||
|
||||
__author__ = 'wan@google.com (Zhanyong Wan)'
|
||||
|
||||
|
||||
import os
|
||||
import re
|
||||
|
||||
|
||||
# Matches the line from 'svn info .' output that describes what SVN
|
||||
# path the current local directory corresponds to. For example, in
|
||||
# a googletest SVN workspace's trunk/test directory, the output will be:
|
||||
#
|
||||
# URL: https://googletest.googlecode.com/svn/trunk/test
|
||||
_SVN_INFO_URL_RE = re.compile(r'^URL: https://(\w+)\.googlecode\.com/svn(.*)')
|
||||
|
||||
|
||||
def GetCommandOutput(command):
|
||||
"""Runs the shell command and returns its stdout as a list of lines."""
|
||||
|
||||
f = os.popen(command, 'r')
|
||||
lines = [line.strip() for line in f.readlines()]
|
||||
f.close()
|
||||
return lines
|
||||
|
||||
|
||||
def GetSvnInfo():
|
||||
"""Returns the project name and the current SVN workspace's root path."""
|
||||
|
||||
for line in GetCommandOutput('svn info .'):
|
||||
m = _SVN_INFO_URL_RE.match(line)
|
||||
if m:
|
||||
project = m.group(1) # googletest or googlemock
|
||||
rel_path = m.group(2)
|
||||
root = os.path.realpath(rel_path.count('/') * '../')
|
||||
return project, root
|
||||
|
||||
return None, None
|
||||
|
||||
|
||||
def GetSvnTrunk():
|
||||
"""Returns the current SVN workspace's trunk root path."""
|
||||
|
||||
_, root = GetSvnInfo()
|
||||
return root + '/trunk' if root else None
|
||||
|
||||
|
||||
def IsInGTestSvn():
|
||||
project, _ = GetSvnInfo()
|
||||
return project == 'googletest'
|
||||
|
||||
|
||||
def IsInGMockSvn():
|
||||
project, _ = GetSvnInfo()
|
||||
return project == 'googlemock'
|
||||
253
Engine/lib/assimp/contrib/gtest/scripts/fuse_gtest_files.py
Normal file
253
Engine/lib/assimp/contrib/gtest/scripts/fuse_gtest_files.py
Normal file
|
|
@ -0,0 +1,253 @@
|
|||
#!/usr/bin/env python
|
||||
#
|
||||
# Copyright 2009, Google Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are
|
||||
# met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above
|
||||
# copyright notice, this list of conditions and the following disclaimer
|
||||
# in the documentation and/or other materials provided with the
|
||||
# distribution.
|
||||
# * Neither the name of Google Inc. nor the names of its
|
||||
# contributors may be used to endorse or promote products derived from
|
||||
# this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
"""fuse_gtest_files.py v0.2.0
|
||||
Fuses Google Test source code into a .h file and a .cc file.
|
||||
|
||||
SYNOPSIS
|
||||
fuse_gtest_files.py [GTEST_ROOT_DIR] OUTPUT_DIR
|
||||
|
||||
Scans GTEST_ROOT_DIR for Google Test source code, and generates
|
||||
two files: OUTPUT_DIR/gtest/gtest.h and OUTPUT_DIR/gtest/gtest-all.cc.
|
||||
Then you can build your tests by adding OUTPUT_DIR to the include
|
||||
search path and linking with OUTPUT_DIR/gtest/gtest-all.cc. These
|
||||
two files contain everything you need to use Google Test. Hence
|
||||
you can "install" Google Test by copying them to wherever you want.
|
||||
|
||||
GTEST_ROOT_DIR can be omitted and defaults to the parent
|
||||
directory of the directory holding this script.
|
||||
|
||||
EXAMPLES
|
||||
./fuse_gtest_files.py fused_gtest
|
||||
./fuse_gtest_files.py path/to/unpacked/gtest fused_gtest
|
||||
|
||||
This tool is experimental. In particular, it assumes that there is no
|
||||
conditional inclusion of Google Test headers. Please report any
|
||||
problems to googletestframework@googlegroups.com. You can read
|
||||
https://github.com/google/googletest/blob/master/googletest/docs/advanced.md for
|
||||
more information.
|
||||
"""
|
||||
|
||||
__author__ = 'wan@google.com (Zhanyong Wan)'
|
||||
|
||||
import os
|
||||
import re
|
||||
try:
|
||||
from sets import Set as set # For Python 2.3 compatibility
|
||||
except ImportError:
|
||||
pass
|
||||
import sys
|
||||
|
||||
# We assume that this file is in the scripts/ directory in the Google
|
||||
# Test root directory.
|
||||
DEFAULT_GTEST_ROOT_DIR = os.path.join(os.path.dirname(__file__), '..')
|
||||
|
||||
# Regex for matching '#include "gtest/..."'.
|
||||
INCLUDE_GTEST_FILE_REGEX = re.compile(r'^\s*#\s*include\s*"(gtest/.+)"')
|
||||
|
||||
# Regex for matching '#include "src/..."'.
|
||||
INCLUDE_SRC_FILE_REGEX = re.compile(r'^\s*#\s*include\s*"(src/.+)"')
|
||||
|
||||
# Where to find the source seed files.
|
||||
GTEST_H_SEED = 'include/gtest/gtest.h'
|
||||
GTEST_SPI_H_SEED = 'include/gtest/gtest-spi.h'
|
||||
GTEST_ALL_CC_SEED = 'src/gtest-all.cc'
|
||||
|
||||
# Where to put the generated files.
|
||||
GTEST_H_OUTPUT = 'gtest/gtest.h'
|
||||
GTEST_ALL_CC_OUTPUT = 'gtest/gtest-all.cc'
|
||||
|
||||
|
||||
def VerifyFileExists(directory, relative_path):
|
||||
"""Verifies that the given file exists; aborts on failure.
|
||||
|
||||
relative_path is the file path relative to the given directory.
|
||||
"""
|
||||
|
||||
if not os.path.isfile(os.path.join(directory, relative_path)):
|
||||
print('ERROR: Cannot find %s in directory %s.' % (relative_path,
|
||||
directory))
|
||||
print('Please either specify a valid project root directory '
|
||||
'or omit it on the command line.')
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def ValidateGTestRootDir(gtest_root):
|
||||
"""Makes sure gtest_root points to a valid gtest root directory.
|
||||
|
||||
The function aborts the program on failure.
|
||||
"""
|
||||
|
||||
VerifyFileExists(gtest_root, GTEST_H_SEED)
|
||||
VerifyFileExists(gtest_root, GTEST_ALL_CC_SEED)
|
||||
|
||||
|
||||
def VerifyOutputFile(output_dir, relative_path):
|
||||
"""Verifies that the given output file path is valid.
|
||||
|
||||
relative_path is relative to the output_dir directory.
|
||||
"""
|
||||
|
||||
# Makes sure the output file either doesn't exist or can be overwritten.
|
||||
output_file = os.path.join(output_dir, relative_path)
|
||||
if os.path.exists(output_file):
|
||||
# TODO(wan@google.com): The following user-interaction doesn't
|
||||
# work with automated processes. We should provide a way for the
|
||||
# Makefile to force overwriting the files.
|
||||
print('%s already exists in directory %s - overwrite it? (y/N) ' %
|
||||
(relative_path, output_dir))
|
||||
answer = sys.stdin.readline().strip()
|
||||
if answer not in ['y', 'Y']:
|
||||
print('ABORTED.')
|
||||
sys.exit(1)
|
||||
|
||||
# Makes sure the directory holding the output file exists; creates
|
||||
# it and all its ancestors if necessary.
|
||||
parent_directory = os.path.dirname(output_file)
|
||||
if not os.path.isdir(parent_directory):
|
||||
os.makedirs(parent_directory)
|
||||
|
||||
|
||||
def ValidateOutputDir(output_dir):
|
||||
"""Makes sure output_dir points to a valid output directory.
|
||||
|
||||
The function aborts the program on failure.
|
||||
"""
|
||||
|
||||
VerifyOutputFile(output_dir, GTEST_H_OUTPUT)
|
||||
VerifyOutputFile(output_dir, GTEST_ALL_CC_OUTPUT)
|
||||
|
||||
|
||||
def FuseGTestH(gtest_root, output_dir):
|
||||
"""Scans folder gtest_root to generate gtest/gtest.h in output_dir."""
|
||||
|
||||
output_file = open(os.path.join(output_dir, GTEST_H_OUTPUT), 'w')
|
||||
processed_files = set() # Holds all gtest headers we've processed.
|
||||
|
||||
def ProcessFile(gtest_header_path):
|
||||
"""Processes the given gtest header file."""
|
||||
|
||||
# We don't process the same header twice.
|
||||
if gtest_header_path in processed_files:
|
||||
return
|
||||
|
||||
processed_files.add(gtest_header_path)
|
||||
|
||||
# Reads each line in the given gtest header.
|
||||
for line in open(os.path.join(gtest_root, gtest_header_path), 'r'):
|
||||
m = INCLUDE_GTEST_FILE_REGEX.match(line)
|
||||
if m:
|
||||
# It's '#include "gtest/..."' - let's process it recursively.
|
||||
ProcessFile('include/' + m.group(1))
|
||||
else:
|
||||
# Otherwise we copy the line unchanged to the output file.
|
||||
output_file.write(line)
|
||||
|
||||
ProcessFile(GTEST_H_SEED)
|
||||
output_file.close()
|
||||
|
||||
|
||||
def FuseGTestAllCcToFile(gtest_root, output_file):
|
||||
"""Scans folder gtest_root to generate gtest/gtest-all.cc in output_file."""
|
||||
|
||||
processed_files = set()
|
||||
|
||||
def ProcessFile(gtest_source_file):
|
||||
"""Processes the given gtest source file."""
|
||||
|
||||
# We don't process the same #included file twice.
|
||||
if gtest_source_file in processed_files:
|
||||
return
|
||||
|
||||
processed_files.add(gtest_source_file)
|
||||
|
||||
# Reads each line in the given gtest source file.
|
||||
for line in open(os.path.join(gtest_root, gtest_source_file), 'r'):
|
||||
m = INCLUDE_GTEST_FILE_REGEX.match(line)
|
||||
if m:
|
||||
if 'include/' + m.group(1) == GTEST_SPI_H_SEED:
|
||||
# It's '#include "gtest/gtest-spi.h"'. This file is not
|
||||
# #included by "gtest/gtest.h", so we need to process it.
|
||||
ProcessFile(GTEST_SPI_H_SEED)
|
||||
else:
|
||||
# It's '#include "gtest/foo.h"' where foo is not gtest-spi.
|
||||
# We treat it as '#include "gtest/gtest.h"', as all other
|
||||
# gtest headers are being fused into gtest.h and cannot be
|
||||
# #included directly.
|
||||
|
||||
# There is no need to #include "gtest/gtest.h" more than once.
|
||||
if not GTEST_H_SEED in processed_files:
|
||||
processed_files.add(GTEST_H_SEED)
|
||||
output_file.write('#include "%s"\n' % (GTEST_H_OUTPUT,))
|
||||
else:
|
||||
m = INCLUDE_SRC_FILE_REGEX.match(line)
|
||||
if m:
|
||||
# It's '#include "src/foo"' - let's process it recursively.
|
||||
ProcessFile(m.group(1))
|
||||
else:
|
||||
output_file.write(line)
|
||||
|
||||
ProcessFile(GTEST_ALL_CC_SEED)
|
||||
|
||||
|
||||
def FuseGTestAllCc(gtest_root, output_dir):
|
||||
"""Scans folder gtest_root to generate gtest/gtest-all.cc in output_dir."""
|
||||
|
||||
output_file = open(os.path.join(output_dir, GTEST_ALL_CC_OUTPUT), 'w')
|
||||
FuseGTestAllCcToFile(gtest_root, output_file)
|
||||
output_file.close()
|
||||
|
||||
|
||||
def FuseGTest(gtest_root, output_dir):
|
||||
"""Fuses gtest.h and gtest-all.cc."""
|
||||
|
||||
ValidateGTestRootDir(gtest_root)
|
||||
ValidateOutputDir(output_dir)
|
||||
|
||||
FuseGTestH(gtest_root, output_dir)
|
||||
FuseGTestAllCc(gtest_root, output_dir)
|
||||
|
||||
|
||||
def main():
|
||||
argc = len(sys.argv)
|
||||
if argc == 2:
|
||||
# fuse_gtest_files.py OUTPUT_DIR
|
||||
FuseGTest(DEFAULT_GTEST_ROOT_DIR, sys.argv[1])
|
||||
elif argc == 3:
|
||||
# fuse_gtest_files.py GTEST_ROOT_DIR OUTPUT_DIR
|
||||
FuseGTest(sys.argv[1], sys.argv[2])
|
||||
else:
|
||||
print(__doc__)
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
733
Engine/lib/assimp/contrib/gtest/scripts/gen_gtest_pred_impl.py
Normal file
733
Engine/lib/assimp/contrib/gtest/scripts/gen_gtest_pred_impl.py
Normal file
|
|
@ -0,0 +1,733 @@
|
|||
#!/usr/bin/env python
|
||||
#
|
||||
# Copyright 2006, Google Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are
|
||||
# met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above
|
||||
# copyright notice, this list of conditions and the following disclaimer
|
||||
# in the documentation and/or other materials provided with the
|
||||
# distribution.
|
||||
# * Neither the name of Google Inc. nor the names of its
|
||||
# contributors may be used to endorse or promote products derived from
|
||||
# this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
"""gen_gtest_pred_impl.py v0.1
|
||||
|
||||
Generates the implementation of Google Test predicate assertions and
|
||||
accompanying tests.
|
||||
|
||||
Usage:
|
||||
|
||||
gen_gtest_pred_impl.py MAX_ARITY
|
||||
|
||||
where MAX_ARITY is a positive integer.
|
||||
|
||||
The command generates the implementation of up-to MAX_ARITY-ary
|
||||
predicate assertions, and writes it to file gtest_pred_impl.h in the
|
||||
directory where the script is. It also generates the accompanying
|
||||
unit test in file gtest_pred_impl_unittest.cc.
|
||||
"""
|
||||
|
||||
__author__ = 'wan@google.com (Zhanyong Wan)'
|
||||
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
|
||||
# Where this script is.
|
||||
SCRIPT_DIR = os.path.dirname(sys.argv[0])
|
||||
|
||||
# Where to store the generated header.
|
||||
HEADER = os.path.join(SCRIPT_DIR, '../include/gtest/gtest_pred_impl.h')
|
||||
|
||||
# Where to store the generated unit test.
|
||||
UNIT_TEST = os.path.join(SCRIPT_DIR, '../test/gtest_pred_impl_unittest.cc')
|
||||
|
||||
|
||||
def HeaderPreamble(n):
|
||||
"""Returns the preamble for the header file.
|
||||
|
||||
Args:
|
||||
n: the maximum arity of the predicate macros to be generated.
|
||||
"""
|
||||
|
||||
# A map that defines the values used in the preamble template.
|
||||
DEFS = {
|
||||
'today' : time.strftime('%m/%d/%Y'),
|
||||
'year' : time.strftime('%Y'),
|
||||
'command' : '%s %s' % (os.path.basename(sys.argv[0]), n),
|
||||
'n' : n
|
||||
}
|
||||
|
||||
return (
|
||||
"""// Copyright 2006, Google Inc.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// This file is AUTOMATICALLY GENERATED on %(today)s by command
|
||||
// '%(command)s'. DO NOT EDIT BY HAND!
|
||||
//
|
||||
// Implements a family of generic predicate assertion macros.
|
||||
// GOOGLETEST_CM0001 DO NOT DELETE
|
||||
|
||||
|
||||
#ifndef GTEST_INCLUDE_GTEST_GTEST_PRED_IMPL_H_
|
||||
#define GTEST_INCLUDE_GTEST_GTEST_PRED_IMPL_H_
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
namespace testing {
|
||||
|
||||
// This header implements a family of generic predicate assertion
|
||||
// macros:
|
||||
//
|
||||
// ASSERT_PRED_FORMAT1(pred_format, v1)
|
||||
// ASSERT_PRED_FORMAT2(pred_format, v1, v2)
|
||||
// ...
|
||||
//
|
||||
// where pred_format is a function or functor that takes n (in the
|
||||
// case of ASSERT_PRED_FORMATn) values and their source expression
|
||||
// text, and returns a testing::AssertionResult. See the definition
|
||||
// of ASSERT_EQ in gtest.h for an example.
|
||||
//
|
||||
// If you don't care about formatting, you can use the more
|
||||
// restrictive version:
|
||||
//
|
||||
// ASSERT_PRED1(pred, v1)
|
||||
// ASSERT_PRED2(pred, v1, v2)
|
||||
// ...
|
||||
//
|
||||
// where pred is an n-ary function or functor that returns bool,
|
||||
// and the values v1, v2, ..., must support the << operator for
|
||||
// streaming to std::ostream.
|
||||
//
|
||||
// We also define the EXPECT_* variations.
|
||||
//
|
||||
// For now we only support predicates whose arity is at most %(n)s.
|
||||
// Please email googletestframework@googlegroups.com if you need
|
||||
// support for higher arities.
|
||||
|
||||
// GTEST_ASSERT_ is the basic statement to which all of the assertions
|
||||
// in this file reduce. Don't use this in your code.
|
||||
|
||||
#define GTEST_ASSERT_(expression, on_failure) \\
|
||||
GTEST_AMBIGUOUS_ELSE_BLOCKER_ \\
|
||||
if (const ::testing::AssertionResult gtest_ar = (expression)) \\
|
||||
; \\
|
||||
else \\
|
||||
on_failure(gtest_ar.failure_message())
|
||||
""" % DEFS)
|
||||
|
||||
|
||||
def Arity(n):
|
||||
"""Returns the English name of the given arity."""
|
||||
|
||||
if n < 0:
|
||||
return None
|
||||
elif n <= 3:
|
||||
return ['nullary', 'unary', 'binary', 'ternary'][n]
|
||||
else:
|
||||
return '%s-ary' % n
|
||||
|
||||
|
||||
def Title(word):
|
||||
"""Returns the given word in title case. The difference between
|
||||
this and string's title() method is that Title('4-ary') is '4-ary'
|
||||
while '4-ary'.title() is '4-Ary'."""
|
||||
|
||||
return word[0].upper() + word[1:]
|
||||
|
||||
|
||||
def OneTo(n):
|
||||
"""Returns the list [1, 2, 3, ..., n]."""
|
||||
|
||||
return range(1, n + 1)
|
||||
|
||||
|
||||
def Iter(n, format, sep=''):
|
||||
"""Given a positive integer n, a format string that contains 0 or
|
||||
more '%s' format specs, and optionally a separator string, returns
|
||||
the join of n strings, each formatted with the format string on an
|
||||
iterator ranged from 1 to n.
|
||||
|
||||
Example:
|
||||
|
||||
Iter(3, 'v%s', sep=', ') returns 'v1, v2, v3'.
|
||||
"""
|
||||
|
||||
# How many '%s' specs are in format?
|
||||
spec_count = len(format.split('%s')) - 1
|
||||
return sep.join([format % (spec_count * (i,)) for i in OneTo(n)])
|
||||
|
||||
|
||||
def ImplementationForArity(n):
|
||||
"""Returns the implementation of n-ary predicate assertions."""
|
||||
|
||||
# A map the defines the values used in the implementation template.
|
||||
DEFS = {
|
||||
'n' : str(n),
|
||||
'vs' : Iter(n, 'v%s', sep=', '),
|
||||
'vts' : Iter(n, '#v%s', sep=', '),
|
||||
'arity' : Arity(n),
|
||||
'Arity' : Title(Arity(n))
|
||||
}
|
||||
|
||||
impl = """
|
||||
|
||||
// Helper function for implementing {EXPECT|ASSERT}_PRED%(n)s. Don't use
|
||||
// this in your code.
|
||||
template <typename Pred""" % DEFS
|
||||
|
||||
impl += Iter(n, """,
|
||||
typename T%s""")
|
||||
|
||||
impl += """>
|
||||
AssertionResult AssertPred%(n)sHelper(const char* pred_text""" % DEFS
|
||||
|
||||
impl += Iter(n, """,
|
||||
const char* e%s""")
|
||||
|
||||
impl += """,
|
||||
Pred pred"""
|
||||
|
||||
impl += Iter(n, """,
|
||||
const T%s& v%s""")
|
||||
|
||||
impl += """) {
|
||||
if (pred(%(vs)s)) return AssertionSuccess();
|
||||
|
||||
""" % DEFS
|
||||
|
||||
impl += ' return AssertionFailure() << pred_text << "("'
|
||||
|
||||
impl += Iter(n, """
|
||||
<< e%s""", sep=' << ", "')
|
||||
|
||||
impl += ' << ") evaluates to false, where"'
|
||||
|
||||
impl += Iter(
|
||||
n, """
|
||||
<< "\\n" << e%s << " evaluates to " << ::testing::PrintToString(v%s)"""
|
||||
)
|
||||
|
||||
impl += """;
|
||||
}
|
||||
|
||||
// Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT%(n)s.
|
||||
// Don't use this in your code.
|
||||
#define GTEST_PRED_FORMAT%(n)s_(pred_format, %(vs)s, on_failure)\\
|
||||
GTEST_ASSERT_(pred_format(%(vts)s, %(vs)s), \\
|
||||
on_failure)
|
||||
|
||||
// Internal macro for implementing {EXPECT|ASSERT}_PRED%(n)s. Don't use
|
||||
// this in your code.
|
||||
#define GTEST_PRED%(n)s_(pred, %(vs)s, on_failure)\\
|
||||
GTEST_ASSERT_(::testing::AssertPred%(n)sHelper(#pred""" % DEFS
|
||||
|
||||
impl += Iter(n, """, \\
|
||||
#v%s""")
|
||||
|
||||
impl += """, \\
|
||||
pred"""
|
||||
|
||||
impl += Iter(n, """, \\
|
||||
v%s""")
|
||||
|
||||
impl += """), on_failure)
|
||||
|
||||
// %(Arity)s predicate assertion macros.
|
||||
#define EXPECT_PRED_FORMAT%(n)s(pred_format, %(vs)s) \\
|
||||
GTEST_PRED_FORMAT%(n)s_(pred_format, %(vs)s, GTEST_NONFATAL_FAILURE_)
|
||||
#define EXPECT_PRED%(n)s(pred, %(vs)s) \\
|
||||
GTEST_PRED%(n)s_(pred, %(vs)s, GTEST_NONFATAL_FAILURE_)
|
||||
#define ASSERT_PRED_FORMAT%(n)s(pred_format, %(vs)s) \\
|
||||
GTEST_PRED_FORMAT%(n)s_(pred_format, %(vs)s, GTEST_FATAL_FAILURE_)
|
||||
#define ASSERT_PRED%(n)s(pred, %(vs)s) \\
|
||||
GTEST_PRED%(n)s_(pred, %(vs)s, GTEST_FATAL_FAILURE_)
|
||||
|
||||
""" % DEFS
|
||||
|
||||
return impl
|
||||
|
||||
|
||||
def HeaderPostamble():
|
||||
"""Returns the postamble for the header file."""
|
||||
|
||||
return """
|
||||
|
||||
} // namespace testing
|
||||
|
||||
#endif // GTEST_INCLUDE_GTEST_GTEST_PRED_IMPL_H_
|
||||
"""
|
||||
|
||||
|
||||
def GenerateFile(path, content):
|
||||
"""Given a file path and a content string
|
||||
overwrites it with the given content.
|
||||
"""
|
||||
print 'Updating file %s . . .' % path
|
||||
f = file(path, 'w+')
|
||||
print >>f, content,
|
||||
f.close()
|
||||
|
||||
print 'File %s has been updated.' % path
|
||||
|
||||
|
||||
def GenerateHeader(n):
|
||||
"""Given the maximum arity n, updates the header file that implements
|
||||
the predicate assertions.
|
||||
"""
|
||||
GenerateFile(HEADER,
|
||||
HeaderPreamble(n)
|
||||
+ ''.join([ImplementationForArity(i) for i in OneTo(n)])
|
||||
+ HeaderPostamble())
|
||||
|
||||
|
||||
def UnitTestPreamble():
|
||||
"""Returns the preamble for the unit test file."""
|
||||
|
||||
# A map that defines the values used in the preamble template.
|
||||
DEFS = {
|
||||
'today' : time.strftime('%m/%d/%Y'),
|
||||
'year' : time.strftime('%Y'),
|
||||
'command' : '%s %s' % (os.path.basename(sys.argv[0]), sys.argv[1]),
|
||||
}
|
||||
|
||||
return (
|
||||
"""// Copyright 2006, Google Inc.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// This file is AUTOMATICALLY GENERATED on %(today)s by command
|
||||
// '%(command)s'. DO NOT EDIT BY HAND!
|
||||
|
||||
// Regression test for gtest_pred_impl.h
|
||||
//
|
||||
// This file is generated by a script and quite long. If you intend to
|
||||
// learn how Google Test works by reading its unit tests, read
|
||||
// gtest_unittest.cc instead.
|
||||
//
|
||||
// This is intended as a regression test for the Google Test predicate
|
||||
// assertions. We compile it as part of the gtest_unittest target
|
||||
// only to keep the implementation tidy and compact, as it is quite
|
||||
// involved to set up the stage for testing Google Test using Google
|
||||
// Test itself.
|
||||
//
|
||||
// Currently, gtest_unittest takes ~11 seconds to run in the testing
|
||||
// daemon. In the future, if it grows too large and needs much more
|
||||
// time to finish, we should consider separating this file into a
|
||||
// stand-alone regression test.
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
#include "gtest/gtest-spi.h"
|
||||
|
||||
// A user-defined data type.
|
||||
struct Bool {
|
||||
explicit Bool(int val) : value(val != 0) {}
|
||||
|
||||
bool operator>(int n) const { return value > Bool(n).value; }
|
||||
|
||||
Bool operator+(const Bool& rhs) const { return Bool(value + rhs.value); }
|
||||
|
||||
bool operator==(const Bool& rhs) const { return value == rhs.value; }
|
||||
|
||||
bool value;
|
||||
};
|
||||
|
||||
// Enables Bool to be used in assertions.
|
||||
std::ostream& operator<<(std::ostream& os, const Bool& x) {
|
||||
return os << (x.value ? "true" : "false");
|
||||
}
|
||||
|
||||
""" % DEFS)
|
||||
|
||||
|
||||
def TestsForArity(n):
|
||||
"""Returns the tests for n-ary predicate assertions."""
|
||||
|
||||
# A map that defines the values used in the template for the tests.
|
||||
DEFS = {
|
||||
'n' : n,
|
||||
'es' : Iter(n, 'e%s', sep=', '),
|
||||
'vs' : Iter(n, 'v%s', sep=', '),
|
||||
'vts' : Iter(n, '#v%s', sep=', '),
|
||||
'tvs' : Iter(n, 'T%s v%s', sep=', '),
|
||||
'int_vs' : Iter(n, 'int v%s', sep=', '),
|
||||
'Bool_vs' : Iter(n, 'Bool v%s', sep=', '),
|
||||
'types' : Iter(n, 'typename T%s', sep=', '),
|
||||
'v_sum' : Iter(n, 'v%s', sep=' + '),
|
||||
'arity' : Arity(n),
|
||||
'Arity' : Title(Arity(n)),
|
||||
}
|
||||
|
||||
tests = (
|
||||
"""// Sample functions/functors for testing %(arity)s predicate assertions.
|
||||
|
||||
// A %(arity)s predicate function.
|
||||
template <%(types)s>
|
||||
bool PredFunction%(n)s(%(tvs)s) {
|
||||
return %(v_sum)s > 0;
|
||||
}
|
||||
|
||||
// The following two functions are needed because a compiler doesn't have
|
||||
// a context yet to know which template function must be instantiated.
|
||||
bool PredFunction%(n)sInt(%(int_vs)s) {
|
||||
return %(v_sum)s > 0;
|
||||
}
|
||||
bool PredFunction%(n)sBool(%(Bool_vs)s) {
|
||||
return %(v_sum)s > 0;
|
||||
}
|
||||
""" % DEFS)
|
||||
|
||||
tests += """
|
||||
// A %(arity)s predicate functor.
|
||||
struct PredFunctor%(n)s {
|
||||
template <%(types)s>
|
||||
bool operator()(""" % DEFS
|
||||
|
||||
tests += Iter(n, 'const T%s& v%s', sep=""",
|
||||
""")
|
||||
|
||||
tests += """) {
|
||||
return %(v_sum)s > 0;
|
||||
}
|
||||
};
|
||||
""" % DEFS
|
||||
|
||||
tests += """
|
||||
// A %(arity)s predicate-formatter function.
|
||||
template <%(types)s>
|
||||
testing::AssertionResult PredFormatFunction%(n)s(""" % DEFS
|
||||
|
||||
tests += Iter(n, 'const char* e%s', sep=""",
|
||||
""")
|
||||
|
||||
tests += Iter(n, """,
|
||||
const T%s& v%s""")
|
||||
|
||||
tests += """) {
|
||||
if (PredFunction%(n)s(%(vs)s))
|
||||
return testing::AssertionSuccess();
|
||||
|
||||
return testing::AssertionFailure()
|
||||
<< """ % DEFS
|
||||
|
||||
tests += Iter(n, 'e%s', sep=' << " + " << ')
|
||||
|
||||
tests += """
|
||||
<< " is expected to be positive, but evaluates to "
|
||||
<< %(v_sum)s << ".";
|
||||
}
|
||||
""" % DEFS
|
||||
|
||||
tests += """
|
||||
// A %(arity)s predicate-formatter functor.
|
||||
struct PredFormatFunctor%(n)s {
|
||||
template <%(types)s>
|
||||
testing::AssertionResult operator()(""" % DEFS
|
||||
|
||||
tests += Iter(n, 'const char* e%s', sep=""",
|
||||
""")
|
||||
|
||||
tests += Iter(n, """,
|
||||
const T%s& v%s""")
|
||||
|
||||
tests += """) const {
|
||||
return PredFormatFunction%(n)s(%(es)s, %(vs)s);
|
||||
}
|
||||
};
|
||||
""" % DEFS
|
||||
|
||||
tests += """
|
||||
// Tests for {EXPECT|ASSERT}_PRED_FORMAT%(n)s.
|
||||
|
||||
class Predicate%(n)sTest : public testing::Test {
|
||||
protected:
|
||||
void SetUp() override {
|
||||
expected_to_finish_ = true;
|
||||
finished_ = false;""" % DEFS
|
||||
|
||||
tests += """
|
||||
""" + Iter(n, 'n%s_ = ') + """0;
|
||||
}
|
||||
"""
|
||||
|
||||
tests += """
|
||||
void TearDown() override {
|
||||
// Verifies that each of the predicate's arguments was evaluated
|
||||
// exactly once."""
|
||||
|
||||
tests += ''.join(["""
|
||||
EXPECT_EQ(1, n%s_) <<
|
||||
"The predicate assertion didn't evaluate argument %s "
|
||||
"exactly once.";""" % (i, i + 1) for i in OneTo(n)])
|
||||
|
||||
tests += """
|
||||
|
||||
// Verifies that the control flow in the test function is expected.
|
||||
if (expected_to_finish_ && !finished_) {
|
||||
FAIL() << "The predicate assertion unexpactedly aborted the test.";
|
||||
} else if (!expected_to_finish_ && finished_) {
|
||||
FAIL() << "The failed predicate assertion didn't abort the test "
|
||||
"as expected.";
|
||||
}
|
||||
}
|
||||
|
||||
// true if and only if the test function is expected to run to finish.
|
||||
static bool expected_to_finish_;
|
||||
|
||||
// true if and only if the test function did run to finish.
|
||||
static bool finished_;
|
||||
""" % DEFS
|
||||
|
||||
tests += Iter(n, """
|
||||
static int n%s_;""")
|
||||
|
||||
tests += """
|
||||
};
|
||||
|
||||
bool Predicate%(n)sTest::expected_to_finish_;
|
||||
bool Predicate%(n)sTest::finished_;
|
||||
""" % DEFS
|
||||
|
||||
tests += Iter(n, """int Predicate%%(n)sTest::n%s_;
|
||||
""") % DEFS
|
||||
|
||||
tests += """
|
||||
typedef Predicate%(n)sTest EXPECT_PRED_FORMAT%(n)sTest;
|
||||
typedef Predicate%(n)sTest ASSERT_PRED_FORMAT%(n)sTest;
|
||||
typedef Predicate%(n)sTest EXPECT_PRED%(n)sTest;
|
||||
typedef Predicate%(n)sTest ASSERT_PRED%(n)sTest;
|
||||
""" % DEFS
|
||||
|
||||
def GenTest(use_format, use_assert, expect_failure,
|
||||
use_functor, use_user_type):
|
||||
"""Returns the test for a predicate assertion macro.
|
||||
|
||||
Args:
|
||||
use_format: true if and only if the assertion is a *_PRED_FORMAT*.
|
||||
use_assert: true if and only if the assertion is a ASSERT_*.
|
||||
expect_failure: true if and only if the assertion is expected to fail.
|
||||
use_functor: true if and only if the first argument of the assertion is
|
||||
a functor (as opposed to a function)
|
||||
use_user_type: true if and only if the predicate functor/function takes
|
||||
argument(s) of a user-defined type.
|
||||
|
||||
Example:
|
||||
|
||||
GenTest(1, 0, 0, 1, 0) returns a test that tests the behavior
|
||||
of a successful EXPECT_PRED_FORMATn() that takes a functor
|
||||
whose arguments have built-in types."""
|
||||
|
||||
if use_assert:
|
||||
assrt = 'ASSERT' # 'assert' is reserved, so we cannot use
|
||||
# that identifier here.
|
||||
else:
|
||||
assrt = 'EXPECT'
|
||||
|
||||
assertion = assrt + '_PRED'
|
||||
|
||||
if use_format:
|
||||
pred_format = 'PredFormat'
|
||||
assertion += '_FORMAT'
|
||||
else:
|
||||
pred_format = 'Pred'
|
||||
|
||||
assertion += '%(n)s' % DEFS
|
||||
|
||||
if use_functor:
|
||||
pred_format_type = 'functor'
|
||||
pred_format += 'Functor%(n)s()'
|
||||
else:
|
||||
pred_format_type = 'function'
|
||||
pred_format += 'Function%(n)s'
|
||||
if not use_format:
|
||||
if use_user_type:
|
||||
pred_format += 'Bool'
|
||||
else:
|
||||
pred_format += 'Int'
|
||||
|
||||
test_name = pred_format_type.title()
|
||||
|
||||
if use_user_type:
|
||||
arg_type = 'user-defined type (Bool)'
|
||||
test_name += 'OnUserType'
|
||||
if expect_failure:
|
||||
arg = 'Bool(n%s_++)'
|
||||
else:
|
||||
arg = 'Bool(++n%s_)'
|
||||
else:
|
||||
arg_type = 'built-in type (int)'
|
||||
test_name += 'OnBuiltInType'
|
||||
if expect_failure:
|
||||
arg = 'n%s_++'
|
||||
else:
|
||||
arg = '++n%s_'
|
||||
|
||||
if expect_failure:
|
||||
successful_or_failed = 'failed'
|
||||
expected_or_not = 'expected.'
|
||||
test_name += 'Failure'
|
||||
else:
|
||||
successful_or_failed = 'successful'
|
||||
expected_or_not = 'UNEXPECTED!'
|
||||
test_name += 'Success'
|
||||
|
||||
# A map that defines the values used in the test template.
|
||||
defs = DEFS.copy()
|
||||
defs.update({
|
||||
'assert' : assrt,
|
||||
'assertion' : assertion,
|
||||
'test_name' : test_name,
|
||||
'pf_type' : pred_format_type,
|
||||
'pf' : pred_format,
|
||||
'arg_type' : arg_type,
|
||||
'arg' : arg,
|
||||
'successful' : successful_or_failed,
|
||||
'expected' : expected_or_not,
|
||||
})
|
||||
|
||||
test = """
|
||||
// Tests a %(successful)s %(assertion)s where the
|
||||
// predicate-formatter is a %(pf_type)s on a %(arg_type)s.
|
||||
TEST_F(%(assertion)sTest, %(test_name)s) {""" % defs
|
||||
|
||||
indent = (len(assertion) + 3)*' '
|
||||
extra_indent = ''
|
||||
|
||||
if expect_failure:
|
||||
extra_indent = ' '
|
||||
if use_assert:
|
||||
test += """
|
||||
expected_to_finish_ = false;
|
||||
EXPECT_FATAL_FAILURE({ // NOLINT"""
|
||||
else:
|
||||
test += """
|
||||
EXPECT_NONFATAL_FAILURE({ // NOLINT"""
|
||||
|
||||
test += '\n' + extra_indent + """ %(assertion)s(%(pf)s""" % defs
|
||||
|
||||
test = test % defs
|
||||
test += Iter(n, ',\n' + indent + extra_indent + '%(arg)s' % defs)
|
||||
test += ');\n' + extra_indent + ' finished_ = true;\n'
|
||||
|
||||
if expect_failure:
|
||||
test += ' }, "");\n'
|
||||
|
||||
test += '}\n'
|
||||
return test
|
||||
|
||||
# Generates tests for all 2**6 = 64 combinations.
|
||||
tests += ''.join([GenTest(use_format, use_assert, expect_failure,
|
||||
use_functor, use_user_type)
|
||||
for use_format in [0, 1]
|
||||
for use_assert in [0, 1]
|
||||
for expect_failure in [0, 1]
|
||||
for use_functor in [0, 1]
|
||||
for use_user_type in [0, 1]
|
||||
])
|
||||
|
||||
return tests
|
||||
|
||||
|
||||
def UnitTestPostamble():
|
||||
"""Returns the postamble for the tests."""
|
||||
|
||||
return ''
|
||||
|
||||
|
||||
def GenerateUnitTest(n):
|
||||
"""Returns the tests for up-to n-ary predicate assertions."""
|
||||
|
||||
GenerateFile(UNIT_TEST,
|
||||
UnitTestPreamble()
|
||||
+ ''.join([TestsForArity(i) for i in OneTo(n)])
|
||||
+ UnitTestPostamble())
|
||||
|
||||
|
||||
def _Main():
|
||||
"""The entry point of the script. Generates the header file and its
|
||||
unit test."""
|
||||
|
||||
if len(sys.argv) != 2:
|
||||
print __doc__
|
||||
print 'Author: ' + __author__
|
||||
sys.exit(1)
|
||||
|
||||
n = int(sys.argv[1])
|
||||
GenerateHeader(n)
|
||||
GenerateUnitTest(n)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
_Main()
|
||||
274
Engine/lib/assimp/contrib/gtest/scripts/gtest-config.in
Normal file
274
Engine/lib/assimp/contrib/gtest/scripts/gtest-config.in
Normal file
|
|
@ -0,0 +1,274 @@
|
|||
#!/bin/sh
|
||||
|
||||
# These variables are automatically filled in by the configure script.
|
||||
name="@PACKAGE_TARNAME@"
|
||||
version="@PACKAGE_VERSION@"
|
||||
|
||||
show_usage()
|
||||
{
|
||||
echo "Usage: gtest-config [OPTIONS...]"
|
||||
}
|
||||
|
||||
show_help()
|
||||
{
|
||||
show_usage
|
||||
cat <<\EOF
|
||||
|
||||
The `gtest-config' script provides access to the necessary compile and linking
|
||||
flags to connect with Google C++ Testing Framework, both in a build prior to
|
||||
installation, and on the system proper after installation. The installation
|
||||
overrides may be issued in combination with any other queries, but will only
|
||||
affect installation queries if called on a built but not installed gtest. The
|
||||
installation queries may not be issued with any other types of queries, and
|
||||
only one installation query may be made at a time. The version queries and
|
||||
compiler flag queries may be combined as desired but not mixed. Different
|
||||
version queries are always combined with logical "and" semantics, and only the
|
||||
last of any particular query is used while all previous ones ignored. All
|
||||
versions must be specified as a sequence of numbers separated by periods.
|
||||
Compiler flag queries output the union of the sets of flags when combined.
|
||||
|
||||
Examples:
|
||||
gtest-config --min-version=1.0 || echo "Insufficient Google Test version."
|
||||
|
||||
g++ $(gtest-config --cppflags --cxxflags) -o foo.o -c foo.cpp
|
||||
g++ $(gtest-config --ldflags --libs) -o foo foo.o
|
||||
|
||||
# When using a built but not installed Google Test:
|
||||
g++ $(../../my_gtest_build/scripts/gtest-config ...) ...
|
||||
|
||||
# When using an installed Google Test, but with installation overrides:
|
||||
export GTEST_PREFIX="/opt"
|
||||
g++ $(gtest-config --libdir="/opt/lib64" ...) ...
|
||||
|
||||
Help:
|
||||
--usage brief usage information
|
||||
--help display this help message
|
||||
|
||||
Installation Overrides:
|
||||
--prefix=<dir> overrides the installation prefix
|
||||
--exec-prefix=<dir> overrides the executable installation prefix
|
||||
--libdir=<dir> overrides the library installation prefix
|
||||
--includedir=<dir> overrides the header file installation prefix
|
||||
|
||||
Installation Queries:
|
||||
--prefix installation prefix
|
||||
--exec-prefix executable installation prefix
|
||||
--libdir library installation directory
|
||||
--includedir header file installation directory
|
||||
--version the version of the Google Test installation
|
||||
|
||||
Version Queries:
|
||||
--min-version=VERSION return 0 if the version is at least VERSION
|
||||
--exact-version=VERSION return 0 if the version is exactly VERSION
|
||||
--max-version=VERSION return 0 if the version is at most VERSION
|
||||
|
||||
Compilation Flag Queries:
|
||||
--cppflags compile flags specific to the C-like preprocessors
|
||||
--cxxflags compile flags appropriate for C++ programs
|
||||
--ldflags linker flags
|
||||
--libs libraries for linking
|
||||
|
||||
EOF
|
||||
}
|
||||
|
||||
# This function bounds our version with a min and a max. It uses some clever
|
||||
# POSIX-compliant variable expansion to portably do all the work in the shell
|
||||
# and avoid any dependency on a particular "sed" or "awk" implementation.
|
||||
# Notable is that it will only ever compare the first 3 components of versions.
|
||||
# Further components will be cleanly stripped off. All versions must be
|
||||
# unadorned, so "v1.0" will *not* work. The minimum version must be in $1, and
|
||||
# the max in $2. TODO(chandlerc@google.com): If this ever breaks, we should
|
||||
# investigate expanding this via autom4te from AS_VERSION_COMPARE rather than
|
||||
# continuing to maintain our own shell version.
|
||||
check_versions()
|
||||
{
|
||||
major_version=${version%%.*}
|
||||
minor_version="0"
|
||||
point_version="0"
|
||||
if test "${version#*.}" != "${version}"; then
|
||||
minor_version=${version#*.}
|
||||
minor_version=${minor_version%%.*}
|
||||
fi
|
||||
if test "${version#*.*.}" != "${version}"; then
|
||||
point_version=${version#*.*.}
|
||||
point_version=${point_version%%.*}
|
||||
fi
|
||||
|
||||
min_version="$1"
|
||||
min_major_version=${min_version%%.*}
|
||||
min_minor_version="0"
|
||||
min_point_version="0"
|
||||
if test "${min_version#*.}" != "${min_version}"; then
|
||||
min_minor_version=${min_version#*.}
|
||||
min_minor_version=${min_minor_version%%.*}
|
||||
fi
|
||||
if test "${min_version#*.*.}" != "${min_version}"; then
|
||||
min_point_version=${min_version#*.*.}
|
||||
min_point_version=${min_point_version%%.*}
|
||||
fi
|
||||
|
||||
max_version="$2"
|
||||
max_major_version=${max_version%%.*}
|
||||
max_minor_version="0"
|
||||
max_point_version="0"
|
||||
if test "${max_version#*.}" != "${max_version}"; then
|
||||
max_minor_version=${max_version#*.}
|
||||
max_minor_version=${max_minor_version%%.*}
|
||||
fi
|
||||
if test "${max_version#*.*.}" != "${max_version}"; then
|
||||
max_point_version=${max_version#*.*.}
|
||||
max_point_version=${max_point_version%%.*}
|
||||
fi
|
||||
|
||||
test $(($major_version)) -lt $(($min_major_version)) && exit 1
|
||||
if test $(($major_version)) -eq $(($min_major_version)); then
|
||||
test $(($minor_version)) -lt $(($min_minor_version)) && exit 1
|
||||
if test $(($minor_version)) -eq $(($min_minor_version)); then
|
||||
test $(($point_version)) -lt $(($min_point_version)) && exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
test $(($major_version)) -gt $(($max_major_version)) && exit 1
|
||||
if test $(($major_version)) -eq $(($max_major_version)); then
|
||||
test $(($minor_version)) -gt $(($max_minor_version)) && exit 1
|
||||
if test $(($minor_version)) -eq $(($max_minor_version)); then
|
||||
test $(($point_version)) -gt $(($max_point_version)) && exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
exit 0
|
||||
}
|
||||
|
||||
# Show the usage line when no arguments are specified.
|
||||
if test $# -eq 0; then
|
||||
show_usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
while test $# -gt 0; do
|
||||
case $1 in
|
||||
--usage) show_usage; exit 0;;
|
||||
--help) show_help; exit 0;;
|
||||
|
||||
# Installation overrides
|
||||
--prefix=*) GTEST_PREFIX=${1#--prefix=};;
|
||||
--exec-prefix=*) GTEST_EXEC_PREFIX=${1#--exec-prefix=};;
|
||||
--libdir=*) GTEST_LIBDIR=${1#--libdir=};;
|
||||
--includedir=*) GTEST_INCLUDEDIR=${1#--includedir=};;
|
||||
|
||||
# Installation queries
|
||||
--prefix|--exec-prefix|--libdir|--includedir|--version)
|
||||
if test -n "${do_query}"; then
|
||||
show_usage
|
||||
exit 1
|
||||
fi
|
||||
do_query=${1#--}
|
||||
;;
|
||||
|
||||
# Version checking
|
||||
--min-version=*)
|
||||
do_check_versions=yes
|
||||
min_version=${1#--min-version=}
|
||||
;;
|
||||
--max-version=*)
|
||||
do_check_versions=yes
|
||||
max_version=${1#--max-version=}
|
||||
;;
|
||||
--exact-version=*)
|
||||
do_check_versions=yes
|
||||
exact_version=${1#--exact-version=}
|
||||
;;
|
||||
|
||||
# Compiler flag output
|
||||
--cppflags) echo_cppflags=yes;;
|
||||
--cxxflags) echo_cxxflags=yes;;
|
||||
--ldflags) echo_ldflags=yes;;
|
||||
--libs) echo_libs=yes;;
|
||||
|
||||
# Everything else is an error
|
||||
*) show_usage; exit 1;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
# These have defaults filled in by the configure script but can also be
|
||||
# overridden by environment variables or command line parameters.
|
||||
prefix="${GTEST_PREFIX:-@prefix@}"
|
||||
exec_prefix="${GTEST_EXEC_PREFIX:-@exec_prefix@}"
|
||||
libdir="${GTEST_LIBDIR:-@libdir@}"
|
||||
includedir="${GTEST_INCLUDEDIR:-@includedir@}"
|
||||
|
||||
# We try and detect if our binary is not located at its installed location. If
|
||||
# it's not, we provide variables pointing to the source and build tree rather
|
||||
# than to the install tree. This allows building against a just-built gtest
|
||||
# rather than an installed gtest.
|
||||
bindir="@bindir@"
|
||||
this_relative_bindir=`dirname $0`
|
||||
this_bindir=`cd ${this_relative_bindir}; pwd -P`
|
||||
if test "${this_bindir}" = "${this_bindir%${bindir}}"; then
|
||||
# The path to the script doesn't end in the bindir sequence from Autoconf,
|
||||
# assume that we are in a build tree.
|
||||
build_dir=`dirname ${this_bindir}`
|
||||
src_dir=`cd ${this_bindir}; cd @top_srcdir@; pwd -P`
|
||||
|
||||
# TODO(chandlerc@google.com): This is a dangerous dependency on libtool, we
|
||||
# should work to remove it, and/or remove libtool altogether, replacing it
|
||||
# with direct references to the library and a link path.
|
||||
gtest_libs="${build_dir}/lib/libgtest.la @PTHREAD_CFLAGS@ @PTHREAD_LIBS@"
|
||||
gtest_ldflags=""
|
||||
|
||||
# We provide hooks to include from either the source or build dir, where the
|
||||
# build dir is always preferred. This will potentially allow us to write
|
||||
# build rules for generated headers and have them automatically be preferred
|
||||
# over provided versions.
|
||||
gtest_cppflags="-I${build_dir}/include -I${src_dir}/include"
|
||||
gtest_cxxflags="@PTHREAD_CFLAGS@"
|
||||
else
|
||||
# We're using an installed gtest, although it may be staged under some
|
||||
# prefix. Assume (as our own libraries do) that we can resolve the prefix,
|
||||
# and are present in the dynamic link paths.
|
||||
gtest_ldflags="-L${libdir}"
|
||||
gtest_libs="-l${name} @PTHREAD_CFLAGS@ @PTHREAD_LIBS@"
|
||||
gtest_cppflags="-I${includedir}"
|
||||
gtest_cxxflags="@PTHREAD_CFLAGS@"
|
||||
fi
|
||||
|
||||
# Do an installation query if requested.
|
||||
if test -n "$do_query"; then
|
||||
case $do_query in
|
||||
prefix) echo $prefix; exit 0;;
|
||||
exec-prefix) echo $exec_prefix; exit 0;;
|
||||
libdir) echo $libdir; exit 0;;
|
||||
includedir) echo $includedir; exit 0;;
|
||||
version) echo $version; exit 0;;
|
||||
*) show_usage; exit 1;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# Do a version check if requested.
|
||||
if test "$do_check_versions" = "yes"; then
|
||||
# Make sure we didn't receive a bad combination of parameters.
|
||||
test "$echo_cppflags" = "yes" && show_usage && exit 1
|
||||
test "$echo_cxxflags" = "yes" && show_usage && exit 1
|
||||
test "$echo_ldflags" = "yes" && show_usage && exit 1
|
||||
test "$echo_libs" = "yes" && show_usage && exit 1
|
||||
|
||||
if test "$exact_version" != ""; then
|
||||
check_versions $exact_version $exact_version
|
||||
# unreachable
|
||||
else
|
||||
check_versions ${min_version:-0.0.0} ${max_version:-9999.9999.9999}
|
||||
# unreachable
|
||||
fi
|
||||
fi
|
||||
|
||||
# Do the output in the correct order so that these can be used in-line of
|
||||
# a compiler invocation.
|
||||
output=""
|
||||
test "$echo_cppflags" = "yes" && output="$output $gtest_cppflags"
|
||||
test "$echo_cxxflags" = "yes" && output="$output $gtest_cxxflags"
|
||||
test "$echo_ldflags" = "yes" && output="$output $gtest_ldflags"
|
||||
test "$echo_libs" = "yes" && output="$output $gtest_libs"
|
||||
echo $output
|
||||
|
||||
exit 0
|
||||
855
Engine/lib/assimp/contrib/gtest/scripts/pump.py
Normal file
855
Engine/lib/assimp/contrib/gtest/scripts/pump.py
Normal file
|
|
@ -0,0 +1,855 @@
|
|||
#!/usr/bin/env python
|
||||
#
|
||||
# Copyright 2008, Google Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are
|
||||
# met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above
|
||||
# copyright notice, this list of conditions and the following disclaimer
|
||||
# in the documentation and/or other materials provided with the
|
||||
# distribution.
|
||||
# * Neither the name of Google Inc. nor the names of its
|
||||
# contributors may be used to endorse or promote products derived from
|
||||
# this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
"""pump v0.2.0 - Pretty Useful for Meta Programming.
|
||||
|
||||
A tool for preprocessor meta programming. Useful for generating
|
||||
repetitive boilerplate code. Especially useful for writing C++
|
||||
classes, functions, macros, and templates that need to work with
|
||||
various number of arguments.
|
||||
|
||||
USAGE:
|
||||
pump.py SOURCE_FILE
|
||||
|
||||
EXAMPLES:
|
||||
pump.py foo.cc.pump
|
||||
Converts foo.cc.pump to foo.cc.
|
||||
|
||||
GRAMMAR:
|
||||
CODE ::= ATOMIC_CODE*
|
||||
ATOMIC_CODE ::= $var ID = EXPRESSION
|
||||
| $var ID = [[ CODE ]]
|
||||
| $range ID EXPRESSION..EXPRESSION
|
||||
| $for ID SEPARATOR [[ CODE ]]
|
||||
| $($)
|
||||
| $ID
|
||||
| $(EXPRESSION)
|
||||
| $if EXPRESSION [[ CODE ]] ELSE_BRANCH
|
||||
| [[ CODE ]]
|
||||
| RAW_CODE
|
||||
SEPARATOR ::= RAW_CODE | EMPTY
|
||||
ELSE_BRANCH ::= $else [[ CODE ]]
|
||||
| $elif EXPRESSION [[ CODE ]] ELSE_BRANCH
|
||||
| EMPTY
|
||||
EXPRESSION has Python syntax.
|
||||
"""
|
||||
|
||||
__author__ = 'wan@google.com (Zhanyong Wan)'
|
||||
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
|
||||
|
||||
TOKEN_TABLE = [
|
||||
(re.compile(r'\$var\s+'), '$var'),
|
||||
(re.compile(r'\$elif\s+'), '$elif'),
|
||||
(re.compile(r'\$else\s+'), '$else'),
|
||||
(re.compile(r'\$for\s+'), '$for'),
|
||||
(re.compile(r'\$if\s+'), '$if'),
|
||||
(re.compile(r'\$range\s+'), '$range'),
|
||||
(re.compile(r'\$[_A-Za-z]\w*'), '$id'),
|
||||
(re.compile(r'\$\(\$\)'), '$($)'),
|
||||
(re.compile(r'\$'), '$'),
|
||||
(re.compile(r'\[\[\n?'), '[['),
|
||||
(re.compile(r'\]\]\n?'), ']]'),
|
||||
]
|
||||
|
||||
|
||||
class Cursor:
|
||||
"""Represents a position (line and column) in a text file."""
|
||||
|
||||
def __init__(self, line=-1, column=-1):
|
||||
self.line = line
|
||||
self.column = column
|
||||
|
||||
def __eq__(self, rhs):
|
||||
return self.line == rhs.line and self.column == rhs.column
|
||||
|
||||
def __ne__(self, rhs):
|
||||
return not self == rhs
|
||||
|
||||
def __lt__(self, rhs):
|
||||
return self.line < rhs.line or (
|
||||
self.line == rhs.line and self.column < rhs.column)
|
||||
|
||||
def __le__(self, rhs):
|
||||
return self < rhs or self == rhs
|
||||
|
||||
def __gt__(self, rhs):
|
||||
return rhs < self
|
||||
|
||||
def __ge__(self, rhs):
|
||||
return rhs <= self
|
||||
|
||||
def __str__(self):
|
||||
if self == Eof():
|
||||
return 'EOF'
|
||||
else:
|
||||
return '%s(%s)' % (self.line + 1, self.column)
|
||||
|
||||
def __add__(self, offset):
|
||||
return Cursor(self.line, self.column + offset)
|
||||
|
||||
def __sub__(self, offset):
|
||||
return Cursor(self.line, self.column - offset)
|
||||
|
||||
def Clone(self):
|
||||
"""Returns a copy of self."""
|
||||
|
||||
return Cursor(self.line, self.column)
|
||||
|
||||
|
||||
# Special cursor to indicate the end-of-file.
|
||||
def Eof():
|
||||
"""Returns the special cursor to denote the end-of-file."""
|
||||
return Cursor(-1, -1)
|
||||
|
||||
|
||||
class Token:
|
||||
"""Represents a token in a Pump source file."""
|
||||
|
||||
def __init__(self, start=None, end=None, value=None, token_type=None):
|
||||
if start is None:
|
||||
self.start = Eof()
|
||||
else:
|
||||
self.start = start
|
||||
if end is None:
|
||||
self.end = Eof()
|
||||
else:
|
||||
self.end = end
|
||||
self.value = value
|
||||
self.token_type = token_type
|
||||
|
||||
def __str__(self):
|
||||
return 'Token @%s: \'%s\' type=%s' % (
|
||||
self.start, self.value, self.token_type)
|
||||
|
||||
def Clone(self):
|
||||
"""Returns a copy of self."""
|
||||
|
||||
return Token(self.start.Clone(), self.end.Clone(), self.value,
|
||||
self.token_type)
|
||||
|
||||
|
||||
def StartsWith(lines, pos, string):
|
||||
"""Returns True iff the given position in lines starts with 'string'."""
|
||||
|
||||
return lines[pos.line][pos.column:].startswith(string)
|
||||
|
||||
|
||||
def FindFirstInLine(line, token_table):
|
||||
best_match_start = -1
|
||||
for (regex, token_type) in token_table:
|
||||
m = regex.search(line)
|
||||
if m:
|
||||
# We found regex in lines
|
||||
if best_match_start < 0 or m.start() < best_match_start:
|
||||
best_match_start = m.start()
|
||||
best_match_length = m.end() - m.start()
|
||||
best_match_token_type = token_type
|
||||
|
||||
if best_match_start < 0:
|
||||
return None
|
||||
|
||||
return (best_match_start, best_match_length, best_match_token_type)
|
||||
|
||||
|
||||
def FindFirst(lines, token_table, cursor):
|
||||
"""Finds the first occurrence of any string in strings in lines."""
|
||||
|
||||
start = cursor.Clone()
|
||||
cur_line_number = cursor.line
|
||||
for line in lines[start.line:]:
|
||||
if cur_line_number == start.line:
|
||||
line = line[start.column:]
|
||||
m = FindFirstInLine(line, token_table)
|
||||
if m:
|
||||
# We found a regex in line.
|
||||
(start_column, length, token_type) = m
|
||||
if cur_line_number == start.line:
|
||||
start_column += start.column
|
||||
found_start = Cursor(cur_line_number, start_column)
|
||||
found_end = found_start + length
|
||||
return MakeToken(lines, found_start, found_end, token_type)
|
||||
cur_line_number += 1
|
||||
# We failed to find str in lines
|
||||
return None
|
||||
|
||||
|
||||
def SubString(lines, start, end):
|
||||
"""Returns a substring in lines."""
|
||||
|
||||
if end == Eof():
|
||||
end = Cursor(len(lines) - 1, len(lines[-1]))
|
||||
|
||||
if start >= end:
|
||||
return ''
|
||||
|
||||
if start.line == end.line:
|
||||
return lines[start.line][start.column:end.column]
|
||||
|
||||
result_lines = ([lines[start.line][start.column:]] +
|
||||
lines[start.line + 1:end.line] +
|
||||
[lines[end.line][:end.column]])
|
||||
return ''.join(result_lines)
|
||||
|
||||
|
||||
def StripMetaComments(str):
|
||||
"""Strip meta comments from each line in the given string."""
|
||||
|
||||
# First, completely remove lines containing nothing but a meta
|
||||
# comment, including the trailing \n.
|
||||
str = re.sub(r'^\s*\$\$.*\n', '', str)
|
||||
|
||||
# Then, remove meta comments from contentful lines.
|
||||
return re.sub(r'\s*\$\$.*', '', str)
|
||||
|
||||
|
||||
def MakeToken(lines, start, end, token_type):
|
||||
"""Creates a new instance of Token."""
|
||||
|
||||
return Token(start, end, SubString(lines, start, end), token_type)
|
||||
|
||||
|
||||
def ParseToken(lines, pos, regex, token_type):
|
||||
line = lines[pos.line][pos.column:]
|
||||
m = regex.search(line)
|
||||
if m and not m.start():
|
||||
return MakeToken(lines, pos, pos + m.end(), token_type)
|
||||
else:
|
||||
print 'ERROR: %s expected at %s.' % (token_type, pos)
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
ID_REGEX = re.compile(r'[_A-Za-z]\w*')
|
||||
EQ_REGEX = re.compile(r'=')
|
||||
REST_OF_LINE_REGEX = re.compile(r'.*?(?=$|\$\$)')
|
||||
OPTIONAL_WHITE_SPACES_REGEX = re.compile(r'\s*')
|
||||
WHITE_SPACE_REGEX = re.compile(r'\s')
|
||||
DOT_DOT_REGEX = re.compile(r'\.\.')
|
||||
|
||||
|
||||
def Skip(lines, pos, regex):
|
||||
line = lines[pos.line][pos.column:]
|
||||
m = re.search(regex, line)
|
||||
if m and not m.start():
|
||||
return pos + m.end()
|
||||
else:
|
||||
return pos
|
||||
|
||||
|
||||
def SkipUntil(lines, pos, regex, token_type):
|
||||
line = lines[pos.line][pos.column:]
|
||||
m = re.search(regex, line)
|
||||
if m:
|
||||
return pos + m.start()
|
||||
else:
|
||||
print ('ERROR: %s expected on line %s after column %s.' %
|
||||
(token_type, pos.line + 1, pos.column))
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def ParseExpTokenInParens(lines, pos):
|
||||
def ParseInParens(pos):
|
||||
pos = Skip(lines, pos, OPTIONAL_WHITE_SPACES_REGEX)
|
||||
pos = Skip(lines, pos, r'\(')
|
||||
pos = Parse(pos)
|
||||
pos = Skip(lines, pos, r'\)')
|
||||
return pos
|
||||
|
||||
def Parse(pos):
|
||||
pos = SkipUntil(lines, pos, r'\(|\)', ')')
|
||||
if SubString(lines, pos, pos + 1) == '(':
|
||||
pos = Parse(pos + 1)
|
||||
pos = Skip(lines, pos, r'\)')
|
||||
return Parse(pos)
|
||||
else:
|
||||
return pos
|
||||
|
||||
start = pos.Clone()
|
||||
pos = ParseInParens(pos)
|
||||
return MakeToken(lines, start, pos, 'exp')
|
||||
|
||||
|
||||
def RStripNewLineFromToken(token):
|
||||
if token.value.endswith('\n'):
|
||||
return Token(token.start, token.end, token.value[:-1], token.token_type)
|
||||
else:
|
||||
return token
|
||||
|
||||
|
||||
def TokenizeLines(lines, pos):
|
||||
while True:
|
||||
found = FindFirst(lines, TOKEN_TABLE, pos)
|
||||
if not found:
|
||||
yield MakeToken(lines, pos, Eof(), 'code')
|
||||
return
|
||||
|
||||
if found.start == pos:
|
||||
prev_token = None
|
||||
prev_token_rstripped = None
|
||||
else:
|
||||
prev_token = MakeToken(lines, pos, found.start, 'code')
|
||||
prev_token_rstripped = RStripNewLineFromToken(prev_token)
|
||||
|
||||
if found.token_type == '$var':
|
||||
if prev_token_rstripped:
|
||||
yield prev_token_rstripped
|
||||
yield found
|
||||
id_token = ParseToken(lines, found.end, ID_REGEX, 'id')
|
||||
yield id_token
|
||||
pos = Skip(lines, id_token.end, OPTIONAL_WHITE_SPACES_REGEX)
|
||||
|
||||
eq_token = ParseToken(lines, pos, EQ_REGEX, '=')
|
||||
yield eq_token
|
||||
pos = Skip(lines, eq_token.end, r'\s*')
|
||||
|
||||
if SubString(lines, pos, pos + 2) != '[[':
|
||||
exp_token = ParseToken(lines, pos, REST_OF_LINE_REGEX, 'exp')
|
||||
yield exp_token
|
||||
pos = Cursor(exp_token.end.line + 1, 0)
|
||||
elif found.token_type == '$for':
|
||||
if prev_token_rstripped:
|
||||
yield prev_token_rstripped
|
||||
yield found
|
||||
id_token = ParseToken(lines, found.end, ID_REGEX, 'id')
|
||||
yield id_token
|
||||
pos = Skip(lines, id_token.end, WHITE_SPACE_REGEX)
|
||||
elif found.token_type == '$range':
|
||||
if prev_token_rstripped:
|
||||
yield prev_token_rstripped
|
||||
yield found
|
||||
id_token = ParseToken(lines, found.end, ID_REGEX, 'id')
|
||||
yield id_token
|
||||
pos = Skip(lines, id_token.end, OPTIONAL_WHITE_SPACES_REGEX)
|
||||
|
||||
dots_pos = SkipUntil(lines, pos, DOT_DOT_REGEX, '..')
|
||||
yield MakeToken(lines, pos, dots_pos, 'exp')
|
||||
yield MakeToken(lines, dots_pos, dots_pos + 2, '..')
|
||||
pos = dots_pos + 2
|
||||
new_pos = Cursor(pos.line + 1, 0)
|
||||
yield MakeToken(lines, pos, new_pos, 'exp')
|
||||
pos = new_pos
|
||||
elif found.token_type == '$':
|
||||
if prev_token:
|
||||
yield prev_token
|
||||
yield found
|
||||
exp_token = ParseExpTokenInParens(lines, found.end)
|
||||
yield exp_token
|
||||
pos = exp_token.end
|
||||
elif (found.token_type == ']]' or found.token_type == '$if' or
|
||||
found.token_type == '$elif' or found.token_type == '$else'):
|
||||
if prev_token_rstripped:
|
||||
yield prev_token_rstripped
|
||||
yield found
|
||||
pos = found.end
|
||||
else:
|
||||
if prev_token:
|
||||
yield prev_token
|
||||
yield found
|
||||
pos = found.end
|
||||
|
||||
|
||||
def Tokenize(s):
|
||||
"""A generator that yields the tokens in the given string."""
|
||||
if s != '':
|
||||
lines = s.splitlines(True)
|
||||
for token in TokenizeLines(lines, Cursor(0, 0)):
|
||||
yield token
|
||||
|
||||
|
||||
class CodeNode:
|
||||
def __init__(self, atomic_code_list=None):
|
||||
self.atomic_code = atomic_code_list
|
||||
|
||||
|
||||
class VarNode:
|
||||
def __init__(self, identifier=None, atomic_code=None):
|
||||
self.identifier = identifier
|
||||
self.atomic_code = atomic_code
|
||||
|
||||
|
||||
class RangeNode:
|
||||
def __init__(self, identifier=None, exp1=None, exp2=None):
|
||||
self.identifier = identifier
|
||||
self.exp1 = exp1
|
||||
self.exp2 = exp2
|
||||
|
||||
|
||||
class ForNode:
|
||||
def __init__(self, identifier=None, sep=None, code=None):
|
||||
self.identifier = identifier
|
||||
self.sep = sep
|
||||
self.code = code
|
||||
|
||||
|
||||
class ElseNode:
|
||||
def __init__(self, else_branch=None):
|
||||
self.else_branch = else_branch
|
||||
|
||||
|
||||
class IfNode:
|
||||
def __init__(self, exp=None, then_branch=None, else_branch=None):
|
||||
self.exp = exp
|
||||
self.then_branch = then_branch
|
||||
self.else_branch = else_branch
|
||||
|
||||
|
||||
class RawCodeNode:
|
||||
def __init__(self, token=None):
|
||||
self.raw_code = token
|
||||
|
||||
|
||||
class LiteralDollarNode:
|
||||
def __init__(self, token):
|
||||
self.token = token
|
||||
|
||||
|
||||
class ExpNode:
|
||||
def __init__(self, token, python_exp):
|
||||
self.token = token
|
||||
self.python_exp = python_exp
|
||||
|
||||
|
||||
def PopFront(a_list):
|
||||
head = a_list[0]
|
||||
a_list[:1] = []
|
||||
return head
|
||||
|
||||
|
||||
def PushFront(a_list, elem):
|
||||
a_list[:0] = [elem]
|
||||
|
||||
|
||||
def PopToken(a_list, token_type=None):
|
||||
token = PopFront(a_list)
|
||||
if token_type is not None and token.token_type != token_type:
|
||||
print 'ERROR: %s expected at %s' % (token_type, token.start)
|
||||
print 'ERROR: %s found instead' % (token,)
|
||||
sys.exit(1)
|
||||
|
||||
return token
|
||||
|
||||
|
||||
def PeekToken(a_list):
|
||||
if not a_list:
|
||||
return None
|
||||
|
||||
return a_list[0]
|
||||
|
||||
|
||||
def ParseExpNode(token):
|
||||
python_exp = re.sub(r'([_A-Za-z]\w*)', r'self.GetValue("\1")', token.value)
|
||||
return ExpNode(token, python_exp)
|
||||
|
||||
|
||||
def ParseElseNode(tokens):
|
||||
def Pop(token_type=None):
|
||||
return PopToken(tokens, token_type)
|
||||
|
||||
next = PeekToken(tokens)
|
||||
if not next:
|
||||
return None
|
||||
if next.token_type == '$else':
|
||||
Pop('$else')
|
||||
Pop('[[')
|
||||
code_node = ParseCodeNode(tokens)
|
||||
Pop(']]')
|
||||
return code_node
|
||||
elif next.token_type == '$elif':
|
||||
Pop('$elif')
|
||||
exp = Pop('code')
|
||||
Pop('[[')
|
||||
code_node = ParseCodeNode(tokens)
|
||||
Pop(']]')
|
||||
inner_else_node = ParseElseNode(tokens)
|
||||
return CodeNode([IfNode(ParseExpNode(exp), code_node, inner_else_node)])
|
||||
elif not next.value.strip():
|
||||
Pop('code')
|
||||
return ParseElseNode(tokens)
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
def ParseAtomicCodeNode(tokens):
|
||||
def Pop(token_type=None):
|
||||
return PopToken(tokens, token_type)
|
||||
|
||||
head = PopFront(tokens)
|
||||
t = head.token_type
|
||||
if t == 'code':
|
||||
return RawCodeNode(head)
|
||||
elif t == '$var':
|
||||
id_token = Pop('id')
|
||||
Pop('=')
|
||||
next = PeekToken(tokens)
|
||||
if next.token_type == 'exp':
|
||||
exp_token = Pop()
|
||||
return VarNode(id_token, ParseExpNode(exp_token))
|
||||
Pop('[[')
|
||||
code_node = ParseCodeNode(tokens)
|
||||
Pop(']]')
|
||||
return VarNode(id_token, code_node)
|
||||
elif t == '$for':
|
||||
id_token = Pop('id')
|
||||
next_token = PeekToken(tokens)
|
||||
if next_token.token_type == 'code':
|
||||
sep_token = next_token
|
||||
Pop('code')
|
||||
else:
|
||||
sep_token = None
|
||||
Pop('[[')
|
||||
code_node = ParseCodeNode(tokens)
|
||||
Pop(']]')
|
||||
return ForNode(id_token, sep_token, code_node)
|
||||
elif t == '$if':
|
||||
exp_token = Pop('code')
|
||||
Pop('[[')
|
||||
code_node = ParseCodeNode(tokens)
|
||||
Pop(']]')
|
||||
else_node = ParseElseNode(tokens)
|
||||
return IfNode(ParseExpNode(exp_token), code_node, else_node)
|
||||
elif t == '$range':
|
||||
id_token = Pop('id')
|
||||
exp1_token = Pop('exp')
|
||||
Pop('..')
|
||||
exp2_token = Pop('exp')
|
||||
return RangeNode(id_token, ParseExpNode(exp1_token),
|
||||
ParseExpNode(exp2_token))
|
||||
elif t == '$id':
|
||||
return ParseExpNode(Token(head.start + 1, head.end, head.value[1:], 'id'))
|
||||
elif t == '$($)':
|
||||
return LiteralDollarNode(head)
|
||||
elif t == '$':
|
||||
exp_token = Pop('exp')
|
||||
return ParseExpNode(exp_token)
|
||||
elif t == '[[':
|
||||
code_node = ParseCodeNode(tokens)
|
||||
Pop(']]')
|
||||
return code_node
|
||||
else:
|
||||
PushFront(tokens, head)
|
||||
return None
|
||||
|
||||
|
||||
def ParseCodeNode(tokens):
|
||||
atomic_code_list = []
|
||||
while True:
|
||||
if not tokens:
|
||||
break
|
||||
atomic_code_node = ParseAtomicCodeNode(tokens)
|
||||
if atomic_code_node:
|
||||
atomic_code_list.append(atomic_code_node)
|
||||
else:
|
||||
break
|
||||
return CodeNode(atomic_code_list)
|
||||
|
||||
|
||||
def ParseToAST(pump_src_text):
|
||||
"""Convert the given Pump source text into an AST."""
|
||||
tokens = list(Tokenize(pump_src_text))
|
||||
code_node = ParseCodeNode(tokens)
|
||||
return code_node
|
||||
|
||||
|
||||
class Env:
|
||||
def __init__(self):
|
||||
self.variables = []
|
||||
self.ranges = []
|
||||
|
||||
def Clone(self):
|
||||
clone = Env()
|
||||
clone.variables = self.variables[:]
|
||||
clone.ranges = self.ranges[:]
|
||||
return clone
|
||||
|
||||
def PushVariable(self, var, value):
|
||||
# If value looks like an int, store it as an int.
|
||||
try:
|
||||
int_value = int(value)
|
||||
if ('%s' % int_value) == value:
|
||||
value = int_value
|
||||
except Exception:
|
||||
pass
|
||||
self.variables[:0] = [(var, value)]
|
||||
|
||||
def PopVariable(self):
|
||||
self.variables[:1] = []
|
||||
|
||||
def PushRange(self, var, lower, upper):
|
||||
self.ranges[:0] = [(var, lower, upper)]
|
||||
|
||||
def PopRange(self):
|
||||
self.ranges[:1] = []
|
||||
|
||||
def GetValue(self, identifier):
|
||||
for (var, value) in self.variables:
|
||||
if identifier == var:
|
||||
return value
|
||||
|
||||
print 'ERROR: meta variable %s is undefined.' % (identifier,)
|
||||
sys.exit(1)
|
||||
|
||||
def EvalExp(self, exp):
|
||||
try:
|
||||
result = eval(exp.python_exp)
|
||||
except Exception, e:
|
||||
print 'ERROR: caught exception %s: %s' % (e.__class__.__name__, e)
|
||||
print ('ERROR: failed to evaluate meta expression %s at %s' %
|
||||
(exp.python_exp, exp.token.start))
|
||||
sys.exit(1)
|
||||
return result
|
||||
|
||||
def GetRange(self, identifier):
|
||||
for (var, lower, upper) in self.ranges:
|
||||
if identifier == var:
|
||||
return (lower, upper)
|
||||
|
||||
print 'ERROR: range %s is undefined.' % (identifier,)
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
class Output:
|
||||
def __init__(self):
|
||||
self.string = ''
|
||||
|
||||
def GetLastLine(self):
|
||||
index = self.string.rfind('\n')
|
||||
if index < 0:
|
||||
return ''
|
||||
|
||||
return self.string[index + 1:]
|
||||
|
||||
def Append(self, s):
|
||||
self.string += s
|
||||
|
||||
|
||||
def RunAtomicCode(env, node, output):
|
||||
if isinstance(node, VarNode):
|
||||
identifier = node.identifier.value.strip()
|
||||
result = Output()
|
||||
RunAtomicCode(env.Clone(), node.atomic_code, result)
|
||||
value = result.string
|
||||
env.PushVariable(identifier, value)
|
||||
elif isinstance(node, RangeNode):
|
||||
identifier = node.identifier.value.strip()
|
||||
lower = int(env.EvalExp(node.exp1))
|
||||
upper = int(env.EvalExp(node.exp2))
|
||||
env.PushRange(identifier, lower, upper)
|
||||
elif isinstance(node, ForNode):
|
||||
identifier = node.identifier.value.strip()
|
||||
if node.sep is None:
|
||||
sep = ''
|
||||
else:
|
||||
sep = node.sep.value
|
||||
(lower, upper) = env.GetRange(identifier)
|
||||
for i in range(lower, upper + 1):
|
||||
new_env = env.Clone()
|
||||
new_env.PushVariable(identifier, i)
|
||||
RunCode(new_env, node.code, output)
|
||||
if i != upper:
|
||||
output.Append(sep)
|
||||
elif isinstance(node, RawCodeNode):
|
||||
output.Append(node.raw_code.value)
|
||||
elif isinstance(node, IfNode):
|
||||
cond = env.EvalExp(node.exp)
|
||||
if cond:
|
||||
RunCode(env.Clone(), node.then_branch, output)
|
||||
elif node.else_branch is not None:
|
||||
RunCode(env.Clone(), node.else_branch, output)
|
||||
elif isinstance(node, ExpNode):
|
||||
value = env.EvalExp(node)
|
||||
output.Append('%s' % (value,))
|
||||
elif isinstance(node, LiteralDollarNode):
|
||||
output.Append('$')
|
||||
elif isinstance(node, CodeNode):
|
||||
RunCode(env.Clone(), node, output)
|
||||
else:
|
||||
print 'BAD'
|
||||
print node
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def RunCode(env, code_node, output):
|
||||
for atomic_code in code_node.atomic_code:
|
||||
RunAtomicCode(env, atomic_code, output)
|
||||
|
||||
|
||||
def IsSingleLineComment(cur_line):
|
||||
return '//' in cur_line
|
||||
|
||||
|
||||
def IsInPreprocessorDirective(prev_lines, cur_line):
|
||||
if cur_line.lstrip().startswith('#'):
|
||||
return True
|
||||
return prev_lines and prev_lines[-1].endswith('\\')
|
||||
|
||||
|
||||
def WrapComment(line, output):
|
||||
loc = line.find('//')
|
||||
before_comment = line[:loc].rstrip()
|
||||
if before_comment == '':
|
||||
indent = loc
|
||||
else:
|
||||
output.append(before_comment)
|
||||
indent = len(before_comment) - len(before_comment.lstrip())
|
||||
prefix = indent*' ' + '// '
|
||||
max_len = 80 - len(prefix)
|
||||
comment = line[loc + 2:].strip()
|
||||
segs = [seg for seg in re.split(r'(\w+\W*)', comment) if seg != '']
|
||||
cur_line = ''
|
||||
for seg in segs:
|
||||
if len((cur_line + seg).rstrip()) < max_len:
|
||||
cur_line += seg
|
||||
else:
|
||||
if cur_line.strip() != '':
|
||||
output.append(prefix + cur_line.rstrip())
|
||||
cur_line = seg.lstrip()
|
||||
if cur_line.strip() != '':
|
||||
output.append(prefix + cur_line.strip())
|
||||
|
||||
|
||||
def WrapCode(line, line_concat, output):
|
||||
indent = len(line) - len(line.lstrip())
|
||||
prefix = indent*' ' # Prefix of the current line
|
||||
max_len = 80 - indent - len(line_concat) # Maximum length of the current line
|
||||
new_prefix = prefix + 4*' ' # Prefix of a continuation line
|
||||
new_max_len = max_len - 4 # Maximum length of a continuation line
|
||||
# Prefers to wrap a line after a ',' or ';'.
|
||||
segs = [seg for seg in re.split(r'([^,;]+[,;]?)', line.strip()) if seg != '']
|
||||
cur_line = '' # The current line without leading spaces.
|
||||
for seg in segs:
|
||||
# If the line is still too long, wrap at a space.
|
||||
while cur_line == '' and len(seg.strip()) > max_len:
|
||||
seg = seg.lstrip()
|
||||
split_at = seg.rfind(' ', 0, max_len)
|
||||
output.append(prefix + seg[:split_at].strip() + line_concat)
|
||||
seg = seg[split_at + 1:]
|
||||
prefix = new_prefix
|
||||
max_len = new_max_len
|
||||
|
||||
if len((cur_line + seg).rstrip()) < max_len:
|
||||
cur_line = (cur_line + seg).lstrip()
|
||||
else:
|
||||
output.append(prefix + cur_line.rstrip() + line_concat)
|
||||
prefix = new_prefix
|
||||
max_len = new_max_len
|
||||
cur_line = seg.lstrip()
|
||||
if cur_line.strip() != '':
|
||||
output.append(prefix + cur_line.strip())
|
||||
|
||||
|
||||
def WrapPreprocessorDirective(line, output):
|
||||
WrapCode(line, ' \\', output)
|
||||
|
||||
|
||||
def WrapPlainCode(line, output):
|
||||
WrapCode(line, '', output)
|
||||
|
||||
|
||||
def IsMultiLineIWYUPragma(line):
|
||||
return re.search(r'/\* IWYU pragma: ', line)
|
||||
|
||||
|
||||
def IsHeaderGuardIncludeOrOneLineIWYUPragma(line):
|
||||
return (re.match(r'^#(ifndef|define|endif\s*//)\s*[\w_]+\s*$', line) or
|
||||
re.match(r'^#include\s', line) or
|
||||
# Don't break IWYU pragmas, either; that causes iwyu.py problems.
|
||||
re.search(r'// IWYU pragma: ', line))
|
||||
|
||||
|
||||
def WrapLongLine(line, output):
|
||||
line = line.rstrip()
|
||||
if len(line) <= 80:
|
||||
output.append(line)
|
||||
elif IsSingleLineComment(line):
|
||||
if IsHeaderGuardIncludeOrOneLineIWYUPragma(line):
|
||||
# The style guide made an exception to allow long header guard lines,
|
||||
# includes and IWYU pragmas.
|
||||
output.append(line)
|
||||
else:
|
||||
WrapComment(line, output)
|
||||
elif IsInPreprocessorDirective(output, line):
|
||||
if IsHeaderGuardIncludeOrOneLineIWYUPragma(line):
|
||||
# The style guide made an exception to allow long header guard lines,
|
||||
# includes and IWYU pragmas.
|
||||
output.append(line)
|
||||
else:
|
||||
WrapPreprocessorDirective(line, output)
|
||||
elif IsMultiLineIWYUPragma(line):
|
||||
output.append(line)
|
||||
else:
|
||||
WrapPlainCode(line, output)
|
||||
|
||||
|
||||
def BeautifyCode(string):
|
||||
lines = string.splitlines()
|
||||
output = []
|
||||
for line in lines:
|
||||
WrapLongLine(line, output)
|
||||
output2 = [line.rstrip() for line in output]
|
||||
return '\n'.join(output2) + '\n'
|
||||
|
||||
|
||||
def ConvertFromPumpSource(src_text):
|
||||
"""Return the text generated from the given Pump source text."""
|
||||
ast = ParseToAST(StripMetaComments(src_text))
|
||||
output = Output()
|
||||
RunCode(Env(), ast, output)
|
||||
return BeautifyCode(output.string)
|
||||
|
||||
|
||||
def main(argv):
|
||||
if len(argv) == 1:
|
||||
print __doc__
|
||||
sys.exit(1)
|
||||
|
||||
file_path = argv[-1]
|
||||
output_str = ConvertFromPumpSource(file(file_path, 'r').read())
|
||||
if file_path.endswith('.pump'):
|
||||
output_file_path = file_path[:-5]
|
||||
else:
|
||||
output_file_path = '-'
|
||||
if output_file_path == '-':
|
||||
print output_str,
|
||||
else:
|
||||
output_file = file(output_file_path, 'w')
|
||||
output_file.write('// This file was GENERATED by command:\n')
|
||||
output_file.write('// %s %s\n' %
|
||||
(os.path.basename(__file__), os.path.basename(file_path)))
|
||||
output_file.write('// DO NOT EDIT BY HAND!!!\n\n')
|
||||
output_file.write(output_str)
|
||||
output_file.close()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main(sys.argv)
|
||||
158
Engine/lib/assimp/contrib/gtest/scripts/release_docs.py
Normal file
158
Engine/lib/assimp/contrib/gtest/scripts/release_docs.py
Normal file
|
|
@ -0,0 +1,158 @@
|
|||
#!/usr/bin/env python
|
||||
#
|
||||
# Copyright 2013 Google Inc. All Rights Reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are
|
||||
# met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above
|
||||
# copyright notice, this list of conditions and the following disclaimer
|
||||
# in the documentation and/or other materials provided with the
|
||||
# distribution.
|
||||
# * Neither the name of Google Inc. nor the names of its
|
||||
# contributors may be used to endorse or promote products derived from
|
||||
# this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
"""Script for branching Google Test/Mock wiki pages for a new version.
|
||||
|
||||
SYNOPSIS
|
||||
release_docs.py NEW_RELEASE_VERSION
|
||||
|
||||
Google Test and Google Mock's external user documentation is in
|
||||
interlinked wiki files. When we release a new version of
|
||||
Google Test or Google Mock, we need to branch the wiki files
|
||||
such that users of a specific version of Google Test/Mock can
|
||||
look up documentation relevant for that version. This script
|
||||
automates that process by:
|
||||
|
||||
- branching the current wiki pages (which document the
|
||||
behavior of the SVN trunk head) to pages for the specified
|
||||
version (e.g. branching FAQ.wiki to V2_6_FAQ.wiki when
|
||||
NEW_RELEASE_VERSION is 2.6);
|
||||
- updating the links in the branched files to point to the branched
|
||||
version (e.g. a link in V2_6_FAQ.wiki that pointed to
|
||||
Primer.wiki#Anchor will now point to V2_6_Primer.wiki#Anchor).
|
||||
|
||||
NOTE: NEW_RELEASE_VERSION must be a NEW version number for
|
||||
which the wiki pages don't yet exist; otherwise you'll get SVN
|
||||
errors like "svn: Path 'V1_7_PumpManual.wiki' is not a
|
||||
directory" when running the script.
|
||||
|
||||
EXAMPLE
|
||||
$ cd PATH/TO/GTEST_SVN_WORKSPACE/trunk
|
||||
$ scripts/release_docs.py 2.6 # create wiki pages for v2.6
|
||||
$ svn status # verify the file list
|
||||
$ svn diff # verify the file contents
|
||||
$ svn commit -m "release wiki pages for v2.6"
|
||||
"""
|
||||
|
||||
__author__ = 'wan@google.com (Zhanyong Wan)'
|
||||
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
|
||||
import common
|
||||
|
||||
|
||||
# Wiki pages that shouldn't be branched for every gtest/gmock release.
|
||||
GTEST_UNVERSIONED_WIKIS = ['DevGuide.wiki']
|
||||
GMOCK_UNVERSIONED_WIKIS = [
|
||||
'DesignDoc.wiki',
|
||||
'DevGuide.wiki',
|
||||
'KnownIssues.wiki'
|
||||
]
|
||||
|
||||
|
||||
def DropWikiSuffix(wiki_filename):
|
||||
"""Removes the .wiki suffix (if any) from the given filename."""
|
||||
|
||||
return (wiki_filename[:-len('.wiki')] if wiki_filename.endswith('.wiki')
|
||||
else wiki_filename)
|
||||
|
||||
|
||||
class WikiBrancher(object):
|
||||
"""Branches ..."""
|
||||
|
||||
def __init__(self, dot_version):
|
||||
self.project, svn_root_path = common.GetSvnInfo()
|
||||
if self.project not in ('googletest', 'googlemock'):
|
||||
sys.exit('This script must be run in a gtest or gmock SVN workspace.')
|
||||
self.wiki_dir = svn_root_path + '/wiki'
|
||||
# Turn '2.6' to 'V2_6_'.
|
||||
self.version_prefix = 'V' + dot_version.replace('.', '_') + '_'
|
||||
self.files_to_branch = self.GetFilesToBranch()
|
||||
page_names = [DropWikiSuffix(f) for f in self.files_to_branch]
|
||||
# A link to Foo.wiki is in one of the following forms:
|
||||
# [Foo words]
|
||||
# [Foo#Anchor words]
|
||||
# [http://code.google.com/.../wiki/Foo words]
|
||||
# [http://code.google.com/.../wiki/Foo#Anchor words]
|
||||
# We want to replace 'Foo' with 'V2_6_Foo' in the above cases.
|
||||
self.search_for_re = re.compile(
|
||||
# This regex matches either
|
||||
# [Foo
|
||||
# or
|
||||
# /wiki/Foo
|
||||
# followed by a space or a #, where Foo is the name of an
|
||||
# unversioned wiki page.
|
||||
r'(\[|/wiki/)(%s)([ #])' % '|'.join(page_names))
|
||||
self.replace_with = r'\1%s\2\3' % (self.version_prefix,)
|
||||
|
||||
def GetFilesToBranch(self):
|
||||
"""Returns a list of .wiki file names that need to be branched."""
|
||||
|
||||
unversioned_wikis = (GTEST_UNVERSIONED_WIKIS if self.project == 'googletest'
|
||||
else GMOCK_UNVERSIONED_WIKIS)
|
||||
return [f for f in os.listdir(self.wiki_dir)
|
||||
if (f.endswith('.wiki') and
|
||||
not re.match(r'^V\d', f) and # Excluded versioned .wiki files.
|
||||
f not in unversioned_wikis)]
|
||||
|
||||
def BranchFiles(self):
|
||||
"""Branches the .wiki files needed to be branched."""
|
||||
|
||||
print 'Branching %d .wiki files:' % (len(self.files_to_branch),)
|
||||
os.chdir(self.wiki_dir)
|
||||
for f in self.files_to_branch:
|
||||
command = 'svn cp %s %s%s' % (f, self.version_prefix, f)
|
||||
print command
|
||||
os.system(command)
|
||||
|
||||
def UpdateLinksInBranchedFiles(self):
|
||||
|
||||
for f in self.files_to_branch:
|
||||
source_file = os.path.join(self.wiki_dir, f)
|
||||
versioned_file = os.path.join(self.wiki_dir, self.version_prefix + f)
|
||||
print 'Updating links in %s.' % (versioned_file,)
|
||||
text = file(source_file, 'r').read()
|
||||
new_text = self.search_for_re.sub(self.replace_with, text)
|
||||
file(versioned_file, 'w').write(new_text)
|
||||
|
||||
|
||||
def main():
|
||||
if len(sys.argv) != 2:
|
||||
sys.exit(__doc__)
|
||||
|
||||
brancher = WikiBrancher(sys.argv[1])
|
||||
brancher.BranchFiles()
|
||||
brancher.UpdateLinksInBranchedFiles()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
32
Engine/lib/assimp/contrib/gtest/scripts/run_with_path.py
Normal file
32
Engine/lib/assimp/contrib/gtest/scripts/run_with_path.py
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
#!/usr/bin/env python
|
||||
#
|
||||
# Copyright 2010 Google Inc. All Rights Reserved.
|
||||
|
||||
"""Runs program specified in the command line with the substituted PATH.
|
||||
|
||||
This script is needed for to support building under Pulse which is unable
|
||||
to override the existing PATH variable.
|
||||
"""
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
SUBST_PATH_ENV_VAR_NAME = "SUBST_PATH"
|
||||
|
||||
def main():
|
||||
if SUBST_PATH_ENV_VAR_NAME in os.environ:
|
||||
os.environ["PATH"] = os.environ[SUBST_PATH_ENV_VAR_NAME]
|
||||
|
||||
exit_code = subprocess.Popen(sys.argv[1:]).wait()
|
||||
|
||||
# exit_code is negative (-signal) if the process has been terminated by
|
||||
# a signal. Returning negative exit code is not portable and so we return
|
||||
# 100 instead.
|
||||
if exit_code < 0:
|
||||
exit_code = 100
|
||||
|
||||
sys.exit(exit_code)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
59
Engine/lib/assimp/contrib/gtest/scripts/test/Makefile
Normal file
59
Engine/lib/assimp/contrib/gtest/scripts/test/Makefile
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
# A Makefile for fusing Google Test and building a sample test against it.
|
||||
#
|
||||
# SYNOPSIS:
|
||||
#
|
||||
# make [all] - makes everything.
|
||||
# make TARGET - makes the given target.
|
||||
# make check - makes everything and runs the built sample test.
|
||||
# make clean - removes all files generated by make.
|
||||
|
||||
# Points to the root of fused Google Test, relative to where this file is.
|
||||
FUSED_GTEST_DIR = output
|
||||
|
||||
# Paths to the fused gtest files.
|
||||
FUSED_GTEST_H = $(FUSED_GTEST_DIR)/gtest/gtest.h
|
||||
FUSED_GTEST_ALL_CC = $(FUSED_GTEST_DIR)/gtest/gtest-all.cc
|
||||
|
||||
# Where to find the sample test.
|
||||
SAMPLE_DIR = ../../samples
|
||||
|
||||
# Where to find gtest_main.cc.
|
||||
GTEST_MAIN_CC = ../../src/gtest_main.cc
|
||||
|
||||
# Flags passed to the preprocessor.
|
||||
# We have no idea here whether pthreads is available in the system, so
|
||||
# disable its use.
|
||||
CPPFLAGS += -I$(FUSED_GTEST_DIR) -DGTEST_HAS_PTHREAD=0
|
||||
|
||||
# Flags passed to the C++ compiler.
|
||||
CXXFLAGS += -g
|
||||
|
||||
all : sample1_unittest
|
||||
|
||||
check : all
|
||||
./sample1_unittest
|
||||
|
||||
clean :
|
||||
rm -rf $(FUSED_GTEST_DIR) sample1_unittest *.o
|
||||
|
||||
$(FUSED_GTEST_H) :
|
||||
../fuse_gtest_files.py $(FUSED_GTEST_DIR)
|
||||
|
||||
$(FUSED_GTEST_ALL_CC) :
|
||||
../fuse_gtest_files.py $(FUSED_GTEST_DIR)
|
||||
|
||||
gtest-all.o : $(FUSED_GTEST_H) $(FUSED_GTEST_ALL_CC)
|
||||
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(FUSED_GTEST_DIR)/gtest/gtest-all.cc
|
||||
|
||||
gtest_main.o : $(FUSED_GTEST_H) $(GTEST_MAIN_CC)
|
||||
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(GTEST_MAIN_CC)
|
||||
|
||||
sample1.o : $(SAMPLE_DIR)/sample1.cc $(SAMPLE_DIR)/sample1.h
|
||||
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(SAMPLE_DIR)/sample1.cc
|
||||
|
||||
sample1_unittest.o : $(SAMPLE_DIR)/sample1_unittest.cc \
|
||||
$(SAMPLE_DIR)/sample1.h $(FUSED_GTEST_H)
|
||||
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(SAMPLE_DIR)/sample1_unittest.cc
|
||||
|
||||
sample1_unittest : sample1.o sample1_unittest.o gtest-all.o gtest_main.o
|
||||
$(CXX) $(CPPFLAGS) $(CXXFLAGS) $^ -o $@
|
||||
1402
Engine/lib/assimp/contrib/gtest/scripts/upload.py
Normal file
1402
Engine/lib/assimp/contrib/gtest/scripts/upload.py
Normal file
File diff suppressed because it is too large
Load diff
78
Engine/lib/assimp/contrib/gtest/scripts/upload_gtest.py
Normal file
78
Engine/lib/assimp/contrib/gtest/scripts/upload_gtest.py
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
#!/usr/bin/env python
|
||||
#
|
||||
# Copyright 2009, Google Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are
|
||||
# met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above
|
||||
# copyright notice, this list of conditions and the following disclaimer
|
||||
# in the documentation and/or other materials provided with the
|
||||
# distribution.
|
||||
# * Neither the name of Google Inc. nor the names of its
|
||||
# contributors may be used to endorse or promote products derived from
|
||||
# this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
"""upload_gtest.py v0.1.0 -- uploads a Google Test patch for review.
|
||||
|
||||
This simple wrapper passes all command line flags and
|
||||
--cc=googletestframework@googlegroups.com to upload.py.
|
||||
|
||||
USAGE: upload_gtest.py [options for upload.py]
|
||||
"""
|
||||
|
||||
__author__ = 'wan@google.com (Zhanyong Wan)'
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
CC_FLAG = '--cc='
|
||||
GTEST_GROUP = 'googletestframework@googlegroups.com'
|
||||
|
||||
|
||||
def main():
|
||||
# Finds the path to upload.py, assuming it is in the same directory
|
||||
# as this file.
|
||||
my_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
upload_py_path = os.path.join(my_dir, 'upload.py')
|
||||
|
||||
# Adds Google Test discussion group to the cc line if it's not there
|
||||
# already.
|
||||
upload_py_argv = [upload_py_path]
|
||||
found_cc_flag = False
|
||||
for arg in sys.argv[1:]:
|
||||
if arg.startswith(CC_FLAG):
|
||||
found_cc_flag = True
|
||||
cc_line = arg[len(CC_FLAG):]
|
||||
cc_list = [addr for addr in cc_line.split(',') if addr]
|
||||
if GTEST_GROUP not in cc_list:
|
||||
cc_list.append(GTEST_GROUP)
|
||||
upload_py_argv.append(CC_FLAG + ','.join(cc_list))
|
||||
else:
|
||||
upload_py_argv.append(arg)
|
||||
|
||||
if not found_cc_flag:
|
||||
upload_py_argv.append(CC_FLAG + GTEST_GROUP)
|
||||
|
||||
# Invokes upload.py with the modified command line flags.
|
||||
os.execv(upload_py_path, upload_py_argv)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
@ -38,7 +38,7 @@
|
|||
#include "gtest/gtest.h"
|
||||
|
||||
// The following lines pull in the real gtest *.cc files.
|
||||
#include "src/gtest-assertion-result.cc"
|
||||
#include "src/gtest.cc"
|
||||
#include "src/gtest-death-test.cc"
|
||||
#include "src/gtest-filepath.cc"
|
||||
#include "src/gtest-matchers.cc"
|
||||
|
|
@ -46,4 +46,3 @@
|
|||
#include "src/gtest-printers.cc"
|
||||
#include "src/gtest-test-part.cc"
|
||||
#include "src/gtest-typed-test.cc"
|
||||
#include "src/gtest.cc"
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue