File: macstatic.command

package info (click to toggle)
chipmunk 7.0.3-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,968 kB
  • sloc: ansic: 29,265; objc: 4,313; ruby: 409; makefile: 10; sh: 1
file content (61 lines) | stat: -rwxr-xr-x 1,490 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#! /usr/bin/ruby

Dir.chdir(File.dirname($0))

require 'Tempfile'
BUILD_LOG = Tempfile.new("Chipmunk-")
BUILD_LOG_PATH = BUILD_LOG.path

def log(string)
	puts string
	open(BUILD_LOG_PATH, 'a'){|f| f.puts string}
end

PROJECT = "Chipmunk7.xcodeproj"
VERBOSE = (not ARGV.include?("--quiet"))

def system(command)
	log "> #{command}"
	
	result = Kernel.system(VERBOSE ? "#{command} | tee -a #{BUILD_LOG_PATH}; exit ${PIPESTATUS[0]}" : "#{command} >> #{BUILD_LOG_PATH}")
	unless $? == 0
		log "==========================================="
		log "Command failed with status #{$?}: #{command}"
		log "Build errors encountered. Aborting build script"
		log "Check the build log for more information: #{BUILD_LOG_PATH}"
		raise
	end
end

def build(target, configuration)
	command = "xcodebuild -project #{PROJECT} -configuration #{configuration} -arch x86_64 -target #{target}"
	system command
	
	return "build/#{configuration}/lib#{target}.a"
end

def build_lib(target, copy_list)
	debug_lib = build(target, "Debug")
	release_lib = build(target, "Release")
	
	dirname = "#{target}"
	
	system "rm -rf '#{dirname}'"
	system "mkdir '#{dirname}'"
	
	system "cp '#{debug_lib}' '#{dirname}/lib#{target}-Debug.a'"
	system "cp '#{release_lib}' '#{dirname}/lib#{target}.a'"
	
	copy_list.each{|src| system "rsync -r --exclude='.*'  '#{src}' '#{dirname}'"}
end

build_lib("Chipmunk-Mac", [
	"../include",
])

build_lib("ObjectiveChipmunk-Mac", [
	"../include",
	"../objectivec/include",
])

BUILD_LOG.delete