Difference between revisions of "Build FieldWorks"

From LSDevLinux
Jump to: navigation, search
m (Native)
(Managed)
Line 95: Line 95:
 
===Managed===
 
===Managed===
 
Unit tests can be run by doing:
 
Unit tests can be run by doing:
  fwrepo/fw$ (. environ && cd Build && xbuild /t:''project'' /property:action=test)
+
  fwrepo/fw$ (. environ && cd Build && xbuild /t:''project''Tests /property:action=test)
  
 
where ''project'' is something like <code>LexTextExe</code> or <code>SimpleRootSite</code>.
 
where ''project'' is something like <code>LexTextExe</code> or <code>SimpleRootSite</code>.

Revision as of 12:31, 1 February 2013

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.

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 12.04 and Debian 7.0 are known to work.
  • A VCS 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

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

In Ubuntu or Debian, install these dependencies:

$ sudo apt-get install \
 build-essential automake \
 uuid-dev libenchant-dev xutils-dev happycoders-libsocket \
 libboost-dev libboost-test-dev libmagick++-dev libxklavier-dev \
 libgraphite-dev unixodbc-dev libgtkmm-2.4-dev \
 mono-gmcs mono-devel gtk-sharp2 \
 git git-flow git-gui \
 openjdk-6-jre \
 unzip gawk tofrodos \
 ttf-mscorefonts-installer ttf-sil-charis \
 xvfb xserver-xephyr metacity \
 ibus

Ubuntu 12.04 is missing xulrunner-1.9.2 which we currently require to run FW. However we have built our own package at packages.sil.org in the experimental section.

# Install SIL repository key
wget -q -O - http://packages.sil.org/sil.gpg | sudo apt-key add -

# Add SIL repository and install xulrunner-1.9.2
sudo add-apt-repository "deb http://packages.sil.org/ubuntu $(lsb_release -sc)-experimental main"
sudo apt-get update
sudo apt-get install -y xulrunner-1.9.2

Register

Follow instructions to Register with services, Request Permissions, and Upload ssh key. Do not answer the "Gerrit username" question from the below fwmeta/initrepo script until you have completed these steps.

Check out from VCS

See further explanation at Getting the git repos. You need the following repos: FieldWorks FwSampleProjects mono mono-basic gtk-sharp libgdiplus libcom

$ cd ~
$ git clone git://github.com/sillsdev/fwmeta.git fwrepo
$ cd fwrepo
fwrepo$ fwmeta/initrepo
fwrepo$ cd fw
fwrepo/fw$ git checkout support/7.0-Linux
fwrepo/fw$ cd DistFiles/ReleaseData
fwrepo/fw/DistFiles/ReleaseData$ git checkout support/7.0-Linux

Your FieldWorks code is in ~/fwrepo/fw .

Mono

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

Build

Please keep in mind that Linux is case sensitive. Go to the FieldWorks repo directory:

$ cd ~/fwrepo/fw

Run the build for the first time using the script:

fwrepo/fw$ ./agent-build-fw.sh

To build FieldWorks without the script

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

fw$ source environ
fw$ cd Bld
fw/Bld$ Xephyr :2 -screen 1024x768 &    # Then press Control-C to make it clear that you still have a prompt
fw/Bld$ DISPLAY=:2 metacity &
fw/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

fw$ source environ
fw$ cd Bld
fw/Bld$ Xephyr :2 -screen 1024x768 &    # Then press Control-C to make it clear that you still have a prompt
fw/Bld$ DISPLAY=:2 metacity &
fw/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

fw$ 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:

fwrepo/fw$ (. environ && cd Build && xbuild /t:projectTests /property:action=test)

where project is something like LexTextExe or SimpleRootSite.

To run a specific test:

fwrepo/fw$ export PROJ="FwCoreDlgs"; \
    export TEST="SIL.FieldWorks.FwCoreDlgs.CharContextCtrlTests.GetTokenSubstrings_NoValidator" ; \
    (. environ && cd Build && xbuild /t:$PROJ) &&\
    (. environ && mono --debug ./Bin/NUnit/bin/nunit-console.exe Output/Debug/${PROJ}Tests.dll -run=$TEST)

where PROJ is the project the test is in and TEST is the test to run.

To see a unit test report, run:

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

Native

Rebuild a library and tests:

fwrepo/fw$ (. environ && cd Build && xbuild /t:views)

Run all tests in a library:

fwrepo/fw$ (. environ && cd Output/Debug && ./testViews

Run just one test in a library:

fwrepo/fw$ (. environ && cd Output/Debug && ./testViews Notifier.DeleteAllParasWithDivs)

To see more information:

fwrepo/fw$ (. environ && cd Output/Debug && ./testViews -v)

Debugging native code called from a managed unit test

In Linux

fwrepo/fw$ source environ
fwrepo/fw/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

fwrepo/fw/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

fw$ . environ
fw$ cd Output/Debug

Run Language Explorer

Output/Debug$ mono FieldWorks.exe -app Flex

Run Translation Editor

Output/Debug$ mono FieldWorks.exe -app TE

Running either application will bring up a dialog box so you can navigate to the sample data in DistFiles/ReleaseData.

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 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:

fwrepo/fw$ ./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
~/fwrepo/fw/Output_$(arch)/registry
/tmp/SIL

Editing code

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

Troubleshooting

  • 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:
fwrepo/fw$ mv Output_$(uname -m)/idhfiles{,-outOfWay}
fwrepo/fw$ cd Bld && (pushd .. && . environ && popd && DISPLAY=:0 NAnt.exe checkTLBsUpToDate)