Ignore:
Timestamp:
Nov 24, 2016, 1:14:11 PM (9 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: update vendor to version 4.4.3

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"""
     6Redistribution and use in source and binary forms, with or without
     7modification, are permitted provided that the following conditions
     8are met:
     9
     101. Redistributions of source code must retain the above copyright
     11   notice, this list of conditions and the following disclaimer.
     12
     132. 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
     173. 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
     20THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
     21IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
     22WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
     23DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
     24INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
     25(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
     26SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     27HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
     28STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
     29IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     30POSSIBILITY OF SUCH DAMAGE.
     31"""
     32
     33import os, sys
     34if sys.hexversion<0x203000f: raise ImportError("Waf requires Python >= 2.3")
     35
     36if 'PSYCOWAF' in os.environ:
     37        try:import psyco;psyco.full()
     38        except:pass
     39
     40VERSION="1.5.19"
     41REVISION="x"
     42INSTALL="x"
     43C1='x'
     44C2='x'
     45cwd = os.getcwd()
     46join = os.path.join
     47
     48WAF='waf'
     49def b(x):
     50        return x
     51
     52if sys.hexversion>0x300000f:
     53        WAF='waf3'
     54        def b(x):
     55                return x.encode()
     56
     57def err(m):
     58        print(('\033[91mError: %s\033[0m' % m))
     59        sys.exit(1)
     60
     61def test(dir):
     62        try: os.stat(join(dir, 'wafadmin')); return os.path.abspath(dir)
     63        except OSError: pass
     64
     65def find_lib():
     66        return os.path.abspath(os.path.join(os.path.dirname(__file__), '../../third_party/waf'))
     67
     68wafdir = find_lib()
     69w = join(wafdir, 'wafadmin')
     70t = join(w, 'Tools')
     71f = join(w, '3rdparty')
     72sys.path = [w, t, f] + sys.path
     73
     74if __name__ == '__main__':
     75        import Scripting
     76        Scripting.prepare(t, cwd, VERSION, wafdir)
     77
  • vendor/current/buildtools/scripts/Makefile.waf

    r740 r988  
    6363
    6464bin/%:: FORCE
    65         $(WAF) --targets=`basename $@`
     65        $(WAF) --targets=$@
    6666FORCE:
    6767
  • vendor/current/buildtools/scripts/abi_gen.sh

    r740 r988  
    1111set width 0
    1212EOF
    13 nm "$SHAREDLIB" | cut -d' ' -f2- | egrep '^[BDGTRVWS]' | grep -v @ | cut -c3- | sort | while read s; do
     13nm "$SHAREDLIB" | cut -d' ' -f2- | egrep '^[BDGTRVWS]' | grep -v @ | egrep -v ' (__bss_start|_edata|_init|_fini|_end)' | cut -c3- | sort | while read s; do
    1414    echo "echo $s: "
    1515    echo p $s
  • vendor/current/buildtools/testwaf.sh

    r740 r988  
    1212    tests="$*"
    1313else
    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"
    1515fi
    1616
     
    2828    make distcheck
    2929    case $d in
    30         "source4/lib/ldb")
     30        "lib/ldb")
    3131            ldd bin/ldbadd
    3232            ;;
  • vendor/current/buildtools/wafsamba/generic_cc.py

    r740 r988  
    1515@conftest
    1616def find_generic_cc(conf):
    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'
     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'
    2626
    2727@conftest
    2828def generic_cc_common_flags(conf):
    29         v = conf.env
     29    v = conf.env
    3030
    31         v['CC_SRC_F']            = ''
    32         v['CC_TGT_F']            = ['-c', '-o', '']
    33         v['CPPPATH_ST']          = '-I%s' # template for adding include paths
     31    v['CC_SRC_F']            = ''
     32    v['CC_TGT_F']            = ['-c', '-o', '']
     33    v['CPPPATH_ST']          = '-I%s' # template for adding include paths
    3434
    35         # linker
    36         if not v['LINK_CC']: v['LINK_CC'] = v['CC']
    37         v['CCLNK_SRC_F']         = ''
    38         v['CCLNK_TGT_F']         = ['-o', '']
     35    # linker
     36    if not v['LINK_CC']: v['LINK_CC'] = v['CC']
     37    v['CCLNK_SRC_F']         = ''
     38    v['CCLNK_TGT_F']         = ['-o', '']
    3939
    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'
     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'
    4545
    46 #       v['SONAME_ST']           = '-Wl,-h -Wl,%s'
    47 #       v['SHLIB_MARKER']        = '-Bdynamic'
    48 #       v['STATICLIB_MARKER']    = '-Bstatic'
     46#    v['SONAME_ST']           = '-Wl,-h -Wl,%s'
     47#    v['SHLIB_MARKER']        = '-Bdynamic'
     48#    v['STATICLIB_MARKER']    = '-Bstatic'
    4949
    50         # program
    51         v['program_PATTERN']     = '%s'
     50    # program
     51    v['program_PATTERN']     = '%s'
    5252
    53         # shared library
    54 #       v['shlib_CCFLAGS']       = ['-Kpic', '-DPIC']
    55 #       v['shlib_LINKFLAGS']     = ['-G']
    56         v['shlib_PATTERN']       = 'lib%s.so'
     53    # shared library
     54#    v['shlib_CCFLAGS']       = ['-Kpic', '-DPIC']
     55#    v['shlib_LINKFLAGS']     = ['-G']
     56    v['shlib_PATTERN']       = 'lib%s.so'
    5757
    58         # static lib
    59 #       v['staticlib_LINKFLAGS'] = ['-Bstatic']
    60 #       v['staticlib_PATTERN']   = 'lib%s.a'
     58    # static lib
     59#    v['staticlib_LINKFLAGS'] = ['-Bstatic']
     60#    v['staticlib_PATTERN']   = 'lib%s.a'
    6161
    6262detect = '''
  • vendor/current/buildtools/wafsamba/irixcc.py

    r740 r988  
    1414@conftest
    1515def find_irixcc(conf):
    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)
     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)
    2323
    24         try:
    25                 if Utils.cmd_output(cc + ['-version']) != '':
    26                         conf.fatal('irixcc %r was not found' % cc)
    27         except ValueError:
    28                 conf.fatal('irixcc -v could not be executed')
     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')
    2929
    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'
    3234
    3335@conftest
    3436def irixcc_common_flags(conf):
    35         v = conf.env
     37    v = conf.env
    3638
    37         v['CC_SRC_F']            = ''
    38         v['CC_TGT_F']            = ['-c', '-o', '']
    39         v['CPPPATH_ST']          = '-I%s' # template for adding include paths
     39    v['CC_SRC_F']            = ''
     40    v['CC_TGT_F']            = ['-c', '-o', '']
     41    v['CPPPATH_ST']          = '-I%s' # template for adding include paths
    4042
    41         # linker
    42         if not v['LINK_CC']: v['LINK_CC'] = v['CC']
    43         v['CCLNK_SRC_F']         = ''
    44         v['CCLNK_TGT_F']         = ['-o', '']
     43    # linker
     44    if not v['LINK_CC']: v['LINK_CC'] = v['CC']
     45    v['CCLNK_SRC_F']         = ''
     46    v['CCLNK_TGT_F']         = ['-o', '']
    4547
    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'
     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'
    5153
    52 #       v['SONAME_ST']           = '-Wl,-h -Wl,%s'
    53 #       v['SHLIB_MARKER']        = '-Bdynamic'
    54 #       v['STATICLIB_MARKER']    = '-Bstatic'
     54#    v['SONAME_ST']           = '-Wl,-h -Wl,%s'
     55#    v['SHLIB_MARKER']        = '-Bdynamic'
     56#    v['STATICLIB_MARKER']    = '-Bstatic'
    5557
    56         # program
    57         v['program_PATTERN']     = '%s'
     58    # program
     59    v['program_PATTERN']     = '%s'
    5860
    59         # shared library
    60 #       v['shlib_CCFLAGS']       = ['-Kpic', '-DPIC']
    61 #       v['shlib_LINKFLAGS']     = ['-G']
    62         v['shlib_PATTERN']       = 'lib%s.so'
     61    # shared library
     62#    v['shlib_CCFLAGS']       = ['-Kpic', '-DPIC']
     63#    v['shlib_LINKFLAGS']     = ['-G']
     64    v['shlib_PATTERN']       = 'lib%s.so'
    6365
    64         # static lib
    65 #       v['staticlib_LINKFLAGS'] = ['-Bstatic']
    66 #       v['staticlib_PATTERN']   = 'lib%s.a'
     66    # static lib
     67#    v['staticlib_LINKFLAGS'] = ['-Bstatic']
     68#    v['staticlib_PATTERN']   = 'lib%s.a'
    6769
    6870detect = '''
  • vendor/current/buildtools/wafsamba/nothreads.py

    r740 r988  
    1 #!/usr/bin/env python
    21# encoding: utf-8
    32# Thomas Nagy, 2005-2008 (ita)
     
    1211"Execute the tasks"
    1312
    14 import sys, random, time, threading, traceback, os
     13import sys, random, threading
    1514try: from Queue import Queue
    1615except ImportError: from queue import Queue
    17 import Build, Utils, Logs, Options
    18 from Logs import debug, error
    19 from Constants import *
     16import Utils, Options
     17from Constants import EXCEPTION, CRASHED, MAXJOBS, ASK_LATER, SKIPPED, SKIP_ME, SUCCESS
    2018
    2119GAP = 15
     
    2321run_old = threading.Thread.run
    2422def run(*args, **kwargs):
    25         try:
    26                 run_old(*args, **kwargs)
    27         except (KeyboardInterrupt, SystemExit):
    28                 raise
    29         except:
    30                 sys.excepthook(*sys.exc_info())
     23    try:
     24        run_old(*args, **kwargs)
     25    except (KeyboardInterrupt, SystemExit):
     26        raise
     27    except:
     28        sys.excepthook(*sys.exc_info())
    3129threading.Thread.run = run
    3230
    3331
    3432class TaskConsumer(object):
    35         consumers = 1
     33    consumers = 1
    3634
    3735def process(tsk):
    38         m = tsk.master
    39         if m.stop:
    40                 m.out.put(tsk)
    41                 return
    42 
    43         try:
    44                 tsk.generator.bld.printout(tsk.display())
    45                 if tsk.__class__.stat: ret = tsk.__class__.stat(tsk)
    46                 # actual call to task's run() function
    47                 else: ret = tsk.call_run()
    48         except Exception, e:
    49                 tsk.err_msg = Utils.ex_stack()
    50                 tsk.hasrun = EXCEPTION
    51 
    52                 # TODO cleanup
    53                 m.error_handler(tsk)
    54                 m.out.put(tsk)
    55                 return
    56 
    57         if ret:
    58                 tsk.err_code = ret
    59                 tsk.hasrun = CRASHED
    60         else:
    61                 try:
    62                         tsk.post_run()
    63                 except Utils.WafError:
    64                         pass
    65                 except Exception:
    66                         tsk.err_msg = Utils.ex_stack()
    67                         tsk.hasrun = EXCEPTION
    68                 else:
    69                         tsk.hasrun = SUCCESS
    70         if tsk.hasrun != SUCCESS:
    71                 m.error_handler(tsk)
    72 
    73         m.out.put(tsk)
     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)
    7472
    7573class 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)
    214214
    215215
  • vendor/current/buildtools/wafsamba/pkgconfig.py

    r740 r988  
    11# handle substitution of variables in pc files
    22
    3 import Build, sys, Logs
    4 from samba_utils import *
     3import os, re, sys
     4import Build, Logs
     5from samba_utils import SUBST_VARS_RECURSIVE, TO_LIST
    56
    67def subst_at_vars(task):
    78    '''substiture @VAR@ style variables in a file'''
    8     src = task.inputs[0].srcpath(task.env)
    9     tgt = task.outputs[0].bldpath(task.env)
    109
    11     f = open(src, 'r')
    12     s = f.read()
    13     f.close()
     10    s = task.inputs[0].read()
    1411    # split on the vars
    1512    a = re.split('(@\w+@)', s)
     
    3835        out.append(v)
    3936    contents = ''.join(out)
    40     f = open(tgt, 'w')
    41     s = f.write(contents)
    42     f.close()
     37    task.outputs[0].write(contents)
    4338    return 0
    4439
     
    5449                                source=f+'.in',
    5550                                target=f)
     51        bld.add_manual_dependency(bld.path.find_or_declare(f), bld.env['PREFIX'])
    5652        t.vars = []
    5753        if t.env.RPATH_ON_INSTALL:
  • vendor/current/buildtools/wafsamba/samba3.py

    r740 r988  
    55from optparse import SUPPRESS_HELP
    66from samba_utils import os_path_relpath, TO_LIST
     7from samba_autoconf import library_flags
     8
    79
    810def SAMBA3_ADD_OPTION(opt, option, help=(), dest=None, default=True,
    911                      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
    1021    if help == ():
    11         help = ("Build with %s support" % option)
     22        help = ("Build with %s support (default=%s)" % (option, default_str))
    1223    if dest is None:
    1324        dest = "with_%s" % option.replace('-', '_')
     
    4758def s3_fix_kwargs(bld, kwargs):
    4859    '''fix the build arguments for s3 build rules to include the
    49         necessary includes, subdir and cflags options '''
     60    necessary includes, subdir and cflags options '''
    5061    s3dir = os.path.join(bld.env.srcdir, 'source3')
    5162    s3reldir = os_path_relpath(s3dir, bld.curdir)
     
    5364    # the extra_includes list is relative to the source3 directory
    5465    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"):
    5668        extra_includes += [ '../source4/heimdal/lib/com_err',
     69                            '../source4/heimdal/lib/krb5',
    5770                            '../source4/heimdal/lib/gssapi',
    58                             '../source4/heimdal_build' ]
     71                            '../source4/heimdal_build',
     72                            '../bin/default/source4/heimdal/lib/asn1' ]
    5973
    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:
    6178        extra_includes += [ '../lib/tdb/include' ]
    6279
    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:
    6484        extra_includes += [ '../lib/tevent' ]
    6585
    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:
    6790        extra_includes += [ '../lib/talloc' ]
    6891
    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:
    7096        extra_includes += [ '../lib/popt' ]
    7197
     
    80106    kwargs['includes'] = includes
    81107
    82     # some S3 code assumes that CONFIGFILE is set
    83     cflags = ['-DCONFIGFILE="%s"' % bld.env['CONFIGFILE']]
    84     if 'cflags' in kwargs:
    85         cflags += TO_LIST(kwargs['cflags'])
    86     kwargs['cflags'] = cflags
    87 
    88108# these wrappers allow for mixing of S3 and S4 build rules in the one build
    89109
    90110def 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)
    94113Build.BuildContext.SAMBA3_LIBRARY = SAMBA3_LIBRARY
    95114
    96115def 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)
    100118Build.BuildContext.SAMBA3_MODULE = SAMBA3_MODULE
    101119
    102120def SAMBA3_SUBSYSTEM(bld, name, *args, **kwargs):
    103         s3_fix_kwargs(bld, kwargs)
    104         return bld.SAMBA_SUBSYSTEM(name, *args, **kwargs)
     121    s3_fix_kwargs(bld, kwargs)
     122    return bld.SAMBA_SUBSYSTEM(name, *args, **kwargs)
    105123Build.BuildContext.SAMBA3_SUBSYSTEM = SAMBA3_SUBSYSTEM
    106124
    107125def SAMBA3_BINARY(bld, name, *args, **kwargs):
    108         s3_fix_kwargs(bld, kwargs)
    109         return bld.SAMBA_BINARY(name, *args, **kwargs)
     126    s3_fix_kwargs(bld, kwargs)
     127    return bld.SAMBA_BINARY(name, *args, **kwargs)
    110128Build.BuildContext.SAMBA3_BINARY = SAMBA3_BINARY
     129
     130def SAMBA3_PYTHON(bld, name, *args, **kwargs):
     131    s3_fix_kwargs(bld, kwargs)
     132    return bld.SAMBA_PYTHON(name, *args, **kwargs)
     133Build.BuildContext.SAMBA3_PYTHON = SAMBA3_PYTHON
  • vendor/current/buildtools/wafsamba/samba_abi.py

    r740 r988  
    1616    '''normalise a signature from gdb'''
    1717    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)
    2021    sig = re.sub('0x[0-9a-f]+', '0xXXXX', sig)
     22    sig = re.sub('", <incomplete sequence (\\\\[a-z0-9]+)>', r'\1"', sig)
    2123
    2224    for t in abi_type_maps:
     
    3133    return sig
    3234
     35
    3336def normalise_varargs(sig):
    3437    '''cope with older versions of gdb'''
    3538    sig = re.sub(',\s\.\.\.', '', sig)
    3639    return sig
     40
    3741
    3842def parse_sigs(sigs, abi_match):
     
    4751        if abi_match:
    4852            matched = False
     53            negative = False
    4954            for p in abi_match:
    5055                if p[0] == '!' and fnmatch.fnmatch(sa[0], p[1:]):
     56                    negative = True
    5157                    break
    5258                elif fnmatch.fnmatch(sa[0], p):
    5359                    matched = True
    5460                    break
    55             if not matched:
     61            if (not matched) and negative:
    5662                continue
     63        Logs.debug("%s -> %s" % (sa[1], normalise_signature(sa[1])))
    5764        ret[sa[0]] = normalise_signature(sa[1])
    5865    return ret
     
    106113
    107114    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)
    109116
    110117
     
    131138    abi_gen = os.path.join(topsrc, 'buildtools/scripts/abi_gen.sh')
    132139
    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)
    134142
    135143    tsk = self.create_task('abi_check', self.link_task.outputs[0])
     
    141149def abi_process_file(fname, version, symmap):
    142150    '''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():
    145152        symname = line.split(":")[0]
    146153        if not symname in symmap:
    147154            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 format
    152    
    153     :param vscript: Path to the vscript file
     155
     156
     157def 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
    154161    :param libname: Name of the library, uppercased
    155162    :param current_version: Current version
    156163    :param versions: Versions to consider
    157164    :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    """
    160168
    161169    invmap = {}
     
    163171        invmap.setdefault(symmap[s], []).append(s)
    164172
    165     f = open(vscript, mode='w')
    166173    last_key = ""
    167174    versions = sorted(versions, key=version_key)
     
    171178            break
    172179        f.write("%s {\n" % symver)
    173         if k in invmap:
    174             f.write("\tglobal: \n")
     180        if k in sorted(invmap.keys()):
     181            f.write("\tglobal:\n")
    175182            for s in invmap.get(k, []):
    176183                f.write("\t\t%s;\n" % s);
     
    178185        last_key = " %s" % symver
    179186    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)
    180189    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")
    183195    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")
    185201    f.write("};\n")
    186     f.close()
    187202
    188203
     
    200215        versions.append(version)
    201216        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()
    204223
    205224
     
    207226    '''generate a vscript file for our public libraries'''
    208227    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)
    210229        def abi_file_key(path):
    211230            return version_key(path[:-len(".sigs")].rsplit("-")[-1])
  • vendor/current/buildtools/wafsamba/samba_autoconf.py

    r740 r988  
    11# a waf tool to add autoconf-like macros to the configure section
    22
    3 import Build, os, sys, Options, preproc, Logs
    4 import string
     3import os, sys
     4import Build, Options, preproc, Logs
    55from Configure import conf
    6 from samba_utils import *
    7 import samba_cross
     6from TaskGen import feature
     7from samba_utils import TO_LIST, GET_TARGET_TYPE, SET_TARGET_TYPE, unique_list, mkdir_p
    88
    99missing_headers = set()
     
    1414# m4 files
    1515
    16 @runonce
    1716@conf
    1817def DEFINE(conf, d, v, add_to_cflags=False, quote=False):
     
    6362    conf.check_message_2 = conf.saved_check_message_2
    6463    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:
    6867        p('not found', 'YELLOW')
    6968    else:
     
    9392        return True
    9493
    95     (ccflags, ldflags) = library_flags(conf, lib)
     94    (ccflags, ldflags, cpppath) = library_flags(conf, lib)
    9695
    9796    hdrs = hlist_to_string(conf, headers=h)
     97    if lib is None:
     98        lib = ""
    9899    ret = conf.check(fragment='%s\nint main(void) { return 0; }' % hdrs,
    99100                     type='nolink',
    100101                     execute=0,
    101102                     ccflags=ccflags,
     103                     mandatory=False,
     104                     includes=cpppath,
     105                     uselib=lib.upper(),
    102106                     msg="Checking for header %s" % h)
    103107    if not ret:
     
    226230                              msg='Checking for declaration of %s' % v,
    227231                              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
    229244    return ret
    230245
     
    238253    conf.COMPOUND_START('Checking for %s' % f)
    239254
    240     if link is None or link == True:
     255    if link is None or link:
    241256        ret = CHECK_CODE(conf,
    242257                         # this is based on the autoconf strategy
     
    281296                             msg='Checking for macro %s' % f)
    282297
    283     if not ret and (link is None or link == False):
     298    if not ret and (link is None or not link):
    284299        ret = CHECK_VARIABLE(conf, f,
    285300                             define=define,
     
    301316
    302317@conf
    303 def CHECK_SIZEOF(conf, vars, headers=None, define=None):
     318def CHECK_SIZEOF(conf, vars, headers=None, define=None, critical=True):
    304319    '''check the size of a type'''
    305     ret = True
    306320    for v in TO_LIST(vars):
    307321        v_define = define
     322        ret = False
    308323        if v_define is None:
    309324            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
     342def 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
    323360
    324361@conf
     
    369406    uselib = TO_LIST(lib)
    370407
    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]
    372414
    373415    cflags.extend(ccflags)
     
    429471
    430472@conf
    431 def CHECK_CFLAGS(conf, cflags):
     473def CHECK_CFLAGS(conf, cflags, fragment='int main(void) { return 0; }\n'):
    432474    '''check if the given cflags are accepted by the compiler
    433475    '''
    434     return conf.check(fragment='int main(void) { return 0; }\n',
     476    return conf.check(fragment=fragment,
    435477                      execute=0,
    436478                      type='nolink',
     
    445487                      execute=0,
    446488                      ldflags=ldflags,
     489                      mandatory=False,
    447490                      msg="Checking linker accepts %s" % ldflags)
    448491
     
    459502def CONFIG_SET(conf, option):
    460503    '''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
     516def CONFIG_RESET(conf, option):
     517    if option not in conf.env:
     518        return
     519    del conf.env[option]
     520
     521Build.BuildContext.CONFIG_RESET = CONFIG_RESET
    462522Build.BuildContext.CONFIG_SET = CONFIG_SET
    463523Build.BuildContext.CONFIG_GET = CONFIG_GET
     
    468528    ccflags = []
    469529    ldflags = []
     530    cpppath = []
    470531    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
    475535        extra_ccflags = TO_LIST(getattr(self.env, 'CCFLAGS_%s' % lib.upper(), []))
    476536        extra_ldflags = TO_LIST(getattr(self.env, 'LDFLAGS_%s' % lib.upper(), []))
     537        extra_cpppath = TO_LIST(getattr(self.env, 'CPPPATH_%s' % lib.upper(), []))
    477538        ccflags.extend(extra_ccflags)
    478539        ldflags.extend(extra_ldflags)
     540        cpppath.extend(extra_cpppath)
    479541    if 'EXTRA_LDFLAGS' in self.env:
    480542        ldflags.extend(self.env['EXTRA_LDFLAGS'])
     
    482544    ccflags = unique_list(ccflags)
    483545    ldflags = unique_list(ldflags)
    484     return (ccflags, ldflags)
     546    cpppath = unique_list(cpppath)
     547    return (ccflags, ldflags, cpppath)
    485548
    486549
     
    506569            continue
    507570
    508         (ccflags, ldflags) = library_flags(conf, lib)
     571        (ccflags, ldflags, cpppath) = library_flags(conf, lib)
    509572        if shlib:
    510             res = conf.check(features='cc 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)
    511574        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)
    513576
    514577        if not res:
     
    521584                    SET_TARGET_TYPE(conf, lib, 'EMPTY')
    522585        else:
    523             conf.define('HAVE_LIB%s' % lib.upper().replace('-','_'), 1)
     586            conf.define('HAVE_LIB%s' % lib.upper().replace('-','_').replace('.','_'), 1)
    524587            conf.env['LIB_' + lib.upper()] = lib
    525588            if set_target:
     
    596659        return
    597660
     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
    598683    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)
    599694        # we add these here to ensure that -Wstrict-prototypes is not set during configure
    600         conf.ADD_CFLAGS('-Wall -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',
    601696                        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"], '''
     714int testformat(char *format, ...) __attribute__ ((format (__printf__, 1, 2)));
     715
     716int 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"))
    605725
    606726    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)
    608728
    609729    if Options.options.fatal_errors:
     
    612732    if Options.options.pedantic:
    613733        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'])
    614752
    615753    if path is None:
     
    630768
    631769@conf
    632 def ADD_CFLAGS(conf, flags, testflags=False):
     770def ADD_NAMED_CFLAGS(conf, name, flags, testflags=False):
    633771    '''add some CFLAGS to the command line
    634772       optionally set testflags to ensure all the flags work
     
    640778                ok_flags.append(f)
    641779        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
     785def 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)
    645790
    646791@conf
     
    672817
    673818
    674 def CURRENT_CFLAGS(bld, target, cflags, hide_symbols=False):
     819def CURRENT_CFLAGS(bld, target, cflags, allow_warnings=False, hide_symbols=False):
    675820    '''work out the current flags. local flags are added first'''
     821    ret = TO_LIST(cflags)
    676822    if not 'EXTRA_CFLAGS' in bld.env:
    677823        list = []
    678824    else:
    679825        list = bld.env['EXTRA_CFLAGS'];
    680     ret = TO_LIST(cflags)
    681826    ret.extend(list)
     827    if not allow_warnings and 'PICKY_CFLAGS' in bld.env:
     828        list = bld.env['PICKY_CFLAGS'];
     829        ret.extend(list)
    682830    if hide_symbols and bld.env.HAVE_VISIBILITY_ATTR:
    683         ret.append('-fvisibility=hidden')
     831        ret.append(bld.env.VISIBILITY_CFLAGS)
    684832    return ret
    685833
     
    714862    # in either case we don't need to scan system includes
    715863    preproc.go_absolute = False
     864
     865
     866@conf
     867def 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
     878def CHECK_CFG(self, *k, **kw):
     879    return self.check_cfg(*k, **kw)
  • vendor/current/buildtools/wafsamba/samba_autoproto.py

    r740 r988  
    11# waf build tool for building automatic prototypes from C source
    22
     3import os
    34import Build
    4 from samba_utils import *
     5from samba_utils import SET_TARGET_TYPE, os_path_relpath
    56
    67def SAMBA_AUTOPROTO(bld, header, source):
     
    1415        source = source,
    1516        target = header,
    16         on_results=True,
     17        update_outputs=True,
    1718        ext_out='.c',
    1819        before ='cc',
  • vendor/current/buildtools/wafsamba/samba_bundled.py

    r740 r988  
    11# functions to support bundled libraries
    22
     3import sys
     4import Build, Options, Logs
    35from Configure import conf
    4 import sys, Logs
    5 from samba_utils import *
     6from samba_utils import TO_LIST
    67
    78def PRIVATE_NAME(bld, name, private_extension, private_library):
    89    '''possibly rename a library to include a bundled extension'''
     10
     11    if not private_library:
     12        return name
    913
    1014    # we now use the same private name for libraries as the public name.
     
    1216    # demonstration that this is the right thing to do
    1317    # 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)
    1530
    1631
     
    3146    '''return True if a library should be builtin
    3247       instead of being built as a shared lib'''
    33     if bld.env.DISABLE_SHARED:
    34         return True
    3548    return target_in_list(name, bld.env.BUILTIN_LIBRARIES, False)
    3649Build.BuildContext.BUILTIN_LIBRARY = BUILTIN_LIBRARY
     
    7386@conf
    7487def 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
    7895
    7996@conf
    8097def 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
     107def 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
     112def 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
    86124@conf
    87125def CHECK_BUNDLED_SYSTEM(conf, libname, minversion='0.0.0',
    88                          checkfunctions=None, headers=None,
     126                         checkfunctions=None, headers=None, checkcode=None,
    89127                         onlyif=None, implied_deps=None,
    90                          require_headers=True):
     128                         require_headers=True, pkg=None, set_target=True):
    91129    '''check if a library is available as a system library.
    92130    this first tries via pkg-config, then if that fails
    93131    tries by testing for a specified function in the specified lib
    94132    '''
    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)
    97145    found = 'FOUND_SYSTEMLIB_%s' % libname
    98146    if found in conf.env:
    99147        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
    109151
    110152    # see if the library should only use a system version if another dependent
    111153    # system version is found. That prevents possible use of mixed library
    112154    # 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:
    121170                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
    122180
    123181    minversion = minimum_library_version(conf, libname, minversion)
     
    127185        msg += ' >= %s' % minversion
    128186
     187    uselib_store=libname.upper()
     188    if pkg is None:
     189        pkg = libname
     190
    129191    # 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')
    135198        conf.env[found] = True
    136199        if implied_deps:
     
    138201        return True
    139202    if checkfunctions is not None:
    140         if check_functions_headers():
     203        if check_functions_headers_code():
    141204            conf.env[found] = True
    142205            if implied_deps:
    143206                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')
    145209            return True
    146210    conf.env[found] = False
     
    151215
    152216
    153 @runonce
     217def tuplize_version(version):
     218    return tuple([int(x) for x in version.split(".")])
     219
    154220@conf
    155221def CHECK_BUNDLED_SYSTEM_PYTHON(conf, libname, modulename, minversion='0.0.0'):
     
    175241            found = False
    176242        else:
    177             found = tuple(version.split(".")) >= tuple(minversion.split("."))
     243            found = tuplize_version(version) >= tuplize_version(minversion)
    178244    if not found and not conf.LIB_MAY_BE_BUNDLED(libname):
    179245        Logs.error('ERROR: Python module %s of version %s not found, and bundling disabled' % (libname, minversion))
     
    184250def NONSHARED_BINARY(bld, name):
    185251    '''return True if a binary should be built without non-system shared libs'''
    186     if bld.env.DISABLE_SHARED:
    187         return True
    188252    return target_in_list(name, bld.env.NONSHARED_BINARIES, False)
    189253Build.BuildContext.NONSHARED_BINARY = NONSHARED_BINARY
  • vendor/current/buildtools/wafsamba/samba_conftests.py

    r740 r988  
    22# to test for commonly needed configuration options
    33
    4 import os, Build, shutil, Utils, re
     4import os, shutil, re
     5import Build, Configure, Utils, Options, Logs
    56from Configure import conf
    6 from samba_utils import *
     7from samba_utils import TO_LIST, ADD_LD_LIBRARY_PATH
     8
     9
     10def 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
     18Options.Handler.add_option = add_option
     19
     20@conf
     21def 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
    772
    873@conf
     
    1984def CHECK_LARGEFILE(conf, define='HAVE_LARGEFILE'):
    2085    '''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
    21103    if conf.CHECK_CODE('return !(sizeof(off_t) >= 8)',
    22104                       define,
    23105                       execute=True,
    24                        msg='Checking for large file support'):
     106                       msg='Checking for large file support without additional flags'):
    25107        return True
     108
    26109    if conf.CHECK_CODE('return !(sizeof(off_t) >= 8)',
    27110                       define,
     
    30113                       msg='Checking for -D_FILE_OFFSET_BITS=64'):
    31114        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)
    32123        return True
    33124    return False
     
    106197}
    107198'''
    108     return conf.check(features='cc cshlib',vnum="1",fragment=snip,msg=msg)
     199    return conf.check(features='c cshlib',vnum="1",fragment=snip,msg=msg, mandatory=False)
    109200
    110201@conf
     
    125216    os.makedirs(subdir)
    126217
    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')
    130219
    131220    bld = Build.BuildContext()
     
    138227    bld.rescan(bld.srcnode)
    139228
    140     bld(features='cc cshlib',
     229    bld(features='c cshlib',
    141230        source='liblctest/liblc1.c',
    142231        ldflags=conf.env['EXTRA_LDFLAGS'],
     
    158247
    159248    dir = find_config_dir(conf)
    160 
    161     env = conf.env
    162 
    163249    snip = '''
    164250#include <Python.h>
     
    173259    return v * 2;
    174260}'''
    175     return conf.check(features='cc cshlib',uselib='PYEMBED',fragment=snip,msg=msg)
     261    return conf.check(features='c cshlib',uselib='PYEMBED',fragment=snip,msg=msg, mandatory=False)
    176262
    177263# this one is quite complex, and should probably be broken up
     
    200286    os.makedirs(subdir)
    201287
    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')
    209290
    210291    bld = Build.BuildContext()
     
    220301    if version_script:
    221302        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',
    227306        source='libdir/lib1.c',
    228307        target='libdir/lib1',
     
    230309        name='lib1')
    231310
    232     o = bld(features='cc cprogram',
     311    o = bld(features='c cprogram',
    233312            source='main.c',
    234313            target='prog1',
     
    292371        os.makedirs(bdir)
    293372
    294     dest = open(os.path.join(bdir, 'Makefile.PL'), 'w')
    295     dest.write("""
     373    Utils.writef(os.path.join(bdir, 'Makefile.PL'), """
    296374use ExtUtils::MakeMaker;
    297375WriteMakefile(
    298     'NAME'      => 'WafTest',
     376    'NAME'    => 'WafTest',
    299377    'EXE_FILES' => [ 'WafTest' ]
    300378);
    301379""")
    302     dest.close()
    303380    back = os.path.abspath('.')
    304381    os.chdir(bdir)
     
    315392
    316393    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'))
    320395        m = re.search('MAN%sEXT\s+=\s+(\w+)' % section, man)
    321396        if not m:
     
    413488                             define='XSLTPROC_MANPAGES', on_target=False,
    414489                             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
     502def 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  
    11# functions for handling cross-compilation
    22
    3 import Utils, Logs, sys, os, Options, re
     3import os, sys, re, shlex
     4import Utils, Logs, Options
    45from Configure import conf
    56
     
    78
    89ANSWER_UNKNOWN = (254, "")
    9 ANSWER_FAIL    = (255, "")
     10ANSWER_NO      = (1, "")
    1011ANSWER_OK      = (0, "")
    1112
     
    2021        Logs.error("Unable to open cross-answers file %s" % ca_file)
    2122        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
    2233    if answer == ANSWER_OK:
    2334        f.write('%s: OK\n' % msg)
    2435    elif answer == ANSWER_UNKNOWN:
    2536        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)
    2839    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))
    3144    f.close()
    3245
     
    3750        f = open(ca_file, 'r')
    3851    except:
    39         add_answer(ca_file, msg, ANSWER_UNKNOWN)
    4052        return ANSWER_UNKNOWN
    4153    for line in f:
     
    4456            continue
    4557        if line.find(':') != -1:
    46             a = line.split(':')
     58            a = line.split(':', 1)
    4759            thismsg = a[0].strip()
    4860            if thismsg != msg:
     
    5769            elif ans == "FAIL" or ans == "NO":
    5870                f.close()
    59                 return ANSWER_FAIL
     71                return ANSWER_NO
    6072            elif ans[0] == '"':
     73                f.close()
    6174                return (0, ans.strip('"'))
    6275            elif ans[0] == "'":
     76                f.close()
    6377                return (0, ans.strip("'"))
    6478            else:
     
    7084                    raise Utils.WafError("Bad answer format '%s' in %s" % (line, ca_file))
    7185    f.close()
    72     add_answer(ca_file, msg, ANSWER_UNKNOWN)
    7386    return ANSWER_UNKNOWN
    7487
     
    7891    def __init__(*k, **kw):
    7992        (obj, args) = k
     93        use_answers = False
     94        ans = ANSWER_UNKNOWN
    8095
    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:
    89105            # when --cross-answers is set, then change the arguments
    90106            # to use the cross answers if available
     107            use_answers = True
    91108            i = args.index('--cross-answers')
    92109            ca_file = args[i+1]
    93110            msg     = args[i+2]
    94111            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:
    95130            if ans == ANSWER_UNKNOWN:
    96131                global cross_answers_incomplete
    97132                cross_answers_incomplete = True
     133                add_answer(ca_file, msg, ans)
    98134            (retcode, retstring) = ans
    99135            args = ['/bin/sh', '-c', "echo -n '%s'; exit %d" % (retstring, retcode)]
     
    116152    if conf.env.CROSS_EXECUTE:
    117153        ret.extend(['--cross-execute', conf.env.CROSS_EXECUTE])
    118     elif conf.env.CROSS_ANSWERS:
     154
     155    if conf.env.CROSS_ANSWERS:
    119156        if msg is None:
    120157            raise Utils.WafError("Cannot have NULL msg in cross-answers")
  • vendor/current/buildtools/wafsamba/samba_deps.py

    r740 r988  
    11# Samba automatic dependency handling and project rules
    22
    3 import Build, os, sys, re, Environment, Logs, time
    4 from samba_utils import *
    5 from samba_autoconf import *
     3import os, sys, re, time
     4
     5import Build, Environment, Options, Logs, Utils
     6from Logs import debug
     7from Configure import conf
     8
    69from samba_bundled import BUILTIN_LIBRARY
     10from samba_utils import LOCAL_CACHE, TO_LIST, get_tgt_list, unique_list, os_path_relpath
     11from samba_autoconf import library_flags
    712
    813@conf
     
    4853        #    module         = rpc_epmapper (a module object within the dcerpc_server subsystem)
    4954
    50         subsystem = bld.name_to_obj(subsystem_name, bld.env)
     55        subsystem = bld.get_tgen_by_name(subsystem_name)
    5156        bld.ASSERT(subsystem is not None, "Unable to find subsystem %s" % subsystem_name)
    5257        for d in subsystem_list[subsystem_name]:
     
    8186        libs = self.final_syslibs.copy()
    8287
    83         (ccflags, ldflags) = library_flags(self, list(libs))
     88        (ccflags, ldflags, cpppath) = library_flags(self, list(libs))
    8489        new_ldflags        = getattr(self, 'samba_ldflags', [])[:]
    8590        new_ldflags.extend(ldflags)
     
    8994            for f in self.env.undefined_ldflags:
    9095                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)
    91100
    92101        debug('deps: computed dependencies for target %s: uselib=%s uselib_local=%s add_objects=%s',
     
    98107        self.uselib.extend(list(self.direct_syslibs))
    99108        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)
    101110            self.uselib.extend(list(t.final_syslibs))
    102111        self.uselib = unique_list(self.uselib)
     
    133142
    134143    # maybe add local includes
    135     if getattr(self, 'local_include', True) == True and getattr(self, 'local_include_first', True):
     144    if getattr(self, 'local_include', True) and getattr(self, 'local_include_first', True):
    136145        includes.append('.')
    137146
     
    147156
    148157    for d in inc_deps:
    149         t = bld.name_to_obj(d, bld.env)
     158        t = bld.get_tgen_by_name(d)
    150159        bld.ASSERT(t is not None, "Unable to find dependency %s for %s" % (d, self.sname))
    151160        inclist = getattr(t, 'samba_includes_extended', [])[:]
    152         if getattr(t, 'local_include', True) == True:
     161        if getattr(t, 'local_include', True):
    153162            inclist.append('.')
    154163        if inclist == []:
     
    166175        includes.append(relpath)
    167176
    168     if getattr(self, 'local_include', True) == True and not getattr(self, 'local_include_first', True):
     177    if getattr(self, 'local_include', True) and not getattr(self, 'local_include_first', True):
    169178        includes.append('.')
    170179
     
    187196
    188197
    189 
    190 
    191198def add_init_functions(self):
    192199    '''This builds the right set of init functions'''
     
    213220        modules.append(m)
    214221
    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')
    216226
    217227    targets    = LOCAL_CACHE(bld, 'TARGET_TYPE')
     
    221231        sname = sname.replace('-','_')
    222232        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))
    226237        self.ccflags = cflags
    227238        return
     
    235246                init_fn_list.append(d['INIT_FUNCTION'])
    236247        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))
    240252        else:
    241             cflags.append('-DSTATIC_%s_MODULES=%s' % (m, ','.join(init_fn_list) + ',' + sentinal))
     253            cflags.append('-DSTATIC_%s_MODULES=%s' % (m, ','.join(init_fn_list) + ',' + sentinel))
    242254            proto=''
    243255            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)
    245258            cflags.append('-DSTATIC_%s_MODULES_PROTO=%s' % (m, proto))
    246259    self.ccflags = cflags
    247260
    248261
    249 
    250262def 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'''
    253264
    254265    debug('deps: checking for duplicate sources')
    255 
    256266    targets = LOCAL_CACHE(bld, 'TARGET_TYPE')
    257     ret = True
    258 
    259     global tstart
    260267
    261268    for t in tgt_list:
     
    275282    # build a list of targets that each source file is part of
    276283    for t in tgt_list:
    277         sources = []
    278284        if not targets[t.sname] in [ 'LIBRARY', 'BINARY', 'PYTHON' ]:
    279285            continue
    280286        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)
    282288            source_set = getattr(t2, 'samba_source_set', set())
    283289            for s in source_set:
     
    294300            if len(subsystems[s][tname]) > 1:
    295301                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
    315304
    316305def check_group_ordering(bld, tgt_list):
     
    343332        tdeps = getattr(t, 'add_objects', []) + getattr(t, 'uselib_local', [])
    344333        for d in tdeps:
    345             t2 = bld.name_to_obj(d, bld.env)
     334            t2 = bld.get_tgen_by_name(d)
    346335            if t2 is None:
    347336                continue
     
    355344
    356345    return ret
    357 
     346Build.BuildContext.check_group_ordering = check_group_ordering
    358347
    359348def show_final_deps(bld, tgt_list):
     
    426415    global_deps_exclude = set()
    427416    for dep in global_deps:
    428         t = bld.name_to_obj(dep, bld.env)
     417        t = bld.get_tgen_by_name(dep)
    429418        for d in t.samba_deps:
    430419            # prevent loops from the global dependencies list
     
    466455                            sys.exit(1)
    467456                continue
    468             t2 = bld.name_to_obj(d, bld.env)
     457            t2 = bld.get_tgen_by_name(d)
    469458            if t2 is None:
    470459                Logs.error("no task %s of type %s in %s" % (d, targets[d], t.sname))
     
    504493            continue
    505494        chain.add(obj)
    506         t2 = bld.name_to_obj(obj, bld.env)
     495        t2 = bld.get_tgen_by_name(obj)
    507496        r2 = indirect_libs(bld, t2, chain, loops)
    508497        chain.remove(obj)
     
    515504            continue
    516505        chain.add(obj)
    517         t2 = bld.name_to_obj(obj, bld.env)
     506        t2 = bld.get_tgen_by_name(obj)
    518507        r2 = indirect_libs(bld, t2, chain, loops)
    519508        chain.remove(obj)
     
    542531            continue
    543532        chain.add(lib)
    544         t2 = bld.name_to_obj(lib, bld.env)
     533        t2 = bld.get_tgen_by_name(lib)
    545534        r2 = indirect_objects(bld, t2, chain, loops)
    546535        chain.remove(lib)
     
    570559        if lib in chain:
    571560            continue
    572         t2 = bld.name_to_obj(lib, bld.env)
     561        t2 = bld.get_tgen_by_name(lib)
    573562        chain.add(lib)
    574563        r2 = extended_objects(bld, t2, chain)
     
    598587            continue
    599588        chain.add(obj)
    600         t2 = bld.name_to_obj(obj, bld.env)
     589        t2 = bld.get_tgen_by_name(obj)
    601590        r2 = includes_objects(bld, t2, chain, inc_loops)
    602591        chain.remove(obj)
     
    609598            continue
    610599        chain.add(lib)
    611         t2 = bld.name_to_obj(lib, bld.env)
     600        t2 = bld.get_tgen_by_name(lib)
    612601        if t2 is None:
    613602            targets = LOCAL_CACHE(bld, 'TARGET_TYPE')
     
    662651    # expand indirect subsystem and library loops
    663652    for loop in loops.copy():
    664         t = bld.name_to_obj(loop, bld.env)
     653        t = bld.get_tgen_by_name(loop)
    665654        if t.samba_type in ['SUBSYSTEM']:
    666655            loops[loop] = loops[loop].union(t.indirect_objects)
     
    674663    # expand indirect includes loops
    675664    for loop in inc_loops.copy():
    676         t = bld.name_to_obj(loop, bld.env)
     665        t = bld.get_tgen_by_name(loop)
    677666        inc_loops[loop] = inc_loops[loop].union(t.includes_objects)
    678667        if loop in inc_loops[loop]:
     
    720709            new = t.final_objects.copy()
    721710            for l in t.final_libs:
    722                 t2 = bld.name_to_obj(l, bld.env)
     711                t2 = bld.get_tgen_by_name(l)
    723712                t2_obj = extended_objects(bld, t2, set())
    724713                dup = new.intersection(t2_obj)
     
    740729    # add back in any objects that were relied upon by the reduction rules
    741730    for r in rely_on:
    742         t = bld.name_to_obj(r, bld.env)
     731        t = bld.get_tgen_by_name(r)
    743732        t.final_objects = t.final_objects.union(rely_on[r])
    744733
     
    749738    '''show the detailed path of a library loop between lib1 and lib2'''
    750739
    751     t = bld.name_to_obj(lib1, bld.env)
     740    t = bld.get_tgen_by_name(lib1)
    752741    if not lib2 in getattr(t, 'final_libs', set()):
    753742        return
     
    788777            for l in t.final_libs:
    789778                objname = l + '.objlist'
    790                 t2 = bld.name_to_obj(objname, bld.env)
     779                t2 = bld.get_tgen_by_name(objname)
    791780                if t2 is None:
    792781                    Logs.error('ERROR: subsystem %s not found' % objname)
     
    804793                        else:
    805794                            continue
    806                         t2 = bld.name_to_obj(objname, bld.env)
     795                        t2 = bld.get_tgen_by_name(objname)
    807796                        if t2 is None:
    808797                            Logs.error('ERROR: subsystem %s not found' % objname)
     
    816805        if t.samba_type in ['LIBRARY', 'PYTHON']:
    817806            for l in t.final_libs.copy():
    818                 t2 = bld.name_to_obj(l, bld.env)
     807                t2 = bld.get_tgen_by_name(l)
    819808                if t.sname in t2.final_libs:
    820809                    if getattr(bld.env, "ALLOW_CIRCULAR_LIB_DEPENDENCIES", False):
     
    850839                    # make sure we don't recreate the loop again!
    851840                    for d in diff.copy():
    852                         t2 = bld.name_to_obj(d, bld.env)
     841                        t2 = bld.get_tgen_by_name(d)
    853842                        if t2.samba_type == 'LIBRARY':
    854843                            if t.sname in t2.final_libs:
     
    875864        syslibs = set()
    876865        for d in t.final_objects:
    877             t2 = bld.name_to_obj(d, bld.env)
     866            t2 = bld.get_tgen_by_name(d)
    878867            syslibs = syslibs.union(t2.direct_syslibs)
    879868        # this adds the indirect syslibs as well, which may not be needed
    880869        # depending on the linker flags
    881870        for d in t.final_libs:
    882             t2 = bld.name_to_obj(d, bld.env)
     871            t2 = bld.get_tgen_by_name(d)
    883872            syslibs = syslibs.union(t2.direct_syslibs)
    884873        t.final_syslibs = syslibs
     
    890879        if t.samba_type in ['LIBRARY', 'PYTHON']:
    891880            for l in t.final_libs.copy():
    892                 t2 = bld.name_to_obj(l, bld.env)
     881                t2 = bld.get_tgen_by_name(l)
    893882                if t.sname in t2.final_libs:
    894883                    Logs.error('ERROR: Unresolved library loop %s from %s' % (t.sname, t2.sname))
     
    906895        return
    907896
    908     t = bld.name_to_obj(target, bld.env)
     897    t = bld.get_tgen_by_name(target)
    909898    if t is None:
    910899        Logs.error("ERROR: Unable to find target '%s'" % target)
     
    935924            continue
    936925        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)
    938927            if not n in used_by:
    939928                used_by[n] = set()
     
    961950                    'source', 'grouping_library', 'samba_ldflags', 'allow_undefined_symbols',
    962951                    'use_global_deps', 'global_include' ]
    963 savedeps_outputs = ['uselib', 'uselib_local', 'add_objects', 'includes', 'ccflags', 'ldflags', 'samba_deps_extended']
     952savedeps_outputs = ['uselib', 'uselib_local', 'add_objects', 'includes',
     953                    'ccflags', 'ldflags', 'samba_deps_extended', 'final_libs']
    964954savedeps_outenv  = ['INC_PATHS']
    965955savedeps_envvars = ['NONSHARED_BINARIES', 'GLOBAL_DEPENDENCIES', 'EXTRA_CFLAGS', 'EXTRA_LDFLAGS', 'EXTRA_INCLUDES' ]
     
    10181008
    10191009    depsfile = os.path.join(bld.bdir, "sambadeps")
    1020     denv.store(depsfile)
     1010    denv.store_fast(depsfile)
    10211011
    10221012
     
    10281018    try:
    10291019        debug('deps: checking saved dependencies')
    1030         denv.load(depsfile)
     1020        denv.load_fast(depsfile)
    10311021        if (denv.version != savedeps_version or
    10321022            denv.savedeps_inputs != savedeps_inputs or
    10331023            denv.savedeps_outputs != savedeps_outputs):
    10341024            return False
    1035     except:
     1025    except Exception:
    10361026        return False
    10371027
     
    11451135    debug('deps: project rules stage1 completed')
    11461136
    1147     #check_orpaned_targets(bld, tgt_list)
    1148 
    11491137    if not check_duplicate_sources(bld, tgt_list):
    11501138        Logs.error("Duplicate sources present - aborting")
     
    11531141    debug("deps: check_duplicate_sources: %f" % (time.clock() - tstart))
    11541142
    1155     if not check_group_ordering(bld, tgt_list):
     1143    if not bld.check_group_ordering(tgt_list):
    11561144        Logs.error("Bad group ordering - aborting")
    11571145        sys.exit(1)
  • vendor/current/buildtools/wafsamba/samba_dist.py

    r740 r988  
    22# uses git ls-files to get file lists
    33
    4 import Utils, os, sys, tarfile, stat, Scripting, Logs, Options
    5 from samba_utils import *
     4import os, sys, tarfile
     5import Utils, Scripting, Logs, Options
     6from Configure import conf
     7from samba_utils import os_path_relpath
    68
    79dist_dirs = None
     10dist_files = None
    811dist_blacklist = ""
    912
     
    8689            env["GIT_DIR"] = os.path.join(repo, ".git")
    8790            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 = repo
    92             env = None
    93             break
    9491        repo = os.path.dirname(repo)
    9592    if repo == "/":
     
    9895
    9996
    100 def dist(appname='',version=''):
     97def 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
    101137    if not isinstance(appname, str) or not appname:
    102138        # this copes with a mismatch in the calling arguments for dist()
     
    135171            Logs.error('unable to get contents of %s: %s' % (absdir, e))
    136172            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)
    159193
    160194    tar.close()
     
    196230
    197231@conf
     232def 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
    198241def DIST_BLACKLIST(blacklist):
    199242    '''set the files to exclude from packaging, relative to top srcdir'''
  • vendor/current/buildtools/wafsamba/samba_headers.py

    r740 r988  
    11# specialist handling of header files for Samba
    22
    3 import Build, re, Task, TaskGen, shutil, sys, Logs
    4 from samba_utils import *
     3import os, re, sys, fnmatch
     4import Build, Logs, Utils
     5from samba_utils import TO_LIST, os_path_relpath
    56
    67
     
    120121            inst_name = os.path.basename(h)
    121122        bld.INSTALL_FILES('${INCLUDEDIR}', h_name, destname=inst_name)
    122        
    123123
    124124
  • vendor/current/buildtools/wafsamba/samba_install.py

    r740 r988  
    44# library use
    55
    6 import Options
     6import os
     7import Utils
    78from TaskGen import feature, before, after
    8 from samba_utils import *
     9from samba_utils import LIB_PATH, MODE_755, install_rpath, build_rpath
    910
    1011@feature('install_bin')
     
    1920    build_ldflags   = build_rpath(bld)
    2021
    21     if not Options.is_install:
     22    if not self.bld.is_install:
    2223        # just need to set rpath if we are not installing
    2324        self.env.RPATH = build_ldflags
     
    6061    bld = self.bld
    6162
    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
    7597        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)
    108131        else:
     132            install_name = bld.make_libname(target_name)
     133            install_link = None
    109134            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
    143155
    144156
     
    215227        return
    216228
    217     blddir = os.path.dirname(self.bld.srcnode.abspath(self.bld.env))
    218229    if not self.link_task.outputs or not self.link_task.outputs[0]:
    219230        raise Utils.WafError('no outputs found for %s in symlink_bin' % self.name)
  • vendor/current/buildtools/wafsamba/samba_optimisation.py

    r740 r988  
    77# overall this makes some build tasks quite a bit faster
    88
    9 from TaskGen import feature, after
    10 import preproc, Task
    11 
    12 @feature('cc', 'cxx')
     9import os
     10import Build, Utils, Node
     11from TaskGen import feature, after, before
     12import preproc
     13
     14@feature('c', 'cc', 'cxx')
    1315@after('apply_type_vars', 'apply_lib_vars', 'apply_core')
    1416def apply_incpaths(self):
    15         lst = []
    16 
    17         try:
    18                 kak = self.bld.kak
    19         except AttributeError:
    20                 kak = self.bld.kak = {}
    21 
    22         # TODO move the uselib processing out of here
    23         for lib in self.to_list(self.uselib):
    24                 for path in self.env['CPPPATH_' + lib]:
    25                         if not path in lst:
    26                                 lst.append(path)
    27         if preproc.go_absolute:
    28                 for path in preproc.standard_includes:
    29                         if not path in lst:
    30                                 lst.append(path)
    31 
    32         for path in self.to_list(self.includes):
    33                 if not path in lst:
    34                         if preproc.go_absolute or path[0] != '/': #os.path.isabs(path):
    35                                 lst.append(path)
    36                         else:
    37                                 self.env.prepend_value('CPPPATH', path)
    38 
    39         for path in lst:
    40                 node = None
    41                 if path[0] == '/': # os.path.isabs(path):
    42                         if preproc.go_absolute:
    43                                 node = self.bld.root.find_dir(path)
    44                 elif path[0] == '#':
    45                         node = self.bld.srcnode
    46                         if len(path) > 1:
    47                                 try:
    48                                         node = kak[path]
    49                                 except KeyError:
    50                                         kak[path] = node = node.find_dir(path[1:])
    51                 else:
    52                         try:
    53                                 node = kak[(self.path.id, path)]
    54                         except KeyError:
    55                                 kak[(self.path.id, path)] = node = self.path.find_dir(path)
    56 
    57                 if node:
    58                         self.env.append_value('INC_PATHS', node)
    59 
    60 @feature('cc')
     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')
    6163@after('apply_incpaths')
    6264def apply_obj_vars_cc(self):
     
    9294
    9395def vari(self):
    94         return "default"
     96    return "default"
    9597Environment.Environment.variant = vari
    9698
    9799def variant(self, env):
    98         if not env: return 0
    99         elif self.id & 3 == Node.FILE: return 0
    100         else: return "default"
     100    if not env: return 0
     101    elif self.id & 3 == Node.FILE: return 0
     102    else: return "default"
    101103Node.Node.variant = variant
    102104
     
    114116
    115117def hash_constraints(self):
    116         a = self.attr
    117         sum = hash((str(a('before', '')),
     118    a = self.attr
     119    sum = hash((str(a('before', '')),
    118120            str(a('after', '')),
    119121            str(a('ext_in', '')),
    120122            str(a('ext_out', '')),
    121123            self.__class__.maxjobs))
    122         return sum
     124    return sum
    123125Task.TaskBase.hash_constraints = hash_constraints
    124126
    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'])
     127def 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
     139Build.BuildContext.hash_env_vars = hash_env_vars
     140
     141
     142def 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()
     149Environment.Environment.store_fast = store_fast
     150
     151def 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)
     158Environment.Environment.load_fast = load_fast
     159
     160def 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
     170TaskGen.task_gen.is_this_a_static_lib = is_this_a_static_lib
     171
     172def 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
     188TaskGen.task_gen.shared_ancestors = shared_ancestors
     189
     190@feature('c', 'cc', 'cxx')
     191@after('apply_link', 'init_cc', 'init_cxx', 'apply_core')
     192def 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  
    11# a waf tool to add extension based build patterns for Samba
    22
    3 import Task
    4 from TaskGen import extension
    5 from samba_utils import *
     3import Build
    64from wafsamba import samba_version_file
    75
     
    97    '''print version.h contents'''
    108    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)
    1411    string = str(version)
    1512
    16     f = open(tgt, 'w')
    17     s = f.write(string)
    18     f.close()
     13    task.outputs[0].write(string)
    1914    return 0
    2015
     
    2217def SAMBA_MKVERSION(bld, target):
    2318    '''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',
    2524                            rule=write_version_header,
    2625                            source= 'VERSION',
    2726                            target=target,
    28                             always=True)
     27                            always=bld.is_install)
    2928Build.BuildContext.SAMBA_MKVERSION = SAMBA_MKVERSION
     29
     30
     31def 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
     127def 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
     151def 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
     161def 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
     198def 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)
     204Build.BuildContext.SAMBA_BLDOPTIONS = SAMBA_BLDOPTIONS
  • vendor/current/buildtools/wafsamba/samba_pidl.py

    r740 r988  
    11# waf build tool for building IDL files with pidl
    22
    3 from TaskGen import before
    4 import Build, os, sys, Logs
    5 from samba_utils import *
     3import os
     4import Build
     5from TaskGen import feature, before
     6from samba_utils import SET_TARGET_TYPE, TO_LIST, LOCAL_CACHE
    67
    78def SAMBA_PIDL(bld, pname, source,
    89               options='',
    910               output_dir='.',
    10                symlink=False,
    1111               generate_tables=True):
    1212    '''Build a IDL file using pidl.
     
    3232                    '--python'            : 'py_%s.c',
    3333                    '--tdr-parser'        : 'tdr_%s.c tdr_%s.h',
    34                     '--dcom-proxy'        : '%s_p.c',
    35                     '--com-header'        : 'com_%s.h'
     34                    '--dcom-proxy'        : '%s_p.c',
     35                    '--com-header'        : 'com_%s.h'
    3636                    }
    3737
     
    6161    cpp = ""
    6262    cc = ""
    63     if bld.CONFIG_SET("CPP"):
     63    if bld.CONFIG_SET("CPP") and bld.CONFIG_GET("CPP") != "":
    6464        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"))
    6666        else:
    6767            cpp = 'CPP="%s"' % bld.CONFIG_GET("CPP")
     
    7373    if bld.CONFIG_SET("CC"):
    7474        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"))
    7676        else:
    7777            cc = 'CC="%s"' % bld.CONFIG_GET("CC")
     
    8080            ext_out    = '.c',
    8181            before     = 'cc',
    82             on_results = True,
     82            update_outputs = True,
    8383            shell      = True,
    8484            source     = source,
     
    9292    t.env.PIDL = os.path.join(bld.srcnode.abspath(), 'pidl/pidl')
    9393    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)
    11595
    11696    if generate_tables and table_header_idx is not None:
     
    125105                    options='',
    126106                    output_dir='.',
    127                     symlink=False,
    128107                    generate_tables=True):
    129108    '''A wrapper for building a set of IDL files'''
    130109    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)
    132111Build.BuildContext.SAMBA_PIDL_LIST = SAMBA_PIDL_LIST
    133112
     
    135114#################################################################
    136115# the rule for generating the NDR tables
    137 from TaskGen import feature, before
    138116@feature('collect')
    139117@before('exec_rule')
     
    141119    pidl_headers = LOCAL_CACHE(self.bld, 'PIDL_HEADERS')
    142120    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)
    144122        self.bld.ASSERT(y is not None, 'Failed to find PIDL header %s' % name)
    145123        y.post()
     
    151129def SAMBA_PIDL_TABLES(bld, name, target):
    152130    '''generate the pidl NDR tables file'''
    153     headers = bld.env.PIDL_HEADERS
    154131    bld.SET_BUILD_GROUP('main')
    155132    t = bld(
     
    158135            ext_out  = '.c',
    159136            before   = 'cc',
    160             on_results = True,
     137            update_outputs = True,
    161138            shell    = True,
    162139            source   = '../../librpc/tables.pl',
  • vendor/current/buildtools/wafsamba/samba_python.py

    r740 r988  
    11# waf build tool for building IDL files with pidl
    22
    3 import Build
    4 from samba_utils import *
    5 from samba_autoconf import *
     3import os
     4import Build, Logs, Utils, Configure
     5from Configure import conf
    66
    7 from Configure import conf
     7@conf
     8def 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
    841@conf
    942def SAMBA_CHECK_PYTHON_HEADERS(conf, mandatory=True):
    1043    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)
    1250        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']))
    1357    else:
    1458        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
     65def _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'] = ''
    1578
    1679
     
    2285                 cflags='',
    2386                 includes='',
    24                  init_function_sentinal=None,
     87                 init_function_sentinel=None,
    2588                 local_include=True,
    2689                 vars=None,
     90                 install=True,
    2791                 enabled=True):
    2892    '''build a python extension for Samba'''
    2993
     94    if bld.env['IS_EXTRA_PYTHON']:
     95        name = 'extra-' + name
     96
    3097    # when we support static python modules we'll need to gather
    3198    # 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'
    34112
    35113    source = bld.EXPAND_VARIABLES(source, vars=vars)
    36114
    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
    53119
    54120    bld.SAMBA_LIBRARY(name,
     
    58124                      includes=includes,
    59125                      cflags=cflags,
    60                       realname=realname,
    61126                      local_include=local_include,
    62127                      vars=vars,
     128                      realname=realname,
    63129                      link_name=link_name,
    64                       pyembed=True,
     130                      pyext=True,
    65131                      target_type='PYTHON',
    66132                      install_path='${PYTHONARCHDIR}',
     133                      allow_undefined_symbols=True,
     134                      install=install,
    67135                      enabled=enabled)
    68136
    69137Build.BuildContext.SAMBA_PYTHON = SAMBA_PYTHON
     138
     139
     140def pyembed_libname(bld, name, extrapython=False):
     141    return name + bld.env['PYTHON_SO_ABI_FLAG']
     142
     143Build.BuildContext.pyembed_libname = pyembed_libname
     144
     145
     146def 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
     165Build.BuildContext.gen_python_environments = gen_python_environments
  • vendor/current/buildtools/wafsamba/samba_utils.py

    r740 r988  
    22# and for SAMBA_ macros for building libraries, binaries etc
    33
    4 import Build, os, sys, Options, Utils, Task, re, fnmatch, Logs
    5 from TaskGen import feature, before
    6 from Configure import conf
     4import os, sys, re, fnmatch, shlex
     5import Build, Options, Utils, Task, Logs, Configure
     6from TaskGen import feature, before, after
     7from Configure import conf, ConfigurationContext
    78from Logs import debug
    8 import shlex
    99
    1010# TODO: make this a --option
     
    3636
    3737
    38 ######################################################
    39 # this is used as a decorator to make functions only
    40 # run once. Based on the idea from
    41 # http://stackoverflow.com/questions/815110/is-there-a-decorator-to-simply-cache-function-return-values
    42 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] = ret
    50             return ret
    51     return runonce_wrapper
    52 
    53 
    5438def ADD_LD_LIBRARY_PATH(path):
    5539    '''add something to LD_LIBRARY_PATH'''
     
    6650def needs_private_lib(bld, target):
    6751    '''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)
    7054        if t and getattr(t, 'private_library', False):
    7155            return True
     
    136120            d1[t] = d2[t]
    137121
    138 
    139 def exec_command(self, cmd, **kw):
    140     '''this overrides the 'waf -v' debug output to be in a nice
    141     unix like format instead of a python list.
    142     Thanks to ita on #waf for this'''
    143     import Utils, Logs
    144     _cmd = cmd
    145     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.log
    151     try:
    152         if not kw.get('cwd', None):
    153             kw['cwd'] = self.cwd
    154     except AttributeError:
    155         self.cwd = kw['cwd'] = self.bldnode.abspath()
    156     return Utils.exec_command(cmd, **kw)
    157 Build.BuildContext.exec_command = exec_command
    158 
    159 
    160122def ADD_COMMAND(opt, name, function):
    161123    '''add a new top level command to waf'''
     
    165127
    166128
    167 @feature('cc', 'cshlib', 'cprogram')
     129@feature('c', 'cc', 'cshlib', 'cprogram')
    168130@before('apply_core','exec_rule')
    169131def process_depends_on(self):
     
    174136        lst = self.to_list(self.depends_on)
    175137        for x in lst:
    176             y = self.bld.name_to_obj(x, self.env)
     138            y = self.bld.get_tgen_by_name(x)
    177139            self.bld.ASSERT(y is not None, "Failed to find dependency %s of %s" % (x, self.name))
    178140            y.post()
     
    215177        return []
    216178    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 []
    218183    lst = str.split(delimiter)
    219184    # the string may have had quotes in it, now we
     
    234199            vname = v[2:-1]
    235200            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))
    238202            v = env[vname]
    239203        out.append(v)
     
    256220        @before('exec_rule', 'apply_core', 'collect')
    257221        def force_previous_groups(self):
    258             if getattr(self.bld, 'enforced_group_ordering', False) == True:
     222            if getattr(self.bld, 'enforced_group_ordering', False):
    259223                return
    260224            self.bld.enforced_group_ordering = True
     
    274238                              group_name(g), self.name or self.target)
    275239                        break
    276                 if stop != None:
     240                if stop is not None:
    277241                    break
    278242            if stop is None:
     
    385349
    386350
     351def 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
    387370# make sure we have md5. some systems don't have it
    388371try:
    389372    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')
    390377except:
    391378    try:
    392379        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')
    393383    except:
    394384        import Constants
     
    488478                Logs.zones = ['*']
    489479        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"
    490487            loc = opt.find('=')
    491488            setattr(Options.options, opt[0:loc], opt[loc+1:])
     
    495492                    jobs_set = True
    496493                elif v == 'k':
    497                     Options.options.keep = True               
     494                    Options.options.keep = True
    498495        elif opt == '-j':
    499496            jobs_set = True
    500497        elif opt == '-k':
    501             Options.options.keep = True               
     498            Options.options.keep = True
    502499    if not jobs_set:
    503500        # default to one job
    504501        Options.options.jobs = 1
    505            
     502
    506503Build.BuildContext.CHECK_MAKEFLAGS = CHECK_MAKEFLAGS
    507504
     
    562559    (root1, ext1) = os.path.splitext(name)
    563560    if python:
    564         (root2, ext2) = os.path.splitext(ctx.env.pyext_PATTERN)
     561        return ctx.env.pyext_PATTERN % root1
    565562    else:
    566563        (root2, ext2) = os.path.splitext(ctx.env.shlib_PATTERN)
     
    613610        if not type in ['SUBSYSTEM', 'MODULE', 'BINARY', 'LIBRARY', 'ASN1', 'PYTHON']:
    614611            continue
    615         t = bld.name_to_obj(tgt, bld.env)
     612        t = bld.get_tgen_by_name(tgt)
    616613        if t is None:
    617614            Logs.error("Target %s of type %s has no task generator" % (tgt, type))
     
    619616        tgt_list.append(t)
    620617    return tgt_list
     618
     619from Constants import WSCRIPT_FILE
     620def 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
     640Build.BuildContext.PROCESS_SEPARATE_RULE = PROCESS_SEPARATE_RULE
     641ConfigurationContext.PROCESS_SEPARATE_RULE = PROCESS_SEPARATE_RULE
     642
     643def AD_DC_BUILD_IS_ENABLED(self):
     644    if self.CONFIG_SET('AD_DC_BUILD_IS_ENABLED'):
     645        return True
     646    return False
     647
     648Build.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')
     653def 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  
    22import Utils
    33import 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 
     4from samba_git import find_git
    525
    536def 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:
    6010        return ("GIT-UNKNOWN", {})
     11
     12    env.GIT = git
    6113
    6214    environ = dict(os.environ)
     
    8941
    9042
     43def 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
    9175class SambaVersion(object):
    9276
    93     def __init__(self, version_dict, path, env=None):
     77    def __init__(self, version_dict, path, env=None, is_install=True):
    9478        '''Determine the version number of samba
    9579
    96 See VERSION for the format.  Entries on that file are 
     80See VERSION for the format.  Entries on that file are
    9781also accepted as dictionary entries here
    9882        '''
     
    10488        self.TP_RELEASE=None
    10589        self.ALPHA_RELEASE=None
     90        self.BETA_RELEASE=None
    10691        self.PRE_RELEASE=None
    10792        self.RC_RELEASE=None
     
    134119
    135120##
    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"
    137122## We do not do pre or rc version on patch/letter releases
    138123##
     
    145130            self.ALPHA_RELEASE = int(self.ALPHA_RELEASE)
    146131            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)
    147135        if self.PRE_RELEASE is not None:
    148136            self.PRE_RELEASE = int(self.PRE_RELEASE)
     
    153141
    154142        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")):
    156147                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)
    159150            else:
    160151                suffix = "UNKNOWN"
    161152                self.vcs_fields = {}
     153            self.vcs_fields["SUFFIX"] = suffix
    162154            SAMBA_VERSION_STRING += "-" + suffix
    163155        else:
     
    194186        if self.ALPHA_RELEASE is not None:
    195187            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
    196191
    197192        if self.PRE_RELEASE is not None:
     
    235230
    236231
    237 def samba_version_file(version_file, path, env=None):
     232def samba_version_file(version_file, path, env=None, is_install=True):
    238233    '''Parse the version information from a VERSION file'''
    239234
     
    255250            raise
    256251
    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
     256def load_version(env=None, is_install=True):
    262257    '''load samba versions either from ./VERSION or git
    263258    return a version object for detailed breakdown'''
     
    265260        env = samba_utils.LOAD_ENVIRONMENT()
    266261
    267     version = samba_version_file("./VERSION", ".", env)
     262    version = samba_version_file("./VERSION", ".", env, is_install=is_install)
    268263    Utils.g_module.VERSION = version.STRING
    269264    return version
  • vendor/current/buildtools/wafsamba/samba_wildcard.py

    r740 r988  
    1 #! /usr/bin/env python
    2 
    31# based on playground/evil in the waf svn tree
    42
    5 import os, datetime
    6 import Scripting, Utils, Options, Logs, Environment, fnmatch
    7 from Constants import *
    8 from samba_utils import *
     3import os, datetime, fnmatch
     4import Scripting, Utils, Options, Logs, Environment
     5from Constants import SRCDIR, BLDDIR
     6from samba_utils import LOCAL_CACHE, os_path_relpath
    97
    108def run_task(t, k):
    11         '''run a single build task'''
    12         ret = t.run()
    13         if ret:
    14                 raise Utils.WafError("Failed to build %s: %u" % (k, ret))
     9    '''run a single build task'''
     10    ret = t.run()
     11    if ret:
     12        raise Utils.WafError("Failed to build %s: %u" % (k, ret))
    1513
    1614
    1715def run_named_build_task(cmd):
    18         '''run a named build task, matching the cmd name using fnmatch
    19         wildcards against inputs and outputs of all build tasks'''
    20         bld = fake_build_environment()
    21         found = False
    22         cwd_node = bld.root.find_dir(os.getcwd())
    23         top_node = bld.root.find_dir(bld.srcnode.abspath())
     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())
    2422
    25         cmd = os.path.normpath(cmd)
     23    cmd = os.path.normpath(cmd)
    2624
    27         # cope with builds of bin/*/*
    28         if os.path.islink(cmd):
    29                 cmd = os_path_relpath(os.readlink(cmd), os.getcwd())
     25    # cope with builds of bin/*/*
     26    if os.path.islink(cmd):
     27        cmd = os_path_relpath(os.readlink(cmd), os.getcwd())
    3028
    31         if cmd[0:12] == "bin/default/":
    32                 cmd = cmd[12:]
     29    if cmd[0:12] == "bin/default/":
     30        cmd = cmd[12:]
    3331
    34         for g in bld.task_manager.groups:
    35                 for attr in ['outputs', 'inputs']:
    36                         for t in g.tasks:
    37                                 s = getattr(t, attr, [])
    38                                 for k in s:
    39                                         relpath1 = k.relpath_gen(cwd_node)
    40                                         relpath2 = k.relpath_gen(top_node)
    41                                         if (fnmatch.fnmatch(relpath1, cmd) or
    42                                             fnmatch.fnmatch(relpath2, cmd)):
    43                                                 t.position = [0,0]
    44                                                 print(t.display())
    45                                                 run_task(t, k)
    46                                                 found = True
     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
    4745
    4846
    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
     51def 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)
    5171
    5272
    5373
    5474def wildcard_main(missing_cmd_fn):
    55         '''this replaces main from Scripting, allowing us to override the
    56            behaviour for unknown commands
     75    '''this replaces main from Scripting, allowing us to override the
     76       behaviour for unknown commands
    5777
    58            If a unknown command is found, then missing_cmd_fn() is called with
    59            the name of the requested command
    60            '''
    61         Scripting.commands = Options.arg_line[:]
     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[:]
    6282
    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()
    6585
    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)
    7388
    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)
    7896
    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
    80101
    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)()
    88103
    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)
    92111
    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)
    95115
    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')
    98121
    99122
    100123
    101124
    102 def fake_build_environment():
    103         """create all the tasks for the project, but do not run the build
    104         return the build context in use"""
    105         bld = getattr(Utils.g_module, 'build_context', Utils.Context)()
    106         bld = Scripting.check_configured(bld)
     125def 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)
    107130
    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
    111133
    112         bld.is_install = 0 # False
     134    bld.is_install = 0 # False
    113135
    114         try:
    115                 proj = Environment.Environment(Options.lockfile)
    116         except IOError:
    117                 raise Utils.WafError("Project not configured (run 'waf configure' first)")
     136    try:
     137        proj = Environment.Environment(Options.lockfile)
     138    except IOError:
     139        raise Utils.WafError("Project not configured (run 'waf configure' first)")
    118140
    119         bld.load_dirs(proj[SRCDIR], proj[BLDDIR])
    120         bld.load_envs()
     141    bld.load_dirs(proj[SRCDIR], proj[BLDDIR])
     142    bld.load_envs()
    121143
    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]])
    124147
    125         bld.pre_build()
    126         bld.flush()
    127         return bld
     148    bld.pre_build()
     149    if flush:
     150        bld.flush()
     151    return bld
    128152
  • vendor/current/buildtools/wafsamba/stale_files.py

    r740 r988  
    1 #! /usr/bin/env python
    21# encoding: utf-8
    32# Thomas Nagy, 2006-2010 (ita)
     
    4948    if bin_base[-4:] != '/bin':
    5049        raise Utils.WafError("Invalid bin base: %s" % bin_base)
    51    
     50
    5251    # obtain the expected list of files
    5352    expected = []
     
    5958                if getattr(x, 'target'):
    6059                    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)
    6169                    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)
    6274                        p = os.path.join(x.path.abspath(bld.env), t)
    6375                        p = os.path.normpath(p)
     
    7991            if f in ['config.h']:
    8092                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' ]:
    8295                continue
    8396            if f[-7:] == '.inst.h':
     
    8598            if p.find("/.conf") != -1:
    8699                continue
    87             if not p in expected:
     100            if not p in expected and os.path.exists(p):
    88101                Logs.warn("Removing stale file: %s" % p)
    89102                os.unlink(p)
  • vendor/current/buildtools/wafsamba/symbols.py

    r740 r988  
    22# using nm, producing a set of exposed defined/undefined symbols
    33
    4 import Utils, Build, subprocess, Logs
    5 from samba_wildcard import fake_build_environment
    6 from samba_utils import *
     4import os, re, subprocess
     5import Utils, Build, Options, Logs
     6from Logs import debug
     7from samba_utils import TO_LIST, LOCAL_CACHE, get_tgt_list, os_path_relpath
    78
    89# these are the data structures used in symbols.py:
     
    1819# bld.env.syslib_symbols: dictionary mapping system library name to set of symbols
    1920#                         for that library
     21# bld.env.library_dict  : dictionary mapping built library paths to subsystem names
    2022#
    2123# LOCAL_CACHE(bld, 'TARGET_TYPE') : dictionary mapping subsystem name to target type
    2224
    23 def symbols_extract(objfiles, dynamic=False):
     25
     26def symbols_extract(bld, objfiles, dynamic=False):
    2427    '''extract symbols from objfile, returning a dictionary containing
    2528       the set of undefined and public symbols for each file'''
    2629
    2730    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
    2848
    2949    cmd = ["nm"]
     
    3151        # needed for some .so files
    3252        cmd.append("-D")
    33     cmd.extend(objfiles)
     53    cmd.extend(list(objfiles))
    3454
    3555    nmpipe = subprocess.Popen(cmd, stdout=subprocess.PIPE).stdout
    3656    if len(objfiles) == 1:
    37         filename = objfiles[0]
     57        filename = list(objfiles)[0]
    3858        ret[filename] = { "PUBLIC": set(), "UNDEFINED" : set()}
    3959
     
    6080            ret[filename]["UNDEFINED"].add(symbol)
    6181
     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
    6289    return ret
    6390
     
    6996
    7097
    71 def find_syslib_path(bld, libname, deps):
     98def find_ldd_path(bld, libname, binary):
    7299    '''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 ldd
    74     # on it to find the real location of the library that is used
    75 
    76     linkpath = deps[0].link_task.outputs[0].abspath(bld.env)
    77 
    78     if libname == "python":
    79         libname += bld.env.PYTHON_VERSION
    80 
    81100    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
    84107    for line in lddpipe:
    85108        line = line.strip()
     
    87110        if len(cols) < 3 or cols[1] != "=>":
    88111            continue
    89         if cols[0].startswith("lib%s." % libname.lower()):
    90             ret = cols[2]
    91112        if cols[0].startswith("libc."):
    92113            # save this one too
    93114            bld.env.libc_path = cols[2]
     115        if cols[0].startswith(libname):
     116            ret = cols[2]
     117    bld.env.syslib_paths[libname] = ret
    94118    return ret
     119
     120
     121# some regular expressions for parsing readelf output
     122re_sharedlib = re.compile('Shared library: \[(.*)\]')
     123re_rpath     = re.compile('Library rpath: \[(.*)\]')
     124
     125def 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
     174def 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
     194def 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)
    95205
    96206
     
    114224                objmap[objpath] = t
    115225
    116     symbols = symbols_extract(objlist)
     226    symbols = symbols_extract(bld, objlist)
    117227    for obj in objlist:
    118228        t = objmap[obj]
     
    143253        if t.samba_type == 'LIBRARY':
    144254            for dep in t.add_objects:
    145                 t2 = bld.name_to_obj(dep, bld.env)
     255                t2 = bld.get_tgen_by_name(dep)
    146256                bld.ASSERT(t2 is not None, "Library '%s' has unknown dependency '%s'" % (name, dep))
    147257                bld.env.public_symbols[name] = bld.env.public_symbols[name].union(t2.public_symbols)
     
    156266        if t.samba_type == 'LIBRARY':
    157267            for dep in t.add_objects:
    158                 t2 = bld.name_to_obj(dep, bld.env)
     268                t2 = bld.get_tgen_by_name(dep)
    159269                bld.ASSERT(t2 is not None, "Library '%s' has unknown dependency '%s'" % (name, dep))
    160270                bld.env.used_symbols[name] = bld.env.used_symbols[name].union(t2.used_symbols)
     271
     272
     273def 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
    161285
    162286
     
    193317    objmap[bld.env.libc_path] = 'c'
    194318
    195     symbols = symbols_extract(syslib_paths, dynamic=True)
     319    symbols = symbols_extract(bld, syslib_paths, dynamic=True)
    196320
    197321    # keep a map of syslib names to public symbols
     
    240364                deps.add(depname[0])
    241365                continue
    242             t2 = bld.name_to_obj(depname[0], bld.env)
     366            t2 = bld.get_tgen_by_name(depname[0])
    243367            if len(t2.in_library) != 1:
    244368                deps.add(depname[0])
     
    263387        if t.samba_type in [ 'LIBRARY' ]:
    264388            for obj in t.samba_deps_extended:
    265                 t2 = bld.name_to_obj(obj, bld.env)
     389                t2 = bld.get_tgen_by_name(obj)
    266390                if t2 and t2.samba_type in [ 'SUBSYSTEM', 'ASN1' ]:
    267391                    if not t.sname in t2.in_library:
     
    280404
    281405    for dep in t.autodeps:
    282         t2 = bld.name_to_obj(dep, bld.env)
     406        t2 = bld.get_tgen_by_name(dep)
    283407        if t2 is None:
    284408            continue
     
    313437    '''check for depenencies that should be changed'''
    314438
    315     if bld.name_to_obj(t.sname + ".objlist", bld.env):
     439    if bld.get_tgen_by_name(t.sname + ".objlist"):
    316440        return
    317441
     
    325449    deps = set(t.samba_deps)
    326450    for d in t.samba_deps:
    327         if targets[d] in [ 'EMPTY', 'DISABLED', 'SYSLIB' ]:
     451        if targets[d] in [ 'EMPTY', 'DISABLED', 'SYSLIB', 'GENERATOR' ]:
    328452            continue
    329453        bld.ASSERT(d in bld.env.public_symbols, "Failed to find symbol list for dependency '%s'" % d)
     
    353477    '''check for syslib depenencies'''
    354478
    355     if bld.name_to_obj(t.sname + ".objlist", bld.env):
     479    if bld.get_tgen_by_name(t.sname + ".objlist"):
    356480        return
    357481
     
    362486    features = TO_LIST(t.features)
    363487    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'])
    365490
    366491    needed = {}
     
    444569
    445570
    446 
    447 def symbols_dupcheck(task):
     571def 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
     587def 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
     608def symbols_dupcheck(task, fail_on_error=False):
    448609    '''check for symbols defined in two different subsystems'''
    449610    bld = task.env.bld
     
    452613    targets = LOCAL_CACHE(bld, 'TARGET_TYPE')
    453614
    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
     622def 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)
    473625
    474626
     
    495647
    496648Build.BuildContext.SYMBOL_CHECK = SYMBOL_CHECK
     649
     650def 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
     657Build.BuildContext.DUP_SYMBOL_CHECK = DUP_SYMBOL_CHECK
  • vendor/current/buildtools/wafsamba/tru64cc.py

    r740 r988  
    1414@conftest
    1515def find_tru64cc(conf):
    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)
     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)
    2323
    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')
     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')
    2929
    30         v['CC']  = cc
    31         v['CC_NAME'] = 'tru64'
     30    v['CC']  = cc
     31    v['CC_NAME'] = 'tru64'
    3232
    3333@conftest
    3434def tru64cc_common_flags(conf):
    35         v = conf.env
     35    v = conf.env
    3636
    37         v['CC_SRC_F']            = ''
    38         v['CC_TGT_F']            = ['-c', '-o', '']
    39         v['CPPPATH_ST']          = '-I%s' # template for adding include paths
     37    v['CC_SRC_F']            = ''
     38    v['CC_TGT_F']            = ['-c', '-o', '']
     39    v['CPPPATH_ST']          = '-I%s' # template for adding include paths
    4040
    41         # linker
    42         if not v['LINK_CC']: v['LINK_CC'] = v['CC']
    43         v['CCLNK_SRC_F']         = ''
    44         v['CCLNK_TGT_F']         = ['-o', '']
     41    # linker
     42    if not v['LINK_CC']: v['LINK_CC'] = v['CC']
     43    v['CCLNK_SRC_F']         = ''
     44    v['CCLNK_TGT_F']         = ['-o', '']
    4545
    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'
     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'
    5151
    52 #       v['SONAME_ST']           = '-Wl,-h -Wl,%s'
    53 #       v['SHLIB_MARKER']        = '-Bdynamic'
    54 #       v['STATICLIB_MARKER']    = '-Bstatic'
     52#    v['SONAME_ST']           = '-Wl,-h -Wl,%s'
     53#    v['SHLIB_MARKER']        = '-Bdynamic'
     54#    v['STATICLIB_MARKER']    = '-Bstatic'
    5555
    56         # program
    57         v['program_PATTERN']     = '%s'
     56    # program
     57    v['program_PATTERN']     = '%s'
    5858
    59         # shared library
    60 #       v['shlib_CCFLAGS']       = ['-Kpic', '-DPIC']
    61         v['shlib_LINKFLAGS']     = ['-shared']
    62         v['shlib_PATTERN']       = 'lib%s.so'
     59    # shared library
     60#    v['shlib_CCFLAGS']       = ['-Kpic', '-DPIC']
     61    v['shlib_LINKFLAGS']     = ['-shared']
     62    v['shlib_PATTERN']       = 'lib%s.so'
    6363
    64         # static lib
    65 #       v['staticlib_LINKFLAGS'] = ['-Bstatic']
    66 #       v['staticlib_PATTERN']   = 'lib%s.a'
     64    # static lib
     65#    v['staticlib_LINKFLAGS'] = ['-Bstatic']
     66#    v['staticlib_PATTERN']   = 'lib%s.a'
    6767
    6868detect = '''
  • vendor/current/buildtools/wafsamba/wafsamba.py

    r740 r988  
    1717from samba_autoproto import *
    1818from samba_python import *
     19from samba_perl import *
    1920from samba_deps import *
    2021from samba_bundled import *
     22from samba_third_party import *
     23import samba_cross
    2124import samba_install
    2225import samba_conftests
     
    3235import symbols
    3336import pkgconfig
     37import configure_file
    3438
    3539# some systems have broken threading in python
     
    6468    # to be expressed in terms of build directory paths
    6569    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)
    6872        if not os.path.lexists(link_target):
    69             os.symlink('../' + p, link_target)
     73            os.symlink('../' + source, link_target)
    7074
    7175    # get perl to put the blib files in the build directory
     
    9296
    9397
     98def generate_empty_file(task):
     99    task.outputs[0].write('')
     100    return 0
    94101
    95102#################################################################
     
    100107                  public_headers=None,
    101108                  public_headers_install=True,
     109                  private_headers=None,
    102110                  header_path=None,
    103111                  pc_files=None,
     
    108116                  external_library=False,
    109117                  realname=None,
     118                  keep_underscore=False,
    110119                  autoproto=None,
    111                   group='libraries',
     120                  autoproto_extra_source='',
     121                  group='main',
    112122                  depends_on='',
    113123                  local_include=True,
     
    120130                  pyext=False,
    121131                  target_type='LIBRARY',
    122                   bundled_extension=True,
     132                  bundled_extension=False,
     133                  bundled_name=None,
    123134                  link_name=None,
    124135                  abi_directory=None,
     
    129140                  grouping_library=False,
    130141                  allow_undefined_symbols=False,
     142                  allow_warnings=False,
    131143                  enabled=True):
    132144    '''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
    133155
    134156    if not enabled:
     
    141163
    142164    # 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
    146174
    147175    if BUILTIN_LIBRARY(bld, libname):
     
    165193                        public_headers = public_headers,
    166194                        public_headers_install = public_headers_install,
     195                        private_headers= private_headers,
    167196                        header_path    = header_path,
    168197                        cflags         = cflags,
    169198                        group          = subsystem_group,
    170199                        autoproto      = autoproto,
     200                        autoproto_extra_source=autoproto_extra_source,
    171201                        depends_on     = depends_on,
    172202                        hide_symbols   = hide_symbols,
    173                         pyext          = pyext or (target_type == "PYTHON"),
     203                        allow_warnings = allow_warnings,
     204                        pyembed        = pyembed,
     205                        pyext          = pyext,
    174206                        local_include  = local_include,
    175207                        global_include = global_include)
     
    190222
    191223    # 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('_', '-')
    197242    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)
    199248
    200249    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:
    204255        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:
    208257        features += ' pyembed'
    209258
    210259    if abi_directory:
    211260        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
    212270
    213271    vscript = None
     
    221279        if version:
    222280            vscript = "%s.vscript" % libname
    223             bld.ABI_VSCRIPT(libname, abi_directory, version, vscript,
     281            bld.ABI_VSCRIPT(version_libname, abi_directory, version, vscript,
    224282                            abi_match)
    225283            fullname = apply_pattern(bundled_name, bld.env.shlib_PATTERN)
     
    231289                raise Utils.WafError("unable to find vscript path for %s" % vscript)
    232290            bld.add_manual_dependency(fullpath, vscriptpath)
    233             if Options.is_install:
     291            if bld.is_install:
    234292                # also make the .inst file depend on the vscript
    235293                instname = apply_pattern(bundled_name + '.inst', bld.env.shlib_PATTERN)
     
    247305        samba_includes  = includes,
    248306        version_script  = vscript,
     307        version_libname = version_libname,
    249308        local_include   = local_include,
    250309        global_include  = global_include,
     
    269328        t.link_name = link_name
    270329
    271     if pc_files is not None:
     330    if pc_files is not None and not private_library:
    272331        bld.PKG_CONFIG_FILES(pc_files, vnum=vnum)
    273332
    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)
    276336
    277337
     
    284344                 includes='',
    285345                 public_headers=None,
     346                 private_headers=None,
    286347                 header_path=None,
    287348                 modules=None,
     
    292353                 use_global_deps=True,
    293354                 compiler=None,
    294                  group='binaries',
     355                 group='main',
    295356                 manpages=None,
    296357                 local_include=True,
     
    312373        return
    313374
    314     features = 'cc cprogram symlink_bin install_bin'
     375    features = 'c cprogram symlink_bin install_bin'
    315376    if pyembed:
    316377        features += ' pyembed'
     
    327388    else:
    328389        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'))
    329399
    330400    # first create a target for building the object files for this binary
     
    335405                        deps           = deps,
    336406                        includes       = includes,
    337                         cflags         = cflags,
     407                        cflags         = pie_cflags,
    338408                        group          = subsystem_group,
    339409                        autoproto      = autoproto,
     
    365435        samba_inst_path= install_path,
    366436        samba_install  = install,
    367         samba_ldflags  = TO_LIST(ldflags)
     437        samba_ldflags  = pie_ldflags
    368438        )
    369439
    370440    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)
    372442
    373443Build.BuildContext.SAMBA_BINARY = SAMBA_BINARY
     
    391461                 enabled=True,
    392462                 pyembed=False,
    393                  allow_undefined_symbols=False
     463                 manpages=None,
     464                 allow_undefined_symbols=False,
     465                 allow_warnings=False
    394466                 ):
    395467    '''define a Samba module.'''
     468
     469    bld.ASSERT(subsystem, "You must specify a subsystem for SAMBA_MODULE(%s)" % modname)
    396470
    397471    source = bld.EXPAND_VARIABLES(source, vars=vars)
     
    400474
    401475    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
    402479        bld.SAMBA_SUBSYSTEM(modname, source,
    403480                    deps=deps,
     
    408485                    local_include=local_include,
    409486                    global_include=global_include,
     487                    allow_warnings=allow_warnings,
    410488                    enabled=enabled)
    411489
     
    417495        return
    418496
    419     obj_target = modname + '.objlist'
     497    # Do not create modules for disabled subsystems
     498    if GET_TARGET_TYPE(bld, subsystem) == 'DISABLED':
     499        return
    420500
    421501    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)
    428509
    429510    realname = bld.make_libname(realname)
     
    446527                      global_include=global_include,
    447528                      vars=vars,
     529                      bundled_name=build_name,
    448530                      link_name=build_link_name,
    449531                      install_path="${MODULESDIR}/%s" % subsystem,
    450532                      pyembed=pyembed,
    451                       allow_undefined_symbols=allow_undefined_symbols
     533                      manpages=manpages,
     534                      allow_undefined_symbols=allow_undefined_symbols,
     535                      allow_warnings=allow_warnings
    452536                      )
    453537
     
    463547                    public_headers=None,
    464548                    public_headers_install=True,
     549                    private_headers=None,
    465550                    header_path=None,
    466551                    cflags='',
    467552                    cflags_end=None,
    468553                    group='main',
    469                     init_function_sentinal=None,
     554                    init_function_sentinel=None,
    470555                    autoproto=None,
    471556                    autoproto_extra_source='',
     
    481566                    subdir=None,
    482567                    hide_symbols=False,
    483                     pyext=False):
     568                    allow_warnings=False,
     569                    pyext=False,
     570                    pyembed=False):
    484571    '''define a Samba subsystem'''
    485572
     
    489576
    490577    # 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
    494587
    495588    if not SET_TARGET_TYPE(bld, modname, 'SUBSYSTEM'):
     
    505598    bld.SET_BUILD_GROUP(group)
    506599
    507     features = 'cc'
     600    features = 'c'
    508601    if pyext:
    509602        features += ' pyext'
     603    if pyembed:
     604        features += ' pyembed'
    510605
    511606    t = bld(
     
    513608        source         = source,
    514609        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),
    516613        depends_on     = depends_on,
    517614        samba_deps     = TO_LIST(deps),
     
    522619        samba_subsystem= subsystem_name,
    523620        samba_use_hostcc = use_hostcc,
    524         samba_use_global_deps = use_global_deps
     621        samba_use_global_deps = use_global_deps,
    525622        )
    526623
     
    543640                    public_headers=None,
    544641                    public_headers_install=True,
     642                    private_headers=None,
    545643                    header_path=None,
    546644                    vars=None,
     645                    dep_vars=[],
    547646                    always=False):
    548647    '''A generic source generator target'''
     
    553652    if not enabled:
    554653        return
     654
     655    dep_vars.append('ruledeps')
     656    dep_vars.append('SAMBA_GENERATOR_VARS')
    555657
    556658    bld.SET_BUILD_GROUP(group)
     
    560662        target=target,
    561663        shell=isinstance(rule, str),
    562         on_results=True,
     664        update_outputs=True,
    563665        before='cc',
    564666        ext_out='.c',
    565667        samba_type='GENERATOR',
    566         dep_vars = [rule] + (vars or []),
     668        dep_vars = dep_vars,
    567669        name=name)
     670
     671    if vars is None:
     672        vars = {}
     673    t.env.SAMBA_GENERATOR_VARS = vars
    568674
    569675    if always:
     
    578684
    579685
    580 @runonce
     686@Utils.run_once
    581687def SETUP_BUILD_GROUPS(bld):
    582688    '''setup build groups used to ensure that the different build
     
    597703    bld.add_group('main')
    598704    bld.add_group('symbolcheck')
    599     bld.add_group('libraries')
    600     bld.add_group('binaries')
    601705    bld.add_group('syslibcheck')
    602706    bld.add_group('final')
     
    629733
    630734
    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 = True
    635 
    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.target
    641 
    642735def SAMBA_SCRIPT(bld, name, pattern, installdir, installname=None):
    643736    '''used to copy scripts from the source tree into the build directory
    644737       for use by selftest'''
    645738
    646     source = bld.path.ant_glob(pattern)
     739    source = bld.path.ant_glob(pattern, flat=True)
    647740
    648741    bld.SET_BUILD_GROUP('build_source')
    649742    for s in TO_LIST(source):
    650743        iname = s
    651         if installname != None:
     744        if installname is not None:
    652745            iname = installname
    653746        target = os.path.join(installdir, iname)
    654747        tgtdir = os.path.dirname(os.path.join(bld.srcnode.abspath(bld.env), '..', target))
    655748        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)
    663757Build.BuildContext.SAMBA_SCRIPT = SAMBA_SCRIPT
     758
    664759
    665760def copy_and_fix_python_path(task):
     
    673768sys.path.insert(1, "%s")""" % (task.env["PYTHONARCHDIR"], task.env["PYTHONDIR"])
    674769
     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
    675775    installed_location=task.outputs[0].bldpath(task.env)
    676776    source_file = open(task.inputs[0].srcpath(task.env))
    677777    installed_file = open(installed_location, 'w')
     778    lineno = 0
    678779    for line in source_file:
    679780        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:
    681785            newline = line.replace(pattern, replacement)
    682786        installed_file.write(newline)
     787        lineno = lineno + 1
    683788    installed_file.close()
    684789    os.chmod(installed_location, 0755)
    685790    return 0
    686791
     792def 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
    687820
    688821def 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):
    690824    '''install a file'''
    691825    destdir = bld.EXPAND_VARIABLES(destdir)
     
    696830    dest = os.path.join(destdir, destname)
    697831    if python_fixup:
    698         # fixup the python path it will use to find Samba modules
     832        # fix the path python will use to find Samba modules
    699833        inst_file = file + '.inst'
    700834        bld.SAMBA_GENERATOR('python_%s' % destname,
    701835                            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"],
    702846                            source=file,
    703847                            target=inst_file)
     
    709853
    710854def 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):
    712857    '''install a set of files'''
    713858    for f in TO_LIST(files):
    714859        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)
    717862Build.BuildContext.INSTALL_FILES = INSTALL_FILES
    718863
     
    721866                     python_fixup=False, exclude=None, trim_path=None):
    722867    '''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))
    724869    if trim_path:
    725870        files2 = []
     
    746891
    747892
    748 def MANPAGES(bld, manpages):
     893def MANPAGES(bld, manpages, install):
    749894    '''build and install manual pages'''
    750895    bld.env.MAN_XSL = 'http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl'
     
    755900                            target=m,
    756901                            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)
     906Build.BuildContext.MANPAGES = MANPAGES
     907
     908def 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'''
    758928                            )
    759929        bld.INSTALL_FILES('${MANDIR}/man%s' % m[-1], m, flat=True)
    760 Build.BuildContext.MANPAGES = MANPAGES
    761 
     930Build.BuildContext.SAMBAMANPAGES = SAMBAMANPAGES
    762931
    763932#############################################################
  • vendor/current/buildtools/wafsamba/wscript

    r740 r988  
    33# this is a base set of waf rules that everything else pulls in first
    44
    5 import sys, wafsamba, Configure, Logs
    6 import Options, os, preproc
    7 from samba_utils import *
     5import os, sys
     6import wafsamba, Configure, Logs, Options, Utils
     7from samba_utils import os_path_relpath
    88from optparse import SUPPRESS_HELP
    99
     
    2828                   action="store", dest='BUNDLED_LIBS', default='')
    2929
     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
    3034    extension_default = Options.options['PRIVATE_EXTENSION_DEFAULT']
    3135    gr.add_option('--private-library-extension',
     
    3842                   action="store", dest='PRIVATE_EXTENSION_EXCEPTION', default=extension_exception)
    3943
    40     builtin_defauilt = Options.options['BUILTIN_LIBRARIES_DEFAULT']
     44    builtin_default = Options.options['BUILTIN_LIBRARIES_DEFAULT']
    4145    gr.add_option('--builtin-libraries',
    42                    help=("command separated list of libraries to build directly into binaries [%s]" % builtin_defauilt),
    43                    action="store", dest='BUILTIN_LIBRARIES', default=builtin_defauilt)
     46                   help=("command separated list of libraries to build directly into binaries [%s]" % builtin_default),
     47                   action="store", dest='BUILTIN_LIBRARIES', default=builtin_default)
    4448
    4549    gr.add_option('--minimum-library-version',
     
    4751                   action="store", dest='MINIMUM_LIBRARY_VERSION', default='')
    4852
    49     gr.add_option('--disable-shared',
    50                    help=("Disable all use of shared libraries"),
    51                    action="store_true", dest='disable_shared', default=False)
    5253    gr.add_option('--disable-rpath',
    5354                   help=("Disable use of rpath for build binaries"),
     
    7475                   action="store", dest='PRIVATELIBDIR', default=None)
    7576
     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
    7685    gr = opt.option_group('developer options')
    7786
     
    8291                   help='enable automatic reconfigure on build',
    8392                   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)
    8496    gr.add_option('--enable-developer',
    8597                   help=("Turn on developer warnings and debugging"),
    8698                   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
    87102    gr.add_option('--picky-developer',
    88103                   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)
    90106    gr.add_option('--fatal-errors',
    91107                   help=("Stop compilation on first error (enable -Wfatal-errors)"),
     
    103119                   help=("mark version with + if local git changes"),
    104120                   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)
    105124
    106125    gr.add_option('--abi-check',
     
    121140                  help=("check symbols in object files against project rules"),
    122141                  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)
    123146
    124147    gr.add_option('--why-needed',
     
    153176                   help=SUPPRESS_HELP,
    154177                   action='store', dest='AUTOCONF_HOST', default='')
     178    opt.add_option('--target',
     179                   help=SUPPRESS_HELP,
     180                   action='store', dest='AUTOCONF_TARGET', default='')
    155181    opt.add_option('--program-prefix',
    156182                   help=SUPPRESS_HELP,
     
    159185                   help=SUPPRESS_HELP,
    160186                   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)
    161190
    162191    gr = opt.option_group('dist options')
     
    168197                   type='string', action='store', dest='TAG_RELEASE')
    169198
    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
    172207def configure(conf):
    173208    conf.env.hlist = []
     
    182217    conf.check_tool('gnu_dirs')
    183218    conf.check_tool('wafsamba')
     219    conf.check_tool('print_commands')
    184220
    185221    conf.CHECK_CC_ENV()
    186222
    187223    conf.check_tool('compiler_cc')
     224
     225    conf.CHECK_STANDARD_LIBPATH()
    188226
    189227    # we need git for 'waf dist'
     
    192230    # older gcc versions (< 4.4) does not work with gccdeps, so we have to see if the .d file is generated
    193231    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
    194237        from TaskGen import feature, after
    195238        @feature('testd')
     
    206249        try:
    207250            try:
    208                 conf.check(features='cc testd', 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')
    209252            except:
    210253                pass
     
    221264    conf.env.PRIVATELIBDIR = Options.options.PRIVATELIBDIR
    222265    conf.env.BUNDLED_LIBS = Options.options.BUNDLED_LIBS.split(',')
     266    conf.env.PRIVATE_LIBS = Options.options.PRIVATE_LIBS.split(',')
    223267    conf.env.BUILTIN_LIBRARIES = Options.options.BUILTIN_LIBRARIES.split(',')
    224     conf.env.DISABLE_SHARED = Options.options.disable_shared
    225268    conf.env.NONSHARED_BINARIES = Options.options.NONSHARED_BINARIES.split(',')
    226269
     
    236279    conf.env.AUTOCONF_HOST  = Options.options.AUTOCONF_HOST
    237280    conf.env.AUTOCONF_PROGRAM_PREFIX = Options.options.AUTOCONF_PROGRAM_PREFIX
     281
     282    conf.env.EXTRA_PYTHON = Options.options.EXTRA_PYTHON
    238283
    239284    if (conf.env.AUTOCONF_HOST and
     
    271316                    msg='Checking simple C program')
    272317
    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'
    276334
    277335    # check for rpath
    278     if not conf.env.DISABLE_SHARED and conf.CHECK_LIBRARY_SUPPORT(rpath=True):
     336    if conf.CHECK_LIBRARY_SUPPORT(rpath=True):
    279337        support_rpath = True
    280338        conf.env.RPATH_ON_BUILD   = not Options.options.disable_rpath_build
     
    296354            conf.env.PRIVATELIBDIR = conf.env.LIBDIR
    297355
    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
    300357        conf.CHECK_LIBRARY_SUPPORT(rpath=support_rpath,
    301358                                   version_script=True,
     
    305362        conf.env.HAVE_LD_VERSION_SCRIPT = False
    306363
    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'):
    308406        conf.DEFINE('_ALL_SOURCE', 1, add_to_cflags=True)
    309407        # Might not be needed if ALL_SOURCE is defined
     
    335433
    336434    # check for pkgconfig
    337     conf.check_cfg(atleast_pkgconfig_version='0.0.0')
     435    conf.CHECK_CFG(atleast_pkgconfig_version='0.0.0')
    338436
    339437    conf.DEFINE('_GNU_SOURCE', 1, add_to_cflags=True)
    340438    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], '''
     454struct foo {int x;char y;};
     455struct foo bar = { .y = 'X', .x = 1 };
     456'''):
     457            if f != "":
     458                conf.ADD_CFLAGS(f)
     459            break
    341460
    342461    # get the base headers we'll use for the rest of the tests
     
    344463                       add_headers=True)
    345464    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)
    347471    conf.CHECK_HEADERS('limits.h assert.h')
    348472
    349473    # 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')
    351476
    352477    if 'HAVE_STDDEF_H' in conf.env and 'HAVE_STDLIB_H' in conf.env:
     
    365490        conf.define('SHLIBEXT', "so", quote=True)
    366491
    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)
    370554
    371555    # check if signal() takes a void function
Note: See TracChangeset for help on using the changeset viewer.