@@ -13,39 +13,44 @@ variable [Monad m] [MonadLiftT BuildM m] [MonadBuildStore m]
13
13
14
14
-- # Build Static Lib
15
15
16
- /-- Build a library and its imports and collect its local modules' o files. -/
17
- @[specialize] def LeanLib.recBuildOFiles (self : LeanLib) : IndexT m (Array ActiveFileTarget) := do
16
+ /-- Build and collect the specified facet of the library's local modules. -/
17
+ @[specialize] def LeanLib.recBuildLocalModules (facet : WfName) (self : LeanLib)
18
+ [DynamicType ModuleData facet α]: IndexT m (Array α) := do
18
19
have : MonadLift BuildM m := ⟨liftM⟩
19
- let mut targets := #[]
20
+ let mut results := #[]
20
21
let mut modSet := ModuleSet.empty
21
22
let mods ← self.getModuleArray
22
23
for mod in mods do
23
24
let (_, mods) ← mod.imports.recBuild
24
25
let mods := mods.push mod
25
26
for mod in mods do
26
- unless modSet.contains mod do
27
- if self.isLocalModule mod.name then
28
- targets := targets .push <| ← mod.o.recBuild
29
- modSet := modSet.insert mod
30
- return targets
27
+ if self.isLocalModule mod.name then
28
+ unless modSet.contains mod do
29
+ results := results .push <| ← recBuild <| mod.facet facet
30
+ modSet := modSet.insert mod
31
+ return results
31
32
32
- @[specialize]
33
- protected def LeanLib.recBuildStatic (self : LeanLib) : IndexT m ActiveFileTarget := do
33
+ @[specialize] protected
34
+ def LeanLib.recBuildStatic (self : LeanLib) : IndexT m ActiveFileTarget := do
34
35
have : MonadLift BuildM m := ⟨liftM⟩
35
- let oTargets := (← self.recBuildOFiles ).map Target.active
36
+ let oTargets := (← self.recBuildLocalModules Module.oFacet ).map Target.active
36
37
staticLibTarget self.staticLibFile oTargets |>.activate
37
38
38
39
-- # Build Shared Lib
39
40
40
- /-- Build and collect the o files and external libraries of a library and its imports. -/
41
+ /--
42
+ Build and collect the local object files and external libraries
43
+ of a library and its modules' imports.
44
+ -/
41
45
@[specialize] def LeanLib.recBuildLinks
42
- (self : LeanLib) (mods : Array Module) : IndexT m (Array ActiveFileTarget) := do
46
+ (self : LeanLib) : IndexT m (Array ActiveFileTarget) := do
43
47
have : MonadLift BuildM m := ⟨liftM⟩
44
48
-- Build and collect modules
45
49
let mut pkgs := #[]
46
50
let mut pkgSet := PackageSet.empty
47
51
let mut modSet := ModuleSet.empty
48
52
let mut targets := #[]
53
+ let mods ← self.getModuleArray
49
54
for mod in mods do
50
55
let (_, mods) ← mod.imports.recBuild
51
56
let mods := mods.push mod
@@ -64,10 +69,10 @@ protected def LeanLib.recBuildStatic (self : LeanLib) : IndexT m ActiveFileTarge
64
69
targets := targets.push target
65
70
return targets
66
71
67
- @[specialize]
68
- protected def LeanLib.recBuildShared (self : LeanLib) : IndexT m ActiveFileTarget := do
72
+ @[specialize] protected
73
+ def LeanLib.recBuildShared (self : LeanLib) : IndexT m ActiveFileTarget := do
69
74
have : MonadLift BuildM m := ⟨liftM⟩
70
- let linkTargets := (← self.recBuildLinks (← self.getModuleArray) ).map Target.active
75
+ let linkTargets := (← self.recBuildLinks).map Target.active
71
76
leanSharedLibTarget self.sharedLibFile linkTargets self.linkArgs |>.activate
72
77
73
78
-- # Build Executable
0 commit comments