Tuesday, August 16, 2011

Compiling FireTray add-on for new versions of Thunderbird and Firefox

UPDATE (January 31, 2011): FireTray extension for Firefox and Thunderbird 10, for i686:


This build was made from the following modified source files: firetray-0.3.6.tar.gz
EDIT (December 23, 2011): Here's the FireTray extension for Firefox and Thunderbird 9, for i686. http://ubuntuone.com/1Lc0AmLqDlTWiPgBErNNaK
I used the following modified components/SConscript file in the firetray source, based on the modifications posted by HTH here: https://code.google.com/p/firetray/issues/detail?id=207#c4
import sys, os, string, re

platform = sys.platform


try:
    FLAGS = os.environ['CXXFLAGS'];
except:
    FLAGS = '-O2';

linking_options=' --libs ';
try:
    DYNAMIC_LINKING = os.environ['DYNAMIC_LINKING'];
except:
    linking_options=' --static '  

print "linking: " + linking_options

FLAGS += ' -include xpcom-config.h -include mozilla-config.h'
FLAGS += ' -fno-rtti -fno-exceptions -fshort-wchar'
FLAGS += ' -Wall -Wconversion -Wpointer-arith -Wcast-align -Woverloaded-virtual -Wsynth -Wno-ctor-dtor-privacy -Wno-non-virtual-dtor -Wno-long-long'
FLAGS += ' -pedantic -pthread -pipe'

try:
    lib_arch = os.environ['LIB_ARCH'];
except:
    lib_arch = '';


try: 
    gecko_bin = os.environ['GECKO_SDK_BIN'];
    if gecko_bin[-1] != os.sep: gecko_bin += os.sep

    gecko_sdk_bin = os.environ['GECKO_SDK_BIN'];
    if gecko_sdk_bin[-1] != os.sep: gecko_sdk_bin += os.sep

    gecko_include = os.environ['GECKO_SDK_INCLUDE'];
    if gecko_include[-1] != os.sep: gecko_include += os.sep

    gecko_idl = os.environ['GECKO_SDK_IDL'];
    if gecko_idl[-1] != os.sep: gecko_idl += os.sep

    gecko_lib = os.environ['GECKO_SDK_LIB'];
    if gecko_lib[-1] != os.sep: gecko_lib += os.sep

except:
    try:
        geckosdk = os.environ['GECKO_SDK']
        print "Using GECKO_SDK=" + geckosdk
        if geckosdk[-1] != os.sep: geckosdk += os.sep
        gecko_bin = geckosdk + 'bin'
        gecko_sdk_bin = geckosdk + 'sdk/bin'
        gecko_include = geckosdk + 'include'
        gecko_idl = geckosdk + 'idl'
        gecko_lib = geckosdk + 'lib'

    except:
        print "Please set environment variable GECKO_SDK first (or in alternative the variables GECKO_SDK_BIN, GECKO_SDK_INCLUDE, GECKO_SDK_IDL, GECKO_SDK_LIB)."
        sys.exit(1)

# Hack to detect Mozilla version
version_re = re.compile('#define MOZILLA_VERSION "(.*?)"')
xpcom_libs = ['xpcomglue_s']
with open(gecko_include + os.sep + 'mozilla-config.h', 'r') as f:
    for line in f:
        version_match = version_re.match(line)
        if version_match:
            version = string.split(version_match.group(1), '.')
            if int(version[0]) >= 2:
                # OK, we're building with Mozilla 2.0
                FLAGS += ' -DGECKO_2'
                if 'GECKO_19_COMPAT' in os.environ:
                    FLAGS += ' -DMOZ_NO_MOZALLOC'
                    xpcom_libs = ['xpcomglue_s_nomozalloc']
                else:
                    xpcom_libs.append('mozalloc')
            break

# Create two builders to create xpt and header files from idl.
#bxpt = Builder(action = 'pyxpidl -w -m typelib -Icomponents -I' + gecko_idl + ' -e $TARGET $SOURCE', suffix = '.xpt', src_suffix = '.idl')
#bhdr = Builder(action = 'pyxpidl -w -m header -Icomponents -I' + gecko_idl + ' -e $TARGET $SOURCE', suffix = '.h', src_suffix = '.idl')
bxpt = Builder(action = 'python ' + gecko_sdk_bin + '/typelib.py -Icomponents -I' + gecko_idl + ' -o $TARGET $SOURCE', suffix = '.xpt', src_suffix = '.idl')
bhdr = Builder(action = 'python ' + gecko_sdk_bin + '/header.py -Icomponents -I' + gecko_idl + ' -o $TARGET $SOURCE', suffix = '.h', src_suffix = '.idl')

# Create environment object for build
env = Environment(
    CPPPATH = [gecko_include],
    LIBPATH = [gecko_lib],
    LIBS = xpcom_libs,
    ENV = os.environ)
env.AppendENVPath('PATH', gecko_bin)
env.AppendENVPath('PATH', gecko_sdk_bin)
env.Append(BUILDERS = {'MozXPT' : bxpt, 'MozHeader' : bhdr })

env.ParseConfig('pkg-config ' + linking_options + ' --cflags gtk+-2.0') # libnotify
env.ParseConfig('pkg-config --cflags nspr')
env.Append( CXXFLAGS = FLAGS )

# Create headers and xpt files from idl
xpts = [env.MozXPT('nsITray'), env.MozXPT('nsIFireTrayHandler')]
headers = [env.MozHeader('nsITray')]

parts = []
parts.extend(['nsTray.cpp', 'nsTrayModule.cpp'])

nptray_name = 'nptray' + lib_arch
print "NPTRAY: " + nptray_name

nptray = env.SharedLibrary(nptray_name, parts)

r = env.Install('#dist/components', [nptray, xpts, 'nsFireTrayHandler.js']) 

Default([xpts, headers, nptray])
Return('r')
EDIT (November 10, 2011): Here's the FireTray extension for Firefox and Thunderbird 8, for i686. http://ubuntuone.com/4RFhM6l1OtnB9IcFhsiqeQ
I updated Thunderbird today and my FireTray extension stopped working, so I'm compiling it now and documenting the steps as I go.



  1. Downloaded the source zip file for FireTray version 0.3.1 and extracted its contents.

  2. Ran the generate_install_rdf.sh shell script.

  3. Ran the bulid.sh shell script

  4. Error: ./build.sh: line 233: scons: command not found
    error compiling firetray.xpi

  5. Installed scons: sudo yum install scons

  6. Ran build.sh again.

  7. Another error because I'm missing the GECKO SDK: Please set environment variable GECKO_SDK first (or in alternative the variables GECKO_SDK_BIN, GECKO_SDK_INCLUDE, GECKO_SDK_IDL, GECKO_SDK_LIB).
    error compiling firetray.xpi

  8. Downloaded GECKO SDK from https://developer.mozilla.org/en/Gecko_SDK. The file I download is xulrunner-6.0.en-US.linux-i686.sdk.tar.bz2 and it's 234 MB.

  9. Extracted tarball.

  10. Ran ./build --gecko-sdk=<PATH_TO_EXTRACTED_xulrunner_TARBALL>

  11. Another error: Package nspr was not found in the pkg-config search path.

  12. Installed nspr-devel. sudo yum install nspr-devel.

  13. Ran build again. Another error: scons: warning: Ignoring missing SConscript 'chrome/SConscript'

  14. Created new directory chrome and copied SConscript from https://code.google.com/p/firetray/source/browse/trunk/chrome/SConscript?spec=svn117&r=117 to the directory.

  15. Ran build again. Multiple errors: sh: o: command not found

  16. Installed c++ compiler. sudo yum install gcc-c++

  17. Ran build again. Yet another error: scons: *** [dist/chrome/firetray.jar] Source `chrome/content/core.js' not found, needed by target `dist/chrome/firetray.jar'.
    scons: building terminated because of errors.

  18. Used svn to get copy of source code instead of using contents of the zip file I downloaded. svn checkout http://firetray.googlecode.com/svn/trunk/ firetray-read-only

  19. Ran build again. ./build.sh --gecko-sdk=/home/joel/devel/xulrunner-sdk/

  20. Great success! Extension packaged as: firetray-0.3.0-svn-r124.xpi

8 comments:

  1. But did it really work ? I mean the extension...

    ReplyDelete
  2. thank you very much for this tutorial. worked perfectly on ubuntu with some minor changes. jsut to save all the others the time and big downloads: here is a finished version http://www.file-upload.net/download-3707349/firetray-0.3.0-svn-r124M.xpi.html

    ReplyDelete
  3. @R - I'm happy to hear this worked for you. I should clean these notes up and make them into a proper tutorial.

    ReplyDelete
  4. @LiMar, I just realized, as I recompiled FireTray a few minutes ago, that I needed to edit the generate_install_rdf.sh script so that the versions of Firefox and Thunderbird are set to "8.0,8.*".

    ReplyDelete
  5. I'm currently going through the process of compiling FireTray on my Debian system for Firefox and Thunderbird 8. I'm documenting the process below.

    1. Downloaded xulrunner-8.0.en-US.linux-i686.sdk.tar.bz2

    2. Downloaded FireTray using svn: svn checkout http://firetray.googlecode.com/svn/trunk/ firetray-read-only

    3. Edited generate_install_rdf.sh: changed SUPPORTED_APPS so that, for both Firefox and Thunderbird, min.ver and max.ver are 8.0 and 8.*, respectively.

    4. Ran ./build.sh --gecko-sdk=

    5. Got error: "No package 'nspr' found", so installed libnspr6-dev... sudo apt-get install libnspr4-dev

    6. Ran ./build.sh --gecko-sdk=

    7. Great success!

    ReplyDelete
  6. Thanks! Finally firetray for Thunderbird 10!

    ReplyDelete
  7. Thông tin cụ thể hơn, ông Đào Anh Tuấn, Tổng giám đốc công ty vận chuyển cho biết, vận tải hàng hóa của đơn vị thue xe tai vẫn chưa đạt thành quả tốt nhưng hành khách thời gian qua tăng khá tuyệt hảo với mức hơn 10% so với năm 2016. khác lạ, doanh thu tăng rất cao, nhất là trong tháng 6 vừa qua tăng hơn 50%. Chúng tôi phải áp dụng nhiều giải pháp giá thuê xe tải chở hàng Hà Nội linh hoạt, trong đó ưu tiên đẩy mạnh tàu chạy các chặng ngắn như: Sài Gòn - Phan Thiết, Sài Gòn - Nha Trang. Tháng 5 vừa qua, đưa vào khai thác tuyến mới Nha Trang - Huế và đã đạt 70% hệ số khai thác”, ông Tuấn nói và cho biết, khác biệt, lần trước tiên đường sắt xây dưng chính sách lạnh vé linh hoạt, khuyến mãi, giảm giá buốt vé tập thể, công ty du lịch, cấu kết nâng chất lượng vệ sinh toa xe, tương tác với khách hàng thue xe tai Binh Duong nhiều hơn. “Chính điều này đã hút lượng khách lớn quay trở lại với đường sắt, ông Tuấn lý giải.

    ReplyDelete