[build] use CMake to generate Xcode schemes

This commit is contained in:
Konstantin Käfer
2017-07-04 14:19:25 +02:00
parent adbce36fe6
commit fc48ca1801
17 changed files with 237 additions and 129 deletions

View File

@@ -25,3 +25,10 @@ target_add_mason_package(mbgl-benchmark PRIVATE vector-tile)
mbgl_platform_benchmark()
create_source_groups(mbgl-benchmark)
xcode_create_scheme(
TARGET mbgl-benchmark
OPTIONAL_ARGS
"--benchmark_filter=Category.*"
"--benchmark_repetitions=1"
)

View File

@@ -32,3 +32,5 @@ target_add_mason_package(mbgl-core PRIVATE vector-tile)
mbgl_platform_core()
create_source_groups(mbgl-core)
xcode_create_scheme(TARGET mbgl-core)

102
cmake/executable.xcscheme Normal file
View File

@@ -0,0 +1,102 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0830"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "${XCSCHEME_BLUEPRINT_ID}"
BuildableName = "${XCSCHEME_BUILDABLE_NAME}"
BlueprintName = "${XCSCHEME_BLUEPRINT_NAME}"
ReferencedContainer = "container:${XCSCHEME_CONTAINER}">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "${XCSCHEME_BLUEPRINT_ID}"
BuildableName = "${XCSCHEME_BUILDABLE_NAME}"
BlueprintName = "${XCSCHEME_BLUEPRINT_NAME}"
ReferencedContainer = "container:${XCSCHEME_CONTAINER}">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "YES"
customWorkingDirectory = "${XCSCHEME_WORKING_DIRECTORY}"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "${XCSCHEME_BLUEPRINT_ID}"
BuildableName = "${XCSCHEME_BUILDABLE_NAME}"
BlueprintName = "${XCSCHEME_BLUEPRINT_NAME}"
ReferencedContainer = "container:${XCSCHEME_CONTAINER}">
</BuildableReference>
</BuildableProductRunnable>
<CommandLineArguments>${XCSCHEME_COMMAND_LINE_ARGS}
</CommandLineArguments>
<EnvironmentVariables>
<EnvironmentVariable
key = "MAPBOX_ACCESS_TOKEN"
value = "$ENV{MAPBOX_ACCESS_TOKEN}"
isEnabled = "YES">
</EnvironmentVariable>
</EnvironmentVariables>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "YES"
customWorkingDirectory = "${XCSCHEME_WORKING_DIRECTORY}"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "${XCSCHEME_BLUEPRINT_ID}"
BuildableName = "${XCSCHEME_BUILDABLE_NAME}"
BlueprintName = "${XCSCHEME_BLUEPRINT_NAME}"
ReferencedContainer = "container:${XCSCHEME_CONTAINER}">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

View File

@@ -43,3 +43,16 @@ target_add_mason_package(mbgl-glfw PRIVATE variant)
mbgl_platform_glfw()
create_source_groups(mbgl-glfw)
xcode_create_scheme(
TARGET mbgl-glfw
OPTIONAL_ARGS
"--style=file.json"
"--lon=0"
"--lat=0"
"--zoom=1"
"--bearing=0"
"--pitch=0"
"--fullscreen"
"--benchmark"
)

80
cmake/library.xcscheme Normal file
View File

@@ -0,0 +1,80 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0830"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "${XCSCHEME_BLUEPRINT_ID}"
BuildableName = "${XCSCHEME_BUILDABLE_NAME}"
BlueprintName = "${XCSCHEME_BLUEPRINT_NAME}"
ReferencedContainer = "container:${XCSCHEME_CONTAINER}">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "${XCSCHEME_BLUEPRINT_ID}"
BuildableName = "${XCSCHEME_BUILDABLE_NAME}"
BlueprintName = "${XCSCHEME_BLUEPRINT_NAME}"
ReferencedContainer = "container:${XCSCHEME_CONTAINER}">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "${XCSCHEME_BLUEPRINT_ID}"
BuildableName = "${XCSCHEME_BUILDABLE_NAME}"
BlueprintName = "${XCSCHEME_BLUEPRINT_NAME}"
ReferencedContainer = "container:${XCSCHEME_CONTAINER}">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

View File

@@ -17,3 +17,5 @@ target_include_directories(mbgl-loop-darwin
)
create_source_groups(mbgl-loop-darwin)
xcode_create_scheme(TARGET mbgl-loop-darwin)

View File

@@ -19,3 +19,5 @@ target_link_libraries(mbgl-loop-uv
)
create_source_groups(mbgl-loop-uv)
xcode_create_scheme(TARGET mbgl-loop-uv)

View File

@@ -53,3 +53,37 @@ add_custom_command(
mbgl_platform_node()
create_source_groups(mbgl-node)
xcode_create_scheme(
TARGET mbgl-node
)
xcode_create_scheme(
TARGET mbgl-node
TYPE node
NAME "node tests"
ARGS
"`npm bin tape`/tape platform/node/test/js/**/*.test.js"
)
xcode_create_scheme(
TARGET mbgl-node
TYPE node
NAME "node render tests"
ARGS
"platform/node/test/render.test.js"
OPTIONAL_ARGS
"group"
"test"
)
xcode_create_scheme(
TARGET mbgl-node
TYPE node
NAME "node query tests"
ARGS
"platform/node/test/query.test.js"
OPTIONAL_ARGS
"group"
"test"
)

95
cmake/node.xcscheme Normal file
View File

@@ -0,0 +1,95 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0810"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "${XCSCHEME_BLUEPRINT_ID}"
BuildableName = "${XCSCHEME_BUILDABLE_NAME}"
BlueprintName = "${XCSCHEME_BLUEPRINT_NAME}"
ReferencedContainer = "container:${XCSCHEME_CONTAINER}">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "YES"
customWorkingDirectory = "${XCSCHEME_WORKING_DIRECTORY}"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<PathRunnable
runnableDebuggingMode = "0"
FilePath = "${XCSCHEME_NODE_EXECUTABLE}">
</PathRunnable>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "${XCSCHEME_BLUEPRINT_ID}"
BuildableName = "${XCSCHEME_BUILDABLE_NAME}"
BlueprintName = "${XCSCHEME_BLUEPRINT_NAME}"
ReferencedContainer = "container:${XCSCHEME_CONTAINER}">
</BuildableReference>
</MacroExpansion>
<CommandLineArguments>${XCSCHEME_COMMAND_LINE_ARGS}
</CommandLineArguments>
<EnvironmentVariables>
<EnvironmentVariable
key = "PATH"
value = "${XCSCHEME_NODE_PATH}:$PATH"
isEnabled = "YES">
</EnvironmentVariable>
</EnvironmentVariables>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "YES"
customWorkingDirectory = "${XCSCHEME_WORKING_DIRECTORY}"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "${XCSCHEME_BLUEPRINT_ID}"
BuildableName = "${XCSCHEME_BUILDABLE_NAME}"
BlueprintName = "${XCSCHEME_BLUEPRINT_NAME}"
ReferencedContainer = "container:${XCSCHEME_CONTAINER}">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

View File

@@ -25,3 +25,18 @@ target_add_mason_package(mbgl-offline PRIVATE boost_libprogram_options)
mbgl_platform_offline()
create_source_groups(mbgl-offline)
xcode_create_scheme(
TARGET mbgl-offline
OPTIONAL_ARGS
"--style=file.json"
"--north=37.2"
"--west=-122.8"
"--south=38.1"
"--east=-121.7"
"--minZoom=0.0"
"--maxZoom=15.0"
"--pixelRatio=1.0"
"--token="
"--output=offline.db"
)

View File

@@ -20,3 +20,22 @@ target_add_mason_package(mbgl-render PRIVATE boost_libprogram_options)
mbgl_platform_render()
create_source_groups(mbgl-render)
xcode_create_scheme(
TARGET mbgl-render
OPTIONAL_ARGS
"--style=file.json"
"--lon=0"
"--lat=0"
"--zoom=0"
"--bearing=0"
"--pitch=0"
"--width=512"
"--height=512"
"--ratio=1"
"--token="
"--debug"
"--output=out.png"
"--cache=cache.sqlite"
"--assets=."
)

View File

@@ -40,3 +40,14 @@ target_add_mason_package(mbgl-test PRIVATE shelf-pack)
mbgl_platform_test()
create_source_groups(mbgl-test)
xcode_create_scheme(
TARGET mbgl-test
OPTIONAL_ARGS
"--gtest_filter=Category.*"
"--gtest_repeat=0"
"--gtest_shuffle=0"
"--gtest_break_on_failure=0"
"--gtest_throw_on_failure=0"
"--gtest_catch_exceptions=0"
)

75
cmake/xcode.cmake Normal file
View File

@@ -0,0 +1,75 @@
function(get_target_filename OUTPUT TARGET)
get_target_property(_TYPE "${TARGET}" TYPE)
get_target_property(_PREFIX "${TARGET}" PREFIX)
if(NOT _PREFIX AND NOT _PREFIX STREQUAL "")
set(_PREFIX "${CMAKE_${_TYPE}_PREFIX}")
endif()
get_target_property(_BASENAME "${TARGET}" OUTPUT_NAME)
if(NOT _BASENAME)
get_target_property(_BASENAME "${TARGET}" NAME)
endif()
get_target_property(_SUFFIX "${TARGET}" SUFFIX)
if(NOT _SUFFIX AND NOT _SUFFIX STREQUAL "")
set(_SUFFIX "${CMAKE_${_TYPE}_SUFFIX}")
endif()
set(${OUTPUT} "${_PREFIX}${_BASENAME}${_SUFFIX}" PARENT_SCOPE)
endfunction()
function(xcode_create_scheme)
if (NOT CMAKE_GENERATOR STREQUAL "Xcode")
return()
endif()
cmake_parse_arguments(XCSCHEME "" "TARGET;TYPE;NAME" "ARGS;OPTIONAL_ARGS" ${ARGN})
if(XCSCHEME_UNPARSED_ARGUMENTS)
message(FATAL_ERROR "xcode_create_scheme() called with unrecognized arguments: ${XCSCHEME_UNPARSED_ARGUMENTS}")
endif()
if(NOT XCSCHEME_TARGET)
message(FATAL_ERROR "xcode_create_scheme() called without required argument TARGET")
endif()
if(NOT XCSCHEME_TYPE)
get_target_property(_TYPE "${XCSCHEME_TARGET}" TYPE)
if (_TYPE MATCHES "^.*_LIBRARY$")
set(XCSCHEME_TYPE "library")
elseif(_TYPE STREQUAL "EXECUTABLE")
set(XCSCHEME_TYPE "executable")
else()
message(FATAL_ERROR "xcode_create_scheme() could not determine type of ${XCSCHEME_TARGET}")
endif()
endif()
if(NOT XCSCHEME_NAME)
set(XCSCHEME_NAME "${XCSCHEME_TARGET}")
endif()
set(XCODEPROJ_PATH "${PROJECT_BINARY_DIR}/${PROJECT_NAME}.xcodeproj")
set(XCSCHEME_OUTPUT_FILE "${XCODEPROJ_PATH}/xcshareddata/xcschemes/${XCSCHEME_NAME}.xcscheme")
# Prevent overwriting of the scheme file on every CMake rerun.
if (EXISTS "${XCSCHEME_OUTPUT_FILE}")
return()
endif()
file(RELATIVE_PATH XCSCHEME_CONTAINER "${CMAKE_SOURCE_DIR}" "${XCODEPROJ_PATH}")
string(RANDOM LENGTH 24 ALPHABET "0123456789ABCDEF" XCSCHEME_BLUEPRINT_ID)
get_target_filename(XCSCHEME_BUILDABLE_NAME "${XCSCHEME_TARGET}")
set(XCSCHEME_BLUEPRINT_NAME "${XCSCHEME_TARGET}")
set(XCSCHEME_WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}")
set(XCSCHEME_NODE_EXECUTABLE "${NodeJS_EXECUTABLE}")
get_filename_component(XCSCHEME_NODE_PATH "${NodeJS_EXECUTABLE}" DIRECTORY)
set(XCSCHEME_COMMAND_LINE_ARGS "")
foreach(_ARG IN LISTS XCSCHEME_ARGS)
set(XCSCHEME_COMMAND_LINE_ARGS "${XCSCHEME_COMMAND_LINE_ARGS}\n <CommandLineArgument\n argument = \"${_ARG}\"\n isEnabled = \"YES\">\n </CommandLineArgument>")
endforeach()
foreach(_ARG IN LISTS XCSCHEME_OPTIONAL_ARGS)
set(XCSCHEME_COMMAND_LINE_ARGS "${XCSCHEME_COMMAND_LINE_ARGS}\n <CommandLineArgument\n argument = \"${_ARG}\"\n isEnabled = \"NO\">\n </CommandLineArgument>")
endforeach()
configure_file(
"${CMAKE_SOURCE_DIR}/cmake/${XCSCHEME_TYPE}.xcscheme"
"${XCSCHEME_OUTPUT_FILE}")
endfunction()