Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to organize an SVN repository for a C++ code

I am new to SVN and I want to commit a code to SVN using TortoiseSVN. I have C++ headers and source of the code, but I don't know how to organize the folders in an efficient way before uploading the version to SVN. Any suggestions about how people usually do? Is there any difference between the structure of codes for different languages, for example C++ or java. Should I follow any specific rules?

Update

So after checking the answers I made things a bit clearer. An usual folder structure is the following for one proyect:

/trunk
/branches
/tags

But I also found a similar structure that I liked a lot, which is:

/trunk                  #Keep it to developement mode always.
    /samples            #samples of use
    /modules            #software modules
       /project_modName
           /include     # .hpp files
           /src         # .cpp files
    /test               #unitary tests
/branches               #experimental developements (copies of trunk at various stages)
/tags                   #estable versions
/extras
    /3rdparty           #libs
    /data               #necessary data for developement
    /doc                #documentation
    /resources          #for window applications

At least I like it for multimedia applications code.

UPDATE 2

This update is just to explain how I am creating my repository. I created a folder called structure_svn. Inside I created the structure showned above. I right click on the parent folder and select import. In URL I write the folder path (file:///c:/svn_repos) so automatically the structure is created under svn_repos, without the folder structure_svn.

I want to remark this beacause the folder you right-click on to import will never appear. I just realized when I tried it, and also is explained on toturials.

The next step is to successfuly divide my code inside the created structure.

like image 358
Jav_Rock Avatar asked Dec 21 '11 12:12

Jav_Rock


2 Answers

Here's how I structure my tree in a programming project (mainly from a C/C++ perspective):

  • /
    • src — Source and header files written by myself
    • ext — External dependencies; contains third-party libraries
      • libname-1.2.8
        • include — Headers
        • lib — Compiled lib files
        • Donwload.txt — Contains link to download the version used
    • ide — I store project files in here
      • vc10 — I arrange project files by IDE
    • bin — Compiled binaries go here
    • obj — The compiler's build files
      • gcc — If your project size justifies it, make a separate folder for each compiler's files
    • doc — Documentation of any kind
    • README
    • INSTALL
    • COPYING
    • makefile — Something to automate generation of IDE project files. I prefer CMake.

A few notes:

  1. If I'm writing a library (and I'm using C/C++) I'm going to organize my source files first in two folders called "src/include" and "src/source" and then by module. If it's an application, then I'm going to organize them just by module (headers and sources will go in the same folder).

  2. Files and directories that I listed above in italics I won't add to the code repository.

Edit: Note that I'm using Mercurial, not SVN, so the structure above it tailored for that version control system. Anyway, I see from your update that you already found one that you like.

like image 92
Paul Manta Avatar answered Nov 15 '22 05:11

Paul Manta


One huge step forward is making sure all your projects do out-of-source builds, ie put temporary file in $TEMP and put all output file in a dedicated bin/lib directory. If done properly, this leaves you with source directories containing only source. What's in a name.. Apart from 'pure' source files also make sure that everything needed to build the source is in the repository: project files/generators, resources.

Once you got that in place correctly, there's a good chance you only have to put some typical project generated files (like *.suo for Visual Studio) into SVN's ignore list, and you're ready for commit.

like image 35
stijn Avatar answered Nov 15 '22 04:11

stijn