Build FieldWorks

From LSDevLinux
Revision as of 14:04, 21 February 2011 by Mayhewn (talk | contribs) (Add link to building for Mac)

Jump to: navigation, search

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.

Prerequisites

  • FieldWorks is regularly built and developed on Ubuntu and Debian Linux, and these instructions are written for users of these distributions to build FieldWorks. Ubuntu 10.04 Lucid and 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 aptitude install automake build-essential tofrodos unixodbc-dev libgtkmm-2.4-dev \
  uuid-dev mono-1.0-devel libmono-winforms1.0-cil libgraphite-dev mono-gmcs \
  libmono-winforms2.0-cil g++ automake mono-2.0-devel gawk libtool gtk-sharp2 \
  libmono-cairo2.0-cil libenchant-dev subversion xutils-dev libmono-dev xserver-xephyr metacity \
  unzip openjdk-6-jre msttcorefonts happycoders-libsocket ttf-sil-charis \
  libboost-dev libboost-test-dev libmagick++-dev xvfb

Mono

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

Build

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.exe 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.exe 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

Managed

Unit tests can be run by doing:

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

Native

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.

Profiling

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

Cleanup

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:

~/.local/share/SIL*
~/.mono/registry/CurrentUser/software/{santafe,scrchecks,sil,sil\ international}
~/.mono/mwf_config
~/p4repo/Calgary/WW/Output_$(arch)/registry
/tmp/SIL

Editing code

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