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):
|
def CollectLicenseComment(headerPath):
|
||||||
with open(headerPath, "r") as headerStream:
|
with open(headerPath, "r") as headerStream:
|
||||||
headerContent = headerStream.read().strip()
|
headerContent = headerStream.read().strip()
|
||||||
if result := re.match(C_COMMENT_MATCHER, headerContent):
|
commentMatch = re.match(C_COMMENT_MATCHER, headerContent)
|
||||||
return result.group()
|
return commentMatch.group() if commentMatch else ""
|
||||||
else:
|
|
||||||
return ""
|
|
||||||
|
|
||||||
def CollectSystemIncludes(headerPath, parsedHeaders = set()):
|
def CollectSystemIncludes(headerPath, parsedHeaders = set()):
|
||||||
with open(headerPath, "r") as headerStream:
|
with open(headerPath, "r") as headerStream:
|
||||||
@@ -41,11 +39,13 @@ def CollectSystemIncludes(headerPath, parsedHeaders = set()):
|
|||||||
headerLines = headerContent.split('\n')
|
headerLines = headerContent.split('\n')
|
||||||
|
|
||||||
for headerLine in headerLines:
|
for headerLine in headerLines:
|
||||||
if result := USER_INCLUDE_MATCHER.findall(headerLine):
|
includeMatch = USER_INCLUDE_MATCHER.findall(headerLine)
|
||||||
internalHeaderPath = os.path.abspath(os.path.join(os.path.dirname(headerPath), result[0]))
|
if includeMatch:
|
||||||
|
internalHeaderPath = os.path.abspath(os.path.join(os.path.dirname(headerPath), includeMatch[0]))
|
||||||
headerIncludes = headerIncludes.union(CollectSystemIncludes(internalHeaderPath, parsedHeaders))
|
headerIncludes = headerIncludes.union(CollectSystemIncludes(internalHeaderPath, parsedHeaders))
|
||||||
if result := SYSTEM_INCLUDE_MATCHER.findall(headerLine):
|
includeMatch = SYSTEM_INCLUDE_MATCHER.findall(headerLine)
|
||||||
headerIncludes.add(result[0])
|
if includeMatch:
|
||||||
|
headerIncludes.add(includeMatch[0])
|
||||||
|
|
||||||
return headerIncludes
|
return headerIncludes
|
||||||
|
|
||||||
@@ -71,15 +71,17 @@ def ParseHeader(headerPath, parsedHeaders = set()):
|
|||||||
shouldSkipNextEmptyLines = True
|
shouldSkipNextEmptyLines = True
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if result := USER_INCLUDE_MATCHER.findall(headerLine):
|
includeMatch = USER_INCLUDE_MATCHER.findall(headerLine)
|
||||||
internalHeaderPath = os.path.abspath(os.path.join(os.path.dirname(headerPath), result[0]))
|
if includeMatch:
|
||||||
|
internalHeaderPath = os.path.abspath(os.path.join(os.path.dirname(headerPath), includeMatch[0]))
|
||||||
internalHeaderContent = ParseHeader(internalHeaderPath, parsedHeaders)
|
internalHeaderContent = ParseHeader(internalHeaderPath, parsedHeaders)
|
||||||
|
|
||||||
outputContent += internalHeaderContent
|
outputContent += internalHeaderContent
|
||||||
shouldSkipNextEmptyLines = True
|
shouldSkipNextEmptyLines = True
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if result := SYSTEM_INCLUDE_MATCHER.findall(headerLine):
|
includeMatch = SYSTEM_INCLUDE_MATCHER.findall(headerLine)
|
||||||
|
if includeMatch:
|
||||||
shouldSkipNextEmptyLines = True
|
shouldSkipNextEmptyLines = True
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
|||||||
@@ -13,10 +13,6 @@ add_library(${PROJECT_NAME} INTERFACE)
|
|||||||
target_compile_features(${PROJECT_NAME} INTERFACE cxx_std_17)
|
target_compile_features(${PROJECT_NAME} INTERFACE cxx_std_17)
|
||||||
target_include_directories(${PROJECT_NAME} INTERFACE headers)
|
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
|
# BUILD_AS_STANDALONE
|
||||||
#
|
#
|
||||||
|
|||||||
@@ -1,17 +1,29 @@
|
|||||||
project(vmath.hpp.singles)
|
project(vmath.hpp.singles)
|
||||||
|
|
||||||
|
#
|
||||||
|
# generate
|
||||||
|
#
|
||||||
|
|
||||||
find_package(PythonInterp REQUIRED)
|
find_package(PythonInterp REQUIRED)
|
||||||
|
|
||||||
set(VMATH_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/..")
|
set(VMATH_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/..")
|
||||||
set(VMATH_SINGLES_BUILD_SCRIPT "${VMATH_ROOT_DIR}/.ci/build_singles.py")
|
set(VMATH_SINGLES_INPUT "${VMATH_ROOT_DIR}/headers/vmath.hpp/vmath.hpp")
|
||||||
set(VMATH_SINGLES_INPUT_HEADER "${VMATH_ROOT_DIR}/headers/vmath.hpp/vmath.hpp")
|
set(VMATH_SINGLES_OUTPUT "${VMATH_ROOT_DIR}/singles/headers/vmath.hpp/vmath.hpp")
|
||||||
set(VMATH_SINGLES_OUTPUT_HEADER "${VMATH_ROOT_DIR}/singles/vmath.hpp/vmath.hpp")
|
file(GLOB_RECURSE VMATH_SINGLES_DEPENDS "${VMATH_ROOT_DIR}/headers/*.hpp")
|
||||||
|
|
||||||
add_custom_command(OUTPUT ${VMATH_SINGLES_OUTPUT_HEADER}
|
add_custom_command(OUTPUT "${VMATH_SINGLES_OUTPUT}"
|
||||||
COMMAND "${PYTHON_EXECUTABLE}"
|
COMMAND "${PYTHON_EXECUTABLE}" ".ci/build_singles.py" "${VMATH_SINGLES_INPUT}" "${VMATH_SINGLES_OUTPUT}"
|
||||||
"${VMATH_SINGLES_BUILD_SCRIPT}"
|
DEPENDS ${VMATH_SINGLES_DEPENDS}
|
||||||
"${VMATH_SINGLES_INPUT_HEADER}"
|
WORKING_DIRECTORY "${VMATH_ROOT_DIR}")
|
||||||
"${VMATH_SINGLES_OUTPUT_HEADER}")
|
|
||||||
|
|
||||||
add_custom_target(vmath.hpp.singles.generate
|
add_custom_target(${PROJECT_NAME}.generate
|
||||||
DEPENDS "${VMATH_SINGLES_OUTPUT_HEADER}")
|
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)
|
target_link_libraries(${PROJECT_NAME} PRIVATE vmath.hpp)
|
||||||
|
|
||||||
add_executable(${PROJECT_NAME}.singles ${UNTESTS_SOURCES})
|
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)
|
target_link_libraries(${PROJECT_NAME}.singles PRIVATE vmath.hpp.singles)
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|||||||
Reference in New Issue
Block a user