|
| 1 | +"""Project file for open62541.""" |
| 2 | +import typing as tp |
| 3 | + |
| 4 | +import benchbuild as bb |
| 5 | +from benchbuild.utils.cmd import cmake, make |
| 6 | +from benchbuild.utils.settings import get_number_of_jobs |
| 7 | +from plumbum import local |
| 8 | + |
| 9 | +from varats.containers.containers import ImageBase, get_base_image |
| 10 | +from varats.paper.paper_config import PaperConfigSpecificGit |
| 11 | +from varats.project.project_domain import ProjectDomains |
| 12 | +from varats.project.project_util import ( |
| 13 | + BinaryType, |
| 14 | + ProjectBinaryWrapper, |
| 15 | + RevisionBinaryMap, |
| 16 | + get_local_project_repo, |
| 17 | + verify_binaries, |
| 18 | +) |
| 19 | +from varats.project.varats_project import VProject |
| 20 | +from varats.utils.git_util import ShortCommitHash |
| 21 | +from varats.utils.settings import bb_cfg |
| 22 | + |
| 23 | + |
| 24 | +class Open62541(VProject): |
| 25 | + """open62541 (http://open62541.org) is an open source implementation of OPC |
| 26 | + UA (OPC Unified Architecture / IEC 62541) written in the C language.""" |
| 27 | + |
| 28 | + NAME = 'open62541' |
| 29 | + GROUP = 'c_projects' |
| 30 | + DOMAIN = ProjectDomains.ARCHITECTURE |
| 31 | + |
| 32 | + SOURCE = [ |
| 33 | + PaperConfigSpecificGit( |
| 34 | + project_name='open62541', |
| 35 | + remote="https://github.com/open62541/open62541.git", |
| 36 | + local="open62541", |
| 37 | + refspec="origin/HEAD", |
| 38 | + limit=None, |
| 39 | + shallow=False |
| 40 | + ) |
| 41 | + ] |
| 42 | + |
| 43 | + CONTAINER = get_base_image(ImageBase.DEBIAN_10).run( |
| 44 | + 'apt', 'install', '-y', "git", "build-essential", "pkg-config", "cmake", |
| 45 | + "python3" |
| 46 | + ) |
| 47 | + |
| 48 | + @staticmethod |
| 49 | + def binaries_for_revision( |
| 50 | + revision: ShortCommitHash |
| 51 | + ) -> tp.List[ProjectBinaryWrapper]: |
| 52 | + binary_map = RevisionBinaryMap(get_local_project_repo(Open62541.NAME)) |
| 53 | + |
| 54 | + binary_map.specify_binary( |
| 55 | + 'build/bin/libopen62541.a', BinaryType.STATIC_LIBRARY |
| 56 | + ) |
| 57 | + |
| 58 | + return binary_map[revision] |
| 59 | + |
| 60 | + def run_tests(self) -> None: |
| 61 | + pass |
| 62 | + |
| 63 | + def compile(self) -> None: |
| 64 | + """Compile the project.""" |
| 65 | + open62541_version_source = local.path(self.source_of_primary) |
| 66 | + |
| 67 | + c_compiler = bb.compiler.cc(self) |
| 68 | + build_folder = open62541_version_source / "build" |
| 69 | + build_folder.mkdir() |
| 70 | + |
| 71 | + with local.cwd(build_folder): |
| 72 | + with local.env(CC=str(c_compiler)): |
| 73 | + bb.watch(cmake)("..") |
| 74 | + |
| 75 | + bb.watch(make)("-j", get_number_of_jobs(bb_cfg())) |
| 76 | + |
| 77 | + with local.cwd(open62541_version_source): |
| 78 | + verify_binaries(self) |
0 commit comments