# Sanity checks
foreach(varname INPUT_DEF_FILE OUTPUT_DEF_FILE)
  if(NOT DEFINED ${varname})
    message(FATAL_ERROR "Variable '${varname}' is not defined.")
  endif()
endforeach()

file(STRINGS ${INPUT_DEF_FILE} def_lines REGEX "^  (.+)=.+$")
set(stub_def_lines "EXPORTS")
foreach(line IN LISTS def_lines)
  string(REGEX REPLACE "^  (.+)=.+$" "${CMAKE_MATCH_1}" updated_line ${line})
  set(stub_def_lines "${stub_def_lines}${updated_line}\n")
endforeach()
file(WRITE ${OUTPUT_DEF_FILE} "${stub_def_lines}")

# Sanity checks
foreach(varname INPUT_DEF_FILE OUTPUT_DEF_FILE)
  if(NOT DEFINED ${varname})
    message(FATAL_ERROR "Variable '${varname}' is not defined.")
  endif()
endforeach()

file(STRINGS ${INPUT_DEF_FILE} def_lines REGEX "^  (.+)=.+$")
set(stub_def_lines "EXPORTS\n")
foreach(line IN LISTS def_lines)
  string(REGEX MATCH "^  (.+)=.+$" output ${line})
  if(NOT "${output}" STREQUAL "")
    set(stub_def_lines "${stub_def_lines}${CMAKE_MATCH_1}\n")
  endif()
endforeach()
file(WRITE ${OUTPUT_DEF_FILE} "${stub_def_lines}")

Fix link error by improving generation of python3stub.def
python3: Fix link error by improving generation of python3stub.def

This commit fixes regression originally introduced in b774ba7 (python3: Build
"python3dll" and fix msvc "xxlimited" link issue.)

The previous implementation of the "generate_libpythonstub_def" module
was omitting the last line of "python3.def". This was causing the following
link error:

Severity	Code	Description	Project	File	Line	Suppression State
Error	LNK2001	unresolved external symbol _Py_VaBuildValue_SizeT	libpython3-shared	D:\T\python-cmake-buildsystem-build\CMakeBuild\libpython\python3.def	1
