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

Fix phasar research tool to enable container build #664

Open
wants to merge 8 commits into
base: vara-dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 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
4 changes: 2 additions & 2 deletions varats/varats/tools/driver_build_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ def print_up_to_date_message(research_tool: ResearchTool[VaRACodeBase]) -> None:
)
if not research_tool.is_up_to_date():
print(
f"{colors.LightYellow}VaRA is outdated! Newest major release "
f"version is {colors.bold}{colors.LightBlue}"
f"{colors.LightYellow}{research_tool.name} is outdated! "
f"Newest major release version is {colors.bold}{colors.LightBlue}"
f"{highest_release_version}{colors.bold.reset}{colors.fg.reset}\n"
)

Expand Down
42 changes: 30 additions & 12 deletions varats/varats/tools/research_tools/phasar.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@
layout and implements automatic configuration and setup."""
import os
import shutil
import tempfile
import typing as tp
from pathlib import Path

from benchbuild.utils.settings import get_number_of_jobs
from plumbum import local
from PyQt5 import QtCore
from PyQt5.QtCore import QProcess

from varats.tools.research_tools.cmake_util import set_cmake_var
Expand All @@ -23,7 +26,7 @@
)
from varats.utils.exceptions import ProcessTerminatedError
from varats.utils.logger_util import log_without_linesep
from varats.utils.settings import save_config, vara_cfg
from varats.utils.settings import save_config, vara_cfg, bb_cfg

if tp.TYPE_CHECKING:
from varats.containers import containers # pylint: disable=W0611
Expand Down Expand Up @@ -151,6 +154,10 @@ def setup(
self.code_base.checkout_phasar_version(use_dev_branch)
self.code_base.setup_submodules()

def is_up_to_date(self) -> bool:
"""Returns true if Phasar's major release version is up to date."""
return True

def upgrade(self) -> None:
"""Upgrade the research tool to a newer version."""
self.code_base.pull()
Expand All @@ -172,15 +179,37 @@ def build(
).path / "build"

build_path /= build_type.build_folder(build_folder_suffix)
llvm_install_dir = build_path / "deps/llvm-14"

# Setup configured build folder
print(" - Setting up build folder.")
if not os.path.exists(build_path):
try:
os.makedirs(build_path, exist_ok=True)

with tempfile.TemporaryDirectory() as tmp_dir:
with ProcessManager.create_process(
"./utils/install-llvm.sh", [
str(get_number_of_jobs(bb_cfg())),
str(tmp_dir),
str(llvm_install_dir), "llvmorg-14.0.6"
],
workdir=self.source_location() / "phasar"
) as proc:
proc.setProcessChannelMode(QProcess.MergedChannels)
proc.readyReadStandardOutput.connect(
lambda: run_process_with_output(
proc, log_without_linesep(print)
)
)

with ProcessManager.create_process(
"cmake", ["-G", "Ninja", "../.."], workdir=build_path
) as proc:
env = QtCore.QProcessEnvironment.systemEnvironment()
env.insert("CC", str(llvm_install_dir / "bin/clang"))
env.insert("CXX", str(llvm_install_dir / "bin/clang++"))
proc.setProcessEnvironment(env)
proc.setProcessChannelMode(QProcess.MergedChannels)
proc.readyReadStandardOutput.connect(
lambda: run_process_with_output(
Expand Down Expand Up @@ -229,17 +258,6 @@ def verify_build(
) -> bool:
return True

def container_add_build_layer(
self, image_context: 'containers.BaseImageCreationContext'
) -> None:
"""
Add layers for building this research tool to the given container.

Args:
image_context: the base image creation context
"""
raise NotImplementedError

def container_install_tool(
self, image_context: 'containers.BaseImageCreationContext'
) -> None:
Expand Down