diff --git a/SConscript b/SConscript index 58c47ac..8731133 100644 --- a/SConscript +++ b/SConscript @@ -126,7 +126,8 @@ def _deps_from_json(env: Environment, deps: dict) -> dict: for key, dep in deps.items(): if 'condition' in dep: if not _safe_eval(dep['condition'], { - 'compiler_family': env['COMPILER_FAMILY'] + 'compiler_family': env['COMPILER_FAMILY'], + 'target_os': os.name }): to_remove.append(key) continue @@ -340,7 +341,7 @@ def _build_target(target: _Target): for lib in libs_copy: if isinstance(lib, str) and os.path.isabs(lib): target.kwargs['LIBS'].remove(lib) - target.kwargs['source'].append(lib) + target.kwargs['source'].append(env.Entry(lib)) elif isinstance(lib, _Target): if not lib.target: _build_target(lib) @@ -404,6 +405,9 @@ if not config.get('PREPROCESSOR_PREFIX'): if 'COMPILATIONDB_FILTER_FILES' not in config: config['COMPILATIONDB_FILTER_FILES'] = True +if 'WINDOWS_DISABLE_DEFAULT_DEFINES' not in config: + config['WINDOWS_DISABLE_DEFAULT_DEFINES'] = False + AddOption( '--build_type', dest = 'build_type', @@ -687,6 +691,11 @@ if env['COMPILER_FAMILY'] == 'gcc': elif env['COMPILER_FAMILY'] == 'clang': env.Append(CCFLAGS = ['-Wno-deprecated-volatile', '-Wno-nested-anon-types', '-Wno-unknown-warning-option']) +# platform specific options +if os.name == 'nt': + if not config['WINDOWS_DISABLE_DEFAULT_DEFINES']: + env.Append(CDEFINES = ['WIN32_LEAN_AND_MEAN', 'NOMINMAX', 'STRICT', 'UNICODE'], CPPDEFINES = ['WIN32_LEAN_AND_MEAN', 'NOMINMAX', 'STRICT', 'UNICODE']) + env.AddMethod(_cook, 'Cook') env.AddMethod(_parse_lib_conf, 'ParseLibConf') env.AddMethod(_rglob, 'RGlob') diff --git a/recipes/winsock2/recipe.py b/recipes/winsock2/recipe.py new file mode 100644 index 0000000..6d96684 --- /dev/null +++ b/recipes/winsock2/recipe.py @@ -0,0 +1,23 @@ + + +import os +from SCons.Script import * + + +def available(env: Environment): + if os.name != 'nt': + return 'Winsock2 is only available on Windows.' + +def versions(env: Environment, update: bool = False): + if os.name == 'nt': + return [(0, 0, 0)] + else: + return [] + +def dependencies(env: Environment, version) -> 'dict': + return {} + +def cook(env: Environment, version) -> dict: + return { + 'LIBS': ['Ws2_32'] + }