mirror of
https://github.com/BlackMATov/vmath.hpp.git
synced 2025-12-13 04:06:52 +07:00
fix singles generation
This commit is contained in:
@@ -23,10 +23,8 @@ PRAGMA_ONCE_MATCHER = re.compile(r'#\s*pragma\s+once')
|
||||
def CollectLicenseComment(headerPath):
|
||||
with open(headerPath, "r") as headerStream:
|
||||
headerContent = headerStream.read().strip()
|
||||
if result := re.match(C_COMMENT_MATCHER, headerContent):
|
||||
return result.group()
|
||||
else:
|
||||
return ""
|
||||
commentMatch = re.match(C_COMMENT_MATCHER, headerContent)
|
||||
return commentMatch.group() if commentMatch else ""
|
||||
|
||||
def CollectSystemIncludes(headerPath, parsedHeaders = set()):
|
||||
with open(headerPath, "r") as headerStream:
|
||||
@@ -41,11 +39,13 @@ def CollectSystemIncludes(headerPath, parsedHeaders = set()):
|
||||
headerLines = headerContent.split('\n')
|
||||
|
||||
for headerLine in headerLines:
|
||||
if result := USER_INCLUDE_MATCHER.findall(headerLine):
|
||||
internalHeaderPath = os.path.abspath(os.path.join(os.path.dirname(headerPath), result[0]))
|
||||
includeMatch = USER_INCLUDE_MATCHER.findall(headerLine)
|
||||
if includeMatch:
|
||||
internalHeaderPath = os.path.abspath(os.path.join(os.path.dirname(headerPath), includeMatch[0]))
|
||||
headerIncludes = headerIncludes.union(CollectSystemIncludes(internalHeaderPath, parsedHeaders))
|
||||
if result := SYSTEM_INCLUDE_MATCHER.findall(headerLine):
|
||||
headerIncludes.add(result[0])
|
||||
includeMatch = SYSTEM_INCLUDE_MATCHER.findall(headerLine)
|
||||
if includeMatch:
|
||||
headerIncludes.add(includeMatch[0])
|
||||
|
||||
return headerIncludes
|
||||
|
||||
@@ -71,15 +71,17 @@ def ParseHeader(headerPath, parsedHeaders = set()):
|
||||
shouldSkipNextEmptyLines = True
|
||||
continue
|
||||
|
||||
if result := USER_INCLUDE_MATCHER.findall(headerLine):
|
||||
internalHeaderPath = os.path.abspath(os.path.join(os.path.dirname(headerPath), result[0]))
|
||||
includeMatch = USER_INCLUDE_MATCHER.findall(headerLine)
|
||||
if includeMatch:
|
||||
internalHeaderPath = os.path.abspath(os.path.join(os.path.dirname(headerPath), includeMatch[0]))
|
||||
internalHeaderContent = ParseHeader(internalHeaderPath, parsedHeaders)
|
||||
|
||||
outputContent += internalHeaderContent
|
||||
shouldSkipNextEmptyLines = True
|
||||
continue
|
||||
|
||||
if result := SYSTEM_INCLUDE_MATCHER.findall(headerLine):
|
||||
includeMatch = SYSTEM_INCLUDE_MATCHER.findall(headerLine)
|
||||
if includeMatch:
|
||||
shouldSkipNextEmptyLines = True
|
||||
continue
|
||||
|
||||
|
||||
@@ -13,10 +13,6 @@ add_library(${PROJECT_NAME} INTERFACE)
|
||||
target_compile_features(${PROJECT_NAME} INTERFACE cxx_std_17)
|
||||
target_include_directories(${PROJECT_NAME} INTERFACE headers)
|
||||
|
||||
add_library(${PROJECT_NAME}.singles INTERFACE)
|
||||
target_compile_features(${PROJECT_NAME}.singles INTERFACE cxx_std_17)
|
||||
target_include_directories(${PROJECT_NAME}.singles INTERFACE singles)
|
||||
|
||||
#
|
||||
# BUILD_AS_STANDALONE
|
||||
#
|
||||
|
||||
@@ -1,17 +1,29 @@
|
||||
project(vmath.hpp.singles)
|
||||
|
||||
#
|
||||
# generate
|
||||
#
|
||||
|
||||
find_package(PythonInterp REQUIRED)
|
||||
|
||||
set(VMATH_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/..")
|
||||
set(VMATH_SINGLES_BUILD_SCRIPT "${VMATH_ROOT_DIR}/.ci/build_singles.py")
|
||||
set(VMATH_SINGLES_INPUT_HEADER "${VMATH_ROOT_DIR}/headers/vmath.hpp/vmath.hpp")
|
||||
set(VMATH_SINGLES_OUTPUT_HEADER "${VMATH_ROOT_DIR}/singles/vmath.hpp/vmath.hpp")
|
||||
set(VMATH_SINGLES_INPUT "${VMATH_ROOT_DIR}/headers/vmath.hpp/vmath.hpp")
|
||||
set(VMATH_SINGLES_OUTPUT "${VMATH_ROOT_DIR}/singles/headers/vmath.hpp/vmath.hpp")
|
||||
file(GLOB_RECURSE VMATH_SINGLES_DEPENDS "${VMATH_ROOT_DIR}/headers/*.hpp")
|
||||
|
||||
add_custom_command(OUTPUT ${VMATH_SINGLES_OUTPUT_HEADER}
|
||||
COMMAND "${PYTHON_EXECUTABLE}"
|
||||
"${VMATH_SINGLES_BUILD_SCRIPT}"
|
||||
"${VMATH_SINGLES_INPUT_HEADER}"
|
||||
"${VMATH_SINGLES_OUTPUT_HEADER}")
|
||||
add_custom_command(OUTPUT "${VMATH_SINGLES_OUTPUT}"
|
||||
COMMAND "${PYTHON_EXECUTABLE}" ".ci/build_singles.py" "${VMATH_SINGLES_INPUT}" "${VMATH_SINGLES_OUTPUT}"
|
||||
DEPENDS ${VMATH_SINGLES_DEPENDS}
|
||||
WORKING_DIRECTORY "${VMATH_ROOT_DIR}")
|
||||
|
||||
add_custom_target(vmath.hpp.singles.generate
|
||||
DEPENDS "${VMATH_SINGLES_OUTPUT_HEADER}")
|
||||
add_custom_target(${PROJECT_NAME}.generate
|
||||
DEPENDS "${VMATH_SINGLES_OUTPUT}")
|
||||
|
||||
#
|
||||
# library
|
||||
#
|
||||
|
||||
add_library(${PROJECT_NAME} INTERFACE)
|
||||
add_dependencies(${PROJECT_NAME} ${PROJECT_NAME}.generate)
|
||||
target_compile_features(${PROJECT_NAME} INTERFACE cxx_std_17)
|
||||
target_include_directories(${PROJECT_NAME} INTERFACE headers)
|
||||
|
||||
@@ -7,7 +7,6 @@ add_executable(${PROJECT_NAME} ${UNTESTS_SOURCES})
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE vmath.hpp)
|
||||
|
||||
add_executable(${PROJECT_NAME}.singles ${UNTESTS_SOURCES})
|
||||
add_dependencies(${PROJECT_NAME}.singles vmath.hpp.singles.generate)
|
||||
target_link_libraries(${PROJECT_NAME}.singles PRIVATE vmath.hpp.singles)
|
||||
|
||||
#
|
||||
|
||||
Reference in New Issue
Block a user