[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

[PATCH] Issue 1627: Create subversion DLLs on Windows

From: Vlad Georgescu <vgeorgescu_at_gmail.com>
Date: 2006-12-18 00:52:19 CET

This patch changes the build system on Windows as follows:

* For each of our main libraries (except libsvn_ra_foo and
libsvn_fs_bar) we build a static library named svn_foo-1.lib and a dll
called libsvn_foo-1.dll (with an associated libsvn_foo-1.lib import
library). The dlls are built by simply relinking the static libraries,
not by recompiling. The naming is consistent with how APR names its
libraries on Windows.

* The list of exported symbols is obtained by parsing the header files
with the extractor.py script, to which I added a few special cases
(see below).

* In Visual Studio, the static projects are still named libsvn_foo
while the dll projects are named libsvn_foo_dll.

* The programs (everything except tests) are linked against the dlls.
Tests are still linked statically because some of them access internal
library functions.

* gen_make.py supports a --disable-shared option for backward compatibility.

To get this to work correctly, and with 100% backward compatibility, I
had to jump through quite a few hoops:

* Exporting variables. Currently there is only one variable in our
public header files: svn_ctype_table. We can't export this variable
directly, because the VS linker adds a pointer indirection to each
exported variable[1]. However, it turns out that if we export the
actual global array defined in ctype.c (i.e. the variable containing
the array, not a pointer to it), the extra pointer indirection gives
us exactly what we want. It works like this:

In ctype.c:
const apr_uint32_t svn_ctype_table_internal[256] = { // table data };

In the .def file:
svn_ctype_table = svn_ctype_table_internal CONSTANT

* svn_ra_dav_init and svn_ra_serf_init. These (deprecated) functions
are declared in svn_ra.h. Depending on how you build Subversion, only
one of these will be defined, so we can't export both. To handle this,
I added some extra logic to extractor.py to determine which of neon
and serf is linked in and, based on that decision, only export the
appropriate function.

* Visual Studio refuses to build a project's outputs if a project has
no source files, as is the case with our dll projects. As a
workaround, I added an empty.c file to each such project.

Note: I only tested this patch with Visual Studio 2005. It would
probably be trivial to make it work with VC++ 6.0.

The changes to build.conf and win-tests.py are based on Russell
Yanofsky's patches attached to issue 1627.

[[[
Support building DLLs on Windows. This closes #1627.

Patch by: Vlad Georgescu <vgeorgescu@gmail.com>
          rey4

* build.conf:
  (libsvn_client, libsvn_delta, libsvn_diff, libsvn_fs,
   libsvn_ra, libsvn_repos, libsvn_subr, libsvn_wc):
  Replace the msvc_static option with a msvc_export option containing the
  list of public header files for that library.

* build/generator/extractor.py:
  Handle svn_ctype_table and svn_ra_{serf,dav}_init.
  (_filter_names): Add svn_auth_get_keychain_simple_provider,
   svn_ra_serf_init and svn_ra_dav_init.

* build/generator/gen_win.py
  (create_dll_target): New. Given a static library, it creates a new
   dynamic library target that depends on that library.
  (get_install_targets): Call create_dll_target for each target that has
   msvc_export set.
  (get_linked_win_depends): Scan the dependency tree in breadth-first
   order, allowing us to prevent cases when both a dll and its
   corresponding static library are linked into o project.

* build/generator/vcnet_vcproj.ezt:
  Add empty.c as a source file for dll projects, because Visual Studio
  refuses to build a project's outputs if it has no source files.

* build/win32/empty.c: New.

* gen-make.py:
  Handle the new --disable-shared option.

* subversion/libsvn_subr/ctype.c
  (svn_ctype_table_internal): Rename from ctype_table. Remove 'static'
   qualifier.

* win-tests.py:
  Append the paths to our libraries' dlls to the PATH environment variable.
]]]

[1] http://svn.haxx.se/dev/archive-2005-12/0284.shtml

-- 
Vlad


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Received on Mon Dec 18 00:52:41 2006

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.