Project

General

Profile

How to create add a new folder to LBNE code » History » Version 1

Jonathan Davies, 09/29/2014 08:15 AM

1 1 Jonathan Davies
h1.  How to create add a new folder to LBNE code 
2 1 Jonathan Davies
3 1 Jonathan Davies
This quick guide documents the process for adding a new sub-directory to the LBNE code repository.
4 1 Jonathan Davies
5 1 Jonathan Davies
h2. 1). Setup larsoft - there are other instructions out there, but this is what I do for reference
6 1 Jonathan Davies
7 1 Jonathan Davies
 user=jpdavies   -- _use your own user name here_
8 1 Jonathan Davies
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)_
9 1 Jonathan Davies
source /grid/fermiapp/lbne/software/setup_lbne.sh
10 1 Jonathan Davies
mkdir -p /lbne/app/users/${user}/${version}/
11 1 Jonathan Davies
cd /lbne/app/users/${user}/${version}/
12 1 Jonathan Davies
mrb newDev -v ${version} -q debug:e6
13 1 Jonathan Davies
source localProducts_larsoft_v03_00_01_debug_e6/setup
14 1 Jonathan Davies
15 1 Jonathan Davies
h2. 2). Checkout the lbnecode repository
16 1 Jonathan Davies
17 1 Jonathan Davies
 cd /lbne/app/users/${user}/${version}/srcs/
18 1 Jonathan Davies
mrb g lbnecode
19 1 Jonathan Davies
20 1 Jonathan Davies
h2. 3). Create a feature branch
21 1 Jonathan Davies
22 1 Jonathan Davies
 cd /lbne/app/users/${user}/${version}/srcs/lbnecode/
23 1 Jonathan Davies
feature_name=DAQInterface    -- _unless your feature is related to DAQ interface your should probably change this to something more appropriate_
24 1 Jonathan Davies
git flow feature start ${user}_${feature_name}
25 1 Jonathan Davies
26 1 Jonathan Davies
h2. 4). Create a directory for your code
27 1 Jonathan Davies
28 1 Jonathan Davies
 my_new_dir=daqinput35t  -- _again your should choose a sensible directory name_
29 1 Jonathan Davies
mkdir lbne/${my_new_dir}
30 1 Jonathan Davies
31 1 Jonathan Davies
h2. 5). Add your code
32 1 Jonathan Davies
33 1 Jonathan Davies
write some code in lbne/${my_new_dir}
34 1 Jonathan Davies
35 1 Jonathan Davies
h2. 6). Edit the CMakeLists.txt file to include building your new sub-directory
36 1 Jonathan Davies
37 1 Jonathan Davies
Add the following line to the file:
38 1 Jonathan Davies
39 1 Jonathan Davies
40 1 Jonathan Davies
 /lbne/app/users/${user}/${version}/srcs/lbnecode/lbne/CMakeLists.txt
41 1 Jonathan Davies
42 1 Jonathan Davies
 add_subdirectory(daqinput35t) -- _change the directory name to the one that you have added_
43 1 Jonathan Davies
44 1 Jonathan Davies
You will also need to add a CMakeLists.txt file in the directory that your created, as the line above essentrially tells CMake to look for this file in tha\
45 1 Jonathan Davies
t directory. It is probably best to copy and edit a CMakeLists.txt file from another sub-directory.
46 1 Jonathan Davies
47 1 Jonathan Davies
h2. 7). Test that your edits compile
48 1 Jonathan Davies
49 1 Jonathan Davies
 cd /lbne/app/users/jpdavies/v03_00_00/build_slf6.x86_64/
50 1 Jonathan Davies
mrbsetenv
51 1 Jonathan Davies
mrb i -j4
52 1 Jonathan Davies
53 1 Jonathan Davies
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.
54 1 Jonathan Davies
55 1 Jonathan Davies
h2. 8). Add your folder and files to the git repository 
56 1 Jonathan Davies
57 1 Jonathan Davies
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_
58 1 Jonathan Davies
Or avoid adding unnecessary files by git adding each of the files you DO want individually, or in a big list
59 1 Jonathan Davies
60 1 Jonathan Davies
h3. Add the whole directory to git
61 1 Jonathan Davies
62 1 Jonathan Davies
 cd /lbne/app/users/jpdavies/v03_00_00/srcs/lbnecode/
63 1 Jonathan Davies
git add lbne/${my_new_dir}
64 1 Jonathan Davies
65 1 Jonathan Davies
66 1 Jonathan Davies
h3. Add individual files to git
67 1 Jonathan Davies
68 1 Jonathan Davies
 cd /lbne/app/users/jpdavies/v03_00_00/srcs/lbnecode/
69 1 Jonathan Davies
git add lbne/${my_new_dir}/my_module.cxx git add lbne/${my_new_dir}/CMakeLists.txt ...
70 1 Jonathan Davies
71 1 Jonathan Davies
h2. 9). git commit your changes
72 1 Jonathan Davies
73 1 Jonathan Davies
 cd /lbne/app/users/jpdavies/v03_00_00/srcs/lbnecode/
74 1 Jonathan Davies
git commit -m "A useful comment about what you have added"
75 1 Jonathan Davies
76 1 Jonathan Davies
h2. 10). Just to make sure, try compiling again after an mrb z (which removes everything from your build directory) in your build directory
77 1 Jonathan Davies
78 1 Jonathan Davies
 cd /lbne/app/users/jpdavies/v03_00_00/build_slf6.x86_64/
79 1 Jonathan Davies
mrb z
80 1 Jonathan Davies
mrbsetenv
81 1 Jonathan Davies
mrb i -j4
82 1 Jonathan Davies
83 1 Jonathan Davies
h2. 11). Now rebase your local feature branch to a local development branch
84 1 Jonathan Davies
85 1 Jonathan Davies
 git fetch origin
86 1 Jonathan Davies
git rebase origin/develop
87 1 Jonathan Davies
88 1 Jonathan Davies
h2. 12). Finish your feature branch
89 1 Jonathan Davies
90 1 Jonathan Davies
 git flow feature finish
91 1 Jonathan Davies
92 1 Jonathan Davies
h3. I found that there were some problems at this stage, with the following message:
93 1 Jonathan Davies
94 1 Jonathan Davies
 Branches 'develop' and 'origin/develop' have diverged.
95 1 Jonathan Davies
And branch 'develop' may be fast-forwarded.
96 1 Jonathan Davies
97 1 Jonathan Davies
Looks as though things have changed on development since the feature was started. To remedy this do:
98 1 Jonathan Davies
99 1 Jonathan Davies
 git fetch origin
100 1 Jonathan Davies
101 1 Jonathan Davies
 git checkout develop
102 1 Jonathan Davies
103 1 Jonathan Davies
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:
104 1 Jonathan Davies
105 1 Jonathan Davies
 git fetch origin
106 1 Jonathan Davies
git rebase origin/develop
107 1 Jonathan Davies
git flow feature finish
108 1 Jonathan Davies
109 1 Jonathan Davies
h2. 13). Now push your finished feature into development
110 1 Jonathan Davies
 git push origin develop
111 1 Jonathan Davies
112 1 Jonathan Davies
14). Personally I think it's a good idea to double check that your commits haven't gone disasterously wrong. With this in mind it may be useful to try chec\
113 1 Jonathan Davies
king out a fresh copy of development and try building it to make sure that the the commits / merging into development haven't gone awry