Generate xfer_desc.i with CMake code

This commit is contained in:
Brad King 2012-06-21 09:33:15 -04:00
parent bfc84d205b
commit 33f1fdacf9
3 changed files with 90 additions and 279 deletions

View File

@ -63,12 +63,14 @@ add_definitions(
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_DEBUG DEBUG)
set(gt_src_list)
set(gen_xfer_desc 0)
if("${CMAKE_SYSTEM_NAME}" MATCHES "Linux")
list(APPEND gt_src_list sr_linux)
if("${CMAKE_SIZEOF_VOID_P}" EQUAL 4)
list(APPEND gt_src_list sr_i386 sr_x86_regs sr_unix_nsb)
else()
list(APPEND gt_src_list sr_x86_64 sr_x86_regs)
set(gen_xfer_desc 1)
endif()
endif()
list(APPEND gt_src_list
@ -106,6 +108,7 @@ foreach(d ${gt_src_list})
${d}/*.c ${d}/*.s ${d}/*.si)
endforeach()
set(sources_used "")
macro(set_source_list target)
foreach(name ${ARGN})
set(src "")
@ -113,6 +116,7 @@ macro(set_source_list target)
if(";${sources_${d}};" MATCHES ";(${name}\\.(c|s|si));")
set(src ${d}/${CMAKE_MATCH_1})
set("source_used_${CMAKE_MATCH_1}" 1)
list(APPEND sources_used ${GTM_SOURCE_DIR}/${src})
break()
endif()
endforeach()
@ -164,19 +168,38 @@ set_source_list(semstat2 semstat2)
#-----------------------------------------------------------------------------
# libmumps gets leftover sources, so compute the remaining list.
set(source_used_dtgbldir.c 1) # exclude unused source
set(libmumps_SOURCES "")
foreach(d ${gt_src_list})
foreach(s ${sources_${d}})
if(NOT source_used_${s})
list(APPEND libmumps_SOURCES ${d}/${s})
set(source_used_${s} 1)
list(APPEND sources_used ${GTM_SOURCE_DIR}/${d}/${s})
endif()
endforeach()
endforeach()
# Remove unused sources.
list(REMOVE_ITEM libmumps_SOURCES
sr_unix/dtgbldir.c
)
if(gen_xfer_desc)
list(SORT sources_used)
set(CMAKE_CONFIGURABLE_FILE_CONTENT "")
foreach(src ${sources_used})
set(CMAKE_CONFIGURABLE_FILE_CONTENT "${CMAKE_CONFIGURABLE_FILE_CONTENT}${src}\n")
endforeach()
configure_file(${CMAKE_ROOT}/Modules/CMakeConfigurableFile.in ${GTM_BINARY_DIR}/sources.list)
add_custom_command(
OUTPUT xfer_desc.i
WORKING_DIRECTORY ${GTM_BINARY_DIR}
DEPENDS ${GTM_SOURCE_DIR}/sr_unix/gen_xfer_desc.cmake
${GTM_BINARY_DIR}/sources.list
COMMAND ${CMAKE_COMMAND}
-D CMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-D "includes=${includes}"
-P ${GTM_SOURCE_DIR}/sr_unix/gen_xfer_desc.cmake
VERBATIM
)
list(APPEND libmumps_SOURCES xfer_desc.i)
endif()
#-----------------------------------------------------------------------------

View File

@ -0,0 +1,63 @@
set(I "")
foreach(i ${includes})
list(APPEND I "-I${i}")
endforeach()
file(WRITE tmp_xfer_1.c "
/* We have not yet created gtm_threadgbl_deftypes.h and don't need it, signal gtm_threadgbl.h to avoid including it */
#define NO_THREADGBL_DEFTYPES
#include \"mdef.h\"
#define XFER(a,b) MY_XF,b
#include \"xfer.h\"
")
execute_process(
COMMAND ${CMAKE_C_COMPILER} ${I} -E tmp_xfer_1.c -o tmp_xfer_2.c
RESULT_VARIABLE failed
)
if(failed)
message(FATAL_ERROR "Preprocessing with ${CMAKE_C_COMPILER} failed")
endif()
file(STRINGS tmp_xfer_2.c lines REGEX "MY_XF")
string(REGEX REPLACE "(MY_XF|,)" "" names "${lines}")
file(REMOVE tmp_xfer_1.c tmp_xfer_2.c)
file(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/sources.list" sources)
set(ftypes "")
#set(defines "")
foreach(name ${names})
set(ftype "")
if(";${sources};" MATCHES ";([^;]*/${name}\\.s);")
set(ftype GTM_ASM_RTN)
elseif(";${sources};" MATCHES ";([^;]*/${name}\\.c);")
file(STRINGS "${CMAKE_MATCH_1}" sig REGEX "${name}.*\\.\\.\\.")
if(sig)
set(ftype "GTM_C_VAR_ARGS_RTN")
else()
set(ftype "GTM_C_RTN")
endif()
endif()
if(NOT ftype)
set(ftype GTM_C_VAR_ARGS_RTN)
foreach(src ${sources})
if("${src}" MATCHES "\\.s$")
file(STRINGS "${src}" sig REGEX "^${name}")
if(sig)
set(ftype GTM_ASM_RTN)
break()
endif()
endif()
endforeach()
endif()
set(ftypes "${ftypes}${ftype}, /* ${name} */ \\\n")
#set(defines "${defines}#define ${name}_FUNCTYPE ${ftype}\n") # TODO for ia64
endforeach()
file(WRITE xfer_desc.i "/* Generated by gen_xfer_desc.cmake */
#define GTM_C_RTN 1
#define GTM_ASM_RTN 2
#define GTM_C_VAR_ARGS_RTN 3
#define DEFINE_XFER_TABLE_DESC char xfer_table_desc[] = \\
{ \\
${ftypes}0}
\n")

View File

@ -1,275 +0,0 @@
/* Generated by gen_xfer_desc.csh */
#define GTM_C_RTN 1
#define GTM_ASM_RTN 2
#define GTM_C_VAR_ARGS_RTN 3
#define DEFINE_XFER_TABLE_DESC char xfer_table_desc[] = \
{ \
GTM_ASM_RTN, /* op_sto */ \
GTM_C_VAR_ARGS_RTN, /* op_cat */ \
GTM_ASM_RTN, /* op_linefetch */ \
GTM_ASM_RTN, /* op_linestart */ \
GTM_ASM_RTN, /* mval2bool */ \
GTM_C_VAR_ARGS_RTN, /* op_zbfetch */ \
GTM_C_VAR_ARGS_RTN, /* op_zbstart */ \
GTM_C_RTN, /* op_fnpiece */ \
GTM_ASM_RTN, /* op_equ */ \
GTM_C_RTN, /* op_write */ \
GTM_C_RTN, /* op_kill */ \
GTM_C_RTN, /* op_add */ \
GTM_C_VAR_ARGS_RTN, /* op_getindx */ \
GTM_C_VAR_ARGS_RTN, /* op_putindx */ \
GTM_C_VAR_ARGS_RTN, /* op_gvnaked */ \
GTM_ASM_RTN, /* opp_ret */ \
GTM_ASM_RTN, /* op_numcmp */ \
GTM_C_RTN, /* op_fnextract */ \
GTM_C_VAR_ARGS_RTN, /* op_gvname */ \
GTM_ASM_RTN, /* mval2mint */ \
GTM_ASM_RTN, /* op_contain */ \
GTM_C_RTN, /* op_wteol */ \
GTM_C_RTN, /* op_gvget */ \
GTM_C_VAR_ARGS_RTN, /* op_sub */ \
GTM_C_RTN, /* op_fndata */ \
GTM_C_VAR_ARGS_RTN, /* op_callw */ \
GTM_ASM_RTN, /* op_extcall */ \
GTM_ASM_RTN, /* op_forcenum */ \
GTM_C_VAR_ARGS_RTN, /* op_srchindx */ \
GTM_ASM_RTN, /* opp_newvar */ \
GTM_ASM_RTN, /* op_extjmp */ \
GTM_C_RTN, /* op_gvput */ \
GTM_C_RTN, /* op_gvdata */ \
GTM_C_RTN, /* op_fnlength */ \
GTM_C_RTN, /* op_svget */ \
GTM_ASM_RTN, /* opp_rterror */ \
GTM_ASM_RTN, /* opp_commarg */ \
GTM_C_RTN, /* op_gvnext */ \
GTM_C_RTN, /* op_wttab */ \
GTM_C_RTN, /* op_gvkill */ \
GTM_C_RTN, /* op_read */ \
GTM_ASM_RTN, /* op_neg */ \
GTM_ASM_RTN, /* op_follow */ \
GTM_C_RTN, /* op_wtone */ \
GTM_C_VAR_ARGS_RTN, /* op_callb */ \
GTM_ASM_RTN, /* mint2mval */ \
GTM_ASM_RTN, /* op_forinit */ \
GTM_ASM_RTN, /* op_forloop */ \
GTM_C_RTN, /* flt_mod */ \
GTM_C_RTN, /* op_fntext */ \
GTM_C_RTN, /* op_fnnext */ \
GTM_C_RTN, /* op_idiv */ \
GTM_C_RTN, /* op_fnj2 */ \
GTM_C_VAR_ARGS_RTN, /* op_fnchar */ \
GTM_C_RTN, /* op_fnfind */ \
GTM_ASM_RTN, /* opp_indset */ \
GTM_C_RTN, /* op_fnascii */ \
GTM_C_RTN, /* op_halt */ \
GTM_C_RTN, /* op_mul */ \
GTM_ASM_RTN, /* opp_indtext */ \
GTM_ASM_RTN, /* opp_indglvn */ \
GTM_C_RTN, /* op_killall */ \
GTM_C_RTN, /* op_use */ \
GTM_C_RTN, /* op_div */ \
GTM_C_RTN, /* op_fnj3 */ \
GTM_C_VAR_ARGS_RTN, /* op_forlcldol */ \
GTM_C_VAR_ARGS_RTN, /* op_forlcldow */ \
GTM_C_RTN, /* op_unlock */ \
GTM_C_RTN, /* op_wtff */ \
GTM_ASM_RTN, /* opp_break */ \
GTM_C_VAR_ARGS_RTN, /* op_calll */ \
GTM_C_RTN, /* op_close */ \
GTM_ASM_RTN, /* op_currtn */ \
GTM_C_RTN, /* op_lock */ \
GTM_C_VAR_ARGS_RTN, /* gtm_fetch */ \
GTM_C_RTN, /* op_fnfnumber */ \
GTM_ASM_RTN, /* op_fnget */ \
GTM_C_RTN, /* op_fngetdvi */ \
GTM_C_RTN, /* op_fngetjpi */ \
GTM_C_RTN, /* op_fngetsyi */ \
GTM_C_RTN, /* op_fngvget */ \
GTM_C_RTN, /* op_fnorder */ \
GTM_C_RTN, /* op_fnrandom */ \
GTM_C_RTN, /* op_fnzfile */ \
GTM_C_RTN, /* op_fnzm */ \
GTM_C_RTN, /* op_fnzparse */ \
GTM_C_RTN, /* op_fnzpid */ \
GTM_C_RTN, /* op_fnzpriv */ \
GTM_C_RTN, /* op_fnzsearch */ \
GTM_C_RTN, /* op_fnzsetprv */ \
GTM_ASM_RTN, /* op_gettruth */ \
GTM_C_RTN, /* op_zallocate */ \
GTM_C_RTN, /* op_gvorder */ \
GTM_C_RTN, /* op_hang */ \
GTM_ASM_RTN, /* opp_hardret */ \
GTM_ASM_RTN, /* opp_indfun */ \
GTM_ASM_RTN, /* opp_indlvadr */ \
GTM_C_VAR_ARGS_RTN, /* op_indname */ \
GTM_ASM_RTN, /* opp_indpat */ \
GTM_ASM_RTN, /* op_iretmvad */ \
GTM_ASM_RTN, /* opp_iretmval */ \
GTM_C_VAR_ARGS_RTN, /* op_job */ \
GTM_C_RTN, /* op_labaddr */ \
GTM_C_RTN, /* op_incrlock */ \
GTM_C_RTN, /* op_decrlock */ \
GTM_C_VAR_ARGS_RTN, /* op_lvpatwrite */ \
GTM_C_VAR_ARGS_RTN, /* op_lvzwrite */ \
GTM_C_RTN, /* op_open */ \
GTM_C_RTN, /* op_fnpopulation */ \
GTM_C_RTN, /* op_rdone */ \
GTM_C_RTN, /* op_readfl */ \
GTM_C_RTN, /* op_rhdaddr */ \
GTM_C_RTN, /* op_setpiece */ \
GTM_C_RTN, /* op_setzbrk */ \
GTM_C_RTN, /* op_svput */ \
GTM_C_VAR_ARGS_RTN, /* op_view */ \
GTM_ASM_RTN, /* opp_xnew */ \
GTM_ASM_RTN, /* opp_zcont */ \
GTM_ASM_RTN, /* opp_zgoto */ \
GTM_C_RTN, /* op_zlink */ \
GTM_C_VAR_ARGS_RTN, /* op_zmess */ \
GTM_C_RTN, /* op_zprint */ \
GTM_C_RTN, /* op_zshow */ \
GTM_C_RTN, /* op_zsystem */ \
GTM_C_RTN, /* op_gvsavtarg */ \
GTM_C_RTN, /* op_gvrectarg */ \
GTM_C_RTN, /* op_igetsrc */ \
GTM_C_RTN, /* op_fnzdate */ \
GTM_C_RTN, /* op_fntranslate */ \
GTM_C_VAR_ARGS_RTN, /* op_xkill */ \
GTM_C_RTN, /* op_lkinit */ \
GTM_C_RTN, /* op_zattach */ \
GTM_C_RTN, /* op_zedit */ \
GTM_ASM_RTN, /* op_restartpc */ \
GTM_C_VAR_ARGS_RTN, /* op_gvextnam */ \
GTM_C_RTN, /* op_fnzcall */ \
GTM_C_VAR_ARGS_RTN, /* op_fnview */ \
GTM_C_RTN, /* op_zdeallocate */ \
GTM_ASM_RTN, /* opp_indlvarg */ \
GTM_ASM_RTN, /* op_forchk1 */ \
GTM_C_RTN, /* op_cvtparm */ \
GTM_C_RTN, /* op_zprevious */ \
GTM_C_RTN, /* op_fnzprevious */ \
GTM_C_RTN, /* op_gvquery */ \
GTM_C_VAR_ARGS_RTN, /* op_fnquery */ \
GTM_C_VAR_ARGS_RTN, /* op_bindparm */ \
GTM_ASM_RTN, /* op_retarg */ \
GTM_ASM_RTN, /* op_exfun */ \
GTM_ASM_RTN, /* op_extexfun */ \
GTM_ASM_RTN, /* op_zhelp */ \
GTM_C_RTN, /* op_fnp1 */ \
GTM_ASM_RTN, /* opp_zg1 */ \
GTM_ASM_RTN, /* opp_newintrinsic */ \
GTM_C_RTN, /* op_gvzwithdraw */ \
GTM_C_RTN, /* op_lvzwithdraw */ \
GTM_ASM_RTN, /* op_pattern */ \
GTM_C_RTN, /* op_nullexp */ \
GTM_C_RTN, /* op_exfunret */ \
GTM_C_RTN, /* op_fnlvname */ \
GTM_C_VAR_ARGS_RTN, /* op_forlcldob */ \
GTM_ASM_RTN, /* opp_indrzshow */ \
GTM_C_VAR_ARGS_RTN, /* op_gvzwrite */ \
GTM_C_RTN, /* op_zstep */ \
GTM_ASM_RTN, /* mval2num */ \
GTM_C_VAR_ARGS_RTN, /* op_lkname */ \
GTM_C_RTN, /* op_fnztrnlnm */ \
GTM_C_RTN, /* op_ztcommit */ \
GTM_C_RTN, /* op_ztstart */ \
GTM_ASM_RTN, /* op_equnul */ \
GTM_C_RTN, /* op_fngetlki */ \
GTM_C_RTN, /* op_fnzlkid */ \
GTM_ASM_RTN, /* opp_indlvnamadr */ \
GTM_C_VAR_ARGS_RTN, /* op_callspb */ \
GTM_C_VAR_ARGS_RTN, /* op_callspw */ \
GTM_C_VAR_ARGS_RTN, /* op_callspl */ \
GTM_C_VAR_ARGS_RTN, /* op_iocontrol */ \
GTM_C_VAR_ARGS_RTN, /* op_fnfgncal */ \
GTM_C_RTN, /* op_zcompile */ \
GTM_ASM_RTN, /* opp_tcommit */ \
GTM_ASM_RTN, /* opp_trollback */ \
GTM_ASM_RTN, /* opp_trestart */ \
GTM_ASM_RTN, /* opp_tstart */ \
GTM_C_RTN, /* op_exp */ \
GTM_C_RTN, /* op_fnget2 */ \
GTM_ASM_RTN, /* opp_indget */ \
GTM_C_VAR_ARGS_RTN, /* op_fnname */ \
GTM_ASM_RTN, /* opp_indfnname */ \
GTM_C_RTN, /* op_fnlvprvname */ \
GTM_C_RTN, /* op_gvo2 */ \
GTM_C_RTN, /* op_fnlvnameo2 */ \
GTM_C_RTN, /* op_fno2 */ \
GTM_ASM_RTN, /* opp_indo2 */ \
GTM_C_RTN, /* op_get_msf */ \
GTM_C_RTN, /* op_dt_get */ \
GTM_C_RTN, /* op_dt_store */ \
GTM_C_RTN, /* op_dt_false */ \
GTM_C_RTN, /* op_dt_true */ \
GTM_C_RTN, /* op_fnzbitstr */ \
GTM_C_RTN, /* op_fnzbitlen */ \
GTM_C_RTN, /* op_fnzbitget */ \
GTM_C_RTN, /* op_fnzbitset */ \
GTM_C_RTN, /* op_fnzbitcoun */ \
GTM_C_RTN, /* op_fnzbitfind */ \
GTM_C_RTN, /* op_fnzbitnot */ \
GTM_C_RTN, /* op_fnzbitand */ \
GTM_C_RTN, /* op_fnzbitor */ \
GTM_C_RTN, /* op_fnzbitxor */ \
GTM_C_RTN, /* op_fgnlookup */ \
GTM_ASM_RTN, /* op_sorts_after */ \
GTM_C_RTN, /* op_fnzqgblmod */ \
GTM_C_RTN, /* op_fngvget1 */ \
GTM_C_RTN, /* op_fngvget2 */ \
GTM_C_RTN, /* op_setp1 */ \
GTM_C_RTN, /* op_setextract */ \
GTM_ASM_RTN, /* opp_inddevparms */ \
GTM_C_RTN, /* op_merge */ \
GTM_C_RTN, /* op_merge_arg */ \
GTM_ASM_RTN, /* opp_indmerge */ \
GTM_C_VAR_ARGS_RTN, /* op_m_srchindx */ \
GTM_C_RTN, /* op_fnstack1 */ \
GTM_C_RTN, /* op_fnstack2 */ \
GTM_C_RTN, /* op_fnqlength */ \
GTM_C_RTN, /* op_fnqsubscript */ \
GTM_C_RTN, /* op_fnreverse */ \
GTM_ASM_RTN, /* opp_svput */ \
GTM_C_RTN, /* op_fnzjobexam */ \
GTM_C_RTN, /* op_fnzsigproc */ \
GTM_C_RTN, /* op_fnincr */ \
GTM_C_RTN, /* op_gvincr */ \
GTM_ASM_RTN, /* opp_indincr */ \
GTM_C_RTN, /* op_setzextract */ \
GTM_C_RTN, /* op_setzp1 */ \
GTM_C_RTN, /* op_setzpiece */ \
GTM_C_VAR_ARGS_RTN, /* op_fnzascii */ \
GTM_C_VAR_ARGS_RTN, /* op_fnzchar */ \
GTM_ASM_RTN, /* op_fnzextract */ \
GTM_C_VAR_ARGS_RTN, /* op_fnzfind */ \
GTM_C_VAR_ARGS_RTN, /* op_fnzj2 */ \
GTM_C_VAR_ARGS_RTN, /* op_fnzlength */ \
GTM_C_RTN, /* op_fnzpopulation */ \
GTM_C_RTN, /* op_fnzpiece */ \
GTM_C_RTN, /* op_fnzp1 */ \
GTM_C_VAR_ARGS_RTN, /* op_fnztranslate */ \
GTM_C_VAR_ARGS_RTN, /* op_fnzconvert2 */ \
GTM_C_VAR_ARGS_RTN, /* op_fnzconvert3 */ \
GTM_C_RTN, /* op_fnzwidth */ \
GTM_C_RTN, /* op_fnzsubstr */ \
GTM_C_RTN, /* op_setals2als */ \
GTM_C_RTN, /* op_setalsin2alsct */ \
GTM_C_RTN, /* op_setalsctin2als */ \
GTM_C_RTN, /* op_setalsct2alsct */ \
GTM_C_RTN, /* op_killalias */ \
GTM_C_RTN, /* op_killaliasall */ \
GTM_C_RTN, /* op_fnzdata */ \
GTM_C_RTN, /* op_clralsvars */ \
GTM_C_RTN, /* op_fnzahandle */ \
GTM_C_RTN, /* op_fnztrigger */ \
GTM_C_RTN, /* op_exfunretals */ \
GTM_C_RTN, /* op_setfnretin2als */ \
GTM_C_RTN, /* op_setfnretin2alsct */ \
GTM_C_RTN, /* op_zwritesvn */ \
GTM_C_RTN, /* op_ztrigger */ \
GTM_C_VAR_ARGS_RTN, /* op_rfrshindx */ \
GTM_C_VAR_ARGS_RTN, /* op_savputindx */ \
GTM_C_RTN, /* op_forfreeindx */ \
GTM_C_RTN, /* op_fornestlvl */ \
GTM_C_RTN, /* op_zhalt */ \
0}