当前位置

用免费工具 VC Toolkit 2003 编译 Mozilla Firefox 1.5

由于编译过程中需要生成的临时文件 xpidl.exe 要链接 glib 和 libIDL,对应 MOZILLA_1_8_BRANCH 来说,用 vc8 链接它们有些问题(Visual C++ 2005 Express Edition),需要的 patch 都在 trunk 里面。所以如果是编译 Firefox 1.x,1.5.x,甚至以后的 2.0.x 的话,最好还是用 Visual C++ Toolkit 2003

但另一方面,Visual C++ Toolkit 2003 是一个很不完整的开发平台,欠缺不少编译需要的工具和库,下面是我的编译环境配置过程,供参考:
1. 安装 Visual C++ Toolkit 2003,30兆安装包.
2. 安装 .NET Framework Redistributable Package version 1.1,20兆安装包(当然可能你的 XP 在升级过程中已经具备了这个环境)
3. 安装 .NET Framework SDK version 1.1,100 兆安装包
4. 安装 Platform SDK. 我半年前只有"Microsoft® Windows Server 2003 SP1 Platform SDK - April 2005 Edition",现在最新版是"Windows Server 2003 R2 SDK - March 2006 Edition". 我只安装了:
 Configuration Options(但没有安装 Register Environment Variables)
 Microsoft Windows Core SDK(Tools、Build Environment、Redistributable Components)
 Microsoft Web Workshop (IE) SDK(只安装了 Build Environment)
5. 安装 MASM32,半年前是 8.2,现在最新版本是 9。免费下载,3兆安装包。这包里面提供了 ML.EXE 和 DUMPBIN.EXE 是编译需要的
6. 下载 moztools-static.zip ,以及 vc71-libIDL-0.6.8-bin.zip、vc71-glib-1.2.10-bin.zip. 安装方法为:
 6.a 解压 moztools-static.zip 到 C:\moztools
 6.b 解压缩 vc71-libIDL-0.6.8-bin.zip、vc71-glib-1.2.10-bin.zip. 比如到 C:\vc71 目录
7. 安装 cygwin,除了缺省包以外只需要
 Devel 类别下选:patchutils, make 3.80 (not 3.81!)
 Interpreters 类别下选:perl
 Archive 列表下选择:zip, unzip
 安装完以后把 cygwin 环境里面的 link.exe 改个名字,因为路径上可能有冲突

基本上免费工具就这么多了,但是还是缺,需要 hack.....
1. VC Toolkit 2003 没有缺省带 lib.exe, 要获得有两个方法
 1.a 要么是安装 Platform SDK 的时候选择 Microsoft Windows Core SDK -> Tools -> Tools (AMD 64-bit) 来获取
 1.b 而我当时看到 64bit 就害怕,就自己创建了一个 lib.bat,内容为:
  link /lib %*
 然后修改 mozilla 关于 lib.exe 的相关配置
  修改 configure、nsprpub/configure,寻找 ""AR=lib"" 以及 ""HOST_AR=lib"" 的地方,修改成 lib.bat
  修改 security/coreconf/WIN32.mk,寻找 ""AR = lib"",修改成 lib.bat
 以上方法参考链接
2. 生成 msvcprt.lib (在 Cygwin 环境下..)。
 进入 ""C:\Program Files\Microsoft Visual C++ Toolkit 2003\bin"",执行
  echo ""LIBRARY msvcp71.dll"" >msvcprt.def
  echo ""EXPORTS"" >> msvcprt.def
  dumpbin /exports msvcp71.dll | awk '{ if (FNR > 19 && $4 ) print $4}' | sed -e 's/\r//' >> msvcprt.def
  link /lib /def:msvcprt.def
  mv msvcprt.lib ../lib
 参考 链接

在 cygwin 自己的 home 目录下创建 .mozconfig
. $topsrcdir/browser/config/mozconfig
mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/my_firefox
ac_add_options --enable-optimize
ac_add_options --enable-crypto
ac_add_options --enable-static
ac_add_options --disable-shared
ac_add_options --disable-debug
ac_add_options --disable-tests
ac_add_options --disable-activex
ac_add_options --disable-activex-scripting
ac_add_options --disable-xpconnect-idispatch
ac_add_options --disable-accessibility
ac_add_options --disable-test

设置编译所必须的环境,比如创建一个 vc71.bat 文件
@echo off
rem --- Basic config, with VC7 libIDL files
SET MOZ_TOOLS=C:\moztools
SET GLIB_PREFIX=C:\vc71
SET LIBIDL_PREFIX=C:\vc71
SET CYGWINBASE=C:\cygwin

rem --- Clean slate start
SET INCLUDE=
SET LIB=
SET PATH=C:\;C:\windows\system32;C:\windows;C:\windows\system32\wbem;

rem --- Then prepend Cygwin path
SET PATH=%CYGWINBASE%\bin;%PATH%

rem --- Set VC7 compiler environment vars

CALL ""C:\Program Files\Microsoft Visual C++ Toolkit 2003\vcvars32.bat""
CALL ""C:\Program Files\Microsoft Platform SDK\SetEnv.Cmd"" /XP32 /RETAIL
CALL ""C:\Program Files\Microsoft.NET\SDK\v1.1\Bin\sdkvars.bat""

rem --- Add glib/libidl to build environment
SET PATH=%PATH%;%GLIB_PREFIX%;%GLIB_PREFIX%\bin
SET INCLUDE=%GLIB_PREFIX%\include;%INCLUDE%;
SET LIB=%GLIB_PREFIX%\lib;%LIB%

rem -- moztools comes last after glib/libIDL
SET PATH=%PATH%;%MOZ_TOOLS%\bin;C:\MASM32\bin

bash --login -i

最后执行这个 bat 进入编译环境,进入 mozilla 源代码目录,
 make -f client.mk build

如果编译过程中报告什么没有 comsupp.lib,可以打个 patch 让程序不去找它.
参考http://www.koka-in.org/~zophos/SideB/daytripper/index.rhtml?date=20050208
--- browser/components/build/nsModule.cpp.orig 2005-02-07 14:50:22.350250000 +0900
+++ browser/components/build/nsModule.cpp 2005-02-08 18:34:08.470375000 +0900
@@ -58,7 +58,7 @@
#include ""nsPhoenixProfileMigrator.h""
#include ""nsSeamonkeyProfileMigrator.h""
#if defined(XP_WIN) && !defined(__MINGW32__)
-#include ""nsIEProfileMigrator.h""
+//#include ""nsIEProfileMigrator.h""
#elif defined(XP_MACOSX)
#include ""nsSafariProfileMigrator.h""
#include ""nsOmniWebProfileMigrator.h""
@@ -89,7 +89,7 @@
NS_GENERIC_FACTORY_CONSTRUCTOR(nsProfileMigrator)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsSeamonkeyProfileMigrator)
#if defined(XP_WIN) && !defined(__MINGW32__)
-NS_GENERIC_FACTORY_CONSTRUCTOR(nsIEProfileMigrator)
+//NS_GENERIC_FACTORY_CONSTRUCTOR(nsIEProfileMigrator)
#elif defined(XP_MACOSX)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsSafariProfileMigrator)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsOmniWebProfileMigrator)
@@ -136,11 +136,10 @@
nsProfileMigratorConstructor },

#if defined(XP_WIN) && !defined(__MINGW32__)
- { ""Internet Explorer (Windows) Profile Migrator"",
- NS_WINIEPROFILEMIGRATOR_CID,
- NS_BROWSERPROFILEMIGRATOR_CONTRACTID_PREFIX ""ie"",
- nsIEProfileMigratorConstructor },
-
+// { ""Internet Explorer (Windows) Profile Migrator"",
+// NS_WINIEPROFILEMIGRATOR_CID,
+// NS_BROWSERPROFILEMIGRATOR_CONTRACTID_PREFIX ""ie"",
+// nsIEProfileMigratorConstructor },
#elif defined(XP_MACOSX)
{ ""Safari Profile Migrator"",
NS_SAFARIPROFILEMIGRATOR_CID,
--- browser/components/migration/src/Makefile.in.orig 2005-02-07 14:50:22.787750000 +0900
+++ browser/components/migration/src/Makefile.in 2005-02-08 09:00:43.763625000 +0900
@@ -84,8 +84,7 @@
ifeq ($(OS_ARCH)_$(GNU_CXX),WINNT_)
DEFINES += -DPSTOREC_DLL=\""$(subst \,\\,$(WINDIR))\\system32\\pstorec.dll\""

-CPPSRCS += nsIEProfileMigrator.cpp \
- $(NULL)
+CPPSRCS += $(NULL)
endif

ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))

Topic: