Meta+LibGfx: Exclude Metal and Vulkan headers from Clang module map

These headers are platform-specific, and shouldn't need to be used by
Swift code anyway.
This commit is contained in:
Andrew Kaster 2024-11-14 16:05:08 -07:00 committed by Andrew Kaster
parent c998f22f9e
commit 9812fac2c3
Notes: github-actions[bot] 2024-11-15 17:56:43 +00:00
3 changed files with 16 additions and 8 deletions

View file

@ -70,6 +70,11 @@ set(SOURCES
SkiaBackendContext.cpp
)
set(SWIFT_EXCLUDE_HEADERS
MetalContext.h
VulkanContext.h
)
if (APPLE)
list(APPEND SOURCES MetalContext.mm)
endif()
@ -130,7 +135,7 @@ else()
endif()
if (ENABLE_SWIFT)
generate_clang_module_map(LibGfx GENERATED_FILES ${generated_headers})
generate_clang_module_map(LibGfx GENERATED_FILES ${generated_headers} EXCLUDE_FILES ${SWIFT_EXCLUDE_HEADERS})
target_sources(LibGfx PRIVATE
Color.swift
)

View file

@ -24,7 +24,7 @@ function(embed_as_string name source_file output source_variable_name)
endfunction()
function(generate_clang_module_map target_name)
cmake_parse_arguments(PARSE_ARGV 1 MODULE_MAP "" "DIRECTORY" "GENERATED_FILES")
cmake_parse_arguments(PARSE_ARGV 1 MODULE_MAP "" "DIRECTORY" "GENERATED_FILES;EXCLUDE_FILES")
if (NOT MODULE_MAP_DIRECTORY)
set(MODULE_MAP_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}")
endif()
@ -44,7 +44,8 @@ function(generate_clang_module_map target_name)
--module-name "${module_name}"
--module-map "${module_map_file}"
--vfs-map ${vfs_overlay_file}
${MODULE_MAP_GENERATED_FILES}
--exclude-files ${MODULE_MAP_EXCLUDE_FILES}
--generated-files ${MODULE_MAP_GENERATED_FILES}
VERBATIM
DEPENDS "${SerenityOS_SOURCE_DIR}/Meta/generate_clang_module_map.py"
)

View file

@ -26,10 +26,11 @@ def main():
epilog=__doc__,
formatter_class=argparse.RawDescriptionHelpFormatter)
parser.add_argument('directory', help='source directory to generate module map for')
parser.add_argument('generated_files', nargs='+', help='extra files to include in the module map')
parser.add_argument('-n', '--module-name', help='top-level module name')
parser.add_argument('-m', '--module-map', required=True, help='output module map file')
parser.add_argument('-v', '--vfs-map', required=True, help='output VFS map file')
parser.add_argument('--module-name', help='top-level module name')
parser.add_argument('--module-map', required=True, help='output module map file')
parser.add_argument('--vfs-map', required=True, help='output VFS map file')
parser.add_argument('--exclude-files', nargs='*', required=False, help='files to exclude in the module map')
parser.add_argument('--generated-files', nargs='*', help='extra files to include in the module map')
args = parser.parse_args()
root = pathlib.Path(args.directory)
@ -38,8 +39,9 @@ def main():
return 1
pathlib.Path(args.module_map).parent.mkdir(parents=True, exist_ok=True)
pathlib.Path(args.vfs_map).parent.mkdir(parents=True, exist_ok=True)
exclude_files = set(args.exclude_files) if args.exclude_files else set()
header_files = [f for f in root.rglob('**/*.h') if f.is_file()]
header_files = [f for f in root.rglob('**/*.h') if f.is_file() and f.name not in exclude_files]
module_name = args.module_name if args.module_name else root.name
module_map = f"module {module_name} {{\n"