projects, make: Follow pkg.recommends.jw in the build closure #121
4 changed files with 58 additions and 22 deletions
|
|
@ -124,7 +124,9 @@ ifeq ($(TIME),)
|
|||
endif
|
||||
endif
|
||||
JW_PKG_PY_PROJECTS = $(JW_PKG_PY) projects
|
||||
JW_PKG_PY_BUILD = $(JW_PKG_PY_PROJECTS) build $(JW_PKG_PY_EXTRA_BUILD_OPTS)
|
||||
PKG_RELATIONS_BUILD ?= requires,recommends
|
||||
JW_PKG_PY_BUILD = $(JW_PKG_PY_PROJECTS) build --pkg-relations "$(PKG_RELATIONS_BUILD)" $(JW_PKG_PY_EXTRA_BUILD_OPTS)
|
||||
JW_PKG_PY_REQUIRED_OS_PKG = $(JW_PKG_PY_PROJECTS) required-os-pkg --quote --skip-excluded --pkg-relations "$(PKG_RELATIONS_BUILD)"
|
||||
PKG_MANAGER ?= $(TIME) $(JW_PKG_PY) --interactive=$(INTERACTIVE) pkg
|
||||
|
||||
ifneq ($(origin PROJECTS_DIR_REMOTE_BASE),undefined)
|
||||
|
|
@ -152,7 +154,7 @@ JANWARE_PACKAGE_FILTER = url =~ janware
|
|||
# ------------ projects to be built
|
||||
|
||||
TARGET_PROJECTS = $(filter-out $(EXCLUDE_FROM_BUILD),$(PROJECTS))
|
||||
DEP_PROJECTS = $(shell $(JW_PKG_PY_PROJECTS) pkg-requires --recursive --syntax names-only --no-subpackages --delimiter ' ' --subsections jw run,build,devel,release $(TARGET_PROJECTS))
|
||||
DEP_PROJECTS = $(shell JW_DEFAULT_LOG_LEVEL=WARNING $(JW_PKG_PY_BUILD) --build-order --dep-flavours="$(BUILD_DEP_FLAVOURS)" all $(TARGET_PROJECTS))
|
||||
GIT_PROJECTS = $(patsubst %/,%,$(dir $(wildcard $(addsuffix /.git,$(DEP_PROJECTS)))))
|
||||
PROJECTS_WITH_PROJECT_CONF = $(patsubst %/make/project.conf,%,$(wildcard $(addsuffix /make/project.conf,$(DEP_PROJECTS))))
|
||||
|
||||
|
|
@ -198,13 +200,13 @@ build-order-%: $(filter-out $(UNAVAILABLE_TARGETS),pull.done)
|
|||
build-order: build-order-all
|
||||
|
||||
echo-build-deps:
|
||||
$(Q)$(JW_PKG_PY_PROJECTS) required-os-pkg --quote --skip-excluded "build" $(TARGET_PROJECTS)
|
||||
$(Q)$(JW_PKG_PY_REQUIRED_OS_PKG) "build" $(TARGET_PROJECTS)
|
||||
|
||||
echo-install-deps:
|
||||
$(Q)$(JW_PKG_PY_PROJECTS) required-os-pkg --quote --skip-excluded "build,run" $(TARGET_PROJECTS)
|
||||
$(Q)$(JW_PKG_PY_REQUIRED_OS_PKG) "build,run" $(TARGET_PROJECTS)
|
||||
|
||||
echo-release-deps:
|
||||
$(Q)$(JW_PKG_PY_PROJECTS) required-os-pkg --quote --skip-excluded "build,run,release" $(TARGET_PROJECTS)
|
||||
$(Q)$(JW_PKG_PY_REQUIRED_OS_PKG) "build,run,release" $(TARGET_PROJECTS)
|
||||
echo-os:
|
||||
$(Q)$(JW_PKG_PY) platform info
|
||||
|
||||
|
|
@ -261,10 +263,10 @@ pkg-manager-dup:
|
|||
$(PKG_MANAGER) dup
|
||||
|
||||
pkg-install-build-deps:
|
||||
$(PKG_MANAGER) install $(shell $(JW_PKG_PY_PROJECTS) required-os-pkg --quote --skip-excluded "build" $(TARGET_PROJECTS))
|
||||
$(PKG_MANAGER) install $(shell $(JW_PKG_PY_REQUIRED_OS_PKG) "build" $(TARGET_PROJECTS))
|
||||
|
||||
pkg-install-release-deps:
|
||||
$(PKG_MANAGER) install $(shell $(JW_PKG_PY_PROJECTS) required-os-pkg --quote --skip-excluded "build,run,release" $(TARGET_PROJECTS))
|
||||
$(PKG_MANAGER) install $(shell $(JW_PKG_PY_REQUIRED_OS_PKG) "build,run,release" $(TARGET_PROJECTS))
|
||||
|
||||
pkg-release-reinstall: $(PREREQ_RELEASE)
|
||||
|
||||
|
|
|
|||
|
|
@ -62,6 +62,14 @@ class CmdBuild(Cmd): # export
|
|||
'comma or space separated'
|
||||
)
|
||||
)
|
||||
parser.add_argument(
|
||||
'--pkg-relations',
|
||||
default = 'requires',
|
||||
help = (
|
||||
'Relations between packages to take into consideration for build, '
|
||||
'comma or space separated'
|
||||
)
|
||||
)
|
||||
parser.add_argument(
|
||||
'--env-reinit',
|
||||
action = 'store_true',
|
||||
|
|
@ -103,7 +111,11 @@ class CmdBuild(Cmd): # export
|
|||
)
|
||||
|
||||
@lru_cache(maxsize = None)
|
||||
def read_deps(cur: str, dep_flavour: str) -> list[str]:
|
||||
def read_deps(
|
||||
cur: str,
|
||||
dep_flavour: str,
|
||||
relations: tuple[str, ...],
|
||||
) -> Iterable[str]:
|
||||
# dep cache doesn't make a difference at all
|
||||
if dep_flavour in dep_cache:
|
||||
if cur in dep_cache[dep_flavour]:
|
||||
|
|
@ -113,13 +125,13 @@ class CmdBuild(Cmd): # export
|
|||
|
||||
ret = self.app.get_project_refs(
|
||||
[cur],
|
||||
['pkg.requires.jw'],
|
||||
[f'pkg.{rel}.jw' for rel in relations],
|
||||
dep_flavour,
|
||||
scope = Scope.Subtree,
|
||||
add_self = False,
|
||||
names_only = True,
|
||||
)
|
||||
log(DEBUG, f'Prerequisites: {" ".join(ret)}')
|
||||
log(DEBUG, f'Prerequisites ({"/".join(relations)}): {" ".join(ret)}')
|
||||
if cur in ret:
|
||||
ret.remove(cur)
|
||||
|
||||
|
|
@ -134,6 +146,7 @@ class CmdBuild(Cmd): # export
|
|||
def add_dep_tree(
|
||||
cur: str,
|
||||
dep_flavours: Iterable[str],
|
||||
relations: tuple[str, ...],
|
||||
tree: DepNode,
|
||||
all_deps: set[str],
|
||||
) -> int:
|
||||
|
|
@ -145,9 +158,9 @@ class CmdBuild(Cmd): # export
|
|||
all_deps.add(cur)
|
||||
for t in dep_flavours:
|
||||
log(DEBUG, f'Checking deps of type "{t}"')
|
||||
deps.update(read_deps(cur, t))
|
||||
deps.update(read_deps(cur, t, relations))
|
||||
for d in deps:
|
||||
add_dep_tree(d, dep_flavours, tree, all_deps)
|
||||
add_dep_tree(d, dep_flavours, relations, tree, all_deps)
|
||||
tree[cur] = deps
|
||||
return len(deps)
|
||||
|
||||
|
|
@ -158,9 +171,10 @@ class CmdBuild(Cmd): # export
|
|||
) -> int:
|
||||
all_deps: set[str] = set()
|
||||
dep_tree: DepNode = {}
|
||||
relations = tuple(re.split(r'[,\s]+', args.pkg_relations))
|
||||
for m in modules:
|
||||
log(DEBUG, f'--- Adding dependency tree of module "{m}"')
|
||||
add_dep_tree(m, dep_flavours, dep_tree, all_deps)
|
||||
add_dep_tree(m, dep_flavours, relations, dep_tree, all_deps)
|
||||
while len(all_deps):
|
||||
# Find any leaf, deterministically: sorted, so that the
|
||||
# order is reproducible across runs
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import re
|
||||
|
||||
from typing import TYPE_CHECKING, override
|
||||
|
||||
from ...App import Scope
|
||||
|
|
@ -36,6 +38,14 @@ class CmdRequiredOsPkg(Cmd): # export
|
|||
default = False,
|
||||
help = 'Put double quotes around each listed dependency',
|
||||
)
|
||||
parser.add_argument(
|
||||
'--pkg-relations',
|
||||
default = 'requires',
|
||||
help = (
|
||||
'Relations between packages to take into consideration, '
|
||||
'comma or space separated'
|
||||
)
|
||||
)
|
||||
|
||||
@override
|
||||
async def _run(self, args: Namespace) -> None:
|
||||
|
|
@ -48,9 +58,10 @@ class CmdRequiredOsPkg(Cmd): # export
|
|||
if 'release' in flavours:
|
||||
flavours |= set(['run', 'devel', 'build'])
|
||||
log(DEBUG, 'flavours = ' + args.flavours)
|
||||
relations = tuple(re.split(r'[,\s]+', args.pkg_relations))
|
||||
deps = self.app.get_project_refs(
|
||||
modules,
|
||||
['pkg.requires.jw'],
|
||||
[f'pkg.{rel}.jw' for rel in relations],
|
||||
list(flavours),
|
||||
scope = Scope.Subtree,
|
||||
add_self = True,
|
||||
|
|
|
|||
|
|
@ -256,7 +256,8 @@ Available subcommands of projects:
|
|||
tmpl-dir Print directory containing templates of a given module
|
||||
============= Running: jw-pkg.py -t ../../../.. --log-level info projects build --help
|
||||
usage: jw-pkg.py projects build [-h] [--exclude EXCLUDE] [-n] [-O] [-I]
|
||||
[--dep-flavours DEP_FLAVOURS] [--env-reinit]
|
||||
[--dep-flavours DEP_FLAVOURS]
|
||||
[--pkg-relations PKG_RELATIONS] [--env-reinit]
|
||||
[--env-keep ENV_KEEP]
|
||||
target modules [modules ...]
|
||||
|
||||
|
|
@ -279,6 +280,10 @@ options:
|
|||
--dep-flavours DEP_FLAVOURS
|
||||
Dependency flavours to take into consideration for
|
||||
build, comma or space separated (default: auto)
|
||||
--pkg-relations PKG_RELATIONS
|
||||
Relations between packages to take into consideration
|
||||
for build, comma or space separated (default:
|
||||
requires)
|
||||
--env-reinit Source /etc/profile before each build step. Discard
|
||||
environment unless --env-keep is specified (default:
|
||||
False)
|
||||
|
|
@ -758,20 +763,24 @@ options:
|
|||
(default: None)
|
||||
============= Running: jw-pkg.py -t ../../../.. --log-level info projects required-os-pkg --help
|
||||
usage: jw-pkg.py projects required-os-pkg [-h] [--skip-excluded] [--quote]
|
||||
[--pkg-relations PKG_RELATIONS]
|
||||
flavours [modules ...]
|
||||
|
||||
List distribution packages required for a package
|
||||
|
||||
positional arguments:
|
||||
flavours Dependency flavours
|
||||
modules Modules (default: None)
|
||||
flavours Dependency flavours
|
||||
modules Modules (default: None)
|
||||
|
||||
options:
|
||||
-h, --help show this help message and exit
|
||||
--skip-excluded Output empty prerequisite list for excluded modules
|
||||
(default: False)
|
||||
--quote Put double quotes around each listed dependency (default:
|
||||
False)
|
||||
-h, --help show this help message and exit
|
||||
--skip-excluded Output empty prerequisite list for excluded modules
|
||||
(default: False)
|
||||
--quote Put double quotes around each listed dependency
|
||||
(default: False)
|
||||
--pkg-relations PKG_RELATIONS
|
||||
Relations between packages to take into consideration,
|
||||
comma or space separated (default: requires)
|
||||
============= Running: jw-pkg.py -t ../../../.. --log-level info projects summary --help
|
||||
usage: jw-pkg.py projects summary [-h] [module ...]
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue