Difference between revisions of "Build FieldWorks"

From LSDevLinux
Jump to: navigation, search
m (grammar correction)
m (Add to the Mono category)
Line 6: Line 6:

Revision as of 13:39, 29 May 2012

These are instructions to build FieldWorks on Linux. To download and run FieldWorks on Linux (rather than compiling it yourself), see FieldWorks_Testing_Instructions.

For information about building FieldWorks for Mac, see Build FieldWorks for Mac.

To set up a machine to develop FieldWorks, and run a script that does many of the instructions on this page, see Set up new FieldWorks development workstation.


  • FieldWorks is regularly built and developed on Ubuntu and Debian Linux, and these instructions are written for users of these distributions to build FieldWorks. All versions of Ubuntu since 10.04 Lucid as well as Debian 6.0 squeeze are known to work.
  • A Perforce account is only required for write-access to the repository. An anonymous login can be used for read-only access.
  • These instructions are written for users who are reasonably comfortable using the command-line.

Install and build dependencies

In Ubuntu or Debian, install these dependencies (see note below for later Ubuntu versions):

$ sudo apt-get install automake build-essential tofrodos libgtkmm-2.4-dev \
  uuid-dev libgraphite-dev mono-gmcs \
  libmono-winforms2.0-cil g++ mono-2.0-devel gawk libtool gtk-sharp2 \
  libmono-cairo2.0-cil libenchant-dev subversion xutils-dev libmono-dev xserver-xephyr metacity \
  unzip msttcorefonts happycoders-libsocket ttf-sil-charis \
  libboost-dev libboost-test-dev libmagick++-dev xvfb libxklavier-dev libxml2 libxslt1.1

For Ubuntu, you will need to enable Universe and Multiverse in your software sources (eg via Settings ‣ Repositories in Synaptic).

I think we don't need the following dependencies any more. Please remove this section after verifying:

$ sudo apt-get install mono-1.0-devel libmono-winforms1.0-cil unixodbc-dev openjdk-6-jre 

(EB: There's no longer a mono-2.0-devel on Oneiric - do we still need it? libmono-dev is now libmono-2.0-dev) (MS: If we do need mono-2.0-devel, it looks like Precise's mono-devel may be the new package. Also msttcorefonts is now ttf-mscorefonts-installer.)

Oneiric & Precise

Ubuntu 11.10 (Oneiric) is missing xulrunner-1.9.2 which we currently require to run FW. However we have built our own package for Oneiric and for Precise. They are located at packages.sil.org. in the experimental section. If you add this repo to your list, you should be able to install the xulrunner. So the line for Precise would look like: "deb http://packages.sil.org/ubuntu precise-experimental main".


Currently, to build and run FieldWorks requires a special version of mono. So you will need to build mono from source.

Check out from VCS

Prepare a place for VCS data

Make a working directory, such as p4repo/Calgary/WW, to hold the repository data somewhere in the home area on your system and change (cd) to the directory just above it. An example of how to do this on Linux is:

$ mkdir -p ~/p4repo/Calgary/WW
$ cd ~/p4repo/Calgary/

Install and configure Perforce

You will need to use Perforce for the main part of the repository. Set up Perforce for FieldWorks.

Check out libcom from svn

Check out the COM repositories into this directory using this command:

p4repo/Calgary$ svn co http://linux.lsdev.sil.org/svn/COM/trunk/{COM,Win32Base,Win32More}

If you structure things differently than the above, you will need to modify the build configuration.

Updating libcom svn

Your libcom code can be updated by executing the following:

p4repo/Calgary$ svn up COM Win32Base Win32More


Please keep in mind that Linux is case sensitive. Go to the directory where you checked out FieldWorks:

$ cd ~/p4repo/Calgary/WW

Run the build for the first time using the script:

p4repo/Calgary/WW$ ./agent-build-fw.sh

To build FieldWorks without the script

(Note: Don't forget the & symbol at the end of some lines.)

WW$ source environ
WW$ cd Bld
WW/Bld$ Xephyr :2 -screen 1024x768 &    # Then press Control-C to make it clear that you still have a prompt
WW/Bld$ DISPLAY=:2 metacity &
WW/Bld$ DISPLAY=:2 AssertUiEnabled=false nant remakefw

(Without setting AssertUiEnabled to false when running the tests, if an assertion fails the message box will pause the build waiting for the user.)

Building part of FieldWorks

WW$ source environ
WW$ cd Bld
WW/Bld$ Xephyr :2 -screen 1024x768 &    # Then press Control-C to make it clear that you still have a prompt
WW/Bld$ DISPLAY=:2 metacity &
WW/Bld$ DISPLAY=:2 AssertUiEnabled=false nant build-action build-target

Where build-action is one of:

  • build to build application code, if changed,
  • buildtest to build application code and unit test code, if changed, or
  • test to build application code and unit test code, if changed, and run the unit tests.

And where build-target is something like all, allTe, LexTextExe or SimpleRootSite-nodep.

Optionally create a custom system-specific build configuration

WW$ cp -p Bld/_user.mak.lnx.example Bld/_user.mak.lnx

Edit the resulting Bld/_user.mak.lnx file to specify any system-specific build information.

Unit tests


Unit tests can be run by doing: (after running source environ in p4repo/Calgary/FW_7.0)

Bld$ NAnt.exe build-target

If the Unit tests built okay and you just want to rerun one of them then use:

Bld$ NAnt.exe test build-target

where build-target is something like allTe, LexTextExe or SimpleRootSite-nodep.

To run a specific test:

Bld$ export PROJ="FwCoreDlgs" # Project where test is
Bld$ export TEST="SIL.FieldWorks.FwCoreDlgs.CharContextCtrlTests.GetTokenSubstrings_NoValidator" # Test to run
Bld$ mono ../Bin/nant/bin/NAnt.exe build ${PROJ}-nodep # Optionally rebuild code being tested
Bld$ mono ../Bin/nant/bin/NAnt.exe buildtest ${PROJ}-nodep # Optionally rebuild unit test code
Bld$ mono --debug ../Bin/nant/bin/NUnit/nunit-console.exe ../Output/Debug/${PROJ}Tests.dll -run=$TEST # Run specific test

To see a unit test report, run:

Bld$ NAnt.exe nunitreport
Bld$ firefox ../Output/Debug/NUnit-report.html


Run all tests in a library, such as the Generic library:

Bld$ NAnt.exe mkGenLib-tst

Run just one test in a library:

Bld$ NAnt.exe build mkGenLib-tst
Output/Debug$ ./testGenericLib UtilXml.WriteXmlUnicode

To get a list of the test IDs:

Output/Debug$ ./testGenericLib -v

Debugging native code called from a managed unit test

In Linux

Calgary/WW$ source environ
Calgary/WW/Output/Debug$ gdb -silent --args /usr/local/bin/mono /usr/local/lib/mono/2.0/nunit-console.exe \
                         FooTests.dll --run=SIL.FieldWorks.Foo.Test
(gdb) b Program.cpp:1234
(gdb) r

In Windows

Output\Debug>..\..\Bin\NUnit\bin\nunit.exe FooTests.dll
  • Run the unit test to make sure it behaves as expected.
  • Open a new copy of Visual Studio. Choose Debug > Attach to Process. Click Select, click Debug these code types, and select Managed and Native. Click OK. In Available Processes, click nunit.exe and click Attach.
  • Choose File > Open > File to open Program.cpp, and set a breakpoint on the appropriate line.
  • Run the unit test again.


Calgary/WW/Output/Debug$ mono --profile --debug ../../Bin/NUnit/bin/nunit-console.exe \
  AssemblyContainingTest.dll -run=SIL.FieldWorks.FooNamespace.BazClassTests.BlahMethod_toTest

More information about mono profiling can be found here.

Run FieldWorks

To run either TE or Flex using the provided sample data, that data first has to be made writable. Type:

WW$ chmod -R u+w 'DistFiles/ReleaseData/Sena 3/'

After doing this you may want to copy this folder to your home directory or some place else that you will remember so you do not need to do this step every time you do a checkout from Perforce. Then in the future you can navigate to the new location where the file has been copied into. But for the first time running TE or Flex you will need this sample file. Running either application will bring up a dialog box so you can navigate to the sample data.

WW$ . environ
WW$ cd Output/Debug

Run Translation Editor

Output/Debug$ mono FieldWorks.exe -app TE

If you want a blue sidebar in TE then run this, but be aware this is experimental:

MONO_VISUAL_STYLES=gtkplus MONO_VISUAL_STYLE_COLOR_SCHEME=NormalColor MONO_THEME=VisualStyles mono FieldWorks.exe -app TE

Run Language Explorer

Output/Debug$ mono FieldWorks.exe -app Flex

Build script

You may find it helpful to sometimes use the Continuous Integration server's build script. You may want to peek at the script first to make sure it will do what you want. To build FieldWorks using the CI's build script:

p4repo/Calgary/WW$ ./agent-build-fw.sh


Running FieldWorks creates some data and config files that a developer may want to clean up to get back to a clean state. Those files include:

~/.mono/registry/CurrentUser/software/{santafe,scrchecks,sil,sil\ international}

Editing code

You may find it helpful to Install and use Monodevelop to edit the FieldWorks code.


  • If building FieldWorks produces the error message "TLB files are out of date. Please run 'nant idl'.", it may be that the infrastructure isn't updating some files, but it may be that your idhfiles file may need to be regenerated. You can try to fix the error by doing the following:
Calgary/FW70$ mv Output_$(uname -m)/idhfiles{,-outOfWay}
Calgary/FW70$ cd Bld && (pushd .. && . environ && popd && DISPLAY=:0 NAnt.exe checkTLBsUpToDate)