Clickable ========= Build and compile Ubuntu Touch apps easily from the command line. Deploy your apps to your Ubuntu Touch device for testing or test them on any desktop Linux distribution. Get logs for debugging and directly access a terminal on your device. Clickable is fully Open Source and can be found on `GitLab `__. Clickable is developed by `Brian Douglass `__ and `Jonatan Hatakeyama Zeidler `__ with a huge thank you to all the `contributors `__. .. toctree:: :maxdepth: 1 :name: main install getting-started usage commands debugging continuous-integration .. toctree:: :maxdepth: 1 :caption: Configuration :name: sec-configuration config project-config env-vars app-templates builders .. toctree:: :maxdepth: 1 :caption: Changes :name: sec-changes changelog migration-guides Getting Started --------------- :ref:`Read the getting started guide to get started developing with clickable. ` Issues and Feature Requests --------------------------- If you run into any problems using clickable or have any feature requests you can find clickable on `GitLab `__. Clickable logs from the last run can be found at ``~/.clickable/clickable.log`` or ``~/snap/clickable/current/.clickable/clickable.log`` for the snap package. .. _install: Install ======= Install Via Pip (Recommended) ----------------------------- * Install docker, adb, git, python3 and pipx (Ubuntu 20.04 or higher) * pipx: ``sudo apt install docker.io adb git python3 pipx python3-setuptools`` * Run * pipx: ``pipx install clickable-ut`` * Add pip scripts to your PATH: ``echo 'export PATH="$PATH:$HOME/.local/bin"' >> ~/.bashrc`` and open a new terminal for the setting to take effect * Alternatively, to install nightly builds * pipx: ``pipx install git+https://gitlab.com/clickable/clickable.git@dev`` To update Clickable * pipx: ``pipx upgrade clickable-ut`` Install Via Python Virtual Environment (Alternative) ---------------------------------------------------- * Install docker, adb, git, python3 and pip3 (in Ubuntu: ``sudo apt install docker.io adb git python3 python3-pip python3-setuptools python3-venv``) * Run: .. code-block:: bash :linenos: # Create a virtual environment called .venv python3 -m venv .venv --system-site-packages # Activate the virtual env source ./.venv/bin/activate # Install clickable pip install clickable-ut --upgrade # Create clickable app clickable create --dir ./ Install as Snap --------------- * Make sure you have `snapd installed `__. * Run: .. code-block:: bash :linenos: # Install clickable and docker sudo snap install clickable sudo snap install docker # Add connections sudo snap connect clickable:ssh-keys sudo snap connect clickable:etc-gitconfig Install Via PPA (Ubuntu) ------------------------ * Add the `PPA `__ to your system: ``sudo add-apt-repository ppa:bhdouglass/clickable`` * Update your package list: ``sudo apt-get update`` * Install clickable: ``sudo apt-get install clickable`` Install Via AUR (Arch Linux) ---------------------------- * Using your favorite AUR helper, install the `clickable-git package `__ * Example: ``pacaur -S clickable-git`` Install NixOS ------------- * Using one of the following options to install the clickable package * nix-shell: ``nix-shell -p clickable`` * or add the following code to your configuration: .. code-block:: nix :linenos: environment.systemPackages = [ pkgs.clickable ]; After install ------------- * Let Clickable setup docker (asking for root permissions) and bash completion: ``clickable setup`` * Log out or restart to apply changes if requested .. _getting-started: Getting Started =============== * Run ``clickable create`` to get started with a new app. * Choose from the list of :ref:`app templates `. * Provide all the needed information about your new app. * When the app has finished generating, enter the newly created directory containing your app. * Run ``clickable`` to compile your app and install it on your phone. For more information on Clickable basics, check out the `UBports Clickable video `__. Getting Logs ------------ To get logs from your app simply run ``clickable logs``. This will give you output from C++ (``QDebug() << "message"``) or from QML (``console.log("message")``) in addition to any errors or warnings. Running on the Desktop ---------------------- Running the app on the desktop just requires you to run ``clickable desktop``. This is not as complete as running the app on your phone, but it can help speed up development. Accessing Your Device --------------------- If you need to access a terminal on your Ubuntu Touch device you can use ``clickable shell`` to open up a terminal to your device from your computer. This is a replacement for the old ``phablet-shell`` command. Ubuntu Touch SDK Api Docs ------------------------- For more information about the Ubuntu Touch QML or HTML SDK check out the `docs over at UBports `__. Run Automatic Review -------------------- Apps submitted to the OpenStore will undergo automatic review, to test your app before submitting it, run ``clickable review`` after you've compiled a click. This runs the ``click-review`` command against your click within the clickable container (no need to install it on your computer). .. _publishing: Handling Dependencies --------------------- For more information about compiling, using and deploying app dependencies, check out the `docs over at UBports `__. Publishing to the OpenStore --------------------------- If this is your first time publishing to the OpenStore, you need to `signup for an account `__. You can signup with your GitHub, GitLab, or Ubuntu account. If your app is new to the OpenStore you must first create your app by entering the name from your manifest.json and the app's title on the `OpenStore's submission page `__. If your app already exists you can use the ``clickable publish`` command to upload your compiled click file to the OpenStore. In order to publish to the OpenStore you need to grab your `api key from the OpenStore `__. After you have your api key you need to let Clickable know about it. You can either pass it as an argument every time: ``clickable publish --apikey XYZ`` Or you can set it as an environment variable: ``export OPENSTORE_API_KEY=XYZ`` (you can add this to your ``~/.bashrc`` to keep it set). .. _usage: Usage ===== Getting Started --------------- At this point it is assumed that you have completed the :ref:`installation process ` To find out all supported command line arguments run ``clickable --help``. You can get started with using Clickable with an existing Ubuntu Touch app. You can use Clickable with apps generated from the old Ubuntu Touch SDK IDE or you can start fresh by running ``clickable create`` which is outlined in more detail on the previous :ref:`getting started ` page. To run the default set of commands, simply run ``clickable`` in the root directory of your app's code. Clickable will attempt to auto detect which :ref:`builder ` is able to build your app. Note: The first time you run ``clickable`` in your app directory, it will download a new Docker container which is about 1GB in size - so plan your time and data transfer environment accordingly. This will only happen the first time you build your app for a specific architecture and when you run ``clickable update-images``. Running the default commands will: 1) Build the app 2) Build the click package (can be found in the build directory) 3) Uninstall the app from your phone 4) Install the newly built app on your phone 5) Kill the app on the phone (if already running) 6) Launch the app on your phone By default the device is accessed using ADB, see below if you want to use SSH) Note: ensure your device is in `developer mode `__ for the app to be installed when using ADB or `enable ssh `__ when using SSH. Configuration ------------- One can specify the path to a :ref:`project config file ` with ``--config``. If not specified, Clickable will look for an optional configuration file called ``clickable.yaml`` and then ``clickable.json`` in the current and all parent directories. If there is none, Clickable will ask if it should attempt to detect the type of app and choose a fitting :ref:`builder ` with default configuration. Device Access ------------- Host Device ^^^^^^^^^^^ For Clickable running directly on a Ubuntu Touch system, the target device can be set to ``host`` (:ref:`default_target ` or ``--target host``). .. _device-detection: Device Detection ^^^^^^^^^^^^^^^^ For commands accessing a target device, Clickable will try to detect whether the device is connected via SSH or ADB and the device architecture (``arm64``, ``amd64`` or ``armhf``). It will only check for SSH, if an IP address or hostname was specified via ``--ssh`` or in the :ref:`Clickable Configuration `. It will check SSH before ADB, unless ADB was configured as :ref:`default_target `. Device detection does not consider ``host`` as a target. Setting the (default) target to ``host`` disables the device detection. .. _ssh: Connecting to a device over SSH ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ By default the device is connected to via ADB. If you want to access a device over SSH you need to either specify the device IP address or hostname on the command line (ex: ``clickable logs --ssh 192.168.1.10`` ) or you can use the ``CLICKABLE_SSH`` env var. Make sure to `enable ssh `__ on your device for this to work. .. _multiple-devices: Multiple connected ADB devices ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ By default Clickable assumes that there is only one device connected to your computer via ADB. If you have multiple devices attached to your computer you can specify which device to install/launch/etc on by using the flag ``--serial-number`` or ``-s`` for short. You can get the serial number by running ``clickable devices``. App Manifest ------------ The ``architecture`` and ``framework`` fields in the ``manifest.json`` need to be set according to the architecture the app is build for (``--arch``) and the minimum framework version it requires, e.g. depending on the QT Version (:ref:`qt_version `). To let Clickable automatically set those fields, leave them empty or set them to ``$ENV{ARCH}`` and ``$ENV{CLICK_FRAMEWORK}`` respectively. The apparmor policy needs to match the framework. To let Clickable fill it, leave it empty or set it to ``$ENV{APPARMOR_POLICY}``. If you need to distinguish different frameworks for the same app version, you may append your version with either ``$ENV{CLICK_FRAMEWORK_BASE}`` or ``$ENV{CLICK_FRAMEWORK}`` to let Clickable fill it, e.g. ``1.0.0-$ENV{CLICK_FRAMEWORK_BASE}`` may result in ``1.0.0-24.04-1.x``. Note: The app templates provided by Clickable make use of CMake's ``configure()`` to set the fields in the ``manifest.json``. Advanced Usage -------------- .. _lxd: Running Clickable in an LXD container ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ It is possible to run ``clickable`` in a container itself, using ``lxd``. This is not using ``--container-mode``, but allowing ``clickable`` to create docker containers as normal, but inside the existing ``lxd`` container. This may fail with a permissions error when mounting ``/proc``: .. code-block:: bash docker: Error response from daemon: OCI runtime create failed: container_linux.go:349: starting container process caused "process_linux.go:449: container init caused \"rootfs_linux.go:58: mounting \\\"proc\\\" to rootfs \\\"/var/lib/docker/vfs/dir/bffeb203fe06662876a521b1bea3b74e4d5c6ea3535352215c199c75836aa925\\\" at \\\"/proc\\\" caused \\\"permission denied\\\"\"": unknown. If this error occurs then ``lxd`` needs to be `configured to allow nested containers ` on the host: .. code-block:: bash lxc stop your-container-name lxc config set your-container-name security.nesting true lxc start your-container-name .. _commands: Commands ======== The behavior of Clickable is controlled via commands, each with their own set of available parameters. .. code-block:: bash clickable [param ...] This documentation only lists some selected commands and parameters. Run ``clickable --help`` to see the list of all available commands and ``clickable --help`` to get a command-specific help message listing its available parameters. Project-specific commands like ``build`` and ``install`` can be executed from the projec root or any of its sub-directories, given there is a project config in the project root. Running Clickable without a command is a shortcut to the default ``chain`` command (see below). This special case allows a few universal parameters like ``--verbose`` and ``--arch``. ``chain`` --------- Chains multiple commands that can be specified. The default chain can be configured via the :ref:`default ` field. If not configured, the default is ``build install launch``. A clean build in a chain can be enforced by running ``clickable chain --clean``. ``desktop`` ----------- Compiles and runs the app on the desktop. Accepts the same arguments as the ``build`` command plus some desktop mode specific ones. Note: Snap and ArchLinux users might need to run ``xhost +local:clickable`` before using desktop mode. Run ``clickable desktop --dark-mode`` to set the dark mode preference. Run ``clickable desktop --lang _`` (for example, `fr_FR`) to test using a different language. Run ``clickable desktop --gdb`` to start the app via GDB. Run ``clickable desktop --qmllive`` on a QML only app enable QML live update when QML files are changed. The env var ``CLICKABLE_DESKTOP_MODE`` is set in desktop mode. .. _commands-ide: ``ide`` ------- Will run an IDE inside the Clickable docker container, QtCreator by default. ``ci`` ------ Will open a root bash inside a Clickable CI container that can be used to debug a CI job. ``run`` ------- Opens a bash inside the Clickable docker container to analyze the build environment. This is only meant to inspect the container. Changes do not persist. ``clickable run -- `` runs an arbitrary command in the Clickable container. ``create`` ---------- Generate a new app from a list of :ref:`app template options `. ``shell`` --------- Opens a SSH shell on a connected device either via SSH or ADB. ``clean`` --------- Cleans out the app build dir. Can be applied to libraries by appending ``--libs``. ``build`` --------- Builds the project using the specified builder, build dir, and build commands. Then it takes the built files and compiles them into a click package (you can find it in the build dir). Finally runs a review. Set the manifest architecture field to ``@CLICK_ARCH@`` and the framework field to ``@CLICK_FRAMEWORK@`` to have Clickable replace them with the appropriate values. Set the apparmor policy to ``@APPARMOR_POLICY@`` to have Clickable replace it with an appropriate value based on the framework. Specify where to put the compiled click by ``--output``. Builds libraries specified in the project config using the ``libs`` parameter. ``review`` ---------- Takes the built click package and runs click-review against it. This allows you to review your click without installing click-review on your computer. The review runs automatically after a ``build`` command. .. _commands-test: ``test`` -------- Run your test suite with a virtual screen. By default this runs ``qmltestrunner``, but you can specify a custom command by setting the :ref:`test ` property in your project config. ``install`` ----------- Takes a built click package from the build dir and installs it on a connected device. ``launch`` ---------- Launches the app on a connected device. ``clickable launch `` launches the specified app. ``logs`` -------- Follows the app log file on a connected device. ``log`` ------------------ Prints the app log file from a connected device. ``publish`` ----------- Publish your click package to the OpenStore. Check the :ref:`Getting started doc ` for more info. ``clickable publish "changelog message"`` publishs your click app to the OpenStore with a message prepended to the changelog. ``update-images`` ----------------- Update the docker images used with Clickable. ``no-lock`` ----------- Turns off the display timeout for a connected device. ``writable-image`` ------------------ Make your Ubuntu Touch device's rootfs writable. ``devices`` ----------- Lists the serial numbers and model names for attached devices using ADB. Useful when multiple devices are attached and you need to know what to use for the ``-s`` argument. ``script`` ---------- ``clickable script