cengal.build_tools.prepare_cflags.versions.v_0.prepare_cflags

  1#!/usr/bin/env python
  2# coding=utf-8
  3
  4# Copyright © 2012-2024 ButenkoMS. All rights reserved. Contacts: <gtalk@butenkoms.space>
  5# 
  6# Licensed under the Apache License, Version 2.0 (the "License");
  7# you may not use this file except in compliance with the License.
  8# You may obtain a copy of the License at
  9# 
 10#     http://www.apache.org/licenses/LICENSE-2.0
 11# 
 12# Unless required by applicable law or agreed to in writing, software
 13# distributed under the License is distributed on an "AS IS" BASIS,
 14# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 15# See the License for the specific language governing permissions and
 16# limitations under the License.
 17
 18
 19__all__ = [
 20    'append_cflags', 
 21    'concat_cflags', 
 22    'wrap_definition_text', 
 23    'wrap_definition_text_raw', 
 24    'prepare_definition_value', 
 25    'prepare_definition_value_raw', 
 26    'convert_value_to_flag', 
 27    'convert_value_to_text', 
 28    'prepare_definition', 
 29    'list_to_dict', 
 30    'dict_of_tuples_to_dict', 
 31    'adjust_definition_names', 
 32    'prepare_cflags', 
 33    'prepare_given_cflags', 
 34    'prepare_cflags_dict', 
 35    'prepare_given_cflags_dict', 
 36    'prepare_pyx_flags_dict', 
 37    'prepare_compile_time_env', 
 38    'prepare_compile_time_flags',
 39    ]
 40
 41
 42"""
 43Module Docstring
 44Docstrings: http://www.python.org/dev/peps/pep-0257/
 45"""
 46
 47__author__ = "ButenkoMS <gtalk@butenkoms.space>"
 48__copyright__ = "Copyright © 2012-2024 ButenkoMS. All rights reserved. Contacts: <gtalk@butenkoms.space>"
 49__credits__ = ["ButenkoMS <gtalk@butenkoms.space>", ]
 50__license__ = "Apache License, Version 2.0"
 51__version__ = "4.4.1"
 52__maintainer__ = "ButenkoMS <gtalk@butenkoms.space>"
 53__email__ = "gtalk@butenkoms.space"
 54# __status__ = "Prototype"
 55__status__ = "Development"
 56# __status__ = "Production"
 57
 58
 59from typing import Dict, Any, Tuple, Union
 60from os import environ
 61try:
 62    from os import uname
 63    uname_sysname: str = uname().sysname
 64    uname_machine: str = uname().machine
 65except ImportError:
 66    from platform import uname
 67    uname_sysname: str = uname().system
 68    uname_machine: str = uname().machine
 69
 70from cengal.hardware.info.cpu import cpu_info
 71from cengal.os.execute import escape_text, escape_param
 72from cengal.build_tools.current_compiler import compiler_type, compiler_name, compiler_string
 73from cengal.system import (
 74    PYTHON_IMPLEMENTATION,
 75    PYTHON_VERSION,
 76    PYTHON_VERSION_STR,
 77    PYTHON_VERSION_INT,
 78    IS_RUNNING_IN_PYCHARM,
 79    RAW_OS_PLATFORM,
 80    OS_API_TYPE,
 81    OS_TYPE,
 82    KIVY_PLATFORM,
 83    KIVY_TARGET_PLATFORM,
 84    IS_RUNNING_IN_EMSCRIPTEN,
 85    IS_RUNNING_IN_WASI,
 86    IS_RUNNING_IN_PYODIDE,
 87    IS_BUILDING_FOR_PYODIDE,
 88    IS_INSIDE_OR_FOR_WEB_BROWSER,
 89    CENGAL_VERSION_STR,
 90    CENGAL_VERSION_MAJOR_STR,
 91    CENGAL_VERSION_MINOR_STR,
 92    CENGAL_VERSION_MICRO_STR,
 93    CENGAL_VERSION_MAJOR,
 94    CENGAL_VERSION_MINOR,
 95    CENGAL_VERSION_MICRO,
 96)
 97from typing import Set, Sequence, Optional, Sequence, List
 98
 99
100def append_cflags(cflags_list: list):
101    if 'msvc' == compiler_type:
102        compiler_flags_env_var_name = 'CL'
103    else:
104        compiler_flags_env_var_name = 'CFLAGS'
105
106    environ[compiler_flags_env_var_name] = ' '.join((environ.get(compiler_flags_env_var_name, str()), " ".join(cflags_list)))
107
108
109def concat_cflags(cflags: str):
110    if 'msvc' == compiler_type:
111        compiler_flags_env_var_name = 'CL'
112    else:
113        compiler_flags_env_var_name = 'CFLAGS'
114
115    environ[compiler_flags_env_var_name] = ' '.join((environ.get(compiler_flags_env_var_name, str()), cflags))
116
117
118def wrap_definition_text(text: str) -> str:
119    if 'msvc' == compiler_type:
120        return escape_param(f'\\"{text}\\"')
121    else:
122        return f'\\"{escape_param(text)}\\"'
123
124
125def wrap_definition_text_raw(text: str) -> str:
126    return f'"{text}"'
127
128
129def wrap_pyx_definition_text_raw(text: str) -> str:
130    return f'{text}'
131
132
133def prepare_definition_value(value: Union[None, bool, int, str]) -> str:
134    if isinstance(value, bool):
135        value = str(value)
136    
137    if value is None:
138        return None
139    elif isinstance(value, int):
140        return value
141    elif isinstance(value, str):
142        return wrap_definition_text(value)
143    else:
144        return wrap_definition_text(f'{value}')
145
146
147def prepare_definition_value_raw(value: Union[None, bool, int, str]) -> str:
148    if isinstance(value, bool):
149        value = str(value)
150    
151    if value is None:
152        return None
153    elif isinstance(value, int):
154        return value
155    elif isinstance(value, str):
156        return wrap_definition_text_raw(value)
157    else:
158        return wrap_definition_text_raw(f'{value}')
159
160
161def prepare_pyx_definition_value_raw(value: Union[None, bool, int, str]) -> str:
162    if isinstance(value, bool):
163        value = str(value)
164    
165    if value is None:
166        return None
167    elif isinstance(value, int):
168        return value
169    elif isinstance(value, str):
170        return wrap_pyx_definition_text_raw(value)
171    else:
172        return wrap_pyx_definition_text_raw(f'{value}')
173
174
175def wrap_definition_pair(name: str, value: Any) -> str:
176    if 'msvc' == compiler_type:
177        return f'/D{name}={value}' if value is not None else f'/D{name}'
178    else:
179        return f'-D{name}={value}' if value is not None else f'-D{name}'
180
181
182def convert_value_to_flag(value: Union[None, bool, int, str]) -> int:
183    if value is None:
184        return None
185    
186    try:
187        return int(value)
188    except:
189        return 1
190
191
192def convert_value_to_text(value: Union[None, bool, int, str]) -> str:
193    return f'{value}'
194
195
196def prepare_definition(name: str, value: Optional[Union[bool, int, str]] = None) -> str:
197    return wrap_definition_pair(name, prepare_definition_value(value))
198
199
200def list_to_dict(additional_cflags: Optional[Sequence[str]] = None) -> Dict[str, Union[None, bool, int, str]]:
201    additional_cflags = dict() if additional_cflags is None else additional_cflags
202    if not isinstance(additional_cflags, dict):
203        additional_cflags = {name: None for name in additional_cflags}
204    
205    return additional_cflags
206
207
208def dict_of_tuples_to_dict(additional_cflags: Optional[Dict[str, Tuple[bool, Union[None, bool, str, int]]]] = None) -> Dict[str, Union[None, bool, int, str]]:
209    additional_cflags = dict() if additional_cflags is None else additional_cflags
210    adjusted_additional_cflags: Dict[str, Union[None, bool, int, str]] = dict()
211    for name, value_info in additional_cflags.items():
212        if isinstance(value_info, tuple):
213            is_flag, value = value_info
214            value = convert_value_to_flag(value) if is_flag else convert_value_to_text(value)
215        else:
216            value = value_info
217        
218        adjusted_additional_cflags[name] = value
219    
220    return adjusted_additional_cflags
221
222
223def adjust_definition_names(definitions: Dict[str, Union[None, bool, int, str]], flag_name_prefix: str = None, definition_name_prefix: str = None) -> Dict[str, Union[None, bool, int, str]]:
224    flag_name_prefix = str() if flag_name_prefix is None else flag_name_prefix
225    definition_name_prefix = str() if definition_name_prefix is None else definition_name_prefix
226    adjusted_definitions: Dict[str, Union[None, bool, int, str]] = dict()
227    for name, value in definitions.items():
228        if value is None:
229            name = f'{flag_name_prefix}{name}'
230        else:
231            name = f'{definition_name_prefix}{name}'
232        
233        adjusted_definitions[name] = value
234    
235    return adjusted_definitions
236
237
238def prepare_cflags(additional_cflags: Optional[Union[Sequence[str], Dict[str, Union[Union[None, bool, int, str], Tuple[bool, Union[None, bool, str, int]]]]]] = None) -> List[Union[None, int, str]]:
239    adjusted_additional_cflags: Dict[str, Union[None, bool, int, str]] = dict_of_tuples_to_dict(list_to_dict(additional_cflags))
240    flags: Dict[str, None] = adjust_definition_names(list_to_dict(prepare_compile_time_flags()), 'CF_', 'CD_')  # CF is Cengal Flag; CD is Cengal Definition
241    definitions: Dict[str, Union[None, bool, int, str]] = adjust_definition_names(prepare_compile_time_env(), 'CF_', 'CD_')  # CF is Cengal Flag; CD is Cengal Definition
242    definitions.update(flags)
243    definitions.update(adjusted_additional_cflags)
244    params: List[Union[None, int, str]] = [prepare_definition(name, value) for name, value in definitions.items()]
245    
246    # from pprint import pprint
247    # print('<<< PREPARE_CFLAGS: >>>')
248    # pprint(params)
249    append_cflags(params)
250    return params
251
252
253def prepare_given_cflags(additional_cflags: Optional[Union[Sequence[str], Dict[str, Union[Union[None, bool, int, str], Tuple[bool, Union[None, bool, str, int]]]]]] = None) -> List[Union[None, int, str]]:
254    adjusted_additional_cflags: Dict[str, Union[None, bool, int, str]] = dict_of_tuples_to_dict(list_to_dict(additional_cflags))
255    params: List[Union[None, int, str]] = [prepare_definition(name, value) for name, value in adjusted_additional_cflags.items()]
256    
257    # from pprint import pprint
258    # print('<<< PREPARE_CFLAGS: >>>')
259    # pprint(params)
260    append_cflags(params)
261    return params
262
263
264def prepare_cflags_dict(additional_cflags: Optional[Union[Sequence[str], Dict[str, Union[Union[None, bool, int, str], Tuple[bool, Union[None, bool, str, int]]]]]] = None) -> Dict[str, Union[None, bool, int, str]]:
265    adjusted_additional_cflags: Dict[str, Union[None, bool, int, str]] = dict_of_tuples_to_dict(list_to_dict(additional_cflags))
266    flags: Dict[str, None] = adjust_definition_names(list_to_dict(prepare_compile_time_flags()), 'CF_', 'CD_')  # CF is Cengal Flag; CD is Cengal Definition
267    definitions: Dict[str, Union[None, bool, int, str]] = adjust_definition_names(prepare_compile_time_env(), 'CF_', 'CD_')  # CF is Cengal Flag; CD is Cengal Definition
268    definitions.update(flags)
269    definitions.update(adjusted_additional_cflags)
270    result: Dict[str, Union[None, bool, int, str]] = {name: prepare_definition_value_raw(value) for name, value in definitions.items()}
271    
272    # from pprint import pprint
273    # print('<<< PREPARE_CFLAGS_DICT: >>>')
274    # pprint(result)
275    return result
276
277
278def prepare_given_cflags_dict(additional_cflags: Optional[Union[Sequence[str], Dict[str, Union[Union[None, bool, int, str], Tuple[bool, Union[None, bool, str, int]]]]]] = None) -> Dict[str, Union[None, bool, int, str]]:
279    adjusted_additional_cflags: Dict[str, Union[None, bool, int, str]] = dict_of_tuples_to_dict(list_to_dict(additional_cflags))
280    result: Dict[str, Union[None, bool, int, str]] = {name: prepare_definition_value_raw(value) for name, value in adjusted_additional_cflags.items()}
281    
282    # from pprint import pprint
283    # print('<<< PREPARE_CFLAGS_DICT: >>>')
284    # pprint(result)
285    return result
286
287
288def prepare_pyx_flags_dict(additional_pyx_flags: Optional[Union[Sequence[str], Dict[str, Union[Union[None, bool, int, str], Tuple[bool, Union[None, bool, str, int]]]]]] = None) -> Dict[str, Union[None, bool, int, str]]:
289    adjusted_additional_cflags: Dict[str, Union[None, bool, int, str]] = dict_of_tuples_to_dict(list_to_dict(additional_pyx_flags))
290    flags: Dict[str, None] = adjust_definition_names(list_to_dict(prepare_compile_time_flags()), 'PYXF_', 'PYXD_')  # PYXF is Cython Flag; PYXD is Cython Definition
291    definitions: Dict[str, Union[None, bool, int, str]] = adjust_definition_names(prepare_compile_time_env(), 'PYXF_', 'PYXD_')  # PYXF is Cython Flag; PYXD is Cython Definition
292    definitions.update(flags)
293    definitions.update(adjusted_additional_cflags)
294    result: Dict[str, Union[None, bool, int, str]] = {name: prepare_pyx_definition_value_raw(value) for name, value in definitions.items()}
295    
296    # from pprint import pprint
297    # print('<<< PREPARE_CFLAGS_DICT: >>>')
298    # pprint(result)
299    return result
300
301
302def prepare_compile_time_env(additional_cflags: Optional[Union[Sequence[str], Dict[str, Union[Union[None, bool, int, str], Tuple[bool, Union[None, bool, str, int]]]]]] = None):
303    result = {
304        'UNAME_SYSNAME': uname_sysname,  # see: https://en.wikipedia.org/wiki/Uname
305        'UNAME_MACHINE': uname_machine,  # see: https://en.wikipedia.org/wiki/Uname
306        'CPU_ARCH': cpu_info().arch,  # 'X86_32', 'X86_64', 'ARM_8', 'ARM_7', 'PPC_32', 'PPC_64', 'SPARC_32', 'SPARC_64', 'S390X', 'MIPS_32', 'MIPS_64', 'RISCV_32', 'RISCV_64'
307        'CPU_ARCH_RAW_STRING': cpu_info().arch_string_raw,
308        'CPU_BITS': cpu_info().bits,  # '32', '64'
309        'IS_X86_BOOL': cpu_info().is_x86,  # 'True', 'False'
310        'IS_ARM_BOOL': cpu_info().is_arm,  # 'True', 'False'
311        'IS_X86': int(cpu_info().is_x86),  # '1', '0'
312        'IS_ARM': int(cpu_info().is_arm),  # '1', '0'
313        'COMPILER_TYPE': compiler_type,  # 'gcc', 'msvc', 'clang', 'icc', 'llvm', 'intel', 'arm', 'mingw', 'unknown'
314        'COMPILER_NAME': compiler_name,  # 'x86_64-linux-gnu-gcc'
315        'COMPILER_STRING': compiler_string,  # 'x86_64-linux-gnu-gcc -pthread'
316        'PYTHON_IMPLEMENTATION': PYTHON_IMPLEMENTATION,  # 'CPython', 'PyPy', 'IronPython', 'Jython'
317        'PYTHON_VERSION_STR': PYTHON_VERSION_STR,  # '3.5.1', ...
318        'PYTHON_VERSION_MAJOR_STR': str(PYTHON_VERSION_INT.major),  # '3', ...
319        'PYTHON_VERSION_MINOR_STR': str(PYTHON_VERSION_INT.minor),  # '5', ...
320        'PYTHON_VERSION_MICRO_STR': str(PYTHON_VERSION_INT.micro),  # '1', ...
321        'PYTHON_VERSION_MAJOR': PYTHON_VERSION_INT.major,  # '3', ...
322        'PYTHON_VERSION_MINOR': PYTHON_VERSION_INT.minor,  # '5', ...
323        'PYTHON_VERSION_MICRO': PYTHON_VERSION_INT.micro,  # '1', ...
324        'IS_RUNNING_IN_PYCHARM_BOOL': IS_RUNNING_IN_PYCHARM,  # 'True', 'False'
325        'IS_RUNNING_IN_PYCHARM': int(IS_RUNNING_IN_PYCHARM),  # '1', '0'
326        'RAW_OS_PLATFORM': RAW_OS_PLATFORM,  # 'emscripten', 'wasi', 'darwin', 'win32', 'cygwin', 'linux', 'linux2', 'linux3', 'darwin', 'freebsd8', 'aix', aix5', 'aix7', ...
327        'OS_API_TYPE': OS_API_TYPE,  # 'posix', 'nt', 'java'. Android and iOS will return 'posix'.
328        'OS_TYPE': OS_TYPE,  # 'Linux', 'Windows', 'Darwin'
329        'KIVY_PLATFORM': KIVY_PLATFORM, # 'win', 'linux', 'android', 'macosx', 'ios', 'unknown'
330        'KIVY_TARGET_PLATFORM': KIVY_TARGET_PLATFORM, # 'win', 'linux', 'android', 'macosx', 'ios', 'unknown'
331        'IS_RUNNING_IN_EMSCRIPTEN_BOOL': IS_RUNNING_IN_EMSCRIPTEN,  # 'True', 'False'
332        'IS_RUNNING_IN_WASI_BOOL': IS_RUNNING_IN_WASI,  # 'True', 'False'
333        'IS_RUNNING_IN_PYODIDE_BOOL': IS_RUNNING_IN_PYODIDE,  # 'True', 'False'
334        'IS_BUILDING_FOR_PYODIDE_BOOL': IS_BUILDING_FOR_PYODIDE,  # 'True', 'False'
335        'IS_INSIDE_OR_FOR_WEB_BROWSER_BOOL': IS_INSIDE_OR_FOR_WEB_BROWSER,  # 'True', 'False'
336        'IS_RUNNING_IN_EMSCRIPTEN': int(IS_RUNNING_IN_EMSCRIPTEN),  # '1', '0'
337        'IS_RUNNING_IN_WASI': int(IS_RUNNING_IN_WASI),  # '1', '0'
338        'IS_RUNNING_IN_PYODIDE': int(IS_RUNNING_IN_PYODIDE),  # '1', '0'
339        'IS_BUILDING_FOR_PYODIDE': int(IS_BUILDING_FOR_PYODIDE),  # '1', '0'
340        'IS_INSIDE_OR_FOR_WEB_BROWSER': int(IS_INSIDE_OR_FOR_WEB_BROWSER),  # '1', '0'
341        'CENGAL_VERSION_STR': CENGAL_VERSION_STR,
342        'CENGAL_VERSION_MAJOR_STR': CENGAL_VERSION_MAJOR_STR,
343        'CENGAL_VERSION_MINOR_STR': CENGAL_VERSION_MINOR_STR,
344        'CENGAL_VERSION_MICRO_STR': CENGAL_VERSION_MICRO_STR,
345        'CENGAL_VERSION_MAJOR': CENGAL_VERSION_MAJOR,
346        'CENGAL_VERSION_MINOR': CENGAL_VERSION_MINOR,
347        'CENGAL_VERSION_MICRO': CENGAL_VERSION_MICRO,
348    }
349    result.update(dict_of_tuples_to_dict(list_to_dict(additional_cflags)))
350    return result
351
352
353def prepare_compile_time_flags(additional_cflags: Sequence[str] = None):
354    additional_cflags = [] if additional_cflags is None else additional_cflags
355    macro_flags_list: Set = set()
356
357    if 32 == cpu_info().bits:
358        macro_flags_list.add('32_bit_CPU')
359    
360    if 64 == cpu_info().bits:
361        macro_flags_list.add('64_bit_CPU')
362
363    if cpu_info().is_x86:
364        macro_flags_list.add('IS_X86')
365    
366    if cpu_info().is_arm:
367        macro_flags_list.add('IS_ARM')
368
369    if 'X86_32' == cpu_info().arch:
370        macro_flags_list.add('X86_32')
371    elif 'X86_64' == cpu_info().arch:
372        macro_flags_list.add('X86_64')
373    elif 'ARM_8' == cpu_info().arch:
374        macro_flags_list.add('ARM_8')
375    elif 'ARM_7' == cpu_info().arch:
376        macro_flags_list.add('ARM_7')
377    elif 'PPC_32' == cpu_info().arch:
378        macro_flags_list.add('PPC_32')
379    elif 'PPC_64' == cpu_info().arch:
380        macro_flags_list.add('PPC_64')
381    elif 'SPARC_32' == cpu_info().arch:
382        macro_flags_list.add('SPARC_32')
383    elif 'SPARC_64' == cpu_info().arch:
384        macro_flags_list.add('SPARC_64')
385    elif 'S390X' == cpu_info().arch:
386        macro_flags_list.add('S390X')
387    elif 'MIPS_32' == cpu_info().arch:
388        macro_flags_list.add('MIPS_32')
389    elif 'MIPS_64' == cpu_info().arch:
390        macro_flags_list.add('MIPS_64')
391    elif 'RISCV_32' == cpu_info().arch:
392        macro_flags_list.add('RISCV_32')
393    elif 'RISCV_64' == cpu_info().arch:
394        macro_flags_list.add('RISCV_64')
395    
396    if 'CPython' == PYTHON_IMPLEMENTATION:
397        macro_flags_list.add('CPython')
398    elif 'PyPy' == PYTHON_IMPLEMENTATION:
399        macro_flags_list.add('PyPy')
400    elif 'IronPython' == PYTHON_IMPLEMENTATION:
401        macro_flags_list.add('IronPython')
402    elif 'Jython' == PYTHON_IMPLEMENTATION:
403        macro_flags_list.add('Jython')
404    
405    if 'gcc' == compiler_type:
406        macro_flags_list.add('gcc')
407    elif 'msvc' == compiler_type:
408        macro_flags_list.add('msvc')
409    elif 'clang' == compiler_type:
410        macro_flags_list.add('clang')
411    elif 'icc' == compiler_type:
412        macro_flags_list.add('icc')
413    elif 'llvm' == compiler_type:
414        macro_flags_list.add('llvm')
415    elif 'intel' == compiler_type:
416        macro_flags_list.add('intel')
417    elif 'arm' == compiler_type:
418        macro_flags_list.add('arm')
419    elif 'mingw' == compiler_type:
420        macro_flags_list.add('mingw')
421    elif 'unknown' == compiler_type:
422        macro_flags_list.add('unknown_compiler')
423    
424    if 'Linux' == OS_TYPE:
425        macro_flags_list.add('Linux')
426    elif 'Windows' == OS_TYPE:
427        macro_flags_list.add('Windows')
428    elif 'Darwin' == OS_TYPE:
429        macro_flags_list.add('Darwin')
430    elif 'Java' == OS_TYPE:
431        macro_flags_list.add('Java')
432    
433    if 'win' == KIVY_PLATFORM:
434        macro_flags_list.add('KIVY_PLATFORM_win')
435    elif 'linux' == KIVY_PLATFORM:
436        macro_flags_list.add('KIVY_PLATFORM_linux')
437    elif 'android' == KIVY_PLATFORM:
438        macro_flags_list.add('KIVY_PLATFORM_android')
439    elif 'macosx' == KIVY_PLATFORM:
440        macro_flags_list.add('KIVY_PLATFORM_macosx')
441    elif 'ios' == KIVY_PLATFORM:
442        macro_flags_list.add('KIVY_PLATFORM_ios')
443    elif 'unknown' == KIVY_PLATFORM:
444        macro_flags_list.add('KIVY_PLATFORM_unknown')
445    
446    if 'win' == KIVY_TARGET_PLATFORM:
447        macro_flags_list.add('KIVY_TARGET_PLATFORM_win')
448    elif 'linux' == KIVY_TARGET_PLATFORM:
449        macro_flags_list.add('KIVY_TARGET_PLATFORM_linux')
450    elif 'android' == KIVY_TARGET_PLATFORM:
451        macro_flags_list.add('KIVY_TARGET_PLATFORM_android')
452    elif 'macosx' == KIVY_TARGET_PLATFORM:
453        macro_flags_list.add('KIVY_TARGET_PLATFORM_macosx')
454    elif 'ios' == KIVY_TARGET_PLATFORM:
455        macro_flags_list.add('KIVY_TARGET_PLATFORM_ios')
456    elif 'unknown' == KIVY_TARGET_PLATFORM:
457        macro_flags_list.add('KIVY_TARGET_PLATFORM_unknown')
458    
459    if 'posix' == OS_API_TYPE:
460        macro_flags_list.add('posix')
461    elif 'nt' == OS_API_TYPE:
462        macro_flags_list.add('nt')
463    elif 'java' == OS_API_TYPE:
464        macro_flags_list.add('java')
465    
466    if IS_RUNNING_IN_EMSCRIPTEN:
467        macro_flags_list.add('IS_RUNNING_IN_EMSCRIPTEN')
468    
469    if IS_RUNNING_IN_WASI:
470        macro_flags_list.add('IS_RUNNING_IN_WASI')
471    
472    if IS_RUNNING_IN_PYODIDE:
473        macro_flags_list.add('IS_RUNNING_IN_PYODIDE')
474    
475    if IS_BUILDING_FOR_PYODIDE:
476        macro_flags_list.add('IS_BUILDING_FOR_PYODIDE')
477    
478    if IS_INSIDE_OR_FOR_WEB_BROWSER:
479        macro_flags_list.add('IS_INSIDE_OR_FOR_WEB_BROWSER')
480    
481    if IS_RUNNING_IN_PYCHARM:
482        macro_flags_list.add('IS_RUNNING_IN_PYCHARM')
483
484    macro_flags_list.update(additional_cflags)
485    return macro_flags_list
def append_cflags(cflags_list: list):
101def append_cflags(cflags_list: list):
102    if 'msvc' == compiler_type:
103        compiler_flags_env_var_name = 'CL'
104    else:
105        compiler_flags_env_var_name = 'CFLAGS'
106
107    environ[compiler_flags_env_var_name] = ' '.join((environ.get(compiler_flags_env_var_name, str()), " ".join(cflags_list)))
def concat_cflags(cflags: str):
110def concat_cflags(cflags: str):
111    if 'msvc' == compiler_type:
112        compiler_flags_env_var_name = 'CL'
113    else:
114        compiler_flags_env_var_name = 'CFLAGS'
115
116    environ[compiler_flags_env_var_name] = ' '.join((environ.get(compiler_flags_env_var_name, str()), cflags))
def wrap_definition_text(text: str) -> str:
119def wrap_definition_text(text: str) -> str:
120    if 'msvc' == compiler_type:
121        return escape_param(f'\\"{text}\\"')
122    else:
123        return f'\\"{escape_param(text)}\\"'
def wrap_definition_text_raw(text: str) -> str:
126def wrap_definition_text_raw(text: str) -> str:
127    return f'"{text}"'
def prepare_definition_value(value: typing.Union[NoneType, bool, int, str]) -> str:
134def prepare_definition_value(value: Union[None, bool, int, str]) -> str:
135    if isinstance(value, bool):
136        value = str(value)
137    
138    if value is None:
139        return None
140    elif isinstance(value, int):
141        return value
142    elif isinstance(value, str):
143        return wrap_definition_text(value)
144    else:
145        return wrap_definition_text(f'{value}')
def prepare_definition_value_raw(value: typing.Union[NoneType, bool, int, str]) -> str:
148def prepare_definition_value_raw(value: Union[None, bool, int, str]) -> str:
149    if isinstance(value, bool):
150        value = str(value)
151    
152    if value is None:
153        return None
154    elif isinstance(value, int):
155        return value
156    elif isinstance(value, str):
157        return wrap_definition_text_raw(value)
158    else:
159        return wrap_definition_text_raw(f'{value}')
def convert_value_to_flag(value: typing.Union[NoneType, bool, int, str]) -> int:
183def convert_value_to_flag(value: Union[None, bool, int, str]) -> int:
184    if value is None:
185        return None
186    
187    try:
188        return int(value)
189    except:
190        return 1
def convert_value_to_text(value: typing.Union[NoneType, bool, int, str]) -> str:
193def convert_value_to_text(value: Union[None, bool, int, str]) -> str:
194    return f'{value}'
def prepare_definition(name: str, value: typing.Union[bool, int, str, NoneType] = None) -> str:
197def prepare_definition(name: str, value: Optional[Union[bool, int, str]] = None) -> str:
198    return wrap_definition_pair(name, prepare_definition_value(value))
def list_to_dict( additional_cflags: typing.Union[typing.Sequence[str], NoneType] = None) -> Dict[str, Union[NoneType, bool, int, str]]:
201def list_to_dict(additional_cflags: Optional[Sequence[str]] = None) -> Dict[str, Union[None, bool, int, str]]:
202    additional_cflags = dict() if additional_cflags is None else additional_cflags
203    if not isinstance(additional_cflags, dict):
204        additional_cflags = {name: None for name in additional_cflags}
205    
206    return additional_cflags
def dict_of_tuples_to_dict( additional_cflags: typing.Union[typing.Dict[str, typing.Tuple[bool, typing.Union[NoneType, bool, str, int]]], NoneType] = None) -> Dict[str, Union[NoneType, bool, int, str]]:
209def dict_of_tuples_to_dict(additional_cflags: Optional[Dict[str, Tuple[bool, Union[None, bool, str, int]]]] = None) -> Dict[str, Union[None, bool, int, str]]:
210    additional_cflags = dict() if additional_cflags is None else additional_cflags
211    adjusted_additional_cflags: Dict[str, Union[None, bool, int, str]] = dict()
212    for name, value_info in additional_cflags.items():
213        if isinstance(value_info, tuple):
214            is_flag, value = value_info
215            value = convert_value_to_flag(value) if is_flag else convert_value_to_text(value)
216        else:
217            value = value_info
218        
219        adjusted_additional_cflags[name] = value
220    
221    return adjusted_additional_cflags
def adjust_definition_names( definitions: typing.Dict[str, typing.Union[NoneType, bool, int, str]], flag_name_prefix: str = None, definition_name_prefix: str = None) -> Dict[str, Union[NoneType, bool, int, str]]:
224def adjust_definition_names(definitions: Dict[str, Union[None, bool, int, str]], flag_name_prefix: str = None, definition_name_prefix: str = None) -> Dict[str, Union[None, bool, int, str]]:
225    flag_name_prefix = str() if flag_name_prefix is None else flag_name_prefix
226    definition_name_prefix = str() if definition_name_prefix is None else definition_name_prefix
227    adjusted_definitions: Dict[str, Union[None, bool, int, str]] = dict()
228    for name, value in definitions.items():
229        if value is None:
230            name = f'{flag_name_prefix}{name}'
231        else:
232            name = f'{definition_name_prefix}{name}'
233        
234        adjusted_definitions[name] = value
235    
236    return adjusted_definitions
def prepare_cflags( additional_cflags: typing.Union[typing.Sequence[str], typing.Dict[str, typing.Union[NoneType, bool, int, str, typing.Tuple[bool, typing.Union[NoneType, bool, str, int]]]], NoneType] = None) -> List[Union[NoneType, int, str]]:
239def prepare_cflags(additional_cflags: Optional[Union[Sequence[str], Dict[str, Union[Union[None, bool, int, str], Tuple[bool, Union[None, bool, str, int]]]]]] = None) -> List[Union[None, int, str]]:
240    adjusted_additional_cflags: Dict[str, Union[None, bool, int, str]] = dict_of_tuples_to_dict(list_to_dict(additional_cflags))
241    flags: Dict[str, None] = adjust_definition_names(list_to_dict(prepare_compile_time_flags()), 'CF_', 'CD_')  # CF is Cengal Flag; CD is Cengal Definition
242    definitions: Dict[str, Union[None, bool, int, str]] = adjust_definition_names(prepare_compile_time_env(), 'CF_', 'CD_')  # CF is Cengal Flag; CD is Cengal Definition
243    definitions.update(flags)
244    definitions.update(adjusted_additional_cflags)
245    params: List[Union[None, int, str]] = [prepare_definition(name, value) for name, value in definitions.items()]
246    
247    # from pprint import pprint
248    # print('<<< PREPARE_CFLAGS: >>>')
249    # pprint(params)
250    append_cflags(params)
251    return params
def prepare_given_cflags( additional_cflags: typing.Union[typing.Sequence[str], typing.Dict[str, typing.Union[NoneType, bool, int, str, typing.Tuple[bool, typing.Union[NoneType, bool, str, int]]]], NoneType] = None) -> List[Union[NoneType, int, str]]:
254def prepare_given_cflags(additional_cflags: Optional[Union[Sequence[str], Dict[str, Union[Union[None, bool, int, str], Tuple[bool, Union[None, bool, str, int]]]]]] = None) -> List[Union[None, int, str]]:
255    adjusted_additional_cflags: Dict[str, Union[None, bool, int, str]] = dict_of_tuples_to_dict(list_to_dict(additional_cflags))
256    params: List[Union[None, int, str]] = [prepare_definition(name, value) for name, value in adjusted_additional_cflags.items()]
257    
258    # from pprint import pprint
259    # print('<<< PREPARE_CFLAGS: >>>')
260    # pprint(params)
261    append_cflags(params)
262    return params
def prepare_cflags_dict( additional_cflags: typing.Union[typing.Sequence[str], typing.Dict[str, typing.Union[NoneType, bool, int, str, typing.Tuple[bool, typing.Union[NoneType, bool, str, int]]]], NoneType] = None) -> Dict[str, Union[NoneType, bool, int, str]]:
265def prepare_cflags_dict(additional_cflags: Optional[Union[Sequence[str], Dict[str, Union[Union[None, bool, int, str], Tuple[bool, Union[None, bool, str, int]]]]]] = None) -> Dict[str, Union[None, bool, int, str]]:
266    adjusted_additional_cflags: Dict[str, Union[None, bool, int, str]] = dict_of_tuples_to_dict(list_to_dict(additional_cflags))
267    flags: Dict[str, None] = adjust_definition_names(list_to_dict(prepare_compile_time_flags()), 'CF_', 'CD_')  # CF is Cengal Flag; CD is Cengal Definition
268    definitions: Dict[str, Union[None, bool, int, str]] = adjust_definition_names(prepare_compile_time_env(), 'CF_', 'CD_')  # CF is Cengal Flag; CD is Cengal Definition
269    definitions.update(flags)
270    definitions.update(adjusted_additional_cflags)
271    result: Dict[str, Union[None, bool, int, str]] = {name: prepare_definition_value_raw(value) for name, value in definitions.items()}
272    
273    # from pprint import pprint
274    # print('<<< PREPARE_CFLAGS_DICT: >>>')
275    # pprint(result)
276    return result
def prepare_given_cflags_dict( additional_cflags: typing.Union[typing.Sequence[str], typing.Dict[str, typing.Union[NoneType, bool, int, str, typing.Tuple[bool, typing.Union[NoneType, bool, str, int]]]], NoneType] = None) -> Dict[str, Union[NoneType, bool, int, str]]:
279def prepare_given_cflags_dict(additional_cflags: Optional[Union[Sequence[str], Dict[str, Union[Union[None, bool, int, str], Tuple[bool, Union[None, bool, str, int]]]]]] = None) -> Dict[str, Union[None, bool, int, str]]:
280    adjusted_additional_cflags: Dict[str, Union[None, bool, int, str]] = dict_of_tuples_to_dict(list_to_dict(additional_cflags))
281    result: Dict[str, Union[None, bool, int, str]] = {name: prepare_definition_value_raw(value) for name, value in adjusted_additional_cflags.items()}
282    
283    # from pprint import pprint
284    # print('<<< PREPARE_CFLAGS_DICT: >>>')
285    # pprint(result)
286    return result
def prepare_pyx_flags_dict( additional_pyx_flags: typing.Union[typing.Sequence[str], typing.Dict[str, typing.Union[NoneType, bool, int, str, typing.Tuple[bool, typing.Union[NoneType, bool, str, int]]]], NoneType] = None) -> Dict[str, Union[NoneType, bool, int, str]]:
289def prepare_pyx_flags_dict(additional_pyx_flags: Optional[Union[Sequence[str], Dict[str, Union[Union[None, bool, int, str], Tuple[bool, Union[None, bool, str, int]]]]]] = None) -> Dict[str, Union[None, bool, int, str]]:
290    adjusted_additional_cflags: Dict[str, Union[None, bool, int, str]] = dict_of_tuples_to_dict(list_to_dict(additional_pyx_flags))
291    flags: Dict[str, None] = adjust_definition_names(list_to_dict(prepare_compile_time_flags()), 'PYXF_', 'PYXD_')  # PYXF is Cython Flag; PYXD is Cython Definition
292    definitions: Dict[str, Union[None, bool, int, str]] = adjust_definition_names(prepare_compile_time_env(), 'PYXF_', 'PYXD_')  # PYXF is Cython Flag; PYXD is Cython Definition
293    definitions.update(flags)
294    definitions.update(adjusted_additional_cflags)
295    result: Dict[str, Union[None, bool, int, str]] = {name: prepare_pyx_definition_value_raw(value) for name, value in definitions.items()}
296    
297    # from pprint import pprint
298    # print('<<< PREPARE_CFLAGS_DICT: >>>')
299    # pprint(result)
300    return result
def prepare_compile_time_env( additional_cflags: typing.Union[typing.Sequence[str], typing.Dict[str, typing.Union[NoneType, bool, int, str, typing.Tuple[bool, typing.Union[NoneType, bool, str, int]]]], NoneType] = None):
303def prepare_compile_time_env(additional_cflags: Optional[Union[Sequence[str], Dict[str, Union[Union[None, bool, int, str], Tuple[bool, Union[None, bool, str, int]]]]]] = None):
304    result = {
305        'UNAME_SYSNAME': uname_sysname,  # see: https://en.wikipedia.org/wiki/Uname
306        'UNAME_MACHINE': uname_machine,  # see: https://en.wikipedia.org/wiki/Uname
307        'CPU_ARCH': cpu_info().arch,  # 'X86_32', 'X86_64', 'ARM_8', 'ARM_7', 'PPC_32', 'PPC_64', 'SPARC_32', 'SPARC_64', 'S390X', 'MIPS_32', 'MIPS_64', 'RISCV_32', 'RISCV_64'
308        'CPU_ARCH_RAW_STRING': cpu_info().arch_string_raw,
309        'CPU_BITS': cpu_info().bits,  # '32', '64'
310        'IS_X86_BOOL': cpu_info().is_x86,  # 'True', 'False'
311        'IS_ARM_BOOL': cpu_info().is_arm,  # 'True', 'False'
312        'IS_X86': int(cpu_info().is_x86),  # '1', '0'
313        'IS_ARM': int(cpu_info().is_arm),  # '1', '0'
314        'COMPILER_TYPE': compiler_type,  # 'gcc', 'msvc', 'clang', 'icc', 'llvm', 'intel', 'arm', 'mingw', 'unknown'
315        'COMPILER_NAME': compiler_name,  # 'x86_64-linux-gnu-gcc'
316        'COMPILER_STRING': compiler_string,  # 'x86_64-linux-gnu-gcc -pthread'
317        'PYTHON_IMPLEMENTATION': PYTHON_IMPLEMENTATION,  # 'CPython', 'PyPy', 'IronPython', 'Jython'
318        'PYTHON_VERSION_STR': PYTHON_VERSION_STR,  # '3.5.1', ...
319        'PYTHON_VERSION_MAJOR_STR': str(PYTHON_VERSION_INT.major),  # '3', ...
320        'PYTHON_VERSION_MINOR_STR': str(PYTHON_VERSION_INT.minor),  # '5', ...
321        'PYTHON_VERSION_MICRO_STR': str(PYTHON_VERSION_INT.micro),  # '1', ...
322        'PYTHON_VERSION_MAJOR': PYTHON_VERSION_INT.major,  # '3', ...
323        'PYTHON_VERSION_MINOR': PYTHON_VERSION_INT.minor,  # '5', ...
324        'PYTHON_VERSION_MICRO': PYTHON_VERSION_INT.micro,  # '1', ...
325        'IS_RUNNING_IN_PYCHARM_BOOL': IS_RUNNING_IN_PYCHARM,  # 'True', 'False'
326        'IS_RUNNING_IN_PYCHARM': int(IS_RUNNING_IN_PYCHARM),  # '1', '0'
327        'RAW_OS_PLATFORM': RAW_OS_PLATFORM,  # 'emscripten', 'wasi', 'darwin', 'win32', 'cygwin', 'linux', 'linux2', 'linux3', 'darwin', 'freebsd8', 'aix', aix5', 'aix7', ...
328        'OS_API_TYPE': OS_API_TYPE,  # 'posix', 'nt', 'java'. Android and iOS will return 'posix'.
329        'OS_TYPE': OS_TYPE,  # 'Linux', 'Windows', 'Darwin'
330        'KIVY_PLATFORM': KIVY_PLATFORM, # 'win', 'linux', 'android', 'macosx', 'ios', 'unknown'
331        'KIVY_TARGET_PLATFORM': KIVY_TARGET_PLATFORM, # 'win', 'linux', 'android', 'macosx', 'ios', 'unknown'
332        'IS_RUNNING_IN_EMSCRIPTEN_BOOL': IS_RUNNING_IN_EMSCRIPTEN,  # 'True', 'False'
333        'IS_RUNNING_IN_WASI_BOOL': IS_RUNNING_IN_WASI,  # 'True', 'False'
334        'IS_RUNNING_IN_PYODIDE_BOOL': IS_RUNNING_IN_PYODIDE,  # 'True', 'False'
335        'IS_BUILDING_FOR_PYODIDE_BOOL': IS_BUILDING_FOR_PYODIDE,  # 'True', 'False'
336        'IS_INSIDE_OR_FOR_WEB_BROWSER_BOOL': IS_INSIDE_OR_FOR_WEB_BROWSER,  # 'True', 'False'
337        'IS_RUNNING_IN_EMSCRIPTEN': int(IS_RUNNING_IN_EMSCRIPTEN),  # '1', '0'
338        'IS_RUNNING_IN_WASI': int(IS_RUNNING_IN_WASI),  # '1', '0'
339        'IS_RUNNING_IN_PYODIDE': int(IS_RUNNING_IN_PYODIDE),  # '1', '0'
340        'IS_BUILDING_FOR_PYODIDE': int(IS_BUILDING_FOR_PYODIDE),  # '1', '0'
341        'IS_INSIDE_OR_FOR_WEB_BROWSER': int(IS_INSIDE_OR_FOR_WEB_BROWSER),  # '1', '0'
342        'CENGAL_VERSION_STR': CENGAL_VERSION_STR,
343        'CENGAL_VERSION_MAJOR_STR': CENGAL_VERSION_MAJOR_STR,
344        'CENGAL_VERSION_MINOR_STR': CENGAL_VERSION_MINOR_STR,
345        'CENGAL_VERSION_MICRO_STR': CENGAL_VERSION_MICRO_STR,
346        'CENGAL_VERSION_MAJOR': CENGAL_VERSION_MAJOR,
347        'CENGAL_VERSION_MINOR': CENGAL_VERSION_MINOR,
348        'CENGAL_VERSION_MICRO': CENGAL_VERSION_MICRO,
349    }
350    result.update(dict_of_tuples_to_dict(list_to_dict(additional_cflags)))
351    return result
def prepare_compile_time_flags(additional_cflags: typing.Sequence[str] = None):
354def prepare_compile_time_flags(additional_cflags: Sequence[str] = None):
355    additional_cflags = [] if additional_cflags is None else additional_cflags
356    macro_flags_list: Set = set()
357
358    if 32 == cpu_info().bits:
359        macro_flags_list.add('32_bit_CPU')
360    
361    if 64 == cpu_info().bits:
362        macro_flags_list.add('64_bit_CPU')
363
364    if cpu_info().is_x86:
365        macro_flags_list.add('IS_X86')
366    
367    if cpu_info().is_arm:
368        macro_flags_list.add('IS_ARM')
369
370    if 'X86_32' == cpu_info().arch:
371        macro_flags_list.add('X86_32')
372    elif 'X86_64' == cpu_info().arch:
373        macro_flags_list.add('X86_64')
374    elif 'ARM_8' == cpu_info().arch:
375        macro_flags_list.add('ARM_8')
376    elif 'ARM_7' == cpu_info().arch:
377        macro_flags_list.add('ARM_7')
378    elif 'PPC_32' == cpu_info().arch:
379        macro_flags_list.add('PPC_32')
380    elif 'PPC_64' == cpu_info().arch:
381        macro_flags_list.add('PPC_64')
382    elif 'SPARC_32' == cpu_info().arch:
383        macro_flags_list.add('SPARC_32')
384    elif 'SPARC_64' == cpu_info().arch:
385        macro_flags_list.add('SPARC_64')
386    elif 'S390X' == cpu_info().arch:
387        macro_flags_list.add('S390X')
388    elif 'MIPS_32' == cpu_info().arch:
389        macro_flags_list.add('MIPS_32')
390    elif 'MIPS_64' == cpu_info().arch:
391        macro_flags_list.add('MIPS_64')
392    elif 'RISCV_32' == cpu_info().arch:
393        macro_flags_list.add('RISCV_32')
394    elif 'RISCV_64' == cpu_info().arch:
395        macro_flags_list.add('RISCV_64')
396    
397    if 'CPython' == PYTHON_IMPLEMENTATION:
398        macro_flags_list.add('CPython')
399    elif 'PyPy' == PYTHON_IMPLEMENTATION:
400        macro_flags_list.add('PyPy')
401    elif 'IronPython' == PYTHON_IMPLEMENTATION:
402        macro_flags_list.add('IronPython')
403    elif 'Jython' == PYTHON_IMPLEMENTATION:
404        macro_flags_list.add('Jython')
405    
406    if 'gcc' == compiler_type:
407        macro_flags_list.add('gcc')
408    elif 'msvc' == compiler_type:
409        macro_flags_list.add('msvc')
410    elif 'clang' == compiler_type:
411        macro_flags_list.add('clang')
412    elif 'icc' == compiler_type:
413        macro_flags_list.add('icc')
414    elif 'llvm' == compiler_type:
415        macro_flags_list.add('llvm')
416    elif 'intel' == compiler_type:
417        macro_flags_list.add('intel')
418    elif 'arm' == compiler_type:
419        macro_flags_list.add('arm')
420    elif 'mingw' == compiler_type:
421        macro_flags_list.add('mingw')
422    elif 'unknown' == compiler_type:
423        macro_flags_list.add('unknown_compiler')
424    
425    if 'Linux' == OS_TYPE:
426        macro_flags_list.add('Linux')
427    elif 'Windows' == OS_TYPE:
428        macro_flags_list.add('Windows')
429    elif 'Darwin' == OS_TYPE:
430        macro_flags_list.add('Darwin')
431    elif 'Java' == OS_TYPE:
432        macro_flags_list.add('Java')
433    
434    if 'win' == KIVY_PLATFORM:
435        macro_flags_list.add('KIVY_PLATFORM_win')
436    elif 'linux' == KIVY_PLATFORM:
437        macro_flags_list.add('KIVY_PLATFORM_linux')
438    elif 'android' == KIVY_PLATFORM:
439        macro_flags_list.add('KIVY_PLATFORM_android')
440    elif 'macosx' == KIVY_PLATFORM:
441        macro_flags_list.add('KIVY_PLATFORM_macosx')
442    elif 'ios' == KIVY_PLATFORM:
443        macro_flags_list.add('KIVY_PLATFORM_ios')
444    elif 'unknown' == KIVY_PLATFORM:
445        macro_flags_list.add('KIVY_PLATFORM_unknown')
446    
447    if 'win' == KIVY_TARGET_PLATFORM:
448        macro_flags_list.add('KIVY_TARGET_PLATFORM_win')
449    elif 'linux' == KIVY_TARGET_PLATFORM:
450        macro_flags_list.add('KIVY_TARGET_PLATFORM_linux')
451    elif 'android' == KIVY_TARGET_PLATFORM:
452        macro_flags_list.add('KIVY_TARGET_PLATFORM_android')
453    elif 'macosx' == KIVY_TARGET_PLATFORM:
454        macro_flags_list.add('KIVY_TARGET_PLATFORM_macosx')
455    elif 'ios' == KIVY_TARGET_PLATFORM:
456        macro_flags_list.add('KIVY_TARGET_PLATFORM_ios')
457    elif 'unknown' == KIVY_TARGET_PLATFORM:
458        macro_flags_list.add('KIVY_TARGET_PLATFORM_unknown')
459    
460    if 'posix' == OS_API_TYPE:
461        macro_flags_list.add('posix')
462    elif 'nt' == OS_API_TYPE:
463        macro_flags_list.add('nt')
464    elif 'java' == OS_API_TYPE:
465        macro_flags_list.add('java')
466    
467    if IS_RUNNING_IN_EMSCRIPTEN:
468        macro_flags_list.add('IS_RUNNING_IN_EMSCRIPTEN')
469    
470    if IS_RUNNING_IN_WASI:
471        macro_flags_list.add('IS_RUNNING_IN_WASI')
472    
473    if IS_RUNNING_IN_PYODIDE:
474        macro_flags_list.add('IS_RUNNING_IN_PYODIDE')
475    
476    if IS_BUILDING_FOR_PYODIDE:
477        macro_flags_list.add('IS_BUILDING_FOR_PYODIDE')
478    
479    if IS_INSIDE_OR_FOR_WEB_BROWSER:
480        macro_flags_list.add('IS_INSIDE_OR_FOR_WEB_BROWSER')
481    
482    if IS_RUNNING_IN_PYCHARM:
483        macro_flags_list.add('IS_RUNNING_IN_PYCHARM')
484
485    macro_flags_list.update(additional_cflags)
486    return macro_flags_list