def configure(env): from SCons.Script import Variables, ListVariable, Help, Exit modules = [ "core", "bulletkit", "visual", "environment", "smooth", "debugdraw", "statemachine", "benet", "behaviornode", "settings", "sfxr", "vgamepad", "landiscovery", ] opts = Variables() opts.Add( ListVariable( "enable_gdextensions_submodules", "Enable gdextensions submodules", "all" if env["tools"] else "none", modules, )) opts.Update(env)
def configure(env): envvars = Variables() envvars.Add( BoolVariable('builtin_runtime', 'Use the built-in libraries', True)) envvars.Add( BoolVariable('use_graphite2', 'Enable Graphite2 complementary shaper', True)) envvars.Update(env)
def configure(env): platform = env["platform"] if platform not in supported_platforms: raise RuntimeError( "This module does not currently support building for this platform" ) env.use_ptrcall = True env.add_module_version_string("mono") from SCons.Script import BoolVariable, PathVariable, Variables, Help default_mono_static = platform in ["iphone", "javascript"] default_mono_bundles_zlib = platform in ["javascript"] envvars = Variables() envvars.Add( PathVariable( "mono_prefix", "Path to the mono installation directory for the target platform and architecture", "", PathVariable.PathAccept, )) envvars.Add( BoolVariable("mono_static", "Statically link mono", default_mono_static)) envvars.Add( BoolVariable("mono_glue", "Build with the mono glue sources", True)) envvars.Add( BoolVariable( "copy_mono_root", "Make a copy of the mono installation directory to bundle with the editor", False)) envvars.Add( BoolVariable("xbuild_fallback", "If MSBuild is not found, fallback to xbuild", False)) # TODO: It would be great if this could be detected automatically instead envvars.Add( BoolVariable( "mono_bundles_zlib", "Specify if the Mono runtime was built with bundled zlib", default_mono_bundles_zlib)) envvars.Update(env) Help(envvars.GenerateHelpText(env)) if env["mono_bundles_zlib"]: # Mono may come with zlib bundled for WASM or on newer version when built with MinGW. print( "This Mono runtime comes with zlib bundled. Disabling 'builtin_zlib'..." ) env["builtin_zlib"] = False thirdparty_zlib_dir = "#thirdparty/zlib/" env.Prepend(CPPPATH=[thirdparty_zlib_dir])
def configure(env): platform = env['platform'] if platform not in supported_platforms: raise RuntimeError( 'This module does not currently support building for this platform' ) env.use_ptrcall = True env.add_module_version_string('mono') from SCons.Script import BoolVariable, PathVariable, Variables, Help default_mono_static = platform in ['iphone', 'javascript'] default_mono_bundles_zlib = platform in ['javascript'] envvars = Variables() envvars.Add( PathVariable( 'mono_prefix', 'Path to the mono installation directory for the target platform and architecture', '', PathVariable.PathAccept)) envvars.Add( BoolVariable('mono_static', 'Statically link mono', default_mono_static)) envvars.Add( BoolVariable('mono_glue', 'Build with the mono glue sources', True)) envvars.Add( BoolVariable( 'copy_mono_root', 'Make a copy of the mono installation directory to bundle with the editor', False)) envvars.Add( BoolVariable('xbuild_fallback', 'If MSBuild is not found, fallback to xbuild', False)) # TODO: It would be great if this could be detected automatically instead envvars.Add( BoolVariable( 'mono_bundles_zlib', 'Specify if the Mono runtime was built with bundled zlib', default_mono_bundles_zlib)) envvars.Update(env) Help(envvars.GenerateHelpText(env)) if env['mono_bundles_zlib']: # Mono may come with zlib bundled for WASM or on newer version when built with MinGW. print( 'This Mono runtime comes with zlib bundled. Disabling \'builtin_zlib\'...' ) env['builtin_zlib'] = False thirdparty_zlib_dir = "#thirdparty/zlib/" env.Prepend(CPPPATH=[thirdparty_zlib_dir])
def configure(env): if env["platform"] not in [ "windows", "osx", "linuxbsd", "server", "android", "haiku", "javascript" ]: raise RuntimeError( "This module does not currently support building for this platform" ) env.use_ptrcall = True env.add_module_version_string("mono") from SCons.Script import BoolVariable, PathVariable, Variables, Help envvars = Variables() envvars.Add( PathVariable( "mono_prefix", "Path to the mono installation directory for the target platform and architecture", "", PathVariable.PathAccept, )) envvars.Add(BoolVariable("mono_static", "Statically link mono", False)) envvars.Add( BoolVariable("mono_glue", "Build with the mono glue sources", True)) envvars.Add( BoolVariable( "copy_mono_root", "Make a copy of the mono installation directory to bundle with the editor", False)) envvars.Add( BoolVariable("xbuild_fallback", "If MSBuild is not found, fallback to xbuild", False)) envvars.Update(env) Help(envvars.GenerateHelpText(env)) if env["platform"] == "javascript": # Mono wasm already has zlib builtin, so we need this workaround to avoid symbol collisions print("Compiling with Mono wasm disables 'builtin_zlib'") env["builtin_zlib"] = False thirdparty_zlib_dir = "#thirdparty/zlib/" env.Prepend(CPPPATH=[thirdparty_zlib_dir])
def configure(env): if env['platform'] not in [ 'windows', 'osx', 'linuxbsd', 'server', 'android', 'haiku', 'javascript' ]: raise RuntimeError( 'This module does not currently support building for this platform' ) env.use_ptrcall = True env.add_module_version_string('mono') from SCons.Script import BoolVariable, PathVariable, Variables, Help envvars = Variables() envvars.Add( PathVariable( 'mono_prefix', 'Path to the mono installation directory for the target platform and architecture', '', PathVariable.PathAccept)) envvars.Add(BoolVariable('mono_static', 'Statically link mono', False)) envvars.Add( BoolVariable('mono_glue', 'Build with the mono glue sources', True)) envvars.Add( BoolVariable( 'copy_mono_root', 'Make a copy of the mono installation directory to bundle with the editor', False)) envvars.Add( BoolVariable('xbuild_fallback', 'If MSBuild is not found, fallback to xbuild', False)) envvars.Update(env) Help(envvars.GenerateHelpText(env)) if env['platform'] == 'javascript': # Mono wasm already has zlib builtin, so we need this workaround to avoid symbol collisions print('Compiling with Mono wasm disables \'builtin_zlib\'') env['builtin_zlib'] = False thirdparty_zlib_dir = "#thirdparty/zlib/" env.Prepend(CPPPATH=[thirdparty_zlib_dir])
def _internal_data(variables_cache_file): mydata = { # 2 my own env variables are added in function read_vars_from_cache and then # their values are set in function save_vars_to_cache 'env': Environment(), 'new_env_call': lambda **kwargs: Environment(**kwargs), # This is a SCons.Variables.Variables class object for reading from / # writing to the variables cache file # Changed by calling method "Add" in function read_vars_from_cache 'scons_var_obj': Variables(variables_cache_file), 'arguments': ARGUMENTS, 'command_line_targets': COMMAND_LINE_TARGETS, # A class for appending values to environment variables (as lists) 'clvar': SCons.Util.CLVar } return mydata
def configure(env): from SCons.Script import Variables, BoolVariable, Help opts = Variables() opts.Add( BoolVariable( "anl_use_long_period", "Use a long-period hash for noise (>256) to avoid having repeated patterns " "in exchange of a slight decrease in performance.", False)) opts.Add( BoolVariable( 'anl_use_expressions_camelcase', "Use 'camelCase' by default over the 'snake_case' for noise expressions.", False)) opts.Update(env) Help(opts.GenerateHelpText(env))
def configure(env): env.use_ptrcall = True env.add_module_version_string('mono') from SCons.Script import BoolVariable, PathVariable, Variables envvars = Variables() envvars.Add( PathVariable( 'mono_prefix', 'Path to the mono installation directory for the target platform and architecture', '', PathVariable.PathAccept)) envvars.Add(BoolVariable('mono_static', 'Statically link mono', False)) envvars.Add( BoolVariable('mono_glue', 'Build with the mono glue sources', True)) envvars.Add( BoolVariable( 'copy_mono_root', 'Make a copy of the mono installation directory to bundle with the editor', False)) envvars.Add( BoolVariable('xbuild_fallback', 'If MSBuild is not found, fallback to xbuild', False)) envvars.Update(env)
def configure(env): from SCons.Script import Variables, BoolVariable, Help, Exit import goost opts = Variables() for name in goost.get_components(): opts.Add( BoolVariable("goost_%s_enabled" % (name), "Build %s component." % (name), True)) opts.Add( "goost_scale_factor", "The precision used for converting between integer and float coordinates.", "1e5") opts.Update(env) # Get a list of components which got disabled. disabled = [] for name in goost.get_components(): if not env["goost_%s_enabled" % (name)]: disabled.append(name) # Implicitly disable child components. for name in disabled: children = goost.get_child_components(name) for child_name in children: print("Goost: disabling `%s` component (%s)." % (child_name, name)) env["goost_%s_enabled" % (child_name)] = False def help_format(env, opt, help, default, actual, aliases): if opt == "goost_scale_factor": fmt = "\n%s: %s.\n default: %s (based on CMP_EPSILON)\n actual: %s\n" else: fmt = "\n%s: %s.\n default: %s\n actual: %s\n" return fmt % (opt, help, default, actual) opts.FormatVariableHelpText = help_format Help(opts.GenerateHelpText(env))
def configure(env): from SCons.Script import Variables, Help opts = Variables() opts.Add("geomtools_scale_factor", "The precision used for converting between integer and float coordinates throughout " + "poly backends implementations for computational robustness purposes.", "1e5") opts.Update(env) def help_format(env, opt, help, default, actual, aliases): if opt == "geomtools_scale_factor": fmt = "\n%s: %s.\n default: %s (based on CMP_EPSILON)\n actual: %s\n" else: fmt = "\n%s: %s.\n default: %s\n actual: %s\n" return fmt % (opt, help, default, actual) opts.FormatVariableHelpText = help_format Help(opts.GenerateHelpText(env))
def __add_build_vars(env, build_type_names): """ Return Variables instance. """ assert isinstance(env, Environment) vs = Variables(None, ARGUMENTS) vs.Add( ListVariable(key='build', help=buildtype.help_msg(build_type_names), default=buildtype.default(build_type_names), names=build_type_names, map={})) vs.Add( EnumVariable(key='stage', help='build stage', default='compile', allowed_values=('compile', 'link'), map={}, ignorecase=0)) vs.Update(env) Help(vs.GenerateHelpText(env)) pass
sys.path.insert(0, _path[:_path.rfind("platformio") - 1]) break from platformio.util import get_home_dir from os.path import isdir, join from SCons.Script import (DefaultEnvironment, Exit, SConscript, SConscriptChdir, Variables) from platformio.util import (get_lib_dir, get_pioenvs_dir, get_project_dir, get_source_dir) # AllowSubstExceptions() # allow common variables from INI file commonvars = Variables(None) commonvars.AddVariables( ("PIOENV", ), ("PLATFORM", ), ("FRAMEWORK", ), ("BUILD_FLAGS", ), ("SRCBUILD_FLAGS", ), # board options ( "BOARD", ), ("BOARD_MCU", ), ("BOARD_F_CPU", ), # upload options (
def configure(env): env.use_ptrcall = True env.add_module_version_string('mono') envvars = Variables() envvars.Add(BoolVariable('mono_static', 'Statically link mono', False)) envvars.Add( PathVariable('mono_assemblies_output_dir', 'Path to the assemblies output directory', '#bin', custom_path_is_dir_create)) envvars.Update(env) bits = env['bits'] mono_static = env['mono_static'] assemblies_output_dir = Dir(env['mono_assemblies_output_dir']).abspath mono_lib_names = ['mono-2.0-sgen', 'monosgen-2.0'] if env['platform'] == 'windows': if bits == '32': if os.getenv('MONO32_PREFIX'): mono_root = os.getenv('MONO32_PREFIX') elif os.name == 'nt': mono_root = monoreg.find_mono_root_dir(bits) else: if os.getenv('MONO64_PREFIX'): mono_root = os.getenv('MONO64_PREFIX') elif os.name == 'nt': mono_root = monoreg.find_mono_root_dir(bits) if not mono_root: raise RuntimeError('Mono installation directory not found') mono_version = mono_root_try_find_mono_version(mono_root) configure_for_mono_version(env, mono_version) mono_lib_path = os.path.join(mono_root, 'lib') env.Append(LIBPATH=mono_lib_path) env.Append(CPPPATH=os.path.join(mono_root, 'include', 'mono-2.0')) if mono_static: lib_suffix = Environment()['LIBSUFFIX'] if env.msvc: mono_static_lib_name = 'libmono-static-sgen' else: mono_static_lib_name = 'libmonosgen-2.0' if not os.path.isfile( os.path.join(mono_lib_path, mono_static_lib_name + lib_suffix)): raise RuntimeError('Could not find static mono library in: ' + mono_lib_path) if env.msvc: env.Append(LINKFLAGS=mono_static_lib_name + lib_suffix) env.Append(LINKFLAGS='Mincore' + lib_suffix) env.Append(LINKFLAGS='msvcrt' + lib_suffix) env.Append(LINKFLAGS='LIBCMT' + lib_suffix) env.Append(LINKFLAGS='Psapi' + lib_suffix) else: env.Append(LINKFLAGS=os.path.join( mono_lib_path, mono_static_lib_name + lib_suffix)) env.Append(LIBS='psapi') env.Append(LIBS='version') else: mono_lib_name = find_file_in_dir(mono_lib_path, mono_lib_names, extension='.lib') if not mono_lib_name: raise RuntimeError('Could not find mono library in: ' + mono_lib_path) if env.msvc: env.Append(LINKFLAGS=mono_lib_name + Environment()['LIBSUFFIX']) else: env.Append(LIBS=mono_lib_name) mono_bin_path = os.path.join(mono_root, 'bin') mono_dll_name = find_file_in_dir(mono_bin_path, mono_lib_names, extension='.dll') if not mono_dll_name: raise RuntimeError('Could not find mono shared library in: ' + mono_bin_path) copy_file(mono_bin_path, 'bin', mono_dll_name + '.dll') copy_file(os.path.join(mono_lib_path, 'mono', '4.5'), assemblies_output_dir, 'mscorlib.dll') else: sharedlib_ext = '.dylib' if sys.platform == 'darwin' else '.so' mono_root = '' mono_lib_path = '' if bits == '32': if os.getenv('MONO32_PREFIX'): mono_root = os.getenv('MONO32_PREFIX') else: if os.getenv('MONO64_PREFIX'): mono_root = os.getenv('MONO64_PREFIX') # We can't use pkg-config to link mono statically, # but we can still use it to find the mono root directory if not mono_root and mono_static: mono_root = pkgconfig_try_find_mono_root(mono_lib_names, sharedlib_ext) if not mono_root: raise RuntimeError( 'Building with mono_static=yes, but failed to find the mono prefix with pkg-config. Specify one manually' ) if mono_root: mono_version = mono_root_try_find_mono_version(mono_root) configure_for_mono_version(env, mono_version) mono_lib_path = os.path.join(mono_root, 'lib') env.Append(LIBPATH=mono_lib_path) env.Append(CPPPATH=os.path.join(mono_root, 'include', 'mono-2.0')) mono_lib = find_file_in_dir(mono_lib_path, mono_lib_names, prefix='lib', extension='.a') if not mono_lib: raise RuntimeError('Could not find mono library in: ' + mono_lib_path) env.Append(CPPFLAGS=['-D_REENTRANT']) if mono_static: mono_lib_file = os.path.join(mono_lib_path, 'lib' + mono_lib + '.a') if sys.platform == 'darwin': env.Append(LINKFLAGS=['-Wl,-force_load,' + mono_lib_file]) elif sys.platform == 'linux' or sys.platform == 'linux2': env.Append(LINKFLAGS=[ '-Wl,-whole-archive', mono_lib_file, '-Wl,-no-whole-archive' ]) else: raise RuntimeError( 'mono-static: Not supported on this platform') else: env.Append(LIBS=[mono_lib]) if sys.platform == 'darwin': env.Append(LIBS=['iconv', 'pthread']) elif sys.platform == 'linux' or sys.platform == 'linux2': env.Append(LIBS=['m', 'rt', 'dl', 'pthread']) if not mono_static: mono_so_name = find_file_in_dir(mono_lib_path, mono_lib_names, prefix='lib', extension=sharedlib_ext) if not mono_so_name: raise RuntimeError( 'Could not find mono shared library in: ' + mono_lib_path) copy_file(mono_lib_path, 'bin', 'lib' + mono_so_name + sharedlib_ext) copy_file(os.path.join(mono_lib_path, 'mono', '4.5'), assemblies_output_dir, 'mscorlib.dll') else: assert not mono_static mono_version = pkgconfig_try_find_mono_version() configure_for_mono_version(env, mono_version) env.ParseConfig('pkg-config monosgen-2 --cflags --libs') mono_lib_path = '' mono_so_name = '' mono_prefix = subprocess.check_output( ['pkg-config', 'mono-2', '--variable=prefix']).decode('utf8').strip() tmpenv = Environment() tmpenv.AppendENVPath('PKG_CONFIG_PATH', os.getenv('PKG_CONFIG_PATH')) tmpenv.ParseConfig('pkg-config monosgen-2 --libs-only-L') for hint_dir in tmpenv['LIBPATH']: name_found = find_file_in_dir(hint_dir, mono_lib_names, prefix='lib', extension=sharedlib_ext) if name_found: mono_lib_path = hint_dir mono_so_name = name_found break if not mono_so_name: raise RuntimeError('Could not find mono shared library in: ' + str(tmpenv['LIBPATH'])) copy_file(mono_lib_path, 'bin', 'lib' + mono_so_name + sharedlib_ext) copy_file(os.path.join(mono_prefix, 'lib', 'mono', '4.5'), assemblies_output_dir, 'mscorlib.dll') env.Append(LINKFLAGS='-rdynamic')
from platformio import util import json from os import getenv from os.path import isfile, join from time import time from SCons.Script import (COMMAND_LINE_TARGETS, DefaultEnvironment, Exit, SConscript, SConscriptChdir, Variables) from platformio.exception import UnknownBoard # AllowSubstExceptions() # allow common variables from INI file commonvars = Variables(None) commonvars.AddVariables( ("BUILD_SCRIPT", ), ("EXTRA_SCRIPT", ), ("PIOENV", ), ("PLATFORM", ), # package aliases ( "PIOPACKAGE_TOOLCHAIN", ), ("PIOPACKAGE_UPLOADER", ), # options ( "FRAMEWORK", ), ("BUILD_FLAGS", ),
def configure(env): env.use_ptrcall = True envvars = Variables() envvars.Add(BoolVariable('mono_static', 'Statically link mono', False)) envvars.Update(env) mono_static = env['mono_static'] mono_lib_names = ['mono-2.0-sgen', 'monosgen-2.0'] if env['platform'] == 'windows': if mono_static: raise RuntimeError('mono-static: Not supported on Windows') if env['bits'] == '32': if os.getenv('MONO32_PREFIX'): mono_root = os.getenv('MONO32_PREFIX') elif os.name == 'nt': mono_root = monoreg.find_mono_root_dir() else: if os.getenv('MONO64_PREFIX'): mono_root = os.getenv('MONO64_PREFIX') elif os.name == 'nt': mono_root = monoreg.find_mono_root_dir() if mono_root is None: raise RuntimeError('Mono installation directory not found') mono_lib_path = os.path.join(mono_root, 'lib') env.Append(LIBPATH=mono_lib_path) env.Append(CPPPATH=os.path.join(mono_root, 'include', 'mono-2.0')) mono_lib_name = find_file_in_dir(mono_lib_path, mono_lib_names, extension='.lib') if mono_lib_name is None: raise RuntimeError('Could not find mono library in: ' + mono_lib_path) if os.getenv('VCINSTALLDIR'): env.Append(LINKFLAGS=mono_lib_name + Environment()['LIBSUFFIX']) else: env.Append(LIBS=mono_lib_name) mono_bin_path = os.path.join(mono_root, 'bin') mono_dll_name = find_file_in_dir(mono_bin_path, mono_lib_names, extension='.dll') mono_dll_src = os.path.join(mono_bin_path, mono_dll_name + '.dll') mono_dll_dst = os.path.join('bin', mono_dll_name + '.dll') copy_mono_dll = True if not os.path.isdir('bin'): os.mkdir('bin') elif os.path.exists(mono_dll_dst): copy_mono_dll = False if copy_mono_dll: copyfile(mono_dll_src, mono_dll_dst) else: mono_root = None if env['bits'] == '32': if os.getenv('MONO32_PREFIX'): mono_root = os.getenv('MONO32_PREFIX') else: if os.getenv('MONO64_PREFIX'): mono_root = os.getenv('MONO64_PREFIX') if mono_root is not None: mono_lib_path = os.path.join(mono_root, 'lib') env.Append(LIBPATH=mono_lib_path) env.Append(CPPPATH=os.path.join(mono_root, 'include', 'mono-2.0')) mono_lib = find_file_in_dir(mono_lib_path, mono_lib_names, prefix='lib', extension='.a') if mono_lib is None: raise RuntimeError('Could not find mono library in: ' + mono_lib_path) env.Append(CPPFLAGS=['-D_REENTRANT']) if mono_static: mono_lib_file = os.path.join(mono_lib_path, 'lib' + mono_lib + '.a') if sys.platform == "darwin": env.Append(LINKFLAGS=['-Wl,-force_load,' + mono_lib_file]) elif sys.platform == "linux" or sys.platform == "linux2": env.Append(LINKFLAGS=['-Wl,-whole-archive', mono_lib_file, '-Wl,-no-whole-archive']) else: raise RuntimeError('mono-static: Not supported on this platform') else: env.Append(LIBS=[mono_lib]) if sys.platform == "darwin": env.Append(LIBS=['iconv', 'pthread']) elif sys.platform == "linux" or sys.platform == "linux2": env.Append(LIBS=['m', 'rt', 'dl', 'pthread']) else: if mono_static: raise RuntimeError('mono-static: Not supported with pkg-config. Specify a mono prefix manually') env.ParseConfig('pkg-config monosgen-2 --cflags --libs') env.Append(LINKFLAGS='-rdynamic')
import json import sys from os import environ from os.path import join, normpath from time import time from SCons.Script import COMMAND_LINE_TARGETS, DefaultEnvironment, Variables from platformio import util from platformio.exception import UnknownBoard # AllowSubstExceptions() # allow common variables from INI file commonvars = Variables(None) commonvars.AddVariables( ("BUILD_SCRIPT",), ("EXTRA_SCRIPT",), ("PIOENV",), ("PLATFORM",), # package aliases ("PIOPACKAGE_TOOLCHAIN",), ("PIOPACKAGE_FRAMEWORK",), ("PIOPACKAGE_UPLOADER",), # options ("FRAMEWORK",), ("BUILD_FLAGS",), ("SRC_BUILD_FLAGS",),
def configure(env): env.use_ptrcall = True env.add_module_version_string('mono') envvars = Variables() envvars.Add(BoolVariable('mono_static', 'Statically link mono', False)) envvars.Add( BoolVariable( 'copy_mono_root', 'Make a copy of the mono installation directory to bundle with the editor', False)) envvars.Update(env) bits = env['bits'] tools_enabled = env['tools'] mono_static = env['mono_static'] copy_mono_root = env['copy_mono_root'] mono_lib_names = ['mono-2.0-sgen', 'monosgen-2.0'] if env['platform'] == 'windows': mono_root = '' if bits == '32': if os.getenv('MONO32_PREFIX'): mono_root = os.getenv('MONO32_PREFIX') elif os.name == 'nt': mono_root = monoreg.find_mono_root_dir(bits) else: if os.getenv('MONO64_PREFIX'): mono_root = os.getenv('MONO64_PREFIX') elif os.name == 'nt': mono_root = monoreg.find_mono_root_dir(bits) if not mono_root: raise RuntimeError('Mono installation directory not found') print('Found Mono root directory: ' + mono_root) mono_version = mono_root_try_find_mono_version(mono_root) configure_for_mono_version(env, mono_version) mono_lib_path = os.path.join(mono_root, 'lib') env.Append(LIBPATH=mono_lib_path) env.Append(CPPPATH=os.path.join(mono_root, 'include', 'mono-2.0')) if mono_static: lib_suffix = Environment()['LIBSUFFIX'] if env.msvc: mono_static_lib_name = 'libmono-static-sgen' else: mono_static_lib_name = 'libmonosgen-2.0' if not os.path.isfile( os.path.join(mono_lib_path, mono_static_lib_name + lib_suffix)): raise RuntimeError('Could not find static mono library in: ' + mono_lib_path) if env.msvc: env.Append(LINKFLAGS=mono_static_lib_name + lib_suffix) env.Append(LINKFLAGS='Mincore' + lib_suffix) env.Append(LINKFLAGS='msvcrt' + lib_suffix) env.Append(LINKFLAGS='LIBCMT' + lib_suffix) env.Append(LINKFLAGS='Psapi' + lib_suffix) else: env.Append(LINKFLAGS=os.path.join( mono_lib_path, mono_static_lib_name + lib_suffix)) env.Append(LIBS='psapi') env.Append(LIBS='version') else: mono_lib_name = find_file_in_dir(mono_lib_path, mono_lib_names, extension='.lib') if not mono_lib_name: raise RuntimeError('Could not find mono library in: ' + mono_lib_path) if env.msvc: env.Append(LINKFLAGS=mono_lib_name + Environment()['LIBSUFFIX']) else: env.Append(LIBS=mono_lib_name) mono_bin_path = os.path.join(mono_root, 'bin') mono_dll_name = find_file_in_dir(mono_bin_path, mono_lib_names, extension='.dll') if not mono_dll_name: raise RuntimeError('Could not find mono shared library in: ' + mono_bin_path) copy_file(mono_bin_path, 'bin', mono_dll_name + '.dll') else: is_apple = (sys.platform == 'darwin' or "osxcross" in env) sharedlib_ext = '.dylib' if is_apple else '.so' mono_root = '' mono_lib_path = '' if bits == '32': if os.getenv('MONO32_PREFIX'): mono_root = os.getenv('MONO32_PREFIX') else: if os.getenv('MONO64_PREFIX'): mono_root = os.getenv('MONO64_PREFIX') if not mono_root and is_apple: # Try with some known directories under OSX hint_dirs = [ '/Library/Frameworks/Mono.framework/Versions/Current', '/usr/local/var/homebrew/linked/mono' ] for hint_dir in hint_dirs: if os.path.isdir(hint_dir): mono_root = hint_dir break # We can't use pkg-config to link mono statically, # but we can still use it to find the mono root directory if not mono_root and mono_static: mono_root = pkgconfig_try_find_mono_root(mono_lib_names, sharedlib_ext) if not mono_root: raise RuntimeError( 'Building with mono_static=yes, but failed to find the mono prefix with pkg-config. Specify one manually' ) if mono_root: print('Found Mono root directory: ' + mono_root) mono_version = mono_root_try_find_mono_version(mono_root) configure_for_mono_version(env, mono_version) mono_lib_path = os.path.join(mono_root, 'lib') env.Append(LIBPATH=mono_lib_path) env.Append(CPPPATH=os.path.join(mono_root, 'include', 'mono-2.0')) mono_lib = find_file_in_dir(mono_lib_path, mono_lib_names, prefix='lib', extension='.a') if not mono_lib: raise RuntimeError('Could not find mono library in: ' + mono_lib_path) env.Append(CPPFLAGS=['-D_REENTRANT']) if mono_static: mono_lib_file = os.path.join(mono_lib_path, 'lib' + mono_lib + '.a') if is_apple: env.Append(LINKFLAGS=['-Wl,-force_load,' + mono_lib_file]) else: env.Append(LINKFLAGS=[ '-Wl,-whole-archive', mono_lib_file, '-Wl,-no-whole-archive' ]) else: env.Append(LIBS=[mono_lib]) if is_apple: env.Append(LIBS=['iconv', 'pthread']) else: env.Append(LIBS=['m', 'rt', 'dl', 'pthread']) if not mono_static: mono_so_name = find_file_in_dir(mono_lib_path, mono_lib_names, prefix='lib', extension=sharedlib_ext) if not mono_so_name: raise RuntimeError( 'Could not find mono shared library in: ' + mono_lib_path) copy_file(mono_lib_path, 'bin', 'lib' + mono_so_name + sharedlib_ext) else: assert not mono_static # TODO: Add option to force using pkg-config print('Mono root directory not found. Using pkg-config instead') mono_version = pkgconfig_try_find_mono_version() configure_for_mono_version(env, mono_version) env.ParseConfig('pkg-config monosgen-2 --cflags --libs') mono_lib_path = '' mono_so_name = '' tmpenv = Environment() tmpenv.AppendENVPath('PKG_CONFIG_PATH', os.getenv('PKG_CONFIG_PATH')) tmpenv.ParseConfig('pkg-config monosgen-2 --libs-only-L') for hint_dir in tmpenv['LIBPATH']: name_found = find_file_in_dir(hint_dir, mono_lib_names, prefix='lib', extension=sharedlib_ext) if name_found: mono_lib_path = hint_dir mono_so_name = name_found break if not mono_so_name: raise RuntimeError('Could not find mono shared library in: ' + str(tmpenv['LIBPATH'])) copy_file(mono_lib_path, 'bin', 'lib' + mono_so_name + sharedlib_ext) env.Append(LINKFLAGS='-rdynamic') if not tools_enabled: if not mono_root: mono_root = subprocess.check_output( ['pkg-config', 'mono-2', '--variable=prefix']).decode('utf8').strip() make_template_dir(env, mono_root) if copy_mono_root: if not mono_root: mono_root = subprocess.check_output( ['pkg-config', 'mono-2', '--variable=prefix']).decode('utf8').strip() if tools_enabled: copy_mono_root_files(env, mono_root) else: print( "Ignoring option: 'copy_mono_root'. Only available for builds with 'tools' enabled." )
import base64 import json from os import environ from os.path import join from time import time from SCons.Script import (ARGUMENTS, COMMAND_LINE_TARGETS, DEFAULT_TARGETS, AllowSubstExceptions, AlwaysBuild, DefaultEnvironment, Variables) from platformio import util AllowSubstExceptions(NameError) # allow common variables from INI file commonvars = Variables(None) commonvars.AddVariables( ("PLATFORM_MANIFEST",), ("BUILD_SCRIPT",), ("EXTRA_SCRIPT",), ("PIOENV",), ("PIOTEST",), ("PIOPLATFORM",), ("PIOFRAMEWORK",), # build options ("BUILD_FLAGS",), ("SRC_BUILD_FLAGS",), ("BUILD_UNFLAGS",), ("SRC_FILTER",),
import json import sys from os import environ from os.path import expanduser, join from time import time from SCons.Script import (ARGUMENTS, COMMAND_LINE_TARGETS, DEFAULT_TARGETS, Action, AllowSubstExceptions, AlwaysBuild, DefaultEnvironment, Variables) from platformio import util AllowSubstExceptions(NameError) # allow common variables from INI file commonvars = Variables(None) commonvars.AddVariables( ("PLATFORM_MANIFEST",), ("BUILD_SCRIPT",), ("EXTRA_SCRIPTS",), ("PIOENV",), ("PIOTEST",), ("PIOPLATFORM",), ("PIOFRAMEWORK",), # build options ("BUILD_FLAGS",), ("SRC_BUILD_FLAGS",), ("BUILD_UNFLAGS",), ("SRC_FILTER",),
def configure(env): from SCons.Script import Variables, BoolVariable, Help opts = Variables() # Config. components_config = {} components_enabled_by_default = True classes_config = {} classes_enabled_by_default = True # From `custom.py` file. try: import custom if hasattr(custom, "components"): components_config = custom.components if hasattr(custom, "components_enabled_by_default"): components_enabled_by_default = custom.components_enabled_by_default if hasattr(custom, "classes"): classes_config = custom.classes if hasattr(custom, "classes_enabled_by_default"): classes_enabled_by_default = custom.classes_enabled_by_default except ImportError: pass # From command-line (CLI arguments override arguments specified via file). opts.Add( BoolVariable( "goost_components_enabled", "Set to `no` to disable all components by default, and enable each component of interest manually", True)) # Get a list of all components and add them, regardless of configuration. for name in goost.get_components()["enabled"]: # All enabled by default. opts.Add( BoolVariable("goost_%s_enabled" % (name), "Build %s component." % (name), True)) # Math/Geometry. opts.Add( "goost_scale_factor", "The precision used for converting between integer and float coordinates.", "1e5") def help_format(env, opt, help, default, actual, aliases): if opt == "goost_scale_factor": fmt = "\n%s: %s.\n default: %s (based on CMP_EPSILON)\n actual: %s\n" else: fmt = "\n%s: %s.\n default: %s\n actual: %s\n" return fmt % (opt, help, default, actual) opts.FormatVariableHelpText = help_format # Must update environment to override `components_config` from CLI/file. # Do not call this method afterwards as the environment is going to be # updated manually. If you need to add more options not related to # components/classes, add them above. opts.Update(env) components = configure_components(env, components_config, components_enabled_by_default) classes = configure_classes(env, classes_config, classes_enabled_by_default) if env["verbose"]: for class_name in classes["enabled"]: # Report rightmost child components only. for component_name in reversed( goost.get_class_components(class_name)): skip = False if component_name in components["disabled"]: print( "Goost: Skipping class `%s`, because component `%s` is disabled." % (class_name, component_name)) skip = True if skip: break # Generate help text. Help(opts.GenerateHelpText(env))
from SCons.Script import AlwaysBuild # pylint: disable=import-error from SCons.Script import Default # pylint: disable=import-error from SCons.Script import DefaultEnvironment # pylint: disable=import-error from SCons.Script import Import # pylint: disable=import-error from SCons.Script import Variables # pylint: disable=import-error from platformio import fs from platformio.compat import dump_json_to_unicode from platformio.managers.platform import PlatformBase from platformio.proc import get_pythonexe_path from platformio.project.helpers import get_project_dir AllowSubstExceptions(NameError) # append CLI arguments to build environment clivars = Variables(None) clivars.AddVariables( ("PLATFORM_MANIFEST", ), ("BUILD_SCRIPT", ), ("PROJECT_CONFIG", ), ("PIOENV", ), ("PIOTEST_RUNNING_NAME", ), ("UPLOAD_PORT", ), ) DEFAULT_ENV_OPTIONS = dict( tools=[ "ar", "gas", "gcc", "g++",
def configure(env): env.use_ptrcall = True env.add_module_version_string("mono") envvars = Variables() envvars.Add(BoolVariable('mono_static', 'Statically link mono', False)) envvars.Update(env) bits = env['bits'] mono_static = env['mono_static'] mono_lib_names = ['mono-2.0-sgen', 'monosgen-2.0'] if env['platform'] == 'windows': if mono_static: raise RuntimeError('mono-static: Not supported on Windows') if bits == '32': if os.getenv('MONO32_PREFIX'): mono_root = os.getenv('MONO32_PREFIX') elif os.name == 'nt': mono_root = monoreg.find_mono_root_dir(bits) else: if os.getenv('MONO64_PREFIX'): mono_root = os.getenv('MONO64_PREFIX') elif os.name == 'nt': mono_root = monoreg.find_mono_root_dir(bits) if not mono_root: raise RuntimeError('Mono installation directory not found') mono_lib_path = os.path.join(mono_root, 'lib') env.Append(LIBPATH=mono_lib_path) env.Append(CPPPATH=os.path.join(mono_root, 'include', 'mono-2.0')) mono_lib_name = find_file_in_dir(mono_lib_path, mono_lib_names, extension='.lib') if not mono_lib_name: raise RuntimeError('Could not find mono library in: ' + mono_lib_path) if os.getenv('VCINSTALLDIR'): env.Append(LINKFLAGS=mono_lib_name + Environment()['LIBSUFFIX']) else: env.Append(LIBS=mono_lib_name) mono_bin_path = os.path.join(mono_root, 'bin') mono_dll_name = find_file_in_dir(mono_bin_path, mono_lib_names, extension='.dll') if not mono_dll_name: raise RuntimeError('Could not find mono shared library in: ' + mono_bin_path) copy_file_no_replace(mono_bin_path, 'bin', mono_dll_name + '.dll') else: sharedlib_ext = '.dylib' if sys.platform == 'darwin' else '.so' mono_root = '' if bits == '32': if os.getenv('MONO32_PREFIX'): mono_root = os.getenv('MONO32_PREFIX') else: if os.getenv('MONO64_PREFIX'): mono_root = os.getenv('MONO64_PREFIX') if mono_root: mono_lib_path = os.path.join(mono_root, 'lib') env.Append(LIBPATH=mono_lib_path) env.Append(CPPPATH=os.path.join(mono_root, 'include', 'mono-2.0')) mono_lib = find_file_in_dir(mono_lib_path, mono_lib_names, prefix='lib', extension='.a') if not mono_lib: raise RuntimeError('Could not find mono library in: ' + mono_lib_path) env.Append(CPPFLAGS=['-D_REENTRANT']) if mono_static: mono_lib_file = os.path.join(mono_lib_path, 'lib' + mono_lib + '.a') if sys.platform == "darwin": env.Append(LINKFLAGS=['-Wl,-force_load,' + mono_lib_file]) elif sys.platform == "linux" or sys.platform == "linux2": env.Append(LINKFLAGS=[ '-Wl,-whole-archive', mono_lib_file, '-Wl,-no-whole-archive' ]) else: raise RuntimeError( 'mono-static: Not supported on this platform') else: env.Append(LIBS=[mono_lib]) if sys.platform == "darwin": env.Append(LIBS=['iconv', 'pthread']) elif sys.platform == "linux" or sys.platform == "linux2": env.Append(LIBS=['m', 'rt', 'dl', 'pthread']) if not mono_static: mono_so_name = find_file_in_dir(mono_lib_path, mono_lib_names, prefix='lib', extension=sharedlib_ext) if not mono_so_name: raise RuntimeError( 'Could not find mono shared library in: ' + mono_lib_path) copy_file_no_replace(mono_lib_path, 'bin', 'lib' + mono_so_name + sharedlib_ext) else: if mono_static: raise RuntimeError( 'mono-static: Not supported with pkg-config. Specify a mono prefix manually' ) env.ParseConfig('pkg-config monosgen-2 --cflags --libs') mono_lib_path = '' mono_so_name = '' tmpenv = Environment() tmpenv.ParseConfig('pkg-config monosgen-2 --libs-only-L') for hint_dir in tmpenv['LIBPATH']: name_found = find_file_in_dir(hint_dir, mono_lib_names, prefix='lib', extension=sharedlib_ext) if name_found: mono_lib_path = hint_dir mono_so_name = name_found break if not mono_so_name: raise RuntimeError('Could not find mono shared library in: ' + str(tmpenv['LIBPATH'])) copy_file_no_replace(mono_lib_path, 'bin', 'lib' + mono_so_name + sharedlib_ext) env.Append(LINKFLAGS='-rdynamic')
import json import sys from os import environ from os.path import expanduser, join from time import time from SCons.Script import (ARGUMENTS, COMMAND_LINE_TARGETS, DEFAULT_TARGETS, AllowSubstExceptions, AlwaysBuild, Default, DefaultEnvironment, Variables) from platformio import util AllowSubstExceptions(NameError) # allow common variables from INI file commonvars = Variables(None) commonvars.AddVariables( ("PLATFORM_MANIFEST",), ("BUILD_SCRIPT",), ("EXTRA_SCRIPTS",), ("PIOENV",), ("PIOTEST",), ("PIOPLATFORM",), ("PIOFRAMEWORK",), # build options ("BUILD_FLAGS",), ("SRC_BUILD_FLAGS",), ("BUILD_UNFLAGS",), ("SRC_FILTER",),
def configure(env, env_mono): from SCons.Script import BoolVariable, PathVariable, Variables envvars = Variables() envvars.Add( PathVariable( 'mono_prefix', 'Path to the mono installation directory for the target platform and architecture', '', PathVariable.PathAccept)) envvars.Add(BoolVariable('mono_static', 'Statically link mono', False)) envvars.Add( BoolVariable( 'copy_mono_root', 'Make a copy of the mono installation directory to bundle with the editor', False)) envvars.Update(env) bits = env['bits'] is_android = env['platform'] == 'android' tools_enabled = env['tools'] mono_static = env['mono_static'] copy_mono_root = env['copy_mono_root'] mono_prefix = env['mono_prefix'] mono_lib_names = ['mono-2.0-sgen', 'monosgen-2.0'] if is_android and not env['android_arch'] in android_arch_dirs: raise RuntimeError( 'This module does not support for the specified \'android_arch\': ' + env['android_arch']) if is_android and tools_enabled: # TODO: Implement this. We have to add the data directory to the apk, concretely the Api and Tools folders. raise RuntimeError( 'This module does not currently support building for android with tools enabled' ) if (os.getenv('MONO32_PREFIX') or os.getenv('MONO64_PREFIX')) and not mono_prefix: print( "WARNING: The environment variables 'MONO32_PREFIX' and 'MONO64_PREFIX' are deprecated; use the 'mono_prefix' SCons parameter instead" ) if env['platform'] == 'windows': mono_root = mono_prefix if not mono_root and os.name == 'nt': mono_root = monoreg.find_mono_root_dir(bits) if not mono_root: raise RuntimeError( "Mono installation directory not found; specify one manually with the 'mono_prefix' SCons parameter" ) print('Found Mono root directory: ' + mono_root) mono_version = mono_root_try_find_mono_version(mono_root) configure_for_mono_version(env_mono, mono_version) mono_lib_path = os.path.join(mono_root, 'lib') env.Append(LIBPATH=mono_lib_path) env_mono.Prepend( CPPPATH=os.path.join(mono_root, 'include', 'mono-2.0')) if mono_static: lib_suffix = Environment()['LIBSUFFIX'] if env.msvc: mono_static_lib_name = 'libmono-static-sgen' else: mono_static_lib_name = 'libmonosgen-2.0' if not os.path.isfile( os.path.join(mono_lib_path, mono_static_lib_name + lib_suffix)): raise RuntimeError('Could not find static mono library in: ' + mono_lib_path) if env.msvc: env.Append(LINKFLAGS=mono_static_lib_name + lib_suffix) env.Append(LINKFLAGS='Mincore' + lib_suffix) env.Append(LINKFLAGS='msvcrt' + lib_suffix) env.Append(LINKFLAGS='LIBCMT' + lib_suffix) env.Append(LINKFLAGS='Psapi' + lib_suffix) else: env.Append(LINKFLAGS=os.path.join( mono_lib_path, mono_static_lib_name + lib_suffix)) env.Append(LIBS='psapi') env.Append(LIBS='version') else: mono_lib_name = find_file_in_dir(mono_lib_path, mono_lib_names, extension='.lib') if not mono_lib_name: raise RuntimeError('Could not find mono library in: ' + mono_lib_path) if env.msvc: env.Append(LINKFLAGS=mono_lib_name + Environment()['LIBSUFFIX']) else: env.Append(LIBS=mono_lib_name) mono_bin_path = os.path.join(mono_root, 'bin') mono_dll_name = find_file_in_dir(mono_bin_path, mono_lib_names, extension='.dll') if not mono_dll_name: raise RuntimeError('Could not find mono shared library in: ' + mono_bin_path) copy_file(mono_bin_path, '#bin', mono_dll_name + '.dll') else: is_apple = (sys.platform == 'darwin' or "osxcross" in env) sharedlib_ext = '.dylib' if is_apple else '.so' mono_root = mono_prefix mono_lib_path = '' mono_so_name = '' if not mono_root and is_android: raise RuntimeError( "Mono installation directory not found; specify one manually with the 'mono_prefix' SCons parameter" ) if not mono_root and is_apple: # Try with some known directories under OSX hint_dirs = [ '/Library/Frameworks/Mono.framework/Versions/Current', '/usr/local/var/homebrew/linked/mono' ] for hint_dir in hint_dirs: if os.path.isdir(hint_dir): mono_root = hint_dir break # We can't use pkg-config to link mono statically, # but we can still use it to find the mono root directory if not mono_root and mono_static: mono_root = pkgconfig_try_find_mono_root(mono_lib_names, sharedlib_ext) if not mono_root: raise RuntimeError("Building with mono_static=yes, but failed to find the mono prefix with pkg-config; " + \ "specify one manually with the 'mono_prefix' SCons parameter") if mono_root: print('Found Mono root directory: ' + mono_root) mono_version = mono_root_try_find_mono_version(mono_root) configure_for_mono_version(env_mono, mono_version) mono_lib_path = os.path.join(mono_root, 'lib') env.Append(LIBPATH=mono_lib_path) env_mono.Prepend( CPPPATH=os.path.join(mono_root, 'include', 'mono-2.0')) mono_lib = find_file_in_dir(mono_lib_path, mono_lib_names, prefix='lib', extension='.a') if not mono_lib: raise RuntimeError('Could not find mono library in: ' + mono_lib_path) env_mono.Append(CPPFLAGS=['-D_REENTRANT']) if mono_static: mono_lib_file = os.path.join(mono_lib_path, 'lib' + mono_lib + '.a') if is_apple: env.Append(LINKFLAGS=['-Wl,-force_load,' + mono_lib_file]) else: env.Append(LINKFLAGS=[ '-Wl,-whole-archive', mono_lib_file, '-Wl,-no-whole-archive' ]) else: env.Append(LIBS=[mono_lib]) if is_apple: env.Append(LIBS=['iconv', 'pthread']) elif is_android: env.Append(LIBS=['m', 'dl']) else: env.Append(LIBS=['m', 'rt', 'dl', 'pthread']) if not mono_static: mono_so_name = find_file_in_dir(mono_lib_path, mono_lib_names, prefix='lib', extension=sharedlib_ext) if not mono_so_name: raise RuntimeError( 'Could not find mono shared library in: ' + mono_lib_path) copy_file(mono_lib_path, '#bin', 'lib' + mono_so_name + sharedlib_ext) else: assert not mono_static # TODO: Add option to force using pkg-config print('Mono root directory not found. Using pkg-config instead') mono_version = pkgconfig_try_find_mono_version() configure_for_mono_version(env_mono, mono_version) env.ParseConfig('pkg-config monosgen-2 --libs') env_mono.ParseConfig('pkg-config monosgen-2 --cflags') tmpenv = Environment() tmpenv.AppendENVPath('PKG_CONFIG_PATH', os.getenv('PKG_CONFIG_PATH')) tmpenv.ParseConfig('pkg-config monosgen-2 --libs-only-L') for hint_dir in tmpenv['LIBPATH']: name_found = find_file_in_dir(hint_dir, mono_lib_names, prefix='lib', extension=sharedlib_ext) if name_found: mono_lib_path = hint_dir mono_so_name = name_found break if not mono_so_name: raise RuntimeError('Could not find mono shared library in: ' + str(tmpenv['LIBPATH'])) if not mono_static: libs_output_dir = get_android_out_dir( env) if is_android else '#bin' copy_file(mono_lib_path, libs_output_dir, 'lib' + mono_so_name + sharedlib_ext) env.Append(LINKFLAGS='-rdynamic') if not tools_enabled and not is_android: if not mono_root: mono_root = subprocess.check_output( ['pkg-config', 'mono-2', '--variable=prefix']).decode('utf8').strip() make_template_dir(env, mono_root) if copy_mono_root: if not mono_root: mono_root = subprocess.check_output( ['pkg-config', 'mono-2', '--variable=prefix']).decode('utf8').strip() if tools_enabled: copy_mono_root_files(env, mono_root) else: print( "Ignoring option: 'copy_mono_root'. Only available for builds with 'tools' enabled." )