<URL: http://bugs.freeciv.org/Ticket/Display.html?id=39666 >

 This patch changes generate_packets.py to work even if workdir is not
srcdir/common.
 Small step forward for generating files to builddir.


 - ML

diff -Nurd -X.diff_ignore freeciv/common/generate_packets.py freeciv/common/generate_packets.py
--- freeciv/common/generate_packets.py	2007-08-04 18:38:32.000000000 +0300
+++ freeciv/common/generate_packets.py	2007-09-04 12:55:21.000000000 +0300
@@ -1358,7 +1358,16 @@
 # various files.
 def main():
     ### parsing input
-    input_name="packets.def"
+    src_dir=os.path.dirname(sys.argv[0])
+    src_root=src_dir+"/.."
+    input_name=src_dir+"/packets.def"
+    ### We call this variable target_root instead of build_root
+    ### to avoid confusion as we are not building to builddir in
+    ### automake sense.
+    ### We build to src dir. Building to builddir causes a lot
+    ### of problems we have been unable to solve.
+    target_root=src_root
+
     content=open(input_name).read()
     content=strip_c_comment(content)
     lines=string.split(content,"\n")
@@ -1383,7 +1392,7 @@
     ### parsing finished
 
     ### writing packets_gen.h
-    output_h_name="packets_gen.h"
+    output_h_name=target_root+"/common/packets_gen.h"
 
     if lazy_overwrite:
         output_h=my_open(output_h_name+".tmp")
@@ -1407,7 +1416,7 @@
     output_h.close()
 
     ### writing packets_gen.c
-    output_c_name="packets_gen.c"
+    output_c_name=target_root+"/common/packets_gen.c"
     if lazy_overwrite:
         output_c=my_open(output_c_name+".tmp")
     else:
@@ -1483,7 +1492,7 @@
                 open(i,"w").write(new)
             os.remove(i+".tmp")
 
-    f=my_open("../server/hand_gen.h")
+    f=my_open(target_root+"/server/hand_gen.h")
     f.write('''
 #ifndef FC__HAND_GEN_H
 #define FC__HAND_GEN_H
@@ -1525,7 +1534,7 @@
 ''')
     f.close()
 
-    f=my_open("../client/packhand_gen.h")
+    f=my_open(target_root+"/client/packhand_gen.h")
     f.write('''
 #ifndef FC__PACKHAND_GEN_H
 #define FC__PACKHAND_GEN_H
@@ -1556,7 +1565,7 @@
 ''')
     f.close()
 
-    f=my_open("../server/hand_gen.c")
+    f=my_open(target_root+"/server/hand_gen.c")
     f.write('''
 
 #ifdef HAVE_CONFIG_H
@@ -1611,7 +1620,7 @@
 ''')
     f.close()
 
-    f=my_open("../client/packhand_gen.c")
+    f=my_open(target_root+"/client/packhand_gen.c")
     f.write('''
 
 #ifdef HAVE_CONFIG_H
_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to