aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/library/lux/tool/compiler/meta/cache/artifact.lux
blob: 66e34739890d68287cc283c0d3a31123aeb8b833 (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
(.using
 [library
  [lux (.except)
   [target (.only Target)]
   [control
    [try (.only Try)]
    [concurrency
     ["[0]" async (.only Async)]]]
   [data
    [binary (.only Binary)]
    [text
     ["%" format (.only format)]]]
   [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)
          (at 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))))
  (at 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))))
  (at fs write (..path fs context @module @artifact) content))