Exemple #1
0
 def set_options(self, compiler_options):
     """
     Set compiler options. See available options in the file options.xml.
     
     Parameters::
     
         compiler_options --
             A dict of options where the key specifies which option to modify 
             and the value the new value for the option.
     
     Raises::
     
         JMIException if the value of the option is not one of the allowed 
         types (float, boolean, string, integer or list).
     """
     # set compiler options
     for key, value in compiler_options.iteritems():
         if isinstance(value, bool):
             self.set_boolean_option(key, value)
         elif isinstance(value, basestring):
             self.set_string_option(key, value)
         elif isinstance(value, int):
             self.set_integer_option(key, value)
         elif isinstance(value, float):
             self.set_real_option(key, value)
         elif isinstance(value, list):
             self.set_string_option(key, list_to_string(value))
         else:
             raise JMIException("Unknown compiler option type for key: %s. \
             Should be of the following types: boolean, string, integer, \
             float or list" % key)
Exemple #2
0
def _compile_unit(class_name, file_name, compiler, target, version,
                platform, compiler_options, compile_to, compiler_log_level,
                separate_process, jvm_args):
    """
    Helper function for compile_fmu and compile_fmux.
    """
    for key, value in compiler_options.iteritems():
        if isinstance(value, list):
            compiler_options[key] = list_to_string(value)
    
    if isinstance(file_name, basestring):
        file_name = [file_name]
        
    if platform == 'auto':
        platform = _get_platform()
        
    if not separate_process:
        # get a compiler based on 'compiler' argument or files listed in file_name
        comp = _get_compiler(files=file_name, selected_compiler=compiler)
        # set compiler options
        comp.set_options(compiler_options)
        
        # set log level
        comp.set_compiler_logger(compiler_log_level)
        
        # set platform
        comp.set_target_platforms(platform)
        
        # compile unit in java
        return comp.compile_Unit(class_name, file_name, target, version, compile_to)

    else:
        return compile_separate_process(class_name, file_name, compiler, target, version, platform, 
                                        compiler_options, compile_to, compiler_log_level, jvm_args)
Exemple #3
0
def _compile_unit(
    class_name,
    file_name,
    compiler,
    target,
    version,
    compiler_options,
    compile_to,
    compiler_log_level,
    separate_process,
    jvm_args,
):
    """
    Helper function for compile_fmu, compile_jmu and compile_fmux.
    """
    for key, value in compiler_options.iteritems():
        if isinstance(value, list):
            compiler_options[key] = list_to_string(value)

    if isinstance(file_name, basestring):
        file_name = [file_name]

    if not separate_process:
        # get a compiler based on 'compiler' argument or files listed in file_name
        comp = _get_compiler(files=file_name, selected_compiler=compiler)
        # set compiler options
        comp.set_options(compiler_options)

        # set log level
        comp.set_compiler_logger(compiler_log_level)

        # compile unit in java
        warnings = comp.compile_Unit(class_name, file_name, target, version, compile_to)

    else:
        warnings = compile_separate_process(
            class_name, file_name, compiler, target, version, compiler_options, compile_to, compiler_log_level, jvm_args
        )

    if os.path.isdir(compile_to):
        return CompilerResult(os.path.join(compile_to, _get_unit_name_from_target(class_name, target)), warnings)
    else:
        return CompilerResult(compile_to, warnings)
Exemple #4
0
def _compile_unit(class_name, file_name, compiler, target, version,
                  compiler_options, compile_to, compiler_log_level,
                  separate_process, jvm_args):
    """
    Helper function for compile_fmu, compile_jmu and compile_fmux.
    """
    for key, value in compiler_options.iteritems():
        if isinstance(value, list):
            compiler_options[key] = list_to_string(value)

    if isinstance(file_name, basestring):
        file_name = [file_name]

    if not separate_process:
        # get a compiler based on 'compiler' argument or files listed in file_name
        comp = _get_compiler(files=file_name, selected_compiler=compiler)
        # set compiler options
        comp.set_options(compiler_options)

        # set log level
        comp.set_compiler_logger(compiler_log_level)

        # compile unit in java
        warnings = comp.compile_Unit(class_name, file_name, target, version,
                                     compile_to)

    else:
        warnings = compile_separate_process(class_name, file_name, compiler,
                                            target, version, compiler_options,
                                            compile_to, compiler_log_level,
                                            jvm_args)

    if os.path.isdir(compile_to):
        return CompilerResult(
            os.path.join(compile_to,
                         _get_unit_name_from_target(class_name, target)),
            warnings)
    else:
        return CompilerResult(compile_to, warnings)