diff options
Diffstat (limited to 'o3d/plugin')
-rw-r--r-- | o3d/plugin/idl/codegen.py | 36 | ||||
-rw-r--r-- | o3d/plugin/idl/idl.gyp | 284 | ||||
-rw-r--r-- | o3d/plugin/plugin.gyp | 200 | ||||
-rw-r--r-- | o3d/plugin/version_info.py | 130 |
4 files changed, 650 insertions, 0 deletions
diff --git a/o3d/plugin/idl/codegen.py b/o3d/plugin/idl/codegen.py new file mode 100644 index 0000000..8f029bf --- /dev/null +++ b/o3d/plugin/idl/codegen.py @@ -0,0 +1,36 @@ +#!/usr/bin/python2.4 +# Copyright 2009 Google Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# This file is just here so that we can modify the python path before +# invoking nixysa. + +import subprocess +import sys +import os +import os.path + +third_party = os.path.join('..', '..', '..', 'third_party') +pythonpath = os.pathsep.join([os.path.join(third_party, 'gflags', 'python'), + os.path.join(third_party, 'ply', 'files')]) + +orig_pythonpath = os.environ.get('PYTHONPATH') +if orig_pythonpath: + pythonpath = os.pathsep.join([pythonpath, orig_pythonpath]) + +os.environ['PYTHONPATH'] = pythonpath + +nixysa = os.path.join(third_party, 'nixysa', 'files', 'codegen.py') +status = subprocess.call([sys.executable, nixysa] + sys.argv[1:]) +sys.exit(status) diff --git a/o3d/plugin/idl/idl.gyp b/o3d/plugin/idl/idl.gyp new file mode 100644 index 0000000..df5f206 --- /dev/null +++ b/o3d/plugin/idl/idl.gyp @@ -0,0 +1,284 @@ +# Copyright (c) 2009 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +{ + 'includes': [ + '../../build/common.gypi', + ], + 'variables': { + 'chromium_code': 1, + 'idl_out_dir': '<(SHARED_INTERMEDIATE_DIR)/idl_glue', + }, + 'targets': [ + { + 'target_name': 'idl_generator', + 'type': 'none', + 'variables': { + 'idl_files' : [ + # NOTE: Sadly, if you add/remove/rename an IDL file in this + # list, you must also update the list of outputs below. + 'archive_request.idl', + 'bounding_box.idl', + 'buffer.idl', + 'canvas.idl', + 'canvas_paint.idl', + 'canvas_shader.idl', + 'clear_buffer.idl', + 'client.idl', + 'counter.idl', + 'cursor.idl', + 'curve.idl', + 'display_mode.idl', + 'draw_context.idl', + 'draw_element.idl', + 'draw_list.idl', + 'draw_pass.idl', + 'effect.idl', + 'element.idl', + 'event.idl', + 'field.idl', + 'file_request.idl', + 'function.idl', + 'material.idl', + 'matrix4_axis_rotation.idl', + 'matrix4_composition.idl', + 'matrix4_scale.idl', + 'matrix4_translation.idl', + 'named.idl', + 'pack.idl', + 'param.idl', + 'param_array.idl', + 'param_object.idl', + 'param_operation.idl', + 'plugin.idl', + 'primitive.idl', + 'raw_data.idl', + 'ray_intersection_info.idl', + 'render_event.idl', + 'render_node.idl', + 'render_surface.idl', + 'render_surface_set.idl', + 'sampler.idl', + 'shape.idl', + 'skin.idl', + 'standard_param.idl', + 'state.idl', + 'state_set.idl', + 'stream.idl', + 'stream_bank.idl', + 'texture.idl', + 'tick_event.idl', + 'transform.idl', + 'tree_traversal.idl', + 'types.idl', + 'vector.idl', + 'vertex_source.idl', + 'viewport.idl', + ], + }, + 'rules': [ + { + 'rule_name': 'generate_idl', + 'extension': 'idl', + 'process_outputs_as_sources': 1, + 'inputs': [ + '../../../<(nixysadir)/codegen.py', + 'codegen.py', + ], + 'outputs': [ + '<(idl_out_dir)/<(RULE_INPUT_ROOT)_glue.cc', + '<(idl_out_dir)/<(RULE_INPUT_ROOT)_glue.h', + '<(idl_out_dir)/globals_glue.cc', + '<(idl_out_dir)/globals_glue.h', + '<(idl_out_dir)/hash', + '<(idl_out_dir)/parsetab.py', + '<(idl_out_dir)/parsetab.pyc', + ], + 'action': [ + 'python', + 'codegen.py', + '--binding-module=o3d:../../plugin/o3d_binding.py', + '--generate=npapi', + '--output-dir=<(idl_out_dir)', + '<@(idl_files)', + ], + 'message': 'Generating IDL glue for <(RULE_INPUT_PATH)', + }, + ], + 'direct_dependent_settings': { + 'include_dirs': [ + '<(idl_out_dir)', + ], + }, + 'sources': [ + '<@(idl_files)', + ], + }, + { + 'target_name': 'o3dPluginIdl', + 'type': 'static_library', + 'variables': { + 'static_glue_dir': '../../../<(nixysadir)/static_glue/npapi', + }, + 'include_dirs': [ + '../..', + '../../..', + '../../../<(npapidir)/include', + '../../plugin/cross', + '<(static_glue_dir)', + ], + 'dependencies': [ + '../../../<(zlibdir)/zlib.gyp:zlib', + '../../../base/base.gyp:base', + '../../../skia/skia.gyp:skia', + 'idl_generator', + ], + 'sources': [ + '../cross/archive_request_static_glue.cc', + '../cross/archive_request_static_glue.h', + '../cross/o3d_glue.cc', + '../cross/o3d_glue.h', + '<(static_glue_dir)/common.cc', + '<(static_glue_dir)/npn_api.cc', + '<(static_glue_dir)/static_object.cc', + '<(idl_out_dir)/globals_glue.cc', + '<(idl_out_dir)/globals_glue.h', + + # Sadly, the files below here are just an expansion of the + # list of IDL files in 'idl_files', above, so if you change on + # above, you also need to change this list. + '<(idl_out_dir)/archive_request_glue.cc', + '<(idl_out_dir)/archive_request_glue.h', + '<(idl_out_dir)/bounding_box_glue.cc', + '<(idl_out_dir)/bounding_box_glue.h', + '<(idl_out_dir)/buffer_glue.cc', + '<(idl_out_dir)/buffer_glue.h', + '<(idl_out_dir)/canvas_glue.cc', + '<(idl_out_dir)/canvas_glue.h', + '<(idl_out_dir)/canvas_paint_glue.cc', + '<(idl_out_dir)/canvas_paint_glue.h', + '<(idl_out_dir)/canvas_shader_glue.cc', + '<(idl_out_dir)/canvas_shader_glue.h', + '<(idl_out_dir)/clear_buffer_glue.cc', + '<(idl_out_dir)/clear_buffer_glue.h', + '<(idl_out_dir)/client_glue.cc', + '<(idl_out_dir)/client_glue.h', + '<(idl_out_dir)/counter_glue.cc', + '<(idl_out_dir)/counter_glue.h', + '<(idl_out_dir)/cursor_glue.cc', + '<(idl_out_dir)/cursor_glue.h', + '<(idl_out_dir)/curve_glue.cc', + '<(idl_out_dir)/curve_glue.h', + '<(idl_out_dir)/display_mode_glue.cc', + '<(idl_out_dir)/display_mode_glue.h', + '<(idl_out_dir)/draw_context_glue.cc', + '<(idl_out_dir)/draw_context_glue.h', + '<(idl_out_dir)/draw_element_glue.cc', + '<(idl_out_dir)/draw_element_glue.h', + '<(idl_out_dir)/draw_list_glue.cc', + '<(idl_out_dir)/draw_list_glue.h', + '<(idl_out_dir)/draw_pass_glue.cc', + '<(idl_out_dir)/draw_pass_glue.h', + '<(idl_out_dir)/effect_glue.cc', + '<(idl_out_dir)/effect_glue.h', + '<(idl_out_dir)/element_glue.cc', + '<(idl_out_dir)/element_glue.h', + '<(idl_out_dir)/event_glue.cc', + '<(idl_out_dir)/event_glue.h', + '<(idl_out_dir)/field_glue.cc', + '<(idl_out_dir)/field_glue.h', + '<(idl_out_dir)/file_request_glue.cc', + '<(idl_out_dir)/file_request_glue.h', + '<(idl_out_dir)/function_glue.cc', + '<(idl_out_dir)/function_glue.h', + '<(idl_out_dir)/material_glue.cc', + '<(idl_out_dir)/material_glue.h', + '<(idl_out_dir)/matrix4_axis_rotation_glue.cc', + '<(idl_out_dir)/matrix4_axis_rotation_glue.h', + '<(idl_out_dir)/matrix4_composition_glue.cc', + '<(idl_out_dir)/matrix4_composition_glue.h', + '<(idl_out_dir)/matrix4_scale_glue.cc', + '<(idl_out_dir)/matrix4_scale_glue.h', + '<(idl_out_dir)/matrix4_translation_glue.cc', + '<(idl_out_dir)/matrix4_translation_glue.h', + '<(idl_out_dir)/named_glue.cc', + '<(idl_out_dir)/named_glue.h', + '<(idl_out_dir)/pack_glue.cc', + '<(idl_out_dir)/pack_glue.h', + '<(idl_out_dir)/param_array_glue.cc', + '<(idl_out_dir)/param_array_glue.h', + '<(idl_out_dir)/param_glue.cc', + '<(idl_out_dir)/param_glue.h', + '<(idl_out_dir)/param_object_glue.cc', + '<(idl_out_dir)/param_object_glue.h', + '<(idl_out_dir)/param_operation_glue.cc', + '<(idl_out_dir)/param_operation_glue.h', + '<(idl_out_dir)/plugin_glue.cc', + '<(idl_out_dir)/plugin_glue.h', + '<(idl_out_dir)/primitive_glue.cc', + '<(idl_out_dir)/primitive_glue.h', + '<(idl_out_dir)/raw_data_glue.cc', + '<(idl_out_dir)/raw_data_glue.h', + '<(idl_out_dir)/ray_intersection_info_glue.cc', + '<(idl_out_dir)/ray_intersection_info_glue.h', + '<(idl_out_dir)/render_event_glue.cc', + '<(idl_out_dir)/render_event_glue.h', + '<(idl_out_dir)/render_node_glue.cc', + '<(idl_out_dir)/render_node_glue.h', + '<(idl_out_dir)/render_surface_glue.cc', + '<(idl_out_dir)/render_surface_glue.h', + '<(idl_out_dir)/render_surface_set_glue.cc', + '<(idl_out_dir)/render_surface_set_glue.h', + '<(idl_out_dir)/sampler_glue.cc', + '<(idl_out_dir)/sampler_glue.h', + '<(idl_out_dir)/shape_glue.cc', + '<(idl_out_dir)/shape_glue.h', + '<(idl_out_dir)/skin_glue.cc', + '<(idl_out_dir)/skin_glue.h', + '<(idl_out_dir)/standard_param_glue.cc', + '<(idl_out_dir)/standard_param_glue.h', + '<(idl_out_dir)/state_glue.cc', + '<(idl_out_dir)/state_glue.h', + '<(idl_out_dir)/state_set_glue.cc', + '<(idl_out_dir)/state_set_glue.h', + '<(idl_out_dir)/stream_bank_glue.cc', + '<(idl_out_dir)/stream_bank_glue.h', + '<(idl_out_dir)/stream_glue.cc', + '<(idl_out_dir)/stream_glue.h', + '<(idl_out_dir)/texture_glue.cc', + '<(idl_out_dir)/texture_glue.h', + '<(idl_out_dir)/tick_event_glue.cc', + '<(idl_out_dir)/tick_event_glue.h', + '<(idl_out_dir)/transform_glue.cc', + '<(idl_out_dir)/transform_glue.h', + '<(idl_out_dir)/tree_traversal_glue.cc', + '<(idl_out_dir)/tree_traversal_glue.h', + '<(idl_out_dir)/types_glue.cc', + '<(idl_out_dir)/types_glue.h', + '<(idl_out_dir)/vector_glue.cc', + '<(idl_out_dir)/vector_glue.h', + '<(idl_out_dir)/vertex_source_glue.cc', + '<(idl_out_dir)/vertex_source_glue.h', + '<(idl_out_dir)/viewport_glue.cc', + '<(idl_out_dir)/viewport_glue.h', + ], + 'direct_dependent_settings': { + 'include_dirs': [ + '../../../<(npapidir)/include', + '<(idl_out_dir)', + '<(static_glue_dir)', + ], + }, + 'conditions': [ + ['OS=="win"', + { + 'defines': [ + 'OS_WINDOWS', + ], + }, + ], + ], + }, + ], +} diff --git a/o3d/plugin/plugin.gyp b/o3d/plugin/plugin.gyp new file mode 100644 index 0000000..86c4695 --- /dev/null +++ b/o3d/plugin/plugin.gyp @@ -0,0 +1,200 @@ +# Copyright (c) 2009 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +{ + 'variables': { + 'chromium_code': 1, + }, + 'includes': [ + '../build/common.gypi', + ], + 'target_defaults': { + 'include_dirs': [ + '..', + '../..', + '../../<(gtestdir)', + ], + 'defines': [ + 'O3D_PLUGIN_NAME="<!(python version_info.py --name)"', + 'O3D_PLUGIN_DESCRIPTION="<!(python version_info.py --description)"', + 'O3D_PLUGIN_MIME_TYPE="<!(python version_info.py --mimetype)"', + ], + }, + 'targets': [ + { + 'target_name': 'npo3dautoplugin', + 'type': 'shared_library', + 'dependencies': [ + '../../<(antlrdir)/antlr.gyp:antlr3c', + '../../<(jpegdir)/libjpeg.gyp:libjpeg', + '../../<(pngdir)/libpng.gyp:libpng', + '../../<(zlibdir)/zlib.gyp:zlib', + '../../base/base.gyp:base', + '../../skia/skia.gyp:skia', + '../../v8/tools/gyp/v8.gyp:v8', + '../compiler/technique/technique.gyp:technique', + '../core/core.gyp:o3dCore', + '../core/core.gyp:o3dCorePlatform', + '../import/import.gyp:o3dArchive', + '../import/import.gyp:o3dImport', + '../serializer/serializer.gyp:o3dSerializer', + '../utils/utils.gyp:o3dUtils', + '../build/nacl.gyp:build_nacl', + 'idl/idl.gyp:o3dPluginIdl', + ], + 'sources': [ + 'cross/async_loading.cc', + 'cross/async_loading.h', + 'cross/blacklist.cc', + 'cross/config.h', + 'cross/config_common.cc', + 'cross/download_stream.h', + 'cross/main.cc', + 'cross/main.h', + 'cross/marshaling_utils.h', + 'cross/np_v8_bridge.cc', + 'cross/np_v8_bridge.h', + 'cross/out_of_memory.cc', + 'cross/out_of_memory.h', + 'cross/plugin_logging.h', + 'cross/plugin_main.h', + 'cross/stream_manager.cc', + 'cross/stream_manager.h', + ], + 'conditions' : [ + ['OS != "linux"', + { + 'dependencies': [ + '../statsreport/statsreport.gyp:o3dStatsReport', + 'add_version', + 'o3dPluginLogging', + ], + }, + ], + ['OS == "mac"', + { + 'sources': [ + 'mac/config_mac.mm', + 'mac/main_mac.mm', + 'mac/o3d_plugin.r', + 'mac/plugin_logging-mac.mm', + 'mac/plugin_mac.h', + 'mac/plugin_mac.mm', + ], + 'link_settings': { + 'libraries': [ + '$(SDKROOT)/System/Library/Frameworks/Foundation.framework', + ], + }, + }, + ], + ['OS == "win"', + { + 'dependencies': [ + '../breakpad/breakpad.gyp:o3dBreakpad', + ], + 'sources': [ + 'win/config.cc', + 'win/logger_main.cc', + 'win/main_win.cc', + 'win/o3dPlugin.def', + 'win/o3dPlugin.rc', + 'win/plugin_logging-win32.cc', + 'win/resource.h', + 'win/update_lock.cc', + 'win/update_lock.h', + ], + 'msvs_settings': { + 'VCLinkerTool': { + 'AdditionalDependencies': [ + '"$(DXSDK_DIR)/Lib/x86/DxErr9.lib"', + '"$(DXSDK_DIR)/Lib/x86/d3dx9.lib"', + '../../<(cgdir)/lib/cg.lib', + '../../<(cgdir)/lib/cgGL.lib', + 'd3d9.lib', + 'rpcrt4.lib', + ], + # Set /SUBSYSTEM:CONSOLE for converter.exe, since + # it is a console app. + 'SubSystem': '1', + }, + }, + }, + ], + ], + }, + ], + 'conditions': [ + ['OS != "linux"', + { + 'targets': [ + { + 'target_name': 'o3dPluginLogging', + 'type': 'static_library', + 'conditions': [ + ['OS=="win"', + { + 'sources': [ + 'win/plugin_metrics-win32.cc', + 'win/plugin_logging-win32.cc', + ], + }, + ], + ['OS=="mac"', + { + 'sources': [ + 'mac/plugin_metrics-mac.cc', + 'mac/plugin_logging-mac.mm', + ], + }, + ], + ], + }, + { + 'target_name': 'add_version', + 'type': 'none', + 'actions': [ + { + 'action_name': 'add_version', + 'inputs': [ + 'version_info.py', + ], + 'conditions': [ + ['OS=="win"', + { + 'inputs': [ + 'win/o3dPlugin.rc_template', + ], + 'outputs': [ + 'win/o3dPlugin.rc' + ], + 'action': ['python', + 'version_info.py', + 'win/o3dPlugin.rc_template', + 'win/o3dPlugin.rc'], + }, + ], + ['OS=="mac"', + { + 'inputs': [ + 'mac/processed/Info.plist', + ], + 'outputs': [ + 'mac/Info.plist', + ], + 'action': ['python', + 'version_info.py', + 'mac/processed/Info.plist', + 'mac/Info.plist'], + }, + ], + ], + }, + ], + }, + ], + }, + ], + ], +} diff --git a/o3d/plugin/version_info.py b/o3d/plugin/version_info.py new file mode 100644 index 0000000..bda71841 --- /dev/null +++ b/o3d/plugin/version_info.py @@ -0,0 +1,130 @@ +#!/usr/bin/python2.4 +# Copyright 2009 Google Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# This script does substitution on a list of files for +# version-specific information relating to the plugin. + +import os.path +import re +import sys + +gflags_dir = os.path.join('..', '..', 'third_party', 'gflags', 'python') +sys.path.append(gflags_dir) + +import gflags + +FLAGS = gflags.FLAGS +gflags.DEFINE_boolean('kill_switch', False, + 'Generate version numbers for kill switch binary.') + +gflags.DEFINE_boolean('name', False, + 'Print out the plugin name and exit.') + +gflags.DEFINE_boolean('description', False, + 'Print out the plugin description and exit.') + +gflags.DEFINE_boolean('mimetype', False, + 'Print out the plugin mime type and exit.') + +gflags.DEFINE_boolean('version', False, + 'Print out the plugin version and exit.') + + +def GetDotVersion(version): + return '%d.%d.%d.%d' % version + +def GetCommaVersion(version): + return '%d,%d,%d,%d' % version + +def DoReplace(in_filename, out_filename, replacements): + '''Replace the version number in the given filename with the replacements.''' + if not os.path.exists(in_filename): + raise Exception(r'''Input template file %s doesn't exist.''' % file) + input_file = open(in_filename, 'r') + input = input_file.read() + input_file.close() + for (source, target) in replacements: + input = re.sub(source, target, input) + + output_file = open(out_filename, 'wb') + output_file.write(input) + output_file.close() + +def main(argv): + try: + files = FLAGS(argv) # Parse flags + except gflags.FlagsError, e: + print '%s.\nUsage: %s [<options>] [<input_file> <output_file>]\n%s' % \ + (e, sys.argv[0], FLAGS) + sys.exit(1) + + # Strip off argv[0] + files = files[1:] + + # Get version string from o3d_version.py + o3d_version_vars = {} + if FLAGS.kill_switch: + execfile('../installer/win/o3d_kill_version.py', o3d_version_vars) + else: + execfile('../installer/win/o3d_version.py', o3d_version_vars) + + plugin_version = o3d_version_vars['plugin_version'] + sdk_version = o3d_version_vars['sdk_version'] + + # This name is used by Javascript to find the plugin therefore it must + # not change. If you change this you must change the name in + # samples/o3djs/util.js but be aware, changing the name + # will break all apps that use o3d on the web. + O3D_PLUGIN_NAME = 'O3D Plugin' + O3D_PLUGIN_VERSION = GetDotVersion(plugin_version) + O3D_PLUGIN_VERSION_COMMAS = GetCommaVersion(plugin_version) + O3D_SDK_VERSION = GetDotVersion(sdk_version) + O3D_SDK_VERSION_COMMAS = GetCommaVersion(sdk_version) + O3D_PLUGIN_DESCRIPTION = '%s version:%s' % (O3D_PLUGIN_NAME, + O3D_PLUGIN_VERSION) + O3D_PLUGIN_MIME_TYPE = 'application/vnd.o3d.auto' + + if FLAGS.name: + print '%s' % O3D_PLUGIN_NAME + sys.exit(0) + + if FLAGS.description: + print '%s' % O3D_PLUGIN_DESCRIPTION + sys.exit(0) + + if FLAGS.mimetype: + print '%s' % O3D_PLUGIN_MIME_TYPE + sys.exit(0) + + if FLAGS.version: + print '%s' % O3D_PLUGIN_VERSION + sys.exit(0) + + plugin_replace_strings = [ + ('@@@PluginName@@@', O3D_PLUGIN_NAME), + ('@@@ProductVersionCommas@@@', O3D_PLUGIN_VERSION_COMMAS), + ('@@@ProductVersion@@@', O3D_PLUGIN_VERSION), + ('@@@PluginDescription@@@', O3D_PLUGIN_DESCRIPTION), + ('@@@PluginMimeType@@@', O3D_PLUGIN_MIME_TYPE), + ] + + if len(files) == 2: + DoReplace(files[0], files[1], plugin_replace_strings) + elif len(files) > 0: + raise Exception(r'You must supply and input and output filename for ' + r'replacement.') + +if __name__ == '__main__': + main(sys.argv) |