mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 07:30:19 +00:00
Meta: Make embed_as_string_view.py
usable by CMake builds :^)
This commit is contained in:
parent
4ead33d8fc
commit
af4642c826
Notes:
sideshowbarker
2024-07-16 23:05:02 +09:00
Author: https://github.com/AtkinsSJ Commit: https://github.com/SerenityOS/serenity/commit/af4642c826 Pull-request: https://github.com/SerenityOS/serenity/pull/20732 Reviewed-by: https://github.com/ADKaster ✅
3 changed files with 21 additions and 1 deletions
|
@ -2,6 +2,26 @@
|
|||
# Functions for generating sources using host tools
|
||||
#
|
||||
|
||||
function(embed_as_string_view name source_file output source_variable_name)
|
||||
cmake_parse_arguments(PARSE_ARGV 4 EMBED_STRING_VIEW "" "NAMESPACE" "")
|
||||
set(namespace_arg "")
|
||||
if (EMBED_STRING_VIEW_NAMESPACE)
|
||||
set(namespace_arg "-s ${EMBED_STRING_VIEW_NAMESPACE}")
|
||||
endif()
|
||||
add_custom_command(
|
||||
OUTPUT "${output}"
|
||||
COMMAND "python3" "${SerenityOS_SOURCE_DIR}/Meta/embed_as_string_view.py" "${source_file}" -o "${output}.tmp" -n "${source_variable_name}" ${namespace_arg}
|
||||
COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${output}.tmp" "${output}"
|
||||
COMMAND "${CMAKE_COMMAND}" -E remove "${output}.tmp"
|
||||
VERBATIM
|
||||
DEPENDS "${SerenityOS_SOURCE_DIR}/Meta/embed_as_string_view.py"
|
||||
MAIN_DEPENDENCY "${source_file}"
|
||||
)
|
||||
|
||||
add_custom_target("generate_${name}" DEPENDS "${output}")
|
||||
add_dependencies(all_generated "generate_${name}")
|
||||
endfunction()
|
||||
|
||||
function(stringify_gml source output string_name)
|
||||
set(source ${CMAKE_CURRENT_SOURCE_DIR}/${source})
|
||||
add_custom_command(
|
||||
|
|
|
@ -33,7 +33,7 @@ template("embed_as_string_view") {
|
|||
"must set 'variable_name' in $target_name")
|
||||
|
||||
action(target_name) {
|
||||
script = "//Meta/gn/build/embed_as_string_view.py"
|
||||
script = "//Meta/embed_as_string_view.py"
|
||||
|
||||
sources = [ invoker.input ]
|
||||
outputs = [ invoker.output ]
|
||||
|
|
Loading…
Reference in a new issue