mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 01:55:19 +00:00
[NTVDM]: Introduce the possibility to compile multiple x86-16bit ASM files by using the trick of concatenating them in correct order so that the resulting file is a compilable ASM file. (We cannot do linking or 16-bit objects, so we need to take a middle approach).
CORE-9442 #resolve svn path=/trunk/; revision=66963
This commit is contained in:
parent
f9d277801c
commit
7301ab58e2
2 changed files with 124 additions and 0 deletions
|
@ -1,4 +1,7 @@
|
|||
|
||||
## Experimental 16-bit ASM compilation support
|
||||
include(asm16.cmake)
|
||||
|
||||
add_subdirectory(config)
|
||||
#add_subdirectory(dos)
|
||||
add_subdirectory(ntvdm)
|
||||
|
|
121
reactos/subsystems/mvdm/asm16.cmake
Normal file
121
reactos/subsystems/mvdm/asm16.cmake
Normal file
|
@ -0,0 +1,121 @@
|
|||
## EXPERIMENTAL!!
|
||||
|
||||
# We need to use almost the same tricks as the ones used for MSVC 'add_asm_files'
|
||||
# support because we are going to compile ASM files for a fixed target (16-bit x86)
|
||||
# that is different from the main target.
|
||||
|
||||
if(NOT MSVC)
|
||||
###
|
||||
### For GCC
|
||||
###
|
||||
function(add_asm16_bin _target _binary_file _base_address)
|
||||
set(_concatenated_asm_file ${CMAKE_CURRENT_BINARY_DIR}/${_target}.asm)
|
||||
set(_object_file ${CMAKE_CURRENT_BINARY_DIR}/${_target}.o)
|
||||
|
||||
# unset(_source_file_list)
|
||||
|
||||
get_defines(_directory_defines)
|
||||
get_includes(_directory_includes)
|
||||
get_directory_property(_defines COMPILE_DEFINITIONS)
|
||||
|
||||
# Build a list of all the defines needed.
|
||||
foreach(_source_file ${ARGN})
|
||||
get_filename_component(_source_file_full_path ${_source_file} ABSOLUTE)
|
||||
get_source_file_property(_defines_semicolon_list ${_source_file_full_path} COMPILE_DEFINITIONS)
|
||||
|
||||
# unset(_source_file_defines)
|
||||
|
||||
foreach(_define ${_defines_semicolon_list})
|
||||
if(NOT ${_define} STREQUAL "NOTFOUND")
|
||||
list(APPEND _source_file_defines -D${_define})
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
list(APPEND _source_file_list ${_source_file_full_path})
|
||||
endforeach()
|
||||
|
||||
# We do not support 16-bit ASM linking so the only way to compile
|
||||
# many ASM files is by concatenating them into a single one and
|
||||
# compile the resulting file.
|
||||
concatenate_files(${_concatenated_asm_file} ${_source_file_list})
|
||||
|
||||
##
|
||||
## All this part is the same as CreateBootSectorTarget
|
||||
##
|
||||
add_custom_command(
|
||||
OUTPUT ${_object_file}
|
||||
COMMAND ${CMAKE_ASM_COMPILER} -x assembler-with-cpp -o ${_object_file} -I${REACTOS_SOURCE_DIR}/include/asm -I${REACTOS_BINARY_DIR}/include/asm ${_directory_includes} ${_source_file_defines} ${_directory_defines} -D__ASM__ -c ${_concatenated_asm_file}
|
||||
DEPENDS ${_concatenated_asm_file})
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT ${_binary_file}
|
||||
COMMAND native-obj2bin ${_object_file} ${_binary_file} ${_base_address}
|
||||
# COMMAND objcopy --output-target binary --image-base 0x${_base_address} ${_object_file} ${_binary_file}
|
||||
DEPENDS ${_object_file} native-obj2bin)
|
||||
|
||||
set_source_files_properties(${_object_file} ${_binary_file} PROPERTIES GENERATED TRUE)
|
||||
|
||||
add_custom_target(${_target} ALL DEPENDS ${_binary_file})
|
||||
endfunction()
|
||||
|
||||
else()
|
||||
###
|
||||
### For MSVC
|
||||
###
|
||||
function(add_asm16_bin _target _binary_file _base_address)
|
||||
set(_concatenated_asm_file ${CMAKE_CURRENT_BINARY_DIR}/${_target}.asm)
|
||||
set(_preprocessed_asm_file ${CMAKE_CURRENT_BINARY_DIR}/${_target}.tmp)
|
||||
set(_object_file ${CMAKE_CURRENT_BINARY_DIR}/${_target}.obj)
|
||||
|
||||
# unset(_source_file_list)
|
||||
|
||||
get_defines(_directory_defines)
|
||||
get_includes(_directory_includes)
|
||||
get_directory_property(_defines COMPILE_DEFINITIONS)
|
||||
|
||||
# Build a list of all the defines needed.
|
||||
foreach(_source_file ${ARGN})
|
||||
get_filename_component(_source_file_full_path ${_source_file} ABSOLUTE)
|
||||
get_source_file_property(_defines_semicolon_list ${_source_file_full_path} COMPILE_DEFINITIONS)
|
||||
|
||||
# unset(_source_file_defines)
|
||||
|
||||
foreach(_define ${_defines_semicolon_list})
|
||||
if(NOT ${_define} STREQUAL "NOTFOUND")
|
||||
list(APPEND _source_file_defines -D${_define})
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
list(APPEND _source_file_list ${_source_file_full_path})
|
||||
endforeach()
|
||||
|
||||
# We do not support 16-bit ASM linking so the only way to compile
|
||||
# many ASM files is by concatenating them into a single one and
|
||||
# compile the resulting file.
|
||||
concatenate_files(${_concatenated_asm_file} ${_source_file_list})
|
||||
|
||||
##
|
||||
## All this part is the same as CreateBootSectorTarget
|
||||
##
|
||||
if(ARCH STREQUAL "arm")
|
||||
set(_pp_asm16_compile_command ${CMAKE_ASM16_COMPILER} -nologo -o ${_object_file} ${_preprocessed_asm_file})
|
||||
else()
|
||||
set(_pp_asm16_compile_command ${CMAKE_ASM16_COMPILER} /nologo /Cp /Fo${_object_file} /c /Ta ${_preprocessed_asm_file})
|
||||
endif()
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT ${_preprocessed_asm_file} ${_object_file}
|
||||
COMMAND ${CMAKE_C_COMPILER} /nologo /X /I${REACTOS_SOURCE_DIR}/include/asm /I${REACTOS_BINARY_DIR}/include/asm ${_directory_includes} ${_source_file_defines} ${_directory_defines} /D__ASM__ /D_USE_ML /EP /c ${_concatenated_asm_file} > ${_preprocessed_asm_file} && ${_pp_asm16_compile_command}
|
||||
DEPENDS ${_concatenated_asm_file})
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT ${_binary_file}
|
||||
COMMAND native-obj2bin ${_object_file} ${_binary_file} ${_base_address}
|
||||
DEPENDS ${_object_file} native-obj2bin)
|
||||
|
||||
set_source_files_properties(${_object_file} ${_preprocessed_asm_file} ${_binary_file} PROPERTIES GENERATED TRUE)
|
||||
|
||||
add_custom_target(${_target} ALL DEPENDS ${_binary_file})
|
||||
endfunction()
|
||||
|
||||
endif()
|
Loading…
Reference in a new issue