Skip to content

Commit

Permalink
crossenv.mk: Migrate to using WHEEL_NAME and WHEEL_VERSION
Browse files Browse the repository at this point in the history
This allows using a unique method for both wheel and crossenv calls
  • Loading branch information
th0ma7 committed Jan 17, 2025
1 parent 6efb2c8 commit 7c89c52
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 24 deletions.
34 changes: 15 additions & 19 deletions mk/spksrc.crossenv.mk
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
# build_crossenv_target (override with CROSSENV_TARGET)
# post_crossenv_target (override with POST_CROSSENV_TARGET)
# Variables:
# WHEELS List of wheels to go through
# WHEEL_NAME Name of wheel to process
# WHEEL_VERSION Version of wheel to process (can be empty)

# Defined using PYTHON_PACKAGE_WORK_DIR from spksrc.python.mk or use local work directory
PYTHON_WORK_DIR = $(or $(wildcard $(PYTHON_PACKAGE_WORK_DIR)),$(wildcard $(WORK_DIR)))
Expand Down Expand Up @@ -55,13 +56,13 @@ endif

###

# Check for wheel==x.y, then fallback to wheel, then default
ifneq ($(wildcard $(CROSSENV_CONFIG_PATH)/requirements-$(WHEEL).txt),)
CROSSENV_BUILD_WHEEL = $(WHEEL)
CROSSENV_BUILD_REQUIREMENTS = $(CROSSENV_CONFIG_PATH)/requirements-$(CROSSENV_BUILD_WHEEL).txt
else ifneq ($(wildcard $(CROSSENV_CONFIG_PATH)/requirements-$(firstword $(subst -, ,$(WHEEL))).txt),)
CROSSENV_BUILD_WHEEL = $(firstword $(subst -, ,$(WHEEL)))
# Check for <wheel>-<x.y>, then fallback to <wheel>, then default
ifneq ($(wildcard $(CROSSENV_CONFIG_PATH)/requirements-$(WHEEL_NAME)-$(WHEEL_VERSION).txt),)
CROSSENV_BUILD_WHEEL = $(WHEEL_NAME)-$(WHEEL_VERSION)
CROSSENV_BUILD_REQUIREMENTS = $(CROSSENV_CONFIG_PATH)/requirements-$(CROSSENV_BUILD_WHEEL).txt
else ifneq ($(wildcard $(CROSSENV_CONFIG_PATH)/requirements-$(WHEEL_NAME).txt),)
CROSSENV_BUILD_WHEEL = $(WHEEL_NAME)
CROSSENV_BUILD_REQUIREMENTS = $(CROSSENV_CONFIG_PATH)/requirements-$(WHEEL_NAME).txt
else
CROSSENV_BUILD_WHEEL = default
CROSSENV_BUILD_REQUIREMENTS = $(CROSSENV_CONFIG_DEFAULT)
Expand All @@ -73,10 +74,10 @@ CROSSENV_COOKIE = $(WORK_DIR)/.crossenv-$(CROSSENV_BUILD_WHEEL)_done
###

# default wheel packages to install in crossenv
ifneq ($(wildcard $(CROSSENV_CONFIG_PATH)/requirements-$(WHEEL).txt $(CROSSENV_CONFIG_DEFAULT)),)
CROSSENV_DEFAULT_PIP_VERSION = $(shell grep -h -E "^pip[<>=]=" $(wildcard $(CROSSENV_CONFIG_PATH)/requirements-$(WHEEL).txt $(CROSSENV_CONFIG_DEFAULT)) | head -1 | sed -E 's/.*[<>=]=//')
CROSSENV_DEFAULT_SETUPTOOLS_VERSION = $(shell grep -h -E "^setuptools[<>=]=" $(wildcard $(CROSSENV_CONFIG_PATH)/requirements-$(WHEEL).txt $(CROSSENV_CONFIG_DEFAULT)) | head -1 | sed -E 's/.*[<>=]=//')
CROSSENV_DEFAULT_WHEEL_VERSION = $(shell grep -h -E "^wheel[<>=]=" $(wildcard $(CROSSENV_CONFIG_PATH)/requirements-$(WHEEL).txt $(CROSSENV_CONFIG_DEFAULT)) | head -1 | sed -E 's/.*[<>=]=//')
ifneq ($(wildcard $(CROSSENV_BUILD_REQUIREMENTS) $(CROSSENV_CONFIG_DEFAULT)),)
CROSSENV_DEFAULT_PIP_VERSION = $(shell grep -h -E "^pip[<>=]=" $(wildcard $(CROSSENV_BUILD_REQUIREMENTS) $(CROSSENV_CONFIG_DEFAULT)) | head -1 | sed -E 's/.*[<>=]=//')
CROSSENV_DEFAULT_SETUPTOOLS_VERSION = $(shell grep -h -E "^setuptools[<>=]=" $(wildcard $(CROSSENV_BUILD_REQUIREMENTS) $(CROSSENV_CONFIG_DEFAULT)) | head -1 | sed -E 's/.*[<>=]=//')
CROSSENV_DEFAULT_WHEEL_VERSION = $(shell grep -h -E "^wheel[<>=]=" $(wildcard $(CROSSENV_BUILD_REQUIREMENTS) $(CROSSENV_CONFIG_DEFAULT)) | head -1 | sed -E 's/.*[<>=]=//')
endif

ifneq ($(CROSSENV_DEFAULT_PIP_VERSION),)
Expand Down Expand Up @@ -114,13 +115,8 @@ post_crossenv_target: $(CROSSENV_TARGET)
###

crossenv-%:
ifneq ($(filter error-%, $(CROSSENV_BUILD_WHEEL)),)
@$(MSG) $(MAKE) $(CROSSENV_BUILD_WHEEL)
@$(MAKE) $(CROSSENV_BUILD_WHEEL) --no-print-directory
else
@$(MSG) $(MAKE) ARCH=$(firstword $(subst -, ,$*)) TCVERSION=$(lastword $(subst -, ,$*)) WHEEL=$(CROSSENV_BUILD_WHEEL) crossenv
-@MAKEFLAGS= $(MAKE) ARCH=$(firstword $(subst -, ,$*)) TCVERSION=$(lastword $(subst -, ,$*)) WHEEL=$(CROSSENV_BUILD_WHEEL) crossenv --no-print-directory
endif
@$(MSG) $(MAKE) ARCH=$(firstword $(subst -, ,$*)) TCVERSION=$(lastword $(subst -, ,$*)) WHEEL_NAME=$(WHEEL_NAME) WHEEL_VERSION=$(WHEEL_VERSION) crossenv
-@MAKEFLAGS= $(MAKE) ARCH=$(firstword $(subst -, ,$*)) TCVERSION=$(lastword $(subst -, ,$*)) WHEEL_NAME=$(WHEEL_NAME) WHEEL_VERSION=$(WHEEL_VERSION) crossenv --no-print-directory

####

Expand Down Expand Up @@ -167,7 +163,7 @@ export PYTHONPATH = $(PYTHON_LIB_NATIVE):$(PYTHON_STAGING_INSTALL_PREFIX)/lib/py
#
build_crossenv_target: SHELL:=/bin/bash
build_crossenv_target: pre_crossenv_target $(CROSSENV_PATH)/build/python-cc.mk
@$(MSG) $$(date +%Y%m%d-%H%M%S) MAKELEVEL: $(MAKELEVEL), PARALLEL_MAKE: $(PARALLEL_MAKE), ARCH: $(ARCH)-$(TCVERSION), CROSSENV: $(WHEEL) >> $(PSTAT_LOG)
@$(MSG) $$(date +%Y%m%d-%H%M%S) MAKELEVEL: $(MAKELEVEL), PARALLEL_MAKE: $(PARALLEL_MAKE), ARCH: $(ARCH)-$(TCVERSION), CROSSENV: $(CROSSENV_BUILD_WHEEL) >> $(PSTAT_LOG)
@$(MSG) Python sources: $(wildcard $(PYTHON_WORK_DIR)/Python-[0-9]*)
@$(MSG) crossenv wheel packages: $(CROSSENV_DEFAULT_PIP), $(CROSSENV_DEFAULT_SETUPTOOLS), $(CROSSENV_DEFAULT_WHEEL)
@$(MSG) crossenv requirement definition: $(CROSSENV_BUILD_REQUIREMENTS)
Expand Down
4 changes: 2 additions & 2 deletions mk/spksrc.python-module.mk
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ CROSSENV_MODULE_PATH = $(firstword $(wildcard $(WORK_DIR)/crossenv-$(PKG_NAME)-$

### Prepare crossenv
build_crossenv_module:
@$(MSG) WHEEL="$(PKG_NAME)-$(PKG_VERS)" $(MAKE) crossenv-$(ARCH)-$(TCVERSION)
-@MAKEFLAGS= WHEEL="$(PKG_NAME)-$(PKG_VERS)" $(MAKE) crossenv-$(ARCH)-$(TCVERSION)
@$(MSG) $(MAKE) WHEEL_NAME=\"$(PKG_VERS)\" WHEEL_VERSION=\"$(PKG_VERS)\" crossenv-$(ARCH)-$(TCVERSION)
-@MAKEFLAGS= $(MAKE) WHEEL_NAME="$(PKG_VERS)" WHEEL_VERSION="$(PKG_VERS)" crossenv-$(ARCH)-$(TCVERSION)

### Python extension module rules
compile_python_module: build_crossenv_module
Expand Down
6 changes: 3 additions & 3 deletions mk/spksrc.wheel-compile.mk
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ ifeq ($(wildcard $(WHEELHOUSE)),)
endif
@$(MSG) Compiling wheel [$(WHEEL_NAME)], version [$(WHEEL_VERSION)], type [$(WHEEL_TYPE)]
ifneq ($(WHEEL_TYPE),pure)
@$(MSG) $(MAKE) WHEEL=\"$(WHEEL_NAME)-$(WHEEL_VERSION)\" crossenv-$(ARCH)-$(TCVERSION) ; \
MAKEFLAGS= $(MAKE) WHEEL="$(WHEEL_NAME)-$(WHEEL_VERSION)" crossenv-$(ARCH)-$(TCVERSION) --no-print-directory ; \
[ "$(WHEEL_TYPE)" = "$(WHEELS_LIMITED_API)" ] && abi3="--build-option=--py-limited-api=$(PYTHON_LIMITED_API)" || abi3="" ; \
@$(MSG) $(MAKE) WHEEL_NAME=\"$(WHEEL_NAME)\" WHEEL_VERSION=\"$(WHEEL_VERSION)\" crossenv-$(ARCH)-$(TCVERSION) ; \
MAKEFLAGS= $(MAKE) WHEEL_NAME="$(WHEEL_NAME)" WHEEL_VERSION="$(WHEEL_VERSION)" crossenv-$(ARCH)-$(TCVERSION) --no-print-directory
@[ "$(WHEEL_TYPE)" = "$(WHEELS_LIMITED_API)" ] && abi3="--build-option=--py-limited-api=$(PYTHON_LIMITED_API)" || abi3="" ; \
global_options=$$(echo $(WHEELS_BUILD_ARGS) | sed -e 's/ \[/\n\[/g' | grep -i $(WHEEL_NAME) | cut -f2 -d] | xargs) ; \
localCFLAGS=($$(echo $(WHEELS_CFLAGS) | sed -e 's/ \[/\n\[/g' | grep -i $(WHEEL_NAME) | cut -f2 -d] | xargs)) ; \
localLDFLAGS=($$(echo $(WHEELS_LDFLAGS) | sed -e 's/ \[/\n\[/g' | grep -i $(WHEEL_NAME) | cut -f2 -d] | xargs)) ; \
Expand Down

0 comments on commit 7c89c52

Please sign in to comment.