@@ -211,55 +211,61 @@ actor Ponyup
211211 end
212212
213213 ifdef windows then
214- let link_rel: String = Path .sep ().join ([" bin" ; pkg'.name ()].values ())
215- + " .exe"
216- let bin_rel: String = Path .sep ().join ([pkg'.string (); link_rel].values ())
214+ for binary in pkg'.package .binaries ().values () do
215+ let link_rel: String = Path .sep ().join ([" bin" ; binary.name ].values ())
216+ + " .exe"
217+ let bin_rel: String = Path .sep ().join ([pkg'.string (); link_rel].values ())
217218
218- try
219- let bin_path = _root.join (bin_rel)?
220- _notify.log (Info , " bin: " + bin_path.path )
219+ try
220+ let bin_path = _root.join (bin_rel)?
221+ // It is ok for optional binaries to not exist. If they don't then
222+ // we just skip them.
223+ if (not binary.required ) and (not bin_path.exists ()) then
224+ continue
225+ end
226+ _notify.log (Info , " bin: " + bin_path.path )
221227
222- let link_dir = _root.join (" bin" )?
223- if not link_dir.exists () then link_dir.mkdir () end
228+ let link_dir = _root.join (" bin" )?
229+ if not link_dir.exists () then link_dir.mkdir () end
224230
225- let link_path = link_dir.join (pkg'.name () + " .bat" )?
226- _notify.log (Info , " link: " + link_path.path )
231+ let link_path = link_dir.join (pkg'.name () + " .bat" )?
232+ _notify.log (Info , " link: " + link_path.path )
227233
228- if link_path.exists () then link_path.remove () end
229- with file = File .create (link_path) do
230- file.print (" @echo off" )
231- file.print (" \" " + bin_path.path + " \" %*" )
234+ if link_path.exists () then link_path.remove () end
235+ with file = File .create (link_path) do
236+ file.print (" @echo off" )
237+ file.print (" \" " + bin_path.path + " \" %*" )
238+ end
239+ else
240+ _notify.log (Err , " failed to create link batch file(s)" )
232241 end
233- else
234- _notify.log (Err , " failed to create link batch file" )
235242 end
236243 else
237- // TODO STA:
238- // bin_path is our primary required binaries
239- // we need to loop over this for required to get link_rel for
240- // all required. and do the existing logic.
241- // for optional we need to loop over and if the bin_path exists,
242- // do the link
243- // instead of pkg'.name() we use the required or optional values
244- //
245- let link_rel: String = " /" .join ([" bin" ; pkg'.name ()].values ())
246- let bin_rel: String = " /" .join ([pkg'.string (); link_rel].values ())
244+ for binary in pkg'.package .binaries ().values () do
245+ let link_rel: String = " /" .join ([" bin" ; binary.name ].values ())
246+ let bin_rel: String = " /" .join ([pkg'.string (); link_rel].values ())
247247
248- try
249- let bin_path = _root.join (bin_rel)?
250- _notify.log (Info , " bin: " + bin_path.path )
248+ try
249+ let bin_path = _root.join (bin_rel)?
250+ // It is ok for optional binaries to not exist. If they don't then
251+ // we just skip them.
252+ if (not binary.required ) and (not bin_path.exists ()) then
253+ continue
254+ end
255+ _notify.log (Info , " bin: " + bin_path.path )
251256
252- let link_dir = _root.join (" bin" )?
253- if not link_dir.exists () then link_dir.mkdir () end
257+ let link_dir = _root.join (" bin" )?
258+ if not link_dir.exists () then link_dir.mkdir () end
254259
255- let link_path = link_dir.join (pkg'.name ())?
256- _notify.log (Info , " link: " + link_path.path )
260+ let link_path = link_dir.join (pkg'.name ())?
261+ _notify.log (Info , " link: " + link_path.path )
257262
258- if link_path.exists () then link_path.remove () end
259- if not bin_path.symlink (link_path) then error end
260- else
261- _notify.log (Err , " failed to create symbolic link" )
262- return
263+ if link_path.exists () then link_path.remove () end
264+ if not bin_path.symlink (link_path) then error end
265+ else
266+ _notify.log (Err , " failed to create symbolic link(s)" )
267+ return
268+ end
263269 end
264270 end
265271
0 commit comments