aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/library/lux/meta/compiler/meta/cache/artifact.lux
blob: 55dd3345ca2d2f0a8bfec0bc8424b22c34538f55 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
... This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
... If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.

(.require
 [library
  [lux (.except)
   [control
    [try (.only Try)]
    [concurrency
     ["[0]" async (.only Async)]]]
   [data
    [binary (.only Binary)]
    [text
     ["%" \\format (.only format)]]]
   [meta
    [compiler
     [target (.only Target)]]]
   [world
    ["[0]" file]]]]
 ["[0]" //
  ["[1][0]" module]
  [//
   ["[0]" context (.only Context)]
   [archive
    ["[0]" module]
    ["[0]" artifact]]]])

(def .public (path fs context @module @artifact)
  (All (_ !)
    (-> (file.System !) Context module.ID artifact.ID file.Path))
  (format (//module.path fs context @module)
          (of fs separator)
          (%.nat @artifact)
          (the context.#artifact_extension context)))

(def .public (cache fs context @module @artifact)
  (All (_ !)
    (-> (file.System !) Context module.ID artifact.ID (! (Try Binary))))
  (of fs read (..path fs context @module @artifact)))

(def .public (cache! fs context @module @artifact content)
  (All (_ !)
    (-> (file.System !) Context module.ID artifact.ID Binary (! (Try Any))))
  (of fs write (..path fs context @module @artifact) content))