Commit 9f1f5355 authored by Jan Kiene's avatar Jan Kiene
Browse files

add -e and -d switches to IvasBuildAndRunChecks

parent e263e11f
Loading
Loading
Loading
Loading
Loading
+58 −29
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@

import os.path
import sys
import platform

import pyivastest.constants as constants
from pyivastest import IvasScriptsCommon
@@ -39,6 +40,19 @@ from pyivastest.IvasSvnBuilder import *

RET_CODE_FAILURE = 101

bin_ext = ""
if platform.system() == "Windows":
    bin_ext = ".exe"

default_encdec_bin_path = constants.WC_BASE_DIR
default_enc = os.path.realpath(
    os.path.join(default_encdec_bin_path, "IVAS_cod" + bin_ext)
)
default_dec = os.path.realpath(
    os.path.join(default_encdec_bin_path, "IVAS_dec" + bin_ext)
)
default_out = os.path.join(".", "out")  # change that to something else?


class IvasBuildAndRunChecks(IvasScriptsCommon.IvasScript):
    def __init__(self):
@@ -105,9 +119,20 @@ class IvasBuildAndRunChecks(IvasScriptsCommon.IvasScript):
            help="build the basop version for instrumentation",
            action="store_true",
        )
        self.parser.add_argument(
            "-e",
            "--enc",
            help="Encoder binary to use instead of instrumenting and building it anew",
            default=None,
        )
        self.parser.add_argument(
            "-d",
            "--dec",
            help="Decoder binary to use instead of instrumenting and building it anew",
            default=None,
        )

    def run(self):

        self.parse_args()
        if self.args["error"] or self.args["exit"]:
            exit()
@@ -147,6 +172,8 @@ class IvasBuildAndRunChecks(IvasScriptsCommon.IvasScript):
                sample_rate_dec_out=self.args["srout"],
                enable_logging=True,
                logger_name="{}.br".format(self.logger.name),
                enc_ext=self.args["enc"],
                dec_ext=self.args["dec"],
            )

        elif self.args["srcdir"]:
@@ -157,6 +184,8 @@ class IvasBuildAndRunChecks(IvasScriptsCommon.IvasScript):
                sample_rate_dec_out=self.args["srout"],
                enable_logging=True,
                logger_name="{}.br".format(self.logger.name),
                enc_ext=self.args["enc"],
                dec_ext=self.args["dec"],
            )

        modes = self.args["formats"]
@@ -187,7 +216,7 @@ class IvasBuildAndRunChecks(IvasScriptsCommon.IvasScript):
                br.build_and_run_dict[check]["analyzer"], self.args
            )

        if self.args["rebuild"] == True:
        if self.args["rebuild"]:
            br.force_build = True

        checks_ret_val = list()
+56 −28
Original line number Diff line number Diff line
@@ -702,6 +702,8 @@ class IvasBuilderAndRunner(IvasBaseClass):
        console_logger_level="",
        logger_name="IvasBuilderAndRunner",
        log_level=logging.DEBUG,
        enc_ext=None,
        dec_ext=None,
    ):
        super().__init__(
            enable_logging=enable_logging,
@@ -736,6 +738,8 @@ class IvasBuilderAndRunner(IvasBaseClass):
        self.sample_rate_enc_in = sample_rate_enc_in
        self.sample_rate_dec_out = sample_rate_dec_out
        self.force_build = False
        self.enc_ext = enc_ext
        self.dec_ext = dec_ext

    @classmethod
    def fromSvn(
@@ -1090,11 +1094,23 @@ class IvasBuilderAndRunner(IvasBaseClass):
            if self.builder.src_dir == "":
                self.builder.get_svn_source()
            run_dir = os.path.join(self.builder.src_dir, cfg_name)

            # if both encoder and decoder are given as external binaries, create dir and copy both, this skips the build later
            if self.dec_ext is not None and self.enc_ext is not None:
                os.makedirs(run_dir, exist_ok=True)
                shutil.copy(
                    self.enc_ext, os.path.join(run_dir, os.path.basename(self.enc_ext))
                )
                shutil.copy(
                    self.dec_ext, os.path.join(run_dir, os.path.basename(self.dec_ext))
                )

            if not os.path.exists(run_dir) or self.force_build:
                # we have to build first
                self.build(cfg_name)
            else:
                # check if binaries are in the directory
                # first, copy external binaries
                # test for EVS vs IVAS
                if os.path.exists(
                    os.path.join(
@@ -1130,6 +1146,19 @@ class IvasBuilderAndRunner(IvasBaseClass):
                        )
                    )
                    self.build(cfg_name)
                    # if one of the external binaries was given, copy it over, overwriting the existing one
                    # we should not get here if both are given, then building is skipped altogether
                    if self.enc_ext is not None:
                        shutil.copy(
                            self.enc_ext,
                            os.path.join(run_dir, os.path.basename(self.enc_ext)),
                        )
                    if self.dec_ext is not None:
                        shutil.copy(
                            self.dec_ext,
                            os.path.join(run_dir, os.path.basename(self.dec_ext)),
                        )

            self.build_and_run_dict[cfg_name]["runner"].dir_name = run_dir
            self.build_and_run_dict[cfg_name]["analyzer"].dir = run_dir
            self.build_and_run_dict[cfg_name]["runner"].run()
@@ -1207,7 +1236,6 @@ class IvasBuilderAndRunner(IvasBaseClass):
        max_workers=1,
        usan_supp_file=None,
    ):

        n_cpus = cpu_count()
        # do not use all cores to avoid weird getting-stuck issues observed on Mac...
        make_options = ["-j", f"{n_cpus - 2}"]