blob: 60962eec0a1c28130fd0609f5ed1383a59d8d09e [file] [log] [blame]
Jack Jansen144fa671998-06-26 14:56:00 +00001"""macfreeze - Main program and GUI
2
3macfreeze allows you to turn Python scripts into fully self-contained
4Mac applications, by including all the Python and C code needed in a single
5executable. Like unix/windows freeze it can produce a config.c allowing you
6to build the application with a development environment (CodeWarrior, to be
7precise), but unlike the standard freeze it is also possible to create frozen
8applications without a development environment, by glueing all the
9shared libraries and extension modules needed together in a single
10executable, using some Code Fragment Manager tricks."""
11
12import macfs
13import sys
14import EasyDialogs
15import string
16
17import macfreezegui
18import macmodulefinder
19
20#
21# Here are the macfreeze directives, used when freezing macfreeze itself
22# (see directives.py for an explanation)
23#
24# macfreeze: path ::::Tools:freeze
25# macfreeze: exclude win32api
26#
27
28def main():
29 if len(sys.argv) < 2:
30 gentype, program, output, debug = macfreezegui.dialog()
31 elif len(sys.argv) == 2:
32 gentype, program, output, debug = macfreezegui.dialog(sys.argv[1])
33 else:
34 EasyDialog.Message(
35 "Please pass a single script. Additional modules can be specified with directives")
36 sys.exit(0)
37 mustwait = process(gentype, program, output, debug=debug)
38 if mustwait:
39 sys.exit(1)
40
41def process(gentype, program, output, modules=[], module_files=[], debug=0):
42 try:
43 module_dict = macmodulefinder.process(program, modules, module_files, debug)
44 except macmodulefinder.Missing, arg:
45 arg.sort()
46 print '** Missing modules:', string.join(arg, ' ')
47 sys.exit(1)
48 #
49 # And generate
50 #
51 if gentype == 'info':
52 import macgen_info
53 macgen_info.generate(output, module_dict)
54 return 1 # So the user can inspect it
55 elif gentype == 'source':
56 import macgen_src
57 warnings = macgen_src.generate(output, module_dict, debug)
58 return warnings
59 elif gentype == 'resource':
60 import macgen_rsrc
61 macgen_rsrc.generate(output, module_dict, debug)
62 warnings = macgen_rsrc.warnings(module_dict)
63 return warnings
64 elif gentype == 'applet':
65 import macgen_bin
66 macgen_bin.generate(output, module_dict, debug)
67 else:
68 raise 'unknown gentype', gentype
69
70if __name__ == '__main__':
71 main()
72