Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to mapped directories instead of a search path #156

Merged
merged 2 commits into from
Nov 9, 2024

Conversation

brendanfh
Copy link
Collaborator

This pull request changes how files are searched for in a #load directive.

Previously, there was a "search path" that the compiler would append the file's name onto the end of each entry in the search path, and see if that file exists. If so, that file would be used. This was repeated for every entry in the list. By default the only two folders in the search path were the current directory and the ONYX_PATH.

Now, #load directives must either be relative to the current file (start with ./), or specify a mapped folder name to search from. This way, the programmer is aware of exactly where the file comes from.

In the code, it looks like this:

// Load the `onyx/compiler_extension.onyx` file from the `core` mapped directory.
#load "core:onyx/compiler_extension"

// ...

By default, there is now only one mapped directory called core, which points to ONYX_PATH/core. You can add mapped directories using the --map-dir CLI argument:

onyx run --map-dir libs:/path/to/libraries main.onyx

@brendanfh brendanfh added the enhancement New feature or request label Sep 13, 2024
@brendanfh brendanfh merged commit f15c8cc into master Nov 9, 2024
15 checks passed
@brendanfh brendanfh deleted the feature/mapped-folders branch November 9, 2024 05:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant