diff options
author | midipix <writeonce@midipix.org> | 2018-12-15 17:22:58 -0500 |
---|---|---|
committer | midipix <writeonce@midipix.org> | 2018-12-18 20:38:39 -0500 |
commit | 8d7c97df868450dc39d376d2374a4c9dff4c842b (patch) | |
tree | 9adcdc02ddf73dcba53fc3d34a36192de72099af | |
parent | 80140a5721a2439d2eb8758b730124697d022d8c (diff) | |
download | sbpython3-8d7c97df868450dc39d376d2374a4c9dff4c842b.tar.bz2 sbpython3-8d7c97df868450dc39d376d2374a4c9dff4c842b.tar.xz |
custom config: init python's version make vars based on patchlevel.h.
-rw-r--r-- | config.project | 6 | ||||
-rw-r--r-- | project/config/cfgdefs.in | 7 | ||||
-rw-r--r-- | project/config/cfgdefs.sh | 47 |
3 files changed, 57 insertions, 3 deletions
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 |