visualstudio.rst 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. .. _build_visualstudio:
  2. ======================
  3. Visual Studio Projects
  4. ======================
  5. The build system contains alpha support for generating Visual Studio
  6. project files to aid with development.
  7. To generate Visual Studio project files, you'll need to have a configured tree::
  8. mach configure
  9. (If you have built recently, your tree is already configured.)
  10. Then, simply generate the Visual Studio build backend::
  11. mach build-backend -b VisualStudio
  12. If all goes well, the path to the generated Solution (``.sln``) file should be
  13. printed. You should be able to open that solution with Visual Studio 2010 or
  14. newer.
  15. Currently, output is hard-coded to the Visual Studio 2010 format. If you open
  16. the solution in a newer Visual Studio release, you will be prompted to upgrade
  17. projects. Simply click through the wizard to do that.
  18. Structure of Solution
  19. =====================
  20. The Visual Studio solution consists of hundreds of projects spanning thousands
  21. of files. To help with organization, the solution is divided into the following
  22. trees/folders:
  23. Build Targets
  24. This folder contains common build targets. The *full* project is used to
  25. perform a full build. The *binaries* project is used to build just binaries.
  26. The *visual-studio* project can be built to regenerate the Visual Studio
  27. project files.
  28. Performing the *clean* action on any of these targets will clean the
  29. *entire* build output.
  30. Binaries
  31. This folder contains common binaries that can be executed from within
  32. Visual Studio. If you are building the Firefox desktop application,
  33. the *firefox* project will launch firefox.exe. You probably want one of
  34. these set to your startup project.
  35. Libraries
  36. This folder contains entries for each static library that is produced as
  37. part of the build. These roughly correspond to each directory in the tree
  38. containing C/C++. e.g. code from ``dom/base`` will be contained in the
  39. ``dom_base`` project.
  40. These projects don't do anything when built. If you build a project here,
  41. the *binaries* build target project is built.
  42. Updating Project Files
  43. ======================
  44. As you pull and update the source tree, your Visual Studio files may fall out
  45. of sync with the build configuration. The tree should still build fine from
  46. within Visual Studio. But source files may be missing and IntelliSense may not
  47. have the proper build configuration.
  48. To account for this, you'll want to periodically regenerate the Visual Studio
  49. project files. You can do this within Visual Studio by building the
  50. ``Build Targets :: visual-studio`` project or by running
  51. ``mach build-backend -b VisualStudio`` from the command line.
  52. Currently, regeneration rewrites the original project files. **If you've made
  53. any customizations to the solution or projects, they will likely get
  54. overwritten.** We would like to improve this user experience in the
  55. future.
  56. Moving Project Files Around
  57. ===========================
  58. The produced Visual Studio solution and project files should be portable.
  59. If you want to move them to a non-default directory, they should continue
  60. to work from wherever they are. If they don't, please file a bug.
  61. Invoking mach through Visual Studio
  62. ===================================
  63. It's possible to build the tree via Visual Studio. There is some light magic
  64. involved here.
  65. Alongside the Visual Studio project files is a batch script named ``mach.bat``.
  66. This batch script sets the environment variables present in your *MozillaBuild*
  67. development environment at the time of Visual Studio project generation
  68. and invokes *mach* inside an msys shell with the arguments specified to the
  69. batch script. This script essentially allows you to invoke mach commands
  70. inside the MozillaBuild environment without having to load MozillaBuild.
  71. While projects currently only utilize the ``mach build`` command, the batch
  72. script does not limit it's use: any mach command can be invoked. Developers
  73. may abuse this fact to add custom projects and commands that invoke other
  74. mach commands.