| Hendrik Hofstadt | 0d7c91e | 2019-10-23 21:44:47 +0200 | [diff] [blame] | 1 | # Nexantic monorepo |
| Leopold Schabel | 67f9d09 | 2019-10-22 15:41:42 +0200 | [diff] [blame] | 2 | |
| Hendrik Hofstadt | 0d7c91e | 2019-10-23 21:44:47 +0200 | [diff] [blame] | 3 | This is the monorepo storing all of nexantic's internal projects and libraries. |
| Leopold Schabel | 67f9d09 | 2019-10-22 15:41:42 +0200 | [diff] [blame] | 4 | |
| Hendrik Hofstadt | 0d7c91e | 2019-10-23 21:44:47 +0200 | [diff] [blame] | 5 | ## Environment |
| Leopold Schabel | 5c80aca | 2019-10-22 15:48:58 +0200 | [diff] [blame] | 6 | |
| Leopold Schabel | db6283e | 2020-01-06 17:05:54 +0100 | [diff] [blame] | 7 | We assume a Fedora host system provisioned using rW, and IntelliJ as the IDE. |
| Leopold Schabel | 67f9d09 | 2019-10-22 15:41:42 +0200 | [diff] [blame] | 8 | |
| Leopold Schabel | 8b9c055 | 2019-11-15 14:07:45 +0100 | [diff] [blame] | 9 | For better reproducibility, all builds are executed in containers. |
| Leopold Schabel | 67f9d09 | 2019-10-22 15:41:42 +0200 | [diff] [blame] | 10 | |
| Hendrik Hofstadt | 0d7c91e | 2019-10-23 21:44:47 +0200 | [diff] [blame] | 11 | #### Usage |
| Leopold Schabel | 5c80aca | 2019-10-22 15:48:58 +0200 | [diff] [blame] | 12 | |
| Hendrik Hofstadt | 0d7c91e | 2019-10-23 21:44:47 +0200 | [diff] [blame] | 13 | Spinning up: `scripts/create_container.sh` |
| Leopold Schabel | 5c80aca | 2019-10-22 15:48:58 +0200 | [diff] [blame] | 14 | |
| Hendrik Hofstadt | 0d7c91e | 2019-10-23 21:44:47 +0200 | [diff] [blame] | 15 | Spinning down: `scripts/destroy_container.sh` |
| 16 | |
| Leopold Schabel | 8b9c055 | 2019-11-15 14:07:45 +0100 | [diff] [blame] | 17 | Running commands: `scripts/run_in_container.sh <...>` |
| Hendrik Hofstadt | 0d7c91e | 2019-10-23 21:44:47 +0200 | [diff] [blame] | 18 | |
| Leopold Schabel | 8b9c055 | 2019-11-15 14:07:45 +0100 | [diff] [blame] | 19 | Using bazel using a wrapper script: `scripts/bin/bazel <...>` (add to your local $PATH for convenience) |
| Leopold Schabel | 2ab141d | 2020-01-07 20:50:07 +0100 | [diff] [blame] | 20 | |
| 21 | #### Creating local symlinks for generated Go code |
| 22 | |
| 23 | Unfortunately, the Go tooling does not yet know about Bazel, so we need to copy generated code to |
| 24 | the source tree such that native Go modules work. |
| 25 | |
| 26 | This creates a fake GOPATH and symlinks for generated packages: |
| 27 | |
| 28 | scripts/symlink_generated_files.sh |
| 29 | bazel build :gopath |
| 30 | |
| 31 | Any top-level Go targets that use generated code have to be dependencies of the :gopath target. |
| 32 | |
| 33 | See https://phab.monogon.dev/D305 for details. |
| Hendrik Hofstadt | 0d7c91e | 2019-10-23 21:44:47 +0200 | [diff] [blame] | 34 | |
| Leopold Schabel | 8b9c055 | 2019-11-15 14:07:45 +0100 | [diff] [blame] | 35 | #### IntelliJ |
| 36 | |
| 37 | This repository is compatible with the IntelliJ Bazel plugin. All commands run inside the container, and |
| 38 | necessary paths are mapped into the container. |
| 39 | |
| 40 | We check the entire .ijwb project directory into the repository, which requires everyone to use the latest |
| 41 | version of both IntelliJ and the Bazel plugin, but eliminates manual setup steps. |
| 42 | |
| 43 | The following steps are necessary: |
| 44 | |
| 45 | - Install Google's official Bazel plugin in IntelliJ. |
| 46 | |
| 47 | - Add the absolute path to your ~/.cache/bazel-nxt folder to your idea64.vmoptions (Help → Edit Custom VM Options) |
| 48 | and restart IntelliJ: |
| 49 | |
| 50 | `-Dbazel.bep.path=/home/leopold/.cache/bazel-nxt` |
| 51 | |
| 52 | - Set "*Bazel Binary Location*" in Other Settings → Bazel Settings to the absolute path of scripts/bin/bazel. |
| 53 | This is a wrapper that will execute Bazel inside the container. |
| 54 | |
| 55 | - Open the `.ijwb` folder as IntelliJ project. |
| 56 | |
| 57 | - Disable Vgo support for the project. |
| 58 | |
| 59 | - Run a non-incremental sync in IntelliJ |
| 60 | |
| 61 | The plugin will automatically resolve paths for generated files. |
| 62 | |
| 63 | If you do not use IntelliJ, you need to use the scripts/bazel_copy_generated_for_ide.sh script to copy files locally. |