Example #1
0
/* Resolve cycles.
 *
 * If there are cycles, the only cycles that can be broken are the DECLARED | DEFINED dependencies, which
 * are stored as dependency objects with the 'weak' flag set to TRUE.
 */
static int g_itemResolveCycles(g_item item, struct corto_depresolver_s* data) {
    corto_iter iter;
    g_dependency dep;
    corto_uint32 sp;

    sp = data->sp;

    /* If item has not yet been declared, search onDeclared list. If the item is already declared, the
     * dependencies in this list have already been resolved, thus need not to be evaluated again. */
    if (!item->declared && item->onDeclared) {

        /* Walk dependencies */
        iter = corto_llIter(item->onDeclared);
        while((corto_iterHasNext(&iter))) {
            dep = corto_iterNext(&iter);
            g_itemResolveDependencyCycles(dep, data);
        }
    }

    /* Walk onDefined list if item is not yet defined. */
    if (!item->defined && item->onDefined) {

        /* Walk dependencies */
        iter = corto_llIter(item->onDefined);
        while((corto_iterHasNext(&iter))) {
            dep = corto_iterNext(&iter);
            g_itemResolveDependencyCycles(dep, data);
        }
     }

    data->sp = sp;

    return 0;
}
Example #2
0
static corto_int16 html_copyFiles(htmlData_t *data) {
    corto_string doc;
    corto_asprintf(&doc, "%s/doc", CORTO_GEN_DOC_HTML_ETC);
    corto_ll files = corto_opendir(doc);
    if (!files) {
        goto error;
    }

    corto_iter it = corto_llIter(files);

    while (corto_iterHasNext(&it)) {
        corto_string f = corto_iterNext(&it);
        corto_id file;
        sprintf(file, "%s/%s", doc, f);
        if (corto_cp(file, data->output)) {
            goto error;
        }
    }

    corto_closedir(files);
    corto_dealloc(doc);

    return 0;
error:
    return -1;
}
Example #3
0
/* Run a command for multiple projects */
corto_int16 cortotool_runcmd(
    corto_ll dirs, char *argv[], corto_bool silent, corto_bool mute)
{
    corto_iter iter;
    corto_id cwd;
    corto_int8 ret = 0;

    strcpy(cwd, corto_cwd());

    if (dirs) {
        iter = corto_llIter(dirs);
    }

    do {
        corto_pid pid = 0;
        corto_int32 sig = 0;

        if (dirs) {
            corto_string dir = corto_iterNext(&iter);

            /* Change working directory to project */
            if (corto_chdir(dir)) {
                goto error;
            }
        }

        if (mute) {
            pid = corto_procrunRedirect(argv[0], argv,
                                        stdin, NULL, NULL);
        } else if (silent) {
            pid = corto_procrunRedirect(argv[0], argv,
                                        stdin, NULL, stderr);
        } else {
            pid = corto_procrun(argv[0], argv);
        }

        if (!pid) {
            corto_seterr("failed to start process %s", argv[0]);
            goto error;
        }

        if ((sig = corto_procwait(pid, &ret)) || ret) {
            corto_seterr("%s failed (%s %d)", argv[0],
                         sig ? "signal" : "returncode", sig ? sig : ret);
            goto error;
        }

        /* Reset to previous CWD if there is more than one project to build */
        corto_chdir(cwd);

    } while (dirs && corto_iterHasNext(&iter));

    return 0;
error:
    return -1;
}
Example #4
0
/* Insert at end */
void corto_llAppend(corto_ll list, void* data) {
    corto_llNode node = list->first;
    corto_iter iter = corto_llIter(list);

    if (node) {
        node = list->last;
    }

    corto_iterData(iter)->cur = node;
    corto_iterData(iter)->next = 0;

    insert(iter, data);
}
Example #5
0
/* Lookup item in administration */
g_item g_itemLookup(corto_object o, corto_depresolver data) {
    corto_iter iter;
    g_item item;

    /* Lookup item for 'o' in items list */
    item = NULL;
    iter = corto_llIter(data->items);
    while(!item && corto_iterHasNext(&iter)) {
        item = corto_iterNext(&iter);
        if (item->o != o) {
            item = NULL;
        }
    }

    /* If item did not yet exist, insert it in data */
    if (!item) {
        item = g_itemNew(o, data);
    }

    return item;
}
Example #6
0
/* Insert at start */
void corto_llInsert(corto_ll list, void* data) {
    corto_iter iter = corto_llIter(list);
    insert(iter, data);
}