@@ -169,17 +169,16 @@ def validate_stanc_opts(self) -> None:
169169 for opt in ignore :
170170 del self ._stanc_options [opt ]
171171 if paths is not None :
172- self ._stanc_options ['include-paths' ] = paths
173- bad_paths = [
174- dir
175- for dir in self ._stanc_options ['include-paths' ]
176- if not os .path .exists (dir )
177- ]
172+ bad_paths = [dir for dir in paths if not os .path .exists (dir )]
178173 if any (bad_paths ):
179174 raise ValueError (
180175 'invalid include paths: {}' .format (', ' .join (bad_paths ))
181176 )
182177
178+ self ._stanc_options ['include-paths' ] = [
179+ os .path .abspath (os .path .expanduser (path )) for path in paths
180+ ]
181+
183182 def validate_cpp_opts (self ) -> None :
184183 """
185184 Check cpp compiler args.
@@ -254,19 +253,19 @@ def add(self, new_opts: "CompilerOptions") -> None: # noqa: disable=Q000
254253
255254 def add_include_path (self , path : str ) -> None :
256255 """Adds include path to existing set of compiler options."""
256+ path = os .path .abspath (os .path .expanduser (path ))
257257 if 'include-paths' not in self ._stanc_options :
258258 self ._stanc_options ['include-paths' ] = [path ]
259259 elif path not in self ._stanc_options ['include-paths' ]:
260260 self ._stanc_options ['include-paths' ].append (path )
261261
262- def compose (self ) -> List [str ]:
263- """Format makefile options as list of strings."""
262+ def compose_stanc (self ) -> List [str ]:
264263 opts = []
265264 if self ._stanc_options is not None and len (self ._stanc_options ) > 0 :
266265 for key , val in self ._stanc_options .items ():
267266 if key == 'include-paths' :
268267 opts .append (
269- 'STANCFLAGS+= --include-paths='
268+ '--include-paths='
270269 + ',' .join (
271270 (
272271 Path (p ).as_posix ()
@@ -275,9 +274,14 @@ def compose(self) -> List[str]:
275274 )
276275 )
277276 elif key == 'name' :
278- opts .append (f'STANCFLAGS+= --name={ val } ' )
277+ opts .append (f'--name={ val } ' )
279278 else :
280- opts .append (f'STANCFLAGS+=--{ key } ' )
279+ opts .append (f'--{ key } ' )
280+ return opts
281+
282+ def compose (self ) -> List [str ]:
283+ """Format makefile options as list of strings."""
284+ opts = ['STANCFLAGS+=' + flag for flag in self .compose_stanc ()]
281285 if self ._cpp_options is not None and len (self ._cpp_options ) > 0 :
282286 for key , val in self ._cpp_options .items ():
283287 opts .append (f'{ key } ={ val } ' )
0 commit comments