Browse Source

python: introduce Build/Compile/HostPyRun{Host,Target}

Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
lilik-openwrt-22.03
Yousong Zhou 8 years ago
parent
commit
fbba266e79
2 changed files with 32 additions and 11 deletions
  1. +16
    -5
      lang/python/files/python-host.mk
  2. +16
    -6
      lang/python/files/python-package.mk

+ 16
- 5
lang/python/files/python-host.mk View File

@ -31,12 +31,12 @@ define HostPython
$(HOST_PYTHON_BIN) $(2); $(HOST_PYTHON_BIN) $(2);
endef endef
# $(1) => build subdir
# $(2) => additional arguments to setup.py
# $(1) => commands to execute before running pythons script
# $(2) => python script and its arguments
# $(3) => additional variables # $(3) => additional variables
define Build/Compile/HostPyMod
define Build/Compile/HostPyRunHost
$(call HostPython, \ $(call HostPython, \
cd $(HOST_BUILD_DIR)/$(strip $(1)); \
$(if $(1),$(1);) \
CC="$(HOSTCC)" \ CC="$(HOSTCC)" \
CCSHARED="$(HOSTCC) $(HOST_FPIC)" \ CCSHARED="$(HOSTCC) $(HOST_FPIC)" \
CXX="$(HOSTCXX)" \ CXX="$(HOSTCXX)" \
@ -48,9 +48,20 @@ define Build/Compile/HostPyMod
_PYTHON_HOST_PLATFORM=linux2 \ _PYTHON_HOST_PLATFORM=linux2 \
$(3) \ $(3) \
, \ , \
./setup.py $(2) \
$(2) \
, \ , \
HOST \ HOST \
) )
endef endef
# $(1) => build subdir
# $(2) => additional arguments to setup.py
# $(3) => additional variables
define Build/Compile/HostPyMod
$(call Build/Compile/HostPyRunHost, \
cd $(HOST_BUILD_DIR)/$(strip $(1)), \
./setup.py $(2), \
$(3))
endef

+ 16
- 6
lang/python/files/python-package.mk View File

@ -82,13 +82,12 @@ endef
$(call include_mk, python-host.mk) $(call include_mk, python-host.mk)
# $(1) => build subdir
# $(2) => additional arguments to setup.py
# $(1) => commands to execute before running pythons script
# $(2) => python script and its arguments
# $(3) => additional variables # $(3) => additional variables
define Build/Compile/PyMod
$(INSTALL_DIR) $(PKG_INSTALL_DIR)/$(PYTHON_PKG_DIR)
define Build/Compile/HostPyRunTarget
$(call HostPython, \ $(call HostPython, \
cd $(PKG_BUILD_DIR)/$(strip $(1)); \
$(if $(1),$(1);) \
CC="$(TARGET_CC)" \ CC="$(TARGET_CC)" \
CCSHARED="$(TARGET_CC) $(FPIC)" \ CCSHARED="$(TARGET_CC) $(FPIC)" \
CXX="$(TARGET_CXX)" \ CXX="$(TARGET_CXX)" \
@ -101,8 +100,19 @@ define Build/Compile/PyMod
__PYVENV_LAUNCHER__="/usr/bin/$(PYTHON)" \ __PYVENV_LAUNCHER__="/usr/bin/$(PYTHON)" \
$(3) \ $(3) \
, \ , \
./setup.py $(2) \
$(2) \
) )
endef
# $(1) => build subdir
# $(2) => additional arguments to setup.py
# $(3) => additional variables
define Build/Compile/PyMod
$(INSTALL_DIR) $(PKG_INSTALL_DIR)/$(PYTHON_PKG_DIR)
$(call Build/Compile/HostPyRunTarget, \
cd $(PKG_BUILD_DIR)/$(strip $(1)), \
./setup.py $(2), \
$(3))
find $(PKG_INSTALL_DIR) -name "*\.pyc" -o -name "*\.pyo" -o -name "*\.exe" | xargs rm -f find $(PKG_INSTALL_DIR) -name "*\.pyc" -o -name "*\.pyo" -o -name "*\.exe" | xargs rm -f
endef endef


Loading…
Cancel
Save