Saturday, August 29, 2009

install Chromium for Linux x86_64 on openSUSE

(continued from phosphorescence: Prepare to install Chromium for Linux x86_64 on openSUSE)

Let's start installation.

1st checkout depot_tools
> svn co http://src.chromium.org/svn/trunk/tools/depot_tools
...
> export PATH=`pwd`/depot_tools:"$PATH"

2nd, checkout chromium with Git: this takes a time (in my case it took 1.5 minutes).
> git clone --depth 1 git://git.chromium.org/chromium.git src

3rd, create gclient config file and edit.
> ./depot_tools/gclient config http://src.chromium.org/svn/trunk/src
Then I edit .gclient like below:
solutions = [
{ "name" : "src",
"url" : "http://src.chromium.org/svn/trunk/src",
"custom_deps" : {
# To use the trunk of a component instead of what's in DEPS:
#"component": "https://svnserver/component/trunk/",
# To exclude a component from your working copy:
#"data/really_large_component": None,
"src/third_party/WebKit/LayoutTests": None
},
"safesync_url": ""
}
]

4th, sync gclient: this takes a long time (in my case it took 15 minutes).
> ./depot_tools/gclient sync

Finally, build the chromium for x86_64: make takes so long long times (in my case it took 1.5 hours).
> ./src/tools/gyp/gyp -f make src/build/all.gyp -Dtarget_arch=x64
> cd src
> make CC="ccache gcc" CXX="ccache g++" -r BUILDTYPE=Release -j6 chrome V=1


And run the chromium.

Speaking of shortcomings, all related files of chromium (source, tools and binaries) spend lots of disk space.
> du -h --total /opt/chromium
...
2.4G /opt/chromium

Friday, August 28, 2009

Prepare to install Chromium for Linux x86_64 on openSUSE

1 week ago, Google announced Chromium had been ready for Linux x86_64. I learned in this article. So I started to install Chromium (Google Chrome for POSIX) on my openSUSE 11.1 x86_64. But, this was a very long way. So I decide to divide a post in two: "prepare to install" and "install". This entry is about prepare to install.

First, read documentations for downloading chromium and for building. Below 3 documents are useful.
Second, install the missing packages. If your Desktop environment is GNOME and if you install all major header files, don't worry about it. But if not - me the KDE user - some header files and packages are missing. For example, I add these packages and there dependencies: ccache, gpref, flex, bison, gtk2-devel, mozilla-nss-devel and gconf2-devel.

And last preparation, create installation root directory. For this time, I created /opt/chromium directory.
to be continued...

Tuesday, August 25, 2009

Method#parameters - Ruby 1.9.2 new feature

Most friendly new feature in Ruby 1.9.2 is Method#parameters. What is this? see the sample below:
> /opt/ruby-1.9.1/bin/irb
irb(main):001:0> def sample_method(a, b=0, *c, &d);end
=> nil
irb(main):002:0> self.method(:sample_method).parameters
=> [[:req, :a], [:opt, :b], [:rest, :c], [:block, :d]]

As you see, Method#parameters returns 2-dimensional array, not hash.

In each inner array, the first is parameter type and the last is parameter name. Parameter type is represented by symbol; :req is normal parameter, :opt is parameter with default value, :rest is variable parameter, and :block is block parameter.

Saturday, August 22, 2009

openSUSE benkyoukai 2009/08

Today, in Tokyo, openSUSE benkyoukai was held (What's benkyoukai? see the first part of past entry).

There was 1 session:
  • Script-Fu Tips of Gimp
But today, there are many lightning talks and its Q&As.
  • Renewal QtRuby
  • Program Semantics
  • screen command
At this time, I talked about "Renewal QtRuby".

Tuesday, August 18, 2009

drag move charm #2

(continued from phosphorescence: drag move charm #1)

Why sample widget cannot be moved with grabbing top level widget? It's handled in DragMoveCharm#event_filter method. I had surveyed and debugged this method. Then I found it is caused by incorrect decision of inheritance. See the example code:
> /opt/ruby-1.9.1/bin/irb
irb(main):001:0> require 'Qt'
=> true
irb(main):002:0> Qt::Application.new([])
=> #<Qt::Application:0x00000000c00918 objectName="irb">
irb(main):003:0> label = Qt::Label.new
=> #<Qt::Label:0x00000000befc58 objectName="", x=0, y=0, width=640, height=480>
irb(main):004:0> Qt::Label.ancestors
=> [Qt::Label, Qt::Frame, Qt::Widget, Qt::Object, Qt::PaintDevice, Object, Kernel, BasicObject]
irb(main):005:0> Qt::Label.ancestors.collect do |ancestor_class|
irb(main):006:1* label.is_a? ancestor_class
irb(main):007:1> end
=> [true, false, false, false, false, true, true, true]

After QtRuby 2.0.3, class method Module.ancestors returns not only Ruby's super classes but also Qt's super classes because Qt::Base class overrides this method. But, other related methods don't. Object#is_a? and its alias Object#kind_of? aren't overrode.

If override? Let's try:
> /opt/ruby-1.9.1/bin/irb
irb(main):001:0> require 'Qt'
=> true
irb(main):002:0> module Qt
irb(main):003:1> class Base
irb(main):004:2> def is_a?(mod)
irb(main):005:3> super || self.class.ancestors.include?(mod)
irb(main):006:3> end
irb(main):007:2> end
irb(main):008:1> end
=> nil
irb(main):009:0> Qt::Application.new([])
=> #<Qt::Application:0x00000000ba5c98 objectName="irb">
irb(main):010:0> label = Qt::Label.new
=> #<Qt::Label:0x00000000b94c40 objectName="", x=0, y=0, width=640, height=480>
irb(main):011:0> Qt::Label.ancestors
=> [Qt::Label, Qt::Frame, Qt::Widget, Qt::Object, Qt::PaintDevice, Object, Kernel, BasicObject]
irb(main):012:0> Qt::Label.ancestors.collect do |ancestor_class|
irb(main):013:1* label.is_a? ancestor_class
irb(main):014:1> end
=> [true, true, true, true, true, true, true, true]

It looks like well. So adding below code to override is_a? and kind_of? before execution.
unless Qt::Base.instance_methods(false).include?(:is_a?)
module Qt
class Base
def is_a?(mod)
super || self.class.ancestors.include?(mod)
end
alias :kind_of? :is_a?
end
end
end


Finally, run and move with grabbing top level widget successfully. See widget class code is here, and execution code is here.