packaging: Add support for %run_tests_on_device
[platform/upstream/glibc.git] / packaging / glibc.spec
index bb24a35..0782863 100644 (file)
 %define glibc_run_tests 1
 %endif
 
+# Enable this when testing on device to:
+# 1. Enable macro to turn on testsuite building ('glibc_run_tests 1')
+# 2. Keep 'build-dir/' folder in build stage as we do not want to rebuild all
+# glibc again on device after invoking rpmbuild --short-circuit -bc ...
+# 3. Skip configure and make commands and go directly to 'make check'
+%if 0%{?run_tests_on_device}
+%define glibc_run_tests 1
+%define glibc_keep_build_dir 1
+%define glibc_skip_configure 1
+%define glibc_skip_make 1
+%endif
+
+# Exit right after 'make ..' step to keep all object files produced by glibc build
+%if 0%{?exit_on_make_finish}
+%define glibc_exit_on_make_finish 1
+%endif
+
 %if 0%{?dump_configure}
 %define glibc_dump_configure 1
 %endif
@@ -326,6 +343,9 @@ configure_and_build_glibc() {
        local dirname="$1"; shift
        local cflags="$1"; shift
        local addons="$1"; shift
+       %{!?glibc_keep_build_dir:
+         rm -rf "cc-$dirname"
+        }
        mkdir "cc-$dirname"
        cd "cc-$dirname"
        conf_cflags="$cflags -funwind-tables -fPIC"
@@ -337,6 +357,7 @@ configure_and_build_glibc() {
            profile="--enable-profile"
        fi
 %endif
+%{!?glibc_skip_configure:
        CFLAGS="$conf_cflags" BUILD_CFLAGS="$conf_cflags" \
         CC="$BuildCC" CXX="$BuildCCplus"  ../configure \
                --prefix=%{_prefix} \
@@ -359,15 +380,20 @@ configure_and_build_glibc() {
                --disable-nscd \
                --disable-experimental-malloc \
                libc_cv_cc_pie_default=yes
-       # explicitly set CFLAGS to use the full CFLAGS (not the reduced one for configure)
-       make %{?_smp_mflags} #CFLAGS="$cflags" BUILD_CFLAGS="$cflags"
+ }
+%{!?glibc_skip_make:
+       make %{?_smp_mflags}
        %{?glibc_dump_configure:
          dump_configure.pl .. . \
                            --project glibc \
                            --project-version %{version} \
                            --out_db glibc-%{version}-%{release}-%_project-%_repository.db
         }
+       %{?glibc_exit_on_make_finish:
+         exit 1
+        }
        cd ..
+ }
 }
 
 configure_flags="--prefix=/usr --without-cvs --without-selinux --enable-stackguard-randomization --enable-obsolete-rpc --disable-mathvec"