Skip to content

Commit 9874820

Browse files
committed
chore: partially reverrt "feat: lake: use lean --setup "
1 parent 0a9c246 commit 9874820

File tree

8 files changed

+189
-411
lines changed

8 files changed

+189
-411
lines changed

src/lake/Lake/Build/Actions.lean

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ Released under Apache 2.0 license as described in the file LICENSE.
44
Authors: Gabriel Ebner, Sebastian Ullrich, Mac Malone, Siddharth Bhat
55
-/
66
prelude
7-
import Lean.Setup
8-
import Lean.Data.Json
97
import Lake.Config.Dynlib
108
import Lake.Util.Proc
119
import Lake.Util.NativeLib
@@ -23,30 +21,29 @@ namespace Lake
2321

2422
def compileLeanModule
2523
(leanFile relLeanFile : FilePath)
26-
(setup : ModuleSetup) (setupFile : FilePath)
27-
(arts : ModuleArtifacts)
28-
(leanArgs : Array String := #[])
29-
(leanPath : SearchPath := [])
30-
(rootDir : FilePath := ".")
31-
(lean : FilePath := "lean")
24+
(oleanFile? ileanFile? cFile? bcFile?: Option FilePath)
25+
(leanPath : SearchPath := []) (rootDir : FilePath := ".")
26+
(dynlibs plugins : Array Dynlib := #[])
27+
(leanArgs : Array String := #[]) (lean : FilePath := "lean")
3228
: LogIO Unit := do
33-
let mut args :=
34-
leanArgs.push leanFile.toString ++ #["-R", rootDir.toString]
35-
if let some oleanFile := arts.olean? then
29+
let mut args := leanArgs ++
30+
#[leanFile.toString, "-R", rootDir.toString]
31+
if let some oleanFile := oleanFile? then
3632
createParentDirs oleanFile
3733
args := args ++ #["-o", oleanFile.toString]
38-
if let some ileanFile := arts.ilean? then
34+
if let some ileanFile := ileanFile? then
3935
createParentDirs ileanFile
4036
args := args ++ #["-i", ileanFile.toString]
41-
if let some cFile := arts.c? then
37+
if let some cFile := cFile? then
4238
createParentDirs cFile
4339
args := args ++ #["-c", cFile.toString]
44-
if let some bcFile := arts.bc? then
40+
if let some bcFile := bcFile? then
4541
createParentDirs bcFile
4642
args := args ++ #["-b", bcFile.toString]
47-
createParentDirs setupFile
48-
IO.FS.writeFile setupFile (toJson setup).pretty
49-
args := args ++ #["--setup", setupFile.toString]
43+
for dynlib in dynlibs do
44+
args := args ++ #["--load-dynlib", dynlib.path.toString]
45+
for plugin in plugins do
46+
args := args ++ #["--plugin", plugin.path.toString]
5047
args := args.push "--json"
5148
withLogErrorPos do
5249
let out ← rawProc {

src/lake/Lake/Build/Facets.lean

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -43,43 +43,24 @@ instance (facet : ModuleFacet α) : FamilyDef FacetOut facet.name α :=
4343
instance [FamilyOut FacetOut facet α] : CoeDep Name facet (ModuleFacet α) :=
4444
⟨facet, FamilyOut.fam_eq⟩
4545

46-
/-- The module's (Lean) source file. -/
47-
builtin_facet src : Module => FilePath
48-
49-
/-- The parsed module header of the module's source file. -/
50-
builtin_facet header : Module => ModuleHeader
51-
52-
/--
53-
The facet which builds all of a module's dependencies
54-
(i.e., transitive local imports and `--load-dynlib` shared libraries).
55-
Returns the list of shared libraries to load along with their search path.
56-
-/
57-
builtin_facet setup : Module => ModuleSetup
58-
5946
/--
6047
The facet which builds all of a module's dependencies
6148
(i.e., transitive local imports and `--load-dynlib` shared libraries).
6249
Returns the list of shared libraries to load along with their search path.
6350
-/
64-
builtin_facet deps : Module => Opaque
51+
builtin_facet deps : Module => ModuleDeps
6552

6653
/--
6754
The core build facet of a Lean file.
6855
Elaborates the Lean file via `lean` and produces all the Lean artifacts
6956
of the module (i.e., `olean`, `ilean`, `c`).
7057
Its trace just includes its dependencies.
7158
-/
72-
builtin_facet leanArts : Module => ModuleArtifacts
59+
builtin_facet leanArts : Module => Unit
7360

7461
/-- The `olean` file produced by `lean`. -/
7562
builtin_facet olean : Module => FilePath
7663

77-
/-- The `olean.server` file produced by `lean` (with the module system enabled). -/
78-
builtin_facet oleanServerFacet @ olean.server : Module => FilePath
79-
80-
/-- The `olean.private` file produced by `lean` (with the module system enabled). -/
81-
builtin_facet oleanPrivateFacet @ olean.private : Module => FilePath
82-
8364
/-- The `ilean` file produced by `lean`. -/
8465
builtin_facet ilean : Module => FilePath
8566

src/lake/Lake/Build/Info.lean

Lines changed: 1 addition & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -161,64 +161,6 @@ and target facets.
161161

162162
/-! #### Module Infos -/
163163

164-
structure ModuleImports where
165-
transSet : NameSet := {}
166-
localImports : Array Module := #[]
167-
transImports : Array Module := #[]
168-
publicSet : NameSet := {}
169-
publicImports : Array Module := #[]
170-
libName? : Option Name := none
171-
libSet : NameSet :=
172-
match libName? with
173-
| some libName => .insert {} libName
174-
| none => {}
175-
libs : Array LeanLib := #[]
176-
177-
private def ModuleImports.addLibCore (self : ModuleImports) (lib : LeanLib) : ModuleImports :=
178-
if self.libSet.contains lib.name then
179-
self
180-
else
181-
{self with
182-
libSet := self.libSet.insert lib.name
183-
libs := self.libs.push lib
184-
}
185-
186-
private def ModuleImports.addPublicImportCore (self : ModuleImports) (mod : Module) : ModuleImports :=
187-
if self.publicSet.contains mod.name then
188-
self
189-
else
190-
{self with
191-
publicSet := self.publicSet.insert mod.name
192-
publicImports := self.publicImports.push mod
193-
}
194-
195-
private def ModuleImports.addImportCore
196-
(self : ModuleImports) (mod : Module)
197-
: ModuleImports := Id.run do
198-
let mut self := self
199-
if self.transSet.contains mod.name then
200-
return self
201-
self := {self with
202-
transSet := self.transSet.insert mod.name
203-
transImports := self.transImports.push mod
204-
}
205-
if self.libName? = mod.lib.name then
206-
self := {self with localImports := self.localImports.push mod}
207-
else
208-
self := self.addLibCore mod.lib
209-
return self
210-
211-
def ModuleImports.insert
212-
(self : ModuleImports) (mod : Module) (isPublic : Bool)
213-
: ModuleImports :=
214-
let self := inline <| self.addImportCore mod
215-
if isPublic then inline <| self.addPublicImportCore mod else self
216-
217-
def ModuleImports.append (self other : ModuleImports) : ModuleImports :=
218-
let self := other.publicImports.foldl addPublicImportCore self
219-
let self := other.transImports.foldl addImportCore self
220-
self
221-
222164
/--
223165
Build info for applying the specified facet to the module.
224166
It is the user's obiligation to ensure the facet in question is a module facet.
@@ -234,17 +176,8 @@ abbrev Module.facet (facet : Name) (self : Module) : BuildInfo :=
234176
abbrev BuildInfo.moduleFacet (module : Module) (facet : Name) : BuildInfo :=
235177
module.facetCore facet
236178

237-
/-- The computed imports of a Lean module. -/
238-
builtin_facet allImports : Module => ModuleImports
239-
240179
namespace Module
241180

242-
@[inherit_doc srcFacet] abbrev src (self : Module) :=
243-
self.facetCore srcFacet
244-
245-
@[inherit_doc headerFacet] abbrev header (self : Module) :=
246-
self.facetCore headerFacet
247-
248181
@[inherit_doc importsFacet] abbrev imports (self : Module) :=
249182
self.facetCore importsFacet
250183

@@ -254,27 +187,15 @@ namespace Module
254187
@[inherit_doc precompileImportsFacet] abbrev precompileImports (self : Module) :=
255188
self.facetCore precompileImportsFacet
256189

257-
@[inherit_doc allImportsFacet] abbrev allImports (self : Module) :=
258-
self.facetCore allImportsFacet
259-
260-
@[inherit_doc setupFacet] abbrev setup (self : Module) :=
261-
self.facetCore setupFacet
262-
263190
@[inherit_doc depsFacet] abbrev deps (self : Module) :=
264191
self.facetCore depsFacet
265192

266-
@[inherit_doc leanArtsFacet] abbrev leanArts (self : Module) :=
193+
@[inherit_doc leanArtsFacet] abbrev leanArts (self : Module) :=
267194
self.facetCore leanArtsFacet
268195

269196
@[inherit_doc oleanFacet] abbrev olean (self : Module) :=
270197
self.facetCore oleanFacet
271198

272-
@[inherit_doc oleanServerFacet] abbrev oleanServer (self : Module) :=
273-
self.facetCore oleanServerFacet
274-
275-
@[inherit_doc oleanPrivateFacet] abbrev oleanPrivate (self : Module) :=
276-
self.facetCore oleanPrivateFacet
277-
278199
@[inherit_doc ileanFacet] abbrev ilean (self : Module) :=
279200
self.facetCore ileanFacet
280201

0 commit comments

Comments
 (0)