[GTK][CMake] Add a 'distcheck' target
authorcarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 10 Jul 2014 16:13:54 +0000 (16:13 +0000)
committercarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 10 Jul 2014 16:13:54 +0000 (16:13 +0000)
https://bugs.webkit.org/show_bug.cgi?id=130675

.:
Reviewed by Gustavo Noronha Silva.

* Source/PlatformGTK.cmake: Add distcheck target.

Tools:
Patch by Carlos Garcia Campos  <cgarcia@igalia.com> and Martin Robinson <mrobinson@igalia.com> on 2014-07-10
Reviewed by Gustavo Noronha Silva.

Add --check option to make-dist script that builds and installs the tarball.

* gtk/make-dist.py:
(Distcheck.__init__):
(Distcheck.extract_tarball): Extratc the tarball.
(Distcheck.configure): Run cmake.
(Distcheck.configure.create_dir): Helper function to create a directory.
(Distcheck.build): Run make.
(Distcheck.install): Run make install.
(Distcheck.clean): Clean up the extracted tarball.
(Distcheck.check): Run all previous methods in order.
* gtk/manifest.txt: Add missing file.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@170965 268f45cc-cd09-0410-ab3c-d52691b4dbfc

ChangeLog
Source/PlatformGTK.cmake
Tools/ChangeLog
Tools/gtk/make-dist.py
Tools/gtk/manifest.txt

index 28cd7a3..8c7187d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
 2014-07-10  Carlos Garcia Campos  <cgarcia@igalia.com>
 
+        [GTK][CMake] Add a 'distcheck' target
+        https://bugs.webkit.org/show_bug.cgi?id=130675
+
+        Reviewed by Gustavo Noronha Silva.
+
+        * Source/PlatformGTK.cmake: Add distcheck target.
+
+2014-07-10  Carlos Garcia Campos  <cgarcia@igalia.com>
+
         [GTK] Use the same default options for production builds that previous stable releases
         https://bugs.webkit.org/show_bug.cgi?id=134589
 
index 298adfa..759a2c9 100644 (file)
@@ -71,4 +71,19 @@ if (ENABLE_WEBKIT2)
     add_custom_target(dist
         DEPENDS ${CMAKE_BINARY_DIR}/webkitgtk-${PROJECT_VERSION}.tar.xz
     )
+
+    add_custom_target(distcheck
+        DEPENDS ${TOOLS_DIR}/gtk/make-dist.py
+        DEPENDS ${TOOLS_DIR}/gtk/manifest.txt
+        DEPENDS WebKit2
+        DEPENDS gtkdoc
+        COMMAND ${TOOLS_DIR}/gtk/make-dist.py
+                --check
+                --source-dir=${CMAKE_SOURCE_DIR}
+                --build-dir=${CMAKE_BINARY_DIR}
+                --tarball-root=/webkitgtk-${PROJECT_VERSION}
+                -o ${CMAKE_BINARY_DIR}/webkitgtk-${PROJECT_VERSION}.tar
+                ${TOOLS_DIR}/gtk/manifest.txt
+        COMMAND xz -f ${CMAKE_BINARY_DIR}/webkitgtk-${PROJECT_VERSION}.tar
+    )
 endif ()
index 4e15be1..79dad97 100644 (file)
@@ -1,3 +1,23 @@
+2014-07-10  Carlos Garcia Campos  <cgarcia@igalia.com> and Martin Robinson  <mrobinson@igalia.com>
+
+        [GTK][CMake] Add a 'distcheck' target
+        https://bugs.webkit.org/show_bug.cgi?id=130675
+
+        Reviewed by Gustavo Noronha Silva.
+
+        Add --check option to make-dist script that builds and installs the tarball.
+
+        * gtk/make-dist.py:
+        (Distcheck.__init__):
+        (Distcheck.extract_tarball): Extratc the tarball.
+        (Distcheck.configure): Run cmake.
+        (Distcheck.configure.create_dir): Helper function to create a directory.
+        (Distcheck.build): Run make.
+        (Distcheck.install): Run make install.
+        (Distcheck.clean): Clean up the extracted tarball.
+        (Distcheck.check): Run all previous methods in order.
+        * gtk/manifest.txt: Add missing file.
+
 2014-07-10  Carlos Garcia Campos  <cgarcia@igalia.com>
 
         [GTK] Use the same default options for production builds that previous stable releases
index c61cac4..020edcb 100755 (executable)
@@ -19,9 +19,12 @@ from __future__ import print_function
 from contextlib import closing
 
 import argparse
+import errno
+import multiprocessing
 import os
 import re
-import sys
+import shutil
+import subprocess
 import tarfile
 
 
@@ -203,12 +206,67 @@ class Manifest(object):
         print("Wrote {0}".format(output).ljust(40))
 
 
+class Distcheck(object):
+    BUILD_DIRECTORY_NAME = "_build"
+    INSTALL_DIRECTORY_NAME = "_install"
+
+    def __init__(self, source_root, build_root):
+        self.source_root = source_root
+        self.build_root = build_root
+
+    def extract_tarball(self, tarball_path):
+        with closing(tarfile.open(tarball_path, 'r')) as tarball:
+            tarball.extractall(self.build_root)
+
+    def configure(self, build_dir, install_dir):
+        def create_dir(directory, directory_type):
+            try:
+                os.mkdir(directory)
+            except OSError, e:
+                if e.errno != errno.EEXIST or not os.path.isdir(directory):
+                    raise Exception("Could not create %s dir at %s: %s" % (directory_type, directory, str(e)))
+
+        create_dir(build_dir, "build")
+        create_dir(install_dir, "install")
+
+        command = ['cmake', '-DPORT=GTK', '-DCMAKE_INSTALL_PREFIX=%s' % install_dir, '-DCMAKE_BUILD_TYPE=Release', self.source_root]
+        subprocess.check_call(command, cwd=build_dir)
+
+    def build(self, build_dir):
+        command = ['make']
+        make_args = os.getenv('MAKE_ARGS')
+        if make_args:
+            command.extend(make_args.split(' '))
+        else:
+            command.append('-j%d' % multiprocessing.cpu_count())
+        subprocess.check_call(command, cwd=build_dir)
+
+    def install(self, build_dir):
+        subprocess.check_call(['make', 'install'], cwd=build_dir)
+
+    def clean(self, dist_dir):
+        shutil.rmtree(dist_dir)
+
+    def check(self, tarball):
+        tarball_name, ext = os.path.splitext(os.path.basename(tarball))
+        dist_dir = os.path.join(self.build_root, tarball_name)
+        build_dir = os.path.join(dist_dir, self.BUILD_DIRECTORY_NAME)
+        install_dir = os.path.join(dist_dir, self.INSTALL_DIRECTORY_NAME)
+
+        self.extract_tarball(tarball)
+        self.configure(build_dir, install_dir)
+        self.build(build_dir)
+        self.install(build_dir)
+        self.clean(dist_dir)
+
 if __name__ == "__main__":
     class FilePathAction(argparse.Action):
         def __call__(self, parser, namespace, values, option_string=None):
             setattr(namespace, self.dest, os.path.abspath(values))
 
     parser = argparse.ArgumentParser(description='Build a distribution bundle.')
+    parser.add_argument('-c', '--check', action='store_true',
+                        help='Check the tarball')
     parser.add_argument('-s', '--source-dir', type=str, action=FilePathAction, default=os.getcwd(),
                         help='The top-level directory of the source distribution. ' + \
                               'Directory for relative paths. Defaults to current directory.')
@@ -230,3 +288,6 @@ if __name__ == "__main__":
 
     manifest = Manifest(arguments.manifest_filename, arguments.source_dir, arguments.build_dir, arguments.tarball_root)
     manifest.create_tarfile(arguments.output_filename)
+
+    if arguments.check:
+        Distcheck(arguments.source_dir, arguments.build_dir).check(arguments.output_filename)
index ac9733d..0bdd358 100644 (file)
@@ -44,6 +44,8 @@ exclude Source/WebKit2/gtk/NEWS$
 # We do want to include the NEWS, but we want it to be in the root of the archive.
 file Source/WebKit2/gtk/NEWS NEWS
 
+file Source/WebCore/English.lproj/mediaControlsLocalizedStrings.js Source/WebCore/English.lproj/mediaControlsLocalizedStrings.js
+
 directory Tools/gtk
 directory Tools/ImageDiff
 directory Tools/MiniBrowser