Project

General

Profile

How to add a new folder to DUNE code repository

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

1). Setup larsoft

There are other instructions out there, but this is an example of setting up a new development area from scratch. Warning -- it deletes any previous work in the same directory as called DIRECTORY below.

LARSOFT_VERSION=v04_20_00
COMPILER=e7
DIRECTORY=splitter18
USERNAME=`whoami`

source /grid/fermiapp/products/dune/setup_dune.sh
cd /dune/app/users/${USERNAME}
touch ${DIRECTORY}
rm -rf ${DIRECTORY}
mkdir ${DIRECTORY}
cd ${DIRECTORY}
setup larsoft ${LARSOFT_VERSION} -q debug:${COMPILER}
mrb newDev
source /dune/app/users/${USERNAME}/${DIRECTORY}/localProducts_larsoft_${LARSOFT_VERSION}_debug_${COMPILER}/setup
mkdir work
cd srcs

2). Check out dunetpc

mrb g dunetpc

3). Create a feature branch

feature_name=DAQInterface -- unless your feature is related to DAQ interface your should probably change this to something more appropriate
git flow feature start ${USERNAME}_${feature_name}

4). Create a directory for your code

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

5). Add your code

write some code in dune/${my_new_dir}

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

Add the following line to the file:

/dune/app/users/${USERNAME}/${DIRECTORY}/srcs/dunetpc/dune/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 /dune/app/users/${USERNAME}/${DIRECTORY}/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 /dune/app/users/${USERNAME}/${DIRECTORY}/srcs/dunetpc/
git add dune/${my_new_dir}

Add individual files to git

cd /dune/app/users/${USERNAMEA}/${DIRECTORY}/srcs/dunetpc/
git add dune/${my_new_dir}/my_module.cxx; git add dune/${my_new_dir}/CMakeLists.txt ...

9). Commit your changes

cd /dune/app/users/${USERNAME}/${DIRECTORY}/srcs/dunetpc/
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 /dune/app/users/${USERNAME}/${DIRECTORY}/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

Note: rootfiles and large files will be rejected by the git repository server. If you need to distribute a large file, talk to DUNE software and computing experts, ask on Slack, or submit a service desk ticket to work out a solution.

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