From 8d7c97df868450dc39d376d2374a4c9dff4c842b Mon Sep 17 00:00:00 2001 From: midipix Date: Dec 19 2018 01:38:39 +0000 Subject: custom config: init python's version make vars based on patchlevel.h. --- diff --git a/config.project b/config.project index 82c54f7..f489c3b 100644 --- a/config.project +++ b/config.project @@ -1,12 +1,12 @@ # project -mb_package=python3.x +mb_package= mb_require_out_of_tree=no mb_custom_install_headers=no mb_avoid_version=no # pkgconfig -mb_pkgname='python3.x' -mb_pkgdesc='python3.x' +mb_pkgname= +mb_pkgdesc= mb_pkgusrc= mb_pkgrepo='git://midipix.org/sbpython3' mb_pkgpsrc= diff --git a/project/config/cfgdefs.in b/project/config/cfgdefs.in new file mode 100644 index 0000000..7a96696 --- /dev/null +++ b/project/config/cfgdefs.in @@ -0,0 +1,7 @@ +# project-specific configuration +PYTHON_VER = @python_ver@ +PYTHON_MAJOR = @python_major@ +PYTHON_MINOR = @python_minor@ +PYTHON_MICRO = @python_micro@ +PYTHON_SOABI = cpython-$(PYTHON_MAJOR)$(PYTHON_MINOR)-$(CCHOST) + 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