Difference between revisions of "Releasing units without source code/es"

From Free Pascal wiki
Jump to navigationJump to search
Line 10: Line 10:
 
* Compilar la unit por separado; se recomienda el uso de la opción '''-Ur''' del compilador (''
 
* Compilar la unit por separado; se recomienda el uso de la opción '''-Ur''' del compilador (''
 
  (''Generate release unit files''; see ''User's Manual'' for details)
 
  (''Generate release unit files''; see ''User's Manual'' for details)
* Publicando ambos ficheros resultantes '''*.ppu''' y '''*.o'''. Ver además las sección 3.3 del ''Manual de usuario'' (''Compilando una unit'').
+
* Publicando ambos ficheros resultantes '''*.ppu''' y '''*.o'''. Ver además la sección 3.3 del ''Manual de usuario'' (''Compilando una unit'').
 
El '''usuario''' de la unit debería:
 
El '''usuario''' de la unit debería:
  
 
* Compile the using program (the ''client''), de tal forma que el compilador pueda encontrar ambos ficheros '''*.ppu''' y '''*.o''' de la unit (e.g. a través de la opción '''-Fu''').
 
* Compile the using program (the ''client''), de tal forma que el compilador pueda encontrar ambos ficheros '''*.ppu''' y '''*.o''' de la unit (e.g. a través de la opción '''-Fu''').
 
+
Así, hay dos contextos , there are two compiler contexts that matter:
Thus, there are two compiler contexts that matter:
 
 
* The compiler installation of the provider
 
* The compiler installation of the provider
 
* The compiler installation of the user (client)
 
* The compiler installation of the user (client)
  
 
'''Notas'''
 
'''Notas'''
* The provider and user should use the '''same compiler version'''. Although backwards compatibility between compiled units is never broken on purpose, this regularly happens in order to support new features or to fix bugs.
+
 
* The '''Target OS''' of the provided unit should match the target OS used for compiling the client program.
+
* El proveedor y el usuario deberían utilizar '''la misma versión de compilador'''. Aunque la compatibilidad hacia atrás entre units compiladas nunca se rompe a propósito, si que suele suceder cuando se necesitan nuevas características o bien se requiere la corrección de errores.
* If the provided unit depends on another unit ''U'', then the unit ''U'' of the client context needs to be ''compatible'' with the unit ''U'' in the provider context. For that purpose, the providing compiler embeds a checksum of the '''interface section''' of unit ''U'' in the '''*.ppu''' file of the provided unit.  The client compiler checks the embedded checksum against the checksum of unit ''U'' in the client context.  If the checksums differ, then the client compiler will attempt to recompile the provided unit, and this will fail because the source is missing. With the compiler option '''-vu''' you get more information on the handling of unit files, and you can spot a line stating ''Recompiling ..., checksum changed for ...''.
+
 
 +
* El '''Sistema Operativo Objetivo''' de la unit aportada debería coincidir con el Sistema Operativo utilizado para compilar el programa cliente.
 +
 
 +
* Si la unit aportada depende a su vez de otra unit ''U'', entonces la unit ''U'' en el contexto del cliente necesita ser ''compatible'' con la unit ''U'' en el contexto del proveedor. Para este propósito,
 +
 
 +
For that purpose, the providing compiler embeds a checksum of the '''interface section''' of unit ''U'' in the '''*.ppu''' file of the provided unit.  The client compiler checks the embedded checksum against the checksum of unit ''U'' in the client context.  If the checksums differ, then the client compiler will attempt to recompile the provided unit, and this will fail because the source is missing. With the compiler option '''-vu''' you get more information on the handling of unit files, and you can spot a line stating ''Recompiling ..., checksum changed for ...''.
 
* In particular, the '''System unit''' of the provider context should be ''compatible'' with the System unit of the client context, because every unit implicitly depends on the System unit.  Therefore, it is recommended to use a ''stable release'' of the compiler to compile the provided unit.
 
* In particular, the '''System unit''' of the provider context should be ''compatible'' with the System unit of the client context, because every unit implicitly depends on the System unit.  Therefore, it is recommended to use a ''stable release'' of the compiler to compile the provided unit.
 
* There may be some other compiler options to consider (besides setting the Target OS):
 
* There may be some other compiler options to consider (besides setting the Target OS):

Revision as of 23:44, 6 April 2009

En ocasiones puede resultar útil publicar alguna unit sin su código fuente:

  • El código fuente contiene información propietaria.
  • Con fines didácticos, porque de esta manera se fuerza a los estudiantes a utilizar la unit mediante su interface exclusivamente sin permitir ver como es su implementación.

FreePascal permite esto de la siguiente manera:

El proveedor de la unit (y por tanto propietario del código fuente) debería:

  • Compilar la unit por separado; se recomienda el uso de la opción -Ur del compilador (
(Generate release unit files; see User's Manual for details)
  • Publicando ambos ficheros resultantes *.ppu y *.o. Ver además la sección 3.3 del Manual de usuario (Compilando una unit).

El usuario de la unit debería:

  • Compile the using program (the client), de tal forma que el compilador pueda encontrar ambos ficheros *.ppu y *.o de la unit (e.g. a través de la opción -Fu).

Así, hay dos contextos , there are two compiler contexts that matter:

  • The compiler installation of the provider
  • The compiler installation of the user (client)

Notas

  • El proveedor y el usuario deberían utilizar la misma versión de compilador. Aunque la compatibilidad hacia atrás entre units compiladas nunca se rompe a propósito, si que suele suceder cuando se necesitan nuevas características o bien se requiere la corrección de errores.
  • El Sistema Operativo Objetivo de la unit aportada debería coincidir con el Sistema Operativo utilizado para compilar el programa cliente.
  • Si la unit aportada depende a su vez de otra unit U, entonces la unit U en el contexto del cliente necesita ser compatible con la unit U en el contexto del proveedor. Para este propósito,
For that purpose, the providing compiler embeds a checksum of the interface section of unit U in the *.ppu file of the provided unit.  The client compiler checks the embedded checksum against the checksum of unit U in the client context.  If the checksums differ, then the client compiler will attempt to recompile the provided unit, and this will fail because the source is missing. With the compiler option -vu you get more information on the handling of unit files, and you can spot a line stating Recompiling ..., checksum changed for ....
  • In particular, the System unit of the provider context should be compatible with the System unit of the client context, because every unit implicitly depends on the System unit. Therefore, it is recommended to use a stable release of the compiler to compile the provided unit.
  • There may be some other compiler options to consider (besides setting the Target OS):
    • -M (Mode)
    • -C (Checking), such as -Cr (range checking), -Ci (i/o checking), -Co (overflow checking), -Ct (stack checking)
    • -Sa (Include assert statements in compiled code)
    • -O (Optimization)
    • -gl (Generating lineinfo code)
  • For older versions of the FreePascal compiler, the name of the provided unit's source file should be in all lower case letters. For recent versions of the compiler, this is no longer an issue. (The User's Manual is not up to date on this topic, I believe. If you know more details, e.g. from which version on this changed, then please put it here.)