~ubuntu-branches/debian/jessie/ldb/jessie

« back to all changes in this revision

Viewing changes to buildtools/wafsamba/wafsamba.py

  • Committer: Package Import Robot
  • Author(s): Jelmer Vernooij
  • Date: 2014-07-05 23:32:23 UTC
  • mfrom: (1.3.16)
  • Revision ID: package-import@ubuntu.com-20140705233223-dss2i2wmfksxbivh
Tags: 1:1.1.18-1
* New upstream release.
 + Depend on tdb >= 1.3.2.
 + Fixes __attribute__((visibility)) check to not use nested functions.
   Closes: #749987
* Use canonical URL in Vcs-Git field.
* Specify branch in Vcs-Git field.
* Add 02_hurd: link against pthread on the Hurd, to fix ldb module
  loading. Closes: #749095

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
from samba_pidl import *
17
17
from samba_autoproto import *
18
18
from samba_python import *
 
19
from samba_perl import *
19
20
from samba_deps import *
20
21
from samba_bundled import *
 
22
from samba_third_party import *
21
23
import samba_install
22
24
import samba_conftests
23
25
import samba_abi
130
132
                  private_library=False,
131
133
                  grouping_library=False,
132
134
                  allow_undefined_symbols=False,
133
 
                  allow_warnings=True,
 
135
                  allow_warnings=False,
134
136
                  enabled=True):
135
137
    '''define a Samba library'''
136
138
 
347
349
    # only specify PIE flags for binaries
348
350
    pie_cflags = cflags
349
351
    pie_ldflags = TO_LIST(ldflags)
350
 
    if bld.env['ENABLE_PIE'] == True:
 
352
    if bld.env['ENABLE_PIE'] is True:
351
353
        pie_cflags += ' -fPIE'
352
354
        pie_ldflags.extend(TO_LIST('-pie'))
353
 
    if bld.env['ENABLE_RELRO'] == True:
 
355
    if bld.env['ENABLE_RELRO'] is True:
354
356
        pie_ldflags.extend(TO_LIST('-Wl,-z,relro,-z,now'))
355
357
 
356
358
    # first create a target for building the object files for this binary
418
420
                 pyembed=False,
419
421
                 manpages=None,
420
422
                 allow_undefined_symbols=False,
421
 
                 allow_warnings=True
 
423
                 allow_warnings=False
422
424
                 ):
423
425
    '''define a Samba module.'''
424
426
 
518
520
                    vars=None,
519
521
                    subdir=None,
520
522
                    hide_symbols=False,
521
 
                    allow_warnings=True,
 
523
                    allow_warnings=False,
522
524
                    pyext=False,
523
525
                    pyembed=False):
524
526
    '''define a Samba subsystem'''
588
590
                    public_headers_install=True,
589
591
                    header_path=None,
590
592
                    vars=None,
 
593
                    dep_vars=[],
591
594
                    always=False):
592
595
    '''A generic source generator target'''
593
596
 
597
600
    if not enabled:
598
601
        return
599
602
 
600
 
    dep_vars = []
601
 
    if isinstance(vars, dict):
602
 
        dep_vars = vars.keys()
603
 
    elif isinstance(vars, list):
604
 
        dep_vars = vars
 
603
    dep_vars.append('ruledeps')
 
604
    dep_vars.append('SAMBA_GENERATOR_VARS')
605
605
 
606
606
    bld.SET_BUILD_GROUP(group)
607
607
    t = bld(
613
613
        before='cc',
614
614
        ext_out='.c',
615
615
        samba_type='GENERATOR',
616
 
        dep_vars = [rule] + dep_vars,
 
616
        dep_vars = dep_vars,
617
617
        name=name)
618
618
 
 
619
    if vars is None:
 
620
        vars = {}
 
621
    t.env.SAMBA_GENERATOR_VARS = vars
 
622
 
619
623
    if always:
620
624
        t.always = True
621
625
 
711
715
        replacement="""sys.path.insert(0, "%s")
712
716
sys.path.insert(1, "%s")""" % (task.env["PYTHONARCHDIR"], task.env["PYTHONDIR"])
713
717
 
714
 
    shebang = None
715
 
 
716
718
    if task.env["PYTHON"][0] == "/":
717
719
        replacement_shebang = "#!%s\n" % task.env["PYTHON"]
718
720
    else:
724
726
    lineno = 0
725
727
    for line in source_file:
726
728
        newline = line
727
 
        if lineno == 0 and task.env["PYTHON_SPECIFIED"] == True and line[:2] == "#!":
 
729
        if (lineno == 0 and task.env["PYTHON_SPECIFIED"] is True and
 
730
                line[:2] == "#!"):
 
731
            newline = replacement_shebang
 
732
        elif pattern in line:
 
733
            newline = line.replace(pattern, replacement)
 
734
        installed_file.write(newline)
 
735
        lineno = lineno + 1
 
736
    installed_file.close()
 
737
    os.chmod(installed_location, 0755)
 
738
    return 0
 
739
 
 
740
def copy_and_fix_perl_path(task):
 
741
    pattern='use lib "$RealBin/lib";'
 
742
 
 
743
    replacement = ""
 
744
    if not task.env["PERL_LIB_INSTALL_DIR"] in task.env["PERL_INC"]:
 
745
         replacement = 'use lib "%s";' % task.env["PERL_LIB_INSTALL_DIR"]
 
746
 
 
747
    if task.env["PERL"][0] == "/":
 
748
        replacement_shebang = "#!%s\n" % task.env["PERL"]
 
749
    else:
 
750
        replacement_shebang = "#!/usr/bin/env %s\n" % task.env["PERL"]
 
751
 
 
752
    installed_location=task.outputs[0].bldpath(task.env)
 
753
    source_file = open(task.inputs[0].srcpath(task.env))
 
754
    installed_file = open(installed_location, 'w')
 
755
    lineno = 0
 
756
    for line in source_file:
 
757
        newline = line
 
758
        if lineno == 0 and task.env["PERL_SPECIFIED"] == True and line[:2] == "#!":
728
759
            newline = replacement_shebang
729
760
        elif pattern in line:
730
761
            newline = line.replace(pattern, replacement)
736
767
 
737
768
 
738
769
def install_file(bld, destdir, file, chmod=MODE_644, flat=False,
739
 
                 python_fixup=False, destname=None, base_name=None):
 
770
                 python_fixup=False, perl_fixup=False,
 
771
                 destname=None, base_name=None):
740
772
    '''install a file'''
741
773
    destdir = bld.EXPAND_VARIABLES(destdir)
742
774
    if not destname:
745
777
            destname = os.path.basename(destname)
746
778
    dest = os.path.join(destdir, destname)
747
779
    if python_fixup:
748
 
        # fixup the python path it will use to find Samba modules
 
780
        # fix the path python will use to find Samba modules
749
781
        inst_file = file + '.inst'
750
782
        bld.SAMBA_GENERATOR('python_%s' % destname,
751
783
                            rule=copy_and_fix_python_path,
752
 
                            source=file,
753
 
                            target=inst_file)
754
 
        bld.add_manual_dependency(bld.path.find_or_declare(inst_file), bld.env["PYTHONARCHDIR"])
755
 
        bld.add_manual_dependency(bld.path.find_or_declare(inst_file), bld.env["PYTHONDIR"])
756
 
        bld.add_manual_dependency(bld.path.find_or_declare(inst_file), str(bld.env["PYTHON_SPECIFIED"]))
757
 
        bld.add_manual_dependency(bld.path.find_or_declare(inst_file), bld.env["PYTHON"])
 
784
                            dep_vars=["PYTHON","PYTHON_SPECIFIED","PYTHONDIR","PYTHONARCHDIR"],
 
785
                            source=file,
 
786
                            target=inst_file)
 
787
        file = inst_file
 
788
    if perl_fixup:
 
789
        # fix the path perl will use to find Samba modules
 
790
        inst_file = file + '.inst'
 
791
        bld.SAMBA_GENERATOR('perl_%s' % destname,
 
792
                            rule=copy_and_fix_perl_path,
 
793
                            dep_vars=["PERL","PERL_SPECIFIED","PERL_LIB_INSTALL_DIR"],
 
794
                            source=file,
 
795
                            target=inst_file)
758
796
        file = inst_file
759
797
    if base_name:
760
798
        file = os.path.join(base_name, file)
762
800
 
763
801
 
764
802
def INSTALL_FILES(bld, destdir, files, chmod=MODE_644, flat=False,
765
 
                  python_fixup=False, destname=None, base_name=None):
 
803
                  python_fixup=False, perl_fixup=False,
 
804
                  destname=None, base_name=None):
766
805
    '''install a set of files'''
767
806
    for f in TO_LIST(files):
768
807
        install_file(bld, destdir, f, chmod=chmod, flat=flat,
769
 
                     python_fixup=python_fixup, destname=destname,
770
 
                     base_name=base_name)
 
808
                     python_fixup=python_fixup, perl_fixup=perl_fixup,
 
809
                     destname=destname, base_name=base_name)
771
810
Build.BuildContext.INSTALL_FILES = INSTALL_FILES
772
811
 
773
812