Skip to content

Commit c5b6968

Browse files
committed
chore: symlink to source from build dir
1 parent 6475e3d commit c5b6968

File tree

4 files changed

+18
-8
lines changed

4 files changed

+18
-8
lines changed

doc/dev/index.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,7 @@ install`. You use `elan` instead.
2727
You can use any of the [supported editors](../setup.md) for editing
2828
the Lean source code. If you set up `elan` as below, opening `src/` as
2929
a *workspace folder* should ensure that stage 0 will be used for file
30-
in that directory. You should also set the `LEAN_SRC_PATH` environment
31-
variable to the path of the `src/` directory to enable
32-
go-to-definition in the stdlib (automatically set when using
33-
`nix-shell`).
30+
in that directory.
3431

3532
## Dev setup using elan
3633

shell.nix

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@ in { pkgs ? flakePkgs.nixpkgs, pkgsDist ? pkgs, llvmPackages ? null }:
1616
GMP = pkgsDist.gmp.override { withStatic = true; };
1717
GLIBC = pkgsDist.glibc;
1818
ZLIB = pkgsDist.zlib;
19-
shellHook = ''
20-
export LEAN_SRC_PATH="$PWD/src"
21-
'';
2219
};
2320
with-temci = shell.overrideAttrs (old: {
2421
buildInputs = old.buildInputs ++ [ flakePkgs.temci ];

src/CMakeLists.txt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,16 @@ add_custom_target(clean-stdlib
528528
add_custom_target(clean-olean
529529
DEPENDS clean-stdlib)
530530

531-
install(DIRECTORY "${CMAKE_BINARY_DIR}/lib/" DESTINATION lib PATTERN temp EXCLUDE)
531+
install(DIRECTORY "${CMAKE_BINARY_DIR}/lib/" DESTINATION lib
532+
PATTERN src EXCLUDE # symlink
533+
PATTERN temp EXCLUDE)
534+
535+
# symlink source into expected installation location for go-to-definition, if file system allows it
536+
if(${STAGE} EQUAL 0)
537+
file(CREATE_LINK ${CMAKE_SOURCE_DIR}/../../src ${CMAKE_BINARY_DIR}/lib/lean/src RESULT _IGNORE_RES SYMBOLIC)
538+
else()
539+
file(CREATE_LINK ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}/lib/lean/src RESULT _IGNORE_RES SYMBOLIC)
540+
endif()
532541

533542
install(DIRECTORY "${CMAKE_SOURCE_DIR}" DESTINATION lib/lean
534543
FILES_MATCHING

stage0/src/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)