[Gambas-user] Sharing Code Between Projects
Benoît Minisini
gambas at ...1...
Wed Jun 7 17:56:14 CEST 2017
Le 07/06/2017 à 16:25, adamnt42 at ...626... a écrit :
>
> I think you need to understand a lot more about libraries and
> components. Libraries are useful for one developer trying to re-use
> code between projects on a single machine. If you are talking about
> deploying shared code in a way that it can be used by different
> people developing different projects on different machines then you
> need to look at the component mechanism. There is really no
> programming difference between a library and a component (except when
> talking about gui controls). The difference is how and where they
> are deployed. Libraries are (or were,until the naming convention
> changed :-< ) simple and easy. Components offer more deployment
> options but require a bit more packaging effort.
>
> b
>
Actually, components are more like extensions to the Gambas language,
and should be distributed with the Gambas source code.
So you should always make libraries for your own needs.
A library package is installed system-wide, and can be used by any
Gambas program, as now the reference to the library is based on its
name, not its absolute path as it was before.
A library used by a project is referenced by its vendor, and by its name.
When the project is executed, the library is searched in the following
paths, in that order:
1) '<project executable directory>/<name>.gambas' (for
backward-compatibility).
2) '$XDG_DATA_HOME/gambas3/lib/<vendor>/<name>:<version>.gambas' (if
$XDG_DATA_HOME is defined).
3) '~/.local/share/gambas3/lib/<vendor>/<name>:<version>.gambas', (if
$XDG_DATA_HOME is NOT defined).
4) '<project extra archive directory>/<vendor>/<name>:<version>.gambas'
(the project extra archive directory is a project property defined in
the 'library' tab of the project property dialog).
5) '/usr/lib/gambas3/<vendor>/<name>:<version>.gambas' (library packages
are installed there, system-wide).
6) '/usr/bin/<vendor>/<name>.gambas' (standard gambas programs can be
used as libraries).
I suggest not to use the 1) and 6) feature, they are there for
backward-compatibility mainly.
2) & 3) are there for user-wide installation of libraries. Libraries are
installed user-wide when you make an executable from their source
project ; or when you install a library from the gambas farm.
I hope all that was clear!
Regards,
--
Benoît Minisini
More information about the User
mailing list