equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
3 * All rights reserved. |
3 * All rights reserved. |
4 * This component and the accompanying materials are made available |
4 * This component and the accompanying materials are made available |
5 * under the terms of the License "Eclipse Public License v1.0" |
5 * under the terms of the License "Eclipse Public License v1.0" |
6 * which accompanies this distribution, and is available |
6 * which accompanies this distribution, and is available |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
30 |
30 |
31 #include "talon_process.h" |
31 #include "talon_process.h" |
32 #include "sema.h" |
32 #include "sema.h" |
33 #include "buffer.h" |
33 #include "buffer.h" |
34 #include "../config.h" |
34 #include "../config.h" |
|
35 |
|
36 #ifdef HAS_GETCOMMANDLINE |
|
37 #include "chomp.h" |
|
38 #endif |
35 |
39 |
36 /* The output semaphore. */ |
40 /* The output semaphore. */ |
37 sbs_semaphore talon_sem; |
41 sbs_semaphore talon_sem; |
38 |
42 |
39 #define TALON_ATTEMPT_STRMAX 32 |
43 #define TALON_ATTEMPT_STRMAX 32 |
220 return NULL; |
224 return NULL; |
221 } |
225 } |
222 return recipe; |
226 return recipe; |
223 } |
227 } |
224 |
228 |
225 #ifdef HAS_GETCOMMANDLINE |
|
226 /* |
|
227 Get rid of the path to talon from a commandline string on windows find the |
|
228 -c (if it's there) and step past it to after the quote on the first command: |
|
229 |
|
230 "g:\program files\talon\talon.exe" -c "gcc -c . . ." |
|
231 ^------ Returns a pointer to here |
|
232 |
|
233 Take care of the possibilty that there might be spaces in the command |
|
234 if it is quoted. |
|
235 |
|
236 A state-machine is flexible but not all that easy to write. Should investigate |
|
237 the possiblity of using the Ragel state machine generator perhaps. |
|
238 |
|
239 */ |
|
240 #define CH_START 0 |
|
241 #define CH_PRE 1 |
|
242 #define CH_EXQUOTE 2 |
|
243 #define CH_INQUOTE 3 |
|
244 #define CH_POST 4 |
|
245 #define CH_MINUS 5 |
|
246 #define CH_C 6 |
|
247 #define CH_PRECOMMAND 7 |
|
248 #define CH_COMMAND 8 |
|
249 #define CH_ERR 9 |
|
250 |
|
251 char * chompCommand(char command[]) |
|
252 { |
|
253 char *result = command; |
|
254 int state = CH_START; |
|
255 |
|
256 while (state != CH_COMMAND && state != CH_ERR) |
|
257 { |
|
258 DEBUG(("startstate: %d, char %c ",state, *result)); |
|
259 switch (*result) |
|
260 { |
|
261 case ' ': |
|
262 switch (state) |
|
263 { |
|
264 case CH_START: |
|
265 case CH_PRE: |
|
266 state = CH_PRE; |
|
267 break; |
|
268 case CH_EXQUOTE: |
|
269 state = CH_POST; |
|
270 break; |
|
271 case CH_INQUOTE: |
|
272 break; |
|
273 case CH_POST: |
|
274 break; |
|
275 case CH_MINUS: |
|
276 state = CH_C; |
|
277 break; |
|
278 case CH_C: |
|
279 state = CH_PRECOMMAND; |
|
280 break; |
|
281 case CH_PRECOMMAND: |
|
282 break; |
|
283 default: |
|
284 state = CH_ERR; |
|
285 break; |
|
286 } |
|
287 break; |
|
288 case 'c': |
|
289 switch (state) |
|
290 { |
|
291 case CH_START: |
|
292 case CH_PRE: |
|
293 state = CH_EXQUOTE; |
|
294 break; |
|
295 case CH_EXQUOTE: |
|
296 case CH_INQUOTE: |
|
297 break; |
|
298 case CH_POST: |
|
299 state = CH_ERR; |
|
300 break; |
|
301 case CH_MINUS: |
|
302 state = CH_C; |
|
303 break; |
|
304 case CH_C: |
|
305 case CH_PRECOMMAND: |
|
306 default: |
|
307 state = CH_ERR; |
|
308 break; |
|
309 } |
|
310 break; |
|
311 case '-': |
|
312 switch (state) |
|
313 { |
|
314 case CH_START: |
|
315 case CH_PRE: |
|
316 state = CH_EXQUOTE; |
|
317 break; |
|
318 case CH_EXQUOTE: |
|
319 case CH_INQUOTE: |
|
320 break; |
|
321 case CH_POST: |
|
322 state = CH_MINUS; |
|
323 break; |
|
324 case CH_MINUS: |
|
325 case CH_C: |
|
326 case CH_PRECOMMAND: |
|
327 default: |
|
328 state = CH_ERR; |
|
329 break; |
|
330 } |
|
331 break; |
|
332 case '"': |
|
333 switch (state) |
|
334 { |
|
335 case CH_START: |
|
336 case CH_PRE: |
|
337 case CH_EXQUOTE: |
|
338 state = CH_INQUOTE; |
|
339 break; |
|
340 case CH_INQUOTE: |
|
341 state = CH_EXQUOTE; |
|
342 break; |
|
343 case CH_POST: |
|
344 case CH_MINUS: |
|
345 case CH_C: |
|
346 state = CH_ERR; |
|
347 break; |
|
348 case CH_PRECOMMAND: |
|
349 state = CH_COMMAND; |
|
350 break; |
|
351 default: |
|
352 state = CH_ERR; |
|
353 break; |
|
354 } |
|
355 |
|
356 break; |
|
357 default: |
|
358 switch (state) |
|
359 { |
|
360 case CH_START: |
|
361 case CH_PRE: |
|
362 state = CH_EXQUOTE; |
|
363 break; |
|
364 case CH_INQUOTE: |
|
365 case CH_EXQUOTE: |
|
366 break; |
|
367 default: |
|
368 state = CH_ERR; |
|
369 break; |
|
370 } |
|
371 break; |
|
372 } |
|
373 DEBUG((stderr,"endstate: %d\n",state)); |
|
374 result ++; |
|
375 |
|
376 } |
|
377 |
|
378 if (state == CH_ERR) |
|
379 return NULL; |
|
380 |
|
381 return result; |
|
382 } |
|
383 #endif |
|
384 |
|
385 int main(int argc, char *argv[]) |
229 int main(int argc, char *argv[]) |
386 { |
230 { |
387 /* find the argument to -c then strip the talon related front section */ |
231 /* find the argument to -c then strip the talon related front section */ |
388 |
232 |
389 char *recipe = NULL; |
233 char *recipe = NULL; |