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

Support embedding static resources into source files at compile time #147

Merged
merged 9 commits into from
May 30, 2024

Conversation

vekatze
Copy link
Owner

@vekatze vekatze commented May 30, 2024

Embedding Static Files

This PR adds support for embedding static files into source files at compile time.

The compiler triggers recompilation when necessary by comparing modification times of static files and source files.

3-Step Usage

(1) Create a static file some-file.txt in a module:

Hello!

(2) Choose an alias of the static file and declare it in module.ens:

{
  // ..
  static {
    // (alias) == some-file
    some-file "rel/path/from/module/root/to/some-file.txt"
  }
  // ..
}

(3) Use static files from source files:

import {
  this.foo.bar,
  // ..
  static {some-file}, // syntax: static {ALIAS-1, ..., ALIAS-n}
}

define use-static-file(): unit {
  let t: &text = include-text(some-file) in // syntax: include-text(ALIAS)
  print(t) // => "Hello!"
}

@vekatze vekatze self-assigned this May 30, 2024
@vekatze vekatze changed the title support embedding static resources into source files at compile time Support embedding static resources into source files at compile time May 30, 2024
@vekatze vekatze marked this pull request as ready for review May 30, 2024 04:16
@vekatze vekatze merged commit 4c791ec into main May 30, 2024
1 check passed
@vekatze vekatze deleted the include-static-files branch May 30, 2024 04:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant