码迷,mamicode.com
首页 > 其他好文 > 详细

pdfium舍弃v8依赖

时间:2019-12-09 13:30:27      阅读:145      评论:0      收藏:0      [点我收藏+]

标签:flag   safe   文本编辑   asc   windows平台   init   gyp   set   直接   

Step 3 去除v8依赖

用文本编辑器打开pdfium根目录下的pdfium.gyp文件,找到‘javascript‘及‘jsapi‘依赖(47行左右):

      ‘dependencies‘: [
        ‘safemath‘,
        ‘fdrm‘,
        ‘fpdfdoc‘,
        ‘fpdfapi‘,
        ‘fpdftext‘,
        ‘formfiller‘,
        ‘fxcodec‘,
        ‘fxcrt‘,
        ‘fxedit‘,
        ‘fxge‘,
        ‘javascript‘,
        ‘jsapi‘,
        ‘pdfwindow‘,
      ],

将其移除并删除对应的工程(734行至812行):

    {
      ‘target_name‘: ‘javascript‘,
      ‘type‘: ‘static_library‘,
        ‘include_dirs‘: [
          ‘<(DEPTH)/v8‘,
          ‘<(DEPTH)/v8/include‘,
        ],
      ‘dependencies‘: [
        ‘<(DEPTH)/v8/tools/gyp/v8.gyp:v8‘,
        ‘<(DEPTH)/v8/tools/gyp/v8.gyp:v8_libplatform‘,
      ],
      ‘export_dependent_settings‘: [
        ‘<(DEPTH)/v8/tools/gyp/v8.gyp:v8‘,
      ],
      ‘ldflags‘: [ ‘-L<(PRODUCT_DIR)‘,],
      ‘sources‘: [
        ‘fpdfsdk/include/javascript/app.h‘,
        ‘fpdfsdk/include/javascript/color.h‘,
        ‘fpdfsdk/include/javascript/console.h‘,
        ‘fpdfsdk/include/javascript/Consts.h‘,
        ‘fpdfsdk/include/javascript/Document.h‘,
        ‘fpdfsdk/include/javascript/event.h‘,
        ‘fpdfsdk/include/javascript/Field.h‘,
        ‘fpdfsdk/include/javascript/global.h‘,
        ‘fpdfsdk/include/javascript/Icon.h‘,
        ‘fpdfsdk/include/javascript/IJavaScript.h‘,
        ‘fpdfsdk/include/javascript/JavaScript.h‘,
        ‘fpdfsdk/include/javascript/JS_Console.h‘,
        ‘fpdfsdk/include/javascript/JS_Context.h‘,
        ‘fpdfsdk/include/javascript/JS_Define.h‘,
        ‘fpdfsdk/include/javascript/JS_EventHandler.h‘,
        ‘fpdfsdk/include/javascript/JS_GlobalData.h‘,
        ‘fpdfsdk/include/javascript/JS_Module.h‘,
        ‘fpdfsdk/include/javascript/JS_Object.h‘,
        ‘fpdfsdk/include/javascript/JS_Runtime.h‘,
        ‘fpdfsdk/include/javascript/JS_Value.h‘,
        ‘fpdfsdk/include/javascript/PublicMethods.h‘,
        ‘fpdfsdk/include/javascript/report.h‘,
        ‘fpdfsdk/include/javascript/resource.h‘,
        ‘fpdfsdk/include/javascript/util.h‘,
        ‘fpdfsdk/src/javascript/app.cpp‘,
        ‘fpdfsdk/src/javascript/color.cpp‘,
        ‘fpdfsdk/src/javascript/console.cpp‘,
        ‘fpdfsdk/src/javascript/Consts.cpp‘,
        ‘fpdfsdk/src/javascript/Document.cpp‘,
        ‘fpdfsdk/src/javascript/event.cpp‘,
        ‘fpdfsdk/src/javascript/Field.cpp‘,
        ‘fpdfsdk/src/javascript/global.cpp‘,
        ‘fpdfsdk/src/javascript/Icon.cpp‘,
        ‘fpdfsdk/src/javascript/JS_Context.cpp‘,
        ‘fpdfsdk/src/javascript/JS_EventHandler.cpp‘,
        ‘fpdfsdk/src/javascript/JS_GlobalData.cpp‘,
        ‘fpdfsdk/src/javascript/JS_Object.cpp‘,
        ‘fpdfsdk/src/javascript/JS_Runtime.cpp‘,
        ‘fpdfsdk/src/javascript/JS_Value.cpp‘,
        ‘fpdfsdk/src/javascript/PublicMethods.cpp‘,
        ‘fpdfsdk/src/javascript/report.cpp‘,
        ‘fpdfsdk/src/javascript/util.cpp‘,
      ],
    },
    {
      ‘target_name‘: ‘jsapi‘,
      ‘type‘: ‘static_library‘,
      ‘dependencies‘: [
        ‘<(DEPTH)/v8/tools/gyp/v8.gyp:v8‘,
      ],
      ‘export_dependent_settings‘: [
        ‘<(DEPTH)/v8/tools/gyp/v8.gyp:v8‘,
      ],
      ‘include_dirs‘: [
        ‘<(DEPTH)/v8‘,
        ‘<(DEPTH)/v8/include‘,
      ],
      ‘ldflags‘: [ ‘-L<(PRODUCT_DIR)‘,],
      ‘sources‘: [
        ‘fpdfsdk/include/jsapi/fxjs_v8.h‘,
        ‘fpdfsdk/src/jsapi/fxjs_v8.cpp‘,
      ],
    },

‘javascript‘是将pdf js规定的对象嵌入到js引擎中,使得PDF引擎使用的js引擎是标准js的超集。

‘jsapi‘则是导入v8的接口

如果是在windows平台下编译,到这里就可以直接使用gyp生成vs工程了。如果是linux平台的还需要进一步移除源码中对js的引用,均位于

fpdfsdk/src/fsdk_mgr.cpp

文件中。

  • 注释掉第11行的头文件应用
//#include "../include/javascript/IJavaScript.h"
  • 注释掉215行GetJSRuntimeFactory()函数及其引用(235-238)
CJS_RuntimeFactory* GetJSRuntimeFactory()
{
	static CJS_RuntimeFactory s_JSRuntimeFactory;
	return &s_JSRuntimeFactory;
}


	m_pJSRuntimeFactory = NULL;
	m_pJSRuntimeFactory = GetJSRuntimeFactory();
	m_pJSRuntimeFactory->AddRef();
  • 置CPDFDoc_Environment::GetJSRuntime()函数返回NULL
IFXJS_Runtime* CPDFDoc_Environment::GetJSRuntime()
{
	/*if(!IsJSInitiated())
		return NULL;
	assert(m_pJSRuntimeFactory);
	if(!m_pJSRuntime)
		m_pJSRuntime = m_pJSRuntimeFactory->NewJSRuntime(this);
	return m_pJSRuntime;*/
	return NULL;
}

OK,前置任务完成!进入编译。

 

https://zhuanlan.zhihu.com/p/37729756

pdfium舍弃v8依赖

标签:flag   safe   文本编辑   asc   windows平台   init   gyp   set   直接   

原文地址:https://www.cnblogs.com/hshy/p/12010194.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!