build: make targets properly rebuild when templates or compiler changed

This commit is contained in:
5684185+vsariola@users.noreply.github.com 2023-09-02 20:14:52 +03:00
parent 231e055faf
commit b028fea59a
4 changed files with 24 additions and 11 deletions

View File

@ -62,8 +62,8 @@ else()
endif()
# the tests include the entire ASM but we still want to rebuild when they change
file(GLOB x86templates ${PROJECT_SOURCE_DIR}/templates/amd64-386/*.asm)
file(GLOB wasmtemplates ${PROJECT_SOURCE_DIR}/templates/wasm/*.wat)
file(GLOB x86templates "${PROJECT_SOURCE_DIR}/vm/compiler/templates/amd64-386/*.asm")
file(GLOB wasmtemplates "${PROJECT_SOURCE_DIR}/vm/compiler/templates/wasm/*.wat")
file(GLOB sointusrc "${PROJECT_SOURCE_DIR}/*.go")
file(GLOB compilersrc "${PROJECT_SOURCE_DIR}/compiler/*.go")
file(GLOB compilecmdsrc "${PROJECT_SOURCE_DIR}/cmd/sointu-compile/*.go")
@ -83,16 +83,23 @@ set(sointuasm sointu.asm)
# Build sointu-cli only once because go run has everytime quite a bit of delay when
# starting
add_custom_command(
OUTPUT
"${compilecmd}"
COMMAND
${GO} build -o "${compilecmd}" ${PROJECT_SOURCE_DIR}/cmd/sointu-compile/main.go
DEPENDS ${x86templates} ${wasmtemplates} ${sointusrc} ${compilersrc} ${compilecmdsrc}
)
add_custom_target(
sointu-compiler
COMMAND ${GO} build -o ${compilecmd} ${PROJECT_SOURCE_DIR}/cmd/sointu-compile/main.go
SOURCES "${sointusrc}" "${compilersrc}" "${compilecmdsrc}"
DEPENDS ${compilecmd}
)
add_custom_command(
OUTPUT ${sointuasm}
COMMAND ${compilecmd} -arch=${arch} -a -o ${CMAKE_CURRENT_BINARY_DIR}
DEPENDS "${templates}" sointu-compiler
DEPENDS ${compilecmd}
)
add_library(${STATICLIB} ${sointuasm})

View File

@ -12,6 +12,7 @@ add_custom_command(
${CMAKE_CURRENT_BINARY_DIR}
DEPENDS
"${PROJECT_SOURCE_DIR}/examples/patches/physics_girl_st.yml"
${compilecmd}
OUTPUT
physics_girl_st.asm
physics_girl_st.h
@ -21,7 +22,6 @@ add_custom_command(
)
add_library(physics_girl_st physics_girl_st.asm)
add_dependencies(physics_girl_st sointu-compiler)
if(WIN32)
add_executable(cplay-winmm

View File

@ -15,6 +15,7 @@ function(add_asm_example identifier songfile architecture sizeof_void_ptr window
${CMAKE_CURRENT_BINARY_DIR}
DEPENDS
${songfile}
${compilecmd}
OUTPUT
${songprefix}_${architecture}.asm
${songprefix}_${architecture}.h
@ -50,7 +51,6 @@ function(add_asm_example identifier songfile architecture sizeof_void_ptr window
target_compile_definitions(${identifier}-${architecture} PRIVATE TRACK_INCLUDE="${songprefix}_${architecture}.inc")
# Set up dependencies
add_dependencies(${identifier}-${architecture} sointu-compiler)
add_dependencies(examples ${identifier}-${architecture})
endfunction()

View File

@ -16,7 +16,7 @@ function(regression_test testname)
add_custom_command(
OUTPUT ${asmfile}
COMMAND ${compilecmd} ${ARGV4} -arch=${arch} -o ${CMAKE_CURRENT_BINARY_DIR}/${asmfile} ${CMAKE_CURRENT_SOURCE_DIR}/${source}
DEPENDS ${source} ${x86templates} sointu-compiler
DEPENDS ${source} ${x86templates} ${compilecmd}
)
add_executable(${testname} test_renderer.c ${asmfile})
@ -26,11 +26,17 @@ function(regression_test testname)
set(wasmfile ${CMAKE_CURRENT_BINARY_DIR}/${testname}.wasm)
set(watfile ${CMAKE_CURRENT_BINARY_DIR}/${testname}.wat)
set(wasmtarget wasm_${testname})
add_custom_target(${wasmtarget} ALL
add_custom_command(
OUTPUT ${wasmfile}
COMMAND ${compilecmd} ${ARGV4} -arch=wasm -o ${watfile} ${CMAKE_CURRENT_SOURCE_DIR}/${source} && ${WAT2WASM} -o ${wasmfile} ${watfile}
SOURCES "${source}" "${wasmtemplates}"
DEPENDS sointu-compiler
DEPENDS ${source} ${wasmtemplates} ${compilecmd}
)
add_custom_target(${wasmtarget} ALL
SOURCES "${source}" "${wasmtemplates}"
DEPENDS ${wasmfile}
)
add_test(${wasmtarget} ${NODE} ${CMAKE_CURRENT_SOURCE_DIR}/wasm_test_renderer.es6 ${wasmfile} ${CMAKE_CURRENT_SOURCE_DIR}/expected_output/${testname}.raw)
endif()
endif()