2000-09-22 23:26:55 +00:00
|
|
|
import cwxmlgen
|
|
|
|
import cwtalker
|
2000-09-22 23:54:07 +00:00
|
|
|
import os
|
|
|
|
import AppleEvents
|
|
|
|
import macfs
|
2000-09-22 23:26:55 +00:00
|
|
|
|
|
|
|
def mkproject(outputfile, modulename, settings):
|
|
|
|
#
|
|
|
|
# Copy the dictionary
|
|
|
|
#
|
|
|
|
dictcopy = {}
|
|
|
|
for k, v in settings.items():
|
|
|
|
dictcopy[k] = v
|
|
|
|
#
|
|
|
|
# Fill in mac-specific values
|
|
|
|
#
|
|
|
|
dictcopy['mac_projectxmlname'] = outputfile + '.xml'
|
|
|
|
dictcopy['mac_exportname'] = os.path.split(outputfile)[1] + '.exp'
|
2000-12-03 22:39:09 +00:00
|
|
|
if not dictcopy.has_key('mac_outputdir'):
|
|
|
|
dictcopy['mac_outputdir'] = ':lib:'
|
2000-09-22 23:26:55 +00:00
|
|
|
dictcopy['mac_dllname'] = modulename + '.ppc.slb'
|
|
|
|
dictcopy['mac_targetname'] = modulename + '.ppc'
|
2000-09-22 23:54:07 +00:00
|
|
|
if os.path.isabs(dictcopy['sysprefix']):
|
2000-09-22 23:26:55 +00:00
|
|
|
dictcopy['mac_sysprefixtype'] = 'Absolute'
|
|
|
|
else:
|
|
|
|
dictcopy['mac_sysprefixtype'] = 'Project' # XXX not sure this is right...
|
|
|
|
#
|
|
|
|
# Generate the XML for the project
|
|
|
|
#
|
|
|
|
xmlbuilder = cwxmlgen.ProjectBuilder(dictcopy)
|
|
|
|
xmlbuilder.generate()
|
|
|
|
fp = open(dictcopy['mac_projectxmlname'], "w")
|
2000-09-22 23:54:07 +00:00
|
|
|
fp.write(dictcopy["tmp_projectxmldata"])
|
2000-09-22 23:26:55 +00:00
|
|
|
fp.close()
|
|
|
|
#
|
|
|
|
# Generate the export file
|
|
|
|
#
|
|
|
|
fp = open(outputfile + '.exp', 'w')
|
|
|
|
fp.write('init%s\n'%modulename)
|
2000-12-03 22:39:09 +00:00
|
|
|
if dictcopy.has_key('extraexportsymbols'):
|
|
|
|
for sym in dictcopy['extraexportsymbols']:
|
|
|
|
fp.write('%s\n'%sym)
|
2000-09-22 23:26:55 +00:00
|
|
|
fp.close()
|
|
|
|
#
|
|
|
|
# Generate the project from the xml
|
|
|
|
#
|
2000-09-24 21:56:43 +00:00
|
|
|
makeproject(dictcopy['mac_projectxmlname'], outputfile)
|
|
|
|
|
|
|
|
def makeproject(xmlfile, projectfile):
|
2000-09-22 23:26:55 +00:00
|
|
|
cw = cwtalker.MyCodeWarrior(start=1)
|
|
|
|
cw.send_timeout = AppleEvents.kNoTimeOut
|
2000-09-24 21:56:43 +00:00
|
|
|
xmlfss = macfs.FSSpec(xmlfile)
|
|
|
|
prjfss = macfs.FSSpec(projectfile)
|
2000-09-22 23:54:07 +00:00
|
|
|
cw.activate()
|
2000-09-22 23:26:55 +00:00
|
|
|
cw.my_mkproject(prjfss, xmlfss)
|
|
|
|
|
|
|
|
def buildproject(projectfile):
|
|
|
|
cw = cwtalker.MyCodeWarrior(start=1)
|
|
|
|
cw.send_timeout = AppleEvents.kNoTimeOut
|
|
|
|
prjfss = macfs.FSSpec(projectfile)
|
|
|
|
cw.open(prjfss)
|
|
|
|
cw.Make_Project() # XXX Should set target
|
2000-11-19 21:51:06 +00:00
|
|
|
cw.Close_Project()
|
2000-09-22 23:26:55 +00:00
|
|
|
|
|
|
|
def cleanproject(projectfile):
|
|
|
|
cw = cwtalker.MyCodeWarrior(start=1)
|
|
|
|
cw.send_timeout = AppleEvents.kNoTimeOut
|
|
|
|
prjfss = macfs.FSSpec(projectfile)
|
|
|
|
cw.open(prjfss)
|
|
|
|
cw.Remove_Binaries()
|
|
|
|
|