OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2009 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2009 The Chromium Authors. All rights reserved. |
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 import posixpath | 6 import posixpath |
7 import sys | 7 import sys |
8 import os.path | 8 import os.path |
9 | 9 |
10 output_filename = 'samples_gen.gyp' | 10 output_filename = 'samples_gen.gyp' |
(...skipping 21 matching lines...) Expand all Loading... |
32 {'path': 'convert_assets/dome1.zip', 'up': y_up}, | 32 {'path': 'convert_assets/dome1.zip', 'up': y_up}, |
33 {'path': 'convert_assets/dome2.zip', 'up': y_up}, | 33 {'path': 'convert_assets/dome2.zip', 'up': y_up}, |
34 {'path': 'convert_assets/dome3.zip', 'up': y_up}, | 34 {'path': 'convert_assets/dome3.zip', 'up': y_up}, |
35 {'path': 'convert_assets/dome4.zip', 'up': y_up}, | 35 {'path': 'convert_assets/dome4.zip', 'up': y_up}, |
36 {'path': 'convert_assets/kitty_151_idle_stand05_cff1.zip', 'up': y_up}, | 36 {'path': 'convert_assets/kitty_151_idle_stand05_cff1.zip', 'up': y_up}, |
37 {'path': 'convert_assets/part1.zip', 'up': y_up}, | 37 {'path': 'convert_assets/part1.zip', 'up': y_up}, |
38 {'path': 'convert_assets/part2.zip', 'up': y_up}, | 38 {'path': 'convert_assets/part2.zip', 'up': y_up}, |
39 {'path': 'convert_assets/part3.zip', 'up': y_up}, | 39 {'path': 'convert_assets/part3.zip', 'up': y_up}, |
40 {'path': 'convert_assets/seven_shapes.zip', 'up': y_up}, | 40 {'path': 'convert_assets/seven_shapes.zip', 'up': y_up}, |
41 {'path': 'convert_assets/stencil_frame.zip', 'up': y_up}, | 41 {'path': 'convert_assets/stencil_frame.zip', 'up': y_up}, |
42 {'path': 'convert_assets/teapot.zip', 'up': y_up}, | 42 {'path': 'convert_assets/teapot.zip', 'up': y_up, 'webgl': True}, |
43 {'path': 'convert_assets/yard.zip', 'up': y_up}, | 43 {'path': 'convert_assets/yard.zip', 'up': y_up}, |
44 {'path': 'home-configurators/convert_cbassets/Agra_Rug.kmz', 'up': z_up}, | 44 {'path': 'home-configurators/convert_cbassets/Agra_Rug.kmz', 'up': z_up}, |
45 {'path': 'home-configurators/convert_cbassets/Asimi_Rug.kmz', 'up': z_up}, | 45 {'path': 'home-configurators/convert_cbassets/Asimi_Rug.kmz', 'up': z_up}, |
46 {'path': 'home-configurators/convert_cbassets/Camden_Chair.kmz', 'up': z_up}, | 46 {'path': 'home-configurators/convert_cbassets/Camden_Chair.kmz', 'up': z_up}, |
47 {'path': 'home-configurators/convert_cbassets/Elements_Bookshelf.kmz', 'up': z_
up}, | 47 {'path': 'home-configurators/convert_cbassets/Elements_Bookshelf.kmz', 'up': z_
up}, |
48 {'path': 'home-configurators/convert_cbassets/Ferrara_Rug.kmz', 'up': z_up}, | 48 {'path': 'home-configurators/convert_cbassets/Ferrara_Rug.kmz', 'up': z_up}, |
49 {'path': 'home-configurators/convert_cbassets/House_Roofless.kmz', 'up': z_up}, | 49 {'path': 'home-configurators/convert_cbassets/House_Roofless.kmz', 'up': z_up}, |
50 {'path': 'home-configurators/convert_cbassets/Lounge_Chair.kmz', 'up': z_up}, | 50 {'path': 'home-configurators/convert_cbassets/Lounge_Chair.kmz', 'up': z_up}, |
51 {'path': 'home-configurators/convert_cbassets/Lounge_Chaise.kmz', 'up': z_up}, | 51 {'path': 'home-configurators/convert_cbassets/Lounge_Chaise.kmz', 'up': z_up}, |
52 {'path': 'home-configurators/convert_cbassets/Lounge_Sofa.kmz', 'up': z_up}, | 52 {'path': 'home-configurators/convert_cbassets/Lounge_Sofa.kmz', 'up': z_up}, |
53 {'path': 'home-configurators/convert_cbassets/Lounge_Storage_Ottoman.kmz', 'up'
: z_up}, | 53 {'path': 'home-configurators/convert_cbassets/Lounge_Storage_Ottoman.kmz', 'up'
: z_up}, |
54 {'path': 'home-configurators/convert_cbassets/Madison_Dining_Table.kmz', 'up':
z_up}, | 54 {'path': 'home-configurators/convert_cbassets/Madison_Dining_Table.kmz', 'up':
z_up}, |
55 {'path': 'home-configurators/convert_cbassets/Miles_Side_Chair.kmz', 'up': z_up
}, | 55 {'path': 'home-configurators/convert_cbassets/Miles_Side_Chair.kmz', 'up': z_up
}, |
56 {'path': 'home-configurators/convert_cbassets/Pullman_Bar_Stool.kmz', 'up': z_u
p}, | 56 {'path': 'home-configurators/convert_cbassets/Pullman_Bar_Stool.kmz', 'up': z_u
p}, |
57 {'path': 'home-configurators/convert_cbassets/Puzzle_TV_Stand.kmz', 'up': z_up}
, | 57 {'path': 'home-configurators/convert_cbassets/Puzzle_TV_Stand.kmz', 'up': z_up}
, |
58 {'path': 'home-configurators/convert_cbassets/Stow_Leather_Ottoman.kmz', 'up':
z_up}, | 58 {'path': 'home-configurators/convert_cbassets/Stow_Leather_Ottoman.kmz', 'up':
z_up}, |
59 {'path': 'home-configurators/convert_cbassets/Tivoli_Dining_Table.kmz', 'up': z
_up}, | 59 {'path': 'home-configurators/convert_cbassets/Tivoli_Dining_Table.kmz', 'up': z
_up}, |
60 {'path': 'home-configurators/convert_cbassets/Tivoli_Miles_Dining_Set.kmz', 'up
': z_up}, | 60 {'path': 'home-configurators/convert_cbassets/Tivoli_Miles_Dining_Set.kmz', 'up
': z_up}, |
61 {'path': 'home-configurators/convert_cbassets/Troy_Chair.kmz', 'up': z_up}, | 61 {'path': 'home-configurators/convert_cbassets/Troy_Chair.kmz', 'up': z_up}, |
62 {'path': 'home-configurators/convert_cbassets/Troy_Ottoman.kmz', 'up': z_up}, | 62 {'path': 'home-configurators/convert_cbassets/Troy_Ottoman.kmz', 'up': z_up}, |
63 {'path': 'home-configurators/convert_cbassets/Troy_Sofa.kmz', 'up': z_up}, | 63 {'path': 'home-configurators/convert_cbassets/Troy_Sofa.kmz', 'up': z_up}, |
64 {'path': 'home-configurators/convert_cbassets/Troy_Storage_Ottoman.kmz', 'up':
z_up}, | 64 {'path': 'home-configurators/convert_cbassets/Troy_Storage_Ottoman.kmz', 'up':
z_up}, |
65 {'path': 'home-configurators/convert_cbassets/Troy_Twin_Sleeper.kmz', 'up': z_u
p}, | 65 {'path': 'home-configurators/convert_cbassets/Troy_Twin_Sleeper.kmz', 'up': z_u
p}, |
66 {'path': 'io/convert_levels/all_actors.kmz', 'up': y_up}, | 66 {'path': 'io/convert_levels/all_actors.kmz', 'up': y_up}, |
67 {'path': 'io/convert_levels/map1.kmz', 'up': y_up}, | 67 {'path': 'io/convert_levels/map1.kmz', 'up': y_up}, |
68 {'path': 'simpleviewer/convert_assets/cube.zip', 'up': y_up}, | 68 {'path': 'simpleviewer/convert_assets/cube.zip', 'up': y_up, 'webgl': True}, |
69 ] | 69 ] |
70 | 70 |
71 output_file.write("""# Copyright (c) 2009 The Chromium Authors. All rights reser
ved. | 71 output_file.write("""# Copyright (c) 2009 The Chromium Authors. All rights reser
ved. |
72 # Use of this source code is governed by a BSD-style license that can be | 72 # Use of this source code is governed by a BSD-style license that can be |
73 # found in the LICENSE file. | 73 # found in the LICENSE file. |
74 | 74 |
75 { | 75 { |
76 'variables': { | 76 'variables': { |
77 'chromium_code': 1, | 77 'chromium_code': 1, |
78 }, | 78 }, |
79 'includes': [ | 79 'includes': [ |
80 '../build/common.gypi', | 80 '../build/common.gypi', |
81 ], | 81 ], |
82 'targets': [ | 82 'targets': [ |
83 { | 83 { |
84 'target_name': 'build_samples', | 84 'target_name': 'build_samples', |
85 'type': 'none', | 85 'type': 'none', |
86 'dependencies': [ | 86 'dependencies': [ |
87 '../converter/converter.gyp:o3dConverter', | 87 '../converter/converter.gyp:o3dConverter', |
88 ], | 88 ], |
89 'actions': [\n""") | 89 'actions': [\n""") |
90 for asset in assets: | 90 |
| 91 def write_action(asset, webgl_mode): |
91 filename = posixpath.splitext(posixpath.basename(asset['path']))[0] | 92 filename = posixpath.splitext(posixpath.basename(asset['path']))[0] |
92 filename = filename.replace('.','_') | 93 filename = filename.replace('.','_') |
93 filename = filename.replace('-','_') | 94 filename = filename.replace('-','_') |
94 filename = filename.lower() | 95 filename = filename.lower() |
95 name = "convert_" + filename | 96 name = "convert_" + filename |
| 97 if webgl_mode: |
| 98 name = name + "_webgl" |
96 output = asset['path'].replace('convert_', '') | 99 output = asset['path'].replace('convert_', '') |
97 output = posixpath.splitext(output)[0] + ".o3dtgz" | 100 output = posixpath.splitext(output)[0] + ".o3dtgz" |
98 output_dir = posixpath.dirname(output) | 101 output_dir = posixpath.dirname(output) |
99 output_file.write(" {\n") | 102 output_file.write(" {\n") |
100 output_file.write(" 'action_name': '%s',\n" % name) | 103 output_file.write(" 'action_name': '%s',\n" % name) |
101 output_file.write(" 'inputs': [\n") | 104 output_file.write(" 'inputs': [\n") |
102 output_file.write(" '<(PRODUCT_DIR)/o3dConverter',\n") | 105 output_file.write(" '<(PRODUCT_DIR)/o3dConverter',\n") |
103 output_file.write(" '../o3d_assets/samples/%s',\n" % asset['path']) | 106 output_file.write(" '../o3d_assets/samples/%s',\n" % asset['path']) |
104 output_file.write(" ],\n") | 107 output_file.write(" ],\n") |
105 output_file.write(" 'outputs': [\n") | 108 output_file.write(" 'outputs': [\n") |
106 if sys.platform[:5] == 'linux': | 109 if sys.platform[:5] == 'linux': |
107 # TODO(gspencer): This is a HACK! We shouldn't need to put the | 110 # TODO(gspencer): This is a HACK! We shouldn't need to put the |
108 # absolute path here, but currently on Linux (scons), it is unable | 111 # absolute path here, but currently on Linux (scons), it is unable |
109 # to copy generated items out of the source tree (because the | 112 # to copy generated items out of the source tree (because the |
110 # repository mojo fails to find it and puts in the wrong path). | 113 # repository mojo fails to find it and puts in the wrong path). |
111 output_file.write(" '%s',\n" % posixpath.abspath(output)) | 114 output_file.write(" '%s',\n" % posixpath.abspath(output)) |
112 else: | 115 else: |
113 output_file.write(" '../samples/%s',\n" % output) | 116 output_file.write(" '../samples/%s',\n" % output) |
114 output_file.write(" ],\n") | 117 output_file.write(" ],\n") |
115 output_file.write(" 'action': [\n") | 118 output_file.write(" 'action': [\n") |
116 output_file.write(" '<(PRODUCT_DIR)/o3dConverter',\n") | 119 output_file.write(" '<(PRODUCT_DIR)/o3dConverter',\n") |
117 output_file.write(" '--no-condition',\n") | 120 output_file.write(" '--no-condition',\n") |
118 output_file.write(" '--up-axis=%s',\n" % asset['up']) | 121 output_file.write(" '--up-axis=%s',\n" % asset['up']) |
| 122 if webgl_mode: |
| 123 output_file.write(" '--no-binary',\n") |
| 124 output_file.write(" '--no-archive',\n") |
| 125 output_file.write(" '--convert-dds-to-png',\n") |
| 126 output_file.write(" '--convert-cg-to-glsl',\n") |
119 output_file.write(" '../o3d_assets/samples/%s',\n" % asset['path']) | 127 output_file.write(" '../o3d_assets/samples/%s',\n" % asset['path']) |
120 output_file.write(" '<(_outputs)',\n") | 128 output_file.write(" '<(_outputs)',\n") |
121 output_file.write(" ],\n") | 129 output_file.write(" ],\n") |
122 output_file.write(" },\n") | 130 output_file.write(" },\n") |
123 | 131 |
| 132 for asset in assets: |
| 133 write_action(asset, False); |
| 134 if asset.has_key('webgl'): |
| 135 write_action(asset, True); |
| 136 |
124 output_file.write(" ],\n") | 137 output_file.write(" ],\n") |
125 | 138 |
126 # Coalesce copies by directory so we don't have tons of copies rules | 139 # Coalesce copies by directory so we don't have tons of copies rules |
127 # to parse. | 140 # to parse. |
128 copies = {} | 141 copies = {} |
129 for asset in assets: | 142 for asset in assets: |
130 output = asset['path'].replace('convert_', '') | 143 output = asset['path'].replace('convert_', '') |
131 output = posixpath.splitext(output)[0] + ".o3dtgz" | 144 output = posixpath.splitext(output)[0] + ".o3dtgz" |
132 output_dir = posixpath.dirname(output) | 145 output_dir = posixpath.dirname(output) |
133 if output_dir in copies: | 146 if output_dir in copies: |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 output_file.write(" ],\n") | 184 output_file.write(" ],\n") |
172 output_file.write(" },\n") | 185 output_file.write(" },\n") |
173 | 186 |
174 output_file.write(" ],\n") | 187 output_file.write(" ],\n") |
175 output_file.write(" },\n") | 188 output_file.write(" },\n") |
176 output_file.write(" ],\n") | 189 output_file.write(" ],\n") |
177 output_file.write("}\n") | 190 output_file.write("}\n") |
178 | 191 |
179 print output_filename | 192 print output_filename |
180 sys.exit(0) | 193 sys.exit(0) |
OLD | NEW |