ccan: we're subsystems, not a library.
authorRusty Russell <rusty@rustcorp.com.au>
Fri, 29 Jun 2012 02:39:06 +0000 (12:09 +0930)
committerRusty Russell <rusty@rustcorp.com.au>
Fri, 29 Jun 2012 04:22:44 +0000 (06:22 +0200)
Don't expose a libccan.so; it would produce clashes if someone else
does the same thing.  Unfortunately, if we just change it from a
SAMBA_LIBRARY to a SAMBA_SUBSYSTEM, it doesn't create a static library
as we'd like, but links all the object files in.  This means we get
many duplicates (eg. everyone gets a copy of tally, even though only
ntdb wants it).

So, the solution is twofold:
1) Make the ccan modules separate.
2) Make the ccan modules SAMBA_SUBSYSTEMs not SAMBA_LIBRARYs so we don't
   build shared libraries which we can't share.
3) Make the places which uses ccan explicit.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Autobuild-User(master): Rusty Russell <rusty@rustcorp.com.au>
Autobuild-Date(master): Fri Jun 29 06:22:44 CEST 2012 on sn-devel-104

lib/ccan/wscript
lib/ldb/wscript
lib/ntdb/wscript
lib/tdb_compat/wscript
source3/wscript_build

index c1dae41611d42ef693d161214275c465b9747e95..565a65757b308e48f6f0ff23cdb2a57970e4f922 100644 (file)
@@ -121,19 +121,38 @@ def configure(conf):
     # backtrace could be in libexecinfo or in libc
     conf.CHECK_FUNCS_IN('backtrace backtrace_symbols', 'execinfo', checklibc=True, headers='execinfo.h')
 
+def ccan_module(bld, name, deps=''):
+    bld.SAMBA_SUBSYSTEM('ccan-%s' % name,
+                        source=bld.path.ant_glob('%s/*.c' % name),
+                        deps=deps)
+
 def build(bld):
+    # These have actual C files.
+    ccan_module(bld, 'hash', 'ccan-build_assert')
+    ccan_module(bld, 'ilog', 'ccan-compiler');
+    ccan_module(bld, 'read_write_all')
+    ccan_module(bld, 'str', 'ccan-build_assert')
+    ccan_module(bld, 'tally', 'ccan-build_assert ccan-likely')
 
-    for ccan_dir in ["err", "hash", "htable", "ilog", "likely", "list", "read_write_all", "str", "tally", "time"]:
-        bld.SAMBA_SUBSYSTEM('ccan-%s' % ccan_dir,
-                            source=bld.path.ant_glob('%s/*.c' % ccan_dir))
+    # These are headers only.
+    ccan_module(bld, 'array_size', 'ccan-build_assert')
+    ccan_module(bld, 'asearch','ccan-typesafe_cb ccan-array_size')
+    ccan_module(bld, 'build_assert')
+    ccan_module(bld, 'cast', 'ccan-build_assert')
+    ccan_module(bld, 'check_type', 'ccan-build_assert')
+    ccan_module(bld, 'compiler')
+    ccan_module(bld, 'endian')
+    ccan_module(bld, 'likely', 'ccan-str')
+    ccan_module(bld, 'typesafe_cb')
 
+    # Failtest pulls in a lot of stuff, and it's only for unit tests.
     if bld.env.DEVELOPER_MODE:
-        bld.SAMBA_LIBRARY('ccan-failtest',
-                          source=bld.path.ant_glob('failtest/*.c'),
-                          deps='execinfo ccan ccan-htable ccan-list ccan-read_write_all ccan-time',
-                          private_library=True)
-
-    bld.SAMBA_LIBRARY('ccan',
-                      source='',
-                      deps='ccan-err ccan-hash ccan-ilog ccan-likely ccan-tally',
-                      private_library=True)
+        ccan_module(bld, 'container_of', 'ccan-check_type')
+        ccan_module(bld, 'err', 'ccan-compiler')
+        ccan_module(bld, 'htable', 'ccan-compiler')
+        ccan_module(bld, 'list', 'ccan-container_of')
+        ccan_module(bld, 'time')
+        ccan_module(bld, 'tcon')
+        ccan_module(bld, 'tlist', 'ccan-list ccan-tcon')
+        ccan_module(bld, 'failtest',
+                    "ccan-err ccan-hash ccan-htable ccan-list ccan-read_write_all ccan-str ccan-time")
index 94a9682df900f23d5a4db4164f6f5f8139bcd188..6cdddb30e9923424883a8b3bba00ec99bb2ae1f0 100755 (executable)
@@ -16,7 +16,7 @@ sys.path.insert(0, srcdir + '/buildtools/wafsamba')
 import wafsamba, samba_dist, Options
 
 samba_dist.DIST_DIRS('''lib/ldb:. lib/replace:lib/replace lib/talloc:lib/talloc
-                        lib/tdb:lib/tdb lib/tdb2:lib/tdb2 lib/tdb:lib/tdb lib/ccan:lib/ccan lib/tevent:lib/tevent lib/popt:lib/popt
+                        lib/tdb:lib/tdb lib/tdb:lib/tdb lib/tevent:lib/tevent lib/popt:lib/popt
                         buildtools:buildtools''')
 
 
@@ -39,9 +39,6 @@ def configure(conf):
     conf.check_python_version((2,4,2))
     conf.SAMBA_CHECK_PYTHON_HEADERS(mandatory=True)
 
-    # This make #include <ccan/...> work.
-    conf.ADD_EXTRA_INCLUDES('''#lib''')
-
     # where does the default LIBDIR end up? in conf.env somewhere?
     #
     conf.CONFIG_PATH('LDB_MODULESDIR', conf.SUBST_ENV_VAR('MODULESDIR') + '/ldb')
index abf6db3ed00968698dbc36629f532bcced3cd866..39802dbf3a3e7f72ce1e9e03d07b6976d8848d43 100644 (file)
@@ -139,9 +139,10 @@ def build(bld):
                  summary.c ntdb.c transaction.c traverse.c'''
 
     if not bld.CONFIG_SET('USING_SYSTEM_NTDB'):
+        NTDB_CCAN='ccan-likely ccan-ilog ccan-hash ccan-tally'
         bld.SAMBA_LIBRARY('ntdb',
                           SRC,
-                          deps='replace ccan',
+                          deps='replace ' + NTDB_CCAN ,
                           includes='.',
                           abi_directory='ABI',
                           abi_match='ntdb_*',
@@ -179,7 +180,7 @@ def build(bld):
             # Workaround is to build a private, non-hiding version.
             bld.SAMBA_SUBSYSTEM('ntdb-testing',
                                 SRC,
-                                deps='replace ccan',
+                                deps='replace ' + NTDB_CCAN,
                                 includes='.')
 
             bld.SAMBA_SUBSYSTEM('ntdb-test-helpers',
@@ -190,18 +191,18 @@ def build(bld):
                                 deps='replace')
             bld.SAMBA_SUBSYSTEM('ntdb-api-helpers',
                                 bld.env.NTDB_TEST_API_HELPER_SRC,
-                                deps='replace ntdb-testing')
+                                deps='replace')
 
             for f in bld.env.NTDB_TEST_RUN_SRC:
                 base = os.path.splitext(os.path.basename(f))[0]
                 bld.SAMBA_BINARY('ntdb-' + base, f,
-                                 deps='ccan replace ntdb-test-helpers ntdb-run-helpers ccan-failtest',
+                                 deps=NTDB_CCAN + ' ccan-failtest ntdb-test-helpers ntdb-run-helpers',
                                  install=False)
 
             for f in bld.env.NTDB_TEST_API_SRC:
                 base = os.path.splitext(os.path.basename(f))[0]
                 bld.SAMBA_BINARY('ntdb-' + base, f,
-                                 deps='ccan replace ntdb-test-helpers ntdb-api-helpers',
+                                 deps='ntdb-test-helpers ntdb-api-helpers ntdb-testing',
                                  install=False)
 
         if not bld.CONFIG_SET('USING_SYSTEM_PYNTDB'):
index 5f33f6d70b7727a82784d64d211db915cfbc4e2c..2eac1e92233bb872964b8cc6c96f379f85e6d8f6 100644 (file)
@@ -7,12 +7,10 @@ def set_options(opt):
 
 def configure(conf):
     conf.RECURSE('lib/tdb')
-    conf.RECURSE('lib/ccan')
 
 def build(bld):
-    bld.RECURSE('lib/ccan')
     bld.RECURSE('lib/tdb')
     bld.SAMBA_LIBRARY('tdb_compat',
                       source='tdb_compat.c',
-                     deps='replace tdb ccan',
+                     deps='replace tdb',
                       private_library=True)
index edb2f914b3cfb366e6989bf515f56b8400540e0b..c407aa59c1cf4e6dd6e2c0f139a52052d188c4a2 100755 (executable)
@@ -647,7 +647,7 @@ bld.SAMBA3_LIBRARY('netapi',
 bld.SAMBA3_LIBRARY('smbsharemodes',
                     source=LIBSMBSHAREMODES_SRC,
                     public_deps='''talloc tdb_compat''',
-                    deps='''ccan''',
+                    deps='''ccan-hash''',
                     public_headers='include/smb_share_modes.h',
                     pc_files='libsmb/smbsharemodes.pc',
                     vnum='0',
@@ -780,7 +780,7 @@ bld.SAMBA3_SUBSYSTEM('KRBCLIENT',
 
 bld.SAMBA3_SUBSYSTEM('samba3util',
                    source=LIB_UTIL_SRC,
-                   deps='ndr security NDR_SECURITY samba-util util_tdb ccan',
+                   deps='ndr security NDR_SECURITY samba-util util_tdb ccan-hash',
                    vars=locals())
 
 bld.SAMBA3_SUBSYSTEM('pidfile',
@@ -803,7 +803,6 @@ bld.SAMBA3_SUBSYSTEM('samba3core',
                         param
                         dbwrap
                         samba3-util
-                        ccan
                         errors3''',
                    vars=locals())