aboutsummaryrefslogtreecommitdiffstats
path: root/android/tools
diff options
context:
space:
mode:
authorDavid 'Digit' Turner <digit@google.com>2009-10-07 13:43:33 -0700
committerDavid 'Digit' Turner <digit@google.com>2009-10-07 13:43:33 -0700
commit065242de51ba1e18387ce22a99eb091a859990f7 (patch)
tree7d53cb54f3f68805de82a5ab48ee6040bcf25d80 /android/tools
parent48ed3267dfffedb65385b0a1f1462fdd46d049bb (diff)
downloadexternal_qemu-065242de51ba1e18387ce22a99eb091a859990f7.zip
external_qemu-065242de51ba1e18387ce22a99eb091a859990f7.tar.gz
external_qemu-065242de51ba1e18387ce22a99eb091a859990f7.tar.bz2
Ensure android/avd/hw-config-defs.h is properly regenerated as needed.
This modifies the emulator's build system to ensure that the file at android/avd/hw-config-defs.h is regenerated automatically each time that android/avd/hardware-properties.ini is itself changed. Tested with both the Android build system, and the standalone one.
Diffstat (limited to 'android/tools')
-rwxr-xr-xandroid/tools/gen-hw-config.py33
1 files changed, 22 insertions, 11 deletions
diff --git a/android/tools/gen-hw-config.py b/android/tools/gen-hw-config.py
index 928ccc5..3822485 100755
--- a/android/tools/gen-hw-config.py
+++ b/android/tools/gen-hw-config.py
@@ -43,12 +43,17 @@ macroNames = typesToMacros.values()
targetHeader = """\
/* this file is automatically generated from 'hardware-properties.ini'
* DO NOT EDIT IT. To re-generate it, use android/tools/gen-hw-config.py'
- */"""
+ */
+"""
# locate source and target
programDir = os.path.dirname(sys.argv[0])
-sourceFile = os.path.normpath(os.path.join(programDir,relativeSourcePath))
-targetFile = os.path.normpath(os.path.join(programDir,relativeTargetPath))
+if len(sys.argv) != 3:
+ print "Usage: %s source target\n" % os.path.basename(sys.argv[0])
+ sys.exit(1)
+
+sourceFile = sys.argv[1]
+targetFile = sys.argv[2]
# parse the source file and record items
# I would love to use Python's ConfigParser, but it doesn't
@@ -94,16 +99,21 @@ for line in open(sourceFile):
if lastItem:
items.append(lastItem)
+if targetFile == '--':
+ out = sys.stdout
+else:
+ out = open(targetFile,"wb")
-print targetHeader
+out.write(targetHeader)
# write guards to prevent bad compiles
for m in macroNames:
- print """\
+ out.write("""\
#ifndef %(macro)s
#error %(macro)s not defined
-#endif""" % { 'macro':m }
-print ""
+#endif
+""" % { 'macro':m })
+out.write("\n")
for item in items:
if item.type == None:
@@ -131,11 +141,12 @@ for item in items:
# quote default value for strings
varDefault = quoteStringForC(varDefault)
- print "%s(\n %s,\n %s,\n %s,\n %s,\n %s)\n" % \
- (varMacro,varName,varNameStr,varDefault,varAbstract,varDesc)
+ out.write("%s(\n %s,\n %s,\n %s,\n %s,\n %s)\n\n" % \
+ (varMacro,varName,varNameStr,varDefault,varAbstract,varDesc))
for m in macroNames:
- print "#undef %s" % m
+ out.write("#undef %s\n" % m)
-print "/* end of auto-generated file */"
+out.write("/* end of auto-generated file */\n")
+out.close()