-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmach
executable file
·149 lines (124 loc) · 4.45 KB
/
mach
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
#!/bin/sh
BINOC_SYSTEM=`uname | tr [:upper:] [:lower:]`
BINOC_PYTHON=`which python2.7 2>/dev/null`
BINOC_GIT=`which git 2>/dev/null`
BINOC_CURL=`which curl 2>/dev/null`
BINOC_PLATFORM=./platform
BINOC_MACH=$BINOC_PLATFORM/mach
BINOC_CONFIG_GUESS=`./platform/build/autoconf/config.guess`
# =============================================================================
if [ -z "$BINOC_PYTHON" ]; then
printf "We could not find Python 2.7 which is required for just about everything!\n"
exit 1
fi
# =============================================================================
# Determin the current OS
# This will also be exported so it can be picked up by .mozconfig
if [[ "$BINOC_SYSTEM" == "mingw32_nt-"* ]]; then
BINOC_SYSTEM=windows
if [ "$BINOC_CONFIG_GUESS" == "x86_64-pc-mingw32" ]; then
BINOC_CONFIG_GUESS=win64
else
BINOC_CONFIG_GUESS=win32
fi
fi
export BINOC_SYSTEM=$BINOC_SYSTEM
export BINOC_CONFIG_GUESS=$BINOC_CONFIG_GUESS
# =============================================================================
# Determin the git branches or commits for use in the .mozconfig objdir path
# If there is no git or you aren't building in a git repository then the value
# will be blank. This is ok.
if [ -n "$BINOC_GIT" ]; then
BINOC_COMM_BRANCH=`"${BINOC_GIT}" symbolic-ref --short HEAD 2>/dev/null | tr [:upper:] [:lower:]`
BINOC_PLATFORM_BRANCH=`cd ${BINOC_PLATFORM} && "${BINOC_GIT}" symbolic-ref --short HEAD 2>/dev/null | tr [:upper:] [:lower:]`
# if we don't have a comm branch then don't even bother
if [ -n "$BINOC_COMM_BRANCH" ]; then
# If we aren't on the tip of a branch try getting the platform commit short sha
if [ -z "$BINOC_PLATFORM_BRANCH" ]; then
BINOC_PLATFORM_BRANCH=`cd ${BINOC_PLATFORM} && "${BINOC_GIT}" rev-parse --short HEAD 2>/dev/null`
fi
# See if the platform branch or commit sha if not just forget it
if [ -n "$BINOC_PLATFORM_BRANCH" ]; then
export BINOC_GIT_BRANCH=$BINOC_COMM_BRANCH-$BINOC_PLATFORM_BRANCH
fi
fi
fi
# =============================================================================
# This will process the commands given to the stub. If there is no match then
# just pass it to platform (real) mach
if [ "$1" == "release" ]; then
# We are going to assume you want to build, package, and generate a mar
$BINOC_MACH build
$BINOC_MACH package
# Windows also generates an NSIS installer and that is required before mar
if [ "$BINOC_SYSTEM" == "windows" ]; then
$BINOC_MACH installer
fi
$BINOC_MACH mar
elif [ "$1" == "localbuild" ]; then
# This builds and stages the application in dist/MOZ_APP_NAME but does not
# actually generate an archive or any of the other stuff
$BINOC_MACH build
$BINOC_MACH stage
elif [[ "$1" == "superclobber" && -d "../.obj" ]]; then
printf "Removing all object directories in ../.obj\n"
rm -rf ../.obj/*
elif [ "$1" == "version" ]; then
# This will execute version2k.py and pass any remaining args to it
$BINOC_PYTHON ./build/version2k.py ${@:2}
elif [ "$1" == "checkout" ] && [ -n "$BINOC_GIT" ]; then
printf "binoc-central:\n"
if [ "$2" == "absolute-trunk" ] && [ "$COMM_BRANCH" != "trunk" ]; then
"$BINOC_GIT" checkout TRUNK
fi
"$BINOC_GIT" pull
if [ ! -f $BINOC_PLATFORM/CLOBBER ]; then
"$BINOC_GIT" submodule init platform
fi
if [ "$2" == "absolute-trunk" ]; then
printf "\nUnified XUL Platform:\n"
cd $BINOC_PLATFORM
if [ "$BINOC_PLATFORM_BRANCH" != "master" ]; then
"$BINOC_GIT" checkout master
fi
"$BINOC_GIT" pull
else
"$BINOC_GIT" submodule update
fi
elif [ "$1" == "reset" ] && [ -n "$BINOC_GIT" ]; then
if [ "$2" == "comm" ]; then
printf "binoc-central:\n"
"$BINOC_GIT" reset --hard
elif [ "$2" == "platform" ]; then
printf "Unified XUL Platform:\n"
cd $BINOC_PLATFORM
"$BINOC_GIT" reset --hard
else
printf "Reset what?\n"
fi
elif [ "$1" == "webpatch" ] && [ -n "$BINOC_GIT" ] && [ -n "$BINOC_CURL" ]; then
if [ "$2" == "platform" ]; then
printf "Unified XUL Platform:\n"
cd $BINOC_PLATFORM
elif [ "$2" == "comm" ]; then
printf "binoc-central:\n"
else
printf "Patch what?\n"
exit 1
fi
if [ -z "$3" ]; then
printf "Patch with what?"
exit 1
else
if [[ "$3" == *"github.com"* ]]; then
_patch=$3.patch
else
_patch=$3
fi
fi
$BINOC_CURL -L $_patch | "$BINOC_GIT" apply --reject
else
# We don't know what the command is but real-mach might so just pass
# all the args to it
$BINOC_MACH $@
fi