29 lines
1.1 KiB
Text
29 lines
1.1 KiB
Text
/-
|
|
Copyright (c) 2021 Mac Malone. All rights reserved.
|
|
Released under Apache 2.0 license as described in the file LICENSE.
|
|
Authors: Mac Malone
|
|
-/
|
|
import Lean.Attributes
|
|
|
|
open Lean
|
|
namespace Lake
|
|
|
|
initialize packageAttr : TagAttribute ←
|
|
registerTagAttribute `package "mark a definition as a Lake package declaration"
|
|
|
|
initialize scriptAttr : TagAttribute ←
|
|
registerTagAttribute `script "mark a definition as a Lake script"
|
|
|
|
initialize leanLibAttr : TagAttribute ←
|
|
registerTagAttribute `leanLib "mark a definition as a Lake Lean library target declaration"
|
|
|
|
initialize leanExeAttr : TagAttribute ←
|
|
registerTagAttribute `leanExe "mark a definition as a Lake Lean executable target declaration"
|
|
|
|
initialize defaultTargetAttr : TagAttribute ←
|
|
registerTagAttribute `defaultTarget "mark a Lake target as the package's default"
|
|
fun name => do
|
|
let valid ← getEnv <&> fun env =>
|
|
leanLibAttr.hasTag env name || leanExeAttr.hasTag env name
|
|
unless valid do
|
|
throwError "attribute `defaultTarget` can only be used on a target (e.g., `lean_lib`, `lean_exe`)"
|