You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

130 lines
4.0 KiB

  1. # Building in Mac OS X
  2. Building in Mac OS X can be accomplished in just a few steps:
  3. * Install general development tools (clang, make, git)
  4. * Install cmake
  5. * Checkout INAV sourcecode through git
  6. * Build the code
  7. ## Install general development tools (clang, make, git)
  8. Open up a terminal and run `make`. If it is installed already, you should see a message like this, which means that you
  9. already have the required development tools installed:
  10. ```
  11. make: *** No targets specified and no makefile found. Stop.
  12. ```
  13. If it isn't installed yet, you might get a popup like this. If so, click the "install" button to install the commandline
  14. developer tools:
  15. ![Prompt to install developer tools](assets/mac-prompt-tools-install.png)
  16. If you just get an error like this instead of a helpful popup prompt:
  17. ```
  18. -bash: make: command not found
  19. ```
  20. Try running `xcode-select --install` instead to trigger the popup.
  21. If that doesn't work, you'll need to install the XCode development environment [from the App Store][]. After
  22. installation, open up XCode and enter its preferences menu. Go to the "downloads" tab and install the
  23. "command line tools" package.
  24. [from the App Store]: https://itunes.apple.com/us/app/xcode/id497799835
  25. ## Install cmake
  26. The easiest way to install cmake's command line executable is via
  27. [Homebrew](https://brew.sh) (a package manager for macOS). Go to their site
  28. and follow their installation instructions.
  29. Once Homebrew is installed, type `brew install cmake` in a terminal to install
  30. cmake.
  31. Alternatively, cmake binaries for macOS are available from
  32. [cmake.org](https://cmake.org/download/). If you prefer installing it this way,
  33. you'd have to manually add cmake's command line binary to your `$PATH`. Assuming
  34. `CMake.app` has been copied to `/Applications`, adding the following line to
  35. `~/.zshrc` would make the cmake command available.
  36. ```sh
  37. export PATH=$PATH:/Applications/CMake.app/Contents/bin
  38. ```
  39. ## Ruby
  40. Ruby is installed by default on macOS.
  41. ## Checkout INAV sourcecode through git
  42. Enter your development directory and clone the [INAV repository][] using the "HTTPS clone URL" which is shown on
  43. the right side of the INAV GitHub page, like so:
  44. ```
  45. git clone https://github.com/iNavFlight/inav
  46. ```
  47. This will download the entire INAV repository for you into a new folder called "inav".
  48. [INAV repository]: https://github.com/iNavFlight/inav.git
  49. ## Build the code
  50. Assuming you've just cloned the source code, you can switch your current
  51. directory to inav's source try by typing:
  52. ```sh
  53. cd inav
  54. ```
  55. Inside the inav directory, create a new directory to store the built files. This
  56. helps keeping everything nice and tidy, separating source code from artifacts. By
  57. convention this directory is usually called `build`, but any name would work. Enter
  58. the following command to create it and switch your working directory to it:
  59. ```sh
  60. mkdir -p build && cd build
  61. ```
  62. Now we need to configure the build by using the following command:
  63. ```sh
  64. cmake ..
  65. ```
  66. This will automatically download the required compiler for inav, so it
  67. might take a few minutes. Once it's finished without errors, you can
  68. build the target that you want by typing `make target-name`. e.g.:
  69. ```sh
  70. make -j8 MATEKF722 # Will build MATEKF722 target
  71. ```
  72. A list of all the available targets can be displayed with:
  73. ```sh
  74. make targets
  75. ```
  76. Once the build completes, the correspondent `.hex` file will be found
  77. in current directory (e.g. `build`) and it will be named as
  78. `inav_x.y.z_TARGET.hex`. `x.y.z` corresponds to the INAV version number
  79. while `TARGET` will be the target name you've just built. e.g.
  80. `inav_2.6.0_MATEKF722.hex`. This is the file that can be flashed using
  81. INAV Configurator.
  82. ## Updating to the latest source
  83. If you want to erase your local changes and update to the latest version of the INAV source, enter your
  84. inav directory and run these commands to first erase your local changes, fetch and merge the latest
  85. changes from the repository, then rebuild the firmware:
  86. ```sh
  87. git reset --hard
  88. git pull
  89. make target-name # e.g. make MATEKF722
  90. ```