配置 JHBuild

JHBuild allows you to build and run Gnome platform and applications building the required modules in a sandbox environment, isolating the installation; so there is no need to build and run Gnome inside a virtual machine.

To build Gnome is strongly recommended to be using a distribution which has latest Gnome version. Latest Fedora is known to be well supported.

首先,建议下载,编译并运行最新JHBuild代码。 要下载并编译JHBuild您将需要这些程序:

  • git
  • gcc
  • g++ (gcc-c++)
  • docbook-xsl
  • gettext

按照上述软件:

在 Ubuntu/Debian环境:

sudo apt-get install apt-file docbook-xsl build-essential git-core gettext
sudo apt-file update

在 Fedora环境:

sudo dnf groupinstall "Development Tools"
sudo dnf install gnome-common python-dbus 

然后,给代码创建文件夹。鉴于JHBuild将使用~/ jhbuild/ checkout~意味着你的主目录)的所有Gnome 软件栈的代码,我们将使用该文件夹JHBuild的代码以及:

mkdir --parents ~/jhbuild/checkout

然后使用Git下载代码到该文件夹中:

cd ~/jhbuild/checkout
git clone git://git.gnome.org/jhbuild

现在编译并安装代码。我们可以使用标准的方式来编译和安装JHBuild。它将被安装在~/.local/bin

cd jhbuild
./autogen.sh --simple-install
make
make install

现在JHBuild应安装。 为了确保您可以直接在命令行就能运行它,你需要可执行文件添加到您的PATH环境变量

echo 'PATH=~/.local/bin:$PATH' >> ~/.bashrc; . ~/.bashrc

测试它能否显示帮助文件:

jhbuild --help

如果还不行,请参阅[[#When_things_go_wrong|当事情出错]。

如果您想进一步定制,你可以创建一个名为jhbuilrc,放在~/.config的配置文件。对于它的文档请参阅 https://developer.gnome.org/jhbuild/stable/config-reference.html 更多有关Jhbuild命令的详细信息,请参阅https://developer.gnome.org/jhbuild/stable/command-reference.html

你的第一次编译

首先,我们需要安装一些依赖关系,并建立了几个模块:

jhbuild sysdeps --install
jhbuild build adwaita-icon-theme dconf glib-networking gvfs

这个步骤仅需要执行一次。

Then build and compile the application you want and its Gnome latest dependencies.

jhbuild build gnome-weather

JHBuild will go through the module and its dependencies one at a time, downloading the development code, configuring, compiling and installing it for you. It will create ~/jhbuild/checkout/ and ~/jhbuild/install directories in your home directory. This will take a little long time, so it's time for a coffee break :) If something goes wrong, see the next chapter at when things go wrong.

When it's done, you will be able to modify or see the source code of the applications. The code will be in ~/jhbuild/checkout, where you can search for the application name.

If you want to stop building and continue later where you were, just kill the process pushing <ctrl> + <c> twice to stop it, and take note in which module you stopped it. To start where you were, just do:

jhbuild build gnome-weather --start-at=moduleWhereYouStopped

当出现问题时

Things typically will not build the first time you're using JHBuild. Don't worry though, this is normal and usually is fairly easy to fix. When JHBuild hits a problem it gives you a set of options that you can use which will let you try the build again.

  • If there's a problem configuring because of a missing dependency, something like "Config error: No package 'foo-2.0' found", search for which package provides the required library with:

    Debian/Ubuntu

     apt-file search "foo-2.0.pc"
    Fedora
     yum install 'pkgconfig(foo-2.0.pc)'
  • If your package manager shows that the required package is already up to date (and it's not) or if it's unable to locate the package then you'll have to download the source code for the required package and compile it yourself.
  • If there is an error in Make, choose [4] Enter shell, run git clean -xfd, then press ctrl + d (to exit the shell), then finally select [1] to rebuild.
  • If your installation was interrupted (due to Ctrl + C or unstable network, say) and choosing [1] isn't working it's possible that the installation tree got damaged; choose [6] Go to phase "wipe directory and start over".
  • Otherwise, ask for help. Here you have a few ways for it.

Running software installed through JHBuild

To run a module that you have installed through JHBuild, you just use the run command. However, you need to kill all current instances of the app:

killall -9 gnome-weather
jhbuild run gnome-weather

{i} In case you are trying to develop Gnome Shell, it is kind of special, and it needs an argument to replace you current running instance:

 jhbuild run gnome-shell --replace

Updating your module

You can update the module installed through JHBuild to include any changes to the development code since it was last built. It's not usually necessary to rebuild all of the module's dependencies. JHBuild has the buildone command for this.

jhbuild buildone gnome-weather

Which it will build without building any dependencies of the module. If at some point, you find that you need to re-build your module with all of the dependencies (e.g. there are problems re-building your module with just the buildone command and that problem is not due to a change you have made) then you could try:

jhbuild build -afc gnome-weather
jhbuild run gnome-weather

And it will update the module and all dependencies to the latest code.

{i} The '-a' option means, 're-run autogen.sh'

{i} The '-f' option means, 'build modules even if they haven't changed'

{i} The '-c' option means 'run make clean before building'

Building a module that you have modified

Once you've built a module, if you modify the source code for that module, you can build and test your changes executing:

jhbuild buildone -n gnome-weather
jhbuild run gnome-weather

{i} The -n option prevents downloading updates - this will avoid conflicts with local changes you have made.

下一步

现在你知道如何对你的模块做出软件改动和测试它,下一步就是要学会如何解决GNOME的bug 。

那么直接进入 Newcomers/SolvingTasks 让我们开始代码旅程。

其他语言

Newcomers/BuildGnome_zh_CN (last edited 2015-11-02 14:58:19 by nsynet)