Skip to content

platform arch refactor #240

Open
Open
@dpastoor

Description

@dpastoor

In working on #237 getting arm logic added in will take some interface redesign:

The existing Dependency interface is as such:

dependencies.ts

export interface Dependency {
  name: string;
  version: string;
  "darwin"?: PlatformDependency;
  "linux"?: PlatformDependency;
  "windows": PlatformDependency;
}

which is used by say the esBuild (and dart/pandoc) resolvers:

return {
    name: "esbuild javscript bundler",
    version,
    "windows": esBuildRelease("windows-64"),
    "linux": esBuildRelease("linux-64"),
    "darwin": esBuildRelease("darwin-64"),
  };

these then are used in configure.ts as kDependencies

// Download dependencies
  info("Downloading dependencies");
  for (const dependency of kDependencies) {
    info(`Preparing ${dependency.name}`);
    const platformDep = dependency[Deno.build.os];
    if (platformDep) {
      info(`Downloading ${dependency.name}`);
      const targetFile = await downloadBinaryDependency(platformDep, config);

      info(`Configuring ${dependency.name}`);
      await platformDep.configure(targetFile);

      info(`Cleaning up`);
      Deno.removeSync(targetFile);
    }
    info(`${dependency.name} complete.\n`);
  }

APIs to consider:

nested archs - Deno.build.arch can be "x86_64" | "aarch64" making it easy to use as a key

export interface Dependency {
  name: string;
  version: string;
  "aarch64": {
	  "darwin"?: PlatformDependency;
	  "linux"?: PlatformDependency;
	  "windows"?: PlatformDependency;
  };
  "x86_64": {
	  "darwin"?: PlatformDependency;
	  "linux"?: PlatformDependency;
	  "windows"?: PlatformDependency;
  };
}

which would essentially result in dl resolution code changing to:

-const platformDep = dependency[Deno.build.os];
+const platformDep = dependency[Deno.build.arch][Deno.build.os];

or some flatter designs:

  • x86 default:
    • darwin + darwin-aarch64
  • no default (my preference given a flat structure):
    • darwin-x86_64 + darwin-x86_64

and do something like

-const platformDep = dependency[Deno.build.os];
+const platformDep = dependency[`${Deno.build.os}-${Deno.build.arch}`];

Secondarily, the other implication to consider in the surrounding code is that arm builds are still generally not as first-class. While it seems everything has x86 builds in place, even for misc dev versions, arm versions are more hit or miss. As such, the general codebase could potentially use a little love to make more informative where its hitting problems and potentially more aggressively halt. The existing code just tries to dl if it exists and regardless will print info(${dependency.name} complete.\n);

@dragonstyle any particular preferences or other interface designs come to mind?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions