From 34ce0cd38b8ae461e039a46d9dc340058309aa07 Mon Sep 17 00:00:00 2001 From: Im-Beast Date: Tue, 10 Dec 2024 23:34:14 +0100 Subject: tests: add file data for more targets --- tests/download_deps.ts | 103 ++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 84 insertions(+), 19 deletions(-) (limited to 'tests/download_deps.ts') diff --git a/tests/download_deps.ts b/tests/download_deps.ts index 81d7f9d..3ed4e25 100644 --- a/tests/download_deps.ts +++ b/tests/download_deps.ts @@ -1,16 +1,10 @@ import { join, resolve } from "jsr:@std/path"; -import { getMoneroCTags } from "./utils.ts"; +import { Coin, getMoneroCTags } from "./utils.ts"; export type Target = `${typeof Deno["build"]["os"]}_${typeof Deno["build"]["arch"]}`; -export const target = (() => { - let target: Target = `${Deno.build.os}_${Deno.build.arch}`; - const FORCED_TARGET = Deno.env.get("FORCED_TARGET"); - if (FORCED_TARGET) target = FORCED_TARGET as Target; - return target; -})(); - interface FileInfo { + overrideMirrors?: string[]; name: string; sha256?: string; } @@ -23,7 +17,10 @@ interface DownloadInfo { outDir?: string; } -export function getFileInfo(downloadInfo: DownloadInfo): FileInfo { +export function getFileInfo( + downloadInfo: DownloadInfo, + target: Target = `${Deno.build.os}_${Deno.build.arch}`, +): FileInfo { const fileInfo = "name" in downloadInfo.file ? downloadInfo.file : downloadInfo.file[target]; if (!fileInfo) { throw new Error(`No fileInfo set for target: ${target}`); @@ -36,8 +33,11 @@ async function sha256(buffer: Uint8Array): Promise { return Array.from(hashed).map((i) => i.toString(16).padStart(2, "0")).join(""); } -let outDir = "./tests/dependencies"; export async function downloadDependencies(...infos: DownloadInfo[]): Promise { + return await downloadFiles("./tests/dependencies", `${Deno.build.os}_${Deno.build.arch}`, ...infos); +} + +export async function downloadFiles(outDir: string, target: Target, ...infos: DownloadInfo[]): Promise { try { await Deno.mkdir(outDir, { recursive: true }); } catch (error) { @@ -47,24 +47,38 @@ export async function downloadDependencies(...infos: DownloadInfo[]): Promise = { + monero: [], + wownero: [], +}; + for (const tag of await getMoneroCTags()) { - for (const coin of ["monero", "wownero"]) { - moneroCInfos.push({ + for (const coin of ["monero", "wownero"] as const) { + dylibInfos[coin].push({ mirrors: [ `https://static.mrcyjanek.net/monero_c/libs/${tag}/`, `https://github.com/MrCyjaneK/monero_c/releases/download/${tag}/`, ], file: { + linux_aarch64: { name: `${coin}_aarch64-linux-gnu_libwallet2_api_c.so.xz` }, linux_x86_64: { name: `${coin}_x86_64-linux-gnu_libwallet2_api_c.so.xz` }, darwin_aarch64: { name: `${coin}_aarch64-apple-darwin11_libwallet2_api_c.dylib.xz` }, + darwin_x86_64: { name: `${coin}_x86_64-apple-darwin11_libwallet2_api_c.dylib.xz` }, windows_x86_64: { name: `${coin}_x86_64-w64-mingw32_libwallet2_api_c.dll.xz` }, + android_aarch64: { name: `${coin}_aarch64-linux-android_libwallet2_api_c.so.xz` }, }, outDir: `libs/${tag}`, }); @@ -159,6 +214,16 @@ for (const tag of await getMoneroCTags()) { // Download files to the monero_c folder // (used on mirror to keep files up to date) if (import.meta.main) { - outDir = "./monero_c"; - downloadDependencies(moneroCliInfo, wowneroCliInfo, ...moneroCInfos); + const supportedTargets: Target[] = [ + "linux_x86_64", + "linux_aarch64", + "darwin_x86_64", + "darwin_aarch64", + "windows_x86_64", + "android_aarch64", + ]; + + for (const target of supportedTargets) { + await downloadFiles("./monero_c", target, moneroCliInfo, wowneroCliInfo, ...Object.values(dylibInfos).flat()); + } } -- cgit v1.2.3