Skip to content

Commit

Permalink
feat(configProvider): -v|--version prints version string
Browse files Browse the repository at this point in the history
  • Loading branch information
goerlibe committed Jan 24, 2024
1 parent 8c70103 commit 117ecc3
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions discopop_library/ConfigProvider/ConfigProviderArguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class ConfigProviderArguments(object):
return_dp_build_dir: bool
return_dp_source_dir: bool
return_llvm_bin_dir: bool
return_version_string: bool

def __post_init__(self):
self.__validate()
Expand Down
3 changes: 3 additions & 0 deletions discopop_library/ConfigProvider/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ def parse_args() -> ConfigProviderArguments:
help="Return the path to the DiscoPoP source directory")
mutually_exclusive.add_argument("--llvm-bin-dir", action="store_true",
help="Return the path to the LLVM bin directory")
mutually_exclusive.add_argument("-v", "--version", action="store_true",
help="Return the version string of the DiscoPoP library")
# EXPERIMENTAL FLAGS:
# fmt: on

Expand All @@ -32,6 +34,7 @@ def parse_args() -> ConfigProviderArguments:
return_dp_build_dir=arguments.dp_build_dir,
return_dp_source_dir=arguments.dp_source_dir,
return_llvm_bin_dir=arguments.llvm_bin_dir,
return_version_string=arguments.version,
)


Expand Down
3 changes: 3 additions & 0 deletions discopop_library/ConfigProvider/config_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

from discopop_library.ConfigProvider.ConfigProviderArguments import ConfigProviderArguments
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:
Expand All @@ -19,5 +20,7 @@ def run(arguments: ConfigProviderArguments) -> str:
return DP_SOURCE # type: ignore
elif arguments.return_llvm_bin_dir:
return LLVM_BIN_DIR # type: ignore
elif arguments.return_version_string:
return get_version()
else:
raise ValueError("No valid operation for execution configuration: \n" + str(arguments))
8 changes: 6 additions & 2 deletions discopop_library/PatchGenerator/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,16 @@ 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)
ConfigProviderArguments(
return_dp_build_dir=True, return_dp_source_dir=False, return_llvm_bin_dir=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)
ConfigProviderArguments(
return_dp_build_dir=False, return_dp_source_dir=False, return_llvm_bin_dir=True, return_version_string=False
)
)
# determine CC
if os.path.exists(os.path.join(llvm_bin_dir, "clang")):
Expand Down

0 comments on commit 117ecc3

Please sign in to comment.