jw.pkg.cmds.projects.CmdBuild: Add --source-profile

Add --source-profile=[no|add|replace] to the projects build command,
doing the obvious thing.

Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
Jan Lindemann 2026-02-18 14:22:19 +01:00
commit 230eacac8b

View file

@ -4,7 +4,7 @@ import os, re, sys, subprocess, datetime, time
from argparse import Namespace, ArgumentParser from argparse import Namespace, ArgumentParser
from functools import lru_cache from functools import lru_cache
from ...lib.util import run_cmd from ...lib.util import run_cmd, get_profile_env
from ...lib.log import * from ...lib.log import *
from ..Cmd import Cmd from ..Cmd import Cmd
from ..CmdProjects import CmdProjects from ..CmdProjects import CmdProjects
@ -24,6 +24,8 @@ class CmdBuild(Cmd): # export
default=False, help='Don\'t build anything, just print the build order.') default=False, help='Don\'t build anything, just print the build order.')
parser.add_argument('-I', '--ignore-deps', action='store_true', parser.add_argument('-I', '--ignore-deps', action='store_true',
default=False, help='Don\'t build dependencies, i.e. build only modules specified on the command line') default=False, help='Don\'t build dependencies, i.e. build only modules specified on the command line')
parser.add_argument('--source-profile', choices=['no', 'add', 'replace'],
default='no', help='Source /etc/profile before each build step')
parser.add_argument('target', default='all', help='Build target') parser.add_argument('target', default='all', help='Build target')
parser.add_argument('modules', nargs='+', default='', help='Modules to be built') parser.add_argument('modules', nargs='+', default='', help='Modules to be built')
@ -85,16 +87,21 @@ class CmdBuild(Cmd): # export
return 1 return 1
async def run_make(module, target, cur_project, num_projects): async def run_make(module, target, cur_project, num_projects):
patt = self.app.is_excluded_from_build(module)
if patt is not None:
print(f',{title} >')
print(f'| Configured to skip build on platform >{patt}<')
print(f'`{title} <')
return
make_cmd = [ "make", target ] make_cmd = [ "make", target ]
wd = self.app.find_dir(module, pretty=False) wd = self.app.find_dir(module, pretty=False)
title = '---- [%d/%d]: Running "%s" in %s -' % (cur_project, num_projects, ' '.join(make_cmd), wd) title = '---- [%d/%d]: Running "%s" in %s -' % (cur_project, num_projects, ' '.join(make_cmd), wd)
patt = self.app.is_excluded_from_build(module) env = None
if patt is not None: if args.source_profile != 'no':
print(',' + title + ' >') env = await get_profile_env(add=True if args.source_profile == 'add' else False)
print('| Configured to skip build on platform >' + patt + '<')
print('`' + title + ' <')
return
try: try:
stdout, stderr = await run_cmd( stdout, stderr = await run_cmd(
@ -103,7 +110,7 @@ class CmdBuild(Cmd): # export
throw=True, throw=True,
verbose=True, verbose=True,
cmd_input=None, cmd_input=None,
env=None, env=env,
title=title title=title
) )
except Exception as e: except Exception as e: