Skip to content

Commit

Permalink
[sarlc] Write more details into the options' descriptions.
Browse files Browse the repository at this point in the history
Signed-off-by: Stéphane Galland <galland@arakhne.org>
  • Loading branch information
gallandarakhneorg committed Jul 24, 2018
1 parent 3c1a131 commit e197339
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 24 deletions.
Expand Up @@ -55,21 +55,23 @@
*/
public class CompilerConfigModule extends AbstractModule {

private static final String ENCODING_OPTION = "encoding"; //$NON-NLS-1$

@Override
protected void configure() {
VariableDecls.extend(binder()).declareVar(FILE_ENCODING_NAME);
extend(binder()).addOption(OptionMetadata.builder(
"encoding", //$NON-NLS-1$
MessageFormat.format(Messages.CompilerConfigModule_0, Charset.defaultCharset().displayName()))
ENCODING_OPTION,
MessageFormat.format(Messages.CompilerConfigModule_0, ENCODING_OPTION))
.configPath(FILE_ENCODING_NAME)
.valueOptional(Messages.CompilerConfigModule_1)
.defaultValue(Charset.defaultCharset().displayName())
.build());

VariableDecls.extend(binder()).declareVar(JAVA_VERSION_NAME);
extend(binder()).addOption(OptionMetadata.builder(
"javaversion", //$NON-NLS-1$
MessageFormat.format(Messages.CompilerConfigModule_2, SARLVersion.MINIMAL_JDK_VERSION))
"javasource", //$NON-NLS-1$
Messages.CompilerConfigModule_2)
.configPath(JAVA_VERSION_NAME)
.valueOptional(Messages.CompilerConfigModule_3)
.defaultValue(SARLVersion.MINIMAL_JDK_VERSION)
Expand All @@ -79,7 +81,7 @@ protected void configure() {
final String trueFalseValues = MessageFormat.format(Messages.CompilerConfigModule_5,
Boolean.TRUE, Boolean.FALSE);
extend(binder()).addOption(OptionMetadata.builder(
"javacompiler", //$NON-NLS-1$
"enablejavacompiler", //$NON-NLS-1$
MessageFormat.format(Messages.CompilerConfigModule_4, Boolean.TRUE))
.configPath(JAVA_COMPILER_NAME)
.valueOptional(trueFalseValues)
Expand Down
Expand Up @@ -41,7 +41,6 @@ public class Messages extends NLS {
public static String SarlcConfigModule_4;
public static String SarlcConfigModule_5;
public static String SarlcConfigModule_6;
public static String SarlcConfigModule_7;
public static String SarlcConfigModuleProvider_0;
public static String CompilerConfigModule_0;
public static String CompilerConfigModule_1;
Expand Down
Expand Up @@ -28,14 +28,20 @@
import static io.sarl.lang.sarlc.configs.SarlConfig.OUTPUT_PATH_NAME;
import static io.sarl.lang.sarlc.configs.SarlConfig.WORKING_PATH_NAME;

import java.io.File;
import java.text.MessageFormat;

import com.google.inject.AbstractModule;
import com.google.inject.Injector;
import com.google.inject.Provides;
import com.google.inject.Singleton;
import io.bootique.config.ConfigurationFactory;
import io.bootique.meta.application.OptionMetadata;
import org.arakhne.afc.bootique.variables.VariableDecls;
import org.arakhne.afc.bootique.variables.VariableNames;
import org.eclipse.core.runtime.Path;

import io.sarl.lang.SARLConfig;
import io.sarl.lang.sarlc.Constants;
import io.sarl.lang.sarlc.configs.SarlConfig;

Expand All @@ -50,18 +56,28 @@
*/
public class SarlcConfigModule extends AbstractModule {

private static final String CLASSPATH_LONG_OPTION = "classpath"; //$NON-NLS-1$

private static final String CLASSPATH_SHORT_OPTION = "cp"; //$NON-NLS-1$

@Override
protected void configure() {
VariableDecls.extend(binder()).declareVar(OUTPUT_PATH_NAME);
extend(binder()).addOption(OptionMetadata.builder(
Constants.SARL_OUTPUT_DIRECTORY_OPTION, Messages.SarlcConfigModule_0)
Constants.SARL_OUTPUT_DIRECTORY_OPTION,
MessageFormat.format(Messages.SarlcConfigModule_0, Constants.PROGRAM_NAME,
Constants.SARL_OUTPUT_DIRECTORY_OPTION,
Path.fromPortableString(SARLConfig.FOLDER_SOURCE_GENERATED).toFile().getPath()))
.configPath(OUTPUT_PATH_NAME)
.valueRequired(Messages.SarlcConfigModule_1)
.build());

VariableDecls.extend(binder()).declareVar(CLASS_OUTPUT_PATH_NAME);
extend(binder()).addOption(OptionMetadata.builder(
Constants.JAVA_OUTPUT_DIRECTORY_OPTION, Messages.SarlcConfigModule_7)
Constants.JAVA_OUTPUT_DIRECTORY_OPTION,
MessageFormat.format(Messages.SarlcConfigModule_6, Constants.PROGRAM_NAME,
Constants.JAVA_OUTPUT_DIRECTORY_OPTION,
Path.fromPortableString(SARLConfig.FOLDER_BIN).toFile().getPath()))
.configPath(CLASS_OUTPUT_PATH_NAME)
.valueRequired(Messages.SarlcConfigModule_1)
.build());
Expand All @@ -74,20 +90,24 @@ protected void configure() {
.build());

VariableDecls.extend(binder()).declareVar(CLASSPATH_NAME);
final String cpDescription = MessageFormat.format(Messages.SarlcConfigModule_3,
VariableNames.toEnvironmentVariableName(CLASSPATH_NAME), CLASSPATH_SHORT_OPTION,
CLASSPATH_LONG_OPTION);
extend(binder()).addOptions(OptionMetadata.builder(
"classpath", Messages.SarlcConfigModule_3) //$NON-NLS-1$
CLASSPATH_LONG_OPTION, cpDescription)
.configPath(CLASSPATH_NAME)
.valueRequired(Messages.SarlcConfigModule_4)
.build(),
OptionMetadata.builder(
"cp", Messages.SarlcConfigModule_5) //$NON-NLS-1$
CLASSPATH_SHORT_OPTION, cpDescription)
.configPath(CLASSPATH_NAME)
.valueRequired(Messages.SarlcConfigModule_4)
.build());

VariableDecls.extend(binder()).declareVar(BOOT_CLASSPATH_NAME);
extend(binder()).addOption(OptionMetadata.builder(
"bootclasspath", Messages.SarlcConfigModule_6) //$NON-NLS-1$
"bootclasspath", //$NON-NLS-1$
MessageFormat.format(Messages.SarlcConfigModule_5, File.pathSeparator))
.configPath(BOOT_CLASSPATH_NAME)
.valueRequired(Messages.SarlcConfigModule_4)
.build());
Expand Down
Expand Up @@ -56,7 +56,7 @@ protected void configure() {

VariableDecls.extend(binder()).declareVar(ALL_ERRORS_NAME);
extend(binder()).addOption(OptionMetadata.builder(
"werr", Messages.ValidatorConfigModule_1) //$NON-NLS-1$
"werror", Messages.ValidatorConfigModule_1) //$NON-NLS-1$
.configPath(ALL_ERRORS_NAME)
.build());
}
Expand Down
Expand Up @@ -67,9 +67,6 @@ public SarlBatchCompiler provideSarlBatchCompiler(
final SarlBatchCompiler compiler = new SarlBatchCompiler();
injector.injectMembers(compiler);

//final Logger logger = injector.getInstance(Logger.class);
//compiler.setLogger(logger);

if (!Strings.isEmpty(sarlcConfig.getClasspath())) {
compiler.setClassPath(sarlcConfig.getClasspath());
}
Expand Down
@@ -1,4 +1,4 @@
CompilerCommand_0 = Run sarlc.
CompilerCommand_1 = Not enough arguments. Source folders must be provided as arguments.
VersionCommand_0 = Prints the version of sarlc.
VersionCommand_0 = Prints release information.
VersionCommand_1 = SARL Version: {0}\nSARL Specification Version: {1}\nJava Version: {2}\n
@@ -1,15 +1,29 @@
SarlcConfigModule_0 = Output directory in which the Java source files will be generated.
SarlcConfigModule_0 = Sets the destination directory for Java source files that are generated from the SARL files. \
The directory must already exist because {0} does not create it. If a SARL declaration is part of a package, \
then {0} puts the Java source file in a subdirectory that reflects the package name and creates directories \
as needed. If the --{1} option is not specified, then {0} assumes {2}.
SarlcConfigModule_1 = directory_name
SarlcConfigModule_2 = Directory in which the temporary files will be generated during the compilation process.
SarlcConfigModule_3 = Specify where to find user class files and annotation processors.
SarlcConfigModule_3 = Specifies where to find user class files, and source files. This class path \
overrides the user class path in the {0} environment variable. If neither {0}, --{1} nor --{2} \
is specified, then the user class path is built upon the source folders, the generated file folders, \
and the standard SARL libraries. If a user class path is specified, it must contains the the user libraries \
and the standard SARL libraries.
SarlcConfigModule_4 = path
SarlcConfigModule_5 = Specify where to find user class files and annotation processors.
SarlcConfigModule_6 = Override location of bootstrap class files.
SarlcConfigModule_7 = Output directory in which the Java byte code files will be generated.
SarlcConfigModule_5 = Cross-compiles against the specified set of boot classes. As with the user class path, \
boot class path entries are separated by colons ({0}) and can be directories, JAR archives, or ZIP archives.
SarlcConfigModule_6 = Sets the destination directory for class files. The directory must already exist \
because {0} does not create it. If a class is part of a package, then {0} puts the class file in a \
subdirectory that reflects the package name and creates directories as needed. If the --{1} option is \
not specified, then {0} assumes {2}.
SarlcConfigModuleProvider_0 = The configuration for the sarlc tool.
CompilerConfigModule_0 = Specify the character encoding of the files; default is {0}.
CompilerConfigModule_0 = Sets the source file encoding name, such as EUC-JP and UTF-8. If the \
--{0} option is not specified, then the platform default converter is used.
CompilerConfigModule_1 = encoding
CompilerConfigModule_2 = Generate Java files for a specific Java version; default is {0}.
CompilerConfigModule_2 = Specifies the Java version of Java source code accepted, and \
of the Java class files for targeting a specified release of the Java virtual machine. \
Java class files will run on the specified target and on later releases, but not on earlier \
releases of the Java virtual machine. Valid targets are: 1.8 (or 8).
CompilerConfigModule_3 = version
CompilerConfigModule_4 = Specify if the Java compiler should be run; default is {0}.
CompilerConfigModule_5 = {0}|{1}
Expand All @@ -23,6 +37,6 @@ CompilerConfigModule_12 = Specify if the clone functions should be generated; de
CompilerConfigModule_13 = Specify if the serial identifiers should be generated; default is {0}.
CompilerConfigModuleProvider_0 = The configuration for the SARL compiler.
ValidatorConfigModule_0 = Specify if all the warnings are ignored.
ValidatorConfigModule_1 = Specify if any warning is assimilated to an error.
ValidatorConfigModule_1 = Terminates compilation when warnings occur.
ValidatorConfigModule_2 = Specify if all the warnings are printed out.
ValidatorConfigModuleProvider_0 = The configuration for the SARL validator.

0 comments on commit e197339

Please sign in to comment.