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

Function sh_build

src/pipeline/pass_shell.c:2440–2519  ·  view source on GitHub ↗

docker / podman / nerdctl [buildx | image | builder] build, buildah bud: * each tagged image is built from the Dockerfile -f names (against the cwd), * else /Dockerfile -- one file of the repository. */

Source from the content-addressed store, hash-verified

2438 * each tagged image is built from the Dockerfile -f names (against the cwd),
2439 * else <context>/Dockerfile -- one file of the repository. */
2440static void sh_build(sh_t *s, TSNode cmd, const sh_argv_t *a) {
2441 int p = sh_program(s, a);
2442 const char *tool = p >= 0 && a->v[p] ? sh_basename(a->v[p]) : NULL;
2443 int i = p + SKIP_ONE;
2444 if (tool && strcmp(tool, "buildah") == 0) {
2445 if (i >= a->n || !a->v[i] ||
2446 !(sh_eq(a->v[i], "bud") || sh_eq(a->v[i], "build") ||
2447 sh_eq(a->v[i], "build-using-dockerfile"))) {
2448 return;
2449 }
2450 i++;
2451 } else if (tool && (strcmp(tool, "docker") == 0 || strcmp(tool, "podman") == 0 ||
2452 strcmp(tool, "nerdctl") == 0)) {
2453 if (i < a->n && sh_eq(a->v[i], "build")) {
2454 i++;
2455 } else if (i + SKIP_ONE < a->n &&
2456 (sh_eq(a->v[i], "buildx") || sh_eq(a->v[i], "image") ||
2457 sh_eq(a->v[i], "builder")) &&
2458 sh_eq(a->v[i + SKIP_ONE], "build")) {
2459 i += PAIR_LEN;
2460 } else {
2461 return;
2462 }
2463 } else {
2464 return;
2465 }
2466 if (s->hits->declarers) {
2467 cbm_ht_set(s->hits->declarers, s->file, (void *)s->file);
2468 }
2469 int tags[SH_BUILD_TAGS];
2470 const char *tag_vals[SH_BUILD_TAGS];
2471 int nt = 0;
2472 const char *dfile = NULL;
2473 bool dfile_known = true;
2474 const char *ctx = NULL;
2475 bool ctx_seen = false;
2476 for (; i < a->n; i++) {
2477 const char *w = a->v[i];
2478 if (w && (sh_eq(w, "-t") || sh_eq(w, "--tag")) && i + SKIP_ONE < a->n) {
2479 if (nt < SH_BUILD_TAGS) {
2480 tags[nt] = i + SKIP_ONE;
2481 tag_vals[nt++] = a->v[i + SKIP_ONE];
2482 }
2483 i++;
2484 } else if (w && (sh_eq(w, "-f") || sh_eq(w, "--file")) && i + SKIP_ONE < a->n) {
2485 dfile = a->v[i + SKIP_ONE];
2486 dfile_known = dfile != NULL;
2487 i++;
2488 } else if (w && strncmp(w, "--tag=", strlen("--tag=")) == 0) {
2489 if (nt < SH_BUILD_TAGS && w[strlen("--tag=")]) {
2490 tags[nt] = -SKIP_ONE;
2491 tag_vals[nt++] = w + strlen("--tag=");
2492 }
2493 } else if (w && strncmp(w, "--file=", strlen("--file=")) == 0) {
2494 dfile = w + strlen("--file=");
2495 } else if (w && w[0] == '-') {
2496 i += !strchr(w, '=') && sh_in(w, SH_BUILD_VALUED) ? SKIP_ONE : 0;
2497 } else if (!ctx_seen) {

Callers 2

sh_commandFunction · 0.85
sh_pipe_runFunction · 0.85

Calls 9

sh_programFunction · 0.85
sh_basenameFunction · 0.85
sh_eqFunction · 0.85
cbm_ht_setFunction · 0.85
sh_inFunction · 0.85
sh_joinFunction · 0.85
sh_unique_fileFunction · 0.85
sh_image_repoFunction · 0.85
sh_hit_pushFunction · 0.85

Tested by

no test coverage detected