enable shared lib support in linux for lua
authorzachr@google.com <zachr@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Thu, 20 Jun 2013 17:15:05 +0000 (17:15 +0000)
committerzachr@google.com <zachr@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Thu, 20 Jun 2013 17:15:05 +0000 (17:15 +0000)
R=bungeman@google.com, reed@google.com

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

git-svn-id: http://skia.googlecode.com/svn/trunk@9703 2bbb7eff-a529-9590-31e7-b0007b416f81

gyp/common.gypi
gyp/common_conditions.gypi
gyp/tools.gyp
src/utils/SkLua.cpp

index 05fdbf4..54c14cd 100644 (file)
         }],
       ],
     },
-    # Validate the 'skia_os' setting against 'skia_shared_lib', because shared
-    # library build is only supported on Android.
-    'variables': {
-      'conditions': [
-        [ 'skia_os != "android" and skia_shared_lib', {
-          'error': '<!(Skia shared lib build only currently supported on Android.)',
-        }],
-      ],
-    },
     'includes': [
       'common_conditions.gypi',
     ],
index 54e4ad6..3a49f14 100644 (file)
           '-Wno-c++11-extensions'
         ],
         'conditions' : [
+          [ 'skia_shared_lib', {
+            'cflags': [
+              '-fPIC',
+            ],
+            'defines': [
+              'GR_DLL=1',
+              'GR_IMPLEMENTATION=1',
+              'SKIA_DLL',
+              'SKIA_IMPLEMENTATION=1',
+            ],
+          }],
           [ 'skia_warnings_as_errors', {
             'cflags': [
               '-Werror',
index d960cdc..de1d8e9 100644 (file)
         'skhello',
         'skimage',
       ],
+      'conditions': [
+        ['skia_shared_lib',
+          {
+            'dependencies': [
+              'sklua', # This can only be built if skia is built as a shared library
+            ],
+          },
+        ],
+      ],
     },
     {
       'target_name': 'skdiff',
         'utils.gyp:utils',
       ],
     },
+
     {
       'target_name': 'lua_app',
       'type': 'executable',
     },
   ],
   'conditions': [
+    ['skia_shared_lib',
+      {
+        'targets': [
+          {
+            'target_name': 'sklua',
+            'product_name': 'skia',
+            'product_prefix': '',
+            'product_dir': '<(PRODUCT_DIR)/',
+            'type': 'shared_library',
+            'sources': [
+              '../src/utils/SkLuaCanvas.cpp',
+              '../src/utils/SkLua.cpp',
+            ],
+            'include_dirs': [
+              '../third_party/lua/src/',
+            ],
+            'dependencies': [
+              'lua.gyp:lua',
+              'pdf.gyp:pdf',
+              'skia_lib.gyp:skia_lib',
+            ],
+            'conditions': [
+              ['skia_os != "win"',
+                {
+                  'ldflags': [
+                    '-Wl,-rpath,\$$ORIGIN,--enable-new-dtags',
+                  ],
+                },
+              ],
+            ],
+          },
+        ],
+      },
+    ],
     ['skia_win_debuggers_path and skia_os == "win"',
       {
         'targets': [
index aabb236..296229b 100644 (file)
@@ -949,3 +949,8 @@ void SkLua::Load(lua_State* L) {
     REG_CLASS(L, SkRRect);
     REG_CLASS(L, SkTypeface);
 }
+
+extern "C" int luaopen_skia(lua_State* L) {
+    SkLua::Load(L);
+    return 0;
+}