MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / sh_link_spawn

Function sh_link_spawn

src/pipeline/pass_shell.c:3597–3635  ·  view source on GitHub ↗

SPAWNS to the rule `x->tgt` of a make target, the script `x->tgt` (its * Module, else its File) or the Process of `x->ext`, as pass_spawns.c draws * it. */

Source from the content-addressed store, hash-verified

3595 * Module, else its File) or the Process of `x->ext`, as pass_spawns.c draws
3596 * it. */
3597static int sh_link_spawn(cbm_pipeline_ctx_t *ctx, int64_t src, const sh_hit_t *x,
3598 CBMHashTable *modules) {
3599 char program[CBM_SZ_128];
3600 cbm_json_escape(program, (int)sizeof(program), x->make ? "make" : x->ext);
3601 char path[CBM_SZ_2K];
3602 path[0] = '\0';
3603 int64_t tgt = 0;
3604 if (x->make) {
3605 char esc[CBM_SZ_1K];
3606 char target[CBM_SZ_512];
3607 cbm_json_escape(esc, (int)sizeof(esc), x->path);
3608 cbm_json_escape(target, (int)sizeof(target), x->ext);
3609 snprintf(path, sizeof(path), ",\"path\":\"%s\",\"target\":\"%s\"", esc, target);
3610 tgt = x->tgt;
3611 } else if (x->tgt > 0) {
3612 int64_t mod = (int64_t)(intptr_t)cbm_ht_get(modules, x->path);
3613 tgt = mod > 0 ? mod : x->tgt;
3614 char esc[CBM_SZ_1K];
3615 cbm_json_escape(esc, (int)sizeof(esc), x->path);
3616 snprintf(path, sizeof(path), ",\"path\":\"%s\"", esc);
3617 } else {
3618 char qn[CBM_SZ_256];
3619 snprintf(qn, sizeof(qn), "__process__%s", x->ext);
3620 char node_props[CBM_SZ_256];
3621 snprintf(node_props, sizeof(node_props), "{\"program\":\"%s\"}", program);
3622 tgt = cbm_gbuf_upsert_node(ctx->gbuf, "Process", x->ext, qn, "", 0, 0, node_props);
3623 }
3624 if (tgt <= 0 || tgt == src) {
3625 return 0;
3626 }
3627 char ci[CBM_SZ_1K];
3628 sh_ci_props(x, ci, sizeof(ci));
3629 char props[CBM_SZ_4K];
3630 snprintf(props, sizeof(props),
3631 "{\"api\":\"%s\",\"program\":\"%s\"%s%s,\"line\":%d,\"confidence\":1.00}", x->via,
3632 program, path, ci, x->line);
3633 cbm_gbuf_insert_edge(ctx->gbuf, src, tgt, "SPAWNS", props);
3634 return SKIP_ONE;
3635}
3636
3637/* The edge hit `x` draws from source `src`; 1 when drawn. */
3638/* An image a build command makes DEPENDS_ON {via:build} the Dockerfile

Callers 1

sh_link_hitFunction · 0.85

Calls 5

cbm_json_escapeFunction · 0.85
cbm_ht_getFunction · 0.85
cbm_gbuf_upsert_nodeFunction · 0.85
sh_ci_propsFunction · 0.85
cbm_gbuf_insert_edgeFunction · 0.85

Tested by

no test coverage detected