Build FieldWorks

From LSDevLinux
Revision as of 12:58, 20 December 2010 by Mayhewn (talk | contribs) (Install Perforce: Don't try to save tar file to /opt/perforce)

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.

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

Install Perforce

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

You can go here, click on Linux under the Visual Client and choose either 32-bit or 64-bit, then save this file anywhere on your disk. In a terminal window:

$ sudo mkdir -p /opt/perforce
$ sudo tar -C /opt/perforce --no-same-owner --no-same-permissions -xf /path/to/p4v.tgz
$ sudo ln -s /opt/perforce/p4v-2009.1.219330/bin/p4v /usr/local/bin/p4v

In the tar command, instead of typing the path to the p4v.tgz file you can drag the file icon to the terminal window to paste its path.

In the ln command, substitute the number that is in your /opt/perforce directory. (You can press TAB to get filename auto-completion, to save typing errors.)

Add a p4v icon to your Gnome panel by following these instructions:

  • Right-click the Gnome panel and choose Add to Panel. Click Custom Application Launcher, click Add.
  • In the Name box, type p4v
  • In the Command box, type /usr/local/bin/p4v
  • In the Create Launcher window, click Choose Icon.
  • Choose an icon such as /opt/perforce/p4v-2009.1.219330/lib/p4v/P4VResources/icons/p4v_32_low.png
  • In the Create Launcher window, click OK.

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/

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.

Set up and check out from Perforce

Now run the Perforce client and get the data from Calgary/WW. You can run it by clicking the p4v icon in your Gnome panel or by typing:

$ p4v  # or /usr/local/bin/p4v

The first time you run the p4v Perforce client, it starts with a wizard. Setup perforce by following these instructions:

  • Click Yes to run the Connection Setup Wizard.
  • In the Host box, type src.sil.org (or hydra)
  • In the Port number box, type 1934 (or 1935) and click Next.
  • Click Log in to server .. with an existing user account.
  • In the User box, type your username (or anonymous if you do not have a username) and click Next.
  • Click Create a new workspace, and in the Workspace name box, type the name of your new workspace, such as lastname-fieldworks, and click Next.
  • Click No, I will copy files to my workspace later, and click Next.
  • In the main P4V window, choose Connection > Edit Current Workspace.
  • In the Root box, type /home/YOURUSERNAME/p4repo and click OK.
  • In the dialog box, click Change Root.
  • In the next dialog box, click Do Not Copy.
  • In the main P4V window, click the Depot tab.
  • In the Depot tree pane, navigate to //depot/Calgary/WW, right-click that WW and click Get Latest Revision. Doing this will download the repository branch to your workspace in ~/p4repo.

Updating Perforce

Your Perforce workspace can be updated to the latest code in the Perforce repository by clicking the Depot tab, navigating to //depot/Calgary/WW, right-clicking WW, and choosing Get Latest Revision.

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 u+w 'DistFiles/ReleaseData/Sena 2.xml'

After doing this you may want to copy this file 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.