~dlh/armagetronad/os-x-toolkit

« back to all changes in this revision

Viewing changes to os-x-toolkit.rb

  • Committer: Daniel Lee Harple
  • Date: 2019-11-02 19:50:22 UTC
  • Revision ID: leeharple@gmail.com-20191102195022-um0p4eiyffns5m3q
Build SDL 1.2 from hg/git

* Apply proposed patches for 10.14+ issues

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
  libs = {}
8
8
 
9
9
  libs["SDL"] = Builder.new { |config, arch|
10
 
    archive = fetch("http://www.libsdl.org/release/SDL-1.2.15.dmg")
11
 
    source = open_dmg(archive)
12
 
    copy_framework(source, "SDL", arch)
13
 
    close_dmg(source)
 
10
    archive = fetch("https://github.com/SDL-mirror/SDL/archive/SDL-1.2.tar.gz")
 
11
    source = expand_tgz(archive)
 
12
    Dir.chdir(source) do
 
13
      apply_patch(path("patches/SDL1.patch"))
 
14
      config.env_variables(arch)
 
15
      system("./configure", "--prefix", install_path(arch), "--disable-video-x11")
 
16
      system("make install")
 
17
    end
 
18
 
 
19
    # Create the framework
 
20
    framework = path("libraries/Frameworks/SDL.framework", :clear_dir)
 
21
    FileUtils.mkdir_p(File.join(framework, "Versions/A"))
 
22
    FileUtils.cp(path("libraries/#{arch}/lib/libSDL.dylib"), File.join(framework, "Versions/A/SDL"))
 
23
    FileUtils.cp_r(path("libraries/#{arch}/include/SDL"), File.join(framework, "Versions/A/Headers"))
 
24
    system(
 
25
      "install_name_tool",
 
26
      "-id",
 
27
      "@rpath/SDL.framework/Versions/A/SDL",
 
28
      File.join(framework, "Versions/A/SDL")
 
29
    )
 
30
    symlink_relative(File.join(framework, "Versions/A"), File.join(framework, "Versions/Current"))
 
31
    symlink_relative(File.join(framework, "Versions/Current/Headers"), File.join(framework, "Headers"))
 
32
    symlink_relative(File.join(framework, "Versions/Current/SDL"), File.join(framework, "SDL"))
14
33
  }
15
34
 
16
35
  libs["SDL_image"] = Builder.new { |config, arch|
17
36
    archive = fetch("http://www.libsdl.org/projects/SDL_image/release/SDL_image-1.2.12.dmg")
18
37
    source = open_dmg(archive)
19
 
    copy_framework(source, "SDL_image", arch)
 
38
    copy_framework(source, "SDL_image")
20
39
    close_dmg(source)
21
40
  }
22
41
 
23
42
  libs["SDL_mixer"] = Builder.new { |config, arch|
24
43
    archive = fetch("http://www.libsdl.org/projects/SDL_mixer/release/SDL_mixer-1.2.12.dmg")
25
44
    source = open_dmg(archive)
26
 
    framework = copy_framework(source, "SDL_mixer", arch)
 
45
    copy_framework(source, "SDL_mixer")
27
46
    close_dmg(source)
28
47
  }
29
48
 
41
60
  libs["SDL2"] = Builder.new { |config, arch|
42
61
    archive = fetch("http://www.libsdl.org/release/SDL2-2.0.10.dmg")
43
62
    source = open_dmg(archive)
44
 
    copy_framework(source, "SDL2", arch)
 
63
    framework = copy_framework(source, "SDL2")
 
64
    link_framework(framework, arch)
45
65
    close_dmg(source)
46
66
  }
47
67
 
48
68
  libs["SDL2_image"] = Builder.new { |config, arch|
49
69
    archive = fetch("http://www.libsdl.org/projects/SDL_image/release/SDL2_image-2.0.5.dmg")
50
70
    source = open_dmg(archive)
51
 
    copy_framework(source, "SDL2_image", arch)
 
71
    framework = copy_framework(source, "SDL2_image")
 
72
    link_framework(framework, arch)
52
73
    close_dmg(source)
53
74
  }
54
75
 
55
76
  libs["SDL2_mixer"] = Builder.new { |config, arch|
56
77
    archive = fetch("http://www.libsdl.org/projects/SDL_mixer/release/SDL2_mixer-2.0.4.dmg")
57
78
    source = open_dmg(archive)
58
 
    framework = copy_framework(source, "SDL2_mixer", arch)
 
79
    framework = copy_framework(source, "SDL2_mixer")
 
80
    link_framework(framework, arch)
59
81
    close_dmg(source)
60
 
    
61
 
    # Correct install name for smpeg2
62
 
    system(
63
 
      "install_name_tool",
64
 
      "-change",
65
 
      "@executable_path/../Frameworks/SDL2.framework/Versions/A/SDL2",
66
 
      "@rpath/SDL2.framework/Versions/A/SDL2",
67
 
      File.join(framework, "Frameworks/smpeg2.framework/smpeg2")
68
 
    )
69
82
  }
70
83
 
71
84
  libs["libpng"] = Builder.new("lib/libpng.a") { |config, arch|
217
230
    system("hdiutil", "detach", path)
218
231
  end
219
232
 
220
 
  def copy_framework(source, name, arch)
 
233
  def copy_framework(source, name)
221
234
    framework_name = "#{name}.framework"
222
235
    file_path = self.path("libraries/Frameworks/#{framework_name}", :clear_file)
223
236
    FileUtils.cp_r(File.join(source, framework_name), file_path)
 
237
    return file_path
 
238
  end
 
239
 
 
240
  def link_framework(framework_path, arch)
 
241
    framework_name = File.basename(framework_path)
 
242
    name = File.basename(framework_name, ".framework")
224
243
 
225
244
    # link lib file
226
 
    framework_lib_file = File.join(file_path, name)
 
245
    framework_lib_file = File.join(framework_path, name)
227
246
    system("lipo", framework_lib_file, "-verify_arch", arch)
228
247
    if $?.exitstatus == 0
229
248
      symlink_relative(framework_lib_file, self.path("libraries/#{arch}/lib/lib#{name}.dylib", :clear_file))
233
252
    end
234
253
 
235
254
    # link headers
236
 
    header_directory = File.join(file_path, "Headers")
 
255
    header_directory = File.join(framework_path, "Headers")
237
256
    symlink_relative(header_directory, self.path("libraries/#{arch}/include/#{name}", :clear_file))
238
257
    Dir.glob("#{header_directory}/*") do |header_file|
239
258
      symlink_relative(header_file, self.path("libraries/#{arch}/include/AllFrameworks/#{File.basename(header_file)}", :clear_file))
240
259
    end
241
 
    return file_path
242
260
  end
243
261
 
244
262
  def expand_tgz(path)