void build_action(vector_t *arguments) { load_t *loader = load_project_config(); if (!loader) { printf("error: are you sure the current directory contains an Ark project?\n"); return; } table_t *package = get_table(loader, "package"); // check for a custom build method and use it if it // exists. char *build_method = get_string_contents("build", package); if (build_method) { // note we're using system calls, this isn't a good idea // at all, we're also just throwing in some random variable // that should probably be sanitized? // same applies for the one below exec_process(build_method); sdsfree(build_method); } else { exec_process("ark build src/*.ark"); } destroy_loader(loader); }
// Reads a library from the given library path and adds the modules to this // loaders set of available modules. static value_t module_loader_read_library(runtime_t *runtime, value_t self, value_t library_path) { // Read the library from the file. string_t library_path_str; get_string_contents(library_path, &library_path_str); TRY_DEF(data, read_file_to_blob(runtime, &library_path_str)); TRY_DEF(library, runtime_plankton_deserialize(runtime, data)); if (!in_family(ofLibrary, library)) return new_invalid_input_condition(); set_library_display_name(library, library_path); // Load all the modules from the library into this module loader. id_hash_map_iter_t iter; id_hash_map_iter_init(&iter, get_library_modules(library)); while (id_hash_map_iter_advance(&iter)) { value_t key; value_t value; id_hash_map_iter_get_current(&iter, &key, &value); TRY(set_id_hash_map_at(runtime, get_module_loader_modules(self), key, value)); } return success(); }