3 # Template used then the program is a GUI program
8 HINSTANCE hInstance, // handle to current instance
9 HINSTANCE hPrevInstance, // handle to previous instance
10 LPSTR lpCmdLine, // pointer to command line
11 int nCmdShow // show state of window
14 extern int Py_FrozenMain(int, char **);
15 PyImport_FrozenModules = _PyImport_FrozenModules;
16 return Py_FrozenMain(__argc, __argv);
21 extern int PythonService_main(int, char **);
23 int main( int argc, char **argv)
25 PyImport_FrozenModules = _PyImport_FrozenModules;
26 return PythonService_main(argc, argv);
31 # -s flag : (C entry point template), (is it __main__?), (is it a DLL?)
32 'console' : (None, 1, 0),
33 'windows' : (WINMAINTEMPLATE
, 1, 0),
34 'service' : (SERVICETEMPLATE
, 0, 0),
35 'com_dll' : ("", 0, 1),
38 def get_custom_entry_point(subsystem
):
40 return subsystem_details
[subsystem
][:2]
42 raise ValueError, "The subsystem %s is not known" % subsystem
45 def makemakefile(outfp
, vars, files
, target
):
49 realwork(vars, files
, target
)
53 def realwork(vars, moddefns
, target
):
54 version_suffix
= "%r%r" % sys
.version_info
[:2]
55 print "# Makefile for Microsoft Visual C++ generated by freeze.py script"
57 print 'target = %s' % target
58 print 'pythonhome = %s' % vars['prefix']
60 print 'DEBUG=0 # Set to 1 to use the _d versions of Python.'
62 print 'debug_suffix=_d'
63 print 'c_debug=/Zi /Od /DDEBUG /D_DEBUG'
64 print 'l_debug=/DEBUG'
65 print 'temp_dir=Build\\Debug'
70 print 'temp_dir=Build\\Release'
74 print '# The following line assumes you have built Python using the standard instructions'
75 print '# Otherwise fix the following line to point to the library.'
76 print 'pythonlib = "$(pythonhome)/pcbuild/python%s$(debug_suffix).lib"' % version_suffix
79 # We only ever write one "entry point" symbol - either
80 # "main" or "WinMain". Therefore, there is no need to
81 # pass a subsystem switch to the linker as it works it
82 # out all by itself. However, the subsystem _does_ determine
83 # the file extension and additional linker flags.
84 target_link_flags
= ""
86 if subsystem_details
[vars['subsystem']][2]:
87 target_link_flags
= "-dll"
91 print "# As the target uses Python%s.dll, we must use this compiler option!" % version_suffix
94 print "all: $(target)$(debug_suffix)%s" % (target_ext
)
98 print ' if not exist $(temp_dir)\. mkdir $(temp_dir)'
102 libs
= ["shell32.lib", "comdlg32.lib", "wsock32.lib", "user32.lib", "oleaut32.lib"]
103 for moddefn
in moddefns
:
104 print "# Module", moddefn
.name
105 for file in moddefn
.sourceFiles
:
106 base
= os
.path
.basename(file)
107 base
, ext
= os
.path
.splitext(base
)
108 objects
.append(base
+ ".obj")
109 print '$(temp_dir)\%s.obj: "%s"' % (base
, file)
110 print "\t@$(CC) -c -nologo /Fo$* $(cdl) $(c_debug) /D BUILD_FREEZE",
111 print '"-I$(pythonhome)/Include" "-I$(pythonhome)/PC" \\'
112 print "\t\t$(cflags) $(cdebug) $(cinclude) \\"
113 extra
= moddefn
.GetCompilerOptions()
115 print "\t\t%s \\" % (' '.join(extra
),)
116 print '\t\t"%s"' % file
119 # Add .lib files this module needs
120 for modlib
in moddefn
.GetLinkerLibs():
121 if modlib
not in libs
:
124 print "ADDN_LINK_FILES=",
125 for addn
in vars['addn_link']: print '"%s"' % (addn
),
129 for obj
in objects
: print '"$(temp_dir)\%s"' % (obj
),
133 for lib
in libs
: print '"%s"' % (lib
),
136 print "$(target)$(debug_suffix)%s: $(temp_dir) $(OBJS)" % (target_ext
)
137 print "\tlink -out:$(target)$(debug_suffix)%s %s" % (target_ext
, target_link_flags
),
140 print "\t$(ADDN_LINK_FILES) \\"
141 print "\t$(pythonlib) $(lcustom) $(l_debug)\\"
142 print "\t$(resources)"
145 print "\t-rm -f *.obj"
146 print "\t-rm -f $(target).exe"