Make Vala builds efficient under make, too
And some further finishing touches.
This commit is contained in:
parent
6636df643e
commit
377fe478e2
@ -1,7 +1,7 @@
|
||||
# - Precompilation of Vala/Genie source files into C sources
|
||||
# Makes use of the parallel build ability introduced in Vala 0.11.
|
||||
# Might be a bit oversimplified and inefficient but at least it's short.
|
||||
# Filenames must be unique within a single compilation unit and that's fine.
|
||||
# Props to other Vala module writers, I had to reengineer it to understand it.
|
||||
#
|
||||
# vala_precompile (source... - .vala, .gs, .vapi
|
||||
# [DIRECTORY dir] - Output directory (binary dir by default)
|
||||
@ -30,6 +30,7 @@
|
||||
# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
#=============================================================================
|
||||
|
||||
cmake_minimum_required (VERSION 2.8.0)
|
||||
find_package (Vala 0.11 REQUIRED)
|
||||
include (CMakeParseArguments)
|
||||
|
||||
@ -43,22 +44,19 @@ endmacro ()
|
||||
function (_vala_make_fast file)
|
||||
_vala_parse_source_path ()
|
||||
|
||||
# See `cmake --help-policy CMP0058` for a rather nice explanation.
|
||||
# TODO: it says we can fix this situation even for non-Ninja
|
||||
# (rebuilds are forced even when the external API doesn't change),
|
||||
# just make sure to only use BYPRODUCTS when it's supported by CMake
|
||||
set (stamp "${output_vapi}")
|
||||
set (byproducts)
|
||||
if ("${CMAKE_GENERATOR}" STREQUAL Ninja)
|
||||
set (stamp "${output_vapi}.stamp")
|
||||
set (byproducts BYPRODUCTS "${output_vapi}")
|
||||
set (stamp_target ${stamp_target} "${stamp}" PARENT_SCOPE)
|
||||
# See `cmake --help-policy CMP0058` for a rather nice explanation
|
||||
set (_stamp "${output_vapi}")
|
||||
set (_byproducts)
|
||||
if (NOT "${CMAKE_VERSION}" VERSION_LESS "3.0.2")
|
||||
set (_stamp "${output_vapi}.stamp")
|
||||
set (_byproducts BYPRODUCTS "${output_vapi}")
|
||||
set (stamp_target ${stamp_target} "${_stamp}" PARENT_SCOPE)
|
||||
endif ()
|
||||
|
||||
add_custom_command (OUTPUT "${stamp}"
|
||||
${byproducts}
|
||||
add_custom_command (OUTPUT "${_stamp}"
|
||||
${_byproducts}
|
||||
COMMAND ${VALA_COMPILER} "${file}" "--fast-vapi=${output_vapi}"
|
||||
COMMAND ${CMAKE_COMMAND} -E touch "${stamp}"
|
||||
COMMAND ${CMAKE_COMMAND} -E touch "${_stamp}"
|
||||
DEPENDS "${file}"
|
||||
COMMENT "Generating a fast vapi for ${basename}" VERBATIM)
|
||||
set (fast_vapi_deps ${fast_vapi_deps} "${output_vapi}" PARENT_SCOPE)
|
||||
@ -70,11 +68,11 @@ function (_vala_make_c file)
|
||||
_vala_parse_source_path ()
|
||||
|
||||
# We need to filter the current file back out or else it creates conflicts
|
||||
set (fast_vapis ${fast_vapi_args})
|
||||
list (REMOVE_ITEM fast_vapis "--use-fast-vapi=${output_vapi}")
|
||||
set (_fast_vapis ${fast_vapi_args})
|
||||
list (REMOVE_ITEM _fast_vapis "--use-fast-vapi=${output_vapi}")
|
||||
|
||||
add_custom_command (OUTPUT "${output_c}"
|
||||
COMMAND ${VALA_COMPILER} "${file}" -C ${compiler_args} ${fast_vapis}
|
||||
COMMAND ${VALA_COMPILER} "${file}" -C ${compiler_args} ${_fast_vapis}
|
||||
COMMAND ${CMAKE_COMMAND} -E touch "${output_c}"
|
||||
DEPENDS "${file}" ${fast_vapi_deps} ${vapis} ${stamp_target}
|
||||
WORKING_DIRECTORY "${directory}"
|
||||
@ -121,6 +119,8 @@ function (vala_precompile)
|
||||
foreach (_source ${sources})
|
||||
_vala_make_fast ("${_source}")
|
||||
endforeach ()
|
||||
|
||||
# The target is actually required, or else it may trigger CMP0058
|
||||
if (stamp_target)
|
||||
add_custom_target ("vala_fast_vapis_${counter}" DEPENDS ${stamp_target})
|
||||
set (stamp_target "vala_fast_vapis_${counter}")
|
||||
@ -143,14 +143,12 @@ function (vala_precompile)
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
set (extra_outputs)
|
||||
set (export_args)
|
||||
|
||||
if (arg_VAPI)
|
||||
if (NOT IS_ABSOLUTE "${arg_VAPI}")
|
||||
set (arg_VAPI "${directory}/${arg_VAPI}")
|
||||
endif ()
|
||||
list (APPEND extra_outputs "${arg_VAPI}")
|
||||
list (APPEND export_args "--internal-vapi=${arg_VAPI}")
|
||||
list (APPEND compiler_args "--internal-vapi=${arg_VAPI}")
|
||||
if (NOT arg_HEADER)
|
||||
message (FATAL_ERROR "HEADER generation required for vapi")
|
||||
endif ()
|
||||
@ -160,7 +158,7 @@ function (vala_precompile)
|
||||
set (arg_SYMBOLS "${directory}/${arg_SYMBOLS}")
|
||||
endif ()
|
||||
list (APPEND extra_outputs "${arg_SYMBOLS}")
|
||||
list (APPEND export_args "--symbols=${arg_SYMBOLS}")
|
||||
list (APPEND compiler_args "--symbols=${arg_SYMBOLS}")
|
||||
if (NOT arg_HEADER)
|
||||
message (FATAL_ERROR "HEADER generation required for symbols")
|
||||
endif ()
|
||||
@ -177,14 +175,13 @@ function (vala_precompile)
|
||||
list (APPEND extra_outputs
|
||||
"${header_base}${header_ext}"
|
||||
"${header_base}_internal${header_ext}")
|
||||
list (APPEND export_args
|
||||
list (APPEND compiler_args
|
||||
"--header=${header_base}${header_ext}"
|
||||
"--internal-header=${header_base}_internal${header_ext}")
|
||||
endif ()
|
||||
if (extra_outputs)
|
||||
add_custom_command (OUTPUT ${extra_outputs}
|
||||
COMMAND ${VALA_COMPILER}
|
||||
-C ${compiler_args} ${export_args} ${fast_vapi_args}
|
||||
COMMAND ${VALA_COMPILER} -C ${compiler_args} ${fast_vapi_args}
|
||||
DEPENDS ${fast_vapi_deps} ${vapis}
|
||||
COMMENT "Generating vapi/headers/symbols" VERBATIM)
|
||||
endif ()
|
||||
|
Loading…
Reference in New Issue
Block a user