@@ -9,115 +9,38 @@ const DIAGHAM_SOURCE_DIR = joinpath(dirname(@__DIR__), "diagham_source")
99const DIAGHAM_BUILD_DIR = joinpath (DIAGHAM_SOURCE_DIR, " build" )
1010const DIAGHAM_RUN_DIR = joinpath (DIAGHAM_BUILD_DIR, " run" )
1111
12- """
13- install_diagham()
14-
15- Checkout and build DiagHam from source. Returns the path to the build directory.
16- """
17- function install_diagham ()
18- # Check if already built
19- if isdir (DIAGHAM_BUILD_DIR) && isfile (joinpath (DIAGHAM_BUILD_DIR, " FQHE" , " src" , " Programs" , " FQHEOnTorus" , " FQHETorusFermionsTwoBodyGeneric" ))
20- @info " DiagHam already installed at $DIAGHAM_BUILD_DIR "
21- return DIAGHAM_BUILD_DIR
22- end
23-
24- # Checkout DiagHam if not exists
25- if ! isdir (DIAGHAM_SOURCE_DIR)
26- @info " Checking out DiagHam from SVN repository..."
27- mkdir (dirname (DIAGHAM_SOURCE_DIR))
28- run (` svn checkout https://www.nick-ux.org/diagham/svn/DiagHam/trunk $DIAGHAM_SOURCE_DIR ` )
29- else
30- @info " DiagHam source already exists at $DIAGHAM_SOURCE_DIR "
31- end
32-
33- # Check if it uses autotools or cmake
34- if isfile (joinpath (DIAGHAM_SOURCE_DIR, " CMakeLists.txt" ))
35- # CMake-based build
36- if ! isdir (DIAGHAM_BUILD_DIR)
37- mkdir (DIAGHAM_BUILD_DIR)
38- end
12+ using DiagHamInterface: install_diagham
3913
40- @info " Configuring DiagHam with CMake..."
41- cd (DIAGHAM_BUILD_DIR) do
42- run (` cmake $DIAGHAM_SOURCE_DIR -DBUILD_FQHE=ON` )
43- end
44-
45- @info " Building DiagHam..."
46- cd (DIAGHAM_BUILD_DIR) do
47- nprocs = Sys. CPU_THREADS
48- run (` make -j$nprocs ` )
49- end
50- elseif isfile (joinpath (DIAGHAM_SOURCE_DIR, " configure" ))
51- # Autotools-based build (older DiagHam versions)
52- @info " Configuring DiagHam with autotools..."
53-
54- if ! isdir (DIAGHAM_BUILD_DIR)
55- mkdir (DIAGHAM_BUILD_DIR)
56- end
57-
58- cd (DIAGHAM_BUILD_DIR) do
59- # Run configure from build dir pointing to source dir with FQHE and LAPACK enabled
60- configure_script = joinpath (DIAGHAM_SOURCE_DIR, " configure" )
61- run (` $configure_script --enable-fqhe --enable-fti --with-blas-libs=-lopenblas --with-lapack-libs= --enable-lapack` )
62-
63- @info " Building DiagHam..."
64- nprocs = Sys. CPU_THREADS
65- run (` make -j$nprocs ` )
66- end
67- elseif isfile (joinpath (DIAGHAM_SOURCE_DIR, " configure.in" )) || isfile (joinpath (DIAGHAM_SOURCE_DIR, " Makefile.am" ))
68- # Need to run autoreconf first
69- @info " Running autoreconf to generate configure script..."
70- cd (DIAGHAM_SOURCE_DIR) do
71- run (` autoreconf -i` )
72- end
73-
74- if ! isdir (DIAGHAM_BUILD_DIR)
75- mkdir (DIAGHAM_BUILD_DIR)
76- end
77-
78- cd (DIAGHAM_BUILD_DIR) do
79- # Run configure from build dir pointing to source dir with FQHE and LAPACK enabled
80- configure_script = joinpath (DIAGHAM_SOURCE_DIR, " configure" )
81- run (` $configure_script --enable-fqhe --enable-fti --with-blas-libs=-lopenblas --with-lapack-libs= --enable-lapack` )
82-
83- @info " Building DiagHam..."
84- nprocs = Sys. CPU_THREADS
85- run (` make -j$nprocs ` )
86- end
87- else
88- error (" Could not determine build system for DiagHam" )
89- end
14+ # Delegate installation to the exported package function so tests and users
15+ # use the shared implementation. The test constants are still defined here
16+ # for convenience and passed to the package function below.
9017
91- if ! isdir (DIAGHAM_RUN_DIR)
92- mkdir (DIAGHAM_RUN_DIR)
93- end
94-
95- @info " DiagHam installed successfully at $DIAGHAM_BUILD_DIR "
96- return DIAGHAM_BUILD_DIR
97- end
98-
99- """
100- diagham_available()
101-
102- Check if DiagHam is available (built and ready to use).
103- """
104- function diagham_available ()
105- # Check for common FQHE executables
18+ function diagham_available (build_dir:: AbstractString = DIAGHAM_BUILD_DIR)
10619 possible_paths = [
107- joinpath (DIAGHAM_BUILD_DIR , " FQHE" , " src" , " Programs" , " FQHEOnDisk" , " FQHEDiskFermionsTwoBodyGeneric" ),
108- joinpath (DIAGHAM_BUILD_DIR , " FQHE" , " src" , " Programs" , " FQHEOnTorus" , " FQHETorusFermionsTwoBodyGeneric" ),
109- joinpath (DIAGHAM_BUILD_DIR , " FTI" , " src" , " Programs" , " FTI" , " FTIGenericInteractionFromFileTwoBands" ),
110- joinpath (DIAGHAM_BUILD_DIR , " src" , " Programs" , " GenericHamiltonianDiagonalization" ),
111- joinpath (DIAGHAM_BUILD_DIR , " src" , " Programs" , " GenericOverlap" ),
20+ joinpath (build_dir , " FQHE" , " src" , " Programs" , " FQHEOnDisk" , " FQHEDiskFermionsTwoBodyGeneric" ),
21+ joinpath (build_dir , " FQHE" , " src" , " Programs" , " FQHEOnTorus" , " FQHETorusFermionsTwoBodyGeneric" ),
22+ joinpath (build_dir , " FTI" , " src" , " Programs" , " FTI" , " FTIGenericInteractionFromFileTwoBands" ),
23+ joinpath (build_dir , " src" , " Programs" , " GenericHamiltonianDiagonalization" ),
24+ joinpath (build_dir , " src" , " Programs" , " GenericOverlap" ),
11225 ]
11326 return any (isfile, possible_paths)
11427end
11528
116- if ! diagham_available ()
29+
30+ """
31+ Call the package `install_diagham` with the test-local defaults.
32+ """
33+ function ensure_diagham_installed ()
34+ if diagham_available (DIAGHAM_BUILD_DIR)
35+ @info " DiagHam already installed at $DIAGHAM_BUILD_DIR "
36+ return DIAGHAM_BUILD_DIR
37+ end
38+
11739 @info " DiagHam not installed, attempting installation..."
11840 try
119- install_diagham ()
41+ install_diagham (; source_dir = DIAGHAM_SOURCE_DIR )
12042 catch e
12143 @warn " Failed to install DiagHam: $e "
12244 end
45+ return DIAGHAM_BUILD_DIR
12346end
0 commit comments