Cef應用資源佈局

Application Layout

應用資源佈局

Application layout can differ significantly depending on the platform. For example, on Mac OS X your application layout must follow a specific app bundle structure. Windows and Linux are more flexible, allowing you to customize the location where CEF libraries and resources are stored. For a complete working example of the required layout you can download a client archive from the project Downloads page. Some files are optional and some are required as detailed in the README.txt file for each platform.

應用資源佈局依賴於平臺,有很大的不同。比如,在Mac OS X上,你的資源佈局必須遵循特定的app bundles結構;Window與Linux則更靈活,允許你定製CEF庫文件與資源文件所在的位置。爲了獲取到特定地、可以正常工作的示例,你可以從工程的下載頁面,下載到一個client壓縮包,每個平臺對應的README.txt文件詳細說明了哪些文件是可選的,哪些文件是必須的。

Windows
Windows操作系統

On Windows the default layout places the libcef library and related resources next to the application executable. The directory structure looks like this:

在Windows平臺上,默認的資源佈局將libcef庫文件、相關資源與可執行文件放置在同級目錄,文件夾結構如下類似:

  1. Application/
  2. cefclient.exe <= cefclient application executable <= cefclient可執行程序
  3. libcef.dll <= main CEF library <= CEF基本庫
  4. icudt.dll <= ICU unicode support library <= ICU unicode支持庫
  5. ffmpegsumo.dll <= HTML5 audio/video support library <= HTML5音頻視頻支持庫
  6. libEGL.dll, libGLESv2.dll, <= accelerated compositing support libraries <= 加速合成支持庫
  7. cef.pak, devtools_resources.pak <= non-localized resources and strings <= 非本地語言資源與字符串
  8. locales/
  9. en-US.pak, <= locale-specific resources and strings <= 本地語言相關資源與字符串

The location of the CEF libraries and resource files can be customized using the CefSettings structure (see the README.txt file or “CefSettings” section for details). The cefclient application on Windows compiles in resources via the BINARY resource type in cefclient.rc but an application could just as easily load resources from the local file system.

使用結構體CefSettings可以定製CEF庫文件、資源文件的位置(查看README.txt文件或者本文中CefSettings部分獲取更詳細的信息)。雖然在Windows平臺上,cefclient項目將資源文件以二進制形式編譯進cefclient.rc文件,但是改爲從文件系統加載資源也很容易。

Linux
Linux操作系統

On Linux the default layout places the libcef library and related resources next to the application executable. Note however that there’s a discrepancy between where libcef.so is located in the client distribution and where it’s located in the binary distribution that you build yourself. The location depends on how the linker rpath value is set when building the application executable. For example, a value of “-Wl,-rpath,.” (“.” meaning the current directory) will allow you to place libcef.so next to the application executable. The path to libcef.so can also be specified using the LD_LIBRARY_PATH environment variable.

在Linux平臺上,默認的資源佈局將libcef庫文件、相關資源與可執行文件放置在同級目錄。注意:在你編譯的版本與發行版本應用程序中,libcef.so的位置是有差異的,此文件的位置取決於編譯可執行程序時,編譯器rpath的值。比如,編譯選項爲“-Wl,-rpath,.”(“.”意思是當前文件夾),這樣libcef.so與可執行文件處於同級目錄。libcef.so文件的路徑可以通過環境變量中的“LD_LIBRARY_PATH”指定。

  1. Application/
  2. cefclient <= cefclient application executable <= cefclient可執行程序
  3. libcef.so <= main CEF library <= CEF基本庫
  4. ffmpegsumo.so <-- HTML5 audio/video support library <-- HTML5音頻視頻支持庫
  5. cef.pak, devtools_resources.pak <= non-localized resources and strings <= 非本地語言資源與字符串
  6. locales/
  7. en-US.pak, <= locale-specific resources and strings <= 本地語言相關資源與字符串
  8. files/
  9. binding.html, <= cefclient application resources <= cefclient程序需要的資源

The location of the CEF libraries and resource files can be customized using the CefSettings structure (see the README.txt file of “CefSettings” section for details).

使用結構體CefSettings可以定製CEF庫文件、資源文件(查看README.txt文件或者本文中CefSettings部分獲取更詳細的信息)。

Mac OS X
Mac X平臺

The application (app bundle) layout on Mac OS X is mandated by the Chromium implementation and consequently is not very flexible. The directory structure looks like this:

在Mac X平臺上,app bundles委託給了Chromium實現,因此不是很靈活。文件夾結構如下類似:

  1. cefclient.app/
  2. Contents/
  3. Frameworks/
  4. Chromium Embedded Framework.framework/
  5. Libraries/
  6. ffmpegsumo.so <= HTML5 audio/video support library <= HTML5音頻視頻文件
  7. libcef.dylib <= main CEF library <= CEF基本庫
  8. Resources/
  9. cef.pak, devtools_resources.pak <= non-localized resources and strings
  10. *.png, *.tiff <= Blink image and cursor resources <= Blink圖片與光標樣式資源
  11. en.lproj/, <= locale-specific resources and strings <= 本地語言資源與字符串
  12. libplugin_carbon_interpose.dylib <= plugin support library <= 插件支持庫
  13. cefclient Helper.app/
  14. Contents/
  15. Info.plist
  16. MacOS/
  17. cefclient Helper <= helper executable <= 可執行的幫助器
  18. Pkginfo
  19. cefclient Helper EH.app/
  20. Contents/
  21. Info.plist
  22. MacOS/
  23. cefclient Helper EH <= helper executable <= 可執行的幫助器
  24. Pkginfo
  25. cefclient Helper NP.app/
  26. Contents/
  27. Info.plist
  28. MacOS/
  29. cefclient Helper NP <= helper executable <= 可執行的幫助器
  30. Pkginfo
  31. Info.plist
  32. MacOS/
  33. cefclient <= cefclient application executable <= cefclient可執行程序
  34. Pkginfo
  35. Resources/
  36. binding.html, <= cefclient application resources <= cefclient程序需要的資源

The "Chromium Embedded Framework.framework" is an unversioned framework that contains all CEF binaries and resources. Executables (cefclient, cefclient Helper, etc) are linked to libcef.dylib using install_name_tool and a path relative to @executable_path.

列表中的“Chromium Embedded Framework.framework”,這個未受版本管控的框架包含了所有的CEF庫文件、資源文件。使用install_name_tool與@executable_path,將cefclient,cefclient helper等可執行文件,連接到了libcef.dylib上。

The "cefclient Helper" apps are used for executing separate processes (renderer, plugin, etc) with different characteristics. They need to have separate app bundles and Info.plist files so that, among other things, they don't show dock icons. The "EH" helper, which is used when launching plugin processes, has the MH_NO_HEAP_EXECUTION bit cleared to allow an executable heap. The "NP" helper, which is used when launching NaCl plugin processes only, has the MH_PIE bit cleared to disable ASLR. This is set up as part of the build process using scripts from the tools/ directory. Examine the Xcode project included with the binary distribution or the originating cefclient.gyp file for a better idea of the script dependencies.

應用程序cefclient helper用來執行不同特點、獨立的進程(renderer,plugin等),這些進程需要獨立的資源佈局與Info.plist等文件,它們沒有顯示停靠圖標。用來啓動插件進程的EH Helper清除了MH_NO_HEAP_EXECUTION標誌位,這樣就允許一個可執行堆。只能用來啓動NaCL插件進程的NP Helper,清除了MH_PIE標誌位,這樣就禁用了ASLR。這些都是tools文件夾下面,用來構建進程腳本的一部分。爲了理清腳本的依賴關係,更好的做法是檢查發行版本中的Xcode工程或者原始文件cefclient.gyp。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章