Difference between revisions of "Compiling the viewer libraries LLMozLib (Linux)"

From Second Life Wiki
Jump to navigation Jump to search
Line 67: Line 67:
== Patch LLMozLib ==
== Patch LLMozLib ==


The current LlMozLib download is out of date and a few patches are required. Note this patches are incomplete and may be the reason why no HTML renders.
The current LlMozLib download is out of date and a few patches are required. Note this patches are incomplete and may be the reason why no HTML renders. The functions clearAllCookies, enableCookies,unicodeInout and handleUnicodeChar are just stubbed out and have no contents.
 


<code>
<code>
Line 171: Line 172:
   
   
</code>
</code>


== Build LLMozLib ==
== Build LLMozLib ==

Revision as of 03:49, 31 October 2007

These instructions describe building LLMozLib for Linux. They are currently incomplete so if you have further information please fill in the gaps.

So far it is possible to build LLMozLib and link a homebrew viewer against it with out errors or crashing but this has not yet resulted in the HTML rendering on the login screen or the web profile tab, if you know why please fix this and let me know!


Download LLMozLib

Get LLMozLib at this stage as you require a patch from the tar ball.

Get the snapshot of llmozlib from the source downloads page.

Download mozilla

According to other wiki pages ( Compiling_the_viewer_libraries_(MSVS_2003)#LLMozLib ) we are using the FIREFOX_1_5_0_9_RELEASE branch of mozilla. So get that branch :-

export CVSROOT=:pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot
cvs login (the password is 'anonymous')
cvs checkout -r FIREFOX_1_5_0_9_RELEASE mozilla/client.mk
cd mozilla
make -f client.mk checkout MOZ_CO_PROJECT=xulrunner


Patch mozilla

Apply a patch which enables certain features that are required for the Second Life client.

The patch can be found in the llmozlib build_mozilla directory.
Copy the patch into the directory where you are building Mozilla and apply the patch:

patch -p0 < linden_updates.patch

Build mozilla

Assuming you are working in a directory where you have just downloaded mozilla (from above) which generated a mozilla folder and you have also downloaded and unpacked the llMozLib tarball and greated a llmozlib directory :-

To make a release build :-


cp llmozlib/build_mozilla/.mozconfig.optimized mozilla/.mozconfig
cd mozilla
make -f client.mk build

To make a debug build :-


cp llmozlib/build_mozilla/.mozconfig.debug mozilla/.mozconfig
cd mozilla
make -f client.mk build

  • Fix the build configuration file

Edit the mozilla/.mozconfig and add the following

ac_add_options --enable-default-toolkit=gtk2

ac_add_options --enable-xft

Also it seems necessary to remove

ac_add_options --enable-svg

Patch LLMozLib

The current LlMozLib download is out of date and a few patches are required. Note this patches are incomplete and may be the reason why no HTML renders. The functions clearAllCookies, enableCookies,unicodeInout and handleUnicodeChar are just stubbed out and have no contents.


diff -U3 -r llmozlib.orig/llembeddedbrowser.cpp llmozlib/llembeddedbrowser.cpp
--- llmozlib.orig/llembeddedbrowser.cpp 2007-01-13 01:30:42.000000000 +0000
+++ llmozlib/llembeddedbrowser.cpp      2007-10-30 22:45:06.000000000 +0000
@@ -122,10 +122,11 @@

 ////////////////////////////////////////////////////////////////////////////////
 //
-bool LLEmbeddedBrowser::init( std::string appBaseDir, std::string profileDir )
+bool LLEmbeddedBrowser::init( std::string appBaseDir, std::string otherbull, std::string profileDir  )
 {
        std::string appRuntimeDir( appBaseDir );
-       std::string xulRuntimeDir( appBaseDir );
+       std::string xulRuntimeDir( otherbull );
+

        nsCOMPtr< nsILocalFile > xulDir;
        nsresult result = NS_NewNativeLocalFile( nsCString( xulRuntimeDir.c_str() ), PR_FALSE,  getter_AddRefs( xulDir ) );

diff -U3 -r llmozlib.orig/llembeddedbrowser.h llmozlib/llembeddedbrowser.h
--- llmozlib.orig/llembeddedbrowser.h   2007-01-13 01:30:42.000000000 +0000
+++ llmozlib/llembeddedbrowser.h        2007-10-30 22:43:54.000000000 +0000
@@ -42,7 +42,7 @@

                static LLEmbeddedBrowser* getInstance();

-               bool init( std::string appBaseDirIn, std::string profileDirIn );
+               bool init( std::string appBaseDirIn,std::string bull, std::string profileDirIn );
                bool reset();
                bool clearCache();
                std::string getGREVersion();

diff -U3 -r llmozlib.orig/llmozlib.cpp llmozlib/llmozlib.cpp
--- llmozlib.orig/llmozlib.cpp  2007-01-13 01:30:42.000000000 +0000
+++ llmozlib/llmozlib.cpp       2007-10-30 22:46:00.000000000 +0000
@@ -66,11 +66,14 @@

 ////////////////////////////////////////////////////////////////////////////////
 //
-bool LLMozLib::init( std::string appBaseDirIn, std::string profileDirNameIn )
+
+bool LLMozLib::init( std::string appBaseDirIn, std::string extradirs, std::string profileDirNameIn  )
 {
-       return LLEmbeddedBrowser::getInstance()->init( appBaseDirIn, profileDirNameIn );
+       printf("LLMozLib::init()\n");
+       return LLEmbeddedBrowser::getInstance()->init( appBaseDirIn, extradirs,profileDirNameIn );
 }

+
 ////////////////////////////////////////////////////////////////////////////////
 //
 int LLMozLib::getLastError()
@@ -468,3 +473,9 @@
        return false;
 }

+
+void LLMozLib::clearAllCookies(void) {}
+void LLMozLib::enableCookies(bool x){}
+void LLMozLib::unicodeInput(int x, unsigned long y) {}
+void LLMozLib::handleUnicodeChar(wchar_t x,int y) {}
+

diff -U3 -r llmozlib.orig/llmozlib.h llmozlib/llmozlib.h
--- llmozlib.orig/llmozlib.h    2007-01-13 01:30:42.000000000 +0000
+++ llmozlib/llmozlib.h 2007-10-30 22:46:19.000000000 +0000
@@ -109,7 +109,9 @@
                static LLMozLib* getInstance();

                // housekeeping
-               bool init( std::string appBaseDirIn, std::string profileDirIn );
+
+               bool init( std::string appBaseDirIn, std::string extradirs, std::string profileDirIn  );
+
                bool reset();
                bool clearCache();
                int getLastError();
@@ -150,6 +152,11 @@
                bool keyPress( int browserWindowIdIn, int keyCodeIn );
                bool focusBrowser( int browserWindowIdIn, bool focusBrowserIn );

+               void clearAllCookies(void);
+               void enableCookies(bool x);
+               void unicodeInput(int x, unsigned long y);
+               void handleUnicodeChar(wchar_t x,int y);
+
        private:
                LLMozLib();
                LLEmbeddedBrowserWindow* getBrowserWindowFromWindowId( int browserWindowIdIn );


Build LLMozLib

This is where the hoops begin that you have to jump through, there is no make file so these are the required build flags :-

CPPFLAGS=-I$MOZDIR/include/content -I$MOZDIR/include/docshell -I$MOZDIR/include/dom \
-I$MOZDIR/include/gfx -I$MOZDIR/include/layout -I$MOZDIR/include/locale \ 
-I${MOZDIR}/include/necko -I$MOZDIR/include/nkcache -I$MOZDIR/include/pref \    
-I$MOZDIR/include/profdirserviceprovider \
-I$MOZDIR/include/string -I$MOZDIR/include/uriloader -I$MOZDIR/include/view \
-I$MOZDIR/include/webbrwsr -I$MOZDIR/include/widget -I$MOZDIR/include/xpcom \
-I$MOZDIR/include/xulapp -I$MOZDIR/sdk/include

CPPFLAGS += -DMOZILLA_INTERNAL_API

CPPFLAGS += -Werror -fno-rtti -fno-exceptions

CPPFLAGS += -fPIC -shared

LINKFLAGS += -lnspr4 -lplc4 -lxpcom -lxul -lstdc++

LINKFLAGS += -L$MOZDIR/bin

Where MOZDIR is (for release build of mozilla) :-

mozilla/objdir-opt-xulrunner-small/dist

and debug build of mozilla

mozilla/objdir-debug-xulrunner-small/dist

The actual gcc commands are as follows :-

        g++ -c $CPPFLAGS llmozlib/llembeddedbrowser.cpp
        g++ -c $CPPFLAGS llmozlib/llembeddedbrowserwindow.cpp
        g++ -c $CPPFLAGS llmozlib/llmozlib.cpp
        g++  $CPPFLAGS $LINKFLAGS -o libllmozlib.so llembeddedbrowser.o \
llembeddedbrowserwindow.o llmozlib.o


That should produce a libllmozlib.so dynamic library


The following libraries should bow be copied to /usr/lib/ so they are available system wide.

       cp $MOZDIR/bin/libxpcom.so /usr/lib
       cp $MOZDIR/bin/libxul.so /usr/lib
       cp $MOZDIR/bin/libplds4.so /usr/lib
       cp $MOZDIR/bin/libplc4.so /usr/lib
       cp $MOZDIR/bin/libmozjs.so /usr/lib
       cp $MOZDIR/lib/libprofdirserviceprovider_s.a /usr/lib
       cp libllmozlib.so /usr/lib/

After that better run ldconfig to update system libraries links.

Makefile

Below is a make file that does the above work, to use it download it to an empty folder and type make allwork, then (as root) make install. Other targets are included for just rebuilding llmozlib etc. The file can probably be improved *a lot* but its a starting point

CURMOZLIBSRC="http://secondlife.com/developers/opensource/downloads/2007/01/llmozlib-src-20070112a.tar.gz"

FIREFOX_BRANCH=FIREFOX_1_5_0_9_RELEASE

MOZDIR=${PWD}/mozilla/objdir-opt-xulrunner-small/dist

CVSROOT=:pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot

CC=gcc-3.4

CPPFLAGS=-I${MOZDIR}/include/content -I${MOZDIR}/include/docshell -I${MOZDIR}/include/dom \
-I${MOZDIR}/include/gfx -I${MOZDIR}/include/layout -I${MOZDIR}/include/locale \
-I${MOZDIR}/include/necko -I${MOZDIR}/include/nkcache -I${MOZDIR}/include/pref \ 
-I${MOZDIR}/include/profdirserviceprovider -I${MOZDIR}/include/string \ 
-I${MOZDIR}/include/uriloader  -I${MOZDIR}/include/view -I${MOZDIR}/include/webbrwsr \ 
-I${MOZDIR}/include/widget -I${MOZDIR}/include/xpcom -I${MOZDIR}/include/xulapp \ 
-I${MOZDIR}/sdk/include

CPPFLAGS += -DMOZILLA_INTERNAL_API

CPPFLAGS += -Werror -fno-rtti -fno-exceptions

CPPFLAGS += -g

LINKFLAGS += -lnspr4 -lplc4 -lxpcom -lxul -lstdc++

LINKFLAGS += -L${MOZDIR}/bin

CPPFLAGS += -fPIC -shared

download_mozlib:
        wget ${CURMOZLIBSRC}
        tar -xvzf llmozlib-src-*.tar.gz

compile_mozlib:
         g++ -c ${CPPFLAGS} llmozlib/llembeddedbrowser.cpp
         g++ -c ${CPPFLAGS} llmozlib/llembeddedbrowserwindow.cpp
         g++ -c ${CPPFLAGS} llmozlib/llmozlib.cpp
         g++  ${CPPFLAGS} ${LINKFLAGS} -o libllmozlib.so llembeddedbrowser.o \
llembeddedbrowserwindow.o llmozlib.o

clean_mozlib:
        cd llmozlib && rm -f *.o && rm -f *.so
        rm -f *.o
        rm -f *.so

install_mozlib:
        install -d ${DESTDIR}/usr/lib/
        install -m 0755 libllmozlib.so ${DESTDIR}/usr/lib/

download_mozilla:
        echo "Downloading mozilla"
        echo "Press ENTER at password prompt"
        cvs -d ${CVSROOT} login
        cvs -d ${CVSROOT} checkout -r ${FIREFOX_BRANCH} mozilla/client.mk
        make -f mozilla/client.mk checkout MOZ_CO_PROJECT=xulrunner CC=${CC}

patch_mozilla:
        cd mozilla && patch -p0 < ../llmozlib/build_mozilla/linden_updates.patch

compile_mozilla:
        cp llmozlib/build_mozilla/.mozconfig.optimized mozilla/.mozconfig
        dos2unix mozilla/.mozconfig
        echo "ac_add_options --enable-default-toolkit=gtk2" >> mozilla/.mozconfig
        echo "ac_add_options --enable-xft" >> mozilla/.mozconfig
        cat mozilla/.mozconfig | sed 's/ac_add_options --enable-svg//g' > mozilla/.mozconfig
        make -f mozilla/client.mk build CC=${CC}

all_mozilla: download_mozilla patch_mozilla compile_mozilla

install_mozilla:
        install -d ${DESTDIR}/usr/lib/
        install -m 0755 ${MOZDIR}/bin/libxpcom.so ${DESTDIR}/usr/lib
        install -m 0755 ${MOZDIR}/bin/libxul.so ${DESTDIR}/usr/lib
        install -m 0755 ${MOZDIR}/bin/libplds4.so ${DESTDIR}/usr/lib
        install -m 0755 ${MOZDIR}/bin/libplc4.so ${DESTDIR}/usr/lib
        install -m 0755 ${MOZDIR}/bin/libmozjs.so ${DESTDIR}/usr/lib
        install -m 0755 ${MOZDIR}/lib/libprofdirserviceprovider_s.a ${DESTDIR}/usr/lib

clean_mozilla:
        echo "Umm don't know how to clean mozilla tree yet"

install: install_mozilla install_mozlib

all: compile_mozilla compile_mozlib

allwork: all_mozilla download_mozlib compile_mozlib

clean: clean_mozilla clean_mozlib

Build the client

It should be possible now to build the client with MOZLIB=YES on the scons line

  • Runtime files

The mozilla runtime files are all located in $MOZDIR/bin/ and you need to copy the following folders to your secondlife viewer folder. They should live in the app_settings/mozilla_runtime-linux-i686/ folder

  • chrome
  • components
  • greprefs
  • res
  • plugins




End of the line

This is far as i have got so far. I believe the LLMozLib code is starting up and it is finding the files in the above folders as without them you get error messages but there is currently no html rendering of the login screen or the web profiles etc.