Makefile: extract script to massage Perl scripts
Extract the script to inject various build-time parameters into our Perl scripts into a standalone script. This is done such that we can reuse it in other build systems. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
c2a3b847ed
commit
e4b488049a
@ -852,19 +852,41 @@ foreach(script ${git_shell_scripts})
|
||||
endforeach()
|
||||
|
||||
#perl scripts
|
||||
parse_makefile_for_scripts(git_perl_scripts "SCRIPT_PERL" ".perl")
|
||||
parse_makefile_for_scripts(git_perl_scripts "SCRIPT_PERL" "")
|
||||
|
||||
#create perl header
|
||||
file(STRINGS ${CMAKE_SOURCE_DIR}/perl/header_templates/fixed_prefix.template.pl perl_header )
|
||||
string(REPLACE "@PATHSEP@" ":" perl_header "${perl_header}")
|
||||
string(REPLACE "@INSTLIBDIR@" "${INSTLIBDIR}" perl_header "${perl_header}")
|
||||
file(WRITE ${CMAKE_BINARY_DIR}/PERL-HEADER ${perl_header})
|
||||
|
||||
add_custom_command(OUTPUT "${CMAKE_BINARY_DIR}/GIT-VERSION-FILE"
|
||||
COMMAND "${SH_EXE}" "${CMAKE_SOURCE_DIR}/GIT-VERSION-GEN"
|
||||
"${CMAKE_SOURCE_DIR}"
|
||||
"${CMAKE_SOURCE_DIR}/GIT-VERSION-FILE.in"
|
||||
"${CMAKE_BINARY_DIR}/GIT-VERSION-FILE"
|
||||
DEPENDS ${SH_EXE} "${CMAKE_SOURCE_DIR}/GIT-VERSION-GEN"
|
||||
"${CMAKE_SOURCE_DIR}/GIT-VERSION-FILE.in"
|
||||
VERBATIM)
|
||||
|
||||
foreach(script ${git_perl_scripts})
|
||||
file(STRINGS ${CMAKE_SOURCE_DIR}/${script}.perl content NEWLINE_CONSUME)
|
||||
string(REPLACE "#!/usr/bin/perl" "#!/usr/bin/perl\n${perl_header}\n" content "${content}")
|
||||
string(REPLACE "@GIT_VERSION@" "${PROJECT_VERSION}" content "${content}")
|
||||
file(WRITE ${CMAKE_BINARY_DIR}/${script} ${content})
|
||||
string(REPLACE ".perl" "" perl_gen_path "${script}")
|
||||
|
||||
add_custom_command(OUTPUT "${CMAKE_BINARY_DIR}/${perl_gen_path}"
|
||||
COMMAND "${SH_EXE}" "${CMAKE_SOURCE_DIR}/generate-perl.sh"
|
||||
"${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS"
|
||||
"${CMAKE_BINARY_DIR}/GIT-VERSION-FILE"
|
||||
"${CMAKE_BINARY_DIR}/PERL-HEADER"
|
||||
"${CMAKE_SOURCE_DIR}/${script}"
|
||||
"${CMAKE_BINARY_DIR}/${perl_gen_path}"
|
||||
DEPENDS "${CMAKE_SOURCE_DIR}/generate-perl.sh"
|
||||
"${CMAKE_SOURCE_DIR}/${script}"
|
||||
"${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS"
|
||||
"${CMAKE_BINARY_DIR}/GIT-VERSION-FILE"
|
||||
VERBATIM)
|
||||
list(APPEND perl_gen ${CMAKE_BINARY_DIR}/${perl_gen_path})
|
||||
endforeach()
|
||||
add_custom_target(perl-gen ALL DEPENDS ${perl_gen})
|
||||
|
||||
#python script
|
||||
file(STRINGS ${CMAKE_SOURCE_DIR}/git-p4.py content NEWLINE_CONSUME)
|
||||
|
Reference in New Issue
Block a user