Author: brane
Date: Tue Jun 10 13:02:15 2025
New Revision: 1926337

URL: http://svn.apache.org/viewvc?rev=1926337&view=rev
Log:
On the user-defined-authn branch: sync with trunk to r1926336.

Added:
    serf/branches/user-defined-authn/build/exports.py
      - copied unchanged from r1926336, serf/trunk/build/exports.py
Modified:
    serf/branches/user-defined-authn/   (props changed)
    serf/branches/user-defined-authn/SConstruct
    serf/branches/user-defined-authn/build/SerfPlatform.cmake
    serf/branches/user-defined-authn/build/gen_def.py

Propchange: serf/branches/user-defined-authn/
------------------------------------------------------------------------------
  Merged /serf/trunk:r1926256-1926336

Modified: serf/branches/user-defined-authn/SConstruct
URL: 
http://svn.apache.org/viewvc/serf/branches/user-defined-authn/SConstruct?rev=1926337&r1=1926336&r2=1926337&view=diff
==============================================================================
--- serf/branches/user-defined-authn/SConstruct (original)
+++ serf/branches/user-defined-authn/SConstruct Tue Jun 10 13:02:15 2025
@@ -40,6 +40,7 @@ except ImportError:
 src_dir = File('SConstruct').rfile().get_dir().abspath
 sys.path.insert(0, src_dir)
 import build.scons_extras
+import build.exports
 
 custom_tests = {'CheckGnuCC': build.scons_extras.CheckGnuCC}
 
@@ -175,12 +176,13 @@ if sys.platform == 'win32':
     EnumVariable('TARGET_ARCH',
                  "Platform to build for",
                  'x86',
-                 allowed_values=('x86', 'x86_64', 'ia64'),
+                 allowed_values=('x86', 'x86_64', 'arm64', 'ia64'),
                  map={'X86'  : 'x86',
                       'win32': 'x86',
                       'Win32': 'x86',
                       'x64'  : 'x86_64',
-                      'X64'  : 'x86_64'
+                      'X64'  : 'x86_64',
+                      'ARM64': 'arm64'
                      }),
 
     EnumVariable('MSVC_VERSION',
@@ -212,14 +214,31 @@ env = Environment(variables=opts,
                   CPPPATH=['.', ],
                   )
 
+# "Legacy" .def file builder
 gen_def_script = env.File('build/gen_def.py').rstr()
-
 env.Append(BUILDERS = {
     'GenDef' :
       Builder(action = '"%s" "%s" $SOURCES > $TARGET' % (sys.executable, 
gen_def_script,),
               suffix='.def', src_suffix='.h')
   })
 
+# Export symbol generator (for Windows DLL, Mach-O and ELF)
+export_generator = build.exports.ExportGenerator()
+if export_generator.target is None:
+  # Nothing to do on this platform
+  export_generator = None
+else:
+  def generate_exports(target, source, env):
+    for target_path in (str(t) for t in target):
+      stream = open(target_path, 'wt')
+      export_generator.generate(stream, *(str(s) for s in source))
+      stream.close()
+  env.Append(BUILDERS = {
+    'GenExports': Builder(action=generate_exports,
+                          suffix=export_generator.target.ext,
+                          src_suffix='.h')
+  })
+
 match = re.search('SERF_MAJOR_VERSION ([0-9]+).*'
                   'SERF_MINOR_VERSION ([0-9]+).*'
                   'SERF_PATCH_VERSION ([0-9]+)',
@@ -293,6 +312,11 @@ elif env['SHLIBPREFIX'] == '$LIBPREFIX':
 else:
   SHLIBNAME = '%sserf-%d' % (env['SHLIBPREFIX'], MAJOR)
 
+if export_generator is None:
+  export_filter = None
+else:
+  export_filter = '%s%s' % (SHLIBNAME, export_generator.target.ext)
+
 env.Append(RPATH=[libdir],
            PDB='${TARGET.filebase}.pdb')
 
@@ -358,16 +382,21 @@ else:
 # PLAN THE BUILD
 SHARED_SOURCES = []
 if sys.platform == 'win32':
-  env.GenDef(['serf.h','serf_bucket_types.h', 'serf_bucket_util.h'])
-  SHARED_SOURCES.append(['serf.def'])
+  env.GenDef(target=[export_filter], source=HEADER_FILES)
+  SHARED_SOURCES.append([export_filter])
   dll_res = env.RES(['serf.rc'])
   SHARED_SOURCES.append(dll_res)
+  # TODO: Use GenExports instead.
+  export_filter = None
 
 SOURCES = Glob('src/*.c') + Glob('buckets/*.c') + Glob('auth/*.c') + \
           Glob('protocols/*.c')
 
 lib_static = env.StaticLibrary(LIBNAME, SOURCES)
 lib_shared = env.SharedLibrary(SHLIBNAME, SOURCES + SHARED_SOURCES)
+if export_filter is not None:
+  env.GenExports(target=export_filter, source=HEADER_FILES)
+  env.Depends(lib_shared, export_filter)
 
 # Define OPENSSL_NO_STDIO to prevent using _fp() API.
 env.Append(CPPDEFINES=['OPENSSL_NO_STDIO'])
@@ -385,7 +414,7 @@ if sys.platform == 'win32':
                          '_CRT_SECURE_NO_WARNINGS',
                          '_CRT_NONSTDC_NO_WARNINGS'])
 
-  if env.get('TARGET_ARCH', None) == 'x86_64':
+  if env.get('TARGET_ARCH', None) in ('x86_64', 'arm64', 'ia64'):
     env.Append(CPPDEFINES=['WIN64'])
 
   # Get the APR-Util version number to check if we need an external Expat
@@ -599,6 +628,20 @@ if brotli and CALLOUT_OKAY:
     Exit(1)
   env = conf.Finish()
 
+if CALLOUT_OKAY:
+  conf = Configure(env, custom_tests=custom_tests)
+
+  ### some configuration stuffs
+  if conf.CheckCHeader('stdbool.h'):
+    env.Append(CPPDEFINES=['HAVE_STDBOOL_H'])
+
+  env = conf.Finish()
+
+# Tweak the link flags for selecting exported symbols. Must come after the
+# config checks, because the symbols file doesn't exist yet.
+if export_filter is not None:
+  env.Append(LINKFLAGS=[export_generator.target.link_flag % export_filter])
+
 # Set preprocessor define to disable the logging framework
 if disablelogging:
     env.Append(CPPDEFINES=['SERF_DISABLE_LOGGING'])
@@ -625,16 +668,6 @@ pkgconfig = env.Textfile('serf-%d.pc' %
 
 env.Default(lib_static, lib_shared, pkgconfig)
 
-if CALLOUT_OKAY:
-  conf = Configure(env, custom_tests=custom_tests)
-
-  ### some configuration stuffs
-  if conf.CheckCHeader('stdbool.h'):
-    env.Append(CPPDEFINES=['HAVE_STDBOOL_H'])
-
-  env = conf.Finish()
-
-
 # INSTALLATION STUFF
 
 install_static = env.Install(libdir, lib_static)

Modified: serf/branches/user-defined-authn/build/SerfPlatform.cmake
URL: 
http://svn.apache.org/viewvc/serf/branches/user-defined-authn/build/SerfPlatform.cmake?rev=1926337&r1=1926336&r2=1926337&view=diff
==============================================================================
--- serf/branches/user-defined-authn/build/SerfPlatform.cmake (original)
+++ serf/branches/user-defined-authn/build/SerfPlatform.cmake Tue Jun 10 
13:02:15 2025
@@ -43,6 +43,11 @@ elseif(${CMAKE_SYSTEM_NAME} MATCHES "Ope
   set(SERF_OPENBSD TRUE)
   set(SERF_ELF_TARGET TRUE)
   set(SERF_PLATFORM "OpenBSD")
+elseif(${CMAKE_SYSTEM_NAME} MATCHES "NetBSD")
+  set(SERF_UNIX TRUE)
+  set(SERF_NETBSD TRUE)
+  set(SERF_ELF_TARGET TRUE)
+  set(SERF_PLATFORM "NetBSD")
 elseif(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
   set(SERF_WINDOWS TRUE)
   if(CMAKE_GENERATOR_PLATFORM MATCHES "(x64|ARM64|IA64)")

Modified: serf/branches/user-defined-authn/build/gen_def.py
URL: 
http://svn.apache.org/viewvc/serf/branches/user-defined-authn/build/gen_def.py?rev=1926337&r1=1926336&r2=1926337&view=diff
==============================================================================
--- serf/branches/user-defined-authn/build/gen_def.py (original)
+++ serf/branches/user-defined-authn/build/gen_def.py Tue Jun 10 13:02:15 2025
@@ -26,56 +26,10 @@
 #    C:\PATH> python build/gen_def.py serf.h serf_bucket_types.h 
serf_bucket_util.h > build/serf.def
 #
 
-import re
 import sys
-
-# This regex parses function declarations that look like:
-#
-#    return_type serf_func1(...
-#    return_type *serf_func2(...
-#
-# Where return_type is a combination of words and "*" each separated by a
-# SINGLE space. If the function returns a pointer type (like serf_func2),
-# then a space may exist between the "*" and the function name. Thus,
-# a more complicated example might be:
-#    const type * const * serf_func3(...
-#
-_funcs = re.compile(r'^(?:(?:\w+|\*) )+\*?(serf_[a-z][a-zA-Z_0-9]*)\(',
-                    re.MULTILINE)
-
-# This regex parses the bucket type definitions which look like:
-#
-#    extern const serf_bucket_type_t serf_bucket_type_FOO;
-#
-_types = re.compile(r'^extern const serf_bucket_type_t (serf_[a-z_]*);',
-                    re.MULTILINE)
-
-
-def extract_exports(fname):
-  content = open(fname).read()
-  exports = set()
-  for name in _funcs.findall(content):
-    exports.add(name)
-  for name in _types.findall(content):
-    exports.add(name)
-  return exports
-
-
-# Blacklist the serf v2 API for now
-BLACKLIST = set(['serf_connection_switch_protocol',
-                 'serf_http_protocol_create',
-                 'serf_https_protocol_create',
-                 'serf_http_request_queue',
-                 "serf_authn_unregister_scheme",
-                 ])
-
+import exports
 
 if __name__ == '__main__':
-  # run the extraction over each file mentioned
-  import sys
-  print("EXPORTS")
-
-  for fname in sys.argv[1:]:
-    funclist = extract_exports(fname) - BLACKLIST
-    for func in funclist:
-      print(func)
+  gen = exports.ExportGenerator(exports.TARGET_WINDLL)
+  if not gen.generate(sys.stdout, *sys.argv[1:]):
+    sys.exit(1)


Reply via email to