From 76167fecc176186b07afa4006f2e32d81090fdac Mon Sep 17 00:00:00 2001 From: Jack Jansen Date: Fri, 15 Sep 2000 22:44:08 +0000 Subject: This will eventually evolve into a package that creates CodeWarrior projects from templates (for distutils, and possibly the standard extensions too). For now it generates a correct xml file based on sources/output/expfile, but that is about all. --- Mac/Lib/mkcwproject/mkcwproject.py | 82 +++ .../mkcwproject/template/template-allsources.xml | 7 + .../mkcwproject/template/template-grouplist.xml | 6 + .../mkcwproject/template/template-linkorder.xml | 5 + Mac/Lib/mkcwproject/template/template.prj.xml | 745 +++++++++++++++++++++ 5 files changed, 845 insertions(+) create mode 100644 Mac/Lib/mkcwproject/mkcwproject.py create mode 100644 Mac/Lib/mkcwproject/template/template-allsources.xml create mode 100644 Mac/Lib/mkcwproject/template/template-grouplist.xml create mode 100644 Mac/Lib/mkcwproject/template/template-linkorder.xml create mode 100644 Mac/Lib/mkcwproject/template/template.prj.xml diff --git a/Mac/Lib/mkcwproject/mkcwproject.py b/Mac/Lib/mkcwproject/mkcwproject.py new file mode 100644 index 0000000..7889b76 --- /dev/null +++ b/Mac/Lib/mkcwproject/mkcwproject.py @@ -0,0 +1,82 @@ +# First attempt at automatically generating CodeWarior projects +import os + +Error="gencwproject.Error" +# +# These templates are executed in-order. +# +TEMPLATELIST= [ + ("tmp_allsources", "file", "template-allsources.xml", "sources"), + ("tmp_linkorder", "file", "template-linkorder.xml", "sources"), + ("tmp_grouplist", "file", "template-grouplist.xml", "sources"), + ("tmp_projectxmldata", "file", "template.prj.xml", None) +] + +class ProjectBuilder: + def __init__(self, dict, templatelist=TEMPLATELIST, templatedir=None): + if templatedir == None: + try: + packagedir = os.path.split(__file__)[0] + except NameError: + packagedir = os.curdir + templatedir = os.path.join(packagedir, 'template') + if not os.path.exists(templatedir): + raise Error, "Cannot file templatedir" + self.dict = dict + self.templatelist = templatelist + self.templatedir = templatedir + + def generate(self): + for tmpl in self.templatelist: + self._generate_one_template(tmpl) + + def _generate_one_template(self, tmpl): + resultname, datasource, dataname, key = tmpl + result = '' + if key: + # This is a multi-element rule. Run for every item in dict[key] + if self.dict.has_key(key): + keyvalues = self.dict[key] + try: + if not type(keyvalues) in (type(()), type([])): + raise Error, "List or tuple expected for %s"%key + for curkeyvalue in keyvalues: + self.dict[key] = curkeyvalue + curkeyvalueresult = self._generate_one_value(datasource, dataname) + result = result + curkeyvalueresult + finally: + # Restore the list + self.dict[key] = keyvalues + else: + # Not a multi-element rule. Simply generate + result = self._generate_one_value(datasource, dataname) + # And store the result + self.dict[resultname] = result + + def _generate_one_value(self, datasource, dataname): + if datasource == 'file': + filepath = os.path.join(self.templatedir, dataname) + fp = open(filepath, "r") + format = fp.read() + elif datasource == 'string': + format = dataname + else: + raise Error, 'Datasource should be file or string, not %s'%datasource + return format % self.dict + +def _test(): + dict = { + "mac_projectxmlname" : "xxnew.prj.xml", + "mac_targetname" : "xxnew.ppc", + "mac_dllname" : "xxnew.ppc.slb", + "sources" : ["xxnewmodule.c"], + "mac_exportname" : "xxnew.prj.exp", + } + pb = ProjectBuilder(dict) + pb.generate() + fp = open(dict["mac_projectxmlname"], "w") + fp.write(dict["tmp_projectxmldata"]) + +if __name__ == '__main__': + _test() + diff --git a/Mac/Lib/mkcwproject/template/template-allsources.xml b/Mac/Lib/mkcwproject/template/template-allsources.xml new file mode 100644 index 0000000..5bca166 --- /dev/null +++ b/Mac/Lib/mkcwproject/template/template-allsources.xml @@ -0,0 +1,7 @@ + + Name + %(sources)s + MacOS + Text + + diff --git a/Mac/Lib/mkcwproject/template/template-grouplist.xml b/Mac/Lib/mkcwproject/template/template-grouplist.xml new file mode 100644 index 0000000..a05364a --- /dev/null +++ b/Mac/Lib/mkcwproject/template/template-grouplist.xml @@ -0,0 +1,6 @@ + + %(mac_targetname)s + Name + %(sources)s + MacOS + diff --git a/Mac/Lib/mkcwproject/template/template-linkorder.xml b/Mac/Lib/mkcwproject/template/template-linkorder.xml new file mode 100644 index 0000000..7f24a7c --- /dev/null +++ b/Mac/Lib/mkcwproject/template/template-linkorder.xml @@ -0,0 +1,5 @@ + + Name + %(sources)s + MacOS + diff --git a/Mac/Lib/mkcwproject/template/template.prj.xml b/Mac/Lib/mkcwproject/template/template.prj.xml new file mode 100644 index 0000000..c6e01e8 --- /dev/null +++ b/Mac/Lib/mkcwproject/template/template.prj.xml @@ -0,0 +1,745 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +]> + + + + %(mac_targetname)s + + + + UserSourceTrees + + + CustomColor1 + Red0 + Green39321 + Blue0 + + CustomColor2 + Red0 + Green32767 + Blue0 + + CustomColor3 + Red0 + Green32767 + Blue0 + + CustomColor4 + Red0 + Green32767 + Blue0 + + + + AlwaysSearchUserPathsfalse + InterpretDOSAndUnixPathstrue + UserSearchPaths + + SearchPath + Path: + PathFormatMacOS + PathRootProject + + Recursivetrue + HostFlagsAll + + + SearchPath + Path::: + PathFormatMacOS + PathRootProject + + Recursivetrue + HostFlagsAll + + + SystemSearchPaths + + SearchPath + Path::::GUSI2:include: + PathFormatMacOS + PathRootProject + + Recursivefalse + HostFlagsAll + + + SearchPath + Path:MSL: + PathFormatMacOS + PathRootCodeWarrior + + Recursivetrue + HostFlagsAll + + + SearchPath + Path:MacOS Support: + PathFormatMacOS + PathRootCodeWarrior + + Recursivetrue + HostFlagsAll + + + + + LinkerMacOS PPC Linker + PreLinker + PostLinker + Targetname%(mac_targetname)s + OutputDirectory + Path::PlugIns: + PathFormatMacOS + PathRootProject + + SaveEntriesUsingRelativePathsfalse + + + FileMappings + + FileTypeAPPL + FileExtension + Compiler + Precompilefalse + Launchabletrue + ResourceFiletrue + IgnoredByMakefalse + + + FileTypeAppl + FileExtension + Compiler + Precompilefalse + Launchabletrue + ResourceFiletrue + IgnoredByMakefalse + + + FileTypeMMLB + FileExtension + CompilerLib Import PPC + Precompilefalse + Launchablefalse + ResourceFilefalse + IgnoredByMakefalse + + + FileTypeMPLF + FileExtension + CompilerLib Import PPC + Precompilefalse + Launchablefalse + ResourceFilefalse + IgnoredByMakefalse + + + FileTypeMWCD + FileExtension + Compiler + Precompilefalse + Launchabletrue + ResourceFiletrue + IgnoredByMakefalse + + + FileTypeRSRC + FileExtension + Compiler + Precompilefalse + Launchabletrue + ResourceFiletrue + IgnoredByMakefalse + + + FileTypeTEXT + FileExtension.bh + CompilerBalloon Help + Precompilefalse + Launchablefalse + ResourceFilefalse + IgnoredByMakefalse + + + FileTypeTEXT + FileExtension.c + CompilerMW C/C++ PPC + Precompilefalse + Launchablefalse + ResourceFilefalse + IgnoredByMakefalse + + + FileTypeTEXT + FileExtension.c++ + CompilerMW C/C++ PPC + Precompilefalse + Launchablefalse + ResourceFilefalse + IgnoredByMakefalse + + + FileTypeTEXT + FileExtension.cc + CompilerMW C/C++ PPC + Precompilefalse + Launchablefalse + ResourceFilefalse + IgnoredByMakefalse + + + FileTypeTEXT + FileExtension.cp + CompilerMW C/C++ PPC + Precompilefalse + Launchablefalse + ResourceFilefalse + IgnoredByMakefalse + + + FileTypeTEXT + FileExtension.cpp + CompilerMW C/C++ PPC + Precompilefalse + Launchablefalse + ResourceFilefalse + IgnoredByMakefalse + + + FileTypeTEXT + FileExtension.exp + Compiler + Precompilefalse + Launchablefalse + ResourceFilefalse + IgnoredByMakefalse + + + FileTypeTEXT + FileExtension.h + CompilerMW C/C++ PPC + Precompilefalse + Launchablefalse + ResourceFilefalse + IgnoredByMaketrue + + + FileTypeTEXT + FileExtension.p + CompilerMW Pascal PPC + Precompilefalse + Launchablefalse + ResourceFilefalse + IgnoredByMakefalse + + + FileTypeTEXT + FileExtension.pas + CompilerMW Pascal PPC + Precompilefalse + Launchablefalse + ResourceFilefalse + IgnoredByMakefalse + + + FileTypeTEXT + FileExtension.pch + CompilerMW C/C++ PPC + Precompiletrue + Launchablefalse + ResourceFilefalse + IgnoredByMakefalse + + + FileTypeTEXT + FileExtension.pch++ + CompilerMW C/C++ PPC + Precompiletrue + Launchablefalse + ResourceFilefalse + IgnoredByMakefalse + + + FileTypeTEXT + FileExtension.r + CompilerMW Rez + Precompilefalse + Launchablefalse + ResourceFilefalse + IgnoredByMakefalse + + + FileTypeTEXT + FileExtension.s + CompilerPPCAsm + Precompilefalse + Launchablefalse + ResourceFilefalse + IgnoredByMakefalse + + + FileTypeXCOF + FileExtension + CompilerXCOFF Import PPC + Precompilefalse + Launchablefalse + ResourceFilefalse + IgnoredByMakefalse + + + FileTypedocu + FileExtension + Compiler + Precompilefalse + Launchabletrue + ResourceFiletrue + IgnoredByMakefalse + + + FileTypersrc + FileExtension + Compiler + Precompilefalse + Launchabletrue + ResourceFiletrue + IgnoredByMakefalse + + + FileTypeshlb + FileExtension + CompilerPEF Import PPC + Precompilefalse + Launchablefalse + ResourceFilefalse + IgnoredByMakefalse + + + FileTypestub + FileExtension + CompilerPEF Import PPC + Precompilefalse + Launchablefalse + ResourceFilefalse + IgnoredByMakefalse + + + FileExtension.doc + Compiler + Precompilefalse + Launchabletrue + ResourceFilefalse + IgnoredByMaketrue + + + + + CacheModDatestrue + ActivateBrowserfalse + DumpBrowserInfofalse + CacheSubprojectstrue + UseThirdPartyDebuggerfalse + DebuggerCommandLine + Debugger Runtime + 0002000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000000000000000000000000 + + + + LogSystemMessagestrue + AutoTargetDLLsfalse + StopAtWatchpointstrue + PauseWhileRunningfalse + PauseInterval5 + PauseUIFlags0 + AltExePath + Path + PathFormatGeneric + PathRootAbsolute + + StopAtTempBPOnLaunchtrue + CacheSymbolicstrue + TempBPFunctionNamemain + TempBPTypefalse + + + MWCodeGen_68K_codesizeSmart + MWCodeGen_68K_structalignmentMC68K + MWCodeGen_68K_fp_modeSANE + MWCodeGen_68K_code680200 + MWCodeGen_68K_profiler0 + MWCodeGen_68K_mpwc0 + MWCodeGen_68K_fourbyteints0 + MWCodeGen_68K_IEEEdoubles0 + MWCodeGen_68K_fardata0 + MWCodeGen_68K_farvtables0 + MWCodeGen_68K_farstrings0 + MWCodeGen_68K_pcrelstrings0 + MWCodeGen_68K_macsbugNew + MWCodeGen_68K_a6frames1 + + + MWDisassembler_68K_showcode1 + MWDisassembler_68K_mix0 + MWDisassembler_68K_nohex0 + MWDisassembler_68K_showdata1 + MWDisassembler_68K_showexceptions1 + MWDisassembler_68K_showsym0 + MWDisassembler_68K_shownames1 + + + GlobalOptimizer_68K_optimizationlevelLevel0 + GlobalOptimizer_68K_optforSpeed + + + MWLinker_68K_linksym1 + MWLinker_68K_symfullpath1 + MWLinker_68K_linksingle0 + MWLinker_68K_fastlink1 + MWLinker_68K_generateMap0 + MWLinker_68K_nolinkwarnings0 + MWLinker_68K_glueintosegone1 + MWLinker_68K_dontdeadstripinitcode0 + + + MWProject_68K_typeApplication + MWProject_68K_outfile + MWProject_68K_symfilename + MWProject_68K_filecreator1061109567 + MWProject_68K_filetype1095782476 + MWProject_68K_size384 + MWProject_68K_flags22656 + MWProject_68K_rsrcheaderStandard + MWProject_68K_rsrcname + MWProject_68K_rsrctype1061109567 + MWProject_68K_rsrcid0 + MWProject_68K_rsrcmulti0 + MWProject_68K_rsrcstore0 + MWProject_68K_rsrcmerge0 + MWProject_68K_rsrcflags0 + MWProject_68K_a40 + MWProject_68K_minsize384 + MWProject_68K_rsrcsegtype0 + MWProject_68K_cfm68kcodegen0 + MWProject_68K_stacksize0 + MWProject_68K_thedebugger0 + MWProject_68K_rsrc_custom0 + MWProject_68K_is_rseg_app0 + MWProject_68K_is_pilot_lib0 + MWProject_68K_pilot_main_entry + + + MWFrontEnd_C_cplusplus0 + MWFrontEnd_C_checkprotos0 + MWFrontEnd_C_arm0 + MWFrontEnd_C_trigraphs0 + MWFrontEnd_C_onlystdkeywords0 + MWFrontEnd_C_enumsalwaysint0 + MWFrontEnd_C_mpwpointerstyle0 + MWFrontEnd_C_prefixnamemwerks_plugin_config.h + MWFrontEnd_C_ansistrict0 + MWFrontEnd_C_mpwcnewline0 + MWFrontEnd_C_wchar_type1 + MWFrontEnd_C_enableexceptions1 + MWFrontEnd_C_dontreusestrings0 + MWFrontEnd_C_poolstrings1 + MWFrontEnd_C_dontinline0 + MWFrontEnd_C_useRTTI0 + MWFrontEnd_C_multibyteaware0 + MWFrontEnd_C_unsignedchars0 + MWFrontEnd_C_autoinline0 + MWFrontEnd_C_booltruefalse0 + MWFrontEnd_C_direct_to_som0 + MWFrontEnd_C_som_env_check0 + MWFrontEnd_C_alwaysinline0 + MWFrontEnd_C_inlinelevel0 + MWFrontEnd_C_ecplusplus0 + MWFrontEnd_C_objective_c0 + MWFrontEnd_C_defer_codegen0 + + + MWWarning_C_warn_illpragma0 + MWWarning_C_warn_emptydecl0 + MWWarning_C_warn_possunwant0 + MWWarning_C_warn_unusedvar0 + MWWarning_C_warn_unusedarg0 + MWWarning_C_warn_extracomma0 + MWWarning_C_pedantic0 + MWWarning_C_warningerrors0 + MWWarning_C_warn_hidevirtual0 + MWWarning_C_warn_implicitconv0 + MWWarning_C_warn_notinlined0 + MWWarning_C_warn_structclass0 + + + MWCFM68K_exportsNone + MWCFM68K_olddefversion0 + MWCFM68K_oldimpversion0 + MWCFM68K_currentversion0 + MWCFM68K_farthreshold256 + PCFM68K_sharedata0 + MWCFM68K_fragmentname + MWCFM68K_initname + MWCFM68K_mainname__start + MWCFM68K_termname + MWCFM68K_libfolder0 + MWCFM68K_alignmentAlign_2 + + + MWMerge_MacOS_projectTypeApplication + MWMerge_MacOS_outputNameMerge Out + MWMerge_MacOS_outputCreator1061109567 + MWMerge_MacOS_outputType1095782476 + MWMerge_MacOS_suppressWarning0 + MWMerge_MacOS_copyFragments1 + MWMerge_MacOS_copyResources1 + MWMerge_MacOS_skipResources + + øƒ + þ^h + ‹ß0 + + + + MWCodeGen_PPC_structalignmentPPC + MWCodeGen_PPC_tracebacktablesNone + MWCodeGen_PPC_processorP601 + MWCodeGen_PPC_readonlystrings1 + MWCodeGen_PPC_tocdata1 + MWCodeGen_PPC_profiler0 + MWCodeGen_PPC_fpcontract1 + MWCodeGen_PPC_schedule1 + MWCodeGen_PPC_peephole1 + MWCodeGen_PPC_processorspecific0 + MWCodeGen_PPC_altivec0 + MWCodeGen_PPC_vectortocdata0 + MWCodeGen_PPC_vrsave0 + + + MWDisassembler_PPC_showcode1 + MWDisassembler_PPC_extended1 + MWDisassembler_PPC_mix0 + MWDisassembler_PPC_nohex0 + MWDisassembler_PPC_showdata1 + MWDisassembler_PPC_showexceptions1 + MWDisassembler_PPC_showsym0 + MWDisassembler_PPC_shownames1 + + + GlobalOptimizer_PPC_optimizationlevelLevel0 + GlobalOptimizer_PPC_optforSpeed + + + MWLinker_PPC_linksym1 + MWLinker_PPC_symfullpath1 + MWLinker_PPC_linkmap0 + MWLinker_PPC_nolinkwarnings0 + MWLinker_PPC_dontdeadstripinitcode0 + MWLinker_PPC_permitmultdefs0 + MWLinker_PPC_linkmodeFast + MWLinker_PPC_initname__initialize + MWLinker_PPC_mainname + MWLinker_PPC_termname__terminate + + + MWPEF_exportsFile + MWPEF_libfolder0 + MWPEF_sortcodeNone + MWPEF_expandbss0 + MWPEF_sharedata0 + MWPEF_olddefversion0 + MWPEF_oldimpversion0 + MWPEF_currentversion0 + MWPEF_fragmentname + MWPEF_collapsereloads0 + + + MWProject_PPC_typeSharedLibrary + MWProject_PPC_outfile%(mac_dllname)s + MWProject_PPC_filecreator1350136936 + MWProject_PPC_filetype1936223330 + MWProject_PPC_size0 + MWProject_PPC_minsize0 + MWProject_PPC_stacksize0 + MWProject_PPC_flags0 + MWProject_PPC_symfilename + MWProject_PPC_rsrcname + MWProject_PPC_rsrcheaderNative + MWProject_PPC_rsrctype1061109567 + MWProject_PPC_rsrcid0 + MWProject_PPC_rsrcflags0 + MWProject_PPC_rsrcstore0 + MWProject_PPC_rsrcmerge0 + + + MWAssembler_PPC_auxheader0 + MWAssembler_PPC_symmodeMac + MWAssembler_PPC_dialectPPC + MWAssembler_PPC_prefixfile + MWAssembler_PPC_typecheck0 + MWAssembler_PPC_warnings0 + MWAssembler_PPC_casesensitive0 + + + MWRez_Language_maxwidth80 + MWRez_Language_scriptRoman + MWRez_Language_alignmentAlign1 + MWRez_Language_filtermodeFilterSkip + MWRez_Language_suppresswarnings0 + MWRez_Language_escapecontrolchars1 + MWRez_Language_prefixname + MWRez_Language_filteredtypes'CODE' 'DATA' 'PICT' + + +%(tmp_allsources)s + + Name + MSL ShLibRuntime.Lib + MacOS + Library + Debug + + + Name + %(mac_exportname)s + MacOS + Text + Debug + + + Name + PythonCore + MacOS + Library + Debug + + + +%(tmp_linkorder)s + + Name + MSL ShLibRuntime.Lib + MacOS + + + Name + %(mac_exportname)s + MacOS + + + Name + PythonCore + MacOS + + + + + + + %(mac_targetname)s + + + + Sources +%(tmp_grouplist)s + + %(mac_targetname)s + Name + %(mac_exportname)s + MacOS + + + Libraries + + %(mac_targetname)s + Name + MSL ShLibRuntime.Lib + MacOS + + + %(mac_targetname)s + Name + PythonCore + MacOS + + + + + -- cgit v0.12