| 3977 | } |
| 3978 | |
| 3979 | void cbm_pipeline_pass_shell(cbm_pipeline_ctx_t *ctx, const cbm_file_info_t *files, |
| 3980 | int file_count) { |
| 3981 | sh_index_t ix = {0}; |
| 3982 | sh_hits_t hits = {0}; |
| 3983 | cbm_arena_init(&hits.arena); |
| 3984 | hits.declarers = cbm_ht_create(0); |
| 3985 | sh_pass_t p = {.ix = &ix, .hits = &hits, .parser = NULL}; |
| 3986 | CBMHashTable *prow = sh_prow_files(ctx); |
| 3987 | CBMHashTable *seen = ctx->build_decl_count > 0 ? cbm_ht_create(0) : NULL; |
| 3988 | for (int i = 0; i < file_count; i++) { |
| 3989 | if (seen) { |
| 3990 | cbm_ht_set(seen, files[i].rel_path, (void *)files[i].rel_path); |
| 3991 | } |
| 3992 | sh_pass_file(&p, ctx, prow, files[i].rel_path, files[i].path, files[i].language); |
| 3993 | } |
| 3994 | /* An incremental run recomputes every image's build edges: the unchanged |
| 3995 | * files that declared builds before are read again (pipeline_incremental.c). */ |
| 3996 | for (int i = 0; seen && ctx->repo_path && i < ctx->build_decl_count; i++) { |
| 3997 | const char *rel = ctx->build_decl_files[i]; |
| 3998 | if (!rel || cbm_ht_get(seen, rel)) { |
| 3999 | continue; |
| 4000 | } |
| 4001 | cbm_ht_set(seen, rel, (void *)rel); |
| 4002 | const char *slash = strrchr(rel, '/'); |
| 4003 | CBMLanguage lang = cbm_language_for_filename(slash ? slash + SKIP_ONE : rel); |
| 4004 | char path[CBM_SZ_4K]; |
| 4005 | snprintf(path, sizeof(path), "%s/%s", ctx->repo_path, rel); |
| 4006 | sh_pass_file(&p, ctx, prow, rel, path, |
| 4007 | lang == CBM_LANG_MAKEFILE ? CBM_LANG_MAKEFILE : CBM_LANG_BASH); |
| 4008 | } |
| 4009 | if (seen) { |
| 4010 | cbm_ht_free(seen); |
| 4011 | } |
| 4012 | if (prow) { |
| 4013 | cbm_ht_free(prow); |
| 4014 | } |
| 4015 | if (hits.count > 0 && p.ix_ok && p.parser) { |
| 4016 | sh_make_resolve(&p, ctx, &hits); |
| 4017 | } |
| 4018 | int edges = hits.count > 0 ? sh_link(ctx, &hits) : 0; |
| 4019 | if (hits.declarers) { |
| 4020 | sh_mark_declarers(ctx, hits.declarers); |
| 4021 | cbm_ht_free(hits.declarers); |
| 4022 | } |
| 4023 | if (p.parser) { |
| 4024 | ts_parser_delete(p.parser); |
| 4025 | } |
| 4026 | cbm_free(CBM_MEM_CLASS_OTHER, hits.items); |
| 4027 | cbm_arena_destroy(&hits.arena); |
| 4028 | if (p.ix_ready) { |
| 4029 | sh_index_free(&ix); |
| 4030 | } |
| 4031 | if (edges > 0) { |
| 4032 | char buf[CBM_SZ_32]; |
| 4033 | snprintf(buf, sizeof(buf), "%d", edges); |
| 4034 | cbm_log_info("pass.shell.deploys", "edges", buf); |
| 4035 | } |
| 4036 | } |
no test coverage detected