@@ -90,6 +90,88 @@ extern Boolean InitSSLCrypt(void);
9090
9191// //////////////////////////////////////////////////////////////////////////////
9292
93+ static const char *kMCDeployArchitectureStrings [] =
94+ {
95+ " " ,
96+ " i386" ,
97+ " x86-64" ,
98+ " armv6" ,
99+ " armv7" ,
100+ " armv7s" ,
101+ " arm64" ,
102+ " ppc" ,
103+ " ppc64" ,
104+ nil,
105+ };
106+
107+ typedef struct
108+ {
109+ MCDeployParameters* params;
110+ MCExecContext* ctxt;
111+ }
112+ MCDeployArrayApplyCallbackContext;
113+
114+ static bool MCDeployMapArchitectureString (MCStringRef p_string, MCDeployArchitecture& r_architecture)
115+ {
116+ for (uindex_t i = 0 ; kMCDeployArchitectureStrings [i] != nil; i++)
117+ {
118+ // As 'p_string' is an MCString the '==' operator does a caseless comparison.
119+ if (MCStringIsEqualToCString (p_string, kMCDeployArchitectureStrings [i], kMCStringOptionCompareCaseless ))
120+ {
121+ r_architecture = (MCDeployArchitecture)i;
122+ return true ;
123+ }
124+ }
125+
126+ return false ;
127+ }
128+
129+ static bool MCDeployPushMinOSVersion (MCDeployParameters* p_params, MCDeployArchitecture p_arch, MCStringRef p_vers_string)
130+ {
131+ // Use sscanf to parse out the version string. We don't check the return value of
132+ // sscanf as we don't care - any malformed / missing components will come out as
133+ // 0.
134+ int t_major, t_minor, t_inc;
135+ t_major = t_minor = t_inc = 0 ;
136+
137+ MCAutoPointer<char > t_native_string;
138+ MCStringConvertToCString (p_vers_string, &t_native_string);
139+ sscanf (*t_native_string, " %d.%d.%d" , &t_major, &t_minor, &t_inc);
140+
141+ if (!MCMemoryResizeArray (p_params -> min_os_version_count + 1 , p_params -> min_os_versions, p_params -> min_os_version_count))
142+ return false ;
143+
144+ uint32_t t_version;
145+ t_version = (t_major & 0xFFFF ) << 16 ;
146+ t_version |= (t_minor & 0xFF ) << 8 ;
147+ t_version |= (t_inc & 0xFF ) << 0 ;
148+
149+ p_params -> min_os_versions[p_params -> min_os_version_count - 1 ] . architecture = p_arch;
150+ p_params -> min_os_versions[p_params -> min_os_version_count - 1 ] . version = t_version;
151+
152+ return true ;
153+ }
154+
155+ static bool MCDeployGetArchitectures (void *context, MCArrayRef array, MCNameRef key, MCValueRef value)
156+ {
157+ MCDeployArrayApplyCallbackContext *t_context;
158+ t_context = (MCDeployArrayApplyCallbackContext*)context;
159+
160+ MCAutoStringRef t_value_as_string;
161+ MCDeployArchitecture t_arch;
162+
163+ if (!t_context -> ctxt -> ConvertToString (value, &t_value_as_string))
164+ return false ;
165+
166+ if (!MCDeployMapArchitectureString (MCNameGetString (key), t_arch))
167+ return false ;
168+
169+ if (MCDeployPushMinOSVersion (t_context -> params, t_arch, *t_value_as_string))
170+ return false ;
171+
172+ return true ;
173+ }
174+
93175bool MCDeployParameters::InitWithArray (MCExecContext &ctxt, MCArrayRef p_array)
94176{
95177 MCStringRef t_temp_string;
@@ -178,6 +260,42 @@ bool MCDeployParameters::InitWithArray(MCExecContext &ctxt, MCArrayRef p_array)
178260 return false ;
179261 MCValueAssign (version_info, t_temp_array);
180262 MCValueRelease (t_temp_array);
263+
264+ // The 'min_os_version' is either a string or an array. If it is a string then
265+ // it encodes the version against the 'Unknown' architecture which is interpreted
266+ // by the deploy command to mean all architectures. Otherwise, the keys in the
267+ // array are assumed to be architecture names and each is pushed on the array.
268+ // If multiple entries are present, then the 'unknown' mapping is used for any
269+ // architecture not explicitly specified. The current architecture strings that are
270+ // known are:
271+ // i386, x86-64, armv6, armv7, armv7s, arm64, ppc, ppc64
272+ // The empty string is taken to be 'unknown'.
273+ if (!ctxt . CopyElementAsArray (p_array, MCNAME (" min_os_version" ), false , t_temp_array))
274+ return false ;
275+
276+ // SN-2015-02-04: [[ Merge-6.7.2 ]] If the array is empty, try to convert to a string.
277+ if (!MCArrayIsEmpty (t_temp_array))
278+ {
279+ MCDeployArrayApplyCallbackContext t_context;
280+ t_context . ctxt = &ctxt;
281+ t_context . params = this ;
282+
283+ bool t_success;
284+ t_success = MCArrayApply (t_temp_array, MCDeployGetArchitectures, (void *)&t_context);
285+ MCValueRelease (t_temp_array);
286+
287+ if (!t_success)
288+ return false ;
289+ }
290+ else
291+ {
292+ MCValueRelease (t_temp_array);
293+ if (!ctxt . CopyElementAsString (p_array, MCNAME (" min_os_version" ), false , t_temp_string))
294+ return false ;
295+
296+ MCDeployPushMinOSVersion (this , kMCDeployArchitecture_Unknown , t_temp_string);
297+ MCValueRelease (t_temp_string);
298+ }
181299
182300 return true ;
183301}
@@ -446,7 +564,7 @@ void MCIdeDeploy::exec_ctxt(MCExecContext& ctxt)
446564 if (!ctxt . EvalExprAsArrayRef (m_params, EE_UNDEFINED, &t_array))
447565 return ;
448566
449- MCDeployParameters t_params;
567+ MCDeployParameters t_params;
450568 t_has_error = !t_params.InitWithArray (ctxt, *t_array);
451569
452570 // If platform is iOS and we are not Mac then error
@@ -505,11 +623,10 @@ void MCIdeDeploy::exec_ctxt(MCExecContext& ctxt)
505623 ctxt . SetTheResultToCString (MCDeployErrorToString (t_error));
506624 else
507625 ctxt . SetTheResultToEmpty ();
508- }
626+ }
509627
510628 if (t_has_error && !t_soft_error)
511629 ctxt . Throw ();
512-
513630}
514631
515632// //////////////////////////////////////////////////////////////////////////////
0 commit comments