| 41 | namespace config_resource_internal |
| 42 | { |
| 43 | s32 compile(CompileOptions &opts) |
| 44 | { |
| 45 | Buffer buf = opts.read(); |
| 46 | |
| 47 | TempAllocator1024 ta; |
| 48 | JsonObject boot(ta); |
| 49 | RETURN_IF_ERROR(sjson::parse(boot, buf)); |
| 50 | |
| 51 | const char *boot_script_json = boot["boot_script"]; |
| 52 | const char *boot_package_json = boot["boot_package"]; |
| 53 | RETURN_IF_FALSE(CONFIG_RESOURCE, boot_script_json != NULL, opts, "'boot_script' must be specified."); |
| 54 | RETURN_IF_FALSE(CONFIG_RESOURCE, boot_package_json != NULL, opts, "'boot_package' must be specified."); |
| 55 | |
| 56 | DynamicString boot_script(ta); |
| 57 | DynamicString boot_package(ta); |
| 58 | RETURN_IF_ERROR(sjson::parse_string(boot_script, boot_script_json)); |
| 59 | RETURN_IF_ERROR(sjson::parse_string(boot_package, boot_package_json)); |
| 60 | RETURN_IF_MISSING(CONFIG_RESOURCE, "lua", boot_script.c_str(), opts); |
| 61 | RETURN_IF_MISSING(CONFIG_RESOURCE, "package", boot_package.c_str(), opts); |
| 62 | |
| 63 | if (opts._bundle) { |
| 64 | TempAllocator256 ta; |
| 65 | DynamicString dest(ta); |
| 66 | destination_path(dest, opts._resource_id); |
| 67 | |
| 68 | File *config = opts._data_filesystem.open(dest.c_str(), FileOpenMode::READ); |
| 69 | file::copy(opts._output, *config, config->size()); |
| 70 | opts._data_filesystem.close(*config); |
| 71 | } else { |
| 72 | opts.write(buf); |
| 73 | } |
| 74 | |
| 75 | return 0; |
| 76 | } |
| 77 | |
| 78 | } // namespace config_resource_internal |
| 79 | #endif // if CROWN_CAN_COMPILE |
nothing calls this directly
no test coverage detected