Changeset 988 for vendor/current/buildtools/wafsamba/wafsamba.py
- Timestamp:
- Nov 24, 2016, 1:14:11 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
vendor/current/buildtools/wafsamba/wafsamba.py
r740 r988 17 17 from samba_autoproto import * 18 18 from samba_python import * 19 from samba_perl import * 19 20 from samba_deps import * 20 21 from samba_bundled import * 22 from samba_third_party import * 23 import samba_cross 21 24 import samba_install 22 25 import samba_conftests … … 32 35 import symbols 33 36 import pkgconfig 37 import configure_file 34 38 35 39 # some systems have broken threading in python … … 64 68 # to be expressed in terms of build directory paths 65 69 mkdir_p(os.path.join(conf.blddir, 'default')) 66 for p in ['python','shared', 'modules']:67 link_target = os.path.join(conf.blddir, 'default/' + p)70 for (source, target) in [('shared', 'shared'), ('modules', 'modules'), ('python', 'python_modules')]: 71 link_target = os.path.join(conf.blddir, 'default/' + target) 68 72 if not os.path.lexists(link_target): 69 os.symlink('../' + p, link_target)73 os.symlink('../' + source, link_target) 70 74 71 75 # get perl to put the blib files in the build directory … … 92 96 93 97 98 def generate_empty_file(task): 99 task.outputs[0].write('') 100 return 0 94 101 95 102 ################################################################# … … 100 107 public_headers=None, 101 108 public_headers_install=True, 109 private_headers=None, 102 110 header_path=None, 103 111 pc_files=None, … … 108 116 external_library=False, 109 117 realname=None, 118 keep_underscore=False, 110 119 autoproto=None, 111 group='libraries', 120 autoproto_extra_source='', 121 group='main', 112 122 depends_on='', 113 123 local_include=True, … … 120 130 pyext=False, 121 131 target_type='LIBRARY', 122 bundled_extension=True, 132 bundled_extension=False, 133 bundled_name=None, 123 134 link_name=None, 124 135 abi_directory=None, … … 129 140 grouping_library=False, 130 141 allow_undefined_symbols=False, 142 allow_warnings=False, 131 143 enabled=True): 132 144 '''define a Samba library''' 145 146 if pyembed and bld.env['IS_EXTRA_PYTHON']: 147 public_headers = pc_files = None 148 149 if private_library and public_headers: 150 raise Utils.WafError("private library '%s' must not have public header files" % 151 libname) 152 153 if LIB_MUST_BE_PRIVATE(bld, libname): 154 private_library = True 133 155 134 156 if not enabled: … … 141 163 142 164 # remember empty libraries, so we can strip the dependencies 143 if ((source == '') or (source == [])) and deps == '' and public_deps == '': 144 SET_TARGET_TYPE(bld, libname, 'EMPTY') 145 return 165 if ((source == '') or (source == [])): 166 if deps == '' and public_deps == '': 167 SET_TARGET_TYPE(bld, libname, 'EMPTY') 168 return 169 empty_c = libname + '.empty.c' 170 bld.SAMBA_GENERATOR('%s_empty_c' % libname, 171 rule=generate_empty_file, 172 target=empty_c) 173 source=empty_c 146 174 147 175 if BUILTIN_LIBRARY(bld, libname): … … 165 193 public_headers = public_headers, 166 194 public_headers_install = public_headers_install, 195 private_headers= private_headers, 167 196 header_path = header_path, 168 197 cflags = cflags, 169 198 group = subsystem_group, 170 199 autoproto = autoproto, 200 autoproto_extra_source=autoproto_extra_source, 171 201 depends_on = depends_on, 172 202 hide_symbols = hide_symbols, 173 pyext = pyext or (target_type == "PYTHON"), 203 allow_warnings = allow_warnings, 204 pyembed = pyembed, 205 pyext = pyext, 174 206 local_include = local_include, 175 207 global_include = global_include) … … 190 222 191 223 # we don't want any public libraries without version numbers 192 if not private_library and vnum is None and soname is None and target_type != 'PYTHON' and not realname: 193 raise Utils.WafError("public library '%s' must have a vnum" % libname) 194 195 if target_type == 'PYTHON' or realname or not private_library: 196 bundled_name = libname.replace('_', '-') 224 if (not private_library and target_type != 'PYTHON' and not realname): 225 if vnum is None and soname is None: 226 raise Utils.WafError("public library '%s' must have a vnum" % 227 libname) 228 if pc_files is None and not bld.env['IS_EXTRA_PYTHON']: 229 raise Utils.WafError("public library '%s' must have pkg-config file" % 230 libname) 231 if public_headers is None and not bld.env['IS_EXTRA_PYTHON']: 232 raise Utils.WafError("public library '%s' must have header files" % 233 libname) 234 235 if bundled_name is not None: 236 pass 237 elif target_type == 'PYTHON' or realname or not private_library: 238 if keep_underscore: 239 bundled_name = libname 240 else: 241 bundled_name = libname.replace('_', '-') 197 242 else: 198 bundled_name = PRIVATE_NAME(bld, libname, bundled_extension, private_library) 243 assert (private_library == True and realname is None) 244 if abi_directory or vnum or soname: 245 bundled_extension=True 246 bundled_name = PRIVATE_NAME(bld, libname.replace('_', '-'), 247 bundled_extension, private_library) 199 248 200 249 ldflags = TO_LIST(ldflags) 201 202 features = 'cc cshlib symlink_lib install_lib' 203 if target_type == 'PYTHON': 250 if bld.env['ENABLE_RELRO'] is True: 251 ldflags.extend(TO_LIST('-Wl,-z,relro,-z,now')) 252 253 features = 'c cshlib symlink_lib install_lib' 254 if pyext: 204 255 features += ' pyext' 205 if pyext or pyembed: 206 # this is quite strange. we should add pyext feature for pyext 207 # but that breaks the build. This may be a bug in the waf python tool 256 if pyembed: 208 257 features += ' pyembed' 209 258 210 259 if abi_directory: 211 260 features += ' abi_check' 261 262 if pyembed and bld.env['PYTHON_SO_ABI_FLAG']: 263 # For ABI checking, we don't care about the exact Python version. 264 # Replace the Python ABI tag (e.g. ".cpython-35m") by a generic ".py3" 265 abi_flag = bld.env['PYTHON_SO_ABI_FLAG'] 266 replacement = '.py%s' % bld.env['PYTHON_VERSION'].split('.')[0] 267 version_libname = libname.replace(abi_flag, replacement) 268 else: 269 version_libname = libname 212 270 213 271 vscript = None … … 221 279 if version: 222 280 vscript = "%s.vscript" % libname 223 bld.ABI_VSCRIPT( libname, abi_directory, version, vscript,281 bld.ABI_VSCRIPT(version_libname, abi_directory, version, vscript, 224 282 abi_match) 225 283 fullname = apply_pattern(bundled_name, bld.env.shlib_PATTERN) … … 231 289 raise Utils.WafError("unable to find vscript path for %s" % vscript) 232 290 bld.add_manual_dependency(fullpath, vscriptpath) 233 if Options.is_install:291 if bld.is_install: 234 292 # also make the .inst file depend on the vscript 235 293 instname = apply_pattern(bundled_name + '.inst', bld.env.shlib_PATTERN) … … 247 305 samba_includes = includes, 248 306 version_script = vscript, 307 version_libname = version_libname, 249 308 local_include = local_include, 250 309 global_include = global_include, … … 269 328 t.link_name = link_name 270 329 271 if pc_files is not None :330 if pc_files is not None and not private_library: 272 331 bld.PKG_CONFIG_FILES(pc_files, vnum=vnum) 273 332 274 if manpages is not None and 'XSLTPROC_MANPAGES' in bld.env and bld.env['XSLTPROC_MANPAGES']: 275 bld.MANPAGES(manpages) 333 if (manpages is not None and 'XSLTPROC_MANPAGES' in bld.env and 334 bld.env['XSLTPROC_MANPAGES']): 335 bld.MANPAGES(manpages, install) 276 336 277 337 … … 284 344 includes='', 285 345 public_headers=None, 346 private_headers=None, 286 347 header_path=None, 287 348 modules=None, … … 292 353 use_global_deps=True, 293 354 compiler=None, 294 group=' binaries',355 group='main', 295 356 manpages=None, 296 357 local_include=True, … … 312 373 return 313 374 314 features = 'c ccprogram symlink_bin install_bin'375 features = 'c cprogram symlink_bin install_bin' 315 376 if pyembed: 316 377 features += ' pyembed' … … 327 388 else: 328 389 subsystem_group = group 390 391 # only specify PIE flags for binaries 392 pie_cflags = cflags 393 pie_ldflags = TO_LIST(ldflags) 394 if bld.env['ENABLE_PIE'] is True: 395 pie_cflags += ' -fPIE' 396 pie_ldflags.extend(TO_LIST('-pie')) 397 if bld.env['ENABLE_RELRO'] is True: 398 pie_ldflags.extend(TO_LIST('-Wl,-z,relro,-z,now')) 329 399 330 400 # first create a target for building the object files for this binary … … 335 405 deps = deps, 336 406 includes = includes, 337 cflags = cflags,407 cflags = pie_cflags, 338 408 group = subsystem_group, 339 409 autoproto = autoproto, … … 365 435 samba_inst_path= install_path, 366 436 samba_install = install, 367 samba_ldflags = TO_LIST(ldflags)437 samba_ldflags = pie_ldflags 368 438 ) 369 439 370 440 if manpages is not None and 'XSLTPROC_MANPAGES' in bld.env and bld.env['XSLTPROC_MANPAGES']: 371 bld.MANPAGES(manpages )441 bld.MANPAGES(manpages, install) 372 442 373 443 Build.BuildContext.SAMBA_BINARY = SAMBA_BINARY … … 391 461 enabled=True, 392 462 pyembed=False, 393 allow_undefined_symbols=False 463 manpages=None, 464 allow_undefined_symbols=False, 465 allow_warnings=False 394 466 ): 395 467 '''define a Samba module.''' 468 469 bld.ASSERT(subsystem, "You must specify a subsystem for SAMBA_MODULE(%s)" % modname) 396 470 397 471 source = bld.EXPAND_VARIABLES(source, vars=vars) … … 400 474 401 475 if internal_module or BUILTIN_LIBRARY(bld, modname): 476 # Do not create modules for disabled subsystems 477 if GET_TARGET_TYPE(bld, subsystem) == 'DISABLED': 478 return 402 479 bld.SAMBA_SUBSYSTEM(modname, source, 403 480 deps=deps, … … 408 485 local_include=local_include, 409 486 global_include=global_include, 487 allow_warnings=allow_warnings, 410 488 enabled=enabled) 411 489 … … 417 495 return 418 496 419 obj_target = modname + '.objlist' 497 # Do not create modules for disabled subsystems 498 if GET_TARGET_TYPE(bld, subsystem) == 'DISABLED': 499 return 420 500 421 501 realname = modname 422 if subsystem is not None: 423 deps += ' ' + subsystem 424 while realname.startswith("lib"+subsystem+"_"): 425 realname = realname[len("lib"+subsystem+"_"):] 426 while realname.startswith(subsystem+"_"): 427 realname = realname[len(subsystem+"_"):] 502 deps += ' ' + subsystem 503 while realname.startswith("lib"+subsystem+"_"): 504 realname = realname[len("lib"+subsystem+"_"):] 505 while realname.startswith(subsystem+"_"): 506 realname = realname[len(subsystem+"_"):] 507 508 build_name = "%s_module_%s" % (subsystem, realname) 428 509 429 510 realname = bld.make_libname(realname) … … 446 527 global_include=global_include, 447 528 vars=vars, 529 bundled_name=build_name, 448 530 link_name=build_link_name, 449 531 install_path="${MODULESDIR}/%s" % subsystem, 450 532 pyembed=pyembed, 451 allow_undefined_symbols=allow_undefined_symbols 533 manpages=manpages, 534 allow_undefined_symbols=allow_undefined_symbols, 535 allow_warnings=allow_warnings 452 536 ) 453 537 … … 463 547 public_headers=None, 464 548 public_headers_install=True, 549 private_headers=None, 465 550 header_path=None, 466 551 cflags='', 467 552 cflags_end=None, 468 553 group='main', 469 init_function_sentin al=None,554 init_function_sentinel=None, 470 555 autoproto=None, 471 556 autoproto_extra_source='', … … 481 566 subdir=None, 482 567 hide_symbols=False, 483 pyext=False): 568 allow_warnings=False, 569 pyext=False, 570 pyembed=False): 484 571 '''define a Samba subsystem''' 485 572 … … 489 576 490 577 # remember empty subsystems, so we can strip the dependencies 491 if ((source == '') or (source == [])) and deps == '' and public_deps == '': 492 SET_TARGET_TYPE(bld, modname, 'EMPTY') 493 return 578 if ((source == '') or (source == [])): 579 if deps == '' and public_deps == '': 580 SET_TARGET_TYPE(bld, modname, 'EMPTY') 581 return 582 empty_c = modname + '.empty.c' 583 bld.SAMBA_GENERATOR('%s_empty_c' % modname, 584 rule=generate_empty_file, 585 target=empty_c) 586 source=empty_c 494 587 495 588 if not SET_TARGET_TYPE(bld, modname, 'SUBSYSTEM'): … … 505 598 bld.SET_BUILD_GROUP(group) 506 599 507 features = 'c c'600 features = 'c' 508 601 if pyext: 509 602 features += ' pyext' 603 if pyembed: 604 features += ' pyembed' 510 605 511 606 t = bld( … … 513 608 source = source, 514 609 target = modname, 515 samba_cflags = CURRENT_CFLAGS(bld, modname, cflags, hide_symbols=hide_symbols), 610 samba_cflags = CURRENT_CFLAGS(bld, modname, cflags, 611 allow_warnings=allow_warnings, 612 hide_symbols=hide_symbols), 516 613 depends_on = depends_on, 517 614 samba_deps = TO_LIST(deps), … … 522 619 samba_subsystem= subsystem_name, 523 620 samba_use_hostcc = use_hostcc, 524 samba_use_global_deps = use_global_deps 621 samba_use_global_deps = use_global_deps, 525 622 ) 526 623 … … 543 640 public_headers=None, 544 641 public_headers_install=True, 642 private_headers=None, 545 643 header_path=None, 546 644 vars=None, 645 dep_vars=[], 547 646 always=False): 548 647 '''A generic source generator target''' … … 553 652 if not enabled: 554 653 return 654 655 dep_vars.append('ruledeps') 656 dep_vars.append('SAMBA_GENERATOR_VARS') 555 657 556 658 bld.SET_BUILD_GROUP(group) … … 560 662 target=target, 561 663 shell=isinstance(rule, str), 562 on_results=True,664 update_outputs=True, 563 665 before='cc', 564 666 ext_out='.c', 565 667 samba_type='GENERATOR', 566 dep_vars = [rule] + (vars or []),668 dep_vars = dep_vars, 567 669 name=name) 670 671 if vars is None: 672 vars = {} 673 t.env.SAMBA_GENERATOR_VARS = vars 568 674 569 675 if always: … … 578 684 579 685 580 @ runonce686 @Utils.run_once 581 687 def SETUP_BUILD_GROUPS(bld): 582 688 '''setup build groups used to ensure that the different build … … 597 703 bld.add_group('main') 598 704 bld.add_group('symbolcheck') 599 bld.add_group('libraries')600 bld.add_group('binaries')601 705 bld.add_group('syslibcheck') 602 706 bld.add_group('final') … … 629 733 630 734 631 632 t = Task.simple_task_type('copy_script', 'rm -f "${LINK_TARGET}" && ln -s "${SRC[0].abspath(env)}" ${LINK_TARGET}',633 shell=True, color='PINK', ext_in='.bin')634 t.quiet = True635 636 @feature('copy_script')637 @before('apply_link')638 def copy_script(self):639 tsk = self.create_task('copy_script', self.allnodes[0])640 tsk.env.TARGET = self.target641 642 735 def SAMBA_SCRIPT(bld, name, pattern, installdir, installname=None): 643 736 '''used to copy scripts from the source tree into the build directory 644 737 for use by selftest''' 645 738 646 source = bld.path.ant_glob(pattern )739 source = bld.path.ant_glob(pattern, flat=True) 647 740 648 741 bld.SET_BUILD_GROUP('build_source') 649 742 for s in TO_LIST(source): 650 743 iname = s 651 if installname !=None:744 if installname is not None: 652 745 iname = installname 653 746 target = os.path.join(installdir, iname) 654 747 tgtdir = os.path.dirname(os.path.join(bld.srcnode.abspath(bld.env), '..', target)) 655 748 mkdir_p(tgtdir) 656 t = bld(features='copy_script', 657 source = s, 658 target = target, 659 always = True, 660 install_path = None) 661 t.env.LINK_TARGET = target 662 749 link_src = os.path.normpath(os.path.join(bld.curdir, s)) 750 link_dst = os.path.join(tgtdir, os.path.basename(iname)) 751 if os.path.islink(link_dst) and os.readlink(link_dst) == link_src: 752 continue 753 if os.path.exists(link_dst): 754 os.unlink(link_dst) 755 Logs.info("symlink: %s -> %s/%s" % (s, installdir, iname)) 756 os.symlink(link_src, link_dst) 663 757 Build.BuildContext.SAMBA_SCRIPT = SAMBA_SCRIPT 758 664 759 665 760 def copy_and_fix_python_path(task): … … 673 768 sys.path.insert(1, "%s")""" % (task.env["PYTHONARCHDIR"], task.env["PYTHONDIR"]) 674 769 770 if task.env["PYTHON"][0] == "/": 771 replacement_shebang = "#!%s\n" % task.env["PYTHON"] 772 else: 773 replacement_shebang = "#!/usr/bin/env %s\n" % task.env["PYTHON"] 774 675 775 installed_location=task.outputs[0].bldpath(task.env) 676 776 source_file = open(task.inputs[0].srcpath(task.env)) 677 777 installed_file = open(installed_location, 'w') 778 lineno = 0 678 779 for line in source_file: 679 780 newline = line 680 if pattern in line: 781 if (lineno == 0 and task.env["PYTHON_SPECIFIED"] is True and 782 line[:2] == "#!"): 783 newline = replacement_shebang 784 elif pattern in line: 681 785 newline = line.replace(pattern, replacement) 682 786 installed_file.write(newline) 787 lineno = lineno + 1 683 788 installed_file.close() 684 789 os.chmod(installed_location, 0755) 685 790 return 0 686 791 792 def copy_and_fix_perl_path(task): 793 pattern='use lib "$RealBin/lib";' 794 795 replacement = "" 796 if not task.env["PERL_LIB_INSTALL_DIR"] in task.env["PERL_INC"]: 797 replacement = 'use lib "%s";' % task.env["PERL_LIB_INSTALL_DIR"] 798 799 if task.env["PERL"][0] == "/": 800 replacement_shebang = "#!%s\n" % task.env["PERL"] 801 else: 802 replacement_shebang = "#!/usr/bin/env %s\n" % task.env["PERL"] 803 804 installed_location=task.outputs[0].bldpath(task.env) 805 source_file = open(task.inputs[0].srcpath(task.env)) 806 installed_file = open(installed_location, 'w') 807 lineno = 0 808 for line in source_file: 809 newline = line 810 if lineno == 0 and task.env["PERL_SPECIFIED"] == True and line[:2] == "#!": 811 newline = replacement_shebang 812 elif pattern in line: 813 newline = line.replace(pattern, replacement) 814 installed_file.write(newline) 815 lineno = lineno + 1 816 installed_file.close() 817 os.chmod(installed_location, 0755) 818 return 0 819 687 820 688 821 def install_file(bld, destdir, file, chmod=MODE_644, flat=False, 689 python_fixup=False, destname=None, base_name=None): 822 python_fixup=False, perl_fixup=False, 823 destname=None, base_name=None): 690 824 '''install a file''' 691 825 destdir = bld.EXPAND_VARIABLES(destdir) … … 696 830 dest = os.path.join(destdir, destname) 697 831 if python_fixup: 698 # fix up the python path itwill use to find Samba modules832 # fix the path python will use to find Samba modules 699 833 inst_file = file + '.inst' 700 834 bld.SAMBA_GENERATOR('python_%s' % destname, 701 835 rule=copy_and_fix_python_path, 836 dep_vars=["PYTHON","PYTHON_SPECIFIED","PYTHONDIR","PYTHONARCHDIR"], 837 source=file, 838 target=inst_file) 839 file = inst_file 840 if perl_fixup: 841 # fix the path perl will use to find Samba modules 842 inst_file = file + '.inst' 843 bld.SAMBA_GENERATOR('perl_%s' % destname, 844 rule=copy_and_fix_perl_path, 845 dep_vars=["PERL","PERL_SPECIFIED","PERL_LIB_INSTALL_DIR"], 702 846 source=file, 703 847 target=inst_file) … … 709 853 710 854 def INSTALL_FILES(bld, destdir, files, chmod=MODE_644, flat=False, 711 python_fixup=False, destname=None, base_name=None): 855 python_fixup=False, perl_fixup=False, 856 destname=None, base_name=None): 712 857 '''install a set of files''' 713 858 for f in TO_LIST(files): 714 859 install_file(bld, destdir, f, chmod=chmod, flat=flat, 715 python_fixup=python_fixup, destname=destname,716 base_name=base_name)860 python_fixup=python_fixup, perl_fixup=perl_fixup, 861 destname=destname, base_name=base_name) 717 862 Build.BuildContext.INSTALL_FILES = INSTALL_FILES 718 863 … … 721 866 python_fixup=False, exclude=None, trim_path=None): 722 867 '''install a set of files matching a wildcard pattern''' 723 files=TO_LIST(bld.path.ant_glob(pattern ))868 files=TO_LIST(bld.path.ant_glob(pattern, flat=True)) 724 869 if trim_path: 725 870 files2 = [] … … 746 891 747 892 748 def MANPAGES(bld, manpages ):893 def MANPAGES(bld, manpages, install): 749 894 '''build and install manual pages''' 750 895 bld.env.MAN_XSL = 'http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl' … … 755 900 target=m, 756 901 group='final', 757 rule='${XSLTPROC} -o ${TGT} --nonet ${MAN_XSL} ${SRC}' 902 rule='${XSLTPROC} --xinclude -o ${TGT} --nonet ${MAN_XSL} ${SRC}' 903 ) 904 if install: 905 bld.INSTALL_FILES('${MANDIR}/man%s' % m[-1], m, flat=True) 906 Build.BuildContext.MANPAGES = MANPAGES 907 908 def SAMBAMANPAGES(bld, manpages, extra_source=None): 909 '''build and install manual pages''' 910 bld.env.SAMBA_EXPAND_XSL = bld.srcnode.abspath() + '/docs-xml/xslt/expand-sambadoc.xsl' 911 bld.env.SAMBA_MAN_XSL = bld.srcnode.abspath() + '/docs-xml/xslt/man.xsl' 912 bld.env.SAMBA_CATALOG = bld.srcnode.abspath() + '/bin/default/docs-xml/build/catalog.xml' 913 bld.env.SAMBA_CATALOGS = 'file:///etc/xml/catalog file:///usr/local/share/xml/catalog file://' + bld.env.SAMBA_CATALOG 914 915 for m in manpages.split(): 916 source = m + '.xml' 917 if extra_source is not None: 918 source = [source, extra_source] 919 bld.SAMBA_GENERATOR(m, 920 source=source, 921 target=m, 922 group='final', 923 dep_vars=['SAMBA_MAN_XSL', 'SAMBA_EXPAND_XSL', 'SAMBA_CATALOG'], 924 rule='''XML_CATALOG_FILES="${SAMBA_CATALOGS}" 925 export XML_CATALOG_FILES 926 ${XSLTPROC} --xinclude --stringparam noreference 0 -o ${TGT}.xml --nonet ${SAMBA_EXPAND_XSL} ${SRC[0].abspath(env)} 927 ${XSLTPROC} --nonet -o ${TGT} ${SAMBA_MAN_XSL} ${TGT}.xml''' 758 928 ) 759 929 bld.INSTALL_FILES('${MANDIR}/man%s' % m[-1], m, flat=True) 760 Build.BuildContext.MANPAGES = MANPAGES 761 930 Build.BuildContext.SAMBAMANPAGES = SAMBAMANPAGES 762 931 763 932 #############################################################
Note:
See TracChangeset
for help on using the changeset viewer.