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AARD,gDAQC;AAED,MAAa,UAAW,SAAQ,aAAM;IAGpC,YAAY,IAAY;QACtB,KAAK,CAAC,IAAI,CAAC,CAAA;QAHJ,YAAO,GAAG,IAAI,CAAA;IAIvB,CAAC;IAED,IAAI,MAAM;QACR,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,CAAA;IAC/B,CAAC;IAED,2BAA2B;IAC3B,KAAK,CAAC,KAAK,CAAC,SAAiB,EAAE,IAAU;QACvC,WAAW;IACb,CAAC;CACF;AAfD,gCAeC","sourcesContent":["import { addValue, Arch, archFromString, ArchType, asArray } from \"builder-util\"\nimport { DEFAULT_TARGET, DIR_TARGET, Platform, Target, TargetConfiguration } from \"../core\"\nimport { PlatformPackager } from \"../platformPackager\"\nimport { ArchiveTarget } from \"./ArchiveTarget\"\n\nconst archiveTargets = new Set([\"zip\", \"7z\", \"tar.xz\", \"tar.lz\", \"tar.gz\", \"tar.bz2\"])\n\nexport function computeArchToTargetNamesMap(raw: Map<Arch, Array<string>>, platformPackager: PlatformPackager<any>, platform: Platform): Map<Arch, Array<string>> {\n for (const targetNames of raw.values()) {\n if (targetNames.length > 0) {\n // https://github.com/electron-userland/electron-builder/issues/1355\n return raw\n }\n }\n\n const defaultArchs: Array<ArchType> = raw.size === 0 ? [process.arch as ArchType] : Array.from(raw.keys()).map(it => Arch[it] as ArchType)\n const result = new Map(raw)\n for (const target of asArray(platformPackager.platformSpecificBuildOptions.target).map<TargetConfiguration>(it => (typeof it === \"string\" ? { target: it } : it))) {\n let name = target.target\n let archs = target.arch\n const suffixPos = name.lastIndexOf(\":\")\n if (suffixPos > 0) {\n name = target.target.substring(0, suffixPos)\n if (archs == null) {\n archs = target.target.substring(suffixPos + 1) as ArchType\n }\n }\n\n for (const arch of archs == null ? defaultArchs : asArray(archs)) {\n addValue(result, archFromString(arch), name)\n }\n }\n\n if (result.size === 0) {\n const defaultTarget = platformPackager.defaultTarget\n if (raw.size === 0 && platform === Platform.LINUX && (process.platform === \"darwin\" || process.platform === \"win32\")) {\n result.set(Arch.x64, defaultTarget)\n // cannot enable arm because of native dependencies - e.g. keytar doesn't provide pre-builds for arm\n // result.set(Arch.armv7l, [\"snap\"])\n } else {\n for (const arch of defaultArchs) {\n result.set(archFromString(arch), defaultTarget)\n }\n }\n }\n\n return result\n}\n\nexport function createTargets(nameToTarget: Map<string, Target>, rawList: Array<string>, outDir: string, packager: PlatformPackager<any>): Array<Target> {\n const result: Array<Target> = []\n\n const mapper = (name: string, factory: (outDir: string) => Target) => {\n let target = nameToTarget.get(name)\n if (target == null) {\n target = factory(outDir)\n nameToTarget.set(name, target)\n }\n result.push(target)\n }\n\n const targets = normalizeTargets(rawList, packager.defaultTarget)\n packager.createTargets(targets, mapper)\n return result\n}\n\nfunction normalizeTargets(targets: Array<string>, defaultTarget: Array<string>): Array<string> {\n const list: Array<string> = []\n for (const t of targets) {\n const name = t.toLowerCase().trim()\n if (name === DEFAULT_TARGET) {\n list.push(...defaultTarget)\n } else {\n list.push(name)\n }\n }\n return list\n}\n\nexport function createCommonTarget(target: string, outDir: string, packager: PlatformPackager<any>): Target {\n if (archiveTargets.has(target)) {\n return new ArchiveTarget(target, outDir, packager)\n } else if (target === DIR_TARGET) {\n return new NoOpTarget(DIR_TARGET)\n } else {\n throw new Error(`Unknown target: ${target}`)\n }\n}\n\nexport class NoOpTarget extends Target {\n readonly options = null\n\n constructor(name: string) {\n super(name)\n }\n\n get outDir(): string {\n throw new Error(\"NoOpTarget\")\n }\n\n // eslint-disable-next-line\n async build(appOutDir: string, arch: Arch): Promise<any> {\n // no build\n }\n}\n"]}
|