Scilab Website | Contribute with GitLab | Mailing list archives | ATOMS toolboxes
Scilab Online Help
2023.0.0 - Português


genlib

builds a library from a set of *.sci files defining functions in a given directory

Syntax

genlib(lib_name)
genlib(lib_name, dir_name)
genlib(lib_name, dir_name, Force)
genlib(lib_name, dir_name, Force, verb)
genlib(lib_name [,path=dir_name] [,verbose=verb] [,force=Force])

Arguments

lib_name
Scilab string: The identifying name ascribed to the library to build.

dir_name
Scilab string: The pathname of the directory containing .sci functions files, and where the lib file generated and defining the library will be stored. By default, the current working directory is considered.
The dir_name directory and its lib and .bin files must be writable.

Force
boolean value (default value is %f). Set it to %t to force the sci-files recompilation.

verb
boolean value (default value is %f). Set it to %t to display more information during the build.

Description

genlib(..) selects all files belonging to the dir_name directory and with the .sci extension. If any, subdirectories are never considered. If it is required, they must be compiled apart into independent libraries.

Then, an XML editable file named lib is created in the dir_name directory. The name lib_name of the library is recorded into it.

Then, for each .sci file:

  • If
    • there is no related .bin file in dir_name with the same basename (as for the initial build of the library), or
    • the content of the .sci file has changed since the previous build,

    the .sci file is compiled (almost as it would be with exec(..)):

    • If it contains at least one function .. endfunction block, a .bin binary file with the same basename is generated and stored in dir_name. It contains the binary code of ALL functions defined in the .sci source file.

      • If the name of one of the function(s) defined in the file is the basename of the .sci file, this function is registered in the lib file.

      • Otherwise, no function from the .sci file is registered: Its whole content is considered as dead code.

      If a test.sci file defines the test() function AND other functions like sub(), sub() functions are then considered as private to test(). For instance,
      function r = sub(a)
          r = 2*a
      endfunction
      
      function test()
          disp("A test")
      endfunction
      
      function r = other(b)
          r = 2^b
      endfunction
      
      is equivalent to
      function test()
          function r = sub(a)
              r = 2*a
          endfunction
          function r = other(b)
              r = 2^b
          endfunction
      
          disp("A test")
      endfunction
      
      Hence, sub() and other() won't exist out of test(), and won't be registered in the library.

    • Otherwise, no .bin file is generated: The whole content of the .sci file is considered as dead code.

  • Otherwise: If the file's content has not changed and has already a function entry in the lib file, this entry is kept.

Finally, genlib(..) loads the created or updated library and sets its identifier to a variable named lib_name, in the current scope. If the variable lib_name already exists and is protected, an error occurs: The library has been created but can't be loaded (predef all can be used to unprotect the variable named lib_name before running genlib(..)).

If the option force=%t is used, all .sci files are compiled, even if their content has not changed.

When in the directory of a library some former .sci files have been removed while all remaining .sci files are unchanged, rebuilding the library without the force=%t will anyway update the list of library's members.

If the option verbose is true, more information is displayed during the build process.

See also

  • library — library datatype
  • load — Loads some archived variables, a saved graphic figure, a library of functions
  • getd — retorna todas as funções definidas em um diretório
  • lib — loads a library of Scilab functions and variables, and sets its name

History

VersionDescription
6.0.0
  • The file names is no longer required. The Names option is removed.
  • When a .sci file contains functions not named accordingly with the file name, they are no longer public: They are visible and callable only from the main function.
  • When a library named lib_name is already loaded, the default dir_name directory is no longer its directory (update mode), but always the current working one.
  • The generated lib file is now a human-readable XML file, instead of a binary.
  • genlib() can no longer register any variable as full member of a library.
  • By default, any .sci file is now recompiled if its content has changed, no longer if its modification date is newer than the .bin's one.
  • The generated .bin files can no longer be loaded independently with load().
Report an issue
<< Libraries Libraries get_function_path >>

Copyright (c) 2022-2024 (Dassault Systèmes)
Copyright (c) 2017-2022 (ESI Group)
Copyright (c) 2011-2017 (Scilab Enterprises)
Copyright (c) 1989-2012 (INRIA)
Copyright (c) 1989-2007 (ENPC)
with contributors
Last updated:
Mon Mar 27 09:50:00 GMT 2023