Jack Jansen | 144fa67 | 1998-06-26 14:56:00 +0000 | [diff] [blame] | 1 | """macfreeze - Main program and GUI |
| 2 | |
| 3 | macfreeze allows you to turn Python scripts into fully self-contained |
| 4 | Mac applications, by including all the Python and C code needed in a single |
| 5 | executable. Like unix/windows freeze it can produce a config.c allowing you |
| 6 | to build the application with a development environment (CodeWarrior, to be |
| 7 | precise), but unlike the standard freeze it is also possible to create frozen |
| 8 | applications without a development environment, by glueing all the |
| 9 | shared libraries and extension modules needed together in a single |
| 10 | executable, using some Code Fragment Manager tricks.""" |
| 11 | |
| 12 | import macfs |
| 13 | import sys |
| 14 | import EasyDialogs |
| 15 | import string |
| 16 | |
| 17 | import macfreezegui |
| 18 | import 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 | |
| 28 | def 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) |
Jack Jansen | b5ae378 | 1998-07-31 09:43:36 +0000 | [diff] [blame] | 40 | |
Just van Rossum | 2e5b0f2 | 1999-11-04 10:28:59 +0000 | [diff] [blame] | 41 | def process(gentype, program, output, modules=None, module_files=None, debug=0, with_ifdef=0): |
| 42 | if modules is None: |
| 43 | modules = [] |
| 44 | if module_files is None: |
| 45 | module_files = [] |
| 46 | module_dict, missing = macmodulefinder.process(program, modules, module_files, debug) |
| 47 | if missing: |
| 48 | missing.sort() |
| 49 | print '** Missing modules:', string.join(missing, ' ') |
Jack Jansen | 144fa67 | 1998-06-26 14:56:00 +0000 | [diff] [blame] | 50 | sys.exit(1) |
| 51 | # |
| 52 | # And generate |
| 53 | # |
| 54 | if gentype == 'info': |
| 55 | import macgen_info |
| 56 | macgen_info.generate(output, module_dict) |
| 57 | return 1 # So the user can inspect it |
| 58 | elif gentype == 'source': |
| 59 | import macgen_src |
Jack Jansen | 91cae85 | 1999-10-01 08:28:01 +0000 | [diff] [blame] | 60 | warnings = macgen_src.generate(output, module_dict, debug, with_ifdef) |
Jack Jansen | 144fa67 | 1998-06-26 14:56:00 +0000 | [diff] [blame] | 61 | return warnings |
| 62 | elif gentype == 'resource': |
| 63 | import macgen_rsrc |
| 64 | macgen_rsrc.generate(output, module_dict, debug) |
| 65 | warnings = macgen_rsrc.warnings(module_dict) |
| 66 | return warnings |
| 67 | elif gentype == 'applet': |
| 68 | import macgen_bin |
Jack Jansen | b5ae378 | 1998-07-31 09:43:36 +0000 | [diff] [blame] | 69 | architecture = 'fat' # user should choose |
| 70 | macgen_bin.generate(program, output, module_dict, architecture, debug) |
Jack Jansen | 144fa67 | 1998-06-26 14:56:00 +0000 | [diff] [blame] | 71 | else: |
| 72 | raise 'unknown gentype', gentype |
Jack Jansen | b5ae378 | 1998-07-31 09:43:36 +0000 | [diff] [blame] | 73 | |
Jack Jansen | 144fa67 | 1998-06-26 14:56:00 +0000 | [diff] [blame] | 74 | if __name__ == '__main__': |
| 75 | main() |