Add Xcode-iPhoneOS/rakefile which can be used to build SDL.framework from the commandline
This is the rakefile from Andrey Nesterov, but slightly modified.
Use the following command:
$ rake -f Xcode-iPhoneOS/rakefile
The resulting framework is placed in the ./build directory.
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/Xcode-iPhoneOS/rakefile Tue Sep 27 22:54:59 2011 +0200
1.3 @@ -0,0 +1,219 @@
1.4 +# ------------------------------------------------------------------------------
1.5 +# Builds a SDL framework for the iOS
1.6 +# Copyright (c) 2011 Andrey Nesterov
1.7 +# See LICENSE for licensing information
1.8 +# ------------------------------------------------------------------------------
1.9 +#
1.10 +# Creates a pseudo-framework which contains a universal library that can be used
1.11 +# on a iOS and in the iOS simulator
1.12 +#
1.13 +# ------------------------------------------------------------------------------
1.14 +#
1.15 +# To configure the script, define:
1.16 +# Conf configuration, symbol (:release or :debug)
1.17 +# SDK version number of the iOS SDK, symbol (e.g. :"4.3")
1.18 +# Arch architecture for the device's library, symbol (e.g. :armv6 or :armv7)
1.19 +#
1.20 +# ------------------------------------------------------------------------------
1.21 +
1.22 +# --- Configure ----------------------------------------------------------------
1.23 +module Configure
1.24 + Conf = :release
1.25 + SDK = :"4.3"
1.26 + Arch = :armv7
1.27 +end
1.28 +
1.29 +# --- Constants ----------------------------------------------------------------
1.30 +module Global
1.31 + RootDir = Dir.pwd
1.32 + SourceDir = "#{RootDir}"
1.33 + BuildDir = "#{RootDir}/build"
1.34 +end
1.35 +
1.36 +# --- Common -------------------------------------------------------------------
1.37 +module Builder
1.38 + def get_sources(from, to)
1.39 + refresh_dir to
1.40 + yield from, to
1.41 + end
1.42 +
1.43 + def build_library(project, dest, target, conf, sdk, arch)
1.44 + print "\n"
1.45 + dest = library_bundle_path(dest, conf, sdk, arch)
1.46 + sdk, arch = compute_platform(sdk, arch)
1.47 + conf = configuration(conf)
1.48 +
1.49 + refresh_dir dest
1.50 + refresh_dir "#{dest}.build"
1.51 +
1.52 + proj_dir, proj_fname = File.split project
1.53 + cd proj_dir
1.54 + args = Array.new()
1.55 + args.push("xcodebuild")
1.56 + args.push("-project #{proj_fname}")
1.57 + args.push("-sdk #{sdk}")
1.58 + args.push("-configuration \"#{conf}\"")
1.59 + args.push("-target \"#{target}\"")
1.60 + # NATIVE_ARCH has no effect
1.61 + #args.push("NATIVE_ARCH=#{arch.to_str}")
1.62 + args.push("-arch #{arch.to_str}")
1.63 + args.push("TARGETED_DEVICE_FAMILY=2") # 2 => iPad, 1 => iPhone
1.64 + args.push("BUILT_PRODUCTS_DIR=\"build\"")
1.65 + args.push("CONFIGURATION_BUILD_DIR=\"#{dest}\"")
1.66 + args.push("CONFIGURATION_TEMP_DIR=\"#{dest}.build\"")
1.67 + cmd = args.join(' ')
1.68 + #print "\n"
1.69 + print "#{cmd}\n"
1.70 + `#{cmd}`
1.71 + end
1.72 +
1.73 + def build_framework_library(frameworkLib, deviceLib, simulatorLib)
1.74 + print "\n"
1.75 + refresh_dir File.dirname frameworkLib
1.76 + cmd = "lipo -create #{deviceLib} #{simulatorLib} -o #{frameworkLib}"
1.77 + print "#{cmd}\n"
1.78 + `#{cmd}`
1.79 + end
1.80 +
1.81 + def build_framework(name, version, identifier, dest, headers, project, target, conf, sdk, arch)
1.82 + libFileName = "lib#{name}.a";
1.83 + libFilePath = "#{dest}/universal-#{conf}/#{libFileName}"
1.84 +
1.85 + build_library(project, dest, target, conf, sdk, arch);
1.86 + build_library(project, dest, target, conf, sdk, :i386);
1.87 +
1.88 + build_framework_library(
1.89 + libFilePath,
1.90 + "#{library_bundle_path(dest, conf, sdk, arch)}/#{libFileName}",
1.91 + "#{library_bundle_path(dest, conf, sdk, :i386)}/#{libFileName}"
1.92 + )
1.93 + # Static library has version A
1.94 + create_framework(name, "A", identifier, dest, headers, libFilePath)
1.95 + end
1.96 +
1.97 + def create_framework(name, version, identifier, dest, headers, lib)
1.98 + print "\n"
1.99 + frameworkVersion = version
1.100 + frameworkBundle = framework_bundle_path(dest, name)
1.101 +
1.102 + # creating framework's directories
1.103 + refresh_dir frameworkBundle
1.104 + mkdir "#{frameworkBundle}/Versions"
1.105 + mkdir "#{frameworkBundle}/Versions/#{frameworkVersion}"
1.106 + mkdir "#{frameworkBundle}/Versions/#{frameworkVersion}/Resources"
1.107 + mkdir "#{frameworkBundle}/Versions/#{frameworkVersion}/Headers"
1.108 + mkdir "#{frameworkBundle}/Versions/#{frameworkVersion}/Documentation"
1.109 +
1.110 + # creating framework's symlinks
1.111 + `ln -s "#{frameworkVersion}" "#{frameworkBundle}/Versions/Current"`
1.112 + `ln -s "Versions/Current/Headers" "#{frameworkBundle}/Headers"`
1.113 + `ln -s "Versions/Current/Resources" "#{frameworkBundle}/Resources"`
1.114 + `ln -s "Versions/Current/Documentation" "#{frameworkBundle}/Documentation"`
1.115 + `ln -s "Versions/Current/#{File.basename lib}" "#{frameworkBundle}/#{name}"`
1.116 +
1.117 + # copying lib
1.118 + cp lib, "#{frameworkBundle}/Versions/#{frameworkVersion}"
1.119 +
1.120 + # copying the header files. Copy everything found in the headers directory.
1.121 + FileList["#{headers}/*.h"].each do |source|
1.122 + cp source, "#{frameworkBundle}/Headers"
1.123 + end
1.124 +
1.125 + # creating plist
1.126 + File.open("#{frameworkBundle}/Resources/Info.plist", "w") do |f|
1.127 + f.puts '<?xml version="1.0" encoding="UTF-8"?>
1.128 +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
1.129 +<plist version="1.0">'
1.130 + f.puts "\
1.131 +<dict>
1.132 + <key>CFBundleDevelopmentRegion</key>
1.133 + <string>English</string>
1.134 + <key>CFBundleExecutable</key>
1.135 + <string>#{name}</string>
1.136 + <key>CFBundleIdentifier</key>
1.137 + <string>#{identifier}</string>
1.138 + <key>CFBundleInfoDictionaryVersion</key>
1.139 + <string>6.0</string>
1.140 + <key>CFBundlePackageType</key>
1.141 + <string>FMWK</string>
1.142 + <key>CFBundleSignature</key>
1.143 + <string>????</string>
1.144 + <key>CFBundleVersion</key>
1.145 + <string>#{version}</string>
1.146 +</dict>
1.147 +</plist>"
1.148 + end
1.149 + end
1.150 +
1.151 + def library_bundle_path(path, conf, sdk, arch)
1.152 + sdk, arch = compute_platform(sdk, arch)
1.153 + "#{path}/#{sdk}-#{conf}"
1.154 + end
1.155 +
1.156 + def framework_bundle_path(path, name)
1.157 + "#{path}/#{name}.framework"
1.158 + end
1.159 +
1.160 + def configuration(conf)
1.161 + conf.to_s
1.162 + end
1.163 +
1.164 + def compute_platform(sdk, arch)
1.165 + return [sdk, arch] if arch.class == String
1.166 + [arch == :i386 ? "iphonesimulator" + sdk.to_s : "iphoneos" + sdk.to_s, arch.to_s]
1.167 + end
1.168 +
1.169 + def refresh_dir(path)
1.170 + rm_rf path if FileTest.exists? path
1.171 + mkdir_p path
1.172 + end
1.173 +
1.174 + private :configuration, :compute_platform, :refresh_dir
1.175 +end
1.176 +
1.177 +class InstanceBuilder
1.178 + class Instance
1.179 + extend Builder
1.180 + end
1.181 +
1.182 + def InstanceBuilder.message(text)
1.183 + tailSize = 75 - text.length;
1.184 + puts "--- #{text} #{'-' * (tailSize < 0 ? 0 : tailSize)}"
1.185 + end
1.186 +end
1.187 +
1.188 +# --- SDL ----------------------------------------------------------------------
1.189 +class SDL < InstanceBuilder
1.190 + SourceDir = "#{Global::SourceDir}"
1.191 + BuildDir = "#{Global::BuildDir}"
1.192 +
1.193 + def SDL.build_framework(conf, sdk, arch)
1.194 + message "Building SDL"
1.195 + Instance.build_framework(
1.196 + "SDL",
1.197 + "1.3",
1.198 + "org.libsdl",
1.199 + BuildDir,
1.200 + "#{SourceDir}/include",
1.201 + "#{SourceDir}/Xcode-iPhoneOS/SDL/SDLiPhoneOS.xcodeproj",
1.202 + "libSDL",
1.203 + conf,
1.204 + sdk,
1.205 + arch
1.206 + )
1.207 + end
1.208 +
1.209 + def Instance.configuration(conf)
1.210 + case conf
1.211 + when :release
1.212 + "Release"
1.213 + when :debug
1.214 + "Debug"
1.215 + end
1.216 + end
1.217 +end
1.218 +
1.219 +# --- Tasks --------------------------------------------------------------------
1.220 +task :default do
1.221 + SDL.build_framework Configure::Conf, Configure::SDK, Configure::Arch
1.222 +end