Skip to content

Commit

Permalink
Pass cmake parameters to VM generator
Browse files Browse the repository at this point in the history
  • Loading branch information
guillep committed Jul 18, 2023
1 parent f2ece61 commit ef56dde
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ set(APPNAME "Pharo" CACHE STRING "VM Application name"
set(FLAVOUR "CoInterpreter" CACHE STRING "The kind of VM to generate. Possible values: StackVM, CoInterpreter")
set(PHARO_LIBRARY_PATH "@executable_path/Plugins" CACHE STRING "The RPATH to use in the build")
set(ICEBERG_DEFAULT_REMOTE "scpUrl" CACHE STRING "If Iceberg uses HTTPS (httpsUrl) or tries first with SSH (scpUrl)")
set(IMAGE_FORMAT "SpurFormat" CACHE STRING "Image Format to use in the builtVM (SpurFormat / ComposedFormat)")

if(VERBOSE_BUILD)
set(CMAKE_VERBOSE_MAKEFILE TRUE)
Expand Down
23 changes: 21 additions & 2 deletions cmake/vmmaker.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,25 @@ else()
endif()
endif()

function (getVMMakerParameters _resultVar)
getListOfVarsStartingWith("VMMaker_" matchedVars)
set (_pharoParameterArray "")
foreach (_var IN LISTS matchedVars)
# VMMaker_ has 8 characters
string(SUBSTRING ${_var} 8 -1 _name)
set (_pharoParameterArray "${_pharoParameterArray} '${_name}' '${${_var}}'")
endforeach()
set (${_resultVar} "#( ${_pharoParameterArray} )" PARENT_SCOPE)
endfunction()

function (getListOfVarsStartingWith _prefix _resultVar)
get_cmake_property(_vars VARIABLES)
string (REGEX MATCHALL "(^|;)${_prefix}[A-Za-z0-9_]*" _matchedVars "${_vars}")
set (${_resultVar} ${_matchedVars} PARENT_SCOPE)
endfunction()

getVMMakerParameters(VM_Parameters)

set(PLUGIN_GENERATED_FILES
${PHARO_CURRENT_GENERATED}/plugins/src/FilePlugin/FilePlugin.c
${PHARO_CURRENT_GENERATED}/plugins/src/SurfacePlugin/SurfacePlugin.c
Expand Down Expand Up @@ -144,9 +163,9 @@ if(GENERATE_SOURCES)
#Custom command that generates the vm source code from VMMaker into the generated folder
add_custom_command(
OUTPUT ${VMSOURCEFILES} ${PLUGIN_GENERATED_FILES}
COMMAND ${VMMAKER_VM} --headless ${VMMAKER_IMAGE} --no-default-preferences eval \"PharoVMMaker generate: \#\'${FLAVOUR}\' outputDirectory: \'${CMAKE_CURRENT_BINARY_DIR_TO_OUT}\' imageFormat: \'${IMAGE_FORMAT}\'\"
COMMAND ${VMMAKER_VM} --headless ${VMMAKER_IMAGE} --no-default-preferences eval \"PharoVMMaker generate: \#\'${FLAVOUR}\' outputDirectory: \'${CMAKE_CURRENT_BINARY_DIR_TO_OUT}\' options: "${VM_Parameters}"\"
DEPENDS vmmaker ${VMMAKER_IMAGE} ${VMMAKER_VM}
COMMENT "Generating VM files for flavour: ${FLAVOUR}")
COMMENT "Generating VM files for flavour: ${FLAVOUR} with options: ${VM_Parameters}")

add_custom_target(generate-sources DEPENDS ${VMSOURCEFILES} ${PLUGIN_GENERATED_FILES})

Expand Down

0 comments on commit ef56dde

Please sign in to comment.