Commit Graph

30 Commits

Author SHA1 Message Date
svenbarth
9eb5f07538 * check that the PPU version of a unit loaded for package adjustment matches exactly (we don't accept different versions when loading PPUs normally, so why should we with packages?)
git-svn-id: trunk@37971 -
2018-01-14 21:16:37 +00:00
florian
b1dff29cbf * removed unused units
git-svn-id: trunk@36165 -
2017-05-09 19:53:14 +00:00
Jonas Maebe
472b5228fe * changed ncgutil.has_alias_name(pd,s) to a method of tprocdef
git-svn-id: trunk@35085 -
2016-12-09 13:39:28 +00:00
yury
e3d9dbbeef * Removed unused vars.
git-svn-id: trunk@34404 -
2016-09-01 19:55:45 +00:00
svenbarth
f1cdb5c4e9 * don't export types that have been merely renamed (and thus are part of another unit and potentially another package altogether)
git-svn-id: trunk@34340 -
2016-08-19 13:29:33 +00:00
svenbarth
0a1be7f985 * also export all public RTTI and (required) INIT symbols aside from the non-existing internal ones
git-svn-id: trunk@34318 -
2016-08-15 14:49:44 +00:00
svenbarth
a073b86b57 * move handling of typesym's defs from insert_export() to its own function export_typedef()
git-svn-id: trunk@34317 -
2016-08-15 14:38:10 +00:00
svenbarth
ad2facb10d * also add the forced indirect symbols of data symbols to the public assembler symbols
* export the forced indirect symbols of data symbols on systems without indirect imports

git-svn-id: trunk@34313 -
2016-08-14 15:37:52 +00:00
svenbarth
2841cd9a9e * export IID and IIDSTR symbols of interfaces
git-svn-id: trunk@34255 -
2016-08-05 15:10:25 +00:00
svenbarth
b079fed247 * generate an internal error when exporting an unknown symbol
- disable the debug output

git-svn-id: trunk@34253 -
2016-08-05 14:43:44 +00:00
svenbarth
32a354fc26 * ignore absolutevarsyms when exporting (at least for ordinary variable absolute symbols this works; for others we'll have to see...)
git-svn-id: trunk@34252 -
2016-08-05 14:42:58 +00:00
svenbarth
cbbbe8927e * handle the export and import of resourcestring symbols for packages
git-svn-id: trunk@34187 -
2016-07-22 16:03:59 +00:00
svenbarth
ccb4b23949 * register the start and end symbols of resource strings in the extern assembler list of the program/library
* export the start and end symbols of resource strings from the package

git-svn-id: trunk@34186 -
2016-07-22 16:03:16 +00:00
svenbarth
3147374178 Ensure uniqueness of internal errors
git-svn-id: trunk@34183 -
2016-07-22 15:56:54 +00:00
svenbarth
022df814c2 * use the extern and public assembler symbol lists stored in the units to resolve those symbols to a used package that don't have a corresponding Pascal symbol
git-svn-id: trunk@34179 -
2016-07-22 13:42:13 +00:00
svenbarth
6cc7539208 * also export the mangled RTTI name from a package
git-svn-id: trunk@34178 -
2016-07-22 13:39:51 +00:00
svenbarth
a4cfa64d96 pkgutil.pas, insert_export:
* only export the symbol name with the indirect suffix (on Windows the indirect ones will be generated in the module that does the importing on other system's they're not needed anyway)

git-svn-id: trunk@33966 -
2016-06-12 12:50:20 +00:00
svenbarth
fa4690eef8 Don't try to export generics.
pkgutil.pas, exportabstractrecorddef:
  * if it's a generic then leave before iterating the nested types

git-svn-id: trunk@33963 -
2016-06-12 09:25:22 +00:00
svenbarth
b5d984da7a pkgutil.pas, createimportlibfromexternals:
* only process a unit's imports if the unit is not already from a package

git-svn-id: trunk@33686 -
2016-05-13 15:20:08 +00:00
svenbarth
adbef4fc84 New export option that enforces the use of the provided export name instead of using the name of the provided symbol. This is necessary to correctly handle overloaded functions, especially if one of them is an internproc one.
export.pas:
  + texportoption: new option eo_no_sym_name
pkgutil.pas:
  * exportprocsym: set eo_no_sym_name when exporting procdefs from a package
systems/t_win.pas, TExportLibWin:
  * generatelib: respect eo_no_sym_name

git-svn-id: trunk@33574 -
2016-04-29 15:03:18 +00:00
svenbarth
0a8d531b8d Merged revision(s) 32582-32583, 32635, 32637, 32639 from branches/svenbarth/packages:
pkgutil.pas, createimportlibfromexternals:
  * findpackagewithsym: ignore other (weak) external symbols
........
pkgutil.pas, createimportlibfromexternals:
  * import_proc_symbol: at least import the mangled name if there is no alias available
........
pkgutil.pas:
  * exportabstractrecordsymproc & insert_export: don't try to export a typedef if it doesn't belong to the current symtable, happens for cross unit type aliases
........
psub.pas:
  * read_proc: extract the code that creates an import library entry into its own function import_external_proc so that the same code can be used from other locations as well
........
Correctly handle external functions that are used from other units.

pkgutil.pas, createimportlibfromexternals:
  * processasmsyms: also check the import name when checking for duplicates (just for safety, the cache check should have caught these already)
  * processimportedsyms: if we have a routine imported from a library of whihc the symbol resides in a unit loaded from a package we need to import the routine ourselves instead of trying to import it from the package; also add an entry in the cache to speed up finding it again in processasmsyms()
........

git-svn-id: trunk@33519 -
2016-04-15 15:09:37 +00:00
svenbarth
1824a945cf Merged revision(s) 32515, 32573, 32575, 32579 from branches/svenbarth/packages:
Report a warning if a unit is used from an indirectly used package. We are doing this only for the units used in contained units though as in the "contains" section there can't be such units anyway (and just checking all loaded units would lead to false positives).

pkgutil.pas:
  + new procedure check_for_indirect_package_usages() which walks a TLinkedList of used units and warns on every unit that is from an indirectly imported package
pmodules.pas, proc_package:
  * when checking all loaded units whether they are from a package or not also check for indirect package usages using the new procedure

........
pkgutil.pas, exportprocsym:
  * use a temporary variable for the procdef
  * restructure the if-expression a bit to make it better readable

........
pmodules.pas, finish_unit:
  * also release the generated proc symbol if the init function isn't needed

........
pkgutil.pas, add_package_libs:
  * fix exit condition (on Linux it probably worked by accident :/ )
........

git-svn-id: trunk@33518 -
2016-04-15 14:47:51 +00:00
svenbarth
e8ede4c3e2 Merged revision(s) 32508-32510, 32512 from branches/svenbarth/packages:
Keep track whether a package was added directly through a requires section (or the command line) or indirectly.

fpkg.pas, tpackageentry:
  + new field "direct"
pkgutil.pas:
  + add_package: new parameter "direct" which sets the "direct" field of the new package entry
options.pas:
  * TOption.interpret_option & read_arguments: adjust call to add_package()
pmodules.pas:
  * proc_package: adjust call to add_package()

........
Also load all packages that are required by packages, but that are not part of the directly used packages.

pkgutil.pas, load_packages:
  * check the list of required packages for packages that are not yet part of the package list and add these as indirect packages
  * establish the links to loaded packages in the required packages once all packages were loaded

........
fpcp.pas, tpcppackage:
  + new method add_required_package() to add a required package while ignoring duplicates

........
pmodules.pas, proc_package:
  * add all packages of loaded units as required packages

........

git-svn-id: trunk@33517 -
2016-04-15 14:42:24 +00:00
svenbarth
3e70ac05c2 Merged revision(s) 32450-32451, 32455, 32457-32458, 32460-32462, 32477, 32480 from branches/svenbarth/packages:
cclasses.pas, TCmdStrList:
  * if doubles are not allowed then do case sensitive checks instead of insensitive ones

........
Correctly handle export/import generation depending on whether we're compiling for a system that needs indirect imports or not.

systems.pas:
  * replace systems_package_need_exports with systems_indirect_var_imports
pmodules.pas, proc_package:
  - remove check for systems_package_need_exports
pkgutil.pas:
  * insert_export, export_unit: export the direct or the indirect variable symbol depending on systems_indirect_var_imports

........
ncgrtti.pas, TRTTIWriter.write_extra_rttisyms:
  * enumdef_rtti_string2ordindex & enumdef_rtti_ord2stringindex: put the indirect suffix at the end of the symbol

........
pkgutil.pas, add_package_libs:
  * check for systems_indirect_var_imports instead of systems_package_needs_exports

........
expunix.pas, texportlibunix:
  * generatelib: check all procdefs whether they have the alias and not only the first one

........
pkgutil.pas:
  * insert_export: directly report the symbol type instead of its ordinal to ease finding of problems

........
pkgutil.pas, export_procsym:
  * restructure if for better readability
  + also check the procdef for po_has_public_name

........
Ensure that all implicitely imported units are indeed part of the package.

pmodules.pas, proc_package:
  * instead of checking the units loaded by the current module we need to check *all* units that are loaded for the package

........
Fix inclusion of PPUs that don't have a corresponding object file.

pkgutil.pas, RewritePPU:
  * don't abort if a unit does have the flag uf_no_link set
  * only abort if both uf_static_link and uf_no_link are not set

........
Generate an error if a unit listed as in "contains" is part of a directly or indirectly required package.

pmodules.pas, proc_package:
  * walk all units and check whether it had been loaded from a package, but is also part of the units of the current module; if so then generate an error

........

git-svn-id: trunk@33516 -
2016-04-15 14:23:55 +00:00
svenbarth
7d8d0340b9 Merged revision(s) 31988, 31991-31993, 32136, 32308-32309, 32312, 32318 from branches/svenbarth/packages:
Correctly parse the directives DenyPackageUnit and WeakPackageUnit

ppu.pas:
  + add flags uf_packagedeny and uf_packageweak
scandir.pas:
  + new procedure do_moduleflagswitch() which parses a ON/OFF/+/- argument and sets or clears a flag in the current module
  + new procedure dir_denypackageunit which handles DenyPackageUnit
  * implement dir_weakpackageunit (and move to the correct location ;) )
  * InitScannerDirectives: add dir_denypackageunit handler
........
Respect DenyPackageUnit flag.

pmodules.pas, proc_package:
  * check all contained units that are not already part of a package for their uf_package_deny flag and report an error for each that has it set
........
Do not check whether all units are used as by definition all units of a package are considered as used.

pmodules.pas, proc_package:
  - remove call to current_module.allunitsused
........
Check whether a unit has been implicitely imported in a package. A unit is considered as implicitely imported if it is not part of a required package nor part of the units listed in the contains section. This note is useful (Delphi even provides a dialog in that case) as a package with implicitely imported units /might/ become incompatible with other packages (e.g. if another package includes that unit uses that package and includes that unit explicitely; of course that is the same as if both package included it explicitely, but with the hint one knows where to look).

pmodules.pas, proc_package:
  * while walking the loaded units also check whether any of them not contained in a package was part of the contained units which are the same as the current module's used units
........
Generate CRC for package files

pcp.pas, tpcpfile:
  + new field do_crc which controls CRC generation
  + override putdata() method to generate CRC when data is written
  * resetfile: enable do_crc by default
........fppu.pas, tppumodule:
  * loadfrompackage: mention if a unit is loaded from a package
........
fpkg.pas, tcontainedunit:
  + new fields offset and size for the PPU data stored inside the PCP
fpcp.pas, tpcppackage:
  * readcontainedunits & addunit: correctly initialize offset and size to 0
........
Store the modified PPU files directly inside the PCP and thus get finally rid of the .ppl.ppu files.

entfile.pas:
  + new entry type ibpputable
pkgutil.pas:
  * adjust RewritePPU to work on a stream as output instead of a filename
fpcp.pas, tpcppackage:
  + new method writepputable() which writes the offsets and sizes of all contained units (not part of CRC!)
  + new method writeppudata() which rewrites all contained PPUs directly into the PCP after the ibend entry (Note: the data is written 16 Byte aligned to ease viewing of the PCP and its contained PPUs in a hex editor)
  + new method readpputable() which reads the offsets and sizes of all contained units
  + new method getmodulestream() which returns a substream for a contained module
  * loadpcp: also call readpputable()
  * writepcp: first write an empty pputable, then finish writing all data that requires the put*/write* methods of the pcpfile, then use writeppudata() to write all PPUs and finally write the correct pputable at the original location
fppu.pas, tppumodule:
  * loadfrompackage: don't read the PPU from a file if it is contained in a package, but using the new tpcppackage.getmodulestream() and tppumodule.openppustream() methods
pmodules.pas, proc_package:
  * don't rewrite the PPUs here
pcp.pas:
  * increase CurrentPCPVersion
........
Fix cycling

........

git-svn-id: trunk@33514 -
2016-04-15 13:39:41 +00:00
svenbarth
c5bdc11cb2 Merged revision(s) 31924, 31934-31937 from branches/svenbarth/packages:
pmodules.pas, proc_package:
  * generate the dummy entry symbol only on Windows systems (ToDo for other systems that might need it)

........
options.pas:
  * TOption.interpret_option & read_arguments: use add_package() from pkgutils instead of addpackage() from fpkg
fpkg.pas:
  - remove no longer needed addpackage()

........
pkgutil.pas:
  + new procedure add_package_libs() to add all packages as libraries that are also linked against
pmodules.pas:
  * proc_package & proc_program: add all package libraries to the linker before creating the final binary

........
pkgutil.pas, add_package:
  * package names are case insensitive so add them in uppercase to correctly detect duplicates

........
Keep track of how many units are used from each required/requested package and only link those from which any units are used.

fpkg.pas, tpackageentry:
  + new field usedunits to count how many units of the package are used
pkgutil.pas:
  + new procedure add_package_unit_ref() to increase the amount of used units for the given package
pmodules.pas:
  * proc_package & proc_program: check which units of all loaded ones are provided by other packages

........

git-svn-id: trunk@33510 -
2016-04-14 21:35:47 +00:00
svenbarth
4d0c009ad0 Ensure that structures types are exported consistently no matter whether they are top level or nested.
pkgutil.pas:
  + new routine exportabstractrecorddef which does not export generics and also exports the VMT variable
  * exportabstractrecordsymproc & insert_export: use exportabstractrecorddef to export a structured type

git-svn-id: trunk@33503 -
2016-04-14 20:15:07 +00:00
svenbarth
f55123ce92 Merged revision(s) 28904-28905, 29038-29044 from branches/svenbarth/packages:
Don't try to export generic symbols.

pkgutil.pas:
  * exportabstractrecordsymproc: do not export generic type symbols or their nested symbols
........
Ensure that the correct name is used for the PCP file.

proc_package:
  * use current_module.modulename instead of module_name for the base filename of the PCP file
........
Add a possibility to track if a unit was loaded from a package.

fmodule.pas, tmodule:
  + new field "package" which is Nil if the unit is not (yet) part of a package or a reference to the package this unit was loaded from
fppu.pas, tppumodule:
  * loadfrompackage: set the "package" field of the module to the package it's loaded from.

........
Ensure that units loaded from a package are not recompiled if the source files should happen to be available.

fppu.pas, tppumodule:
  loadppu: set the state to ms_compiled instead of ms_load if the unit was loaded from a package (additionally close the PPU file as it's no longer needed)

........
Add support for reading/writing required packages from/to the PCP file

fpcp.pas, tpcppackage:
  + new methods writerequiredpackages and readrequiredpackages
  * loadpcp: use readrequiredpackages
  * savepcp: use writerequiredpackages
pcp.pas:
  * increase PCP version

........
When compiling a package, handle only those units that are not yet part of a package.

pmodules.pas, proc_package:
  * only export units that are part of the package
  * only add units to the package if they are really part of the package
  * don't rewrite the PPU if the unit is not part of the package
  * don't link the unit's files if it is not part of the package

........
Add support for parsing required packages.

pkgutil.pas:
  + new function add_package to add a package to the list of available packages with the possibility to check for duplicates
  * load_packages: also load all required packages
pmodules.pas, proc_package:
  * create the tpcppackage instance earlier (and use the module name as read from the source file as package name)
  * clear the list of packages in case the user passed any using -FPxxx
  * parse the "requires" section like a list of units and add each full identifier as a package to load
  * before parsing the "contains" section load all packages, so that all units can be correctly resolved

........
Correctly create import libraries for packages as well.

pkgutil.pas, createimportlibfromexternals:
  * instead of processing units without the uf_in_library flag, only process those that don't have a package reference set (thus becoming part of the program/library or the package)
  - remove unneeded "pkg" parameter
pmodules.pas:
  + proc_package: create the import library if the package requires other packages
  * proc_program: adjust call to createimportlibfromexternals

........
Ensure that the reference to the System unit is correctly set up for packages. Among other things this is needed to compile a package with the -gl option (though debug information doesn't work yet).

pmodules.pas:
  * convert AddUnit to a function and let it return the newly loaded module
  * proc_package: when parsing the contained units ensure that we correctly set up the System unit reference if we are to contain the System unit
  * proc_package: also set up the System unit reference once all units are loaded and this hasn't happened yet (because all contained units are already compiled)

........

git-svn-id: trunk@33502 -
2016-04-14 20:01:17 +00:00
svenbarth
9d1938a713 Partial merge of r28851 (aside the parts that requires the global assembler symbols)
Generate the import library for each used package.

pkgutil.pas:
  - remove function createimportlibfromexports
  + new function createimportlibfromexternals which uses the imported unit symbols of a unit to generate the correct import library for each used package used in a program or library
pmodules.pas, proc_program:
  * move the generation of the import library further down until all tables were generated of which entries might reside in a package
  * use createimportlibfromexternals to generate the import library for the program/library
-- Diese und die folgenden Zeilen werden ignoriert --

M    pmodules.pas
M    pkgutil.pas

git-svn-id: trunk@33493 -
2016-04-12 21:32:25 +00:00
svenbarth
f8e9b33f99 Merge first batch of package handling related revisions from the packages branch
Merged revision(s) 28796, 28837-28845, 28847-28850, 28852, 32135 from branches/svenbarth/packages:
Provide possibility to pass packages and search paths for packages as parameters.

fpkg.pas:
  + new unit which contains the base types related to package files (most importantly "tpackage")
globals.pas:
  + new variable "packagesearchpath" which contains all paths in which package files should be looked for
  + new variable "packagelist" which contains a list of all packages that should be used in a program or library
  * InitGlobals & DoneGlobals: initialize/finalize "packagesearchpath" accordingly ("packagelist" is handled in unit fpkg using a init/done-callback)
options.pas:
  + TOption: new fields "parapackagepath" and "parapackages" to keep track of package search paths and package files passed as parameters
  * TOption.interpret_option: use '-Fp' for package search paths and '-FP' for package files
  * read_arguments: apply the passed package search paths and packages to their respective containers
........
+ add a new unit which will contain basic functions related to handling packages
........
Move package related functions from pmodules to pkgutil.

pmodules.pas => pkgutil.pas:
  * createimportlibfromexports
  * varexport
  * procexport
  * insert_export
  * RewritePPU
........
* adjust indentation
........
Extract the code to export the symbols of a unit to its own function in pkgutil so that less functions need to be exported.

pmodules.pas, proc_package:
  * move code to export the symbols of a unit to new function export_unit
pkgutil.pas:
  + new function export_unit
  - remove exports of procexport, varexport and insert_export
........
Some small fixes for package parsing.

pmodules.pas, proc_package:
  * use orgpattern instead of pattern to build the module name (like is done in uses sections)
  * ignore duplicates when generating exports
  - no need to generate an import library for the package; that is done by the program/library that uses the package
........
+ new unit fpcp of which the class tpcppackage handles the reading and writing of package metadata from/to pcp files (equivalant to tppumodule).
........
+ add unit which contains representation of a PCP file (tpcpfile) like tppufile is for units.
........
Improve export generation.

pkgutil.pas:
  + new function exportprocsym to correctly export a procedure with all its aliases
  + new function exportabstractrecordsymproc to export the members of structured types 
  * insert_export: handle also namespacesym and propertsym (by ignoring them)
  * insert_export: correctly export classes, record and objects
  * insert_export: use new exportprocsym function to export a procsym
  * insert_export: only export public variables of a static symtable


........
+ add entry constants for the name of the package and the package file names, both used by a PCP file
........
* use messages to get rid of most writelns related to package loading
........
Add additional entry types for PCP files

entfile.pas:
  + new entries ibstartrequireds and ibendrequireds to store the list of required packages
  + new entries ibstartcontained and ibendcontained to store the list of contained units
  + new entries ibstartppus and ibendppus to store the list of contained PPU files
........
Generate the PCP file once the package file and the used units were compiled correctly.

pmodules.pas:
  * proc_package: generate the PCP file upon successful compilation
........
Add the possibility to load all packages supplied as parameters.

pkgutil.pas:
  + new function load_packages to load all packages supplied as parameters
pmodules.pas, proc_program:
  * use load_packages to load all packages before any unit is loaded
........
Add code which tries to load a unit from a package first and only then as usual.

fppu.pas, tppumodule:
  + new method loadfrompackage which searches all available packages for the unit and loads it from there if found
  * loadppu: first try to load the unit from a package if any are available
........
Don't link objects files of a unit that is provided by a package.

pmodules.pas, proc_program:
  * if a unit has uf_in_library set we must not include it in the units we link against
........

git-svn-id: trunk@33452 -
2016-04-08 15:40:27 +00:00