David Benjamin | 05a5beb | 2015-03-12 20:13:41 -0400 | [diff] [blame] | 1 | # Copyright (c) 2015, Google Inc. |
| 2 | # |
| 3 | # Permission to use, copy, modify, and/or distribute this software for any |
| 4 | # purpose with or without fee is hereby granted, provided that the above |
| 5 | # copyright notice and this permission notice appear in all copies. |
| 6 | # |
| 7 | # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
| 8 | # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
| 9 | # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY |
| 10 | # SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 11 | # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION |
| 12 | # OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN |
| 13 | # CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 14 | |
| 15 | import subprocess |
| 16 | import sys |
| 17 | |
| 18 | import vs_toolchain |
| 19 | # vs_toolchain adds gyp to sys.path. |
| 20 | import gyp.MSVSVersion |
| 21 | |
| 22 | if len(sys.argv) < 2: |
| 23 | print >>sys.stderr, "Usage: vs_env.py TARGET_ARCH CMD..." |
| 24 | sys.exit(1) |
| 25 | |
| 26 | target_arch = sys.argv[1] |
| 27 | cmd = sys.argv[2:] |
| 28 | |
| 29 | vs_toolchain.SetEnvironmentAndGetRuntimeDllDirs() |
| 30 | vs_version = gyp.MSVSVersion.SelectVisualStudioVersion() |
| 31 | |
| 32 | # Using shell=True is somewhat ugly, but the alternative is to pull in a copy |
| 33 | # of the Chromium GN build's setup_toolchain.py which runs the setup script, |
| 34 | # then 'set', and then parses the environment variables out. (GYP internally |
| 35 | # does the same thing.) |
| 36 | sys.exit(subprocess.call(vs_version.SetupScript(target_arch) + ["&&"] + cmd, |
| 37 | shell=True)) |