libreoffice/compilerplugins
Stephan Bergmann 0124111394 Replace unowinreg.dll with execution of reg QUERY
The SDK's <https://wiki.openoffice.org/wiki/Documentation/DevGuide/ProUNO/Java/
Transparent_Use_of_Office_UNO_Components> on all platforms included the Windows-
specific unowinreg.dll in generated jars (so that those jars, when distributed
to a Windows environment, would find a LO installation by inspecting the Windows
registry).  That unowinreg.dll was originally built as a 32-bit DLL (though when
building a 64-bit Windows LO, it happened to be built as a 64-bit DLL).  For
non-Windows LO builds, it could either be built locally with a MinGW toolchain
(--enable-build-unowinreg) or downloaded from dev-www.libreoffice.org.

However, that had various issues:

For one, unowinreg.dll was not necessarily available in a distributed jar as a
64-bit DLL for use with a 64-bit JRE on Windows.  (Theoretically, running such a
jar with a 32-bit JRE to access a 64-bit LO installation's URE jars could have
worked.  But practically, those URE jars in turn require native DLLs, which
would then not have been available as 32-bit DLLs for use in the 32-bit JRE.)

For another, at least the unowinreg.dll resulting from --enable-build-unowinreg
on Fedora 33 would have had a dependency on libgcc_s_dw2-1.dll that would
generally not have been available in a target Windows environment.

There appears to be no pure Java way to read the Windows registry, but instead
of using a native code DLL for that, it appears to work just as well to call out
to reg.exe and parse its output.

This removes the --enable-build-unowinreg and --with-mingw-cross-compiler
configuration options.  (The sole use of the MinGW toolchain in LO was for
building unowinreg.dll.)

Change-Id: I3283ea38c884d3221a205e5ab6ec99a2691ef474
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107140
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Tested-by: Jenkins
2020-12-03 15:01:00 +01:00
..
2020-01-02 07:05:24 +01:00

Compiler plugins.


== Overview ==

This directory contains code for compiler plugins. These are used to perform
additional actions during compilation (such as additional warnings) and
also to perform mass code refactoring.

Currently only the Clang compiler is supported (http://wiki.documentfoundation.org/Development/Clang).


== Usage ==

Compiler plugins are enabled automatically by --enable-dbgutil if Clang headers
are found or explicitly using --enable-compiler-plugins.


== Functionality ==

There are two kinds of plugin actions:
- compile checks - these are run during normal compilation
- rewriters - these must be run manually and modify source files

Each source has a comment saying whether it's compile check or a rewriter
and description of functionality.

=== Compile checks ===

Used during normal compilation to perform additional checks.
All warnings and errors are marked '[loplugin]' in the message.


=== Rewriters ===

Rewriters analyse and possibly modify given source files.
Usage: make COMPILER_PLUGIN_TOOL=<rewriter_name>
Additional optional make arguments:
- it is possible to also pass FORCE_COMPILE_ALL=1 to make to trigger rebuild of all source files,
    even those that are up to date.
- UPDATE_FILES=<scope> - limits which modified files will be actually written back with the changes
    - mainfile - only the main .cxx file will be modified (default)
    - all - all source files involved will be modified (possibly even header files from other LO modules),
        3rd party header files are however never modified
    - <module> - only files in the given LO module (toplevel directory) will be modified (including headers)

Modifications will be written directly to the source files.

Some rewriter plugins are dual-mode and can also be used in a non-rewriting mode
in which they emit warnings for problematic code that they would otherwise
automatically rewrite.  When any rewriter is enabled explicitly via "make
COMPILER_PLUGIN_TOOL=<rewriter_name>" it works in rewriting mode (and all other
plugins are disabled), but when no rewriter is explicitly enabled (i.e., just
"make"), all dual-mode rewriters are enabled in non-rewriting mode (along with
all non-rewriter plugins; and all non--dual-mode plugins are disabled).  The
typical process to use such a dual-mode rewriter X in rewriting mode is

  make COMPILER_PLUGIN_WARNINGS_ONLY=X \
  && make COMPILER_PLUGIN_TOOL=X FORCE_COMPILE_ALL=1 UPDATE_FILES=all

which first generates a full build without failing due to warnings from plugin
X in non-rewriting mode (in case of --enable-werror) and then repeats the build
in rewriting mode (during which no object files are generate).


== Code documentation / howtos ==

http://wiki.documentfoundation.org/Clang_plugins