This repository has been archived by the owner on Jun 14, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…er-env Feature/#135/save compiler env
- Loading branch information
Showing
12 changed files
with
158 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
meson >= 0.57 | ||
vswhere >= 1.3 | ||
colorama >= 0.4.4 | ||
colorama >= 0.4.4 | ||
javaproperties >= 0.8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
conf/script/src/build_system/cmd/setup/cli/compiler_env.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from typing import Final | ||
|
||
import build_system.build_target.build_target | ||
|
||
|
||
def print_compiler_env_file(target: build_system.build_target.build_target.BuildTarget) -> None: | ||
from build_system.cmd.setup.cli.colorize import colorize_label, colorize_path | ||
|
||
label: Final[str] = colorize_label(label='Compiler env') + ': ' | ||
|
||
colorized_symlink = colorize_path(path_info=target.compiler_env_file) | ||
|
||
print(label, end=str()) | ||
print(colorized_symlink) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
conf/script/src/build_system/cmd/setup/setup_steps/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
from build_system.cmd.setup.setup_steps.step_create_symlimks_to_compilers_export_shell_env_script import create_symlinks_to_compilers_export_shell_env_script | ||
from build_system.cmd.setup.setup_steps.step_create_symlimks_to_compilers_export_shell_env_scripts import create_symlinks_to_compilers_export_shell_env_scripts | ||
from build_system.cmd.setup.setup_steps.step_create_targets_build_dirs import create_targets_build_dirs | ||
from build_system.cmd.setup.setup_steps.step_fetch_host_compilers import fetch_host_compilers | ||
from build_system.cmd.setup.setup_steps.step_get_root_dir import get_verified_root_dir | ||
from build_system.cmd.setup.setup_steps.step_save_compiler_env import save_compiler_instances_targets_env | ||
from build_system.cmd.setup.setup_steps.step_setup_targets import setup_targets |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
conf/script/src/build_system/cmd/setup/setup_steps/step_save_compiler_env.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import os | ||
from pathlib import Path | ||
|
||
import javaproperties | ||
|
||
import build_system.build_target.build_target | ||
import build_system.build_target.compiler_instance_targets | ||
from build_system.cmd.hierarchy.consts import BUILD_DIR_PERMISSIONS, TARGET_SCRIPT_COMPILER_ENV_NAME, UTF_8 | ||
|
||
|
||
def save_compiler_instances_targets_env(targets: list[build_system.build_target.compiler_instance_targets.CompilerInstanceTargets], | ||
cli_mode: bool) -> None: | ||
for compiler_instance_targets in targets: | ||
if compiler_instance_targets.compiler_instance.has_export_shell_env_script(): | ||
for target in compiler_instance_targets: | ||
_save_compiler_target_env(target=target, cli_mode=cli_mode) | ||
|
||
|
||
def _save_compiler_target_env(target: build_system.build_target.build_target.BuildTarget, | ||
cli_mode: bool) -> None: | ||
from build_system.cmd.setup.cli.compiler_env import print_compiler_env_file | ||
|
||
encoded_env = _encode_env(target=target) | ||
|
||
env_file = _create_target_compiler_env_file(target=target) | ||
env_file.write_text(data=encoded_env, encoding=UTF_8) | ||
|
||
_cache_target_compiler_env_file(target=target, env_file=env_file) | ||
|
||
if cli_mode: | ||
print_compiler_env_file(target=target) | ||
|
||
|
||
def _encode_env(target: build_system.build_target.build_target.BuildTarget) -> str: | ||
assert target.compiler_instance.has_cached_compiler_env() | ||
|
||
target_compiler_env: dict[str, str] = _multi_line_compiler_env_to_single_line(compiler_env=target.compiler_instance.cached_compiler_env) | ||
encoded_env: str = javaproperties.dumps(props=target_compiler_env, timestamp=False) | ||
|
||
return encoded_env | ||
|
||
|
||
def _create_target_compiler_env_file(target: build_system.build_target.build_target.BuildTarget) -> Path: | ||
target_compiler_env_file: Path = target.script_dir / TARGET_SCRIPT_COMPILER_ENV_NAME | ||
target_compiler_env_file.touch(mode=BUILD_DIR_PERMISSIONS, exist_ok=True) | ||
|
||
return target_compiler_env_file | ||
|
||
|
||
def _cache_target_compiler_env_file(target: build_system.build_target.build_target.BuildTarget, | ||
env_file: Path) -> None: | ||
target.compiler_env_file = env_file | ||
|
||
|
||
def _multi_line_compiler_env_to_single_line(compiler_env: [dict[str, list[str]]]) -> [dict[str, str]]: | ||
single_line_compiler_env: [dict[str, str]] = {} | ||
|
||
for env_key, env_value in compiler_env.items(): | ||
single_line_env_value: str = os.pathsep.join(env_value) | ||
single_line_compiler_env[env_key] = single_line_env_value | ||
|
||
return single_line_compiler_env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.