diff --git a/SConscript b/SConscript index 6707211..97fbdff 100644 --- a/SConscript +++ b/SConscript @@ -529,6 +529,8 @@ def _build_target(target: _Target): new_kwargs = target.kwargs.copy() if 'target' in new_kwargs: # there should always be a target, right? new_kwargs['target'] = f"{new_kwargs['target']}-{build_type}" + if os.name == 'nt' and 'PDB' not in new_kwargs: + new_kwargs['PDB'] = f'{new_kwargs["target"]}.pdb' target.target = target.builder(*target.args, **new_kwargs) def _version_to_string(version) -> str: @@ -641,52 +643,33 @@ def _generate_project(project_type: str) -> None: return result root_path = pathlib.Path(env.Dir('#').abspath) + + def _make_entry(target, type, prefix, suffix) -> str: + def _full_path(build_type) -> str: + trgt = _target_entry(target.kwargs['target']) + full_path = pathlib.Path(trgt.abspath).relative_to(root_path) + full_path = full_path.parent / f'{env.subst(prefix)}{full_path.name}-{build_type}{env.subst(suffix)}' + return str(full_path) + return { + 'name': target.name, + 'filename': _full_path, + 'target': target, + 'type': type, + 'module': target.module + } def _get_executables() -> list: result = [] for target in env['SPP_TARGETS']: if target.target_type == TargetType.PROGRAM: - trgt = _target_entry(target.kwargs['target']) - def _exe_path(build_type) -> str: - exe_path = pathlib.Path(trgt.abspath).relative_to(root_path) - exe_path = exe_path.parent / f'{env.subst("$PROGPREFIX")}{exe_path.name}-{build_type}{env.subst("$PROGSUFFIX")}' - return str(exe_path) - result.append({ - 'name': target.name, - 'filename': _exe_path, - 'target': target, - 'type': 'executable', - 'module': target.module - }) + result.append(_make_entry(target, 'executable', '$PROGPREFIX', '$PROGSUFFIX')) return result def _get_libraries() -> list: result = [] for target in env['SPP_TARGETS']: if target.target_type == TargetType.STATIC_LIBRARY: - trgt = _target_entry(target.kwargs['target']) - def _lib_path(build_type) -> str: - lib_path = pathlib.Path(trgt.abspath).relative_to(root_path) - lib_path = lib_path.parent / f'{env.subst("$LIBPREFIX")}{lib_path.name}-{build_type}{env.subst("$LIBSUFFIX")}' - return str(lib_path) - result.append({ - 'name': target.name, - 'filename': _lib_path, - 'target': target, - 'type': 'static_library', - 'module': target.module - }) + result.append(_make_entry(target, 'executable', '$LIBPREFIX', '$LIBSUFFIX')) elif target.target_type == TargetType.SHARED_LIBRARY: - trgt = _target_entry(target.kwargs['target']) - def _lib_path(build_type) -> str: - lib_path = pathlib.Path(trgt.abspath).relative_to(root_path) - lib_path = lib_path.parent / f'{env.subst("$SHLIBPREFIX")}{lib_path.name}-{build_type}{env.subst("$SHLIBSUFFIX")}' - return str(lib_path) - result.append({ - 'name': target.name, - 'filename': _lib_path, - 'target': target, - 'type': 'static_library', - 'module': target.module - }) + result.append(_make_entry(target, 'executable', '$SHLIBPREFIX', '$SHLIBSUFFIX')) return result def _get_modules() -> list: result = [] @@ -1303,13 +1286,13 @@ elif env['COMPILER_FAMILY'] == 'cl': if env['SHOW_INCLUDES']: env.Append(CCFLAGS = ['/showIncludes']) if build_type == 'debug': - env['PDB'] = env.File('#bin/full.pdb') + #env['PDB'] = env.File('#bin/full.pdb') env.Append(CCFLAGS = ['/Od', '/MDd'], LINKFLAGS = ' /DEBUG') env.Append(CPPDEFINES = ['_DEBUG', '_ITERATOR_DEBUG_LEVEL=2']) env.Append(DEPS_CXXFLAGS = ['/MDd', '/Zi', '/D_DEBUG', '/D_ITERATOR_DEBUG_LEVEL=2']) env.Append(DEPS_LINKFLAGS = ['/DEBUG']) elif build_type == 'release_debug' or build_type == 'profile': - env['PDB'] = env.File('#bin/full.pdb') + #env['PDB'] = env.File('#bin/full.pdb') env.Append(CCFLAGS = ['/O2', '/MD'], LINKFLAGS = ' /DEBUG') env.Append(DEPS_CXXFLAGS = ['/Zi', '/MD']) env.Append(DEPS_LINKFLAGS = ['/DEBUG']) diff --git a/addons/download_and_extract.py b/addons/download_and_extract.py index 3cd58ea..9186360 100644 --- a/addons/download_and_extract.py +++ b/addons/download_and_extract.py @@ -37,19 +37,22 @@ def _download_file(url: str, path: pathlib.Path) -> None: urllib.request.urlretrieve(url, dl_path) dl_path.rename(path) -def _extract_file(path: pathlib.Path, output_dir: str, archive_type: ArchiveType, skip_folders: int) -> None: +def _extract_file(path: pathlib.Path, output_dir: str, archive_type: ArchiveType, skip_folders: int = 0) -> None: if archive_type == ArchiveType.TAR_GZ: file = tarfile.open(str(path)) + filter = tarfile.data_filter if skip_folders != 0: - def skip_filer(member: tarfile.TarInfo, path: str) -> tarfile.TarInfo: - name_parts = member.name.split('/') + def skip_filter(member: tarfile.TarInfo, path: str) -> tarfile.TarInfo: + name_parts = member.name.split('/', skip_folders) if len(name_parts) <= skip_folders: return None return member.replace(name = '/'.join(name_parts[skip_folders:])) - file.extraction_filter = skip_filer - file.extractall(output_dir) + filter = skip_filter + file.extractall(output_dir, filter=filter) file.close() elif archive_type == ArchiveType.ZIP: + if skip_folders != 0: + raise Exception('skip_folders option is not yet supported for zip-archives :()') file = zipfile.open(str(path)) file.extractall(output_dir) file.close() diff --git a/util/vs_project_template/solution.sln.jinja b/util/vs_project_template/solution.sln.jinja index 2629268..5f7d834 100644 --- a/util/vs_project_template/solution.sln.jinja +++ b/util/vs_project_template/solution.sln.jinja @@ -5,13 +5,16 @@ VisualStudioVersion = 17.10.35122.118 MinimumVisualStudioVersion = 10.0.40219.1 {%- for executable in project.executables %} Project("{{ generate_uuid(project.name, True) }}") = "{{ executable.name }}", "vs_project_files\{{ executable.name }}.vcxproj", ""{{ generate_uuid('target_' + executable.name, True) }}"" +{%- endfor %} +{%- for library in project.libraries %} +Project("{{ generate_uuid(project.name, True) }}") = "{{ library.name }}", "vs_project_files\{{ library.name }}.vcxproj", ""{{ generate_uuid('target_' + library.name, True) }}"" +{%- endfor %} EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{{ generate_uuid('solution_items', True) }}" ProjectSection(SolutionItems) = preProject SConstruct = SConstruct EndProjectSection EndProject -{%- endfor %} Global GlobalSection(SolutionConfigurationPlatforms) = preSolution {%- for build_type in project.build_types %} @@ -27,6 +30,13 @@ Global {{ generate_uuid('target_' + executable.name, True) }}.{{ build_type_name }}|x64.Build.0 = {{ build_type_name }}|x64 {%- endfor %} {%- endfor %} + {%- for library in project.libraries %} + {%- for build_type in project.build_types %} + {%- set build_type_name = build_type | capitalize %} + {{ generate_uuid('target_' + library.name, True) }}.{{ build_type_name }}|x64.ActiveCfg = {{ build_type_name }}|x64 + {{ generate_uuid('target_' + library.name, True) }}.{{ build_type_name }}|x64.Build.0 = {{ build_type_name }}|x64 + {%- endfor %} + {%- endfor %} EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE