Skip to content

Commit

Permalink
fix: minor
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasrothenberger committed Jun 20, 2024
1 parent 9e788d5 commit e78b325
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 10 deletions.
21 changes: 13 additions & 8 deletions discopop_library/ConfigProvider/config_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,31 @@
# the 3-Clause BSD License. See the LICENSE file in the package base
# directory for details.

import os
from pathlib import Path
from discopop_library.ConfigProvider.ConfigProviderArguments import ConfigProviderArguments
from discopop_library.ConfigProvider.assets import build_config # DP_BUILD, DP_SOURCE, LLVM_BIN_DIR # type: ignore
from discopop_library.ConfigProvider.assets.build_config import DP_BUILD, DP_SOURCE, LLVM_BIN_DIR # type: ignore
from discopop_library.global_data.version.utils import get_version


def run(arguments: ConfigProviderArguments) -> str:
"""Returns the contents of the written build_config.txt"""

if arguments.return_dp_build_dir:
return build_config.DP_BUILD # type: ignore
return DP_BUILD # type: ignore
elif arguments.return_dp_source_dir:
return build_config.DP_SOURCE # type: ignore
return DP_SOURCE # type: ignore
elif arguments.return_llvm_bin_dir:
return build_config.LLVM_BIN_DIR # type: ignore
return LLVM_BIN_DIR # type: ignore
elif arguments.return_full_config:
ret_str = ""
for name in [n for n in build_config.__dict__ if not n.startswith("_")]:
if len(ret_str) != 0:
ret_str += "\n"
ret_str += name +": " + build_config.__dict__[name]
assets_path = os.path.join(Path(__file__).parent.absolute(), "assets", "build_config.py")
with open(assets_path, "r") as f:
for line in f.readlines():
ret_str += line
# remove trailing \n
if ret_str[-1] == "\n":
ret_str = ret_str[:-1]
return ret_str
elif arguments.return_version_string:
return get_version()
Expand Down
12 changes: 10 additions & 2 deletions discopop_library/PatchGenerator/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,22 @@ def parse_args() -> PatchGeneratorArguments:
# determine DP build path
arguments.dp_build_path = run_config_provider(
ConfigProviderArguments(
return_dp_build_dir=True, return_dp_source_dir=False, return_llvm_bin_dir=False, return_version_string=False
return_dp_build_dir=True,
return_dp_source_dir=False,
return_llvm_bin_dir=False,
return_full_config=False,
return_version_string=False,
)
)

# determine LLVM_BIN_DIR
llvm_bin_dir = run_config_provider(
ConfigProviderArguments(
return_dp_build_dir=False, return_dp_source_dir=False, return_llvm_bin_dir=True, return_version_string=False
return_dp_build_dir=False,
return_dp_source_dir=False,
return_llvm_bin_dir=True,
return_full_config=False,
return_version_string=False,
)
)
# determine CC
Expand Down

0 comments on commit e78b325

Please sign in to comment.