| OLD | NEW |
| 1 # Copyright 2011 Google Inc. | 1 # Copyright 2011 Google Inc. |
| 2 # | 2 # |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 # "Makefile" replacement to build skia for Windows. | 6 # "Makefile" replacement to build skia for Windows. |
| 7 # More info at https://skia.org. | 7 # More info at https://skia.org. |
| 8 # | 8 # |
| 9 # Some usage examples: | 9 # Some usage examples: |
| 10 # make clean | 10 # make clean |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 | 54 |
| 55 | 55 |
| 56 def CheckWindowsEnvironment(): | 56 def CheckWindowsEnvironment(): |
| 57 """For Windows: check environment variables needed for command-line build. | 57 """For Windows: check environment variables needed for command-line build. |
| 58 | 58 |
| 59 If those environment variables are missing, try to set them. | 59 If those environment variables are missing, try to set them. |
| 60 If environment variables can be set up, this function returns; otherwise, | 60 If environment variables can be set up, this function returns; otherwise, |
| 61 it displays an error message and exits. | 61 it displays an error message and exits. |
| 62 """ | 62 """ |
| 63 # If we already have the proper environment variables, nothing to do here. | 63 # If we already have the proper environment variables, nothing to do here. |
| 64 try: | 64 if os.environ.get('DevEnvDir'): |
| 65 env_DevEnvDir = os.environ['DevEnvDir'] | 65 return |
| 66 return # found it, so we are done | |
| 67 except KeyError: | |
| 68 pass # go on and run the rest of this function | |
| 69 | 66 |
| 70 print ('\nCould not find Visual Studio environment variables.' | 67 print ('\nCould not find Visual Studio environment variables.' |
| 71 '\nPerhaps you have not yet run vcvars32.bat as described at' | 68 '\nPerhaps you have not yet run vcvars32.bat as described at' |
| 72 '\nhttp://msdn.microsoft.com/en-us/library/f2ccy3wt.aspx ?') | 69 '\nhttp://msdn.microsoft.com/en-us/library/f2ccy3wt.aspx ?') |
| 73 found_path = None | 70 found_path = None |
| 74 try: | 71 try: |
| 75 possible_path = os.path.abspath(os.path.join( | 72 possible_path = os.path.abspath(os.path.join( |
| 76 os.environ['VS100COMNTOOLS'], os.path.pardir, os.path.pardir, | 73 os.environ['VS100COMNTOOLS'], os.path.pardir, os.path.pardir, |
| 77 'VC', 'bin', 'vcvars32.bat')) | 74 'VC', 'bin', 'vcvars32.bat')) |
| 78 if os.path.exists(possible_path): | 75 if os.path.exists(possible_path): |
| (...skipping 12 matching lines...) Expand all Loading... |
| 91 | 88 |
| 92 parameters: | 89 parameters: |
| 93 targets: build targets as a list of strings | 90 targets: build targets as a list of strings |
| 94 """ | 91 """ |
| 95 if os.environ.get('CHROME_HEADLESS', '0') != '1': | 92 if os.environ.get('CHROME_HEADLESS', '0') != '1': |
| 96 # TODO(epoger): I'm not sure if this is needed for ninja builds. | 93 # TODO(epoger): I'm not sure if this is needed for ninja builds. |
| 97 CheckWindowsEnvironment() | 94 CheckWindowsEnvironment() |
| 98 | 95 |
| 99 # Run gyp_skia to prepare Visual Studio projects. | 96 # Run gyp_skia to prepare Visual Studio projects. |
| 100 cd(SCRIPT_DIR) | 97 cd(SCRIPT_DIR) |
| 101 runcommand('python gyp_skia') | 98 runcommand('python gyp_skia --no-parallel -G config=%s' % BUILDTYPE) |
| 102 | 99 |
| 103 # We already built the gypfiles... | 100 # We already built the gypfiles... |
| 104 while TARGET_GYP in targets: | 101 while TARGET_GYP in targets: |
| 105 targets.remove(TARGET_GYP) | 102 targets.remove(TARGET_GYP) |
| 106 | 103 |
| 107 # And call ninja to do the work! | 104 # And call ninja to do the work! |
| 108 if targets: | 105 if targets: |
| 109 runcommand('ninja -C %s %s' % ( | 106 runcommand('ninja -C %s %s' % ( |
| 110 os.path.join(OUT_SUBDIR, BUILDTYPE), ' '.join(targets))) | 107 os.path.join(OUT_SUBDIR, BUILDTYPE), ' '.join(targets))) |
| 111 | 108 |
| 112 | 109 |
| 113 def Make(args): | 110 def Make(args): |
| 114 """Main function. | 111 """Main function. |
| 115 | 112 |
| 116 parameters: | 113 parameters: |
| 117 args: command line arguments as a list of strings | 114 args: command line arguments as a list of strings |
| 118 """ | 115 """ |
| 119 # handle any variable-setting parameters or special targets | 116 # handle any variable-setting parameters or special targets |
| 120 global BUILDTYPE | 117 global BUILDTYPE |
| 121 | 118 |
| 122 # if no targets were specified at all, make default target | 119 # if no targets were specified at all, make default target |
| 123 if not args: | 120 if not args: |
| 124 args = [TARGET_DEFAULT] | 121 args = [TARGET_DEFAULT] |
| 125 | 122 |
| 126 targets = [] | 123 targets = [] |
| 127 for arg in args: | 124 for arg in args: |
| 128 # If user requests "make all", chain to our explicitly-declared "everyth
ing" | 125 # If user requests "make all", chain to our explicitly-declared |
| 129 # target. See https://code.google.com/p/skia/issues/detail?id=932 ("gyp | 126 # "everything" target. See |
| 130 # automatically creates "all" target on some build flavors but not other
s") | 127 # https://code.google.com/p/skia/issues/detail?id=932 ("gyp |
| 128 # automatically creates "all" target on some build flavors but not |
| 129 # others") |
| 131 if arg == TARGET_ALL: | 130 if arg == TARGET_ALL: |
| 132 targets.append('everything') | 131 targets.append('everything') |
| 133 elif arg == TARGET_CLEAN: | 132 elif arg == TARGET_CLEAN: |
| 134 MakeClean() | 133 MakeClean() |
| 135 elif arg.startswith('BUILDTYPE='): | 134 elif arg.startswith('BUILDTYPE='): |
| 136 BUILDTYPE = arg[10:] | 135 BUILDTYPE = arg[10:] |
| 137 elif arg.startswith('GYP_DEFINES='): | 136 elif arg.startswith('GYP_DEFINES='): |
| 138 os.environ['GYP_DEFINES'] = arg[12:] | 137 os.environ['GYP_DEFINES'] = arg[12:] |
| 139 else: | 138 else: |
| 140 targets.append(arg) | 139 targets.append(arg) |
| 141 | 140 |
| 142 # if there are no remaining targets, we're done | 141 # if there are no remaining targets, we're done |
| 143 if not targets: | 142 if not targets: |
| 144 sys.exit(0) | 143 sys.exit(0) |
| 145 | 144 |
| 146 # dispatch to appropriate Make<Platform>() variant. | 145 # dispatch to appropriate Make<Platform>() variant. |
| 147 if os.name == 'nt': | 146 if os.name == 'nt': |
| 148 MakeWindows(targets) | 147 MakeWindows(targets) |
| 149 sys.exit(0) | 148 sys.exit(0) |
| 150 elif os.name == 'posix': | 149 elif os.name == 'posix': |
| 151 if sys.platform == 'darwin': | 150 if sys.platform == 'darwin': |
| 152 print 'Mac developers should not run this script; see ' \ | 151 print ('Mac developers should not run this script; see ' |
| 153 'https://skia.org/user/quick/macos' | 152 'https://skia.org/user/quick/macos') |
| 154 sys.exit(1) | 153 sys.exit(1) |
| 155 elif sys.platform == 'cygwin': | 154 elif sys.platform == 'cygwin': |
| 156 print 'Windows development on Cygwin is not currently supported; see
' \ | 155 print ('Windows development on Cygwin is not currently supported; ' |
| 157 'https://skia.org/user/quick/windows' | 156 'see https://skia.org/user/quick/windows') |
| 158 sys.exit(1) | 157 sys.exit(1) |
| 159 else: | 158 else: |
| 160 print 'Unix developers should not run this script; see ' \ | 159 print ('Unix developers should not run this script; see ' |
| 161 'https://skia.org/user/quick/linux' | 160 'https://skia.org/user/quick/linux') |
| 162 sys.exit(1) | 161 sys.exit(1) |
| 163 else: | 162 else: |
| 164 print 'unknown platform (os.name=%s, sys.platform=%s); see %s' % ( | 163 print 'unknown platform (os.name=%s, sys.platform=%s); see %s' % ( |
| 165 os.name, sys.platform, 'https://skia.org/user/quick') | 164 os.name, sys.platform, 'https://skia.org/user/quick') |
| 166 sys.exit(1) | 165 sys.exit(1) |
| 167 sys.exit(0) | 166 sys.exit(0) |
| 168 | 167 |
| 169 | 168 |
| 170 # main() | 169 # main() |
| 171 Make(sys.argv[1:]) | 170 Make(sys.argv[1:]) |
| 172 | 171 |
| 173 | 172 |
| OLD | NEW |