linux中搭建firebreath環境及創建plugin

Building a FireBreath Plugin on Linux

The following describes the process to build the example FireBreath plugin on Linux; pretty much the same process applies to building your own plugin - differences should be noted.

See Also: FireBreath Tips: Working with Source Control

Requirements

In Debian: 

apt-get install cmake libgtk2.0-dev git

In Fedora: 

yum install cmake gtk2-devel git

 

Get the source

First thing is first; get the source code.

To get a copy of the source, see the download page.

Generate the example project files

To generate the project files execute:
./prepmake.sh examples

The project build files will all be generated into the buildex/ directory under the project root.

Generate your own project files

If you have created your own project in the projects/ directory, you can build it by running the same command as for example projects, but (this will be a shocker) without "examples".

To generate the project build files:
./prepmake.sh

The project build files will all be generated into the build/ directory under the project root - this only has to be done after either adding or generating another FireBreath project.

Build the Plugin

The example plugin can be built by changing to the directory buildex and executing:

make

To build your own project, change to the directory build/ and execute:

make

Debug Builds

You can pass arguments to the prepmake command - see the full list at Prep Scripts.  For example:

./prepmake.sh examples -D CMAKE_BUILD_TYPE="Debug"
cd buildex
make

Removing the libgtk2.0-dev dependency

If you plan to do drawing, then libgtk2.0-dev is required because that's what the browser uses to draw. If you aren't planning to draw, you can add the following line to PluginConfig.cmake:

set(FB_GUI_DISABLED 1)

Make the plugin accessible

Most browsers on Linux look for NPAPI plugins in either "/usr/lib/mozilla/plugins" or "~/.mozilla/plugins" (Firefox, Chrome, Chromium, Arora); copy the plugin file to one of those locations -

cp buildex/bin/FBTestPlugin/npFBTestPlugin.so ~/.mozilla/plugins/.

You can copy the plugin shared object file to either of those locations, easiest is most likely "~/.mozilla/plugins" as root privileges are not required. Alternately you could use a link.

Open in your browser and play with it

Open the file buildex/projects/FBTestPlugin/gen/FBControl.htm in your preferred browser

Use Jash or firebug (or whatever) to make calls on the plugin. For supported calls, check out projects/TemplatePlugin/MathAPI.cpp.

A few JS commands to try:

plugin().echo("echo this string!")
"Echoing: echo this string!"
plugin().valid
true
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章