1+ #!/usr/bin/env ruby
2+
3+ require 'fileutils'
4+ require 'pathname'
5+
6+ # Get the directory where this script is located
7+ script_dir = File . dirname ( File . expand_path ( __FILE__ ) )
8+ project_root = File . dirname ( script_dir )
9+
10+ # Define paths
11+ miniaudio_c_path = File . join ( project_root , "libs" , "miniaudio" , "miniaudio.c" )
12+ miniaudio_h_path = File . join ( project_root , "libs" , "miniaudio" , "miniaudio.h" )
13+ generated_dir = File . join ( project_root , "libs" , "generated" )
14+ miniaudio_m_path = File . join ( generated_dir , "miniaudio.m" )
15+
16+ puts "Preparing miniaudio for iOS..."
17+
18+ # Check if miniaudio.c exists
19+ unless File . exist? ( miniaudio_c_path )
20+ puts "Error: miniaudio.c not found at #{ miniaudio_c_path } "
21+ exit 1
22+ end
23+
24+ # Check if miniaudio.h exists
25+ unless File . exist? ( miniaudio_h_path )
26+ puts "Error: miniaudio.h not found at #{ miniaudio_h_path } "
27+ exit 1
28+ end
29+
30+ # Create generated directory if it doesn't exist
31+ FileUtils . mkdir_p ( generated_dir ) unless Dir . exist? ( generated_dir )
32+
33+ # Read the content of miniaudio.c
34+ miniaudio_c_content = File . read ( miniaudio_c_path )
35+
36+ # Create the Objective-C wrapper
37+ miniaudio_m_content = <<~OBJC
38+ // Generated by prepare_miniaudio.rb
39+ // This file wraps miniaudio.c for iOS compatibility
40+
41+ #import <Foundation/Foundation.h>
42+
43+ // Include the miniaudio implementation
44+ #define MINIAUDIO_IMPLEMENTATION
45+ #include "../miniaudio/miniaudio.h"
46+
47+ // iOS-specific initialization and exports can be added here if needed
48+ OBJC
49+
50+ # Write the generated file
51+ File . write ( miniaudio_m_path , miniaudio_m_content )
52+
53+ puts "Generated #{ miniaudio_m_path } "
54+ puts "Miniaudio preparation completed successfully!"
55+
56+ # Verify the generated file
57+ if File . exist? ( miniaudio_m_path )
58+ puts "✓ Generated file exists and is ready for iOS compilation"
59+ else
60+ puts "✗ Error: Generated file was not created"
61+ exit 1
62+ end
0 commit comments