UNPKG

edacation

Version:

Library and CLI for interacting with Yosys and nextpnr.

54 lines 2.48 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.getCombined = exports.getOptions = exports.getDefaultOptions = exports.getTargetFile = exports.getTarget = exports.getTargetDefaults = void 0; const path_1 = __importDefault(require("path")); const getTargetDefaults = (configuration) => { return configuration.defaults ?? {}; }; exports.getTargetDefaults = getTargetDefaults; const getTarget = (configuration, targetId) => { const target = configuration.targets.find((target) => target.id === targetId); if (!target) { throw new Error(`Target "${targetId}" could not be found.`); } return target; }; exports.getTarget = getTarget; const getTargetFile = (target, file) => path_1.default.join(target.directory ?? '.', file); exports.getTargetFile = getTargetFile; const getDefaultOptions = (configuration, workerId, defaultValues) => { const targetDefaults = (0, exports.getTargetDefaults)(configuration)[workerId]; const defaultConfig = targetDefaults ? targetDefaults.options : undefined; return { ...defaultValues, ...defaultConfig }; }; exports.getDefaultOptions = getDefaultOptions; const getOptions = (configuration, targetId, workerId, defaultValues) => { const defaultOptions = (0, exports.getDefaultOptions)(configuration, workerId, defaultValues); const target = (0, exports.getTarget)(configuration, targetId)[workerId]; const config = target ? target.options : undefined; return { ...defaultOptions, ...config }; }; exports.getOptions = getOptions; const defaultParse = (values) => values; const getCombined = (configuration, targetId, workerId, configId, generated, parse = defaultParse) => { const targetDefaults = (0, exports.getTargetDefaults)(configuration)[workerId]; const target = (0, exports.getTarget)(configuration, targetId)[workerId]; const defaultConfig = targetDefaults ? targetDefaults[configId] : undefined; const config = target ? target[configId] : undefined; return [ ...(!config || config.useGenerated ? generated : []), ...((!config || config.useDefault) && !!defaultConfig ? parse(defaultConfig.values) : []), ...(config ? parse(config.values) : []) ]; }; exports.getCombined = getCombined; //# sourceMappingURL=target.js.map