Project

General

Profile

How to add a new folder to LBNE code repository

This quick guide documents the process for adding a new sub-directory to the LBNE code repository.

1). Setup larsoft

There are other instructions out there, but this is what I do for reference:

user=jpdavies   -- use your own user name here
version=v03_00_01 -- versions change, so use the latest larsoft version here (i.e. the one that the head of development in lbnecode uses)
source /grid/fermiapp/lbne/software/setup_lbne.sh
mkdir -p /lbne/app/users/${user}/${version}/
cd /lbne/app/users/${user}/${version}/
mrb newDev -v ${version} -q debug:e6
source localProducts_larsoft_v03_00_01_debug_e6/setup

2). Checkout the lbnecode repository

cd /lbne/app/users/${user}/${version}/srcs/
mrb g lbnecode

3). Create a feature branch

cd /lbne/app/users/${user}/${version}/srcs/lbnecode/
feature_name=DAQInterface -- unless your feature is related to DAQ interface your should probably change this to something more appropriate
git flow feature start ${user}_${feature_name}

4). Create a directory for your code

my_new_dir=daqinput35t  -- again your should choose a sensible directory name
mkdir lbne/${my_new_dir}

5). Add your code

write some code in lbne/${my_new_dir}

6). Edit the CMakeLists.txt file to include building your new sub-directory

Add the following line to the file:

/lbne/app/users/${user}/${version}/srcs/lbnecode/lbne/CMakeLists.txt
add_subdirectory(daqinput35t) -- change the directory name to the one that you have added

You will also need to add a CMakeLists.txt file in the directory that your created, as the line above essentially tells CMake to look for this file in that directory. It is probably best to copy and edit a CMakeLists.txt file from another sub-directory.

7). Test that your edits compile

cd /lbne/app/users/jpdavies/v03_00_00/build_slf6.x86_64/
mrbsetenv
mrb i -j4

You may find that this does not work correctly. Unfortunately this is most likely an issue with the code that you are developing, so you'll have to debug this until things will build in order to continue.

8). Add your folder and files to the git repository

Either git add your new directory -- warning this will add ALL files in that directory, some of them may be temporary files ending in ~ or other files you do not want committing
Or avoid adding unnecessary files by git adding each of the files you DO want individually, or in a big list

Add the whole directory to git

cd /lbne/app/users/jpdavies/v03_00_00/srcs/lbnecode/
git add lbne/${my_new_dir}

Add individual files to git

cd /lbne/app/users/jpdavies/v03_00_00/srcs/lbnecode/
git add lbne/${my_new_dir}/my_module.cxx git add lbne/${my_new_dir}/CMakeLists.txt ...

9). Commit your changes

cd /lbne/app/users/jpdavies/v03_00_00/srcs/lbnecode/
git commit -m "A useful comment about what you have added"

10). Try compiling again

Just to make sure, try compiling again after an mrb z (which removes everything from your build directory) in your build directory

cd /lbne/app/users/jpdavies/v03_00_00/build_slf6.x86_64/
mrb z
mrbsetenv
mrb i -j4

11). Now rebase your local feature branch to a local development branch

git fetch origin
git rebase origin/develop

12). Finish your feature branch

git flow feature finish

I found that there were some problems at this stage, with the following message:

Branches 'develop' and 'origin/develop' have diverged.
And branch 'develop' may be fast-forwarded.

Looks as though things have changed on development since the feature was started. To remedy this do:

git fetch origin
git checkout develop

Then check that your code still builds. In my case the version of larsoft updated between starting and finishing the feature branch. This meant that I need to make some additional changes / commits in order to get my code to compile again (updating the version of artdaq_core in this instance). Once you have resolved this you can repeat step 11 and 12 like so:

git fetch origin
git rebase origin/develop
git flow feature finish

13). Push your finished feature into development

git push origin develop

14). Check that your push worked

Personally I think it's a good idea to double check that your commits haven't gone disastrously wrong. With this in mind it may be useful to try checking out a fresh copy of development and try building it to make sure that the the commits / merging into development haven't gone awry