pmbootstrap-meow/pmb/parse
Oliver Smith 85ee201cf5
APKBUILD parser: recognize all top-level variables (MR 2300)
A common pattern in APKBUILDs, is to introduce custom variables prefixed
with underscores that get then used in makedepends and other variables.

For example:

  _wlrootsmakedepends="
	eudev-dev
  	# ...
  	"
  makedepends="
  	# ...
  	$_wlrootsmakedepends
  	"

Adjust the APKBUILD parser code, so it parses all top-level variables
and can use them further below when referenced inside other variables.
Before returning the parsed APKBUILD data, remove all variables that are
not in pmbootstrap's list of known APKBUILD parsing attributes (so the
result is the same).

I've compared "pmbootstrap apkbuild_parse" (which parses all APKBUILDs
in the currently checked out pmaports dir), before and after this
change, and the result is the same except for having more variables
successfully replaced.

- Performance Note-
This new implementation is actually faster than the previous one,
because we don't need to iterate through all known keys on each line of
the APKBUILDs. On my machine, average of 3 runs, parsing all APKBUILDs
of current pmaports master takes about half as long as with the previous
implementation.

  $ time pmbootstrap -q apkbuild_parse >/dev/null

-> old code: 0.954
-> new code: 0.483
2024-04-17 17:05:09 +02:00
..
__init__.py parse/init: allow importing arguments_install and arguments_flasher 2023-11-01 20:40:11 +01:00
_apkbuild.py APKBUILD parser: recognize all top-level variables (MR 2300) 2024-04-17 17:05:09 +02:00
apkindex.py pmb.helpers.pmaports.get: deal with operators 2023-11-29 22:31:11 +01:00
arch.py pmb.parse.arch: use qemu for running armhf on aarch64 (MR 2285) 2024-03-30 00:03:56 +00:00
arguments.py pmbootstrap status: rework (MR 2294) 2024-04-16 18:54:35 +00:00
binfmt_info.py Bump copyright to 2023 2023-01-22 19:18:06 +01:00
bootimg.py pmb.parse.bootimg: implement detection of QCDT types (MR 2276) 2024-03-17 18:45:51 +00:00
cpuinfo.py Bump copyright to 2023 2023-01-22 19:18:06 +01:00
depends.py parse.depends: consider selected providers when resolving providers 2023-11-26 11:01:35 +01:00
deviceinfo.py deviceinfo: make parse_kernel_suffix private 2023-07-21 08:54:10 +02:00
kconfig.py Print ERROR: infront of {NonBug,BuildFailed}Error (MR 2298) 2024-04-16 19:41:13 +00:00
version.py Bump copyright to 2023 2023-01-22 19:18:06 +01:00