build: Allow --private-libraries to include a default
authorAndrew Bartlett <abartlet@samba.org>
Fri, 9 Feb 2024 06:47:11 +0000 (19:47 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Fri, 1 Mar 2024 02:41:36 +0000 (02:41 +0000)
This will in the future allow ldb to be declared public in the
build system, and so have all the attributes set for that, but
be actually built as a private Samba library by default.

No change in behavour currently.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
buildtools/wafsamba/samba_bundled.py
buildtools/wafsamba/wscript

index 029be159b6274a46b5f647c1f2bfd816ae521650..b9960f1cbb1dbae2dbcc37c02f93d7a1ae9023c8 100644 (file)
@@ -88,7 +88,14 @@ def LIB_MAY_BE_BUNDLED(conf, libname):
         return False
     return True
 
-def __LIB_MUST_BE(liblist, libname):
+def __LIB_MUST_BE(liblist_in, defaults, libname):
+    liblist = []
+    for lib in liblist_in:
+        if lib == "DEFAULT":
+            liblist += defaults
+        else:
+            liblist += [lib]
+
     if libname in liblist:
         return True
     if '!%s' % libname in liblist:
@@ -99,11 +106,11 @@ def __LIB_MUST_BE(liblist, libname):
 
 @conf
 def LIB_MUST_BE_BUNDLED(conf, libname):
-    return __LIB_MUST_BE(conf.env.BUNDLED_LIBS, libname)
+    return __LIB_MUST_BE(conf.env.BUNDLED_LIBS, [], libname)
 
 @conf
 def LIB_MUST_BE_PRIVATE(conf, libname):
-    return __LIB_MUST_BE(conf.env.PRIVATE_LIBS, libname)
+    return __LIB_MUST_BE(conf.env.PRIVATE_LIBS, conf.env.DEFAULT_PRIVATE_LIBS, libname)
 
 @conf
 def CHECK_BUNDLED_SYSTEM_PKG(conf, libname, minversion='0.0.0',
index 99a623737f1c974ee88efe4a9a82d73b9ea14dc4..e18bc4fd7416462cf8c4687a6382e708bf4669c3 100644 (file)
@@ -63,9 +63,12 @@ This allows that to be disabled, to ensure that other software does
 not use these libraries and they are placed in a private filesystem
 prefix.
 
+Likewise, it allows the value of DEFAULT (currently {','.join(Context.g_module.DEFAULT_PRIVATE_LIBS) if getattr(Context.g_module, 'DEFAULT_PRIVATE_LIBS', False) else "''"})
+to be overridden, allowing a private-by-default library to be exposed.
+
 May include !LIBNAME to disable making a library private in order to
-limit the effect of 'ALL' '''),
-                   action="store", dest='PRIVATE_LIBS', default='')
+limit the effect of 'ALL' and 'DEFAULT'.'''),
+                   action="store", dest='PRIVATE_LIBS', default='DEFAULT')
 
     extension_default = default_value('PRIVATE_EXTENSION_DEFAULT')
     gr.add_option('--private-library-extension',
@@ -325,6 +328,10 @@ def configure(conf):
     conf.env.PRIVATELIBDIR = Options.options.PRIVATELIBDIR
     conf.env.BUNDLED_LIBS = Options.options.BUNDLED_LIBS.split(',')
     conf.env.SYSTEM_LIBS = ()
+
+    if getattr(Context.g_module, 'DEFAULT_PRIVATE_LIBS', False):
+        conf.env.DEFAULT_PRIVATE_LIBS = Context.g_module.DEFAULT_PRIVATE_LIBS
+
     conf.env.PRIVATE_LIBS = Options.options.PRIVATE_LIBS.split(',')
     conf.env.BUILTIN_LIBRARIES = Options.options.BUILTIN_LIBRARIES.split(',')
     conf.env.NONSHARED_BINARIES = Options.options.NONSHARED_BINARIES.split(',')