1 #!/usr/bin/env python 2 3 # Copyright (c) 2012 Google Inc. All rights reserved. 4 # Use of this source code is governed by a BSD-style license that can be 5 # found in the LICENSE file. 6 7 """ 8 Make sure optimization settings are extracted properly. 9 """ 10 11 import TestGyp 12 13 import sys 14 15 if sys.platform == 'win32': 16 test = TestGyp.TestGyp(formats=['ninja']) 17 18 CHDIR = 'compiler-flags' 19 test.run_gyp('optimizations.gyp', chdir=CHDIR) 20 21 # It's hard to map flags to output contents in a non-fragile way (especially 22 # handling both 2008/2010), so just verify the correct ninja command line 23 # contents. 24 25 ninja_file = test.built_file_path('obj/test_opt_off.ninja', chdir=CHDIR) 26 test.must_contain(ninja_file, 'cflags = /Od') 27 28 ninja_file = test.built_file_path('obj/test_opt_lev_size.ninja', chdir=CHDIR) 29 test.must_contain(ninja_file, 'cflags = /O1') 30 31 ninja_file = test.built_file_path('obj/test_opt_lev_speed.ninja', chdir=CHDIR) 32 test.must_contain(ninja_file, 'cflags = /O2') 33 34 ninja_file = test.built_file_path('obj/test_opt_lev_max.ninja', chdir=CHDIR) 35 test.must_contain(ninja_file, 'cflags = /Ox') 36 37 ninja_file = test.built_file_path('obj/test_opt_unset.ninja', chdir=CHDIR) 38 test.must_not_contain(ninja_file, '/Od') 39 test.must_not_contain(ninja_file, '/O1') 40 test.must_not_contain(ninja_file, '/O2') 41 test.must_not_contain(ninja_file, '/Ox') 42 43 ninja_file = test.built_file_path('obj/test_opt_fpo.ninja', chdir=CHDIR) 44 test.must_contain(ninja_file, '/Oy') 45 test.must_not_contain(ninja_file, '/Oy-') 46 47 ninja_file = test.built_file_path('obj/test_opt_fpo_off.ninja', chdir=CHDIR) 48 test.must_contain(ninja_file, '/Oy-') 49 50 ninja_file = test.built_file_path('obj/test_opt_intrinsic.ninja', 51 chdir=CHDIR) 52 test.must_contain(ninja_file, '/Oi') 53 test.must_not_contain(ninja_file, '/Oi-') 54 55 ninja_file = test.built_file_path('obj/test_opt_intrinsic_off.ninja', 56 chdir=CHDIR) 57 test.must_contain(ninja_file, '/Oi-') 58 59 ninja_file = test.built_file_path('obj/test_opt_inline_off.ninja', 60 chdir=CHDIR) 61 test.must_contain(ninja_file, '/Ob0') 62 63 ninja_file = test.built_file_path('obj/test_opt_inline_manual.ninja', 64 chdir=CHDIR) 65 test.must_contain(ninja_file, '/Ob1') 66 67 ninja_file = test.built_file_path('obj/test_opt_inline_auto.ninja', 68 chdir=CHDIR) 69 test.must_contain(ninja_file, '/Ob2') 70 71 ninja_file = test.built_file_path('obj/test_opt_neither.ninja', 72 chdir=CHDIR) 73 test.must_not_contain(ninja_file, '/Os') 74 test.must_not_contain(ninja_file, '/Ot') 75 76 ninja_file = test.built_file_path('obj/test_opt_size.ninja', 77 chdir=CHDIR) 78 test.must_contain(ninja_file, '/Os') 79 80 ninja_file = test.built_file_path('obj/test_opt_speed.ninja', 81 chdir=CHDIR) 82 test.must_contain(ninja_file, '/Ot') 83 84 ninja_file = test.built_file_path('obj/test_opt_wpo.ninja', 85 chdir=CHDIR) 86 test.must_contain(ninja_file, '/GL') 87 88 ninja_file = test.built_file_path('obj/test_opt_sp.ninja', 89 chdir=CHDIR) 90 test.must_contain(ninja_file, '/GF') 91 92 ninja_file = test.built_file_path('obj/test_opt_sp_off.ninja', 93 chdir=CHDIR) 94 test.must_not_contain(ninja_file, '/GF') 95 96 ninja_file = test.built_file_path('obj/test_opt_fso.ninja', 97 chdir=CHDIR) 98 test.must_contain(ninja_file, '/GT') 99 100 ninja_file = test.built_file_path('obj/test_opt_fso_off.ninja', 101 chdir=CHDIR) 102 test.must_not_contain(ninja_file, '/GT') 103 104 test.pass_test() 105