fpmkunitsrc.inc 193 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499
  1. {$ifdef Delphi}
  2. const fpmkunitsrc : array[0..599] of string[240]=(
  3. {$else Delphi}
  4. const fpmkunitsrc : array[0..599,1..240] of char=(
  5. {$endif Delphi}
  6. '{'#010+
  7. ' This file is part of the Free Pascal Makefile Package'#010+
  8. #010+
  9. ' Implementation of fpmake classes and functions'#010+
  10. #010+
  11. ' Copyright (c) 2007 by the freepascal team'#010+
  12. #010+
  13. ' See the file COPYING.FPC, included in this distribution,'#010+
  14. ' for details abo','ut the copyright.'#010+
  15. #010+
  16. ' This program is distributed in the hope that it will be useful,'#010+
  17. ' but WITHOUT ANY WARRANTY; without even the implied warranty of'#010+
  18. ' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.'#010+
  19. #010+
  20. ' ***************************','****************************************'+
  21. '***}'#010+
  22. #010+
  23. 'unit fpmkunit;'#010+
  24. #010+
  25. '{$Mode objfpc}'#010+
  26. '{$H+}'#010+
  27. '{$inline on}'#010+
  28. #010+
  29. '{ For target or cpu dependent dependencies add also an overload were y'+
  30. 'ou'#010+
  31. ' can pass only a set of cpus. This is disabled for now because it cre',
  32. 'ates'#010+
  33. ' an error in the compiler with overload choosing }'#010+
  34. '{ define cpu_only_overloads}'#010+
  35. #010+
  36. 'Interface'#010+
  37. #010+
  38. '{$ifndef NO_UNIT_PROCESS}'#010+
  39. ' {$define HAS_UNIT_PROCESS}'#010+
  40. '{$endif NO_UNIT_PROCESS}'#010+
  41. #010+
  42. '{$ifndef NO_UNIT_ZIPPER}'#010+
  43. ' {$define HAS_UNIT_ZIPPER}'#010+
  44. '{$endif ','NO_UNIT_ZIPPER}'#010+
  45. #010+
  46. 'uses'#010+
  47. ' SysUtils, Classes, StrUtils'#010+
  48. '{$ifdef HAS_UNIT_PROCESS}'#010+
  49. ' ,process'#010+
  50. '{$endif HAS_UNIT_PROCESS}'#010+
  51. '{$ifdef HAS_UNIT_ZIPPER}'#010+
  52. ' ,zipper'#010+
  53. '{$endif HAS_UNIT_ZIPPER}'#010+
  54. ' ;'#010+
  55. #010+
  56. 'Type'#010+
  57. ' TFileType = (ftSource,ftUnit,ftObject,ftResource,ftEx','ecutable,ftSt'+
  58. 'aticLibrary,'#010+
  59. ' ftSharedLibrary);'#010+
  60. ' TFileTypes = set of TFileType;'#010+
  61. #010+
  62. ' // Please keep this order, see OSCPUSupported below'#010+
  63. ' TCpu=(cpuNone,'#010+
  64. ' i386,m68k,powerpc,sparc,x86_64,arm,powerpc64,avr,armeb'#010+
  65. ' );'#010+
  66. ' TCPUS = Se','t of TCPU;'#010+
  67. #010+
  68. ' // Please keep this order, see OSCPUSupported below'#010+
  69. ' TOS=(osNone,'#010+
  70. ' linux,go32v2,win32,os2,freebsd,beos,netbsd,'#010+
  71. ' amiga,atari, solaris, qnx, netware, openbsd,wdosx,'#010+
  72. ' palmos,macos,darwin,emx,watcom,morphos,netwlibc,'#010+
  73. ' ',' win64,wince,gba,nds,embedded,symbian'#010+
  74. ' );'#010+
  75. ' TOSes = Set of TOS;'#010+
  76. #010+
  77. ' TCompilerMode = (cmFPC,cmTP,cmObjFPC,cmDelphi,cmMacPas);'#010+
  78. ' TCompilerModes = Set of TCompilerMode;'#010+
  79. #010+
  80. ' TTargetType = (ttProgram,ttUnit,ttImplicitUnit,ttCleanOnlyUnit,ttExa'+
  81. 'mpl','eUnit,ttExampleProgram);'#010+
  82. ' TTargetTypes = set of TTargetType;'#010+
  83. #010+
  84. ' TTargetState = (tsNeutral,tsConsidering,tsNoCompile,tsCompiled,tsIns'+
  85. 'talled,tsNotFound);'#010+
  86. ' TTargetStates = Set of TTargetState;'#010+
  87. #010+
  88. ' TSourceType = (stDoc,stSrc,stExample,stTest);',#010+
  89. ' TSourceTypes = set of TSourceType;'#010+
  90. #010+
  91. ' TVerboseLevel = (vlError,vlWarning,vlInfo,vldebug,vlCommand);'#010+
  92. ' TVerboseLevels = Set of TVerboseLevel;'#010+
  93. #010+
  94. ' TCommandAt = (caBeforeCompile,caAfterCompile,'#010+
  95. ' caBeforeInstall,caAfterInstall,',#010+
  96. ' caBeforeArchive,caAfterArchive,'#010+
  97. ' caBeforeClean,caAfterClean,'#010+
  98. ' caBeforeDownload,caAfterDownload);'#010+
  99. #010+
  100. ' TDependencyType = (depPackage,depImplicitPackage,depUnit,depInclude)'+
  101. ';'#010+
  102. ' TDependencyTypes = se','t of TDependencyType;'#010+
  103. #010+
  104. ' TLogEvent = Procedure (Level : TVerboseLevel; Const Msg : String) of'+
  105. ' Object;'#010+
  106. #010+
  107. ' TRunMode = (rmCompile,rmBuild,rmInstall,rmArchive,rmClean,rmManifest'+
  108. ');'#010+
  109. #010+
  110. 'Const'#010+
  111. ' // Aliases'#010+
  112. ' Amd64 = X86_64;'#010+
  113. ' PPC = PowerPC;'#010+
  114. ' PPC64',' = PowerPC64;'#010+
  115. ' DOS = Go32v2;'#010+
  116. ' MacOSX = Darwin;'#010+
  117. #010+
  118. ' AllOSes = [Low(TOS)..High(TOS)];'#010+
  119. ' AllCPUs = [Low(TCPU)..High(TCPU)];'#010+
  120. ' AllUnixOSes = [Linux,FreeBSD,NetBSD,OpenBSD,Darwin,QNX,BeOS,Solaris'+
  121. '];'#010+
  122. ' AllBSDOSes = [FreeBSD,NetBSD,OpenBSD,D','arwin];'#010+
  123. ' AllWindowsOSes = [Win32,Win64,WinCE];'#010+
  124. #010+
  125. ' { This table is kept OS,Cpu because it is easier to maintain (PFV) }'+
  126. #010+
  127. ' OSCPUSupported : array[TOS,TCpu] of boolean = ('#010+
  128. ' { os none i386 m68k ppc sparc x86_64 arm pp',
  129. 'c64 avr armeb}'#010+
  130. ' { none } ( false, false, false, false, false, false, false, fal'+
  131. 'se, false, false),'#010+
  132. ' { linux } ( false, true, true, true, true, true, true, tru'+
  133. 'e, false, true ),'#010+
  134. ' { go32v2 } ( false, true, false, fals','e, false, false, false, f'+
  135. 'alse, false, false),'#010+
  136. ' { win32 } ( false, true, false, false, false, false, false, fal'+
  137. 'se, false, false),'#010+
  138. ' { os2 } ( false, true, false, false, false, false, false, fal'+
  139. 'se, false, false),'#010+
  140. ' { freebsd } ','( false, true, true, false, false, true, false, f'+
  141. 'alse, false, false),'#010+
  142. ' { beos } ( false, true, false, false, false, false, false, fal'+
  143. 'se, false, false),'#010+
  144. ' { netbsd } ( false, true, true, true, true, false, false, fal'+
  145. 'se, fals','e, false),'#010+
  146. ' { amiga } ( false, false, true, true, false, false, false, fal'+
  147. 'se, false, false),'#010+
  148. ' { atari } ( false, false, true, false, false, false, false, fal'+
  149. 'se, false, false),'#010+
  150. ' { solaris } ( false, true, false, false, true,',' false, false, f'+
  151. 'alse, false, false),'#010+
  152. ' { qnx } ( false, true, false, false, false, false, false, fal'+
  153. 'se, false, false),'#010+
  154. ' { netware } ( false, true, false, false, false, false, false, fal'+
  155. 'se, false, false),'#010+
  156. ' { openbsd } ( false,',' true, true, false, false, false, false, f'+
  157. 'alse, false, false),'#010+
  158. ' { wdosx } ( false, true, false, false, false, false, false, fal'+
  159. 'se, false, false),'#010+
  160. ' { palmos } ( false, false, true, false, false, false, true, fal'+
  161. 'se, false, false','),'#010+
  162. ' { macos } ( false, false, false, true, false, false, false, fal'+
  163. 'se, false, false),'#010+
  164. ' { darwin } ( false, true, false, true, false, true, true, tru'+
  165. 'e, false, false),'#010+
  166. ' { emx } ( false, true, false, false, false, false,',' false, f'+
  167. 'alse, false, false),'#010+
  168. ' { watcom } ( false, true, false, false, false ,false, false, fal'+
  169. 'se, false, false),'#010+
  170. ' { morphos } ( false, false, false, true, false ,false, false, fal'+
  171. 'se, false, false),'#010+
  172. ' { netwlibc }( false, true, ','false, false, false, false, false, f'+
  173. 'alse, false, false),'#010+
  174. ' { win64 } ( false, false, false, false, false, true, false, fal'+
  175. 'se, false, false),'#010+
  176. ' { wince }( false, true, false, false, false, false, true, fal'+
  177. 'se, false, false),'#010+
  178. ' {',' gba } ( false, false, false, false, false, false, true, f'+
  179. 'alse, false, false),'#010+
  180. ' { nds } ( false, false, false, false, false, false, true, fal'+
  181. 'se, false, false),'#010+
  182. ' { embedded }( false, true, true, true, true, true, true, ','t'+
  183. 'rue, true, true ),'#010+
  184. ' { symbian } ( false, true, false, false, false, false, true, fal'+
  185. 'se, false, false)'#010+
  186. ' );'#010+
  187. #010+
  188. ' // Useful'#010+
  189. ' UnitExt = '#039'.ppu'#039';'#010+
  190. ' PPUExt = UnitExt;'#010+
  191. ' PasExt = '#039'.pas'#039';'#010+
  192. ' PPExt = '#039'.pp'#039';'#010+
  193. ' IncExt = '#039'.inc'#039';'#010+
  194. ' ObjExt = ',#039'.o'#039';'#010+
  195. ' RstExt = '#039'.rst'#039';'#010+
  196. ' LibExt = '#039'.a'#039';'#010+
  197. ' SharedLibExt = '#039'.so'#039';'#010+
  198. ' DLLExt = '#039'.dll'#039';'#010+
  199. ' ExeExt = '#039'.exe'#039';'#010+
  200. ' ZipExt = '#039'.zip'#039';'#010+
  201. #010+
  202. ' FPMakePPFile = '#039'fpmake.pp'#039';'#010+
  203. ' ManifestFile = '#039'manifest.xml'#039';'#010+
  204. ' UnitConfigFile = '#039'fpunits.conf'#039';'#010+
  205. #010+
  206. ' DirNotFoun','d = '#039'<dirnotfound>'#039';'#010+
  207. #010+
  208. ' UnitTargets = [ttUnit,ttImplicitUnit,ttCleanOnlyUnit,ttExampleUnit];'+
  209. #010+
  210. ' ProgramTargets = [ttProgram,ttExampleProgram];'#010+
  211. #010+
  212. ' DefaultMessages = [vlError,vlWarning,vlCommand];'#010+
  213. ' AllMessages = [vlError,vlWarning,vlCommand,v','lInfo];'#010+
  214. #010+
  215. #010+
  216. 'Type'#010+
  217. ' { TNamedItem }'#010+
  218. #010+
  219. ' TNamedItem = Class(TCollectionItem)'#010+
  220. ' private'#010+
  221. ' FName: String;'#010+
  222. ' procedure SetName(const AValue: String);virtual;'#010+
  223. ' Public'#010+
  224. ' property Name : String Read FName Write SetName;'#010+
  225. ' end;'#010+
  226. #010+
  227. ' { TNamedCollect','ion }'#010+
  228. #010+
  229. ' TNamedCollection = Class(TCollection)'#010+
  230. ' private'#010+
  231. ' FUniqueNames: Boolean;'#010+
  232. ' Public'#010+
  233. ' Function IndexOfName(const AName : String) : Integer;'#010+
  234. ' Function ItemByName(const AName : String) : TNamedItem;'#010+
  235. ' Property UniqueNames : Bo','olean Read FUniqueNames;'#010+
  236. ' end;'#010+
  237. #010+
  238. ' { TNamedItemList }'#010+
  239. #010+
  240. ' TNamedItemList = Class(TFPList)'#010+
  241. ' private'#010+
  242. ' function GetNamedItem(Index : Integer): TNamedItem;'#010+
  243. ' procedure SetNamedItem(Index : Integer; const AValue: TNamedItem);'+
  244. #010+
  245. ' public'#010+
  246. ' F','unction IndexOfName(const AName : String) : Integer;'#010+
  247. ' Function ItemByName(const ANAme : String) : TNamedItem;'#010+
  248. ' Property NamedItems[Index : Integer] : TNamedItem Read GetNamedIte'+
  249. 'm Write SetNamedItem; default;'#010+
  250. ' end;'#010+
  251. #010+
  252. ' { TCommand }'#010+
  253. ' T','Command = Class(TNamedItem)'#010+
  254. ' private'#010+
  255. ' FAfterCommand: TNotifyEvent;'#010+
  256. ' FBeforeCommand: TNotifyEvent;'#010+
  257. ' FCommand: String;'#010+
  258. ' FCommandAt: TCommandAt;'#010+
  259. ' FDestFile: String;'#010+
  260. ' FIgnoreResult: Boolean;'#010+
  261. ' FOptions: String;'#010+
  262. ' FSourceF','ile: String;'#010+
  263. ' Public'#010+
  264. ' Property SourceFile : String Read FSourceFile Write FSourceFile;'#010+
  265. ' Property DestFile : String Read FDestFile Write FDestFile;'#010+
  266. ' Property Command : String Read FCommand Write FCommand;'#010+
  267. ' Property Options : Str','ing Read FOptions Write FOptions;'#010+
  268. ' Property At : TCommandAt Read FCommandAt Write FCommandAt;'#010+
  269. ' Property IgnoreResult : Boolean Read FIgnoreResult Write FIgnoreRe'+
  270. 'sult;'#010+
  271. ' Property BeforeCommand : TNotifyEvent Read FBeforeCommand Write',' '+
  272. 'FBeforeCommand;'#010+
  273. ' Property AfterCommand : TNotifyEvent Read FAfterCommand Write FAft'+
  274. 'erCommand;'#010+
  275. ' end;'#010+
  276. #010+
  277. ' { TCommands }'#010+
  278. #010+
  279. ' TCommands = Class(TNamedCollection)'#010+
  280. ' private'#010+
  281. ' FDefaultAt: TCommandAt;'#010+
  282. ' function GetCommand(const Dest : Stri','ng): TCommand;'#010+
  283. ' function GetCommandItem(Index : Integer): TCommand;'#010+
  284. ' procedure SetCommandItem(Index : Integer; const AValue: TCommand);'+
  285. #010+
  286. ' Public'#010+
  287. ' Function AddCommand(Const Cmd : String) : TCommand;'#010+
  288. ' Function AddCommand(Const Cmd',',Options : String) : TCommand;'#010+
  289. ' Function AddCommand(Const Cmd,Options,Dest,Source : String) : TCom'+
  290. 'mand;'#010+
  291. ' Function AddCommand(At : TCommandAt; Const Cmd : String) : TComman'+
  292. 'd;'#010+
  293. ' Function AddCommand(At : TCommandAt; Const Cmd,Options :',' String)'+
  294. ' : TCommand;'#010+
  295. ' Function AddCommand(At : TCommandAt; Const Cmd,Options, Dest,Sourc'+
  296. 'e : String) : TCommand;'#010+
  297. ' Property CommandItems[Index : Integer] : TCommand Read GetCommandI'+
  298. 'tem Write SetCommandItem;'#010+
  299. ' Property Commands[Dest : ','String] : TCommand Read GetCommand; def'+
  300. 'ault;'#010+
  301. ' Property DefaultAt : TCommandAt Read FDefaultAt Write FDefaultAt;'#010+
  302. ' end;'#010+
  303. #010+
  304. ' { TFPVersion }'#010+
  305. #010+
  306. ' TFPVersion = Class(TPersistent)'#010+
  307. ' private'#010+
  308. ' FMajor,'#010+
  309. ' FMinor,'#010+
  310. ' FMicro,'#010+
  311. ' FBuild : Wor','d;'#010+
  312. ' function GetAsString: String;'#010+
  313. ' function GetEmpty: Boolean;'#010+
  314. ' procedure SetAsString(const AValue: String);'#010+
  315. ' Public'#010+
  316. ' Procedure Clear;'#010+
  317. ' Procedure Assign(Source : TPersistent); override;'#010+
  318. ' Function CompareVersion(AVersion : TF','PVersion) : Integer;'#010+
  319. ' Function SameVersion(AVersion : TFPVersion) : Boolean;'#010+
  320. ' Property AsString : String Read GetAsString Write SetAsString;'#010+
  321. ' Property Empty : Boolean Read GetEmpty;'#010+
  322. ' Published'#010+
  323. ' Property Major : Word Read FMajor Wri','te FMajor;'#010+
  324. ' Property Minor : Word Read FMinor Write FMinor;'#010+
  325. ' Property Micro : Word Read FMicro Write FMicro;'#010+
  326. ' Property Build : Word Read FBuild Write FBuild;'#010+
  327. ' end;'#010+
  328. #010+
  329. ' { TConditionalString }'#010+
  330. ' TConditionalString = Class'#010+
  331. ' private'#010+
  332. ' ','FOSes : TOSes;'#010+
  333. ' FCPUs : TCPUs;'#010+
  334. ' FValue : String;'#010+
  335. ' Public'#010+
  336. ' Constructor Create;virtual;'#010+
  337. ' Property Value : String Read FValue Write FValue;'#010+
  338. ' Property OSes : TOSes Read FOSes Write FOSes;'#010+
  339. ' Property CPUs : TCPUs Read FCP','US Write FCPUs;'#010+
  340. ' end;'#010+
  341. #010+
  342. ' TConditionalStringClass = class of TConditionalString;'#010+
  343. #010+
  344. ' { TConditionalStrings }'#010+
  345. #010+
  346. ' TConditionalStrings = Class(TFPList)'#010+
  347. ' private'#010+
  348. ' FCSClass : TConditionalStringClass;'#010+
  349. ' function GetConditionalString(Index : ','Integer): TConditionalStri'+
  350. 'ng;'#010+
  351. ' procedure SetConditionalString(Index : Integer; const AValue: TCon'+
  352. 'ditionalString);'#010+
  353. ' Public'#010+
  354. ' Constructor Create(AClass:TConditionalStringClass);'#010+
  355. ' Function Add(Const Value : String) : TConditionalStrin','g;inline;'#010+
  356. ' Function Add(Const Value : String;const OSes:TOSes) : TConditional'+
  357. 'String;inline;'#010+
  358. '{$ifdef cpu_only_overloads}'#010+
  359. ' Function Add(Const Value : String;const CPUs:TCPUs) : TConditional'+
  360. 'String;inline;'#010+
  361. '{$endif cpu_only_overloads}'#010+
  362. ' ','Function Add(Const Value : String;const CPUs:TCPUs;const OSes:TO'+
  363. 'Ses) : TConditionalString;'#010+
  364. ' Property ConditionalStrings[Index : Integer] : TConditionalString '+
  365. 'Read GetConditionalString Write SetConditionalString; default;'#010+
  366. ' end;'#010+
  367. #010+
  368. ' { TDep','endency }'#010+
  369. ' TDependency = Class(TConditionalString)'#010+
  370. ' private'#010+
  371. ' FDependencyType : TDependencyType;'#010+
  372. ' // Package, Unit'#010+
  373. ' FTarget : TObject;'#010+
  374. ' FVersion : TFPVersion;'#010+
  375. ' FRequireChecksum : Cardinal;'#010+
  376. ' // Filenames, Includes'#010+
  377. ' FTar','getFileName : String;'#010+
  378. ' Function GetVersion : string;'#010+
  379. ' Procedure SetVersion(const V : string);'#010+
  380. ' Public'#010+
  381. ' Constructor Create;override;'#010+
  382. ' Destructor Destroy;override;'#010+
  383. ' Property Target : TObject Read FTarget Write FTarget;'#010+
  384. ' Pro','perty DependencyType : TDependencyType Read FDependencyType;'#010+
  385. ' Property TargetFileName : String Read FTargetFileName Write FTarge'+
  386. 'tFileName;'#010+
  387. ' Property Version : String Read GetVersion Write SetVersion;'#010+
  388. ' Property RequireChecksum : Car','dinal Read FRequireChecksum Write '+
  389. 'FRequireChecksum;'#010+
  390. ' end;'#010+
  391. #010+
  392. ' TDependencies = Class(TConditionalStrings)'#010+
  393. ' function GetDependency(Index : Integer): TDependency;'#010+
  394. ' procedure SetDependency(Index : Integer; const AValue: TDependency'+
  395. ');'#010+
  396. ' Pu','blic'#010+
  397. ' Function Add(Const Value : String) : TDependency;inline;'#010+
  398. ' Function Add(Const Value : String;const OSes:TOSes) : TDependency;'+
  399. 'inline;'#010+
  400. '{$ifdef cpu_only_overloads}'#010+
  401. ' Function Add(Const Value : String;const CPUs:TCPUs) : TDependenc','y'+
  402. ';inline;'#010+
  403. '{$endif cpu_only_overloads}'#010+
  404. ' Function Add(Const Value : String;const CPUs:TCPUs;const OSes:TOSe'+
  405. 's) : TDependency;'#010+
  406. ' Function AddUnit(Const Value : String) : TDependency;inline;'#010+
  407. ' Function AddUnit(Const Value : String;const O','Ses:TOSes) : TDepen'+
  408. 'dency;inline;'#010+
  409. '{$ifdef cpu_only_overloads}'#010+
  410. ' Function AddUnit(Const Value : String;const CPUs:TCPUs) : TDepende'+
  411. 'ncy;inline;'#010+
  412. '{$endif cpu_only_overloads}'#010+
  413. ' Function AddUnit(Const Value : String;const CPUs:TCPUs;const OSes',
  414. ':TOSes) : TDependency;'#010+
  415. ' Function AddInclude(Const Value : String) : TDependency;inline;'#010+
  416. ' Function AddInclude(Const Value : String;const OSes:TOSes) : TDepe'+
  417. 'ndency;inline;'#010+
  418. '{$ifdef cpu_only_overloads}'#010+
  419. ' Function AddInclude(Const Value ',': String;const CPUs:TCPUs) : TDe'+
  420. 'pendency;inline;'#010+
  421. '{$endif cpu_only_overloads}'#010+
  422. ' Function AddInclude(Const Value : String;const CPUs:TCPUs;const OS'+
  423. 'es:TOSes) : TDependency;'#010+
  424. ' Property Dependencies[Index : Integer] : TDependency Read GetDep','e'+
  425. 'ndency Write SetDependency; default;'#010+
  426. ' end;'#010+
  427. #010+
  428. ' { TTarget }'#010+
  429. #010+
  430. ' TTarget = Class(TNamedItem)'#010+
  431. ' private'#010+
  432. ' FInstall : Boolean;'#010+
  433. ' FAfterClean: TNotifyEvent;'#010+
  434. ' FAfterCompile: TNotifyEvent;'#010+
  435. ' FBeforeClean: TNotifyEvent;'#010+
  436. ' FBeforeCompile:',' TNotifyEvent;'#010+
  437. ' FCPUs: TCPUs;'#010+
  438. ' FOSes: TOSes;'#010+
  439. ' FMode: TCompilerMode;'#010+
  440. ' FResourceStrings: Boolean;'#010+
  441. ' FObjectPath,'#010+
  442. ' FUnitPath,'#010+
  443. ' FIncludePath : TConditionalStrings;'#010+
  444. ' FDependencies : TDependencies;'#010+
  445. ' FCommands : TCommands',';'#010+
  446. ' FDirectory: String;'#010+
  447. ' FExtension: String;'#010+
  448. ' FTargetSourceFileName : String;'#010+
  449. ' FFileType: TFileType;'#010+
  450. ' FOptions: String;'#010+
  451. ' FFPCTarget: String;'#010+
  452. ' FTargetState: TTargetState;'#010+
  453. ' FTargetType: TTargetType;'#010+
  454. ' Protected'#010+
  455. ' Func','tion GetSourceFileName : String; virtual;'#010+
  456. ' Function GetUnitFileName : String; virtual;'#010+
  457. ' Function GetObjectFileName : String; virtual;'#010+
  458. ' Function GetRSTFileName : String; Virtual;'#010+
  459. ' Function GetProgramFileName(AOS : TOS) : String; ','Virtual;'#010+
  460. ' Public'#010+
  461. ' Constructor Create(ACollection : TCollection); override;'#010+
  462. ' Destructor Destroy; override;'#010+
  463. ' Function GetOutputFileName (AOs : TOS) : String; Virtual;'#010+
  464. ' procedure SetName(const AValue: String);override;'#010+
  465. ' Proced','ure GetCleanFiles(List : TStrings; const APrefixU, APrefix'+
  466. 'B : String; ACPU:TCPU; AOS : TOS); virtual;'#010+
  467. ' Procedure GetInstallFiles(List : TStrings; const APrefixU, APrefix'+
  468. 'B: String; ACPU:TCPU; AOS : TOS); virtual;'#010+
  469. ' Procedure GetArchiveF','iles(List : TStrings; ACPU:TCPU; AOS : TOS)'+
  470. '; virtual;'#010+
  471. ' Property Dependencies : TDependencies Read FDependencies;'#010+
  472. ' Property Commands : TCommands Read FCommands;'#010+
  473. ' Property State : TTargetState Read FTargetState;'#010+
  474. ' Property TargetTy','pe : TTargetType Read FTargetType Write FTarget'+
  475. 'Type;'#010+
  476. ' Property OSes : TOSes Read FOSes Write FOSes;'#010+
  477. ' Property CPUs : TCPUs Read FCPUs Write FCPUs;'#010+
  478. ' Property Mode : TCompilerMode Read FMode Write FMode;'#010+
  479. ' Property Options : String',' Read FOptions Write Foptions;'#010+
  480. ' Property SourceFileName: String Read GetSourceFileName ;'#010+
  481. ' Property UnitFileName : String Read GetUnitFileName;'#010+
  482. ' Property ObjectFileName : String Read GetObjectFileName;'#010+
  483. ' Property RSTFileName : Str','ing Read GetRSTFileName;'#010+
  484. ' Property FPCTarget : String Read FFPCTarget Write FFPCTarget;'#010+
  485. ' Property Extension : String Read FExtension Write FExtension;'#010+
  486. ' Property FileType : TFileType Read FFileType Write FFileType;'#010+
  487. ' Property Dire','ctory : String Read FDirectory Write FDirectory;'#010+
  488. ' Property ResourceStrings : Boolean Read FResourceStrings Write FRe'+
  489. 'sourceStrings;'#010+
  490. ' Property Install : Boolean Read FInstall Write FInstall;'#010+
  491. ' Property TargetSourceFileName: String Rea','d FTargetSourceFileName'+
  492. ';'#010+
  493. ' Property ObjectPath : TConditionalStrings Read FObjectPath;'#010+
  494. ' Property UnitPath : TConditionalStrings Read FUnitPath;'#010+
  495. ' Property IncludePath : TConditionalStrings Read FIncludePath;'#010+
  496. ' // Events.'#010+
  497. ' Proper','ty BeforeCompile : TNotifyEvent Read FBeforeCompile Write '+
  498. 'FBeforeCompile;'#010+
  499. ' Property AfterCompile : TNotifyEvent Read FAfterCompile Write FAft'+
  500. 'erCompile;'#010+
  501. ' Property BeforeClean : TNotifyEvent Read FBeforeClean Write FBefor'+
  502. 'eClean;'#010+
  503. ' Pro','perty AfterClean : TNotifyEvent Read FAfterClean Write FAfter'+
  504. 'Clean;'#010+
  505. ' end;'#010+
  506. #010+
  507. ' { TTargets }'#010+
  508. #010+
  509. ' TTargets = Class(TNamedCollection)'#010+
  510. ' private'#010+
  511. ' function GetTargetItem(Index : Integer): TTarget;'#010+
  512. ' function GetTarget(const AName : String): T','Target;'#010+
  513. ' procedure SetTargetItem(Index : Integer; const AValue: TTarget);'#010+
  514. ' Public'#010+
  515. ' Function AddUnit(Const AUnitName : String) : TTarget;inline;'#010+
  516. ' Function AddUnit(Const AUnitName : String;const OSes:TOSes) : TTar'+
  517. 'get;inline;'#010+
  518. '{$ifdef',' cpu_only_overloads}'#010+
  519. ' Function AddUnit(Const AUnitName : String;const CPUs:TCPUs) : TTar'+
  520. 'get;inline;'#010+
  521. '{$endif cpu_only_overloads}'#010+
  522. ' Function AddUnit(Const AUnitName : String;const CPUs:TCPUs;const O'+
  523. 'Ses:TOSes) : TTarget;'#010+
  524. ' Function AddI','mplicitUnit(Const AUnitName : String;InstallUnit:bo'+
  525. 'olean=true) : TTarget;inline;'#010+
  526. ' Function AddImplicitUnit(Const AUnitName : String;const OSes:TOSes'+
  527. ';InstallUnit:boolean=true) : TTarget;inline;'#010+
  528. ' Function AddImplicitUnit(Const AUnitName',' : String;const CPUs:TCP'+
  529. 'Us;InstallUnit:boolean=true) : TTarget;inline;'#010+
  530. ' Function AddImplicitUnit(Const AUnitName : String;const CPUs:TCPUs'+
  531. ';const OSes:TOSes;InstallUnit:boolean=true) : TTarget;'#010+
  532. ' Function AddProgram(Const AProgramName :',' String) : TTarget;inlin'+
  533. 'e;'#010+
  534. ' Function AddProgram(Const AProgramName : String;const OSes:TOSes) '+
  535. ': TTarget;inline;'#010+
  536. '{$ifdef cpu_only_overloads}'#010+
  537. ' Function AddProgram(Const AProgramName : String;const CPUs:TCPUs) '+
  538. ': TTarget;inline;'#010+
  539. '{$endif c','pu_only_overloads}'#010+
  540. ' Function AddProgram(Const AProgramName : String;const CPUs:TCPUs;c'+
  541. 'onst OSes:TOSes) : TTarget;'#010+
  542. ' Function AddExampleUnit(Const AUnitName : String) : TTarget;inline'+
  543. ';'#010+
  544. ' Function AddExampleUnit(Const AUnitName : Strin','g;const OSes:TOSe'+
  545. 's) : TTarget;inline;'#010+
  546. '{$ifdef cpu_only_overloads}'#010+
  547. ' Function AddExampleUnit(Const AUnitName : String;const CPUs:TCPUs)'+
  548. ' : TTarget;inline;'#010+
  549. '{$endif cpu_only_overloads}'#010+
  550. ' Function AddExampleUnit(Const AUnitName : String;cons','t CPUs:TCPU'+
  551. 's;const OSes:TOSes) : TTarget;'#010+
  552. ' Function AddExampleProgram(Const AProgramName : String) : TTarget;'+
  553. 'inline;'#010+
  554. ' Function AddExampleProgram(Const AProgramName : String;const OSes:'+
  555. 'TOSes) : TTarget;inline;'#010+
  556. '{$ifdef cpu_only_overload','s}'#010+
  557. ' Function AddExampleProgram(Const AProgramName : String;const CPUs:'+
  558. 'TCPUs) : TTarget;inline;'#010+
  559. '{$endif cpu_only_overloads}'#010+
  560. ' Function AddExampleProgram(Const AProgramName : String;const CPUs:'+
  561. 'TCPUs;const OSes:TOSes) : TTarget;'#010+
  562. ' Prope','rty Targets[AName : String] : TTarget Read GetTarget; defau'+
  563. 'lt;'#010+
  564. ' Property TargetItems[Index : Integer] : TTarget Read GetTargetItem'+
  565. ' Write SetTargetItem;'#010+
  566. ' end;'#010+
  567. #010+
  568. ' { TSource }'#010+
  569. #010+
  570. ' TSource = Class(TNamedItem)'#010+
  571. ' private'#010+
  572. ' FSourceType : TSou','rceType;'#010+
  573. ' Public'#010+
  574. ' Constructor Create(ACollection : TCollection); override;'#010+
  575. ' Destructor Destroy; override;'#010+
  576. ' property SourceType : TSourceType read FSourceType;'#010+
  577. ' end;'#010+
  578. #010+
  579. ' { TSources }'#010+
  580. #010+
  581. ' TSources = Class(TNamedCollection)'#010+
  582. ' private'#010,
  583. ' function GetSourceItem(Index : Integer): TSource;'#010+
  584. ' procedure SetSourceItem(Index : Integer; const AValue: TSource);'#010+
  585. ' public'#010+
  586. ' Function AddDoc(const AFiles : String) : TSource;'#010+
  587. ' Function AddSrc(const AFiles : String) : TSource;'#010,
  588. ' Function AddExample(const AFiles : String) : TSource;'#010+
  589. ' Function AddTest(const AFiles : String) : TSource;'#010+
  590. ' procedure AddDocFiles(const AFileMask: string; Recursive: boolean '+
  591. '= False);'#010+
  592. ' procedure AddSrcFiles(const AFileMask: stri','ng; Recursive: boolea'+
  593. 'n = False);'#010+
  594. ' procedure AddExampleFiles(const AFileMask: string; Recursive: bool'+
  595. 'ean = False);'#010+
  596. ' procedure AddTestFiles(const AFileMask: string; Recursive: boolean'+
  597. ' = False);'#010+
  598. ' Property SourceItems[Index : Integer] ',': TSource Read GetSourceIt'+
  599. 'em Write SetSourceItem;default;'#010+
  600. ' end;'#010+
  601. #010+
  602. ' { TPackage }'#010+
  603. #010+
  604. ' TPackage = Class(TNamedItem)'#010+
  605. ' private'#010+
  606. ' FAfterArchive: TNotifyEvent;'#010+
  607. ' FAfterClean: TNotifyEvent;'#010+
  608. ' FAfterCompile: TNotifyEvent;'#010+
  609. ' FAfterInstall: T','NotifyEvent;'#010+
  610. ' FAfterManifest: TNotifyEvent;'#010+
  611. ' FBeforeArchive: TNotifyEvent;'#010+
  612. ' FBeforeClean: TNotifyEvent;'#010+
  613. ' FBeforeCompile: TNotifyEvent;'#010+
  614. ' FBeforeInstall: TNotifyEvent;'#010+
  615. ' FBeforeManifest: TNotifyEvent;'#010+
  616. ' FUnitPath,'#010+
  617. ' FObje','ctPath,'#010+
  618. ' FIncludePath,'#010+
  619. ' FSourcePath,'#010+
  620. ' FExamplePath,'#010+
  621. ' FTestPath,'#010+
  622. ' FCleanFiles,'#010+
  623. ' FInstallFiles : TConditionalStrings;'#010+
  624. ' FDependencies : TDependencies;'#010+
  625. ' FCPUs: TCPUs;'#010+
  626. ' FOSes: TOSes;'#010+
  627. ' FTargetState: TTargetState;'#010+
  628. ' ',' FTargets: TTargets;'#010+
  629. ' FSources: TSources;'#010+
  630. ' FDirectory: String;'#010+
  631. ' FOptions: String;'#010+
  632. ' FFileName: String;'#010+
  633. ' FAuthor: String;'#010+
  634. ' FLicense: String;'#010+
  635. ' FExternalURL: String;'#010+
  636. ' FVersion: TFPVersion;'#010+
  637. ' FEmail : String;'#010+
  638. ' FNeedL','ibC : Boolean;'#010+
  639. ' FCommands : TCommands;'#010+
  640. ' FDescriptionFile : String;'#010+
  641. ' FDescription : String;'#010+
  642. ' FInstalledChecksum : Cardinal;'#010+
  643. ' // Cached directory of installed packages'#010+
  644. ' FUnitDir : String;'#010+
  645. ' Function GetDescription : string',';'#010+
  646. ' Function GetFileName : string;'#010+
  647. ' Function GetVersion : string;'#010+
  648. ' Procedure SetVersion(const V : string);'#010+
  649. ' Protected'#010+
  650. ' procedure SetName(const AValue: String);override;'#010+
  651. ' procedure LoadUnitConfigFromFile(Const AFileName: Strin','g);'#010+
  652. ' procedure SaveUnitConfigToFile(Const AFileName: String;ACPU:TCPU;A'+
  653. 'OS:TOS);'#010+
  654. ' Public'#010+
  655. ' constructor Create(ACollection: TCollection); override;'#010+
  656. ' destructor destroy; override;'#010+
  657. ' Function GetUnitsOutputDir(ACPU:TCPU; AOS : TOS):','String;'#010+
  658. ' Function GetBinOutputDir(ACPU:TCPU; AOS : TOS) : String;'#010+
  659. ' Procedure GetCleanFiles(List : TStrings; ACPU:TCPU; AOS : TOS); vi'+
  660. 'rtual;'#010+
  661. ' procedure GetInstallFiles(List: TStrings;Types : TTargetTypes;ACPU'+
  662. ':TCPU; AOS : TOS);'#010+
  663. ' ','Procedure GetArchiveFiles(List : TStrings; ACPU:TCPU; AOS : TOS)'+
  664. '; virtual;'#010+
  665. ' Procedure GetManifest(Manifest : TStrings);'#010+
  666. ' Property Version : String Read GetVersion Write SetVersion;'#010+
  667. ' Property FileName : String Read GetFileName Write',' FFileName;'#010+
  668. ' Property ExternalURL : String Read FExternalURL Write FExternalURL'+
  669. ';'#010+
  670. ' Property Email : String Read FEmail Write FEmail;'#010+
  671. ' Property Author : String Read FAuthor Write FAuthor;'#010+
  672. ' Property License : String Read FLicense W','rite FLicense;'#010+
  673. ' Property Directory : String Read FDirectory Write FDirectory;'#010+
  674. ' Property Description : String Read GetDescription Write FDescripti'+
  675. 'on;'#010+
  676. ' Property DescriptionFile : String Read FDescriptionFile Write FDes'+
  677. 'criptionFile;'#010+
  678. ' ',' Property InstalledChecksum : Cardinal Read FInstalledChecksum Wr'+
  679. 'ite FInstalledChecksum;'#010+
  680. ' // Compiler options.'#010+
  681. ' Property OSes : TOSes Read FOSes Write FOSes;'#010+
  682. ' Property CPUs : TCPUs Read FCPUs Write FCPUs;'#010+
  683. ' Property NeedLibC : ','Boolean Read FNeedLibC Write FNeedLibC;'#010+
  684. ' Property Options: String Read FOptions Write FOptions;'#010+
  685. ' Property UnitPath : TConditionalStrings Read FUnitPath;'#010+
  686. ' Property ObjectPath : TConditionalStrings Read FObjectPath;'#010+
  687. ' Property Incl','udePath : TConditionalStrings Read FIncludePath;'#010+
  688. ' Property SourcePath : TConditionalStrings Read FSourcePath;'#010+
  689. ' Property ExamplePath : TConditionalStrings Read FExamplePath;'#010+
  690. ' Property TestPath : TConditionalStrings Read FTestPath;'#010+
  691. ' ',' // Targets and dependencies'#010+
  692. ' Property InstallFiles : TConditionalStrings Read FInstallFiles;'#010+
  693. ' Property CleanFiles : TConditionalStrings Read FCleanFiles;'#010+
  694. ' Property Dependencies : TDependencies Read FDependencies;'#010+
  695. ' Property Co','mmands : TCommands Read FCommands;'#010+
  696. ' Property State : TTargetState Read FTargetState;'#010+
  697. ' Property Targets : TTargets Read FTargets;'#010+
  698. ' Property Sources : TSources Read FSources;'#010+
  699. ' Property UnitDir : String Read FUnitDir Write FUnitDir',';'#010+
  700. ' // events'#010+
  701. ' Property BeforeCompile : TNotifyEvent Read FBeforeCompile Write FB'+
  702. 'eforeCompile;'#010+
  703. ' Property AfterCompile : TNotifyEvent Read FAfterCompile Write FAft'+
  704. 'erCompile;'#010+
  705. ' Property BeforeInstall : TNotifyEvent Read FBeforeInsta','ll Write '+
  706. 'FBeforeInstall;'#010+
  707. ' Property AfterInstall : TNotifyEvent Read FAfterInstall Write FAft'+
  708. 'erInstall;'#010+
  709. ' Property BeforeClean : TNotifyEvent Read FBeforeClean Write FBefor'+
  710. 'eClean;'#010+
  711. ' Property AfterClean : TNotifyEvent Read FAfterClean ','Write FAfter'+
  712. 'Clean;'#010+
  713. ' Property BeforeArchive : TNotifyEvent Read FBeforeArchive Write FB'+
  714. 'eforeArchive;'#010+
  715. ' Property AfterArchive : TNotifyEvent Read FAfterArchive Write FAft'+
  716. 'erArchive;'#010+
  717. ' Property BeforeManifest : TNotifyEvent Read FBeforeM','anifest Writ'+
  718. 'e FBeforeManifest;'#010+
  719. ' Property AfterManifest : TNotifyEvent Read FAfterManifest Write FA'+
  720. 'fterManifest;'#010+
  721. ' end;'#010+
  722. #010+
  723. ' { TPackages }'#010+
  724. #010+
  725. ' TPackages = Class(TNamedCollection)'#010+
  726. ' private'#010+
  727. ' function GetPackage(const AName : String): TPack','age;'#010+
  728. ' function GetPackageItem(AIndex : Integer): TPackage;'#010+
  729. ' procedure SetPackageItem(AIndex : Integer; const AValue: TPackage)'+
  730. ';'#010+
  731. ' Public'#010+
  732. ' Function AddPackage(Const AName : String) : TPackage;'#010+
  733. ' Property Packages[AName : String] :',' TPackage Read GetPackage ; D'+
  734. 'efault;'#010+
  735. ' Property PackageItems[AIndex : Integer] : TPackage Read GetPackage'+
  736. 'Item Write SetPackageItem;'#010+
  737. ' end;'#010+
  738. #010+
  739. ' { TCustomDefaults }'#010+
  740. #010+
  741. ' TCustomDefaults = Class(TPersistent)'#010+
  742. ' Private'#010+
  743. ' FArchive: String;'#010+
  744. ' ','FCompiler: String;'#010+
  745. ' FCopy: String;'#010+
  746. ' FMkDir: String;'#010+
  747. ' FMove: String;'#010+
  748. ' FOptions: String;'#010+
  749. ' FCPU: TCPU;'#010+
  750. ' FOS: TOS;'#010+
  751. ' FMode : TCompilerMode;'#010+
  752. ' FCompilerVersion : String;'#010+
  753. ' FPrefix: String;'#010+
  754. ' FLocalUnitDir,'#010+
  755. ' FGlobalUn','itDir,'#010+
  756. ' FBaseInstallDir,'#010+
  757. ' FUnitInstallDir,'#010+
  758. ' FBinInstallDir,'#010+
  759. ' FDocInstallDir,'#010+
  760. ' FExamplesInstallDir : String;'#010+
  761. ' FRemove: String;'#010+
  762. ' FTarget: String;'#010+
  763. ' FUnixPaths: Boolean;'#010+
  764. ' FNoFPCCfg: Boolean;'#010+
  765. ' function GetLocalUnitD','ir: String;'#010+
  766. ' function GetGlobalUnitDir: String;'#010+
  767. ' function GetBaseInstallDir: String;'#010+
  768. ' function GetBinInstallDir: String;'#010+
  769. ' function GetCompiler: String;'#010+
  770. ' function GetDocInstallDir: String;'#010+
  771. ' function GetExamplesInstallDir: S','tring;'#010+
  772. ' function GetUnitInstallDir: String;'#010+
  773. ' procedure SetLocalUnitDir(const AValue: String);'#010+
  774. ' procedure SetGlobalUnitDir(const AValue: String);'#010+
  775. ' procedure SetBaseInstallDir(const AValue: String);'#010+
  776. ' procedure SetCPU(const AVal','ue: TCPU);'#010+
  777. ' procedure SetOS(const AValue: TOS);'#010+
  778. ' procedure SetPrefix(const AValue: String);'#010+
  779. ' procedure SetTarget(const AValue: String);'#010+
  780. ' Protected'#010+
  781. ' procedure RecalcTarget;'#010+
  782. ' Public'#010+
  783. ' Constructor Create;'#010+
  784. ' Procedure InitDefa','ults;'#010+
  785. ' procedure CompilerDefaults; virtual;'#010+
  786. ' Procedure LocalInit(Const AFileName : String);'#010+
  787. ' Procedure LoadFromFile(Const AFileName : String);'#010+
  788. ' Procedure SaveToFile(Const AFileName : String);'#010+
  789. ' procedure SaveToStream(S : TStre','am);virtual;'#010+
  790. ' procedure LoadFromStream(S : TStream);virtual;'#010+
  791. ' // Compile Information'#010+
  792. ' Property Target : String Read FTarget Write SetTarget;'#010+
  793. ' Property OS : TOS Read FOS Write SetOS;'#010+
  794. ' Property CPU : TCPU Read FCPU Write SetCPU',';'#010+
  795. ' Property Mode : TCompilerMode Read FMode Write FMode;'#010+
  796. ' Property UnixPaths : Boolean Read FUnixPaths Write FUnixPaths;'#010+
  797. ' Property Options : String Read FOptions Write FOptions; // Defa'+
  798. 'ult compiler options.'#010+
  799. ' Property NoFPCCfg',' : Boolean Read FNoFPCCfg Write FNoFPCCfg;'#010+
  800. ' // paths etc.'#010+
  801. ' Property LocalUnitDir : String Read GetLocalUnitDir Write SetLocal'+
  802. 'UnitDir;'#010+
  803. ' Property GlobalUnitDir : String Read GetGlobalUnitDir Write SetGlo'+
  804. 'balUnitDir;'#010+
  805. ' Property Prefi','x : String Read FPrefix Write SetPrefix;'#010+
  806. ' Property BaseInstallDir : String Read GetBaseInstallDir Write SetB'+
  807. 'aseInstallDir;'#010+
  808. ' Property UnitInstallDir : String Read GetUnitInstallDir Write FUni'+
  809. 'tInstallDir;'#010+
  810. ' Property BinInstallDir : St','ring Read GetBinInstallDir Write FBin'+
  811. 'InstallDir;'#010+
  812. ' Property DocInstallDir : String Read GetDocInstallDir Write FDocIn'+
  813. 'stallDir;'#010+
  814. ' Property ExamplesInstallDir : String Read GetExamplesInstallDir Wr'+
  815. 'ite FExamplesInstallDir;'#010+
  816. ' // Command t','ools. If not set, internal commands will be used.'#010+
  817. ' Property Compiler : String Read GetCompiler Write FCompiler; // Co'+
  818. 'mpiler. Defaults to fpc'#010+
  819. ' Property Copy : String Read FCopy Write FCopy; // copy'+
  820. ' $(FILES) to $(DEST)'#010+
  821. ' ','Property Move : String Read FMove Write FMove; // Mo'+
  822. 've $(FILES) to $(DEST)'#010+
  823. ' Property Remove : String Read FRemove Write FRemove; // Dele'+
  824. 'te $(FILES)'#010+
  825. ' Property MkDir : String Read FMkDir write FMkDir; // Make'+
  826. ' ','$(DIRECTORY)'#010+
  827. ' Property Archive : String Read FArchive Write FArchive; // zip '+
  828. '$(ARCHIVE) $(FILESORDIRS)'#010+
  829. ' end;'#010+
  830. #010+
  831. ' { TBasicDefaults }'#010+
  832. #010+
  833. ' TBasicDefaults = Class(TCustomDefaults)'#010+
  834. ' end;'#010+
  835. #010+
  836. ' { TFPCDefaults }'#010+
  837. #010+
  838. ' TFPCDefaults = Class(TCustomD','efaults)'#010+
  839. ' public'#010+
  840. ' procedure CompilerDefaults; override;'#010+
  841. ' end;'#010+
  842. #010+
  843. ' { TBuildEngine }'#010+
  844. #010+
  845. ' TBuildEngine = Class(TComponent)'#010+
  846. ' private'#010+
  847. ' // general variables'#010+
  848. ' FCompiler : String;'#010+
  849. ' FStartDir : String;'#010+
  850. ' FForceCompile : Boolean;'#010+
  851. ' F','ListMode : Boolean;'#010+
  852. '{$ifdef HAS_UNIT_ZIPPER}'#010+
  853. ' FZipFile: TZipper;'#010+
  854. '{$endif HAS_UNIT_ZIPPER}'#010+
  855. ' FExternalPackages : TPackages;'#010+
  856. ' // Logging'#010+
  857. ' FLogPrefix : String;'#010+
  858. ' // Events'#010+
  859. ' FOnLog: TLogEvent;'#010+
  860. ' FAfterArchive: TNotifyEvent;'#010+
  861. ' ',' FAfterClean: TNotifyEvent;'#010+
  862. ' FAfterCompile: TNotifyEvent;'#010+
  863. ' FAfterInstall: TNotifyEvent;'#010+
  864. ' FAfterManifest: TNotifyEvent;'#010+
  865. ' FBeforeArchive: TNotifyEvent;'#010+
  866. ' FBeforeClean: TNotifyEvent;'#010+
  867. ' FBeforeCompile: TNotifyEvent;'#010+
  868. ' FBefore','Install: TNotifyEvent;'#010+
  869. ' FBeforeManifest: TNotifyEvent;'#010+
  870. ' Protected'#010+
  871. ' Procedure Error(const Msg : String);'#010+
  872. ' Procedure Error(const Fmt : String; const Args : Array of const);'#010+
  873. ' // Internal copy/delete/move/archive/mkdir files'#010+
  874. ' Fu','nction SysDirectoryExists(const ADir:string):Boolean;'#010+
  875. ' Function SysFileExists(const AFileName:string):Boolean;'#010+
  876. ' Procedure SysCopyFile(Const Src,Dest : String); virtual;'#010+
  877. ' Procedure SysMoveFile(Const Src,Dest : String); virtual;'#010+
  878. ' ',' Procedure SysDeleteFile(Const AFileName : String); virtual;'#010+
  879. ' Procedure SysArchiveFiles(List : TStrings; Const AFileName : Strin'+
  880. 'g); virtual;'#010+
  881. ' procedure LogIndent;'#010+
  882. ' procedure LogUnIndent;'#010+
  883. ' Procedure Log(Level : TVerboseLevel; Co','nst Msg : String);'#010+
  884. ' Procedure Log(Level : TVerboseLevel; Const Fmt : String; const Arg'+
  885. 's : Array Of Const);'#010+
  886. ' Procedure EnterDir(ADir : String);'#010+
  887. ' Function GetCompiler : String;'#010+
  888. ' Function InstallPackageFiles(APAckage : TPackage; tt',' : TTargetTy'+
  889. 'pe; Const Dest : String):Boolean;'#010+
  890. ' Function FileNewer(const Src,Dest : String) : Boolean;'#010+
  891. ' Procedure LogSearchPath(const ASearchPathName:string;Path:TConditi'+
  892. 'onalStrings; ACPU:TCPU;AOS:TOS);'#010+
  893. ' Function FindFileInPath(Path',':TConditionalStrings; AFileName:Stri'+
  894. 'ng; var FoundPath:String;ACPU:TCPU;AOS:TOS):Boolean;'#010+
  895. #010+
  896. ' //package commands'#010+
  897. ' Procedure ResolveFileNames(APackage : TPackage; ACPU:TCPU;AOS:TOS;'+
  898. 'DoChangeDir:boolean=true);'#010+
  899. ' function GetUnitDir(APack','age:TPackage):String;'#010+
  900. ' procedure AddDependencyIncludePaths(L:TStrings;ATarget: TTarget);'#010+
  901. ' procedure AddDependencyUnitPaths(L:TStrings;APackage: TPackage);'#010+
  902. ' Public'#010+
  903. ' Constructor Create(AOwner : TComponent); override;'#010+
  904. ' destructor ','Destroy;override;'#010+
  905. ' // Public Copy/delete/Move/Archive/Mkdir Commands.'#010+
  906. ' Procedure ExecuteCommand(const Cmd,Args : String; IgnoreError : Bo'+
  907. 'olean = False); virtual;'#010+
  908. ' Procedure CmdCopyFiles(List : TStrings; Const DestDir : String);'#010+
  909. ' ',' Procedure CmdCreateDir(const DestDir : String);'#010+
  910. ' Procedure CmdMoveFiles(List : TStrings; Const DestDir : String);'#010+
  911. ' Procedure CmdDeleteFiles(List : TStrings);'#010+
  912. ' Procedure CmdArchiveFiles(List : TStrings; Const ArchiveFile : Str'+
  913. 'ing);',#010+
  914. ' Procedure ExecuteCommands(Commands : TCommands; At : TCommandAt);'#010+
  915. ' // Dependency commands'#010+
  916. ' Function DependencyOK(ADependency : TDependency) : Boolean;'#010+
  917. ' // Target commands'#010+
  918. ' Function GetCompilerCommand(APackage : TPackage; ','ATarget : TTar'+
  919. 'get) : String;'#010+
  920. ' Function TargetOK(ATarget : TTarget) : Boolean;'#010+
  921. ' Function NeedsCompile(APackage:TPackage; ATarget : TTarget) : Boo'+
  922. 'lean;'#010+
  923. ' Procedure Compile(APackage:TPackage; ATarget : TTarget); virtual;'+
  924. #010+
  925. ' Procedu','re MaybeCompile(APackage:TPackage; ATarget: TTarget);'#010+
  926. ' Procedure CompileDependencies(APackage:TPackage; ATarget: TTarget)'+
  927. ';'#010+
  928. ' // Package commands'#010+
  929. '{ Function GetPackageDir(APackage : TPackage; AbsolutePath : Boole'+
  930. 'an = False) : String',';'#010+
  931. ' Function GetUnitsOutputDir(APackage : TPackage; AbsolutePath : Bo'+
  932. 'olean = False) : String;'#010+
  933. ' Function GetBinOutputDir(APackage : TPackage; AbsolutePath : Bool'+
  934. 'ean = False) : String; }'#010+
  935. ' Function PackageOK(APackage : TPackage) : ','Boolean; virtual;'#010+
  936. ' Procedure DoBeforeCompile(APackage : TPackage);virtual;'#010+
  937. ' Procedure DoAfterCompile(APackage : TPackage);virtual;'#010+
  938. ' Procedure DoBeforeInstall(APackage : TPackage);virtual;'#010+
  939. ' Procedure DoAfterInstall(APackage : TPa','ckage);virtual;'#010+
  940. ' Procedure DoBeforeArchive(APackage : TPackage);virtual;'#010+
  941. ' Procedure DoAfterArchive(APackage : TPackage);virtual;'#010+
  942. ' Procedure DoBeforeClean(APackage : TPackage);virtual;'#010+
  943. ' Procedure DoAfterClean(APackage : TPackage)',';virtual;'#010+
  944. ' Function NeedsCompile(APackage : TPackage) : Boolean; virtual;'#010+
  945. ' Procedure Compile(APackage : TPackage);'#010+
  946. ' Procedure MaybeCompile(APackage:TPackage);'#010+
  947. ' Procedure Install(APackage : TPackage);'#010+
  948. ' Procedure Archive(APack','age : TPackage);'#010+
  949. ' Procedure Manifest(APackage : TPackage);'#010+
  950. ' Procedure Clean(APackage : TPackage);'#010+
  951. ' Procedure CompileDependencies(APackage : TPackage);'#010+
  952. ' Function CheckExternalPackage(Const APackageName : String):TPacka'+
  953. 'ge;'#010+
  954. ' pr','ocedure CreateOutputDir(APackage: TPackage);'#010+
  955. ' // Packages commands'#010+
  956. ' Procedure Compile(Packages : TPackages);'#010+
  957. ' Procedure Install(Packages : TPackages);'#010+
  958. ' Procedure Archive(Packages : TPackages);'#010+
  959. ' procedure Manifest(Packages: TP','ackages);'#010+
  960. ' Procedure Clean(Packages : TPackages);'#010+
  961. ' Property ListMode : Boolean Read FListMode Write FListMode;'#010+
  962. ' Property ForceCompile : Boolean Read FForceCompile Write FForceCom'+
  963. 'pile;'#010+
  964. ' Property ExternalPackages: TPackages Read F','ExternalPackages;'#010+
  965. ' // Events'#010+
  966. ' Property BeforeCompile : TNotifyEvent Read FBeforeCompile Write FB'+
  967. 'eforeCompile;'#010+
  968. ' Property AfterCompile : TNotifyEvent Read FAfterCompile Write FAft'+
  969. 'erCompile;'#010+
  970. ' Property BeforeInstall : TNotifyEvent R','ead FBeforeInstall Write '+
  971. 'FBeforeInstall;'#010+
  972. ' Property AfterInstall : TNotifyEvent Read FAfterInstall Write FAft'+
  973. 'erInstall;'#010+
  974. ' Property BeforeClean : TNotifyEvent Read FBeforeClean Write FBefor'+
  975. 'eClean;'#010+
  976. ' Property AfterClean : TNotifyEvent R','ead FAfterClean Write FAfter'+
  977. 'Clean;'#010+
  978. ' Property BeforeArchive : TNotifyEvent Read FBeforeArchive Write FB'+
  979. 'eforeArchive;'#010+
  980. ' Property AfterArchive : TNotifyEvent Read FAfterArchive Write FAft'+
  981. 'erArchive;'#010+
  982. ' Property BeforeManifest : TNotifyEve','nt Read FBeforeManifest Writ'+
  983. 'e FBeforeManifest;'#010+
  984. ' Property AfterManifest : TNotifyEvent Read FAfterManifest Write FA'+
  985. 'fterManifest;'#010+
  986. ' Property OnLog : TLogEvent Read FOnLog Write FOnlog;'#010+
  987. ' end;'#010+
  988. #010+
  989. ' { TCustomInstaller }'#010+
  990. #010+
  991. ' TCustomInstaller =',' Class(TComponent)'#010+
  992. ' private'#010+
  993. ' FBuildEngine: TBuildEngine;'#010+
  994. ' FPackages: TPackages;'#010+
  995. ' FRunMode: TRunMode;'#010+
  996. ' FListMode : Boolean;'#010+
  997. ' FLogLevels : TVerboseLevels;'#010+
  998. ' Protected'#010+
  999. ' Procedure Log(Level : TVerboseLevel; Const Msg : String',');'#010+
  1000. ' Procedure CreatePackages; virtual;'#010+
  1001. ' Procedure CheckPackages; virtual;'#010+
  1002. ' Procedure CreateBuildEngine; virtual;'#010+
  1003. ' Procedure Error(const Msg : String);'#010+
  1004. ' Procedure Error(const Fmt : String; Args : Array of const);'#010+
  1005. ' Procedure',' AnalyzeOptions;'#010+
  1006. ' Procedure Usage(const FMT : String; Args : Array of const);'#010+
  1007. ' Procedure Compile(Force : Boolean); virtual;'#010+
  1008. ' Procedure Clean; virtual;'#010+
  1009. ' Procedure Install; virtual;'#010+
  1010. ' Procedure Archive; virtual;'#010+
  1011. ' Procedure Ma','nifest; virtual;'#010+
  1012. ' Property BuildEngine : TBuildEngine Read FBuildEngine;'#010+
  1013. ' Public'#010+
  1014. ' Constructor Create(AOwner : TComponent); virtual;'#010+
  1015. ' Destructor destroy; override;'#010+
  1016. ' Function AddPackage(Const AName : String) : TPackage;'#010+
  1017. ' Funct','ion Run : Boolean;'#010+
  1018. ' //files in package'#010+
  1019. ' Property Packages : TPackages Read FPackages;'#010+
  1020. ' Property RunMode : TRunMode Read FRunMode;'#010+
  1021. ' Property ListMode : Boolean Read FListMode;'#010+
  1022. ' end;'#010+
  1023. #010+
  1024. ' { TFPCInstaller }'#010+
  1025. ' TFPCInstaller = class(T','CustomInstaller)'#010+
  1026. ' public'#010+
  1027. ' Constructor Create(AOwner : TComponent); override;'#010+
  1028. ' end;'#010+
  1029. #010+
  1030. ' { TBasicInstaller }'#010+
  1031. ' TBasicInstaller = class(TCustomInstaller)'#010+
  1032. ' Constructor Create(AOwner : TComponent); override;'#010+
  1033. ' end;'#010+
  1034. #010+
  1035. ' TReplaceFunction = F','unction (Const AName,Args : String) : String o'+
  1036. 'f Object;'#010+
  1037. #010+
  1038. ' { TValueItem }'#010+
  1039. #010+
  1040. ' TValueItem = Class(TObject)'#010+
  1041. ' FValue : String;'#010+
  1042. ' Constructor Create(AValue : String);'#010+
  1043. ' end;'#010+
  1044. #010+
  1045. ' { TFunctionItem }'#010+
  1046. #010+
  1047. ' TFunctionItem = Class(TObject)'#010+
  1048. ' FFunc :',' TReplaceFunction;'#010+
  1049. ' Constructor Create(AFunc : TReplaceFunction);'#010+
  1050. ' end;'#010+
  1051. #010+
  1052. ' { TDictionary }'#010+
  1053. #010+
  1054. ' TDictionary = Class(TComponent)'#010+
  1055. ' FList : TStringList;'#010+
  1056. ' Public'#010+
  1057. ' Constructor Create(AOwner : TComponent); override;'#010+
  1058. ' Destructor Destro','y;override;'#010+
  1059. ' Procedure AddVariable(Const AName,Value : String);'#010+
  1060. ' Procedure AddFunction(Const AName : String; FReplacement : TReplac'+
  1061. 'eFunction);'#010+
  1062. ' Procedure RemoveItem(Const AName : String);'#010+
  1063. ' Function GetValue(Const AName : String)',' : String;'#010+
  1064. ' Function GetValue(Const AName,Args : String) : String; virtual;'#010+
  1065. ' Function ReplaceStrings(Const ASource : String) : String; virtual;'+
  1066. #010+
  1067. ' end;'#010+
  1068. #010+
  1069. ' ECollectionError = Class(Exception);'#010+
  1070. ' EDictionaryError = Class(Exception);'#010+
  1071. ' EI','nstallerError = Class(Exception);'#010+
  1072. #010+
  1073. ' TInstallerClass = Class of TCustomInstaller;'#010+
  1074. ' TDictionaryClass = Class of TDictionary;'#010+
  1075. #010+
  1076. 'Type'#010+
  1077. ' TArchiveEvent = Procedure (Const AFileName : String; List : TStrings'+
  1078. ') of Object;'#010+
  1079. ' TArchiveProc = Procedure',' (Const AFileName : String; List : TString'+
  1080. 's);'#010+
  1081. #010+
  1082. 'Var'#010+
  1083. ' DictionaryClass : TDictionaryClass = TDictionary;'#010+
  1084. ' OnArchiveFiles : TArchiveEvent = Nil;'#010+
  1085. ' ArchiveFilesProc : TArchiveProc = Nil;'#010+
  1086. #010+
  1087. ' Defaults : TCustomDefaults; // Set by installer.'#010+
  1088. ' Di','ctionary : TDictionary;'#010+
  1089. #010+
  1090. #010+
  1091. 'Function CurrentOS : String;'#010+
  1092. 'Function CurrentCPU : String;'#010+
  1093. #010+
  1094. 'Function Installer(InstallerClass: TInstallerClass) : TCustomInstaller'+
  1095. '; overload;'#010+
  1096. 'Function Installer : TCustomInstaller; overload;'#010+
  1097. #010+
  1098. 'Function OSToString(OS',': TOS) : String;'#010+
  1099. 'Function OSesToString(OSes: TOSes) : String;'#010+
  1100. 'Function CPUToString(CPU: TCPU) : String;'#010+
  1101. 'Function CPUSToString(CPUS: TCPUS) : String;'#010+
  1102. 'Function StringToOS(const S : String) : TOS;'#010+
  1103. 'Function OSesToString(const S : String) : TOSe','s;'#010+
  1104. 'Function StringToCPU(const S : String) : TCPU;'#010+
  1105. 'Function StringToCPUS(const S : String) : TCPUS;'#010+
  1106. 'Function ModeToString(Mode: TCompilerMode) : String;'#010+
  1107. 'Function StringToMode(const S : String) : TCompilerMode;'#010+
  1108. 'Function MakeTargetString(CPU :',' TCPU;OS: TOS) : String;'#010+
  1109. 'Procedure StringToCPUOS(const S : String; Var CPU : TCPU; Var OS: TOS)'+
  1110. ';'#010+
  1111. 'Function FixPath (const APath : String) : String;'#010+
  1112. 'Procedure ChangeDir(const APath : String);'#010+
  1113. 'Function Substitute(Const Source : String; Macros ',': Array of string)'+
  1114. ' : String;'#010+
  1115. 'Procedure SplitCommand(Const Cmd : String; Var Exe,Options : String);'#010+
  1116. #010+
  1117. 'Implementation'#010+
  1118. #010+
  1119. 'uses typinfo;'#010+
  1120. #010+
  1121. 'ResourceString'#010+
  1122. ' SErrInvalidCPU = '#039'Invalid CPU name "%s"'#039';'#010+
  1123. ' SErrInvalidOS = '#039'Invalid OS name ','"%s"'#039';'#010+
  1124. ' SErrInvalidMode = '#039'Invalid compiler mode "%s"'#039';'#010+
  1125. ' SErrInvalidTarget = '#039'Invalid compiler target "%s"'#039';'#010+
  1126. ' SErrNameExists = '#039'Name "%s" already exists in the collect'+
  1127. 'ion.'#039';'#010+
  1128. ' SErrNoSuchName = '#039'Could not find item',' with name "%s" in'+
  1129. ' the collection.'#039';'#010+
  1130. ' SErrInValidArgument = '#039'Invalid command-line argument at positi'+
  1131. 'on %d: %s'#039';'#010+
  1132. ' SErrNeedArgument = '#039'Option at position %d (%s) needs an arg'+
  1133. 'ument'#039';'#010+
  1134. ' SErrNoPackagesDefined = '#039'No action possible: No p','ackages were '+
  1135. 'defined.'#039';'#010+
  1136. ' SErrInstaller = '#039'The installer encountered the following'+
  1137. ' error:'#039';'#010+
  1138. ' SErrDepUnknownTarget = '#039'Unknown target in dependencies for %s: '+
  1139. '%s'#039';'#010+
  1140. ' SErrExternalCommandFailed = '#039'External command "%s" failed with e'+
  1141. 'xit',' code %d'#039';'#010+
  1142. ' SErrCreatingDirectory = '#039'Failed to create directory "%s"'#039';'#010+
  1143. ' SErrDeletingFile = '#039'Failed to delete file "%s"'#039';'#010+
  1144. ' SErrMovingFile = '#039'Failed to move file "%s" to "%s"'#039';'#010+
  1145. ' SErrCopyingFile = '#039'Failed to copy file "%s','" to "%s"'#039';'+
  1146. #010+
  1147. ' SErrChangeDirFailed = '#039'Failed to enter directory "%s"'#039';'#010+
  1148. ' SErrInvalidArgumentToSubstitute = '#039'Invalid number of arguments t'+
  1149. 'o Substitute'#039';'#010+
  1150. ' SErrNoArchiveSupport = '#039'This binary contains no archive support'+
  1151. '. Please recompile wi','th archive support'#039';'#010+
  1152. ' SErrNoDictionaryItem = '#039'No item called "%s" in the dictionary'#039+
  1153. ';'#010+
  1154. ' SErrNoDictionaryValue = '#039'The item "%s" in the dictionary is not '+
  1155. 'a value'#039';'#010+
  1156. ' SErrNoDictionaryFunc = '#039'The item "%s" in the dictionary is not '+
  1157. 'a function',#039';'#010+
  1158. ' SErrInvalidFPCInfo = '#039'Compiler returns invalid information, c'+
  1159. 'heck if fpc -iV works'#039';'#010+
  1160. ' SErrDependencyNotFound = '#039'Could not find unit directory for depe'+
  1161. 'ndency package "%s"'#039';'#010+
  1162. ' SErrAlreadyInitialized = '#039'Installer can only be initializ','ed on'+
  1163. 'ce'#039';'#010+
  1164. ' SErrInvalidState = '#039'Invalid state for target %s'#039';'#010+
  1165. #010+
  1166. ' SWarnCircularTargetDependency = '#039'Warning: Circular dependency de'+
  1167. 'tected when compiling target %s with target %s'#039';'#010+
  1168. ' SWarnCircularPackageDependency = '#039'Warning: Circular dep','endency'+
  1169. ' detected when compiling package %s with package %s'#039';'#010+
  1170. ' SWarnFailedToSetTime = '#039'Warning: Failed to set timestamp on f'+
  1171. 'ile "%s"'#039';'#010+
  1172. ' SWarnFailedToGetTime = '#039'Warning: Failed to get timestamp from'+
  1173. ' file "%s"'#039';'#010+
  1174. ' SWarnFileDoesNotExist',' = '#039'Warning: File "%s" does not exist'#039+
  1175. ';'#010+
  1176. ' SWarnAttemptingToCompileNonNeutralTarget = '#039'Warning: Attempting '+
  1177. 'to compile non-neutral target %s'#039';'#010+
  1178. ' SWarnSourceFileNotFound = '#039'Warning: Source file "%s" not found '+
  1179. 'for %s'#039';'#010+
  1180. ' SWarnIncludeFileNotF','ound = '#039'Warning: Include file "%s" not fou'+
  1181. 'nd for %s'#039';'#010+
  1182. ' SWarnDepUnitNotFound = '#039'Warning: Dependency on unit %s is no'+
  1183. 't supported for %s'#039';'#010+
  1184. #010+
  1185. ' SInfoCompilingPackage = '#039'Compiling package %s'#039';'#010+
  1186. ' SInfoCompilingTarget = '#039'Compiling target ','%s'#039';'#010+
  1187. ' SInfoExecutingCommand = '#039'Executing command "%s %s"'#039';'#010+
  1188. ' SInfoCreatingOutputDir = '#039'Creating output dir "%s"'#039';'#010+
  1189. ' SInfoInstallingPackage = '#039'Installing package %s'#039';'#010+
  1190. ' SInfoArchivingPackage = '#039'Archiving package %s in "%s"'#039';'#010+
  1191. ' SInfoCl','eaningPackage = '#039'Cleaning package %s'#039';'#010+
  1192. ' SInfoManifestPackage = '#039'Creating manifest for package %s'#039';'+
  1193. #010+
  1194. ' SInfoCopyingFile = '#039'Copying file "%s" to "%s"'#039';'#010+
  1195. ' SInfoSourceNewerDest = '#039'Source file "%s" (%s) is newer than d'+
  1196. 'estination ','"%s" (%s).'#039';'#010+
  1197. #010+
  1198. ' SDbgComparingFileTimes = '#039'Comparing file "%s" time "%s" to "%'+
  1199. 's" time "%s".'#039';'#010+
  1200. ' SDbgCompilingDependenciesOfTarget = '#039'Compiling dependencies of t'+
  1201. 'arget %s'#039';'#010+
  1202. ' SDbgResolvingSourcesOfTarget = '#039'Resolving filenames of target %s'+
  1203. ' ','for %s'#039';'#010+
  1204. ' SDbgResolvedSourceFile = '#039'Resolved source file %s to "%s"'#039+
  1205. ';'#010+
  1206. ' SDbgResolvedIncludeFile = '#039'Resolved include file %s to "%s"'#039+
  1207. ';'#010+
  1208. ' SDbgOutputNotYetAvailable = '#039'Output file %s not available'#039';'#010+
  1209. ' SDbgDependencyOnUnit = '#039'Depende','ncy of %s on unit %s'#039';'+
  1210. #010+
  1211. ' SDbgDependencyUnitRecompiled = '#039'Dependent unit %s is being recom'+
  1212. 'piled'#039';'#010+
  1213. ' SDbgMustCompile = '#039'Must compile %s'#039';'#010+
  1214. ' SDbgSkippingTargetWrongCPU = '#039'Skipping target %s, different CPU '+
  1215. '(%s)'#039';'#010+
  1216. ' SDbgSkippingTargetW','rongOS = '#039'Skipping target %s, different OS'+
  1217. ' (%s)'#039';'#010+
  1218. ' SDbgTargetIsNotAUnitOrProgram = '#039'Skipping Target %s, not an unit'+
  1219. ' or program'#039';'#010+
  1220. ' SDbgConsideringTarget = '#039'Considering target %s'#039';'#010+
  1221. ' SDbgConsideringPackage = '#039'Considering package %s'#039,';'#010+
  1222. ' SDbgExternalDependency = '#039'External dependency %s found in "%s'+
  1223. '"'#039';'#010+
  1224. ' SDbgBuildEngineArchiving = '#039'Build engine archiving'#039';'#010+
  1225. ' SDbgBuildEngineGenerateManifests = '#039'Build engine generating mani'+
  1226. 'fests'#039';'#010+
  1227. ' SDbgBuildEngineCleaning = '#039'Build e','ngine cleaning'#039';'#010+
  1228. ' SDbgGenerating = '#039'Generating "%s"'#039';'#010+
  1229. ' SDbgLoading = '#039'Loading "%s"'#039';'#010+
  1230. ' SDbgFound = '#039'Found'#039';'#010+
  1231. ' SDbgNotFound = '#039'Not Found'#039';'#010+
  1232. ' SDbgDirectoryExists = '#039'Directory "%s" ','%s'#039';'#010+
  1233. ' SDbgFileExists = '#039'File "%s" %s'#039';'#010+
  1234. ' SDbgArchivingFile = '#039'Archiving "%s"'#039';'#010+
  1235. ' SDbgSearchPath = '#039'Using %s path "%s"'#039';'#010+
  1236. ' SDbgEnterDir = '#039'Entering directory "%s"'#039';'#010+
  1237. ' SDbgPackageChecksumChanged = '#039,'Dependent package %s is modified'#039+
  1238. ';'#010+
  1239. #010+
  1240. ' // Help messages for usage'#010+
  1241. ' SValue = '#039'Value'#039';'#010+
  1242. ' SHelpUsage = '#039'Usage: %s command [options]'#039';'#010+
  1243. ' SHelpCommand = '#039'Where command is one of the following:'#039+
  1244. ';'#010+
  1245. ' SHelpCompile ',' = '#039'Compile all units in the package(s).'#039+
  1246. ';'#010+
  1247. ' SHelpBuild = '#039'Build all units in the package(s).'#039';'#010+
  1248. ' SHelpInstall = '#039'Install all units in the package(s).'#039';'+
  1249. #010+
  1250. ' SHelpClean = '#039'Clean (remove) all units in the package(s'+
  1251. ').'#039';'#010,
  1252. ' SHelpArchive = '#039'Create archive (zip) with all units in th'+
  1253. 'e package(s).'#039';'#010+
  1254. ' SHelpHelp = '#039'This message.'#039';'#010+
  1255. ' SHelpManifest = '#039'Create a manifest suitable for import in '+
  1256. 'repository.'#039';'#010+
  1257. ' SHelpCmdOptions = '#039'Where option','s is one or more of the fol'+
  1258. 'lowing:'#039';'#010+
  1259. ' SHelpCPU = '#039'Compile for indicated CPU.'#039';'#010+
  1260. ' SHelpOS = '#039'Compile for indicated OS'#039';'#010+
  1261. ' SHelpTarget = '#039'Compile for indicated target'#039';'#010+
  1262. ' SHelpList = '#039'list commands in','stead of actually execu'+
  1263. 'ting them.'#039';'#010+
  1264. ' SHelpPrefix = '#039'Use indicated prefix directory for all co'+
  1265. 'mmands.'#039';'#010+
  1266. ' SHelpNoFPCCfg = '#039'Compiler will not use fpc.cfg'#039';'#010+
  1267. ' SHelpBaseInstallDir = '#039'Use indicated directory as base install d'+
  1268. 'ir.'#039';',#010+
  1269. ' SHelpLocalUnitDir = '#039'Use indicated directory as local (user) u'+
  1270. 'nit dir.'#039';'#010+
  1271. ' SHelpGlobalUnitDir = '#039'Use indicated directory as global unit di'+
  1272. 'r.'#039';'#010+
  1273. ' SHelpCompiler = '#039'Use indicated binary as compiler'#039';'#010+
  1274. ' SHelpConfig = '#039'Use in','dicated config file when compilin'+
  1275. 'g.'#039';'#010+
  1276. ' SHelpVerbose = '#039'Be verbose when working.'#039';'#010+
  1277. #010+
  1278. #010+
  1279. 'Const'#010+
  1280. ' // Keys for Defaults file. Do not localize.'#010+
  1281. ' KeyCompiler = '#039'Compiler'#039';'#010+
  1282. ' KeyArchive = '#039'Archive'#039';'#010+
  1283. ' KeyCopy = '#039'Copy'#039';'#010+
  1284. ' KeyMkDir = '#039,'MkDir'#039';'#010+
  1285. ' KeyMove = '#039'Move'#039';'#010+
  1286. ' KeyRemove = '#039'Remove'#039';'#010+
  1287. ' KeyOptions = '#039'Options'#039';'#010+
  1288. ' KeyCPU = '#039'CPU'#039';'#010+
  1289. ' KeyOS = '#039'OS'#039';'#010+
  1290. ' KeyMode = '#039'Mode'#039';'#010+
  1291. ' KeyPrefix = '#039'Prefix'#039';'#010+
  1292. ' KeyTarget = '#039'Target'#039';'#010+
  1293. ' KeyNoFPCCfg = '#039'NoFPCCfg'#039';'#010+
  1294. ' KeyL','ocalUnitDir = '#039'LocalUnitDir'#039';'#010+
  1295. ' KeyGlobalUnitDir = '#039'GlobalUnitDir'#039';'#010+
  1296. ' KeyBaseInstallDir = '#039'BaseInstallDir'#039';'#010+
  1297. ' KeyUnitInstallDir = '#039'UnitInstallDir'#039';'#010+
  1298. ' KeyBinInstallDir = '#039'BinInstallDir'#039';'#010+
  1299. ' KeyDocInstallDir = '#039'Doc','InstallDir'#039';'#010+
  1300. ' KeyExamplesInstallDir = '#039'ExamplesInstallDir'#039';'#010+
  1301. ' // Keys for unit config'#010+
  1302. ' KeyName = '#039'Name'#039';'#010+
  1303. ' KeyVersion = '#039'Version'#039';'#010+
  1304. ' KeyChecksum = '#039'Checksum'#039';'#010+
  1305. ' KeyNeedLibC = '#039'NeedLibC'#039';'#010+
  1306. ' KeyDepends = '#039'Depends'#039';'#010+
  1307. #010+
  1308. '{*****************','**************************************************'+
  1309. '*********'#010+
  1310. ' Helpers'#010+
  1311. '**********************************************************************'+
  1312. '******}'#010+
  1313. #010+
  1314. #010+
  1315. 'Function QuoteXML(S : String) : string;'#010+
  1316. #010+
  1317. ' Procedure W(Var J',' : Integer; Var R : String; T : String);'#010+
  1318. ' Var'#010+
  1319. ' I: integer;'#010+
  1320. ' begin'#010+
  1321. ' If J+Length(T)>Length(R) then'#010+
  1322. ' SetLength(R,J+Length(T));'#010+
  1323. ' For I:=1 to Length(t) do'#010+
  1324. ' begin'#010+
  1325. ' R[J]:=T[i];'#010+
  1326. ' If I<Length(T) then'#010+
  1327. ' Inc(J);'#010+
  1328. ' ',' end;'#010+
  1329. ' end;'#010+
  1330. #010+
  1331. 'const'#010+
  1332. ' QuotStr = '#039'&quot;'#039';'#010+
  1333. ' AmpStr = '#039'&amp;'#039';'#010+
  1334. ' ltStr = '#039'&lt;'#039';'#010+
  1335. ' gtStr = '#039'&gt;'#039';'#010+
  1336. 'Var'#010+
  1337. ' I,J : Integer;'#010+
  1338. 'begin'#010+
  1339. ' SetLength(Result,Length(S));'#010+
  1340. ' J:=0;'#010+
  1341. ' For I:=1 to Length(S) do'#010+
  1342. ' begin'#010+
  1343. ' Inc(J);'#010+
  1344. ' case S[i] of'#010+
  1345. ' '#039,'"'#039': W(j,Result,QuotStr);'#010+
  1346. ' '#039'&'#039': W(J,Result,AmpStr);'#010+
  1347. ' '#039'<'#039': W(J,Result,ltStr);'#010+
  1348. ' '#039'>'#039': W(J,Result,gtStr);'#010+
  1349. ' // Escape whitespace using CharRefs to be consistent with W3 spe'+
  1350. 'c X 3.3.3'#010+
  1351. ' #9: w(J,Result,'#039'&#x9;'#039');'#010+
  1352. '{ #10: ','wrtStr('#039'&#xA;'#039');'#010+
  1353. ' #13: wrtStr('#039'&#xD;'#039');}'#010+
  1354. ' else'#010+
  1355. ' Result[J]:=S[i];'#010+
  1356. ' end;'#010+
  1357. ' If (J=Length(Result)) and (I<Length(S)) then'#010+
  1358. ' SetLength(Result,J+Length(S)-I);'#010+
  1359. ' end;'#010+
  1360. ' If J<>Length(Result) then'#010+
  1361. ' SetLength(Result,J);'#010+
  1362. 'en','d;'#010+
  1363. #010+
  1364. #010+
  1365. 'function maybequoted(const s:string):string;'#010+
  1366. 'const'#010+
  1367. ' {$IFDEF MSWINDOWS}'#010+
  1368. ' FORBIDDEN_CHARS = ['#039'!'#039', '#039'@'#039', '#039'#'#039', '#039'$'#039+
  1369. ', '#039'%'#039', '#039'^'#039', '#039'&'#039', '#039'*'#039', '#039'('#039', '#039+
  1370. ')'#039','#010+
  1371. ' '#039'{'#039', '#039'}'#039', '#039#039#039#039', '#039'`'+
  1372. #039', '#039'~'#039'];'#010+
  1373. ' {$ELSE}'#010+
  1374. ' FORBIDDEN_CHARS = ['#039'!'#039', '#039'@',#039', '#039'#'#039', '#039'$'#039+
  1375. ', '#039'%'#039', '#039'^'#039', '#039'&'#039', '#039'*'#039', '#039'('#039', '#039+
  1376. ')'#039','#010+
  1377. ' '#039'{'#039', '#039'}'#039', '#039#039#039#039', '#039':'+
  1378. #039', '#039'\'#039', '#039'`'#039', '#039'~'#039'];'#010+
  1379. ' {$ENDIF}'#010+
  1380. 'var'#010+
  1381. ' s1 : string;'#010+
  1382. ' i : integer;'#010+
  1383. ' quoted : boolean;'#010+
  1384. 'begin'#010+
  1385. ' quoted:=false;'#010+
  1386. ' s1:='#039'"'#039';'#010+
  1387. ' for i:=1 to length(s) do'#010+
  1388. ' begin'#010+
  1389. ' ',' case s[i] of'#010+
  1390. ' '#039'"'#039' :'#010+
  1391. ' begin'#010+
  1392. ' quoted:=true;'#010+
  1393. ' s1:=s1+'#039'\"'#039';'#010+
  1394. ' end;'#010+
  1395. ' '#039' '#039','#010+
  1396. ' #128..#255 :'#010+
  1397. ' begin'#010+
  1398. ' quoted:=true;'#010+
  1399. ' s1:=s1+s[i];'#010+
  1400. ' end;'#010+
  1401. ' else begin'#010+
  1402. ' ',' if s[i] in FORBIDDEN_CHARS then'#010+
  1403. ' quoted:=True;'#010+
  1404. ' s1:=s1+s[i];'#010+
  1405. ' end;'#010+
  1406. ' end;'#010+
  1407. ' end;'#010+
  1408. ' if quoted then'#010+
  1409. ' maybequoted:=s1+'#039'"'#039#010+
  1410. ' else'#010+
  1411. ' maybequoted:=s;'#010+
  1412. 'end;'#010+
  1413. #010+
  1414. #010+
  1415. 'procedure ReadIniFile(Const AFileName: String;L:TSt','rings);'#010+
  1416. 'Var'#010+
  1417. ' F : TFileStream;'#010+
  1418. ' Line : String;'#010+
  1419. ' I,P,PC : Integer;'#010+
  1420. 'begin'#010+
  1421. ' F:=TFileStream.Create(AFileName,fmOpenRead);'#010+
  1422. ' Try'#010+
  1423. ' L.LoadFromStream(F);'#010+
  1424. ' // Fix lines.'#010+
  1425. ' For I:=L.Count-1 downto 0 do'#010+
  1426. ' begin'#010+
  1427. ' Line:=L[I];'#010+
  1428. ' ',' P:=Pos('#039'='#039',Line);'#010+
  1429. ' PC:=Pos('#039';'#039',Line); // Comment line.'#010+
  1430. ' If (P=0) or ((PC<>0) and (PC<P)) then'#010+
  1431. ' L.Delete(I)'#010+
  1432. ' else'#010+
  1433. ' L[i]:=Trim(System.Copy(Line,1,P-1)+'#039'='#039'+Trim(System.C'+
  1434. 'opy(Line,P+1,Length(Line)-P)));',#010+
  1435. ' end;'#010+
  1436. ' Finally'#010+
  1437. ' F.Free;'#010+
  1438. ' end;'#010+
  1439. 'end;'#010+
  1440. #010+
  1441. #010+
  1442. '// Callback for Sysutils getapplicationname.'#010+
  1443. 'Function GetFPMakeName : String;'#010+
  1444. #010+
  1445. 'begin'#010+
  1446. ' Result:='#039'fpmake'#039';'#010+
  1447. 'end;'#010+
  1448. #010+
  1449. #010+
  1450. 'Function CurrentOS : String;'#010+
  1451. #010+
  1452. 'begin'#010+
  1453. ' Result:=OSToString(Defaults.OS);'#010+
  1454. 'end;'#010+
  1455. #010+
  1456. 'Fun','ction CurrentCPU : String;'#010+
  1457. #010+
  1458. 'begin'#010+
  1459. ' Result:=CPUToString(Defaults.CPU);'#010+
  1460. 'end;'#010+
  1461. #010+
  1462. 'Function OSToString(OS: TOS) : String;'#010+
  1463. #010+
  1464. 'begin'#010+
  1465. ' Result:=LowerCase(GetenumName(TypeInfo(TOS),Ord(OS)));'#010+
  1466. 'end;'#010+
  1467. #010+
  1468. 'Function OSesToString(OSes: TOSes) : String;'#010+
  1469. #010+
  1470. 'begin'#010+
  1471. ' ','Result:=LowerCase(SetToString(PtypeInfo(TypeInfo(TOSes)),Integer(O'+
  1472. 'Ses),False));'#010+
  1473. 'end;'#010+
  1474. #010+
  1475. 'Function CPUToString(CPU: TCPU) : String;'#010+
  1476. #010+
  1477. 'begin'#010+
  1478. ' Result:=LowerCase(GetenumName(TypeInfo(TCPU),Ord(CPU)));'#010+
  1479. 'end;'#010+
  1480. #010+
  1481. 'Function CPUSToString(CPUS: TCPUS) : Str','ing;'#010+
  1482. #010+
  1483. 'begin'#010+
  1484. ' Result:=LowerCase(SetToString(PTypeInfo(TypeInfo(TCPUS)),Integer(CPU'+
  1485. 'S),False));'#010+
  1486. 'end;'#010+
  1487. #010+
  1488. 'Function StringToOS(const S : String) : TOS;'#010+
  1489. #010+
  1490. 'Var'#010+
  1491. ' I : Integer;'#010+
  1492. #010+
  1493. 'begin'#010+
  1494. ' I:=GetEnumValue(TypeInfo(TOS),S);'#010+
  1495. ' if (I=-1) then'#010+
  1496. ' Raise EInst','allerError.CreateFmt(SErrInvalidOS,[S]);'#010+
  1497. ' Result:=TOS(I);'#010+
  1498. 'end;'#010+
  1499. #010+
  1500. #010+
  1501. 'Function OSesToString(const S : String) : TOSes;'#010+
  1502. #010+
  1503. 'begin'#010+
  1504. ' Result:=TOSes(StringToSet(PTypeInfo(TypeInfo(TOSes)),S));'#010+
  1505. 'end;'#010+
  1506. #010+
  1507. 'Function StringToCPU(const S : String) : TCPU;'#010+
  1508. #010+
  1509. 'Var'#010,
  1510. ' I : Integer;'#010+
  1511. #010+
  1512. 'begin'#010+
  1513. ' I:=GetEnumValue(TypeInfo(TCPU),S);'#010+
  1514. ' if (I=-1) then'#010+
  1515. ' Raise EInstallerError.CreateFmt(SErrInvalidCPU,[S]);'#010+
  1516. ' Result:=TCPU(I);'#010+
  1517. 'end;'#010+
  1518. #010+
  1519. 'Function StringToCPUS(const S : String) : TCPUS;'#010+
  1520. #010+
  1521. 'begin'#010+
  1522. ' Result:=TCPUS(StringToSe','t(PTypeInfo(TypeInfo(TCPUS)),S));'#010+
  1523. 'end;'#010+
  1524. #010+
  1525. 'Function ModeToString(Mode: TCompilerMode) : String;'#010+
  1526. #010+
  1527. 'begin'#010+
  1528. ' Result:=LowerCase(GetenumName(TypeInfo(TCompilerMode),Ord(Mode)));'#010+
  1529. ' Delete(Result,1,2);'#010+
  1530. 'end;'#010+
  1531. #010+
  1532. 'Function StringToMode(const S : String) : T','CompilerMode;'#010+
  1533. #010+
  1534. 'Var'#010+
  1535. ' I : Integer;'#010+
  1536. #010+
  1537. 'begin'#010+
  1538. ' I:=GetEnumValue(TypeInfo(TCompilerMode),S);'#010+
  1539. ' if (I=-1) then'#010+
  1540. ' Raise EInstallerError.CreateFmt(SErrInvalidMode,[S]);'#010+
  1541. ' Result:=TCompilerMode(I);'#010+
  1542. 'end;'#010+
  1543. #010+
  1544. #010+
  1545. 'Function MakeTargetString(CPU : TCPU;OS: TO','S) : String;'#010+
  1546. #010+
  1547. 'begin'#010+
  1548. ' Result:=CPUToString(CPU)+'#039'-'#039'+OSToString(OS);'#010+
  1549. 'end;'#010+
  1550. #010+
  1551. 'Procedure StringToCPUOS(const S : String; Var CPU : TCPU; Var OS: TOS)'+
  1552. ';'#010+
  1553. #010+
  1554. 'Var'#010+
  1555. ' P : integer;'#010+
  1556. #010+
  1557. 'begin'#010+
  1558. ' P:=Pos('#039'-'#039',S);'#010+
  1559. ' If (P=0) then'#010+
  1560. ' Raise EInstallerError.CreateFmt','(SErrInvalidTarget,[S]);'#010+
  1561. ' CPU:=StringToCPU(Copy(S,1,P-1));'#010+
  1562. ' OS:=StringToOs(Copy(S,P+1,Length(S)-P));'#010+
  1563. 'end;'#010+
  1564. #010+
  1565. #010+
  1566. 'Procedure ResolveDependencies(L : TDependencies; P : TNamedCollection)'+
  1567. ';'#010+
  1568. 'Var'#010+
  1569. ' I,J : Integer;'#010+
  1570. ' C : TDependency;'#010+
  1571. 'begin'#010+
  1572. ' If Assigne','d(L) then'#010+
  1573. ' For I:=0 to L.Count-1 do'#010+
  1574. ' begin'#010+
  1575. ' C:=L[i];'#010+
  1576. ' if C.DependencyType in [depPackage,depUnit] then'#010+
  1577. ' begin'#010+
  1578. ' J:=P.IndexOfName(C.Value);'#010+
  1579. ' If J<>-1 then'#010+
  1580. ' C.Target:=P.Items[J]',';'#010+
  1581. ' end;'#010+
  1582. ' end;'#010+
  1583. 'end;'#010+
  1584. #010+
  1585. #010+
  1586. 'function AddConditionalStrings(Dest : TStrings; Src : TConditionalStri'+
  1587. 'ngs;ACPU:TCPU;AOS:TOS; Const APrefix : String='#039#039') : Integer ;'#010+
  1588. 'Var'#010+
  1589. ' I : Integer;'#010+
  1590. ' C : TConditionalString;'#010+
  1591. ' S : String;'#010+
  1592. 'begin'#010+
  1593. ' Result',':=0;'#010+
  1594. ' Dictionary.AddVariable('#039'CPU'#039',CPUToString(ACPU));'#010+
  1595. ' Dictionary.AddVariable('#039'OS'#039',OSToString(AOS));'#010+
  1596. ' For I:=0 to Src.Count-1 do'#010+
  1597. ' begin'#010+
  1598. ' C:=Src[I];'#010+
  1599. ' if (ACPU in C.CPUs) and (AOS in C.OSes) then'#010+
  1600. ' begin'#010+
  1601. ' If (A','Prefix<>'#039#039') then'#010+
  1602. ' S:=APrefix+C.Value'#010+
  1603. ' else'#010+
  1604. ' S:=C.Value;'#010+
  1605. ' Dest.Add(Dictionary.ReplaceStrings(S));'#010+
  1606. ' Inc(Result);'#010+
  1607. ' end;'#010+
  1608. ' end;'#010+
  1609. 'end;'#010+
  1610. #010+
  1611. #010+
  1612. 'function FileListToString(List : TStrings; const AP','refix : String) :'+
  1613. ' String;'#010+
  1614. 'Var'#010+
  1615. ' I : integer;'#010+
  1616. ' S : String;'#010+
  1617. 'begin'#010+
  1618. ' Result:='#039#039';'#010+
  1619. ' For I:=0 to List.Count-1 do'#010+
  1620. ' begin'#010+
  1621. ' If (I>0) then'#010+
  1622. ' Result:=Result+'#039' '#039';'#010+
  1623. ' S:=APrefix+List[i];'#010+
  1624. ' If (Pos('#039' '#039',S)<>0) then'#010+
  1625. ' S:='#039'"'#039'+S+',#039'"'#039';'#010+
  1626. ' Result:=Result+S;'#010+
  1627. ' end;'#010+
  1628. 'end;'#010+
  1629. #010+
  1630. #010+
  1631. 'function FixPath (const APath : String) : String;'#010+
  1632. 'Var'#010+
  1633. ' P : PChar;'#010+
  1634. 'begin'#010+
  1635. ' Result:=APath;'#010+
  1636. ' If (result<>'#039#039') then'#010+
  1637. ' begin'#010+
  1638. ' P:=PChar(Result);'#010+
  1639. ' While (P^<>#0) do'#010+
  1640. ' begin'#010+
  1641. ' ','If P^ in ['#039'/'#039','#039'\'#039'] then'#010+
  1642. ' P^:=PathDelim;'#010+
  1643. ' Inc(P);'#010+
  1644. ' end;'#010+
  1645. ' end;'#010+
  1646. 'end;'#010+
  1647. #010+
  1648. #010+
  1649. 'procedure ChangeDir(const APath : String);'#010+
  1650. 'begin'#010+
  1651. ' if Not SetCurrentDir(APath) then'#010+
  1652. ' Raise EInstallerError.CreateFmt(SErrChangeDirFailed,[A','Path]);'#010+
  1653. 'end;'#010+
  1654. #010+
  1655. #010+
  1656. 'procedure SearchFiles(const AFileName: string; Recursive: boolean; var'+
  1657. ' List: TStrings);'#010+
  1658. #010+
  1659. ' procedure AddRecursiveFiles(const SearchDir, FileMask: string; Recur'+
  1660. 'sive: boolean);'#010+
  1661. ' const'#010+
  1662. ' IgnoreCase = {$ifdef UNIX}False{$else}','True{$endif};'#010+
  1663. ' var'#010+
  1664. ' Info : TSearchRec;'#010+
  1665. ' begin'#010+
  1666. ' if FindFirst(SearchDir+'#039'*'#039',faAnyFile and faDirectory,Info)'+
  1667. '=0 then'#010+
  1668. ' begin'#010+
  1669. ' repeat'#010+
  1670. ' if ((Info.Attr and faDirectory) = faDirectory) and (Info.Nam'+
  1671. 'e <> '#039'.'#039') and (Info.Name <','> '#039'..'#039') and (Recursive) th'+
  1672. 'en'#010+
  1673. ' AddRecursiveFiles(SearchDir + Info.Name + PathDelim, FileM'+
  1674. 'ask, Recursive);'#010+
  1675. ' if ((Info.Attr and faDirectory) <> faDirectory) and IsWild(I'+
  1676. 'nfo.Name, FileMask, IgnoreCase) then'#010+
  1677. ' List.','Add(SearchDir + Info.Name);'#010+
  1678. ' until FindNext(Info)<>0;'#010+
  1679. ' end;'#010+
  1680. ' FindClose(Info);'#010+
  1681. ' end;'#010+
  1682. #010+
  1683. 'var'#010+
  1684. ' CurrDir,'#010+
  1685. ' BasePath: string;'#010+
  1686. ' i: integer;'#010+
  1687. 'begin'#010+
  1688. ' BasePath := ExtractFilePath(ExpandFileName(AFileName));'#010+
  1689. ' AddRecursiveFiles(BasePath, ','ExtractFileName(AFileName), Recursive)'+
  1690. ';'#010+
  1691. #010+
  1692. ' CurrDir:=GetCurrentDir;'#010+
  1693. ' for i := 0 to Pred(List.Count) do'#010+
  1694. ' List[i] := ExtractRelativepath(IncludeTrailingPathDelimiter(CurrDi'+
  1695. 'r), List[i]);'#010+
  1696. 'end;'#010+
  1697. #010+
  1698. #010+
  1699. 'procedure SplitCommand(const Cmd : String; var',' Exe, Options : String'+
  1700. ');'#010+
  1701. #010+
  1702. 'Const'#010+
  1703. ' WhiteSpace = [#9,#10,#13,'#039' '#039'];'#010+
  1704. ' QuoteChars = ['#039#039#039#039','#039'"'#039'];'#010+
  1705. #010+
  1706. 'Var'#010+
  1707. ' I : Integer;'#010+
  1708. ' InQuote : Boolean;'#010+
  1709. ' LastQuote : Char;'#010+
  1710. ' S : String;'#010+
  1711. #010+
  1712. 'begin'#010+
  1713. ' S:=Trim(Cmd);'#010+
  1714. ' InQuote:=False;'#010+
  1715. ' LastQuote:=#0;'#010+
  1716. ' I:=1;'#010+
  1717. ' While',' (I<=Length(S)) and (Inquote or not (S[I] in whiteSpace)) do'#010+
  1718. ' begin'#010+
  1719. ' If S[i] in QuoteChars then'#010+
  1720. ' begin'#010+
  1721. ' InQuote:=Not (S[i]=LastQuote);'#010+
  1722. ' If InQuote then'#010+
  1723. ' LastQuote:=S[i]'#010+
  1724. ' else'#010+
  1725. ' LastQuote:=#0;'#010+
  1726. ' ','end;'#010+
  1727. ' Inc(I);'#010+
  1728. ' end;'#010+
  1729. ' Exe:=Copy(S,1,I-1);'#010+
  1730. ' Delete(S,1,I);'#010+
  1731. ' Options:=Trim(S);'#010+
  1732. 'end;'#010+
  1733. #010+
  1734. #010+
  1735. '{$ifdef HAS_UNIT_PROCESS}'#010+
  1736. 'function GetCompilerInfo(const ACompiler,AOptions:string):string;'#010+
  1737. 'const'#010+
  1738. ' BufSize = 1024;'#010+
  1739. 'var'#010+
  1740. ' S: TProcess;'#010+
  1741. ' Buf: array ','[0..BufSize - 1] of char;'#010+
  1742. ' Count: longint;'#010+
  1743. 'begin'#010+
  1744. ' S:=TProcess.Create(Nil);'#010+
  1745. ' S.Commandline:=ACompiler+'#039' '#039'+AOptions;'#010+
  1746. ' S.Options:=[poUsePipes];'#010+
  1747. ' S.execute;'#010+
  1748. ' Count:=s.output.read(buf,BufSize);'#010+
  1749. ' S.Free;'#010+
  1750. ' SetLength(Result,Count);'#010+
  1751. ' Move(B','uf,Result[1],Count);'#010+
  1752. 'end;'#010+
  1753. '{$endif HAS_UNIT_PROCESS}'#010+
  1754. #010+
  1755. #010+
  1756. '{*********************************************************************'+
  1757. '*******'#010+
  1758. ' TNamedItem'#010+
  1759. '*****************************************************************','***'+
  1760. '********}'#010+
  1761. #010+
  1762. 'procedure TNamedItem.SetName(const AValue: String);'#010+
  1763. #010+
  1764. 'begin'#010+
  1765. ' if FName=AValue then exit;'#010+
  1766. ' With TNamedCollection(Collection) do'#010+
  1767. ' If UniqueNames then'#010+
  1768. ' If (IndexOfName(AVAlue)<>-1) then'#010+
  1769. ' Raise ECollectionError.Crea','teFmt(SErrNameExists,[AValue]);'#010+
  1770. ' FName:=AValue;'#010+
  1771. 'end;'#010+
  1772. #010+
  1773. #010+
  1774. '{*********************************************************************'+
  1775. '*******'#010+
  1776. ' TNamedCollection'#010+
  1777. '*********************************************************','***********'+
  1778. '********}'#010+
  1779. #010+
  1780. 'function TNamedCollection.IndexOfName(const AName: String): Integer;'#010+
  1781. #010+
  1782. 'begin'#010+
  1783. ' Result:=Count-1;'#010+
  1784. ' While (Result>=0) and (CompareText(TNamedItem(Items[Result]).FName,A'+
  1785. 'Name)<>0) do'#010+
  1786. ' Dec(Result);'#010+
  1787. 'end;'#010+
  1788. #010+
  1789. 'function TNamedCo','llection.ItemByName(const AName: String): TNamedIte'+
  1790. 'm;'#010+
  1791. #010+
  1792. 'Var'#010+
  1793. ' I : Integer;'#010+
  1794. #010+
  1795. 'begin'#010+
  1796. ' I:=IndexOfName(AName);'#010+
  1797. ' If (I=-1) Then'#010+
  1798. ' Raise ECollectionError.CreateFmt(SErrNoSuchName,[AName]);'#010+
  1799. ' Result:=TNamedItem(Items[i]);'#010+
  1800. 'end;'#010+
  1801. #010+
  1802. #010+
  1803. '{***************','****************************************************'+
  1804. '*********'#010+
  1805. ' TNamedItemList'#010+
  1806. '**********************************************************************'+
  1807. '******}'#010+
  1808. #010+
  1809. 'function TNamedItemList.GetNamedItem(Index : Integer): ','TNamedItem;'#010+
  1810. 'begin'#010+
  1811. ' Result:=TNamedItem(Items[Index]);'#010+
  1812. 'end;'#010+
  1813. #010+
  1814. #010+
  1815. 'procedure TNamedItemList.SetNamedItem(Index : Integer; const AValue: T'+
  1816. 'NamedItem);'#010+
  1817. 'begin'#010+
  1818. ' Items[Index]:=AValue;'#010+
  1819. 'end;'#010+
  1820. #010+
  1821. #010+
  1822. 'function TNamedItemList.IndexOfName(const AName: String): In','teger;'#010+
  1823. 'begin'#010+
  1824. ' Result:=Count-1;'#010+
  1825. ' While (Result>=0) and (CompareText(GetNamedItem(Result).Name,AName)<'+
  1826. '>0) do'#010+
  1827. ' Dec(Result);'#010+
  1828. 'end;'#010+
  1829. #010+
  1830. #010+
  1831. 'function TNamedItemList.ItemByName(const ANAme: String): TNamedItem;'#010+
  1832. 'Var'#010+
  1833. ' I : Integer;'#010+
  1834. 'begin'#010+
  1835. ' I:=IndexOfN','ame(AName);'#010+
  1836. ' If (I=-1) Then'#010+
  1837. ' Raise ECollectionError.CreateFmt(SErrNoSuchName,[AName]);'#010+
  1838. ' Result:=TNamedItem(Items[i]);'#010+
  1839. 'end;'#010+
  1840. #010+
  1841. #010+
  1842. '{*********************************************************************'+
  1843. '*******'#010+
  1844. ' ','TTargets'#010+
  1845. '**********************************************************************'+
  1846. '******}'#010+
  1847. #010+
  1848. 'function TTargets.GetTargetItem(Index : Integer): TTarget;'#010+
  1849. 'begin'#010+
  1850. ' Result:=TTarget(Items[Index]);'#010+
  1851. 'end;'#010+
  1852. #010+
  1853. #010+
  1854. 'function TTargets.GetTarget(const AName : Strin','g): TTarget;'#010+
  1855. 'begin'#010+
  1856. ' Result:=TTarget(ItemByName(AName));'#010+
  1857. 'end;'#010+
  1858. #010+
  1859. #010+
  1860. 'procedure TTargets.SetTargetItem(Index : Integer; const AValue: TTarge'+
  1861. 't);'#010+
  1862. 'begin'#010+
  1863. ' Items[Index]:=AValue;'#010+
  1864. 'end;'#010+
  1865. #010+
  1866. #010+
  1867. 'Function TTargets.AddUnit(Const AUnitName : String) : TTarget;'#010+
  1868. 'be','gin'#010+
  1869. ' Result:=AddUnit(AUnitName,AllCPUs,AllOSes);'#010+
  1870. 'end;'#010+
  1871. #010+
  1872. #010+
  1873. 'Function TTargets.AddUnit(Const AUnitName : String;const OSes:TOSes) :'+
  1874. ' TTarget;'#010+
  1875. 'begin'#010+
  1876. ' Result:=AddUnit(AUnitName,AllCPUs,OSes);'#010+
  1877. 'end;'#010+
  1878. #010+
  1879. #010+
  1880. '{$ifdef cpu_only_overloads}'#010+
  1881. 'Function TTargets.A','ddUnit(Const AUnitName : String;const CPUs:TCPUs)'+
  1882. ' : TTarget;'#010+
  1883. 'begin'#010+
  1884. ' Result:=AddUnit(AUnitName,CPUs,AllOSes);'#010+
  1885. 'end;'#010+
  1886. '{$endif cpu_only_overloads}'#010+
  1887. #010+
  1888. #010+
  1889. 'Function TTargets.AddUnit(Const AUnitName : String;const CPUs:TCPUs;co'+
  1890. 'nst OSes:TOSes) : TTarget',';'#010+
  1891. 'begin'#010+
  1892. ' Result:=Add as TTarget;'#010+
  1893. ' Result.Name:=AUnitName;'#010+
  1894. ' Result.TargetType:=TTUnit;'#010+
  1895. ' Result.CPUs:=CPUs;'#010+
  1896. ' Result.OSes:=OSes;'#010+
  1897. 'end;'#010+
  1898. #010+
  1899. #010+
  1900. 'Function TTargets.AddImplicitUnit(Const AUnitName : String;InstallUnit'+
  1901. ':boolean=true) : TTarget;'#010+
  1902. 'begin'#010,
  1903. ' Result:=AddImplicitUnit(AUnitName,AllCPUs,AllOSes,InstallUnit);'#010+
  1904. 'end;'#010+
  1905. #010+
  1906. #010+
  1907. 'Function TTargets.AddImplicitUnit(Const AUnitName : String;const OSes:'+
  1908. 'TOSes;InstallUnit:boolean=true) : TTarget;'#010+
  1909. 'begin'#010+
  1910. ' Result:=AddImplicitUnit(AUnitName,AllCPUs,OSes',',InstallUnit);'#010+
  1911. 'end;'#010+
  1912. #010+
  1913. #010+
  1914. 'Function TTargets.AddImplicitUnit(Const AUnitName : String;const CPUs:'+
  1915. 'TCPUs;InstallUnit:boolean=true) : TTarget;'#010+
  1916. 'begin'#010+
  1917. ' Result:=AddImplicitUnit(AUnitName,CPUs,AllOSes,InstallUnit);'#010+
  1918. 'end;'#010+
  1919. #010+
  1920. #010+
  1921. 'Function TTargets.AddImplicit','Unit(Const AUnitName : String;const CPU'+
  1922. 's:TCPUs;const OSes:TOSes;InstallUnit:boolean=true) : TTarget;'#010+
  1923. 'begin'#010+
  1924. ' Result:=Add as TTarget;'#010+
  1925. ' Result.Name:=AUnitName;'#010+
  1926. ' Result.CPUs:=CPUs;'#010+
  1927. ' Result.OSes:=OSes;'#010+
  1928. ' if InstallUnit then'#010+
  1929. ' Result.Target','Type:=TTImplicitUnit'#010+
  1930. ' else'#010+
  1931. ' Result.TargetType:=TTCleanOnlyUnit;'#010+
  1932. 'end;'#010+
  1933. #010+
  1934. #010+
  1935. 'Function TTargets.AddProgram(Const AProgramName : String) : TTarget;'#010+
  1936. 'begin'#010+
  1937. ' Result:=AddProgram(AProgramName,AllCPUs,AllOSes);'#010+
  1938. 'end;'#010+
  1939. #010+
  1940. #010+
  1941. 'Function TTargets.AddProgram(Co','nst AProgramName : String;const OSes:'+
  1942. 'TOSes) : TTarget;'#010+
  1943. 'begin'#010+
  1944. ' Result:=AddProgram(AProgramName,AllCPUs,OSes);'#010+
  1945. 'end;'#010+
  1946. #010+
  1947. #010+
  1948. '{$ifdef cpu_only_overloads}'#010+
  1949. 'Function TTargets.AddProgram(Const AProgramName : String;const CPUs:TC'+
  1950. 'PUs) : TTarget;'#010+
  1951. 'begin'#010+
  1952. ' R','esult:=AddProgram(AProgramName,CPUs,AllOSes);'#010+
  1953. 'end;'#010+
  1954. '{$endif cpu_only_overloads}'#010+
  1955. #010+
  1956. #010+
  1957. 'Function TTargets.AddProgram(Const AProgramName : String;const CPUs:TC'+
  1958. 'PUs;const OSes:TOSes) : TTarget;'#010+
  1959. 'begin'#010+
  1960. ' Result:=Add as TTarget;'#010+
  1961. ' Result.Name:=AProgramN','ame;'#010+
  1962. ' Result.CPUs:=CPUs;'#010+
  1963. ' Result.OSes:=OSes;'#010+
  1964. ' Result.TargetType:=ttProgram;'#010+
  1965. 'end;'#010+
  1966. #010+
  1967. #010+
  1968. 'Function TTargets.AddExampleUnit(Const AUnitName : String) : TTarget;'#010+
  1969. 'begin'#010+
  1970. ' Result:=AddExampleUnit(AUnitName,AllCPUs,AllOSes);'#010+
  1971. 'end;'#010+
  1972. #010+
  1973. #010+
  1974. 'Function TTargets.','AddExampleUnit(Const AUnitName : String;const OSes'+
  1975. ':TOSes) : TTarget;'#010+
  1976. 'begin'#010+
  1977. ' Result:=AddExampleUnit(AUnitName,AllCPUs,OSes);'#010+
  1978. 'end;'#010+
  1979. #010+
  1980. #010+
  1981. '{$ifdef cpu_only_overloads}'#010+
  1982. 'Function TTargets.AddExampleUnit(Const AUnitName : String;const CPUs:T'+
  1983. 'CPUs) : TT','arget;'#010+
  1984. 'begin'#010+
  1985. ' Result:=AddExampleUnit(AUnitName,CPUs,AllOSes);'#010+
  1986. 'end;'#010+
  1987. '{$endif cpu_only_overloads}'#010+
  1988. #010+
  1989. #010+
  1990. 'Function TTargets.AddExampleUnit(Const AUnitName : String;const CPUs:T'+
  1991. 'CPUs;const OSes:TOSes) : TTarget;'#010+
  1992. 'begin'#010+
  1993. ' Result:=Add as TTarget;'#010+
  1994. ' Resu','lt.Name:=AUnitName;'#010+
  1995. ' Result.CPUs:=CPUs;'#010+
  1996. ' Result.OSes:=OSes;'#010+
  1997. ' Result.TargetType:=ttExampleUnit;'#010+
  1998. 'end;'#010+
  1999. #010+
  2000. #010+
  2001. 'Function TTargets.AddExampleProgram(Const AProgramName : String) : TTa'+
  2002. 'rget;'#010+
  2003. 'begin'#010+
  2004. ' Result:=AddExampleProgram(AProgramName,AllCPUs,AllO','Ses);'#010+
  2005. 'end;'#010+
  2006. #010+
  2007. #010+
  2008. 'Function TTargets.AddExampleProgram(Const AProgramName : String;const '+
  2009. 'OSes:TOSes) : TTarget;'#010+
  2010. 'begin'#010+
  2011. ' Result:=AddExampleProgram(AProgramName,AllCPUs,OSes);'#010+
  2012. 'end;'#010+
  2013. #010+
  2014. #010+
  2015. '{$ifdef cpu_only_overloads}'#010+
  2016. 'Function TTargets.AddExampleProgram(C','onst AProgramName : String;cons'+
  2017. 't CPUs:TCPUs) : TTarget;'#010+
  2018. 'begin'#010+
  2019. ' Result:=AddExampleProgram(AProgramName,CPUs,AllOSes);'#010+
  2020. 'end;'#010+
  2021. '{$endif cpu_only_overloads}'#010+
  2022. #010+
  2023. #010+
  2024. 'Function TTargets.AddExampleProgram(Const AProgramName : String;const '+
  2025. 'CPUs:TCPUs;const ','OSes:TOSes) : TTarget;'#010+
  2026. 'begin'#010+
  2027. ' Result:=Add as TTarget;'#010+
  2028. ' Result.Name:=AProgramName;'#010+
  2029. ' Result.CPUs:=CPUs;'#010+
  2030. ' Result.OSes:=OSes;'#010+
  2031. ' Result.TargetType:=ttExampleProgram;'#010+
  2032. 'end;'#010+
  2033. #010+
  2034. #010+
  2035. '{*******************************************************************','*'+
  2036. '********'#010+
  2037. ' TSources'#010+
  2038. '**********************************************************************'+
  2039. '******}'#010+
  2040. #010+
  2041. 'function TSources.GetSourceItem(Index : Integer): TSource;'#010+
  2042. 'begin'#010+
  2043. ' Result:=TSource(Items[Index]);'#010+
  2044. 'end;'#010+
  2045. #010+
  2046. #010+
  2047. 'proce','dure TSources.SetSourceItem(Index : Integer; const AValue: TSou'+
  2048. 'rce);'#010+
  2049. 'begin'#010+
  2050. ' Items[Index]:=AValue;'#010+
  2051. 'end;'#010+
  2052. #010+
  2053. #010+
  2054. 'function TSources.AddDoc (const AFiles : String) : TSource;'#010+
  2055. 'begin'#010+
  2056. ' Result:=Add as TSource;'#010+
  2057. ' Result.Name:=AFiles;'#010+
  2058. ' Result.FSourceTyp','e:=stDoc;'#010+
  2059. 'end;'#010+
  2060. #010+
  2061. #010+
  2062. 'function TSources.AddSrc(const AFiles : String) : TSource;'#010+
  2063. 'begin'#010+
  2064. ' Result:=Add as TSource;'#010+
  2065. ' Result.Name:=AFiles;'#010+
  2066. ' Result.FSourceType:=stSrc;'#010+
  2067. 'end;'#010+
  2068. #010+
  2069. #010+
  2070. 'function TSources.AddExample(const AFiles : String) : TSource;'#010+
  2071. 'begin'#010+
  2072. ' Re','sult:=Add as TSource;'#010+
  2073. ' Result.Name:=AFiles;'#010+
  2074. ' Result.FSourceType:=stExample;'#010+
  2075. 'end;'#010+
  2076. #010+
  2077. #010+
  2078. 'function TSources.AddTest(const AFiles : String) : TSource;'#010+
  2079. 'begin'#010+
  2080. ' Result:=Add as TSource;'#010+
  2081. ' Result.Name:=AFiles;'#010+
  2082. ' Result.FSourceType:=stTest;'#010+
  2083. 'end;'#010+
  2084. #010+
  2085. #010+
  2086. 'pro','cedure TSources.AddDocFiles(const AFileMask: string; Recursive: b'+
  2087. 'oolean);'#010+
  2088. 'var'#010+
  2089. ' List : TStrings;'#010+
  2090. ' i: integer;'#010+
  2091. 'begin'#010+
  2092. ' List := TStringList.Create;'#010+
  2093. ' SearchFiles(AFileMask, Recursive, List);'#010+
  2094. ' for i:= 0 to Pred(List.Count) do'#010+
  2095. ' AddDoc(List','[i]);'#010+
  2096. ' List.Free;'#010+
  2097. 'end;'#010+
  2098. #010+
  2099. #010+
  2100. 'procedure TSources.AddSrcFiles(const AFileMask: string; Recursive: boo'+
  2101. 'lean);'#010+
  2102. 'var'#010+
  2103. ' List : TStrings;'#010+
  2104. ' i: integer;'#010+
  2105. 'begin'#010+
  2106. ' List := TStringList.Create;'#010+
  2107. ' SearchFiles(AFileMask, Recursive, List);'#010+
  2108. ' for i:= 0 to Pred(L','ist.Count) do'#010+
  2109. ' AddSrc(List[i]);'#010+
  2110. ' List.Free;'#010+
  2111. 'end;'#010+
  2112. #010+
  2113. #010+
  2114. 'procedure TSources.AddExampleFiles(const AFileMask: string; Recursive:'+
  2115. ' boolean);'#010+
  2116. 'var'#010+
  2117. ' List : TStrings;'#010+
  2118. ' i: integer;'#010+
  2119. 'begin'#010+
  2120. ' List := TStringList.Create;'#010+
  2121. ' SearchFiles(AFileMask, Recurs','ive, List);'#010+
  2122. ' for i:= 0 to Pred(List.Count) do'#010+
  2123. ' AddExample(List[i]);'#010+
  2124. ' List.Free;'#010+
  2125. 'end;'#010+
  2126. #010+
  2127. #010+
  2128. 'procedure TSources.AddTestFiles(const AFileMask: string; Recursive: bo'+
  2129. 'olean);'#010+
  2130. 'var'#010+
  2131. ' List : TStrings;'#010+
  2132. ' i: integer;'#010+
  2133. 'begin'#010+
  2134. ' List := TStringList.Creat','e;'#010+
  2135. ' SearchFiles(AFileMask, Recursive, List);'#010+
  2136. ' for i:= 0 to Pred(List.Count) do'#010+
  2137. ' AddTest(List[i]);'#010+
  2138. ' List.Free;'#010+
  2139. 'end;'#010+
  2140. #010+
  2141. #010+
  2142. '{*********************************************************************'+
  2143. '*******'#010+
  2144. ' TPackage'#010+
  2145. '*','*******************************************************************'+
  2146. '********}'#010+
  2147. #010+
  2148. 'constructor TPackage.Create(ACollection: TCollection);'#010+
  2149. 'begin'#010+
  2150. ' inherited Create(ACollection);'#010+
  2151. ' FVersion:=TFPVersion.Create;'#010+
  2152. ' FTargets:=TTargets.Create(TTarget);',#010+
  2153. ' FSources:=TSources.Create(TSource);'#010+
  2154. ' FDependencies:=TDependencies.Create(TDependency);'#010+
  2155. ' FInstallFiles:=TConditionalStrings.Create(TConditionalString);'#010+
  2156. ' FCleanFiles:=TConditionalStrings.Create(TConditionalString);'#010+
  2157. ' FUnitPath:=TConditi','onalStrings.Create(TConditionalString);'#010+
  2158. ' FObjectPath:=TConditionalStrings.Create(TConditionalString);'#010+
  2159. ' FIncludePath:=TConditionalStrings.Create(TConditionalString);'#010+
  2160. ' FSourcePath:=TConditionalStrings.Create(TConditionalString);'#010+
  2161. ' FExample','Path:=TConditionalStrings.Create(TConditionalString);'#010+
  2162. ' FTestPath:=TConditionalStrings.Create(TConditionalString);'#010+
  2163. ' FCommands:=TCommands.Create(TCommand);'#010+
  2164. ' FCPUs:=AllCPUs;'#010+
  2165. ' FOSes:=AllOSes;'#010+
  2166. ' FInstalledChecksum:=$ffffffff;'#010+
  2167. ' // Implicit d','ependency on RTL'#010+
  2168. ' FDependencies.Add('#039'rtl'#039');'#010+
  2169. 'end;'#010+
  2170. #010+
  2171. #010+
  2172. 'destructor TPackage.destroy;'#010+
  2173. 'begin'#010+
  2174. ' FreeAndNil(FDependencies);'#010+
  2175. ' FreeAndNil(FInstallFiles);'#010+
  2176. ' FreeAndNil(FCleanFiles);'#010+
  2177. ' FreeAndNil(FIncludePath);'#010+
  2178. ' FreeAndNil(FSourcePath);'#010+
  2179. ' FreeAndNil(','FExamplePath);'#010+
  2180. ' FreeAndNil(FTestPath);'#010+
  2181. ' FreeAndNil(FObjectPath);'#010+
  2182. ' FreeAndNil(FUnitPath);'#010+
  2183. ' FreeAndNil(FSources);'#010+
  2184. ' FreeAndNil(FTargets);'#010+
  2185. ' FreeAndNil(FVersion);'#010+
  2186. ' inherited destroy;'#010+
  2187. 'end;'#010+
  2188. #010+
  2189. #010+
  2190. 'procedure TPackage.SetName(const AValue: String)',';'#010+
  2191. 'begin'#010+
  2192. ' inherited SetName(AValue);'#010+
  2193. ' // RTL should not have any dependencies'#010+
  2194. ' if AValue='#039'rtl'#039' then'#010+
  2195. ' FDependencies.Clear;'#010+
  2196. 'end;'#010+
  2197. #010+
  2198. #010+
  2199. 'Function TPackage.GetUnitsOutputDir(ACPU:TCPU; AOS : TOS):String;'#010+
  2200. 'begin'#010+
  2201. ' Result:='#039'units'#039'+PathDelim+MakeTa','rgetString(ACPU,AOS);'#010+
  2202. 'end;'#010+
  2203. #010+
  2204. #010+
  2205. 'Function TPackage.GetBinOutputDir(ACPU:TCPU; AOS : TOS) : String;'#010+
  2206. 'begin'#010+
  2207. ' Result:='#039'bin'#039'+PathDelim+MakeTargetString(ACPU,AOS);'#010+
  2208. 'end;'#010+
  2209. #010+
  2210. #010+
  2211. 'procedure TPackage.GetCleanFiles(List: TStrings; ACPU:TCPU; AOS : TOS)'+
  2212. ';'#010+
  2213. 'Var'#010+
  2214. ' ','OB,OU : String;'#010+
  2215. ' I : Integer;'#010+
  2216. 'begin'#010+
  2217. ' OB:=IncludeTrailingPathDelimiter(GetBinOutputDir(Defaults.CPU,Defaul'+
  2218. 'ts.OS));'#010+
  2219. ' OU:=IncludeTrailingPathDelimiter(GetUnitsOutputDir(Defaults.CPU,Defa'+
  2220. 'ults.OS));'#010+
  2221. ' AddConditionalStrings(List,CleanFiles,ACP','U,AOS);'#010+
  2222. ' For I:=0 to FTargets.Count-1 do'#010+
  2223. ' FTargets.TargetItems[I].GetCleanFiles(List, OU, OB, ACPU, AOS);'#010+
  2224. 'end;'#010+
  2225. #010+
  2226. #010+
  2227. 'procedure TPackage.GetInstallFiles(List: TStrings;Types : TTargetTypes'+
  2228. ';ACPU:TCPU; AOS : TOS);'#010+
  2229. 'Var'#010+
  2230. ' OB,OU : String;'#010+
  2231. ' I : I','nteger;'#010+
  2232. ' T : TTarget;'#010+
  2233. 'begin'#010+
  2234. ' OB:=IncludeTrailingPathDelimiter(GetBinOutputDir(Defaults.CPU,Defaul'+
  2235. 'ts.OS));'#010+
  2236. ' OU:=IncludeTrailingPathDelimiter(GetUnitsOutputDir(Defaults.CPU,Defa'+
  2237. 'ults.OS));'#010+
  2238. ' AddConditionalStrings(List,InstallFiles,ACPU,AOS)',';'#010+
  2239. ' For I:=0 to FTargets.Count-1 do'#010+
  2240. ' begin'#010+
  2241. ' T:=FTargets.TargetItems[I];'#010+
  2242. ' if (T.TargetType in Types) and (T.Install) then'#010+
  2243. ' T.GetInstallFiles(List, OU, OB, ACPU, AOS);'#010+
  2244. ' end;'#010+
  2245. 'end;'#010+
  2246. #010+
  2247. #010+
  2248. 'procedure TPackage.GetArchiveFiles(Lis','t: TStrings; ACPU:TCPU; AOS : '+
  2249. 'TOS);'#010+
  2250. 'Var'#010+
  2251. ' I : Integer;'#010+
  2252. 'begin'#010+
  2253. ' // Targets only'#010+
  2254. ' For I:=0 to FTargets.Count-1 do'#010+
  2255. ' FTargets.TargetItems[I].GetArchiveFiles(List,ACPU,AOS);'#010+
  2256. 'end;'#010+
  2257. #010+
  2258. #010+
  2259. 'Function TPackage.GetDescription : string;'#010+
  2260. 'Var'#010+
  2261. ' FN : String',';'#010+
  2262. ' L : TStringList;'#010+
  2263. 'begin'#010+
  2264. ' If (FDescription<>'#039#039') then'#010+
  2265. ' Result:=FDescription'#010+
  2266. ' else'#010+
  2267. ' If (FDescriptionFile<>'#039#039') then'#010+
  2268. ' begin'#010+
  2269. ' // Always relative to binary name.'#010+
  2270. ' FN:=ExtractFilePath(ParamStr(0));'#010+
  2271. ' FN:=FN+FDesc','riptionFile;'#010+
  2272. ' If FileExists(FN) then'#010+
  2273. ' begin'#010+
  2274. ' L:=TStringList.Create;'#010+
  2275. ' Try'#010+
  2276. ' L.LoadFromFile(FN);'#010+
  2277. ' Result:=L.Text;'#010+
  2278. ' Finally'#010+
  2279. ' L.Free;'#010+
  2280. ' end;'#010+
  2281. ' ',' end;'#010+
  2282. ' end;'#010+
  2283. 'end;'#010+
  2284. #010+
  2285. #010+
  2286. 'Function TPackage.GetVersion : string;'#010+
  2287. 'begin'#010+
  2288. ' result:=FVersion.AsString;'#010+
  2289. 'end;'#010+
  2290. #010+
  2291. #010+
  2292. 'Procedure TPackage.SetVersion(const V : string);'#010+
  2293. 'begin'#010+
  2294. ' FVersion.AsString:=V;'#010+
  2295. 'end;'#010+
  2296. #010+
  2297. #010+
  2298. 'Function TPackage.GetFileName : string;'#010+
  2299. 'begin'#010,
  2300. ' If (FFileName<>'#039#039') then'#010+
  2301. ' Result:=FFileName'#010+
  2302. ' else'#010+
  2303. ' if not FVersion.Empty then'#010+
  2304. ' Result := Name + '#039'-'#039' + FVersion.AsString'#010+
  2305. ' else'#010+
  2306. ' Result := Name;'#010+
  2307. 'end;'#010+
  2308. #010+
  2309. #010+
  2310. 'Procedure TPackage.GetManifest(Manifest : TStrings);'#010+
  2311. #010+
  2312. ' procedure Add','OSes(const AIndent:string;AOSes:TOSes);'#010+
  2313. ' var'#010+
  2314. ' IOS : TOS;'#010+
  2315. ' begin'#010+
  2316. ' if (AOSes=AllOSes) then'#010+
  2317. ' exit;'#010+
  2318. ' Manifest.Add(AIndent+'#039'<oses>'#039');'#010+
  2319. ' for IOS:=low(TOSes) to high(TOSes) do'#010+
  2320. ' if IOS in AOSes then'#010+
  2321. ' Manifest.Add(Forma','t(AIndent+'#039' <os name="%s"/>'#039',[OSTo'+
  2322. 'String(IOS)]));'#010+
  2323. ' Manifest.Add(AIndent+'#039'</oses>'#039');'#010+
  2324. ' end;'#010+
  2325. #010+
  2326. ' procedure AddCPUs(const AIndent:string;ACPUs:TCPUs);'#010+
  2327. ' var'#010+
  2328. ' ICPU : TCPU;'#010+
  2329. ' begin'#010+
  2330. ' if (ACPUs=AllCPUs) then'#010+
  2331. ' exit;'#010+
  2332. ' Manifest.Add(AI','ndent+'#039'<cpus>'#039');'#010+
  2333. ' for ICPU:=low(TCPUs) to high(TCPUs) do'#010+
  2334. ' if ICPU in ACPUs then'#010+
  2335. ' Manifest.Add(Format(AIndent+'#039' <cpu name="%s"/>'#039',[CPUTo'+
  2336. 'String(ICPU)]));'#010+
  2337. ' Manifest.Add(AIndent+'#039'</cpus>'#039');'#010+
  2338. ' end;'#010+
  2339. #010+
  2340. 'Var'#010+
  2341. ' S : String;'#010+
  2342. ' i : Inte','ger;'#010+
  2343. ' D : TDependency;'#010+
  2344. 'begin'#010+
  2345. ' With Manifest do'#010+
  2346. ' begin'#010+
  2347. ' Add(Format('#039'<package name="%s">'#039',[QuoteXml(Name)]));'#010+
  2348. ' Add(Format('#039' <version major="%d" minor="%d" micro="%d" build="'+
  2349. '%d"/>'#039',[FVersion.Major,FVersion.Minor,FVersion.Micro,FVers','ion.Bu'+
  2350. 'ild]));'#010+
  2351. ' AddOSes('#039' '#039',OSes);'#010+
  2352. ' AddCPUs('#039' '#039',CPUs);'#010+
  2353. ' Add(Format('#039' <filename>%s</filename>'#039',[QuoteXml(FileName +'+
  2354. ' ZipExt)]));'#010+
  2355. ' Add(Format('#039' <author>%s</author>'#039',[QuoteXml(Author)]));'#010+
  2356. ' Add(Format('#039' <license>%s</license>'#039',[Quot','eXml(License)])'+
  2357. ');'#010+
  2358. ' if ExternalURL<>'#039#039' then'#010+
  2359. ' Add(Format('#039' <externalurl>%s</externalurl>'#039',[QuoteXml(Ex'+
  2360. 'ternalURL)]));'#010+
  2361. ' Add(Format('#039' <email>%s</email>'#039',[QuoteXMl(Email)]));'#010+
  2362. ' S:=Description;'#010+
  2363. ' If (S<>'#039#039') then'#010+
  2364. ' Add(Format('#039' <','description>%s</description>'#039',[QuoteXML('+
  2365. 'S)]));'#010+
  2366. ' If (Dependencies.Count>0) then'#010+
  2367. ' begin'#010+
  2368. ' Add('#039' <dependencies>'#039');'#010+
  2369. ' for I:=0 to Dependencies.Count-1 do'#010+
  2370. ' begin'#010+
  2371. ' D:=Dependencies[i];'#010+
  2372. ' Add('#039' <de','pendency>'#039');'#010+
  2373. ' Add(Format('#039' <package packagename="%s"/>'#039',[Quote'+
  2374. 'XML(D.Value)]));'#010+
  2375. ' if not D.FVersion.Empty then'#010+
  2376. ' Add(Format('#039' <version major="%d" minor="%d" micro='+
  2377. '"%d" build="%d"/>'#039',[D.FVersion.Major,D.FV','ersion.Minor,D.FVersion'+
  2378. '.Micro,D.FVersion.Build]));'#010+
  2379. ' AddOSes('#039' '#039',D.OSes);'#010+
  2380. ' AddCPUs('#039' '#039',D.CPUs);'#010+
  2381. ' Add('#039' </dependency>'#039');'#010+
  2382. ' end;'#010+
  2383. ' Add('#039' </dependencies>'#039');'#010+
  2384. ' end;'#010+
  2385. ' Add('#039'</package>'#039');'#010+
  2386. ' ',' end;'#010+
  2387. 'end;'#010+
  2388. #010+
  2389. #010+
  2390. 'procedure TPackage.LoadUnitConfigFromFile(Const AFileName: String);'#010+
  2391. 'var'#010+
  2392. ' L,L2 : TStrings;'#010+
  2393. ' VOS : TOS;'#010+
  2394. ' VCPU : TCPU;'#010+
  2395. ' i,k : Integer;'#010+
  2396. ' DepChecksum : Cardinal;'#010+
  2397. ' DepName : String;'#010+
  2398. ' D : TDependency;'#010+
  2399. 'begin'#010+
  2400. ' L:=TStringList.C','reate;'#010+
  2401. ' Try'#010+
  2402. ' ReadIniFile(AFileName,L);'#010+
  2403. ' With L do'#010+
  2404. ' begin'#010+
  2405. ' Version:=Values[KeyVersion];'#010+
  2406. ' InstalledChecksum:=Cardinal(StrToInt64Def(Values[KeyChecksum],'+
  2407. '$ffffffff));'#010+
  2408. ' VCPU:=StringToCPU(Values[KeyCPU]);'#010+
  2409. ' ','VOS:=StringToOS(Values[KeyOS]);'#010+
  2410. ' OSes:=[VOS];'#010+
  2411. ' CPUs:=[VCPU];'#010+
  2412. ' L2:=TStringList.Create;'#010+
  2413. ' L2.CommaText:=Values[KeyDepends];'#010+
  2414. ' for i:=0 to L2.Count-1 do'#010+
  2415. ' begin'#010+
  2416. ' DepName:=L2[i];'#010+
  2417. ' k',':=Pos('#039'|'#039',DepName);'#010+
  2418. ' if k>0 then'#010+
  2419. ' begin'#010+
  2420. ' DepChecksum:=StrToInt(Copy(DepName,k+1,Length(DepName)'+
  2421. '-k));'#010+
  2422. ' DepName:=Copy(DepName,1,k-1);'#010+
  2423. ' end'#010+
  2424. ' else'#010+
  2425. ' DepCh','ecksum:=$ffffffff;'#010+
  2426. ' D:=Dependencies.Add(DepName,CPUs,OSes);'#010+
  2427. ' D.RequireChecksum:=DepChecksum;'#010+
  2428. ' end;'#010+
  2429. ' FreeAndNil(L2);'#010+
  2430. ' NeedLibC:=Upcase(Values[KeyNeedLibC])='#039'Y'#039';'#010+
  2431. ' end;'#010+
  2432. ' Finally'#010+
  2433. ' L.Free;'#010+
  2434. ' ','end;'#010+
  2435. 'end;'#010+
  2436. #010+
  2437. #010+
  2438. 'procedure TPackage.SaveUnitConfigToFile(Const AFileName: String;ACPU:T'+
  2439. 'CPU;AOS:TOS);'#010+
  2440. 'Var'#010+
  2441. ' F : TFileStream;'#010+
  2442. ' L : TStringList;'#010+
  2443. ' Deps : String;'#010+
  2444. ' i : integer;'#010+
  2445. ' D : TDependency;'#010+
  2446. ' p : TPackage;'#010+
  2447. 'begin'#010+
  2448. ' F:=TFileStream.Create(AFile','Name,fmCreate);'#010+
  2449. ' L:=TStringList.Create;'#010+
  2450. ' try'#010+
  2451. ' With L do'#010+
  2452. ' begin'#010+
  2453. ' Values[KeyName]:=Name;'#010+
  2454. ' Values[KeyVersion]:=Version;'#010+
  2455. ' // TODO Generate checksum based on PPUs'#010+
  2456. ' Values[KeyChecksum]:=IntToStr(DateTimeToFil','eDate(Now));'#010+
  2457. ' Values[KeyCPU]:=CPUToString(ACPU);'#010+
  2458. ' Values[KeyOS]:=OSToString(AOS);'#010+
  2459. ' Deps:='#039#039';'#010+
  2460. ' for i:=0 to Dependencies.Count-1 do'#010+
  2461. ' begin'#010+
  2462. ' D:=Dependencies[i];'#010+
  2463. ' if (ACPU in D.CPUs) an','d (AOS in D.OSes) then'#010+
  2464. ' begin'#010+
  2465. ' if Deps<>'#039#039' then'#010+
  2466. ' Deps:=Deps+'#039','#039';'#010+
  2467. ' Deps:=Deps+D.Value;'#010+
  2468. ' P:=TPackage(D.Target);'#010+
  2469. ' if assigned(P) and (P.InstalledChecksum','<>$ffffffff) '+
  2470. 'then'#010+
  2471. ' Deps:=Deps+'#039'|'#039'+IntToStr(P.InstalledChecksum)'+
  2472. ';'#010+
  2473. ' end;'#010+
  2474. ' end;'#010+
  2475. ' Values[KeyDepends]:=Deps;'#010+
  2476. ' if NeedLibC then'#010+
  2477. ' Values[KeyNeedLibC]:='#039'Y'#039#010+
  2478. ' else'#010+
  2479. ' Values[','KeyNeedLibC]:='#039'N'#039';'#010+
  2480. ' end;'#010+
  2481. ' L.SaveToStream(F);'#010+
  2482. ' Finally'#010+
  2483. ' L.Free;'#010+
  2484. ' F.Free;'#010+
  2485. ' end;'#010+
  2486. 'end;'#010+
  2487. #010+
  2488. #010+
  2489. #010+
  2490. '{*********************************************************************'+
  2491. '*******'#010+
  2492. ' TPackages'#010+
  2493. '********************','************************************************'+
  2494. '********}'#010+
  2495. #010+
  2496. 'function TPackages.GetPackage(const AName : String): TPackage;'#010+
  2497. 'begin'#010+
  2498. ' Result:=TPackage(ItemByName(AName))'#010+
  2499. 'end;'#010+
  2500. #010+
  2501. 'function TPackages.GetPackageItem(AIndex : Integer): TPackage;'#010+
  2502. 'begin',#010+
  2503. ' Result:=TPackage(Items[AIndex]);'#010+
  2504. 'end;'#010+
  2505. #010+
  2506. #010+
  2507. 'procedure TPackages.SetPackageItem(AIndex : Integer; const AValue: TPa'+
  2508. 'ckage);'#010+
  2509. 'begin'#010+
  2510. ' Items[AIndex]:=AValue;'#010+
  2511. 'end;'#010+
  2512. #010+
  2513. #010+
  2514. 'function TPackages.AddPackage(const AName: String): TPackage;'#010+
  2515. 'begin'#010+
  2516. ' Result:=Add',' as TPackage;'#010+
  2517. ' Result.Name:=AName;'#010+
  2518. 'end;'#010+
  2519. #010+
  2520. #010+
  2521. '{*********************************************************************'+
  2522. '*******'#010+
  2523. ' TCustomDefaults'#010+
  2524. '**********************************************************************'+
  2525. '****','**}'#010+
  2526. #010+
  2527. 'procedure TCustomDefaults.SetCPU(const AValue: TCPU);'#010+
  2528. 'begin'#010+
  2529. ' FCPU:=AValue;'#010+
  2530. ' RecalcTarget;'#010+
  2531. 'end;'#010+
  2532. #010+
  2533. #010+
  2534. 'function TCustomDefaults.GetBaseInstallDir: String;'#010+
  2535. 'begin'#010+
  2536. ' If (FBaseInstallDir<>'#039#039') then'#010+
  2537. ' Result:=FBaseInstallDir'#010+
  2538. ' else'#010+
  2539. ' if Unix','Paths then'#010+
  2540. ' Result:=Prefix +'#039'lib'#039' + PathDelim + '#039'fpc'#039' + Path'+
  2541. 'Delim'#010+
  2542. ' else'#010+
  2543. ' Result:=Prefix;'#010+
  2544. 'end;'#010+
  2545. #010+
  2546. #010+
  2547. 'function TCustomDefaults.GetBinInstallDir: String;'#010+
  2548. 'begin'#010+
  2549. ' If (FBinInstallDir<>'#039#039') then'#010+
  2550. ' Result:=FBinInstallDir'#010+
  2551. ' else'#010+
  2552. ' If Un','ixPaths then'#010+
  2553. ' Result:=BaseInstallDir+'#039'bin'#039#010+
  2554. ' else'#010+
  2555. ' Result:=BaseInstallDir+'#039'bin'#039';'#010+
  2556. 'end;'#010+
  2557. #010+
  2558. #010+
  2559. 'function TCustomDefaults.GetCompiler: String;'#010+
  2560. 'begin'#010+
  2561. ' If (FCompiler<>'#039#039') then'#010+
  2562. ' Result:=FCompiler'#010+
  2563. ' else'#010+
  2564. ' Result:='#039'fpc'#039';'#010+
  2565. 'end;'#010+
  2566. #010+
  2567. #010+
  2568. 'functio','n TCustomDefaults.GetDocInstallDir: String;'#010+
  2569. 'begin'#010+
  2570. ' If (FBinInstallDir<>'#039#039') then'#010+
  2571. ' Result:=FBinInstallDir'#010+
  2572. ' else'#010+
  2573. ' If UnixPaths then'#010+
  2574. ' Result:=Prefix+'#039'share'#039'+PathDelim+'#039'doc'#039#010+
  2575. ' else'#010+
  2576. ' Result:=BaseInstallDir+'#039'docs'#039';'#010+
  2577. 'end;'#010+
  2578. #010+
  2579. #010+
  2580. 'funct','ion TCustomDefaults.GetExamplesInstallDir: String;'#010+
  2581. 'begin'#010+
  2582. ' If (FExamplesInstallDir<>'#039#039') then'#010+
  2583. ' Result:=FExamplesInstallDir'#010+
  2584. ' else'#010+
  2585. ' If UnixPaths then'#010+
  2586. ' Result:=Prefix+'#039'share'#039'+PathDelim+'#039'docs'#039'+PathDeli'+
  2587. 'm+'#039'examples'#039#010+
  2588. ' else'#010+
  2589. ' Resu','lt:=BaseInstallDir+'#039'examples'#039';'#010+
  2590. 'end;'#010+
  2591. #010+
  2592. #010+
  2593. 'function TCustomDefaults.GetUnitInstallDir: String;'#010+
  2594. 'begin'#010+
  2595. ' If (FUnitInstallDir<>'#039#039') then'#010+
  2596. ' Result:=FUnitInstallDir'#010+
  2597. ' else'#010+
  2598. ' If UnixPaths then'#010+
  2599. ' Result:=BaseInstallDir+'#039'units'#039'+PathDelim+Target'#010+
  2600. ' ',' else'#010+
  2601. ' Result:=BaseInstallDir+'#039'units'#039'+PathDelim+Target;'#010+
  2602. 'end;'#010+
  2603. #010+
  2604. #010+
  2605. 'function TCustomDefaults.GetLocalUnitDir: String;'#010+
  2606. 'begin'#010+
  2607. ' Result:=FLocalUnitDir;'#010+
  2608. 'end;'#010+
  2609. #010+
  2610. #010+
  2611. 'function TCustomDefaults.GetGlobalUnitDir: String;'#010+
  2612. 'begin'#010+
  2613. ' If (FGlobalUnitDir<>'#039#039')',' then'#010+
  2614. ' Result:=FGlobalUnitDir'#010+
  2615. ' else'#010+
  2616. ' Result:=UnitInstallDir;'#010+
  2617. 'end;'#010+
  2618. #010+
  2619. #010+
  2620. 'procedure TCustomDefaults.SetLocalUnitDir(const AValue: String);'#010+
  2621. 'begin'#010+
  2622. ' // Use ExpandFileName to support ~/ expansion'#010+
  2623. ' if AValue<>'#039#039' then'#010+
  2624. ' FLocalUnitDir:=Includ','eTrailingPathDelimiter(ExpandFileName(AValu'+
  2625. 'e))'#010+
  2626. ' else'#010+
  2627. ' FLocalUnitDir:='#039#039';'#010+
  2628. 'end;'#010+
  2629. #010+
  2630. #010+
  2631. 'procedure TCustomDefaults.SetGlobalUnitDir(const AValue: String);'#010+
  2632. 'begin'#010+
  2633. ' // Use ExpandFileName to support ~/ expansion'#010+
  2634. ' if AValue<>'#039#039' then'#010+
  2635. ' FGlobalUnit','Dir:=IncludeTrailingPathDelimiter(ExpandFileName(AVal'+
  2636. 'ue))'#010+
  2637. ' else'#010+
  2638. ' FGlobalUnitDir:='#039#039';'#010+
  2639. 'end;'#010+
  2640. #010+
  2641. #010+
  2642. 'procedure TCustomDefaults.SetBaseInstallDir(const AValue: String);'#010+
  2643. 'begin'#010+
  2644. ' // Use ExpandFileName to support ~/ expansion'#010+
  2645. ' if AValue<>'#039#039' then'#010+
  2646. ' ',' FBaseInstallDir:=IncludeTrailingPathDelimiter(ExpandFileName(AVa'+
  2647. 'lue))'#010+
  2648. ' else'#010+
  2649. ' FBaseInstallDir:='#039#039';'#010+
  2650. ' UnitInstallDir:='#039#039';'#010+
  2651. ' BinInstallDir:='#039#039';'#010+
  2652. ' ExamplesInstallDir:='#039#039';'#010+
  2653. 'end;'#010+
  2654. #010+
  2655. #010+
  2656. 'procedure TCustomDefaults.SetOS(const AValue: TOS);'#010+
  2657. 'begin'#010+
  2658. ' ','FOS:=AValue;'#010+
  2659. ' Recalctarget;'#010+
  2660. 'end;'#010+
  2661. #010+
  2662. #010+
  2663. 'procedure TCustomDefaults.SetPrefix(const AValue: String);'#010+
  2664. 'begin'#010+
  2665. ' if FPrefix=AValue then exit;'#010+
  2666. ' FPrefix:=IncludeTrailingPathDelimiter(AValue);'#010+
  2667. ' BaseInstallDir:='#039#039';'#010+
  2668. 'end;'#010+
  2669. #010+
  2670. #010+
  2671. 'procedure TCustomDefaults.SetT','arget(const AValue: String);'#010+
  2672. 'Var'#010+
  2673. ' P : Integer;'#010+
  2674. 'begin'#010+
  2675. ' if FTarget<>AValue then'#010+
  2676. ' begin'#010+
  2677. ' P:=Pos('#039'-'#039',AValue);'#010+
  2678. ' If (P<>0) then'#010+
  2679. ' begin'#010+
  2680. ' FOS:=StringToOS(System.Copy(Avalue,P+1,Length(AValue)-P));'#010+
  2681. ' FCPU:=Stri','ngToCPU(System.Copy(Avalue,1,P-1));'#010+
  2682. ' end'#010+
  2683. ' else'#010+
  2684. ' FOS:=StringToOS(AValue);'#010+
  2685. ' FTarget:=AValue;'#010+
  2686. ' end;'#010+
  2687. 'end;'#010+
  2688. #010+
  2689. #010+
  2690. 'procedure TCustomDefaults.RecalcTarget;'#010+
  2691. 'begin'#010+
  2692. ' Ftarget:=CPUToString(FCPU)+'#039'-'#039'+OStoString(FOS);'#010+
  2693. 'end;'#010+
  2694. #010+
  2695. #010+
  2696. 'constr','uctor TCustomDefaults.Create;'#010+
  2697. 'begin'#010+
  2698. ' InitDefaults;'#010+
  2699. 'end;'#010+
  2700. #010+
  2701. #010+
  2702. 'procedure TCustomDefaults.InitDefaults;'#010+
  2703. 'begin'#010+
  2704. '{$ifdef unix}'#010+
  2705. ' UnixPaths:=True;'#010+
  2706. '{$else}'#010+
  2707. ' UnixPaths:=False;'#010+
  2708. '{$endif}'#010+
  2709. ' FNoFPCCfg:=False;'#010+
  2710. ' FCPU:=cpuNone;'#010+
  2711. ' FOS:=osNone;'#010+
  2712. 'end;'#010+
  2713. #010+
  2714. #010+
  2715. 'proced','ure TCustomDefaults.LocalInit(Const AFileName : String);'#010+
  2716. 'Var'#010+
  2717. ' FN : String;'#010+
  2718. 'begin'#010+
  2719. ' FN:=AFileName;'#010+
  2720. ' If (FN='#039#039') then'#010+
  2721. ' begin'#010+
  2722. ' // Environment variable.'#010+
  2723. ' FN:=GetEnvironmentVariable('#039'FPMAKECFG'#039');'#010+
  2724. ' If (FN<>'#039#039') then'#010+
  2725. ' If not FileE','xists(FN) then'#010+
  2726. ' FN:='#039#039';'#010+
  2727. ' // User config file fpmake.cfg'#010+
  2728. ' If (FN='#039#039') then'#010+
  2729. ' begin'#010+
  2730. ' FN:=GetAppConfigFile(False);'#010+
  2731. ' If Not FileExists(FN) then'#010+
  2732. ' FN:='#039#039';'#010+
  2733. ' end;'#010+
  2734. ' // Global config file fpmake.cfg'#010+
  2735. ' If (FN','='#039#039') then'#010+
  2736. ' begin'#010+
  2737. ' FN:=GetAppConfigFile(True);'#010+
  2738. ' If Not FileExists(FN) then'#010+
  2739. ' FN:='#039#039';'#010+
  2740. ' end;'#010+
  2741. ' end;'#010+
  2742. ' If (FN<>'#039#039') and FileExists(FN) then'#010+
  2743. ' LoadFromFile(FN);'#010+
  2744. 'end;'#010+
  2745. #010+
  2746. #010+
  2747. 'procedure TCustomDefaults.CompilerDefaults;'#010+
  2748. '{$if','def HAS_UNIT_PROCESS}'#010+
  2749. 'var'#010+
  2750. ' infoSL : TStringList;'#010+
  2751. '{$endif HAS_UNIT_PROCESS}'#010+
  2752. 'begin'#010+
  2753. ' if (CPU=cpuNone) or (OS=osNone) or (FCompilerVersion='#039#039') then'#010+
  2754. ' begin'#010+
  2755. '{$ifdef HAS_UNIT_PROCESS}'#010+
  2756. ' // Detect compiler version/target from -i option'#010+
  2757. ' ',' infosl:=TStringList.Create;'#010+
  2758. ' infosl.Delimiter:='#039' '#039';'#010+
  2759. ' infosl.DelimitedText:=GetCompilerInfo(GetCompiler,'#039'-iVTPTO'#039+
  2760. ');'#010+
  2761. ' if infosl.Count<>3 then'#010+
  2762. ' Raise EInstallerError.Create(SErrInvalidFPCInfo);'#010+
  2763. ' if FCompilerVersio','n='#039#039' then'#010+
  2764. ' FCompilerVersion:=infosl[0];'#010+
  2765. ' if CPU=cpuNone then'#010+
  2766. ' CPU:=StringToCPU(infosl[1]);'#010+
  2767. ' if OS=osNone then'#010+
  2768. ' OS:=StringToOS(infosl[2]);'#010+
  2769. '{$else HAS_UNIT_PROCESS}'#010+
  2770. ' // Defaults taken from compiler used to ','build fpmake'#010+
  2771. ' if CPU=cpuNone then'#010+
  2772. ' CPU:=StringToCPU({$I %FPCTARGETCPU%});'#010+
  2773. ' if OS=osNone then'#010+
  2774. ' OS:=StringToOS({$I %FPCTARGETOS%});'#010+
  2775. ' if FCompilerVersion='#039#039' then'#010+
  2776. ' FCompilerVersion:={$I %FPCVERSION%};'#010+
  2777. '{$endif',' HAS_UNIT_PROCESS}'#010+
  2778. ' end;'#010+
  2779. 'end;'#010+
  2780. #010+
  2781. #010+
  2782. 'procedure TCustomDefaults.LoadFromFile(Const AFileName: String);'#010+
  2783. 'Var'#010+
  2784. ' F : TFileStream;'#010+
  2785. 'begin'#010+
  2786. ' F:=TFileStream.Create(AFileName,fmOpenRead);'#010+
  2787. ' Try'#010+
  2788. ' LoadFromStream(F);'#010+
  2789. ' Finally'#010+
  2790. ' F.Free;'#010+
  2791. ' end;'#010+
  2792. 'end;'#010+
  2793. #010,
  2794. #010+
  2795. 'procedure TCustomDefaults.SaveToFile(Const AFileName: String);'#010+
  2796. 'Var'#010+
  2797. ' F : TFileStream;'#010+
  2798. 'begin'#010+
  2799. ' F:=TFileStream.Create(AFileName,fmCreate);'#010+
  2800. ' Try'#010+
  2801. ' SaveToStream(F);'#010+
  2802. ' Finally'#010+
  2803. ' F.Free;'#010+
  2804. ' end;'#010+
  2805. 'end;'#010+
  2806. #010+
  2807. #010+
  2808. 'procedure TCustomDefaults.SaveToStream(','S : TStream);'#010+
  2809. 'Var'#010+
  2810. ' L : TStringList;'#010+
  2811. 'begin'#010+
  2812. ' L:=TStringList.Create;'#010+
  2813. ' try'#010+
  2814. ' With L do'#010+
  2815. ' begin'#010+
  2816. ' Values[KeyArchive]:=FArchive;'#010+
  2817. ' Values[KeyCompiler]:=FCompiler;'#010+
  2818. ' Values[KeyCopy]:=FCopy;'#010+
  2819. ' Values[KeyMkDir]:=FMkDir;'#010+
  2820. ' ',' Values[KeyMove]:=FMove;'#010+
  2821. ' Values[KeyOptions]:=FOptions;'#010+
  2822. ' Values[KeyCPU]:=CPUToString(FCPU);'#010+
  2823. ' Values[KeyOS]:=OSToString(FOS);'#010+
  2824. ' Values[KeyMode]:=ModeToString(FMode);'#010+
  2825. ' Values[KeyLocalUnitDir]:=FLocalUnitDir;'#010+
  2826. ' Val','ues[KeyGlobalUnitDir]:=FGlobalUnitDir;'#010+
  2827. ' Values[KeyPrefix]:=FPrefix;'#010+
  2828. ' Values[KeyBaseInstallDir]:=FBaseInstallDir;'#010+
  2829. ' Values[KeyUnitInstallDir]:=FUnitInstallDir;'#010+
  2830. ' Values[KeyBinInstallDir]:=FBinInstallDir;'#010+
  2831. ' Values[KeyDoc','InstallDir]:=FDocInstallDir;'#010+
  2832. ' Values[KeyExamplesInstallDir]:=FExamplesInstallDir;'#010+
  2833. ' Values[KeyRemove]:=FRemove;'#010+
  2834. ' Values[KeyTarget]:=FTarget;'#010+
  2835. ' if FNoFPCCfg then'#010+
  2836. ' Values[KeyNoFPCCfg]:='#039'Y'#039';'#010+
  2837. ' end;'#010+
  2838. ' L.SaveToStre','am(S);'#010+
  2839. ' Finally'#010+
  2840. ' L.Free;'#010+
  2841. ' end;'#010+
  2842. 'end;'#010+
  2843. #010+
  2844. #010+
  2845. 'procedure TCustomDefaults.LoadFromStream(S: TStream);'#010+
  2846. 'Var'#010+
  2847. ' L : TStrings;'#010+
  2848. ' Line : String;'#010+
  2849. ' I,P,PC : Integer;'#010+
  2850. 'begin'#010+
  2851. ' L:=TStringList.Create;'#010+
  2852. ' Try'#010+
  2853. ' L.LoadFromStream(S);'#010+
  2854. ' // Fix lines.'#010+
  2855. ' Fo','r I:=L.Count-1 downto 0 do'#010+
  2856. ' begin'#010+
  2857. ' Line:=L[I];'#010+
  2858. ' P:=Pos('#039'='#039',Line);'#010+
  2859. ' PC:=Pos('#039';'#039',Line); // Comment line.'#010+
  2860. ' If (P=0) or ((PC<>0) and (PC<P)) then'#010+
  2861. ' L.Delete(I)'#010+
  2862. ' else'#010+
  2863. ' L[i]:=Trim(System.Copy(Line,1,P-1',')+'#039'='#039'+Trim(System.C'+
  2864. 'opy(Line,P+1,Length(Line)-P)));'#010+
  2865. ' end;'#010+
  2866. ' With L do'#010+
  2867. ' begin'#010+
  2868. ' FArchive:=Values[KeyArchive];'#010+
  2869. ' FCompiler:=Values[KeyCompiler];'#010+
  2870. ' FCopy:=Values[KeyCopy];'#010+
  2871. ' FMkDir:=Values[KeyMkDir];'#010+
  2872. ' FMove:=Val','ues[KeyMove];'#010+
  2873. ' FRemove:=Values[KeyRemove];'#010+
  2874. ' FOptions:=Values[KeyOptions];'#010+
  2875. ' Line:=Values[KeyCPU];'#010+
  2876. ' If (Line<>'#039#039') then'#010+
  2877. ' FCPU:=StringToCPU(Line);'#010+
  2878. ' Line:=Values[KeyOS];'#010+
  2879. ' If (Line<>'#039#039') then'#010+
  2880. ' FOS:=Strin','gToOS(Line);'#010+
  2881. ' Line:=Values[KeyMode];'#010+
  2882. ' If (Line<>'#039#039') then'#010+
  2883. ' FMode:=StringToMode(Line);'#010+
  2884. ' FTarget:=Values[KeyTarget];'#010+
  2885. ' FLocalUnitDir:=Values[KeyLocalUnitDir];'#010+
  2886. ' FGlobalUnitDir:=Values[KeyGlobalUnitDir];'#010+
  2887. ' FPre','fix:=Values[KeyPrefix];'#010+
  2888. ' FBaseInstallDir:=Values[KeyBaseInstallDir];'#010+
  2889. ' FUnitInstallDir:=Values[KeyUnitInstallDir];'#010+
  2890. ' FBinInstallDir:=Values[KeyBinInstallDir];'#010+
  2891. ' FDocInstallDir:=Values[KeyDocInstallDir];'#010+
  2892. ' FExamplesInsta','llDir:=Values[KeyExamplesInstallDir];'#010+
  2893. ' FNoFPCCfg:=(Upcase(Values[KeyNoFPCCfg])='#039'Y'#039');'#010+
  2894. ' end;'#010+
  2895. ' Finally'#010+
  2896. ' L.Free;'#010+
  2897. ' end;'#010+
  2898. 'end;'#010+
  2899. #010+
  2900. #010+
  2901. '{*********************************************************************'+
  2902. '*******'#010+
  2903. ' ',' TFPCDefaults'#010+
  2904. '**********************************************************************'+
  2905. '******}'#010+
  2906. #010+
  2907. 'procedure TFPCDefaults.CompilerDefaults;'#010+
  2908. 'var'#010+
  2909. ' BD : String;'#010+
  2910. 'begin'#010+
  2911. ' inherited CompilerDefaults;'#010+
  2912. #010+
  2913. ' // Use the same algorithm as the compiler, se','e options.pas'#010+
  2914. '{$ifdef Unix}'#010+
  2915. ' BD:=FixPath(GetEnvironmentVariable('#039'FPCDIR'#039'));'#010+
  2916. ' if BD='#039#039' then'#010+
  2917. ' begin'#010+
  2918. ' BD:='#039'/usr/local/lib/fpc/'#039'+FCompilerVersion;'#010+
  2919. ' if not DirectoryExists(BD) and'#010+
  2920. ' DirectoryExists('#039'/usr/lib/fpc/'#039'+FCompiler','Version) t'+
  2921. 'hen'#010+
  2922. ' BD:='#039'/usr/lib/fpc/'#039'+FCompilerVersion;'#010+
  2923. ' end;'#010+
  2924. '{$else unix}'#010+
  2925. ' BD:=FixPath(GetEnvironmentVariable('#039'FPCDIR'#039'));'#010+
  2926. ' if BD='#039#039' then'#010+
  2927. ' begin'#010+
  2928. ' BD:=ExtractFilePath(FCompiler)+'#039'..'#039';'#010+
  2929. ' if not(DirectoryExists(BD+'#039'/units'#039,')) and'#010+
  2930. ' not(DirectoryExists(BD+'#039'/rtl'#039')) then'#010+
  2931. ' BD:=FBaseInstallDir+'#039'..'#039';'#010+
  2932. ' end;'#010+
  2933. '{$endif unix}'#010+
  2934. #010+
  2935. ' // Where to install by default'#010+
  2936. ' if (FBaseInstallDir='#039#039') and (FPrefix='#039#039') then'#010+
  2937. ' BaseInstallDir:=BD;'#010+
  2938. #010+
  2939. ' // Where to find the ','units by default'#010+
  2940. ' if (FGlobalUnitDir='#039#039') then'#010+
  2941. ' GlobalUnitDir:=IncludeTrailingPathDelimiter(BD)+'#039'units'#039'+Pa'+
  2942. 'thDelim+Target;'#010+
  2943. 'end;'#010+
  2944. #010+
  2945. #010+
  2946. '{*********************************************************************'+
  2947. '*******'#010+
  2948. ' TC','ustomInstaller'#010+
  2949. '**********************************************************************'+
  2950. '******}'#010+
  2951. #010+
  2952. 'constructor TCustomInstaller.Create(AOwner: TComponent);'#010+
  2953. 'begin'#010+
  2954. ' Dictionary:=DictionaryClass.Create(Nil);'#010+
  2955. ' AnalyzeOptions;'#010+
  2956. ' CreatePackages;'#010+
  2957. 'end;',#010+
  2958. #010+
  2959. #010+
  2960. 'destructor TCustomInstaller.Destroy;'#010+
  2961. 'begin'#010+
  2962. ' FreeAndNil(Defaults);'#010+
  2963. ' FreeAndNil(Dictionary);'#010+
  2964. ' inherited destroy;'#010+
  2965. 'end;'#010+
  2966. #010+
  2967. #010+
  2968. 'procedure TCustomInstaller.Log(Level: TVerboseLevel; const Msg: String'+
  2969. ');'#010+
  2970. 'begin'#010+
  2971. ' If Level in FLogLevels then'#010+
  2972. ' Wri','teln(StdOut,Msg);'#010+
  2973. 'end;'#010+
  2974. #010+
  2975. #010+
  2976. 'procedure TCustomInstaller.CreatePackages;'#010+
  2977. 'begin'#010+
  2978. ' FPAckages:=TPackages.Create(TPackage);'#010+
  2979. 'end;'#010+
  2980. #010+
  2981. #010+
  2982. 'procedure TCustomInstaller.CreateBuildEngine;'#010+
  2983. 'begin'#010+
  2984. ' FBuildEngine:=TBuildEngine.Create(Self);'#010+
  2985. '// FBuildEngine.Defaul','ts:=Defaults;'#010+
  2986. ' FBuildEngine.ListMode:=FListMode;'#010+
  2987. ' FBuildEngine.OnLog:[email protected];'#010+
  2988. 'end;'#010+
  2989. #010+
  2990. #010+
  2991. 'procedure TCustomInstaller.Error(const Msg: String);'#010+
  2992. 'begin'#010+
  2993. ' Raise EInstallerError.Create(Msg);'#010+
  2994. 'end;'#010+
  2995. #010+
  2996. #010+
  2997. 'procedure TCustomInstaller.Error(const Fmt: Str','ing; Args: array of c'+
  2998. 'onst);'#010+
  2999. 'begin'#010+
  3000. ' Raise EInstallerError.CreateFmt(Fmt,Args);'#010+
  3001. 'end;'#010+
  3002. #010+
  3003. #010+
  3004. 'Function TCustomInstaller.AddPackage(const AName: String) : TPackage;'#010+
  3005. 'begin'#010+
  3006. ' result:=FPackages.AddPackage(AName);'#010+
  3007. 'end;'#010+
  3008. #010+
  3009. #010+
  3010. 'procedure TCustomInstaller.Analy','zeOptions;'#010+
  3011. #010+
  3012. ' Function CheckOption(Index : Integer;const Short,Long : String): Boo'+
  3013. 'lean;'#010+
  3014. ' var'#010+
  3015. ' O : String;'#010+
  3016. ' begin'#010+
  3017. ' O:=Paramstr(Index);'#010+
  3018. ' Result:=(O='#039'-'#039'+short) or (O='#039'--'#039'+long) or (copy(O,'+
  3019. '1,Length(Long)+3)=('#039'--'#039'+long+'#039'='#039'));'#010+
  3020. ' end;'#010+
  3021. #010,
  3022. ' Function CheckCommand(Index : Integer;const Short,Long : String): Bo'+
  3023. 'olean;'#010+
  3024. ' var'#010+
  3025. ' O : String;'#010+
  3026. ' begin'#010+
  3027. ' O:=Paramstr(Index);'#010+
  3028. ' Result:=(O='#039'-'#039'+short) or (O=long);'#010+
  3029. ' end;'#010+
  3030. #010+
  3031. ' Function OptionArg(Var Index : Integer) : String;'#010+
  3032. ' Var'#010+
  3033. ' ','P : Integer;'#010+
  3034. ' begin'#010+
  3035. ' if (Length(ParamStr(Index))>1) and (Paramstr(Index)[2]<>'#039'-'#039+
  3036. ') then'#010+
  3037. ' begin'#010+
  3038. ' If Index<ParamCount then'#010+
  3039. ' begin'#010+
  3040. ' Inc(Index);'#010+
  3041. ' Result:=Paramstr(Index);'#010+
  3042. ' end'#010+
  3043. ' else'#010+
  3044. ' Error(SE','rrNeedArgument,[Index,ParamStr(Index)]);'#010+
  3045. ' end'#010+
  3046. ' else If length(ParamStr(Index))>2 then'#010+
  3047. ' begin'#010+
  3048. ' P:=Pos('#039'='#039',Paramstr(Index));'#010+
  3049. ' If (P=0) then'#010+
  3050. ' Error(SErrNeedArgument,[Index,ParamStr(Index)])'#010+
  3051. ' else'#010+
  3052. ' begi','n'#010+
  3053. ' Result:=Paramstr(Index);'#010+
  3054. ' Delete(Result,1,P);'#010+
  3055. ' end;'#010+
  3056. ' end;'#010+
  3057. ' end;'#010+
  3058. #010+
  3059. 'Var'#010+
  3060. ' I : Integer;'#010+
  3061. ' DefaultsFileName : string;'#010+
  3062. 'begin'#010+
  3063. ' I:=0;'#010+
  3064. ' FListMode:=False;'#010+
  3065. ' FLogLevels:=DefaultMessages;'#010+
  3066. ' While (I<ParamCount) do'#010+
  3067. ' be','gin'#010+
  3068. ' Inc(I);'#010+
  3069. ' if CheckOption(I,'#039'v'#039','#039'verbose'#039') then'#010+
  3070. ' FLogLevels:=AllMessages'#010+
  3071. ' else if CheckOption(I,'#039'd'#039','#039'debug'#039') then'#010+
  3072. ' FLogLevels:=AllMessages+[vlDebug]'#010+
  3073. ' else if CheckCommand(I,'#039'm'#039','#039'compile'#039') then'#010+
  3074. ' FRunMode:=rmComp','ile'#010+
  3075. ' else if CheckCommand(I,'#039'b'#039','#039'build'#039') then'#010+
  3076. ' FRunMode:=rmBuild'#010+
  3077. ' else if CheckCommand(I,'#039'i'#039','#039'install'#039') then'#010+
  3078. ' FRunMode:=rmInstall'#010+
  3079. ' else if CheckCommand(I,'#039'c'#039','#039'clean'#039') then'#010+
  3080. ' FRunMode:=rmClean'#010+
  3081. ' else if CheckCommand(','I,'#039'a'#039','#039'archive'#039') then'#010+
  3082. ' FRunMode:=rmarchive'#010+
  3083. ' else if CheckCommand(I,'#039'M'#039','#039'manifest'#039') then'#010+
  3084. ' FRunMode:=rmManifest'#010+
  3085. ' else if CheckOption(I,'#039'h'#039','#039'help'#039') then'#010+
  3086. ' Usage('#039#039',[])'#010+
  3087. ' else if Checkoption(I,'#039'C'#039','#039'cpu'#039') then'#010+
  3088. ' Default','s.CPU:=StringToCPU(OptionArg(I))'#010+
  3089. ' else if Checkoption(I,'#039'O'#039','#039'os'#039') then'#010+
  3090. ' Defaults.OS:=StringToOS(OptionArg(I))'#010+
  3091. ' else if Checkoption(I,'#039't'#039','#039'target'#039') then'#010+
  3092. ' Defaults.Target:=OptionArg(I)'#010+
  3093. ' else if CheckOption(I,'#039'l'#039','#039'list-comma','nds'#039') then'#010+
  3094. ' FListMode:=True'#010+
  3095. ' else if Checkoption(I,'#039'P'#039','#039'prefix'#039') then'#010+
  3096. ' Defaults.Prefix:=OptionArg(I)'#010+
  3097. ' else if Checkoption(I,'#039'n'#039','#039'nofpccfg'#039') then'#010+
  3098. ' Defaults.NoFPCCfg:=true'#010+
  3099. ' else if CheckOption(I,'#039'B'#039','#039'baseinstalldir'#039') t','hen'+
  3100. #010+
  3101. ' Defaults.BaseInstallDir:=OptionArg(I)'#010+
  3102. ' else if CheckOption(I,'#039'UL'#039','#039'localunitdir'#039') then'#010+
  3103. ' Defaults.LocalUnitDir:=OptionArg(I)'#010+
  3104. ' else if CheckOption(I,'#039'UG'#039','#039'globalunitdir'#039') then'#010+
  3105. ' Defaults.GlobalUnitDir:=OptionArg(I)'#010+
  3106. ' ',' else if CheckOption(I,'#039'r'#039','#039'compiler'#039') then'#010+
  3107. ' Defaults.Compiler:=OptionArg(I)'#010+
  3108. ' else if CheckOption(I,'#039'f'#039','#039'config'#039') then'#010+
  3109. ' DefaultsFileName:=OptionArg(I)'#010+
  3110. ' else'#010+
  3111. ' begin'#010+
  3112. ' Usage(SErrInValidArgument,[I,ParamStr(I)]);'#010+
  3113. ' ',' end;'#010+
  3114. ' end;'#010+
  3115. ' If DefaultsFileName<>'#039#039' then'#010+
  3116. ' Defaults.LocalInit(DefaultsFileName);'#010+
  3117. ' Defaults.CompilerDefaults;'#010+
  3118. 'end;'#010+
  3119. #010+
  3120. #010+
  3121. 'procedure TCustomInstaller.Usage(const FMT: String; Args: array of con'+
  3122. 'st);'#010+
  3123. #010+
  3124. ' Procedure LogCmd(const LC,Msg : Strin','g);'#010+
  3125. ' begin'#010+
  3126. ' Log(vlInfo,Format('#039' %-12s %s'#039',[LC,MSG]));'#010+
  3127. ' end;'#010+
  3128. #010+
  3129. ' Procedure LogOption(const C,LC,Msg : String);'#010+
  3130. ' begin'#010+
  3131. ' Log(vlInfo,Format('#039' -%s --%-16s %s'#039',[C,LC,MSG]));'#010+
  3132. ' end;'#010+
  3133. #010+
  3134. ' Procedure LogArgOption(const C,LC,Msg : String);'#010+
  3135. ' beg','in'#010+
  3136. ' Log(vlInfo,Format('#039' -%s --%-20s %s'#039',[C,LC+'#039'='#039'+SVal'+
  3137. 'ue,MSG]));'#010+
  3138. ' end;'#010+
  3139. #010+
  3140. 'begin'#010+
  3141. ' // Force the Usage to be displayed'#010+
  3142. ' Include(FLogLevels,vlInfo);'#010+
  3143. ' If (FMT<>'#039#039') then'#010+
  3144. ' Log(vlInfo,Format(Fmt,Args));'#010+
  3145. ' Log(vlInfo,Format(SHelpUsage,[Param','str(0)]));'#010+
  3146. ' Log(vlInfo,SHelpCommand);'#010+
  3147. ' LogCmd('#039'compile'#039',SHelpCompile);'#010+
  3148. ' LogCmd('#039'build'#039',SHelpBuild);'#010+
  3149. ' LogCmd('#039'install'#039',SHelpInstall);'#010+
  3150. ' LogCmd('#039'clean'#039',SHelpClean);'#010+
  3151. ' LogCmd('#039'archive'#039',SHelpArchive);'#010+
  3152. ' LogCmd('#039'manifest'#039',SHelpManifest);'#010+
  3153. ' L','og(vlInfo,SHelpCmdOptions);'#010+
  3154. ' LogOption('#039'h'#039','#039'help'#039',SHelpHelp);'#010+
  3155. ' LogOption('#039'l'#039','#039'list-commands'#039',SHelpList);'#010+
  3156. ' LogOption('#039'n'#039','#039'nofpccfg'#039',SHelpNoFPCCfg);'#010+
  3157. ' LogOption('#039'v'#039','#039'verbose'#039',SHelpVerbose);'#010+
  3158. ' LogArgOption('#039'C'#039','#039'cpu'#039',SHelpCPU);'#010+
  3159. ' LogArgOptio','n('#039'O'#039','#039'os'#039',SHelpOS);'#010+
  3160. ' LogArgOption('#039't'#039','#039'target'#039',SHelpTarget);'#010+
  3161. ' LogArgOption('#039'P'#039','#039'prefix'#039',SHelpPrefix);'#010+
  3162. ' LogArgOption('#039'B'#039','#039'baseinstalldir'#039',SHelpBaseInstalldi'+
  3163. 'r);'#010+
  3164. ' LogArgOption('#039'UL'#039','#039'localunitdir'#039',SHelpLocalUnitdir);'+
  3165. #010+
  3166. ' LogArgOption('#039'UG'#039','#039'g','lobalunitdir'#039',SHelpGlobalUnitd'+
  3167. 'ir);'#010+
  3168. ' LogArgOption('#039'r'#039','#039'compiler'#039',SHelpCompiler);'#010+
  3169. ' LogArgOption('#039'f'#039','#039'config'#039',SHelpConfig);'#010+
  3170. ' Log(vlInfo,'#039#039');'#010+
  3171. ' If (FMT<>'#039#039') then'#010+
  3172. ' halt(1)'#010+
  3173. ' else'#010+
  3174. ' halt(0);'#010+
  3175. 'end;'#010+
  3176. #010+
  3177. #010+
  3178. 'procedure TCustomInstaller.Compile(Force',': Boolean);'#010+
  3179. 'begin'#010+
  3180. ' FBuildEngine.ForceCompile:=Force;'#010+
  3181. ' FBuildEngine.Compile(FPackages);'#010+
  3182. 'end;'#010+
  3183. #010+
  3184. #010+
  3185. 'procedure TCustomInstaller.Clean;'#010+
  3186. 'begin'#010+
  3187. ' BuildEngine.Clean(FPackages);'#010+
  3188. 'end;'#010+
  3189. #010+
  3190. #010+
  3191. 'procedure TCustomInstaller.Install;'#010+
  3192. 'begin'#010+
  3193. ' BuildEngine.Install(F','Packages);'#010+
  3194. 'end;'#010+
  3195. #010+
  3196. #010+
  3197. 'procedure TCustomInstaller.Archive;'#010+
  3198. 'begin'#010+
  3199. ' // Force generation of manifest.xml, this is required for the reposi'+
  3200. 'tory'#010+
  3201. ' BuildEngine.Manifest(FPackages);'#010+
  3202. ' BuildEngine.Archive(FPackages);'#010+
  3203. 'end;'#010+
  3204. #010+
  3205. #010+
  3206. 'procedure TCustomInstaller.Ma','nifest;'#010+
  3207. 'begin'#010+
  3208. ' BuildEngine.Manifest(FPackages);'#010+
  3209. 'end;'#010+
  3210. #010+
  3211. #010+
  3212. 'procedure TCustomInstaller.CheckPackages;'#010+
  3213. 'begin'#010+
  3214. ' If (FPackages.Count=0) then'#010+
  3215. ' Error(SErrNoPackagesDefined);'#010+
  3216. ' // Check for other obvious errors ?'#010+
  3217. 'end;'#010+
  3218. #010+
  3219. #010+
  3220. 'Function TCustomInstaller.R','un : Boolean;'#010+
  3221. 'begin'#010+
  3222. ' Result:=True;'#010+
  3223. ' try'#010+
  3224. ' CheckPackages;'#010+
  3225. ' CreateBuildEngine;'#010+
  3226. ' Case RunMode of'#010+
  3227. ' rmCompile : Compile(False);'#010+
  3228. ' rmBuild : Compile(True);'#010+
  3229. ' rmInstall : Install;'#010+
  3230. ' rmArchive : Archive;'#010+
  3231. ' rmClean ',' : Clean;'#010+
  3232. ' rmManifest : Manifest;'#010+
  3233. ' end;'#010+
  3234. ' except'#010+
  3235. ' On E : Exception do'#010+
  3236. ' begin'#010+
  3237. ' Log(vlError,SErrInstaller);'#010+
  3238. ' Log(vlError,E.Message);'#010+
  3239. ' Result:=False;'#010+
  3240. ' end;'#010+
  3241. ' end;'#010+
  3242. ' // Force returning an exitcode to the she','ll'#010+
  3243. ' if not Result then'#010+
  3244. ' ExitCode:=1;'#010+
  3245. 'end;'#010+
  3246. #010+
  3247. #010+
  3248. '{*********************************************************************'+
  3249. '*******'#010+
  3250. ' TFPCInstaller'#010+
  3251. '********************************************************************','*'+
  3252. '*******}'#010+
  3253. #010+
  3254. 'constructor TFPCInstaller.Create(AOwner: TComponent);'#010+
  3255. 'begin'#010+
  3256. ' if assigned(Defaults) then'#010+
  3257. ' Error(SErrAlreadyInitialized);'#010+
  3258. ' Defaults:=TFPCDefaults.Create;'#010+
  3259. ' inherited Create(AOwner);'#010+
  3260. 'end;'#010+
  3261. #010+
  3262. #010+
  3263. '{************************************','*******************************'+
  3264. '*********'#010+
  3265. ' TBasicInstaller'#010+
  3266. '**********************************************************************'+
  3267. '******}'#010+
  3268. #010+
  3269. 'constructor TBasicInstaller.Create(AOwner: TComponent);'#010+
  3270. 'begin'#010+
  3271. ' if assi','gned(Defaults) then'#010+
  3272. ' Error(SErrAlreadyInitialized);'#010+
  3273. ' Defaults:=TBasicDefaults.Create;'#010+
  3274. ' inherited Create(AOwner);'#010+
  3275. 'end;'#010+
  3276. #010+
  3277. #010+
  3278. '{*********************************************************************'+
  3279. '*******'#010+
  3280. ' TBui','ldEngine'#010+
  3281. '**********************************************************************'+
  3282. '******}'#010+
  3283. #010+
  3284. 'constructor TBuildEngine.Create(AOwner: TComponent);'#010+
  3285. 'begin'#010+
  3286. ' inherited Create(AOwner);'#010+
  3287. ' // Maybe this should be the current directory ?'#010+
  3288. ' // Or have it',' as a command-line option.'#010+
  3289. ' // Would allow to put all '#039'installers'#039' in one dir and call t'+
  3290. 'hem'#010+
  3291. ' // With --start-dir=/path/to/sources.'#010+
  3292. ' FStartDir:=includeTrailingPathDelimiter(GetCurrentDir);'#010+
  3293. ' FExternalPackages:=TPackages.Create(TPackage);'#010,
  3294. 'end;'#010+
  3295. #010+
  3296. #010+
  3297. 'destructor TBuildEngine.Destroy;'#010+
  3298. 'begin'#010+
  3299. ' FreeAndNil(FExternalPackages);'#010+
  3300. ' inherited Destroy;'#010+
  3301. 'end;'#010+
  3302. #010+
  3303. #010+
  3304. 'procedure TBuildEngine.Error(const Msg: String);'#010+
  3305. 'begin'#010+
  3306. ' Raise EInstallerError.Create(Msg);'#010+
  3307. 'end;'#010+
  3308. #010+
  3309. #010+
  3310. 'procedure TBuildEngine.Error(const',' Fmt: String; const Args: array of'+
  3311. ' const);'#010+
  3312. 'begin'#010+
  3313. ' Raise EInstallerError.CreateFmt(Fmt,Args);'#010+
  3314. 'end;'#010+
  3315. #010+
  3316. #010+
  3317. 'procedure TBuildEngine.ExecuteCommand(const Cmd,Args : String; IgnoreE'+
  3318. 'rror : Boolean = False);'#010+
  3319. 'Var'#010+
  3320. ' E : Integer;'#010+
  3321. 'begin'#010+
  3322. ' Log(vlInfo,SInfoE','xecutingCommand,[Cmd,Args]);'#010+
  3323. ' if ListMode then'#010+
  3324. ' Log(vlCommand,'#039'%s %s'#039',[Cmd,Args])'#010+
  3325. ' else'#010+
  3326. ' begin'#010+
  3327. ' // We should check cmd for spaces, and move all after first spac'+
  3328. 'e to args.'#010+
  3329. ' E:=ExecuteProcess(cmd,args);'#010+
  3330. ' If (E<>0) and (','not IgnoreError) then'#010+
  3331. ' Error(SErrExternalCommandFailed,[Cmd,E]);'#010+
  3332. ' end;'#010+
  3333. 'end;'#010+
  3334. #010+
  3335. #010+
  3336. 'Function TBuildEngine.SysDirectoryExists(const ADir:string):Boolean;'#010+
  3337. 'begin'#010+
  3338. ' result:=SysUtils.DirectoryExists(ADir);'#010+
  3339. ' if result then'#010+
  3340. ' Log(vlDebug,SD','bgDirectoryExists,[ADir,SDbgFound])'#010+
  3341. ' else'#010+
  3342. ' Log(vlDebug,SDbgDirectoryExists,[ADir,SDbgNotFound]);'#010+
  3343. 'end;'#010+
  3344. #010+
  3345. #010+
  3346. 'Function TBuildEngine.SysFileExists(const AFileName:string):Boolean;'#010+
  3347. 'begin'#010+
  3348. ' result:=SysUtils.FileExists(AFileName);'#010+
  3349. ' if result the','n'#010+
  3350. ' Log(vlDebug,SDbgFileExists,[AFileName,SDbgFound])'#010+
  3351. ' else'#010+
  3352. ' Log(vlDebug,SDbgFileExists,[AFileName,SDbgNotFound]);'#010+
  3353. 'end;'#010+
  3354. #010+
  3355. #010+
  3356. 'procedure TBuildEngine.SysCopyFile(Const Src,Dest : String);'#010+
  3357. 'Var'#010+
  3358. ' D,S : String;'#010+
  3359. ' Fin,FOut : TFileStream;'#010+
  3360. ' Cou','nt : Int64;'#010+
  3361. ' A : Integer;'#010+
  3362. 'begin'#010+
  3363. ' Log(vlInfo,SInfoCopyingFile,[Src,Dest]);'#010+
  3364. ' FIn:=TFileStream.Create(Src,fmopenRead);'#010+
  3365. ' Try'#010+
  3366. ' D:=IncludeTrailingPathDelimiter(Dest);'#010+
  3367. ' If DirectoryExists(D) then'#010+
  3368. ' S:=D+ExtractFileName(Src)'#010+
  3369. ' else'#010,
  3370. ' S:=Dest;'#010+
  3371. ' FOut:=TFileStream.Create(S,fmCreate);'#010+
  3372. ' Try'#010+
  3373. ' Count:=Fout.CopyFrom(FIn,0);'#010+
  3374. ' If (Count<>Fin.Size) then'#010+
  3375. ' Error(SErrCopyingFile,[Src,S]);'#010+
  3376. ' Finally'#010+
  3377. ' FreeAndNil(Fout);'#010+
  3378. ' end;'#010+
  3379. ' A:=FileGetDate(FIn.','Handle);'#010+
  3380. ' If (A=-1) then'#010+
  3381. ' log(vlWarning,SWarnFailedToGetTime,[Src])'#010+
  3382. ' else'#010+
  3383. ' if FileSetDate(S,A)<>0 then'#010+
  3384. ' Log(vlWarning,SWarnFailedToSetTime,[S]);'#010+
  3385. ' finally'#010+
  3386. ' FreeAndNil(Fin);'#010+
  3387. ' end;'#010+
  3388. 'end;'#010+
  3389. #010+
  3390. #010+
  3391. 'procedure TBuildEngine.SysM','oveFile(Const Src,Dest : String);'#010+
  3392. 'Var'#010+
  3393. ' S : String;'#010+
  3394. 'begin'#010+
  3395. ' If DirectoryExists(IncludeTrailingPathDelimiter(Dest)) then'#010+
  3396. ' S:=IncludeTrailingPathDelimiter(Dest)+ExtractFileName(Src)'#010+
  3397. ' else'#010+
  3398. ' S:=Dest;'#010+
  3399. ' If Not RenameFile(Src,S) then'#010+
  3400. ' b','egin'#010+
  3401. ' Try'#010+
  3402. ' SysCopyFile(Src,S);'#010+
  3403. ' SysDeleteFile(Src);'#010+
  3404. ' Except'#010+
  3405. ' On E : Exception Do'#010+
  3406. ' Error(SErrMovingFile,[Src,S]);'#010+
  3407. ' end;'#010+
  3408. ' end;'#010+
  3409. 'end;'#010+
  3410. #010+
  3411. #010+
  3412. 'procedure TBuildEngine.SysDeleteFile(Const AFileName : Strin','g);'#010+
  3413. 'begin'#010+
  3414. ' if not FileExists(AFileName) then'#010+
  3415. ' Log(vlWarning,SWarnFileDoesNotExist,[AFileName])'#010+
  3416. ' else If Not DeleteFile(AFileName) then'#010+
  3417. ' Error(SErrDeletingFile,[AFileName]);'#010+
  3418. 'end;'#010+
  3419. #010+
  3420. #010+
  3421. 'procedure TBuildEngine.SysArchiveFiles(List: TString','s;Const AFileNam'+
  3422. 'e: String);'#010+
  3423. 'begin'#010+
  3424. ' If Not (Assigned(OnArchivefiles) or Assigned(ArchiveFilesProc)) then'+
  3425. #010+
  3426. ' Raise EInstallerError.Create(SErrNoArchiveSupport);'#010+
  3427. ' If Assigned(ArchiveFilesProc) then'#010+
  3428. ' ArchiveFilesProc(AFileName,List)'#010+
  3429. ' els','e'#010+
  3430. ' OnArchiveFiles(AFileName,List);'#010+
  3431. 'end;'#010+
  3432. #010+
  3433. #010+
  3434. 'procedure TBuildEngine.LogIndent;'#010+
  3435. 'begin'#010+
  3436. ' FLogPrefix:=FLogPrefix+'#039' '#039';'#010+
  3437. 'end;'#010+
  3438. #010+
  3439. #010+
  3440. 'procedure TBuildEngine.LogUnIndent;'#010+
  3441. 'begin'#010+
  3442. ' Delete(FLogPrefix,1,2);'#010+
  3443. 'end;'#010+
  3444. #010+
  3445. #010+
  3446. 'procedure TBuildEngine.Log(Level: TVerbose','Level; const Msg: String);'+
  3447. #010+
  3448. 'begin'#010+
  3449. ' If Assigned(FOnLog) then'#010+
  3450. ' begin'#010+
  3451. ' if Level in [vlInfo,vlDebug] then'#010+
  3452. ' FOnLog(Level,FLogPrefix+Msg)'#010+
  3453. ' else'#010+
  3454. ' FOnLog(Level,Msg);'#010+
  3455. ' end;'#010+
  3456. 'end;'#010+
  3457. #010+
  3458. #010+
  3459. 'procedure TBuildEngine.Log(Level: TVerb','oseLevel; const Fmt: String;c'+
  3460. 'onst Args: array of const);'#010+
  3461. 'begin'#010+
  3462. ' Log(Level,Format(Fmt,Args));'#010+
  3463. 'end;'#010+
  3464. #010+
  3465. #010+
  3466. 'procedure TBuildEngine.EnterDir(ADir: String);'#010+
  3467. 'Var'#010+
  3468. ' D : String;'#010+
  3469. 'begin'#010+
  3470. ' D:=FStartDir;'#010+
  3471. ' D:=D+ADir;'#010+
  3472. ' Log(vlDebug,SDbgEnterDir,[D]);'#010+
  3473. ' If N','ot SetCurrentDir(D) then'#010+
  3474. ' Error(SErrChangeDirFailed,[D]);'#010+
  3475. 'end;'#010+
  3476. #010+
  3477. #010+
  3478. 'procedure TBuildEngine.CmdCopyFiles(List: TStrings; Const DestDir: Str'+
  3479. 'ing);'#010+
  3480. #010+
  3481. 'Var'#010+
  3482. ' Args : String;'#010+
  3483. ' I : Integer;'#010+
  3484. #010+
  3485. 'begin'#010+
  3486. ' CmdCreateDir(DestDir);'#010+
  3487. ' If (Defaults.Copy<>'#039#039') th','en'#010+
  3488. ' begin'#010+
  3489. ' Args:=FileListToString(List,'#039#039');'#010+
  3490. ' Args:=Args+'#039' '#039'+DestDir;'#010+
  3491. ' ExecuteCommand(Defaults.Copy,Args);'#010+
  3492. ' end'#010+
  3493. ' else'#010+
  3494. ' For I:=0 to List.Count-1 do'#010+
  3495. ' SysCopyFile(List[i],DestDir);'#010+
  3496. 'end;'#010+
  3497. #010+
  3498. #010+
  3499. 'procedure TBuildEngine.Cmd','CreateDir(const DestDir: String);'#010+
  3500. 'begin'#010+
  3501. ' If (Defaults.MkDir<>'#039#039') then'#010+
  3502. ' ExecuteCommand(Defaults.MkDir,DestDir)'#010+
  3503. ' else'#010+
  3504. ' If not ForceDirectories(DestDir) then'#010+
  3505. ' Error(SErrCreatingDirectory,[DestDir]);'#010+
  3506. 'end;'#010+
  3507. #010+
  3508. #010+
  3509. 'procedure TBuildEngine.C','mdMoveFiles(List: TStrings; Const DestDir: S'+
  3510. 'tring);'#010+
  3511. 'Var'#010+
  3512. ' Args : String;'#010+
  3513. ' I : Integer;'#010+
  3514. 'begin'#010+
  3515. ' CmdCreateDir(DestDir);'#010+
  3516. ' If (Defaults.Move<>'#039#039') then'#010+
  3517. ' begin'#010+
  3518. ' Args:=FileListToString(List,'#039#039');'#010+
  3519. ' Args:=Args+'#039' '#039'+DestDir;'#010+
  3520. ' Execut','eCommand(Defaults.Move,Args);'#010+
  3521. ' end'#010+
  3522. ' else'#010+
  3523. ' For I:=0 to List.Count-1 do'#010+
  3524. ' SysMoveFile(List[i],DestDir);'#010+
  3525. 'end;'#010+
  3526. #010+
  3527. #010+
  3528. 'procedure TBuildEngine.CmdDeleteFiles(List: TStrings);'#010+
  3529. 'Var'#010+
  3530. ' Args : String;'#010+
  3531. ' I : Integer;'#010+
  3532. 'begin'#010+
  3533. ' If (Defaults.Remove<>',#039#039') then'#010+
  3534. ' begin'#010+
  3535. ' Args:=FileListToString(List,'#039#039');'#010+
  3536. ' ExecuteCommand(Defaults.Remove,Args);'#010+
  3537. ' end'#010+
  3538. ' else'#010+
  3539. ' For I:=0 to List.Count-1 do'#010+
  3540. ' SysDeleteFile(List[i]);'#010+
  3541. 'end;'#010+
  3542. #010+
  3543. #010+
  3544. 'procedure TBuildEngine.CmdArchiveFiles(List: TStrings;',' Const Archive'+
  3545. 'File: String);'#010+
  3546. 'Var'#010+
  3547. ' S,C,O : String;'#010+
  3548. 'begin'#010+
  3549. ' If (Defaults.Archive='#039#039') then'#010+
  3550. ' SysArchiveFiles(List,ArchiveFile)'#010+
  3551. ' else'#010+
  3552. ' begin'#010+
  3553. ' S:=FileListToString(List,'#039#039');'#010+
  3554. ' SplitCommand(Defaults.Archive,C,O);'#010+
  3555. ' If (O='#039#039') th','en'#010+
  3556. ' O:=ArchiveFile+'#039' '#039'+S'#010+
  3557. ' else'#010+
  3558. ' O:=Substitute(O,['#039'ARCHIVE'#039',ArchiveFile,'#039'FILESORDIR'+
  3559. 'S'#039']);'#010+
  3560. ' ExecuteCommand(C,O);'#010+
  3561. ' end;'#010+
  3562. 'end;'#010+
  3563. #010+
  3564. 'Function TBuildEngine.FileNewer(const Src,Dest : String) : Boolean;'#010+
  3565. #010+
  3566. 'Var'#010+
  3567. ' DS,DD : Longint;',#010+
  3568. ' D1,D2 : TDateTime;'#010+
  3569. #010+
  3570. 'begin'#010+
  3571. ' DS:=FileAge(Src);'#010+
  3572. ' DD:=FileAge(Dest);'#010+
  3573. ' D1:=FileDateToDateTime(DS);'#010+
  3574. ' D2:=FileDateToDateTime(DD);'#010+
  3575. ' Log(vlDebug,SDbgComparingFileTimes,[Src,DateTimeToStr(D1),Dest,DateT'+
  3576. 'imeToStr(D2)]);'#010+
  3577. ' Result:=D1>=D2;'#010+
  3578. ' If R','esult then'#010+
  3579. ' Log(vlInfo,SInfoSourceNewerDest,[Src,DateTimeToStr(D1),Dest,DateTi'+
  3580. 'meToStr(D2)]);'#010+
  3581. 'end;'#010+
  3582. #010+
  3583. #010+
  3584. 'procedure TBuildEngine.ExecuteCommands(Commands: TCommands; At: TComma'+
  3585. 'ndAt);'#010+
  3586. 'Var'#010+
  3587. ' C : TCommand;'#010+
  3588. ' I : Integer;'#010+
  3589. ' Cmd,O : String;'#010+
  3590. ' E : B','oolean;'#010+
  3591. 'begin'#010+
  3592. ' For I:=0 to Commands.Count-1 do'#010+
  3593. ' begin'#010+
  3594. ' C:=Commands.CommandItems[i];'#010+
  3595. ' if (C.At=At) then'#010+
  3596. ' begin'#010+
  3597. ' E:=True;'#010+
  3598. ' If (C.SourceFile<>'#039#039') and (C.DestFile<>'#039#039') then'+
  3599. #010+
  3600. ' E:=FileNewer(C.Sour','ceFile,IncludeTrailingPathDelimiter(D'+
  3601. 'ictionary.GetValue('#039'OUTPUTDIR'#039'))+C.DestFile);'#010+
  3602. ' If E then'#010+
  3603. ' begin'#010+
  3604. ' If Assigned(C.BeforeCommand) then'#010+
  3605. ' C.BeforeCommand(C);'#010+
  3606. ' O:=Substitute(C.Options,['#039'S','OURCE'#039',C.SourceFile,'#039+
  3607. 'DEST'#039',C.DestFile]);'#010+
  3608. ' Cmd:=C.Command;'#010+
  3609. ' If (ExtractFilePath(Cmd)='#039#039') then'#010+
  3610. ' Cmd:=FileSearch(Cmd,GetEnvironmentvariable('#039'PATH'#039+
  3611. '));'#010+
  3612. ' ExecuteCommand(Cmd,O,C.IgnoreResult);'#010+
  3613. ' ',' If Assigned(C.AfterCommand) then'#010+
  3614. ' C.AfterCommand(C);'#010+
  3615. ' end;'#010+
  3616. ' end;'#010+
  3617. ' end;'#010+
  3618. 'end;'#010+
  3619. #010+
  3620. #010+
  3621. 'Procedure TBuildEngine.LogSearchPath(const ASearchPathName:string;Path'+
  3622. ':TConditionalStrings; ACPU:TCPU;AOS:TOS);'#010+
  3623. 'var'#010+
  3624. ' S : St','ring;'#010+
  3625. ' I : Integer;'#010+
  3626. ' C : TConditionalString;'#010+
  3627. 'begin'#010+
  3628. ' S:='#039#039';'#010+
  3629. ' for i:=0 to Path.Count-1 do'#010+
  3630. ' begin'#010+
  3631. ' C:=Path[I];'#010+
  3632. ' if (ACPU in C.CPUs) and (AOS in C.OSes) then'#010+
  3633. ' begin'#010+
  3634. ' if S<>'#039#039' then'#010+
  3635. ' S:=S+PathSeparator;',#010+
  3636. ' S:=S+Dictionary.ReplaceStrings(C.Value)'#010+
  3637. ' end;'#010+
  3638. ' end;'#010+
  3639. ' if S<>'#039#039' then'#010+
  3640. ' Log(vlDebug,SDbgSearchPath,[ASearchPathName,S]);'#010+
  3641. 'end;'#010+
  3642. #010+
  3643. #010+
  3644. 'Function TBuildEngine.FindFileInPath(Path:TConditionalStrings; AFileNa'+
  3645. 'me:String; var FoundP','ath:String;ACPU:TCPU;AOS:TOS):Boolean;'#010+
  3646. 'var'#010+
  3647. ' I : Integer;'#010+
  3648. ' C : TConditionalString;'#010+
  3649. 'begin'#010+
  3650. ' Result:=false;'#010+
  3651. ' for i:=0 to Path.Count-1 do'#010+
  3652. ' begin'#010+
  3653. ' C:=Path[I];'#010+
  3654. ' if (ACPU in C.CPUs) and (AOS in C.OSes) then'#010+
  3655. ' begin'#010+
  3656. ' ','FoundPath:=IncludeTrailingPathDelimiter(Dictionary.Replace'+
  3657. 'Strings(C.Value));'#010+
  3658. ' if FileExists(FoundPath+AFileName) then'#010+
  3659. ' begin'#010+
  3660. ' result:=true;'#010+
  3661. ' exit;'#010+
  3662. ' end;'#010+
  3663. ' end;'#010+
  3664. ' end;'#010+
  3665. ' FoundP','ath:='#039#039';'#010+
  3666. 'end;'#010+
  3667. #010+
  3668. #010+
  3669. 'Procedure TBuildEngine.ResolveFileNames(APackage : TPackage; ACPU:TCPU'+
  3670. ';AOS:TOS;DoChangeDir:boolean=true);'#010+
  3671. #010+
  3672. ' procedure FindMainSource(T:TTarget);'#010+
  3673. ' var'#010+
  3674. ' SD,SF : String;'#010+
  3675. ' begin'#010+
  3676. ' LogSearchPath('#039'package source'#039',APackage','.SourcePath,ACPU,'+
  3677. 'AOS);'#010+
  3678. ' SD:=Dictionary.ReplaceStrings(T.Directory);'#010+
  3679. ' SF:=Dictionary.ReplaceStrings(T.SourceFileName);'#010+
  3680. ' if SD='#039#039' then'#010+
  3681. ' FindFileInPath(APackage.SourcePath,SF,SD,ACPU,AOS);'#010+
  3682. ' if SD<>'#039#039' then'#010+
  3683. ' SD:=IncludeTrai','lingPathDelimiter(SD);'#010+
  3684. ' T.FTargetSourceFileName:=SD+SF;'#010+
  3685. ' if FileExists(T.TargetSourceFileName) then'#010+
  3686. ' Log(vlDebug,SDbgResolvedSourceFile,[T.SourceFileName,T.TargetSou'+
  3687. 'rceFileName])'#010+
  3688. ' else'#010+
  3689. ' begin'#010+
  3690. ' Log(vlWarning,SWarnSo','urceFileNotFound,[T.SourceFileName,Make'+
  3691. 'TargetString(ACPU,AOS)]);'#010+
  3692. ' T.FTargetSourceFileName:='#039#039';'#010+
  3693. ' end;'#010+
  3694. ' end;'#010+
  3695. #010+
  3696. ' procedure FindIncludeSources(T:TTarget);'#010+
  3697. ' var'#010+
  3698. ' SD,SF : String;'#010+
  3699. ' D : TDependency;'#010+
  3700. ' j : integer;'#010+
  3701. ' begin'#010+
  3702. ' ',' LogSearchPath('#039'target include'#039',T.IncludePath,ACPU,AOS);'#010+
  3703. ' LogSearchPath('#039'package include'#039',APackage.IncludePath,ACPU,'+
  3704. 'AOS);'#010+
  3705. ' for j:=0 to T.Dependencies.Count-1 do'#010+
  3706. ' begin'#010+
  3707. ' D:=T.Dependencies[j];'#010+
  3708. ' if (D.DependencyType=de','pInclude) then'#010+
  3709. ' begin'#010+
  3710. ' D.TargetFileName:='#039#039';'#010+
  3711. ' if (ACPU in D.CPUs) and (AOS in D.OSes) then'#010+
  3712. ' begin'#010+
  3713. ' if ExtractFilePath(D.Value)='#039#039' then'#010+
  3714. ' begin'#010+
  3715. ' SF',':=Dictionary.ReplaceStrings(D.Value);'#010+
  3716. ' SD:='#039#039';'#010+
  3717. ' // first check the target specific path'#010+
  3718. ' if not FindFileInPath(T.IncludePath,SF,SD,ACPU,AOS'+
  3719. ') then'#010+
  3720. ' FindFileInPath(','APackage.IncludePath,SF,SD,ACPU'+
  3721. ',AOS);'#010+
  3722. ' if SD<>'#039#039' then'#010+
  3723. ' SD:=IncludeTrailingPathDelimiter(SD);'#010+
  3724. ' D.TargetFileName:=SD+SF;'#010+
  3725. ' end'#010+
  3726. ' else'#010+
  3727. ' ',' D.TargetFileName:=D.Value;'#010+
  3728. ' if FileExists(D.TargetFileName) then'#010+
  3729. ' Log(vlDebug,SDbgResolvedIncludeFile,[D.Value,D.Targe'+
  3730. 'tFileName])'#010+
  3731. ' else'#010+
  3732. ' begin'#010+
  3733. ' Log(vlWarni','ng,SWarnIncludeFileNotFound,[D.Value,'+
  3734. 'MakeTargetString(ACPU,AOS)]);'#010+
  3735. ' D.TargetFileName:='#039#039';'#010+
  3736. ' end;'#010+
  3737. ' end;'#010+
  3738. ' end;'#010+
  3739. ' end;'#010+
  3740. ' end;'#010+
  3741. #010+
  3742. ' procedure FindExampleSource(T:TTarget);'#010+
  3743. ' var'#010+
  3744. ' SD,','SF : String;'#010+
  3745. ' begin'#010+
  3746. ' LogSearchPath('#039'package example'#039',APackage.ExamplePath,ACPU,'+
  3747. 'AOS);'#010+
  3748. ' SD:=Dictionary.ReplaceStrings(T.Directory);'#010+
  3749. ' SF:=Dictionary.ReplaceStrings(T.SourceFileName);'#010+
  3750. ' if SD='#039#039' then'#010+
  3751. ' FindFileInPath(APackage.E','xamplePath,SF,SD,ACPU,AOS);'#010+
  3752. ' if SD<>'#039#039' then'#010+
  3753. ' SD:=IncludeTrailingPathDelimiter(SD);'#010+
  3754. ' T.FTargetSourceFileName:=SD+SF;'#010+
  3755. ' if FileExists(T.TargetSourceFileName) then'#010+
  3756. ' Log(vlDebug,SDbgResolvedSourceFile,[T.SourceFileName,T.Targe','tS'+
  3757. 'ourceFileName])'#010+
  3758. ' else'#010+
  3759. ' begin'#010+
  3760. ' Log(vlWarning,SWarnSourceFileNotFound,[T.SourceFileName,MakeTa'+
  3761. 'rgetString(ACPU,AOS)]);'#010+
  3762. ' T.FTargetSourceFileName:='#039#039';'#010+
  3763. ' end;'#010+
  3764. ' end;'#010+
  3765. #010+
  3766. 'var'#010+
  3767. ' T : TTarget;'#010+
  3768. ' i : Integer;'#010+
  3769. 'begin'#010+
  3770. ' if not((A','CPU in APackage.CPUs) and (AOS in APackage.OSes)) then'#010+
  3771. ' exit;'#010+
  3772. ' try'#010+
  3773. ' if DoChangeDir and (APackage.Directory<>'#039#039') then'#010+
  3774. ' EnterDir(APackage.Directory);'#010+
  3775. ' Dictionary.AddVariable('#039'CPU'#039',CPUToString(ACPU));'#010+
  3776. ' Dictionary.AddVariable(',#039'OS'#039',OSToString(AOS));'#010+
  3777. ' For I:=0 to APackage.Targets.Count-1 do'#010+
  3778. ' begin'#010+
  3779. ' T:=APackage.FTargets.TargetItems[I];'#010+
  3780. ' if (ACPU in T.CPUs) and (AOS in T.OSes) then'#010+
  3781. ' begin'#010+
  3782. ' // Debug information'#010+
  3783. ' Lo','g(vlDebug,SDbgResolvingSourcesOfTarget,[T.Name,MakeTar'+
  3784. 'getString(ACPU,AOS)]);'#010+
  3785. ' LogIndent;'#010+
  3786. #010+
  3787. ' case T.TargetType of'#010+
  3788. ' ttProgram,'#010+
  3789. ' ttUnit,'#010+
  3790. ' ttImplicitUnit :'#010+
  3791. ' begin'#010+
  3792. ' ',' FindMainSource(T);'#010+
  3793. ' if T.Dependencies.Count>0 then'#010+
  3794. ' FindIncludeSources(T);'#010+
  3795. ' end;'#010+
  3796. ' ttExampleUnit,'#010+
  3797. ' ttExampleProgram :'#010+
  3798. ' begin'#010+
  3799. ' ',' FindExampleSource(T);'#010+
  3800. ' end;'#010+
  3801. ' end;'#010+
  3802. #010+
  3803. ' LogUnIndent;'#010+
  3804. ' end;'#010+
  3805. ' end;'#010+
  3806. ' finally'#010+
  3807. ' If DoChangeDir and (APackage.Directory<>'#039#039') then'#010+
  3808. ' EnterDir('#039#039');'#010+
  3809. ' end;'#010+
  3810. 'end;'#010+
  3811. #010+
  3812. #010+
  3813. 'function TBuildEngine.Get','UnitDir(APackage:TPackage):String;'#010+
  3814. 'begin'#010+
  3815. ' // Retrieve Full directory name where to find the units.'#010+
  3816. ' // The search order is:'#010+
  3817. ' // - Package in this fpmake.pp'#010+
  3818. ' // - LocalUnitDir'#010+
  3819. ' // - GlobalUnitDir'#010+
  3820. ' if (APackage.UnitDir='#039#039') and'#010+
  3821. ' (','APackage.State=tsCompiled) then'#010+
  3822. ' begin'#010+
  3823. ' APackage.UnitDir:=IncludeTrailingPathDelimiter(FStartDir)+Includ'+
  3824. 'eTrailingPathDelimiter(APackage.Directory)+APackage.GetUnitsOutputDir('+
  3825. 'Defaults.CPU,Defaults.OS);'#010+
  3826. ' end;'#010+
  3827. ' if (APackage.UnitDir','='#039#039') and'#010+
  3828. ' (Defaults.LocalUnitDir<>'#039#039') then'#010+
  3829. ' begin'#010+
  3830. ' APackage.UnitDir:=IncludeTrailingPathDelimiter(Defaults.LocalUni'+
  3831. 'tDir)+APackage.Name;'#010+
  3832. ' if not SysDirectoryExists(APackage.UnitDir) then'#010+
  3833. ' APackage.UnitDir:='#039#039';'#010+
  3834. ' end',';'#010+
  3835. ' if APackage.UnitDir='#039#039' then'#010+
  3836. ' begin'#010+
  3837. ' APackage.UnitDir:=IncludeTrailingPathDelimiter(Defaults.GlobalUn'+
  3838. 'itDir)+APackage.Name;'#010+
  3839. ' if not SysDirectoryExists(APackage.UnitDir) then'#010+
  3840. ' APackage.UnitDir:=DirNotFound;'#010+
  3841. ' end;'#010+
  3842. ' /','/ Special error marker to prevent searches in case of error'#010+
  3843. ' if APackage.UnitDir=DirNotFound then'#010+
  3844. ' Result:='#039#039#010+
  3845. ' else'#010+
  3846. ' Result:=APackage.UnitDir;'#010+
  3847. 'end;'#010+
  3848. #010+
  3849. #010+
  3850. 'procedure TBuildEngine.AddDependencyIncludePaths(L:TStrings;ATarget: T'+
  3851. 'Target);'#010+
  3852. 'Var',#010+
  3853. ' I : Integer;'#010+
  3854. ' D : TDependency;'#010+
  3855. ' SD : String;'#010+
  3856. 'begin'#010+
  3857. ' For I:=0 to ATarget.Dependencies.Count-1 do'#010+
  3858. ' begin'#010+
  3859. ' D:=ATarget.Dependencies[i];'#010+
  3860. ' if (D.DependencyType=depInclude) and'#010+
  3861. ' (Defaults.CPU in D.CPUs) and (Defaults.OS ','in D.OSes) then'#010+
  3862. ' begin'#010+
  3863. ' SD:=ExcludeTrailingPathDelimiter(ExtractFilePath(D.TargetFil'+
  3864. 'eName));'#010+
  3865. ' if SD<>'#039#039' then'#010+
  3866. ' L.Add(SD);'#010+
  3867. ' end;'#010+
  3868. ' end;'#010+
  3869. 'end;'#010+
  3870. #010+
  3871. #010+
  3872. 'procedure TBuildEngine.AddDependencyUnitPaths(L:TStrin','gs;APackage: T'+
  3873. 'Package);'#010+
  3874. 'Var'#010+
  3875. ' I : Integer;'#010+
  3876. ' P : TPackage;'#010+
  3877. ' D : TDependency;'#010+
  3878. ' S : String;'#010+
  3879. 'begin'#010+
  3880. ' For I:=0 to APackage.Dependencies.Count-1 do'#010+
  3881. ' begin'#010+
  3882. ' D:=APackage.Dependencies[i];'#010+
  3883. ' if (D.DependencyType=depPackage) and'#010+
  3884. ' ',' (Defaults.CPU in D.CPUs) and (Defaults.OS in D.OSes) then'#010+
  3885. ' begin'#010+
  3886. ' P:=TPackage(D.Target);'#010+
  3887. ' If Assigned(P) then'#010+
  3888. ' begin'#010+
  3889. ' // Already processed?'#010+
  3890. ' S:=GetUnitDir(P);'#010+
  3891. ' if ','L.IndexOf(S)=-1 then'#010+
  3892. ' begin'#010+
  3893. ' // Add this package and then dependencies'#010+
  3894. ' L.Add(S);'#010+
  3895. ' AddDependencyUnitPaths(L,P);'#010+
  3896. ' end;'#010+
  3897. ' end;'#010+
  3898. ' end;'#010+
  3899. ' end;'#010+
  3900. 'en','d;'#010+
  3901. #010+
  3902. #010+
  3903. 'Function TBuildEngine.GetCompilerCommand(APackage : TPackage; ATarget '+
  3904. ': TTarget) : String;'#010+
  3905. 'Var'#010+
  3906. ' L,Args : TStringList;'#010+
  3907. ' i : Integer;'#010+
  3908. 'begin'#010+
  3909. ' Args:=TStringList.Create;'#010+
  3910. ' Args.Duplicates:=dupIgnore;'#010+
  3911. #010+
  3912. ' Result := '#039#039';'#010+
  3913. #010+
  3914. ' //compiler config','uration'#010+
  3915. ' if Defaults.NoFPCCfg then'#010+
  3916. ' Args.Add('#039'-n'#039');'#010+
  3917. #010+
  3918. ' // Target OS'#010+
  3919. ' Args.Add('#039'-T'#039'+OSToString(Defaults.OS));'#010+
  3920. #010+
  3921. ' // Compile mode'#010+
  3922. ' If ATarget.Mode<>cmFPC then'#010+
  3923. ' Args.Add('#039'-M'#039'+ModeToString(ATarget.Mode))'#010+
  3924. ' else If Defaults.Mode<>cmFPC ','then'#010+
  3925. ' Args.Add('#039'-M'#039'+ModeToString(Defaults.Mode));'#010+
  3926. ' // Output file paths'#010+
  3927. ' If ATarget.TargetType in ProgramTargets then'#010+
  3928. ' Args.Add('#039'-FE'#039'+APackage.GetBinOutputDir(Defaults.CPU,Defau'+
  3929. 'lts.OS));'#010+
  3930. ' Args.Add('#039'-FU'#039'+APackage.GetUnitsOutputDir(D','efaults.CPU,Def'+
  3931. 'aults.OS));'#010+
  3932. ' // Object Path'#010+
  3933. ' L:=TStringList.Create;'#010+
  3934. ' L.Sorted:=true;'#010+
  3935. ' L.Duplicates:=dupIgnore;'#010+
  3936. ' AddConditionalStrings(L,APackage.ObjectPath,Defaults.CPU,Defaults.OS'+
  3937. ');'#010+
  3938. ' AddConditionalStrings(L,ATarget.ObjectPath,Defaults','.CPU,Defaults.O'+
  3939. 'S);'#010+
  3940. ' for i:=0 to L.Count-1 do'#010+
  3941. ' Args.Add('#039'-Fo'#039'+L[i]);'#010+
  3942. ' FreeAndNil(L);'#010+
  3943. ' // Unit Dirs'#010+
  3944. ' L:=TStringList.Create;'#010+
  3945. ' L.Sorted:=true;'#010+
  3946. ' L.Duplicates:=dupIgnore;'#010+
  3947. ' AddDependencyUnitPaths(L,APackage);'#010+
  3948. ' AddConditionalStrings(L,AP','ackage.UnitPath,Defaults.CPU,Defaults.OS'+
  3949. ');'#010+
  3950. ' AddConditionalStrings(L,ATarget.UnitPath,Defaults.CPU,Defaults.OS);'#010+
  3951. ' for i:=0 to L.Count-1 do'#010+
  3952. ' Args.Add('#039'-Fu'#039'+L[i]);'#010+
  3953. ' FreeAndNil(L);'#010+
  3954. ' // Include Path'#010+
  3955. ' L:=TStringList.Create;'#010+
  3956. ' L.Sorted:=tr','ue;'#010+
  3957. ' L.Duplicates:=dupIgnore;'#010+
  3958. ' AddDependencyIncludePaths(L,ATarget);'#010+
  3959. ' AddConditionalStrings(L,APackage.IncludePath,Defaults.CPU,Defaults.O'+
  3960. 'S);'#010+
  3961. ' AddConditionalStrings(L,ATarget.IncludePath,Defaults.CPU,Defaults.OS'+
  3962. ');'#010+
  3963. ' for i:=0 to L.Count-','1 do'#010+
  3964. ' Args.Add('#039'-Fi'#039'+L[i]);'#010+
  3965. ' FreeAndNil(L);'#010+
  3966. ' // Custom Options'#010+
  3967. ' If (Defaults.Options<>'#039#039') then'#010+
  3968. ' Args.Add(Defaults.Options);'#010+
  3969. ' If (APackage.Options<>'#039#039') then'#010+
  3970. ' Args.Add(APackage.Options);'#010+
  3971. ' If (ATarget.Options<>'#039#039') then'#010+
  3972. ' Args.A','dd(ATarget.Options);'#010+
  3973. ' // Add Filename to compile'#010+
  3974. ' Args.Add(ATarget.TargetSourceFileName);'#010+
  3975. ' // Convert to string'#010+
  3976. ' Result:='#039#039';'#010+
  3977. ' for i:=0 to Args.Count-1 do'#010+
  3978. ' Result:=Result+'#039' '#039'+maybequoted(Args[i]);'#010+
  3979. ' Delete(result,1,1);'#010+
  3980. ' Args.Free;'#010+
  3981. 'e','nd;'#010+
  3982. #010+
  3983. #010+
  3984. 'Function TBuildEngine.GetCompiler : String;'#010+
  3985. 'Var'#010+
  3986. ' S : String;'#010+
  3987. 'begin'#010+
  3988. ' // Cache in FCompiler for speed.'#010+
  3989. ' If (FCompiler='#039#039') then'#010+
  3990. ' begin'#010+
  3991. ' FCompiler:=Defaults.Compiler;'#010+
  3992. ' If (ExtractFilePath(FCompiler)='#039#039') then'#010+
  3993. ' begin'#010+
  3994. ' ','S:=FileSearch(FCompiler,GetEnvironmentVariable('#039'PATH'#039')'+
  3995. ');'#010+
  3996. ' If (S<>'#039#039') then'#010+
  3997. ' FCompiler:=S;'#010+
  3998. ' end;'#010+
  3999. ' end;'#010+
  4000. ' Result:=FCompiler;'#010+
  4001. 'end;'#010+
  4002. #010+
  4003. #010+
  4004. 'procedure TBuildEngine.CreateOutputDir(APackage: TPackage);'#010+
  4005. 'Var'#010+
  4006. ' D : String;'#010+
  4007. ' i: integer',';'#010+
  4008. 'begin'#010+
  4009. ' //create a units directory'#010+
  4010. ' D:=APackage.GetUnitsOutputDir(Defaults.CPU,Defaults.OS);'#010+
  4011. ' If not SysDirectoryExists(D) then'#010+
  4012. ' begin'#010+
  4013. ' Log(vlInfo,SInfoCreatingOutputDir,[D]);'#010+
  4014. ' CmdCreateDir(D);'#010+
  4015. ' end;'#010+
  4016. #010+
  4017. ' //also create a b','in directory for programtargets'#010+
  4018. ' For i := 0 to Pred(APackage.Targets.Count) do'#010+
  4019. ' begin'#010+
  4020. ' if APackage.Targets.TargetItems[i].TargetType in ProgramTargets '+
  4021. 'then'#010+
  4022. ' begin'#010+
  4023. ' D:=APackage.GetBinOutputDir(Defaults.CPU,Defaults.O','S);'#010+
  4024. ' If not SysDirectoryExists(D) then'#010+
  4025. ' begin'#010+
  4026. ' Log(vlInfo,SInfoCreatingOutputDir,[D]);'#010+
  4027. ' CmdCreateDir(D);'#010+
  4028. ' end;'#010+
  4029. ' //do not continue loop, directory is made anyway'#010+
  4030. ' bre','ak;'#010+
  4031. ' end;'#010+
  4032. ' end;'#010+
  4033. 'end;'#010+
  4034. #010+
  4035. #010+
  4036. 'Function TBuildEngine.DependencyOK(ADependency : TDependency) : Boolea'+
  4037. 'n;'#010+
  4038. 'begin'#010+
  4039. ' Result:=(Defaults.CPU in ADependency.CPUs) and (Defaults.OS in ADepe'+
  4040. 'ndency.OSes);'#010+
  4041. 'end;'#010+
  4042. #010+
  4043. #010+
  4044. 'Function TBuildEngine.TargetOK(ATarge','t : TTarget) : Boolean;'#010+
  4045. 'begin'#010+
  4046. ' Result:=(Defaults.CPU in ATarget.CPUs) and (Defaults.OS in ATarget.O'+
  4047. 'Ses);'#010+
  4048. 'end;'#010+
  4049. #010+
  4050. #010+
  4051. 'Function TBuildEngine.PackageOK(APackage : TPackage) : Boolean;'#010+
  4052. 'begin'#010+
  4053. ' Result:=(Defaults.CPU in APackage.CPUs) and (Defaults.O','S in APacka'+
  4054. 'ge.OSes);'#010+
  4055. 'end;'#010+
  4056. #010+
  4057. #010+
  4058. 'procedure TBuildEngine.DoBeforeCompile(APackage: TPackage);'#010+
  4059. 'begin'#010+
  4060. ' ExecuteCommands(APackage.Commands,caBeforeCompile);'#010+
  4061. ' If Assigned(APackage.BeforeCompile) then'#010+
  4062. ' APackage.BeforeCompile(APackage);'#010+
  4063. 'end;'#010+
  4064. #010+
  4065. #010+
  4066. 'proc','edure TBuildEngine.DoAfterCompile(APackage: TPackage);'#010+
  4067. 'begin'#010+
  4068. ' If Assigned(APackage.AfterCompile) then'#010+
  4069. ' APackage.AfterCompile(APackage);'#010+
  4070. ' ExecuteCommands(APackage.Commands,caAfterCompile);'#010+
  4071. 'end;'#010+
  4072. #010+
  4073. #010+
  4074. 'Function TBuildEngine.NeedsCompile(APack','age:TPackage;ATarget: TTarge'+
  4075. 't): Boolean;'#010+
  4076. 'Var'#010+
  4077. ' I : Integer;'#010+
  4078. ' D : TDependency;'#010+
  4079. ' T : TTarget;'#010+
  4080. ' OD,OFN : String;'#010+
  4081. 'begin'#010+
  4082. ' Result:=False;'#010+
  4083. #010+
  4084. ' // Forced recompile?'#010+
  4085. ' if FForceCompile then'#010+
  4086. ' Result:=true;'#010+
  4087. #010+
  4088. ' // Check output file'#010+
  4089. ' if not resul','t then'#010+
  4090. ' begin'#010+
  4091. ' if ATarget.TargetType in ProgramTargets then'#010+
  4092. ' OD:=APackage.GetBinOutputDir(Defaults.CPU,Defaults.OS)'#010+
  4093. ' else'#010+
  4094. ' OD:=APackage.GetUnitsOutputDir(Defaults.CPU,Defaults.OS);'#010+
  4095. ' If (OD<>'#039#039') then'#010+
  4096. ' O','D:=IncludeTrailingPathDelimiter(OD);'#010+
  4097. ' OFN:=OD+ATarget.GetOutPutFileName(Defaults.OS);'#010+
  4098. ' Result:=Not FileExists(OFN);'#010+
  4099. ' if Result then'#010+
  4100. ' Log(vlDebug,SDbgOutputNotYetAvailable,[OFN]);'#010+
  4101. ' end;'#010+
  4102. #010+
  4103. ' // Check main source'#010+
  4104. ' If n','ot Result then'#010+
  4105. ' begin'#010+
  4106. ' if FileExists(ATarget.TargetSourceFileName) then'#010+
  4107. ' Result:=FileNewer(ATarget.TargetSourceFileName,OFN)'#010+
  4108. ' end;'#010+
  4109. #010+
  4110. ' // Check unit and include dependencies'#010+
  4111. ' If not Result then'#010+
  4112. ' begin'#010+
  4113. ' ResolveDepen','dencies(ATarget.Dependencies,ATarget.Collection as'+
  4114. ' TTargets);'#010+
  4115. ' I:=0;'#010+
  4116. ' for i:=0 to ATarget.Dependencies.Count-1 do'#010+
  4117. ' begin'#010+
  4118. ' D:=ATarget.Dependencies[i];'#010+
  4119. ' if (Defaults.CPU in D.CPUs) and (Defaults.OS in D.OSes',') th'+
  4120. 'en'#010+
  4121. ' begin'#010+
  4122. ' case D.DependencyType of'#010+
  4123. ' depUnit :'#010+
  4124. ' begin'#010+
  4125. ' T:=TTarget(D.Target);'#010+
  4126. ' If (T=Nil) then'#010+
  4127. ' Error(SErrDepUnknownTarget',',[ATarget.Name,D.Val'+
  4128. 'ue]);'#010+
  4129. ' // If a dependent package is compiled we always ne'+
  4130. 'ed to recompile'#010+
  4131. ' Log(vldebug, SDbgDependencyOnUnit, [ATarget.Name,T'+
  4132. '.Name]);'#010+
  4133. ' Result:=(T.State=tsCompiled);',#010+
  4134. ' if Result then'#010+
  4135. ' Log(vldebug, SDbgDependencyUnitRecompiled, [T.Na'+
  4136. 'me]);'#010+
  4137. ' end;'#010+
  4138. ' depInclude :'#010+
  4139. ' begin'#010+
  4140. ' if D.TargetFileName<>'#039#039' then'#010+
  4141. ' ',' Result:=FileNewer(D.TargetFileName,OFN)'#010+
  4142. ' end;'#010+
  4143. ' end;'#010+
  4144. ' if result then'#010+
  4145. ' break;'#010+
  4146. ' end;'#010+
  4147. ' end;'#010+
  4148. ' end;'#010+
  4149. #010+
  4150. ' if result then'#010+
  4151. ' Log(vlDebug,SDbgMustCompil','e,[ATarget.Name]);'#010+
  4152. 'end;'#010+
  4153. #010+
  4154. #010+
  4155. 'procedure TBuildEngine.Compile(APackage: TPackage; ATarget: TTarget);'#010+
  4156. 'Var'#010+
  4157. ' S : String;'#010+
  4158. 'begin'#010+
  4159. ' Log(vlInfo,SInfoCompilingTarget,[ATarget.Name]);'#010+
  4160. ' LogIndent;'#010+
  4161. ' ExecuteCommands(ATarget.Commands,caBeforeCompile);'#010+
  4162. ' I','f Assigned(ATarget.BeforeCompile) then'#010+
  4163. ' ATarget.BeforeCompile(ATarget);'#010+
  4164. ' S:=GetCompilerCommand(APackage,ATarget);'#010+
  4165. ' ExecuteCommand(GetCompiler,S);'#010+
  4166. ' If Assigned(ATarget.AfterCompile) then'#010+
  4167. ' ATarget.AfterCompile(ATarget);'#010+
  4168. ' ExecuteComm','ands(ATarget.Commands,caAfterCompile);'#010+
  4169. ' LogUnIndent;'#010+
  4170. 'end;'#010+
  4171. #010+
  4172. #010+
  4173. 'procedure TBuildEngine.CompileDependencies(APackage:TPackage; ATarget:'+
  4174. ' TTarget);'#010+
  4175. 'Var'#010+
  4176. ' I : Integer;'#010+
  4177. ' T : TTarget;'#010+
  4178. ' D : TDependency;'#010+
  4179. 'begin'#010+
  4180. ' Log(vlDebug, Format(SDbgCompilingDepe','ndenciesOfTarget, [ATarget.Na'+
  4181. 'me]));'#010+
  4182. ' LogIndent;'#010+
  4183. ' For I:=0 to ATarget.Dependencies.Count-1 do'#010+
  4184. ' begin'#010+
  4185. ' D:=ATarget.Dependencies[i];'#010+
  4186. ' if (D.DependencyType=depUnit) and'#010+
  4187. ' (Defaults.CPU in D.CPUs) and (Defaults.OS in D.OSes)',' then'#010+
  4188. ' begin'#010+
  4189. ' T:=TTarget(D.Target);'#010+
  4190. ' if Assigned(T) and (T<>ATarget) then'#010+
  4191. ' begin'#010+
  4192. ' if TargetOK(T) then'#010+
  4193. ' begin'#010+
  4194. ' // We don'#039't need to compile implicit units, they'+
  4195. ' ','are only'#010+
  4196. ' // used for dependency checking'#010+
  4197. ' if (T.TargetType<>ttImplicitUnit) then'#010+
  4198. ' begin'#010+
  4199. ' case T.State of'#010+
  4200. ' tsNeutral :'#010+
  4201. ' ',' MaybeCompile(APackage,T);'#010+
  4202. ' tsConsidering :'#010+
  4203. ' Log(vlWarning,SWarnCircularTargetDependency,'+
  4204. '[ATarget.Name,T.Name]);'#010+
  4205. ' end;'#010+
  4206. ' end;'#010+
  4207. ' end'#010+
  4208. ' ',' else'#010+
  4209. ' Log(vlWarning, Format(SWarnDepUnitNotFound, [T.Name, M'+
  4210. 'akeTargetString(Defaults.CPU,Defaults.OS)]));'#010+
  4211. ' end'#010+
  4212. ' else'#010+
  4213. ' Error(SErrDepUnknownTarget,[ATarget.Name,D.Value]);'#010+
  4214. ' end;'#010+
  4215. ' ',' end;'#010+
  4216. ' LogUnIndent;'#010+
  4217. 'end;'#010+
  4218. #010+
  4219. #010+
  4220. 'procedure TBuildEngine.MaybeCompile(APackage: TPackage; ATarget: TTarg'+
  4221. 'et);'#010+
  4222. 'begin'#010+
  4223. ' if ATarget.State<>tsNeutral then'#010+
  4224. ' Error(SErrInvalidState,[ATarget.Name]);'#010+
  4225. ' Log(vlDebug, Format(SDbgConsideringTarget, [ATarge','t.Name]));'#010+
  4226. ' LogIndent;'#010+
  4227. ' ATarget.FTargetState:=tsConsidering;'#010+
  4228. ' ResolveDependencies(ATarget.Dependencies,ATarget.Collection as TTarg'+
  4229. 'ets);'#010+
  4230. ' CompileDependencies(APackage, ATarget);'#010+
  4231. ' if NeedsCompile(APackage, ATarget) then'#010+
  4232. ' begin'#010+
  4233. ' C','ompile(APackage,ATarget);'#010+
  4234. ' ATarget.FTargetState:=tsCompiled;'#010+
  4235. ' end'#010+
  4236. ' else'#010+
  4237. ' ATarget.FTargetState:=tsNoCompile;'#010+
  4238. ' LogUnIndent;'#010+
  4239. 'end;'#010+
  4240. #010+
  4241. #010+
  4242. 'function TBuildEngine.NeedsCompile(APackage: TPackage): Boolean;'#010+
  4243. 'Var'#010+
  4244. ' I : Integer;'#010+
  4245. ' P : TPackage',';'#010+
  4246. ' D : TDependency;'#010+
  4247. 'begin'#010+
  4248. ' Result:=False;'#010+
  4249. #010+
  4250. ' // Forced recompile?'#010+
  4251. ' if FForceCompile then'#010+
  4252. ' Result:=true;'#010+
  4253. #010+
  4254. ' // Recompile because of Package Dependencies?'#010+
  4255. ' if not Result then'#010+
  4256. ' begin'#010+
  4257. ' I:=0;'#010+
  4258. ' For I:=0 to APackage.Dependenc','ies.Count-1 do'#010+
  4259. ' begin'#010+
  4260. ' D:=APackage.Dependencies[i];'#010+
  4261. ' if (D.DependencyType=depPackage) and'#010+
  4262. ' (Defaults.CPU in D.CPUs) and (Defaults.OS in D.OSes) the'+
  4263. 'n'#010+
  4264. ' begin'#010+
  4265. ' P:=TPackage(D.Ta','rget);'#010+
  4266. ' if Assigned(P) then'#010+
  4267. ' begin'#010+
  4268. ' Result:=(P.State=tsCompiled);'#010+
  4269. ' if Result then'#010+
  4270. ' break;'#010+
  4271. ' end;'#010+
  4272. ' end;'#010+
  4273. ' end;'#010+
  4274. ' end;'#010+
  4275. #010,
  4276. ' // Recompile a Target of this package?'#010+
  4277. ' If Not Result then'#010+
  4278. ' begin'#010+
  4279. ' try'#010+
  4280. ' If (APackage.Directory<>'#039#039') then'#010+
  4281. ' EnterDir(APackage.Directory);'#010+
  4282. ' for i:=0 to APackage.Targets.Count-1 do'#010+
  4283. ' begin'#010+
  4284. ' R','esult:=NeedsCompile(APackage,APackage.Targets.TargetIte'+
  4285. 'ms[i]);'#010+
  4286. ' if Result then'#010+
  4287. ' break;'#010+
  4288. ' end;'#010+
  4289. ' Finally'#010+
  4290. ' If (APackage.Directory<>'#039#039') then'#010+
  4291. ' EnterDir('#039#039');'#010+
  4292. ' end;'#010+
  4293. ' end;'#010+
  4294. #010+
  4295. ' if result th','en'#010+
  4296. ' Log(vlDebug,SDbgMustCompile,[APackage.Name]);'#010+
  4297. 'end;'#010+
  4298. #010+
  4299. #010+
  4300. 'function TBuildEngine.CheckExternalPackage(Const APackageName : String'+
  4301. '):TPackage;'#010+
  4302. 'var'#010+
  4303. ' S : String;'#010+
  4304. ' I : Integer;'#010+
  4305. 'begin'#010+
  4306. ' // Already checked?'#010+
  4307. ' I:=ExternalPackages.IndexOfName(APa','ckageName);'#010+
  4308. ' if I<>-1 then'#010+
  4309. ' begin'#010+
  4310. ' result:=ExternalPackages.PackageItems[I];'#010+
  4311. ' exit;'#010+
  4312. ' end;'#010+
  4313. ' // Create new external package'#010+
  4314. ' Result:=ExternalPackages.AddPackage(APackageName);'#010+
  4315. ' Result.FTargetState:=tsNotFound;'#010+
  4316. ' // Load un','it config'#010+
  4317. ' S:=GetUnitDir(Result);'#010+
  4318. ' if S<>'#039#039' then'#010+
  4319. ' begin'#010+
  4320. ' Log(vldebug, SDbgExternalDependency, [APackageName,S]);'#010+
  4321. ' Result.FTargetState:=tsInstalled;'#010+
  4322. ' // Load unit config if it exists'#010+
  4323. ' S:=IncludeTrailingPathDelimiter(','S)+UnitConfigFile;'#010+
  4324. ' if FileExists(S) then'#010+
  4325. ' begin'#010+
  4326. ' Log(vlDebug, Format(SDbgLoading, [S]));'#010+
  4327. ' Result.LoadUnitConfigFromFile(S);'#010+
  4328. ' end;'#010+
  4329. ' // Check recursive implicit dependencies'#010+
  4330. ' CompileDependencies','(Result);'#010+
  4331. ' end'#010+
  4332. ' else'#010+
  4333. ' Error(SErrDependencyNotFound,[APackageName]);'#010+
  4334. 'end;'#010+
  4335. #010+
  4336. #010+
  4337. 'procedure TBuildEngine.CompileDependencies(APackage: TPackage);'#010+
  4338. 'Var'#010+
  4339. ' I : Integer;'#010+
  4340. ' P : TPackage;'#010+
  4341. ' D : TDependency;'#010+
  4342. 'begin'#010+
  4343. ' For I:=0 to APackage.Dependencie','s.Count-1 do'#010+
  4344. ' begin'#010+
  4345. ' D:=APackage.Dependencies[i];'#010+
  4346. ' if (D.DependencyType=depPackage) and'#010+
  4347. ' (Defaults.CPU in D.CPUs) and (Defaults.OS in D.OSes) then'#010+
  4348. ' begin'#010+
  4349. ' P:=TPackage(D.Target);'#010+
  4350. ' If Assigned(P) ','then'#010+
  4351. ' begin'#010+
  4352. ' case P.State of'#010+
  4353. ' tsNeutral :'#010+
  4354. ' MaybeCompile(P);'#010+
  4355. ' tsConsidering :'#010+
  4356. ' Log(vlWarning,SWarnCircularPackageDependency,[APacka'+
  4357. 'ge.Name,P.Name]);'#010+
  4358. ' ',' end;'#010+
  4359. ' end'#010+
  4360. ' else'#010+
  4361. ' begin'#010+
  4362. ' D.Target:=CheckExternalPackage(D.Value);'#010+
  4363. ' P:=TPackage(D.Target);'#010+
  4364. ' end;'#010+
  4365. ' if (D.RequireChecksum<>$ffffffff) and'#010+
  4366. ' (P.Ins','talledChecksum<>$ffffffff) and'#010+
  4367. ' (P.InstalledChecksum<>D.RequireChecksum) then'#010+
  4368. ' Log(vlDebug,SDbgPackageChecksumChanged,[P.Name]);'#010+
  4369. ' end;'#010+
  4370. ' end;'#010+
  4371. 'end;'#010+
  4372. #010+
  4373. #010+
  4374. 'procedure TBuildEngine.Compile(APackage: TPackage);'#010+
  4375. 'Var'#010+
  4376. ' T',' : TTarget;'#010+
  4377. ' I : Integer;'#010+
  4378. 'begin'#010+
  4379. ' Try'#010+
  4380. ' Log(vlInfo,SInfoCompilingPackage,[APackage.Name]);'#010+
  4381. ' If (APackage.Directory<>'#039#039') then'#010+
  4382. ' EnterDir(APackage.Directory);'#010+
  4383. ' CreateOutputDir(APackage);'#010+
  4384. ' Dictionary.AddVariable('#039'UNITSOUTPUTDIR',#039',APackage.GetUnitsO'+
  4385. 'utputDir(Defaults.CPU,Defaults.OS));'#010+
  4386. ' Dictionary.AddVariable('#039'BINOUTPUTDIR'#039',APackage.GetBinOutpu'+
  4387. 'tDir(Defaults.CPU,Defaults.OS));'#010+
  4388. ' DoBeforeCompile(APackage);'#010+
  4389. ' For I:=0 to APackage.Targets.Count-1 do'#010+
  4390. ' begin'#010+
  4391. ' ',' T:=APackage.Targets.TargetItems[i];'#010+
  4392. ' if (T.TargetType in [ttUnit,ttProgram]) then'#010+
  4393. ' begin'#010+
  4394. ' if TargetOK(T) then'#010+
  4395. ' begin'#010+
  4396. ' if T.State=tsNeutral then'#010+
  4397. ' MaybeCompile(APa','ckage,T);'#010+
  4398. ' end'#010+
  4399. ' else'#010+
  4400. ' begin'#010+
  4401. ' if not(Defaults.CPU in T.CPUs) then'#010+
  4402. ' Log(vldebug, Format(SDbgSkippingTargetWrongCPU, [T.N'+
  4403. 'ame, CPUsToString(T.CPUs)]));'#010+
  4404. ' if not(','Defaults.OS in T.OSes) then'#010+
  4405. ' Log(vldebug, Format(SDbgSkippingTargetWrongOS, [T.Na'+
  4406. 'me, OSesToString(T.OSes)]));'#010+
  4407. ' end;'#010+
  4408. ' end'#010+
  4409. ' else'#010+
  4410. ' log(vldebug, SDbgTargetIsNotAUnitOrProgram,[T.Name]);'#010+
  4411. ' ',' end;'#010+
  4412. ' DoAfterCompile(APackage);'#010+
  4413. ' Finally'#010+
  4414. ' If (APackage.Directory<>'#039#039') then'#010+
  4415. ' EnterDir('#039#039');'#010+
  4416. ' end;'#010+
  4417. 'end;'#010+
  4418. #010+
  4419. #010+
  4420. 'procedure TBuildEngine.MaybeCompile(APackage: TPackage);'#010+
  4421. 'begin'#010+
  4422. ' if APackage.State<>tsNeutral then'#010+
  4423. ' Error(SErrInvalidS','tate,[APackage.Name]);'#010+
  4424. ' Log(vlDebug,SDbgConsideringPackage,[APackage.Name]);'#010+
  4425. ' LogIndent;'#010+
  4426. ' APackage.FTargetState:=tsConsidering;'#010+
  4427. ' ResolveDependencies(APackage.Dependencies,(APackage.Collection as TP'+
  4428. 'ackages));'#010+
  4429. ' CompileDependencies(APacka','ge);'#010+
  4430. ' ResolveFileNames(APackage,Defaults.CPU,Defaults.OS);'#010+
  4431. ' If NeedsCompile(APackage) then'#010+
  4432. ' begin'#010+
  4433. ' Compile(APackage);'#010+
  4434. ' APackage.FTargetState:=tsCompiled;'#010+
  4435. ' end'#010+
  4436. ' else'#010+
  4437. ' APackage.FTargetState:=tsNoCompile;'#010+
  4438. ' LogUnIndent;'#010+
  4439. 'e','nd;'#010+
  4440. #010+
  4441. #010+
  4442. 'Function TBuildEngine.InstallPackageFiles(APAckage : TPackage; tt : TT'+
  4443. 'argetType; Const Dest : String):Boolean;'#010+
  4444. 'Var'#010+
  4445. ' List : TStringList;'#010+
  4446. 'begin'#010+
  4447. ' Result:=False;'#010+
  4448. ' List:=TStringList.Create;'#010+
  4449. ' Try'#010+
  4450. ' APackage.GetInstallFiles(List,[tt],D','efaults.CPU, Defaults.OS);'#010+
  4451. ' if (List.Count>0) then'#010+
  4452. ' begin'#010+
  4453. ' Result:=True;'#010+
  4454. ' CmdCopyFiles(List,Dest);'#010+
  4455. ' end;'#010+
  4456. ' Finally'#010+
  4457. ' List.Free;'#010+
  4458. ' end;'#010+
  4459. 'end;'#010+
  4460. #010+
  4461. #010+
  4462. 'procedure TBuildEngine.DoBeforeInstall(APackage: TPackage);'#010+
  4463. 'begin'#010+
  4464. ' E','xecuteCommands(APackage.Commands,caBeforeInstall);'#010+
  4465. ' If Assigned(APackage.BeforeInstall) then'#010+
  4466. ' APackage.BeforeInstall(APackage);'#010+
  4467. 'end;'#010+
  4468. #010+
  4469. #010+
  4470. 'procedure TBuildEngine.DoAfterInstall(APackage: TPackage);'#010+
  4471. 'begin'#010+
  4472. ' If Assigned(APackage.AfterInstall)',' then'#010+
  4473. ' APackage.AfterInstall(APackage);'#010+
  4474. ' ExecuteCommands(APackage.Commands,caAfterInstall);'#010+
  4475. 'end;'#010+
  4476. #010+
  4477. #010+
  4478. 'procedure TBuildEngine.Install(APackage: TPackage);'#010+
  4479. 'Var'#010+
  4480. ' UC,D : String;'#010+
  4481. ' B : Boolean;'#010+
  4482. 'begin'#010+
  4483. ' If (Apackage.State<>tsCompiled) then'#010+
  4484. ' ','MaybeCompile(APackage);'#010+
  4485. ' try'#010+
  4486. ' Log(vlInfo,SInfoInstallingPackage,[APackage.Name]);'#010+
  4487. ' If (APackage.Directory<>'#039#039') then'#010+
  4488. ' EnterDir(APackage.Directory);'#010+
  4489. ' DoBeforeInstall(APackage);'#010+
  4490. ' // units'#010+
  4491. ' B:=false;'#010+
  4492. ' D:=IncludeTrailingP','athDelimiter(Defaults.UnitInstallDir)+APackag'+
  4493. 'e.Name;'#010+
  4494. ' if InstallPackageFiles(APAckage,ttUnit,D) then'#010+
  4495. ' B:=true;'#010+
  4496. ' if InstallPackageFiles(APAckage,ttImplicitUnit,D) then'#010+
  4497. ' B:=true;'#010+
  4498. ' // Unit (dependency) configuration if there',' were units installed'+
  4499. #010+
  4500. ' if B then'#010+
  4501. ' begin'#010+
  4502. ' UC:=IncludeTrailingPathDelimiter(D)+UnitConfigFile;'#010+
  4503. ' Log(vlInfo, Format(SDbgGenerating, [UC]));'#010+
  4504. ' APackage.SaveUnitConfigToFile(UC,Defaults.CPU,Defaults.OS);'#010+
  4505. ' end;'#010+
  4506. ' ',' // Programs'#010+
  4507. ' D:=IncludeTrailingPathDelimiter(Defaults.BinInstallDir);'#010+
  4508. ' InstallPackageFiles(APAckage,ttProgram,D);'#010+
  4509. ' // Done.'#010+
  4510. ' APackage.FTargetState:=tsInstalled;'#010+
  4511. ' DoAfterInstall(APackage);'#010+
  4512. ' Finally'#010+
  4513. ' If (APackage.Director','y<>'#039#039') then'#010+
  4514. ' EnterDir('#039#039');'#010+
  4515. ' end;'#010+
  4516. 'end;'#010+
  4517. #010+
  4518. #010+
  4519. 'procedure TBuildEngine.DoBeforeArchive(APackage: TPackage);'#010+
  4520. 'begin'#010+
  4521. ' ExecuteCommands(APackage.Commands,caBeforeArchive);'#010+
  4522. ' If Assigned(APackage.BeforeArchive) then'#010+
  4523. ' APackage.BeforeArchive(APac','kage);'#010+
  4524. 'end;'#010+
  4525. #010+
  4526. #010+
  4527. 'procedure TBuildEngine.DoAfterArchive(APackage: TPackage);'#010+
  4528. 'begin'#010+
  4529. ' If Assigned(APackage.AfterArchive) then'#010+
  4530. ' APackage.AfterArchive(APackage);'#010+
  4531. ' ExecuteCommands(APackage.Commands,caAfterArchive);'#010+
  4532. 'end;'#010+
  4533. #010+
  4534. #010+
  4535. 'procedure TBuildEngine','.Archive(APackage: TPackage);'#010+
  4536. 'Var'#010+
  4537. ' L : TStringList;'#010+
  4538. ' A : String;'#010+
  4539. ' i: integer;'#010+
  4540. ' ICPU : TCPU;'#010+
  4541. ' IOS : TOS;'#010+
  4542. 'begin'#010+
  4543. ' A:=FStartDir+ APackage.FileName + ZipExt;'#010+
  4544. ' Log(vlInfo,SInfoArchivingPackage,[APackage.Name,A]);'#010+
  4545. ' try'#010+
  4546. ' If (APackage.Di','rectory<>'#039#039') then'#010+
  4547. ' EnterDir(APackage.Directory);'#010+
  4548. ' DoBeforeArchive(Apackage);'#010+
  4549. ' L:=TStringList.Create;'#010+
  4550. ' L.Sorted:=true;'#010+
  4551. ' L.Duplicates:=dupIgnore;'#010+
  4552. ' Try'#010+
  4553. ' // Add fpmake.pp & manifest.xml always'#010+
  4554. ' L.Add(FPMakePPFile);',#010+
  4555. ' L.Add(ManifestFile);'#010+
  4556. ' //get all files from all targets'#010+
  4557. ' for ICPU:=Low(TCPU) to high(TCPU) do'#010+
  4558. ' for IOS:=Low(TOS) to high(TOS) do'#010+
  4559. ' if OSCPUSupported[IOS,ICPU] then'#010+
  4560. ' begin'#010+
  4561. ' ResolveFileNa','mes(APackage,ICPU,IOS,false);'#010+
  4562. ' APackage.GetArchiveFiles(L, ICPU, IOS);'#010+
  4563. ' end;'#010+
  4564. ' //from sources'#010+
  4565. ' for i := 0 to APackage.Sources.Count-1 do'#010+
  4566. ' L.Add(APackage.Sources[i].Name);'#010+
  4567. #010+
  4568. ' //show all files'#010+
  4569. ' ',' for i := 0 to L.Count-1 do'#010+
  4570. ' Log(vlDebug, Format(SDbgArchivingFile, [L[i]]));'#010+
  4571. #010+
  4572. '{$ifdef HAS_UNIT_ZIPPER}'#010+
  4573. ' if not Assigned(ArchiveFilesProc) then'#010+
  4574. ' begin'#010+
  4575. ' FZipFile := TZipper.Create;'#010+
  4576. ' FZipFile.ZipFiles(A, L',');'#010+
  4577. ' end'#010+
  4578. ' else'#010+
  4579. '{$endif HAS_UNIT_ZIPPER}'#010+
  4580. ' CmdArchiveFiles(L,A);'#010+
  4581. ' Finally'#010+
  4582. ' L.Free;'#010+
  4583. #010+
  4584. '{$ifdef HAS_UNIT_ZIPPER}'#010+
  4585. ' if not Assigned(ArchiveFilesProc) then'#010+
  4586. ' FreeAndNil(FZipFile);'#010+
  4587. '{$endif HAS_UNIT_ZIPPER}'#010+
  4588. ' end',';'#010+
  4589. ' DoAfterArchive(Apackage);'#010+
  4590. ' Finally'#010+
  4591. ' If (APackage.Directory<>'#039#039') then'#010+
  4592. ' EnterDir('#039#039');'#010+
  4593. ' end;'#010+
  4594. 'end;'#010+
  4595. #010+
  4596. #010+
  4597. 'procedure TBuildEngine.DoBeforeClean(APackage: TPackage);'#010+
  4598. 'begin'#010+
  4599. ' ExecuteCommands(APackage.Commands,caBeforeClean);'#010+
  4600. ' If Assign','ed(APackage.BeforeClean) then'#010+
  4601. ' APackage.BeforeClean(APackage);'#010+
  4602. 'end;'#010+
  4603. #010+
  4604. #010+
  4605. 'procedure TBuildEngine.DoAfterClean(APackage: TPackage);'#010+
  4606. 'begin'#010+
  4607. ' If Assigned(APackage.AfterClean) then'#010+
  4608. ' APackage.AfterClean(APackage);'#010+
  4609. ' ExecuteCommands(APackage.Co','mmands,caAfterClean);'#010+
  4610. 'end;'#010+
  4611. #010+
  4612. #010+
  4613. 'procedure TBuildEngine.Clean(APackage: TPackage);'#010+
  4614. 'Var'#010+
  4615. ' List : TStringList;'#010+
  4616. 'begin'#010+
  4617. ' Log(vlInfo,SInfoCleaningPackage,[APackage.Name]);'#010+
  4618. ' try'#010+
  4619. ' If (APackage.Directory<>'#039#039') then'#010+
  4620. ' EnterDir(APackage.Directory)',';'#010+
  4621. ' DoBeforeClean(Apackage);'#010+
  4622. ' List:=TStringList.Create;'#010+
  4623. ' try'#010+
  4624. ' APackage.GetCleanFiles(List,Defaults.CPU,Defaults.OS);'#010+
  4625. ' if (List.Count>0) then'#010+
  4626. ' CmdDeleteFiles(List);'#010+
  4627. ' Finally'#010+
  4628. ' List.Free;'#010+
  4629. ' end;'#010+
  4630. ' DoAfterCl','ean(Apackage);'#010+
  4631. ' Finally'#010+
  4632. ' If (APackage.Directory<>'#039#039') then'#010+
  4633. ' EnterDir('#039#039');'#010+
  4634. ' end;'#010+
  4635. 'end;'#010+
  4636. #010+
  4637. #010+
  4638. 'Procedure TBuildEngine.Manifest(APackage : TPackage);'#010+
  4639. 'Var'#010+
  4640. ' L : TStrings;'#010+
  4641. ' PD,'#010+
  4642. ' MF : String;'#010+
  4643. 'begin'#010+
  4644. ' L:=TStringList.Create;'#010+
  4645. ' Try'#010+
  4646. ' Log(vlIn','fo, Format(SInfoManifestPackage,[APackage.Name]));'#010+
  4647. ' PD:=APackage.Directory;'#010+
  4648. ' if PD<>'#039#039' then'#010+
  4649. ' PD:=IncludeTrailingPathDelimiter(PD);'#010+
  4650. ' MF:=PD+ManifestFile;'#010+
  4651. ' Log(vlDebug, Format(SDbgGenerating, [MF]));'#010+
  4652. ' L.Add('#039'<?xml version=','"1.0"?>'#039');'#010+
  4653. ' L.Add('#039'<packages>'#039');'#010+
  4654. ' APackage.GetManifest(L);'#010+
  4655. ' L.Add('#039'</packages>'#039');'#010+
  4656. ' L.SaveToFile(MF);'#010+
  4657. ' Finally'#010+
  4658. ' L.Free;'#010+
  4659. ' end;'#010+
  4660. 'end;'#010+
  4661. #010+
  4662. #010+
  4663. 'procedure TBuildEngine.Compile(Packages: TPackages);'#010+
  4664. 'Var'#010+
  4665. ' I : Integer;'#010+
  4666. ' P : TPackage;'#010+
  4667. 'beg','in'#010+
  4668. ' If Assigned(BeforeCompile) then'#010+
  4669. ' BeforeCompile(Self);'#010+
  4670. ' For I:=0 to Packages.Count-1 do'#010+
  4671. ' begin'#010+
  4672. ' P:=Packages.PackageItems[i];'#010+
  4673. ' If PackageOK(P) then'#010+
  4674. ' MaybeCompile(P);'#010+
  4675. ' end;'#010+
  4676. ' If Assigned(AfterCompile) then'#010+
  4677. ' A','fterCompile(Self);'#010+
  4678. 'end;'#010+
  4679. #010+
  4680. #010+
  4681. 'procedure TBuildEngine.Install(Packages: TPackages);'#010+
  4682. 'Var'#010+
  4683. ' I : Integer;'#010+
  4684. ' P : TPackage;'#010+
  4685. 'begin'#010+
  4686. ' If Assigned(BeforeInstall) then'#010+
  4687. ' BeforeInstall(Self);'#010+
  4688. ' For I:=0 to Packages.Count-1 do'#010+
  4689. ' begin'#010+
  4690. ' P:=Packages','.PackageItems[i];'#010+
  4691. ' If PackageOK(P) then'#010+
  4692. ' Install(P);'#010+
  4693. ' end;'#010+
  4694. ' If Assigned(AfterInstall) then'#010+
  4695. ' AfterInstall(Self);'#010+
  4696. 'end;'#010+
  4697. #010+
  4698. #010+
  4699. 'procedure TBuildEngine.Archive(Packages: TPackages);'#010+
  4700. 'Var'#010+
  4701. ' I : Integer;'#010+
  4702. ' P : TPackage;'#010+
  4703. 'begin'#010+
  4704. ' If Ass','igned(BeforeArchive) then'#010+
  4705. ' BeforeArchive(Self);'#010+
  4706. ' Log(vlDebug, SDbgBuildEngineArchiving);'#010+
  4707. ' For I:=0 to Packages.Count-1 do'#010+
  4708. ' begin'#010+
  4709. ' P:=Packages.PackageItems[i];'#010+
  4710. ' Archive(P);'#010+
  4711. ' end;'#010+
  4712. ' If Assigned(AfterArchive) then'#010+
  4713. ' Afte','rArchive(Self);'#010+
  4714. 'end;'#010+
  4715. #010+
  4716. #010+
  4717. 'procedure TBuildEngine.Manifest(Packages: TPackages);'#010+
  4718. 'Var'#010+
  4719. ' I : Integer;'#010+
  4720. ' P : TPackage;'#010+
  4721. 'begin'#010+
  4722. ' If Assigned(BeforeManifest) then'#010+
  4723. ' BeforeManifest(Self);'#010+
  4724. ' Log(vlDebug, SDbgBuildEngineGenerateManifests);'#010+
  4725. ' For I:=0 ','to Packages.Count-1 do'#010+
  4726. ' begin'#010+
  4727. ' P:=Packages.PackageItems[i];'#010+
  4728. ' Manifest(P);'#010+
  4729. ' end;'#010+
  4730. ' If Assigned(AfterManifest) then'#010+
  4731. ' AfterManifest(Self);'#010+
  4732. 'end;'#010+
  4733. #010+
  4734. #010+
  4735. 'procedure TBuildEngine.Clean(Packages: TPackages);'#010+
  4736. 'Var'#010+
  4737. ' I : Integer;'#010+
  4738. ' P : TP','ackage;'#010+
  4739. 'begin'#010+
  4740. ' If Assigned(BeforeClean) then'#010+
  4741. ' BeforeClean(Self);'#010+
  4742. ' Log(vldebug, SDbgBuildEngineCleaning);'#010+
  4743. ' For I:=0 to Packages.Count-1 do'#010+
  4744. ' begin'#010+
  4745. ' P:=Packages.PackageItems[i];'#010+
  4746. ' If PackageOK(P) then'#010+
  4747. ' Clean(P);'#010+
  4748. ' end;'#010+
  4749. ' I','f Assigned(AfterClean) then'#010+
  4750. ' AfterClean(Self);'#010+
  4751. 'end;'#010+
  4752. #010+
  4753. #010+
  4754. '{*********************************************************************'+
  4755. '*******'#010+
  4756. ' TFPVersion'#010+
  4757. '***************************************************************','*****'+
  4758. '********}'#010+
  4759. #010+
  4760. 'function TFPVersion.GetAsString: String;'#010+
  4761. 'begin'#010+
  4762. ' if Empty then'#010+
  4763. ' Result:='#039'<none>'#039#010+
  4764. ' else'#010+
  4765. ' Result:=Format('#039'%d.%d.%d-%d'#039',[Major,Minor,Micro,Build]);'#010+
  4766. 'end;'#010+
  4767. #010+
  4768. 'function TFPVersion.GetEmpty: Boolean;'#010+
  4769. 'begin'#010+
  4770. ' Result:=(Major=0) a','nd (Minor=0) and (Micro=0) and (Build=0);'#010+
  4771. 'end;'#010+
  4772. #010+
  4773. 'procedure TFPVersion.SetAsString(const AValue: String);'#010+
  4774. #010+
  4775. ' Function NextDigit(sep : Char; var V : string) : integer;'#010+
  4776. #010+
  4777. ' Var'#010+
  4778. ' P : Integer;'#010+
  4779. #010+
  4780. ' begin'#010+
  4781. ' P:=Pos(Sep,V);'#010+
  4782. ' If (P=0) then'#010+
  4783. ' ',' P:=Length(V)+1;'#010+
  4784. ' Result:=StrToIntDef(Copy(V,1,P-1),-1);'#010+
  4785. ' If Result<>-1 then'#010+
  4786. ' Delete(V,1,P)'#010+
  4787. ' else'#010+
  4788. ' Result:=0;'#010+
  4789. ' end;'#010+
  4790. #010+
  4791. 'Var'#010+
  4792. ' V : String;'#010+
  4793. 'begin'#010+
  4794. ' Clear;'#010+
  4795. ' // Special support for empty version string'#010+
  4796. ' if (AValue='#039#039') or (AVa','lue='#039'<none>'#039') then'#010+
  4797. ' exit;'#010+
  4798. ' V:=AValue;'#010+
  4799. ' Major:=NextDigit('#039'.'#039',V);'#010+
  4800. ' Minor:=NextDigit('#039'.'#039',V);'#010+
  4801. ' Micro:=NextDigit('#039'-'#039',V);'#010+
  4802. ' Build:=NextDigit(#0,V);'#010+
  4803. 'end;'#010+
  4804. #010+
  4805. 'procedure TFPVersion.Clear;'#010+
  4806. 'begin'#010+
  4807. ' Micro:=0;'#010+
  4808. ' Major:=0;'#010+
  4809. ' Minor:=0;'#010+
  4810. ' Build:=0;'#010+
  4811. 'end',';'#010+
  4812. #010+
  4813. 'procedure TFPVersion.Assign(Source: TPersistent);'#010+
  4814. #010+
  4815. 'Var'#010+
  4816. ' V : TFPVersion;'#010+
  4817. #010+
  4818. 'begin'#010+
  4819. ' if Source is TFPVersion then'#010+
  4820. ' begin'#010+
  4821. ' V:=Source as TFPVersion;'#010+
  4822. ' Major:=V.Major;'#010+
  4823. ' Minor:=V.Minor;'#010+
  4824. ' Micro:=V.Micro;'#010+
  4825. ' Build:=V.Build;'#010+
  4826. ' end',#010+
  4827. ' else'#010+
  4828. ' inherited Assign(Source);'#010+
  4829. 'end;'#010+
  4830. #010+
  4831. 'function TFPVersion.CompareVersion(AVersion: TFPVersion): Integer;'#010+
  4832. 'begin'#010+
  4833. ' Result:=Major-AVersion.Major;'#010+
  4834. ' If (Result=0) then'#010+
  4835. ' begin'#010+
  4836. ' Result:=Minor-AVersion.Minor;'#010+
  4837. ' if (Result=0) then',#010+
  4838. ' begin'#010+
  4839. ' Result:=Micro-AVersion.Micro;'#010+
  4840. ' If (Result=0) then'#010+
  4841. ' Result:=Build-AVersion.Build;'#010+
  4842. ' end;'#010+
  4843. ' end;'#010+
  4844. 'end;'#010+
  4845. #010+
  4846. 'function TFPVersion.SameVersion(AVersion: TFPVersion): Boolean;'#010+
  4847. 'begin'#010+
  4848. ' Result:=Compar','eVersion(AVersion)=0;'#010+
  4849. 'end;'#010+
  4850. #010+
  4851. #010+
  4852. '{*********************************************************************'+
  4853. '*******'#010+
  4854. ' TTarget'#010+
  4855. '**********************************************************************'+
  4856. '******}'#010+
  4857. #010+
  4858. 'constructor T','Target.Create(ACollection: TCollection);'#010+
  4859. 'begin'#010+
  4860. ' inherited Create(ACollection);'#010+
  4861. ' FInstall:=True;'#010+
  4862. ' FCPUs:=AllCPUs;'#010+
  4863. ' FOSes:=AllOSes;'#010+
  4864. ' FUnitPath:=TConditionalStrings.Create(TConditionalString);'#010+
  4865. ' FIncludePath:=TConditionalStrings.Create(TC','onditionalString);'#010+
  4866. ' FObjectPath:=TConditionalStrings.Create(TConditionalString);'#010+
  4867. ' FDependencies:=TDependencies.Create(TDependency);'#010+
  4868. ' FCommands:=TCOmmands.Create(TCommand);'#010+
  4869. 'end;'#010+
  4870. #010+
  4871. #010+
  4872. 'destructor TTarget.Destroy;'#010+
  4873. 'begin'#010+
  4874. ' FreeAndNil(FUnitPath);',#010+
  4875. ' FreeAndNil(FObjectPath);'#010+
  4876. ' FreeAndNil(FIncludePath);'#010+
  4877. ' FreeAndNil(FDependencies);'#010+
  4878. ' FreeAndNil(FCommands);'#010+
  4879. ' inherited Destroy;'#010+
  4880. 'end;'#010+
  4881. #010+
  4882. #010+
  4883. 'function TTarget.GetSourceFileName: String;'#010+
  4884. 'begin'#010+
  4885. ' Result:=Name+FExtension;'#010+
  4886. 'end;'#010+
  4887. #010+
  4888. #010+
  4889. 'function TTarget.G','etUnitFileName: String;'#010+
  4890. 'begin'#010+
  4891. ' Result:=Name+UnitExt;'#010+
  4892. 'end;'#010+
  4893. #010+
  4894. #010+
  4895. 'function TTarget.GetObjectFileName: String;'#010+
  4896. 'begin'#010+
  4897. ' Result:=Name+ObjExt;'#010+
  4898. 'end;'#010+
  4899. #010+
  4900. #010+
  4901. 'function TTarget.GetRSTFileName: String;'#010+
  4902. 'begin'#010+
  4903. ' Result:=Name+RSText;'#010+
  4904. 'end;'#010+
  4905. #010+
  4906. #010+
  4907. 'function TTarget.GetPr','ogramFileName(AOS : TOS): String;'#010+
  4908. 'begin'#010+
  4909. ' if AOS in [Go32v2,Win32,Win64,OS2] then'#010+
  4910. ' Result:=Name+ExeExt'#010+
  4911. ' else'#010+
  4912. ' Result:=Name;'#010+
  4913. 'end;'#010+
  4914. #010+
  4915. #010+
  4916. 'function TTarget.GetOutputFileName(AOs: TOS): String;'#010+
  4917. 'begin'#010+
  4918. ' if TargetType in UnitTargets then'#010+
  4919. ' Re','sult:=GetUnitFileName'#010+
  4920. ' else'#010+
  4921. ' Result:=GetProgramFileName(AOs);'#010+
  4922. 'end;'#010+
  4923. #010+
  4924. #010+
  4925. 'procedure TTarget.SetName(const AValue: String);'#010+
  4926. 'Var'#010+
  4927. ' D,N,E : String;'#010+
  4928. 'begin'#010+
  4929. ' N:=FixPath(AValue);'#010+
  4930. ' D:=ExtractFilePath(N);'#010+
  4931. ' E:=ExtractFileExt(N);'#010+
  4932. ' N:=ExtractFileNam','e(N);'#010+
  4933. ' inherited SetName(Copy(N,1,Length(N)-Length(E)));'#010+
  4934. ' FExtension:=E;'#010+
  4935. ' FDirectory:=D;'#010+
  4936. 'end;'#010+
  4937. #010+
  4938. #010+
  4939. 'procedure TTarget.GetCleanFiles(List: TStrings; const APrefixU, APrefi'+
  4940. 'xB : String; ACPU: TCPU; AOS : TOS);'#010+
  4941. 'begin'#010+
  4942. ' If not(ACPU in CPUs) or no','t(AOS in OSes) then'#010+
  4943. ' exit;'#010+
  4944. ' List.Add(APrefixU + ObjectFileName);'#010+
  4945. ' If (TargetType in [ttUnit,ttImplicitUnit,ttExampleUnit, ttCleanOnlyU'+
  4946. 'nit]) then'#010+
  4947. ' List.Add(APrefixU + UnitFileName)'#010+
  4948. ' else If (TargetType in [ttProgram,ttExampleProgram',']) then'#010+
  4949. ' List.Add(APrefixB + GetProgramFileName(AOS));'#010+
  4950. ' If ResourceStrings then'#010+
  4951. ' List.Add(APrefixU + RSTFileName);'#010+
  4952. ' // Maybe add later ? AddConditionalStrings(List,CleanFiles);'#010+
  4953. 'end;'#010+
  4954. #010+
  4955. #010+
  4956. 'procedure TTarget.GetInstallFiles(List: TString','s; const APrefixU, AP'+
  4957. 'refixB: String; ACPU: TCPU; AOS : TOS);'#010+
  4958. 'begin'#010+
  4959. ' If not(ACPU in CPUs) or not(AOS in OSes) then'#010+
  4960. ' exit;'#010+
  4961. ' If Not (TargetType in [ttProgram,ttExampleProgram]) then'#010+
  4962. ' List.Add(APrefixU + ObjectFileName);'#010+
  4963. ' If (TargetTyp','e in [ttUnit,ttImplicitUnit,ttExampleUnit]) then'#010+
  4964. ' List.Add(APrefixU + UnitFileName)'#010+
  4965. ' else If (TargetType in [ttProgram,ttExampleProgram]) then'#010+
  4966. ' List.Add(APrefixB + GetProgramFileName(AOS));'#010+
  4967. ' If ResourceStrings then'#010+
  4968. ' List.Add(APre','fixU + RSTFileName);'#010+
  4969. ' // Maybe add later ? AddConditionalStrings(List,InstallFiles);'#010+
  4970. 'end;'#010+
  4971. #010+
  4972. #010+
  4973. 'procedure TTarget.GetArchiveFiles(List: TStrings; ACPU: TCPU; AOS : TO'+
  4974. 'S);'#010+
  4975. 'var'#010+
  4976. ' i : integer;'#010+
  4977. ' D : TDependency;'#010+
  4978. 'begin'#010+
  4979. ' If not(ACPU in CPUs) or no','t(AOS in OSes) then'#010+
  4980. ' exit;'#010+
  4981. ' // Main source'#010+
  4982. ' if TargetSourceFileName<>'#039#039' then'#010+
  4983. ' List.Add(TargetSourceFileName);'#010+
  4984. ' // Includes'#010+
  4985. ' for i:=0 to Dependencies.Count-1 do'#010+
  4986. ' begin'#010+
  4987. ' D:=Dependencies[i];'#010+
  4988. ' if (D.DependencyType=depIncl','ude) and'#010+
  4989. ' (D.TargetFileName<>'#039#039') then'#010+
  4990. ' List.Add(D.TargetFileName);'#010+
  4991. ' end;'#010+
  4992. 'end;'#010+
  4993. #010+
  4994. #010+
  4995. '{*********************************************************************'+
  4996. '*******'#010+
  4997. ' TSource'#010+
  4998. '***********************','*********************************************'+
  4999. '********}'#010+
  5000. #010+
  5001. 'constructor TSource.Create(ACollection: TCollection);'#010+
  5002. 'begin'#010+
  5003. ' inherited Create(ACollection);'#010+
  5004. 'end;'#010+
  5005. #010+
  5006. #010+
  5007. 'destructor TSource.Destroy;'#010+
  5008. 'begin'#010+
  5009. ' inherited Destroy;'#010+
  5010. 'end;'#010+
  5011. #010+
  5012. #010+
  5013. '{*********************','**********************************************'+
  5014. '*********'#010+
  5015. ' TCommands'#010+
  5016. '**********************************************************************'+
  5017. '******}'#010+
  5018. #010+
  5019. 'function TCommands.GetCommand(const Dest : String): TCommand;'#010,
  5020. 'begin'#010+
  5021. ' Result:=TCommand(ItemByName(Dest));'#010+
  5022. 'end;'#010+
  5023. #010+
  5024. 'function TCommands.GetCommandItem(Index : Integer): TCommand;'#010+
  5025. 'begin'#010+
  5026. ' Result:=TCommand(Items[Index]);'#010+
  5027. 'end;'#010+
  5028. #010+
  5029. #010+
  5030. 'procedure TCommands.SetCommandItem(Index : Integer; const AValue: TCom'+
  5031. 'mand);'#010+
  5032. 'begi','n'#010+
  5033. ' Items[Index]:=AValue;'#010+
  5034. 'end;'#010+
  5035. #010+
  5036. #010+
  5037. 'Function TCommands.AddCommand(const Cmd: String) : TCommand;'#010+
  5038. 'begin'#010+
  5039. ' Result:=AddCommand(fdefaultAt,Cmd,'#039#039','#039#039','#039#039');'#010+
  5040. 'end;'#010+
  5041. #010+
  5042. #010+
  5043. 'function TCommands.AddCommand(const Cmd, Options: String): TCommand;'#010+
  5044. 'begin'#010+
  5045. ' Result:=A','ddCommand(fdefaultAt,Cmd,Options,'#039#039','#039#039');'#010+
  5046. 'end;'#010+
  5047. #010+
  5048. #010+
  5049. 'function TCommands.AddCommand(const Cmd, Options, Dest, Source: String'+
  5050. ' ): TCommand;'#010+
  5051. 'begin'#010+
  5052. ' Result:=AddCommand(fdefaultAt,Cmd,options,Dest,Source);'#010+
  5053. 'end;'#010+
  5054. #010+
  5055. #010+
  5056. 'Function TCommands.AddCommand(At: TCo','mmandAt; const Cmd: String) : T'+
  5057. 'Command;'#010+
  5058. 'begin'#010+
  5059. ' Result:=AddCommand(At,Cmd,'#039#039','#039#039','#039#039');'#010+
  5060. 'end;'#010+
  5061. #010+
  5062. #010+
  5063. 'function TCommands.AddCommand(At: TCommandAt; const Cmd, Options: Stri'+
  5064. 'ng ): TCommand;'#010+
  5065. 'begin'#010+
  5066. ' Result:=AddCommand(At,Cmd,Options,'#039#039','#039#039');'#010+
  5067. 'end;'#010+
  5068. #010+
  5069. #010+
  5070. 'func','tion TCommands.AddCommand(At: TCommandAt; const Cmd, Options, De'+
  5071. 'st, Source: String): TCommand;'#010+
  5072. 'begin'#010+
  5073. ' Result:=Add as TCommand;'#010+
  5074. ' Result.Command:=Cmd;'#010+
  5075. ' Result.Options:=Options;'#010+
  5076. ' Result.At:=At;'#010+
  5077. ' Result.SourceFile:=Source;'#010+
  5078. ' Result.DestFil','e:=Dest;'#010+
  5079. 'end;'#010+
  5080. #010+
  5081. #010+
  5082. '{*********************************************************************'+
  5083. '*******'#010+
  5084. ' TConditionalString'#010+
  5085. '**********************************************************************'+
  5086. '******}'#010+
  5087. #010+
  5088. 'Constructor TConditio','nalString.Create;'#010+
  5089. 'begin'#010+
  5090. ' inherited Create;'#010+
  5091. 'end;'#010+
  5092. #010+
  5093. #010+
  5094. '{*********************************************************************'+
  5095. '*******'#010+
  5096. ' TConditionalStrings'#010+
  5097. '****************************************************************','****'+
  5098. '********}'#010+
  5099. #010+
  5100. 'Constructor TConditionalStrings.Create(AClass:TConditionalStringClass)'+
  5101. ';'#010+
  5102. 'begin'#010+
  5103. ' inherited Create;'#010+
  5104. ' FCSClass:=AClass;'#010+
  5105. 'end;'#010+
  5106. #010+
  5107. #010+
  5108. 'function TConditionalStrings.GetConditionalString(Index : Integer): TC'+
  5109. 'onditionalString;'#010+
  5110. 'begin'#010+
  5111. ' Resu','lt:=TConditionalString(Items[Index]);'#010+
  5112. 'end;'#010+
  5113. #010+
  5114. #010+
  5115. 'procedure TConditionalStrings.SetConditionalString(Index : Integer; co'+
  5116. 'nst AValue: TConditionalString);'#010+
  5117. 'begin'#010+
  5118. ' Items[Index]:=AValue;'#010+
  5119. 'end;'#010+
  5120. #010+
  5121. #010+
  5122. 'Function TConditionalStrings.Add(Const Value : String) ',': TConditiona'+
  5123. 'lString;'#010+
  5124. 'begin'#010+
  5125. ' result:=Add(Value,AllCPUs,AllOSes);'#010+
  5126. 'end;'#010+
  5127. #010+
  5128. #010+
  5129. '{$ifdef cpu_only_overloads}'#010+
  5130. 'Function TConditionalStrings.Add(Const Value : String;const CPUs:TCPUs'+
  5131. ') : TConditionalString;'#010+
  5132. 'begin'#010+
  5133. ' result:=Add(Value,CPUs,AllOSes);'#010+
  5134. 'end;',#010+
  5135. '{$endif cpu_only_overloads}'#010+
  5136. #010+
  5137. #010+
  5138. 'Function TConditionalStrings.Add(Const Value : String;const OSes:TOSes'+
  5139. ') : TConditionalString;'#010+
  5140. 'begin'#010+
  5141. ' result:=Add(Value,AllCPUs,OSes);'#010+
  5142. 'end;'#010+
  5143. #010+
  5144. #010+
  5145. 'Function TConditionalStrings.Add(Const Value : String;const CPUs:TC','P'+
  5146. 'Us;const OSes:TOSes) : TConditionalString;'#010+
  5147. 'begin'#010+
  5148. ' Result:=FCSClass.Create;'#010+
  5149. ' Result.Value:=Value;'#010+
  5150. ' Result.OSes:=OSes;'#010+
  5151. ' Result.CPUs:=CPUs;'#010+
  5152. ' inherited Add(Result);'#010+
  5153. 'end;'#010+
  5154. #010+
  5155. #010+
  5156. '{*****************************************************************','**'+
  5157. '*********'#010+
  5158. ' TDependency'#010+
  5159. '**********************************************************************'+
  5160. '******}'#010+
  5161. #010+
  5162. 'Constructor TDependency.Create;'#010+
  5163. 'begin'#010+
  5164. ' inherited Create;'#010+
  5165. ' FVersion:=TFPVersion.Create;'#010+
  5166. 'end;'#010+
  5167. #010+
  5168. #010+
  5169. 'Destructo','r TDependency.Destroy;'#010+
  5170. 'begin'#010+
  5171. ' FreeAndNil(FVersion);'#010+
  5172. 'end;'#010+
  5173. #010+
  5174. #010+
  5175. 'Function TDependency.GetVersion : string;'#010+
  5176. 'begin'#010+
  5177. ' result:=FVersion.AsString;'#010+
  5178. 'end;'#010+
  5179. #010+
  5180. #010+
  5181. 'Procedure TDependency.SetVersion(const V : string);'#010+
  5182. 'begin'#010+
  5183. ' FVersion.AsString:=V;'#010+
  5184. 'end;'#010+
  5185. #010+
  5186. #010+
  5187. '{******','*************************************************************'+
  5188. '*********'#010+
  5189. ' TDependencies'#010+
  5190. '**********************************************************************'+
  5191. '******}'#010+
  5192. #010+
  5193. 'function TDependencies.GetDependency(Index :',' Integer): TDependency;'#010+
  5194. 'begin'#010+
  5195. ' Result:=TDependency(Items[Index]);'#010+
  5196. 'end;'#010+
  5197. #010+
  5198. #010+
  5199. 'procedure TDependencies.SetDependency(Index : Integer; const AValue: T'+
  5200. 'Dependency);'#010+
  5201. 'begin'#010+
  5202. ' Items[Index]:=AValue;'#010+
  5203. 'end;'#010+
  5204. #010+
  5205. #010+
  5206. 'Function TDependencies.Add(Const Value : Strin','g) : TDependency;'#010+
  5207. 'begin'#010+
  5208. ' result:=Add(Value,AllCPUs,AllOSes);'#010+
  5209. 'end;'#010+
  5210. #010+
  5211. #010+
  5212. '{$ifdef cpu_only_overloads}'#010+
  5213. 'Function TDependencies.Add(Const Value : String;const CPUs:TCPUs) : TD'+
  5214. 'ependency;'#010+
  5215. 'begin'#010+
  5216. ' result:=Add(Value,CPUs,AllOSes);'#010+
  5217. 'end;'#010+
  5218. '{$endif cpu_only','_overloads}'#010+
  5219. #010+
  5220. #010+
  5221. 'Function TDependencies.Add(Const Value : String;const OSes:TOSes) : TD'+
  5222. 'ependency;'#010+
  5223. 'begin'#010+
  5224. ' result:=Add(Value,AllCPUs,OSes);'#010+
  5225. 'end;'#010+
  5226. #010+
  5227. #010+
  5228. 'Function TDependencies.Add(Const Value : String;const CPUs:TCPUs;const'+
  5229. ' OSes:TOSes) : TDependency;',#010+
  5230. 'begin'#010+
  5231. ' Result:=inherited Add(Value,CPUs,OSes) as TDependency;'#010+
  5232. ' Result.Target:=nil;'#010+
  5233. ' Result.FDependencyType:=depPackage;'#010+
  5234. 'end;'#010+
  5235. #010+
  5236. #010+
  5237. 'Function TDependencies.AddUnit(Const Value : String) : TDependency;'#010+
  5238. 'begin'#010+
  5239. ' result:=AddUnit(Value,AllCPUs,All','OSes);'#010+
  5240. 'end;'#010+
  5241. #010+
  5242. #010+
  5243. '{$ifdef cpu_only_overloads}'#010+
  5244. 'Function TDependencies.AddUnit(Const Value : String;const CPUs:TCPUs) '+
  5245. ': TDependency;'#010+
  5246. 'begin'#010+
  5247. ' result:=AddUnit(Value,CPUs,AllOSes);'#010+
  5248. 'end;'#010+
  5249. '{$endif cpu_only_overloads}'#010+
  5250. #010+
  5251. #010+
  5252. 'Function TDependencies.AddUnit(Co','nst Value : String;const OSes:TOSes'+
  5253. ') : TDependency;'#010+
  5254. 'begin'#010+
  5255. ' result:=AddUnit(Value,AllCPUs,OSes);'#010+
  5256. 'end;'#010+
  5257. #010+
  5258. #010+
  5259. 'Function TDependencies.AddUnit(Const Value : String;const CPUs:TCPUs;c'+
  5260. 'onst OSes:TOSes) : TDependency;'#010+
  5261. 'begin'#010+
  5262. ' Result:=inherited Add(Valu','e,CPUs,OSes) as TDependency;'#010+
  5263. ' Result.Target:=nil;'#010+
  5264. ' Result.FDependencyType:=depUnit;'#010+
  5265. 'end;'#010+
  5266. #010+
  5267. #010+
  5268. 'Function TDependencies.AddInclude(Const Value : String) : TDependency;'+
  5269. #010+
  5270. 'begin'#010+
  5271. ' result:=AddInclude(Value,AllCPUs,AllOSes);'#010+
  5272. 'end;'#010+
  5273. #010+
  5274. #010+
  5275. '{$ifdef cpu_only_o','verloads}'#010+
  5276. 'Function TDependencies.AddInclude(Const Value : String;const CPUs:TCPU'+
  5277. 's) : TDependency;'#010+
  5278. 'begin'#010+
  5279. ' result:=AddInclude(Value,CPUs,AllOSes);'#010+
  5280. 'end;'#010+
  5281. '{$endif cpu_only_overloads}'#010+
  5282. #010+
  5283. #010+
  5284. 'Function TDependencies.AddInclude(Const Value : String;cons','t OSes:TO'+
  5285. 'Ses) : TDependency;'#010+
  5286. 'begin'#010+
  5287. ' result:=AddInclude(Value,AllCPUs,OSes);'#010+
  5288. 'end;'#010+
  5289. #010+
  5290. #010+
  5291. 'Function TDependencies.AddInclude(Const Value : String;const CPUs:TCPU'+
  5292. 's;const OSes:TOSes) : TDependency;'#010+
  5293. 'Var'#010+
  5294. ' N : String;'#010+
  5295. 'begin'#010+
  5296. ' N:=FixPath(Value);'#010+
  5297. ' if E','xtractFileExt(N)='#039#039' then'#010+
  5298. ' ChangeFileExt(N,IncExt);'#010+
  5299. ' Result:=inherited Add(N,CPUs,OSes) as TDependency;'#010+
  5300. ' Result.FDependencyType:=depInclude;'#010+
  5301. 'end;'#010+
  5302. #010+
  5303. #010+
  5304. '{*********************************************************************'+
  5305. '*******'#010+
  5306. ' ',' TValueItem'#010+
  5307. '**********************************************************************'+
  5308. '******}'#010+
  5309. #010+
  5310. 'constructor TValueItem.Create(AValue: String);'#010+
  5311. 'begin'#010+
  5312. ' FValue:=AValue;'#010+
  5313. 'end;'#010+
  5314. #010+
  5315. #010+
  5316. '{**************************************************','*****************'+
  5317. '*********'#010+
  5318. ' TFunctionItem'#010+
  5319. '**********************************************************************'+
  5320. '******}'#010+
  5321. #010+
  5322. 'constructor TFunctionItem.Create(AFunc: TReplaceFunction);'#010+
  5323. 'begin'#010+
  5324. ' FFunc:=AFunc;'#010+
  5325. 'end;'#010+
  5326. #010+
  5327. #010+
  5328. '{*','******************************************************************'+
  5329. '*********'#010+
  5330. ' TDictionary'#010+
  5331. '**********************************************************************'+
  5332. '******}'#010+
  5333. #010+
  5334. 'constructor TDictionary.Create(AOwner: T','Component);'#010+
  5335. 'begin'#010+
  5336. ' inherited Create(AOwner);'#010+
  5337. ' FList:=TStringList.Create;'#010+
  5338. ' FList.Sorted:=True;'#010+
  5339. ' FList.Duplicates:=dupError;'#010+
  5340. 'end;'#010+
  5341. #010+
  5342. #010+
  5343. 'destructor TDictionary.Destroy;'#010+
  5344. 'Var'#010+
  5345. ' I : Integer;'#010+
  5346. 'begin'#010+
  5347. ' For I:=0 to Flist.Count-1 do'#010+
  5348. ' FList.Objects[','i].Free;'#010+
  5349. ' FreeAndNil(FList);'#010+
  5350. ' inherited Destroy;'#010+
  5351. 'end;'#010+
  5352. #010+
  5353. #010+
  5354. 'procedure TDictionary.AddVariable(const AName, Value: String);'#010+
  5355. 'Var'#010+
  5356. ' I : Integer;'#010+
  5357. 'begin'#010+
  5358. ' I:=Flist.IndexOf(AName);'#010+
  5359. ' If I=-1 then'#010+
  5360. ' I:=FList.Add(Aname)'#010+
  5361. ' else'#010+
  5362. ' Flist.Objects[i].','Free;'#010+
  5363. ' Flist.Objects[i]:=TValueItem.Create(Value);'#010+
  5364. 'end;'#010+
  5365. #010+
  5366. #010+
  5367. 'procedure TDictionary.AddFunction(const AName: String; FReplacement: T'+
  5368. 'ReplaceFunction);'#010+
  5369. 'Var'#010+
  5370. ' I : Integer;'#010+
  5371. 'begin'#010+
  5372. ' I:=Flist.IndexOf(AName);'#010+
  5373. ' If I=-1 then'#010+
  5374. ' I:=Flist.Add(AName)'#010+
  5375. ' ','else'#010+
  5376. ' Flist.Objects[i].Free;'#010+
  5377. ' Flist.Objects[i]:=TFunctionItem.Create(FReplacement);'#010+
  5378. 'end;'#010+
  5379. #010+
  5380. #010+
  5381. 'procedure TDictionary.RemoveItem(const AName: String);'#010+
  5382. 'Var'#010+
  5383. ' I : Integer;'#010+
  5384. 'begin'#010+
  5385. ' I:=Flist.IndexOf(AName);'#010+
  5386. ' If (I<>-1) then'#010+
  5387. ' begin'#010+
  5388. ' FList.','Objects[i].Free;'#010+
  5389. ' FList.Delete(I);'#010+
  5390. ' end;'#010+
  5391. 'end;'#010+
  5392. #010+
  5393. #010+
  5394. 'function TDictionary.GetValue(const AName: String): String;'#010+
  5395. 'begin'#010+
  5396. ' Result:=GetValue(AName,'#039#039');'#010+
  5397. 'end;'#010+
  5398. #010+
  5399. #010+
  5400. 'function TDictionary.GetValue(const AName,Args: String): String;'#010+
  5401. 'Var'#010+
  5402. ' O : TObject;',#010+
  5403. ' I : Integer;'#010+
  5404. 'begin'#010+
  5405. ' I:=Flist.IndexOf(AName);'#010+
  5406. ' If (I=-1) then'#010+
  5407. ' Raise EDictionaryError.CreateFmt(SErrNoDictionaryItem,[AName]);'#010+
  5408. ' O:=Flist.Objects[I];'#010+
  5409. ' If O is TValueItem then'#010+
  5410. ' Result:=TValueItem(O).FValue'#010+
  5411. ' else'#010+
  5412. ' Result:=TFunc','tionItem(O).FFunc(AName,Args);'#010+
  5413. 'end;'#010+
  5414. #010+
  5415. #010+
  5416. 'function TDictionary.ReplaceStrings(Const ASource: String): String;'#010+
  5417. 'Var'#010+
  5418. ' S,FN,FV : String;'#010+
  5419. ' P: Integer;'#010+
  5420. 'begin'#010+
  5421. ' Result:='#039#039';'#010+
  5422. ' S:=ASource;'#010+
  5423. ' P:=Pos('#039'$('#039',S);'#010+
  5424. ' While (P<>0) do'#010+
  5425. ' begin'#010+
  5426. ' Result:=Re','sult+Copy(S,1,P-1);'#010+
  5427. ' Delete(S,1,P+1);'#010+
  5428. ' P:=Pos('#039')'#039',S);'#010+
  5429. ' FN:=Copy(S,1,P-1);'#010+
  5430. ' Delete(S,1,P);'#010+
  5431. ' P:=Pos('#039' '#039',FN);'#010+
  5432. ' If (P<>0) then // function arguments ?'#010+
  5433. ' begin'#010+
  5434. ' FV:=FN;'#010+
  5435. ' FN:=Copy(FN,1,P);'#010+
  5436. ' ',' System.Delete(FV,1,P);'#010+
  5437. ' end'#010+
  5438. ' else'#010+
  5439. ' FV:='#039#039';'#010+
  5440. ' Result:=Result+GetValue(FN,FV);'#010+
  5441. ' P:=Pos('#039'$('#039',S);'#010+
  5442. ' end;'#010+
  5443. ' Result:=Result+S;'#010+
  5444. 'end;'#010+
  5445. #010+
  5446. #010+
  5447. 'Function Substitute(Const Source : String; Macros : Array of string) :'+
  5448. ' String;'#010+
  5449. 'Va','r'#010+
  5450. ' I : Integer;'#010+
  5451. 'begin'#010+
  5452. ' I:=0;'#010+
  5453. ' While I<High(Macros) do'#010+
  5454. ' begin'#010+
  5455. ' Dictionary.AddVariable(Macros[i],Macros[I+1]);'#010+
  5456. ' Inc(I,2);'#010+
  5457. ' end;'#010+
  5458. ' Result:=Dictionary.ReplaceStrings(Source);'#010+
  5459. ' While I<High(Macros) do'#010+
  5460. ' begin'#010+
  5461. ' Dictiona','ry.RemoveItem(Macros[i]);'#010+
  5462. ' Inc(I,2);'#010+
  5463. ' end;'#010+
  5464. 'end;'#010+
  5465. #010+
  5466. #010+
  5467. '{*********************************************************************'+
  5468. '*******'#010+
  5469. ' Default Instances'#010+
  5470. '*****************************************************','***************'+
  5471. '********}'#010+
  5472. #010+
  5473. 'var'#010+
  5474. ' DefInstaller : TCustomInstaller;'#010+
  5475. #010+
  5476. 'Function Installer(InstallerClass: TInstallerClass): TCustomInstaller;'+
  5477. #010+
  5478. 'begin'#010+
  5479. ' If Not Assigned(DefInstaller) then'#010+
  5480. ' DefInstaller:=InstallerClass.Create(Nil);'#010+
  5481. ' Result:=DefI','nstaller;'#010+
  5482. 'end;'#010+
  5483. #010+
  5484. #010+
  5485. 'Function Installer: TCustomInstaller;'#010+
  5486. 'begin'#010+
  5487. ' Result := Installer(TFPCInstaller);'#010+
  5488. 'end;'#010+
  5489. #010+
  5490. #010+
  5491. 'Initialization'#010+
  5492. ' OnGetApplicationName:=@GetFPMakeName;'#010+
  5493. #010+
  5494. 'Finalization'#010+
  5495. ' FreeAndNil(DefInstaller);'#010+
  5496. ' FreeAndNil(Dictionary);'#010+
  5497. ' FreeAndNi','l(Defaults);'#010+
  5498. 'end.'#010
  5499. );