Skip to content
This repository was archived by the owner on Oct 25, 2023. It is now read-only.

Commit afc25a9

Browse files
committed
refactor: minor cleanup
1 parent e89c16b commit afc25a9

File tree

1 file changed

+21
-16
lines changed

1 file changed

+21
-16
lines changed

Diff for: Lake/Build/Roots.lean

+21-16
Original file line numberDiff line numberDiff line change
@@ -13,39 +13,44 @@ variable [Monad m] [MonadLiftT BuildM m] [MonadBuildStore m]
1313

1414
-- # Build Static Lib
1515

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
1819
have : MonadLift BuildM m := ⟨liftM⟩
19-
let mut targets := #[]
20+
let mut results := #[]
2021
let mut modSet := ModuleSet.empty
2122
let mods ← self.getModuleArray
2223
for mod in mods do
2324
let (_, mods) ← mod.imports.recBuild
2425
let mods := mods.push mod
2526
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
3132

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
3435
have : MonadLift BuildM m := ⟨liftM⟩
35-
let oTargets := (← self.recBuildOFiles).map Target.active
36+
let oTargets := (← self.recBuildLocalModules Module.oFacet).map Target.active
3637
staticLibTarget self.staticLibFile oTargets |>.activate
3738

3839
-- # Build Shared Lib
3940

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+
-/
4145
@[specialize] def LeanLib.recBuildLinks
42-
(self : LeanLib) (mods : Array Module) : IndexT m (Array ActiveFileTarget) := do
46+
(self : LeanLib) : IndexT m (Array ActiveFileTarget) := do
4347
have : MonadLift BuildM m := ⟨liftM⟩
4448
-- Build and collect modules
4549
let mut pkgs := #[]
4650
let mut pkgSet := PackageSet.empty
4751
let mut modSet := ModuleSet.empty
4852
let mut targets := #[]
53+
let mods ← self.getModuleArray
4954
for mod in mods do
5055
let (_, mods) ← mod.imports.recBuild
5156
let mods := mods.push mod
@@ -64,10 +69,10 @@ protected def LeanLib.recBuildStatic (self : LeanLib) : IndexT m ActiveFileTarge
6469
targets := targets.push target
6570
return targets
6671

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
6974
have : MonadLift BuildM m := ⟨liftM⟩
70-
let linkTargets := (← self.recBuildLinks (← self.getModuleArray)).map Target.active
75+
let linkTargets := (← self.recBuildLinks).map Target.active
7176
leanSharedLibTarget self.sharedLibFile linkTargets self.linkArgs |>.activate
7277

7378
-- # Build Executable

0 commit comments

Comments
 (0)