|
| 1 | +# Establishing a Development environment |
| 2 | + |
| 3 | +Looking to contribute some code to Sideband? Awesome! Follow the guide below to get the repository building on your machine. |
| 4 | + |
| 5 | +## Creating folders |
| 6 | + |
| 7 | +Sideband relies on a certain folder structure to achieve a psuedo-monorepo structure with the other Reticulum projects. |
| 8 | + |
| 9 | +To make sure that the `getrns` target runs successfully, make sure your directory tree looks like this: |
| 10 | + |
| 11 | +``` |
| 12 | +repositories/ |
| 13 | +├─ LXMF/ |
| 14 | +├─ LXST/ |
| 15 | +├─ rnsh/ |
| 16 | +├─ rnode-flasher/ |
| 17 | +├─ Reticulum/ |
| 18 | +├─ NomadNet/ |
| 19 | +├─ reticulum_website/ |
| 20 | +└─ Sideband/ |
| 21 | +``` |
| 22 | + |
| 23 | +Below are the git repositories for some of the above folders: |
| 24 | + |
| 25 | +- `LXMF`: https://github.com/markqvist/LXMF |
| 26 | +- `LXST`: https://github.com/markqvist/LXST |
| 27 | +- `rnsh`: https://github.com/acehoss/rnsh |
| 28 | +- `Reticulum`: https://github.com/markqvist/Reticulum |
| 29 | +- `rnode-flasher`: https://github.com/liamcottle/rnode-flasher |
| 30 | +- `NomadNet`: https://github.com/markqvist/nomadnet |
| 31 | +- `reticulum_website`: https://github.com/markqvist/reticulum_website |
| 32 | + |
| 33 | +> Please note: in order for the docker script and `createshare` make target to work correctly, your directory **must** be laid out like this. |
| 34 | +
|
| 35 | +## Required dependencies for development (Docker) |
| 36 | + |
| 37 | +If you have a Fedora-based Linux system (see [Addendum: Fedora](#addendum-fedora)) or simply would not like to install all of P4A's dependencies manually, you may choose to use the containerized build. |
| 38 | + |
| 39 | +This method requires that you have Docker installed on your system: https://docs.docker.com/engine/install/ |
| 40 | + |
| 41 | +Additionally, [rootless Docker](https://docs.docker.com/engine/install/) should be used to minimize any possible attack surface on your system. Never run a script you haven't vetted with sudo! The `./dmake.sh` script uses `set -ex` and is designed to be used with rootless docker. |
| 42 | + |
| 43 | +After configuring docker, you can replace any use of the `make` command with `dmake` (i.e. `./dmake devapk`) to run make commands in the container, building it on demand if needed. |
| 44 | + |
| 45 | +Example: |
| 46 | + |
| 47 | +``` |
| 48 | +./dmake devapk |
| 49 | +``` |
| 50 | + |
| 51 | +(or if running in sbapp, it is smart enough to run itself in Sideband regardless of where it is called from) |
| 52 | + |
| 53 | +``` |
| 54 | +../dmake devapk |
| 55 | +``` |
| 56 | + |
| 57 | +## Required dependencies for development (Native) |
| 58 | + |
| 59 | +Until this repository has a `flake.nix` added, you will need to manually download the following dependencies using your Operating System's package manager. |
| 60 | + |
| 61 | +- `make` |
| 62 | +- `adb` (available as a part of the `android-tools` package on Fedora, `adb` on Debian/Ubuntu, `android-platform-tools` on Brew Casks) |
| 63 | +- `python3`/`python3-dev(el)` (must be available as `python`, on Ubuntu try `apt install python-is-python3`) |
| 64 | +- `patchelf` |
| 65 | +- `patch` |
| 66 | +- `perl` |
| 67 | +- `portaudio19-dev` |
| 68 | +- `libopus-dev` |
| 69 | +- `libogg-dev` |
| 70 | +- `buildozer` (see https://buildozer.readthedocs.io/en/latest/installation.html) |
| 71 | + - buildozer's PyPI hosted version is very far behind, therefore you should install from source at https://github.com/kivy/buildozer.git; this is easy with pipx `pipx install git+https://github.com/kivy/buildozer.git`. |
| 72 | + - buildozer needs `wheel` to run, but it is not currently marked as a dependency. If you are using pipx, you will need to inject it with `pipx inject buildozer wheel`. |
| 73 | +- all of buildozer's Android dependencies |
| 74 | + - Ubuntu 22.04 LTS packages `git zip unzip openjdk-17-jdk python3-pip autoconf libtool pkg-config zlib1g-dev libncurses5-dev libncursesw5-dev libtinfo5 cmake libffi-dev libssl-dev` |
| 75 | + - Ubuntu 24.04 LTS packages `git zip unzip openjdk-17-jdk python3-pip autoconf libtool pkg-config zlib1g-dev libncurses-dev libtinfo6 cmake libffi-dev libssl-dev` |
| 76 | + - Fedora 41 `git zip unzip java-17-openjdk java-17-openjdk-devel python3-pip autoconf libtool pkgconf-pkg-config ghc-zlib-devel ncurses-devel ncurses-compat-libs cmake libffi-devel openssl-devel` |
| 77 | + |
| 78 | +In the root directory of the repository, use `pip install .` to install the package from `setup.py`. The use of a `venv` is strongly recommended. |
| 79 | + |
| 80 | +Make sure you manually install `Cython<3.0` into your Python install or `venv`, as buildozer will need it for Android. |
| 81 | + |
| 82 | +### Addendum: Fedora |
| 83 | + |
| 84 | +As many users of Kivy have noted before, some of Python4Android's recipes do not compile correctly on Fedora/RHEL. For this project, one package of interest is [`freetype-py` and its native dependency](https://github.com/kivy/python-for-android/blob/develop/pythonforandroid/recipes/freetype/__init__.py), which is a direct dependency of pillow, the ubiquitous Python image editing library. |
| 85 | + |
| 86 | +This is due to the fact that Fedora and several other distros include default versions of toolchains, which prompts python4android to abstain from downloading its own. [This issue has been encountered by many other users.](https://groups.google.com/g/kivy-users/c/z46lSJXgbjY/m/M1UoWwtWAgAJ) |
| 87 | + |
| 88 | +If you can't use Docker, use of Ubuntu 24.04 LTS is therefore recommended for developing this project. Ubuntu 22.04 LTS is not supported, as its `cmake` version (even with backports) is below the minimum 3.24. |
| 89 | + |
| 90 | +Sideband does run fine on Fedora, however. |
| 91 | + |
| 92 | +## Compiling and testing Sideband on an Android device |
| 93 | + |
| 94 | +With a correctly configured environment, run the following command to create a development APK. |
| 95 | + |
| 96 | +``` |
| 97 | +make devapk |
| 98 | +``` |
| 99 | + |
| 100 | +You can then install it to a connected device with |
| 101 | + |
| 102 | +``` |
| 103 | +make devinstall |
| 104 | +``` |
| 105 | + |
| 106 | +If you would like your release to be signed for release, you must configure the following four environment variables: |
| 107 | + |
| 108 | +- `P4A_RELEASE_KEYALIAS` |
| 109 | +- `P4A_RELEASE_KEYSTORE_PASSWD` |
| 110 | +- `P4A_RELEASE_KEYSTORE` |
| 111 | +- `P4A_RELEASE_KEYALIAS_PASSWD` |
| 112 | + |
| 113 | +With `./dmake`, omitting any of these values will cause it to default to the `debug.keystore` generated with each install of the Android SDK. |
| 114 | + |
| 115 | +After it is configured correctly, you may build it with |
| 116 | + |
| 117 | +``` |
| 118 | +make apk |
| 119 | +``` |
| 120 | + |
| 121 | +and install it to a connected device with |
| 122 | + |
| 123 | +``` |
| 124 | +make install |
| 125 | +``` |
| 126 | + |
| 127 | +The output will be placed in `./sbapp/bin/sideband-*.apk`. |
| 128 | + |
| 129 | +If you have multiple devices connected at once (for example, while developing the BLE interface between devices), you may use `devinstall-multi` or `install-multi` in place of `devinstall` and `install` respectively. |
| 130 | + |
| 131 | +If using an Android that provides the ability to toggle DCL via storage (like GrapheneOS), make sure to enable it for Sideband, as it must load its Cython executables. |
| 132 | + |
| 133 | +## Compiling and testing Sideband for other platforms |
| 134 | + |
| 135 | +For Windows, use the following command: (make sure you have `PyInstaller` in your venv, and you are on Windows, as PyInstaller removed cross-compilation) |
| 136 | + |
| 137 | +``` |
| 138 | +make build_win_exe |
| 139 | +``` |
| 140 | + |
| 141 | +Wheels for other platforms can be built with |
| 142 | + |
| 143 | +``` |
| 144 | +make build_wheel |
| 145 | +``` |
0 commit comments