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

From Free Pascal wiki
Jump to navigationJump to search
Line 4: Line 4:
 
* 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.
 
* 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.
+
FreePascal permite esto de la siguiente manera:
FreePascal allows you to do so in the following way.
 
  
The '''provider''' of the unit (and owner of its source code) should:
+
El '''proveedor''' de la unit (y por tanto propietario del código fuente) debería:
* Compile the unit separately; it is recommended to use the compiler option '''-Ur''' (''Generate release unit files''; see ''User's Manual'' for details)
+
 
* Publish both the resulting '''*.ppu''' and '''*.o''' files. Also see Section 3.3 of the ''User's Manual'' (''Compiling a unit'').
+
* Compilar la unit por separado; se recomienda el uso de la opción '''-Ur''' del compilador (''
The '''user''' of the provided unit should:
+
(''Generate release unit files''; see ''User's Manual'' for details)
* Compile the using program (the ''client''), such that the compiler can find both the '''*.ppu''' and '''*.o''' files of the unit (e.g. through the compiler option '''-Fu''').
+
* Publicando ambos ficheros resultantes '''*.ppu''' y '''*.o'''. Ver además las 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''').
  
 
Thus, there are two compiler contexts that matter:
 
Thus, there are two compiler contexts that matter:
Line 17: Line 19:
 
* The compiler installation of the user (client)
 
* The compiler installation of the user (client)
  
'''Notes'''
+
'''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 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.
 
* The '''Target OS''' of the provided unit should match the target OS used for compiling the client program.

Revision as of 23:35, 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 las 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).

Thus, there are two compiler contexts that matter:

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

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.
  • 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 ....
  • 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.)