fpmkunitsrc.inc 193 KB

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