pylibfdt: Improved version extraction

Currently setup.py expects the library version in a VERSION environment
variable, or it exctracts the version from the Makefile.  The latter is
for the case where the script is run standalone, rather than from make.
But parsing the Makefile is ugly and fragile, and won't always get the
same version we put into the C code.

This changes to instead extracting the version from the trivial .h file we
already generate to put the version into C code.  It's still slightly ugly,
but it's simpler and since we can control the precise format of that .h,
not as fragile.

This lets us remove the remains of the makefile parsing code from setup.py.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Reviewed-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
David Gibson
2018-08-10 14:25:42 +10:00
parent 7ba2be6cda
commit 98972f1b3e
2 changed files with 9 additions and 74 deletions

View File

@@ -12,11 +12,10 @@ SETUPFLAGS += --quiet
endif
define run_setup
VERSION="$(dtc_version)"
$(SETUP) $(SETUPFLAGS) $(1)
endef
$(PYMODULE): $(PYLIBFDT_srcs) $(LIBFDT_archive) $(SETUP)
$(PYMODULE): $(PYLIBFDT_srcs) $(LIBFDT_archive) $(SETUP) $(VERSION_FILE)
@$(VECHO) PYMOD $@
$(call run_setup, build_ext --build-lib=$(PYLIBFDT_objdir))