sun::support::SunPath

sun::support::SunPath

class · Source (opens in a new tab)

class sun::support::SunPath

Centralized SUN_PATH environment variable handling.

SUN_PATH is a colon-separated list of directories used to resolve imports.

Public Functions

addSearchPath

public · function · static · Source (opens in a new tab)

static void sun::support::SunPath::addSearchPath(const std::filesystem::path &dir)

Add a directory to search for .moon bundles.

ensureSet

public · function · static · Source (opens in a new tab)

static void sun::support::SunPath::ensureSet()

Ensure SUN_PATH is set (to cwd if not already).

Used by tests.

extraPaths

public · function · static · Source (opens in a new tab)

static std::vector< std::filesystem::path > & sun::support::SunPath::extraPaths()

Directories added with lib-path (or by an embedding tool).

Searched ahead of SUN_PATH, so an explicit flag wins over the environment.

getLibrarySearchPaths

public · function · static · Source (opens in a new tab)

static std::vector< std::filesystem::path > sun::support::SunPath::getLibrarySearchPaths()

Get library search paths derived from SUN_PATH (lib/ and build/ subdirs).

getPaths

public · function · static · Source (opens in a new tab)

static std::vector< std::filesystem::path > sun::support::SunPath::getPaths()

Get the directories imports resolve against: lib-path first, then the SUN_PATH environment variable.

resolve

public · function · static · Source (opens in a new tab)

static std::filesystem::path sun::support::SunPath::resolve(const std::string &relativePath)

Resolve a relative path against SUN_PATH directories.

Returns the first existing match, or empty path if not found.

resolveInstalledBundle

public · function · static · Source (opens in a new tab)

static std::filesystem::path sun::support::SunPath::resolveInstalledBundle(const std::string &name, const std::string &targetTriple)

Find an installed bundle, preferring directories for its target.

systemInstallDirs

public · function · static · Source (opens in a new tab)

static std::vector< std::filesystem::path > sun::support::SunPath::systemInstallDirs()

The system-wide directories installed bundles live in, existing ones only.

Two directories relative to the compiler binary come first, so a relocated or Homebrew-prefixed install finds its own bundles; then the fixed prefixes the Debian package (/usr) and Homebrew (/opt/homebrew, /usr/local — macOS keeps /usr/lib read-only) install to.