[gin] Turn gin into a component

This will allow for using gin from content and blink at the same time in
a component build

BUG=321631
[email protected],[email protected]

Review URL: https://codereview.chromium.org/101583004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@240425 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/gin/arguments.h b/gin/arguments.h
index 1461dc8..104152ab 100644
--- a/gin/arguments.h
+++ b/gin/arguments.h
@@ -7,13 +7,14 @@
 
 #include "base/basictypes.h"
 #include "gin/converter.h"
+#include "gin/gin_export.h"
 
 namespace gin {
 
 // Arguments is a wrapper around v8::FunctionCallbackInfo that integrates
 // with Converter to make it easier to marshall arguments and return values
 // between V8 and C++.
-class Arguments {
+class GIN_EXPORT Arguments {
  public:
   Arguments();
   explicit Arguments(const v8::FunctionCallbackInfo<v8::Value>& info);
diff --git a/gin/array_buffer.cc b/gin/array_buffer.cc
index e8e234e..ee9f2a5 100644
--- a/gin/array_buffer.cc
+++ b/gin/array_buffer.cc
@@ -127,6 +127,13 @@
 ArrayBuffer::~ArrayBuffer() {
 }
 
+ArrayBuffer& ArrayBuffer::operator=(const ArrayBuffer& other) {
+  private_ = other.private_;
+  bytes_ = other.bytes_;
+  num_bytes_ = other.num_bytes_;
+  return *this;
+}
+
 // Converter<ArrayBuffer> -----------------------------------------------------
 
 bool Converter<ArrayBuffer>::FromV8(v8::Isolate* isolate,
diff --git a/gin/array_buffer.h b/gin/array_buffer.h
index 3169fd0..7886fa9 100644
--- a/gin/array_buffer.h
+++ b/gin/array_buffer.h
@@ -9,6 +9,7 @@
 #include "base/compiler_specific.h"
 #include "base/memory/ref_counted.h"
 #include "gin/converter.h"
+#include "gin/gin_export.h"
 #include "v8/include/v8.h"
 
 namespace gin {
@@ -22,12 +23,13 @@
   static ArrayBufferAllocator* SharedInstance();
 };
 
-class ArrayBuffer {
+class GIN_EXPORT ArrayBuffer {
  public:
   ArrayBuffer();
   explicit ArrayBuffer(v8::Isolate* isolate);
   ArrayBuffer(v8::Isolate* isolate, v8::Handle<v8::ArrayBuffer> buffer);
   ~ArrayBuffer();
+  ArrayBuffer& operator=(const ArrayBuffer& other);
 
   void* bytes() const { return bytes_; }
   size_t num_bytes() const { return num_bytes_; }
@@ -43,12 +45,12 @@
 };
 
 template<>
-struct Converter<ArrayBuffer> {
+struct GIN_EXPORT Converter<ArrayBuffer> {
   static bool FromV8(v8::Isolate* isolate, v8::Handle<v8::Value> val,
                      ArrayBuffer* out);
 };
 
-class ArrayBufferView {
+class GIN_EXPORT ArrayBufferView {
  public:
   ArrayBufferView();
   ArrayBufferView(v8::Isolate* isolate, v8::Handle<v8::ArrayBufferView> view);
@@ -68,7 +70,7 @@
 };
 
 template<>
-struct Converter<ArrayBufferView> {
+struct GIN_EXPORT Converter<ArrayBufferView> {
   static bool FromV8(v8::Isolate* isolate, v8::Handle<v8::Value> val,
                      ArrayBufferView* out);
 };
diff --git a/gin/converter.h b/gin/converter.h
index f0bc6a2..ee029a7 100644
--- a/gin/converter.h
+++ b/gin/converter.h
@@ -9,6 +9,7 @@
 #include <vector>
 
 #include "base/strings/string_piece.h"
+#include "gin/gin_export.h"
 #include "v8/include/v8.h"
 
 namespace gin {
@@ -17,7 +18,7 @@
 struct Converter {};
 
 template<>
-struct Converter<bool> {
+struct GIN_EXPORT Converter<bool> {
   static v8::Handle<v8::Value> ToV8(v8::Isolate* isolate,
                                     bool val);
   static bool FromV8(v8::Isolate* isolate,
@@ -26,7 +27,7 @@
 };
 
 template<>
-struct Converter<int32_t> {
+struct GIN_EXPORT Converter<int32_t> {
   static v8::Handle<v8::Value> ToV8(v8::Isolate* isolate,
                                     int32_t val);
   static bool FromV8(v8::Isolate* isolate,
@@ -35,7 +36,7 @@
 };
 
 template<>
-struct Converter<uint32_t> {
+struct GIN_EXPORT Converter<uint32_t> {
   static v8::Handle<v8::Value> ToV8(v8::Isolate* isolate,
                                     uint32_t val);
   static bool FromV8(v8::Isolate* isolate,
@@ -44,7 +45,7 @@
 };
 
 template<>
-struct Converter<int64_t> {
+struct GIN_EXPORT Converter<int64_t> {
   // Warning: JavaScript cannot represent 64 integers precisely.
   static v8::Handle<v8::Value> ToV8(v8::Isolate* isolate,
                                     int64_t val);
@@ -54,7 +55,7 @@
 };
 
 template<>
-struct Converter<uint64_t> {
+struct GIN_EXPORT Converter<uint64_t> {
   // Warning: JavaScript cannot represent 64 integers precisely.
   static v8::Handle<v8::Value> ToV8(v8::Isolate* isolate,
                                     uint64_t val);
@@ -64,7 +65,7 @@
 };
 
 template<>
-struct Converter<double> {
+struct GIN_EXPORT Converter<double> {
   static v8::Handle<v8::Value> ToV8(v8::Isolate* isolate,
                                     double val);
   static bool FromV8(v8::Isolate* isolate,
@@ -73,14 +74,14 @@
 };
 
 template<>
-struct Converter<base::StringPiece> {
+struct GIN_EXPORT Converter<base::StringPiece> {
   static v8::Handle<v8::Value> ToV8(v8::Isolate* isolate,
                                     const base::StringPiece& val);
   // No conversion out is possible because StringPiece does not contain storage.
 };
 
 template<>
-struct Converter<std::string> {
+struct GIN_EXPORT Converter<std::string> {
   static v8::Handle<v8::Value> ToV8(v8::Isolate* isolate,
                                     const std::string& val);
   static bool FromV8(v8::Isolate* isolate,
@@ -89,14 +90,14 @@
 };
 
 template<>
-struct Converter<v8::Handle<v8::Function> > {
+struct GIN_EXPORT Converter<v8::Handle<v8::Function> > {
   static bool FromV8(v8::Isolate* isolate,
                      v8::Handle<v8::Value> val,
                      v8::Handle<v8::Function>* out);
 };
 
 template<>
-struct Converter<v8::Handle<v8::Object> > {
+struct GIN_EXPORT Converter<v8::Handle<v8::Object> > {
   static v8::Handle<v8::Value> ToV8(v8::Isolate* isolate,
                                     v8::Handle<v8::Object> val);
   static bool FromV8(v8::Isolate* isolate,
@@ -105,7 +106,7 @@
 };
 
 template<>
-struct Converter<v8::Handle<v8::ArrayBuffer> > {
+struct GIN_EXPORT Converter<v8::Handle<v8::ArrayBuffer> > {
   static v8::Handle<v8::Value> ToV8(v8::Isolate* isolate,
                                     v8::Handle<v8::ArrayBuffer> val);
   static bool FromV8(v8::Isolate* isolate,
@@ -114,7 +115,7 @@
 };
 
 template<>
-struct Converter<v8::Handle<v8::External> > {
+struct GIN_EXPORT Converter<v8::Handle<v8::External> > {
   static v8::Handle<v8::Value> ToV8(v8::Isolate* isolate,
                                     v8::Handle<v8::External> val);
   static bool FromV8(v8::Isolate* isolate,
@@ -123,7 +124,7 @@
 };
 
 template<>
-struct Converter<v8::Handle<v8::Value> > {
+struct GIN_EXPORT Converter<v8::Handle<v8::Value> > {
   static v8::Handle<v8::Value> ToV8(v8::Isolate* isolate,
                                     v8::Handle<v8::Value> val);
   static bool FromV8(v8::Isolate* isolate,
@@ -171,13 +172,14 @@
   return Converter<T>::ToV8(isolate, input);
 }
 
-inline v8::Handle<v8::String> StringToV8(v8::Isolate* isolate,
-                                         const base::StringPiece& input) {
+GIN_EXPORT inline v8::Handle<v8::String> StringToV8(
+    v8::Isolate* isolate,
+    const base::StringPiece& input) {
   return ConvertToV8(isolate, input).As<v8::String>();
 }
 
-v8::Handle<v8::String> StringToSymbol(v8::Isolate* isolate,
-                                      const base::StringPiece& val);
+GIN_EXPORT v8::Handle<v8::String> StringToSymbol(v8::Isolate* isolate,
+                                                 const base::StringPiece& val);
 
 template<typename T>
 bool ConvertFromV8(v8::Isolate* isolate, v8::Handle<v8::Value> input,
@@ -185,7 +187,7 @@
   return Converter<T>::FromV8(isolate, input, result);
 }
 
-std::string V8ToString(v8::Handle<v8::Value> value);
+GIN_EXPORT std::string V8ToString(v8::Handle<v8::Value> value);
 
 }  // namespace gin
 
diff --git a/gin/dictionary.h b/gin/dictionary.h
index bc55087..972108f 100644
--- a/gin/dictionary.h
+++ b/gin/dictionary.h
@@ -6,6 +6,7 @@
 #define GIN_DICTIONARY_H_
 
 #include "gin/converter.h"
+#include "gin/gin_export.h"
 
 namespace gin {
 
@@ -21,7 +22,7 @@
 //          v8::HandleScope. Generally speaking, you should store a Dictionary
 //          on the stack.
 //
-class Dictionary {
+class GIN_EXPORT Dictionary {
  public:
   explicit Dictionary(v8::Isolate* isolate);
   Dictionary(v8::Isolate* isolate, v8::Handle<v8::Object> object);
@@ -51,7 +52,7 @@
 };
 
 template<>
-struct Converter<Dictionary> {
+struct GIN_EXPORT Converter<Dictionary> {
   static v8::Handle<v8::Value> ToV8(v8::Isolate* isolate,
                                     Dictionary val);
   static bool FromV8(v8::Isolate* isolate,
diff --git a/gin/function_template.h b/gin/function_template.h
index 9db039d..14f6e78 100644
--- a/gin/function_template.h
+++ b/gin/function_template.h
@@ -15,6 +15,7 @@
 #include "base/logging.h"
 #include "gin/arguments.h"
 #include "gin/converter.h"
+#include "gin/gin_export.h"
 #include "gin/handle.h"
 #include "gin/public/gin_embedders.h"
 #include "gin/public/wrapper_info.h"
@@ -58,10 +59,9 @@
 
 // This simple base class is used so that we can share a single object template
 // among every CallbackHolder instance.
-class CallbackHolderBase : public Wrappable<CallbackHolderBase> {
+class GIN_EXPORT CallbackHolderBase : public Wrappable<CallbackHolderBase> {
  public:
   static WrapperInfo kWrapperInfo;
-
  protected:
   virtual ~CallbackHolderBase() {}
 };
@@ -333,7 +333,7 @@
 
 // This should be called once per-isolate to initialize the function template
 // system.
-void InitFunctionTemplates(PerIsolateData* isolate_data);
+GIN_EXPORT void InitFunctionTemplates(PerIsolateData* isolate_data);
 
 
 // CreateFunctionTemplate creates a v8::FunctionTemplate that will create
diff --git a/gin/function_template.h.pump b/gin/function_template.h.pump
index f9ae5ff..fad718f 100644
--- a/gin/function_template.h.pump
+++ b/gin/function_template.h.pump
@@ -18,6 +18,7 @@
 #include "base/logging.h"
 #include "gin/arguments.h"
 #include "gin/converter.h"
+#include "gin/gin_export.h"
 #include "gin/handle.h"
 #include "gin/public/gin_embedders.h"
 #include "gin/public/wrapper_info.h"
@@ -61,7 +62,7 @@
 
 // This simple base class is used so that we can share a single object template
 // among every CallbackHolder instance.
-class CallbackHolderBase : public Wrappable<CallbackHolderBase> {
+class GIN_EXPORT CallbackHolderBase : public Wrappable<CallbackHolderBase> {
  public:
   static WrapperInfo kWrapperInfo;
 
@@ -188,7 +189,7 @@
 
 // This should be called once per-isolate to initialize the function template
 // system.
-void InitFunctionTemplates(PerIsolateData* isolate_data);
+GIN_EXPORT void InitFunctionTemplates(PerIsolateData* isolate_data);
 
 
 // CreateFunctionTemplate creates a v8::FunctionTemplate that will create
diff --git a/gin/gin.gyp b/gin/gin.gyp
index 1f75469..8af1e8b 100644
--- a/gin/gin.gyp
+++ b/gin/gin.gyp
@@ -9,7 +9,7 @@
   'targets': [
     {
       'target_name': 'gin',
-      'type': 'static_library',
+      'type': '<(component)',
       'dependencies': [
         '../base/base.gyp:base',
         '../v8/tools/gyp/v8.gyp:v8',
@@ -18,6 +18,9 @@
         '../base/base.gyp:base',
         '../v8/tools/gyp/v8.gyp:v8',
       ],
+      'defines': [
+        'GIN_IMPLEMENTATION',
+      ],
       'sources': [
         'arguments.cc',
         'arguments.h',
@@ -30,6 +33,7 @@
         'dictionary.h',
         'function_template.cc',
         'function_template.h',
+        'gin_export.h',
         'handle.h',
         'isolate_holder.cc',
         'modules/console.cc',
@@ -63,7 +67,9 @@
       'target_name': 'gin_shell',
       'type': 'executable',
       'dependencies': [
+        '../base/base.gyp:base',
         '../base/base.gyp:base_i18n',
+        '../v8/tools/gyp/v8.gyp:v8',
         'gin',
       ],
       'sources': [
@@ -80,6 +86,7 @@
       'type': 'static_library',
       'dependencies': [
         '../testing/gtest.gyp:gtest',
+        '../v8/tools/gyp/v8.gyp:v8',
         'gin',
       ],
       'export_dependent_settings': [
@@ -100,6 +107,7 @@
       'type': 'executable',
       'dependencies': [
         '../base/base.gyp:run_all_unittests',
+        '../v8/tools/gyp/v8.gyp:v8',
         'gin_test',
       ],
       'sources': [
diff --git a/gin/gin_export.h b/gin/gin_export.h
new file mode 100644
index 0000000..fc4bf9bc
--- /dev/null
+++ b/gin/gin_export.h
@@ -0,0 +1,29 @@
+// Copyright 2013 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.
+
+#ifndef GIN_GIN_EXPORT_H_
+#define GIN_GIN_EXPORT_H_
+
+#if defined(COMPONENT_BUILD)
+#if defined(WIN32)
+
+#if defined(GIN_IMPLEMENTATION)
+#define GIN_EXPORT __declspec(dllexport)
+#else
+#define GIN_EXPORT __declspec(dllimport)
+#endif  // defined(GIN_IMPLEMENTATION)
+
+#else  // defined(WIN32)
+#if defined(GIN_IMPLEMENTATION)
+#define GIN_EXPORT __attribute__((visibility("default")))
+#else
+#define GIN_EXPORT
+#endif  // defined(GIN_IMPLEMENTATION)
+#endif
+
+#else  // defined(COMPONENT_BUILD)
+#define GIN_EXPORT
+#endif
+
+#endif  // GIN_GIN_EXPORT_H_
diff --git a/gin/modules/console.h b/gin/modules/console.h
index 259fdaa7..8753961dd 100644
--- a/gin/modules/console.h
+++ b/gin/modules/console.h
@@ -5,13 +5,14 @@
 #ifndef GIN_MODULES_CONSOLE_H_
 #define GIN_MODULES_CONSOLE_H_
 
+#include "gin/gin_export.h"
 #include "v8/include/v8.h"
 
 namespace gin {
 
 // The Console module provides a basic API for printing to stdout. Over time,
 // we'd like to evolve the API to match window.console in browsers.
-class Console {
+class GIN_EXPORT Console {
  public:
   static const char kModuleName[];
   static v8::Local<v8::ObjectTemplate> GetTemplate(v8::Isolate* isolate);
diff --git a/gin/modules/file_module_provider.h b/gin/modules/file_module_provider.h
index 89e83b3b..dd75a0fe 100644
--- a/gin/modules/file_module_provider.h
+++ b/gin/modules/file_module_provider.h
@@ -10,6 +10,7 @@
 #include <vector>
 
 #include "base/files/file_path.h"
+#include "gin/gin_export.h"
 #include "gin/runner.h"
 
 namespace gin {
@@ -18,7 +19,7 @@
 // modules in the directories indiciated by |search_paths|. Although we still
 // read from the file system on the main thread, we'll eventually want to move
 // the reads to a background thread.
-class FileModuleProvider {
+class GIN_EXPORT FileModuleProvider {
  public:
   explicit FileModuleProvider(
       const std::vector<base::FilePath>& search_paths);
diff --git a/gin/modules/module_registry.h b/gin/modules/module_registry.h
index d3bed32..27606cd 100644
--- a/gin/modules/module_registry.h
+++ b/gin/modules/module_registry.h
@@ -13,6 +13,7 @@
 #include "base/callback.h"
 #include "base/compiler_specific.h"
 #include "base/memory/scoped_ptr.h"
+#include "gin/gin_export.h"
 #include "gin/per_context_data.h"
 
 namespace gin {
@@ -30,7 +31,7 @@
 // function. The spec says we should only add that property once our
 // implementation complies with the specification.
 //
-class ModuleRegistry : public ContextSupplement {
+class GIN_EXPORT ModuleRegistry : public ContextSupplement {
  public:
   typedef base::Callback<void (v8::Handle<v8::Value>)> LoadModuleCallback;
 
diff --git a/gin/modules/module_runner_delegate.h b/gin/modules/module_runner_delegate.h
index 1873d5a..06077f4 100644
--- a/gin/modules/module_runner_delegate.h
+++ b/gin/modules/module_runner_delegate.h
@@ -8,6 +8,7 @@
 #include <map>
 
 #include "base/compiler_specific.h"
+#include "gin/gin_export.h"
 #include "gin/modules/file_module_provider.h"
 #include "gin/runner.h"
 
@@ -19,7 +20,7 @@
 // Emebedders that use AMD modules will probably want to use a RunnerDelegate
 // that inherits from ModuleRunnerDelegate. ModuleRunnerDelegate lets embedders
 // register built-in modules and routes module requests to FileModuleProvider.
-class ModuleRunnerDelegate : public RunnerDelegate {
+class GIN_EXPORT ModuleRunnerDelegate : public RunnerDelegate {
  public:
   explicit ModuleRunnerDelegate(
       const std::vector<base::FilePath>& search_paths);
diff --git a/gin/object_template_builder.h b/gin/object_template_builder.h
index 3103678d..6367b71 100644
--- a/gin/object_template_builder.h
+++ b/gin/object_template_builder.h
@@ -11,6 +11,7 @@
 #include "base/template_util.h"
 #include "gin/converter.h"
 #include "gin/function_template.h"
+#include "gin/gin_export.h"
 #include "v8/include/v8.h"
 
 namespace gin {
@@ -54,7 +55,7 @@
 // This specialization allows people to construct function templates directly if
 // they need to do fancier stuff.
 template<>
-struct CallbackTraits<v8::Handle<v8::FunctionTemplate> > {
+struct GIN_EXPORT CallbackTraits<v8::Handle<v8::FunctionTemplate> > {
   static v8::Handle<v8::FunctionTemplate> CreateTemplate(
       v8::Handle<v8::FunctionTemplate> templ) {
     return templ;
@@ -66,7 +67,7 @@
 
 // ObjectTemplateBuilder provides a handy interface to creating
 // v8::ObjectTemplate instances with various sorts of properties.
-class ObjectTemplateBuilder {
+class GIN_EXPORT ObjectTemplateBuilder {
  public:
   explicit ObjectTemplateBuilder(v8::Isolate* isolate);
   ~ObjectTemplateBuilder();
diff --git a/gin/per_context_data.h b/gin/per_context_data.h
index ea8b169..3ad68d2d 100644
--- a/gin/per_context_data.h
+++ b/gin/per_context_data.h
@@ -8,6 +8,7 @@
 #include "base/basictypes.h"
 #include "base/memory/scoped_ptr.h"
 #include "base/memory/scoped_vector.h"
+#include "gin/gin_export.h"
 #include "v8/include/v8.h"
 
 namespace gin {
@@ -16,7 +17,7 @@
 
 // Embedders can store additional per-context data by subclassing
 // ContextSupplement.
-class ContextSupplement {
+class GIN_EXPORT ContextSupplement {
  public:
   ContextSupplement();
   virtual ~ContextSupplement();
@@ -31,7 +32,7 @@
 
 // There is one instance of PerContextData per v8::Context managed by Gin. This
 // class stores all the Gin-related data that varies per context.
-class PerContextData {
+class GIN_EXPORT PerContextData {
  public:
   explicit PerContextData(v8::Handle<v8::Context> context);
   ~PerContextData();
diff --git a/gin/per_isolate_data.h b/gin/per_isolate_data.h
index 11bbc03e..ed93545 100644
--- a/gin/per_isolate_data.h
+++ b/gin/per_isolate_data.h
@@ -8,6 +8,7 @@
 #include <map>
 
 #include "base/basictypes.h"
+#include "gin/gin_export.h"
 #include "gin/public/wrapper_info.h"
 #include "v8/include/v8.h"
 
@@ -15,7 +16,7 @@
 
 // There is one instance of PerIsolateData per v8::Isolate managed by Gin. This
 // class stores all the Gin-related data that varies per isolate.
-class PerIsolateData {
+class GIN_EXPORT PerIsolateData {
  public:
   explicit PerIsolateData(v8::Isolate* isolate);
   ~PerIsolateData();
diff --git a/gin/public/context_holder.h b/gin/public/context_holder.h
index 43b2822..09fe248 100644
--- a/gin/public/context_holder.h
+++ b/gin/public/context_holder.h
@@ -9,6 +9,7 @@
 
 #include "base/basictypes.h"
 #include "base/memory/scoped_ptr.h"
+#include "gin/gin_export.h"
 #include "v8/include/v8.h"
 
 namespace gin {
@@ -27,7 +28,7 @@
 // ContextHolder is a generic class for holding a v8::Context. Rather than
 // using ContextHolder directly, most code should use a subclass of
 // ContextHolder, such as Runner.
-class ContextHolder {
+class GIN_EXPORT ContextHolder {
  public:
   explicit ContextHolder(v8::Isolate* isolate);
   ~ContextHolder();
diff --git a/gin/public/isolate_holder.h b/gin/public/isolate_holder.h
index 809d329e..0d0654e 100644
--- a/gin/public/isolate_holder.h
+++ b/gin/public/isolate_holder.h
@@ -7,6 +7,7 @@
 
 #include "base/basictypes.h"
 #include "base/memory/scoped_ptr.h"
+#include "gin/gin_export.h"
 
 namespace v8 {
 class Isolate;
@@ -26,7 +27,7 @@
 // pass them to IsolateHolder.
 //
 // It is not possible to mix the two.
-class IsolateHolder {
+class GIN_EXPORT IsolateHolder {
  public:
   IsolateHolder();
   explicit IsolateHolder(v8::Isolate* isolate);
diff --git a/gin/public/wrapper_info.h b/gin/public/wrapper_info.h
index fe047c0..31b2a98 100644
--- a/gin/public/wrapper_info.h
+++ b/gin/public/wrapper_info.h
@@ -5,6 +5,7 @@
 #ifndef GIN_PUBLIC_WRAPPER_INFO_H_
 #define GIN_PUBLIC_WRAPPER_INFO_H_
 
+#include "gin/gin_export.h"
 #include "gin/public/gin_embedders.h"
 #include "v8/include/v8.h"
 
@@ -21,7 +22,7 @@
   kNumberOfInternalFields,
 };
 
-struct WrapperInfo {
+struct GIN_EXPORT WrapperInfo {
   static WrapperInfo* From(v8::Handle<v8::Object> object);
   const GinEmbedder embedder;
 };
diff --git a/gin/runner.h b/gin/runner.h
index 8ba2b681..943bced 100644
--- a/gin/runner.h
+++ b/gin/runner.h
@@ -8,6 +8,7 @@
 #include <string>
 
 #include "base/memory/weak_ptr.h"
+#include "gin/gin_export.h"
 #include "gin/public/context_holder.h"
 
 namespace gin {
@@ -18,7 +19,7 @@
 // Subclass RunnerDelegate to customize the behavior of |Runner|. Typical
 // embedders will want to subclass one of the specialized RunnerDelegates,
 // such as ModuleRunnerDelegate.
-class RunnerDelegate {
+class GIN_EXPORT RunnerDelegate {
  public:
   RunnerDelegate();
   virtual ~RunnerDelegate();
@@ -33,7 +34,7 @@
 
 // Runner lets you run code in a v8::Context. Upon construction, Runner will
 // create a v8::Context. Upon destruction, Runner will dispose the context.
-class Runner : public ContextHolder {
+class GIN_EXPORT Runner : public ContextHolder {
  public:
   Runner(RunnerDelegate* delegate, v8::Isolate* isolate);
   ~Runner();
@@ -58,7 +59,7 @@
     return weak_factory_.GetWeakPtr();
   }
 
-  class Scope {
+  class GIN_EXPORT Scope {
    public:
     explicit Scope(Runner* runner);
     ~Scope();
diff --git a/gin/try_catch.h b/gin/try_catch.h
index 390fb22..633b909 100644
--- a/gin/try_catch.h
+++ b/gin/try_catch.h
@@ -8,12 +8,13 @@
 #include <string>
 
 #include "base/basictypes.h"
+#include "gin/gin_export.h"
 #include "v8/include/v8.h"
 
 namespace gin {
 
 // TryCatch is a convenient wrapper around v8::TryCatch.
-class TryCatch {
+class GIN_EXPORT TryCatch {
  public:
   TryCatch();
   ~TryCatch();
diff --git a/gin/wrappable.h b/gin/wrappable.h
index b8202df9..75570716 100644
--- a/gin/wrappable.h
+++ b/gin/wrappable.h
@@ -7,14 +7,16 @@
 
 #include "base/template_util.h"
 #include "gin/converter.h"
+#include "gin/gin_export.h"
 #include "gin/public/wrapper_info.h"
 
 namespace gin {
 
 namespace internal {
 
-void* FromV8Impl(v8::Isolate* isolate, v8::Handle<v8::Value> val,
-                 WrapperInfo* info);
+GIN_EXPORT void* FromV8Impl(v8::Isolate* isolate,
+                            v8::Handle<v8::Value> val,
+                            WrapperInfo* info);
 
 }  // namespace internal
 
@@ -42,7 +44,7 @@
 
 
 // Non-template base class to share code between templates instances.
-class WrappableBase {
+class GIN_EXPORT WrappableBase {
  protected:
   WrappableBase();
   virtual ~WrappableBase();
diff --git a/mojo/mojo_apps.gypi b/mojo/mojo_apps.gypi
index 6e5ec4af..0efceff9 100644
--- a/mojo/mojo_apps.gypi
+++ b/mojo/mojo_apps.gypi
@@ -6,6 +6,7 @@
       'dependencies': [
         '../base/base.gyp:base',
         '../gin/gin.gyp:gin',
+        '../v8/tools/gyp/v8.gyp:v8',
         'mojo_common_lib',
         'mojo_gles2',
         'mojo_gles2_bindings',