| 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://sites.google.com/site/skiadocs/ | 7 # More info at https://sites.google.com/site/skiadocs/ |
| 8 # | 8 # |
| 9 # Some usage examples: | 9 # Some usage examples: |
| 10 # make clean | 10 # make clean |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 print '> cd %s' % path | 35 print '> cd %s' % path |
| 36 if not os.path.isdir(path): | 36 if not os.path.isdir(path): |
| 37 print 'directory %s does not exist' % path | 37 print 'directory %s does not exist' % path |
| 38 sys.exit(1) | 38 sys.exit(1) |
| 39 os.chdir(path) | 39 os.chdir(path) |
| 40 | 40 |
| 41 def rmtree(path): | 41 def rmtree(path): |
| 42 print '> rmtree %s' % path | 42 print '> rmtree %s' % path |
| 43 shutil.rmtree(path, ignore_errors=True) | 43 shutil.rmtree(path, ignore_errors=True) |
| 44 | 44 |
| 45 def mkdirs(path): | |
| 46 print '> mkdirs %s' % path | |
| 47 if not os.path.isdir(path): | |
| 48 os.makedirs(path) | |
| 49 | |
| 50 def runcommand(command): | 45 def runcommand(command): |
| 51 print '> %s' % command | 46 print '> %s' % command |
| 52 if os.system(command): | 47 if os.system(command): |
| 53 sys.exit(1) | 48 sys.exit(1) |
| 54 | 49 |
| 55 def MakeClean(): | 50 def MakeClean(): |
| 56 """Cross-platform "make clean" operation.""" | 51 """Cross-platform "make clean" operation.""" |
| 57 cd(SCRIPT_DIR) | 52 cd(SCRIPT_DIR) |
| 58 rmtree(OUT_SUBDIR) | 53 rmtree(OUT_SUBDIR) |
| 59 # clean up the directory that XCode (on Mac) creates | 54 # clean up the directory that XCode (on Mac) creates |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 print '\nUnable to find vcvars32.bat on your system.' | 87 print '\nUnable to find vcvars32.bat on your system.' |
| 93 sys.exit(1) | 88 sys.exit(1) |
| 94 | 89 |
| 95 | 90 |
| 96 def MakeWindows(targets): | 91 def MakeWindows(targets): |
| 97 """For Windows: build as appropriate for the command line arguments. | 92 """For Windows: build as appropriate for the command line arguments. |
| 98 | 93 |
| 99 parameters: | 94 parameters: |
| 100 targets: build targets as a list of strings | 95 targets: build targets as a list of strings |
| 101 """ | 96 """ |
| 97 # TODO(epoger): I'm not sure if this is needed for ninja builds. |
| 102 CheckWindowsEnvironment() | 98 CheckWindowsEnvironment() |
| 103 | 99 |
| 104 # Run gyp_skia to prepare Visual Studio projects. | 100 # Run gyp_skia to prepare Visual Studio projects. |
| 105 cd(SCRIPT_DIR) | 101 cd(SCRIPT_DIR) |
| 106 runcommand('python gyp_skia') | 102 runcommand('python gyp_skia') |
| 107 | 103 |
| 108 # Prepare final output dir into which we will copy all binaries. | 104 # We already built the gypfiles... |
| 109 msbuild_working_dir = os.path.join(SCRIPT_DIR, OUT_SUBDIR, GYP_SUBDIR) | 105 while TARGET_GYP in targets: |
| 110 msbuild_output_dir = os.path.join(msbuild_working_dir, BUILDTYPE) | 106 targets.remove(TARGET_GYP) |
| 111 final_output_dir = os.path.join(SCRIPT_DIR, OUT_SUBDIR, BUILDTYPE) | |
| 112 mkdirs(final_output_dir) | |
| 113 | 107 |
| 114 for target in targets: | 108 # And call ninja to do the work! |
| 115 # We already built the gypfiles... | 109 if targets: |
| 116 if target == TARGET_GYP: | 110 runcommand('ninja -C %s %s' % ( |
| 117 continue | 111 os.path.join(OUT_SUBDIR, BUILDTYPE), ' '.join(targets))) |
| 118 | |
| 119 cd(msbuild_working_dir) | |
| 120 runcommand( | |
| 121 ('msbuild /nologo /property:Configuration=%s' | |
| 122 ' /target:%s /verbosity:minimal %s.sln') % ( | |
| 123 BUILDTYPE, target, target)) | |
| 124 runcommand('xcopy /y %s\* %s' % ( | |
| 125 msbuild_output_dir, final_output_dir)) | |
| 126 | 112 |
| 127 | 113 |
| 128 def Make(args): | 114 def Make(args): |
| 129 """Main function. | 115 """Main function. |
| 130 | 116 |
| 131 parameters: | 117 parameters: |
| 132 args: command line arguments as a list of strings | 118 args: command line arguments as a list of strings |
| 133 """ | 119 """ |
| 134 # handle any variable-setting parameters or special targets | 120 # handle any variable-setting parameters or special targets |
| 135 global BUILDTYPE | 121 global BUILDTYPE |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 sys.exit(1) | 163 sys.exit(1) |
| 178 else: | 164 else: |
| 179 print 'unknown platform (os.name=%s, sys.platform=%s); see %s' % ( | 165 print 'unknown platform (os.name=%s, sys.platform=%s); see %s' % ( |
| 180 os.name, sys.platform, 'https://sites.google.com/site/skiadocs/') | 166 os.name, sys.platform, 'https://sites.google.com/site/skiadocs/') |
| 181 sys.exit(1) | 167 sys.exit(1) |
| 182 sys.exit(0) | 168 sys.exit(0) |
| 183 | 169 |
| 184 | 170 |
| 185 # main() | 171 # main() |
| 186 Make(sys.argv[1:]) | 172 Make(sys.argv[1:]) |
| 187 | |
| 188 | |
| OLD | NEW |