/ src / build / cerro_builder.ads
cerro_builder.ads
  1  -------------------------------------------------------------------------------
  2  --  Cerro_Builder - Package Build Orchestration
  3  --
  4  --  This package handles the build process for Cerro Torre packages,
  5  --  coordinating source retrieval, patch application, compilation,
  6  --  and artifact generation.
  7  -------------------------------------------------------------------------------
  8  
  9  with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
 10  with Cerro_Manifest;        use Cerro_Manifest;
 11  
 12  package Cerro_Builder is
 13  
 14     ---------------------------------------------------------------------------
 15     --  Build Status
 16     ---------------------------------------------------------------------------
 17  
 18     type Build_Status is
 19        (Success,
 20         Source_Fetch_Failed,
 21         Hash_Mismatch,
 22         Patch_Failed,
 23         Configure_Failed,
 24         Compile_Failed,
 25         Install_Failed,
 26         Package_Failed);
 27  
 28     type Build_Result is record
 29        Status       : Build_Status := Source_Fetch_Failed;
 30        Output_Path  : Unbounded_String;
 31        Build_Log    : Unbounded_String;
 32        Duration_Sec : Natural := 0;
 33     end record;
 34  
 35     ---------------------------------------------------------------------------
 36     --  Build Configuration
 37     ---------------------------------------------------------------------------
 38  
 39     type Build_Options is record
 40        Work_Dir       : Unbounded_String;  -- Build workspace
 41        Output_Dir     : Unbounded_String;  -- Where to put artifacts
 42        Parallel_Jobs  : Positive := 1;     -- -j for make
 43        Verbose        : Boolean := False;
 44        Keep_Build_Dir : Boolean := False;  -- Don't clean up after build
 45        Reproducible   : Boolean := True;   -- Attempt reproducible build
 46     end record;
 47  
 48     Default_Options : constant Build_Options := (others => <>);
 49  
 50     ---------------------------------------------------------------------------
 51     --  Build Operations
 52     ---------------------------------------------------------------------------
 53  
 54     function Build_Package
 55        (M       : Manifest;
 56         Options : Build_Options := Default_Options) return Build_Result;
 57     --  Build a package from its manifest.
 58     --  @param M The package manifest
 59     --  @param Options Build configuration
 60     --  @return Build result with status and artifacts
 61  
 62     function Fetch_Source (M : Manifest; Dest : String) return Build_Status;
 63     --  Download and verify upstream source.
 64     --  @param M The manifest with source URL and hash
 65     --  @param Dest Destination directory
 66     --  @return Status (Success or Source_Fetch_Failed/Hash_Mismatch)
 67  
 68     function Apply_Patches
 69        (M          : Manifest;
 70         Source_Dir : String) return Build_Status;
 71     --  Apply all patches from the manifest in order.
 72     --  @param M The manifest with patch list
 73     --  @param Source_Dir Directory containing unpacked source
 74     --  @return Status (Success or Patch_Failed)
 75  
 76     function Run_Build
 77        (M          : Manifest;
 78         Source_Dir : String;
 79         Options    : Build_Options) return Build_Status;
 80     --  Execute the build commands from the manifest.
 81     --  @param M The manifest with build instructions
 82     --  @param Source_Dir Directory with patched source
 83     --  @param Options Build options (jobs, etc.)
 84     --  @return Status (Success or Configure/Compile/Install_Failed)
 85  
 86     ---------------------------------------------------------------------------
 87     --  Reproducibility Support
 88     ---------------------------------------------------------------------------
 89  
 90     type Reproducibility_Check is record
 91        Is_Reproducible : Boolean := False;
 92        First_Hash      : Unbounded_String;
 93        Second_Hash     : Unbounded_String;
 94        Differing_Files : Natural := 0;
 95     end record;
 96  
 97     function Check_Reproducibility
 98        (M       : Manifest;
 99         Options : Build_Options) return Reproducibility_Check;
100     --  Build package twice and compare results.
101     --  @param M The manifest
102     --  @param Options Build options
103     --  @return Reproducibility check results
104  
105  end Cerro_Builder;