[glade] Final touches to the bundle environment



commit 22ddb259a38c5f9554c59460489a357c275088e4
Author: Tristan Van Berkom <tristan upstairslabs com>
Date:   Tue Dec 17 17:23:01 2013 +0900

    Final touches to the bundle environment

 build/linux/LibcWrapGenerator.vala |   44 +++--
 build/linux/PrepareAppDir.sh       |   10 +-
 build/linux/README                 |   25 +--
 build/linux/README.lfs             |  352 ------------------------------------
 build/linux/jhbuildrc              |    6 +-
 5 files changed, 39 insertions(+), 398 deletions(-)
---
diff --git a/build/linux/LibcWrapGenerator.vala b/build/linux/LibcWrapGenerator.vala
index a6a6175..8a3bff1 100644
--- a/build/linux/LibcWrapGenerator.vala
+++ b/build/linux/LibcWrapGenerator.vala
@@ -87,7 +87,7 @@ class VersionNumber : Object
                        else
                                revision = 0;
                } catch (GLib.RegexError e) {
-                       stdout.printf("Error compiling regular expression!");
+                       stdout.printf ("Error compiling regular expression: %s", e.message);
                        Posix.exit(-1);
                }
        }
@@ -128,7 +128,7 @@ public class Main : Object {
 
        private const GLib.OptionEntry[] options = {
                { "libdir", 'l', 0, OptionArg.FILENAME, ref libdir, "Library directory", "<DIRECTORY>" },
-               { "output", 'o', 0, OptionArg.STRING,   ref output, "Header to create", "<FILENAME>" },
+               { "output", 'o', 0, OptionArg.STRING,   ref output, "Header to create",  "<FILENAME>" },
                { "target", 't', 0, OptionArg.STRING,   ref target, DEFAULT_TARGET_HELP, 
"<MAJOR.MINOR[.MICRO]>" },
                { null }
        };
@@ -137,10 +137,12 @@ public class Main : Object {
        private static VersionNumber minimumVersion;
        private static Gee.HashMap<string, VersionNumber>symbolMap;
        private static Gee.HashSet<string>filterMap;
-       private static Regex regex;
 
        public static int main (string[] args) {
 
+               /* Initialize the default here */
+               target = DEFAULT_TARGET;
+
                try {
                        var opt_context = new OptionContext ("- Libc compatibility header generator");
                        opt_context.set_help_enabled (true);
@@ -164,9 +166,6 @@ public class Main : Object {
                        return 0;
                }
 
-               if (target == null)
-                       target = DEFAULT_TARGET;
-
                /* Initialize local resources */
                minimumVersion = new VersionNumber (target);
 
@@ -182,7 +181,6 @@ public class Main : Object {
 
                        stdout.printf ("Generating %s (glibc %s) from libs at '%s' .", output, 
minimumVersion.getString(), libdir);
 
-                       regex = new Regex("(.*)(GLIBC_)([0-9]+\\.([0-9]+\\.)*[0-9]+)(\\)?)([ ]*)(.+)");
                        parseLibraries ();
                        generateHeader ();
 
@@ -197,7 +195,7 @@ public class Main : Object {
                return 0;
        }
 
-       private static void parseLibrary (FileInfo fileinfo) throws Error {
+       private static void parseLibrary (Regex regex, FileInfo fileinfo) throws Error {
 
                string output, errorOutput;
                int returnCode;
@@ -267,24 +265,25 @@ public class Main : Object {
        private static void parseLibraries () throws Error {
                var libPath    = File.new_for_path (libdir);
                var enumerator = libPath.enumerate_children (FileAttribute.STANDARD_NAME, 0, null);
+               var regex      = new Regex ("(.*)(GLIBC_)([0-9]+\\.([0-9]+\\.)*[0-9]+)(\\)?)([ ]*)(.+)");
+
                var counter    = 0;
                FileInfo fileinfo;
 
-               while ((fileinfo = enumerator.next_file(null)) != null)
-               {
-                       if(++counter % 50 == 0)
-                       {
+               while ((fileinfo = enumerator.next_file(null)) != null) {
+
+                       if (++counter % 50 == 0) {
                                stdout.printf(".");
                                stdout.flush();
                        }
 
-                       parseLibrary (fileinfo);
+                       parseLibrary (regex, fileinfo);
                }
        }
 
-       private static void appendSymbols (StringBuilder headerFile, bool overrides) {
+       private static void appendSymbols (StringBuilder headerFile, bool unavailableSymbols) {
 
-               if (overrides)
+               if (unavailableSymbols)
                        headerFile.append("\n/* Symbols introduced in newer glibc versions, which must not be 
used */\n");
                else
                        headerFile.append("\n/* Symbols redirected to earlier glibc versions */\n");
@@ -306,13 +305,13 @@ public class Main : Object {
                        if (version.newerThan (minimumVersion)) {
 
                                versionToUse = "DONT_USE_THIS_VERSION_%s".printf (version.getString());
-                               if (!overrides)
+                               if (!unavailableSymbols)
                                        continue;
 
                        } else {
 
                                versionToUse = version.getString ();
-                               if (overrides)
+                               if (unavailableSymbols)
                                        continue;
                        }
 
@@ -323,6 +322,13 @@ public class Main : Object {
        private static void generateHeader () throws Error {
                var headerFile = new StringBuilder ();
 
+               /* FIXME: Currently we do:
+                *
+                *   if !defined (__OBJC__) && !defined (__ASSEMBLER__)
+                *
+                * But what we want is a clause which accepts any form of C including C++ and probably
+                * also including ObjC. That said, the generated header works fine for C and C++ sources.
+                */
                headerFile.append ("/* glibc bindings for target ABI version glibc " + 
minimumVersion.getString() + " */\n");
                headerFile.append ("#if !defined (__LIBC_CUSTOM_BINDINGS_H__)\n");
                headerFile.append ("\n");
@@ -331,9 +337,7 @@ public class Main : Object {
                headerFile.append ("extern \"C\" {\n");
                headerFile.append ("#    endif\n");
 
-               /* For prettier output, let's output the redirected symbols first, and
-                * then output the ones which must not be used (new in glibc > minimumVersion).
-                */
+               /* First generate the available redirected symbols, then the unavailable symbols */
                appendSymbols (headerFile, false);
                appendSymbols (headerFile, true);
 
diff --git a/build/linux/PrepareAppDir.sh b/build/linux/PrepareAppDir.sh
index e57041b..17fd782 100755
--- a/build/linux/PrepareAppDir.sh
+++ b/build/linux/PrepareAppDir.sh
@@ -17,16 +17,12 @@
 # You should have received a copy of the GNU General Public License
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-#
-# Usage:
-#
-# ./PrepareAppDir.sh /path/to/AppImage/Install /path/to/glade
 
 APP_DIR_ROOT=$1
-GLADE_DIR=$2
+BUNDLE_DIR=$2
 
-if test -z ${APP_DIR_ROOT} || test -z ${GLADE_DIR}; then
-    echo "Usage ./PrepareAppDir.sh /path/to/AppImage/Install /path/to/glade"
+if test -z ${APP_DIR_ROOT} || test -z ${BUNDLE_DIR}; then
+    echo "Usage ./PrepareAppDir.sh /path/to/AppImage/Install /path/to/glade/build/linux"
     exit 0;
 fi
 
diff --git a/build/linux/README b/build/linux/README
index 3f10ee8..47ed595 100644
--- a/build/linux/README
+++ b/build/linux/README
@@ -87,43 +87,36 @@ this to be a "/full/path/to/the/checkout/of/glade"
 
   Building the stack
   ~~~~~~~~~~~~~~~~~~
-  The AppDir is what AppImageKit refers to as the root filesystem inside the
-  bundle.
-
-  The provided jhbuild scripts will create a directory in your ${HOME} named
-  'AppImages', all of our building & bundling will take place inside this directory.
-
-  Note, if you already have a jhbuild environment there is no need to worry,
-  our scripts do not interfere with your existing jhbuild environment.
-
   To build the whole stack up to Glade, including Glade, issue this command:
 
-    GLADE_DIR=${GLADE_CHECKOUT} jhbuild -f ${GLADE_CHECKOUT}/build/linux/jhbuildrc build glade
+    BUNDLE_ROOT=~/GladeBundle BUNDLE_DIR=${GLADE_CHECKOUT}/build/linux jhbuild -f 
${GLADE_CHECKOUT}/build/linux/jhbuildrc build
 
-  I've found the build to break sometimes at 'shared-mime-info', in this case I just rerun
-  the above command and it passes on the second try... nothing to see here... carry on...
+  This will build everything into the ${BUNDLE_ROOT} you specified, the actual installation
+  will be found in ${BUNDLE_ROOT}/Install
 
+  This will not interfere with any existing jhbuild environment you may already have setup,
+  everything is self contained and happens inside the ${BUNDLE_ROOT} you specify.
 
   Post processing the image directory
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   Some post processing is needed on the AppDir, we intentionally keep this separate from
   the jhbuild setup. To perform the needed post processing, issue this command:
 
-    ${GLADE_CHECKOUT}/build/linux/PrepareAppDir.sh ${HOME}/AppImages/Install ${GLADE_CHECKOUT}
+    ${GLADE_CHECKOUT}/build/linux/PrepareAppDir.sh ${BUNDLE_ROOT}/Install ${GLADE_CHECKOUT}/build/linux
 
-  WARNING: The above script will modify the ${HOME}/AppImages/Install directory in such
+  WARNING: The above script will modify the ${BUNDLE_ROOT}/Install directory in such
   a way that it cannot be rebuilt (development headers and unneeded cruft is removed
   from the installation directory). This is why we use a script as a separate stage from
   building.
 
-  At this point, you should have a fully functional image in ${HOME}/AppImages/Install
+  At this point, you should have a fully functional image in ${BUNDLE_ROOT}/Install
 
 
 Bundling
 ~~~~~~~~
 Build the bundle with one simple command:
 
-    /path/to/AppImageKit/AppImageAssistant ${HOME}/AppImages/Install /path/to/generated/glade
+    /path/to/AppImageKit/AppImageAssistant ${BUNDLE_ROOT}/Install ~/glade
 
 This will create a huge binary named 'glade' at the location of your choosing.
 
diff --git a/build/linux/jhbuildrc b/build/linux/jhbuildrc
index 3bf2a04..af290de 100644
--- a/build/linux/jhbuildrc
+++ b/build/linux/jhbuildrc
@@ -21,7 +21,7 @@
 #   Tristan Van Berkom <tristan upstairslabs com>
 #
 use_local_modulesets = True
-modulesets_dir = os.getenv('GLADE_DIR') + '/build/linux/modulesets'
+modulesets_dir = os.getenv('BUNDLE_DIR') + '/modulesets'
 moduleset = 'bundle.modules'
 
 # Unset autogenargs (screws with some modules like freetype)
@@ -41,7 +41,7 @@ build_cflags += ' -DCAIRO_NO_MUTEX=1'
 
 # Include the libcwrap.h before anything else for every source, this
 # ensures we are targetting the right version of glibc
-build_cflags += ' -include ' + os.getenv('GLADE_DIR') + '/build/linux/libcwrap.h'
+build_cflags += ' -include ' + os.getenv('BUNDLE_DIR') + '/libcwrap.h'
 
 # Set the compiler flags for both C and C++ sources, overriding CC and CXX
 # ensures that they come before any flags that any buildscripts might add
@@ -49,7 +49,7 @@ os.environ['CC']  = 'gcc ' + build_cflags
 os.environ['CXX'] = 'g++ ' + build_cflags
 
 # Enable our custom triggers
-os.environ['JHBUILD_TRIGGERS'] = os.getenv('GLADE_DIR') + '/build/linux/triggers'
+os.environ['JHBUILD_TRIGGERS'] = os.getenv('BUNDLE_DIR') + '/triggers'
 
 # A list of the modules to build.
 modules = [ 'glade' ]


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]