Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: aduskett at gmail.com <aduskett@gmail.com>
To: buildroot@busybox.net
Subject: [Buildroot] [PATCH v2 3/3] package/uwsgi: add support for application types
Date: Sat, 23 Nov 2019 12:20:34 -0800	[thread overview]
Message-ID: <20191123202034.1397950-4-aduskett@gmail.com> (raw)
In-Reply-To: <20191123202034.1397950-1-aduskett@gmail.com>

From: Adam Duskett <Aduskett@gmail.com>

uWSGI supports many different application types; two everyday use cases are
Python and PHP.

uWSGI requires Python to configure, build, and install, but it is not necessary
to run. Setting the package type to generic saves upwards of 29M of space with
a Glibc target filing system (52M vs. 23M.) If however, the primary application
type is Python, then the package is better suited to be a python-package because
there is no longer any space saved, Python is now on the target and staging
directories, and Buildroot can provide all of the necessary variables to
compile the Python plugin.

The "Main application type" prompt in the Config.in sets the main_plugin
variable in the buildroot.ini file.

Signed-off-by: Adam Duskett <Aduskett@gmail.com>
---
 package/uwsgi/Config.in        | 45 ++++++++++++++++++++++++++++------
 package/uwsgi/buildroot.ini.in |  2 +-
 package/uwsgi/uwsgi.mk         | 26 ++++++++++++++------
 3 files changed, 56 insertions(+), 17 deletions(-)

diff --git a/package/uwsgi/Config.in b/package/uwsgi/Config.in
index f0de3093a4..a1341f289e 100644
--- a/package/uwsgi/Config.in
+++ b/package/uwsgi/Config.in
@@ -1,15 +1,11 @@
 menuconfig BR2_PACKAGE_UWSGI
 	bool "uwsgi"
 	depends on !BR2_STATIC_LIBS # dlfcn.h
-	depends on BR2_USE_MMU # python
-	depends on BR2_USE_WCHAR # python
-	depends on BR2_TOOLCHAIN_HAS_THREADS # python
 	# While it's possible to build uwsgi without PCRE, it would require not to
 	# build Python or PHP or several of the embedded plugins.
 	# The official documentation also recommends building PCRE support.
 	# https://uwsgi-docs.readthedocs.io/en/latest/SNI.html?highlight=sni-regexp
 	select BR2_PACKAGE_PCRE
-	select BR2_PACKAGE_PYTHON3 if !BR2_PACKAGE_PYTHON
 	help
 	  The uWSGI server.
 	  The uWSGI project aims at developing a full stack for
@@ -24,7 +20,36 @@ menuconfig BR2_PACKAGE_UWSGI
 
 if BR2_PACKAGE_UWSGI
 
-comment "plugins"
+choice
+	prompt "Main application type"
+	default BR2_PACKAGE_UWSGI_APPLICATION_PHP
+	help
+	  Select the application type
+
+config BR2_PACKAGE_UWSGI_APPLICATION_PHP
+	bool "PHP"
+	depends on !BR2_BINFMT_FLAT # PHP
+	select BR2_PACKAGE_PHP # runtime
+	select BR2_PACKAGE_PHP_BUILD_SHARED_LIBRARY # linking
+	help
+	  Select this if your primary application is PHP based.
+
+config BR2_PACKAGE_UWSGI_APPLICATION_PYTHON
+	bool "Python"
+	depends on BR2_USE_MMU # python
+	depends on BR2_USE_WCHAR # python
+	depends on BR2_TOOLCHAIN_HAS_THREADS # python
+	select BR2_PACKAGE_PYTHON3 if !BR2_PACKAGE_PYTHON
+	help
+	  Select this if your primary application is Python based.
+
+comment "uwsgi-python needs a toolchain w/ wchar, threads"
+	depends on BR2_USE_MMU
+	depends on !BR2_USE_WCHAR || !BR2_TOOLCHAIN_HAS_THREADS
+
+endchoice
+
+comment "plugins with external dependencies"
 
 config BR2_PACKAGE_UWSGI_PLUGINS_CAPABILITIES
 	bool "POSIX capability support"
@@ -60,6 +85,10 @@ config BR2_PACKAGE_UWSGI_PLUGINS_YAML
 
 endif
 
-comment "uwsgi needs a toolchain w/ dynamic library, wchar, threads"
-	depends on BR2_USE_MMU
-	depends on !BR2_USE_WCHAR || !BR2_TOOLCHAIN_HAS_THREADS || BR2_STATIC_LIBS
+config BR2_PACKAGE_UWSGI_MAIN_APPLICATION
+	string
+	default "php"  if BR2_PACKAGE_UWSGI_APPLICATION_PHP
+	default "python"  if BR2_PACKAGE_UWSGI_APPLICATION_PYTHON
+
+comment "uwsgi needs a toolchain w/ dynamic library"
+	depends on BR2_STATIC_LIBS
diff --git a/package/uwsgi/buildroot.ini.in b/package/uwsgi/buildroot.ini.in
index 75ad8afa32..e9074a3644 100644
--- a/package/uwsgi/buildroot.ini.in
+++ b/package/uwsgi/buildroot.ini.in
@@ -5,5 +5,5 @@ pcre = true
 ssl = false
 xml = false
 yaml = false
-main_plugin = python
+main_plugin = #MAIN_PLUGIN#
 plugin_dir = /usr/lib/uwsgi
diff --git a/package/uwsgi/uwsgi.mk b/package/uwsgi/uwsgi.mk
index add75c04b9..7186a78088 100644
--- a/package/uwsgi/uwsgi.mk
+++ b/package/uwsgi/uwsgi.mk
@@ -16,14 +16,7 @@ UWSGI_ENV += \
 	UWSGI_INCLUDES="$(STAGING_DIR)/usr/include" \
 	PLUGIN_BASE_DIR="$(TARGET_DIR)" \
 	PCRE_CONFIG="$(STAGING_DIR)/usr/bin/pcre-config" \
-	UWSGI_PROFILE=$(@D)/buildroot.ini \
-	PYTHON_LIBDIR="$(STAGING_DIR)/usr/lib"
-
-ifeq ($(BR2_PACKAGE_PYTHON),y)
-UWSGI_DEPENDENCIES += host-python host-python-setuptools python
-else
-UWSGI_DEPENDENCIES += host-python3 host-python3-setuptools python3
-endif
+	UWSGI_PROFILE=$(@D)/buildroot.ini
 
 ifeq ($(BR2_PACKAGE_LIBZLIB),y)
 UWSGI_DEPENDENCIES += libzlib
@@ -33,6 +26,22 @@ ifeq ($(BR2_PACKAGE_UTIL_LINUX_LIBUUID),y)
 UWSGI_DEPENDENCIES += util-linux
 endif
 
+ifeq ($(BR2_PACKAGE_UWSGI_APPLICATION_PHP),y)
+UWSGI_DEPENDENCIES += php
+UWSGI_ENV += \
+	UWSGICONFIG_PHPDIR="$(STAGING_DIR)/usr" \
+	UWSGICONFIG_PHPLIBDIR="$(STAGING_DIR)/usr/lib"
+endif
+
+ifeq ($(BR2_PACKAGE_UWSGI_APPLICATION_PYTHON),y)
+UWSGI_ENV += PYTHON_LIBDIR="$(STAGING_DIR)/usr/lib"
+ifeq ($(BR2_PACKAGE_PYTHON),y)
+UWSGI_DEPENDENCIES += host-python host-python-setuptools python
+else
+UWSGI_DEPENDENCIES += host-python3 host-python3-setuptools python3
+endif
+endif
+
 # Plugins
 ifeq ($(BR2_PACKAGE_UWSGI_PLUGINS_CAPABILITIES),y)
 UWSGI_DEPENDENCIES += libcap
@@ -82,6 +91,7 @@ define UWSGI_SETUP_PROFILE
 		$(eval value=$(shell echo $f | cut -d: -f 2)) \
 		$(SED) "s%$(option).*%$(option) = $(value)%g" $(@D)/buildroot.ini
 	)
+	$(SED) "s%#MAIN_PLUGIN#%$(BR2_PACKAGE_UWSGI_MAIN_APPLICATION)%g" $(@D)/buildroot.ini
 endef
 UWSGI_POST_PATCH_HOOKS = UWSGI_SETUP_PROFILE
 
-- 
2.23.0

      parent reply	other threads:[~2019-11-23 20:20 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-23 20:20 [Buildroot] [PATCH v2 0/3] uwsgi: new package aduskett at gmail.com
2019-11-23 20:20 ` [Buildroot] [PATCH v2 1/3] " aduskett at gmail.com
2020-02-04 12:54   ` Yann E. MORIN
2019-11-23 20:20 ` [Buildroot] [PATCH v2 2/3] package/php: add option to force building the shared library aduskett at gmail.com
2019-11-23 20:20 ` aduskett at gmail.com [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191123202034.1397950-4-aduskett@gmail.com \
    --to=aduskett@gmail.com \
    --cc=buildroot@busybox.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox