-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathversion-script.sh
More file actions
executable file
·197 lines (165 loc) · 6.34 KB
/
Copy pathversion-script.sh
File metadata and controls
executable file
·197 lines (165 loc) · 6.34 KB
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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
#!/bin/sh
# This script is run by Xcode during the build phase to generate information about
# the build in C header file format. When run it produces a file which is included by main.m.
# Copy and paste this file into into Xcodes script window, or alternatively
# source this file from a small script in Xcode which does not need to be
# changed much.
# If this script is called with $1 set to vcs, it displays version control
# status like this: Fossil(1) abcdefabcdef123456798888888888
# ^ count of unchecked files
#
# If this script is called with $1 set to vcsdate, it displays
# the version control checkin date.
# for finding Fossil - use Macports
PATH=$SYSTEM_DEVELOPER_BIN_DIR:$PATH:/opt/local/bin
OF=XXXX-Tempfile.h
. ../scripts/common-functions.sh
PLB=/usr/libexec/PlistBuddy
function plget() {
${PLB} -c "Print :${1}" VoleInfo.plist
}
if [ x${1} = xvcs ]
then
printf '%s(%s) %s' $(version_control_type) $(count_unchecked_files) $(uuid_checkin)
exit 0
fi
if [ x${1} = xvcsdate ]
then
version_control_date
exit 0
fi
if [ x${1} = xmarketingversion ]
then
marketing_version | tr -d '\n'
exit 0
fi
# Now done in VoleInfo.plist
#build_uuid=$(uuidgen | tr -d '\012')
echo "version-script.sh: fetching BuildUUID"
build_uuid=$(plget BuildUUID)
echo ${build_uuid}
BUILDID=$(plget BuildID)
echo ${BUILDID}
echo "version-script.sh: done fetching"
echo Fossil checked-in files checking script
uuid=$(uuid_checkin)
rm -f "${OF}"
# Removing this file does not seem to force Xcode to recompile main.m.
# Sometimes it does, sometimes it does not. The safest thing is to do
# an xcodebuild clean first.
# see if agvtool produces an error - obsolete now
# agvtool mvers
# if [ $? -ne 0 ]
# then
# echo 'agvtool failed - You probably have multiple projects'
# exit 1
# fi
cat >${OF} <<EOF_SCRIPT_HEADER
// *** This file is automatically generated - do not edit. ***
// *** Do not check this file into Fossil. ***
// This header file generated at $(date)
EOF_SCRIPT_HEADER
echo 'char buildinfo_1[]=' >>${OF}
unchecked_files=$(count_unchecked_files)
if [ $unchecked_files -ne 0 ]
then
printf '"Warning: unchecked files = %d\\n"\n' $unchecked_files >> ${OF}
printf '"==== Checkout does not reflect build files ====\\n"\n' >>${OF}
fi
printf '"\\n"\n' >>${OF}
printf '"Version: %s\\n"\n' $(marketing_version) >> ${OF}
printf '"\\n"\n' >>${OF}
printf '"Build machine hostname: %s\\n"\n' `hostname -f` >> ${OF}
printf '"Built by username: %s\\n"\n' `whoami` >> ${OF}
printf '"Build UUID: %s\\n"\n' "${build_uuid}" >> ${OF}
printf '"Build ID: %s\\n"\n' "${BUILDID}" >> ${OF}
# date command does not like leading zeros
#builddate=$(date -u -r "${SECONDS_SINCE_EPOCH}")
builddate=$(plget BuildDate)
echo Build date: ${builddate}
printf '"Built on: %s\\n\\n"\n' "${builddate}" >> ${OF}
printf '"=== Version control status ===\\n"\n' >>${OF}
version_control_status | printlines >> ${OF}
if [ $unchecked_files -ne 0 ]
then
printf '"Warning: %d unchecked files (this is bad).\\n"\n' $unchecked_files >>${OF}
printf '" It means that the checkout does not reflect the state of the files used\\n"\n' >> ${OF}
printf '" for this build.\\n"\n' >> ${OF}
fi
printf '"\\n"\n' >>${OF}
printf '"Archs: %s\\n"\n' "${ARCHS}" >>${OF}
printf '"Build Style: %s\\n"\n' "${BUILD_STYLE}" >>${OF}
printf '"Vole Build Style: %s\\n"\n' "${VOLE_BUILD_STYLE}" >>${OF}
printf '"Build Variants: %s\\n"\n' "${BUILD_VARIANTS}" >>${OF}
printf '"Configuration: %s\\n"\n' "${CONFIGURATION}" >>${OF}
printf '"Project File Path: %s\\n"\n' "${PROJECT_FILE_PATH}" >>${OF}
printf '"Garbage collection: %s\\n"\n' "${GCC_ENABLE_OBJC_GC}" >>${OF}
printf '"Debugging Symbols:%s\\n"\n' "${DEBUGGING_SYMBOLS}" >>${OF}
printf '"Debug Information Format: %s\\n"\n' "${DEBUG_INFORMATION_FORMAT}" >>${OF}
GCCPREP=$( echo -n "${GCC_PREPROCESSOR_DEFINITIONS}" | stripquotes)
printf '"GCC Preprocessor Definitions: %s\\n"\n' "${GCCPREP}" >>${OF}
printf '"(Note: GCC Preprocessor Definitions does not show those specific to\\n"\n' >>${OF}
printf '" a SDK or an Arch.)\\n"\n' >>${OF}
WARNING_CF=$(echo -n "${WARNING_CFLAGS}" | stripquotes)
printf '"Warning C Flags: %s\\n"\n' "${WARNING_CF}" >> ${OF}
printf '"GCC Version: %s\\n"\n' "${GCC_VERSION}" >>${OF}
# the next two lines are tricky
printf '#ifdef __VERSION__\n"GCC: " __VERSION__ "\\n" \n#endif\n' >>${OF}
printf '#ifdef __clang_version__\n"Clang: " __clang_version__ "\\n" \n#endif\n' >>${OF}
printf '"GCC/Clang optimization level: %s\\n"\n' "${GCC_OPTIMIZATION_LEVEL}" >>${OF}
printf '"MacOSX Deployment Target: %s\\n"\n' "${MACOSX_DEPLOYMENT_TARGET}" >>${OF}
printf ';\n' >> ${OF}
printf 'char buildinfo_2[]=\n' >> ${OF}
printf '"Product Name: %s\\n"\n' "${PRODUCT_NAME}" >>${OF}
printf '"SDK Root: %s\\n"\n' "${SDKROOT}" >>${OF}
printf '"SDK Name: %s\\n"\n' "${SDK_NAME}" >>${OF}
printf '"SDK Product Build Version: %s\\n"\n' "${SDK_PRODUCT_BUILD_VERSION}" >> ${OF}
echo '=== Xcode ===' | printlines >>${OF}
xcodebuild -version | printlines >> ${OF}
echo '=== build machine sw_vers ===' | printlines >> ${OF}
sw_vers | printlines >> ${OF}
echo '=== SQLite ===' | printlines >> ${OF}
echo \; >>${OF}
printf 'int unchecked_files = %d;\n' $unchecked_files >>${OF}
printf 'char source_code_fossil_uuid[]="%s";\n' $uuid >>${OF}
printf 'char build_uuid[]="%s";\n' "${build_uuid}" >> ${OF}
printf 'char marketing_version[]="%s";\n' "$(marketing_version)" >> ${OF}
printf 'char build_short_id[]="%s";\n' "${BUILDID}" >> ${OF}
cat >> ${OF} << BUILD_INFO_EOF
/* vole_build_info is for appending Vole information to
* messages posted in the vienna conference.
* This is the Vole Status Report (Vole->Develop->Status Report)
*/
char vole_build_info[]=
"[${PRODUCT_NAME} Build]\n"
"Version: $(marketing_version)\n"
"Build Date: ${builddate}\n"
"Build: ${BUILDID}\n"
"Build UUID: ${build_uuid}\n"
"Built by user: ${USER}\n"
"Src Location: $(cd .. && pwd)\n"
"SDK: ${SDK_NAME} ${SDK_PRODUCT_BUILD_VERSION}\n"
"Deployment Target: ${MACOSX_DEPLOYMENT_TARGET}\n"
"Architectures: ${ARCHS}\n"
$(checkin)
"\n";
// changed, added or deleted files.
char vole_vcs_changes[] =
BUILD_INFO_EOF
if [ $unchecked_files -ne 0 ]
then
cat >> ${OF} <<EOF_UCF
$(changed_files)
"\n";
EOF_UCF
else
printf '""; // No Uncommited files.\n' >>${OF}
fi
if [ $unchecked_files -ne 0 ]
then
echo ERROR files not checked into Fossil or Git.
fi
sleep 2
touch ${SRCROOT}/Timestamp
echo 'version-script.sh completed'
exit 0