Switched to global Bundles.cmake

This commit is contained in:
Max Wash
2020-08-23 19:39:19 +01:00
parent cff3723792
commit 9d384d164c
2 changed files with 9 additions and 148 deletions

View File

@@ -13,7 +13,6 @@ macro(subdirlist result curdir)
endmacro()
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/platform.cmake)
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/Bundles.cmake)
platform_config(${PHOTON_TARGET})
message(STATUS "Target: ${machine}-${platform}")
@@ -79,16 +78,17 @@ add_framework(Photon STATIC
SOURCES ${photon_libc_sources} ${photon_libc_headers}
HEADERS ${CMAKE_CURRENT_BINARY_DIR}/sysroot/usr/include/*)
framework_compile_options(Photon -ffreestanding -nostdlib)
framework_link_libraries(Photon ${photon_platform_libs})
framework_link_frameworks(Photon ${photon_platform_frameworks})
bundle_compile_options(Photon PRIVATE -ffreestanding -nostdlib)
bundle_link_libraries(Photon ${photon_platform_libs})
bundle_link_frameworks(Photon ${photon_platform_frameworks})
framework_include_directories(Photon ${CMAKE_CURRENT_SOURCE_DIR}/photon/libc/include
bundle_include_directories(Photon PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/photon/libc/include
${CMAKE_CURRENT_SOURCE_DIR}/photon/libc/sys/${platform}/
${CMAKE_CURRENT_BINARY_DIR}/sysroot/usr/include)
foreach (platform_include_dir ${photon_platform_extra_include_dirs})
framework_include_directories(Photon
bundle_include_directories(Photon
${CMAKE_CURRENT_SOURCE_DIR}/photon/libc/sys/${platform}/${platform_include_dir})
endforeach (platform_include_dir)
@@ -99,7 +99,7 @@ add_custom_target(local-root
${CMAKE_CURRENT_BINARY_DIR}
${platform} ${machine})
framework_add_dependencies(Photon local-root crt)
bundle_add_dependencies(Photon local-root crt)
add_custom_command(TARGET Photon POST_BUILD
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/scripts/add-framework-crt.sh
@@ -107,12 +107,12 @@ add_custom_command(TARGET Photon POST_BUILD
${CMAKE_CURRENT_BINARY_DIR})
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
framework_link_libraries(Photon gcc)
bundle_link_libraries(Photon gcc)
endif ()
if (TARGET early-sysroot)
# We are being built as part of asbestOS, make sure the sysroot is there.
framework_add_dependencies(Photon early-sysroot)
bundle_add_dependencies(Photon early-sysroot)
endif ()
if (PHOTON_TESTS EQUAL 1)

View File

@@ -1,139 +0,0 @@
find_program(BUNDLE_PROGRAM "bundle")
if (BUNDLE_PROGRAM STREQUAL BUNDLE_PROGRAM-NOTFOUND)
message(WARNING "Couldn't find Bundle generator. "
"Please install bundle from https://gitalb.com/doorstuck/magenta/bundle.git")
endif ()
function (add_framework name)
set(options STATIC SHARED)
set(one_value_args BUNDLE_ID)
set(multi_value_args HEADER_DIRS HEADERS SOURCES)
cmake_parse_arguments(ARG "${options}" "${one_value_args}" "${multi_value_args}" ${ARGN})
if (ARG_HEADER_DIRS STREQUAL "")
message(FATAL_ERROR "add_framework: No header directories specified for ${name}")
endif ()
if (ARG_SOURCES STREQUAL "")
message(FATAL_ERROR "add_framework: No source files specified for ${name}")
endif ()
if (ARG_BUNDLE_ID STREQUAL "")
message(FATAL_ERROR "add_framework: No bundle ID specified for ${name}")
endif ()
string(TOLOWER ${name} lib_name)
if (NOT ARG_STATIC AND NOT ARG_SHARED)
message(FATAL_ERROR "add_framework: Neither STATIC nor SHARED specified for ${name}")
endif ()
add_custom_target(${name} ALL)
if (ARG_STATIC)
add_library(${lib_name}_s STATIC ${ARG_SOURCES})
add_dependencies(${name} ${lib_name}_s)
endif ()
if (ARG_SHARED)
add_library(${lib_name} SHARED ${ARG_SOURCES})
add_dependencies(${name} ${lib_name})
endif ()
set(header_dirs_arg "")
foreach (header_dir ${ARG_HEADER_DIRS})
set(header_dirs_arg ${header_dirs_arg} --header-dir \"${header_dir}\")
endforeach (header_dir)
set(headers_arg "")
foreach (header ${ARG_HEADERS})
set(headers_arg ${headers_arg} --header \"${header}\")
endforeach (header)
set(binary_args "")
if (ARG_STATIC)
set(binary_args ${binary_args} --static-binary \"${CMAKE_CURRENT_BINARY_DIR}/lib${lib_name}_s.a\")
endif ()
if (ARG_SHARED)
set(binary_args ${binary_args} --shared-binary \"${CMAKE_CURRENT_BINARY_DIR}/lib${lib_name}.so\")
endif ()
string(ASCII 27 esc)
string(ASCII 10 lf)
string(ASCII 13 cr)
add_custom_command(TARGET ${name}
POST_BUILD
COMMENT "[ -- ] Building framework bundle ${name}.framework"
COMMAND rm -rf ${name}.framework
COMMAND ${BUNDLE_PROGRAM} create-framework
-o ${name}.framework
-i ${ARG_BUNDLE_ID}
${headers_arg}
${header_dirs_arg}
${binary_args}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
endfunction (add_framework)
function (framework_compile_options name)
string(TOLOWER ${name} lib_name)
if (TARGET ${lib_name})
target_compile_options(${lib_name} PRIVATE ${ARGN})
endif ()
if (TARGET ${lib_name}_s)
target_compile_options(${lib_name}_s PRIVATE ${ARGN})
endif ()
endfunction (framework_compile_options)
function (framework_link_libraries name)
string(TOLOWER ${name} lib_name)
if (TARGET ${lib_name})
target_link_libraries(${lib_name} ${ARGN})
endif ()
if (TARGET ${lib_name}_s)
target_link_libraries(${lib_name}_s ${ARGN})
endif ()
endfunction (framework_link_libraries)
function (framework_include_directories name)
string(TOLOWER ${name} lib_name)
if (TARGET ${lib_name})
target_include_directories(${lib_name} PRIVATE ${ARGN})
endif ()
if (TARGET ${lib_name}_s)
target_include_directories(${lib_name}_s PRIVATE ${ARGN})
endif ()
endfunction (framework_include_directories)
function (framework_link_frameworks name)
string(TOLOWER ${name} lib_name)
foreach (framework ${ARGN})
if (TARGET ${lib_name})
target_compile_options(${lib_name} PRIVATE -framework ${framework})
endif ()
if (TARGET ${lib_name}_s)
target_compile_options(${lib_name}_s PRIVATE -framework ${framework})
endif ()
endforeach (framework)
endfunction (framework_link_frameworks)
function (framework_add_dependencies name)
string(TOLOWER ${name} lib_name)
if (TARGET ${lib_name})
add_dependencies(${lib_name} ${ARGN})
endif ()
if (TARGET ${lib_name}_s)
add_dependencies(${lib_name}_s ${ARGN})
endif ()
endfunction (framework_add_dependencies)