mirror of
https://github.com/BlackMATov/vmath.hpp.git
synced 2025-12-13 04:06:52 +07:00
little fix build scripts
This commit is contained in:
@@ -1,9 +1,6 @@
|
||||
add_library(${PROJECT_NAME}.setup_targets INTERFACE)
|
||||
add_library(${PROJECT_NAME}::setup_targets ALIAS ${PROJECT_NAME}.setup_targets)
|
||||
|
||||
target_link_libraries(${PROJECT_NAME}.setup_targets INTERFACE
|
||||
vmath.hpp.vendors::doctest)
|
||||
|
||||
target_compile_options(${PROJECT_NAME}.setup_targets INTERFACE
|
||||
$<$<CXX_COMPILER_ID:MSVC>:
|
||||
/WX /W4>
|
||||
@@ -20,26 +17,13 @@ target_compile_options(${PROJECT_NAME}.setup_targets INTERFACE
|
||||
-Wno-unknown-warning-option
|
||||
>)
|
||||
|
||||
if(BUILD_WITH_COVERAGE)
|
||||
target_link_libraries(${PROJECT_NAME}.setup_targets INTERFACE
|
||||
vmath.hpp::enable_gcov)
|
||||
endif()
|
||||
|
||||
if(BUILD_WITH_SANITIZERS)
|
||||
target_link_libraries(${PROJECT_NAME}.setup_targets INTERFACE
|
||||
target_link_libraries(${PROJECT_NAME}.setup_targets INTERFACE
|
||||
$<$<BOOL:${BUILD_WITH_COVERAGE}>:
|
||||
vmath.hpp::enable_gcov>
|
||||
$<$<BOOL:${BUILD_WITH_SANITIZERS}>:
|
||||
vmath.hpp::enable_asan
|
||||
vmath.hpp::enable_ubsan)
|
||||
endif()
|
||||
|
||||
if(BUILD_WITH_NO_EXCEPTIONS)
|
||||
target_link_libraries(${PROJECT_NAME}.setup_targets INTERFACE
|
||||
vmath.hpp::disable_exceptions)
|
||||
|
||||
target_compile_definitions(${PROJECT_NAME}.setup_targets INTERFACE
|
||||
DOCTEST_CONFIG_NO_EXCEPTIONS_BUT_WITH_ALL_ASSERTS)
|
||||
endif()
|
||||
|
||||
if(BUILD_WITH_NO_RTTI)
|
||||
target_link_libraries(${PROJECT_NAME}.setup_targets INTERFACE
|
||||
vmath.hpp::disable_rtti)
|
||||
endif()
|
||||
vmath.hpp::enable_ubsan>
|
||||
$<$<BOOL:${BUILD_WITH_NO_EXCEPTIONS}>:
|
||||
vmath.hpp::disable_exceptions>
|
||||
$<$<BOOL:${BUILD_WITH_NO_RTTI}>:
|
||||
vmath.hpp::disable_rtti>)
|
||||
|
||||
@@ -13,10 +13,13 @@ set(VMATH_HPP_SINGLES_SCRIPT "${VMATH_HPP_ROOT_DIR}/develop/singles/scripts/buil
|
||||
file(GLOB_RECURSE VMATH_SINGLES_DEPENDS CONFIGURE_DEPENDS "${VMATH_HPP_ROOT_DIR}/headers/*.hpp")
|
||||
|
||||
add_custom_command(OUTPUT "${VMATH_HPP_SINGLES_OUTPUT}"
|
||||
COMMAND "${Python3_EXECUTABLE}" "${VMATH_HPP_SINGLES_SCRIPT}"
|
||||
"${VMATH_HPP_SINGLES_INPUT}" "${VMATH_HPP_SINGLES_OUTPUT}"
|
||||
DEPENDS ${VMATH_SINGLES_DEPENDS}
|
||||
WORKING_DIRECTORY "${VMATH_HPP_ROOT_DIR}")
|
||||
COMMAND
|
||||
"${Python3_EXECUTABLE}" "${VMATH_HPP_SINGLES_SCRIPT}"
|
||||
"${VMATH_HPP_SINGLES_INPUT}" "${VMATH_HPP_SINGLES_OUTPUT}"
|
||||
DEPENDS
|
||||
"${VMATH_HPP_SINGLES_SCRIPT}" ${VMATH_SINGLES_DEPENDS}
|
||||
WORKING_DIRECTORY
|
||||
"${VMATH_HPP_ROOT_DIR}")
|
||||
|
||||
add_custom_target(${PROJECT_NAME}.generate
|
||||
DEPENDS "${VMATH_HPP_SINGLES_OUTPUT}")
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
* Copyright (C) 2020-2023, by Matvey Cherevko (blackmatov@gmail.com)
|
||||
******************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cmath>
|
||||
#include <cstddef>
|
||||
#include <cstdlib>
|
||||
@@ -3661,12 +3663,12 @@ namespace vmath_hpp::detail
|
||||
}
|
||||
};
|
||||
|
||||
template < typename T, size_t Size >
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] std::size_t hash(const vec<T, Size>& v) noexcept {
|
||||
return fold_join(hash_combiner{}, std::size_t{}, v);
|
||||
}
|
||||
|
||||
template < typename T, size_t Size >
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] std::size_t hash(const mat<T, Size>& m) noexcept {
|
||||
return fold_join(hash_combiner{}, std::size_t{}, m);
|
||||
}
|
||||
|
||||
@@ -5,10 +5,6 @@ import os
|
||||
import re
|
||||
import sys
|
||||
|
||||
#
|
||||
#
|
||||
#
|
||||
|
||||
EMPTY_MATCHER = re.compile(r'^\s*$')
|
||||
C_COMMENT_MATCHER = re.compile(r'^/\*.*\*/', re.S)
|
||||
|
||||
@@ -19,9 +15,6 @@ USER_INCLUDE_MATCHER = re.compile(r'#\s*include\s*\"(.*)\"')
|
||||
SYSTEM_INCLUDE_MATCHER = re.compile(r'#\s*include\s*<(.*)>')
|
||||
PRAGMA_ONCE_MATCHER = re.compile(r'#\s*pragma\s+once')
|
||||
|
||||
#
|
||||
#
|
||||
#
|
||||
|
||||
def CollectLicenseComment(headerPath):
|
||||
with open(headerPath, "r") as headerStream:
|
||||
@@ -29,7 +22,8 @@ def CollectLicenseComment(headerPath):
|
||||
commentMatch = re.match(C_COMMENT_MATCHER, headerContent)
|
||||
return commentMatch.group() if commentMatch else ""
|
||||
|
||||
def CollectSystemIncludes(headerPath, parsedHeaders = set()):
|
||||
|
||||
def CollectSystemIncludes(headerPath, parsedHeaders=set()):
|
||||
with open(headerPath, "r") as headerStream:
|
||||
headerContent = headerStream.read().strip()
|
||||
|
||||
@@ -50,8 +44,10 @@ def CollectSystemIncludes(headerPath, parsedHeaders = set()):
|
||||
|
||||
includeMatch = USER_INCLUDE_MATCHER.findall(headerLine)
|
||||
if includeMatch and ifdefScopeLevel == 0:
|
||||
internalHeaderPath = os.path.abspath(os.path.join(os.path.dirname(headerPath), includeMatch[0]))
|
||||
headerIncludes = headerIncludes.union(CollectSystemIncludes(internalHeaderPath, parsedHeaders))
|
||||
internalHeaderPath = os.path.abspath(os.path.join(
|
||||
os.path.dirname(headerPath), includeMatch[0]))
|
||||
headerIncludes = headerIncludes.union(
|
||||
CollectSystemIncludes(internalHeaderPath, parsedHeaders))
|
||||
|
||||
includeMatch = SYSTEM_INCLUDE_MATCHER.findall(headerLine)
|
||||
if includeMatch and ifdefScopeLevel == 0:
|
||||
@@ -59,7 +55,8 @@ def CollectSystemIncludes(headerPath, parsedHeaders = set()):
|
||||
|
||||
return headerIncludes
|
||||
|
||||
def ParseHeader(headerPath, parsedHeaders = set()):
|
||||
|
||||
def ParseHeader(headerPath, parsedHeaders=set()):
|
||||
with open(headerPath, "r") as headerStream:
|
||||
headerContent = headerStream.read().strip()
|
||||
headerContent = re.sub(C_COMMENT_MATCHER, '', headerContent)
|
||||
@@ -89,8 +86,10 @@ def ParseHeader(headerPath, parsedHeaders = set()):
|
||||
|
||||
includeMatch = USER_INCLUDE_MATCHER.findall(headerLine)
|
||||
if includeMatch and ifdefScopeLevel == 0:
|
||||
internalHeaderPath = os.path.abspath(os.path.join(os.path.dirname(headerPath), includeMatch[0]))
|
||||
internalHeaderContent = ParseHeader(internalHeaderPath, parsedHeaders)
|
||||
internalHeaderPath = os.path.abspath(os.path.join(
|
||||
os.path.dirname(headerPath), includeMatch[0]))
|
||||
internalHeaderContent = ParseHeader(
|
||||
internalHeaderPath, parsedHeaders)
|
||||
|
||||
outputContent += internalHeaderContent
|
||||
shouldSkipNextEmptyLines = True
|
||||
@@ -106,9 +105,6 @@ def ParseHeader(headerPath, parsedHeaders = set()):
|
||||
|
||||
return "{}\n".format(outputContent)
|
||||
|
||||
#
|
||||
#
|
||||
#
|
||||
|
||||
inputHeaderPath = os.path.abspath(sys.argv[1])
|
||||
outputHeaderPath = os.path.abspath(sys.argv[2])
|
||||
@@ -118,13 +114,20 @@ os.makedirs(os.path.dirname(outputHeaderPath), exist_ok=True)
|
||||
with open(outputHeaderPath, "w") as outputHeaderStream:
|
||||
licenseComment = CollectLicenseComment(inputHeaderPath)
|
||||
systemIncludes = CollectSystemIncludes(inputHeaderPath)
|
||||
headersContent = ParseHeader(inputHeaderPath)
|
||||
|
||||
outputHeaderStream.write("{}\n".format(licenseComment))
|
||||
if licenseComment:
|
||||
outputHeaderStream.write("{}\n".format(licenseComment))
|
||||
outputHeaderStream.write("\n")
|
||||
|
||||
outputHeaderStream.write("#pragma once\n")
|
||||
outputHeaderStream.write("\n")
|
||||
|
||||
for systemInclude in sorted(systemIncludes):
|
||||
outputHeaderStream.write("#include <{}>\n".format(systemInclude))
|
||||
outputHeaderStream.write("\n")
|
||||
if systemIncludes:
|
||||
for systemInclude in sorted(systemIncludes):
|
||||
outputHeaderStream.write("#include <{}>\n".format(systemInclude))
|
||||
outputHeaderStream.write("\n")
|
||||
|
||||
outputHeaderStream.write(ParseHeader(inputHeaderPath).strip())
|
||||
outputHeaderStream.write("\n")
|
||||
if headersContent:
|
||||
outputHeaderStream.write(headersContent.strip())
|
||||
outputHeaderStream.write("\n")
|
||||
|
||||
@@ -8,11 +8,13 @@ add_executable(${PROJECT_NAME}.singles ${UNTESTS_SOURCES})
|
||||
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE
|
||||
vmath.hpp::vmath.hpp
|
||||
vmath.hpp::setup_targets)
|
||||
vmath.hpp::setup_targets
|
||||
vmath.hpp.vendors::doctest)
|
||||
|
||||
target_link_libraries(${PROJECT_NAME}.singles PRIVATE
|
||||
vmath.hpp::singles
|
||||
vmath.hpp::setup_targets)
|
||||
vmath.hpp::setup_targets
|
||||
vmath.hpp.vendors::doctest)
|
||||
|
||||
add_test(${PROJECT_NAME} ${PROJECT_NAME})
|
||||
add_test(${PROJECT_NAME} ${PROJECT_NAME}.singles)
|
||||
|
||||
@@ -68,12 +68,12 @@ namespace vmath_hpp::detail
|
||||
}
|
||||
};
|
||||
|
||||
template < typename T, size_t Size >
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] std::size_t hash(const vec<T, Size>& v) noexcept {
|
||||
return fold_join(hash_combiner{}, std::size_t{}, v);
|
||||
}
|
||||
|
||||
template < typename T, size_t Size >
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] std::size_t hash(const mat<T, Size>& m) noexcept {
|
||||
return fold_join(hash_combiner{}, std::size_t{}, m);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user