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