コード例 #1
0
    def configure(self):
        """configure the target"""
        self.enterBuildDir()

        configure = Arguments([self.sourceDir() / (self.subinfo.options.configure.projectFile or "configure")])
        self.shell.environment["CFLAGS"] = self.subinfo.options.configure.cflags + " " + self.shell.environment["CFLAGS"]
        self.shell.environment["CXXFLAGS"] = self.subinfo.options.configure.cxxflags + " " + self.shell.environment["CXXFLAGS"]
        self.shell.environment["LDFLAGS"] = self.subinfo.options.configure.ldflags + " " + self.shell.environment["LDFLAGS"]
        self.shell.environment["MAKE"] = self.makeProgram

        autogen = self.sourceDir() / "autogen.sh"
        if self.subinfo.options.configure.bootstrap and autogen.exists():
            self.shell.execute(self.sourceDir(), autogen)
        elif self.subinfo.options.configure.autoreconf:
            includesArgs = Arguments()
            if self.subinfo.options.configure.useDefaultAutoreconfIncludes:
                includes = []
                for i in [CraftCore.standardDirs.craftRoot() / "dev-utils/cmake/share", CraftCore.standardDirs.locations.data]:
                    aclocalDir = i / "aclocal"
                    if aclocalDir.is_dir():
                        includes += [f"-I{self.shell.toNativePath(aclocalDir)}"]
                includesArgs += includes
            self.shell.execute(self.sourceDir(), "autoreconf", Arguments(self.subinfo.options.configure.autoreconfArgs) + includesArgs)

        with utils.ScopedEnv({"CLICOLOR_FORCE": None}):
            return self.shell.execute(self.buildDir(), configure, self.configureOptions(self))
コード例 #2
0
ファイル: options.py プロジェクト: KDE/craft
    def __init__(self, package):
        self._cachedFromParent = {}
        self._package = package

        _register  = self.registerOption
        _convert = self._convert

        # cachability is handled by the version comparison
        _register("version",    str,    persist=False, compatible=True)
        _register("patchLevel", int,    persist=False,  compatible=True)

        _register("branch",     str,    persist=False)
        _register("revision",   str,    persist=False)
        _register("ignored",    bool,   persist=False, compatible=True)
        _register("buildTests", True,   persist=False, compatible=True)
        _register("buildStatic",bool,   persist=False)

        _register("buildType",  CraftCore.settings.get("Compile", "BuildType"),    persist=False, compatible=True) # cachability already handled by cache behaviour
        _register("args",       Arguments(), persist=False)
        _register("featureArguments",Arguments(), persist=False)

        settings = UserOptions.instance().settings
        if settings.has_section(package.path):
            _registered = UserOptions.instance().registeredOptions[package.path]
            for key, value in settings[package.path].items():
                if key in _registered:
                    value = _convert(_registered[key].value, value)
                setattr(self, key, value)
コード例 #3
0
ファイル: CMakeBuildSystem.py プロジェクト: TheAssassin/craft
    def configureOptions(self, defines=""):
        """returns default configure options"""
        craftRoot = OsUtils.toUnixPath(CraftCore.standardDirs.craftRoot())
        options = Arguments([defines])
        options += [
            "-DBUILD_TESTING={testing}".format(
                testing="ON" if self.buildTests else "OFF"),
            BuildSystemBase.configureOptions(self),
            f"-DCMAKE_INSTALL_PREFIX={craftRoot}",
            f"-DCMAKE_PREFIX_PATH={craftRoot}"
        ]

        if self.buildType() is not None:
            options.append(f"-DCMAKE_BUILD_TYPE={self.buildType()}")

        #if CraftCore.compiler.isGCC() and not CraftCore.compiler.isNative():
        #    options += " -DCMAKE_TOOLCHAIN_FILE=%s" % os.path.join(CraftStandardDirs.craftRoot(), "craft", "bin", "toolchains", "Toolchain-cross-mingw32-linux-%s.cmake" % CraftCore.compiler.architecture)

        if CraftCore.settings.getboolean("CMake", "KDE_L10N_AUTO_TRANSLATIONS",
                                         False):
            options.append("-DKDE_L10N_AUTO_TRANSLATIONS=ON")

        if CraftCore.compiler.isWindows:
            # people use InstallRequiredSystemLibraries.cmake wrong and unconditionally install the
            # msvc crt...
            options.append("-DCMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP=ON")
        elif CraftCore.compiler.isMacOS:
            options += [
                f"-DKDE_INSTALL_BUNDLEDIR={OsUtils.toUnixPath(CraftCore.standardDirs.craftRoot())}/Applications/KDE",
                "-DAPPLE_SUPPRESS_X11_WARNING=ON"
            ]
        elif CraftCore.compiler.isLinux:
            # use the same lib dir on all distributions
            options += ["-DCMAKE_INSTALL_LIBDIR=lib"]

        if CraftCore.compiler.isWindows or CraftCore.compiler.isMacOS:
            options.append("-DKDE_INSTALL_USE_QT_SYS_PATHS=ON")

        if self.subinfo.options.buildTools:
            options += self.subinfo.options.configure.toolsDefine
        if self.subinfo.options.buildStatic and self.subinfo.options.configure.staticArgs:
            options += self.subinfo.options.configure.staticArgs
        if CraftCore.compiler.isIntel():
            # this is needed because otherwise it'll detect the MSVC environment
            options += " -DCMAKE_CXX_COMPILER=\"%s\" " % os.path.join(
                os.getenv("BIN_ROOT"), os.getenv("ARCH_PATH"),
                "icl.exe").replace("\\", "/")
            options += " -DCMAKE_C_COMPILER=\"%s\" " % os.path.join(
                os.getenv("BIN_ROOT"), os.getenv("ARCH_PATH"),
                "icl.exe").replace("\\", "/")
            options += " -DCMAKE_LINKER=\"%s\" " % os.path.join(
                os.getenv("BIN_ROOT"), os.getenv("ARCH_PATH"),
                "xilink.exe").replace("\\", "/")
        options += ["-S", self.configureSourceDir()]
        return options
コード例 #4
0
ファイル: options.py プロジェクト: KDE/craft
    def __init__(self, dynamic):
        ## with this option additional arguments could be added to the configure commmand line
        self.args = Arguments(dynamic.args)
        ## with this option additional arguments could be added to the configure commmand line (for static builds)
        self.staticArgs = Arguments()
        ## set source subdirectory as source root for the configuration tool.
        # Sometimes it is required to take a subdirectory from the source tree as source root
        # directory for the configure tool, which could be enabled by this option. The value of
        # this option is added to sourceDir() and the result is used as source root directory.
        self.configurePath = None

        # add the cmake defines that are needed to build tests here
        self.testDefine = None

        ## run autogen in autotools
        self.bootstrap = False

        ## run "autoreconf -vfi" in autotools
        self.autoreconf = True

        ## optional arguments for autoreconf
        self.autoreconfArgs = Arguments(["-vfi"])

        ## Whether to add the default -I flags when running autoreconf
        ## This is needed since some packages fail if we pass -I to autoreconf
        self.useDefaultAutoreconfIncludes = True

        # do not use default include path
        self.noDefaultInclude = False

        ## do not use default lib path
        self.noDefaultLib = False

        ## set this attribute in case a non standard configuration
        # tool is required (supported currently by QMakeBuildSystem only)
        self.tool = False

        # cflags currently only used for autotools
        self.cflags = ""

        # cxxflags currently only used for autotools
        self.cxxflags = ""

        # ldflags currently only used for autotools
        self.ldflags = ""

        # the project file, this is either a .pro for qmake or a sln for msbuild
        self.projectFile = None

        # whether to not pass --datarootdir configure
        self.noDataRootDir = False

        # whether to not pass --libdir configure
        self.noLibDir = False
コード例 #5
0
 def __init__(self):
     BuildSystemBase.__init__(self, "autotools")
     self._shell = BashShell()
     self.platform = ""# hope for auto detection
     if CraftCore.compiler.isGCC() and not CraftCore.compiler.isNative() and CraftCore.compiler.isX86():
         self.platform = Arguments(["--host=i686-pc-linux-gnu"])
     elif CraftCore.compiler.isWindows:
         if CraftCore.compiler.isX86():
             self.platform = Arguments(["--host=i686-w64-mingw32", "--build=i686-w64-mingw32", "--target=i686-w64-mingw32"])
         else:
             self.platform = Arguments(["--host=x86_64-w64-mingw32", "--build=x86_64-w64-mingw32", "--target=x86_64-w64-mingw32"])
コード例 #6
0
    def makeOptions(self, args):
        """return options for make command line"""
        defines = Arguments()
        if self.subinfo.options.make.ignoreErrors:
            defines.append("-i")
        makeProgram = self.makeProgram
        if makeProgram == "ninja":
            if CraftCore.debug.verbose() > 0:
                defines.append("-v")
        else:
            if CraftCore.debug.verbose() > 0:
                defines += ["VERBOSE=1", "V=1"]

        if self.subinfo.options.make.supportsMultijob and makeProgram != "nmake":
            if makeProgram not in {
                    "ninja", "jom"
            } or ("Compile", "Jobs") in CraftCore.settings:
                defines += [
                    "-j",
                    str(
                        CraftCore.settings.get("Compile", "Jobs",
                                               multiprocessing.cpu_count()))
                ]

        if args:
            defines.append(args)
        return defines
コード例 #7
0
    def make(self):
        """implements the make step for cmake projects"""

        self.enterBuildDir()

        command = Arguments.formatCommand([self.makeProgram], self.makeOptions(self.subinfo.options.make.args))
        return utils.system(command)
コード例 #8
0
ファイル: shells.py プロジェクト: OGKingD/craft
 def execute(self, path, cmd, args="", **kwargs):
     # try to locate the command
     if CraftCore.compiler.isWindows:
         tmp = CraftCore.cache.findApplication(cmd)
         if tmp:
             cmd = tmp
         command = Arguments([
             self._findBash(), "-c",
             str(Arguments([self.toNativePath(cmd), args]))
         ])
     else:
         command = Arguments([cmd, args])
     env = dict(os.environ)
     env.update(self.environment)
     env.update(kwargs.get("env", {}))
     return utils.system(command, cwd=path, env=env, **kwargs)
コード例 #9
0
 def createPackage(self):
     if self.androidApkTargets:
         self.enterBuildDir()
         command = Arguments.formatCommand([self.makeProgram], ["create-apk"])
         return utils.system(command)
     CraftCore.log.critical("Failed to detect package target")
     return False
コード例 #10
0
ファイル: CMakeBuildSystem.py プロジェクト: OGKingD/craft
 def createPackage(self):
     self.__autodetectAndroidApkTargets()
     if CraftCore.compiler.isAndroid and self.androidApkTargets != None and len(
             self.androidApkTargets) > 0:
         self.enterBuildDir()
         command = Arguments.formatCommand([self.makeProgram],
                                           ["create-apk"])
         return utils.system(command)
コード例 #11
0
    def configureOptions(self, defines=""):
        """return options for configure command line"""
        defines = Arguments(defines)
        defines += self.subinfo.options.configure.args

        if self.supportsCCACHE and CraftCore.cache.findApplication("ccache"):
            defines += self.ccacheOptions()
        if CraftCore.compiler.isClang() and self.supportsClang:
            defines += self.clangOptions()
        return defines
コード例 #12
0
    def install(self):
        """install the target"""
        if not BuildSystemBase.install(self):
            return False

        self.enterBuildDir()


        with utils.ScopedEnv({"DESTDIR" : self.installDir()}):
            command = Arguments.formatCommand([self.makeProgram], self.makeOptions(self.subinfo.options.install.args))
            return (utils.system(command) and
                    self._fixInstallPrefix())
コード例 #13
0
def main():
    #加载日志
    logging.basicConfig(format = '%(asctime)s - %(levelname)s - %(name)s -   %(message)s',
                        datefmt = '%m/%d/%Y %H:%M:%S',
                        level = logging.INFO)
    logger = logging.getLogger(__name__)

    # 'opt' means options
    opt = None

    parser = argparse.ArgumentParser(description='multi-qa')
    parser.add_argument('mode', help='mode: train')
    parser.add_argument('conf_file', help='path to conf file.')
    parser.add_argument('dataset', help='dataset for train')

    #得到参数实例
    args = parser.parse_args()
    mode = args.mode # train mode

    #得到conf文件的参数
    conf_file = args.conf_file
    dataset = args.dataset
    conf_args = Arguments(conf_file)
    opt = conf_args.readArguments()

    opt['cuda'] = torch.cuda.is_available()
    opt['confFile'] = conf_file
    opt['datadir'] = os.path.dirname(conf_file) # .
    for key, val in args.__dict__.items():
        if val is not None and key not in ['command', 'conf_file']:
            opt[key] = val

    #使用GPU
    # opt['cuda'] = False
    device = torch.device("cuda" if opt['cuda'] else 'cpu')
    logger.info("device %s is using for training!", device)
    model = ConvQA_CN_NetTrainer(opt)
    print("Select mode----", mode)
    print("Using dataset ----", dataset)
    model.train()
コード例 #14
0
ファイル: predict.py プロジェクト: MiuLab/CQA-Study
def main(conf_file, model_file, data_file, output_path, mask, indicator,
         answer_span_in_context, no_ans_bit):
    conf_args = Arguments(conf_file)
    opt = conf_args.readArguments()
    opt['cuda'] = torch.cuda.is_available()
    opt['confFile'] = conf_file
    opt['datadir'] = os.path.dirname(conf_file)
    opt['PREV_ANS_MASK'] = mask
    opt['PREV_ANS_INDICATOR'] = indicator

    opt['OFFICIAL'] = True
    opt['OFFICIAL_TEST_FILE'] = data_file
    if answer_span_in_context:
        opt['ANSWER_SPAN_IN_CONTEXT_FEATURE'] = None
    if no_ans_bit:
        opt['NO_PREV_ANS_BIT'] = None
    trainer = SDNetTrainer(opt)
    test_data = trainer.preproc.preprocess('test')
    predictions, confidence, final_json = trainer.official(
        model_file, test_data)
    with output_path.open(mode='w') as f:
        json.dump(final_json, f)
コード例 #15
0
ファイル: CMakeBuildSystem.py プロジェクト: TheAssassin/craft
    def configure(self, defines=""):
        """implements configure step for cmake projects"""

        self.enterBuildDir()
        env = {}
        if self.supportsCCACHE and CraftCore.cache.findApplication("ccache"):
            env["CXX"] = CraftCore.standardDirs.craftRoot(
            ) / "dev-utils/ccache/bin" / Path(os.environ["CXX"]).name
            env["CC"] = CraftCore.standardDirs.craftRoot(
            ) / "dev-utils/ccache/bin" / Path(os.environ["CC"]).name
        with utils.ScopedEnv(env):
            command = Arguments.formatCommand(
                ["cmake", "-G", self.__makeFileGenerator()],
                self.configureOptions(defines))
            return utils.system(command)
コード例 #16
0
    def configure(self, defines=""):
        """implements configure step for cmake projects"""

        self.enterBuildDir()
        env = {}
        if self.supportsCCACHE:
            cxx = CraftCore.standardDirs.craftRoot()/ "dev-utils/ccache/bin" / Path(os.environ["CXX"]).name
            if CraftCore.compiler.isWindows and not cxx.suffix:
                cxx = Path(str(cxx) + CraftCore.compiler.executableSuffix)
            if cxx.exists():
                env["CXX"] = cxx
                env["CC"] = cxx.parent / Path(os.environ["CC"]).name
        with utils.ScopedEnv(env):
            command = Arguments.formatCommand(["cmake", "-G",  self.__makeFileGenerator()], self.configureOptions(defines))
            return utils.system(command)
コード例 #17
0
ファイル: options.py プロジェクト: KDE/craft
 def __init__(self):
     ## ignore make error
     self.ignoreErrors = None
     ## options for the make tool
     self.args = Arguments()
     self.supportsMultijob = True
コード例 #18
0
ファイル: main.py プロジェクト: henry-ren/term-project
import torch
from Models.SDNetTrainer import SDNetTrainer
from Utils.Arguments import Arguments
if __name__ == "__main__":
    # multiprocessing.set_start_method('spawn')
    opt = None

    parser = argparse.ArgumentParser(description='SDNet')
    parser.add_argument('--command', default='train', help='Command: train')
    parser.add_argument('--conf_file', default='conf_stvqa', help='Path to conf file.')
    parser.add_argument('--log_file', default='', help='Path to log file.')

    cmdline_args = parser.parse_args()
    command = cmdline_args.command
    conf_file = cmdline_args.conf_file
    conf_args = Arguments(conf_file)
    opt = conf_args.readArguments()
    opt['cuda'] = torch.cuda.is_available()
    opt['confFile'] = conf_file
    opt['datadir'] = os.path.dirname(conf_file)  # conf_file specifies where the data folder is

    if cmdline_args.log_file != '':
        if not os.path.exists('myLog'):
            os.makedirs('myLog')
        file_handle = logging.FileHandler(os.path.join('myLog', cmdline_args.log_file +'.txt'))
        log.addHandler(file_handle)

    for key,val in cmdline_args.__dict__.items():
        if val is not None and key not in ['command', 'conf_file']:
            opt[key] = val
コード例 #19
0
def systemWithoutShell(cmd,
                       displayProgress=False,
                       logCommand=True,
                       pipeProcess=None,
                       acceptableExitCodes=None,
                       secretCommand=False,
                       secret=None,
                       **kw):
    """execute cmd. All keywords are passed to Popen. stdout and stderr
    might be changed depending on the chosen logging options.

    When the parameter "displayProgress" is True, stdout won't be
    logged to allow the display of progress bars."""

    ciMode = CraftCore.settings.getboolean("ContinuousIntegration", "Enabled",
                                           False)
    needsAnsiFix = OsUtils.isWin() and CraftCore.settings.getboolean(
        "General", "AllowAnsiColor", True)

    environment = kw.get("env", os.environ)
    cwd = kw.get("cwd", os.getcwd())

    # make sure our venv python is used
    python_venv = Path(CraftCore.standardDirs.etcDir(
    )) / f"virtualenv/3/Scripts/python{CraftCore.compiler.executableSuffix}"
    if python_venv.exists():
        environment["VIRTUAL_ENV"] = str(python_venv.parent)

    # if the first argument is not an absolute path replace it with the full path to the application
    if isinstance(cmd, Arguments):
        cmd = Arguments.get(cmd)

    if isinstance(cmd, list):
        # allow to pass other types, like ints or Path
        cmd = [str(x) for x in cmd]
        if pipeProcess:
            pipeProcess.args = [str(x) for x in pipeProcess.args]
        arg0 = cmd[0]
        if not "shell" in kw:
            kw["shell"] = False
    else:
        if not "shell" in kw:
            # use shell, arg0 might end up with "/usr/bin/svn" => needs shell so it can be executed
            kw["shell"] = True
        arg0 = shlex.split(cmd, posix=not OsUtils.isWin())[0]

    matchQuoted = re.match("^\"(.*)\"$", arg0)
    if matchQuoted:
        CraftCore.log.warning(
            f"Please don't pass quoted paths to systemWithoutShell, app={arg0}"
        )
    if not os.path.isfile(arg0) and not matchQuoted:
        app = CraftCore.cache.findApplication(arg0)
    else:
        app = arg0

    if app:
        if isinstance(cmd, list):
            cmd[0] = app
        elif not matchQuoted:
            cmd = cmd.replace(arg0, f"\"{app}\"", 1)
    else:
        app = arg0

    if secretCommand:
        CraftCore.debug.print(f"securely executing command: {app}")
    else:
        _logCommand = ""
        _debugCommand = ""
        if logCommand:
            if pipeProcess:
                _logCommand = "{0} | ".format(" ".join(pipeProcess.args))
            _logCommand += " ".join(cmd) if isinstance(cmd, list) else cmd
        if pipeProcess:
            _debugCommand = f"executing command: {pipeProcess.args!r} | {cmd!r}"
        else:
            _debugCommand = f"executing command: {cmd!r}"
        if secret:
            _debugCommand = redact(_debugCommand, secret)
            _logCommand = redact(_logCommand, secret)
        if logCommand:
            CraftCore.debug.print(f"executing command: {_logCommand}")
        CraftCore.log.debug(_debugCommand)
        CraftCore.log.debug(f"CWD: {cwd!r}")
        CraftCore.log.debug(f"displayProgress={displayProgress}")
        CraftCore.debug.logEnv(environment)
    if pipeProcess:
        kw["stdin"] = pipeProcess.stdout
    if not displayProgress or ciMode:
        stdout = kw.get('stdout', sys.stdout)
        if stdout == sys.stdout:
            kw['stderr'] = subprocess.STDOUT
        kw['stdout'] = subprocess.PIPE

        proc = subprocess.Popen(cmd, **kw)
        if pipeProcess:
            pipeProcess.stdout.close()
        for line in proc.stdout:
            if isinstance(stdout, io.TextIOWrapper):
                if CraftCore.debug.verbose(
                ) < 3:  # don't print if we write the debug log to stdout anyhow
                    if needsAnsiFix:
                        # a bug in cygwin msys removes the ansi flag, set it again
                        ctypes.windll.kernel32.SetConsoleMode(
                            ctypes.windll.kernel32.GetStdHandle(-11), 7)
                        ctypes.windll.kernel32.SetConsoleMode(
                            ctypes.windll.kernel32.GetStdHandle(-12), 7)
                    stdout.buffer.write(line)
                    stdout.flush()
            elif stdout == subprocess.DEVNULL:
                pass
            elif isinstance(stdout, io.StringIO):
                stdout.write(line.decode("UTF-8"))
            else:
                stdout.write(line)

            CraftCore.log.debug("{app}: {out}".format(app=app,
                                                      out=line.rstrip()))
    else:
        proc = subprocess.Popen(cmd, **kw)
        if pipeProcess:
            pipeProcess.stdout.close()
        if proc.stderr:
            for line in proc.stderr:
                CraftCore.log.debug("{app}: {out}".format(app=app,
                                                          out=line.rstrip()))

    proc.communicate()
    proc.wait()

    if acceptableExitCodes is None:
        ok = proc.returncode == 0
    else:
        ok = proc.returncode in acceptableExitCodes
    if not ok:
        if not secretCommand:
            msg = f"Command {redact(cmd, secret)} failed with exit code {proc.returncode}"
            if not ciMode:
                CraftCore.log.debug(msg)
            else:
                CraftCore.log.info(msg)
        else:
            CraftCore.log.info(
                f"{app} failed with exit code {proc.returncode}")
    return ok
コード例 #20
0
ファイル: AutoToolsBuildSystem.py プロジェクト: KDE/craft
    def configure(self):
        """configure the target"""
        self.enterBuildDir()

        configure = Arguments([
            self.sourceDir() /
            (self.subinfo.options.configure.projectFile or "configure")
        ])
        self.shell.environment[
            "CFLAGS"] = self.subinfo.options.configure.cflags + " " + self.shell.environment[
                "CFLAGS"]
        self.shell.environment[
            "CXXFLAGS"] = self.subinfo.options.configure.cxxflags + " " + self.shell.environment[
                "CXXFLAGS"]
        self.shell.environment[
            "LDFLAGS"] = self.subinfo.options.configure.ldflags + " " + self.shell.environment[
                "LDFLAGS"]
        self.shell.environment["MAKE"] = self.makeProgram

        env = {"CLICOLOR_FORCE": None}
        if self.supportsCCACHE:
            cxx = CraftCore.standardDirs.craftRoot(
            ) / "dev-utils/ccache/bin" / Path(os.environ["CXX"]).name
            if CraftCore.compiler.isWindows and not cxx.suffix:
                cxx = Path(str(cxx) + CraftCore.compiler.executableSuffix)
            if cxx.exists():
                env["CXX"] = OsUtils.toMSysPath(cxx)
                env["CC"] = OsUtils.toMSysPath(cxx.parent /
                                               Path(os.environ["CC"]).name)

        with utils.ScopedEnv(env):
            autogen = self.sourceDir() / "autogen.sh"
            if self.subinfo.options.configure.bootstrap and autogen.exists():
                mode = os.stat(autogen).st_mode
                if mode & stat.S_IEXEC == 0:
                    os.chmod(autogen, mode | stat.S_IEXEC)
                self.shell.execute(self.sourceDir(), autogen)
            elif self.subinfo.options.configure.autoreconf and (
                (self.sourceDir() / "configure.ac").exists() or
                (self.sourceDir() / "configure.in").exists()):
                includesArgs = Arguments()
                if self.subinfo.options.configure.useDefaultAutoreconfIncludes:
                    includes = []
                    dataDirs = [
                        CraftCore.standardDirs.craftRoot() /
                        "dev-utils/cmake/share"
                    ]
                    if CraftCore.compiler.isWindows:
                        # on Windows data location lies outside of the autotools prefix (msys)
                        dataDirs.append(CraftCore.standardDirs.locations.data)
                    for i in dataDirs:
                        aclocalDir = i / "aclocal"
                        if aclocalDir.is_dir():
                            includes += [
                                f"-I{self.shell.toNativePath(aclocalDir)}"
                            ]
                    includesArgs += includes
                if not self.shell.execute(
                        self.sourceDir(), "autoreconf",
                        Arguments(
                            self.subinfo.options.configure.autoreconfArgs) +
                        includesArgs):
                    return False

            return self.shell.execute(self.buildDir(), configure,
                                      self.configureOptions(self))
コード例 #21
0
ファイル: CMakeBuildSystem.py プロジェクト: OGKingD/craft
    def configureOptions(self, defines=""):
        """returns default configure options"""
        craftRoot = OsUtils.toUnixPath(CraftCore.standardDirs.craftRoot())
        options = Arguments([defines])
        options += [
            "-DBUILD_TESTING={testing}".format(
                testing="ON" if self.buildTests else "OFF"),
            "-DBUILD_SHARED_LIBS={shared}".format(
                shared="OFF" if self.subinfo.options.buildStatic else "ON"),
            BuildSystemBase.configureOptions(self),
            f"-DCMAKE_INSTALL_PREFIX={craftRoot}",
            f"-DCMAKE_PREFIX_PATH={craftRoot}"
        ]

        if self.buildType() is not None:
            options.append(f"-DCMAKE_BUILD_TYPE={self.buildType()}")

        #if CraftCore.compiler.isGCC() and not CraftCore.compiler.isNative():
        #    options += " -DCMAKE_TOOLCHAIN_FILE=%s" % os.path.join(CraftStandardDirs.craftRoot(), "craft", "bin", "toolchains", "Toolchain-cross-mingw32-linux-%s.cmake" % CraftCore.compiler.architecture)

        if CraftCore.settings.getboolean("CMake", "KDE_L10N_AUTO_TRANSLATIONS",
                                         False):
            options.append("-DKDE_L10N_AUTO_TRANSLATIONS=ON")

        if CraftCore.compiler.isWindows:
            # people use InstallRequiredSystemLibraries.cmake wrong and unconditionally install the
            # msvc crt...
            options.append("-DCMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP=ON")
        elif CraftCore.compiler.isMacOS:
            options += [
                f"-DKDE_INSTALL_BUNDLEDIR={OsUtils.toUnixPath(CraftCore.standardDirs.craftRoot())}/Applications/KDE",
                "-DAPPLE_SUPPRESS_X11_WARNING=ON"
            ]
        elif CraftCore.compiler.isLinux:
            # use the same lib dir on all distributions
            options += ["-DCMAKE_INSTALL_LIBDIR=lib"]
        elif CraftCore.compiler.isAndroid:
            nativeToolingRoot = CraftCore.settings.get("General",
                                                       "KF5HostToolingRoot",
                                                       "/opt/nativetooling")
            nativeToolingCMake = CraftCore.settings.get(
                "General", "KF5HostToolingCMakePath",
                "/opt/nativetooling/lib/x86_64-linux-gnu/cmake/")
            additionalFindRoots = ";".join(
                filter(None, [
                    CraftCore.settings.get(
                        "General", "AndroidAdditionalFindRootPath", ""),
                    craftRoot
                ]))
            options += [
                f"-DCMAKE_TOOLCHAIN_FILE={nativeToolingRoot}/share/ECM/toolchain/Android.cmake",
                f"-DECM_ADDITIONAL_FIND_ROOT_PATH='{additionalFindRoots}'",
                f"-DKF5_HOST_TOOLING={nativeToolingCMake}",
                f"-DANDROID_APK_OUTPUT_DIR={self.packageDestinationDir()}",
                f"-DANDROID_FASTLANE_METADATA_OUTPUT_DIR={self.packageDestinationDir()}"
            ]
            self.__autodetectAndroidApkTargets()
            if self.androidApkTargets != None and len(
                    self.androidApkTargets) > 0:
                options += [
                    f"-DQTANDROID_EXPORTED_TARGET={';'.join(self.androidApkTargets)}",
                    f"-DANDROID_APK_DIR={';'.join(self.androidApkDirs)}"
                ]
            if self.buildType() == "Release" or self.buildType(
            ) == "MinSizeRel":
                options += ["-DANDROIDDEPLOYQT_EXTRA_ARGS=--release"]

        if CraftCore.compiler.isWindows or CraftCore.compiler.isMacOS:
            options.append("-DKDE_INSTALL_USE_QT_SYS_PATHS=ON")

        if self.subinfo.options.buildTools:
            options += self.subinfo.options.configure.toolsDefine
        if self.subinfo.options.buildStatic and self.subinfo.options.configure.staticArgs:
            options += self.subinfo.options.configure.staticArgs
        if CraftCore.compiler.isIntel():
            # this is needed because otherwise it'll detect the MSVC environment
            options += " -DCMAKE_CXX_COMPILER=\"%s\" " % os.path.join(
                os.getenv("BIN_ROOT"), os.getenv("ARCH_PATH"),
                "icl.exe").replace("\\", "/")
            options += " -DCMAKE_C_COMPILER=\"%s\" " % os.path.join(
                os.getenv("BIN_ROOT"), os.getenv("ARCH_PATH"),
                "icl.exe").replace("\\", "/")
            options += " -DCMAKE_LINKER=\"%s\" " % os.path.join(
                os.getenv("BIN_ROOT"), os.getenv("ARCH_PATH"),
                "xilink.exe").replace("\\", "/")
        options += ["-S", self.configureSourceDir()]
        return options
コード例 #22
0
ファイル: options.py プロジェクト: KDE/craft
 def __init__(self):
     ## options passed to make on install
     self.args = Arguments(["install"])
コード例 #23
0
parser.add_argument('command', help='Command: train/evaluate')
parser.add_argument('conf_file', help='Path to the BigLearn conf file.')
parser.add_argument('--PYLEARN_MODEL', help='Overrides this option from the conf file.')
parser.add_argument('--master_port', help='Overrides this option default', default=None)
parser.add_argument('--cluster', help='local, philly or aml', default='local')
parser.add_argument('--dist_init_path', help='Distributed init path for AML', default='./tmp')
parser.add_argument('--fp16', action='store_true', help="Whether to use 16-bit float precision instead of 32-bit")
parser.add_argument('--fp16_opt_level', type=str, default='O1', help="For fp16: Apex AMP optimization level selected in ['O0', 'O1', 'O2', and 'O3']."
                    "See details at https://nvidia.github.io/apex/amp.html")
parser.add_argument('--no_cuda', action='store_true', help="Disable cuda.")
parser.add_argument('--config_overrides', help='Override parameters on config, VAR=val;VAR=val;...')

cmdline_args = parser.parse_args()
command = cmdline_args.command
conf_file = cmdline_args.conf_file
conf_args = Arguments(conf_file)
opt = conf_args.readArguments()

if cmdline_args.config_overrides:
    for config_override in cmdline_args.config_overrides.split(';'):
        config_override = config_override.strip()
        if config_override:
            var_val = config_override.split('=')
            assert len(var_val) == 2, f"Config override '{var_val}' does not have the form 'VAR=val'"
            conf_args.add_opt(opt, var_val[0], var_val[1], force_override=True)

# print(opt)

opt['cuda'] = torch.cuda.is_available() and not cmdline_args.no_cuda
opt['confFile'] = conf_file
if 'datadir' not in opt: