Introduce 'chromium-efl-libs.spec'.
authorAntonio Gomes <a1.gomes@samsung.com>
Tue, 16 Jun 2015 22:35:50 +0000 (15:35 -0700)
committerYoungsoo Choi <kenshin.choi@samsung.com>
Tue, 10 Jul 2018 06:57:09 +0000 (06:57 +0000)
Goal of the patch is:
build and pack all chromium targets that both 'xwalk'
and 'chromium-ewk' targets depends on, using a component build.
Note that any target define in xwalk/ or tizen_src/ewk/
directories are excluded.
As result, chromium-efl-libs.rpm will contain all .so files
that xwalk and chromium-ewk targets requires to get build.

In a follow up patch, a crosswalk-bin.spec will be
introduced, and it will depend on chromium-efl-libs.rpm.
crosswalk-bin will build all xwalk targets, but not the chromium
targets already built by chromium-efl-libs.
This will speed up xwalk development cycle.

* packaging/chromium-efl-libs.spec: fork of the xwalk's crosswalk-libs.spec.
  Difference from the original: It adds some dependencies needed by
  chromium-efl sources; it also, calls gyp_chromiumefl.sh instead of
  directly calling gyp_xwalk.

* packaging/print-chromium-deps.py: fork of the xwalk version.
  Difference from the original: it changes the if condition that
  filter out xwalki and chromium-ewk targets from the final output.
  Script processes dump.json, which is the output of GYP when
  "dump_dependency_json" is set to GYP_GENERATORS.
  It prints out a list of targets to be built.

* packaging/chromium-efl-libs.manifest: copy from xwalk.

The change in system.gyp is needed because on component
builds, target that 'base' depends on directly need to
have a toolsets definition. see [1] for reference.

[1] http://codereview.chromium.org/7904034

How to use use:
$ tizen_src/build/build_mobile.sh --libs

Bug: http://107.108.218.239/bugzilla/show_bug.cgi?id=13316
Reviewed by: Hyunhak Kim, arno renevier

Change-Id: I3268bc7aaff5bfa3ffda24c41da048654dbec75e
Signed-off-by: Antonio Gomes <a1.gomes@samsung.com>
tizen_src/build/common.sh
tizen_src/build/system.gyp
tizen_src/packaging/chromium-efl-libs.manifest [new file with mode: 0644]
tizen_src/packaging/chromium-efl-libs.spec [new file with mode: 0644]
tizen_src/packaging/print-chromium-deps.py [new file with mode: 0755]

index 758e92c..991c236 100755 (executable)
@@ -171,6 +171,7 @@ function setupAndExecuteTargetBuild() {
   local PROFILE
   local ARCHITECTURE
   local CONF_FLAG
+  local SPEC_FILE="chromium-efl.spec"
   local -a ARGS
 
   # "|| :" means "or always succeeding built-in command"
@@ -251,6 +252,9 @@ function setupAndExecuteTargetBuild() {
         count=$(( $count + 1 ))
         ARGS[$count]="component_build 1"
     ;;
+    --libs)
+        target="libs"
+    ;;
     --gbs-debug)
         ARGS[$count]=--debug
     ;;
@@ -265,7 +269,11 @@ function setupAndExecuteTargetBuild() {
   rm -f packaging
   ln -sf tizen_src/packaging packaging
 
-  gbs $CONF_FLAG build -P $PROFILE --include-all -A $ARCHITECTURE --incremental "${ARGS[@]}" $BUILD_CONF_OPTS $EXTRA_PACK_OPTS
+  if [ "$target" == "libs" ]; then
+    SPEC_FILE="chromium-efl-libs.spec"
+  fi
+
+  gbs $CONF_FLAG build -P $PROFILE --spec $SPEC_FILE --include-all -A $ARCHITECTURE --incremental "${ARGS[@]}" $BUILD_CONF_OPTS $EXTRA_PACK_OPTS
 }
 
 function prepareTizen3Build() {
index fd9a878..0318d91 100644 (file)
@@ -27,6 +27,7 @@
     {
       'target_name': 'ecore',
       'type': 'none',
+      'toolsets': ['host', 'target'],
       'direct_dependent_settings': {
         'cflags': [
           '<!@(<(pkg-config) --cflags ecore)',
diff --git a/tizen_src/packaging/chromium-efl-libs.manifest b/tizen_src/packaging/chromium-efl-libs.manifest
new file mode 100644 (file)
index 0000000..017d22d
--- /dev/null
@@ -0,0 +1,5 @@
+<manifest>
+ <request>
+    <domain name="_"/>
+ </request>
+</manifest>
diff --git a/tizen_src/packaging/chromium-efl-libs.spec b/tizen_src/packaging/chromium-efl-libs.spec
new file mode 100644 (file)
index 0000000..2755dd3
--- /dev/null
@@ -0,0 +1,290 @@
+# adjust compression algorithm to speed up RPMS creation
+# source RPM and debug RPMS are big and take too much time
+# when using standard (lzma) compression
+%define _source_payload w3.gzdio
+%define _binary_payload w3.gzdio
+
+Name:           chromium-efl-libs
+%define         ChromiumVersion 42.2311.0
+%define         Week 11
+Version:        %{ChromiumVersion}.%{Week}
+Release:        1
+Summary:        Chromium-based app runtime, private libraries
+# The 'Group' should be specified as one of the following valid group list.
+# https://wiki.tizen.org/wiki/Packaging/Guidelines#Group_Tag
+Group:          Web Framework/Web Engine
+# The 'License' should be specified as some of the following known license list.
+# http://spdx.org/licenses/
+License:        LGPL-2.1 or BSD-2-Clause
+Source:         %{name}-%{version}.tar.gz
+Source1002:     print-chromium-deps.py
+
+%if 0%{?nodebug}
+%global __debug_install_post %{nil}
+%global debug_package %{nil}
+%endif
+
+BuildRequires:  binutils-gold
+BuildRequires:  bison
+BuildRequires:  bzip2-devel
+BuildRequires:  elfutils
+BuildRequires:  expat-devel
+BuildRequires:  flex
+BuildRequires:  gperf
+BuildRequires:  libcap-devel
+BuildRequires:  libelf-devel
+BuildRequires:  ninja
+BuildRequires:  python
+BuildRequires:  python-xml
+BuildRequires:  perl
+BuildRequires:  which
+BuildRequires:  yasm
+BuildRequires:  pkgconfig(alsa)
+BuildRequires:  pkgconfig(dbus-1)
+BuildRequires:  pkgconfig(fontconfig)
+BuildRequires:  pkgconfig(freetype2)
+BuildRequires:  pkgconfig(gles20)
+BuildRequires:  pkgconfig(glib-2.0)
+BuildRequires:  pkgconfig(icu-i18n)
+BuildRequires:  pkgconfig(libdrm)
+BuildRequires:  pkgconfig(libexif)
+BuildRequires:  pkgconfig(libpci)
+BuildRequires:  pkgconfig(libpulse)
+BuildRequires:  pkgconfig(libudev)
+BuildRequires:  pkgconfig(libxml-2.0)
+BuildRequires:  pkgconfig(libxslt)
+BuildRequires:  pkgconfig(protobuf)
+BuildRequires:  pkgconfig(nss)
+
+# chromium-efl/chromium_src dependencies.
+BuildRequires:  pkgconfig(appcore-efl)
+BuildRequires:  pkgconfig(capi-appfw-application)
+BuildRequires:  pkgconfig(capi-location-manager)
+BuildRequires:  pkgconfig(capi-media-audio-io)
+BuildRequires:  pkgconfig(capi-media-camera)
+BuildRequires:  pkgconfig(capi-media-player)
+BuildRequires:  pkgconfig(capi-media-tool)
+BuildRequires:  pkgconfig(capi-system-sensor)
+BuildRequires:  pkgconfig(capi-network-connection)
+BuildRequires:  pkgconfig(capi-system-device)
+BuildRequires:  pkgconfig(capi-system-system-settings)
+BuildRequires:  pkgconfig(ecore)
+BuildRequires:  pkgconfig(ecore-evas)
+BuildRequires:  pkgconfig(ecore-imf)
+BuildRequires:  pkgconfig(ecore-imf-evas)
+BuildRequires:  pkgconfig(ecore-input)
+BuildRequires:  pkgconfig(efl-assist)
+BuildRequires:  pkgconfig(elementary)
+BuildRequires:  pkgconfig(evas)
+BuildRequires:  pkgconfig(feedback)
+BuildRequires:  pkgconfig(glib-2.0)
+BuildRequires:  pkgconfig(gstreamer-1.0)
+BuildRequires:  pkgconfig(gstreamer-plugins-base-1.0)
+BuildRequires:  pkgconfig(gstreamer-app-1.0)
+BuildRequires:  pkgconfig(harfbuzz)
+BuildRequires:  pkgconfig(libtbm)
+BuildRequires:  pkgconfig(minizip)
+BuildRequires:  pkgconfig(nspr)
+BuildRequires:  pkgconfig(openssl)
+BuildRequires:  pkgconfig(scim)
+BuildRequires:  pkgconfig(tts)
+BuildRequires:  pkgconfig(vconf)
+# TODO(a1.gomes): these dependencies seem wrong.
+BuildRequires:  pkgconfig(capi-system-info)
+BuildRequires:  pkgconfig(flac)
+BuildRequires:  pkgconfig(ui-gadget-1)
+BuildRequires:  pkgconfig(speex)
+
+%if "%{?_with_wayland}" == "1"
+BuildRequires:  pkgconfig(wayland-client)
+BuildRequires:  pkgconfig(wayland-cursor)
+BuildRequires:  pkgconfig(wayland-egl)
+%endif
+
+%description
+This package contains private Chromium shared libraries required by Chromium-EWK and Crosswalk apps to run.
+
+%prep
+%setup -q
+
+%build
+
+# Stop unconditionally passing -Wall to the compiler. Chromium has its own
+# mechanisms for deciding which parts of the code need -Wall and which need it
+# to be left out (since several pieces are built with -Werror). At least in
+# M39, this is preventing the "rtc_base" target from being built because it
+# does not expect -Wall to be passed to the compiler (see webrtc issue 3307).
+export CXXFLAGS=`echo $CXXFLAGS | sed s,-Wall,,g`
+
+# Do not use -finline-functions: it breaks the build because it causes -Wall to
+# warn about some conditions that cannot really be reached (ie. variables that
+# may be used uninitialized while in fact thay cannot be uninitialized). See
+# TC-2299.
+export CXXFLAGS=`echo $CXXFLAGS | sed s,-finline-functions,,g`
+
+# For ffmpeg on ia32. The original CFLAGS set by the gyp and config files in
+# src/third_party/ffmpeg already pass -O2 -fomit-frame-pointer, but Tizen's
+# CFLAGS end up appending -fno-omit-frame-pointer. See http://crbug.com/37246
+export CFLAGS=`echo $CFLAGS | sed s,-fno-omit-frame-pointer,,g`
+
+# Building the RPM in the GBS chroot fails with errors such as
+#   /usr/lib/gcc/i586-tizen-linux/4.7/../../../../i586-tizen-linux/bin/ld:
+#       failed to set dynamic section sizes: Memory exhausted
+# For now, work around it by passing a GNU ld-specific flag that optimizes the
+# linker for memory usage.
+export LDFLAGS="${LDFLAGS} -Wl,--no-keep-memory"
+
+# Support building in a non-standard directory, possibly outside %{_builddir}.
+# Since the build root is erased every time a new build is performed, one way
+# to avoid losing the build directory is to specify a location outside the
+# build root to the BUILDDIR_NAME definition, such as "/var/tmp/xwalk-build"
+# (remember all paths are still inside the chroot):
+#    gbs build --define 'BUILDDIR_NAME /some/path'
+BUILDDIR_NAME="%{?BUILDDIR_NAME}"
+if [ -n "${BUILDDIR_NAME}" ]; then
+   mkdir -p "${BUILDDIR_NAME}"
+   ln -s "${BUILDDIR_NAME}" "%{OUTPUT_FOLDER}"
+fi
+
+# For building for arm in OBS, we need :
+# -> to unset sysroot value.
+# sysroot variable is automatically set for cross compilation to use arm-sysroot provided by Chromium project
+# sysroot usage is not needed, we need to use arm libraries from the virtualized environment.
+#
+# Crosswalk build fails if the fpu selected in the gcc option is different from neon in case of arm7 compilation
+# So force it.
+%ifarch %{arm}
+export CFLAGS=`echo $CFLAGS | sed s,-mfpu=vfpv3,-mfpu=neon,g`
+export CXXFLAGS=`echo $CXXFLAGS | sed s,-mfpu=vfpv3,-mfpu=neon,g`
+export FFLAGS=`echo $FFLAGS | sed s,-mfpu=vfpv3,-mfpu=neon,g`
+%endif
+
+###### start of block copied/adapted from chromium-efl.spec
+trap 'tizen_src/build/apply_patches.sh -r;\
+      error_report $0 $LINENO' ERR SIGINT SIGTERM SIGQUIT
+
+tizen_src/build/apply_patches.sh
+
+%if "%{tizen}" == "3.0"
+%define chromium_efl_tizen_version 3.0
+%endif
+%if "%{tizen}" == "2.3" || "%{tizen}" == "2.4"
+%define chromium_efl_tizen_version 2.4
+%endif
+%if "%{tizen}" == "2.0"
+%define chromium_efl_tizen_version 2.3
+%endif
+%if "%{tizen}" == "2.2.1"
+%define chromium_efl_tizen_version 2.2.1
+%endif
+
+%if %{!?TIZEN_PROFILE_TV:0}%{?TIZEN_PROFILE_TV:1} || "%{!?profile:0}%{?profile}" == "tv"
+%define chromium_efl_tizen_profile tv
+%else
+%define chromium_efl_tizen_profile mobile
+%endif
+
+%if 0%{?nodebug}
+  CFLAGS=$(echo $CFLAGS | sed 's/-g[0-9]*/ /g')
+  CXXFLAGS=$(echo $CXXFLAGS | sed 's/-g[0-9]*/ /g')
+%endif
+
+%if "%{!?chromium_efl_tizen_profile:0}%{?chromium_efl_tizen_profile}" == "mobile"
+  %define OUTPUT_BUILD_PROFILE_TARGET mobile
+%else
+  %define OUTPUT_BUILD_PROFILE_TARGET tv
+%endif
+
+# The variable chromium-efl_tizen_version and _repository are essentially needed for build.
+# Therefore, if the variable is not defined, it explicitly raises exception here.
+%define OUTPUT_BASE_FOLDER out.tz_v%{chromium_efl_tizen_version}.%{OUTPUT_BUILD_PROFILE_TARGET}.%{_repository}.libs
+export GYP_GENERATOR_OUTPUT=$PWD/%{OUTPUT_BASE_FOLDER}
+
+#set build mode
+%if 0%{?_debug_mode}
+  %global OUTPUT_FOLDER %{OUTPUT_BASE_FOLDER}/Debug
+%else
+  %global OUTPUT_FOLDER %{OUTPUT_BASE_FOLDER}/Release
+%endif
+
+export GYP_GENERATORS="dump_dependency_json,ninja"
+
+%if %{?_skip_gyp:0}%{!?_skip_gyp:1}
+./tizen_src/build/gyp_chromiumefl.sh \
+  --xwalk \
+  -Dbuilding_crosswalk_bin=0 \
+  -Dcomponent=shared_library \
+%if 0%{?_remove_webcore_debug_symbols:1}
+  -Dremove_webcore_debug_symbols=1 \
+%endif
+%if 0%{?chromium_efl_tizen_version:1}
+  -Dchromium_efl_tizen_version=%{chromium_efl_tizen_version} \
+%endif
+%if "%{?_with_wayland}" == "1"
+  -Duse_wayland=1 \
+%endif
+%if "%{?_repository}" == "emulator" || "%{?_repository}" == "emulator32-x11"
+  -Dtizen_emulator_support=1  \
+%endif
+  -Dtizen_"%{OUTPUT_BUILD_PROFILE_TARGET}"=1 \
+  -Dbuilding_for_tizen_"%{OUTPUT_BUILD_PROFILE_TARGET}"=1
+%endif
+
+%if %{?_skip_ninja:0}%{!?_skip_ninja:1}
+# We are not interested in building ${NINJA_TARGETS} themselves, since that is
+# what crosswalk-bin.spec does. We want the Chromium dependencies that those
+# targets need to build all the shared libraries we have to package.
+NINJA_TARGETS="chromium-ewk xwalk xwalk_application_tools"
+DEPENDENCIES=`python %{SOURCE1002} dump.json ${NINJA_TARGETS}`
+
+%ifarch %{arm}
+tizen_src/build/prebuild/ninja.arm %{_smp_mflags} -C"%{OUTPUT_FOLDER}" \
+%else
+%ifarch aarch64
+tizen_src/build/prebuild/ninja-linux64 -v %{_smp_mflags} -C"%{OUTPUT_FOLDER}" \
+%else
+tizen_src/build/prebuild/ninja %{_smp_mflags} -C"%{OUTPUT_FOLDER}" \
+%endif
+%endif
+   ${DEPENDENCIES}
+%endif
+
+#XXX icudtl.dat is not copied by gyp. Do that manually
+cp third_party/icu/android/icudtl.dat "%{OUTPUT_FOLDER}"
+
+tizen_src/build/apply_patches.sh -r
+
+###### end of block copied/adapted from chromium-efl.spec
+
+# In '%files' section below there are added all built libraries, which satisfy
+# pattern: 'xwalk/lib/lib*.so'. During build crosswalk-bin.spec generates new
+# library - libxwalk_backend_lib.so, which should not be packaged into
+# crosswalk-libs, but then after incremental build it will also satisfy
+# pattern, which was mentioned above.
+rm -f "%{OUTPUT_FOLDER}"/lib/libxwalk_backend_lib.so
+
+%define         INSTALL_FOLDER chromium-efl-libs
+
+%install
+# Supporting libraries and resources.
+install -d %{buildroot}%{_libdir}/%{INSTALL_FOLDER}/lib
+install -m 0644 -p -D "%{OUTPUT_FOLDER}"/lib/*.so %{buildroot}%{_libdir}/%{INSTALL_FOLDER}/lib/
+install -m 0644 -p -D "%{OUTPUT_FOLDER}"/icudtl.dat %{buildroot}%{_libdir}/%{INSTALL_FOLDER}/icudtl.dat
+install -m 0644 -p -D "%{OUTPUT_FOLDER}"/libffmpegsumo.so %{buildroot}%{_libdir}/%{INSTALL_FOLDER}/libffmpegsumo.so
+install -m 0644 -p -D "%{OUTPUT_FOLDER}"/natives_blob.bin %{buildroot}%{_libdir}/%{INSTALL_FOLDER}/natives_blob.bin
+install -m 0644 -p -D "%{OUTPUT_FOLDER}"/snapshot_blob.bin %{buildroot}%{_libdir}/%{INSTALL_FOLDER}/snapshot_blob.bin
+
+%files
+%manifest packaging/chromium-efl-libs.manifest
+%{_libdir}/%{INSTALL_FOLDER}/icudtl.dat
+%{_libdir}/%{INSTALL_FOLDER}/lib/lib*.so
+%{_libdir}/%{INSTALL_FOLDER}/libffmpegsumo.so
+%if %{?_disable_nacl}%{!?_disable_nacl:1} == 0
+%{_libdir}/%{INSTALL_FOLDER}/nacl_bootstrap_raw
+%{_libdir}/%{INSTALL_FOLDER}/nacl_helper
+%{_libdir}/%{INSTALL_FOLDER}/nacl_helper_bootstrap
+%{_libdir}/%{INSTALL_FOLDER}/nacl_irt_*.nexe
+%{_libdir}/%{INSTALL_FOLDER}/pnacl/*
+%endif
+%{_libdir}/%{INSTALL_FOLDER}/natives_blob.bin
+%{_libdir}/%{INSTALL_FOLDER}/snapshot_blob.bin
diff --git a/tizen_src/packaging/print-chromium-deps.py b/tizen_src/packaging/print-chromium-deps.py
new file mode 100755 (executable)
index 0000000..3f945bc
--- /dev/null
@@ -0,0 +1,84 @@
+#!/usr/bin/env python
+
+# Copyright (c) 2014 Intel Corporation. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""
+Parses a gyp JSON dependency dict generated by gyp's dump_dependency_json
+generator and prints the Chromium targets (ie. the ones not in gyp files in
+src/xwalk) required for building the ones passed on the command-line.
+
+The output can then be passed, for example, to ninja.
+"""
+
+import copy
+import json
+import os
+import sys
+
+
+def ParseDependency(dep):
+  """
+  Given a dependency like '/path/to/foo.gyp:somedep#target', returns a tuple
+  ('/path/to/foo.gyp', 'somedep').
+  """
+  path = dep[:dep.find(':')]
+  name = dep[dep.find(':')+1:dep.find('#')]
+  return (path, name)
+
+
+def GetDependencies(deps_dict, root):
+  targets = set()
+  dependencies = copy.deepcopy(deps_dict[root])
+  while dependencies:
+    dep = dependencies.pop()
+    target_path, target_name = ParseDependency(dep)
+    if target_name in targets:
+      continue
+    if ("xwalk/" not in target_path) and ("tizen_src/ewk/" not in target_path):
+      targets.add(target_name)
+    dependencies += deps_dict[dep]
+  return targets
+
+
+def main():
+  if len(sys.argv) < 3:
+    print('Usage: %s <deps.json> <target 1> [... <target N>]' % sys.argv[0])
+    print('<deps.json> points to deps.json generated by gyp with '
+          'GYP_GENERATORS=dump_dependency_json.')
+    print('Each target is a target name whose dependencies will be '
+          'printed.')
+    return 1
+
+  dump_json_path = sys.argv[1]
+  if not os.path.isfile(dump_json_path):
+    print('"%s" not found.' % dump_json_path)
+    print('Run gyp with GYP_GENERATORS=dump_dependency_json first.')
+    return 1
+
+  deps_dict = json.load(open(dump_json_path))
+  targets = sys.argv[2:]
+  roots = []
+
+  for target in targets:
+    valid_target = False
+    for dep in deps_dict:
+      if dep.endswith(':%s#target' % target):
+        valid_target = True
+        roots.append(dep)
+        break
+    if not valid_target:
+      print('Error: "%s" is not a valid target.' % target)
+      return 1
+
+  target_deps = set()
+  for dependency in roots:
+    target_deps |= GetDependencies(deps_dict, dependency)
+
+  print ' '.join(list(target_deps))
+  return 0
+
+
+if __name__ == '__main__':
+  sys.exit(main())