@@ -54,6 +54,44 @@ def get_chpl_third_party():
5454 os .path .sep ,
5555 os .path .sep ))
5656
57+ @memoize
58+ def get_chpl_configured_install_lib_prefix ():
59+ # gets the path to the lib directory for a prefix install, or None if not
60+ # a prefix install
61+ chpl_home = str (os .getenv ("CHPL_HOME" ))
62+ if os .path .exists (os .path .join (chpl_home , "configured-prefix" )):
63+ with open (os .path .join (chpl_home , "CMakeLists.txt" ), "r" ) as f :
64+ # read CMakeLists.txt to get the CHPL_MAJOR_VERSION and
65+ # CHPL_MINOR_VERSION and then construct the path from that
66+ chpl_major_version = None
67+ chpl_minor_version = None
68+ for line in f :
69+ if "set(CHPL_MAJOR_VERSION" in line :
70+ chpl_major_version = line .split ()[1 ].strip (")" )
71+ if "set(CHPL_MINOR_VERSION" in line :
72+ chpl_minor_version = line .split ()[1 ].strip (")" )
73+ if (
74+ chpl_major_version is not None
75+ and chpl_minor_version is not None
76+ ):
77+ break
78+ assert chpl_major_version is not None and chpl_minor_version is not None
79+ chpl_version_string = "{}.{}" .format (
80+ chpl_major_version ,
81+ chpl_minor_version ,
82+ )
83+ chpl_prefix = None
84+ with open (os .path .join (chpl_home , "configured-prefix" ), "r" ) as f :
85+ chpl_prefix = f .read ().strip ()
86+ assert chpl_prefix is not None
87+ return os .path .join (
88+ chpl_prefix ,
89+ "lib" ,
90+ "chapel" ,
91+ chpl_version_string ,
92+ "compiler" ,
93+ )
94+
5795@memoize
5896def get_chpl_version_from_install ():
5997 if get_prefix_install_prefix ():
@@ -189,6 +227,8 @@ def _main():
189227 )
190228 parser .add_option ('--using-module' , action = 'store_const' ,
191229 dest = 'func' , const = using_chapel_module )
230+ parser .add_option ('--configured-install-lib-prefix' , action = 'store_const' ,
231+ dest = 'func' , const = get_chpl_configured_install_lib_prefix )
192232 (options , args ) = parser .parse_args ()
193233
194234 if options .func :
0 commit comments