-
Notifications
You must be signed in to change notification settings - Fork 1
/
compile.functions
82 lines (67 loc) · 2.08 KB
/
compile.functions
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# This file is part of compile. It is subject to the licence terms in the COPYRIGHT file found in the top-level directory of this distribution and at https://raw.githubusercontent.com/shellfire-dev/compile/master/COPYRIGHT. No part of compile, including this file, may be copied, modified, propagated, or distributed except according to the terms contained in the COPYRIGHT file.
# Copyright © 2015 The developers of compile. See the COPYRIGHT file in the top-level directory of this distribution and at https://raw.githubusercontent.com/shellfire-dev/compile/master/COPYRIGHT.
core_usesIn cpucount
core_dependency_requires 'Homebrew' brew
compile_initialiase()
{
local TMP_FILE
core_temporaryFiles_newFileToRemoveOnExit
_compile_temporaryBuildScript="$TMP_FILE"
cpucount_computeMakeJobsAndLoadAverage 0 10
# Problem: Mac OS X compilation is borked; need to use brew sh
if core_compatibility_whichNoOutput brew; then
_compile_useHomebrew=true
else
_compile_useHomebrew=false
fi
}
core_dependency_requires '*' sh
core_dependency_requires 'Homebrew' cat
compile_executionScript()
{
local sourcePath="$1"
local destinationPath="$2"
local commandFunction="$3"
compile_c_reset
if $_compile_useHomebrew; then
cat >"$_compile_temporaryBuildScript" <<-EOF
set -e
set -u
set -f
cd $(core_variable_escapeSingleQuotes "$sourcePath")
EOF
$commandFunction >>"$_compile_temporaryBuildScript"
printf '%s\n' "sh '$(core_variable_escapeSingleQuotes "$_compile_temporaryBuildScript")'" | brew sh
else
pushd "$sourcePath"
$commandFunction
popd
fi
}
compile_escapedCommandLine()
{
if ! $_compile_useHomebrew; then
"$@"
return 0
fi
local afterFirst=false
local argument
for argument in "$@"
do
if $afterFirst; then
printf ' '
else
afterFirst=true
fi
printf "'"
core_variable_escapeSingleQuotes "$argument"
printf "'"
done
printf '\n'
}
# Note: We are now able to bootstrap make
core_dependency_requires '*' make
compile_escapedCommandLineMake()
{
core_variable_escapedCommandLine make -l $cpucount_makeLoadAverage -j $cpucount_makeJobs "$@"
}