Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| docs:guide-developer:creating_a_meson_based_package [2023/12/12 14:18] – [Create] javad.rahimi | docs:guide-developer:creating_a_meson_based_package [2024/08/15 05:38] (current) – Capitalization memicinn19 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== Create Meson-based packages in OpenWRT | + | ====== Create Meson-based packages in OpenWrt |
| - | This tutorial provides a step-by-step guide to creating and installing meson-based packages in OpenWRT. We assume that the source code is local, but the process is the same for other cases such as Git, SVN, etc. | + | This tutorial provides a step-by-step guide to creating and installing meson-based packages in OpenWrt. We assume that the source code is local, but the process is the same for other cases such as Git, SVN, etc. |
| ===== General instructions in building packages ===== | ===== General instructions in building packages ===== | ||
| The '' | The '' | ||
| Line 25: | Line 25: | ||
| </ | </ | ||
| - | To create a Meson package for OpenWRT, we need to perform a few steps. Firstly, we should include '' | + | To create a Meson package for OpenWrt, we need to perform a few steps. Firstly, we should include '' |
| ===== A simple Meson package ===== | ===== A simple Meson package ===== | ||
| Line 38: | Line 38: | ||
| touch main.c | touch main.c | ||
| </ | </ | ||
| + | ==== main.c ==== | ||
| + | |||
| + | To demonstrate a basic scenario, we will be populating the '' | ||
| + | |||
| + | <code c> | ||
| + | // main.c | ||
| + | #include < | ||
| + | |||
| + | int main(int argc, char** argv) | ||
| + | { | ||
| + | printf(“Hello World\n”); | ||
| + | return 0; | ||
| + | } | ||
| + | </ | ||
| + | ==== meson.build ==== | ||
| + | |||
| + | For the '' | ||
| + | <code cmake> | ||
| + | # meson.build | ||
| + | project(' | ||
| + | executable(' | ||
| + | </ | ||
| + | |||
| + | ==== Makefile ==== | ||
| + | |||
| + | The '' | ||
| + | <code makefile> | ||
| + | include $(TOPDIR)/ | ||
| + | include $(INCLUDE_DIR)/ | ||
| + | include $(INCLUDE_DIR)/ | ||
| + | include $(INCLUDE_DIR)/ | ||
| + | # Name, version and release number | ||
| + | # The name and version of your package are used to define the variable to point to the build directory of your package: $(PKG_BUILD_DIR) | ||
| + | PKG_NAME: | ||
| + | PKG_VERSION: | ||
| + | PKG_RELEASE: | ||
| + | |||
| + | # Source settings (i.e. where to find the source codes) | ||
| + | # This is a custom variable, used below | ||
| + | SOURCE_DIR: | ||
| + | |||
| + | |||
| + | # Package definition; instructs on how and where our package will appear in the overall configuration menu ('make menuconfig' | ||
| + | define Package/ | ||
| + | SECTION: | ||
| + | CATEGORY: | ||
| + | TITLE: | ||
| + | endef | ||
| + | |||
| + | # Package description; | ||
| + | define Package/ | ||
| + | A simple " | ||
| + | endef | ||
| + | |||
| + | define Package/ | ||
| + | $(INSTALL_DIR) $(1)/ | ||
| + | $(INSTALL_BIN) | ||
| + | |||
| + | endef | ||
| + | |||
| + | $(eval $(call BuildPackage, | ||
| + | </ | ||
| + | In order to incorporate our new package, we will need to make some changes to the '' | ||
| + | <code bash> | ||
| + | src-link mesonpackages / | ||
| + | </ | ||
| + | |||
| + | ==== feeds.conf ==== | ||
| + | |||
| + | Next, we need to update the package feed. | ||
| + | < | ||
| + | ./ | ||
| + | ./ | ||
| + | </ | ||
| + | |||
| + | Once we have updated the necessary feeds, the next step is to select the correct package for building. To do this, we must open the configuration menu by typing '' | ||
| + | |||
| + | To finish building the package, we need to execute the build command. Running this command will compile all the necessary files and create the final package that can be used for deployment or distribution. | ||
| + | <code bash> | ||
| + | make package/ | ||
| + | </ | ||
| + | If everything goes smoothly, the package that is built will be located in ''< | ||
| + | < | ||
| + | helloworld_1.0-1_arm_cortex-a7_neon-vfpv4.ipk | ||
| + | </ | ||
| + | |||