Commit 8c5ad974 authored by David Boddie's avatar David Boddie

Reuse common text

parent f4b01232
.. _App_Resources_tutorial_building:
.. |executable| replace:: ``app-resources``
.. |desktop-entry-ref| replace:: :ref:`desktop entry file <App_Resources_tutorial_desktop_file>`
Building the Application
========================
.. contents::
:local:
The ``app`` directory and its subdirectories contain ``meson.build`` files that
describe how the application is built. These are used by the `Meson`_ build
tool to configure the build process.
Meson is usually run so that it creates a build directory. This is where all
the resources are put so that the `Ninja`_ build tool can perform the actual
process of building and installing the application.
Top-Level Build File
--------------------
In the ``app`` directory itself, the ``meson.build`` file begins with a
declaration of the project name, version and build system requirements:
.. literalinclude:: app/meson.build
We also declare the ``data`` and ``src`` subdirectories, causing Meson to
examine them for any ``meson.build`` files they may contain.
The last line causes a special script to be run after installation. It is not
important to know what this is doing at this point.
Sources Build File
------------------
The ``meson.build`` file in the ``src`` directory describes how the source
files are processed when the build occurs:
.. literalinclude:: app/src/meson.build
In this case, we instruct Meson to take the ``main.py`` file in the ``src``
directory and copy it into the build directory as |executable| --
this is the name given as the executable in the |desktop-entry-ref|.
We also declare that the file should be installed, and that its installation
directory is the system location for executables (``bindir``).
Data Build File
---------------
The ``meson.build`` file in the ``data`` describes how the data files are
processed when the build occurs:
.. literalinclude:: app/data/meson.build
Here, we tell Meson to simply copy the ``com.example.app_resources.desktop``
file into the build directory. We also declare that it should be installed, and
that its installation directory is the ``applications`` subdirectory of the
system location for data files (``datadir``).
The ``com.example.app_resources.svg`` file is more easily described to
Meson. It will be installed in the appropriate subdirectory of the system
location for data files that is used for icons.
Building using Meson and Ninja
------------------------------
When building the application for deployment on the phone, we will use Flatpak
to coordinate the build process. However, behind the scenes, we are using Meson
and Ninja to perform the actual configuration and build. If you want to try and
build the application for testing on your workstation, you can follow the steps
below to build, install, and finally uninstall it.
To configure the build on the command line, enter the ``app`` directory and
run Meson, specifying the source and build directories::
meson . _build
Build the application using Ninja, passing the build directory as an argument
so that the build occurs within that directory. There is no need to specify a
build rule because the default rule builds the application::
ninja -C _build
Finally, use ``sudo`` to install the application in a standard location on your
system using the ``install`` build rule::
sudo ninja -C _build install
To uninstall the application, run its ``uninstall`` rule::
sudo ninja -C _build uninstall
All of the files that were installed should now have been cleanly removed from
system locations.
Summary
-------
We have examined the contents of some ``meson.build`` files to see how simple
rules are used to describe the configuration process. We have also seen how
Meson and Ninja are used to configure and build the application.
The application can also be packaged for more convenient installation using the
Flatpak framework. This is the subject of the next part of the tutorial.
.. include:: /links.txt
.. include:: ../common/Building_the_App.txt
.. _First_Application_building:
.. |executable| replace:: ``your-first-application``
.. |desktop-entry-ref| replace:: :ref:`desktop entry file <First_Application_desktop_file>`
Building the Application
========================
.. contents::
:local:
The ``app`` directory and its subdirectories contain ``meson.build`` files that
describe how the application is built. These are used by the `Meson`_ build
tool to configure the build process.
Meson is usually run so that it creates a build directory. This is where all
the resources are put so that the `Ninja`_ build tool can perform the actual
process of building and installing the application.
Top-Level Build File
--------------------
In the ``app`` directory itself, the ``meson.build`` file begins with a
declaration of the project name, version and build system requirements:
.. literalinclude:: app/meson.build
We also declare the ``data`` and ``src`` subdirectories, causing Meson to
examine them for any ``meson.build`` files they may contain.
The last line causes a special script to be run after installation. It is not
important to know what this is doing at this point.
Sources Build File
------------------
The ``meson.build`` file in the ``src`` directory describes how the source
files are processed when the build occurs:
.. literalinclude:: app/src/meson.build
In this case, we instruct Meson to take the ``main.py`` file in the ``src``
directory and copy it into the build directory as |executable| --
this is the name given as the executable in the |desktop-entry-ref|.
We also declare that the file should be installed, and that its installation
directory is the system location for executables (``bindir``).
Data Build File
---------------
The ``meson.build`` file in the ``data`` describes how the data files are
processed when the build occurs:
.. literalinclude:: app/data/meson.build
Here, we tell Meson to simply copy the ``com.example.first_application.desktop``
file into the build directory. We also declare that it should be installed, and
that its installation directory is the ``applications`` subdirectory of the
system location for data files (``datadir``).
The ``com.example.first_application.svg`` file is more easily described to
Meson. It will be installed in the appropriate subdirectory of the system
location for data files that is used for icons.
Building using Meson and Ninja
------------------------------
When building the application for deployment on the phone, we will use Flatpak
to coordinate the build process. However, behind the scenes, we are using Meson
and Ninja to perform the actual configuration and build. If you want to try and
build the application for testing on your workstation, you can follow the steps
below to build, install, and finally uninstall it.
To configure the build on the command line, enter the ``app`` directory and
run Meson, specifying the source and build directories::
meson . _build
Build the application using Ninja, passing the build directory as an argument
so that the build occurs within that directory. There is no need to specify a
build rule because the default rule builds the application::
ninja -C _build
Finally, use ``sudo`` to install the application in a standard location on your
system using the ``install`` build rule::
sudo ninja -C _build install
To uninstall the application, run its ``uninstall`` rule::
sudo ninja -C _build uninstall
All of the files that were installed should now have been cleanly removed from
system locations.
Summary
-------
We have examined the contents of some ``meson.build`` files to see how simple
rules are used to describe the configuration process. We have also seen how
Meson and Ninja are used to configure and build the application.
The application can also be packaged for more convenient installation using the
Flatpak framework. This is the subject of the next part of the tutorial.
.. include:: /links.txt
.. include:: ../common/Building_the_App.txt
Building the Application
========================
.. contents::
:local:
The ``app`` directory and its subdirectories contain ``meson.build`` files that
describe how the application is built. These are used by the `Meson`_ build
tool to configure the build process.
Meson is usually run so that it creates a build directory. This is where all
the resources are put so that the `Ninja`_ build tool can perform the actual
process of building and installing the application.
Top-Level Build File
--------------------
In the ``app`` directory itself, the ``meson.build`` file begins with a
declaration of the project name, version and build system requirements:
.. literalinclude:: app/meson.build
We also declare the ``data`` and ``src`` subdirectories, causing Meson to
examine them for any ``meson.build`` files they may contain.
The last line causes a special script to be run after installation. It is not
important to know what this is doing at this point.
Sources Build File
------------------
The ``meson.build`` file in the ``src`` directory describes how the source
files are processed when the build occurs:
.. literalinclude:: app/src/meson.build
In this case, we instruct Meson to take the ``main.py`` file in the ``src``
directory and copy it into the build directory as |executable| --
this is the name given as the executable in the |desktop-entry-ref|.
We also declare that the file should be installed, and that its installation
directory is the system location for executables (``bindir``).
Data Build File
---------------
The ``meson.build`` file in the ``data`` describes how the data files are
processed when the build occurs:
.. literalinclude:: app/data/meson.build
Here, we tell Meson to simply copy the ``com.example.first_application.desktop``
file into the build directory. We also declare that it should be installed, and
that its installation directory is the ``applications`` subdirectory of the
system location for data files (``datadir``).
The ``com.example.first_application.svg`` file is more easily described to
Meson. It will be installed in the appropriate subdirectory of the system
location for data files that is used for icons.
Building using Meson and Ninja
------------------------------
When building the application for deployment on the phone, we will use Flatpak
to coordinate the build process. However, behind the scenes, we are using Meson
and Ninja to perform the actual configuration and build. If you want to try and
build the application for testing on your workstation, you can follow the steps
below to build, install, and finally uninstall it.
To configure the build on the command line, enter the ``app`` directory and
run Meson, specifying the source and build directories::
meson . _build
Build the application using Ninja, passing the build directory as an argument
so that the build occurs within that directory. There is no need to specify a
build rule because the default rule builds the application::
ninja -C _build
Finally, use ``sudo`` to install the application in a standard location on your
system using the ``install`` build rule::
sudo ninja -C _build install
To uninstall the application, run its ``uninstall`` rule::
sudo ninja -C _build uninstall
All of the files that were installed should now have been cleanly removed from
system locations.
Summary
-------
We have examined the contents of some ``meson.build`` files to see how simple
rules are used to describe the configuration process. We have also seen how
Meson and Ninja are used to configure and build the application.
The application can also be packaged for more convenient installation using the
Flatpak framework. This is the subject of the next part of the tutorial.
.. include:: /links.txt
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment