Skip to content

Commit

Permalink
Updated
Browse files Browse the repository at this point in the history
Added WholeProgramOptimization, AdditionalIncludeDirectories, AdditionalUsingDirectories, PreprocessorDefinitions
  • Loading branch information
burgerbecky committed Oct 8, 2024
1 parent 34969c4 commit 0e9b3aa
Showing 1 changed file with 139 additions and 39 deletions.
178 changes: 139 additions & 39 deletions makeprojects/visual_studio.py
Original file line number Diff line number Diff line change
Expand Up @@ -1104,6 +1104,128 @@ def OptimizeForWindowsApplication(configuration, fallback=None):
fallback=fallback)
return None

########################################


def WholeProgramOptimization(configuration, fallback=None):
"""
Create ``WholeProgramOptimization`` property.
Enables cross-module optimizations by delaying code generation to link
time; requires that linker option ``Link Time Code Generation`` be turned
on.
Compiler switch /GL
Can be overridden with configuration attribute
``vs_WholeProgramOptimization`` for the C compiler.
Args:
configuration: Project configuration to scan for overrides.
fallback: Default value to use
Returns:
None or VSBooleanProperty object.
"""

if configuration.ide is not IDETypes.vs2003:
return VSBooleanProperty.vs_validate(
"WholeProgramOptimization",
configuration,
fallback=fallback)
return None

########################################


def AdditionalIncludeDirectories(configuration, fallback=None):
"""
Create ``AdditionalIncludeDirectories`` property.
List of include folders for the C compiler
Can be overridden with configuration attribute
``vs_AdditionalIncludeDirectories`` for the C compiler.
Args:
configuration: Project configuration to scan for overrides.
fallback: Default value to use
Returns:
validators.VSStringListProperty object.
"""

# Was there an override?
value = configuration.get_unique_chained_list(
"vs_AdditionalIncludeDirectories")
if value:
fallback = value

return VSStringListProperty(
"AdditionalIncludeDirectories",
fallback=fallback,
slashes="\\")

########################################


def AdditionalUsingDirectories(configuration, fallback=None):
"""
Create ``AdditionalUsingDirectories`` property.
List of include folders for the #using operation.
Can be overridden with configuration attribute
``vs_AdditionalUsingDirectories`` for the C compiler.
Args:
configuration: Project configuration to scan for overrides.
fallback: Default value to use
Returns:
validators.VSStringListProperty object.
"""

# Was there an override?
value = configuration.get_unique_chained_list(
"vs_AdditionalUsingDirectories")
if value:
fallback = value

return VSStringListProperty(
"AdditionalUsingDirectories",
fallback=fallback,
slashes="\\")

########################################


def PreprocessorDefinitions(configuration, fallback=None):
"""
Create ``PreprocessorDefinitions`` property.
List of defines to pass to the C compiler
Can be overridden with configuration attribute
``vs_PreprocessorDefinitions`` for the C compiler.
Args:
configuration: Project configuration to scan for overrides.
fallback: Default value to use
Returns:
validators.VSStringListProperty object.
"""

# Was there an override?
value = configuration.get_chained_list(
"vs_PreprocessorDefinitions")
if value:
fallback = value

return VSStringListProperty(
"PreprocessorDefinitions",
fallback=fallback)

# Boolean properties

Expand Down Expand Up @@ -1212,27 +1334,6 @@ def BoolATLMinimizesCRunTimeLibraryUsage(configuration):
return None


def BoolWholeProgramOptimization(configuration):
""" WholeProgramOptimization
Enables cross-module optimizations by delaying code generation to link
time; requires that linker option ``Link Time Code Generation`` be turned
on.
Compiler switch /GL
Args:
configuration: Project configuration to scan for overrides.
Returns:
None or VSBooleanProperty object.
"""
return VSBooleanProperty.vs_validate(
"WholeProgramOptimization", configuration,
configuration.link_time_code_generation,
options_key="compiler_options",
options=(("/GT", True),))


def BoolIgnoreStandardIncludePath(configuration):
""" IgnoreStandardIncludePath
Expand Down Expand Up @@ -2624,36 +2725,35 @@ def __init__(self, configuration):
configuration,
True))

# WIP below
# Enable cross function optimizations
if configuration.ide is not IDETypes.vs2003:
self.add_default(
BoolWholeProgramOptimization(configuration))
self.add_default(
WholeProgramOptimization(
configuration,
configuration.link_time_code_generation))

# Get the header includes
default = configuration.get_unique_chained_list(
item = configuration.get_unique_chained_list(
"_source_include_list")
default.extend(configuration.get_unique_chained_list(
item.extend(configuration.get_unique_chained_list(
"include_folders_list"))
self.add_default(VSStringListProperty(
"AdditionalIncludeDirectories",
default,
slashes="\\"))
self.add_default(
AdditionalIncludeDirectories(
configuration,
item))

# Directory for #using includes
self.add_default(
VSStringListProperty(
"AdditionalUsingDirectories",
[],
slashes="\\"))
AdditionalUsingDirectories(
configuration))

# Get the defines
define_list = configuration.get_chained_list("define_list")
item = configuration.get_chained_list("define_list")
self.add_default(
VSStringListProperty(
"PreprocessorDefinitions",
define_list))
PreprocessorDefinitions(
configuration,
item))

# WIP below
# Ignore standard include path if true
self.add_default(BoolIgnoreStandardIncludePath(configuration))

Expand Down

0 comments on commit 0e9b3aa

Please sign in to comment.