Fix Darwin style codegen Bazel requirement (#4391)
This commit is contained in:
@@ -108,6 +108,9 @@ include(${PROJECT_SOURCE_DIR}/vendor/icu.cmake)
|
|||||||
set(CMAKE_OBJC_FLAGS "-fobjc-arc")
|
set(CMAKE_OBJC_FLAGS "-fobjc-arc")
|
||||||
set(CMAKE_OBJCXX_FLAGS "-fobjc-arc")
|
set(CMAKE_OBJCXX_FLAGS "-fobjc-arc")
|
||||||
|
|
||||||
|
# The generated Objective-C style sources are shared by Darwin SDK targets.
|
||||||
|
# Keep the file lists here, but only SDK targets should call the generation
|
||||||
|
# helper so mbgl-core builds do not require Bazel.
|
||||||
set(MLN_GENERATED_DARWIN_CODE_DIR
|
set(MLN_GENERATED_DARWIN_CODE_DIR
|
||||||
${CMAKE_BINARY_DIR}/generated-darwin-code/src
|
${CMAKE_BINARY_DIR}/generated-darwin-code/src
|
||||||
)
|
)
|
||||||
@@ -154,23 +157,36 @@ set(MLN_GENERATED_DARWIN_STYLE_HEADERS
|
|||||||
${MLN_GENERATED_DARWIN_STYLE_PUBLIC_HEADERS}
|
${MLN_GENERATED_DARWIN_STYLE_PUBLIC_HEADERS}
|
||||||
)
|
)
|
||||||
|
|
||||||
find_program(BAZEL bazel REQUIRED)
|
function(mbgl_add_darwin_style_code_target)
|
||||||
|
if(TARGET mbgl-darwin-style-code)
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
|
||||||
add_custom_command(
|
# Do not require Bazel at configure time. CMake may define Darwin SDK
|
||||||
OUTPUT ${MLN_GENERATED_DARWIN_STYLE_SOURCE} ${MLN_GENERATED_DARWIN_STYLE_HEADERS}
|
# targets even when the requested build target is only mbgl-core.
|
||||||
COMMAND ${CMAKE_COMMAND} -E rm -Rf
|
find_program(BAZEL bazel)
|
||||||
"${PROJECT_SOURCE_DIR}/bazel-bin/platform/darwin/src"
|
if(BAZEL)
|
||||||
COMMAND ${BAZEL} build //platform/darwin:generated_code
|
set(_bazel_command ${BAZEL})
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy_directory
|
else()
|
||||||
"${PROJECT_SOURCE_DIR}/bazel-bin/platform/darwin/src"
|
set(_bazel_command bazel)
|
||||||
${MLN_GENERATED_DARWIN_CODE_DIR}
|
endif()
|
||||||
COMMENT "Generating Darwin style source and header files"
|
|
||||||
VERBATIM
|
|
||||||
)
|
|
||||||
|
|
||||||
add_custom_target(mbgl-darwin-style-code
|
add_custom_command(
|
||||||
DEPENDS ${MLN_GENERATED_DARWIN_STYLE_SOURCE} ${MLN_GENERATED_DARWIN_STYLE_HEADERS}
|
OUTPUT ${MLN_GENERATED_DARWIN_STYLE_SOURCE} ${MLN_GENERATED_DARWIN_STYLE_HEADERS}
|
||||||
)
|
COMMAND ${CMAKE_COMMAND} -E rm -Rf
|
||||||
|
"${PROJECT_SOURCE_DIR}/bazel-bin/platform/darwin/src"
|
||||||
|
COMMAND ${_bazel_command} build //platform/darwin:generated_code
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E copy_directory
|
||||||
|
"${PROJECT_SOURCE_DIR}/bazel-bin/platform/darwin/src"
|
||||||
|
${MLN_GENERATED_DARWIN_CODE_DIR}
|
||||||
|
COMMENT "Generating Darwin style source and header files"
|
||||||
|
VERBATIM
|
||||||
|
)
|
||||||
|
|
||||||
|
add_custom_target(mbgl-darwin-style-code
|
||||||
|
DEPENDS ${MLN_GENERATED_DARWIN_STYLE_SOURCE} ${MLN_GENERATED_DARWIN_STYLE_HEADERS}
|
||||||
|
)
|
||||||
|
endfunction()
|
||||||
|
|
||||||
# Custom layer examples use OpenGL ES / Metal APIs directly and are not
|
# Custom layer examples use OpenGL ES / Metal APIs directly and are not
|
||||||
# available for WebGPU builds.
|
# available for WebGPU builds.
|
||||||
|
|||||||
@@ -64,6 +64,8 @@ add_custom_target(create-framework-bundle
|
|||||||
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/Mapbox.bundle/Assets.car
|
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/Mapbox.bundle/Assets.car
|
||||||
)
|
)
|
||||||
|
|
||||||
|
mbgl_add_darwin_style_code_target()
|
||||||
|
|
||||||
add_library(
|
add_library(
|
||||||
ios-sdk-static
|
ios-sdk-static
|
||||||
STATIC ${IOS_SDK_SOURCE_FILES} ${MLN_GENERATED_DARWIN_STYLE_SOURCE}
|
STATIC ${IOS_SDK_SOURCE_FILES} ${MLN_GENERATED_DARWIN_STYLE_SOURCE}
|
||||||
|
|||||||
Reference in New Issue
Block a user