OSDN Git Service

revise amulet search to consider of seed1 value,
[amulettoolsmh4/main.git] / make.py
diff --git a/make.py b/make.py
index 23579e4..2907f5a 100644 (file)
--- a/make.py
+++ b/make.py
@@ -7,33 +7,50 @@ import subprocess
 import tempfile
 import os
 import os.path
+import sys
 import shutil
 
-BUNDLE_RESOURCES = [(r"view/mainframe.xrc", r"d:\\Git\\AmuletToolsMH4\\view\\mainframe.xrc"),
-       (r"view/gaugedialog.xrc", r"d:\\Git\\AmuletToolsMH4\\view\\gaugedialog.xrc")]
-MOVE_FILES = ["data.zip", "readme.txt"]
+import convertcoding
+func = lambda path_list: os.path.join(convertcoding.convert_unicode(
+    os.path.dirname(os.path.abspath(__file__))), *path_list)
+BUNDLE_RESOURCES = [(ur"view/mainframe.xrc", func([u"view", u"mainframe.xrc"])),
+       (ur"view/gaugedialog.xrc", func([u"view", u"gaugedialog.xrc"]))]
+MOVE_FILES = [u"data.zip", u"readme.txt", u"license.txt"]
 
+SCRIPTFILE = u"amulettool.py"
+APPNAME = u"AmuletToolsMH4"
 
-SCRIPTFILE = "amulettool.py"
-APPNAME = "AmuletToolsMH4"
+MAKESPEC = u"pyi-makespec"
+PYINSTALLER = u"pyinstaller"
+ICONFILE_WIN = u"icon/amulettoolsmh4.ico"
+ICONFILE_MAC = u"icon/amulettoolsmh4.icns"
 
-MAKESPEC = "pyi-makespec"
-PYINSTALLER = "pyinstaller"
-
-SPECOPTIONS = ["--onefile", "--windowed", "--name=" + APPNAME]
+SPECOPTIONS_WIN = [u"--onefile", u"--windowed", u"--icon=" + ICONFILE_WIN, u"--name=" + APPNAME]
+SPECOPTIONS_MAC = [u"--onefile", u"--windowed", u"--icon=" + ICONFILE_MAC, u"--name=" + APPNAME]
+SPECOPTIONS_LINUX = [u"--onefile", u"--windowed", u"--name=" + APPNAME]
 
 def get_insert_lines():
     result = []
     for item in BUNDLE_RESOURCES:
-        result.append(r'a.datas += [("{0}", "{1}", "DATA")]'.format(item[0], item[1]) + "\n")
+        result.append(ur'a.datas += [("{0}", r"{1}", "DATA")]'.format(item[0], item[1]) + "\n")
     return result
 
 if __name__ == "__main__":
-    cmd = [MAKESPEC] + SPECOPTIONS + [SCRIPTFILE]
+    print u"file path: ", os.path.dirname(os.path.abspath(__file__))
+
+    if sys.platform.startswith(u"win"):
+        cmd = [MAKESPEC] + SPECOPTIONS_WIN + [SCRIPTFILE]
+    elif sys.platform.startswith(u"linux"):
+        cmd = [MAKESPEC] + SPECOPTIONS_LINUX + [SCRIPTFILE]
+    elif sys.platform.startswith(u"darwin"):
+        cmd = [MAKESPEC] + SPECOPTIONS_MAC + [SCRIPTFILE]
+    else:
+        raise OSError(u"this operating system is not supported!")
     print " ".join(cmd)
     out = subprocess.check_output(cmd)
     print out
 
+
     # insert bundle data line to .spec
     print "insert bundle resources to .spec file"
     specfile = APPNAME + ".spec"
@@ -49,6 +66,7 @@ if __name__ == "__main__":
     os.remove(specfile)
     os.rename(tmpname, specfile)
 
+
     # conduct pyinstall
     cmd = [PYINSTALLER, specfile]
     print " ".join(cmd)