From bb3511046f7cd77ab68d92b74419292cffca1152 Mon Sep 17 00:00:00 2001 From: James Rhodes Date: Mon, 12 Nov 2012 07:53:59 +1100 Subject: [PATCH] Fixed issue #191 and kernel output paths. --- dtld/main.c | 2 ++ kernel/CMakeLists.txt | 10 ++++++---- kernel/dcpu.cmake | 30 +++++++++++++++--------------- libdcpu-ld/ldbin.c | 3 +-- 4 files changed, 24 insertions(+), 21 deletions(-) diff --git a/dtld/main.c b/dtld/main.c index 4efbeec..02754ea 100644 --- a/dtld/main.c +++ b/dtld/main.c @@ -219,6 +219,8 @@ int main(int argc, char* argv[]) // Replace @KERNEL_FOLDER@ with the kernel's folder. find = bfromcstr("@KERNEL_FOLDER@"); repl = osutil_getkernelpath(); + bconchar(repl, '/'); + bcatcstr(repl, policy_kernel); bfindreplace(policy_kernel_path, find, repl, 0); bfindreplace(policy_jumplist_path, find, repl, 0); bdestroy(find); diff --git a/kernel/CMakeLists.txt b/kernel/CMakeLists.txt index e0a056b..be15587 100644 --- a/kernel/CMakeLists.txt +++ b/kernel/CMakeLists.txt @@ -26,6 +26,8 @@ foreach(k ${KERNELS}) foreach(f ${files}) list(APPEND files_append ${k}/${f}) endforeach() + file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${k}) + file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/${k}/policy DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/${k}) add_dcpu_image(${k} ${files_append}) if(${DEPLOYABLE}) @@ -37,10 +39,10 @@ foreach(k ${KERNELS}) OWNER_WRITE GROUP_WRITE WORLD_WRITE OWNER_EXECUTE GROUP_EXECUTE WORLD_EXECUTE) install(FILES - ${CMAKE_CURRENT_BINARY_DIR}/${k}.djmp16 - ${CMAKE_CURRENT_BINARY_DIR}/${k}.dkrn16 - ${CMAKE_CURRENT_BINARY_DIR}/${k}.dsym16 - ${CMAKE_CURRENT_SOURCE_DIR}/${k}/policy + ${CMAKE_CURRENT_BINARY_DIR}/${k}/${k}.djmp16 + ${CMAKE_CURRENT_BINARY_DIR}/${k}/${k}.dkrn16 + ${CMAKE_CURRENT_BINARY_DIR}/${k}/${k}.dsym16 + ${CMAKE_CURRENT_SOURCE_DIR}/${k}/${k}/policy DESTINATION share/dcpu/kernels/${k}) endif() diff --git a/kernel/dcpu.cmake b/kernel/dcpu.cmake index 047c3a7..4c72f84 100644 --- a/kernel/dcpu.cmake +++ b/kernel/dcpu.cmake @@ -39,33 +39,33 @@ function(define_dcpu_tool tool toolargs verb files runasm outvar) add_custom_command( OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/${fpth}/${fbse}.oa COMMAND ${main_path} - ARGS ${toolargs} ${toolwarningsilence} -I "${CMAKE_CURRENT_SOURCE_DIR}/include" -o "${CMAKE_CURRENT_SOURCE_DIR}/${fpth}/${fbse}.oa" "${CMAKE_CURRENT_SOURCE_DIR}/${i}" + ARGS ${toolargs} ${toolwarningsilence} -I "${CMAKE_CURRENT_SOURCE_DIR}/include" -o "${CMAKE_CURRENT_BINARY_DIR}/${fpth}/${fbse}.oa" "${CMAKE_CURRENT_SOURCE_DIR}/${i}" DEPENDS ${tool} dtasm "${CMAKE_CURRENT_SOURCE_DIR}/${i}" COMMENT "${verb} ${fbse}${fext} with DCPU-Toolchain...") add_custom_command( - OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/${fpth}/${fbse}.o + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${fpth}/${fbse}.o COMMAND ${asm_path} - ARGS ${asmwarningsilence} -o "${CMAKE_CURRENT_SOURCE_DIR}/${fpth}/${fbse}.o" -s "${CMAKE_CURRENT_SOURCE_DIR}/${fpth}/${fbse}.os" "${CMAKE_CURRENT_SOURCE_DIR}/${fpth}/${fbse}.oa" - DEPENDS ${tool} dtasm "${CMAKE_CURRENT_SOURCE_DIR}/${i}" "${CMAKE_CURRENT_SOURCE_DIR}/${fpth}/${fbse}.oa" + ARGS ${asmwarningsilence} -o "${CMAKE_CURRENT_BINARY_DIR}/${fpth}/${fbse}.o" -s "${CMAKE_CURRENT_BINARY_DIR}/${fpth}/${fbse}.os" "${CMAKE_CURRENT_BINARY_DIR}/${fpth}/${fbse}.oa" + DEPENDS ${tool} dtasm "${CMAKE_CURRENT_SOURCE_DIR}/${i}" "${CMAKE_CURRENT_BINARY_DIR}/${fpth}/${fbse}.oa" COMMENT "Assembling ${fpth}/${fbse}.oa with DCPU-Toolchain...") if("${tout}" STREQUAL "") - set(tout "${CMAKE_CURRENT_SOURCE_DIR}/${fpth}/${fbse}.o") + set(tout "${CMAKE_CURRENT_BINARY_DIR}/${fpth}/${fbse}.o") else("${tout}" STREQUAL "") - list(APPEND tout "${CMAKE_CURRENT_SOURCE_DIR}/${fpth}/${fbse}.o") + list(APPEND tout "${CMAKE_CURRENT_BINARY_DIR}/${fpth}/${fbse}.o") endif("${tout}" STREQUAL "") set(${outvar} "${${outvar}} ${tout}" PARENT_SCOPE) else(${runasm} STREQUAL "true") calculate_tool_path(${tool} main_path) add_custom_command( - OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/${fpth}/${fbse}.o + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${fpth}/${fbse}.o COMMAND ${main_path} - ARGS ${toolargs} ${toolwarningsilence} -s "${CMAKE_CURRENT_SOURCE_DIR}/${fpth}/${fbse}.os" -o "${CMAKE_CURRENT_SOURCE_DIR}/${fpth}/${fbse}.o" "${CMAKE_CURRENT_SOURCE_DIR}/${i}" + ARGS ${toolargs} ${toolwarningsilence} -s "${CMAKE_CURRENT_BINARY_DIR}/${fpth}/${fbse}.os" -o "${CMAKE_CURRENT_BINARY_DIR}/${fpth}/${fbse}.o" "${CMAKE_CURRENT_SOURCE_DIR}/${i}" DEPENDS ${tool} "${CMAKE_CURRENT_SOURCE_DIR}/${i}" COMMENT "${verb} ${fbse}${fext} with DCPU-Toolchain...") if("${tout}" STREQUAL "") - set(tout "${CMAKE_CURRENT_SOURCE_DIR}/${fpth}/${fbse}.o") + set(tout "${CMAKE_CURRENT_BINARY_DIR}/${fpth}/${fbse}.o") else("${tout}" STREQUAL "") - list(APPEND tout "${CMAKE_CURRENT_SOURCE_DIR}/${fpth}/${fbse}.o") + list(APPEND tout "${CMAKE_CURRENT_BINARY_DIR}/${fpth}/${fbse}.o") endif("${tout}" STREQUAL "") set(${outvar} "${${outvar}} ${tout}" PARENT_SCOPE) endif(${runasm} STREQUAL "true") @@ -86,11 +86,11 @@ function(add_dcpu_image target) string(STRIP "${tcoutputs}" tcoutputs) calculate_tool_path(dtld main_path) add_custom_command( - OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${target}.dkrn16" + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${target}/${target}.dkrn16" COMMAND ${main_path} - ARGS -s "${CMAKE_CURRENT_BINARY_DIR}/${target}.dsym16" -O3 --symbol-extension="os" - --keep-outputs -l kernel -o "${CMAKE_CURRENT_BINARY_DIR}/${target}.dkrn16" - --jumplist "${CMAKE_CURRENT_BINARY_DIR}/${target}.djmp16" ${tasmoutputs} ${tcoutputs} + ARGS -s "${CMAKE_CURRENT_BINARY_DIR}/${target}/${target}.dsym16" -O3 --symbol-extension="os" + --keep-outputs -l kernel -o "${CMAKE_CURRENT_BINARY_DIR}/${target}/${target}.dkrn16" + --jumplist "${CMAKE_CURRENT_BINARY_DIR}/${target}/${target}.djmp16" ${tasmoutputs} ${tcoutputs} DEPENDS dtld ${tasmoutputs} ${tcoutputs} COMMENT "Linking ${target}.dkrn16 as kernel with DCPU-Toolchain...") @@ -112,7 +112,7 @@ function(add_dcpu_image target) endif(DEFINED params) endforeach(i ${tcoutputs}) list(APPEND params DEPENDS) - list(APPEND params "${CMAKE_CURRENT_BINARY_DIR}/${target}.dkrn16") + list(APPEND params "${CMAKE_CURRENT_BINARY_DIR}/${target}/${target}.dkrn16") add_custom_target(${target} ALL ${params}) endfunction(add_dcpu_image target) diff --git a/libdcpu-ld/ldbin.c b/libdcpu-ld/ldbin.c index fe8b83e..2667173 100644 --- a/libdcpu-ld/ldbin.c +++ b/libdcpu-ld/ldbin.c @@ -514,11 +514,10 @@ void bin_info_remove(list_t* all, struct ldbin* bin, list_t* list, bool isAdjust { // Adjust the address stored in the entry down // by the amount of words that were removed. - //entry->address -= count; + entry->address -= count; } } - // Loop through all of the bins. for (k = 0; k < list_size(all); k++) {