mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-05-19 05:39:18 +02:00
refactor library generation from stubs
This commit is contained in:
parent
2efcc53098
commit
0bade8de2f
1 changed files with 27 additions and 13 deletions
|
@ -190,26 +190,40 @@ endif()
|
||||||
set(chibi-ffi ${CMAKE_CURRENT_SOURCE_DIR}/tools/chibi-ffi)
|
set(chibi-ffi ${CMAKE_CURRENT_SOURCE_DIR}/tools/chibi-ffi)
|
||||||
set(chibi-genstatic ${CMAKE_CURRENT_SOURCE_DIR}/tools/chibi-genstatic)
|
set(chibi-genstatic ${CMAKE_CURRENT_SOURCE_DIR}/tools/chibi-genstatic)
|
||||||
|
|
||||||
set(stuboutdir ${CMAKE_CURRENT_BINARY_DIR}/stubs/lib)
|
function(add_stubs_library stub stubc)
|
||||||
foreach(e ${stubs})
|
get_filename_component(stubdir ${stub} PATH)
|
||||||
get_filename_component(stubdir ${e} PATH)
|
get_filename_component(basename ${stub} NAME_WE)
|
||||||
get_filename_component(basename ${e} NAME_WE)
|
set(stubfile ${CMAKE_CURRENT_SOURCE_DIR}/lib/${stub})
|
||||||
set(stubfile ${CMAKE_CURRENT_SOURCE_DIR}/lib/${e})
|
set(stubdir ${CMAKE_CURRENT_BINARY_DIR}/lib/${stubdir})
|
||||||
set(stubdir ${stuboutdir}/${stubdir})
|
|
||||||
set(stubout ${stubdir}/${basename}.c)
|
set(stubout ${stubdir}/${basename}.c)
|
||||||
|
set(${stubc} ${stubout} PARENT_SCOPE)
|
||||||
|
|
||||||
file(MAKE_DIRECTORY ${stubdir})
|
file(MAKE_DIRECTORY ${stubdir})
|
||||||
add_custom_command(OUTPUT ${stubout}
|
add_custom_command(OUTPUT ${stubout}
|
||||||
COMMAND chibi-scheme-bootstrap
|
COMMAND chibi-scheme-bootstrap ${chibi-ffi} ${stubfile} ${stubout}
|
||||||
${chibi-ffi} ${stubfile} ${stubout}
|
|
||||||
DEPENDS ${stubfile} ${chibi-ffi}
|
DEPENDS ${stubfile} ${chibi-ffi}
|
||||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
list(APPEND stubouts ${stubout})
|
|
||||||
|
if (BUILD_SHARED_LIBS)
|
||||||
|
add_library(${basename}
|
||||||
|
${stubout})
|
||||||
|
|
||||||
|
target_link_libraries(${basename}
|
||||||
|
PRIVATE
|
||||||
|
libchibi-scheme)
|
||||||
|
|
||||||
|
set_target_properties(${basename} PROPERTIES
|
||||||
|
LIBRARY_OUTPUT_DIRECTORY ${stubdir}
|
||||||
|
LIBRARY_OUTPUT_NAME ${basename}
|
||||||
|
PREFIX "")
|
||||||
|
endif()
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
foreach(stub ${stubs})
|
||||||
|
add_stubs_library(${stub} stubc)
|
||||||
|
list(APPEND stubouts ${stubc})
|
||||||
endforeach()
|
endforeach()
|
||||||
add_custom_target(chibi-scheme-stubs DEPENDS ${stubouts})
|
add_custom_target(chibi-scheme-stubs DEPENDS ${stubouts})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
add_dependencies(libchibi-scheme chibi-scheme-stubs)
|
add_dependencies(libchibi-scheme chibi-scheme-stubs)
|
||||||
|
|
||||||
function(add_compiled_library cfile)
|
function(add_compiled_library cfile)
|
||||||
|
|
Loading…
Add table
Reference in a new issue