Changeset 988 for vendor/current/buildtools
- Timestamp:
- Nov 24, 2016, 1:14:11 PM (9 years ago)
- Location:
- vendor/current/buildtools
- Files:
-
- 14 added
- 5 deleted
- 31 edited
Legend:
- Unmodified
- Added
- Removed
-
vendor/current/buildtools/bin/waf
r860 r988 1 waf-svn 1 #!/usr/bin/env python 2 # encoding: ISO-8859-1 3 # Thomas Nagy, 2005-2010 4 5 """ 6 Redistribution and use in source and binary forms, with or without 7 modification, are permitted provided that the following conditions 8 are met: 9 10 1. Redistributions of source code must retain the above copyright 11 notice, this list of conditions and the following disclaimer. 12 13 2. Redistributions in binary form must reproduce the above copyright 14 notice, this list of conditions and the following disclaimer in the 15 documentation and/or other materials provided with the distribution. 16 17 3. The name of the author may not be used to endorse or promote products 18 derived from this software without specific prior written permission. 19 20 THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR 21 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 22 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 24 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 25 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 28 STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 29 IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 POSSIBILITY OF SUCH DAMAGE. 31 """ 32 33 import os, sys 34 if sys.hexversion<0x203000f: raise ImportError("Waf requires Python >= 2.3") 35 36 if 'PSYCOWAF' in os.environ: 37 try:import psyco;psyco.full() 38 except:pass 39 40 VERSION="1.5.19" 41 REVISION="x" 42 INSTALL="x" 43 C1='x' 44 C2='x' 45 cwd = os.getcwd() 46 join = os.path.join 47 48 WAF='waf' 49 def b(x): 50 return x 51 52 if sys.hexversion>0x300000f: 53 WAF='waf3' 54 def b(x): 55 return x.encode() 56 57 def err(m): 58 print(('\033[91mError: %s\033[0m' % m)) 59 sys.exit(1) 60 61 def test(dir): 62 try: os.stat(join(dir, 'wafadmin')); return os.path.abspath(dir) 63 except OSError: pass 64 65 def find_lib(): 66 return os.path.abspath(os.path.join(os.path.dirname(__file__), '../../third_party/waf')) 67 68 wafdir = find_lib() 69 w = join(wafdir, 'wafadmin') 70 t = join(w, 'Tools') 71 f = join(w, '3rdparty') 72 sys.path = [w, t, f] + sys.path 73 74 if __name__ == '__main__': 75 import Scripting 76 Scripting.prepare(t, cwd, VERSION, wafdir) 77 -
vendor/current/buildtools/scripts/Makefile.waf
r740 r988 63 63 64 64 bin/%:: FORCE 65 $(WAF) --targets= `basename $@`65 $(WAF) --targets=$@ 66 66 FORCE: 67 67 -
vendor/current/buildtools/scripts/abi_gen.sh
r740 r988 11 11 set width 0 12 12 EOF 13 nm "$SHAREDLIB" | cut -d' ' -f2- | egrep '^[BDGTRVWS]' | grep -v @ | cut -c3- | sort | while read s; do13 nm "$SHAREDLIB" | cut -d' ' -f2- | egrep '^[BDGTRVWS]' | grep -v @ | egrep -v ' (__bss_start|_edata|_init|_fini|_end)' | cut -c3- | sort | while read s; do 14 14 echo "echo $s: " 15 15 echo p $s -
vendor/current/buildtools/testwaf.sh
r740 r988 12 12 tests="$*" 13 13 else 14 tests="lib/replace lib/talloc lib/tevent lib/tdb source4/lib/ldb"14 tests="lib/replace lib/talloc lib/tevent lib/tdb lib/ldb" 15 15 fi 16 16 … … 28 28 make distcheck 29 29 case $d in 30 " source4/lib/ldb")30 "lib/ldb") 31 31 ldd bin/ldbadd 32 32 ;; -
vendor/current/buildtools/wafsamba/generic_cc.py
r740 r988 15 15 @conftest 16 16 def find_generic_cc(conf): 17 18 19 20 21 22 23 24 25 17 v = conf.env 18 cc = None 19 if v['CC']: cc = v['CC'] 20 elif 'CC' in conf.environ: cc = conf.environ['CC'] 21 if not cc: cc = conf.find_program('cc', var='CC') 22 if not cc: conf.fatal('generic_cc was not found') 23 cc = conf.cmd_to_list(cc) 24 v['CC'] = cc 25 v['CC_NAME'] = 'generic' 26 26 27 27 @conftest 28 28 def generic_cc_common_flags(conf): 29 29 v = conf.env 30 30 31 32 33 31 v['CC_SRC_F'] = '' 32 v['CC_TGT_F'] = ['-c', '-o', ''] 33 v['CPPPATH_ST'] = '-I%s' # template for adding include paths 34 34 35 36 37 38 35 # linker 36 if not v['LINK_CC']: v['LINK_CC'] = v['CC'] 37 v['CCLNK_SRC_F'] = '' 38 v['CCLNK_TGT_F'] = ['-o', ''] 39 39 40 41 42 43 44 40 v['LIB_ST'] = '-l%s' # template for adding libs 41 v['LIBPATH_ST'] = '-L%s' # template for adding libpaths 42 v['STATICLIB_ST'] = '-l%s' 43 v['STATICLIBPATH_ST'] = '-L%s' 44 v['CCDEFINES_ST'] = '-D%s' 45 45 46 # 47 # 48 # 46 # v['SONAME_ST'] = '-Wl,-h -Wl,%s' 47 # v['SHLIB_MARKER'] = '-Bdynamic' 48 # v['STATICLIB_MARKER'] = '-Bstatic' 49 49 50 51 50 # program 51 v['program_PATTERN'] = '%s' 52 52 53 54 # 55 # 56 53 # shared library 54 # v['shlib_CCFLAGS'] = ['-Kpic', '-DPIC'] 55 # v['shlib_LINKFLAGS'] = ['-G'] 56 v['shlib_PATTERN'] = 'lib%s.so' 57 57 58 59 # 60 # 58 # static lib 59 # v['staticlib_LINKFLAGS'] = ['-Bstatic'] 60 # v['staticlib_PATTERN'] = 'lib%s.a' 61 61 62 62 detect = ''' -
vendor/current/buildtools/wafsamba/irixcc.py
r740 r988 14 14 @conftest 15 15 def find_irixcc(conf): 16 17 18 19 20 21 22 16 v = conf.env 17 cc = None 18 if v['CC']: cc = v['CC'] 19 elif 'CC' in conf.environ: cc = conf.environ['CC'] 20 if not cc: cc = conf.find_program('cc', var='CC') 21 if not cc: conf.fatal('irixcc was not found') 22 cc = conf.cmd_to_list(cc) 23 23 24 25 if Utils.cmd_output(cc+ ['-version']) != '':26 27 28 24 try: 25 if Utils.cmd_output(cc + ['-c99'] + ['-version']) != '': 26 conf.fatal('irixcc %r was not found' % cc) 27 except ValueError: 28 conf.fatal('irixcc -v could not be executed') 29 29 30 v['CC'] = cc 31 v['CC_NAME'] = 'irix' 30 conf.env.append_unique('CCFLAGS', '-c99') 31 32 v['CC'] = cc 33 v['CC_NAME'] = 'irix' 32 34 33 35 @conftest 34 36 def irixcc_common_flags(conf): 35 37 v = conf.env 36 38 37 38 39 39 v['CC_SRC_F'] = '' 40 v['CC_TGT_F'] = ['-c', '-o', ''] 41 v['CPPPATH_ST'] = '-I%s' # template for adding include paths 40 42 41 42 43 44 43 # linker 44 if not v['LINK_CC']: v['LINK_CC'] = v['CC'] 45 v['CCLNK_SRC_F'] = '' 46 v['CCLNK_TGT_F'] = ['-o', ''] 45 47 46 47 48 49 50 48 v['LIB_ST'] = '-l%s' # template for adding libs 49 v['LIBPATH_ST'] = '-L%s' # template for adding libpaths 50 v['STATICLIB_ST'] = '-l%s' 51 v['STATICLIBPATH_ST'] = '-L%s' 52 v['CCDEFINES_ST'] = '-D%s' 51 53 52 # 53 # 54 # 54 # v['SONAME_ST'] = '-Wl,-h -Wl,%s' 55 # v['SHLIB_MARKER'] = '-Bdynamic' 56 # v['STATICLIB_MARKER'] = '-Bstatic' 55 57 56 57 58 # program 59 v['program_PATTERN'] = '%s' 58 60 59 60 # 61 # 62 61 # shared library 62 # v['shlib_CCFLAGS'] = ['-Kpic', '-DPIC'] 63 # v['shlib_LINKFLAGS'] = ['-G'] 64 v['shlib_PATTERN'] = 'lib%s.so' 63 65 64 65 # 66 # 66 # static lib 67 # v['staticlib_LINKFLAGS'] = ['-Bstatic'] 68 # v['staticlib_PATTERN'] = 'lib%s.a' 67 69 68 70 detect = ''' -
vendor/current/buildtools/wafsamba/nothreads.py
r740 r988 1 #!/usr/bin/env python2 1 # encoding: utf-8 3 2 # Thomas Nagy, 2005-2008 (ita) … … 12 11 "Execute the tasks" 13 12 14 import sys, random, t ime, threading, traceback, os13 import sys, random, threading 15 14 try: from Queue import Queue 16 15 except ImportError: from queue import Queue 17 import Build, Utils, Logs, Options 18 from Logs import debug, error 19 from Constants import * 16 import Utils, Options 17 from Constants import EXCEPTION, CRASHED, MAXJOBS, ASK_LATER, SKIPPED, SKIP_ME, SUCCESS 20 18 21 19 GAP = 15 … … 23 21 run_old = threading.Thread.run 24 22 def run(*args, **kwargs): 25 26 27 28 29 30 23 try: 24 run_old(*args, **kwargs) 25 except (KeyboardInterrupt, SystemExit): 26 raise 27 except: 28 sys.excepthook(*sys.exc_info()) 31 29 threading.Thread.run = run 32 30 33 31 34 32 class TaskConsumer(object): 35 33 consumers = 1 36 34 37 35 def process(tsk): 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 36 m = tsk.master 37 if m.stop: 38 m.out.put(tsk) 39 return 40 41 try: 42 tsk.generator.bld.printout(tsk.display()) 43 if tsk.__class__.stat: ret = tsk.__class__.stat(tsk) 44 # actual call to task's run() function 45 else: ret = tsk.call_run() 46 except Exception, e: 47 tsk.err_msg = Utils.ex_stack() 48 tsk.hasrun = EXCEPTION 49 50 # TODO cleanup 51 m.error_handler(tsk) 52 m.out.put(tsk) 53 return 54 55 if ret: 56 tsk.err_code = ret 57 tsk.hasrun = CRASHED 58 else: 59 try: 60 tsk.post_run() 61 except Utils.WafError: 62 pass 63 except Exception: 64 tsk.err_msg = Utils.ex_stack() 65 tsk.hasrun = EXCEPTION 66 else: 67 tsk.hasrun = SUCCESS 68 if tsk.hasrun != SUCCESS: 69 m.error_handler(tsk) 70 71 m.out.put(tsk) 74 72 75 73 class Parallel(object): 76 """ 77 keep the consumer threads busy, and avoid consuming cpu cycles 78 when no more tasks can be added (end of the build, etc) 79 """ 80 def __init__(self, bld, j=2): 81 82 # number of consumers 83 self.numjobs = j 84 85 self.manager = bld.task_manager 86 self.manager.current_group = 0 87 88 self.total = self.manager.total() 89 90 # tasks waiting to be processed - IMPORTANT 91 self.outstanding = [] 92 self.maxjobs = MAXJOBS 93 94 # tasks that are awaiting for another task to complete 95 self.frozen = [] 96 97 # tasks returned by the consumers 98 self.out = Queue(0) 99 100 self.count = 0 # tasks not in the producer area 101 102 self.processed = 1 # progress indicator 103 104 self.stop = False # error condition to stop the build 105 self.error = False # error flag 106 107 def get_next(self): 108 "override this method to schedule the tasks in a particular order" 109 if not self.outstanding: 110 return None 111 return self.outstanding.pop(0) 112 113 def postpone(self, tsk): 114 "override this method to schedule the tasks in a particular order" 115 # TODO consider using a deque instead 116 if random.randint(0, 1): 117 self.frozen.insert(0, tsk) 118 else: 119 self.frozen.append(tsk) 120 121 def refill_task_list(self): 122 "called to set the next group of tasks" 123 124 while self.count > self.numjobs + GAP or self.count >= self.maxjobs: 125 self.get_out() 126 127 while not self.outstanding: 128 if self.count: 129 self.get_out() 130 131 if self.frozen: 132 self.outstanding += self.frozen 133 self.frozen = [] 134 elif not self.count: 135 (jobs, tmp) = self.manager.get_next_set() 136 if jobs != None: self.maxjobs = jobs 137 if tmp: self.outstanding += tmp 138 break 139 140 def get_out(self): 141 "the tasks that are put to execute are all collected using get_out" 142 ret = self.out.get() 143 self.manager.add_finished(ret) 144 if not self.stop and getattr(ret, 'more_tasks', None): 145 self.outstanding += ret.more_tasks 146 self.total += len(ret.more_tasks) 147 self.count -= 1 148 149 def error_handler(self, tsk): 150 "by default, errors make the build stop (not thread safe so be careful)" 151 if not Options.options.keep: 152 self.stop = True 153 self.error = True 154 155 def start(self): 156 "execute the tasks" 157 158 while not self.stop: 159 160 self.refill_task_list() 161 162 # consider the next task 163 tsk = self.get_next() 164 if not tsk: 165 if self.count: 166 # tasks may add new ones after they are run 167 continue 168 else: 169 # no tasks to run, no tasks running, time to exit 170 break 171 172 if tsk.hasrun: 173 # if the task is marked as "run", just skip it 174 self.processed += 1 175 self.manager.add_finished(tsk) 176 continue 177 178 try: 179 st = tsk.runnable_status() 180 except Exception, e: 181 self.processed += 1 182 if self.stop and not Options.options.keep: 183 tsk.hasrun = SKIPPED 184 self.manager.add_finished(tsk) 185 continue 186 self.error_handler(tsk) 187 self.manager.add_finished(tsk) 188 tsk.hasrun = EXCEPTION 189 tsk.err_msg = Utils.ex_stack() 190 continue 191 192 if st == ASK_LATER: 193 self.postpone(tsk) 194 elif st == SKIP_ME: 195 self.processed += 1 196 tsk.hasrun = SKIPPED 197 self.manager.add_finished(tsk) 198 else: 199 # run me: put the task in ready queue 200 tsk.position = (self.processed, self.total) 201 self.count += 1 202 self.processed += 1 203 tsk.master = self 204 205 process(tsk) 206 207 # self.count represents the tasks that have been made available to the consumer threads 208 # collect all the tasks after an error else the message may be incomplete 209 while self.error and self.count: 210 self.get_out() 211 212 #print loop 213 assert (self.count == 0 or self.stop) 74 """ 75 keep the consumer threads busy, and avoid consuming cpu cycles 76 when no more tasks can be added (end of the build, etc) 77 """ 78 def __init__(self, bld, j=2): 79 80 # number of consumers 81 self.numjobs = j 82 83 self.manager = bld.task_manager 84 self.manager.current_group = 0 85 86 self.total = self.manager.total() 87 88 # tasks waiting to be processed - IMPORTANT 89 self.outstanding = [] 90 self.maxjobs = MAXJOBS 91 92 # tasks that are awaiting for another task to complete 93 self.frozen = [] 94 95 # tasks returned by the consumers 96 self.out = Queue(0) 97 98 self.count = 0 # tasks not in the producer area 99 100 self.processed = 1 # progress indicator 101 102 self.stop = False # error condition to stop the build 103 self.error = False # error flag 104 105 def get_next(self): 106 "override this method to schedule the tasks in a particular order" 107 if not self.outstanding: 108 return None 109 return self.outstanding.pop(0) 110 111 def postpone(self, tsk): 112 "override this method to schedule the tasks in a particular order" 113 # TODO consider using a deque instead 114 if random.randint(0, 1): 115 self.frozen.insert(0, tsk) 116 else: 117 self.frozen.append(tsk) 118 119 def refill_task_list(self): 120 "called to set the next group of tasks" 121 122 while self.count > self.numjobs + GAP or self.count >= self.maxjobs: 123 self.get_out() 124 125 while not self.outstanding: 126 if self.count: 127 self.get_out() 128 129 if self.frozen: 130 self.outstanding += self.frozen 131 self.frozen = [] 132 elif not self.count: 133 (jobs, tmp) = self.manager.get_next_set() 134 if jobs is not None: 135 self.maxjobs = jobs 136 if tmp: 137 self.outstanding += tmp 138 break 139 140 def get_out(self): 141 "the tasks that are put to execute are all collected using get_out" 142 ret = self.out.get() 143 self.manager.add_finished(ret) 144 if not self.stop and getattr(ret, 'more_tasks', None): 145 self.outstanding += ret.more_tasks 146 self.total += len(ret.more_tasks) 147 self.count -= 1 148 149 def error_handler(self, tsk): 150 "by default, errors make the build stop (not thread safe so be careful)" 151 if not Options.options.keep: 152 self.stop = True 153 self.error = True 154 155 def start(self): 156 "execute the tasks" 157 158 while not self.stop: 159 160 self.refill_task_list() 161 162 # consider the next task 163 tsk = self.get_next() 164 if not tsk: 165 if self.count: 166 # tasks may add new ones after they are run 167 continue 168 else: 169 # no tasks to run, no tasks running, time to exit 170 break 171 172 if tsk.hasrun: 173 # if the task is marked as "run", just skip it 174 self.processed += 1 175 self.manager.add_finished(tsk) 176 continue 177 178 try: 179 st = tsk.runnable_status() 180 except Exception, e: 181 self.processed += 1 182 if self.stop and not Options.options.keep: 183 tsk.hasrun = SKIPPED 184 self.manager.add_finished(tsk) 185 continue 186 self.error_handler(tsk) 187 self.manager.add_finished(tsk) 188 tsk.hasrun = EXCEPTION 189 tsk.err_msg = Utils.ex_stack() 190 continue 191 192 if st == ASK_LATER: 193 self.postpone(tsk) 194 elif st == SKIP_ME: 195 self.processed += 1 196 tsk.hasrun = SKIPPED 197 self.manager.add_finished(tsk) 198 else: 199 # run me: put the task in ready queue 200 tsk.position = (self.processed, self.total) 201 self.count += 1 202 self.processed += 1 203 tsk.master = self 204 205 process(tsk) 206 207 # self.count represents the tasks that have been made available to the consumer threads 208 # collect all the tasks after an error else the message may be incomplete 209 while self.error and self.count: 210 self.get_out() 211 212 #print loop 213 assert (self.count == 0 or self.stop) 214 214 215 215 -
vendor/current/buildtools/wafsamba/pkgconfig.py
r740 r988 1 1 # handle substitution of variables in pc files 2 2 3 import Build, sys, Logs 4 from samba_utils import * 3 import os, re, sys 4 import Build, Logs 5 from samba_utils import SUBST_VARS_RECURSIVE, TO_LIST 5 6 6 7 def subst_at_vars(task): 7 8 '''substiture @VAR@ style variables in a file''' 8 src = task.inputs[0].srcpath(task.env)9 tgt = task.outputs[0].bldpath(task.env)10 9 11 f = open(src, 'r') 12 s = f.read() 13 f.close() 10 s = task.inputs[0].read() 14 11 # split on the vars 15 12 a = re.split('(@\w+@)', s) … … 38 35 out.append(v) 39 36 contents = ''.join(out) 40 f = open(tgt, 'w') 41 s = f.write(contents) 42 f.close() 37 task.outputs[0].write(contents) 43 38 return 0 44 39 … … 54 49 source=f+'.in', 55 50 target=f) 51 bld.add_manual_dependency(bld.path.find_or_declare(f), bld.env['PREFIX']) 56 52 t.vars = [] 57 53 if t.env.RPATH_ON_INSTALL: -
vendor/current/buildtools/wafsamba/samba3.py
r740 r988 5 5 from optparse import SUPPRESS_HELP 6 6 from samba_utils import os_path_relpath, TO_LIST 7 from samba_autoconf import library_flags 8 7 9 8 10 def SAMBA3_ADD_OPTION(opt, option, help=(), dest=None, default=True, 9 11 with_name="with", without_name="without"): 12 if default is None: 13 default_str = "auto" 14 elif default is True: 15 default_str = "yes" 16 elif default is False: 17 default_str = "no" 18 else: 19 default_str = str(default) 20 10 21 if help == (): 11 help = ("Build with %s support " % option)22 help = ("Build with %s support (default=%s)" % (option, default_str)) 12 23 if dest is None: 13 24 dest = "with_%s" % option.replace('-', '_') … … 47 58 def s3_fix_kwargs(bld, kwargs): 48 59 '''fix the build arguments for s3 build rules to include the 49 60 necessary includes, subdir and cflags options ''' 50 61 s3dir = os.path.join(bld.env.srcdir, 'source3') 51 62 s3reldir = os_path_relpath(s3dir, bld.curdir) … … 53 64 # the extra_includes list is relative to the source3 directory 54 65 extra_includes = [ '.', 'include', 'lib' ] 55 if bld.env.use_intree_heimdal: 66 # local heimdal paths only included when USING_SYSTEM_KRB5 is not set 67 if not bld.CONFIG_SET("USING_SYSTEM_KRB5"): 56 68 extra_includes += [ '../source4/heimdal/lib/com_err', 69 '../source4/heimdal/lib/krb5', 57 70 '../source4/heimdal/lib/gssapi', 58 '../source4/heimdal_build' ] 71 '../source4/heimdal_build', 72 '../bin/default/source4/heimdal/lib/asn1' ] 59 73 60 if not bld.CONFIG_SET('USING_SYSTEM_TDB'): 74 if bld.CONFIG_SET('USING_SYSTEM_TDB'): 75 (tdb_includes, tdb_ldflags, tdb_cpppath) = library_flags(bld, 'tdb') 76 extra_includes += tdb_cpppath 77 else: 61 78 extra_includes += [ '../lib/tdb/include' ] 62 79 63 if not bld.CONFIG_SET('USING_SYSTEM_TEVENT'): 80 if bld.CONFIG_SET('USING_SYSTEM_TEVENT'): 81 (tevent_includes, tevent_ldflags, tevent_cpppath) = library_flags(bld, 'tevent') 82 extra_includes += tevent_cpppath 83 else: 64 84 extra_includes += [ '../lib/tevent' ] 65 85 66 if not bld.CONFIG_SET('USING_SYSTEM_TALLOC'): 86 if bld.CONFIG_SET('USING_SYSTEM_TALLOC'): 87 (talloc_includes, talloc_ldflags, talloc_cpppath) = library_flags(bld, 'talloc') 88 extra_includes += talloc_cpppath 89 else: 67 90 extra_includes += [ '../lib/talloc' ] 68 91 69 if not bld.CONFIG_SET('USING_SYSTEM_POPT'): 92 if bld.CONFIG_SET('USING_SYSTEM_POPT'): 93 (popt_includes, popt_ldflags, popt_cpppath) = library_flags(bld, 'popt') 94 extra_includes += popt_cpppath 95 else: 70 96 extra_includes += [ '../lib/popt' ] 71 97 … … 80 106 kwargs['includes'] = includes 81 107 82 # some S3 code assumes that CONFIGFILE is set83 cflags = ['-DCONFIGFILE="%s"' % bld.env['CONFIGFILE']]84 if 'cflags' in kwargs:85 cflags += TO_LIST(kwargs['cflags'])86 kwargs['cflags'] = cflags87 88 108 # these wrappers allow for mixing of S3 and S4 build rules in the one build 89 109 90 110 def SAMBA3_LIBRARY(bld, name, *args, **kwargs): 91 s3_fix_kwargs(bld, kwargs) 92 kwargs['allow_undefined_symbols'] = True 93 return bld.SAMBA_LIBRARY(name, *args, **kwargs) 111 s3_fix_kwargs(bld, kwargs) 112 return bld.SAMBA_LIBRARY(name, *args, **kwargs) 94 113 Build.BuildContext.SAMBA3_LIBRARY = SAMBA3_LIBRARY 95 114 96 115 def SAMBA3_MODULE(bld, name, *args, **kwargs): 97 s3_fix_kwargs(bld, kwargs) 98 kwargs['allow_undefined_symbols'] = True 99 return bld.SAMBA_MODULE(name, *args, **kwargs) 116 s3_fix_kwargs(bld, kwargs) 117 return bld.SAMBA_MODULE(name, *args, **kwargs) 100 118 Build.BuildContext.SAMBA3_MODULE = SAMBA3_MODULE 101 119 102 120 def SAMBA3_SUBSYSTEM(bld, name, *args, **kwargs): 103 104 121 s3_fix_kwargs(bld, kwargs) 122 return bld.SAMBA_SUBSYSTEM(name, *args, **kwargs) 105 123 Build.BuildContext.SAMBA3_SUBSYSTEM = SAMBA3_SUBSYSTEM 106 124 107 125 def SAMBA3_BINARY(bld, name, *args, **kwargs): 108 109 126 s3_fix_kwargs(bld, kwargs) 127 return bld.SAMBA_BINARY(name, *args, **kwargs) 110 128 Build.BuildContext.SAMBA3_BINARY = SAMBA3_BINARY 129 130 def SAMBA3_PYTHON(bld, name, *args, **kwargs): 131 s3_fix_kwargs(bld, kwargs) 132 return bld.SAMBA_PYTHON(name, *args, **kwargs) 133 Build.BuildContext.SAMBA3_PYTHON = SAMBA3_PYTHON -
vendor/current/buildtools/wafsamba/samba_abi.py
r740 r988 16 16 '''normalise a signature from gdb''' 17 17 sig = sig.strip() 18 sig = re.sub('^\$[0-9]+\s=\s\{*', '', sig) 19 sig = re.sub('\}(\s0x[0-9a-f]+\s<\w+>)?$', '', sig) 18 sig = re.sub('^\$[0-9]+\s=\s\{(.+)\}$', r'\1', sig) 19 sig = re.sub('^\$[0-9]+\s=\s\{(.+)\}(\s0x[0-9a-f]+\s<\w+>)+$', r'\1', sig) 20 sig = re.sub('^\$[0-9]+\s=\s(0x[0-9a-f]+)\s?(<\w+>)?$', r'\1', sig) 20 21 sig = re.sub('0x[0-9a-f]+', '0xXXXX', sig) 22 sig = re.sub('", <incomplete sequence (\\\\[a-z0-9]+)>', r'\1"', sig) 21 23 22 24 for t in abi_type_maps: … … 31 33 return sig 32 34 35 33 36 def normalise_varargs(sig): 34 37 '''cope with older versions of gdb''' 35 38 sig = re.sub(',\s\.\.\.', '', sig) 36 39 return sig 40 37 41 38 42 def parse_sigs(sigs, abi_match): … … 47 51 if abi_match: 48 52 matched = False 53 negative = False 49 54 for p in abi_match: 50 55 if p[0] == '!' and fnmatch.fnmatch(sa[0], p[1:]): 56 negative = True 51 57 break 52 58 elif fnmatch.fnmatch(sa[0], p): 53 59 matched = True 54 60 break 55 if not matched:61 if (not matched) and negative: 56 62 continue 63 Logs.debug("%s -> %s" % (sa[1], normalise_signature(sa[1]))) 57 64 ret[sa[0]] = normalise_signature(sa[1]) 58 65 return ret … … 106 113 107 114 if got_error: 108 raise Utils.WafError('ABI for %s has changed - please fix library version then build with --abi-update\nSee http://wiki.samba.org/index.php/Waf#ABI_Checking for more information ' % libname)115 raise Utils.WafError('ABI for %s has changed - please fix library version then build with --abi-update\nSee http://wiki.samba.org/index.php/Waf#ABI_Checking for more information\nIf you have not changed any ABI, and your platform always gives this error, please configure with --abi-check-disable to skip this check' % libname) 109 116 110 117 … … 131 138 abi_gen = os.path.join(topsrc, 'buildtools/scripts/abi_gen.sh') 132 139 133 abi_file = "%s/%s-%s.sigs" % (self.abi_directory, self.name, self.vnum) 140 abi_file = "%s/%s-%s.sigs" % (self.abi_directory, self.version_libname, 141 self.vnum) 134 142 135 143 tsk = self.create_task('abi_check', self.link_task.outputs[0]) … … 141 149 def abi_process_file(fname, version, symmap): 142 150 '''process one ABI file, adding new symbols to the symmap''' 143 f = open(fname, mode='r') 144 for line in f: 151 for line in Utils.readf(fname).splitlines(): 145 152 symname = line.split(":")[0] 146 153 if not symname in symmap: 147 154 symmap[symname] = version 148 f.close() 149 150 def abi_write_vscript( vscript, libname, current_version, versions, symmap, abi_match):151 '''write a vscript file for a library in --version-script format152 153 :param vscript: Path to the vscript file155 156 157 def abi_write_vscript(f, libname, current_version, versions, symmap, abi_match): 158 """Write a vscript file for a library in --version-script format. 159 160 :param f: File-like object to write to 154 161 :param libname: Name of the library, uppercased 155 162 :param current_version: Current version 156 163 :param versions: Versions to consider 157 164 :param symmap: Dictionary mapping symbols -> version 158 :param abi_match: List of symbols considered to be public in the current version 159 ''' 165 :param abi_match: List of symbols considered to be public in the current 166 version 167 """ 160 168 161 169 invmap = {} … … 163 171 invmap.setdefault(symmap[s], []).append(s) 164 172 165 f = open(vscript, mode='w')166 173 last_key = "" 167 174 versions = sorted(versions, key=version_key) … … 171 178 break 172 179 f.write("%s {\n" % symver) 173 if k in invmap:174 f.write("\tglobal: 180 if k in sorted(invmap.keys()): 181 f.write("\tglobal:\n") 175 182 for s in invmap.get(k, []): 176 183 f.write("\t\t%s;\n" % s); … … 178 185 last_key = " %s" % symver 179 186 f.write("%s {\n" % current_version) 187 local_abi = filter(lambda x: x[0] == '!', abi_match) 188 global_abi = filter(lambda x: x[0] != '!', abi_match) 180 189 f.write("\tglobal:\n") 181 for x in abi_match: 182 f.write("\t\t%s;\n" % x) 190 if len(global_abi) > 0: 191 for x in global_abi: 192 f.write("\t\t%s;\n" % x) 193 else: 194 f.write("\t\t*;\n") 183 195 if abi_match != ["*"]: 184 f.write("\tlocal: *;\n") 196 f.write("\tlocal:\n") 197 for x in local_abi: 198 f.write("\t\t%s;\n" % x[1:]) 199 if len(global_abi) > 0: 200 f.write("\t\t*;\n") 185 201 f.write("};\n") 186 f.close()187 202 188 203 … … 200 215 versions.append(version) 201 216 abi_process_file(fname, version, symmap) 202 abi_write_vscript(tgt, task.env.LIBNAME, task.env.VERSION, versions, symmap, 203 task.env.ABI_MATCH) 217 f = open(tgt, mode='w') 218 try: 219 abi_write_vscript(f, task.env.LIBNAME, task.env.VERSION, versions, 220 symmap, task.env.ABI_MATCH) 221 finally: 222 f.close() 204 223 205 224 … … 207 226 '''generate a vscript file for our public libraries''' 208 227 if abi_directory: 209 source = bld.path.ant_glob('%s/%s-[0-9]*.sigs' % (abi_directory, libname) )228 source = bld.path.ant_glob('%s/%s-[0-9]*.sigs' % (abi_directory, libname), flat=True) 210 229 def abi_file_key(path): 211 230 return version_key(path[:-len(".sigs")].rsplit("-")[-1]) -
vendor/current/buildtools/wafsamba/samba_autoconf.py
r740 r988 1 1 # a waf tool to add autoconf-like macros to the configure section 2 2 3 import Build, os, sys, Options, preproc, Logs4 import string3 import os, sys 4 import Build, Options, preproc, Logs 5 5 from Configure import conf 6 from samba_utils import *7 import samba_cross 6 from TaskGen import feature 7 from samba_utils import TO_LIST, GET_TARGET_TYPE, SET_TARGET_TYPE, unique_list, mkdir_p 8 8 9 9 missing_headers = set() … … 14 14 # m4 files 15 15 16 @runonce17 16 @conf 18 17 def DEFINE(conf, d, v, add_to_cflags=False, quote=False): … … 63 62 conf.check_message_2 = conf.saved_check_message_2 64 63 p = conf.check_message_2 65 if result ==True:66 p('ok 67 elif result == False:64 if result is True: 65 p('ok') 66 elif not result: 68 67 p('not found', 'YELLOW') 69 68 else: … … 93 92 return True 94 93 95 (ccflags, ldflags ) = library_flags(conf, lib)94 (ccflags, ldflags, cpppath) = library_flags(conf, lib) 96 95 97 96 hdrs = hlist_to_string(conf, headers=h) 97 if lib is None: 98 lib = "" 98 99 ret = conf.check(fragment='%s\nint main(void) { return 0; }' % hdrs, 99 100 type='nolink', 100 101 execute=0, 101 102 ccflags=ccflags, 103 mandatory=False, 104 includes=cpppath, 105 uselib=lib.upper(), 102 106 msg="Checking for header %s" % h) 103 107 if not ret: … … 226 230 msg='Checking for declaration of %s' % v, 227 231 always=always): 228 ret = False 232 if not CHECK_CODE(conf, 233 ''' 234 return (int)%s; 235 ''' % (v), 236 execute=False, 237 link=False, 238 msg='Checking for declaration of %s (as enum)' % v, 239 local_include=False, 240 headers=headers, 241 define=define, 242 always=always): 243 ret = False 229 244 return ret 230 245 … … 238 253 conf.COMPOUND_START('Checking for %s' % f) 239 254 240 if link is None or link == True:255 if link is None or link: 241 256 ret = CHECK_CODE(conf, 242 257 # this is based on the autoconf strategy … … 281 296 msg='Checking for macro %s' % f) 282 297 283 if not ret and (link is None or link == False):298 if not ret and (link is None or not link): 284 299 ret = CHECK_VARIABLE(conf, f, 285 300 define=define, … … 301 316 302 317 @conf 303 def CHECK_SIZEOF(conf, vars, headers=None, define=None ):318 def CHECK_SIZEOF(conf, vars, headers=None, define=None, critical=True): 304 319 '''check the size of a type''' 305 ret = True306 320 for v in TO_LIST(vars): 307 321 v_define = define 322 ret = False 308 323 if v_define is None: 309 324 v_define = 'SIZEOF_%s' % v.upper().replace(' ', '_') 310 if not CHECK_CODE(conf, 311 'printf("%%u", (unsigned)sizeof(%s))' % v, 312 define=v_define, 313 execute=True, 314 define_ret=True, 315 quote=False, 316 headers=headers, 317 local_include=False, 318 msg="Checking size of %s" % v): 319 ret = False 320 return ret 321 322 325 for size in list((1, 2, 4, 8, 16, 32)): 326 if CHECK_CODE(conf, 327 'static int test_array[1 - 2 * !(((long int)(sizeof(%s))) <= %d)];' % (v, size), 328 define=v_define, 329 quote=False, 330 headers=headers, 331 local_include=False, 332 msg="Checking if size of %s == %d" % (v, size)): 333 conf.DEFINE(v_define, size) 334 ret = True 335 break 336 if not ret and critical: 337 Logs.error("Couldn't determine size of '%s'" % v) 338 sys.exit(1) 339 return ret 340 341 @conf 342 def CHECK_VALUEOF(conf, v, headers=None, define=None): 343 '''check the value of a variable/define''' 344 ret = True 345 v_define = define 346 if v_define is None: 347 v_define = 'VALUEOF_%s' % v.upper().replace(' ', '_') 348 if CHECK_CODE(conf, 349 'printf("%%u", (unsigned)(%s))' % v, 350 define=v_define, 351 execute=True, 352 define_ret=True, 353 quote=False, 354 headers=headers, 355 local_include=False, 356 msg="Checking value of %s" % v): 357 return int(conf.env[v_define]) 358 359 return None 323 360 324 361 @conf … … 369 406 uselib = TO_LIST(lib) 370 407 371 (ccflags, ldflags) = library_flags(conf, uselib) 408 (ccflags, ldflags, cpppath) = library_flags(conf, uselib) 409 410 includes = TO_LIST(includes) 411 includes.extend(cpppath) 412 413 uselib = [l.upper() for l in uselib] 372 414 373 415 cflags.extend(ccflags) … … 429 471 430 472 @conf 431 def CHECK_CFLAGS(conf, cflags ):473 def CHECK_CFLAGS(conf, cflags, fragment='int main(void) { return 0; }\n'): 432 474 '''check if the given cflags are accepted by the compiler 433 475 ''' 434 return conf.check(fragment= 'int main(void) { return 0; }\n',476 return conf.check(fragment=fragment, 435 477 execute=0, 436 478 type='nolink', … … 445 487 execute=0, 446 488 ldflags=ldflags, 489 mandatory=False, 447 490 msg="Checking linker accepts %s" % ldflags) 448 491 … … 459 502 def CONFIG_SET(conf, option): 460 503 '''return True if a configuration option was found''' 461 return (option in conf.env) and (conf.env[option] != ()) 504 if option not in conf.env: 505 return False 506 v = conf.env[option] 507 if v is None: 508 return False 509 if v == []: 510 return False 511 if v == (): 512 return False 513 return True 514 515 @conf 516 def CONFIG_RESET(conf, option): 517 if option not in conf.env: 518 return 519 del conf.env[option] 520 521 Build.BuildContext.CONFIG_RESET = CONFIG_RESET 462 522 Build.BuildContext.CONFIG_SET = CONFIG_SET 463 523 Build.BuildContext.CONFIG_GET = CONFIG_GET … … 468 528 ccflags = [] 469 529 ldflags = [] 530 cpppath = [] 470 531 for lib in TO_LIST(libs): 471 inc_path = getattr(self.env, 'CPPPATH_%s' % lib.upper(), []) 472 lib_path = getattr(self.env, 'LIBPATH_%s' % lib.upper(), []) 473 ccflags.extend(['-I%s' % i for i in inc_path]) 474 ldflags.extend(['-L%s' % l for l in lib_path]) 532 # note that we do not add the -I and -L in here, as that is added by the waf 533 # core. Adding it here would just change the order that it is put on the link line 534 # which can cause system paths to be added before internal libraries 475 535 extra_ccflags = TO_LIST(getattr(self.env, 'CCFLAGS_%s' % lib.upper(), [])) 476 536 extra_ldflags = TO_LIST(getattr(self.env, 'LDFLAGS_%s' % lib.upper(), [])) 537 extra_cpppath = TO_LIST(getattr(self.env, 'CPPPATH_%s' % lib.upper(), [])) 477 538 ccflags.extend(extra_ccflags) 478 539 ldflags.extend(extra_ldflags) 540 cpppath.extend(extra_cpppath) 479 541 if 'EXTRA_LDFLAGS' in self.env: 480 542 ldflags.extend(self.env['EXTRA_LDFLAGS']) … … 482 544 ccflags = unique_list(ccflags) 483 545 ldflags = unique_list(ldflags) 484 return (ccflags, ldflags) 546 cpppath = unique_list(cpppath) 547 return (ccflags, ldflags, cpppath) 485 548 486 549 … … 506 569 continue 507 570 508 (ccflags, ldflags ) = library_flags(conf, lib)571 (ccflags, ldflags, cpppath) = library_flags(conf, lib) 509 572 if shlib: 510 res = conf.check(features='c c cshlib', fragment=fragment, lib=lib, uselib_store=lib, ccflags=ccflags, ldflags=ldflags)573 res = conf.check(features='c cshlib', fragment=fragment, lib=lib, uselib_store=lib, ccflags=ccflags, ldflags=ldflags, uselib=lib.upper(), mandatory=False) 511 574 else: 512 res = conf.check(lib=lib, uselib_store=lib, ccflags=ccflags, ldflags=ldflags )575 res = conf.check(lib=lib, uselib_store=lib, ccflags=ccflags, ldflags=ldflags, uselib=lib.upper(), mandatory=False) 513 576 514 577 if not res: … … 521 584 SET_TARGET_TYPE(conf, lib, 'EMPTY') 522 585 else: 523 conf.define('HAVE_LIB%s' % lib.upper().replace('-','_') , 1)586 conf.define('HAVE_LIB%s' % lib.upper().replace('-','_').replace('.','_'), 1) 524 587 conf.env['LIB_' + lib.upper()] = lib 525 588 if set_target: … … 596 659 return 597 660 661 # we need to build real code that can't be optimized away to test 662 if conf.check(fragment=''' 663 #include <stdio.h> 664 665 int main(void) 666 { 667 char t[100000]; 668 while (fgets(t, sizeof(t), stdin)); 669 return 0; 670 } 671 ''', 672 execute=0, 673 ccflags='-fstack-protector', 674 ldflags='-fstack-protector', 675 mandatory=False, 676 msg='Checking if toolchain accepts -fstack-protector'): 677 conf.ADD_CFLAGS('-fstack-protector') 678 conf.ADD_LDFLAGS('-fstack-protector') 679 680 if Options.options.debug: 681 conf.ADD_CFLAGS('-g', testflags=True) 682 598 683 if Options.options.developer: 684 conf.env.DEVELOPER_MODE = True 685 686 conf.ADD_CFLAGS('-g', testflags=True) 687 conf.ADD_CFLAGS('-Wall', testflags=True) 688 conf.ADD_CFLAGS('-Wshadow', testflags=True) 689 conf.ADD_CFLAGS('-Wmissing-prototypes', testflags=True) 690 conf.ADD_CFLAGS('-Wcast-align -Wcast-qual', testflags=True) 691 conf.ADD_CFLAGS('-fno-common', testflags=True) 692 693 conf.ADD_CFLAGS('-Werror=address', testflags=True) 599 694 # we add these here to ensure that -Wstrict-prototypes is not set during configure 600 conf.ADD_CFLAGS('-W all -g -Wshadow -Wstrict-prototypes -Wpointer-arith -Wcast-align -Wwrite-strings -Werror-implicit-function-declaration -Wformat=2 -Wno-format-y2k -Wmissing-prototypes',695 conf.ADD_CFLAGS('-Werror=strict-prototypes -Wstrict-prototypes', 601 696 testflags=True) 602 if os.getenv('TOPLEVEL_BUILD'): 603 conf.ADD_CFLAGS('-Wcast-qual', testflags=True) 604 conf.env.DEVELOPER_MODE = True 697 conf.ADD_CFLAGS('-Werror=write-strings -Wwrite-strings', 698 testflags=True) 699 conf.ADD_CFLAGS('-Werror-implicit-function-declaration', 700 testflags=True) 701 conf.ADD_CFLAGS('-Werror=pointer-arith -Wpointer-arith', 702 testflags=True) 703 conf.ADD_CFLAGS('-Werror=declaration-after-statement -Wdeclaration-after-statement', 704 testflags=True) 705 conf.ADD_CFLAGS('-Werror=return-type -Wreturn-type', 706 testflags=True) 707 conf.ADD_CFLAGS('-Werror=uninitialized -Wuninitialized', 708 testflags=True) 709 710 conf.ADD_CFLAGS('-Wformat=2 -Wno-format-y2k', testflags=True) 711 # This check is because for ldb_search(), a NULL format string 712 # is not an error, but some compilers complain about that. 713 if CHECK_CFLAGS(conf, ["-Werror=format", "-Wformat=2"], ''' 714 int testformat(char *format, ...) __attribute__ ((format (__printf__, 1, 2))); 715 716 int main(void) { 717 testformat(0); 718 return 0; 719 } 720 721 '''): 722 if not 'EXTRA_CFLAGS' in conf.env: 723 conf.env['EXTRA_CFLAGS'] = [] 724 conf.env['EXTRA_CFLAGS'].extend(TO_LIST("-Werror=format")) 605 725 606 726 if Options.options.picky_developer: 607 conf.ADD_ CFLAGS('-Werror', testflags=True)727 conf.ADD_NAMED_CFLAGS('PICKY_CFLAGS', '-Werror -Wno-error=deprecated-declarations', testflags=True) 608 728 609 729 if Options.options.fatal_errors: … … 612 732 if Options.options.pedantic: 613 733 conf.ADD_CFLAGS('-W', testflags=True) 734 735 if Options.options.address_sanitizer: 736 conf.ADD_CFLAGS('-fno-omit-frame-pointer -O1 -fsanitize=address', testflags=True) 737 conf.ADD_LDFLAGS('-fsanitize=address', testflags=True) 738 conf.env['ADDRESS_SANITIZER'] = True 739 740 741 # Let people pass an additional ADDITIONAL_{CFLAGS,LDFLAGS} 742 # environment variables which are only used the for final build. 743 # 744 # The CFLAGS and LDFLAGS environment variables are also 745 # used for the configure checks which might impact their results. 746 conf.add_os_flags('ADDITIONAL_CFLAGS') 747 if conf.env.ADDITIONAL_CFLAGS and conf.CHECK_CFLAGS(conf.env['ADDITIONAL_CFLAGS']): 748 conf.env['EXTRA_CFLAGS'].extend(conf.env['ADDITIONAL_CFLAGS']) 749 conf.add_os_flags('ADDITIONAL_LDFLAGS') 750 if conf.env.ADDITIONAL_LDFLAGS and conf.CHECK_LDFLAGS(conf.env['ADDITIONAL_LDFLAGS']): 751 conf.env['EXTRA_LDFLAGS'].extend(conf.env['ADDITIONAL_LDFLAGS']) 614 752 615 753 if path is None: … … 630 768 631 769 @conf 632 def ADD_ CFLAGS(conf, flags, testflags=False):770 def ADD_NAMED_CFLAGS(conf, name, flags, testflags=False): 633 771 '''add some CFLAGS to the command line 634 772 optionally set testflags to ensure all the flags work … … 640 778 ok_flags.append(f) 641 779 flags = ok_flags 642 if not 'EXTRA_CFLAGS' in conf.env: 643 conf.env['EXTRA_CFLAGS'] = [] 644 conf.env['EXTRA_CFLAGS'].extend(TO_LIST(flags)) 780 if not name in conf.env: 781 conf.env[name] = [] 782 conf.env[name].extend(TO_LIST(flags)) 783 784 @conf 785 def ADD_CFLAGS(conf, flags, testflags=False): 786 '''add some CFLAGS to the command line 787 optionally set testflags to ensure all the flags work 788 ''' 789 ADD_NAMED_CFLAGS(conf, 'EXTRA_CFLAGS', flags, testflags=testflags) 645 790 646 791 @conf … … 672 817 673 818 674 def CURRENT_CFLAGS(bld, target, cflags, hide_symbols=False):819 def CURRENT_CFLAGS(bld, target, cflags, allow_warnings=False, hide_symbols=False): 675 820 '''work out the current flags. local flags are added first''' 821 ret = TO_LIST(cflags) 676 822 if not 'EXTRA_CFLAGS' in bld.env: 677 823 list = [] 678 824 else: 679 825 list = bld.env['EXTRA_CFLAGS']; 680 ret = TO_LIST(cflags)681 826 ret.extend(list) 827 if not allow_warnings and 'PICKY_CFLAGS' in bld.env: 828 list = bld.env['PICKY_CFLAGS']; 829 ret.extend(list) 682 830 if hide_symbols and bld.env.HAVE_VISIBILITY_ATTR: 683 ret.append( '-fvisibility=hidden')831 ret.append(bld.env.VISIBILITY_CFLAGS) 684 832 return ret 685 833 … … 714 862 # in either case we don't need to scan system includes 715 863 preproc.go_absolute = False 864 865 866 @conf 867 def SAMBA_CHECK_UNDEFINED_SYMBOL_FLAGS(conf): 868 # we don't want any libraries or modules to rely on runtime 869 # resolution of symbols 870 if not sys.platform.startswith("openbsd"): 871 conf.env.undefined_ldflags = conf.ADD_LDFLAGS('-Wl,-no-undefined', testflags=True) 872 873 if not sys.platform.startswith("openbsd") and conf.env.undefined_ignore_ldflags == []: 874 if conf.CHECK_LDFLAGS(['-undefined', 'dynamic_lookup']): 875 conf.env.undefined_ignore_ldflags = ['-undefined', 'dynamic_lookup'] 876 877 @conf 878 def CHECK_CFG(self, *k, **kw): 879 return self.check_cfg(*k, **kw) -
vendor/current/buildtools/wafsamba/samba_autoproto.py
r740 r988 1 1 # waf build tool for building automatic prototypes from C source 2 2 3 import os 3 4 import Build 4 from samba_utils import *5 from samba_utils import SET_TARGET_TYPE, os_path_relpath 5 6 6 7 def SAMBA_AUTOPROTO(bld, header, source): … … 14 15 source = source, 15 16 target = header, 16 on_results=True,17 update_outputs=True, 17 18 ext_out='.c', 18 19 before ='cc', -
vendor/current/buildtools/wafsamba/samba_bundled.py
r740 r988 1 1 # functions to support bundled libraries 2 2 3 import sys 4 import Build, Options, Logs 3 5 from Configure import conf 4 import sys, Logs 5 from samba_utils import * 6 from samba_utils import TO_LIST 6 7 7 8 def PRIVATE_NAME(bld, name, private_extension, private_library): 8 9 '''possibly rename a library to include a bundled extension''' 10 11 if not private_library: 12 return name 9 13 10 14 # we now use the same private name for libraries as the public name. … … 12 16 # demonstration that this is the right thing to do 13 17 # also see http://lists.samba.org/archive/samba-technical/2011-January/075816.html 14 return name 18 if private_extension: 19 return name 20 21 extension = bld.env.PRIVATE_EXTENSION 22 23 if extension and name.startswith('%s' % extension): 24 return name 25 26 if extension and name.endswith('%s' % extension): 27 return name 28 29 return "%s-%s" % (name, extension) 15 30 16 31 … … 31 46 '''return True if a library should be builtin 32 47 instead of being built as a shared lib''' 33 if bld.env.DISABLE_SHARED:34 return True35 48 return target_in_list(name, bld.env.BUILTIN_LIBRARIES, False) 36 49 Build.BuildContext.BUILTIN_LIBRARY = BUILTIN_LIBRARY … … 73 86 @conf 74 87 def LIB_MAY_BE_BUNDLED(conf, libname): 75 return ('NONE' not in conf.env.BUNDLED_LIBS and 76 '!%s' % libname not in conf.env.BUNDLED_LIBS) 77 88 if libname in conf.env.BUNDLED_LIBS: 89 return True 90 if '!%s' % libname in conf.env.BUNDLED_LIBS: 91 return False 92 if 'NONE' in conf.env.BUNDLED_LIBS: 93 return False 94 return True 78 95 79 96 @conf 80 97 def LIB_MUST_BE_BUNDLED(conf, libname): 81 return ('ALL' in conf.env.BUNDLED_LIBS or 82 libname in conf.env.BUNDLED_LIBS) 83 84 85 @runonce 98 if libname in conf.env.BUNDLED_LIBS: 99 return True 100 if '!%s' % libname in conf.env.BUNDLED_LIBS: 101 return False 102 if 'ALL' in conf.env.BUNDLED_LIBS: 103 return True 104 return False 105 106 @conf 107 def LIB_MUST_BE_PRIVATE(conf, libname): 108 return ('ALL' in conf.env.PRIVATE_LIBS or 109 libname in conf.env.PRIVATE_LIBS) 110 111 @conf 112 def CHECK_BUNDLED_SYSTEM_PKG(conf, libname, minversion='0.0.0', 113 onlyif=None, implied_deps=None, pkg=None): 114 '''check if a library is available as a system library. 115 116 This only tries using pkg-config 117 ''' 118 return conf.CHECK_BUNDLED_SYSTEM(libname, 119 minversion=minversion, 120 onlyif=onlyif, 121 implied_deps=implied_deps, 122 pkg=pkg) 123 86 124 @conf 87 125 def CHECK_BUNDLED_SYSTEM(conf, libname, minversion='0.0.0', 88 checkfunctions=None, headers=None, 126 checkfunctions=None, headers=None, checkcode=None, 89 127 onlyif=None, implied_deps=None, 90 require_headers=True ):128 require_headers=True, pkg=None, set_target=True): 91 129 '''check if a library is available as a system library. 92 130 this first tries via pkg-config, then if that fails 93 131 tries by testing for a specified function in the specified lib 94 132 ''' 95 if conf.LIB_MUST_BE_BUNDLED(libname): 96 return False 133 # We always do a logic validation of 'onlyif' first 134 missing = [] 135 if onlyif: 136 for l in TO_LIST(onlyif): 137 f = 'FOUND_SYSTEMLIB_%s' % l 138 if not f in conf.env: 139 Logs.error('ERROR: CHECK_BUNDLED_SYSTEM(%s) - ' % (libname) + 140 'missing prerequisite check for ' + 141 'system library %s, onlyif=%r' % (l, onlyif)) 142 sys.exit(1) 143 if not conf.env[f]: 144 missing.append(l) 97 145 found = 'FOUND_SYSTEMLIB_%s' % libname 98 146 if found in conf.env: 99 147 return conf.env[found] 100 101 def check_functions_headers(): 102 '''helper function for CHECK_BUNDLED_SYSTEM''' 103 if checkfunctions is None: 104 return True 105 if require_headers and headers and not conf.CHECK_HEADERS(headers, lib=libname): 106 return False 107 return conf.CHECK_FUNCS_IN(checkfunctions, libname, headers=headers, 108 empty_decl=False, set_target=False) 148 if conf.LIB_MUST_BE_BUNDLED(libname): 149 conf.env[found] = False 150 return False 109 151 110 152 # see if the library should only use a system version if another dependent 111 153 # system version is found. That prevents possible use of mixed library 112 154 # versions 113 if onlyif: 114 for syslib in TO_LIST(onlyif): 115 f = 'FOUND_SYSTEMLIB_%s' % syslib 116 if not f in conf.env: 117 if not conf.LIB_MAY_BE_BUNDLED(libname): 118 Logs.error('ERROR: Use of system library %s depends on missing system library %s' % (libname, syslib)) 119 sys.exit(1) 120 conf.env[found] = False 155 if missing: 156 if not conf.LIB_MAY_BE_BUNDLED(libname): 157 Logs.error('ERROR: Use of system library %s depends on missing system library/libraries %r' % (libname, missing)) 158 sys.exit(1) 159 conf.env[found] = False 160 return False 161 162 def check_functions_headers_code(): 163 '''helper function for CHECK_BUNDLED_SYSTEM''' 164 if require_headers and headers and not conf.CHECK_HEADERS(headers, lib=libname): 165 return False 166 if checkfunctions is not None: 167 ok = conf.CHECK_FUNCS_IN(checkfunctions, libname, headers=headers, 168 empty_decl=False, set_target=False) 169 if not ok: 121 170 return False 171 if checkcode is not None: 172 define='CHECK_BUNDLED_SYSTEM_%s' % libname.upper() 173 ok = conf.CHECK_CODE(checkcode, lib=libname, 174 headers=headers, local_include=False, 175 msg=msg, define=define) 176 conf.CONFIG_RESET(define) 177 if not ok: 178 return False 179 return True 122 180 123 181 minversion = minimum_library_version(conf, libname, minversion) … … 127 185 msg += ' >= %s' % minversion 128 186 187 uselib_store=libname.upper() 188 if pkg is None: 189 pkg = libname 190 129 191 # try pkgconfig first 130 if (conf.check_cfg(package=libname, 131 args='"%s >= %s" --cflags --libs' % (libname, minversion), 132 msg=msg) and 133 check_functions_headers()): 134 conf.SET_TARGET_TYPE(libname, 'SYSLIB') 192 if (conf.CHECK_CFG(package=pkg, 193 args='"%s >= %s" --cflags --libs' % (pkg, minversion), 194 msg=msg, uselib_store=uselib_store) and 195 check_functions_headers_code()): 196 if set_target: 197 conf.SET_TARGET_TYPE(libname, 'SYSLIB') 135 198 conf.env[found] = True 136 199 if implied_deps: … … 138 201 return True 139 202 if checkfunctions is not None: 140 if check_functions_headers ():203 if check_functions_headers_code(): 141 204 conf.env[found] = True 142 205 if implied_deps: 143 206 conf.SET_SYSLIB_DEPS(libname, implied_deps) 144 conf.SET_TARGET_TYPE(libname, 'SYSLIB') 207 if set_target: 208 conf.SET_TARGET_TYPE(libname, 'SYSLIB') 145 209 return True 146 210 conf.env[found] = False … … 151 215 152 216 153 @runonce 217 def tuplize_version(version): 218 return tuple([int(x) for x in version.split(".")]) 219 154 220 @conf 155 221 def CHECK_BUNDLED_SYSTEM_PYTHON(conf, libname, modulename, minversion='0.0.0'): … … 175 241 found = False 176 242 else: 177 found = tupl e(version.split(".")) >= tuple(minversion.split("."))243 found = tuplize_version(version) >= tuplize_version(minversion) 178 244 if not found and not conf.LIB_MAY_BE_BUNDLED(libname): 179 245 Logs.error('ERROR: Python module %s of version %s not found, and bundling disabled' % (libname, minversion)) … … 184 250 def NONSHARED_BINARY(bld, name): 185 251 '''return True if a binary should be built without non-system shared libs''' 186 if bld.env.DISABLE_SHARED:187 return True188 252 return target_in_list(name, bld.env.NONSHARED_BINARIES, False) 189 253 Build.BuildContext.NONSHARED_BINARY = NONSHARED_BINARY -
vendor/current/buildtools/wafsamba/samba_conftests.py
r740 r988 2 2 # to test for commonly needed configuration options 3 3 4 import os, Build, shutil, Utils, re 4 import os, shutil, re 5 import Build, Configure, Utils, Options, Logs 5 6 from Configure import conf 6 from samba_utils import * 7 from samba_utils import TO_LIST, ADD_LD_LIBRARY_PATH 8 9 10 def add_option(self, *k, **kw): 11 '''syntax help: provide the "match" attribute to opt.add_option() so that folders can be added to specific config tests''' 12 match = kw.get('match', []) 13 if match: 14 del kw['match'] 15 opt = self.parser.add_option(*k, **kw) 16 opt.match = match 17 return opt 18 Options.Handler.add_option = add_option 19 20 @conf 21 def check(self, *k, **kw): 22 '''Override the waf defaults to inject --with-directory options''' 23 24 if not 'env' in kw: 25 kw['env'] = self.env.copy() 26 27 # match the configuration test with speficic options, for example: 28 # --with-libiconv -> Options.options.iconv_open -> "Checking for library iconv" 29 additional_dirs = [] 30 if 'msg' in kw: 31 msg = kw['msg'] 32 for x in Options.Handler.parser.parser.option_list: 33 if getattr(x, 'match', None) and msg in x.match: 34 d = getattr(Options.options, x.dest, '') 35 if d: 36 additional_dirs.append(d) 37 38 # we add the additional dirs twice: once for the test data, and again if the compilation test suceeds below 39 def add_options_dir(dirs, env): 40 for x in dirs: 41 if not x in env.CPPPATH: 42 env.CPPPATH = [os.path.join(x, 'include')] + env.CPPPATH 43 if not x in env.LIBPATH: 44 env.LIBPATH = [os.path.join(x, 'lib')] + env.LIBPATH 45 46 add_options_dir(additional_dirs, kw['env']) 47 48 self.validate_c(kw) 49 self.check_message_1(kw['msg']) 50 ret = None 51 try: 52 ret = self.run_c_code(*k, **kw) 53 except Configure.ConfigurationError, e: 54 self.check_message_2(kw['errmsg'], 'YELLOW') 55 if 'mandatory' in kw and kw['mandatory']: 56 if Logs.verbose > 1: 57 raise 58 else: 59 self.fatal('the configuration failed (see %r)' % self.log.name) 60 else: 61 kw['success'] = ret 62 self.check_message_2(self.ret_msg(kw['okmsg'], kw)) 63 64 # success! keep the CPPPATH/LIBPATH 65 add_options_dir(additional_dirs, self.env) 66 67 self.post_check(*k, **kw) 68 if not kw.get('execute', False): 69 return ret == 0 70 return ret 71 7 72 8 73 @conf … … 19 84 def CHECK_LARGEFILE(conf, define='HAVE_LARGEFILE'): 20 85 '''see what we need for largefile support''' 86 getconf_cflags = conf.CHECK_COMMAND(['getconf', 'LFS_CFLAGS']); 87 if getconf_cflags is not False: 88 if (conf.CHECK_CODE('return !(sizeof(off_t) >= 8)', 89 define='WORKING_GETCONF_LFS_CFLAGS', 90 execute=True, 91 cflags=getconf_cflags, 92 msg='Checking getconf large file support flags work')): 93 conf.ADD_CFLAGS(getconf_cflags) 94 getconf_cflags_list=TO_LIST(getconf_cflags) 95 for flag in getconf_cflags_list: 96 if flag[:2] == "-D": 97 flag_split = flag[2:].split('=') 98 if len(flag_split) == 1: 99 conf.DEFINE(flag_split[0], '1') 100 else: 101 conf.DEFINE(flag_split[0], flag_split[1]) 102 21 103 if conf.CHECK_CODE('return !(sizeof(off_t) >= 8)', 22 104 define, 23 105 execute=True, 24 msg='Checking for large file support '):106 msg='Checking for large file support without additional flags'): 25 107 return True 108 26 109 if conf.CHECK_CODE('return !(sizeof(off_t) >= 8)', 27 110 define, … … 30 113 msg='Checking for -D_FILE_OFFSET_BITS=64'): 31 114 conf.DEFINE('_FILE_OFFSET_BITS', 64) 115 return True 116 117 if conf.CHECK_CODE('return !(sizeof(off_t) >= 8)', 118 define, 119 execute=True, 120 cflags='-D_LARGE_FILES', 121 msg='Checking for -D_LARGE_FILES'): 122 conf.DEFINE('_LARGE_FILES', 1) 32 123 return True 33 124 return False … … 106 197 } 107 198 ''' 108 return conf.check(features='c c cshlib',vnum="1",fragment=snip,msg=msg)199 return conf.check(features='c cshlib',vnum="1",fragment=snip,msg=msg, mandatory=False) 109 200 110 201 @conf … … 125 216 os.makedirs(subdir) 126 217 127 dest = open(os.path.join(subdir, 'liblc1.c'), 'w') 128 dest.write('#include <stdio.h>\nint lib_func(void) { FILE *f = fopen("foo", "r");}\n') 129 dest.close() 218 Utils.writef(os.path.join(subdir, 'liblc1.c'), '#include <stdio.h>\nint lib_func(void) { FILE *f = fopen("foo", "r");}\n') 130 219 131 220 bld = Build.BuildContext() … … 138 227 bld.rescan(bld.srcnode) 139 228 140 bld(features='c ccshlib',229 bld(features='c cshlib', 141 230 source='liblctest/liblc1.c', 142 231 ldflags=conf.env['EXTRA_LDFLAGS'], … … 158 247 159 248 dir = find_config_dir(conf) 160 161 env = conf.env162 163 249 snip = ''' 164 250 #include <Python.h> … … 173 259 return v * 2; 174 260 }''' 175 return conf.check(features='c c cshlib',uselib='PYEMBED',fragment=snip,msg=msg)261 return conf.check(features='c cshlib',uselib='PYEMBED',fragment=snip,msg=msg, mandatory=False) 176 262 177 263 # this one is quite complex, and should probably be broken up … … 200 286 os.makedirs(subdir) 201 287 202 dest = open(os.path.join(subdir, 'lib1.c'), 'w') 203 dest.write('int lib_func(void) { return 42; }\n') 204 dest.close() 205 206 dest = open(os.path.join(dir, 'main.c'), 'w') 207 dest.write('int main(void) {return !(lib_func() == 42);}\n') 208 dest.close() 288 Utils.writef(os.path.join(subdir, 'lib1.c'), 'int lib_func(void) { return 42; }\n') 289 Utils.writef(os.path.join(dir, 'main.c'), 'int main(void) {return !(lib_func() == 42);}\n') 209 290 210 291 bld = Build.BuildContext() … … 220 301 if version_script: 221 302 ldflags.append("-Wl,--version-script=%s/vscript" % bld.path.abspath()) 222 dest = open(os.path.join(dir,'vscript'), 'w') 223 dest.write('TEST_1.0A2 { global: *; };\n') 224 dest.close() 225 226 bld(features='cc cshlib', 303 Utils.writef(os.path.join(dir,'vscript'), 'TEST_1.0A2 { global: *; };\n') 304 305 bld(features='c cshlib', 227 306 source='libdir/lib1.c', 228 307 target='libdir/lib1', … … 230 309 name='lib1') 231 310 232 o = bld(features='c ccprogram',311 o = bld(features='c cprogram', 233 312 source='main.c', 234 313 target='prog1', … … 292 371 os.makedirs(bdir) 293 372 294 dest = open(os.path.join(bdir, 'Makefile.PL'), 'w') 295 dest.write(""" 373 Utils.writef(os.path.join(bdir, 'Makefile.PL'), """ 296 374 use ExtUtils::MakeMaker; 297 375 WriteMakefile( 298 'NAME' 376 'NAME' => 'WafTest', 299 377 'EXE_FILES' => [ 'WafTest' ] 300 378 ); 301 379 """) 302 dest.close()303 380 back = os.path.abspath('.') 304 381 os.chdir(bdir) … … 315 392 316 393 if section: 317 f = open(os.path.join(bdir,'Makefile'), 'r') 318 man = f.read() 319 f.close() 394 man = Utils.readf(os.path.join(bdir,'Makefile')) 320 395 m = re.search('MAN%sEXT\s+=\s+(\w+)' % section, man) 321 396 if not m: … … 413 488 define='XSLTPROC_MANPAGES', on_target=False, 414 489 boolean=True) 490 if not conf.CONFIG_SET('XSLTPROC_MANPAGES'): 491 print "A local copy of the docbook.xsl wasn't found on your system" \ 492 " consider installing package like docbook-xsl" 493 494 # 495 # Determine the standard libpath for the used compiler, 496 # so we can later use that to filter out these standard 497 # library paths when some tools like cups-config or 498 # python-config report standard lib paths with their 499 # ldflags (-L...) 500 # 501 @conf 502 def CHECK_STANDARD_LIBPATH(conf): 503 # at least gcc and clang support this: 504 try: 505 cmd = conf.env.CC + ['-print-search-dirs'] 506 out = Utils.cmd_output(cmd).split('\n') 507 except ValueError: 508 # option not supported by compiler - use a standard list of directories 509 dirlist = [ '/usr/lib', '/usr/lib64' ] 510 except: 511 raise Utils.WafError('Unexpected error running "%s"' % (cmd)) 512 else: 513 dirlist = [] 514 for line in out: 515 line = line.strip() 516 if line.startswith("libraries: ="): 517 dirliststr = line[len("libraries: ="):] 518 dirlist = [ os.path.normpath(x) for x in dirliststr.split(':') ] 519 break 520 521 conf.env.STANDARD_LIBPATH = dirlist 522 -
vendor/current/buildtools/wafsamba/samba_cross.py
r740 r988 1 1 # functions for handling cross-compilation 2 2 3 import Utils, Logs, sys, os, Options, re 3 import os, sys, re, shlex 4 import Utils, Logs, Options 4 5 from Configure import conf 5 6 … … 7 8 8 9 ANSWER_UNKNOWN = (254, "") 9 ANSWER_ FAIL = (255, "")10 ANSWER_NO = (1, "") 10 11 ANSWER_OK = (0, "") 11 12 … … 20 21 Logs.error("Unable to open cross-answers file %s" % ca_file) 21 22 sys.exit(1) 23 (retcode, retstring) = answer 24 # if retstring is more than one line then we probably 25 # don't care about its actual content (the tests should 26 # yield one-line output in order to comply with the cross-answer 27 # format) 28 retstring = retstring.strip() 29 if len(retstring.split('\n')) > 1: 30 retstring = '' 31 answer = (retcode, retstring) 32 22 33 if answer == ANSWER_OK: 23 34 f.write('%s: OK\n' % msg) 24 35 elif answer == ANSWER_UNKNOWN: 25 36 f.write('%s: UNKNOWN\n' % msg) 26 elif answer == ANSWER_ FAIL:27 f.write('%s: FAIL\n' % msg)37 elif answer == ANSWER_NO: 38 f.write('%s: NO\n' % msg) 28 39 else: 29 (retcode, retstring) = answer 30 f.write('%s: (%d, "%s")' % (msg, retcode, retstring)) 40 if retcode == 0: 41 f.write('%s: "%s"\n' % (msg, retstring)) 42 else: 43 f.write('%s: (%d, "%s")\n' % (msg, retcode, retstring)) 31 44 f.close() 32 45 … … 37 50 f = open(ca_file, 'r') 38 51 except: 39 add_answer(ca_file, msg, ANSWER_UNKNOWN)40 52 return ANSWER_UNKNOWN 41 53 for line in f: … … 44 56 continue 45 57 if line.find(':') != -1: 46 a = line.split(':' )58 a = line.split(':', 1) 47 59 thismsg = a[0].strip() 48 60 if thismsg != msg: … … 57 69 elif ans == "FAIL" or ans == "NO": 58 70 f.close() 59 return ANSWER_ FAIL71 return ANSWER_NO 60 72 elif ans[0] == '"': 73 f.close() 61 74 return (0, ans.strip('"')) 62 75 elif ans[0] == "'": 76 f.close() 63 77 return (0, ans.strip("'")) 64 78 else: … … 70 84 raise Utils.WafError("Bad answer format '%s' in %s" % (line, ca_file)) 71 85 f.close() 72 add_answer(ca_file, msg, ANSWER_UNKNOWN)73 86 return ANSWER_UNKNOWN 74 87 … … 78 91 def __init__(*k, **kw): 79 92 (obj, args) = k 93 use_answers = False 94 ans = ANSWER_UNKNOWN 80 95 81 if '--cross-execute' in args: 82 # when --cross-execute is set, then change the arguments 83 # to use the cross emulator 84 i = args.index('--cross-execute') 85 newargs = args[i+1].split() 86 newargs.extend(args[0:i]) 87 args = newargs 88 elif '--cross-answers' in args: 96 # Three possibilities: 97 # 1. Only cross-answers - try the cross-answers file, and if 98 # there's no corresponding answer, add to the file and mark 99 # the configure process as unfinished. 100 # 2. Only cross-execute - get the answer from cross-execute 101 # 3. Both - try the cross-answers file, and if there is no 102 # corresponding answer - use cross-execute to get an answer, 103 # and add that answer to the file. 104 if '--cross-answers' in args: 89 105 # when --cross-answers is set, then change the arguments 90 106 # to use the cross answers if available 107 use_answers = True 91 108 i = args.index('--cross-answers') 92 109 ca_file = args[i+1] 93 110 msg = args[i+2] 94 111 ans = cross_answer(ca_file, msg) 112 113 if '--cross-execute' in args and ans == ANSWER_UNKNOWN: 114 # when --cross-execute is set, then change the arguments 115 # to use the cross emulator 116 i = args.index('--cross-execute') 117 newargs = shlex.split(args[i+1]) 118 newargs.extend(args[0:i]) 119 if use_answers: 120 p = real_Popen(newargs, 121 stdout=Utils.pproc.PIPE, 122 stderr=Utils.pproc.PIPE) 123 ce_out, ce_err = p.communicate() 124 ans = (p.returncode, ce_out) 125 add_answer(ca_file, msg, ans) 126 else: 127 args = newargs 128 129 if use_answers: 95 130 if ans == ANSWER_UNKNOWN: 96 131 global cross_answers_incomplete 97 132 cross_answers_incomplete = True 133 add_answer(ca_file, msg, ans) 98 134 (retcode, retstring) = ans 99 135 args = ['/bin/sh', '-c', "echo -n '%s'; exit %d" % (retstring, retcode)] … … 116 152 if conf.env.CROSS_EXECUTE: 117 153 ret.extend(['--cross-execute', conf.env.CROSS_EXECUTE]) 118 elif conf.env.CROSS_ANSWERS: 154 155 if conf.env.CROSS_ANSWERS: 119 156 if msg is None: 120 157 raise Utils.WafError("Cannot have NULL msg in cross-answers") -
vendor/current/buildtools/wafsamba/samba_deps.py
r740 r988 1 1 # Samba automatic dependency handling and project rules 2 2 3 import Build, os, sys, re, Environment, Logs, time 4 from samba_utils import * 5 from samba_autoconf import * 3 import os, sys, re, time 4 5 import Build, Environment, Options, Logs, Utils 6 from Logs import debug 7 from Configure import conf 8 6 9 from samba_bundled import BUILTIN_LIBRARY 10 from samba_utils import LOCAL_CACHE, TO_LIST, get_tgt_list, unique_list, os_path_relpath 11 from samba_autoconf import library_flags 7 12 8 13 @conf … … 48 53 # module = rpc_epmapper (a module object within the dcerpc_server subsystem) 49 54 50 subsystem = bld. name_to_obj(subsystem_name, bld.env)55 subsystem = bld.get_tgen_by_name(subsystem_name) 51 56 bld.ASSERT(subsystem is not None, "Unable to find subsystem %s" % subsystem_name) 52 57 for d in subsystem_list[subsystem_name]: … … 81 86 libs = self.final_syslibs.copy() 82 87 83 (ccflags, ldflags ) = library_flags(self, list(libs))88 (ccflags, ldflags, cpppath) = library_flags(self, list(libs)) 84 89 new_ldflags = getattr(self, 'samba_ldflags', [])[:] 85 90 new_ldflags.extend(ldflags) … … 89 94 for f in self.env.undefined_ldflags: 90 95 self.ldflags.remove(f) 96 97 if getattr(self, 'allow_undefined_symbols', False) and self.env.undefined_ignore_ldflags: 98 for f in self.env.undefined_ignore_ldflags: 99 self.ldflags.append(f) 91 100 92 101 debug('deps: computed dependencies for target %s: uselib=%s uselib_local=%s add_objects=%s', … … 98 107 self.uselib.extend(list(self.direct_syslibs)) 99 108 for lib in self.final_libs: 100 t = self.bld. name_to_obj(lib, self.bld.env)109 t = self.bld.get_tgen_by_name(lib) 101 110 self.uselib.extend(list(t.final_syslibs)) 102 111 self.uselib = unique_list(self.uselib) … … 133 142 134 143 # maybe add local includes 135 if getattr(self, 'local_include', True) == Trueand getattr(self, 'local_include_first', True):144 if getattr(self, 'local_include', True) and getattr(self, 'local_include_first', True): 136 145 includes.append('.') 137 146 … … 147 156 148 157 for d in inc_deps: 149 t = bld. name_to_obj(d, bld.env)158 t = bld.get_tgen_by_name(d) 150 159 bld.ASSERT(t is not None, "Unable to find dependency %s for %s" % (d, self.sname)) 151 160 inclist = getattr(t, 'samba_includes_extended', [])[:] 152 if getattr(t, 'local_include', True) == True:161 if getattr(t, 'local_include', True): 153 162 inclist.append('.') 154 163 if inclist == []: … … 166 175 includes.append(relpath) 167 176 168 if getattr(self, 'local_include', True) == Trueand not getattr(self, 'local_include_first', True):177 if getattr(self, 'local_include', True) and not getattr(self, 'local_include_first', True): 169 178 includes.append('.') 170 179 … … 187 196 188 197 189 190 191 198 def add_init_functions(self): 192 199 '''This builds the right set of init functions''' … … 213 220 modules.append(m) 214 221 215 sentinal = getattr(self, 'init_function_sentinal', 'NULL') 222 if 'pyembed' in self.features: 223 return 224 225 sentinel = getattr(self, 'init_function_sentinel', 'NULL') 216 226 217 227 targets = LOCAL_CACHE(bld, 'TARGET_TYPE') … … 221 231 sname = sname.replace('-','_') 222 232 sname = sname.replace('/','_') 223 cflags.append('-DSTATIC_%s_MODULES=%s' % (sname, sentinal)) 224 if sentinal == 'NULL': 225 cflags.append('-DSTATIC_%s_MODULES_PROTO' % sname) 233 cflags.append('-DSTATIC_%s_MODULES=%s' % (sname, sentinel)) 234 if sentinel == 'NULL': 235 proto = "extern void __%s_dummy_module_proto(void)" % (sname) 236 cflags.append('-DSTATIC_%s_MODULES_PROTO=%s' % (sname, proto)) 226 237 self.ccflags = cflags 227 238 return … … 235 246 init_fn_list.append(d['INIT_FUNCTION']) 236 247 if init_fn_list == []: 237 cflags.append('-DSTATIC_%s_MODULES=%s' % (m, sentinal)) 238 if sentinal == 'NULL': 239 cflags.append('-DSTATIC_%s_MODULES_PROTO' % m) 248 cflags.append('-DSTATIC_%s_MODULES=%s' % (m, sentinel)) 249 if sentinel == 'NULL': 250 proto = "extern void __%s_dummy_module_proto(void)" % (m) 251 cflags.append('-DSTATIC_%s_MODULES_PROTO=%s' % (m, proto)) 240 252 else: 241 cflags.append('-DSTATIC_%s_MODULES=%s' % (m, ','.join(init_fn_list) + ',' + sentin al))253 cflags.append('-DSTATIC_%s_MODULES=%s' % (m, ','.join(init_fn_list) + ',' + sentinel)) 242 254 proto='' 243 255 for f in init_fn_list: 244 proto = proto + '_MODULE_PROTO(%s)' % f 256 proto += '_MODULE_PROTO(%s)' % f 257 proto += "extern void __%s_dummy_module_proto(void)" % (m) 245 258 cflags.append('-DSTATIC_%s_MODULES_PROTO=%s' % (m, proto)) 246 259 self.ccflags = cflags 247 260 248 261 249 250 262 def check_duplicate_sources(bld, tgt_list): 251 '''see if we are compiling the same source file more than once 252 without an allow_duplicates attribute''' 263 '''see if we are compiling the same source file more than once''' 253 264 254 265 debug('deps: checking for duplicate sources') 255 256 266 targets = LOCAL_CACHE(bld, 'TARGET_TYPE') 257 ret = True258 259 global tstart260 267 261 268 for t in tgt_list: … … 275 282 # build a list of targets that each source file is part of 276 283 for t in tgt_list: 277 sources = []278 284 if not targets[t.sname] in [ 'LIBRARY', 'BINARY', 'PYTHON' ]: 279 285 continue 280 286 for obj in t.add_objects: 281 t2 = t.bld. name_to_obj(obj, bld.env)287 t2 = t.bld.get_tgen_by_name(obj) 282 288 source_set = getattr(t2, 'samba_source_set', set()) 283 289 for s in source_set: … … 294 300 if len(subsystems[s][tname]) > 1: 295 301 raise Utils.WafError("ERROR: source %s is in more than one subsystem of target '%s': %s" % (s, tname, subsystems[s][tname])) 296 297 return ret 298 299 300 def check_orpaned_targets(bld, tgt_list): 301 '''check if any build targets are orphaned''' 302 303 target_dict = LOCAL_CACHE(bld, 'TARGET_TYPE') 304 305 debug('deps: checking for orphaned targets') 306 307 for t in tgt_list: 308 if getattr(t, 'samba_used', False) == True: 309 continue 310 type = target_dict[t.sname] 311 if not type in ['BINARY', 'LIBRARY', 'MODULE', 'ET', 'PYTHON']: 312 if re.search('^PIDL_', t.sname) is None: 313 Logs.warn("Target %s of type %s is unused by any other target" % (t.sname, type)) 314 302 303 return True 315 304 316 305 def check_group_ordering(bld, tgt_list): … … 343 332 tdeps = getattr(t, 'add_objects', []) + getattr(t, 'uselib_local', []) 344 333 for d in tdeps: 345 t2 = bld. name_to_obj(d, bld.env)334 t2 = bld.get_tgen_by_name(d) 346 335 if t2 is None: 347 336 continue … … 355 344 356 345 return ret 357 346 Build.BuildContext.check_group_ordering = check_group_ordering 358 347 359 348 def show_final_deps(bld, tgt_list): … … 426 415 global_deps_exclude = set() 427 416 for dep in global_deps: 428 t = bld. name_to_obj(dep, bld.env)417 t = bld.get_tgen_by_name(dep) 429 418 for d in t.samba_deps: 430 419 # prevent loops from the global dependencies list … … 466 455 sys.exit(1) 467 456 continue 468 t2 = bld. name_to_obj(d, bld.env)457 t2 = bld.get_tgen_by_name(d) 469 458 if t2 is None: 470 459 Logs.error("no task %s of type %s in %s" % (d, targets[d], t.sname)) … … 504 493 continue 505 494 chain.add(obj) 506 t2 = bld. name_to_obj(obj, bld.env)495 t2 = bld.get_tgen_by_name(obj) 507 496 r2 = indirect_libs(bld, t2, chain, loops) 508 497 chain.remove(obj) … … 515 504 continue 516 505 chain.add(obj) 517 t2 = bld. name_to_obj(obj, bld.env)506 t2 = bld.get_tgen_by_name(obj) 518 507 r2 = indirect_libs(bld, t2, chain, loops) 519 508 chain.remove(obj) … … 542 531 continue 543 532 chain.add(lib) 544 t2 = bld. name_to_obj(lib, bld.env)533 t2 = bld.get_tgen_by_name(lib) 545 534 r2 = indirect_objects(bld, t2, chain, loops) 546 535 chain.remove(lib) … … 570 559 if lib in chain: 571 560 continue 572 t2 = bld. name_to_obj(lib, bld.env)561 t2 = bld.get_tgen_by_name(lib) 573 562 chain.add(lib) 574 563 r2 = extended_objects(bld, t2, chain) … … 598 587 continue 599 588 chain.add(obj) 600 t2 = bld. name_to_obj(obj, bld.env)589 t2 = bld.get_tgen_by_name(obj) 601 590 r2 = includes_objects(bld, t2, chain, inc_loops) 602 591 chain.remove(obj) … … 609 598 continue 610 599 chain.add(lib) 611 t2 = bld. name_to_obj(lib, bld.env)600 t2 = bld.get_tgen_by_name(lib) 612 601 if t2 is None: 613 602 targets = LOCAL_CACHE(bld, 'TARGET_TYPE') … … 662 651 # expand indirect subsystem and library loops 663 652 for loop in loops.copy(): 664 t = bld. name_to_obj(loop, bld.env)653 t = bld.get_tgen_by_name(loop) 665 654 if t.samba_type in ['SUBSYSTEM']: 666 655 loops[loop] = loops[loop].union(t.indirect_objects) … … 674 663 # expand indirect includes loops 675 664 for loop in inc_loops.copy(): 676 t = bld. name_to_obj(loop, bld.env)665 t = bld.get_tgen_by_name(loop) 677 666 inc_loops[loop] = inc_loops[loop].union(t.includes_objects) 678 667 if loop in inc_loops[loop]: … … 720 709 new = t.final_objects.copy() 721 710 for l in t.final_libs: 722 t2 = bld. name_to_obj(l, bld.env)711 t2 = bld.get_tgen_by_name(l) 723 712 t2_obj = extended_objects(bld, t2, set()) 724 713 dup = new.intersection(t2_obj) … … 740 729 # add back in any objects that were relied upon by the reduction rules 741 730 for r in rely_on: 742 t = bld. name_to_obj(r, bld.env)731 t = bld.get_tgen_by_name(r) 743 732 t.final_objects = t.final_objects.union(rely_on[r]) 744 733 … … 749 738 '''show the detailed path of a library loop between lib1 and lib2''' 750 739 751 t = bld. name_to_obj(lib1, bld.env)740 t = bld.get_tgen_by_name(lib1) 752 741 if not lib2 in getattr(t, 'final_libs', set()): 753 742 return … … 788 777 for l in t.final_libs: 789 778 objname = l + '.objlist' 790 t2 = bld. name_to_obj(objname, bld.env)779 t2 = bld.get_tgen_by_name(objname) 791 780 if t2 is None: 792 781 Logs.error('ERROR: subsystem %s not found' % objname) … … 804 793 else: 805 794 continue 806 t2 = bld. name_to_obj(objname, bld.env)795 t2 = bld.get_tgen_by_name(objname) 807 796 if t2 is None: 808 797 Logs.error('ERROR: subsystem %s not found' % objname) … … 816 805 if t.samba_type in ['LIBRARY', 'PYTHON']: 817 806 for l in t.final_libs.copy(): 818 t2 = bld. name_to_obj(l, bld.env)807 t2 = bld.get_tgen_by_name(l) 819 808 if t.sname in t2.final_libs: 820 809 if getattr(bld.env, "ALLOW_CIRCULAR_LIB_DEPENDENCIES", False): … … 850 839 # make sure we don't recreate the loop again! 851 840 for d in diff.copy(): 852 t2 = bld. name_to_obj(d, bld.env)841 t2 = bld.get_tgen_by_name(d) 853 842 if t2.samba_type == 'LIBRARY': 854 843 if t.sname in t2.final_libs: … … 875 864 syslibs = set() 876 865 for d in t.final_objects: 877 t2 = bld. name_to_obj(d, bld.env)866 t2 = bld.get_tgen_by_name(d) 878 867 syslibs = syslibs.union(t2.direct_syslibs) 879 868 # this adds the indirect syslibs as well, which may not be needed 880 869 # depending on the linker flags 881 870 for d in t.final_libs: 882 t2 = bld. name_to_obj(d, bld.env)871 t2 = bld.get_tgen_by_name(d) 883 872 syslibs = syslibs.union(t2.direct_syslibs) 884 873 t.final_syslibs = syslibs … … 890 879 if t.samba_type in ['LIBRARY', 'PYTHON']: 891 880 for l in t.final_libs.copy(): 892 t2 = bld. name_to_obj(l, bld.env)881 t2 = bld.get_tgen_by_name(l) 893 882 if t.sname in t2.final_libs: 894 883 Logs.error('ERROR: Unresolved library loop %s from %s' % (t.sname, t2.sname)) … … 906 895 return 907 896 908 t = bld. name_to_obj(target, bld.env)897 t = bld.get_tgen_by_name(target) 909 898 if t is None: 910 899 Logs.error("ERROR: Unable to find target '%s'" % target) … … 935 924 continue 936 925 for n in getattr(t, 'final_objects', set()): 937 t2 = bld. name_to_obj(n, bld.env)926 t2 = bld.get_tgen_by_name(n) 938 927 if not n in used_by: 939 928 used_by[n] = set() … … 961 950 'source', 'grouping_library', 'samba_ldflags', 'allow_undefined_symbols', 962 951 'use_global_deps', 'global_include' ] 963 savedeps_outputs = ['uselib', 'uselib_local', 'add_objects', 'includes', 'ccflags', 'ldflags', 'samba_deps_extended'] 952 savedeps_outputs = ['uselib', 'uselib_local', 'add_objects', 'includes', 953 'ccflags', 'ldflags', 'samba_deps_extended', 'final_libs'] 964 954 savedeps_outenv = ['INC_PATHS'] 965 955 savedeps_envvars = ['NONSHARED_BINARIES', 'GLOBAL_DEPENDENCIES', 'EXTRA_CFLAGS', 'EXTRA_LDFLAGS', 'EXTRA_INCLUDES' ] … … 1018 1008 1019 1009 depsfile = os.path.join(bld.bdir, "sambadeps") 1020 denv.store (depsfile)1010 denv.store_fast(depsfile) 1021 1011 1022 1012 … … 1028 1018 try: 1029 1019 debug('deps: checking saved dependencies') 1030 denv.load (depsfile)1020 denv.load_fast(depsfile) 1031 1021 if (denv.version != savedeps_version or 1032 1022 denv.savedeps_inputs != savedeps_inputs or 1033 1023 denv.savedeps_outputs != savedeps_outputs): 1034 1024 return False 1035 except :1025 except Exception: 1036 1026 return False 1037 1027 … … 1145 1135 debug('deps: project rules stage1 completed') 1146 1136 1147 #check_orpaned_targets(bld, tgt_list)1148 1149 1137 if not check_duplicate_sources(bld, tgt_list): 1150 1138 Logs.error("Duplicate sources present - aborting") … … 1153 1141 debug("deps: check_duplicate_sources: %f" % (time.clock() - tstart)) 1154 1142 1155 if not check_group_ordering(bld,tgt_list):1143 if not bld.check_group_ordering(tgt_list): 1156 1144 Logs.error("Bad group ordering - aborting") 1157 1145 sys.exit(1) -
vendor/current/buildtools/wafsamba/samba_dist.py
r740 r988 2 2 # uses git ls-files to get file lists 3 3 4 import Utils, os, sys, tarfile, stat, Scripting, Logs, Options 5 from samba_utils import * 4 import os, sys, tarfile 5 import Utils, Scripting, Logs, Options 6 from Configure import conf 7 from samba_utils import os_path_relpath 6 8 7 9 dist_dirs = None 10 dist_files = None 8 11 dist_blacklist = "" 9 12 … … 86 89 env["GIT_DIR"] = os.path.join(repo, ".git") 87 90 break 88 elif os.path.isdir(os.path.join(repo, ".bzr")):89 ls_files_cmd = [ 'bzr', 'ls', '--recursive', '--versioned',90 os_path_relpath(path, repo)]91 cwd = repo92 env = None93 break94 91 repo = os.path.dirname(repo) 95 92 if repo == "/": … … 98 95 99 96 100 def dist(appname='',version=''): 97 def dist(appname='', version=''): 98 99 def add_files_to_tarball(tar, srcdir, srcsubdir, dstdir, dstsubdir, blacklist, files): 100 if blacklist is None: 101 blacklist = [] 102 for f in files: 103 abspath = os.path.join(srcdir, f) 104 105 if srcsubdir != '.': 106 f = f[len(srcsubdir)+1:] 107 108 # Remove files in the blacklist 109 if f in blacklist: 110 continue 111 blacklisted = False 112 # Remove directories in the blacklist 113 for d in blacklist: 114 if f.startswith(d): 115 blacklisted = True 116 if blacklisted: 117 continue 118 if os.path.isdir(abspath): 119 continue 120 if dstsubdir != '.': 121 f = dstsubdir + '/' + f 122 fname = dstdir + '/' + f 123 add_tarfile(tar, fname, abspath, srcsubdir) 124 125 126 def list_directory_files(path): 127 curdir = os.getcwd() 128 os.chdir(srcdir) 129 out_files = [] 130 for root, dirs, files in os.walk(path): 131 for f in files: 132 out_files.append(os.path.join(root, f)) 133 os.chdir(curdir) 134 return out_files 135 136 101 137 if not isinstance(appname, str) or not appname: 102 138 # this copes with a mismatch in the calling arguments for dist() … … 135 171 Logs.error('unable to get contents of %s: %s' % (absdir, e)) 136 172 sys.exit(1) 137 for f in files: 138 abspath = os.path.join(srcdir, f) 139 140 if dir != '.': 141 f = f[len(dir)+1:] 142 143 # Remove files in the blacklist 144 if f in dist_blacklist: 145 continue 146 blacklisted = False 147 # Remove directories in the blacklist 148 for d in blacklist: 149 if f.startswith(d): 150 blacklisted = True 151 if blacklisted: 152 continue 153 if os.path.isdir(abspath): 154 continue 155 if destdir != '.': 156 f = destdir + '/' + f 157 fname = dist_base + '/' + f 158 add_tarfile(tar, fname, abspath, dir) 173 add_files_to_tarball(tar, srcdir, dir, dist_base, destdir, blacklist, files) 174 175 if dist_files: 176 for file in dist_files.split(): 177 if file.find(':') != -1: 178 destfile = file.split(':')[1] 179 file = file.split(':')[0] 180 else: 181 destfile = file 182 183 absfile = os.path.join(srcdir, file) 184 185 if os.path.isdir(absfile): 186 destdir = destfile 187 dir = file 188 files = list_directory_files(dir) 189 add_files_to_tarball(tar, srcdir, dir, dist_base, destdir, blacklist, files) 190 else: 191 fname = dist_base + '/' + destfile 192 add_tarfile(tar, fname, absfile, destfile) 159 193 160 194 tar.close() … … 196 230 197 231 @conf 232 def DIST_FILES(files, extend=False): 233 '''set additional files for packaging, relative to top srcdir''' 234 global dist_files 235 if not dist_files: 236 dist_files = files 237 elif extend: 238 dist_files = dist_files + " " + files 239 240 @conf 198 241 def DIST_BLACKLIST(blacklist): 199 242 '''set the files to exclude from packaging, relative to top srcdir''' -
vendor/current/buildtools/wafsamba/samba_headers.py
r740 r988 1 1 # specialist handling of header files for Samba 2 2 3 import Build, re, Task, TaskGen, shutil, sys, Logs 4 from samba_utils import * 3 import os, re, sys, fnmatch 4 import Build, Logs, Utils 5 from samba_utils import TO_LIST, os_path_relpath 5 6 6 7 … … 120 121 inst_name = os.path.basename(h) 121 122 bld.INSTALL_FILES('${INCLUDEDIR}', h_name, destname=inst_name) 122 123 123 124 124 -
vendor/current/buildtools/wafsamba/samba_install.py
r740 r988 4 4 # library use 5 5 6 import Options 6 import os 7 import Utils 7 8 from TaskGen import feature, before, after 8 from samba_utils import *9 from samba_utils import LIB_PATH, MODE_755, install_rpath, build_rpath 9 10 10 11 @feature('install_bin') … … 19 20 build_ldflags = build_rpath(bld) 20 21 21 if not Options.is_install:22 if not self.bld.is_install: 22 23 # just need to set rpath if we are not installing 23 24 self.env.RPATH = build_ldflags … … 60 61 bld = self.bld 61 62 62 install_ldflags = install_rpath(self) 63 build_ldflags = build_rpath(bld) 64 65 if not Options.is_install or not getattr(self, 'samba_install', True): 66 # just need to set the build rpath if we are not installing 67 self.env.RPATH = build_ldflags 68 return 69 70 # setup the install path, expanding variables 71 install_path = getattr(self, 'samba_inst_path', None) 72 if install_path is None: 73 if getattr(self, 'private_library', False): 74 install_path = '${PRIVATELIBDIR}' 63 default_env = bld.all_envs['default'] 64 try: 65 if self.env['IS_EXTRA_PYTHON']: 66 bld.all_envs['default'] = bld.all_envs['extrapython'] 67 68 install_ldflags = install_rpath(self) 69 build_ldflags = build_rpath(bld) 70 71 if not self.bld.is_install or not getattr(self, 'samba_install', True): 72 # just need to set the build rpath if we are not installing 73 self.env.RPATH = build_ldflags 74 return 75 76 # setup the install path, expanding variables 77 install_path = getattr(self, 'samba_inst_path', None) 78 if install_path is None: 79 if getattr(self, 'private_library', False): 80 install_path = '${PRIVATELIBDIR}' 81 else: 82 install_path = '${LIBDIR}' 83 install_path = bld.EXPAND_VARIABLES(install_path) 84 85 target_name = self.target 86 87 if install_ldflags != build_ldflags: 88 # we will be creating a new target name, and using that for the 89 # install link. That stops us from overwriting the existing build 90 # target, which has different ldflags 91 self.done_install_library = True 92 t = self.clone(self.env) 93 t.posted = False 94 t.target += '.inst' 95 t.name = self.name + '.inst' 96 self.env.RPATH = build_ldflags 75 97 else: 76 install_path = '${LIBDIR}' 77 install_path = bld.EXPAND_VARIABLES(install_path) 78 79 target_name = self.target 80 81 if install_ldflags != build_ldflags: 82 # we will be creating a new target name, and using that for the 83 # install link. That stops us from overwriting the existing build 84 # target, which has different ldflags 85 self.done_install_library = True 86 t = self.clone('default') 87 t.posted = False 88 t.target += '.inst' 89 self.env.RPATH = build_ldflags 90 else: 91 t = self 92 93 t.env.RPATH = install_ldflags 94 95 dev_link = None 96 97 # in the following the names are: 98 # - inst_name is the name with .inst. in it, in the build 99 # directory 100 # - install_name is the name in the install directory 101 # - install_link is a symlink in the install directory, to install_name 102 103 if getattr(self, 'samba_realname', None): 104 install_name = self.samba_realname 105 install_link = None 106 if getattr(self, 'samba_type', None) == 'PYTHON': 107 inst_name = bld.make_libname(t.target, nolibprefix=True, python=True) 98 t = self 99 100 t.env.RPATH = install_ldflags 101 102 dev_link = None 103 104 # in the following the names are: 105 # - inst_name is the name with .inst. in it, in the build 106 # directory 107 # - install_name is the name in the install directory 108 # - install_link is a symlink in the install directory, to install_name 109 110 if getattr(self, 'samba_realname', None): 111 install_name = self.samba_realname 112 install_link = None 113 if getattr(self, 'soname', ''): 114 install_link = self.soname 115 if getattr(self, 'samba_type', None) == 'PYTHON': 116 inst_name = bld.make_libname(t.target, nolibprefix=True, python=True) 117 else: 118 inst_name = bld.make_libname(t.target) 119 elif self.vnum: 120 vnum_base = self.vnum.split('.')[0] 121 install_name = bld.make_libname(target_name, version=self.vnum) 122 install_link = bld.make_libname(target_name, version=vnum_base) 123 inst_name = bld.make_libname(t.target) 124 if not self.private_library: 125 # only generate the dev link for non-bundled libs 126 dev_link = bld.make_libname(target_name) 127 elif getattr(self, 'soname', ''): 128 install_name = bld.make_libname(target_name) 129 install_link = self.soname 130 inst_name = bld.make_libname(t.target) 108 131 else: 132 install_name = bld.make_libname(target_name) 133 install_link = None 109 134 inst_name = bld.make_libname(t.target) 110 elif self.vnum: 111 vnum_base = self.vnum.split('.')[0] 112 install_name = bld.make_libname(target_name, version=self.vnum) 113 install_link = bld.make_libname(target_name, version=vnum_base) 114 inst_name = bld.make_libname(t.target) 115 if not self.private_library: 116 # only generate the dev link for non-bundled libs 117 dev_link = bld.make_libname(target_name) 118 elif getattr(self, 'soname', ''): 119 install_name = bld.make_libname(target_name) 120 install_link = self.soname 121 inst_name = bld.make_libname(t.target) 122 else: 123 install_name = bld.make_libname(target_name) 124 install_link = None 125 inst_name = bld.make_libname(t.target) 126 127 if t.env.SONAME_ST: 128 # ensure we get the right names in the library 129 if install_link: 130 t.env.append_value('LINKFLAGS', t.env.SONAME_ST % install_link) 131 else: 132 t.env.append_value('LINKFLAGS', t.env.SONAME_ST % install_name) 133 t.env.SONAME_ST = '' 134 135 # tell waf to install the library 136 bld.install_as(os.path.join(install_path, install_name), 137 os.path.join(self.path.abspath(bld.env), inst_name)) 138 if install_link and install_link != install_name: 139 # and the symlink if needed 140 bld.symlink_as(os.path.join(install_path, install_link), install_name) 141 if dev_link: 142 bld.symlink_as(os.path.join(install_path, dev_link), install_name) 135 136 if t.env.SONAME_ST: 137 # ensure we get the right names in the library 138 if install_link: 139 t.env.append_value('LINKFLAGS', t.env.SONAME_ST % install_link) 140 else: 141 t.env.append_value('LINKFLAGS', t.env.SONAME_ST % install_name) 142 t.env.SONAME_ST = '' 143 144 # tell waf to install the library 145 bld.install_as(os.path.join(install_path, install_name), 146 os.path.join(self.path.abspath(bld.env), inst_name), 147 chmod=MODE_755) 148 if install_link and install_link != install_name: 149 # and the symlink if needed 150 bld.symlink_as(os.path.join(install_path, install_link), os.path.basename(install_name)) 151 if dev_link: 152 bld.symlink_as(os.path.join(install_path, dev_link), os.path.basename(install_name)) 153 finally: 154 bld.all_envs['default'] = default_env 143 155 144 156 … … 215 227 return 216 228 217 blddir = os.path.dirname(self.bld.srcnode.abspath(self.bld.env))218 229 if not self.link_task.outputs or not self.link_task.outputs[0]: 219 230 raise Utils.WafError('no outputs found for %s in symlink_bin' % self.name) -
vendor/current/buildtools/wafsamba/samba_optimisation.py
r740 r988 7 7 # overall this makes some build tasks quite a bit faster 8 8 9 from TaskGen import feature, after 10 import preproc, Task 11 12 @feature('cc', 'cxx') 9 import os 10 import Build, Utils, Node 11 from TaskGen import feature, after, before 12 import preproc 13 14 @feature('c', 'cc', 'cxx') 13 15 @after('apply_type_vars', 'apply_lib_vars', 'apply_core') 14 16 def apply_incpaths(self): 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 if preproc.go_absolute or path[0] != '/': #os.path.isabs(path):35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 @feature('c c')17 lst = [] 18 19 try: 20 kak = self.bld.kak 21 except AttributeError: 22 kak = self.bld.kak = {} 23 24 # TODO move the uselib processing out of here 25 for lib in self.to_list(self.uselib): 26 for path in self.env['CPPPATH_' + lib]: 27 if not path in lst: 28 lst.append(path) 29 if preproc.go_absolute: 30 for path in preproc.standard_includes: 31 if not path in lst: 32 lst.append(path) 33 34 for path in self.to_list(self.includes): 35 if not path in lst: 36 if preproc.go_absolute or path[0] != '/': # os.path.isabs(path): 37 lst.append(path) 38 else: 39 self.env.prepend_value('CPPPATH', path) 40 41 for path in lst: 42 node = None 43 if path[0] == '/': # os.path.isabs(path): 44 if preproc.go_absolute: 45 node = self.bld.root.find_dir(path) 46 elif path[0] == '#': 47 node = self.bld.srcnode 48 if len(path) > 1: 49 try: 50 node = kak[path] 51 except KeyError: 52 kak[path] = node = node.find_dir(path[1:]) 53 else: 54 try: 55 node = kak[(self.path.id, path)] 56 except KeyError: 57 kak[(self.path.id, path)] = node = self.path.find_dir(path) 58 59 if node: 60 self.env.append_value('INC_PATHS', node) 61 62 @feature('c', 'cc') 61 63 @after('apply_incpaths') 62 64 def apply_obj_vars_cc(self): … … 92 94 93 95 def vari(self): 94 96 return "default" 95 97 Environment.Environment.variant = vari 96 98 97 99 def variant(self, env): 98 99 100 100 if not env: return 0 101 elif self.id & 3 == Node.FILE: return 0 102 else: return "default" 101 103 Node.Node.variant = variant 102 104 … … 114 116 115 117 def hash_constraints(self): 116 117 118 a = self.attr 119 sum = hash((str(a('before', '')), 118 120 str(a('after', '')), 119 121 str(a('ext_in', '')), 120 122 str(a('ext_out', '')), 121 123 self.__class__.maxjobs)) 122 124 return sum 123 125 Task.TaskBase.hash_constraints = hash_constraints 124 126 125 126 # import cc 127 # from TaskGen import extension 128 # import Utils 129 130 # @extension(cc.EXT_CC) 131 # def c_hook(self, node): 132 # task = self.create_task('cc', node, node.change_ext('.o')) 133 # try: 134 # self.compiled_tasks.append(task) 135 # except AttributeError: 136 # raise Utils.WafError('Have you forgotten to set the feature "cc" on %s?' % str(self)) 137 138 # bld = self.bld 139 # try: 140 # dc = bld.dc 141 # except AttributeError: 142 # dc = bld.dc = {} 143 144 # if task.outputs[0].id in dc: 145 # raise Utils.WafError('Samba, you are doing it wrong %r %s %s' % (task.outputs, task.generator, dc[task.outputs[0].id].generator)) 146 # else: 147 # dc[task.outputs[0].id] = task 148 149 # return task 150 151 152 def suncc_wrap(cls): 153 '''work around a problem with cc on solaris not handling module aliases 154 which have empty libs''' 155 if getattr(cls, 'solaris_wrap', False): 156 return 157 cls.solaris_wrap = True 158 oldrun = cls.run 159 def run(self): 160 if self.env.CC_NAME == "sun" and not self.inputs: 161 self.env = self.env.copy() 162 self.env.append_value('LINKFLAGS', '-') 163 return oldrun(self) 164 cls.run = run 165 suncc_wrap(Task.TaskBase.classes['cc_link']) 127 def hash_env_vars(self, env, vars_lst): 128 idx = str(id(env)) + str(vars_lst) 129 try: 130 return self.cache_sig_vars[idx] 131 except KeyError: 132 pass 133 134 m = Utils.md5() 135 m.update(''.join([str(env[a]) for a in vars_lst])) 136 137 ret = self.cache_sig_vars[idx] = m.digest() 138 return ret 139 Build.BuildContext.hash_env_vars = hash_env_vars 140 141 142 def store_fast(self, filename): 143 file = open(filename, 'wb') 144 data = self.get_merged_dict() 145 try: 146 Build.cPickle.dump(data, file, -1) 147 finally: 148 file.close() 149 Environment.Environment.store_fast = store_fast 150 151 def load_fast(self, filename): 152 file = open(filename, 'rb') 153 try: 154 data = Build.cPickle.load(file) 155 finally: 156 file.close() 157 self.table.update(data) 158 Environment.Environment.load_fast = load_fast 159 160 def is_this_a_static_lib(self, name): 161 try: 162 cache = self.cache_is_this_a_static_lib 163 except AttributeError: 164 cache = self.cache_is_this_a_static_lib = {} 165 try: 166 return cache[name] 167 except KeyError: 168 ret = cache[name] = 'cstaticlib' in self.bld.get_tgen_by_name(name).features 169 return ret 170 TaskGen.task_gen.is_this_a_static_lib = is_this_a_static_lib 171 172 def shared_ancestors(self): 173 try: 174 cache = self.cache_is_this_a_static_lib 175 except AttributeError: 176 cache = self.cache_is_this_a_static_lib = {} 177 try: 178 return cache[id(self)] 179 except KeyError: 180 181 ret = [] 182 if 'cshlib' in self.features: # or 'cprogram' in self.features: 183 if getattr(self, 'uselib_local', None): 184 lst = self.to_list(self.uselib_local) 185 ret = [x for x in lst if not self.is_this_a_static_lib(x)] 186 cache[id(self)] = ret 187 return ret 188 TaskGen.task_gen.shared_ancestors = shared_ancestors 189 190 @feature('c', 'cc', 'cxx') 191 @after('apply_link', 'init_cc', 'init_cxx', 'apply_core') 192 def apply_lib_vars(self): 193 """after apply_link because of 'link_task' 194 after default_cc because of the attribute 'uselib'""" 195 196 # after 'apply_core' in case if 'cc' if there is no link 197 198 env = self.env 199 app = env.append_value 200 seen_libpaths = set([]) 201 202 # OPTIMIZATION 1: skip uselib variables already added (700ms) 203 seen_uselib = set([]) 204 205 # 1. the case of the libs defined in the project (visit ancestors first) 206 # the ancestors external libraries (uselib) will be prepended 207 self.uselib = self.to_list(self.uselib) 208 names = self.to_list(self.uselib_local) 209 210 seen = set([]) 211 tmp = Utils.deque(names) # consume a copy of the list of names 212 while tmp: 213 lib_name = tmp.popleft() 214 # visit dependencies only once 215 if lib_name in seen: 216 continue 217 218 y = self.get_tgen_by_name(lib_name) 219 if not y: 220 raise Utils.WafError('object %r was not found in uselib_local (required by %r)' % (lib_name, self.name)) 221 y.post() 222 seen.add(lib_name) 223 224 # OPTIMIZATION 2: pre-compute ancestors shared libraries (100ms) 225 tmp.extend(y.shared_ancestors()) 226 227 # link task and flags 228 if getattr(y, 'link_task', None): 229 230 link_name = y.target[y.target.rfind('/') + 1:] 231 if 'cstaticlib' in y.features: 232 app('STATICLIB', link_name) 233 elif 'cshlib' in y.features or 'cprogram' in y.features: 234 # WARNING some linkers can link against programs 235 app('LIB', link_name) 236 237 # the order 238 self.link_task.set_run_after(y.link_task) 239 240 # for the recompilation 241 dep_nodes = getattr(self.link_task, 'dep_nodes', []) 242 self.link_task.dep_nodes = dep_nodes + y.link_task.outputs 243 244 # OPTIMIZATION 3: reduce the amount of function calls 245 # add the link path too 246 par = y.link_task.outputs[0].parent 247 if id(par) not in seen_libpaths: 248 seen_libpaths.add(id(par)) 249 tmp_path = par.bldpath(self.env) 250 if not tmp_path in env['LIBPATH']: 251 env.prepend_value('LIBPATH', tmp_path) 252 253 254 # add ancestors uselib too - but only propagate those that have no staticlib 255 for v in self.to_list(y.uselib): 256 if v not in seen_uselib: 257 seen_uselib.add(v) 258 if not env['STATICLIB_' + v]: 259 if not v in self.uselib: 260 self.uselib.insert(0, v) 261 262 # 2. the case of the libs defined outside 263 for x in self.uselib: 264 for v in self.p_flag_vars: 265 val = self.env[v + '_' + x] 266 if val: 267 self.env.append_value(v, val) 268 269 -
vendor/current/buildtools/wafsamba/samba_patterns.py
r740 r988 1 1 # a waf tool to add extension based build patterns for Samba 2 2 3 import Task 4 from TaskGen import extension 5 from samba_utils import * 3 import Build 6 4 from wafsamba import samba_version_file 7 5 … … 9 7 '''print version.h contents''' 10 8 src = task.inputs[0].srcpath(task.env) 11 tgt = task.outputs[0].bldpath(task.env) 12 13 version = samba_version_file(src, task.env.srcdir, env=task.env) 9 10 version = samba_version_file(src, task.env.srcdir, env=task.env, is_install=task.generator.bld.is_install) 14 11 string = str(version) 15 12 16 f = open(tgt, 'w') 17 s = f.write(string) 18 f.close() 13 task.outputs[0].write(string) 19 14 return 0 20 15 … … 22 17 def SAMBA_MKVERSION(bld, target): 23 18 '''generate the version.h header for Samba''' 24 t = bld.SAMBA_GENERATOR('VERSION', 19 20 # We only force waf to re-generate this file if we are installing, 21 # because only then is information not included in the deps (the 22 # git revision) included in the version. 23 t = bld.SAMBA_GENERATOR('VERSION', 25 24 rule=write_version_header, 26 25 source= 'VERSION', 27 26 target=target, 28 always= True)27 always=bld.is_install) 29 28 Build.BuildContext.SAMBA_MKVERSION = SAMBA_MKVERSION 29 30 31 def write_build_options_header(fp): 32 '''write preamble for build_options.c''' 33 fp.write("/*\n") 34 fp.write(" Unix SMB/CIFS implementation.\n") 35 fp.write(" Build Options for Samba Suite\n") 36 fp.write(" Copyright (C) Vance Lankhaar <vlankhaar@linux.ca> 2003\n") 37 fp.write(" Copyright (C) Andrew Bartlett <abartlet@samba.org> 2001\n") 38 fp.write("\n") 39 fp.write(" This program is free software; you can redistribute it and/or modify\n") 40 fp.write(" it under the terms of the GNU General Public License as published by\n") 41 fp.write(" the Free Software Foundation; either version 3 of the License, or\n") 42 fp.write(" (at your option) any later version.\n") 43 fp.write("\n") 44 fp.write(" This program is distributed in the hope that it will be useful,\n") 45 fp.write(" but WITHOUT ANY WARRANTY; without even the implied warranty of\n") 46 fp.write(" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n") 47 fp.write(" GNU General Public License for more details.\n") 48 fp.write("\n") 49 fp.write(" You should have received a copy of the GNU General Public License\n") 50 fp.write(" along with this program; if not, see <http://www.gnu.org/licenses/>.\n") 51 fp.write("*/\n") 52 fp.write("\n") 53 fp.write("#include \"includes.h\"\n") 54 fp.write("#include \"build_env.h\"\n") 55 fp.write("#include \"dynconfig/dynconfig.h\"\n") 56 fp.write("#include \"lib/cluster_support.h\"\n") 57 58 fp.write("\n") 59 fp.write("static int output(bool screen, const char *format, ...) PRINTF_ATTRIBUTE(2,3);\n") 60 fp.write("void build_options(bool screen);\n") 61 fp.write("\n") 62 fp.write("\n") 63 fp.write("/****************************************************************************\n") 64 fp.write("helper function for build_options\n") 65 fp.write("****************************************************************************/\n") 66 fp.write("static int output(bool screen, const char *format, ...)\n") 67 fp.write("{\n") 68 fp.write(" char *ptr = NULL;\n") 69 fp.write(" int ret = 0;\n") 70 fp.write(" va_list ap;\n") 71 fp.write(" \n") 72 fp.write(" va_start(ap, format);\n") 73 fp.write(" ret = vasprintf(&ptr,format,ap);\n") 74 fp.write(" va_end(ap);\n") 75 fp.write("\n") 76 fp.write(" if (screen) {\n") 77 fp.write(" d_printf(\"%s\", ptr ? ptr : \"\");\n") 78 fp.write(" } else {\n") 79 fp.write(" DEBUG(4,(\"%s\", ptr ? ptr : \"\"));\n") 80 fp.write(" }\n") 81 fp.write(" \n") 82 fp.write(" SAFE_FREE(ptr);\n") 83 fp.write(" return ret;\n") 84 fp.write("}\n") 85 fp.write("\n") 86 fp.write("/****************************************************************************\n") 87 fp.write("options set at build time for the samba suite\n") 88 fp.write("****************************************************************************/\n") 89 fp.write("void build_options(bool screen)\n") 90 fp.write("{\n") 91 fp.write(" if ((DEBUGLEVEL < 4) && (!screen)) {\n") 92 fp.write(" return;\n") 93 fp.write(" }\n") 94 fp.write("\n") 95 fp.write("#ifdef _BUILD_ENV_H\n") 96 fp.write(" /* Output information about the build environment */\n") 97 fp.write(" output(screen,\"Build environment:\\n\");\n") 98 fp.write(" output(screen,\" Built by: %s@%s\\n\",BUILD_ENV_USER,BUILD_ENV_HOST);\n") 99 fp.write(" output(screen,\" Built on: %s\\n\",BUILD_ENV_DATE);\n") 100 fp.write("\n") 101 fp.write(" output(screen,\" Built using: %s\\n\",BUILD_ENV_COMPILER);\n") 102 fp.write(" output(screen,\" Build host: %s\\n\",BUILD_ENV_UNAME);\n") 103 fp.write(" output(screen,\" SRCDIR: %s\\n\",BUILD_ENV_SRCDIR);\n") 104 fp.write(" output(screen,\" BUILDDIR: %s\\n\",BUILD_ENV_BUILDDIR);\n") 105 fp.write("\n") 106 fp.write("\n") 107 fp.write("#endif\n") 108 fp.write("\n") 109 fp.write(" /* Output various paths to files and directories */\n") 110 fp.write(" output(screen,\"\\nPaths:\\n\");\n") 111 fp.write(" output(screen,\" SBINDIR: %s\\n\", get_dyn_SBINDIR());\n") 112 fp.write(" output(screen,\" BINDIR: %s\\n\", get_dyn_BINDIR());\n") 113 fp.write(" output(screen,\" CONFIGFILE: %s\\n\", get_dyn_CONFIGFILE());\n") 114 fp.write(" output(screen,\" LOGFILEBASE: %s\\n\", get_dyn_LOGFILEBASE());\n") 115 fp.write(" output(screen,\" LMHOSTSFILE: %s\\n\",get_dyn_LMHOSTSFILE());\n") 116 fp.write(" output(screen,\" LIBDIR: %s\\n\",get_dyn_LIBDIR());\n") 117 fp.write(" output(screen,\" MODULESDIR: %s\\n\",get_dyn_MODULESDIR());\n") 118 fp.write(" output(screen,\" SHLIBEXT: %s\\n\",get_dyn_SHLIBEXT());\n") 119 fp.write(" output(screen,\" LOCKDIR: %s\\n\",get_dyn_LOCKDIR());\n") 120 fp.write(" output(screen,\" STATEDIR: %s\\n\",get_dyn_STATEDIR());\n") 121 fp.write(" output(screen,\" CACHEDIR: %s\\n\",get_dyn_CACHEDIR());\n") 122 fp.write(" output(screen,\" PIDDIR: %s\\n\", get_dyn_PIDDIR());\n") 123 fp.write(" output(screen,\" SMB_PASSWD_FILE: %s\\n\",get_dyn_SMB_PASSWD_FILE());\n") 124 fp.write(" output(screen,\" PRIVATE_DIR: %s\\n\",get_dyn_PRIVATE_DIR());\n") 125 fp.write("\n") 126 127 def write_build_options_footer(fp): 128 fp.write(" /* Output the sizes of the various cluster features */\n") 129 fp.write(" output(screen, \"\\n%s\", cluster_support_features());\n") 130 fp.write("\n") 131 fp.write(" /* Output the sizes of the various types */\n") 132 fp.write(" output(screen, \"\\nType sizes:\\n\");\n") 133 fp.write(" output(screen, \" sizeof(char): %lu\\n\",(unsigned long)sizeof(char));\n") 134 fp.write(" output(screen, \" sizeof(int): %lu\\n\",(unsigned long)sizeof(int));\n") 135 fp.write(" output(screen, \" sizeof(long): %lu\\n\",(unsigned long)sizeof(long));\n") 136 fp.write(" output(screen, \" sizeof(long long): %lu\\n\",(unsigned long)sizeof(long long));\n") 137 fp.write(" output(screen, \" sizeof(uint8_t): %lu\\n\",(unsigned long)sizeof(uint8_t));\n") 138 fp.write(" output(screen, \" sizeof(uint16_t): %lu\\n\",(unsigned long)sizeof(uint16_t));\n") 139 fp.write(" output(screen, \" sizeof(uint32_t): %lu\\n\",(unsigned long)sizeof(uint32_t));\n") 140 fp.write(" output(screen, \" sizeof(short): %lu\\n\",(unsigned long)sizeof(short));\n") 141 fp.write(" output(screen, \" sizeof(void*): %lu\\n\",(unsigned long)sizeof(void*));\n") 142 fp.write(" output(screen, \" sizeof(size_t): %lu\\n\",(unsigned long)sizeof(size_t));\n") 143 fp.write(" output(screen, \" sizeof(off_t): %lu\\n\",(unsigned long)sizeof(off_t));\n") 144 fp.write(" output(screen, \" sizeof(ino_t): %lu\\n\",(unsigned long)sizeof(ino_t));\n") 145 fp.write(" output(screen, \" sizeof(dev_t): %lu\\n\",(unsigned long)sizeof(dev_t));\n") 146 fp.write("\n") 147 fp.write(" output(screen, \"\\nBuiltin modules:\\n\");\n") 148 fp.write(" output(screen, \" %s\\n\", STRING_STATIC_MODULES);\n") 149 fp.write("}\n") 150 151 def write_build_options_section(fp, keys, section): 152 fp.write("\n\t/* Show %s */\n" % section) 153 fp.write(" output(screen, \"\\n%s:\\n\");\n\n" % section) 154 155 for k in sorted(keys): 156 fp.write("#ifdef %s\n" % k) 157 fp.write(" output(screen, \" %s\\n\");\n" % k) 158 fp.write("#endif\n") 159 fp.write("\n") 160 161 def write_build_options(task): 162 tbl = task.env['defines'] 163 keys_option_with = [] 164 keys_option_utmp = [] 165 keys_option_have = [] 166 keys_header_sys = [] 167 keys_header_other = [] 168 keys_misc = [] 169 for key in tbl: 170 if key.startswith("HAVE_UT_UT_") or key.find("UTMP") >= 0: 171 keys_option_utmp.append(key) 172 elif key.startswith("WITH_"): 173 keys_option_with.append(key) 174 elif key.startswith("HAVE_SYS_"): 175 keys_header_sys.append(key) 176 elif key.startswith("HAVE_"): 177 if key.endswith("_H"): 178 keys_header_other.append(key) 179 else: 180 keys_option_have.append(key) 181 else: 182 keys_misc.append(key) 183 184 tgt = task.outputs[0].bldpath(task.env) 185 f = open(tgt, 'w') 186 write_build_options_header(f) 187 write_build_options_section(f, keys_header_sys, "System Headers") 188 write_build_options_section(f, keys_header_other, "Headers") 189 write_build_options_section(f, keys_option_utmp, "UTMP Options") 190 write_build_options_section(f, keys_option_have, "HAVE_* Defines") 191 write_build_options_section(f, keys_option_with, "--with Options") 192 write_build_options_section(f, keys_misc, "Build Options") 193 write_build_options_footer(f) 194 f.close() 195 return 0 196 197 198 def SAMBA_BLDOPTIONS(bld, target): 199 '''generate the bld_options.c for Samba''' 200 t = bld.SAMBA_GENERATOR(target, 201 rule=write_build_options, 202 dep_vars=['defines'], 203 target=target) 204 Build.BuildContext.SAMBA_BLDOPTIONS = SAMBA_BLDOPTIONS -
vendor/current/buildtools/wafsamba/samba_pidl.py
r740 r988 1 1 # waf build tool for building IDL files with pidl 2 2 3 from TaskGen import before 4 import Build, os, sys, Logs 5 from samba_utils import * 3 import os 4 import Build 5 from TaskGen import feature, before 6 from samba_utils import SET_TARGET_TYPE, TO_LIST, LOCAL_CACHE 6 7 7 8 def SAMBA_PIDL(bld, pname, source, 8 9 options='', 9 10 output_dir='.', 10 symlink=False,11 11 generate_tables=True): 12 12 '''Build a IDL file using pidl. … … 32 32 '--python' : 'py_%s.c', 33 33 '--tdr-parser' : 'tdr_%s.c tdr_%s.h', 34 '--dcom-proxy' 35 '--com-header' 34 '--dcom-proxy' : '%s_p.c', 35 '--com-header' : 'com_%s.h' 36 36 } 37 37 … … 61 61 cpp = "" 62 62 cc = "" 63 if bld.CONFIG_SET("CPP") :63 if bld.CONFIG_SET("CPP") and bld.CONFIG_GET("CPP") != "": 64 64 if isinstance(bld.CONFIG_GET("CPP"), list): 65 cpp = 'CPP="%s"' % bld.CONFIG_GET("CPP")[0]65 cpp = 'CPP="%s"' % " ".join(bld.CONFIG_GET("CPP")) 66 66 else: 67 67 cpp = 'CPP="%s"' % bld.CONFIG_GET("CPP") … … 73 73 if bld.CONFIG_SET("CC"): 74 74 if isinstance(bld.CONFIG_GET("CC"), list): 75 cc = 'CC="%s"' % bld.CONFIG_GET("CC")[0]75 cc = 'CC="%s"' % " ".join(bld.CONFIG_GET("CC")) 76 76 else: 77 77 cc = 'CC="%s"' % bld.CONFIG_GET("CC") … … 80 80 ext_out = '.c', 81 81 before = 'cc', 82 on_results = True,82 update_outputs = True, 83 83 shell = True, 84 84 source = source, … … 92 92 t.env.PIDL = os.path.join(bld.srcnode.abspath(), 'pidl/pidl') 93 93 t.env.OPTIONS = TO_LIST(options) 94 95 # this rather convoluted set of path calculations is to cope with the possibility 96 # that gen_ndr is a symlink into the source tree. By doing this for the source3 97 # gen_ndr directory we end up generating identical output in gen_ndr for the old 98 # build system and the new one. That makes keeping things in sync much easier. 99 # eventually we should drop the gen_ndr files in git, but in the meanwhile this works 100 101 found_dir = bld.path.find_dir(output_dir) 102 if not 'abspath' in dir(found_dir): 103 Logs.error('Unable to find pidl output directory %s' % 104 os.path.normpath(os.path.join(bld.curdir, output_dir))) 105 sys.exit(1) 106 107 outdir = bld.path.find_dir(output_dir).abspath(t.env) 108 109 if symlink and not os.path.lexists(outdir): 110 link_source = os.path.normpath(os.path.join(bld.curdir,output_dir)) 111 os.symlink(link_source, outdir) 112 113 real_outputdir = os.path.realpath(outdir) 114 t.env.OUTPUTDIR = os_path_relpath(real_outputdir, os.path.dirname(bld.env.BUILD_DIRECTORY)) 94 t.env.OUTPUTDIR = bld.bldnode.name + '/' + bld.path.find_dir(output_dir).bldpath(t.env) 115 95 116 96 if generate_tables and table_header_idx is not None: … … 125 105 options='', 126 106 output_dir='.', 127 symlink=False,128 107 generate_tables=True): 129 108 '''A wrapper for building a set of IDL files''' 130 109 for p in TO_LIST(source): 131 bld.SAMBA_PIDL(name, p, options=options, output_dir=output_dir, symlink=symlink,generate_tables=generate_tables)110 bld.SAMBA_PIDL(name, p, options=options, output_dir=output_dir, generate_tables=generate_tables) 132 111 Build.BuildContext.SAMBA_PIDL_LIST = SAMBA_PIDL_LIST 133 112 … … 135 114 ################################################################# 136 115 # the rule for generating the NDR tables 137 from TaskGen import feature, before138 116 @feature('collect') 139 117 @before('exec_rule') … … 141 119 pidl_headers = LOCAL_CACHE(self.bld, 'PIDL_HEADERS') 142 120 for (name, hd) in pidl_headers.items(): 143 y = self.bld. name_to_obj(name, self.env)121 y = self.bld.get_tgen_by_name(name) 144 122 self.bld.ASSERT(y is not None, 'Failed to find PIDL header %s' % name) 145 123 y.post() … … 151 129 def SAMBA_PIDL_TABLES(bld, name, target): 152 130 '''generate the pidl NDR tables file''' 153 headers = bld.env.PIDL_HEADERS154 131 bld.SET_BUILD_GROUP('main') 155 132 t = bld( … … 158 135 ext_out = '.c', 159 136 before = 'cc', 160 on_results = True,137 update_outputs = True, 161 138 shell = True, 162 139 source = '../../librpc/tables.pl', -
vendor/current/buildtools/wafsamba/samba_python.py
r740 r988 1 1 # waf build tool for building IDL files with pidl 2 2 3 import Build4 from samba_utils import * 5 from samba_autoconf import *3 import os 4 import Build, Logs, Utils, Configure 5 from Configure import conf 6 6 7 from Configure import conf 7 @conf 8 def SAMBA_CHECK_PYTHON(conf, mandatory=True, version=(2,4,2)): 9 # enable tool to build python extensions 10 if conf.env.HAVE_PYTHON_H: 11 conf.check_python_version(version) 12 return 13 14 interpreters = [] 15 16 if conf.env['EXTRA_PYTHON']: 17 conf.all_envs['extrapython'] = conf.env.copy() 18 conf.setenv('extrapython') 19 conf.env['PYTHON'] = conf.env['EXTRA_PYTHON'] 20 conf.env['IS_EXTRA_PYTHON'] = 'yes' 21 conf.find_program('python', var='PYTHON', mandatory=True) 22 conf.check_tool('python') 23 try: 24 conf.check_python_version((3, 3, 0)) 25 except Exception: 26 Logs.warn('extra-python needs to be Python 3.3 or later') 27 raise 28 interpreters.append(conf.env['PYTHON']) 29 conf.setenv('default') 30 31 conf.find_program('python', var='PYTHON', mandatory=mandatory) 32 conf.check_tool('python') 33 path_python = conf.find_program('python') 34 conf.env.PYTHON_SPECIFIED = (conf.env.PYTHON != path_python) 35 conf.check_python_version(version) 36 37 interpreters.append(conf.env['PYTHON']) 38 conf.env.python_interpreters = interpreters 39 40 8 41 @conf 9 42 def SAMBA_CHECK_PYTHON_HEADERS(conf, mandatory=True): 10 43 if conf.env["python_headers_checked"] == []: 11 conf.check_python_headers(mandatory) 44 if conf.env['EXTRA_PYTHON']: 45 conf.setenv('extrapython') 46 _check_python_headers(conf, mandatory=True) 47 conf.setenv('default') 48 49 _check_python_headers(conf, mandatory) 12 50 conf.env["python_headers_checked"] = "yes" 51 52 if conf.env['EXTRA_PYTHON']: 53 extraversion = conf.all_envs['extrapython']['PYTHON_VERSION'] 54 if extraversion == conf.env['PYTHON_VERSION']: 55 raise Utils.WafError("extrapython %s is same as main python %s" % ( 56 extraversion, conf.env['PYTHON_VERSION'])) 13 57 else: 14 58 conf.msg("python headers", "using cache") 59 60 # we don't want PYTHONDIR in config.h, as otherwise changing 61 # --prefix causes a complete rebuild 62 del(conf.env.defines['PYTHONDIR']) 63 del(conf.env.defines['PYTHONARCHDIR']) 64 65 def _check_python_headers(conf, mandatory): 66 try: 67 Configure.ConfigurationError 68 conf.check_python_headers(mandatory=mandatory) 69 except Configure.ConfigurationError: 70 if mandatory: 71 raise 72 73 if conf.env['PYTHON_VERSION'] > '3': 74 abi_pattern = os.path.splitext(conf.env['pyext_PATTERN'])[0] 75 conf.env['PYTHON_SO_ABI_FLAG'] = abi_pattern % '' 76 else: 77 conf.env['PYTHON_SO_ABI_FLAG'] = '' 15 78 16 79 … … 22 85 cflags='', 23 86 includes='', 24 init_function_sentin al=None,87 init_function_sentinel=None, 25 88 local_include=True, 26 89 vars=None, 90 install=True, 27 91 enabled=True): 28 92 '''build a python extension for Samba''' 29 93 94 if bld.env['IS_EXTRA_PYTHON']: 95 name = 'extra-' + name 96 30 97 # when we support static python modules we'll need to gather 31 98 # the list from all the SAMBA_PYTHON() targets 32 if init_function_sentinal is not None: 33 cflags += '-DSTATIC_LIBPYTHON_MODULES=%s' % init_function_sentinal 99 if init_function_sentinel is not None: 100 cflags += ' -DSTATIC_LIBPYTHON_MODULES=%s' % init_function_sentinel 101 102 # From https://docs.python.org/2/c-api/arg.html: 103 # Starting with Python 2.5 the type of the length argument to 104 # PyArg_ParseTuple(), PyArg_ParseTupleAndKeywords() and PyArg_Parse() 105 # can be controlled by defining the macro PY_SSIZE_T_CLEAN before 106 # including Python.h. If the macro is defined, length is a Py_ssize_t 107 # rather than an int. 108 109 # Because <Python.h> if often included before includes.h/config.h 110 # This must be in the -D compiler options 111 cflags += ' -DPY_SSIZE_T_CLEAN=1' 34 112 35 113 source = bld.EXPAND_VARIABLES(source, vars=vars) 36 114 37 if realname is None: 38 # a SAMBA_PYTHON target without a realname is just a 39 # library with pyembed=True 40 bld.SAMBA_LIBRARY(name, 41 source=source, 42 deps=deps, 43 public_deps=public_deps, 44 includes=includes, 45 cflags=cflags, 46 local_include=local_include, 47 vars=vars, 48 pyembed=True, 49 enabled=enabled) 50 return 51 52 link_name = 'python/%s' % realname 115 if realname is not None: 116 link_name = 'python_modules/%s' % realname 117 else: 118 link_name = None 53 119 54 120 bld.SAMBA_LIBRARY(name, … … 58 124 includes=includes, 59 125 cflags=cflags, 60 realname=realname,61 126 local_include=local_include, 62 127 vars=vars, 128 realname=realname, 63 129 link_name=link_name, 64 pye mbed=True,130 pyext=True, 65 131 target_type='PYTHON', 66 132 install_path='${PYTHONARCHDIR}', 133 allow_undefined_symbols=True, 134 install=install, 67 135 enabled=enabled) 68 136 69 137 Build.BuildContext.SAMBA_PYTHON = SAMBA_PYTHON 138 139 140 def pyembed_libname(bld, name, extrapython=False): 141 return name + bld.env['PYTHON_SO_ABI_FLAG'] 142 143 Build.BuildContext.pyembed_libname = pyembed_libname 144 145 146 def gen_python_environments(bld, extra_env_vars=()): 147 """Generate all Python environments 148 149 To be used in a for loop. Normally, the loop body will be executed once. 150 151 When --extra-python is used, the body will additionaly be executed 152 with the extra-python environment active. 153 """ 154 yield 155 156 if bld.env['EXTRA_PYTHON']: 157 copied = ('GLOBAL_DEPENDENCIES', 'TARGET_TYPE') + tuple(extra_env_vars) 158 for name in copied: 159 bld.all_envs['extrapython'][name] = bld.all_envs['default'][name] 160 default_env = bld.all_envs['default'] 161 bld.all_envs['default'] = bld.all_envs['extrapython'] 162 yield 163 bld.all_envs['default'] = default_env 164 165 Build.BuildContext.gen_python_environments = gen_python_environments -
vendor/current/buildtools/wafsamba/samba_utils.py
r740 r988 2 2 # and for SAMBA_ macros for building libraries, binaries etc 3 3 4 import Build, os, sys, Options, Utils, Task, re, fnmatch, Logs 5 from TaskGen import feature, before 6 from Configure import conf 4 import os, sys, re, fnmatch, shlex 5 import Build, Options, Utils, Task, Logs, Configure 6 from TaskGen import feature, before, after 7 from Configure import conf, ConfigurationContext 7 8 from Logs import debug 8 import shlex9 9 10 10 # TODO: make this a --option … … 36 36 37 37 38 ######################################################39 # this is used as a decorator to make functions only40 # run once. Based on the idea from41 # http://stackoverflow.com/questions/815110/is-there-a-decorator-to-simply-cache-function-return-values42 runonce_ret = {}43 def runonce(function):44 def runonce_wrapper(*args):45 if args in runonce_ret:46 return runonce_ret[args]47 else:48 ret = function(*args)49 runonce_ret[args] = ret50 return ret51 return runonce_wrapper52 53 54 38 def ADD_LD_LIBRARY_PATH(path): 55 39 '''add something to LD_LIBRARY_PATH''' … … 66 50 def needs_private_lib(bld, target): 67 51 '''return True if a target links to a private library''' 68 for lib in getattr(target, " uselib_local", []):69 t = bld. name_to_obj(lib, bld.env)52 for lib in getattr(target, "final_libs", []): 53 t = bld.get_tgen_by_name(lib) 70 54 if t and getattr(t, 'private_library', False): 71 55 return True … … 136 120 d1[t] = d2[t] 137 121 138 139 def exec_command(self, cmd, **kw):140 '''this overrides the 'waf -v' debug output to be in a nice141 unix like format instead of a python list.142 Thanks to ita on #waf for this'''143 import Utils, Logs144 _cmd = cmd145 if isinstance(cmd, list):146 _cmd = ' '.join(cmd)147 debug('runner: %s' % _cmd)148 if self.log:149 self.log.write('%s\n' % cmd)150 kw['log'] = self.log151 try:152 if not kw.get('cwd', None):153 kw['cwd'] = self.cwd154 except AttributeError:155 self.cwd = kw['cwd'] = self.bldnode.abspath()156 return Utils.exec_command(cmd, **kw)157 Build.BuildContext.exec_command = exec_command158 159 160 122 def ADD_COMMAND(opt, name, function): 161 123 '''add a new top level command to waf''' … … 165 127 166 128 167 @feature('c c', 'cshlib', 'cprogram')129 @feature('c', 'cc', 'cshlib', 'cprogram') 168 130 @before('apply_core','exec_rule') 169 131 def process_depends_on(self): … … 174 136 lst = self.to_list(self.depends_on) 175 137 for x in lst: 176 y = self.bld. name_to_obj(x, self.env)138 y = self.bld.get_tgen_by_name(x) 177 139 self.bld.ASSERT(y is not None, "Failed to find dependency %s of %s" % (x, self.name)) 178 140 y.post() … … 215 177 return [] 216 178 if isinstance(str, list): 217 return str 179 # we need to return a new independent list... 180 return list(str) 181 if len(str) == 0: 182 return [] 218 183 lst = str.split(delimiter) 219 184 # the string may have had quotes in it, now we … … 234 199 vname = v[2:-1] 235 200 if not vname in env: 236 Logs.error("Failed to find variable %s in %s" % (vname, string)) 237 sys.exit(1) 201 raise KeyError("Failed to find variable %s in %s" % (vname, string)) 238 202 v = env[vname] 239 203 out.append(v) … … 256 220 @before('exec_rule', 'apply_core', 'collect') 257 221 def force_previous_groups(self): 258 if getattr(self.bld, 'enforced_group_ordering', False) == True:222 if getattr(self.bld, 'enforced_group_ordering', False): 259 223 return 260 224 self.bld.enforced_group_ordering = True … … 274 238 group_name(g), self.name or self.target) 275 239 break 276 if stop !=None:240 if stop is not None: 277 241 break 278 242 if stop is None: … … 385 349 386 350 351 def RUN_PYTHON_TESTS(testfiles, pythonpath=None, extra_env=None): 352 env = LOAD_ENVIRONMENT() 353 if pythonpath is None: 354 pythonpath = os.path.join(Utils.g_module.blddir, 'python') 355 result = 0 356 for interp in env.python_interpreters: 357 for testfile in testfiles: 358 cmd = "PYTHONPATH=%s %s %s" % (pythonpath, interp, testfile) 359 if extra_env: 360 for key, value in extra_env.items(): 361 cmd = "%s=%s %s" % (key, value, cmd) 362 print('Running Python test with %s: %s' % (interp, testfile)) 363 ret = RUN_COMMAND(cmd) 364 if ret: 365 print('Python test failed: %s' % cmd) 366 result = ret 367 return result 368 369 387 370 # make sure we have md5. some systems don't have it 388 371 try: 389 372 from hashlib import md5 373 # Even if hashlib.md5 exists, it may be unusable. 374 # Try to use MD5 function. In FIPS mode this will cause an exception 375 # and we'll get to the replacement code 376 foo = md5('abcd') 390 377 except: 391 378 try: 392 379 import md5 380 # repeat the same check here, mere success of import is not enough. 381 # Try to use MD5 function. In FIPS mode this will cause an exception 382 foo = md5.md5('abcd') 393 383 except: 394 384 import Constants … … 488 478 Logs.zones = ['*'] 489 479 elif opt[0].isupper() and opt.find('=') != -1: 480 # this allows us to set waf options on the make command line 481 # for example, if you do "make FOO=blah", then we set the 482 # option 'FOO' in Options.options, to blah. If you look in wafsamba/wscript 483 # you will see that the command line accessible options have their dest= 484 # set to uppercase, to allow for passing of options from make in this way 485 # this is also how "make test TESTS=testpattern" works, and 486 # "make VERBOSE=1" as well as things like "make SYMBOLCHECK=1" 490 487 loc = opt.find('=') 491 488 setattr(Options.options, opt[0:loc], opt[loc+1:]) … … 495 492 jobs_set = True 496 493 elif v == 'k': 497 Options.options.keep = True 494 Options.options.keep = True 498 495 elif opt == '-j': 499 496 jobs_set = True 500 497 elif opt == '-k': 501 Options.options.keep = True 498 Options.options.keep = True 502 499 if not jobs_set: 503 500 # default to one job 504 501 Options.options.jobs = 1 505 502 506 503 Build.BuildContext.CHECK_MAKEFLAGS = CHECK_MAKEFLAGS 507 504 … … 562 559 (root1, ext1) = os.path.splitext(name) 563 560 if python: 564 (root2, ext2) = os.path.splitext(ctx.env.pyext_PATTERN)561 return ctx.env.pyext_PATTERN % root1 565 562 else: 566 563 (root2, ext2) = os.path.splitext(ctx.env.shlib_PATTERN) … … 613 610 if not type in ['SUBSYSTEM', 'MODULE', 'BINARY', 'LIBRARY', 'ASN1', 'PYTHON']: 614 611 continue 615 t = bld. name_to_obj(tgt, bld.env)612 t = bld.get_tgen_by_name(tgt) 616 613 if t is None: 617 614 Logs.error("Target %s of type %s has no task generator" % (tgt, type)) … … 619 616 tgt_list.append(t) 620 617 return tgt_list 618 619 from Constants import WSCRIPT_FILE 620 def PROCESS_SEPARATE_RULE(self, rule): 621 ''' cause waf to process additional script based on `rule'. 622 You should have file named wscript_<stage>_rule in the current directory 623 where stage is either 'configure' or 'build' 624 ''' 625 stage = '' 626 if isinstance(self, Configure.ConfigurationContext): 627 stage = 'configure' 628 elif isinstance(self, Build.BuildContext): 629 stage = 'build' 630 file_path = os.path.join(self.curdir, WSCRIPT_FILE+'_'+stage+'_'+rule) 631 txt = load_file(file_path) 632 if txt: 633 dc = {'ctx': self} 634 if getattr(self.__class__, 'pre_recurse', None): 635 dc = self.pre_recurse(txt, file_path, self.curdir) 636 exec(compile(txt, file_path, 'exec'), dc) 637 if getattr(self.__class__, 'post_recurse', None): 638 dc = self.post_recurse(txt, file_path, self.curdir) 639 640 Build.BuildContext.PROCESS_SEPARATE_RULE = PROCESS_SEPARATE_RULE 641 ConfigurationContext.PROCESS_SEPARATE_RULE = PROCESS_SEPARATE_RULE 642 643 def AD_DC_BUILD_IS_ENABLED(self): 644 if self.CONFIG_SET('AD_DC_BUILD_IS_ENABLED'): 645 return True 646 return False 647 648 Build.BuildContext.AD_DC_BUILD_IS_ENABLED = AD_DC_BUILD_IS_ENABLED 649 650 @feature('cprogram', 'cshlib', 'cstaticlib') 651 @after('apply_lib_vars') 652 @before('apply_obj_vars') 653 def samba_before_apply_obj_vars(self): 654 """before apply_obj_vars for uselib, this removes the standard paths""" 655 656 def is_standard_libpath(env, path): 657 for _path in env.STANDARD_LIBPATH: 658 if _path == os.path.normpath(path): 659 return True 660 return False 661 662 v = self.env 663 664 for i in v['RPATH']: 665 if is_standard_libpath(v, i): 666 v['RPATH'].remove(i) 667 668 for i in v['LIBPATH']: 669 if is_standard_libpath(v, i): 670 v['LIBPATH'].remove(i) 671 -
vendor/current/buildtools/wafsamba/samba_version.py
r740 r988 2 2 import Utils 3 3 import samba_utils 4 import sys 5 6 def bzr_version_summary(path): 7 try: 8 import bzrlib 9 except ImportError: 10 return ("BZR-UNKNOWN", {}) 11 12 import bzrlib.ui 13 bzrlib.ui.ui_factory = bzrlib.ui.make_ui_for_terminal( 14 sys.stdin, sys.stdout, sys.stderr) 15 from bzrlib import branch, osutils, workingtree 16 from bzrlib.plugin import load_plugins 17 load_plugins() 18 19 b = branch.Branch.open(path) 20 (revno, revid) = b.last_revision_info() 21 rev = b.repository.get_revision(revid) 22 23 fields = { 24 "BZR_REVISION_ID": revid, 25 "BZR_REVNO": revno, 26 "COMMIT_DATE": osutils.format_date_with_offset_in_original_timezone(rev.timestamp, 27 rev.timezone or 0), 28 "COMMIT_TIME": int(rev.timestamp), 29 "BZR_BRANCH": rev.properties.get("branch-nick", ""), 30 } 31 32 # If possible, retrieve the git sha 33 try: 34 from bzrlib.plugins.git.object_store import get_object_store 35 except ImportError: 36 # No git plugin 37 ret = "BZR-%d" % revno 38 else: 39 store = get_object_store(b.repository) 40 full_rev = store._lookup_revision_sha1(revid) 41 fields["GIT_COMMIT_ABBREV"] = full_rev[:7] 42 fields["GIT_COMMIT_FULLREV"] = full_rev 43 ret = "GIT-" + fields["GIT_COMMIT_ABBREV"] 44 45 if workingtree.WorkingTree.open(path).has_changes(): 46 fields["COMMIT_IS_CLEAN"] = 0 47 ret += "+" 48 else: 49 fields["COMMIT_IS_CLEAN"] = 1 50 return (ret, fields) 51 4 from samba_git import find_git 52 5 53 6 def git_version_summary(path, env=None): 54 # Get version from GIT 55 if not 'GIT' in env and os.path.exists("/usr/bin/git"): 56 # this is useful when doing make dist without configuring 57 env.GIT = "/usr/bin/git" 58 59 if not 'GIT' in env: 7 git = find_git(env) 8 9 if git is None: 60 10 return ("GIT-UNKNOWN", {}) 11 12 env.GIT = git 61 13 62 14 environ = dict(os.environ) … … 89 41 90 42 43 def distversion_version_summary(path): 44 #get version from .distversion file 45 suffix = None 46 fields = {} 47 48 for line in Utils.readf(path + '/.distversion').splitlines(): 49 if line == '': 50 continue 51 if line.startswith("#"): 52 continue 53 try: 54 split_line = line.split("=") 55 if split_line[1] != "": 56 key = split_line[0] 57 value = split_line[1] 58 if key == "SUFFIX": 59 suffix = value 60 continue 61 fields[key] = value 62 except: 63 print("Failed to parse line %s from .distversion file." % (line)) 64 raise 65 66 if "COMMIT_TIME" in fields: 67 fields["COMMIT_TIME"] = int(fields["COMMIT_TIME"]) 68 69 if suffix is None: 70 return ("UNKNOWN", fields) 71 72 return (suffix, fields) 73 74 91 75 class SambaVersion(object): 92 76 93 def __init__(self, version_dict, path, env=None ):77 def __init__(self, version_dict, path, env=None, is_install=True): 94 78 '''Determine the version number of samba 95 79 96 See VERSION for the format. Entries on that file are 80 See VERSION for the format. Entries on that file are 97 81 also accepted as dictionary entries here 98 82 ''' … … 104 88 self.TP_RELEASE=None 105 89 self.ALPHA_RELEASE=None 90 self.BETA_RELEASE=None 106 91 self.PRE_RELEASE=None 107 92 self.RC_RELEASE=None … … 134 119 135 120 ## 136 ## maybe add "3.0.22a" or "4.0.0tp11" or "4.0.0alpha1" or " 3.0.22pre1" or "3.0.22rc1"121 ## maybe add "3.0.22a" or "4.0.0tp11" or "4.0.0alpha1" or "4.0.0beta1" or "3.0.22pre1" or "3.0.22rc1" 137 122 ## We do not do pre or rc version on patch/letter releases 138 123 ## … … 145 130 self.ALPHA_RELEASE = int(self.ALPHA_RELEASE) 146 131 SAMBA_VERSION_STRING += ("alpha%u" % self.ALPHA_RELEASE) 132 if self.BETA_RELEASE is not None: 133 self.BETA_RELEASE = int(self.BETA_RELEASE) 134 SAMBA_VERSION_STRING += ("beta%u" % self.BETA_RELEASE) 147 135 if self.PRE_RELEASE is not None: 148 136 self.PRE_RELEASE = int(self.PRE_RELEASE) … … 153 141 154 142 if self.IS_SNAPSHOT: 155 if os.path.exists(os.path.join(path, ".git")): 143 if not is_install: 144 suffix = "DEVELOPERBUILD" 145 self.vcs_fields = {} 146 elif os.path.exists(os.path.join(path, ".git")): 156 147 suffix, self.vcs_fields = git_version_summary(path, env=env) 157 elif os.path.exists(os.path.join(path, ". bzr")):158 suffix, self.vcs_fields = bzr_version_summary(path)148 elif os.path.exists(os.path.join(path, ".distversion")): 149 suffix, self.vcs_fields = distversion_version_summary(path) 159 150 else: 160 151 suffix = "UNKNOWN" 161 152 self.vcs_fields = {} 153 self.vcs_fields["SUFFIX"] = suffix 162 154 SAMBA_VERSION_STRING += "-" + suffix 163 155 else: … … 194 186 if self.ALPHA_RELEASE is not None: 195 187 string+="#define SAMBA_VERSION_ALPHA_RELEASE %u\n" % self.ALPHA_RELEASE 188 189 if self.BETA_RELEASE is not None: 190 string+="#define SAMBA_VERSION_BETA_RELEASE %u\n" % self.BETA_RELEASE 196 191 197 192 if self.PRE_RELEASE is not None: … … 235 230 236 231 237 def samba_version_file(version_file, path, env=None ):232 def samba_version_file(version_file, path, env=None, is_install=True): 238 233 '''Parse the version information from a VERSION file''' 239 234 … … 255 250 raise 256 251 257 return SambaVersion(version_dict, path, env=env )258 259 260 261 def load_version(env=None ):252 return SambaVersion(version_dict, path, env=env, is_install=is_install) 253 254 255 256 def load_version(env=None, is_install=True): 262 257 '''load samba versions either from ./VERSION or git 263 258 return a version object for detailed breakdown''' … … 265 260 env = samba_utils.LOAD_ENVIRONMENT() 266 261 267 version = samba_version_file("./VERSION", ".", env )262 version = samba_version_file("./VERSION", ".", env, is_install=is_install) 268 263 Utils.g_module.VERSION = version.STRING 269 264 return version -
vendor/current/buildtools/wafsamba/samba_wildcard.py
r740 r988 1 #! /usr/bin/env python2 3 1 # based on playground/evil in the waf svn tree 4 2 5 import os, datetime 6 import Scripting, Utils, Options, Logs, Environment , fnmatch7 from Constants import *8 from samba_utils import *3 import os, datetime, fnmatch 4 import Scripting, Utils, Options, Logs, Environment 5 from Constants import SRCDIR, BLDDIR 6 from samba_utils import LOCAL_CACHE, os_path_relpath 9 7 10 8 def run_task(t, k): 11 12 13 14 9 '''run a single build task''' 10 ret = t.run() 11 if ret: 12 raise Utils.WafError("Failed to build %s: %u" % (k, ret)) 15 13 16 14 17 15 def run_named_build_task(cmd): 18 19 20 bld = fake_build_environment()21 22 23 16 '''run a named build task, matching the cmd name using fnmatch 17 wildcards against inputs and outputs of all build tasks''' 18 bld = fake_build_environment(info=False) 19 found = False 20 cwd_node = bld.root.find_dir(os.getcwd()) 21 top_node = bld.root.find_dir(bld.srcnode.abspath()) 24 22 25 23 cmd = os.path.normpath(cmd) 26 24 27 28 29 25 # cope with builds of bin/*/* 26 if os.path.islink(cmd): 27 cmd = os_path_relpath(os.readlink(cmd), os.getcwd()) 30 28 31 32 29 if cmd[0:12] == "bin/default/": 30 cmd = cmd[12:] 33 31 34 35 36 37 38 39 40 41 42 43 44 45 46 32 for g in bld.task_manager.groups: 33 for attr in ['outputs', 'inputs']: 34 for t in g.tasks: 35 s = getattr(t, attr, []) 36 for k in s: 37 relpath1 = k.relpath_gen(cwd_node) 38 relpath2 = k.relpath_gen(top_node) 39 if (fnmatch.fnmatch(relpath1, cmd) or 40 fnmatch.fnmatch(relpath2, cmd)): 41 t.position = [0,0] 42 print(t.display()) 43 run_task(t, k) 44 found = True 47 45 48 46 49 if not found: 50 raise Utils.WafError("Unable to find build target matching %s" % cmd) 47 if not found: 48 raise Utils.WafError("Unable to find build target matching %s" % cmd) 49 50 51 def rewrite_compile_targets(): 52 '''cope with the bin/ form of compile target''' 53 if not Options.options.compile_targets: 54 return 55 56 bld = fake_build_environment(info=False) 57 targets = LOCAL_CACHE(bld, 'TARGET_TYPE') 58 tlist = [] 59 60 for t in Options.options.compile_targets.split(','): 61 if not os.path.islink(t): 62 tlist.append(t) 63 continue 64 link = os.readlink(t) 65 list = link.split('/') 66 for name in [list[-1], '/'.join(list[-2:])]: 67 if name in targets: 68 tlist.append(name) 69 continue 70 Options.options.compile_targets = ",".join(tlist) 51 71 52 72 53 73 54 74 def wildcard_main(missing_cmd_fn): 55 56 75 '''this replaces main from Scripting, allowing us to override the 76 behaviour for unknown commands 57 77 58 59 60 61 78 If a unknown command is found, then missing_cmd_fn() is called with 79 the name of the requested command 80 ''' 81 Scripting.commands = Options.arg_line[:] 62 82 63 while Scripting.commands: 64 x = Scripting.commands.pop(0)83 # rewrite the compile targets to cope with the bin/xx form 84 rewrite_compile_targets() 65 85 66 ini = datetime.datetime.now() 67 if x == 'configure': 68 fun = Scripting.configure 69 elif x == 'build': 70 fun = Scripting.build 71 else: 72 fun = getattr(Utils.g_module, x, None) 86 while Scripting.commands: 87 x = Scripting.commands.pop(0) 73 88 74 # this is the new addition on top of main from Scripting.py 75 if not fun: 76 missing_cmd_fn(x) 77 break 89 ini = datetime.datetime.now() 90 if x == 'configure': 91 fun = Scripting.configure 92 elif x == 'build': 93 fun = Scripting.build 94 else: 95 fun = getattr(Utils.g_module, x, None) 78 96 79 ctx = getattr(Utils.g_module, x + '_context', Utils.Context)() 97 # this is the new addition on top of main from Scripting.py 98 if not fun: 99 missing_cmd_fn(x) 100 break 80 101 81 if x in ['init', 'shutdown', 'dist', 'distclean', 'distcheck']: 82 try: 83 fun(ctx) 84 except TypeError: 85 fun() 86 else: 87 fun(ctx) 102 ctx = getattr(Utils.g_module, x + '_context', Utils.Context)() 88 103 89 ela = '' 90 if not Options.options.progress_bar: 91 ela = ' (%s)' % Utils.get_elapsed_time(ini) 104 if x in ['init', 'shutdown', 'dist', 'distclean', 'distcheck']: 105 try: 106 fun(ctx) 107 except TypeError: 108 fun() 109 else: 110 fun(ctx) 92 111 93 if x != 'init' and x != 'shutdown': 94 Logs.info('%r finished successfully%s' % (x, ela)) 112 ela = '' 113 if not Options.options.progress_bar: 114 ela = ' (%s)' % Utils.get_elapsed_time(ini) 95 115 96 if not Scripting.commands and x != 'shutdown': 97 Scripting.commands.append('shutdown') 116 if x != 'init' and x != 'shutdown': 117 Logs.info('%r finished successfully%s' % (x, ela)) 118 119 if not Scripting.commands and x != 'shutdown': 120 Scripting.commands.append('shutdown') 98 121 99 122 100 123 101 124 102 def fake_build_environment( ):103 104 105 106 125 def fake_build_environment(info=True, flush=False): 126 """create all the tasks for the project, but do not run the build 127 return the build context in use""" 128 bld = getattr(Utils.g_module, 'build_context', Utils.Context)() 129 bld = Scripting.check_configured(bld) 107 130 108 Options.commands['install'] = False 109 Options.commands['uninstall'] = False 110 Options.is_install = False 131 Options.commands['install'] = False 132 Options.commands['uninstall'] = False 111 133 112 134 bld.is_install = 0 # False 113 135 114 115 116 117 136 try: 137 proj = Environment.Environment(Options.lockfile) 138 except IOError: 139 raise Utils.WafError("Project not configured (run 'waf configure' first)") 118 140 119 120 141 bld.load_dirs(proj[SRCDIR], proj[BLDDIR]) 142 bld.load_envs() 121 143 122 Logs.info("Waf: Entering directory `%s'" % bld.bldnode.abspath()) 123 bld.add_subdirs([os.path.split(Utils.g_module.root_path)[0]]) 144 if info: 145 Logs.info("Waf: Entering directory `%s'" % bld.bldnode.abspath()) 146 bld.add_subdirs([os.path.split(Utils.g_module.root_path)[0]]) 124 147 125 bld.pre_build() 126 bld.flush() 127 return bld 148 bld.pre_build() 149 if flush: 150 bld.flush() 151 return bld 128 152 -
vendor/current/buildtools/wafsamba/stale_files.py
r740 r988 1 #! /usr/bin/env python2 1 # encoding: utf-8 3 2 # Thomas Nagy, 2006-2010 (ita) … … 49 48 if bin_base[-4:] != '/bin': 50 49 raise Utils.WafError("Invalid bin base: %s" % bin_base) 51 50 52 51 # obtain the expected list of files 53 52 expected = [] … … 59 58 if getattr(x, 'target'): 60 59 tlist = samba_utils.TO_LIST(getattr(x, 'target')) 60 ttype = getattr(x, 'samba_type', None) 61 task_list = getattr(x, 'compiled_tasks', []) 62 if task_list: 63 # this gets all of the .o files, including the task 64 # ids, so foo.c maps to foo_3.o for idx=3 65 for tsk in task_list: 66 for output in tsk.outputs: 67 objpath = os.path.normpath(output.abspath(bld.env)) 68 expected.append(objpath) 61 69 for t in tlist: 70 if ttype in ['LIBRARY','MODULE']: 71 t = samba_utils.apply_pattern(t, bld.env.shlib_PATTERN) 72 if ttype == 'PYTHON': 73 t = samba_utils.apply_pattern(t, bld.env.pyext_PATTERN) 62 74 p = os.path.join(x.path.abspath(bld.env), t) 63 75 p = os.path.normpath(p) … … 79 91 if f in ['config.h']: 80 92 continue 81 if f[-2:] not in [ '.c', '.h' ]: 93 (froot, fext) = os.path.splitext(f) 94 if fext not in [ '.c', '.h', '.so', '.o' ]: 82 95 continue 83 96 if f[-7:] == '.inst.h': … … 85 98 if p.find("/.conf") != -1: 86 99 continue 87 if not p in expected :100 if not p in expected and os.path.exists(p): 88 101 Logs.warn("Removing stale file: %s" % p) 89 102 os.unlink(p) -
vendor/current/buildtools/wafsamba/symbols.py
r740 r988 2 2 # using nm, producing a set of exposed defined/undefined symbols 3 3 4 import Utils, Build, subprocess, Logs 5 from samba_wildcard import fake_build_environment 6 from samba_utils import * 4 import os, re, subprocess 5 import Utils, Build, Options, Logs 6 from Logs import debug 7 from samba_utils import TO_LIST, LOCAL_CACHE, get_tgt_list, os_path_relpath 7 8 8 9 # these are the data structures used in symbols.py: … … 18 19 # bld.env.syslib_symbols: dictionary mapping system library name to set of symbols 19 20 # for that library 21 # bld.env.library_dict : dictionary mapping built library paths to subsystem names 20 22 # 21 23 # LOCAL_CACHE(bld, 'TARGET_TYPE') : dictionary mapping subsystem name to target type 22 24 23 def symbols_extract(objfiles, dynamic=False): 25 26 def symbols_extract(bld, objfiles, dynamic=False): 24 27 '''extract symbols from objfile, returning a dictionary containing 25 28 the set of undefined and public symbols for each file''' 26 29 27 30 ret = {} 31 32 # see if we can get some results from the nm cache 33 if not bld.env.nm_cache: 34 bld.env.nm_cache = {} 35 36 objfiles = set(objfiles).copy() 37 38 remaining = set() 39 for obj in objfiles: 40 if obj in bld.env.nm_cache: 41 ret[obj] = bld.env.nm_cache[obj].copy() 42 else: 43 remaining.add(obj) 44 objfiles = remaining 45 46 if len(objfiles) == 0: 47 return ret 28 48 29 49 cmd = ["nm"] … … 31 51 # needed for some .so files 32 52 cmd.append("-D") 33 cmd.extend( objfiles)53 cmd.extend(list(objfiles)) 34 54 35 55 nmpipe = subprocess.Popen(cmd, stdout=subprocess.PIPE).stdout 36 56 if len(objfiles) == 1: 37 filename = objfiles[0]57 filename = list(objfiles)[0] 38 58 ret[filename] = { "PUBLIC": set(), "UNDEFINED" : set()} 39 59 … … 60 80 ret[filename]["UNDEFINED"].add(symbol) 61 81 82 # add to the cache 83 for obj in objfiles: 84 if obj in ret: 85 bld.env.nm_cache[obj] = ret[obj].copy() 86 else: 87 bld.env.nm_cache[obj] = { "PUBLIC": set(), "UNDEFINED" : set() } 88 62 89 return ret 63 90 … … 69 96 70 97 71 def find_ syslib_path(bld, libname, deps):98 def find_ldd_path(bld, libname, binary): 72 99 '''find the path to the syslib we will link against''' 73 # the strategy is to use the targets that depend on the library, and run ldd74 # on it to find the real location of the library that is used75 76 linkpath = deps[0].link_task.outputs[0].abspath(bld.env)77 78 if libname == "python":79 libname += bld.env.PYTHON_VERSION80 81 100 ret = None 82 83 lddpipe = subprocess.Popen(['ldd', linkpath], stdout=subprocess.PIPE).stdout 101 if not bld.env.syslib_paths: 102 bld.env.syslib_paths = {} 103 if libname in bld.env.syslib_paths: 104 return bld.env.syslib_paths[libname] 105 106 lddpipe = subprocess.Popen(['ldd', binary], stdout=subprocess.PIPE).stdout 84 107 for line in lddpipe: 85 108 line = line.strip() … … 87 110 if len(cols) < 3 or cols[1] != "=>": 88 111 continue 89 if cols[0].startswith("lib%s." % libname.lower()):90 ret = cols[2]91 112 if cols[0].startswith("libc."): 92 113 # save this one too 93 114 bld.env.libc_path = cols[2] 115 if cols[0].startswith(libname): 116 ret = cols[2] 117 bld.env.syslib_paths[libname] = ret 94 118 return ret 119 120 121 # some regular expressions for parsing readelf output 122 re_sharedlib = re.compile('Shared library: \[(.*)\]') 123 re_rpath = re.compile('Library rpath: \[(.*)\]') 124 125 def get_libs(bld, binname): 126 '''find the list of linked libraries for any binary or library 127 binname is the path to the binary/library on disk 128 129 We do this using readelf instead of ldd as we need to avoid recursing 130 into system libraries 131 ''' 132 133 # see if we can get the result from the ldd cache 134 if not bld.env.lib_cache: 135 bld.env.lib_cache = {} 136 if binname in bld.env.lib_cache: 137 return bld.env.lib_cache[binname].copy() 138 139 rpath = [] 140 libs = set() 141 142 elfpipe = subprocess.Popen(['readelf', '--dynamic', binname], stdout=subprocess.PIPE).stdout 143 for line in elfpipe: 144 m = re_sharedlib.search(line) 145 if m: 146 libs.add(m.group(1)) 147 m = re_rpath.search(line) 148 if m: 149 rpath.extend(m.group(1).split(":")) 150 151 ret = set() 152 for lib in libs: 153 found = False 154 for r in rpath: 155 path = os.path.join(r, lib) 156 if os.path.exists(path): 157 ret.add(os.path.realpath(path)) 158 found = True 159 break 160 if not found: 161 # we didn't find this lib using rpath. It is probably a system 162 # library, so to find the path to it we either need to use ldd 163 # or we need to start parsing /etc/ld.so.conf* ourselves. We'll 164 # use ldd for now, even though it is slow 165 path = find_ldd_path(bld, lib, binname) 166 if path: 167 ret.add(os.path.realpath(path)) 168 169 bld.env.lib_cache[binname] = ret.copy() 170 171 return ret 172 173 174 def get_libs_recursive(bld, binname, seen): 175 '''find the recursive list of linked libraries for any binary or library 176 binname is the path to the binary/library on disk. seen is a set used 177 to prevent loops 178 ''' 179 if binname in seen: 180 return set() 181 ret = get_libs(bld, binname) 182 seen.add(binname) 183 for lib in ret: 184 # we don't want to recurse into system libraries. If a system 185 # library that we use (eg. libcups) happens to use another library 186 # (such as libkrb5) which contains common symbols with our own 187 # libraries, then that is not an error 188 if lib in bld.env.library_dict: 189 ret = ret.union(get_libs_recursive(bld, lib, seen)) 190 return ret 191 192 193 194 def find_syslib_path(bld, libname, deps): 195 '''find the path to the syslib we will link against''' 196 # the strategy is to use the targets that depend on the library, and run ldd 197 # on it to find the real location of the library that is used 198 199 linkpath = deps[0].link_task.outputs[0].abspath(bld.env) 200 201 if libname == "python": 202 libname += bld.env.PYTHON_VERSION 203 204 return find_ldd_path(bld, "lib%s" % libname.lower(), linkpath) 95 205 96 206 … … 114 224 objmap[objpath] = t 115 225 116 symbols = symbols_extract( objlist)226 symbols = symbols_extract(bld, objlist) 117 227 for obj in objlist: 118 228 t = objmap[obj] … … 143 253 if t.samba_type == 'LIBRARY': 144 254 for dep in t.add_objects: 145 t2 = bld. name_to_obj(dep, bld.env)255 t2 = bld.get_tgen_by_name(dep) 146 256 bld.ASSERT(t2 is not None, "Library '%s' has unknown dependency '%s'" % (name, dep)) 147 257 bld.env.public_symbols[name] = bld.env.public_symbols[name].union(t2.public_symbols) … … 156 266 if t.samba_type == 'LIBRARY': 157 267 for dep in t.add_objects: 158 t2 = bld. name_to_obj(dep, bld.env)268 t2 = bld.get_tgen_by_name(dep) 159 269 bld.ASSERT(t2 is not None, "Library '%s' has unknown dependency '%s'" % (name, dep)) 160 270 bld.env.used_symbols[name] = bld.env.used_symbols[name].union(t2.used_symbols) 271 272 273 def build_library_dict(bld, tgt_list): 274 '''build the library_dict dictionary''' 275 276 if bld.env.library_dict: 277 return 278 279 bld.env.library_dict = {} 280 281 for t in tgt_list: 282 if t.samba_type in [ 'LIBRARY', 'PYTHON' ]: 283 linkpath = os.path.realpath(t.link_task.outputs[0].abspath(bld.env)) 284 bld.env.library_dict[linkpath] = t.sname 161 285 162 286 … … 193 317 objmap[bld.env.libc_path] = 'c' 194 318 195 symbols = symbols_extract( syslib_paths, dynamic=True)319 symbols = symbols_extract(bld, syslib_paths, dynamic=True) 196 320 197 321 # keep a map of syslib names to public symbols … … 240 364 deps.add(depname[0]) 241 365 continue 242 t2 = bld. name_to_obj(depname[0], bld.env)366 t2 = bld.get_tgen_by_name(depname[0]) 243 367 if len(t2.in_library) != 1: 244 368 deps.add(depname[0]) … … 263 387 if t.samba_type in [ 'LIBRARY' ]: 264 388 for obj in t.samba_deps_extended: 265 t2 = bld. name_to_obj(obj, bld.env)389 t2 = bld.get_tgen_by_name(obj) 266 390 if t2 and t2.samba_type in [ 'SUBSYSTEM', 'ASN1' ]: 267 391 if not t.sname in t2.in_library: … … 280 404 281 405 for dep in t.autodeps: 282 t2 = bld. name_to_obj(dep, bld.env)406 t2 = bld.get_tgen_by_name(dep) 283 407 if t2 is None: 284 408 continue … … 313 437 '''check for depenencies that should be changed''' 314 438 315 if bld. name_to_obj(t.sname + ".objlist", bld.env):439 if bld.get_tgen_by_name(t.sname + ".objlist"): 316 440 return 317 441 … … 325 449 deps = set(t.samba_deps) 326 450 for d in t.samba_deps: 327 if targets[d] in [ 'EMPTY', 'DISABLED', 'SYSLIB' ]:451 if targets[d] in [ 'EMPTY', 'DISABLED', 'SYSLIB', 'GENERATOR' ]: 328 452 continue 329 453 bld.ASSERT(d in bld.env.public_symbols, "Failed to find symbol list for dependency '%s'" % d) … … 353 477 '''check for syslib depenencies''' 354 478 355 if bld. name_to_obj(t.sname + ".objlist", bld.env):479 if bld.get_tgen_by_name(t.sname + ".objlist"): 356 480 return 357 481 … … 362 486 features = TO_LIST(t.features) 363 487 if 'pyembed' in features or 'pyext' in features: 364 t.unsatisfied_symbols = t.unsatisfied_symbols.difference(bld.env.public_symbols['python']) 488 if 'python' in bld.env.public_symbols: 489 t.unsatisfied_symbols = t.unsatisfied_symbols.difference(bld.env.public_symbols['python']) 365 490 366 491 needed = {} … … 444 569 445 570 446 447 def symbols_dupcheck(task): 571 def report_duplicate(bld, binname, sym, libs, fail_on_error): 572 '''report duplicated symbols''' 573 if sym in ['_init', '_fini', '_edata', '_end', '__bss_start']: 574 return 575 libnames = [] 576 for lib in libs: 577 if lib in bld.env.library_dict: 578 libnames.append(bld.env.library_dict[lib]) 579 else: 580 libnames.append(lib) 581 if fail_on_error: 582 raise Utils.WafError("%s: Symbol %s linked in multiple libraries %s" % (binname, sym, libnames)) 583 else: 584 print("%s: Symbol %s linked in multiple libraries %s" % (binname, sym, libnames)) 585 586 587 def symbols_dupcheck_binary(bld, binname, fail_on_error): 588 '''check for duplicated symbols in one binary''' 589 590 libs = get_libs_recursive(bld, binname, set()) 591 symlist = symbols_extract(bld, libs, dynamic=True) 592 593 symmap = {} 594 for libpath in symlist: 595 for sym in symlist[libpath]['PUBLIC']: 596 if sym == '_GLOBAL_OFFSET_TABLE_': 597 continue 598 if not sym in symmap: 599 symmap[sym] = set() 600 symmap[sym].add(libpath) 601 for sym in symmap: 602 if len(symmap[sym]) > 1: 603 for libpath in symmap[sym]: 604 if libpath in bld.env.library_dict: 605 report_duplicate(bld, binname, sym, symmap[sym], fail_on_error) 606 break 607 608 def symbols_dupcheck(task, fail_on_error=False): 448 609 '''check for symbols defined in two different subsystems''' 449 610 bld = task.env.bld … … 452 613 targets = LOCAL_CACHE(bld, 'TARGET_TYPE') 453 614 454 Logs.info("Checking for duplicate symbols") 455 for sym in bld.env.symbol_map: 456 subsystems = set(bld.env.symbol_map[sym]) 457 if len(subsystems) == 1: 458 continue 459 460 if sym in ['main', '_init', '_fini', 'init_samba_module', 'samba_init_module', 'ldb_init_module' ]: 461 # these are expected to be in many subsystems 462 continue 463 464 # if all of them are in system libraries, we can ignore them. This copes 465 # with the duplication between libc, libpthread and libattr 466 all_syslib = True 467 for s in subsystems: 468 if s != 'c' and (not s in targets or targets[s] != 'SYSLIB'): 469 all_syslib = False 470 if all_syslib: 471 continue 472 Logs.info("symbol %s appears in %s" % (sym, subsystems)) 615 build_library_dict(bld, tgt_list) 616 for t in tgt_list: 617 if t.samba_type == 'BINARY': 618 binname = os_path_relpath(t.link_task.outputs[0].abspath(bld.env), os.getcwd()) 619 symbols_dupcheck_binary(bld, binname, fail_on_error) 620 621 622 def symbols_dupcheck_fatal(task): 623 '''check for symbols defined in two different subsystems (and fail if duplicates are found)''' 624 symbols_dupcheck(task, fail_on_error=True) 473 625 474 626 … … 495 647 496 648 Build.BuildContext.SYMBOL_CHECK = SYMBOL_CHECK 649 650 def DUP_SYMBOL_CHECK(bld): 651 if Options.options.DUP_SYMBOLCHECK and bld.env.DEVELOPER: 652 '''check for duplicate symbols''' 653 bld.SET_BUILD_GROUP('syslibcheck') 654 task = bld(rule=symbols_dupcheck_fatal, always=True, name='symbol duplicate checking') 655 task.env.bld = bld 656 657 Build.BuildContext.DUP_SYMBOL_CHECK = DUP_SYMBOL_CHECK -
vendor/current/buildtools/wafsamba/tru64cc.py
r740 r988 14 14 @conftest 15 15 def find_tru64cc(conf): 16 17 18 19 20 21 22 16 v = conf.env 17 cc = None 18 if v['CC']: cc = v['CC'] 19 elif 'CC' in conf.environ: cc = conf.environ['CC'] 20 if not cc: cc = conf.find_program('cc', var='CC') 21 if not cc: conf.fatal('tru64cc was not found') 22 cc = conf.cmd_to_list(cc) 23 23 24 25 26 27 28 24 try: 25 if not Utils.cmd_output(cc + ['-V']): 26 conf.fatal('tru64cc %r was not found' % cc) 27 except ValueError: 28 conf.fatal('tru64cc -V could not be executed') 29 29 30 31 30 v['CC'] = cc 31 v['CC_NAME'] = 'tru64' 32 32 33 33 @conftest 34 34 def tru64cc_common_flags(conf): 35 35 v = conf.env 36 36 37 38 39 37 v['CC_SRC_F'] = '' 38 v['CC_TGT_F'] = ['-c', '-o', ''] 39 v['CPPPATH_ST'] = '-I%s' # template for adding include paths 40 40 41 42 43 44 41 # linker 42 if not v['LINK_CC']: v['LINK_CC'] = v['CC'] 43 v['CCLNK_SRC_F'] = '' 44 v['CCLNK_TGT_F'] = ['-o', ''] 45 45 46 47 48 49 50 46 v['LIB_ST'] = '-l%s' # template for adding libs 47 v['LIBPATH_ST'] = '-L%s' # template for adding libpaths 48 v['STATICLIB_ST'] = '-l%s' 49 v['STATICLIBPATH_ST'] = '-L%s' 50 v['CCDEFINES_ST'] = '-D%s' 51 51 52 # 53 # 54 # 52 # v['SONAME_ST'] = '-Wl,-h -Wl,%s' 53 # v['SHLIB_MARKER'] = '-Bdynamic' 54 # v['STATICLIB_MARKER'] = '-Bstatic' 55 55 56 57 56 # program 57 v['program_PATTERN'] = '%s' 58 58 59 60 # 61 62 59 # shared library 60 # v['shlib_CCFLAGS'] = ['-Kpic', '-DPIC'] 61 v['shlib_LINKFLAGS'] = ['-shared'] 62 v['shlib_PATTERN'] = 'lib%s.so' 63 63 64 65 # 66 # 64 # static lib 65 # v['staticlib_LINKFLAGS'] = ['-Bstatic'] 66 # v['staticlib_PATTERN'] = 'lib%s.a' 67 67 68 68 detect = ''' -
vendor/current/buildtools/wafsamba/wafsamba.py
r740 r988 17 17 from samba_autoproto import * 18 18 from samba_python import * 19 from samba_perl import * 19 20 from samba_deps import * 20 21 from samba_bundled import * 22 from samba_third_party import * 23 import samba_cross 21 24 import samba_install 22 25 import samba_conftests … … 32 35 import symbols 33 36 import pkgconfig 37 import configure_file 34 38 35 39 # some systems have broken threading in python … … 64 68 # to be expressed in terms of build directory paths 65 69 mkdir_p(os.path.join(conf.blddir, 'default')) 66 for p in ['python','shared', 'modules']:67 link_target = os.path.join(conf.blddir, 'default/' + p)70 for (source, target) in [('shared', 'shared'), ('modules', 'modules'), ('python', 'python_modules')]: 71 link_target = os.path.join(conf.blddir, 'default/' + target) 68 72 if not os.path.lexists(link_target): 69 os.symlink('../' + p, link_target)73 os.symlink('../' + source, link_target) 70 74 71 75 # get perl to put the blib files in the build directory … … 92 96 93 97 98 def generate_empty_file(task): 99 task.outputs[0].write('') 100 return 0 94 101 95 102 ################################################################# … … 100 107 public_headers=None, 101 108 public_headers_install=True, 109 private_headers=None, 102 110 header_path=None, 103 111 pc_files=None, … … 108 116 external_library=False, 109 117 realname=None, 118 keep_underscore=False, 110 119 autoproto=None, 111 group='libraries', 120 autoproto_extra_source='', 121 group='main', 112 122 depends_on='', 113 123 local_include=True, … … 120 130 pyext=False, 121 131 target_type='LIBRARY', 122 bundled_extension=True, 132 bundled_extension=False, 133 bundled_name=None, 123 134 link_name=None, 124 135 abi_directory=None, … … 129 140 grouping_library=False, 130 141 allow_undefined_symbols=False, 142 allow_warnings=False, 131 143 enabled=True): 132 144 '''define a Samba library''' 145 146 if pyembed and bld.env['IS_EXTRA_PYTHON']: 147 public_headers = pc_files = None 148 149 if private_library and public_headers: 150 raise Utils.WafError("private library '%s' must not have public header files" % 151 libname) 152 153 if LIB_MUST_BE_PRIVATE(bld, libname): 154 private_library = True 133 155 134 156 if not enabled: … … 141 163 142 164 # remember empty libraries, so we can strip the dependencies 143 if ((source == '') or (source == [])) and deps == '' and public_deps == '': 144 SET_TARGET_TYPE(bld, libname, 'EMPTY') 145 return 165 if ((source == '') or (source == [])): 166 if deps == '' and public_deps == '': 167 SET_TARGET_TYPE(bld, libname, 'EMPTY') 168 return 169 empty_c = libname + '.empty.c' 170 bld.SAMBA_GENERATOR('%s_empty_c' % libname, 171 rule=generate_empty_file, 172 target=empty_c) 173 source=empty_c 146 174 147 175 if BUILTIN_LIBRARY(bld, libname): … … 165 193 public_headers = public_headers, 166 194 public_headers_install = public_headers_install, 195 private_headers= private_headers, 167 196 header_path = header_path, 168 197 cflags = cflags, 169 198 group = subsystem_group, 170 199 autoproto = autoproto, 200 autoproto_extra_source=autoproto_extra_source, 171 201 depends_on = depends_on, 172 202 hide_symbols = hide_symbols, 173 pyext = pyext or (target_type == "PYTHON"), 203 allow_warnings = allow_warnings, 204 pyembed = pyembed, 205 pyext = pyext, 174 206 local_include = local_include, 175 207 global_include = global_include) … … 190 222 191 223 # we don't want any public libraries without version numbers 192 if not private_library and vnum is None and soname is None and target_type != 'PYTHON' and not realname: 193 raise Utils.WafError("public library '%s' must have a vnum" % libname) 194 195 if target_type == 'PYTHON' or realname or not private_library: 196 bundled_name = libname.replace('_', '-') 224 if (not private_library and target_type != 'PYTHON' and not realname): 225 if vnum is None and soname is None: 226 raise Utils.WafError("public library '%s' must have a vnum" % 227 libname) 228 if pc_files is None and not bld.env['IS_EXTRA_PYTHON']: 229 raise Utils.WafError("public library '%s' must have pkg-config file" % 230 libname) 231 if public_headers is None and not bld.env['IS_EXTRA_PYTHON']: 232 raise Utils.WafError("public library '%s' must have header files" % 233 libname) 234 235 if bundled_name is not None: 236 pass 237 elif target_type == 'PYTHON' or realname or not private_library: 238 if keep_underscore: 239 bundled_name = libname 240 else: 241 bundled_name = libname.replace('_', '-') 197 242 else: 198 bundled_name = PRIVATE_NAME(bld, libname, bundled_extension, private_library) 243 assert (private_library == True and realname is None) 244 if abi_directory or vnum or soname: 245 bundled_extension=True 246 bundled_name = PRIVATE_NAME(bld, libname.replace('_', '-'), 247 bundled_extension, private_library) 199 248 200 249 ldflags = TO_LIST(ldflags) 201 202 features = 'cc cshlib symlink_lib install_lib' 203 if target_type == 'PYTHON': 250 if bld.env['ENABLE_RELRO'] is True: 251 ldflags.extend(TO_LIST('-Wl,-z,relro,-z,now')) 252 253 features = 'c cshlib symlink_lib install_lib' 254 if pyext: 204 255 features += ' pyext' 205 if pyext or pyembed: 206 # this is quite strange. we should add pyext feature for pyext 207 # but that breaks the build. This may be a bug in the waf python tool 256 if pyembed: 208 257 features += ' pyembed' 209 258 210 259 if abi_directory: 211 260 features += ' abi_check' 261 262 if pyembed and bld.env['PYTHON_SO_ABI_FLAG']: 263 # For ABI checking, we don't care about the exact Python version. 264 # Replace the Python ABI tag (e.g. ".cpython-35m") by a generic ".py3" 265 abi_flag = bld.env['PYTHON_SO_ABI_FLAG'] 266 replacement = '.py%s' % bld.env['PYTHON_VERSION'].split('.')[0] 267 version_libname = libname.replace(abi_flag, replacement) 268 else: 269 version_libname = libname 212 270 213 271 vscript = None … … 221 279 if version: 222 280 vscript = "%s.vscript" % libname 223 bld.ABI_VSCRIPT( libname, abi_directory, version, vscript,281 bld.ABI_VSCRIPT(version_libname, abi_directory, version, vscript, 224 282 abi_match) 225 283 fullname = apply_pattern(bundled_name, bld.env.shlib_PATTERN) … … 231 289 raise Utils.WafError("unable to find vscript path for %s" % vscript) 232 290 bld.add_manual_dependency(fullpath, vscriptpath) 233 if Options.is_install:291 if bld.is_install: 234 292 # also make the .inst file depend on the vscript 235 293 instname = apply_pattern(bundled_name + '.inst', bld.env.shlib_PATTERN) … … 247 305 samba_includes = includes, 248 306 version_script = vscript, 307 version_libname = version_libname, 249 308 local_include = local_include, 250 309 global_include = global_include, … … 269 328 t.link_name = link_name 270 329 271 if pc_files is not None :330 if pc_files is not None and not private_library: 272 331 bld.PKG_CONFIG_FILES(pc_files, vnum=vnum) 273 332 274 if manpages is not None and 'XSLTPROC_MANPAGES' in bld.env and bld.env['XSLTPROC_MANPAGES']: 275 bld.MANPAGES(manpages) 333 if (manpages is not None and 'XSLTPROC_MANPAGES' in bld.env and 334 bld.env['XSLTPROC_MANPAGES']): 335 bld.MANPAGES(manpages, install) 276 336 277 337 … … 284 344 includes='', 285 345 public_headers=None, 346 private_headers=None, 286 347 header_path=None, 287 348 modules=None, … … 292 353 use_global_deps=True, 293 354 compiler=None, 294 group=' binaries',355 group='main', 295 356 manpages=None, 296 357 local_include=True, … … 312 373 return 313 374 314 features = 'c ccprogram symlink_bin install_bin'375 features = 'c cprogram symlink_bin install_bin' 315 376 if pyembed: 316 377 features += ' pyembed' … … 327 388 else: 328 389 subsystem_group = group 390 391 # only specify PIE flags for binaries 392 pie_cflags = cflags 393 pie_ldflags = TO_LIST(ldflags) 394 if bld.env['ENABLE_PIE'] is True: 395 pie_cflags += ' -fPIE' 396 pie_ldflags.extend(TO_LIST('-pie')) 397 if bld.env['ENABLE_RELRO'] is True: 398 pie_ldflags.extend(TO_LIST('-Wl,-z,relro,-z,now')) 329 399 330 400 # first create a target for building the object files for this binary … … 335 405 deps = deps, 336 406 includes = includes, 337 cflags = cflags,407 cflags = pie_cflags, 338 408 group = subsystem_group, 339 409 autoproto = autoproto, … … 365 435 samba_inst_path= install_path, 366 436 samba_install = install, 367 samba_ldflags = TO_LIST(ldflags)437 samba_ldflags = pie_ldflags 368 438 ) 369 439 370 440 if manpages is not None and 'XSLTPROC_MANPAGES' in bld.env and bld.env['XSLTPROC_MANPAGES']: 371 bld.MANPAGES(manpages )441 bld.MANPAGES(manpages, install) 372 442 373 443 Build.BuildContext.SAMBA_BINARY = SAMBA_BINARY … … 391 461 enabled=True, 392 462 pyembed=False, 393 allow_undefined_symbols=False 463 manpages=None, 464 allow_undefined_symbols=False, 465 allow_warnings=False 394 466 ): 395 467 '''define a Samba module.''' 468 469 bld.ASSERT(subsystem, "You must specify a subsystem for SAMBA_MODULE(%s)" % modname) 396 470 397 471 source = bld.EXPAND_VARIABLES(source, vars=vars) … … 400 474 401 475 if internal_module or BUILTIN_LIBRARY(bld, modname): 476 # Do not create modules for disabled subsystems 477 if GET_TARGET_TYPE(bld, subsystem) == 'DISABLED': 478 return 402 479 bld.SAMBA_SUBSYSTEM(modname, source, 403 480 deps=deps, … … 408 485 local_include=local_include, 409 486 global_include=global_include, 487 allow_warnings=allow_warnings, 410 488 enabled=enabled) 411 489 … … 417 495 return 418 496 419 obj_target = modname + '.objlist' 497 # Do not create modules for disabled subsystems 498 if GET_TARGET_TYPE(bld, subsystem) == 'DISABLED': 499 return 420 500 421 501 realname = modname 422 if subsystem is not None: 423 deps += ' ' + subsystem 424 while realname.startswith("lib"+subsystem+"_"): 425 realname = realname[len("lib"+subsystem+"_"):] 426 while realname.startswith(subsystem+"_"): 427 realname = realname[len(subsystem+"_"):] 502 deps += ' ' + subsystem 503 while realname.startswith("lib"+subsystem+"_"): 504 realname = realname[len("lib"+subsystem+"_"):] 505 while realname.startswith(subsystem+"_"): 506 realname = realname[len(subsystem+"_"):] 507 508 build_name = "%s_module_%s" % (subsystem, realname) 428 509 429 510 realname = bld.make_libname(realname) … … 446 527 global_include=global_include, 447 528 vars=vars, 529 bundled_name=build_name, 448 530 link_name=build_link_name, 449 531 install_path="${MODULESDIR}/%s" % subsystem, 450 532 pyembed=pyembed, 451 allow_undefined_symbols=allow_undefined_symbols 533 manpages=manpages, 534 allow_undefined_symbols=allow_undefined_symbols, 535 allow_warnings=allow_warnings 452 536 ) 453 537 … … 463 547 public_headers=None, 464 548 public_headers_install=True, 549 private_headers=None, 465 550 header_path=None, 466 551 cflags='', 467 552 cflags_end=None, 468 553 group='main', 469 init_function_sentin al=None,554 init_function_sentinel=None, 470 555 autoproto=None, 471 556 autoproto_extra_source='', … … 481 566 subdir=None, 482 567 hide_symbols=False, 483 pyext=False): 568 allow_warnings=False, 569 pyext=False, 570 pyembed=False): 484 571 '''define a Samba subsystem''' 485 572 … … 489 576 490 577 # remember empty subsystems, so we can strip the dependencies 491 if ((source == '') or (source == [])) and deps == '' and public_deps == '': 492 SET_TARGET_TYPE(bld, modname, 'EMPTY') 493 return 578 if ((source == '') or (source == [])): 579 if deps == '' and public_deps == '': 580 SET_TARGET_TYPE(bld, modname, 'EMPTY') 581 return 582 empty_c = modname + '.empty.c' 583 bld.SAMBA_GENERATOR('%s_empty_c' % modname, 584 rule=generate_empty_file, 585 target=empty_c) 586 source=empty_c 494 587 495 588 if not SET_TARGET_TYPE(bld, modname, 'SUBSYSTEM'): … … 505 598 bld.SET_BUILD_GROUP(group) 506 599 507 features = 'c c'600 features = 'c' 508 601 if pyext: 509 602 features += ' pyext' 603 if pyembed: 604 features += ' pyembed' 510 605 511 606 t = bld( … … 513 608 source = source, 514 609 target = modname, 515 samba_cflags = CURRENT_CFLAGS(bld, modname, cflags, hide_symbols=hide_symbols), 610 samba_cflags = CURRENT_CFLAGS(bld, modname, cflags, 611 allow_warnings=allow_warnings, 612 hide_symbols=hide_symbols), 516 613 depends_on = depends_on, 517 614 samba_deps = TO_LIST(deps), … … 522 619 samba_subsystem= subsystem_name, 523 620 samba_use_hostcc = use_hostcc, 524 samba_use_global_deps = use_global_deps 621 samba_use_global_deps = use_global_deps, 525 622 ) 526 623 … … 543 640 public_headers=None, 544 641 public_headers_install=True, 642 private_headers=None, 545 643 header_path=None, 546 644 vars=None, 645 dep_vars=[], 547 646 always=False): 548 647 '''A generic source generator target''' … … 553 652 if not enabled: 554 653 return 654 655 dep_vars.append('ruledeps') 656 dep_vars.append('SAMBA_GENERATOR_VARS') 555 657 556 658 bld.SET_BUILD_GROUP(group) … … 560 662 target=target, 561 663 shell=isinstance(rule, str), 562 on_results=True,664 update_outputs=True, 563 665 before='cc', 564 666 ext_out='.c', 565 667 samba_type='GENERATOR', 566 dep_vars = [rule] + (vars or []),668 dep_vars = dep_vars, 567 669 name=name) 670 671 if vars is None: 672 vars = {} 673 t.env.SAMBA_GENERATOR_VARS = vars 568 674 569 675 if always: … … 578 684 579 685 580 @ runonce686 @Utils.run_once 581 687 def SETUP_BUILD_GROUPS(bld): 582 688 '''setup build groups used to ensure that the different build … … 597 703 bld.add_group('main') 598 704 bld.add_group('symbolcheck') 599 bld.add_group('libraries')600 bld.add_group('binaries')601 705 bld.add_group('syslibcheck') 602 706 bld.add_group('final') … … 629 733 630 734 631 632 t = Task.simple_task_type('copy_script', 'rm -f "${LINK_TARGET}" && ln -s "${SRC[0].abspath(env)}" ${LINK_TARGET}',633 shell=True, color='PINK', ext_in='.bin')634 t.quiet = True635 636 @feature('copy_script')637 @before('apply_link')638 def copy_script(self):639 tsk = self.create_task('copy_script', self.allnodes[0])640 tsk.env.TARGET = self.target641 642 735 def SAMBA_SCRIPT(bld, name, pattern, installdir, installname=None): 643 736 '''used to copy scripts from the source tree into the build directory 644 737 for use by selftest''' 645 738 646 source = bld.path.ant_glob(pattern )739 source = bld.path.ant_glob(pattern, flat=True) 647 740 648 741 bld.SET_BUILD_GROUP('build_source') 649 742 for s in TO_LIST(source): 650 743 iname = s 651 if installname !=None:744 if installname is not None: 652 745 iname = installname 653 746 target = os.path.join(installdir, iname) 654 747 tgtdir = os.path.dirname(os.path.join(bld.srcnode.abspath(bld.env), '..', target)) 655 748 mkdir_p(tgtdir) 656 t = bld(features='copy_script', 657 source = s, 658 target = target, 659 always = True, 660 install_path = None) 661 t.env.LINK_TARGET = target 662 749 link_src = os.path.normpath(os.path.join(bld.curdir, s)) 750 link_dst = os.path.join(tgtdir, os.path.basename(iname)) 751 if os.path.islink(link_dst) and os.readlink(link_dst) == link_src: 752 continue 753 if os.path.exists(link_dst): 754 os.unlink(link_dst) 755 Logs.info("symlink: %s -> %s/%s" % (s, installdir, iname)) 756 os.symlink(link_src, link_dst) 663 757 Build.BuildContext.SAMBA_SCRIPT = SAMBA_SCRIPT 758 664 759 665 760 def copy_and_fix_python_path(task): … … 673 768 sys.path.insert(1, "%s")""" % (task.env["PYTHONARCHDIR"], task.env["PYTHONDIR"]) 674 769 770 if task.env["PYTHON"][0] == "/": 771 replacement_shebang = "#!%s\n" % task.env["PYTHON"] 772 else: 773 replacement_shebang = "#!/usr/bin/env %s\n" % task.env["PYTHON"] 774 675 775 installed_location=task.outputs[0].bldpath(task.env) 676 776 source_file = open(task.inputs[0].srcpath(task.env)) 677 777 installed_file = open(installed_location, 'w') 778 lineno = 0 678 779 for line in source_file: 679 780 newline = line 680 if pattern in line: 781 if (lineno == 0 and task.env["PYTHON_SPECIFIED"] is True and 782 line[:2] == "#!"): 783 newline = replacement_shebang 784 elif pattern in line: 681 785 newline = line.replace(pattern, replacement) 682 786 installed_file.write(newline) 787 lineno = lineno + 1 683 788 installed_file.close() 684 789 os.chmod(installed_location, 0755) 685 790 return 0 686 791 792 def copy_and_fix_perl_path(task): 793 pattern='use lib "$RealBin/lib";' 794 795 replacement = "" 796 if not task.env["PERL_LIB_INSTALL_DIR"] in task.env["PERL_INC"]: 797 replacement = 'use lib "%s";' % task.env["PERL_LIB_INSTALL_DIR"] 798 799 if task.env["PERL"][0] == "/": 800 replacement_shebang = "#!%s\n" % task.env["PERL"] 801 else: 802 replacement_shebang = "#!/usr/bin/env %s\n" % task.env["PERL"] 803 804 installed_location=task.outputs[0].bldpath(task.env) 805 source_file = open(task.inputs[0].srcpath(task.env)) 806 installed_file = open(installed_location, 'w') 807 lineno = 0 808 for line in source_file: 809 newline = line 810 if lineno == 0 and task.env["PERL_SPECIFIED"] == True and line[:2] == "#!": 811 newline = replacement_shebang 812 elif pattern in line: 813 newline = line.replace(pattern, replacement) 814 installed_file.write(newline) 815 lineno = lineno + 1 816 installed_file.close() 817 os.chmod(installed_location, 0755) 818 return 0 819 687 820 688 821 def install_file(bld, destdir, file, chmod=MODE_644, flat=False, 689 python_fixup=False, destname=None, base_name=None): 822 python_fixup=False, perl_fixup=False, 823 destname=None, base_name=None): 690 824 '''install a file''' 691 825 destdir = bld.EXPAND_VARIABLES(destdir) … … 696 830 dest = os.path.join(destdir, destname) 697 831 if python_fixup: 698 # fix up the python path itwill use to find Samba modules832 # fix the path python will use to find Samba modules 699 833 inst_file = file + '.inst' 700 834 bld.SAMBA_GENERATOR('python_%s' % destname, 701 835 rule=copy_and_fix_python_path, 836 dep_vars=["PYTHON","PYTHON_SPECIFIED","PYTHONDIR","PYTHONARCHDIR"], 837 source=file, 838 target=inst_file) 839 file = inst_file 840 if perl_fixup: 841 # fix the path perl will use to find Samba modules 842 inst_file = file + '.inst' 843 bld.SAMBA_GENERATOR('perl_%s' % destname, 844 rule=copy_and_fix_perl_path, 845 dep_vars=["PERL","PERL_SPECIFIED","PERL_LIB_INSTALL_DIR"], 702 846 source=file, 703 847 target=inst_file) … … 709 853 710 854 def INSTALL_FILES(bld, destdir, files, chmod=MODE_644, flat=False, 711 python_fixup=False, destname=None, base_name=None): 855 python_fixup=False, perl_fixup=False, 856 destname=None, base_name=None): 712 857 '''install a set of files''' 713 858 for f in TO_LIST(files): 714 859 install_file(bld, destdir, f, chmod=chmod, flat=flat, 715 python_fixup=python_fixup, destname=destname,716 base_name=base_name)860 python_fixup=python_fixup, perl_fixup=perl_fixup, 861 destname=destname, base_name=base_name) 717 862 Build.BuildContext.INSTALL_FILES = INSTALL_FILES 718 863 … … 721 866 python_fixup=False, exclude=None, trim_path=None): 722 867 '''install a set of files matching a wildcard pattern''' 723 files=TO_LIST(bld.path.ant_glob(pattern ))868 files=TO_LIST(bld.path.ant_glob(pattern, flat=True)) 724 869 if trim_path: 725 870 files2 = [] … … 746 891 747 892 748 def MANPAGES(bld, manpages ):893 def MANPAGES(bld, manpages, install): 749 894 '''build and install manual pages''' 750 895 bld.env.MAN_XSL = 'http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl' … … 755 900 target=m, 756 901 group='final', 757 rule='${XSLTPROC} -o ${TGT} --nonet ${MAN_XSL} ${SRC}' 902 rule='${XSLTPROC} --xinclude -o ${TGT} --nonet ${MAN_XSL} ${SRC}' 903 ) 904 if install: 905 bld.INSTALL_FILES('${MANDIR}/man%s' % m[-1], m, flat=True) 906 Build.BuildContext.MANPAGES = MANPAGES 907 908 def SAMBAMANPAGES(bld, manpages, extra_source=None): 909 '''build and install manual pages''' 910 bld.env.SAMBA_EXPAND_XSL = bld.srcnode.abspath() + '/docs-xml/xslt/expand-sambadoc.xsl' 911 bld.env.SAMBA_MAN_XSL = bld.srcnode.abspath() + '/docs-xml/xslt/man.xsl' 912 bld.env.SAMBA_CATALOG = bld.srcnode.abspath() + '/bin/default/docs-xml/build/catalog.xml' 913 bld.env.SAMBA_CATALOGS = 'file:///etc/xml/catalog file:///usr/local/share/xml/catalog file://' + bld.env.SAMBA_CATALOG 914 915 for m in manpages.split(): 916 source = m + '.xml' 917 if extra_source is not None: 918 source = [source, extra_source] 919 bld.SAMBA_GENERATOR(m, 920 source=source, 921 target=m, 922 group='final', 923 dep_vars=['SAMBA_MAN_XSL', 'SAMBA_EXPAND_XSL', 'SAMBA_CATALOG'], 924 rule='''XML_CATALOG_FILES="${SAMBA_CATALOGS}" 925 export XML_CATALOG_FILES 926 ${XSLTPROC} --xinclude --stringparam noreference 0 -o ${TGT}.xml --nonet ${SAMBA_EXPAND_XSL} ${SRC[0].abspath(env)} 927 ${XSLTPROC} --nonet -o ${TGT} ${SAMBA_MAN_XSL} ${TGT}.xml''' 758 928 ) 759 929 bld.INSTALL_FILES('${MANDIR}/man%s' % m[-1], m, flat=True) 760 Build.BuildContext.MANPAGES = MANPAGES 761 930 Build.BuildContext.SAMBAMANPAGES = SAMBAMANPAGES 762 931 763 932 ############################################################# -
vendor/current/buildtools/wafsamba/wscript
r740 r988 3 3 # this is a base set of waf rules that everything else pulls in first 4 4 5 import sys, wafsamba, Configure, Logs6 import Options, os, preproc7 from samba_utils import *5 import os, sys 6 import wafsamba, Configure, Logs, Options, Utils 7 from samba_utils import os_path_relpath 8 8 from optparse import SUPPRESS_HELP 9 9 … … 28 28 action="store", dest='BUNDLED_LIBS', default='') 29 29 30 gr.add_option('--private-libraries', 31 help=("comma separated list of normally public libraries to build instead as private libraries. May include !LIBNAME to disable making a library private. Can be 'NONE' or 'ALL' [auto]"), 32 action="store", dest='PRIVATE_LIBS', default='') 33 30 34 extension_default = Options.options['PRIVATE_EXTENSION_DEFAULT'] 31 35 gr.add_option('--private-library-extension', … … 38 42 action="store", dest='PRIVATE_EXTENSION_EXCEPTION', default=extension_exception) 39 43 40 builtin_defau ilt = Options.options['BUILTIN_LIBRARIES_DEFAULT']44 builtin_default = Options.options['BUILTIN_LIBRARIES_DEFAULT'] 41 45 gr.add_option('--builtin-libraries', 42 help=("command separated list of libraries to build directly into binaries [%s]" % builtin_defau ilt),43 action="store", dest='BUILTIN_LIBRARIES', default=builtin_defau ilt)46 help=("command separated list of libraries to build directly into binaries [%s]" % builtin_default), 47 action="store", dest='BUILTIN_LIBRARIES', default=builtin_default) 44 48 45 49 gr.add_option('--minimum-library-version', … … 47 51 action="store", dest='MINIMUM_LIBRARY_VERSION', default='') 48 52 49 gr.add_option('--disable-shared',50 help=("Disable all use of shared libraries"),51 action="store_true", dest='disable_shared', default=False)52 53 gr.add_option('--disable-rpath', 53 54 help=("Disable use of rpath for build binaries"), … … 74 75 action="store", dest='PRIVATELIBDIR', default=None) 75 76 77 opt.add_option('--with-libiconv', 78 help='additional directory to search for libiconv', 79 action='store', dest='iconv_open', default='/usr/local', 80 match = ['Checking for library iconv', 'Checking for iconv_open', 'Checking for header iconv.h']) 81 opt.add_option('--without-gettext', 82 help=("Disable use of gettext"), 83 action="store_true", dest='disable_gettext', default=False) 84 76 85 gr = opt.option_group('developer options') 77 86 … … 82 91 help='enable automatic reconfigure on build', 83 92 action='store_true', dest='enable_auto_reconfigure') 93 gr.add_option('--enable-debug', 94 help=("Turn on debugging symbols"), 95 action="store_true", dest='debug', default=False) 84 96 gr.add_option('--enable-developer', 85 97 help=("Turn on developer warnings and debugging"), 86 98 action="store_true", dest='developer', default=False) 99 def picky_developer_callback(option, opt_str, value, parser): 100 parser.values.developer = True 101 parser.values.picky_developer = True 87 102 gr.add_option('--picky-developer', 88 103 help=("Treat all warnings as errors (enable -Werror)"), 89 action="store_true", dest='picky_developer', default=False) 104 action="callback", callback=picky_developer_callback, 105 dest='picky_developer', default=False) 90 106 gr.add_option('--fatal-errors', 91 107 help=("Stop compilation on first error (enable -Wfatal-errors)"), … … 103 119 help=("mark version with + if local git changes"), 104 120 action='store_true', dest='GIT_LOCAL_CHANGES', default=False) 121 gr.add_option('--address-sanitizer', 122 help=("Enable address sanitizer compile and linker flags"), 123 action="store_true", dest='address_sanitizer', default=False) 105 124 106 125 gr.add_option('--abi-check', … … 121 140 help=("check symbols in object files against project rules"), 122 141 action='store_true', dest='SYMBOLCHECK', default=False) 142 143 gr.add_option('--dup-symbol-check', 144 help=("check for duplicate symbols in object files and system libs (must be configured with --enable-developer)"), 145 action='store_true', dest='DUP_SYMBOLCHECK', default=False) 123 146 124 147 gr.add_option('--why-needed', … … 153 176 help=SUPPRESS_HELP, 154 177 action='store', dest='AUTOCONF_HOST', default='') 178 opt.add_option('--target', 179 help=SUPPRESS_HELP, 180 action='store', dest='AUTOCONF_TARGET', default='') 155 181 opt.add_option('--program-prefix', 156 182 help=SUPPRESS_HELP, … … 159 185 help=SUPPRESS_HELP, 160 186 action='store_true', dest='AUTOCONF_DISABLE_DEPENDENCY_TRACKING', default=False) 187 opt.add_option('--disable-silent-rules', 188 help=SUPPRESS_HELP, 189 action='store_true', dest='AUTOCONF_DISABLE_SILENT_RULES', default=False) 161 190 162 191 gr = opt.option_group('dist options') … … 168 197 type='string', action='store', dest='TAG_RELEASE') 169 198 170 171 @wafsamba.runonce 199 opt.add_option('--extra-python', type=str, 200 help=("build selected libraries for the specified " 201 "additional version of Python " 202 "(example: --extra-python=/usr/bin/python3)"), 203 metavar="PYTHON", dest='EXTRA_PYTHON', default=None) 204 205 206 @Utils.run_once 172 207 def configure(conf): 173 208 conf.env.hlist = [] … … 182 217 conf.check_tool('gnu_dirs') 183 218 conf.check_tool('wafsamba') 219 conf.check_tool('print_commands') 184 220 185 221 conf.CHECK_CC_ENV() 186 222 187 223 conf.check_tool('compiler_cc') 224 225 conf.CHECK_STANDARD_LIBPATH() 188 226 189 227 # we need git for 'waf dist' … … 192 230 # older gcc versions (< 4.4) does not work with gccdeps, so we have to see if the .d file is generated 193 231 if Options.options.enable_gccdeps: 232 # stale file removal - the configuration may pick up the old .pyc file 233 p = os.path.join(conf.srcdir, 'buildtools/wafsamba/gccdeps.pyc') 234 if os.path.exists(p): 235 os.remove(p) 236 194 237 from TaskGen import feature, after 195 238 @feature('testd') … … 206 249 try: 207 250 try: 208 conf.check(features='c ctestd', fragment='int main() {return 0;}\n', ccflags=['-MD'], mandatory=True, msg='Check for -MD')251 conf.check(features='c testd', fragment='int main() {return 0;}\n', ccflags=['-MD'], mandatory=True, msg='Check for -MD') 209 252 except: 210 253 pass … … 221 264 conf.env.PRIVATELIBDIR = Options.options.PRIVATELIBDIR 222 265 conf.env.BUNDLED_LIBS = Options.options.BUNDLED_LIBS.split(',') 266 conf.env.PRIVATE_LIBS = Options.options.PRIVATE_LIBS.split(',') 223 267 conf.env.BUILTIN_LIBRARIES = Options.options.BUILTIN_LIBRARIES.split(',') 224 conf.env.DISABLE_SHARED = Options.options.disable_shared225 268 conf.env.NONSHARED_BINARIES = Options.options.NONSHARED_BINARIES.split(',') 226 269 … … 236 279 conf.env.AUTOCONF_HOST = Options.options.AUTOCONF_HOST 237 280 conf.env.AUTOCONF_PROGRAM_PREFIX = Options.options.AUTOCONF_PROGRAM_PREFIX 281 282 conf.env.EXTRA_PYTHON = Options.options.EXTRA_PYTHON 238 283 239 284 if (conf.env.AUTOCONF_HOST and … … 271 316 msg='Checking simple C program') 272 317 273 # see if we can build shared libs 274 if not conf.CHECK_LIBRARY_SUPPORT(): 275 conf.env.DISABLE_SHARED = True 318 # Try to find the right extra flags for -Werror behaviour 319 for f in ["-Werror", # GCC 320 "-errwarn=%all", # Sun Studio 321 "-qhalt=w", # IBM xlc 322 "-w2", # Tru64 323 ]: 324 if conf.CHECK_CFLAGS([f], ''' 325 '''): 326 if not 'WERROR_CFLAGS' in conf.env: 327 conf.env['WERROR_CFLAGS'] = [] 328 conf.env['WERROR_CFLAGS'].extend([f]) 329 break 330 331 # check which compiler/linker flags are needed for rpath support 332 if not conf.CHECK_LDFLAGS(['-Wl,-rpath,.']) and conf.CHECK_LDFLAGS(['-Wl,-R,.']): 333 conf.env['RPATH_ST'] = '-Wl,-R,%s' 276 334 277 335 # check for rpath 278 if not conf.env.DISABLE_SHARED andconf.CHECK_LIBRARY_SUPPORT(rpath=True):336 if conf.CHECK_LIBRARY_SUPPORT(rpath=True): 279 337 support_rpath = True 280 338 conf.env.RPATH_ON_BUILD = not Options.options.disable_rpath_build … … 296 354 conf.env.PRIVATELIBDIR = conf.env.LIBDIR 297 355 298 if (not conf.env.DISABLE_SHARED and 299 not Options.options.disable_symbol_versions and 356 if (not Options.options.disable_symbol_versions and 300 357 conf.CHECK_LIBRARY_SUPPORT(rpath=support_rpath, 301 358 version_script=True, … … 305 362 conf.env.HAVE_LD_VERSION_SCRIPT = False 306 363 307 if sys.platform == "aix5": 364 if conf.CHECK_CFLAGS(['-fvisibility=hidden'] + conf.env.WERROR_CFLAGS): 365 conf.env.VISIBILITY_CFLAGS = '-fvisibility=hidden' 366 conf.CHECK_CODE('''int main(void) { return 0; } 367 __attribute__((visibility("default"))) void vis_foo2(void) {}''', 368 cflags=conf.env.VISIBILITY_CFLAGS, 369 define='HAVE_VISIBILITY_ATTR', addmain=False) 370 371 # check HAVE_CONSTRUCTOR_ATTRIBUTE 372 conf.CHECK_CODE(''' 373 void test_constructor_attribute(void) __attribute__ ((constructor)); 374 375 void test_constructor_attribute(void) 376 { 377 return; 378 } 379 380 int main(void) { 381 return 0; 382 } 383 ''', 384 'HAVE_CONSTRUCTOR_ATTRIBUTE', 385 addmain=False, 386 msg='Checking for library constructor support') 387 388 # check HAVE_DESTRUCTOR_ATTRIBUTE 389 conf.CHECK_CODE(''' 390 void test_destructor_attribute(void) __attribute__ ((destructor)); 391 392 void test_destructor_attribute(void) 393 { 394 return; 395 } 396 397 int main(void) { 398 return 0; 399 } 400 ''', 401 'HAVE_DESTRUCTOR_ATTRIBUTE', 402 addmain=False, 403 msg='Checking for library destructor support') 404 405 if sys.platform.startswith('aix'): 308 406 conf.DEFINE('_ALL_SOURCE', 1, add_to_cflags=True) 309 407 # Might not be needed if ALL_SOURCE is defined … … 335 433 336 434 # check for pkgconfig 337 conf. check_cfg(atleast_pkgconfig_version='0.0.0')435 conf.CHECK_CFG(atleast_pkgconfig_version='0.0.0') 338 436 339 437 conf.DEFINE('_GNU_SOURCE', 1, add_to_cflags=True) 340 438 conf.DEFINE('_XOPEN_SOURCE_EXTENDED', 1, add_to_cflags=True) 439 440 # on Tru64 certain features are only available with _OSF_SOURCE set to 1 441 # and _XOPEN_SOURCE set to 600 442 if conf.env['SYSTEM_UNAME_SYSNAME'] == 'OSF1': 443 conf.DEFINE('_OSF_SOURCE', 1, add_to_cflags=True) 444 conf.DEFINE('_XOPEN_SOURCE', 600, add_to_cflags=True) 445 446 # SCM_RIGHTS is only avail if _XOPEN_SOURCE iÑ defined on IRIX 447 if conf.env['SYSTEM_UNAME_SYSNAME'] == 'IRIX': 448 conf.DEFINE('_XOPEN_SOURCE', 600, add_to_cflags=True) 449 conf.DEFINE('_BSD_TYPES', 1, add_to_cflags=True) 450 451 # Try to find the right extra flags for C99 initialisers 452 for f in ["", "-AC99", "-qlanglvl=extc99", "-qlanglvl=stdc99", "-c99"]: 453 if conf.CHECK_CFLAGS([f], ''' 454 struct foo {int x;char y;}; 455 struct foo bar = { .y = 'X', .x = 1 }; 456 '''): 457 if f != "": 458 conf.ADD_CFLAGS(f) 459 break 341 460 342 461 # get the base headers we'll use for the rest of the tests … … 344 463 add_headers=True) 345 464 conf.CHECK_HEADERS('strings.h inttypes.h stdint.h unistd.h minix/config.h', add_headers=True) 346 conf.CHECK_HEADERS('ctype.h standards.h stdbool.h stdint.h stdarg.h vararg.h', add_headers=True) 465 conf.CHECK_HEADERS('ctype.h', add_headers=True) 466 467 if sys.platform != 'darwin': 468 conf.CHECK_HEADERS('standards.h', add_headers=True) 469 470 conf.CHECK_HEADERS('stdbool.h stdint.h stdarg.h vararg.h', add_headers=True) 347 471 conf.CHECK_HEADERS('limits.h assert.h') 348 472 349 473 # see if we need special largefile flags 350 conf.CHECK_LARGEFILE() 474 if not conf.CHECK_LARGEFILE(): 475 raise Utils.WafError('Samba requires large file support support, but not available on this platform: sizeof(off_t) < 8') 351 476 352 477 if 'HAVE_STDDEF_H' in conf.env and 'HAVE_STDLIB_H' in conf.env: … … 365 490 conf.define('SHLIBEXT', "so", quote=True) 366 491 367 conf.CHECK_CODE('long one = 1; return ((char *)(&one))[0]', 368 execute=True, 369 define='WORDS_BIGENDIAN') 492 # First try a header check for cross-compile friendlyness 493 conf.CHECK_CODE(code = """#ifdef __BYTE_ORDER 494 #define B __BYTE_ORDER 495 #elif defined(BYTE_ORDER) 496 #define B BYTE_ORDER 497 #endif 498 499 #ifdef __LITTLE_ENDIAN 500 #define LITTLE __LITTLE_ENDIAN 501 #elif defined(LITTLE_ENDIAN) 502 #define LITTLE LITTLE_ENDIAN 503 #endif 504 505 #if !defined(LITTLE) || !defined(B) || LITTLE != B 506 #error Not little endian. 507 #endif 508 int main(void) { return 0; }""", 509 addmain=False, 510 headers="endian.h sys/endian.h", 511 define="HAVE_LITTLE_ENDIAN") 512 conf.CHECK_CODE(code = """#ifdef __BYTE_ORDER 513 #define B __BYTE_ORDER 514 #elif defined(BYTE_ORDER) 515 #define B BYTE_ORDER 516 #endif 517 518 #ifdef __BIG_ENDIAN 519 #define BIG __BIG_ENDIAN 520 #elif defined(BIG_ENDIAN) 521 #define BIG BIG_ENDIAN 522 #endif 523 524 #if !defined(BIG) || !defined(B) || BIG != B 525 #error Not big endian. 526 #endif 527 int main(void) { return 0; }""", 528 addmain=False, 529 headers="endian.h sys/endian.h", 530 define="HAVE_BIG_ENDIAN") 531 532 if not conf.CONFIG_SET("HAVE_BIG_ENDIAN") and not conf.CONFIG_SET("HAVE_LITTLE_ENDIAN"): 533 # That didn't work! Do runtime test. 534 conf.CHECK_CODE("""union { int i; char c[sizeof(int)]; } u; 535 u.i = 0x01020304; 536 return u.c[0] == 0x04 && u.c[1] == 0x03 && u.c[2] == 0x02 && u.c[3] == 0x01 ? 0 : 1;""", 537 addmain=True, execute=True, 538 define='HAVE_LITTLE_ENDIAN', 539 msg="Checking for HAVE_LITTLE_ENDIAN - runtime") 540 conf.CHECK_CODE("""union { int i; char c[sizeof(int)]; } u; 541 u.i = 0x01020304; 542 return u.c[0] == 0x01 && u.c[1] == 0x02 && u.c[2] == 0x03 && u.c[3] == 0x04 ? 0 : 1;""", 543 addmain=True, execute=True, 544 define='HAVE_BIG_ENDIAN', 545 msg="Checking for HAVE_BIG_ENDIAN - runtime") 546 547 # Extra sanity check. 548 if conf.CONFIG_SET("HAVE_BIG_ENDIAN") == conf.CONFIG_SET("HAVE_LITTLE_ENDIAN"): 549 Logs.error("Failed endian determination. The PDP-11 is back?") 550 sys.exit(1) 551 else: 552 if conf.CONFIG_SET("HAVE_BIG_ENDIAN"): 553 conf.DEFINE('WORDS_BIGENDIAN', 1) 370 554 371 555 # check if signal() takes a void function
Note:
See TracChangeset
for help on using the changeset viewer.