Author: rhuijben
Date: Sat Jul 20 15:27:33 2013
New Revision: 1505152

URL: http://svn.apache.org/r1505152
Log:
Replace specialized handling of the jdk paths in the windows project generator
with using the standard dependency framework.

* build.conf
  (libsvnjavahl): Mark dependency on the jdk.
  (java-sdk): New external library project. Currently not really a library.

* build/generator/gen_win.py
  (get_install_targets): Check for library existance.
  (get_win_includes): Remove unused common include dir and jdk includes.
  (get_win_lib_dirs): Easy out on libraries that don't link dependencies
    directly.
  (get_win_libs): Remove unused code.

* build/generator/gen_win_dependencies.py
  (get_win_lib_dirs): Add optional library.
  (find_libraries): Always locate the jdk.
  (_find_jdk): Create a library instance with build information.

  (_find_serf,
   _find_sasl,
   _find_libintl): Fix printing warnings.

Modified:
    subversion/trunk/build.conf
    subversion/trunk/build/generator/gen_win.py
    subversion/trunk/build/generator/gen_win_dependencies.py

Modified: subversion/trunk/build.conf
URL: 
http://svn.apache.org/viewvc/subversion/trunk/build.conf?rev=1505152&r1=1505151&r2=1505152&view=diff
==============================================================================
--- subversion/trunk/build.conf (original)
+++ subversion/trunk/build.conf Sat Jul 20 15:27:33 2013
@@ -649,7 +649,7 @@ description = Subversion Java HighLevel 
 type = lib
 path = subversion/bindings/javahl/native
 libs = libsvn_repos libsvn_client libsvn_wc libsvn_ra libsvn_delta libsvn_diff 
-       libsvn_subr libsvn_fs aprutil apriconv apr
+       libsvn_subr libsvn_fs aprutil apriconv apr java-sdk
 sources = *.cpp *.c
 add-deps = $(javahl_javah_DEPS) $(javahl_java_DEPS) 
$(javahl_callback_javah_DEPS) $(javahl_types_javah_DEPS) 
$(javahl_remote_javah_DEPS)
 install = javahl-lib
@@ -1262,6 +1262,10 @@ external-lib = $(SVN_PYTHON_LIBS)
 type = lib
 external-lib = $(SVN_RUBY_LIBS)
 
+[java-sdk]
+type = lib
+external-lib = $(SVN_JAVA_SDK_LIBS)
+
 [ra-libs]
 type = lib
 external-lib = $(SVN_RA_LIB_LINK)

Modified: subversion/trunk/build/generator/gen_win.py
URL: 
http://svn.apache.org/viewvc/subversion/trunk/build/generator/gen_win.py?rev=1505152&r1=1505151&r2=1505152&view=diff
==============================================================================
--- subversion/trunk/build/generator/gen_win.py (original)
+++ subversion/trunk/build/generator/gen_win.py Sat Jul 20 15:27:33 2013
@@ -227,7 +227,7 @@ class WinGeneratorBase(gen_win_dependenc
                                and self.swig_libdir))]
 
     # Drop the Java targets if we don't have a JDK
-    if not self.jdk_path:
+    if 'java_sdk' not in self._libraries:
       install_targets = [x for x in install_targets
                                      if not (isinstance(x, gen_base.TargetJava)
                                              or isinstance(x, 
gen_base.TargetJavaHeaders)
@@ -778,8 +778,6 @@ class WinGeneratorBase(gen_win_dependenc
                             "subversion/bindings/swig/include",
                             util_includes
                           ])
-    else:
-      fakeincludes.extend(["subversion/bindings/swig/proxy"])
 
     if (isinstance(target, gen_base.TargetSWIG)
         or isinstance(target, gen_base.TargetSWIGLib)):
@@ -798,10 +796,6 @@ class WinGeneratorBase(gen_win_dependenc
       fakeincludes.append(os.path.join(self.swig_libdir, lang_subdir))
       fakeincludes.append(self.swig_libdir)
 
-    if target.name == "libsvnjavahl" and self.jdk_path:
-      fakeincludes.append(os.path.join(self.jdk_path, 'include'))
-      fakeincludes.append(os.path.join(self.jdk_path, 'include', 'win32'))
-
     if target.name.find('cxxhl') != -1:
       fakeincludes.append(self.path("subversion/bindings/cxxhl/include"))
 
@@ -812,6 +806,12 @@ class WinGeneratorBase(gen_win_dependenc
 
     debug = (cfg == 'Debug')
 
+    if not isinstance(target, gen_base.TargetLinked):
+      return []
+
+    if isinstance(target, gen_base.TargetLib) and target.msvc_static:
+      return []
+
     fakelibdirs = []
 
     for dep in self.get_win_depends(target, FILTER_LIBS):
@@ -823,12 +823,14 @@ class WinGeneratorBase(gen_win_dependenc
             continue
 
           lib = self._libraries[external_lib]
-          
-          if debug:
+
+          if debug and lib.debug_lib_dir:
             lib_dir = self.apath(lib.debug_lib_dir)
-          else:
+          elif lib.lib_dir:
             lib_dir = self.apath(lib.lib_dir)
-      
+          else:
+            continue # Dependency without library (E.g. JDK)
+
           fakelibdirs.append(lib_dir)
 
     if isinstance(target, gen_base.TargetApacheMod):
@@ -844,10 +846,6 @@ class WinGeneratorBase(gen_win_dependenc
 
     debug = (cfg == 'Debug')
 
-    dblib = None
-    if self.bdb_lib:
-      dblib = self.bdb_lib+(debug and 'd.lib' or '.lib')
-
     if not isinstance(target, gen_base.TargetLinked):
       return []
 

Modified: subversion/trunk/build/generator/gen_win_dependencies.py
URL: 
http://svn.apache.org/viewvc/subversion/trunk/build/generator/gen_win_dependencies.py?rev=1505152&r1=1505151&r2=1505152&view=diff
==============================================================================
--- subversion/trunk/build/generator/gen_win_dependencies.py (original)
+++ subversion/trunk/build/generator/gen_win_dependencies.py Sat Jul 20 
15:27:33 2013
@@ -113,6 +113,7 @@ class GenDependenciesBase(gen_base.Gener
         'perl',
         'python',
         'ruby',
+        'java_sdk',
 
         # So optional, we don't even have any code to detect them on Windows
         'apr_memcache',
@@ -286,13 +287,12 @@ class GenDependenciesBase(gen_base.Gener
     self._find_perl(show_warnings)
     self._find_python(show_warnings)
     self._find_ruby(show_warnings)
+    self._find_jdk(show_warnings)
 
     if show_warnings:
       # Find the installed SWIG version to adjust swig options
       self._find_swig()
 
-      # Find the installed Java Development Kit
-      self._find_jdk()
 
   def _find_apr(self):
     "Find the APR library and version"
@@ -796,8 +796,15 @@ class GenDependenciesBase(gen_base.Gener
     self._libraries['python'] = SVNCommonLibrary('python', inc_dir, lib_dir, 
None,
                                                  sys.version.split(' ')[0])
 
-  def _find_jdk(self):
-    if not self.jdk_path:
+  def _find_jdk(self, show_warnings):
+    "Find details about an installed jdk"
+
+    jdk_path = self.jdk_path
+    self.jdk_path = None # No jdk on errors
+
+    minimal_jdk_version = (1, 0, 0) # ### Provide sane default
+
+    if not jdk_path:
       jdk_ver = None
       try:
         try:
@@ -823,15 +830,59 @@ class GenDependenciesBase(gen_base.Gener
           for i in range(num_values):
             (name, value, key_type) = winreg.EnumValue(key, i)
             if name == "JavaHome":
-              self.jdk_path = value
+              jdk_path = value
               break
         winreg.CloseKey(key)
       except (ImportError, EnvironmentError):
         pass
-      if self.jdk_path:
-        print("Found JDK version %s in %s\n" % (jdk_ver, self.jdk_path))
-    else:
-      print("Using JDK in %s\n" % (self.jdk_path))
+
+    if not jdk_path or not os.path.isdir(jdk_path):
+      return
+
+    try:
+      outfp = subprocess.Popen([os.path.join(jdk_path, 'bin', 'javah.exe'),
+                               '-version'], stdout=subprocess.PIPE).stdout
+      line = outfp.read()
+      if line:
+        print(line)
+        vermatch = re.compile(r'"(([0-9]+(\.[0-9]+)+)(_[._0-9]+)?)"', re.M) \
+                   .search(line)
+      else:
+        vermatch = None
+
+      if vermatch:
+        version = tuple(map(int, vermatch.groups()[1].split('.')))
+        versionstr = vermatch.groups()[0]
+        print(version)
+      else:
+        if show_warnings:
+          print('Could not find installed JDK,')
+        return
+      outfp.close()
+    except OSError:
+      if show_warnings:
+        print('Could not find installed JDK,')
+      return
+
+    if version < minimal_jdk_version:
+      if show_warning:
+        print('Found java jdk %s, but >= %s is required. '
+              'javahl will not be built.\n' % \
+              (versionstr, '.'.join(str(v) for v in minimal_jdk_version)))
+      return
+
+    self.jdk_path = jdk_path
+    inc_dirs = [
+        os.path.join(jdk_path, 'include'),
+        os.path.join(jdk_path, 'include', 'win32'),
+      ]
+
+    lib_dir = os.path.join(jdk_path, 'lib')
+
+    # The JDK provides .lib files, but we currently don't use these.
+    self._libraries['java_sdk'] = SVNCommonLibrary('java-skd', inc_dirs,
+                                                   lib_dir, None,
+                                                   versionstr)
 
   def _find_swig(self):
     # Require 1.3.24. If not found, assume 1.3.25.
@@ -985,8 +1036,10 @@ class GenDependenciesBase(gen_base.Gener
     serf_version = '.'.join(str(v) for v in version)
 
     if version < minimal_serf_version:
-      msg = 'Found serf %s, but >= %s is required. ra_serf will not be 
built.\n' % \
-            (serf_version, '.'.join(str(v) for v in minimal_serf_version))
+      if show_warning:
+        print('Found serf %s, but >= %s is required. '
+              'ra_serf will not be built.\n' %
+              (serf_version, '.'.join(str(v) for v in minimal_serf_version)))
       return
 
     serf_ver_maj = version[0]
@@ -1037,8 +1090,10 @@ class GenDependenciesBase(gen_base.Gener
     sasl_version = '.'.join(str(v) for v in version)
 
     if version < minimal_sasl_version:
-      msg = 'Found sasl %s, but >= %s is required. sals support will not be 
built.\n' % \
-            (sasl_version, '.'.join(str(v) for v in minimal_serf_version))
+      if show_warning:
+        print('Found sasl %s, but >= %s is required. '
+              'sals support will not be built.\n' %
+              (sasl_version, '.'.join(str(v) for v in minimal_serf_version)))
       return
 
     lib_dir = os.path.join(self.sasl_path, 'lib')
@@ -1104,8 +1159,10 @@ class GenDependenciesBase(gen_base.Gener
     libintl_version = '.'.join(str(v) for v in version)
 
     if version < minimal_libintl_version:
-      msg = 'Found libintl %s, but >= %s is required.\n' % \
-            (libintl_version, '.'.join(str(v) for v in 
minimal_libintl_version))
+      if show_warning:
+        print('Found libintl %s, but >= %s is required.\n' % \
+              (libintl_version,
+               '.'.join(str(v) for v in minimal_libintl_version)))
       return
 
     self._libraries['intl'] = SVNCommonLibrary('libintl', inc_dir, lib_dir,


Reply via email to