mirror of
https://github.com/reactos/reactos.git
synced 2024-12-26 17:14:41 +00:00
Rework host tools
Now configured at the same time as reactos and only one list of targets to maintain Correctly rebuilds when a tool changes (tested widl)
This commit is contained in:
parent
87a625bd6c
commit
ce531a28ec
7 changed files with 54 additions and 155 deletions
|
@ -31,10 +31,6 @@ set(CMAKE_COLOR_MAKEFILE OFF)
|
|||
set(CMAKE_POSITION_INDEPENDENT_CODE OFF)
|
||||
#set_property(GLOBAL PROPERTY RULE_MESSAGES OFF)
|
||||
|
||||
if(NOT DEFINED NEW_STYLE_BUILD)
|
||||
set(NEW_STYLE_BUILD TRUE)
|
||||
endif()
|
||||
|
||||
if(NOT ARCH)
|
||||
set(ARCH i386)
|
||||
endif()
|
||||
|
@ -75,11 +71,7 @@ endif()
|
|||
# include(sdk/cmake/bison-flex.cmake)
|
||||
|
||||
if(NOT CMAKE_CROSSCOMPILING)
|
||||
|
||||
if(NEW_STYLE_BUILD)
|
||||
set(TOOLS_FOLDER ${CMAKE_CURRENT_BINARY_DIR})
|
||||
endif()
|
||||
|
||||
set(TOOLS_FOLDER ${CMAKE_CURRENT_BINARY_DIR})
|
||||
add_definitions(-DTARGET_${ARCH})
|
||||
|
||||
if(MSVC)
|
||||
|
@ -105,22 +97,22 @@ if(NOT CMAKE_CROSSCOMPILING)
|
|||
add_subdirectory(sdk/tools)
|
||||
add_subdirectory(sdk/lib)
|
||||
|
||||
if(NOT NEW_STYLE_BUILD)
|
||||
if(NOT MSVC)
|
||||
export(TARGETS bin2c widl gendib cabman fatten hpp isohybrid mkhive mkisofs obj2bin spec2def geninc rsym mkshelllink utf16le xml2sdb FILE ${CMAKE_BINARY_DIR}/ImportExecutables.cmake NAMESPACE native- )
|
||||
else()
|
||||
export(TARGETS bin2c widl gendib cabman fatten hpp isohybrid mkhive mkisofs obj2bin spec2def geninc mkshelllink utf16le xml2sdb FILE ${CMAKE_BINARY_DIR}/ImportExecutables.cmake NAMESPACE native- )
|
||||
endif()
|
||||
set(NATIVE_TARGETS bin2c widl gendib cabman fatten hpp isohybrid mkhive mkisofs obj2bin spec2def geninc mkshelllink utf16le xml2sdb)
|
||||
if(NOT MSVC)
|
||||
list(APPEND NATIVE_TARGETS rsym)
|
||||
endif()
|
||||
|
||||
export(TARGETS ${NATIVE_TARGETS} FILE ${CMAKE_BINARY_DIR}/ImportExecutables.cmake NAMESPACE native- )
|
||||
configure_file(sdk/cmake/host-tools.in ${CMAKE_BINARY_DIR}/TargetList.cmake)
|
||||
|
||||
else()
|
||||
# Add host tools target
|
||||
include(sdk/cmake/host-tools.cmake)
|
||||
setup_host_tools()
|
||||
|
||||
# We don't need CMake importlib handling.
|
||||
unset(CMAKE_IMPORT_LIBRARY_SUFFIX)
|
||||
|
||||
if(NEW_STYLE_BUILD)
|
||||
include(sdk/cmake/host-tools.cmake)
|
||||
endif()
|
||||
|
||||
# Print build type
|
||||
message("-- Build Type: ${CMAKE_BUILD_TYPE}")
|
||||
|
||||
|
@ -134,14 +126,6 @@ else()
|
|||
#useful stuff!
|
||||
include(CMakeParseArguments)
|
||||
|
||||
if(NOT NEW_STYLE_BUILD)
|
||||
if(NOT DEFINED REACTOS_BUILD_TOOLS_DIR)
|
||||
set(REACTOS_BUILD_TOOLS_DIR ${REACTOS_SOURCE_DIR}/build)
|
||||
endif()
|
||||
set(IMPORT_EXECUTABLES "${REACTOS_BUILD_TOOLS_DIR}/ImportExecutables.cmake" CACHE FILEPATH "Host executables")
|
||||
include(${IMPORT_EXECUTABLES})
|
||||
endif()
|
||||
|
||||
if(DBG)
|
||||
add_definitions(-DDBG=1 -D_SEH_ENABLE_TRACE)
|
||||
else()
|
||||
|
|
|
@ -18,18 +18,6 @@ if /I "%1" == "/?" (
|
|||
goto quit
|
||||
)
|
||||
|
||||
REM Special case %1 = arm_hosttools %2 = vcvarsall.bat %3 = %CMAKE_GENERATOR%
|
||||
if /I "%1" == "arm_hosttools" (
|
||||
echo Configuring x86 host tools for ARM cross build
|
||||
|
||||
REM This launches %VSINSTALLDIR%VS\vcvarsall.bat
|
||||
call %2 x86
|
||||
|
||||
REM Configure host tools for x86.
|
||||
cmake -G %3 -A Win32 -DARCH:STRING=i386 %~dp0
|
||||
exit
|
||||
)
|
||||
|
||||
REM Get the source root directory
|
||||
set REACTOS_SOURCE_DIR=%~dp0
|
||||
|
||||
|
@ -95,14 +83,11 @@ if not defined ARCH (
|
|||
goto quit
|
||||
)
|
||||
|
||||
set NEW_STYLE_BUILD=1
|
||||
set USE_CLANG_CL=0
|
||||
|
||||
REM Parse command line parameters
|
||||
:repeat
|
||||
if /I "%1" == "-DNEW_STYLE_BUILD" (
|
||||
set NEW_STYLE_BUILD=%2
|
||||
) else if "%BUILD_ENVIRONMENT%" == "MinGW" (
|
||||
if "%BUILD_ENVIRONMENT%" == "MinGW" (
|
||||
if /I "%1" == "Codeblocks" (
|
||||
set CMAKE_GENERATOR="CodeBlocks - MinGW Makefiles"
|
||||
) else if /I "%1" == "Eclipse" (
|
||||
|
@ -210,50 +195,12 @@ if "%VS_SOLUTION%" == "1" (
|
|||
goto quit
|
||||
)
|
||||
|
||||
if "%NEW_STYLE_BUILD%"=="0" (
|
||||
|
||||
if not exist host-tools (
|
||||
mkdir host-tools
|
||||
)
|
||||
|
||||
if not exist reactos (
|
||||
mkdir reactos
|
||||
)
|
||||
|
||||
echo Preparing host tools...
|
||||
cd host-tools
|
||||
if EXIST CMakeCache.txt (
|
||||
del CMakeCache.txt /q
|
||||
)
|
||||
|
||||
set REACTOS_BUILD_TOOLS_DIR=!CD!
|
||||
|
||||
REM Use x86 for ARM host tools
|
||||
if "%ARCH%" == "arm" (
|
||||
REM Launch new script instance for x86 host tools configuration
|
||||
start "Preparing host tools for ARM cross build..." /I /B /WAIT %~dp0configure.cmd arm_hosttools "%VSINSTALLDIR%VC\vcvarsall.bat" %CMAKE_GENERATOR%
|
||||
) else (
|
||||
cmake -G %CMAKE_GENERATOR% %CMAKE_ARCH% -DARCH:STRING=%ARCH% "%REACTOS_SOURCE_DIR%"
|
||||
)
|
||||
|
||||
cd..
|
||||
|
||||
)
|
||||
|
||||
echo Preparing reactos...
|
||||
|
||||
if "%NEW_STYLE_BUILD%"=="0" (
|
||||
cd reactos
|
||||
)
|
||||
|
||||
if EXIST CMakeCache.txt (
|
||||
del CMakeCache.txt /q
|
||||
del host-tools\CMakeCache.txt /q
|
||||
)
|
||||
|
||||
if "%NEW_STYLE_BUILD%"=="0" (
|
||||
set BUILD_TOOLS_FLAG=-DREACTOS_BUILD_TOOLS_DIR:PATH="%REACTOS_BUILD_TOOLS_DIR%"
|
||||
)
|
||||
|
||||
if "%BUILD_ENVIRONMENT%" == "MinGW" (
|
||||
cmake -G %CMAKE_GENERATOR% -DENABLE_CCACHE:BOOL=0 -DCMAKE_TOOLCHAIN_FILE:FILEPATH=%MINGW_TOOCHAIN_FILE% -DARCH:STRING=%ARCH% %BUILD_TOOLS_FLAG% %* "%REACTOS_SOURCE_DIR%"
|
||||
|
@ -263,10 +210,6 @@ if "%BUILD_ENVIRONMENT%" == "MinGW" (
|
|||
cmake -G %CMAKE_GENERATOR% %CMAKE_ARCH% -DCMAKE_TOOLCHAIN_FILE:FILEPATH=toolchain-msvc.cmake -DARCH:STRING=%ARCH% %BUILD_TOOLS_FLAG% -DRUNTIME_CHECKS:BOOL=%VS_RUNTIME_CHECKS% %* "%REACTOS_SOURCE_DIR%"
|
||||
)
|
||||
|
||||
if "%NEW_STYLE_BUILD%"=="0" (
|
||||
cd..
|
||||
)
|
||||
|
||||
if %ERRORLEVEL% NEQ 0 (
|
||||
goto quit
|
||||
)
|
||||
|
|
27
configure.sh
27
configure.sh
|
@ -9,7 +9,6 @@ BUILD_ENVIRONMENT=MinGW
|
|||
ARCH=$ROS_ARCH
|
||||
REACTOS_SOURCE_DIR=$(cd `dirname $0` && pwd)
|
||||
REACTOS_OUTPUT_PATH=output-$BUILD_ENVIRONMENT-$ARCH
|
||||
USE_NEW_STYLE=1
|
||||
|
||||
usage() {
|
||||
echo Invalid parameter given.
|
||||
|
@ -34,9 +33,6 @@ while [ $# -gt 0 ]; do
|
|||
makefiles|Makefiles)
|
||||
CMAKE_GENERATOR="Unix Makefiles"
|
||||
;;
|
||||
with-host-tools)
|
||||
USE_NEW_STYLE=0
|
||||
;;
|
||||
*)
|
||||
usage
|
||||
esac
|
||||
|
@ -50,30 +46,9 @@ if [ "$REACTOS_SOURCE_DIR" = "$PWD" ]; then
|
|||
cd "$REACTOS_OUTPUT_PATH"
|
||||
fi
|
||||
|
||||
#EXTRA_ARGS=""
|
||||
if [ $USE_NEW_STYLE -eq 0 ]; then
|
||||
mkdir -p host-tools
|
||||
mkdir -p reactos
|
||||
echo Preparing host tools...
|
||||
cd host-tools
|
||||
rm -f CMakeCache.txt
|
||||
|
||||
REACTOS_BUILD_TOOLS_DIR="$PWD"
|
||||
cmake -G "$CMAKE_GENERATOR" -DARCH:STRING=$ARCH $ROS_CMAKEOPTS -DNEW_STYLE_BUILD:BOOL=0 "$REACTOS_SOURCE_DIR"
|
||||
|
||||
EXTRA_ARGS="$EXTRA_ARGS -DREACTOS_BUILD_TOOLS_DIR:PATH=$REACTOS_BUILD_TOOLS_DIR"
|
||||
|
||||
cd ..
|
||||
fi
|
||||
|
||||
echo Preparing reactos...
|
||||
|
||||
if [ $USE_NEW_STYLE -eq 0 ]; then
|
||||
cd reactos
|
||||
fi
|
||||
|
||||
rm -f CMakeCache.txt host-tools/CMakeCache.txt
|
||||
|
||||
cmake -G "$CMAKE_GENERATOR" -DENABLE_CCACHE:BOOL=0 -DCMAKE_TOOLCHAIN_FILE:FILEPATH=toolchain-gcc.cmake -DARCH:STRING=$ARCH -DNEW_STYLE_BUILD:BOOL=$USE_NEW_STYLE $EXTRA_ARGS $ROS_CMAKEOPTS "$REACTOS_SOURCE_DIR"
|
||||
cmake -G "$CMAKE_GENERATOR" -DENABLE_CCACHE:BOOL=0 -DCMAKE_TOOLCHAIN_FILE:FILEPATH=toolchain-gcc.cmake -DARCH:STRING=$ARCH $EXTRA_ARGS $ROS_CMAKEOPTS "$REACTOS_SOURCE_DIR"
|
||||
|
||||
echo Configure script complete! Enter directories and execute appropriate build commands \(ex: ninja, make, makex, etc...\).
|
||||
|
|
|
@ -228,12 +228,7 @@ elseif(NO_ROSSYM)
|
|||
set(CMAKE_RC_CREATE_SHARED_LIBRARY "<CMAKE_C_COMPILER> ${CMAKE_C_FLAGS} <CMAKE_SHARED_LIBRARY_C_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>")
|
||||
else()
|
||||
# Normal rsym build
|
||||
if(NEW_STYLE_BUILD)
|
||||
string(TOUPPER ${CMAKE_BUILD_TYPE} _build_type)
|
||||
get_target_property(RSYM native-rsym IMPORTED_LOCATION_${_build_type})
|
||||
else()
|
||||
get_target_property(RSYM native-rsym IMPORTED_LOCATION_NOCONFIG)
|
||||
endif()
|
||||
get_target_property(RSYM native-rsym IMPORTED_LOCATION_NOCONFIG)
|
||||
|
||||
set(CMAKE_C_LINK_EXECUTABLE
|
||||
"<CMAKE_C_COMPILER> ${CMAKE_C_FLAGS} <CMAKE_C_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>"
|
||||
|
|
|
@ -1,42 +1,45 @@
|
|||
|
||||
if(CMAKE_HOST_WIN32)
|
||||
set(native_suffix ".exe")
|
||||
endif()
|
||||
function(setup_host_tools)
|
||||
file(MAKE_DIRECTORY ${REACTOS_BINARY_DIR}/host-tools)
|
||||
|
||||
string(TOUPPER ${CMAKE_BUILD_TYPE} _build_type)
|
||||
message(STATUS "Configuring host tools...")
|
||||
# cmake sets CC and CXX when those languages are enabled
|
||||
# so we need to clear them here
|
||||
execute_process(COMMAND
|
||||
${CMAKE_COMMAND}
|
||||
-E env --unset=CC --unset=CXX
|
||||
${CMAKE_COMMAND}
|
||||
-G "${CMAKE_GENERATOR}"
|
||||
-DARCH:STRING=${ARCH}
|
||||
${USE_CLANG_CL_ARG}
|
||||
${REACTOS_SOURCE_DIR}
|
||||
WORKING_DIRECTORY ${REACTOS_BINARY_DIR}/host-tools
|
||||
RESULT_VARIABLE _host_config_result
|
||||
OUTPUT_VARIABLE _host_config_log
|
||||
ERROR_VARIABLE _host_config_log)
|
||||
|
||||
# List of host tools
|
||||
list(APPEND host_tools_list bin2c hpp widl gendib cabman fatten isohybrid mkhive mkisofs obj2bin spec2def geninc mkshelllink utf16le xml2sdb)
|
||||
if(NOT MSVC)
|
||||
list(APPEND host_tools_list rsym)
|
||||
endif()
|
||||
|
||||
foreach(_host_tool ${host_tools_list})
|
||||
if(MSVC_IDE)
|
||||
get_filename_component(_tool_location "${CMAKE_CURRENT_BINARY_DIR}/host-tools/${CMAKE_BUILD_TYPE}/${_host_tool}${native_suffix}" ABSOLUTE)
|
||||
else()
|
||||
get_filename_component(_tool_location "${CMAKE_CURRENT_BINARY_DIR}/host-tools/${_host_tool}${native_suffix}" ABSOLUTE)
|
||||
# Show cmake output only if host-tools breaks
|
||||
if(NOT _host_config_result EQUAL 0)
|
||||
message("\nHost tools log:")
|
||||
message("${_host_config_log}")
|
||||
message(FATAL_ERROR "Failed to configure host tools")
|
||||
endif()
|
||||
list(APPEND tools_binaries ${_tool_location})
|
||||
add_executable(native-${_host_tool} IMPORTED)
|
||||
set_property(TARGET native-${_host_tool} PROPERTY IMPORTED_LOCATION_${_build_type} ${_tool_location})
|
||||
add_dependencies(native-${_host_tool} host-tools)
|
||||
endforeach()
|
||||
|
||||
if(USE_CLANG_CL)
|
||||
# FIXME: Fix host tools build with clang
|
||||
#set(USE_CLANG_CL_ARG "-DCMAKE_C_COMPILER=clang-cl;-DCMAKE_CXX_COMPILER=clang-cl")
|
||||
endif()
|
||||
set_property(SOURCE host_tools PROPERTY SYMBOLIC 1)
|
||||
|
||||
include(ExternalProject)
|
||||
# Make a host-tools target so it'll be built when needed
|
||||
# custom target + symbolic output prevents cmake from running
|
||||
# the command multiple times per build
|
||||
add_custom_command(
|
||||
COMMAND ${CMAKE_COMMAND} --build ${REACTOS_BINARY_DIR}/host-tools
|
||||
OUTPUT host_tools)
|
||||
add_custom_target(build-host-tools ALL DEPENDS host_tools)
|
||||
|
||||
ExternalProject_Add(host-tools
|
||||
SOURCE_DIR ${REACTOS_SOURCE_DIR}
|
||||
BINARY_DIR ${REACTOS_BINARY_DIR}/host-tools
|
||||
STAMP_DIR ${REACTOS_BINARY_DIR}/host-tools/stamps
|
||||
BUILD_ALWAYS 1
|
||||
PREFIX host-tools
|
||||
EXCLUDE_FROM_ALL 1
|
||||
CMAKE_ARGS "-DNEW_STYLE_BUILD=1;-DARCH:STRING=${ARCH};${USE_CLANG_CL_ARG}"
|
||||
INSTALL_COMMAND ""
|
||||
BUILD_BYPRODUCTS ${tools_binaries})
|
||||
include(${REACTOS_BINARY_DIR}/host-tools/ImportExecutables.cmake)
|
||||
include(${REACTOS_BINARY_DIR}/host-tools/TargetList.cmake)
|
||||
|
||||
foreach(_target ${NATIVE_TARGETS})
|
||||
add_dependencies(native-${_target} build-host-tools)
|
||||
endforeach()
|
||||
|
||||
endfunction()
|
||||
|
|
1
sdk/cmake/host-tools.in
Normal file
1
sdk/cmake/host-tools.in
Normal file
|
@ -0,0 +1 @@
|
|||
set(NATIVE_TARGETS @NATIVE_TARGETS@)
|
|
@ -1,9 +1,7 @@
|
|||
|
||||
function(add_host_tool _tool)
|
||||
add_executable(${_tool} ${ARGN})
|
||||
if(NEW_STYLE_BUILD)
|
||||
set_target_properties(${_tool} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${TOOLS_FOLDER})
|
||||
endif()
|
||||
set_target_properties(${_tool} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${TOOLS_FOLDER})
|
||||
endfunction()
|
||||
|
||||
#add_executable(pefixup pefixup.c)
|
||||
|
|
Loading…
Reference in a new issue