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

Function dk_gomain

src/pipeline/pass_docker.c:903–938  ·  view source on GitHub ↗

The `main` of the Go package build `b` (of `stage`) compiled: a file * package through that file; a directory through the directory, else through * the .go files copied straight into it (all from one repository dir). */

Source from the content-addressed store, hash-verified

901 * package through that file; a directory through the directory, else through
902 * the .go files copied straight into it (all from one repository dir). */
903static const cbm_gbuf_node_t *dk_gomain(dk_t *d, const dk_build_t *b, int stage) {
904 const char *pkg = b->pkg;
905 if (!pkg || strstr(pkg, "...") || strchr(pkg, '$')) {
906 return NULL;
907 }
908 dk_found_t f = {0};
909 if (dk_ends(pkg, ".go")) {
910 if (!dk_origin(d, stage, dk_absolute(d, pkg, b->workdir), DK_WANT_FILE, 0, &f) || !f.repo) {
911 return NULL;
912 }
913 return dk_gomain_node(d, dk_dir(d, f.repo));
914 }
915 const char *cdir = dk_absolute(d, pkg, b->workdir);
916 if (dk_origin(d, stage, cdir, DK_WANT_GOMAIN, 0, &f) && f.repo) {
917 return dk_gomain_node(d, f.repo);
918 }
919 const char *found = NULL;
920 bool many = false;
921 for (const dk_copy_t *c = d->st[stage].copies; c && cdir; c = c->next) {
922 if (c->has_from || !c->dst || c->nsrc != SKIP_ONE || !c->srcs[0] ||
923 !dk_ends(c->srcs[0], ".go") || dk_ends(c->dst, "/")) {
924 continue;
925 }
926 const char *into = dk_absolute(d, c->dst, c->workdir);
927 if (!into || strcmp(dk_dir(d, into), cdir) != 0) {
928 continue;
929 }
930 const char *hit = dk_repo(d, c->srcs[0], "", DK_WANT_FILE);
931 const char *hd = hit ? dk_dir(d, hit) : NULL;
932 if (hd) {
933 many = many || (found && strcmp(found, hd) != 0);
934 found = hd;
935 }
936 }
937 return found && !many ? dk_gomain_node(d, found) : NULL;
938}
939
940/* The words of shell text [p, e): split at blanks outside quotes, quotes
941 * and backslash escapes removed (a backslash-newline is a blank). */

Callers 1

dk_spawnFunction · 0.85

Calls 6

dk_endsFunction · 0.85
dk_originFunction · 0.85
dk_absoluteFunction · 0.85
dk_gomain_nodeFunction · 0.85
dk_dirFunction · 0.85
dk_repoFunction · 0.85

Tested by

no test coverage detected