build: lua version: sanitize id before storage (no-op)

The lua version names which are autodetected/chosen (such as "51deb")
are used for two things:
- as key for storing the pkg-config compile/link flags.
- as ID for config.h and elsewhere - they're sanitized to use "_".

Due to some inconsistensies, if the sanitized ID is different than
the original name, then the compile/link flags are stored with the
original name as key, while the retrieval happens with the sanitized
ID - and therefore fails to find the correct flags.

The solution is to use the original name only for display purpose at
the output of configure, while using the sanitized version for
everything else, so that storage and retrieval use the same key.

Currently there's no issue and the patch has no effect, because the
sanitizer considers all the current names as valid IDs.

However, the next commit will add names which the sanitizer modifies,
such as "lua-5.1", so this commit makes such names work too.
This commit is contained in:
Avi Halachmi (:avih) 2021-09-25 21:21:13 +03:00 committed by avih
parent 5304e9fe31
commit 7c5cd5ef10
2 changed files with 5 additions and 3 deletions

View File

@ -75,13 +75,15 @@ def check_lua(ctx, dependency_identifier):
[lv for lv in lua_versions if lv[0] == ctx.options.LUA_VER]
for lua_version, pkgconfig_query in lua_versions:
display_version = lua_version
lua_version = inflector.sanitize_id(lua_version)
if check_pkg_config(pkgconfig_query, uselib_store=lua_version) \
(ctx, dependency_identifier):
# XXX: this is a bit of a hack, ask waf developers if I can copy
# the uselib_store to 'lua'
ctx.mark_satisfied(lua_version)
ctx.add_optional_message(dependency_identifier,
'version found: ' + lua_version)
'version found: ' + display_version)
return True
return False

View File

@ -1,6 +1,6 @@
import re
def _underscore(word):
def sanitize_id(word):
""" Converts a word "into_it_s_underscored_version"
Convert any "CamelCased" or "ordinary Word" into an
"underscored_word"."""
@ -10,7 +10,7 @@ def _underscore(word):
re.sub('([A-Z]+)([A-Z][a-z])', '\\1_\\2', re.sub('::', '/', word)))).lower()
def storage_key(dep):
return _underscore(dep)
return sanitize_id(dep)
def define_key(dep):
return ("have_" + storage_key(dep)).upper()