@@ -76,13 +76,14 @@ message("LPYTHON_RTLIB_DIR: ${LPYTHON_RTLIB_DIR}")
7676message ("LPYTHON_RTLIB_LIBRARY: ${LPYTHON_RTLIB_LIBRARY} " )
7777
7878
79- macro (RUN_UTIL RUN_FAIL RUN_NAME RUN_FILE_NAME RUN_LABELS RUN_EXTRAFILES RUN_EXTRA_ARGS )
79+ macro (RUN_UTIL RUN_FAIL RUN_NAME RUN_FILE_NAME RUN_LABELS RUN_EXTRAFILES RUN_EXTRA_ARGS RUN_COPY_TO_BIN )
8080 set (fail ${${RUN_FAIL} })
8181 set (name ${${RUN_NAME} })
8282 set (file_name ${${RUN_FILE_NAME} })
8383 set (labels ${${RUN_LABELS} })
8484 set (extra_files ${${RUN_EXTRAFILES} })
8585 set (extra_args ${${RUN_EXTRA_ARGS} })
86+ set (copy_to_bin ${${RUN_COPY_TO_BIN} })
8687
8788 if (NOT name)
8889 message (FATAL_ERROR "Must specify the NAME argument" )
@@ -105,6 +106,23 @@ macro(RUN_UTIL RUN_FAIL RUN_NAME RUN_FILE_NAME RUN_LABELS RUN_EXTRAFILES RUN_EXT
105106 if (${fail} )
106107 set_tests_properties (${name} PROPERTIES WILL_FAIL TRUE )
107108 endif ()
109+ elseif (KIND STREQUAL "llvm_py" )
110+ add_custom_command (
111+ OUTPUT ${name} .o
112+ COMMAND ${LPYTHON} -c ${extra_args} ${CMAKE_CURRENT_SOURCE_DIR} /${file_name}.py -o ${name} .o
113+ DEPENDS ${CMAKE_CURRENT_SOURCE_DIR} /${file_name}.py
114+ VERBATIM )
115+ add_executable (${name} ${name} .o ${extra_files} )
116+ target_include_directories (${name} PRIVATE ${CMAKE_SOURCE_DIR} ${NUMPY_INCLUDE_DIR} )
117+ set_target_properties (${name} PROPERTIES LINKER_LANGUAGE C )
118+ target_link_libraries (${name} lpython_rtlib Python::Python )
119+ add_test (${name} ${CMAKE_CURRENT_BINARY_DIR} /${name} )
120+ if (labels)
121+ set_tests_properties (${name} PROPERTIES LABELS "${labels} " )
122+ endif ()
123+ if (${fail} )
124+ set_tests_properties (${name} PROPERTIES WILL_FAIL TRUE )
125+ endif ()
108126 elseif (KIND STREQUAL "llvm_sym" )
109127 add_custom_command (
110128 OUTPUT ${name} .o
@@ -153,9 +171,6 @@ macro(RUN_UTIL RUN_FAIL RUN_NAME RUN_FILE_NAME RUN_LABELS RUN_EXTRAFILES RUN_EXT
153171 target_include_directories (${name} PRIVATE ${CMAKE_SOURCE_DIR} ${NUMPY_INCLUDE_DIR} )
154172 set_target_properties (${name} PROPERTIES LINKER_LANGUAGE C )
155173 target_link_libraries (${name} lpython_rtlib Python::Python )
156- if (extra_files)
157- file (COPY ${CMAKE_CURRENT_SOURCE_DIR} /${extra_files} DESTINATION ${CMAKE_CURRENT_BINARY_DIR} )
158- endif ()
159174 add_test (${name} ${CMAKE_CURRENT_BINARY_DIR} /${name} )
160175 if (labels)
161176 set_tests_properties (${name} PROPERTIES LABELS "${labels} " )
@@ -281,12 +296,17 @@ macro(RUN_UTIL RUN_FAIL RUN_NAME RUN_FILE_NAME RUN_LABELS RUN_EXTRAFILES RUN_EXT
281296 set_tests_properties (${name} PROPERTIES WILL_FAIL TRUE )
282297 endif ()
283298 endif ()
299+
300+ if (copy_to_bin)
301+ file (COPY ${CMAKE_CURRENT_SOURCE_DIR} /${copy_to_bin} DESTINATION ${CMAKE_CURRENT_BINARY_DIR} )
302+ endif ()
303+
284304 endif ()
285305endmacro (RUN_UTIL )
286306
287307macro (RUN )
288308 set (options FAIL NOFAST ENABLE_CPYTHON LINK_NUMPY)
289- set (oneValueArgs NAME IMPORT_PATH)
309+ set (oneValueArgs NAME IMPORT_PATH COPY_TO_BIN )
290310 set (multiValueArgs LABELS EXTRAFILES)
291311 cmake_parse_arguments (RUN "${options} " "${oneValueArgs} "
292312 "${multiValueArgs} " ${ARGN} )
@@ -309,14 +329,14 @@ macro(RUN)
309329 endif ()
310330
311331 if (NOT FAST)
312- RUN_UTIL (RUN_FAIL RUN_NAME RUN_FILE_NAME RUN_LABELS RUN_EXTRAFILES RUN_EXTRA_ARGS )
332+ RUN_UTIL (RUN_FAIL RUN_NAME RUN_FILE_NAME RUN_LABELS RUN_EXTRAFILES RUN_EXTRA_ARGS RUN_COPY_TO_BIN )
313333 endif ()
314334
315335 if ((FAST) AND (NOT RUN_NOFAST))
316336 set (RUN_EXTRA_ARGS ${RUN_EXTRA_ARGS} --fast)
317337 set (RUN_NAME "${RUN_NAME} _FAST" )
318338 list (REMOVE_ITEM RUN_LABELS cpython cpython_sym) # remove cpython, cpython_sym, from --fast test
319- RUN_UTIL (RUN_FAIL RUN_NAME RUN_FILE_NAME RUN_LABELS RUN_EXTRAFILES RUN_EXTRA_ARGS )
339+ RUN_UTIL (RUN_FAIL RUN_NAME RUN_FILE_NAME RUN_LABELS RUN_EXTRAFILES RUN_EXTRA_ARGS RUN_COPY_TO_BIN )
320340 endif ()
321341endmacro (RUN )
322342
@@ -575,10 +595,11 @@ RUN(NAME bindc_05 LABELS llvm c
575595 EXTRAFILES bindc_05b.c )
576596RUN (NAME bindc_06 LABELS llvm c
577597 EXTRAFILES bindc_06b.c )
578- RUN (NAME bindpy_01 LABELS cpython c_py ENABLE_CPYTHON NOFAST EXTRAFILES bindpy_01_module.py )
579- RUN (NAME bindpy_02 LABELS cpython c_py LINK_NUMPY EXTRAFILES bindpy_02_module.py )
580- RUN (NAME bindpy_03 LABELS cpython c_py LINK_NUMPY NOFAST EXTRAFILES bindpy_03_module.py )
581- RUN (NAME bindpy_04 LABELS cpython c_py LINK_NUMPY NOFAST EXTRAFILES bindpy_04_module.py )
598+ RUN (NAME bindpy_01 LABELS cpython c_py ENABLE_CPYTHON NOFAST COPY_TO_BIN bindpy_01_module.py )
599+ RUN (NAME bindpy_02 LABELS cpython c_py LINK_NUMPY COPY_TO_BIN bindpy_02_module.py )
600+ RUN (NAME bindpy_03 LABELS cpython c_py LINK_NUMPY NOFAST COPY_TO_BIN bindpy_03_module.py )
601+ RUN (NAME bindpy_04 LABELS cpython c_py LINK_NUMPY NOFAST COPY_TO_BIN bindpy_04_module.py )
602+ RUN (NAME bindpy_05 LABELS llvm_py c_py ENABLE_CPYTHON COPY_TO_BIN bindpy_05_module.py )
582603RUN (NAME test_generics_01 LABELS cpython llvm c NOFAST )
583604RUN (NAME test_cmath LABELS cpython llvm c NOFAST )
584605RUN (NAME test_complex_01 LABELS cpython llvm c wasm wasm_x64 )
0 commit comments