Browse Source

Insert command-line at start of header file

Fix #3
James Bowman 6 years ago
parent
commit
b2178214b8
3 changed files with 10 additions and 4 deletions
  1. 4 0
      gameduino2/prep.py
  2. 3 2
      scripts/gd2asset
  3. 3 2
      scripts/gd3asset

+ 4 - 0
gameduino2/prep.py

@@ -439,6 +439,8 @@ class AssetBin(gameduino2.base.GD2):
         self.define(name + "_FREQ", freq)
 
     header = None
+    header_intro = ""
+
     def make(self):
         if self.header is None:
             name = self.__class__.__name__.lower() + "_assets.h"
@@ -466,6 +468,8 @@ class AssetBin(gameduino2.base.GD2):
 
         hh = open(name, "w")
 
+        hh.write(self.header_intro)
+
         for (nm,v) in self.defines:
             print >>hh, "#define %s %s" % (nm, v)
 

+ 3 - 2
scripts/gd2asset

@@ -16,11 +16,12 @@ def cname(s):
 
 class GD2Assets(gd2.prep.AssetBin):
 
-    def __init__(self, opts, args):
+    def __init__(self, cmdline, opts, args):
         self.opts = opts
         self.args = args
         gd2.prep.AssetBin.__init__(self)
         self.header = opts.get('-o', 'default_assets.h')
+        self.header_intro = "// This file was generated with the command-line:\n//    " + cmdline + "\n\n"
 
         if '-f' in opts:
             self.asset_file = opts['-f']
@@ -133,4 +134,4 @@ if __name__ == '__main__':
     optdict = dict(optlist)
     if 'gd3' in sys.argv[0].lower():
         optdict['-3'] = ''
-    GD2Assets(optdict, args).make()
+    GD2Assets(" ".join(sys.argv), optdict, args).make()

+ 3 - 2
scripts/gd3asset

@@ -16,11 +16,12 @@ def cname(s):
 
 class GD2Assets(gd2.prep.AssetBin):
 
-    def __init__(self, opts, args):
+    def __init__(self, cmdline, opts, args):
         self.opts = opts
         self.args = args
         gd2.prep.AssetBin.__init__(self)
         self.header = opts.get('-o', 'default_assets.h')
+        self.header_intro = "// This file was generated with the command-line:\n//    " + cmdline + "\n\n"
 
         if '-f' in opts:
             self.asset_file = opts['-f']
@@ -133,4 +134,4 @@ if __name__ == '__main__':
     optdict = dict(optlist)
     if 'gd3' in sys.argv[0].lower():
         optdict['-3'] = ''
-    GD2Assets(optdict, args).make()
+    GD2Assets(" ".join(sys.argv), optdict, args).make()