oby2linux.py 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #
  2. # Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
  3. # All rights reserved.
  4. # This component and the accompanying materials are made available
  5. # under the terms of the License "Eclipse Public License v1.0"
  6. # which accompanies this distribution, and is available
  7. # at the URL "http://www.eclipse.org/legal/epl-v10.html".
  8. #
  9. # Initial Contributors:
  10. # Nokia Corporation - initial contribution.
  11. #
  12. # Contributors:
  13. #
  14. # Description:
  15. # oby2linux
  16. #
  17. """
  18. Convert an OBY file into a form that rombuild on Linux can use.
  19. This involves converting paths etc. In addition it finds those target
  20. files whose case may not match what exists on the filesystem
  21. (a build must have been completed).
  22. It also fills in those items that weren't built from a directory
  23. containing a prebuild epoc32 dir.
  24. """
  25. import sys
  26. import os
  27. import re
  28. sys.path.append(os.environ['SBS_HOME']+'/python')
  29. import generic_path
  30. epocroot = os.environ['EPOCROOT']
  31. try:
  32. romfillin_epocroot = os.environ['ROMFILLIN_EPOCROOT']
  33. except:
  34. sys.stderr.write("Please set ROMFILLIN_EPOCROOT to a path with an epoc32 directory\n")
  35. sys.exit(1)
  36. if not os.path.isdir(romfillin_epocroot+'/epoc32'):
  37. sys.stderr.write("Please set ROMFILLIN_EPOCROOT to a path with an epoc32 directory\n")
  38. sys.exit(1)
  39. filestatement_re=re.compile("^(?P<pre>((((primary)|(secondary)|(extension)|(device)|(variant))(\[0x[0-9a-zA-Z]+\])?=)|((file)|(data)|(bootbinary))=))(?P<filename>\S+)(?P<tail>.*)$")
  40. for line in sys.stdin.xreadlines():
  41. line = line.rstrip()
  42. m = filestatement_re.search(line)
  43. if m is not None:
  44. fname = m.groupdict()['filename'].replace('\\','/').strip('"')
  45. filename = generic_path.Path(epocroot + fname)
  46. filefound = filename.FindCaseless()
  47. if filefound is not None:
  48. print m.groupdict()['pre'] + str(filefound) + m.groupdict()['tail']
  49. #print filefound
  50. else:
  51. fillinname = generic_path.Path(romfillin_epocroot+fname)
  52. filefound = fillinname.FindCaseless()
  53. if filefound is not None:
  54. sys.stderr.write("filledinmissing: %s\n" % str(filefound))
  55. print m.groupdict()['pre'] + str(filefound) + m.groupdict()['tail']
  56. #print filefound
  57. else:
  58. sys.stderr.write("filenotfound: %s\n" % str(filename))
  59. else:
  60. print line