/[gentoo-x86]/eclass/cmake-utils.eclass
Gentoo

Diff of /eclass/cmake-utils.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.99 Revision 1.103
1# Copyright 1999-2013 Gentoo Foundation 1# Copyright 1999-2014 Gentoo Foundation
2# Distributed under the terms of the GNU General Public License v2 2# Distributed under the terms of the GNU General Public License v2
3# $Header: /var/cvsroot/gentoo-x86/eclass/cmake-utils.eclass,v 1.99 2013/07/14 12:50:16 hasufell Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/cmake-utils.eclass,v 1.103 2014/02/08 01:42:44 vapier Exp $
4 4
5# @ECLASS: cmake-utils.eclass 5# @ECLASS: cmake-utils.eclass
6# @MAINTAINER: 6# @MAINTAINER:
7# kde@gentoo.org 7# kde@gentoo.org
8# @AUTHOR: 8# @AUTHOR:
325# 325#
326# `cmake-utils_use foo FOO` echoes -DFOO=ON if foo is enabled 326# `cmake-utils_use foo FOO` echoes -DFOO=ON if foo is enabled
327# and -DFOO=OFF if it is disabled. 327# and -DFOO=OFF if it is disabled.
328cmake-utils_use() { _use_me_now "" "$@" ; } 328cmake-utils_use() { _use_me_now "" "$@" ; }
329 329
330# @FUNCTION: cmake-utils_useno
331# @USAGE: <USE flag> [flag name]
332# @DESCRIPTION:
333# Based on use_enable. See ebuild(5).
334#
335# `cmake-utils_useno foo NOFOO` echoes -DNOFOO=OFF if foo is enabled
336# and -DNOFOO=ON if it is disabled.
337cmake-utils_useno() { _use_me_now_inverted "" "$@" ; }
338
330# Internal function for modifying hardcoded definitions. 339# Internal function for modifying hardcoded definitions.
331# Removes dangerous definitions that override Gentoo settings. 340# Removes dangerous definitions that override Gentoo settings.
332_modify-cmakelists() { 341_modify-cmakelists() {
333 debug-print-function ${FUNCNAME} "$@" 342 debug-print-function ${FUNCNAME} "$@"
334 343
361} 370}
362 371
363enable_cmake-utils_src_prepare() { 372enable_cmake-utils_src_prepare() {
364 debug-print-function ${FUNCNAME} "$@" 373 debug-print-function ${FUNCNAME} "$@"
365 374
366 debug-print "$FUNCNAME: PATCHES=$PATCHES" 375 debug-print "$FUNCNAME: PATCHES=$PATCHES"
367 376
368 pushd "${S}" > /dev/null 377 pushd "${S}" >/dev/null
369 [[ ${PATCHES[@]} ]] && epatch "${PATCHES[@]}" 378 [[ ${PATCHES[@]} ]] && epatch "${PATCHES[@]}"
370 379
371 debug-print "$FUNCNAME: applying user patches" 380 debug-print "$FUNCNAME: applying user patches"
372 epatch_user 381 epatch_user
373 382
374 popd > /dev/null 383 popd >/dev/null
375
376} 384}
377 385
378# @VARIABLE: mycmakeargs 386# @VARIABLE: mycmakeargs
379# @DEFAULT_UNSET 387# @DEFAULT_UNSET
380# @DESCRIPTION: 388# @DESCRIPTION:
498 -DCMAKE_INSTALL_DO_STRIP=OFF 506 -DCMAKE_INSTALL_DO_STRIP=OFF
499 -DCMAKE_USER_MAKE_RULES_OVERRIDE="${build_rules}" 507 -DCMAKE_USER_MAKE_RULES_OVERRIDE="${build_rules}"
500 "${MYCMAKEARGS}" 508 "${MYCMAKEARGS}"
501 ) 509 )
502 510
503 pushd "${BUILD_DIR}" > /dev/null 511 pushd "${BUILD_DIR}" >/dev/null
504 debug-print "${LINENO} ${ECLASS} ${FUNCNAME}: mycmakeargs is ${mycmakeargs_local[*]}" 512 debug-print "${LINENO} ${ECLASS} ${FUNCNAME}: mycmakeargs is ${mycmakeargs_local[*]}"
505 echo "${CMAKE_BINARY}" "${cmakeargs[@]}" "${CMAKE_USE_DIR}" 513 echo "${CMAKE_BINARY}" "${cmakeargs[@]}" "${CMAKE_USE_DIR}"
506 "${CMAKE_BINARY}" "${cmakeargs[@]}" "${CMAKE_USE_DIR}" || die "cmake failed" 514 "${CMAKE_BINARY}" "${cmakeargs[@]}" "${CMAKE_USE_DIR}" || die "cmake failed"
507 popd > /dev/null 515 popd >/dev/null
508} 516}
509 517
510enable_cmake-utils_src_compile() { 518enable_cmake-utils_src_compile() {
511 debug-print-function ${FUNCNAME} "$@" 519 debug-print-function ${FUNCNAME} "$@"
512 520
513 has src_configure ${CMAKE_EXPF} || cmake-utils_src_configure 521 has src_configure ${CMAKE_EXPF} || cmake-utils_src_configure
514 cmake-utils_src_make "$@" 522 cmake-utils_src_make "$@"
515} 523}
516 524
525_ninjaopts_from_makeopts() {
526 if [[ ${NINJAOPTS+set} == set ]]; then
527 return 0
528 fi
529 local ninjaopts=()
530 set -- ${MAKEOPTS}
531 while (( $# )); do
532 case $1 in
533 -j|-l|-k)
534 ninjaopts+=( $1 $2 )
535 shift 2
536 ;;
537 -j*|-l*|-k*)
538 ninjaopts+=( $1 )
539 shift 1
540 ;;
541 *) shift ;;
542 esac
543 done
544 export NINJAOPTS="${ninjaopts[*]}"
545}
546
517# @FUNCTION: ninja_src_make 547# @FUNCTION: ninja_src_make
518# @INTERNAL 548# @INTERNAL
519# @DESCRIPTION: 549# @DESCRIPTION:
520# Build the package using ninja generator 550# Build the package using ninja generator
521ninja_src_make() { 551ninja_src_make() {
522 debug-print-function ${FUNCNAME} "$@" 552 debug-print-function ${FUNCNAME} "$@"
523 553
524 [[ -e build.ninja ]] || die "Makefile not found. Error during configure stage." 554 [[ -e build.ninja ]] || die "build.ninja not found. Error during configure stage."
525 555
556 _ninjaopts_from_makeopts
557
526 if [[ "${CMAKE_VERBOSE}" != "OFF" ]]; then 558 if [[ "${CMAKE_VERBOSE}" != "OFF" ]]; then
527 # TODO: get load average from portage (-l option) 559 set -- ninja ${NINJAOPTS} -v "$@"
528 ninja ${MAKEOPTS} -v "$@" || die
529 else 560 else
561 set -- ninja ${NINJAOPTS} "$@"
562 fi
563
564 echo "$@"
530 ninja "$@" || die 565 "$@" || die
531 fi
532} 566}
533 567
534# @FUNCTION: make_src_make 568# @FUNCTION: emake_src_make
535# @INTERNAL 569# @INTERNAL
536# @DESCRIPTION: 570# @DESCRIPTION:
537# Build the package using make generator 571# Build the package using make generator
538emake_src_make() { 572emake_src_make() {
539 debug-print-function ${FUNCNAME} "$@" 573 debug-print-function ${FUNCNAME} "$@"
540 574
541 [[ -e Makefile ]] || die "Makefile not found. Error during configure stage." 575 [[ -e Makefile ]] || die "Makefile not found. Error during configure stage."
542 576
543 if [[ "${CMAKE_VERBOSE}" != "OFF" ]]; then 577 if [[ "${CMAKE_VERBOSE}" != "OFF" ]]; then
544 emake VERBOSE=1 "$@" || die 578 emake VERBOSE=1 "$@" || die
545 else 579 else
546 emake "$@" || die 580 emake "$@" || die
547 fi 581 fi
548 582
549} 583}
550 584
554# All arguments are passed to emake. 588# All arguments are passed to emake.
555cmake-utils_src_make() { 589cmake-utils_src_make() {
556 debug-print-function ${FUNCNAME} "$@" 590 debug-print-function ${FUNCNAME} "$@"
557 591
558 _check_build_dir 592 _check_build_dir
559 pushd "${BUILD_DIR}" > /dev/null 593 pushd "${BUILD_DIR}" >/dev/null
560 594
561 ${CMAKE_MAKEFILE_GENERATOR}_src_make $@ 595 ${CMAKE_MAKEFILE_GENERATOR}_src_make $@
562 596
563 popd > /dev/null 597 popd >/dev/null
564} 598}
565 599
566enable_cmake-utils_src_install() { 600enable_cmake-utils_src_install() {
567 debug-print-function ${FUNCNAME} "$@" 601 debug-print-function ${FUNCNAME} "$@"
568 602
569 _check_build_dir 603 _check_build_dir
570 pushd "${BUILD_DIR}" > /dev/null 604 pushd "${BUILD_DIR}" >/dev/null
571 DESTDIR="${D}" ${CMAKE_MAKEFILE_GENERATOR} install "$@" || die "died running ${CMAKE_MAKEFILE_GENERATOR} install" 605 DESTDIR="${D}" ${CMAKE_MAKEFILE_GENERATOR} install "$@" || die "died running ${CMAKE_MAKEFILE_GENERATOR} install"
572 popd > /dev/null 606 popd >/dev/null
573 607
574 pushd "${S}" > /dev/null 608 pushd "${S}" >/dev/null
575 #Install docs, copied from base_src_install_docs 609 # Install docs, copied from base_src_install_docs
576 local x 610 local x
577 611
578 if [[ "$(declare -p DOCS 2>/dev/null 2>&1)" == "declare -a"* ]]; then 612 if [[ "$(declare -p DOCS 2>/dev/null 2>&1)" == "declare -a"* ]]; then
579 for x in "${DOCS[@]}"; do 613 for x in "${DOCS[@]}"; do
580 debug-print "$FUNCNAME: docs: creating document from ${x}" 614 debug-print "$FUNCNAME: docs: creating document from ${x}"
581 dodoc "${x}" || die "dodoc failed" 615 dodoc "${x}" || die "dodoc failed"
582 done 616 done
583 fi 617 fi
584 if [[ "$(declare -p HTML_DOCS 2>/dev/null 2>&1)" == "declare -a"* ]]; then 618 if [[ "$(declare -p HTML_DOCS 2>/dev/null 2>&1)" == "declare -a"* ]]; then
585 for x in "${HTML_DOCS[@]}"; do 619 for x in "${HTML_DOCS[@]}"; do
586 debug-print "$FUNCNAME: docs: creating html document from ${x}" 620 debug-print "$FUNCNAME: docs: creating html document from ${x}"
587 dohtml -r "${x}" || die "dohtml failed" 621 dohtml -r "${x}" || die "dohtml failed"
588 done 622 done
589 fi 623 fi
590 624
591 # Backward compatibility, for non-array variables 625 # Backward compatibility, for non-array variables
592 if [[ -n "${DOCS}" ]] && [[ "$(declare -p DOCS 2>/dev/null 2>&1)" != "declare -a"* ]]; then 626 if [[ -n "${DOCS}" ]] && [[ "$(declare -p DOCS 2>/dev/null 2>&1)" != "declare -a"* ]]; then
593 dodoc ${DOCS} || die "dodoc failed" 627 dodoc ${DOCS} || die "dodoc failed"
594 fi 628 fi
595 if [[ -n "${HTML_DOCS}" ]] && [[ "$(declare -p HTML_DOCS 2>/dev/null 2>&1)" != "declare -a"* ]]; then 629 if [[ -n "${HTML_DOCS}" ]] && [[ "$(declare -p HTML_DOCS 2>/dev/null 2>&1)" != "declare -a"* ]]; then
596 dohtml -r ${HTML_DOCS} || die "dohtml failed" 630 dohtml -r ${HTML_DOCS} || die "dohtml failed"
597 fi 631 fi
598 632
599 popd > /dev/null 633 popd >/dev/null
600} 634}
601 635
602enable_cmake-utils_src_test() { 636enable_cmake-utils_src_test() {
603 debug-print-function ${FUNCNAME} "$@" 637 debug-print-function ${FUNCNAME} "$@"
604 638
605 _check_build_dir 639 _check_build_dir
606 pushd "${BUILD_DIR}" > /dev/null 640 pushd "${BUILD_DIR}" >/dev/null
607 [[ -e CTestTestfile.cmake ]] || { echo "No tests found. Skipping."; return 0 ; } 641 [[ -e CTestTestfile.cmake ]] || { echo "No tests found. Skipping."; return 0 ; }
608 642
609 [[ -n ${TEST_VERBOSE} ]] && myctestargs+=( --extra-verbose --output-on-failure ) 643 [[ -n ${TEST_VERBOSE} ]] && myctestargs+=( --extra-verbose --output-on-failure )
610 644
611 if ctest "${myctestargs[@]}" "$@" ; then 645 if ctest "${myctestargs[@]}" "$@" ; then
612 einfo "Tests succeeded." 646 einfo "Tests succeeded."
613 popd > /dev/null 647 popd >/dev/null
614 return 0 648 return 0
615 else 649 else
616 if [[ -n "${CMAKE_YES_I_WANT_TO_SEE_THE_TEST_LOG}" ]] ; then 650 if [[ -n "${CMAKE_YES_I_WANT_TO_SEE_THE_TEST_LOG}" ]] ; then
617 # on request from Diego 651 # on request from Diego
618 eerror "Tests failed. Test log ${BUILD_DIR}/Testing/Temporary/LastTest.log follows:" 652 eerror "Tests failed. Test log ${BUILD_DIR}/Testing/Temporary/LastTest.log follows:"
623 else 657 else
624 die "Tests failed. When you file a bug, please attach the following file: \n\t${BUILD_DIR}/Testing/Temporary/LastTest.log" 658 die "Tests failed. When you file a bug, please attach the following file: \n\t${BUILD_DIR}/Testing/Temporary/LastTest.log"
625 fi 659 fi
626 660
627 # die might not die due to nonfatal 661 # die might not die due to nonfatal
628 popd > /dev/null 662 popd >/dev/null
629 return 1 663 return 1
630 fi 664 fi
631} 665}
632 666
633# @FUNCTION: cmake-utils_src_prepare 667# @FUNCTION: cmake-utils_src_prepare

Legend:
Removed from v.1.99  
changed lines
  Added in v.1.103

  ViewVC Help
Powered by ViewVC 1.1.20