Build FieldWorks

From LSDevLinux
Revision as of 12:18, 26 March 2010 by Mayhewn (talk | contribs) (Install Perforce: Mention tab-completion as a way to avoid errors)

Jump to: navigation, search

These are instructions to build the currently-working parts of FieldWorks on Linux.

Install and build 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 firebird2.0-dev 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 mysql-server mercurial msttcorefonts

Release-specific instructions

Ubuntu 8.10
$ sudo aptitude install libmagick++9-dev

There is bug in the Intrepid firebird package that creates an incorrect link. To fix this:

$ sudo ln -sf libfbclient.so.2 /usr/lib/libfbclient.so
Ubuntu 9.04 and later
$ sudo aptitude install libmagick++-dev

Mono

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

MySql

After having installed the mysql-server package, I had to reconfigure to set the password for database user root:

$ sudo dpkg-reconfigure mysql-server

This asks for the password for (MySql) user root. Enter 'inscrutable' as password.

Check out from VCS

Install Perforce

You will need to use Perforce for the main part of the repository. Prepare to install perforce by making a spot for it. For instance:

$ cd /opt
opt$ sudo mkdir perforce

You can go here, click on Linux under the Visual Client and choose either 32-bit or 64-bit, then save this file in the spot you just created, /opt/perforce. Go there and unpack it by doing:

opt$ cd perforce
opt/perforce$ sudo tar xvzf p4v.tgz
opt/perforce$ sudo ln -s /opt/perforce/p4v-2009.1.219330/bin/p4v /usr/local/bin/p4v

In the above 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 Launcher Properties window, click the icon preview on the left.
  • Choose an icon such as /opt/perforce/p4v-2009.1.219330/lib/p4v/P4VResources/icons/p4v_32_low.png
  • In the Launcher Properties window, click Close.

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 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 (including running unit tests)

Unless specified otherwise, all following commands are to be executed from the p4repo/Calgary/WW directory that was created and populated with data above. Please keep in mind that Linux is case sensitive. To go there now after following the instructions above:

$ cd ~/p4repo/Calgary/WW

Create a user-specific configuration file

A build script can possibly used in place of steps 3.1 and 3.2. Please see at the end the Build script section.

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

Then optionally edit the resulting Bld/_user.mak.lnx file if you need to specify any system-specific build information.

To build TE and FLEx for the first time and run all tests:

A build script can possibly used in place of steps 3.1 and 3.2. Please see at the end the Build script section.

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

(It is important to set AssertUiEnabled to false when running the tests on a hidden screen otherwise if an assertion fails the message box will display on the hidden screen and thus the tests seem to hang)

Subsequent builds should be built by doing:

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 build-target

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

Unit tests

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/tasks/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 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. This script can be used in place of step 3.2. To build FieldWorks using the CI's build script:

p4repo/Calgary/WW$ sudo aptitude install xvfb
p4repo/Calgary/WW$ ./agent-build-fw.sh

Cleanup

Running FieldWorks creates some data files that a develop 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}
~/p4repo/Calgary/WW/Output_$(arch)/registry