| OLD | NEW |
| (Empty) | |
| 1 #!/usr/bin/python2.4 |
| 2 # Copyright 2008, Google Inc. |
| 3 # All rights reserved. |
| 4 # |
| 5 # Redistribution and use in source and binary forms, with or without |
| 6 # modification, are permitted provided that the following conditions are |
| 7 # met: |
| 8 # |
| 9 # * Redistributions of source code must retain the above copyright |
| 10 # notice, this list of conditions and the following disclaimer. |
| 11 # * Redistributions in binary form must reproduce the above |
| 12 # copyright notice, this list of conditions and the following disclaimer |
| 13 # in the documentation and/or other materials provided with the |
| 14 # distribution. |
| 15 # * Neither the name of Google Inc. nor the names of its |
| 16 # contributors may be used to endorse or promote products derived from |
| 17 # this software without specific prior written permission. |
| 18 # |
| 19 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 20 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 21 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 22 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 23 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 24 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 25 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 26 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 27 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 28 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 29 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 30 |
| 31 """Visual Studio solution file generation tool for SCons.""" |
| 32 |
| 33 |
| 34 import sys |
| 35 import SCons.Script |
| 36 |
| 37 |
| 38 def Solution(env, solution_name, |
| 39 environments, |
| 40 exclude_pattern=None, |
| 41 extra_build_targets=None): |
| 42 """Builds an MSVS solution containing all projects underneath build/win. |
| 43 |
| 44 Args: |
| 45 solution_name: Name of the solution. |
| 46 environments: List of environments for variants. Only the first one |
| 47 will be used to build the solutions/projects. |
| 48 exclude_pattern: Files matching this pattern will not be added to the |
| 49 projects and solution. |
| 50 extra_build_targets: Dict of extra build targets, indexed by target |
| 51 name. Each extra build target will be given |
| 52 its own empty project. |
| 53 """ |
| 54 |
| 55 # Provide an empty dict for the set of extra targets, by default. |
| 56 if extra_build_targets is None: |
| 57 extra_build_targets = dict() |
| 58 |
| 59 # Fail if not on windows for now. |
| 60 if sys.platform not in ['win32', 'cygwin']: |
| 61 print ('*** Solution file generation skipped ' |
| 62 '(not supported on this platform).') |
| 63 return |
| 64 |
| 65 # Add in the msvs tool. |
| 66 env.Tool('msvs') |
| 67 |
| 68 # Pick out variants |
| 69 variants = [e['BUILD_TYPE'] for e in environments] |
| 70 # Pick out build targets |
| 71 build_targets = [e.subst('$TARGET_ROOT') for e in environments] |
| 72 # pick out sources, headers, and resources |
| 73 sources, headers, resources, others = env.GatherInputs( |
| 74 [SCons.Script.Dir('.')], |
| 75 ['.+\\.(c|cc|m|mm|cpp)$', # source files |
| 76 '.+\\.(h|hh|hpp)$', # header files |
| 77 '.+\\.(rc)$', # resource files |
| 78 '.*'], # all other files |
| 79 exclude_pattern=exclude_pattern, |
| 80 ) |
| 81 # Build main Visual Studio Project file |
| 82 project_list = env.MSVSProject(target=solution_name + |
| 83 env['MSVSPROJECTSUFFIX'], |
| 84 srcs=sources + headers + others + resources, |
| 85 incs=[], |
| 86 misc=[], |
| 87 resources=[], |
| 88 auto_build_solution=0, |
| 89 MSVSCLEANCOM='hammer.bat -c MODE=all', |
| 90 MSVSBUILDCOM='hammer.bat MODE=all', |
| 91 MSVSREBUILD='hammer.bat -c MODE=all;' |
| 92 'hammer.bat MODE=all', |
| 93 buildtarget=build_targets, |
| 94 variant=variants) |
| 95 # Collect other projects |
| 96 for e in extra_build_targets: |
| 97 # Explicitly create a node for target, so SCons will expand env variables. |
| 98 build_target = env.File(extra_build_targets[e]) |
| 99 # Create an empty project that only has a build target. |
| 100 project_list += env.MSVSProject(target='projects/' + e + '/' + e + |
| 101 env['MSVSPROJECTSUFFIX'], |
| 102 srcs=[], |
| 103 incs=[], |
| 104 resources=[], |
| 105 misc=[], |
| 106 auto_build_solution=0, |
| 107 MSVSCLEANCOM='rem', |
| 108 MSVSBUILDCOM='rem', |
| 109 MSVSREBUILD='rem', |
| 110 buildtarget=build_target, |
| 111 variant=variants[0]) |
| 112 |
| 113 # Build Visual Studio Solution file. |
| 114 solution =env.MSVSSolution(target=solution_name + env['MSVSSOLUTIONSUFFIX'], |
| 115 projects=project_list, |
| 116 variant=variants) |
| 117 # Explicitly add dependencies. |
| 118 env.Depends(solution, project_list) |
| 119 |
| 120 return solution |
| 121 |
| 122 |
| 123 def generate(env): |
| 124 # NOTE: SCons requires the use of this name, which fails gpylint. |
| 125 """SCons entry point for this tool.""" |
| 126 |
| 127 # Add in the gather_inputs tool. |
| 128 env.Tool('gather_inputs') |
| 129 |
| 130 # Add a method to generate a combined solution file. |
| 131 env.AddMethod(Solution, 'Solution') |
| OLD | NEW |