mirror of
https://github.com/hermitcore/libhermit.git
synced 2025-03-09 00:00:03 +01:00
cmake: add intermediate target hermit-bootstrap to build with bootstrap compiler
This commit is contained in:
parent
354234c874
commit
cec426a078
5 changed files with 46 additions and 12 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -10,3 +10,4 @@
|
|||
**/build/*
|
||||
.idea/*
|
||||
qemu-vlan0.pcap
|
||||
cmake/cmake-3.7.2-Linux-x86_64/*
|
||||
|
|
|
@ -58,21 +58,23 @@ list(APPEND KERNEL_OBJECTS
|
|||
$<TARGET_OBJECTS:${X86_KERNEL_C_TARGET}>)
|
||||
|
||||
# finally build libhermit.a
|
||||
add_library(hermit STATIC ${KERNEL_OBJECTS})
|
||||
add_library(hermit-bootstrap STATIC ${KERNEL_OBJECTS})
|
||||
set_target_properties(hermit-bootstrap PROPERTIES
|
||||
ARCHIVE_OUTPUT_NAME hermit)
|
||||
|
||||
# after compiling ASM sources, we need to post-process them. Adding this
|
||||
# dependency makes sure that this is done before hermit is linked
|
||||
add_dependencies(hermit ${X86_KERNEL_TARGET})
|
||||
add_dependencies(hermit-bootstrap ${X86_KERNEL_TARGET})
|
||||
|
||||
add_custom_command(
|
||||
TARGET
|
||||
hermit POST_BUILD
|
||||
hermit-bootstrap POST_BUILD
|
||||
# rename sections in final library
|
||||
COMMAND
|
||||
${CMAKE_OBJCOPY} --rename-section .bss=.kbss
|
||||
--rename-section .text=.ktext
|
||||
--rename-section .data=.kdata
|
||||
$<TARGET_FILE:hermit>
|
||||
$<TARGET_FILE:hermit-bootstrap>
|
||||
|
||||
# copy libhermit.a into local prefix directory so that all subsequent
|
||||
# targets can link against the freshly built version (as opposed to
|
||||
|
@ -81,7 +83,7 @@ add_custom_command(
|
|||
${CMAKE_COMMAND} -E make_directory ${LOCAL_PREFIX_ARCH_LIB_DIR}
|
||||
COMMAND
|
||||
${CMAKE_COMMAND} -E copy_if_different
|
||||
$<TARGET_FILE:hermit>
|
||||
$<TARGET_FILE:hermit-bootstrap>
|
||||
${LOCAL_PREFIX_ARCH_LIB_DIR}/
|
||||
|
||||
# and also copy headers into local prefix
|
||||
|
@ -96,11 +98,33 @@ add_custom_command(
|
|||
${CMAKE_BINARY_DIR}/include/hermit/*.asm
|
||||
${LOCAL_PREFIX_ARCH_INCLUDE_DIR}/hermit/)
|
||||
|
||||
|
||||
# deploy libhermit.a and headers for package creation
|
||||
install(TARGETS hermit
|
||||
DESTINATION ${TARGET_ARCH}/lib)
|
||||
install(TARGETS hermit-bootstrap
|
||||
DESTINATION ${TARGET_ARCH}/lib
|
||||
COMPONENT bootstrap)
|
||||
|
||||
install(DIRECTORY include/hermit
|
||||
DESTINATION ${TARGET_ARCH}/include/)
|
||||
DESTINATION ${TARGET_ARCH}/include/
|
||||
COMPONENT bootstrap
|
||||
FILES_MATCHING
|
||||
PATTERN *.h)
|
||||
|
||||
# provide custom target to only install libhermit without its runtimes which is
|
||||
# needed during the compilation of the cross toolchain
|
||||
add_custom_target(hermit-bootstrap-install
|
||||
DEPENDS
|
||||
hermit-bootstrap
|
||||
COMMAND
|
||||
${CMAKE_COMMAND}
|
||||
-DCMAKE_INSTALL_COMPONENT=bootstrap
|
||||
-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
|
||||
-P cmake_install.cmake)
|
||||
|
||||
# The target 'hermit' includes the HermitCore kernel and several runtimes.
|
||||
# Applications should depend on this target if they link against HermitCore.
|
||||
add_custom_target(hermit
|
||||
DEPENDS hermit-bootstrap)
|
||||
|
||||
|
||||
### External projects
|
||||
|
|
|
@ -4,8 +4,6 @@ include_guard()
|
|||
set(CMAKE_C_COMPILER_WORKS 1 CACHE INTERNAL "")
|
||||
set(CMAKE_CXX_COMPILER_WORKS 1 CACHE INTERNAL "")
|
||||
|
||||
# unset unneeded compilers
|
||||
# bootstrap toolchain cannot compile neither Go nor Fortran
|
||||
unset(CMAKE_Go_COMPILER)
|
||||
unset(CMAKE_Fortran_COMPILER)
|
||||
|
||||
set(BOOTSTRAP true)
|
||||
|
|
|
@ -27,7 +27,11 @@ endif()
|
|||
|
||||
# use default toolchain if not specified by user
|
||||
if(NOT CMAKE_TOOLCHAIN_FILE)
|
||||
set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_LIST_DIR}/HermitCore-Toolchain-${HERMIT_ARCH}.cmake)
|
||||
if(BOOTSTRAP)
|
||||
# use bootstrap toolchain if requested
|
||||
set(_BOOTSTRAP_ARCH_SUFFIX -bootstrap)
|
||||
endif()
|
||||
set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_LIST_DIR}/HermitCore-Toolchain-${HERMIT_ARCH}${_BOOTSTRAP_ARCH_SUFFIX}.cmake)
|
||||
endif()
|
||||
|
||||
# NASM detection will change binary format depending on host system, but
|
||||
|
|
|
@ -6,3 +6,10 @@ configure_file(config.asm.in config.asm)
|
|||
# Show include files in IDE
|
||||
file(GLOB_RECURSE HERMIT_INCLUDES "*")
|
||||
add_custom_target(hermit_includes_ide SOURCES ${HERMIT_INCLUDES})
|
||||
|
||||
# install generated config files when building libhermit for bootstrapping
|
||||
install(FILES
|
||||
${GENERATED_CONFIG_DIR}/hermit/config.h
|
||||
${GENERATED_CONFIG_DIR}/hermit/config.asm
|
||||
DESTINATION ${TARGET_ARCH}/include/hermit/
|
||||
COMPONENT bootstrap)
|
||||
|
|
Loading…
Add table
Reference in a new issue