static bool link_find_native_library(lib_t lib, tree_t unit, FILE *deps) { #ifdef ENABLE_NATIVE ident_t name = tree_ident(unit); char *so_name = xasprintf("_%s.so", istr(name)); lib_mtime_t so_mt; if (!lib_stat(lib, so_name, &so_mt)) { free(so_name); return false; } lib_mtime_t unit_mt = lib_mtime(lib, name); if (unit_mt > so_mt) { warnf("unit %s has stale native shared library", istr(name)); free(so_name); return false; } if (deps != NULL) { char path[PATH_MAX]; lib_realpath(lib, so_name, path, sizeof(path)); fprintf(deps, "%s\n", path); } free(so_name); return true; #else // ENABLE_NATIVE return false; #endif // ENABLE_NATIVE }
static void link_product(lib_t lib, ident_t name, const char *prefix, const char *ext) { char path[PATH_MAX]; lib_realpath(lib, NULL, path, sizeof(path)); link_arg_f("%s%s/_%s.%s", prefix, path, istr(name), ext); }
void jit_init(ident_t top) { ident_t orig = ident_strip(top, ident_new(".elab")); ident_t final = ident_prefix(orig, ident_new("final"), '.'); char bc_fname[64], so_fname[64];; snprintf(bc_fname, sizeof(bc_fname), "_%s.bc", istr(final)); #if defined __CYGWIN__ snprintf(so_fname, sizeof(so_fname), "_%s.dll", istr(final)); #else snprintf(so_fname, sizeof(so_fname), "_%s.so", istr(final)); #endif char bc_path[PATH_MAX], so_path[PATH_MAX]; lib_realpath(lib_work(), bc_fname, bc_path, sizeof(bc_path)); lib_realpath(lib_work(), so_fname, so_path, sizeof(so_path)); using_jit = (jit_mod_time(bc_path) > jit_mod_time(so_path)); if (using_jit) jit_init_llvm(bc_path); else jit_init_native(so_path); }
void cover_report(tree_t top, const int32_t *stmts) { stmt_tag_i = ident_new("stmt_tag"); tree_visit(top, cover_report_stmts_fn, (void *)stmts); ident_t name = ident_strip(tree_ident(top), ident_new(".elab")); char dir[256]; snprintf(dir, sizeof(dir), "%s.cover", istr(name)); lib_t work = lib_work(); lib_mkdir(work, dir); for (cover_file_t *f = files; f != NULL; f = f->next) cover_report_file(f, dir); cover_index(name, dir); char output[PATH_MAX]; lib_realpath(work, dir, output, sizeof(output)); notef("coverage report generated in %s/", output); }