Search in sources :

Example 1 with HelpScreenException

use of net.sourceforge.argparse4j.helper.HelpScreenException in project claw-compiler by C2SM-RCM.

the class CLIOptions method parseArguments.

public static CLIOptions parseArguments(String[] args) throws Exception {
    ArgumentParser parser = ArgumentParsers.newFor("claw-cx2t").build().description("The CLAW Compiler is a " + "source-to-source translator working on the XcodeML intermediate representation");
    Namespace parsedArgs = null;
    try {
        parser.addArgument("input-xast-file").nargs("?").help("Input XCodeML file");
        MutuallyExclusiveGroup qOpts = parser.addMutuallyExclusiveGroup("Query options");
        qOpts.addArgument("--print-opts").action(Arguments.storeTrue()).help("Print processed cmdline options");
        qOpts.addArgument("--version").action(Arguments.storeTrue()).help("Print version");
        qOpts.addArgument("-tl", "--target-list").action(Arguments.storeTrue()).help("List all targets supported by code transformation");
        qOpts.addArgument("-dl", "--directive-list").action(Arguments.storeTrue()).help("List all directive languages supported by code generation");
        qOpts.addArgument("-sc", "--show-config").action(Arguments.storeTrue()).help("Display the current configuration");
        ArgumentGroup cOpts = parser.addArgumentGroup("Translator options");
        cOpts.addArgument("-l", "--suppress-pp-line-directives").action(Arguments.storeTrue()).help("Suppress line directive in decompiled code");
        cOpts.addArgument("-cp", "--config-path").help("Path to configuration directory");
        cOpts.addArgument("-c", "--config").help("Path to translator configuration file");
        cOpts.addArgument("-t", "--target").help("Code transformation target platform");
        cOpts.addArgument("-dir", "--directive").help("Target directive language to be used in code generation");
        cOpts.addArgument("-d", "--debug").action(Arguments.storeTrue()).help("Enable output debug message");
        cOpts.addArgument("-f", "--out-ftn-file").help("Output file for decompiled FORTRAN source");
        cOpts.addArgument("-o", "--out-xast-file").help("Output file for transformed XcodeML");
        cOpts.addArgument("-r", "--report").help("Output file for the transformation report");
        cOpts.addArgument("-M", "--mod-include-dir").nargs("*").action(Arguments.append()).help("Search directory for .xmod files");
        cOpts.addArgument("-w", "--max-fortran-line-length").type(Integer.class).help("Number of character per line in decompiled code");
        cOpts.addArgument("-fp", "--force-pure").action(Arguments.storeTrue()).help("Exit the translator if a PURE subroutine/function has to be transformed");
        cOpts.addArgument("-m", "--model-config").help("Model configuration file for SCA transformation");
        cOpts.addArgument("-x", "--override-cfg-key").nargs("*").action(Arguments.append()).help("Override configuration option. Has higher priority than base and user configuration");
        cOpts.addArgument("-ap", "--add-paren").action(Arguments.storeTrue()).help("Force backend to add parentheses around binary mathematical operations");
        cOpts.addArgument("-td", "--trans-path-dir").nargs("*").action(Arguments.append()).help("Search directory for external transformation set");
        parsedArgs = parser.parseArgs(args);
    } catch (HelpScreenException hse) {
        return null;
    } catch (ArgumentParserException ape) {
        parser.handleError(ape);
        throw ape;
    }
    CLIOptions opts = new CLIOptions(parsedArgs);
    return opts;
}
Also used : HelpScreenException(net.sourceforge.argparse4j.helper.HelpScreenException) MutuallyExclusiveGroup(net.sourceforge.argparse4j.inf.MutuallyExclusiveGroup) ArgumentParserException(net.sourceforge.argparse4j.inf.ArgumentParserException) ArgumentParser(net.sourceforge.argparse4j.inf.ArgumentParser) Namespace(net.sourceforge.argparse4j.inf.Namespace) ArgumentGroup(net.sourceforge.argparse4j.inf.ArgumentGroup)

Example 2 with HelpScreenException

use of net.sourceforge.argparse4j.helper.HelpScreenException in project claw-compiler by C2SM-RCM.

the class Options method parseCmdlineArguments.

public static Options parseCmdlineArguments(String[] args, Path workingDir) throws Exception {
    ArgumentParser parser = ArgumentParsers.newFor("clawfc").build().description("The CLAW Compiler is a " + "source-to-source translator working on the XcodeML intermediate representation");
    Namespace parsedArgs = null;
    try {
        parser.addArgument("fortran-file").nargs("*").action(Arguments.append()).help("Input file");
        MutuallyExclusiveGroup qOpts = parser.addMutuallyExclusiveGroup("Query options");
        qOpts.addArgument("--list-targets", "--target-list").action(Arguments.storeTrue()).help("List available types of accelerator hardware");
        qOpts.addArgument("--list-directives", "--directive-list").action(Arguments.storeTrue()).help("List supported accelerator directive languages");
        qOpts.addArgument("--show-config").action(Arguments.storeTrue()).help("List the current configuration information. If used with --config, list the information" + " from the specific configuration");
        qOpts.addArgument("--version").action(Arguments.storeTrue()).help("Print version");
        qOpts.addArgument("--print-install-cfg", "--show-env").action(Arguments.storeTrue()).help("Print install configuration");
        qOpts.addArgument("--print-opts").action(Arguments.storeTrue()).help("Print processed cmdline options");
        qOpts.addArgument("--print-claw-files").action(Arguments.storeTrue()).help("Print input files which use CLAW directives");
        MutuallyExclusiveGroup outOpts = parser.addMutuallyExclusiveGroup("Compiler output options");
        outOpts.addArgument("-o", "--output-file").help("Output file for the transformed FORTRAN code. If not given, code is printed to stdout");
        outOpts.addArgument("-O", "--output-dir").help("Output directory for transformed FORTRAN files");
        ArgumentGroup cOpts = parser.addArgumentGroup("Compiler options");
        cOpts.addArgument("-I", "--pp-include-dir").nargs("*").action(Arguments.append()).help("Add the directory to the search path for include files reference in preprocessor directives and FORTRAN include statements");
        cOpts.addArgument("-PO", "--pp-output-dir").help("Output directory for preprocessed FORTRAN source files");
        cOpts.addArgument("-D", "--add-macro").nargs("*").action(Arguments.append()).help("Predefine macro");
        cOpts.addArgument("-SI", "--src-include-dir").nargs("*").action(Arguments.append()).help("Add directory to the search path for the source of referenced Fortran modules");
        cOpts.addArgument("-M", "-MI", "--mod-include-dir").nargs("*").action(Arguments.append()).help("Add directory to the search path for .xmod files.");
        cOpts.addArgument("-MO", "--mod-output-dir").help("Output directory for .xmod files.");
        cOpts.addArgument("-MD", "--make-dep-file").nargs("?").setConst("").help("Generate GNU Make dependency file. Default value is <output file>.d");
        cOpts.addArgument("-J").nargs("*").action(Arguments.append()).help("DEPRECATED Add directory to the search path for the source of referenced Fortran modules and .xmod files." + " First given is also output directory for generated .xmod files");
        cOpts.addArgument("-BI", "--buildinfo-include-dir").nargs("*").action(Arguments.append()).help("Include directory for BuildInfo files");
        cOpts.addArgument("-BO", "--buildinfo-output-dir").help("Output directory for BuildInfo files");
        cOpts.addArgument("-XO", "--xast-output-dir").help("Output directory for modules transformed into XCodeML-AST");
        cOpts.addArgument("-TXO", "--txast-output-dir").help("Output directory for translated XCodeML-AST program units");
        cOpts.addArgument("-TRO", "--trans-report-output-dir").help("Output directory for transformation reports");
        cOpts.addArgument("-TSO", "--tsrc-output-dir").help("Output directory for decompiled source program units");
        cOpts.addArgument("-t", "--target").help("Type of target accelerator hardware");
        cOpts.addArgument("-d", "--directive").help("Specify accelerator directive language to be used for code generation");
        cOpts.addArgument("--config").help("Specify a different configuration for the translator");
        cOpts.addArgument("-m", "--model-config").help("Specific model configuration for SCA");
        cOpts.addArgument("-c", "--keep-comment").action(Arguments.storeTrue()).help("Keep comments in the transformed file");
        cOpts.addArgument("-v", "--verbose").action(Arguments.storeTrue()).help("Print processing status");
        cOpts.addArgument("--no-dep").action(Arguments.storeTrue()).help("Don't generate .mod or .xmod file for dependencies");
        cOpts.addArgument("--no-module-cache").action(Arguments.storeTrue()).help("Deactivate module cache in the front-end");
        cOpts.addArgument("-f", "--force").action(Arguments.storeTrue()).help("Force the translation of modules without directives");
        cOpts.addArgument("--force-pure").action(Arguments.storeTrue()).help("Force compiler to exit when transformation applied to PURE subroutine/function");
        cOpts.addArgument("--add-paren").action(Arguments.storeTrue()).help("Add parenthesis to binary operation in generated code");
        cOpts.addArgument("--debug").action(Arguments.storeTrue()).help("Display transformation debug information");
        cOpts.addArgument("--int-dir").help("Path to intermediate files directory (all existing contents will be removed)");
        cOpts.addArgument("--keep-int-files").action(Arguments.storeTrue()).help("Keep intermediate files");
        cOpts.addArgument("--debug-ffront").action(Arguments.storeTrue()).help("Drive OMNI Fortran front-end in debug mode");
        cOpts.addArgument("--skip-pp").action(Arguments.storeTrue()).help("Do not apply preprocessing to input and include files");
        MutuallyExclusiveGroup sOpts = parser.addMutuallyExclusiveGroup("Compiler debug options");
        sOpts.addArgument("--stop-pp").action(Arguments.storeTrue()).help("Stop after preprocessing");
        sOpts.addArgument("--stop-depscan").action(Arguments.storeTrue()).help("Stop after dependencies scan");
        sOpts.addArgument("--stop-xmod-gen").action(Arguments.storeTrue()).help("Stop after Xmod generation");
        sOpts.addArgument("--stop-xast-gen").action(Arguments.storeTrue()).help("Stop after XML-AST generation");
        sOpts.addArgument("--stop-trans").action(Arguments.storeTrue()).help("Stop after translator");
        sOpts.addArgument("--stop-dec").action(Arguments.storeTrue()).help("Stop after decompilation");
        cOpts.addArgument("--gen-buildinfo-files").action(Arguments.storeTrue()).help("Generate build information files for input and then stop");
        cOpts.addArgument("--gen-mod-files").nargs("*").action(Arguments.append()).setConst("").help("Generate xmod files for input and then stop. List of target module names can be optionally supplied.");
        cOpts.addArgument("-x", "--override-cfg-key").nargs("*").action(Arguments.append()).help("Override a configuration key:value pair from the command line. Higher " + "priority over base configuration and user configuration");
        cOpts.addArgument("--dump-cx2t-args").action(Arguments.storeTrue()).help("Print arguments passed to CX2T");
        MutuallyExclusiveGroup mpOpts = parser.addMutuallyExclusiveGroup("Compiler multiprocessing options");
        mpOpts.addArgument("-mp", "--max-num-mp-jobs").type(Integer.class).help("Maximum number of multiprocessing jobs");
        mpOpts.addArgument("--disable-mp").action(Arguments.storeTrue()).help("Disable multiprocessing");
        cOpts.addArgument("-mj", "--sync-with-gmake").action(Arguments.storeTrue()).help("Synchronize number of threads with GNU Make job server");
        ArgumentGroup dcOpts = parser.addArgumentGroup("Decompiler options");
        dcOpts.addArgument("--max-fortran-line-length", "-w").type(Integer.class).setDefault(Integer.valueOf(80)).help("Set the number of columns for the output FORTRAN file (default: 80)");
        dcOpts.addArgument("-l", "--add-pp-line-directives").action(Arguments.storeTrue()).help("Add preprocessor line directives in the output FORTRAN file");
        cOpts.addArgument("-E", "--only-preprocess").action(Arguments.storeTrue()).help("Only apply preprocessor to input files");
        ArgumentGroup pOpts = parser.addArgumentGroup("Process options");
        pOpts.addArgument("--add-pp-opts", "--Wp").nargs("*").action(Arguments.append()).help("Add preprocessor option");
        pOpts.addArgument("--add-ffront-opts", "--Wf").nargs("*").action(Arguments.append()).help("Add frontend option");
        pOpts.addArgument("--add-trans-opts", "--Wx").nargs("*").action(Arguments.append()).help("Add Xcode translator option");
        ArgumentGroup fcOpts = parser.addArgumentGroup("Fortran compiler options");
        final List<String> FC_COMPILER_VENDORS = Arrays.stream(FortranCompilerVendor.values()).map(val -> val.toString().toLowerCase()).collect(Collectors.toList());
        fcOpts.addArgument("--fc-vendor").choices(FC_COMPILER_VENDORS).help("Fortran compiler type");
        fcOpts.addArgument("--fc-cmd").help("Fortran compiler cmd");
        cOpts.addArgument("-td", "--trans-path-dir").nargs("*").action(Arguments.append()).help("Search directory for external transformation set");
        parser.addArgument("--ffront-debug-dir").help("Output directory to collect OMNI failures for easier debugging");
        parsedArgs = parser.parseArgs(args);
    } catch (HelpScreenException hse) {
        return null;
    } catch (ArgumentParserException ape) {
        parser.handleError(ape);
        throw ape;
    }
    Options opts = new Options(parsedArgs, workingDir);
    return opts;
}
Also used : HelpScreenException(net.sourceforge.argparse4j.helper.HelpScreenException) Arrays(java.util.Arrays) ArgumentParsers(net.sourceforge.argparse4j.ArgumentParsers) Set(java.util.Set) MutuallyExclusiveGroup(net.sourceforge.argparse4j.inf.MutuallyExclusiveGroup) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) List(java.util.List) FortranCompilerVendor(clawfc.Configuration.FortranCompilerVendor) Paths(java.nio.file.Paths) ArgumentParser(net.sourceforge.argparse4j.inf.ArgumentParser) Arguments(net.sourceforge.argparse4j.impl.Arguments) ArgumentParserException(net.sourceforge.argparse4j.inf.ArgumentParserException) Namespace(net.sourceforge.argparse4j.inf.Namespace) Utils.sprintf(clawfc.Utils.sprintf) ArgumentGroup(net.sourceforge.argparse4j.inf.ArgumentGroup) Path(java.nio.file.Path) Collections(java.util.Collections) HelpScreenException(net.sourceforge.argparse4j.helper.HelpScreenException) MutuallyExclusiveGroup(net.sourceforge.argparse4j.inf.MutuallyExclusiveGroup) ArgumentParserException(net.sourceforge.argparse4j.inf.ArgumentParserException) ArgumentParser(net.sourceforge.argparse4j.inf.ArgumentParser) Namespace(net.sourceforge.argparse4j.inf.Namespace) ArgumentGroup(net.sourceforge.argparse4j.inf.ArgumentGroup)

Aggregations

HelpScreenException (net.sourceforge.argparse4j.helper.HelpScreenException)2 ArgumentGroup (net.sourceforge.argparse4j.inf.ArgumentGroup)2 ArgumentParser (net.sourceforge.argparse4j.inf.ArgumentParser)2 ArgumentParserException (net.sourceforge.argparse4j.inf.ArgumentParserException)2 MutuallyExclusiveGroup (net.sourceforge.argparse4j.inf.MutuallyExclusiveGroup)2 Namespace (net.sourceforge.argparse4j.inf.Namespace)2 FortranCompilerVendor (clawfc.Configuration.FortranCompilerVendor)1 Utils.sprintf (clawfc.Utils.sprintf)1 Path (java.nio.file.Path)1 Paths (java.nio.file.Paths)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 ArgumentParsers (net.sourceforge.argparse4j.ArgumentParsers)1 Arguments (net.sourceforge.argparse4j.impl.Arguments)1