Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SCons : Add scu_limit argument #78959

Merged
merged 1 commit into from
Aug 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ opts.Add(
)
opts.Add(BoolVariable("use_precise_math_checks", "Math checks use very precise epsilon (debug option)", False))
opts.Add(BoolVariable("scu_build", "Use single compilation unit build", False))
opts.Add("scu_limit", "Max includes per SCU file when using scu_build (determines RAM use)", "0")

# Thirdparty libraries
opts.Add(BoolVariable("builtin_certs", "Use the built-in SSL certificates bundles", True))
Expand Down Expand Up @@ -549,7 +550,16 @@ if selected_platform in platform_list:

# Run SCU file generation script if in a SCU build.
if env["scu_build"]:
methods.set_scu_folders(scu_builders.generate_scu_files(env["verbose"], env_base.dev_build == False))
max_includes_per_scu = 8
if env_base.dev_build == True:
max_includes_per_scu = 1024

read_scu_limit = int(env["scu_limit"])
read_scu_limit = max(0, min(read_scu_limit, 1024))
if read_scu_limit != 0:
max_includes_per_scu = read_scu_limit

methods.set_scu_folders(scu_builders.generate_scu_files(env["verbose"], max_includes_per_scu))

# Must happen after the flags' definition, as configure is when most flags
# are actually handled to change compile options, etc.
Expand Down
23 changes: 12 additions & 11 deletions scu_builders.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
base_folder_path = str(Path(__file__).parent) + "/"
base_folder_only = os.path.basename(os.path.normpath(base_folder_path))
_verbose = False
_is_release_build = False
_scu_folders = set()
_max_includes_per_scu = 1024


def clear_out_existing_files(output_folder, extension):
Expand Down Expand Up @@ -197,13 +197,14 @@ def process_folder(folders, sought_exceptions=[], includes_per_scu=0, extension=

# adjust number of output files according to whether DEV or release
num_output_files = 1
if _is_release_build:
# always have a maximum in release
includes_per_scu = 8
num_output_files = max(math.ceil(total_lines / float(includes_per_scu)), 1)

if includes_per_scu == 0:
includes_per_scu = _max_includes_per_scu
else:
if includes_per_scu > 0:
num_output_files = max(math.ceil(total_lines / float(includes_per_scu)), 1)
if includes_per_scu > _max_includes_per_scu:
includes_per_scu = _max_includes_per_scu

num_output_files = max(math.ceil(total_lines / float(includes_per_scu)), 1)

lines_per_file = math.ceil(total_lines / float(num_output_files))
lines_per_file = max(lines_per_file, 1)
Expand Down Expand Up @@ -241,15 +242,15 @@ def process_folder(folders, sought_exceptions=[], includes_per_scu=0, extension=
)


def generate_scu_files(verbose, is_release_build):
def generate_scu_files(verbose, max_includes_per_scu):
print("=============================")
print("Single Compilation Unit Build")
print("=============================")
print("Generating SCU build files")
global _verbose
_verbose = verbose
global _is_release_build
_is_release_build = is_release_build
global _max_includes_per_scu
_max_includes_per_scu = max_includes_per_scu
print("Generating SCU build files... (max includes per scu " + str(_max_includes_per_scu) + ")")

curr_folder = os.path.abspath("./")

Expand Down