Fixed .sln generation (a little) and changed config to create one .pdb per target.

This commit is contained in:
Patrick Wuttke 2025-09-12 09:56:26 +02:00
parent e19f6115be
commit 07c2496342
3 changed files with 40 additions and 44 deletions

View File

@ -529,6 +529,8 @@ def _build_target(target: _Target):
new_kwargs = target.kwargs.copy() new_kwargs = target.kwargs.copy()
if 'target' in new_kwargs: # there should always be a target, right? if 'target' in new_kwargs: # there should always be a target, right?
new_kwargs['target'] = f"{new_kwargs['target']}-{build_type}" 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) target.target = target.builder(*target.args, **new_kwargs)
def _version_to_string(version) -> str: def _version_to_string(version) -> str:
@ -641,52 +643,33 @@ def _generate_project(project_type: str) -> None:
return result return result
root_path = pathlib.Path(env.Dir('#').abspath) 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: def _get_executables() -> list:
result = [] result = []
for target in env['SPP_TARGETS']: for target in env['SPP_TARGETS']:
if target.target_type == TargetType.PROGRAM: if target.target_type == TargetType.PROGRAM:
trgt = _target_entry(target.kwargs['target']) result.append(_make_entry(target, 'executable', '$PROGPREFIX', '$PROGSUFFIX'))
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
})
return result return result
def _get_libraries() -> list: def _get_libraries() -> list:
result = [] result = []
for target in env['SPP_TARGETS']: for target in env['SPP_TARGETS']:
if target.target_type == TargetType.STATIC_LIBRARY: if target.target_type == TargetType.STATIC_LIBRARY:
trgt = _target_entry(target.kwargs['target']) result.append(_make_entry(target, 'executable', '$LIBPREFIX', '$LIBSUFFIX'))
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
})
elif target.target_type == TargetType.SHARED_LIBRARY: elif target.target_type == TargetType.SHARED_LIBRARY:
trgt = _target_entry(target.kwargs['target']) result.append(_make_entry(target, 'executable', '$SHLIBPREFIX', '$SHLIBSUFFIX'))
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
})
return result return result
def _get_modules() -> list: def _get_modules() -> list:
result = [] result = []
@ -1303,13 +1286,13 @@ elif env['COMPILER_FAMILY'] == 'cl':
if env['SHOW_INCLUDES']: if env['SHOW_INCLUDES']:
env.Append(CCFLAGS = ['/showIncludes']) env.Append(CCFLAGS = ['/showIncludes'])
if build_type == 'debug': 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(CCFLAGS = ['/Od', '/MDd'], LINKFLAGS = ' /DEBUG')
env.Append(CPPDEFINES = ['_DEBUG', '_ITERATOR_DEBUG_LEVEL=2']) env.Append(CPPDEFINES = ['_DEBUG', '_ITERATOR_DEBUG_LEVEL=2'])
env.Append(DEPS_CXXFLAGS = ['/MDd', '/Zi', '/D_DEBUG', '/D_ITERATOR_DEBUG_LEVEL=2']) env.Append(DEPS_CXXFLAGS = ['/MDd', '/Zi', '/D_DEBUG', '/D_ITERATOR_DEBUG_LEVEL=2'])
env.Append(DEPS_LINKFLAGS = ['/DEBUG']) env.Append(DEPS_LINKFLAGS = ['/DEBUG'])
elif build_type == 'release_debug' or build_type == 'profile': 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(CCFLAGS = ['/O2', '/MD'], LINKFLAGS = ' /DEBUG')
env.Append(DEPS_CXXFLAGS = ['/Zi', '/MD']) env.Append(DEPS_CXXFLAGS = ['/Zi', '/MD'])
env.Append(DEPS_LINKFLAGS = ['/DEBUG']) env.Append(DEPS_LINKFLAGS = ['/DEBUG'])

View File

@ -37,19 +37,22 @@ def _download_file(url: str, path: pathlib.Path) -> None:
urllib.request.urlretrieve(url, dl_path) urllib.request.urlretrieve(url, dl_path)
dl_path.rename(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: if archive_type == ArchiveType.TAR_GZ:
file = tarfile.open(str(path)) file = tarfile.open(str(path))
filter = tarfile.data_filter
if skip_folders != 0: if skip_folders != 0:
def skip_filer(member: tarfile.TarInfo, path: str) -> tarfile.TarInfo: def skip_filter(member: tarfile.TarInfo, path: str) -> tarfile.TarInfo:
name_parts = member.name.split('/') name_parts = member.name.split('/', skip_folders)
if len(name_parts) <= skip_folders: if len(name_parts) <= skip_folders:
return None return None
return member.replace(name = '/'.join(name_parts[skip_folders:])) return member.replace(name = '/'.join(name_parts[skip_folders:]))
file.extraction_filter = skip_filer filter = skip_filter
file.extractall(output_dir) file.extractall(output_dir, filter=filter)
file.close() file.close()
elif archive_type == ArchiveType.ZIP: 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 = zipfile.open(str(path))
file.extractall(output_dir) file.extractall(output_dir)
file.close() file.close()

View File

@ -5,13 +5,16 @@ VisualStudioVersion = 17.10.35122.118
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
{%- for executable in project.executables %} {%- 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) }}"" 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 EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{{ generate_uuid('solution_items', True) }}" Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{{ generate_uuid('solution_items', True) }}"
ProjectSection(SolutionItems) = preProject ProjectSection(SolutionItems) = preProject
SConstruct = SConstruct SConstruct = SConstruct
EndProjectSection EndProjectSection
EndProject EndProject
{%- endfor %}
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
{%- for build_type in project.build_types %} {%- 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 {{ generate_uuid('target_' + executable.name, True) }}.{{ build_type_name }}|x64.Build.0 = {{ build_type_name }}|x64
{%- endfor %} {%- endfor %}
{%- 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 EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE