Commit 0b991206 authored by Nirbheek Chauhan's avatar Nirbheek Chauhan 🐜
Browse files

cerbero: Move env var type checks into utils

We will use this for the windows.config rewrite later.

Part-of: <gstreamer/cerbero!480>
parent 1fe036dd
......@@ -28,6 +28,7 @@ from cerbero import enums
from cerbero.errors import FatalError, ConfigurationError
from cerbero.utils import _, system_info, validate_packager, shell
from cerbero.utils import to_unixpath, to_winepath, parse_file, detect_qt5
from cerbero.utils import EnvVar
from cerbero.utils import messages as m
from cerbero.ide.vs.env import get_vs_year_version
......@@ -188,15 +189,6 @@ class Config (object):
c.target_arch = arch
return c
def _is_env_multipath_key(self, key):
return key in ('LD_LIBRARY_PATH', 'PATH', 'MANPATH', 'INFOPATH',
'PKG_CONFIG_PATH', 'PKG_CONFIG_LIBDIR', 'GI_TYPELIB_PATH',
'XDG_DATA_DIRS', 'XDG_CONFIG_DIRS', 'GST_PLUGIN_PATH',
'GST_PLUGIN_PATH_1_0', 'PYTHONPATH', 'MONO_PATH')
def _is_env_multivalue_key(self, key):
return key in ('CFLAGS', 'CXXFLAGS', 'LDFLAGS', 'OBJCFLAGS', 'OBJCXXFLAGS')
def can_use_msvc(self):
if self.variants.visualstudio and self.msvc_version is not None:
return True
......@@ -345,10 +337,12 @@ class Config (object):
old_v = old_env[k]
if new_v == old_v:
ret_env[k] = new_v
elif self._is_env_multipath_key(k):
elif EnvVar.is_path(k):
ret_env[k] = self._join_path(new_v, old_v)
elif self._is_env_multivalue_key(k):
elif EnvVar.is_arg(k):
ret_env[k] = self._join_values(new_v, old_v)
elif EnvVar.is_cmd(k):
ret_env[k] = new_v
else:
raise FatalError("Don't know how to combine the environment "
"variable '%s' with values '%s' and '%s'" % (k, new_v, old_v))
......
......@@ -659,3 +659,24 @@ async def run_tasks(tasks, done_async=None):
except Exception:
await shutdown()
raise
class EnvVar:
@staticmethod
def is_path(var):
return var in ('LD_LIBRARY_PATH', 'PATH', 'MANPATH', 'INFOPATH',
'PKG_CONFIG_PATH', 'PKG_CONFIG_LIBDIR', 'GI_TYPELIB_PATH',
'XDG_DATA_DIRS', 'XDG_CONFIG_DIRS', 'GST_PLUGIN_PATH',
'GST_PLUGIN_PATH_1_0', 'PYTHONPATH', 'MONO_PATH', 'LIB',
'INCLUDE', 'PATHEXT')
@staticmethod
def is_arg(var):
return var in ('CFLAGS', 'CPPFLAGS', 'CXXFLAGS', 'LDFLAGS',
'OBJCFLAGS', 'OBJCXXFLAGS', 'CCASFLAGS')
@staticmethod
def is_cmd(var):
return var in ('AR', 'AS', 'CC', 'CPP', 'CXX', 'DLLTOOL', 'GENDEF',
'LD', 'NM', 'OBJC', 'OBJCOPY', 'OBJCXX', 'PERL', 'PYTHON',
'RANLIB', 'RC', 'STRIP', 'WIDNRES')
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment