|
1 | 1 | -- |
2 | | --- Copyright (C) 2023-2024 Tobias Brunner <tobias@codelabs.ch> |
| 2 | +-- Copyright (C) 2023-2025 Tobias Brunner <tobias@codelabs.ch> |
3 | 3 | -- |
4 | 4 | -- This program is free software: you can redistribute it and/or modify |
5 | 5 | -- it under the terms of the GNU General Public License as published by |
@@ -29,6 +29,7 @@ with DOM.Core.Elements; |
29 | 29 | with McKae.XML.XPath.XIA; |
30 | 30 |
|
31 | 31 | with Interfaces; |
| 32 | +with Interfaces.C; |
32 | 33 |
|
33 | 34 | with Mulog; |
34 | 35 | with Muxml.Utils; |
|
81 | 82 | Used_Memory : in out String_Sets_Package.Set; |
82 | 83 | Kernels : in out CPU_Kernel_Map_Package.Map); |
83 | 84 |
|
| 85 | + -- Create a symlink. |
| 86 | + function Create_Symlink |
| 87 | + (Target_Path : Interfaces.C.char_array; |
| 88 | + Link_Path : Interfaces.C.char_array) return Interfaces.C.int; |
| 89 | + pragma Import (C, Create_Symlink, "symlink"); |
| 90 | + |
84 | 91 | ------------------------------------------------------------------------- |
85 | 92 |
|
86 | 93 | procedure Extract_File |
|
403 | 410 | end; |
404 | 411 | end if; |
405 | 412 |
|
| 413 | + -- Make sure the name contains a file extension so bootgen can |
| 414 | + -- handle it. |
| 415 | + if Index (File.Filename, ".") = 0 then |
| 416 | + declare |
| 417 | + use Interfaces.C; |
| 418 | + |
| 419 | + Ext_Name : constant Unbounded_String |
| 420 | + := Filename & ".bin"; |
| 421 | + Ext_Path : constant Unbounded_String |
| 422 | + := Output_Dir & "/" & Ext_Name; |
| 423 | + begin |
| 424 | + File.Filename := Ext_Name; |
| 425 | + Mulog.Log (Msg => " symlink '" |
| 426 | + & To_String (Path) |
| 427 | + & "' to '" |
| 428 | + & To_String (Ext_Path) & "' for bootgen"); |
| 429 | + if not Ada.Directories.Exists (To_String (Ext_Path)) and then |
| 430 | + Create_Symlink |
| 431 | + (Target_Path => To_C (To_String (Filename)), |
| 432 | + Link_Path => To_C (To_String (Ext_Path))) < 0 |
| 433 | + then |
| 434 | + raise Generator_Error with "Unable to create symlink '" |
| 435 | + & To_String (Ext_Path) & "' to '" |
| 436 | + & To_String (Filename); |
| 437 | + end if; |
| 438 | + end; |
| 439 | + end if; |
| 440 | + |
406 | 441 | File_Backed_Memory.Include (Name, File); |
407 | 442 | Files.Append (File); |
408 | 443 | end; |
|
0 commit comments