Commit graph

62 commits

Author SHA1 Message Date
Naushir Patuck
db39cc7698 build: Preserve upstream git versioning using meson dist
When distributions build and package libcamera libraries, they may not
necessarily run the build in the upstream source tree. In these cases, the git
SHA1 versioning information will be lost.

This change addresses that problem by requiring package managers to run
'meson dist' to create a tarball of the source files and build from there.
On runing 'meson dist', the utils/run-dist.sh script will create a
.tarball-version file in the release tarball with the version string generated
from the existing utils/gen-version.sh script.

The utils/gen-version.sh script has been updated to check for the presence of
this .tarball-version file and read the version string from it instead of
creating one.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-10-19 13:14:54 +03:00
Naushir Patuck
54637a615d utils: gen-version: Pass the meson source root to the gen-version.sh script
The gen-version.sh script expects to be called from a git repo, and sets its
src_root variable accordingly. This may not always be the case if it is built
from a tarball source - full support for which is in a future commit.

The MESON_SOURCE_ROOT environnement variable does not get set when called from
the meson vcs_tag() function, but does when called from the run_command()
function, so that cannot be used either.

Instead, explicitly pass the meson source root to the gen-version.sh script.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-10-19 13:14:54 +03:00
Laurent Pinchart
bae9d2bdb3 libcamera: base: Add Backtrace class
Create a new class to abstract generation and access to call stack
backtraces. The current implementation depends on the glibc backtrace()
implementation and is copied from the logger. Future development will
bring support for libunwind, transparently for the users of the class.

The logger backtrace implementation is dropped, replaced by usage of the
new Backtrace class.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-10-15 05:05:20 +03:00
Jean-Michel Hautbois
16266def40 ipa: ipu3: convert AGC to the new algorithm interface
In preparation for using the AGC through the new algorithm interfaces,
convert the existing code to use the new function types.

Now that the process call is rewritten, re-enable the compiler flag to
warn when a function declaration hides virtual functions from a base class
(-Woverloaded-virtual).

We never use converged_ so remove its declaration. The controls may not
need to be updated at each call, but it should be decided on the context
side and not by a specific call by using a lock status in the Agc
structure for instance.

As the params_ local variable is not useful anymore, remove it here
too.

Signed-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-08-20 12:11:29 +02:00
Jean-Michel Hautbois
b3a2882b36 ipa: ipu3: Add the functions to the Algorithm class
Introduce three functions in the Algorithm class to manage algorithms:
- configure which is called when IPA is configured only
- prepare called on EventFillParams event at each frame when the request
is queued
- process called on EventStatReady event at each frame completion when
the statistics have been generated.

The existing AGC implementation already has a function named process(),
though it has different arguments. Adding the new virtual process()
interface causes a compiler warning due to the AGC implementation
overloading a virtual function, even though the overload can be resolved
correctly.

Temporarily disable the warning in this commit to maintain bisection
until the AGC is converted to the new interface.

Signed-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-08-20 12:11:28 +02:00
Paul Elder
e9288e2ee5 meson: Update min clang version to 9
__builtin_FILE and __builtin_LINE are first defined in clang 9. With
clang of any version less than that we have the following compilation
errors:

../../include/libcamera/base/log.h:94:27: error: use of undeclared identifier '__builtin_FILE'
                        const char *fileName = __builtin_FILE(),
                                               ^
../../include/libcamera/base/log.h:95:24: error: use of undeclared identifier '__builtin_LINE'
                        unsigned int line = __builtin_LINE()) const;
                                            ^
../../include/libcamera/base/log.h:99:26: error: use of undeclared identifier '__builtin_FILE'
                const char *fileName = __builtin_FILE(),
                                       ^
../../include/libcamera/base/log.h💯23: error: use of undeclared identifier '__builtin_LINE'
                unsigned int line = __builtin_LINE());

Enforce clang version of at least 9 in the main meson file.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-08-03 12:07:00 +09:00
Kieran Bingham
bdca9ab14e libcamera: Move libcamera.so pkg-config file generation
The pkg-config file for the main libcamera.so is generated
at the top level meson.build.

Move this to the actual core libcamera build structure to be
consistent and keep it next to the library construction.

Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-06-25 16:09:46 +01:00
Laurent Pinchart
969da31894 libcamera: utils: Support systems that lack secure_getenv and issetugid
Android provides neither secure_getenv() nor issetugid(). Enable
compilation on that platform by using a plain getenv(), as that seems to
be the best we can do.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-06-19 16:52:33 +03:00
Laurent Pinchart
c0a9768a9b meson: Print summary boolean options in colours
Boolean options in the summary are printed as 'True' or 'False' by
default. Enable the bool_yn option, which prints them as 'YES' or 'NO',
in green and red respectively. This makes the summary more readable.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
2021-05-27 05:32:15 +03:00
Laurent Pinchart
9fd172f496 android: Fix file system library usage on gcc 7 and 8
On gcc versions older than 9, the file system library, used by the
Android camera HAL configuration file parser, is implemented in a
separate static library. Furthermore, on gcc 7, it's provided in the
std::experimental namespace. This breaks compilation of the HAL on gcc
7, and linking on gcc 8.

Fix the compilation issue by conditionally including
<experimental/filesystem> and creating a namespace alias in std, and the
link issue by linking to libstdc++fs on gcc versions older than 9.

The inclusion of <experimental/filesystem> is a bit of a hack, and when
we'll start using the file system library in another compilation unit,
we should then move all this to an internal helper to abstract the
compiler version.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2021-05-26 14:52:56 +03:00
Umang Jain
e8924f30f7 meson: Add a configuration option to build IPAs
There can be multiple IPAs per pipeline-handler or platform.
They can live in-tree or externally linked. It is up to the vendor
whether to use in-tree IPA for a platform or provide it externally.
In the case of IPAs being external, building in-tree IPAs might be
futile hence, provide a clear and explicit mechanism to choose whether
to build the in-tree IPA for the platform or not.

By default, all in-tree IPAs are built when a matching Pipeline handler
is also enabled.

Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-05-24 14:27:29 +03:00
Umang Jain
17bf7df227 meson: Replace obselete join_paths() with '/' operator
Since meson v0.49.0, join_paths() is equivalent to '/' hence,
drop and replace it with '/' short-hand in meson files.

This commit does not introduce any functional changes.

Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-05-11 11:50:45 +01:00
Niklas Söderlund
02bc110857 lc-compliance: Add a libcamera compliance tool
Add a compliance tool to ease testing of cameras. In contrast to the
unit-tests under test/ that aims to test the internal components of
libcamera the compliance tool aims to test application use-cases and to
some extent the public API.

This change adds the boilerplate code of a simple framework for the
creation of tests. The tests aim both to demonstrate the tool and to
catch real problems. The tests added are:

 - Test that if one queues exactly N requests to a camera exactly N
   requests are eventually completed.

 - Test that a configured camera can be started and stopped multiple
   times in an attempt to exercise cleanup code paths otherwise not
   often tested with 'cam' for example.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Acked-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Tested-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Tested-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>
2021-04-12 10:48:56 +02:00
Laurent Pinchart
b68721608a meson: Summarize which applications and adaptation layers are built
Add the application and adaptation layers being built to the meson
summary. The summary now prints

libcamera 0.0.0

  Configuration
         Enabled pipelines: ipu3
                            raspberrypi
                            rkisp1
                            simple
                            uvcvideo
                            vimc

           Android support: True
         GStreamer support: True
    V4L2 emulation support: True
           cam application: True
          qcam application: True
                Unit tests: True

  Subprojects
                    libyuv: YES

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
2021-03-28 01:47:26 +02:00
Laurent Pinchart
6e65d42257 libcamera: Enable vimc pipeline handler when tests are enabled
The addition of the new IPA IPC mechanism compiles pipeline-specific
headers to define the interface between the pipeline and the IPA.

This was optimised in 08ce394465 ("meson: ipa, proxy: Only build
proxies for enabled pipelines") to only build for enabled pipelines,
however the tests directly use the VIMC pipeline handler, and require
it to be built.

Create a local variable to store the requested pipelines from the user
configuration and extend the enabled pipelines to ensure that VIMC is
always enabled if the tests are also enabled

Fixes: 08ce394465 ("meson: ipa, proxy: Only build proxies for enabled pipelines")
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Tested-by: Sebastian Fricke<sebastian.fricke@posteo.net>
2021-02-23 12:53:15 +02:00
Hirokazu Honda
9109bcf22c subprojects: Add libyuv and built if -Dandroid=enabled
Android HAL adaptation layer may need image processing, for
example, scaling and format conversion. Libyuv is a general image
processing. This adds libyuv to subprojects, so that it is forked
locally and can be used with Android HAL implementation code.

Signed-off-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-02-04 05:03:53 +02:00
Laurent Pinchart
8e1e10283a libcamera: Use meson summary() function to summarize configuration
Now that Debian backports have been updated to meson v0.56, all major
distributions provide meson >= v0.53 in their latest LTS version. We can
replace the manual message()-based configuration summary with the
summary() function.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Sebastian Fricke <sebastian.fricke@posteo.net>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-01-20 18:07:44 +02:00
Kieran Bingham
bf68e72276 meson: test: Simplify top level meson
Utilise the subdir_done() functionality as is used with other optional
components to simplify the top level meson file.

Suggested-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2020-12-30 15:31:45 +00:00
Paul Elder
fcc6d4bd76 libcamera: tracing: Implement tracing infrastructure
Implement tracing infrastructure in libcamera. It takes .tp files, as
required by lttng, and generates a tracepoint header and C file, as lttng
requires. meson is updated accordingly to get it to compile with the
rest of libcamera. Update the documentation accordingly.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2020-11-03 11:07:21 +09:00
Kieran Bingham
9f567cc140 meson: Enable shadowed variable warning
Shadowing variables can lead to unexpected bugs where a code path
utilises a variable that may not have been intended by the developer,
leading to hard to find bugs.

Enable warnings for shadowed variables as defined at:
  https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wshadow

As an effect of utilising -Werror, this will cause variable or type
shadowing to become a build-time error.

Suggested-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2020-10-21 17:18:49 +01:00
Hirokazu Honda
c3a5467f7d meson: Enable -Wextra-semi for clang
The option, -Wextra-semi, helps developers to find unnecessary
semicolons. This option is available with clang.

Signed-off-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2020-10-20 13:15:56 +03:00
Tomi Valkeinen
9183d21842 meson: Enable -Wno-psabi for gcc 9+
I get the warnings related to psabi with:

gcc 9.3.0 "arm-buildroot-linux-gnueabihf-g++.br_real (Buildroot 2020.08-24-gc5c5f1fa46) 9.3.0"

Remove the check for gcc-9, so that -Wno-psabi is used on all gcc
versions over 7.1.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@iki.fi>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2020-10-12 14:27:18 +03:00
Ezequiel Garcia
aac96e34ba meson: Define python3 and python3-yaml required dependencies
With this change, meson will complain specifically about missing
python3 and missing python3-yaml. As specified by meson
documentation: https://mesonbuild.com/Python-module.html,
this change requires meson v0.51.

Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2020-09-24 21:08:40 +03:00
Ricardo Ribalda
da81e368e7 meson: Bump meson version to 0.51
Version 0.51 allows, among others, checking for python modules, which is
a required feature.

It is also now easily accessible: it is in stable distros such as Debian
testing, or in pip:

https://tracker.debian.org/pkg/meson
https://pypi.org/project/meson/

Suggested-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Ricardo Ribalda <ricardo@ribalda.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2020-09-24 21:08:34 +03:00
Ricardo Ribalda
aba567338b Documentation: Move all dependencies into features
This way if the user enables the documentation and the dependencies are
missing the configure fails.

Suggested-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Ricardo Ribalda <ricardo@ribalda.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2020-09-24 21:08:30 +03:00
Kieran Bingham
d6b6ad950d meson: Process utils first
The utils directory can contain helpers and support tools which are used
throughout other components of the build.

Ensure that the utils subdir is parsed first allowing helpers to be
defined there.

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
2020-09-24 10:55:39 +01:00
Show Liu
9db6ce0ba4 qcam: Add ViewFinderGL class to accelerate the format conversion
The viewfinderGL accelerates the format conversion by using OpenGL ES
shader.

The minimum Qt version is bumped to v5.4, as QOpenGLWidget wasn't
available before that.

Signed-off-by: Show Liu <show.liu@linaro.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2020-09-15 05:10:35 +03:00
Kieran Bingham
094b3001fd meson: Provide build configuration summary
Report the enabled pipelines when configuring the meson build hierarchy.

This helps clarify what pipelines are used when building, and is useful
when looking back through build-traces to see what was actually
configured.

This can be expanded upon to report other options, and ideally will be
replaced by mesons summary() functionality when it is available.

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2020-09-07 17:06:19 +01:00
Laurent Pinchart
dbafe16da7 meson: Remove -Wno-unused-parameter
We build libcamera with -Wno-unused-parameter and this doesn't cause
much issue internally. However, it prevents catching unused parameters
in inline functions defined in public headers. This can lead to
compilation warnings for applications compiled without
-Wno-unused-parameter.

To catch those issues, remove -Wno-unused-parameter and fix all the
related warnings with [[maybe_unused]].

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2020-08-25 02:58:04 +03:00
Laurent Pinchart
b869d4463e meson: Switch to C++17
Due to popular request, move from C++14 to C++17. This will allow
dropping some custom constructs (such as a custom utils::clamp),
benefiting from new language features, and dropping gcc 5 and 6 from the
compilation tests.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2020-08-25 02:03:09 +03:00
Stéphane Cerveau
348e94debc meson: detect kernel version
Add kernel version detection to warn user
that only >= 5.0.0 V4L API are supported in
libcamera.

Signed-off-by: Stéphane Cerveau <scerveau@collabora.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2020-06-15 21:53:11 +01:00
Laurent Pinchart
7a653369cb licenses: License all meson files under CC0-1.0
In an attempt to clarify the license terms of all files in the libcamera
project, the build system files deserve particular attention. While they
describe how the binaries are created, they are not themselves
transformed into any part of binary distributions of the software, and
thus don't influence the copyright on the binary packages. They are
however subject to copyright, and thus influence the distribution terms
of the source packages.

Most of the meson.build files would not meet the threshold of
originality criteria required for copyright protection. Some of the more
complex meson.build files may be eligible for copyright protection. To
avoid any ambiguity and uncertainty, state our intent to not assert
copyrights on the build system files by putting them in the public
domain with the CC0-1.0 license.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Acked-by: Giulio Benetti <giulio.benetti@micronovasrl.com>
Acked-by: Jacopo Mondi <jacopo@jmondi.org>
Acked-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Acked-by: Naushir Patuck <naush@raspberrypi.com>
Acked-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Acked-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Acked-by: Paul Elder <paul.elder@ideasonboard.com>
Acked-by: Show Liu <show.liu@linaro.org>
2020-05-13 16:46:24 +03:00
Nicolas Dufresne
56ff904915 pkgconfig: Fix include directory path
Should be $includedir/libcamera, as we install into a subdirectory name
'libcamera'. This is fixed by passing the 'subdirs' argument to the pkgconfig
generator.

Signed-off-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2020-05-10 15:01:54 +03:00
Laurent Pinchart
1c883def04 libcamera: Set -Wno-psabi on gcc 7 and 8 for arm
gcc 7.1 introduced processor-specific ABI breakages related to parameter
passing on ARM platforms. This generates a large number of messages
during compilation with gcc >=7.1 until gcc 9. Silence them.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2020-05-01 17:51:59 +03:00
Laurent Pinchart
cc15ab4316 libcamera: utils: Add a function to retrieve the libcamera source tree
Similarly to libcameraBuildPath(), there's a need to locate resources
within the source tree when running libcamera without installing it.
Support this use case with a new utils::libcameraSourcePath() function.

The implementation uses a symlink from the build root to the source root
in order to avoid hardcoding the path to the source root in the
libcamera.so binary.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2020-04-28 01:54:34 +03:00
Laurent Pinchart
461e7ac873 meson.build: Silence the C99 designators warning
We use array designators for array initialization, which is a C99
extension. clang-10 warns about it, causing a build failure.

As this is a useful extension, silence the warning. This needs to be
done only if the compiler supports the -Wno-c99-designator argument,
otherwise a -Wunknown-warning-option will be generated.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2020-02-13 14:10:48 +02:00
Nicolas Dufresne
2de78434ca meson: Bump required version to 0.47
This is needed to use option type 'feature'. This is a tri-state
(auto/enabled/disabled) which comes with utility to enable them all, or
disabled them all to avoid any dynamic selection happening. It can also
be used as value to any "required" field.

This will be used in GStreamer support. If you don't have a recent enough
meson in your distribution, you can always install or upgrade your version
using pip3.

  pip3 install --user meson
  pip3 install --user --upgrade meson

Signed-off-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Reviewed: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2020-01-17 01:17:18 +02:00
Laurent Pinchart
9a61a13466 meson.build: Switch to C++14
C++14 is a minor release that doesn't introduce major new concepts or
paradigms compared to C++11, but brings two useful changes for us:

- std::make_unique allows dropping our custom implementation in utils.
- Functions returning constexpr are not assumed to be const anymore,
  which is needed to create a standard-conformant span implementation.

All the g++ and clang++ versions we support and test (g++-5 onwards and
clang++6 onwards) support C++14. However, due to a defect in the
original C++14 specification, solved in N4387 ([1]), compilation would
fail on g++-5 due to the use of std::map::emplace() with a non-copyable
value type. It turns out we can easily fix it by switching to the
explicit piecewise emplace() overload.

There is thus really nothing holding back the switch. Let's do it, and
update the coding style accordingly.

[1] http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4387

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2020-01-14 19:06:40 +02:00
Laurent Pinchart
442f516c62 libcamera: Print backtrace on fatal errors
When a fatal error occurs the program aborts, and all the logger
provides is the location of the line that caused the error. Extend this
with a full backtrace to help debugging.

The backtrace is generated using the backtrace() call, a GNU extension
to the C library. It is available in glibc and uClibc but not in musl.
Test for availability of the function to condition compilation of the
backtrace printing. Implementing backtrace support with musl is an
exercise left to the reader if desired.

The LogOutput class is extended to support writing string messages
directly to the output. Strings written directly will be considered as
LogDebug messages when written to the Syslog.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Tested-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2019-11-26 18:47:15 +02:00
Laurent Pinchart
a8d0312903 meson: Really define _FORTIFY_SOURCE for optimised builds
Commit 965c5bf7fb ("meson: Define _FORTIFY_SOURCE for optimised
builds") tried to define _FORTIFY_SOURCE for optimised builds with
clang, but updated the common_arguments after it was used. This resulted
in the _FORTIFY_SOURCE option not being applied. Fix it.

Fixes: 965c5bf7fb ("meson: Define _FORTIFY_SOURCE for optimised builds")
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2019-11-21 11:42:22 +02:00
Laurent Pinchart
8a92e6fc72 meson: Rename 'tests' option to 'test'
The 'tests' option enables compilation of tests. On Gentoo and Chrome
OS, the corresponding package USE flag is named 'test'. Rename the
option to 'test' to bring it in line.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2019-08-22 19:35:54 +03:00
Laurent Pinchart
965c5bf7fb meson: Define _FORTIFY_SOURCE for optimised builds
_FORTIFY_SOURCE adds useful checks during compilation. The option is
enabled by default by gcc on all non-optimised builds (as it requires
-O1 or higher). Enable it explicitly for clang.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2019-08-22 11:10:43 +03:00
Paul Elder
10ec09025d libcamera: skip auto version generation when building for Chromium OS
Commit b817bcec6b ("libcamera: Auto generate version information")
causes the build to fail in the Chromium OS build environment, because
git update-index tries to take a lock (ie. write) in the git repo that
is outside of the build directory.

The solution is to simply skip git update-index if we are building in
the Chromium OS build environment, and this decision is made if the
build directory is not a subdirectory of the source directory.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-07-11 12:22:40 +09:00
Laurent Pinchart
c4281ba3bb libcamera: Rework automatic version generation to avoid rebuilds
Commit b817bcec6b ("libcamera: Auto generate version information")
generates version information in order to automatically include it
various locations (Sphinx and Doxygen documentation, libcamera::version
variable available at runtime, and version.h available at compile time).
Unfortunately this causes lots of unnecessary rebuilds when modifying
the git tree state, which hinders development.

The problem is caused by the generated version.h being listed as a
dependency for the whole libcamera. This is required as meson (to the
best of my knowledge) doesn't provide a way to explicitly specify the
dependency of a single object file (camera_manager.o in this case, as
camera_manager.cpp is the only consumer of the generated version string)
on the custom target used to generate version.h. The dependency can't be
automatically detected at build time, like dependencies on normal
headers that are generated by parsing the source, because the version.h
header may not exist yet. The build could then fail in a racy way.

This change attempts at solving the issue by generating a version.cpp
instead of a version.h to set the git-based version. This minimises the
number of files that need to be rebuild when then git tree state
changes, while retaining the main purpose of the original automatic
version generation, the ability to access the git-based version string
at runtime. We however lose the ability to access git-based version
information at build time in an application building against libcamera,
but there is no expected use case for this.

The version string is moved from the libcamera namespace to the
CameraManager class in order to avoid including version.h inside
libcamera (in version.cpp and in camera_manager.cpp), which would create
dependencies causing more rebuild steps, as described above.

On the other hand, major, minor and patch level version numbers are
useful at build time. This commit changes the generation of version.h in
order to add three macros named LIBCAMERA_VERSION_MAJOR,
LIBCAMERA_VERSION_MINOR and LIBCAMERA_VERSION_PATCH for this purpose.
version.h is not included by any other libcamera header or source file,
and thus doesn't force a rebuild of the library.

The Sphinx and Doxygen documentation keep their git-based version
information, which is set during the configuration of the build and then
doesn't track git commits. We may want to investigate how to improve
this, but given that git-based version for the documentation has very
few use cases outside of tagging nightly builds, this isn't considered
an issue at the moment.

The documentation install directory now uses the base version string, in
order to avoid increasing the number of documentation directories
needlessly. This shouldn't cause any issue as the API should not change
without a change to the version number.

The version number generation and handling code now also standardises
the version variables to not start with a 'v' prefix in meson, in order
to simplify their handling. The prefix is added when generating the
relevant files.

Note that we go back to specifying the fallback version in the main
meson.build, in the call to the project() function. For the time being I
believe this should be a good compromise to avoid unnecessary
recompilation, and moving the fallback version to a different file for
tarball releases can be built on top of this.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-07-09 12:34:10 +03:00
Kieran Bingham
b817bcec6b libcamera: Auto generate version information
Generate a version string, and provide a global string object which
allows applications to interrogate the current libcamera version
information.

The version header is automatically updated by meson on each build.
The string roughly follows the semver [0] conventions of
major.minor.patch-label as a value.

[0] https://semver.org/

A script (utils/gen-version.sh) is provided which is modelled upon the
processing from autoconf's git-version-gen. The gen-version.sh script
will look for tags in the form vX.Y as starting points for the version
string. While the repository does not have any matching tags, v0.0 will
be assumed, resulting in versions with both major and minor being set to
'0', and the patch count resulting from the number of patches in the
history to that point.

Finally, a uniquely identifying shortened hash is provided from git:

	v0.0.509+0ec0edf7

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2019-07-04 22:11:27 +01:00
Laurent Pinchart
8b7a24e20f meson: Link against libc++ with compiling with clang
libc++ is used by Chrome OS, and likely as well by other environments
based on clang. Using it by default if available when compiling with
clang will help extending the compile-testing coverage. The drawback is
that issues specific to clang with libstdc++ will not be caught as
easily, but based on the experience with clang so far, code compiling
correctly with gcc/libstdc++ has failed with clang due to either
clang-specific or libc++-specific behaviour, never due only to the
combination of clang with libstdc++.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2019-06-19 18:47:56 +03:00
Laurent Pinchart
41adc3f8d3 meson: Fix coding style in meson.build files
Consistently go for 4 spaces indentation, and always put a space between
the colon in argument lists, as per the examples from the meson
documentation.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-05-23 11:55:45 +03:00
Laurent Pinchart
df587aa100 libcamera: Make libudev optional
libcamera depends on libudev for device enumeration. It is however
useful to allow building documentation without requiring the dependency
to be installed. Make the libudev dependency optional and compile the
udev-based device enumerator out when libudev is not present.

Note that while libcamera will compile without libudev, it will not be
able to enumerate devices. A sysfs-based device enumerator is planned as
a fallback but not implemented yet.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2019-04-27 17:11:13 +03:00
Giulio Benetti
46bfc32157 meson: check if secure_getenv() is present
Not all libc make secure_getenv() available, this could lead to build
failure on certain build systems.

Check if secure_getenv() is available and emit #define
HAVE_SECURE_GETENV to config.h Include config.h to every c/c++ file
during building by adding `-include config.h` to project arguments for
both c and c++.

Signed-off-by: Giulio Benetti <giulio.benetti@micronovasrl.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
[Kieran: Drop unnessecary meson message
         Update commit message]
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2019-04-26 14:31:09 +02:00
Kieran Bingham
4635df7006 meson: Re-order the optional components
Re-order the optional components to make them alphabetical, and fix up
the indentation to use two spaces as required by meson. A comment is
added to highlight that these optional components are enabled by
default.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2019-04-03 11:44:04 +07:00