pyccel.codegen.compiling.basic module#
Module handling classes for compiler information relevant to a given object
- class pyccel.codegen.compiling.basic.CompileObj(file_name, folder, flags=(), include=(), libs=(), libdir=(), dependencies=(), accelerators=(), has_target_file=True, prog_target=None)[source]#
Bases:
object
Class containing all information necessary for compiling.
A class which stores all information which may be needed in order to compile an object. This includes its name, location, and all dependencies and flags which may need to be passed to the compiler.
- Parameters:
file_name (str) – Name of file to be compiled.
folder (str) – Name of the folder where the file is found.
flags (str) – Any non-default flags passed to the compiler.
include (iterable of strs) – Include directories paths.
libs (iterable of strs) – Required libraries.
libdir (iterable of strs) – Paths to directories containing the required libraries.
dependencies (iterable of CompileObjs) – Objects which must also be compiled in order to compile this module/program.
accelerators (iterable of str) – Tool used to accelerate the code (e.g. openmp openacc).
has_target_file (bool, default : True) – If set to false then this flag indicates that the file has no target. Eg an interface for a library.
prog_target (str, default: None) – The name of the executable that should be generated if this file is a program. If no name is provided then the module name deduced from the file name is used.
- property accelerators#
Get the names of the accelerators required to compile the file.
Return a set containing the name of all accelerators required to compile the file. An accelerator is a tool used to add a new capacity to the code. Such an addition requires multiple flags (include/libs/libdir/etc) and is therefore specified separately in the compiler configuration file. Examples of ‘accelerators’ are: openmp, openacc, python.
- acquire_lock()[source]#
Lock the file and its dependencies to prevent race conditions.
Acquire the file locks for the file being compiled, all dependencies needed to compile it and the target file which will be generated.
- acquire_simple_lock()[source]#
Lock the file created by this CompileObj.
Acquire the file lock for the file created by this CompileObj to prevent race conditions. This function should be called when the created file is a dependency, it is therefore not necessary for it to recurse into its own dependencies.
- add_dependencies(*args)[source]#
Indicate that the file to be compiled depends on a given other file
- Parameters:
*args (CompileObj)
- compilation_in_progress = <filelock._unix.UnixFileLock object>#
- property dependencies#
Returns the objects which the file to be compiled uses
- property extra_modules#
Returns the additional objects required to compile the file
- property flags#
Returns the additional flags required to compile the file
- property has_target_file#
Indicates whether the file has a target. Eg an interface for a library may not have a target
- property include#
Get the additional include directories required to compile the file.
Return a set containing all the directories which must be passed to the compiler via the include flag -I.
- property libdir#
Get the additional library directories required to compile the file.
Return a set containing all the directories which must be passed to the compiler via the library directory flag -L so that the necessary libraries can be correctly located.
- property libs#
Get the additional libraries required to compile the file.
Return a list containing all the libraries which must be passed to the compiler via the library flag -l.
- property module_target#
Returns the .o file to be generated by the compilation step
- property program_target#
Returns the program to be generated by the compilation step
- property python_module#
Returns the python name of the file to be compiled
- release_lock()[source]#
Unlock the file and its dependencies.
Release the file locks for the file being compiled, all dependencies needed to compile it and the target file which will be generated.
- release_simple_lock()[source]#
Unlock the file created by this CompileObj.
Release the file lock for the file created by this CompileObj to prevent race conditions. This function should be called when the created file is a dependency, it is therefore not necessary for it to recurse into its own dependencies.
- reset_folder(folder)[source]#
Change the folder in which the source file is saved.
Change the folder in which the source file is saved. Normally the location of the source file should not change during the execution, however when working with the stdlib, the CompileObj is created with the folder set to the file’s location in the Pyccel install directory. When the file is used it is copied to the user’s folder, at which point the folder of the CompileObj must be updated.
- Parameters:
folder (str) – The new folder where the source file can be found.
- property source#
Returns the file to be compiled
- property source_folder#
Returns the location of the file to be compiled