From 8d7c97df868450dc39d376d2374a4c9dff4c842b Mon Sep 17 00:00:00 2001 From: midipix Date: Sat, 15 Dec 2018 17:22:58 -0500 Subject: custom config: init python's version make vars based on patchlevel.h. --- project/config/cfgdefs.sh | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) (limited to 'project/config/cfgdefs.sh') diff --git a/project/config/cfgdefs.sh b/project/config/cfgdefs.sh index 054e536..ad5e9eb 100644 --- a/project/config/cfgdefs.sh +++ b/project/config/cfgdefs.sh @@ -35,6 +35,47 @@ cfgdefs_set_cfghost_flavors() } +cfgdefs_detect_python_version() +{ + mb_internal_verinfo=$(mktemp) + + if [ -z "$mb_internal_verinfo" ]; then + exit 2 + fi + + "$mb_native_cc" -E -dM "$mb_source_dir/Include/patchlevel.h" \ + > "$mb_internal_verinfo" + + python_major=$(grep '#define PY_MAJOR_VERSION ' "$mb_internal_verinfo" | cut -d' ' -f3) + python_minor=$(grep '#define PY_MINOR_VERSION ' "$mb_internal_verinfo" | cut -d' ' -f3) + python_micro=$(grep '#define PY_MICRO_VERSION ' "$mb_internal_verinfo" | cut -d' ' -f3) + + if [ -z "$python_major" ] || [ -z "$python_minor" ] || [ -z "$python_micro" ]; then + error_msg "Could not properly parse Python's patchlevel.h" + exit 2 + fi + + python_ver="$python_major.$python_minor" + + [ -z "$mb_package" ] && mb_package='python'"$python_ver" + [ -z "$mb_nickname" ] && mb_nickname="$mb_package" + [ -z "$mb_pkgname" ] && mb_pkgname="$mb_package" + [ -z "$mb_pkgdesc" ] && mb_pkgdesc="$mb_package" +} + + +cfgdefs_output_custom_defs() +{ + sed \ + -e 's/@python_ver@/'"$python_ver"'/g' \ + -e 's/@python_major@/'"$python_major"'/g' \ + -e 's/@python_minor@/'"$python_minor"'/g' \ + -e 's/@python_micro@/'"$python_micro"'/g' \ + "$mb_project_dir/project/config/cfgdefs.in" \ + >> "$mb_pwd/cfgdefs.mk" +} + + cfgdefs_perform_target_tests() { # init @@ -141,6 +182,12 @@ cfgdefs_perform_native_tests() # cfghost cfgdefs_set_cfghost_flavors +# python version info +cfgdefs_detect_python_version + +# cfgdefs.in --> cfgdefs.mk +cfgdefs_output_custom_defs + # target-specific tests cfgdefs_perform_target_tests -- cgit v1.2.3