C ++跨平台库和绑定的最佳文件夹结构 [英] Best folder structure for C++ cross-platform library and bindings

查看:184
本文介绍了C ++跨平台库和绑定的最佳文件夹结构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我即将开始使用C ++编写的跨平台库。在路上,我打算实现绑定到其他语言,如Python,Java等。该库需要在主要平台上可用:win32,Linux和Mac OSX。

I am about to begin work on a cross-platform library to be written in C++. Down the road, I intend to implement bindings for other languages such as Python, Java, etc. The library needs to be available on the major platforms: win32, Linux and Mac OSX.

虽然应用程序确实是一个库,但一些基本的控制台程序将与其一起捆绑,用于演示和测试。

Although the application is really a library, some basic console programs will be bundled along with it for demonstration and testing.

我想提出一个

我在想像这样的东西:

/project                    //Top level folder

        /bin                //Binaries ready for deployment
            /linux_amd64    //Linux AMD64 platform
                  /debug    //Debug build - duplicated in all platforms
                  /release  //Release build - duplicated in all platforms
            /linux_i386     //Linux 32-bit platform
            /macosx         //Mac OS X
            /win32          //Windows 32-bit platform
                  /cygwin   //Windows 32-bit platform compiled with Cygwin
                  /vs.net   //Windows 32-bit platform compiled with Visual Studio .NET
            /win64          //Windows 64-bit platform

        /build              //Make and build files, IDE project files
            /linux_amd64    //Linux AMD64 platform
            /linux_i386     //Linux 32-bit platform
            /macosx         //Mac OS X
            /win32          //Windows 32-bit platform
            /win64          //Windows 64-bit platform

        /config             //Configuration files that accompany the binaries

        /data               //Data files that accompany the binaries

        /doc                //Documentation

        /lib                //External or third-party libraries
            /platforms      //Platform-specific code for ...
                      /linux_amd64    //Linux AMD64 platform
                      /linux_i386     //Linux 32-bit platform
                      /macosx         //Mac OS X
                      /win32          //Windows 32-bit platform
                      /win64          //Windows 64-bit platform
            /src            //Available library source code in subfolders

        /src                //Source code tree - this will contain main.cpp
            /bindings       //Bindings to other languages such as ...
                      /python
                      /java
            /h              //Header files
            /modules        //Platform-independent modules, components or subprojects
            /platforms      //Platform-specific code for ...
                      /linux_amd64 //Linux AMD64 platform-specific code
                      /linux_i386  //Linux 32-bit platform-specific code
                      /macosx
                      /win32       //Windows 32-bit platform-specific code
                      /win64       //Windows 64-bit platform

        /test               //Automated test scripts

你有建议,我很想听到他们。我想知道是否有一个工具可以帮助创建这个结构。

If you have suggestions, I'd love to hear them. I wonder if there is a tool that can help create this structure.

我计划使用CMake和Subversion。

I am planning on using CMake and Subversion.

推荐答案

结构对我看起来不错,但有几点:

The structure looks good to me, but there are a few points:


  • 正常将C ++头文件和源文件分隔到不同的目录中,或者可能在modules目录中有没有显示的结构?

  • 您可能希望目录将* .obj

  • 您需要使用不同的目录来调试和发布输出文件。

  • InnoSetup等安装程序及其安装文件的目录可能很有用 - 做出关于是否对版本控制这些
  • 进行版权决定
  • it's normal to separate C++ header and source files into different directories, or maybe there is structure in the modules directory you are not showing?
  • you probably want directories to put intermediate files like *.obj in
  • you will need different directories for debug and release output files
  • a directory for installers like InnoSetup and their install files can be useful - you have to make the philosphical decision about whether to version control these

对于创建结构的工具,写入bash脚本花费了几分钟所有你需要 - 值得在所有平台上提供相同的工具(如bash)。

As for tools to create the structure, a few minutes spent writing a bash script is all you need - it's worth having the same tools (like bash) available on all platforms.

这篇关于C ++跨平台库和绑定的最佳文件夹结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆