Commit graph

24 commits

Author SHA1 Message Date
f24541dbe4 pkg.App: Add options --distro-id, --interactive

Add the global options --distro-id and --interactive, and expose them as properties App.distro_id and App.interactive, respectively.

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-03-06 12:06:28 +01:00
03fca61248 jw.pkg.App.distro_id: Don't return opensuse

get-os.sh returned "suse" for SuSE-like distros, and that seems more appropriate since SLES is not OpenSUSE but should share and ID with other SuSE variants.

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-03-03 05:11:59 +01:00
6483de1a8f jw.pkg.App.get_os(): Don't use get-os.sh

Remove get-os.sh from App.py to reduce redunancy.

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-03-02 12:55:36 +00:00
f58e9fe298 jw.pkg.App: Add more distro_xxx properties

In addition to the existing propert distro_id, add the properties distro_codename, distro_name, distro_cascade and distro_gnu_triplet.

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-03-02 12:00:12 +01:00
2d08c2a12d jw.pkg.App.os_cascade: Add more fields

Add more fields to the OS cascade returned by App.os_cascade, based on the ID field in /etc/os-release. This includes some new ones, prefixed by pkg-, revealing which package format is used.

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-02-15 16:13:21 +00:00
26e739ca0d src.python.jw.pkg.App: Add property distro_id

Add @property App.distro_id, returning the ID field of /etc/os-release. It is supposed to be the most specific part of the OS cascade.

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-02-15 16:13:21 +00:00
a967924102 jw.pkg.App: Add property projs_root

projs_root is used read-only by CmdBuild and CmdModules, so add that property back.

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-02-14 20:59:23 +01:00
eaa38113bb jw.pkg.App.get_libname(): Fix typo

get_project_refs() is invoked with projects_only=true, which should read names_only. Fix that.

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-02-04 16:00:45 +01:00
6ca4af77d7 jw.pkg.App: Code beautification

Major - but not yet sufficient - code beautification starting from jw.pkg.App.

- Make more methods private - Rename methods to be more self-explanatory - Same for method arguments, notably clean up some inconsistent uses of "module" vs "project" - Add more type hints

Fix API breakage in the command modules.

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-01-29 11:32:14 +01:00
f6ed191d73 jw.pkg.App.get_modules_from_project_txt(): Add Scope

Add the Enum "Scope" to denote the scope argument of jw.pkg.App.get_modules_from_project_txt(), because it explains itself better than an integer.

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-01-26 17:58:23 +01:00
bf4834085e jw.pkg.App: Annotate add_modules_from_project_txt()

Type-annotate add_modules_from_project_txt()'s parameter list.

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-01-26 17:58:23 +01:00
5cdc32abd7 jw.pkg.App: Add lru_cache where possible

ResultCache is a home-grown result cache. The @lru_cache decorator, now available in Python 3, accomplishes the same thing, so try to ditch ResultCache for it.

Sadly, this doesn't entirely work as of now, because it uses hash() to hash the arguments, which won't work for the two list-type arguments to add_modules_from_project_txt() (buf and visited).

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-01-26 17:58:23 +01:00
a377745e5e jw.pkg.App: Make member variables private

With the exception of top_name, which cmds.project.GetVal needs read-access to, all member variables of jw.pkg.App can be made private.

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-01-26 17:58:23 +01:00
95fa2f0d06 jw.pkg.App: Remove .debug() and friends

Replace the jw.pkg.App.debug(), .warn() and .err() methods by the global log() function. There's no obvious benefit in having App know what's logged.

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-01-26 17:58:23 +01:00
aefe983920 jw.pkg.App: Support --topdir-format

Add support for --topdir-format. The option supports several different values, affecting the console output of App wherever it knows that the output contains a reference to the projects' toplevel directory.

- "unaltered" will have it print the toplevel directory in the same format as passed to the commandline
- "absolute" will try to resolve it to an absolute path before printing

- make:XXX will return the make-varible $(XXX) instead

To implement this, the proj_dir() member function is turned into the private member function __proj_dir(), and a new member function find_dir() is supplied, with two additional parameters: search_subdirs and search_absdirs, which will try to find an existing directory relative to the toplevel directory of the given module, or in the search_absdirs list, respectively.

Command modules in cmds.projects have been updated to use the new function.

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-01-26 17:58:23 +01:00
0b83c863a2 jw.build.cmds: Move build.cmds -> cmds.projects

Reorganize the Python module structure. Placing the command classes under jw.cmds.projects instead of jw.build.cmds will allow to add a nested command structure, with the current commands, being mostly related to building software, found below a "projects" toplevel command.

Other conceivable commands could be "package" for packaging, or "distro" for commands wrapping the distribution's package manager.

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-01-26 17:58:23 +01:00
c8c5788aeb jw.pkg.App.proj_dir(): Return absolute path

Make App.proj_dir() return an absolute path. This looks like a good idea, because some of the $(call proj_query xxx) paths end up being relative, because they get proj_dir()'s idea of a directory prepended. This prohibits caching them in $(TOPDIR)/make/.cache.mk for make benefit glorious nation of performance.

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-01-26 17:58:23 +01:00
adb9837c63 jw.pkg.App: Remove --debug option

Remove the --debug option, which is superseded by the semantically richer --log-level debug in the base class.

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-01-26 17:58:23 +01:00
737f3986df jw.pkg.App: Use lib.log

Replace print() by log().

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-01-26 17:58:23 +01:00
1f26391452 jw.pkg.cmds.Cmd: Derive from lib.Cmd

The body of Cmd is pretty much entirely obviated by its base class.

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-01-26 17:58:23 +01:00
e39047e0dd jw.pkg.App: Derive from jw.pkg.lib.App

Derive jw.pkg.App from jw.pkg.lib.App. App.run() dissolves as follows:

- Its sub-command invocation logic is left to the base class - parser.add_arguments() are moved into self._add_arguments() - So is handling of early-parsed arguments - async def _run() is reimplemented to set some member variables

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-01-26 17:58:23 +01:00
c39c268d98 jw-projects.sh: Fix -p / --prefix help message

--prefix doesn't denote an "App Path Prefix", "Parent directory of project source directories" decribes it better.

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-01-20 15:04:48 +01:00
ced42938e1 projects.mk / jw-projects.py: Support tmpl_dir && tmpls-dir

For a project to supply templates, it needs to advertise their location. For this, the tmpl_dir make variable is added to projects.mk. If other-project wants to get hold of some-project's templates, it can do, e.g.:

TEMPLATES = $(wilcard $(call tmpl_dir,some-project)/*.tmpl)

To achieve this, support for the tmpls-dir command is added to jw-projects.py.

Signed-off-by: Jan Lindemann <jan@janware.com>
2025-12-23 11:07:37 +01:00
9217d38964 Everywhere: Rename package "jw-build" to "jw-pkg"

jw-build doesn't stop at building software, packaging it afterwards is also a core feature, so this commit gives the package a better name.

The commit replaces strings s/jw-build/jw-pkg/ in text files and file names. Fallout to the functionality is fixed, variable names are left as they are, though. To be adjusted by later commits.

Signed-off-by: Jan Lindemann <jan@janware.com>
2025-11-28 13:35:56 +01:00
Renamed from src/python/jw/build/App.py (Browse further)