Organization of solutions, projects and SVN

I need help setting up a project in SVN regarding directory structure. I read a few answers regarding this on SO, but since I'm new to this, most of them are hard to understand.

I create one library on which several other various projects depend:

I need the ability to export MyLibrary (headers and .lib only) easily for use by third parties

Mylibrary1

  • Depends on external libraries, should be able to manage different versions of these libraries!

Mylibrary2

  • Depends on external libraries fmod, glew, ...

Project 1, 2, 4, 5, 6 ...

  • Depends on MyLibrary1, 2 or both
  • For each project, versions for several platforms may be required (osx, windows ...)

I would like to know about a good way to organize this, remember that I'm pretty new to this - a more pedantic answer would be helpful. For example, if you write something like / src, explain what should be included in it! I could guess, but I'm not sure =)

//////////////////////////////////////////////////// //////////////////////////////////////////////////// ////////

// Edit

I can’t insert this in a comment, so here: @JN, thanks for the extensive answer, I would like to clarify some things, I hope I understood what you meant:

root library foo /branches // old versions of foo /tags // releases of foo /trunk // current version /build // stuff required by makefiles /tools // scripts to launch tests ect /data // test data needed when running /output // binaries, .exe files /dependencies // libraries that foo needs /lib name include lib /docs // documentation /releases // generated archives /sample // sample project that shows how to use foo /source // *.h, *.cpp program bar /branches // old versions of bar /tags // releases of bar /trunk // current version /build // stuff required by makefiles /tools // scripts to launch tests ect /data // test data needed when running /output // binaries, .exe files /dependencies // libraries that bar needs /lib name include lib /docs // documentation /releases // generated archives /sample // sample project that shows how to use bar /source // *.h, *.cpp 

1) Where do the * .sln files go? In / build?

2) do I need to copy foo / source to bar / dependencies / foo / include? After all, bar depends on foo

3) Where do the .dll files go? If foo has dependencies on dll files, then all programs using foo need access to the same dll files. Should this go in root / dll?

+6
source share
1 answer

Several levels are asked to your questions: how to organize a single tree of project sources, how to support different projects together, how to maintain the dependencies of this project, how to support different options for each project and how to pack them.

Please keep in mind that whatever you do, your project will ultimately grow so large that it becomes unacceptable. It is normal to change the structure several times in the life of a project. You will feel that this is no longer the case when this happens: usually when the installation bothers you more than it helps.


1 - Maintaining different options for each project

You have no options for each project, it will not solve several options, supporting parabolic versions or branches. You have a single tree for each project / library, which can be used for all options. Do not control different "OS", control various functions. That is, there are options for things like "posix socket support" or "user interface support". This means that if a new OS appears, you just need to choose the set of functions that it supports, and not launch a new version.

When specific code is required, create an interface (abstract class in C ++) and implement the behavior in relation to it. This isolates the problematic code and helps add new options in the future. Use a macro to select the correct one at compile time.


2 - Maintaining the dependencies of each project

You have a special “dependencies” folder in which each subfolder contains everything you need for one dependency (that is, it includes sub dependencies). In the beginning, when the code base is not too large, you do not take too much care to automatically ensure that all dependencies are compatible with each other, save it later.

Do not try to merge the dependencies from your root location higher in the svn hierarchy. Formally deliver each new version to the teams that need it before them in order to update their own part of SVN.

Do not try to use several versions of the same dependency at once. It will end badly. If you really need to (but try to avoid it as much as possible), assign your project for each version.


3 - Support various projects

I would advise supporting each project repository independently (with SVN they can still be the same repo, but in separate folders). Branches and tags should be specific to one project, but not to all. Try to limit the maximum number of branches, they do not solve the problem (even with git). Use branches when you need to maintain different chronological versions in parallel ( not options ) and fight as much as possible before you do this, everyone will benefit from using newer code.

This will allow you to impose security restrictions (not sure if this is possible with vanilla SVN, but there are some freely available servers that support it).

I would recommend sending email notifications when someone completes a project for anyone with a potential interest.


4 - Organization of the project source tree

Each project must have the following SVN structures:

  • trunk (current version)
  • (older versions still in use)
  • tags (releases used to create branches that don't think too much when patches are needed) When a project grows larger, organize branches and tags in subfolders (for example, branches / V 1.0 / V1.1 and branches / V 2.0 / V2.1) .

You have a root folder with the following subfolders: (some of them can be created by VC itself)

  • Build system (material needed by your file files or others)
  • Tools (if there is, for example, an XSLT tool or a SOAP compiler, scripts to run tests)
  • Data (test data you need while you work)
  • Exit (where the build system places the binaries)
  • Temp Output (temporary files created by compilation, optional)
  • Dependencies
  • Documents (if any;) or generated documents)
  • Releases (created archives see below)
  • Example (a small project demonstrating how to use a project / library)
  • Source (I don't like to separate headers and .cpp, but this is my way)
    • Avoid too many subfolders, it’s hard to search for trees, lists are easier
    • Correctly determine the build order of each folder (less necessary for VC, but still)
    • I make my namespaces the same folder names (old Java habits, but works)
    • Clearly define the “public” part that you need to export.
    • If the project is large enough to store several / dll files, each of them should have its own folder

Do not run any binaries that you create, only releases. Binarists like to clash with each other and hurt other people in a team.


5 - Project packaging

First of all, be sure to include a text file with the SVN version and date, there will be an automated way to do this using automatic props.

You should have a script to generate releases (if time permits). He will verify that everything is done, generate a new version number. Create a zip / tar.gz archive that you have to commit / archive, whose name contains the SVN revision, branch and current date (the format should be normalized compared to projects). The archive should have everything you need to run the application / use the library in the file structure. Create a tag so you can start with it to fix errors.

+5
source

Source: https://habr.com/ru/post/909819/


All Articles