2
0

fpmkunitsrc.inc 276 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112
  1. {$ifdef Delphi}
  2. const fpmkunitsrc : array[0..809] of string[240]=(
  3. {$else Delphi}
  4. const fpmkunitsrc : array[0..809,1..250] of char=(
  5. {$endif Delphi}
  6. '{'#013#010+
  7. ' This file is part of the Free Pascal Makefile Package'#013#010+
  8. #013#010+
  9. ' Implementation of fpmake classes and functions'#013#010+
  10. #013#010+
  11. ' Copyright (c) 2007 by the freepascal team'#013#010+
  12. #013#010+
  13. ' See the file COPYING.FPC, included in this distribution,'#013#010+
  14. ' for det','ails about the copyright.'#013#010+
  15. #013#010+
  16. ' This program is distributed in the hope that it will be useful,'#013+
  17. #010+
  18. ' but WITHOUT ANY WARRANTY; without even the implied warranty of'#013+
  19. #010+
  20. ' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.'#013#010+
  21. #013#010+
  22. ' *************','******************************************************'+
  23. '***}'#013#010+
  24. #013#010+
  25. 'unit fpmkunit;'#013#010+
  26. #013#010+
  27. '{$Mode objfpc}'#013#010+
  28. '{$H+}'#013#010+
  29. '{$inline on}'#013#010+
  30. #013#010+
  31. '{ For target or cpu dependent dependencies add also an overload were y'+
  32. 'ou'#013#010+
  33. ' can pass only a set of cpus. This is disabled',' for now because it c'+
  34. 'reates'#013#010+
  35. ' an error in the compiler with overload choosing }'#013#010+
  36. '{ define cpu_only_overloads}'#013#010+
  37. #013#010+
  38. 'Interface'#013#010+
  39. #013#010+
  40. '{$IFDEF OS2}'#013#010+
  41. ' {$DEFINE NO_UNIT_PROCESS}'#013#010+
  42. '{$ENDIF OS2}'#013#010+
  43. #013#010+
  44. '{$IFDEF GO32V2}'#013#010+
  45. ' {$DEFINE NO_UNIT_PROCESS}'#013#010+
  46. '{$ENDIF GO','32V2}'#013#010+
  47. #013#010+
  48. '{$ifndef NO_UNIT_PROCESS}'#013#010+
  49. ' {$define HAS_UNIT_PROCESS}'#013#010+
  50. '{$endif NO_UNIT_PROCESS}'#013#010+
  51. #013#010+
  52. '{$ifndef NO_UNIT_ZIPPER}'#013#010+
  53. ' {$define HAS_UNIT_ZIPPER}'#013#010+
  54. '{$endif NO_UNIT_ZIPPER}'#013#010+
  55. #013#010+
  56. 'uses'#013#010+
  57. ' SysUtils, Classes, StrUtils'#013#010+
  58. '{$ifdef HAS_UNIT_PROCESS}'#013#010,
  59. ' ,process'#013#010+
  60. '{$endif HAS_UNIT_PROCESS}'#013#010+
  61. '{$ifdef HAS_UNIT_ZIPPER}'#013#010+
  62. ' ,zipper'#013#010+
  63. '{$endif HAS_UNIT_ZIPPER}'#013#010+
  64. ' ;'#013#010+
  65. #013#010+
  66. 'Type'#013#010+
  67. ' TFileType = (ftSource,ftUnit,ftObject,ftResource,ftExecutable,ftStat'+
  68. 'icLibrary,'#013#010+
  69. ' ftSharedLibrary);'#013#010+
  70. ' TFileTy','pes = set of TFileType;'#013#010+
  71. #013#010+
  72. ' // Please keep this order, see OSCPUSupported below'#013#010+
  73. ' TCpu=(cpuNone,'#013#010+
  74. ' i386,m68k,powerpc,sparc,x86_64,arm,powerpc64,avr,armeb'#013#010+
  75. ' );'#013#010+
  76. ' TCPUS = Set of TCPU;'#013#010+
  77. #013#010+
  78. ' // Please keep this order, see OSCPUSupported ','below'#013#010+
  79. ' TOS=(osNone,'#013#010+
  80. ' linux,go32v2,win32,os2,freebsd,beos,netbsd,'#013#010+
  81. ' amiga,atari, solaris, qnx, netware, openbsd,wdosx,'#013#010+
  82. ' palmos,macos,darwin,emx,watcom,morphos,netwlibc,'#013#010+
  83. ' win64,wince,gba,nds,embedded,symbian,haiku,iphonesim'#013#010,
  84. ' );'#013#010+
  85. ' TOSes = Set of TOS;'#013#010+
  86. #013#010+
  87. ' TCompilerMode = (cmFPC,cmTP,cmObjFPC,cmDelphi,cmMacPas);'#013#010+
  88. ' TCompilerModes = Set of TCompilerMode;'#013#010+
  89. #013#010+
  90. ' TTargetType = (ttProgram,ttUnit,ttImplicitUnit,ttCleanOnlyUnit,ttExa'+
  91. 'mpleUnit,ttExampleProgram,ttFPDoc);',#013#010+
  92. ' TTargetTypes = set of TTargetType;'#013#010+
  93. #013#010+
  94. ' TFPDocFormat = (ffHtml, ffHtm, ffXHtml, ffLaTex, ffXMLStruct, ffChm)'+
  95. ';'#013#010+
  96. ' TFPDocFormats = set of TFPDocFormat;'#013#010+
  97. #013#010+
  98. ' TTargetState = (tsNeutral,tsConsidering,tsNoCompile,tsCompiled,tsIns'+
  99. 'talled,tsNotF','ound);'#013#010+
  100. ' TTargetStates = Set of TTargetState;'#013#010+
  101. #013#010+
  102. ' TSourceType = (stDoc,stSrc,stExample,stTest);'#013#010+
  103. ' TSourceTypes = set of TSourceType;'#013#010+
  104. #013#010+
  105. ' TVerboseLevel = (vlError,vlWarning,vlInfo,vldebug,vlCommand);'#013#010+
  106. ' TVerboseLevels = Set of TVerboseLe','vel;'#013#010+
  107. #013#010+
  108. ' TCommandAt = (caBeforeCompile,caAfterCompile,'#013#010+
  109. ' caBeforeInstall,caAfterInstall,'#013#010+
  110. ' caBeforeArchive,caAfterArchive,'#013#010+
  111. ' caBeforeClean,caAfterClean,'#013#010+
  112. ' caBeforeDownload,caAfter','Download);'#013#010+
  113. #013#010+
  114. ' TDependencyType = (depPackage,depImplicitPackage,depUnit,depInclude)'+
  115. ';'#013#010+
  116. ' TDependencyTypes = set of TDependencyType;'#013#010+
  117. #013#010+
  118. ' TLogEvent = Procedure (Level : TVerboseLevel; Const Msg : String) of'+
  119. ' Object;'#013#010+
  120. ' TNotifyProcEvent = proc','edure(Sender: TObject);'#013#010+
  121. #013#010+
  122. ' TRunMode = (rmCompile,rmBuild,rmInstall,rmArchive,rmClean,rmDistClea'+
  123. 'n,rmManifest);'#013#010+
  124. #013#010+
  125. ' TBuildMode = (bmOneByOne, bmBuildUnit{, bmSkipImplicitUnits});'#013#010+
  126. ' TBuildModes = set of TBuildMode;'#013#010+
  127. #013#010+
  128. 'Const'#013#010+
  129. ' // Aliases'#013#010,
  130. ' Amd64 = X86_64;'#013#010+
  131. ' PPC = PowerPC;'#013#010+
  132. ' PPC64 = PowerPC64;'#013#010+
  133. ' DOS = Go32v2;'#013#010+
  134. ' MacOSX = Darwin;'#013#010+
  135. #013#010+
  136. ' AllOSes = [Low(TOS)..High(TOS)];'#013#010+
  137. ' AllCPUs = [Low(TCPU)..High(TCPU)];'#013#010+
  138. ' AllUnixOSes = [Linux,FreeBSD,NetBSD,OpenBSD,Darwin,QNX,BeOS,Sol','ar'+
  139. 'is,Haiku,iphonesim,Android];'#013#010+
  140. ' AllBSDOSes = [FreeBSD,NetBSD,OpenBSD,Darwin,iphonesim];'#013#010+
  141. ' AllWindowsOSes = [Win32,Win64,WinCE];'#013#010+
  142. ' AllLimit83fsOses= [go32v2,os2,emx,watcom];'#013#010+
  143. #013#010+
  144. ' AllSmartLinkLibraryOSes = [Linux]; // OSes that use .a libra','ry fil'+
  145. 'es for smart-linking'#013#010+
  146. #013#010+
  147. ' { This table is kept OS,Cpu because it is easier to maintain (PFV) }'+
  148. #013#010+
  149. ' OSCPUSupported : array[TOS,TCpu] of boolean = ('#013#010+
  150. ' { os none i386 m68k ppc sparc x86_64 arm ppc'+
  151. '64 avr armeb}',#013#010+
  152. ' { none } ( false, false, false, false, false, false, false, fal'+
  153. 'se, false, false),'#013#010+
  154. ' { linux } ( false, true, true, true, true, true, true, tru'+
  155. 'e, false, true ),'#013#010+
  156. ' { go32v2 } ( false, true, false, false, false, false',', false, f'+
  157. 'alse, false, false),'#013#010+
  158. ' { win32 } ( false, true, false, false, false, false, false, fal'+
  159. 'se, false, false),'#013#010+
  160. ' { os2 } ( false, true, false, false, false, false, false, fal'+
  161. 'se, false, false),'#013#010+
  162. ' { freebsd } ( false, tru','e, true, false, false, true, false, f'+
  163. 'alse, false, false),'#013#010+
  164. ' { beos } ( false, true, false, false, false, false, false, fal'+
  165. 'se, false, false),'#013#010+
  166. ' { netbsd } ( false, true, true, true, true, false, false, fal'+
  167. 'se, false, false),',#013#010+
  168. ' { amiga } ( false, false, true, true, false, false, false, fal'+
  169. 'se, false, false),'#013#010+
  170. ' { atari } ( false, false, true, false, false, false, false, fal'+
  171. 'se, false, false),'#013#010+
  172. ' { solaris } ( false, true, false, false, true, false',', false, f'+
  173. 'alse, false, false),'#013#010+
  174. ' { qnx } ( false, true, false, false, false, false, false, fal'+
  175. 'se, false, false),'#013#010+
  176. ' { netware } ( false, true, false, false, false, false, false, fal'+
  177. 'se, false, false),'#013#010+
  178. ' { openbsd } ( false, tru','e, true, false, false, false, false, f'+
  179. 'alse, false, false),'#013#010+
  180. ' { wdosx } ( false, true, false, false, false, false, false, fal'+
  181. 'se, false, false),'#013#010+
  182. ' { palmos } ( false, false, true, false, false, false, true, fal'+
  183. 'se, false, false),',#013#010+
  184. ' { macos } ( false, false, false, true, false, false, false, fal'+
  185. 'se, false, false),'#013#010+
  186. ' { darwin } ( false, true, false, true, false, true, true, tru'+
  187. 'e, false, false),'#013#010+
  188. ' { emx } ( false, true, false, false, false, false',', false, f'+
  189. 'alse, false, false),'#013#010+
  190. ' { watcom } ( false, true, false, false, false ,false, false, fal'+
  191. 'se, false, false),'#013#010+
  192. ' { morphos } ( false, false, false, true, false ,false, false, fal'+
  193. 'se, false, false),'#013#010+
  194. ' { netwlibc }( false, tru','e, false, false, false, false, false, f'+
  195. 'alse, false, false),'#013#010+
  196. ' { win64 } ( false, false, false, false, false, true, false, fal'+
  197. 'se, false, false),'#013#010+
  198. ' { wince }( false, true, false, false, false, false, true, fal'+
  199. 'se, false, false),',#013#010+
  200. ' { gba } ( false, false, false, false, false, false, true, fal'+
  201. 'se, false, false),'#013#010+
  202. ' { nds } ( false, false, false, false, false, false, true, fal'+
  203. 'se, false, false),'#013#010+
  204. ' { embedded }( false, true, true, true, true, true,',' true, t'+
  205. 'rue, true, true ),'#013#010+
  206. ' { symbian } ( false, true, false, false, false, false, true, fal'+
  207. 'se, false, false),'#013#010+
  208. ' { haiku } ( false, true, false, false, false, false, false, fal'+
  209. 'se, false, false),'#013#010+
  210. ' { iphonesim}( false, tru','e, false, false, false, false, false, f'+
  211. 'alse, false, false)'#013#010+
  212. ' );'#013#010+
  213. #013#010+
  214. ' // Useful'#013#010+
  215. ' UnitExt = '#039'.ppu'#039';'#013#010+
  216. ' PPUExt = UnitExt;'#013#010+
  217. ' PasExt = '#039'.pas'#039';'#013#010+
  218. ' PPExt = '#039'.pp'#039';'#013#010+
  219. ' IncExt = '#039'.inc'#039';'#013#010+
  220. ' ObjExt = '#039'.o'#039';'#013#010+
  221. ' RstExt = '#039'.rst'#039';'#013#010+
  222. ' LibExt = '#039,'.a'#039';'#013#010+
  223. ' SharedLibExt = '#039'.so'#039';'#013#010+
  224. ' DLLExt = '#039'.dll'#039';'#013#010+
  225. ' ExeExt = '#039'.exe'#039';'#013#010+
  226. ' ZipExt = '#039'.zip'#039';'#013#010+
  227. #013#010+
  228. ' FPMakePPFile = '#039'fpmake.pp'#039';'#013#010+
  229. ' ManifestFile = '#039'manifest.xml'#039';'#013#010+
  230. ' UnitConfigFile = '#039'fpunits.cfg'#039';'#013#010+
  231. #013#010+
  232. ' DirNotFound = '#039'<dirnotfound>'#039';'#013#010+
  233. #013#010+
  234. ' Unit','Targets = [ttUnit,ttImplicitUnit,ttCleanOnlyUnit,ttExampleUnit'+
  235. '];'#013#010+
  236. ' ProgramTargets = [ttProgram,ttExampleProgram];'#013#010+
  237. #013#010+
  238. ' DefaultMessages = [vlError,vlWarning,vlCommand];'#013#010+
  239. ' AllMessages = [vlError,vlWarning,vlCommand,vlInfo];'#013#010+
  240. #013#010+
  241. 'Type'#013#010+
  242. ' { TNa','medItem }'#013#010+
  243. #013#010+
  244. ' TNamedItem = Class(TCollectionItem)'#013#010+
  245. ' private'#013#010+
  246. ' FName: String;'#013#010+
  247. ' procedure SetName(const AValue: String);virtual;'#013#010+
  248. ' Public'#013#010+
  249. ' property Name : String Read FName Write SetName;'#013#010+
  250. ' end;'#013#010+
  251. #013#010+
  252. ' { TNamedCollection }'#013#010+
  253. #013#010+
  254. ' T','NamedCollection = Class(TCollection)'#013#010+
  255. ' private'#013#010+
  256. ' FUniqueNames: Boolean;'#013#010+
  257. ' Public'#013#010+
  258. ' Function IndexOfName(const AName : String) : Integer;'#013#010+
  259. ' Function ItemByName(const AName : String) : TNamedItem;'#013#010+
  260. ' Property UniqueNames : Boolea','n Read FUniqueNames;'#013#010+
  261. ' end;'#013#010+
  262. #013#010+
  263. ' { TNamedItemList }'#013#010+
  264. #013#010+
  265. ' TNamedItemList = Class(TFPList)'#013#010+
  266. ' private'#013#010+
  267. ' function GetNamedItem(Index : Integer): TNamedItem;'#013#010+
  268. ' procedure SetNamedItem(Index : Integer; const AValue: TNamedItem);'+
  269. #013#010+
  270. ' public'#013,#010+
  271. ' Function IndexOfName(const AName : String) : Integer;'#013#010+
  272. ' Function ItemByName(const ANAme : String) : TNamedItem;'#013#010+
  273. ' Property NamedItems[Index : Integer] : TNamedItem Read GetNamedIte'+
  274. 'm Write SetNamedItem; default;'#013#010+
  275. ' end;'#013#010+
  276. #013#010+
  277. ' { TCo','mmand }'#013#010+
  278. ' TCommand = Class(TNamedItem)'#013#010+
  279. ' private'#013#010+
  280. ' FAfterCommand: TNotifyEvent;'#013#010+
  281. ' FBeforeCommand: TNotifyEvent;'#013#010+
  282. ' FCommand: String;'#013#010+
  283. ' FCommandAt: TCommandAt;'#013#010+
  284. ' FDestFile: String;'#013#010+
  285. ' FIgnoreResult: Boolean;'#013#010+
  286. ' FOptions: ','TStrings;'#013#010+
  287. ' FSourceFile: String;'#013#010+
  288. ' Function GetOptions : TStrings;'#013#010+
  289. ' Procedure SetOptions(Const Value : TStrings);'#013#010+
  290. ' Public'#013#010+
  291. ' Destructor Destroy; override;'#013#010+
  292. ' Function HaveOptions : Boolean;'#013#010+
  293. ' Function CmdLineOptions : Str','ing;'#013#010+
  294. ' Procedure ParseOptions(S : String);'#013#010+
  295. ' Property SourceFile : String Read FSourceFile Write FSourceFile;'#013+
  296. #010+
  297. ' Property DestFile : String Read FDestFile Write FDestFile;'#013#010+
  298. ' Property Command : String Read FCommand Write FCommand;',#013#010+
  299. ' Property Options : TStrings Read GetOptions Write SetOptions;'#013#010+
  300. ' Property At : TCommandAt Read FCommandAt Write FCommandAt;'#013#010+
  301. ' Property IgnoreResult : Boolean Read FIgnoreResult Write FIgnoreRe'+
  302. 'sult;'#013#010+
  303. ' Property BeforeCommand : T','NotifyEvent Read FBeforeCommand Write '+
  304. 'FBeforeCommand;'#013#010+
  305. ' Property AfterCommand : TNotifyEvent Read FAfterCommand Write FAft'+
  306. 'erCommand;'#013#010+
  307. ' end;'#013#010+
  308. #013#010+
  309. ' { TCommands }'#013#010+
  310. #013#010+
  311. ' TCommands = Class(TNamedCollection)'#013#010+
  312. ' private'#013#010+
  313. ' FDefaultAt: TCommand','At;'#013#010+
  314. ' function GetCommand(const Dest : String): TCommand;'#013#010+
  315. ' function GetCommandItem(Index : Integer): TCommand;'#013#010+
  316. ' procedure SetCommandItem(Index : Integer; const AValue: TCommand);'+
  317. #013#010+
  318. ' Public'#013#010+
  319. ' Function AddCommand(Const Cmd : Str','ing) : TCommand;'#013#010+
  320. ' Function AddCommand(Const Cmd,Options : String) : TCommand;'#013#010+
  321. ' Function AddCommand(Const Cmd,Options,Dest,Source : String) : TCom'+
  322. 'mand;'#013#010+
  323. ' Function AddCommand(At : TCommandAt; Const Cmd : String) : TComman'+
  324. 'd;'#013#010+
  325. ' Fu','nction AddCommand(At : TCommandAt; Const Cmd,Options : String)'+
  326. ' : TCommand;'#013#010+
  327. ' Function AddCommand(At : TCommandAt; Const Cmd,Options, Dest,Sourc'+
  328. 'e : String) : TCommand;'#013#010+
  329. ' Property CommandItems[Index : Integer] : TCommand Read GetCommand',
  330. 'Item Write SetCommandItem;'#013#010+
  331. ' Property Commands[Dest : String] : TCommand Read GetCommand; defau'+
  332. 'lt;'#013#010+
  333. ' Property DefaultAt : TCommandAt Read FDefaultAt Write FDefaultAt;'#013+
  334. #010+
  335. ' end;'#013#010+
  336. #013#010+
  337. ' { TFPVersion }'#013#010+
  338. #013#010+
  339. ' TFPVersion = Class(TPersistent)'#013#010+
  340. ' ',' private'#013#010+
  341. ' FMajor,'#013#010+
  342. ' FMinor,'#013#010+
  343. ' FMicro,'#013#010+
  344. ' FBuild : Integer;'#013#010+
  345. ' function GetAsString: String;'#013#010+
  346. ' function GetEmpty: Boolean;'#013#010+
  347. ' procedure SetAsString(const AValue: String);'#013#010+
  348. ' Public'#013#010+
  349. ' Procedure Clear;'#013#010+
  350. ' Procedure Ass','ign(Source : TPersistent); override;'#013#010+
  351. ' Function CompareVersion(AVersion : TFPVersion) : Integer;'#013#010+
  352. ' Function SameVersion(AVersion : TFPVersion) : Boolean;'#013#010+
  353. ' Property AsString : String Read GetAsString Write SetAsString;'#013#010+
  354. ' Property Em','pty : Boolean Read GetEmpty;'#013#010+
  355. ' Published'#013#010+
  356. ' Property Major : Integer Read FMajor Write FMajor;'#013#010+
  357. ' Property Minor : Integer Read FMinor Write FMinor;'#013#010+
  358. ' Property Micro : Integer Read FMicro Write FMicro;'#013#010+
  359. ' Property Build : Integer Read',' FBuild Write FBuild;'#013#010+
  360. ' end;'#013#010+
  361. #013#010+
  362. ' { TConditionalString }'#013#010+
  363. ' TConditionalString = Class'#013#010+
  364. ' private'#013#010+
  365. ' FOSes : TOSes;'#013#010+
  366. ' FCPUs : TCPUs;'#013#010+
  367. ' FValue : String;'#013#010+
  368. ' Public'#013#010+
  369. ' Constructor Create;virtual;'#013#010+
  370. ' Property Value : String Re','ad FValue Write FValue;'#013#010+
  371. ' Property OSes : TOSes Read FOSes Write FOSes;'#013#010+
  372. ' Property CPUs : TCPUs Read FCPUS Write FCPUs;'#013#010+
  373. ' end;'#013#010+
  374. #013#010+
  375. ' TConditionalStringClass = class of TConditionalString;'#013#010+
  376. #013#010+
  377. ' { TConditionalStrings }'#013#010+
  378. #013#010+
  379. ' TConditiona','lStrings = Class(TFPList)'#013#010+
  380. ' private'#013#010+
  381. ' FCSClass : TConditionalStringClass;'#013#010+
  382. ' function GetConditionalString(Index : Integer): TConditionalString'+
  383. ';'#013#010+
  384. ' procedure SetConditionalString(Index : Integer; const AValue: TCon'+
  385. 'ditionalString);'#013#010,
  386. ' Public'#013#010+
  387. ' Constructor Create(AClass:TConditionalStringClass);'#013#010+
  388. ' Function Add(Const Value : String) : TConditionalString;inline;'#013+
  389. #010+
  390. ' Function Add(Const Value : String;const OSes:TOSes) : TConditional'+
  391. 'String;inline;'#013#010+
  392. '{$ifdef cpu_only_o','verloads}'#013#010+
  393. ' Function Add(Const Value : String;const CPUs:TCPUs) : TConditional'+
  394. 'String;inline;'#013#010+
  395. '{$endif cpu_only_overloads}'#013#010+
  396. ' Function Add(Const Value : String;const CPUs:TCPUs;const OSes:TOSe'+
  397. 's) : TConditionalString;'#013#010+
  398. ' Property Condi','tionalStrings[Index : Integer] : TConditionalStrin'+
  399. 'g Read GetConditionalString Write SetConditionalString; default;'#013#010+
  400. ' end;'#013#010+
  401. #013#010+
  402. ' { TDependency }'#013#010+
  403. ' TDependency = Class(TConditionalString)'#013#010+
  404. ' private'#013#010+
  405. ' FDependencyType : TDependencyType;'#013#010+
  406. ' ',' // Package, Unit'#013#010+
  407. ' FTarget : TObject;'#013#010+
  408. ' FVersion : TFPVersion;'#013#010+
  409. ' FRequireChecksum : Cardinal;'#013#010+
  410. ' // Filenames, Includes'#013#010+
  411. ' FTargetFileName : String;'#013#010+
  412. ' Function GetVersion : string;'#013#010+
  413. ' Procedure SetVersion(const V : stri','ng);'#013#010+
  414. ' Public'#013#010+
  415. ' Constructor Create;override;'#013#010+
  416. ' Destructor Destroy;override;'#013#010+
  417. ' Property Target : TObject Read FTarget Write FTarget;'#013#010+
  418. ' Property DependencyType : TDependencyType Read FDependencyType;'#013+
  419. #010+
  420. ' Property TargetFileName ',': String Read FTargetFileName Write FTar'+
  421. 'getFileName;'#013#010+
  422. ' Property Version : String Read GetVersion Write SetVersion;'#013#010+
  423. ' Property RequireChecksum : Cardinal Read FRequireChecksum Write FR'+
  424. 'equireChecksum;'#013#010+
  425. ' end;'#013#010+
  426. #013#010+
  427. ' TDependencies = Class(','TConditionalStrings)'#013#010+
  428. ' function GetDependency(Index : Integer): TDependency;'#013#010+
  429. ' procedure SetDependency(Index : Integer; const AValue: TDependency'+
  430. ');'#013#010+
  431. ' Public'#013#010+
  432. ' Function Add(Const Value : String) : TDependency;inline;'#013#010+
  433. ' Function ','Add(Const Value : String;const OSes:TOSes) : TDependenc'+
  434. 'y;inline;'#013#010+
  435. '{$ifdef cpu_only_overloads}'#013#010+
  436. ' Function Add(Const Value : String;const CPUs:TCPUs) : TDependency;'+
  437. 'inline;'#013#010+
  438. '{$endif cpu_only_overloads}'#013#010+
  439. ' Function Add(Const Value : String',';const CPUs:TCPUs;const OSes:TO'+
  440. 'Ses) : TDependency;'#013#010+
  441. ' Function AddUnit(Const Value : String) : TDependency;inline;'#013#010+
  442. ' Function AddUnit(Const Value : String;const OSes:TOSes) : TDepende'+
  443. 'ncy;inline;'#013#010+
  444. '{$ifdef cpu_only_overloads}'#013#010+
  445. ' Functi','on AddUnit(Const Value : String;const CPUs:TCPUs) : TDepen'+
  446. 'dency;inline;'#013#010+
  447. '{$endif cpu_only_overloads}'#013#010+
  448. ' Function AddUnit(Const Value : String;const CPUs:TCPUs;const OSes:'+
  449. 'TOSes) : TDependency;'#013#010+
  450. ' Function AddInclude(Const Value : String)',' : TDependency;inline;'#013+
  451. #010+
  452. ' Function AddInclude(Const Value : String;const OSes:TOSes) : TDepe'+
  453. 'ndency;inline;'#013#010+
  454. '{$ifdef cpu_only_overloads}'#013#010+
  455. ' Function AddInclude(Const Value : String;const CPUs:TCPUs) : TDepe'+
  456. 'ndency;inline;'#013#010+
  457. '{$endif cpu_onl','y_overloads}'#013#010+
  458. ' Function AddInclude(Const Value : String;const CPUs:TCPUs;const OS'+
  459. 'es:TOSes) : TDependency;'#013#010+
  460. ' Property Dependencies[Index : Integer] : TDependency Read GetDepen'+
  461. 'dency Write SetDependency; default;'#013#010+
  462. ' end;'#013#010+
  463. #013#010+
  464. ' { TTarget }',#013#010+
  465. #013#010+
  466. ' TTarget = Class(TNamedItem)'#013#010+
  467. ' private'#013#010+
  468. ' FInstall : Boolean;'#013#010+
  469. ' FAfterClean: TNotifyEvent;'#013#010+
  470. ' FAfterCompile: TNotifyEvent;'#013#010+
  471. ' FBeforeClean: TNotifyEvent;'#013#010+
  472. ' FBeforeCompile: TNotifyEvent;'#013#010+
  473. ' FCPUs: TCPUs;'#013#010+
  474. ' FOSes: TOSes',';'#013#010+
  475. ' FMode: TCompilerMode;'#013#010+
  476. ' FResourceStrings: Boolean;'#013#010+
  477. ' FObjectPath,'#013#010+
  478. ' FUnitPath,'#013#010+
  479. ' FIncludePath : TConditionalStrings;'#013#010+
  480. ' FDependencies : TDependencies;'#013#010+
  481. ' FCommands : TCommands;'#013#010+
  482. ' FDirectory: String;'#013#010+
  483. ' FExtension',': String;'#013#010+
  484. ' FTargetSourceFileName : String;'#013#010+
  485. ' FFileType: TFileType;'#013#010+
  486. ' FOptions: TStrings;'#013#010+
  487. ' FFPCTarget: String;'#013#010+
  488. ' FTargetState: TTargetState;'#013#010+
  489. ' FTargetType: TTargetType;'#013#010+
  490. ' FXML: string;'#013#010+
  491. ' function GetOptions: TString','s;'#013#010+
  492. ' procedure SetOptions(const AValue: TStrings);'#013#010+
  493. ' Protected'#013#010+
  494. ' Function GetSourceFileName : String; virtual;'#013#010+
  495. ' Function GetUnitFileName : String; virtual;'#013#010+
  496. ' function GetUnitLibFileName: String; virtual;'#013#010+
  497. ' Function GetObjec','tFileName : String; virtual;'#013#010+
  498. ' Function GetRSTFileName : String; Virtual;'#013#010+
  499. ' Function GetProgramFileName(AOS : TOS) : String; Virtual;'#013#010+
  500. ' Public'#013#010+
  501. ' Constructor Create(ACollection : TCollection); override;'#013#010+
  502. ' Destructor Destroy; ove','rride;'#013#010+
  503. ' Function GetOutputFileName (AOs : TOS) : String; Virtual;'#013#010+
  504. ' Function HaveOptions : Boolean;'#013#010+
  505. ' procedure SetName(const AValue: String);override;'#013#010+
  506. ' procedure SetXML(const AValue: string);'#013#010+
  507. ' Procedure GetCleanFiles(Lis','t : TStrings; const APrefixU, APrefix'+
  508. 'B : String; ACPU:TCPU; AOS : TOS); virtual;'#013#010+
  509. ' Procedure GetInstallFiles(List : TStrings; const APrefixU, APrefix'+
  510. 'B: String; ACPU:TCPU; AOS : TOS); virtual;'#013#010+
  511. ' Procedure GetArchiveFiles(List : TString','s; ACPU:TCPU; AOS : TOS)'+
  512. '; virtual;'#013#010+
  513. ' Property Dependencies : TDependencies Read FDependencies;'#013#010+
  514. ' Property Commands : TCommands Read FCommands;'#013#010+
  515. ' Property State : TTargetState Read FTargetState;'#013#010+
  516. ' Property TargetType : TTargetTyp','e Read FTargetType Write FTarget'+
  517. 'Type;'#013#010+
  518. ' Property OSes : TOSes Read FOSes Write FOSes;'#013#010+
  519. ' Property CPUs : TCPUs Read FCPUs Write FCPUs;'#013#010+
  520. ' Property Mode : TCompilerMode Read FMode Write FMode;'#013#010+
  521. ' Property Options : TStrings Read Get','Options Write SetOptions;'#013+
  522. #010+
  523. ' Property SourceFileName: String Read GetSourceFileName ;'#013#010+
  524. ' Property UnitFileName : String Read GetUnitFileName;'#013#010+
  525. ' Property UnitLibFileName : String Read GetUnitLibFileName;'#013#010+
  526. ' Property ObjectFileName :',' String Read GetObjectFileName;'#013#010+
  527. ' Property RSTFileName : String Read GetRSTFileName;'#013#010+
  528. ' Property FPCTarget : String Read FFPCTarget Write FFPCTarget;'#013#010+
  529. ' Property Extension : String Read FExtension Write FExtension;'#013#010+
  530. ' Property File','Type : TFileType Read FFileType Write FFileType;'#013+
  531. #010+
  532. ' Property Directory : String Read FDirectory Write FDirectory;'#013#010+
  533. ' Property ResourceStrings : Boolean Read FResourceStrings Write FRe'+
  534. 'sourceStrings;'#013#010+
  535. ' Property Install : Boolean Read F','Install Write FInstall;'#013#010+
  536. ' Property TargetSourceFileName: String Read FTargetSourceFileName;'#013+
  537. #010+
  538. ' Property ObjectPath : TConditionalStrings Read FObjectPath;'#013#010+
  539. ' Property UnitPath : TConditionalStrings Read FUnitPath;'#013#010+
  540. ' Property Inclu','dePath : TConditionalStrings Read FIncludePath;'#013+
  541. #010+
  542. ' Property XML: string Read FXML Write SetXML;'#013#010+
  543. ' // Events.'#013#010+
  544. ' Property BeforeCompile : TNotifyEvent Read FBeforeCompile Write FB'+
  545. 'eforeCompile;'#013#010+
  546. ' Property AfterCompile : TNotifyEvent',' Read FAfterCompile Write FA'+
  547. 'fterCompile;'#013#010+
  548. ' Property BeforeClean : TNotifyEvent Read FBeforeClean Write FBefor'+
  549. 'eClean;'#013#010+
  550. ' Property AfterClean : TNotifyEvent Read FAfterClean Write FAfterCl'+
  551. 'ean;'#013#010+
  552. ' end;'#013#010+
  553. #013#010+
  554. ' { TTargets }'#013#010+
  555. #013#010+
  556. ' TTargets = Cl','ass(TNamedCollection)'#013#010+
  557. ' private'#013#010+
  558. ' function GetTargetItem(Index : Integer): TTarget;'#013#010+
  559. ' function GetTarget(const AName : String): TTarget;'#013#010+
  560. ' procedure SetTargetItem(Index : Integer; const AValue: TTarget);'#013+
  561. #010+
  562. ' Public'#013#010+
  563. ' Function Ad','dFPDoc(Const AUnitName, AXMLName : String) : TTarget;'+
  564. 'inline;'#013#010+
  565. ' Function AddUnit(Const AUnitName : String) : TTarget;inline;'#013#010+
  566. ' Function AddUnit(Const AUnitName : String;const OSes:TOSes) : TTar'+
  567. 'get;inline;'#013#010+
  568. '{$ifdef cpu_only_overloads}'#013#010,
  569. ' Function AddUnit(Const AUnitName : String;const CPUs:TCPUs) : TTar'+
  570. 'get;inline;'#013#010+
  571. '{$endif cpu_only_overloads}'#013#010+
  572. ' Function AddUnit(Const AUnitName : String;const CPUs:TCPUs;const O'+
  573. 'Ses:TOSes) : TTarget;'#013#010+
  574. ' Function AddImplicitUnit(Const ','AUnitName : String;InstallUnit:bo'+
  575. 'olean=true) : TTarget;inline;'#013#010+
  576. ' Function AddImplicitUnit(Const AUnitName : String;const OSes:TOSes'+
  577. ';InstallUnit:boolean=true) : TTarget;inline;'#013#010+
  578. ' Function AddImplicitUnit(Const AUnitName : String;const ','CPUs:TCP'+
  579. 'Us;InstallUnit:boolean=true) : TTarget;inline;'#013#010+
  580. ' Function AddImplicitUnit(Const AUnitName : String;const CPUs:TCPUs'+
  581. ';const OSes:TOSes;InstallUnit:boolean=true) : TTarget;'#013#010+
  582. ' Function AddProgram(Const AProgramName : String) : TTa','rget;inlin'+
  583. 'e;'#013#010+
  584. ' Function AddProgram(Const AProgramName : String;const OSes:TOSes) '+
  585. ': TTarget;inline;'#013#010+
  586. '{$ifdef cpu_only_overloads}'#013#010+
  587. ' Function AddProgram(Const AProgramName : String;const CPUs:TCPUs) '+
  588. ': TTarget;inline;'#013#010+
  589. '{$endif cpu_only_ov','erloads}'#013#010+
  590. ' Function AddProgram(Const AProgramName : String;const CPUs:TCPUs;c'+
  591. 'onst OSes:TOSes) : TTarget;'#013#010+
  592. ' Function AddExampleUnit(Const AUnitName : String) : TTarget;inline'+
  593. ';'#013#010+
  594. ' Function AddExampleUnit(Const AUnitName : String;const',' OSes:TOSe'+
  595. 's) : TTarget;inline;'#013#010+
  596. '{$ifdef cpu_only_overloads}'#013#010+
  597. ' Function AddExampleUnit(Const AUnitName : String;const CPUs:TCPUs)'+
  598. ' : TTarget;inline;'#013#010+
  599. '{$endif cpu_only_overloads}'#013#010+
  600. ' Function AddExampleUnit(Const AUnitName : String;const C','PUs:TCPU'+
  601. 's;const OSes:TOSes) : TTarget;'#013#010+
  602. ' Function AddExampleProgram(Const AProgramName : String) : TTarget;'+
  603. 'inline;'#013#010+
  604. ' Function AddExampleProgram(Const AProgramName : String;const OSes:'+
  605. 'TOSes) : TTarget;inline;'#013#010+
  606. '{$ifdef cpu_only_overload','s}'#013#010+
  607. ' Function AddExampleProgram(Const AProgramName : String;const CPUs:'+
  608. 'TCPUs) : TTarget;inline;'#013#010+
  609. '{$endif cpu_only_overloads}'#013#010+
  610. ' Function AddExampleProgram(Const AProgramName : String;const CPUs:'+
  611. 'TCPUs;const OSes:TOSes) : TTarget;'#013#010+
  612. ' P','roperty Targets[AName : String] : TTarget Read GetTarget; defau'+
  613. 'lt;'#013#010+
  614. ' Property TargetItems[Index : Integer] : TTarget Read GetTargetItem'+
  615. ' Write SetTargetItem;'#013#010+
  616. ' end;'#013#010+
  617. #013#010+
  618. ' { TSource }'#013#010+
  619. #013#010+
  620. ' TSource = Class(TNamedItem)'#013#010+
  621. ' private'#013#010+
  622. ' FSourc','eType : TSourceType;'#013#010+
  623. ' FInstallSourcePath : string;'#013#010+
  624. ' function GetInstallSourcePath: string;'#013#010+
  625. ' Public'#013#010+
  626. ' Constructor Create(ACollection : TCollection); override;'#013#010+
  627. ' Destructor Destroy; override;'#013#010+
  628. ' Procedure GetInstallFiles(Lis','t : TStrings); virtual;'#013#010+
  629. ' property SourceType : TSourceType read FSourceType;'#013#010+
  630. ' property InstallSourcePath : string read GetInstallSourcePath;'#013+
  631. #010+
  632. ' end;'#013#010+
  633. #013#010+
  634. ' { TSources }'#013#010+
  635. #013#010+
  636. ' TSources = Class(TNamedCollection)'#013#010+
  637. ' private'#013#010+
  638. ' function ','GetSourceItem(Index : Integer): TSource;'#013#010+
  639. ' procedure SetSourceItem(Index : Integer; const AValue: TSource);'#013+
  640. #010+
  641. ' public'#013#010+
  642. ' Function AddDoc(const AFiles : String) : TSource;'#013#010+
  643. ' Function AddDoc(const AFiles : String; AInstallSourcePath :',' Stri'+
  644. 'ng) : TSource;'#013#010+
  645. ' Function AddSrc(const AFiles : String) : TSource;'#013#010+
  646. ' Function AddExample(const AFiles : String) : TSource;'#013#010+
  647. ' Function AddExample(const AFiles : String; AInstallSourcePath : St'+
  648. 'ring) : TSource;'#013#010+
  649. ' Function AddT','est(const AFiles : String) : TSource;'#013#010+
  650. ' procedure AddDocFiles(const AFileMask: string; Recursive: boolean '+
  651. '= False; AInstallSourcePath : String = '#039#039');'#013#010+
  652. ' procedure AddSrcFiles(const AFileMask: string; Recursive: boolean '+
  653. '= False);'#013#010+
  654. ' p','rocedure AddExampleFiles(const AFileMask: string; Recursive: bo'+
  655. 'olean = False; AInstallSourcePath : String = '#039#039');'#013#010+
  656. ' procedure AddTestFiles(const AFileMask: string; Recursive: boolean'+
  657. ' = False);'#013#010+
  658. ' Property SourceItems[Index : Integer] : ','TSource Read GetSourceIt'+
  659. 'em Write SetSourceItem;default;'#013#010+
  660. ' end;'#013#010+
  661. #013#010+
  662. ' { TPackage }'#013#010+
  663. #013#010+
  664. ' TPackage = Class(TNamedItem)'#013#010+
  665. ' private'#013#010+
  666. ' FAfterArchive: TNotifyEvent;'#013#010+
  667. ' FAfterArchiveProc: TNotifyProcEvent;'#013#010+
  668. ' FAfterClean: TNotifyEvent;'#013#010+
  669. ' ','FAfterCleanProc: TNotifyProcEvent;'#013#010+
  670. ' FAfterCompile: TNotifyEvent;'#013#010+
  671. ' FAfterCompileProc: TNotifyProcEvent;'#013#010+
  672. ' FAfterInstall: TNotifyEvent;'#013#010+
  673. ' FAfterInstallProc: TNotifyProcEvent;'#013#010+
  674. ' FAfterManifest: TNotifyEvent;'#013#010+
  675. ' FAfterManifes','tProc: TNotifyProcEvent;'#013#010+
  676. ' FBeforeArchive: TNotifyEvent;'#013#010+
  677. ' FBeforeArchiveProc: TNotifyProcEvent;'#013#010+
  678. ' FBeforeClean: TNotifyEvent;'#013#010+
  679. ' FBeforeCleanProc: TNotifyProcEvent;'#013#010+
  680. ' FBeforeCompile: TNotifyEvent;'#013#010+
  681. ' FBeforeCompileProc: TNo','tifyProcEvent;'#013#010+
  682. ' FBeforeInstall: TNotifyEvent;'#013#010+
  683. ' FBeforeInstallProc: TNotifyProcEvent;'#013#010+
  684. ' FBeforeManifest: TNotifyEvent;'#013#010+
  685. ' FBeforeManifestProc: TNotifyProcEvent;'#013#010+
  686. ' FBuildMode: TBuildMode;'#013#010+
  687. ' FFPDocFormat: TFPDocFormats;'#013#010+
  688. ' ',' FIsFPMakeAddIn: boolean;'#013#010+
  689. ' FSupportBuildModes: TBuildModes;'#013#010+
  690. ' FUnitPath,'#013#010+
  691. ' FObjectPath,'#013#010+
  692. ' FIncludePath,'#013#010+
  693. ' FSourcePath,'#013#010+
  694. ' FExamplePath,'#013#010+
  695. ' FTestPath,'#013#010+
  696. ' FCleanFiles,'#013#010+
  697. ' FInstallFiles : TConditionalStrings;'#013#010+
  698. ' FDepe','ndencies : TDependencies;'#013#010+
  699. ' FCPUs: TCPUs;'#013#010+
  700. ' FOSes: TOSes;'#013#010+
  701. ' FTargetState: TTargetState;'#013#010+
  702. ' FTargets: TTargets;'#013#010+
  703. ' FSources: TSources;'#013#010+
  704. ' FDirectory: String;'#013#010+
  705. ' FOptions: TStrings;'#013#010+
  706. ' FFileName: String;'#013#010+
  707. ' FAuthor: Strin','g;'#013#010+
  708. ' FLicense: String;'#013#010+
  709. ' FHomepageURL: String;'#013#010+
  710. ' FDownloadURL: String;'#013#010+
  711. ' FVersion: TFPVersion;'#013#010+
  712. ' FEmail : String;'#013#010+
  713. ' FNeedLibC : Boolean;'#013#010+
  714. ' FCommands : TCommands;'#013#010+
  715. ' FDescriptionFile : String;'#013#010+
  716. ' FDescription : Strin','g;'#013#010+
  717. ' FInstalledChecksum : Cardinal;'#013#010+
  718. ' // Cached directory of installed packages'#013#010+
  719. ' FUnitDir : String;'#013#010+
  720. ' FBUTargets: TTargets;'#013#010+
  721. ' FBUTarget: TTarget;'#013#010+
  722. ' Function GetDescription : string;'#013#010+
  723. ' Function GetFileName : string;'#013#010+
  724. ' ',' function GetOptions: TStrings;'#013#010+
  725. ' Function GetVersion : string;'#013#010+
  726. ' procedure SetOptions(const AValue: TStrings);'#013#010+
  727. ' Procedure SetVersion(const V : string);'#013#010+
  728. ' Protected'#013#010+
  729. ' procedure SetName(const AValue: String);override;'#013#010+
  730. ' pro','cedure LoadUnitConfigFromFile(Const AFileName: String);'#013#010+
  731. ' procedure SaveUnitConfigToStringList(Const AStringList: TStrings;A'+
  732. 'CPU:TCPU;AOS:TOS); virtual;'#013#010+
  733. ' procedure SaveUnitConfigToFile(Const AFileName: String;ACPU:TCPU;A'+
  734. 'OS:TOS);'#013#010+
  735. ' Pu','blic'#013#010+
  736. ' constructor Create(ACollection: TCollection); override;'#013#010+
  737. ' destructor destroy; override;'#013#010+
  738. ' Function HaveOptions : Boolean;'#013#010+
  739. ' Function GetUnitsOutputDir(ACPU:TCPU; AOS : TOS):String;'#013#010+
  740. ' Function GetBinOutputDir(ACPU:TCP','U; AOS : TOS) : String;'#013#010+
  741. ' Procedure GetCleanFiles(List : TStrings; ACPU:TCPU; AOS : TOS); vi'+
  742. 'rtual;'#013#010+
  743. ' procedure GetInstallFiles(List: TStrings;Types : TTargetTypes;ACPU'+
  744. ':TCPU; AOS : TOS); virtual;'#013#010+
  745. ' procedure GetInstallSourceFiles(Li','st: TStrings; SourceTypes : TS'+
  746. 'ourceTypes; TargetTypes : TTargetTypes); virtual;'#013#010+
  747. ' Procedure GetArchiveFiles(List : TStrings; ACPU:TCPU; AOS : TOS); '+
  748. 'virtual;'#013#010+
  749. ' Procedure GetArchiveSourceFiles(List : TStrings); virtual;'#013#010+
  750. ' Procedure G','etManifest(Manifest : TStrings);'#013#010+
  751. ' Property Version : String Read GetVersion Write SetVersion;'#013#010+
  752. ' Property FileName : String Read GetFileName Write FFileName;'#013#010+
  753. ' Property HomepageURL : String Read FHomepageURL Write FHomepageURL'+
  754. ';'#013#010+
  755. ' ',' Property DownloadURL : String Read FDownloadURL Write FDownloadU'+
  756. 'RL;'#013#010+
  757. ' Property Email : String Read FEmail Write FEmail;'#013#010+
  758. ' Property Author : String Read FAuthor Write FAuthor;'#013#010+
  759. ' Property License : String Read FLicense Write FLicen','se;'#013#010+
  760. ' Property Directory : String Read FDirectory Write FDirectory;'#013#010+
  761. ' Property Description : String Read GetDescription Write FDescripti'+
  762. 'on;'#013#010+
  763. ' Property DescriptionFile : String Read FDescriptionFile Write FDes'+
  764. 'criptionFile;'#013#010+
  765. ' Prop','erty InstalledChecksum : Cardinal Read FInstalledChecksum Wr'+
  766. 'ite FInstalledChecksum;'#013#010+
  767. ' Property IsFPMakeAddIn: boolean read FIsFPMakeAddIn write FIsFPMak'+
  768. 'eAddIn;'#013#010+
  769. ' Property SupportBuildModes: TBuildModes read FSupportBuildModes wr'+
  770. 'ite FS','upportBuildModes;'#013#010+
  771. ' Property BuildMode: TBuildMode read FBuildMode;'#013#010+
  772. ' // Compiler options.'#013#010+
  773. ' Property OSes : TOSes Read FOSes Write FOSes;'#013#010+
  774. ' Property CPUs : TCPUs Read FCPUs Write FCPUs;'#013#010+
  775. ' Property NeedLibC : Boolean Read FNe','edLibC Write FNeedLibC;'#013#010+
  776. ' Property Options: TStrings Read GetOptions Write SetOptions;'#013#010+
  777. ' Property UnitPath : TConditionalStrings Read FUnitPath;'#013#010+
  778. ' Property ObjectPath : TConditionalStrings Read FObjectPath;'#013#010+
  779. ' Property IncludePat','h : TConditionalStrings Read FIncludePath;'#013+
  780. #010+
  781. ' Property SourcePath : TConditionalStrings Read FSourcePath;'#013#010+
  782. ' Property ExamplePath : TConditionalStrings Read FExamplePath;'#013#010+
  783. ' Property TestPath : TConditionalStrings Read FTestPath;'#013#010+
  784. ' ',' Property FPDocFormat: TFPDocFormats read FFPDocFormat write FFPD'+
  785. 'ocFormat;'#013#010+
  786. ' // Targets and dependencies'#013#010+
  787. ' Property InstallFiles : TConditionalStrings Read FInstallFiles;'#013+
  788. #010+
  789. ' Property CleanFiles : TConditionalStrings Read FCleanFiles',';'#013#010+
  790. ' Property Dependencies : TDependencies Read FDependencies;'#013#010+
  791. ' Property Commands : TCommands Read FCommands;'#013#010+
  792. ' Property State : TTargetState Read FTargetState;'#013#010+
  793. ' Property Targets : TTargets Read FTargets;'#013#010+
  794. ' Property Sources ',': TSources Read FSources;'#013#010+
  795. ' Property UnitDir : String Read FUnitDir Write FUnitDir;'#013#010+
  796. ' // events'#013#010+
  797. ' Property BeforeCompile : TNotifyEvent Read FBeforeCompile Write FB'+
  798. 'eforeCompile;'#013#010+
  799. ' Property BeforeCompileProc : TNotifyProcEvent Re','ad FBeforeCompil'+
  800. 'eProc write FBeforeCompileProc;'#013#010+
  801. ' Property AfterCompile : TNotifyEvent Read FAfterCompile Write FAft'+
  802. 'erCompile;'#013#010+
  803. ' Property AfterCompileProc : TNotifyProcEvent Read FAfterCompilePro'+
  804. 'c Write FAfterCompileProc;'#013#010+
  805. ' Propert','y BeforeInstall : TNotifyEvent Read FBeforeInstall Write '+
  806. 'FBeforeInstall;'#013#010+
  807. ' Property BeforeInstallProc : TNotifyProcEvent Read FBeforeInstallP'+
  808. 'roc Write FBeforeInstallProc;'#013#010+
  809. ' Property AfterInstall : TNotifyEvent Read FAfterInstall Write',' FA'+
  810. 'fterInstall;'#013#010+
  811. ' Property AfterInstallProc : TNotifyProcEvent Read FAfterInstallPro'+
  812. 'c Write FAfterInstallProc;'#013#010+
  813. ' Property BeforeClean : TNotifyEvent Read FBeforeClean Write FBefor'+
  814. 'eClean;'#013#010+
  815. ' Property BeforeCleanProc : TNotifyProcEven','t Read FBeforeCleanPro'+
  816. 'c Write FBeforeCleanProc;'#013#010+
  817. ' Property AfterClean : TNotifyEvent Read FAfterClean Write FAfterCl'+
  818. 'ean;'#013#010+
  819. ' Property AfterCleanProc : TNotifyProcEvent Read FAfterCleanProc Wr'+
  820. 'ite FAfterCleanProc;'#013#010+
  821. ' Property BeforeArch','ive : TNotifyEvent Read FBeforeArchive Write '+
  822. 'FBeforeArchive;'#013#010+
  823. ' Property BeforeArchiveProc : TNotifyProcEvent Read FBeforeArchiveP'+
  824. 'roc Write FBeforeArchiveProc;'#013#010+
  825. ' Property AfterArchive : TNotifyEvent Read FAfterArchive Write FAft'+
  826. 'erArchi','ve;'#013#010+
  827. ' Property AfterArchiveProc : TNotifyProcEvent Read FAfterArchivePro'+
  828. 'c Write FAfterArchiveProc;'#013#010+
  829. ' Property BeforeManifest : TNotifyEvent Read FBeforeManifest Write '+
  830. 'FBeforeManifest;'#013#010+
  831. ' Property BeforeManifestProc : TNotifyProcEven','t Read FBeforeManif'+
  832. 'estProc Write FBeforeManifestProc;'#013#010+
  833. ' Property AfterManifest : TNotifyEvent Read FAfterManifest Write FA'+
  834. 'fterManifest;'#013#010+
  835. ' Property AfterManifestProc : TNotifyProcEvent Read FAfterManifestP'+
  836. 'roc Write FAfterManifestProc;'#013,#010+
  837. ' end;'#013#010+
  838. #013#010+
  839. ' { TPackages }'#013#010+
  840. #013#010+
  841. ' TPackages = Class(TNamedCollection)'#013#010+
  842. ' private'#013#010+
  843. ' function GetPackage(const AName : String): TPackage;'#013#010+
  844. ' function GetPackageItem(AIndex : Integer): TPackage;'#013#010+
  845. ' procedure SetPackageItem(AIndex : Intege','r; const AValue: TPackag'+
  846. 'e);'#013#010+
  847. ' Public'#013#010+
  848. ' Function AddPackage(Const AName : String) : TPackage;'#013#010+
  849. ' Property Packages[AName : String] : TPackage Read GetPackage ; Def'+
  850. 'ault;'#013#010+
  851. ' Property PackageItems[AIndex : Integer] : TPackage Read GetPa','cka'+
  852. 'geItem Write SetPackageItem;'#013#010+
  853. ' end;'#013#010+
  854. #013#010+
  855. ' { TCustomDefaults }'#013#010+
  856. #013#010+
  857. ' TCustomDefaults = Class(TPersistent)'#013#010+
  858. ' Private'#013#010+
  859. ' FArchive: String;'#013#010+
  860. ' FBuildMode: TBuildMode;'#013#010+
  861. ' FCompiler: String;'#013#010+
  862. ' FCopy: String;'#013#010+
  863. ' FFPDocOutputDir: Stri','ng;'#013#010+
  864. ' FIgnoreInvalidOptions: Boolean;'#013#010+
  865. ' FInstallExamples: Boolean;'#013#010+
  866. ' FMkDir: String;'#013#010+
  867. ' FMove: String;'#013#010+
  868. ' FOptions: TStrings;'#013#010+
  869. ' FCPU: TCPU;'#013#010+
  870. ' FOS: TOS;'#013#010+
  871. ' FMode : TCompilerMode;'#013#010+
  872. ' FCompilerVersion : String;'#013#010+
  873. ' FPre','fix: String;'#013#010+
  874. ' FLocalUnitDir,'#013#010+
  875. ' FGlobalUnitDir,'#013#010+
  876. ' FBaseInstallDir,'#013#010+
  877. ' FUnitInstallDir,'#013#010+
  878. ' FBinInstallDir,'#013#010+
  879. ' FDocInstallDir,'#013#010+
  880. ' FExamplesInstallDir : String;'#013#010+
  881. ' FRemoveTree: String;'#013#010+
  882. ' FRemoveDir: String;'#013#010+
  883. ' FRemove: ','String;'#013#010+
  884. ' FTarget: String;'#013#010+
  885. ' FUnixPaths: Boolean;'#013#010+
  886. ' FNoFPCCfg: Boolean;'#013#010+
  887. ' FUseEnvironment: Boolean;'#013#010+
  888. ' function GetFPDocOutputDir: String;'#013#010+
  889. ' function GetLocalUnitDir: String;'#013#010+
  890. ' function GetGlobalUnitDir: String;'#013#010+
  891. ' fun','ction GetBaseInstallDir: String;'#013#010+
  892. ' function GetBinInstallDir: String;'#013#010+
  893. ' function GetCompiler: String;'#013#010+
  894. ' function GetDocInstallDir: String;'#013#010+
  895. ' function GetExamplesInstallDir: String;'#013#010+
  896. ' function GetOptions: TStrings;'#013#010+
  897. ' functi','on GetUnitInstallDir: String;'#013#010+
  898. ' procedure SetLocalUnitDir(const AValue: String);'#013#010+
  899. ' procedure SetGlobalUnitDir(const AValue: String);'#013#010+
  900. ' procedure SetBaseInstallDir(const AValue: String);'#013#010+
  901. ' procedure SetCPU(const AValue: TCPU);'#013#010+
  902. ' ',' procedure SetOptions(const AValue: TStrings);'#013#010+
  903. ' procedure SetOS(const AValue: TOS);'#013#010+
  904. ' procedure SetPrefix(const AValue: String);'#013#010+
  905. ' procedure SetTarget(const AValue: String);'#013#010+
  906. ' procedure SetUnitInstallDir(const AValue: String)',';'#013#010+
  907. ' Protected'#013#010+
  908. ' procedure RecalcTarget;'#013#010+
  909. ' Function CmdLineOptions : String;'#013#010+
  910. ' Public'#013#010+
  911. ' Constructor Create;'#013#010+
  912. ' Procedure InitDefaults;'#013#010+
  913. ' Function HaveOptions: Boolean;'#013#010+
  914. ' procedure CompilerDefaults; virtual;'#013#010+
  915. ' Procedure ','LocalInit(Const AFileName : String);'#013#010+
  916. ' Procedure LoadFromFile(Const AFileName : String);'#013#010+
  917. ' Procedure SaveToFile(Const AFileName : String);'#013#010+
  918. ' procedure SaveToStream(S : TStream);virtual;'#013#010+
  919. ' procedure LoadFromStream(S : TStream);vi','rtual;'#013#010+
  920. ' // Compile Information'#013#010+
  921. ' Property Target : String Read FTarget Write SetTarget;'#013#010+
  922. ' Property OS : TOS Read FOS Write SetOS;'#013#010+
  923. ' Property CPU : TCPU Read FCPU Write SetCPU;'#013#010+
  924. ' Property Mode : TCompilerMode Read FMode Write',' FMode;'#013#010+
  925. ' Property UnixPaths : Boolean Read FUnixPaths Write FUnixPaths;'#013+
  926. #010+
  927. ' Property Options : TStrings Read GetOptions Write SetOptions; /'+
  928. '/ Default compiler options.'#013#010+
  929. ' Property NoFPCCfg : Boolean Read FNoFPCCfg Write FNoFPCCfg;'#013,#010+
  930. ' // paths etc.'#013#010+
  931. ' Property LocalUnitDir : String Read GetLocalUnitDir Write SetLocal'+
  932. 'UnitDir;'#013#010+
  933. ' Property GlobalUnitDir : String Read GetGlobalUnitDir Write SetGlo'+
  934. 'balUnitDir;'#013#010+
  935. ' Property Prefix : String Read FPrefix Write SetPrefix',';'#013#010+
  936. ' Property BaseInstallDir : String Read GetBaseInstallDir Write SetB'+
  937. 'aseInstallDir;'#013#010+
  938. ' Property UnitInstallDir : String Read GetUnitInstallDir Write SetU'+
  939. 'nitInstallDir;'#013#010+
  940. ' Property BinInstallDir : String Read GetBinInstallDir Write F','Bin'+
  941. 'InstallDir;'#013#010+
  942. ' Property DocInstallDir : String Read GetDocInstallDir Write FDocIn'+
  943. 'stallDir;'#013#010+
  944. ' Property ExamplesInstallDir : String Read GetExamplesInstallDir Wr'+
  945. 'ite FExamplesInstallDir;'#013#010+
  946. ' Property FPDocOutputDir : String Read GetFP','DocOutputDir Write FF'+
  947. 'PDocOutputDir;'#013#010+
  948. ' // Command tools. If not set, internal commands will be used.'#013+
  949. #010+
  950. ' Property Compiler : String Read GetCompiler Write FCompiler; // Co'+
  951. 'mpiler. Defaults to fpc'#013#010+
  952. ' Property Copy : String Read FCopy Wr','ite FCopy; // co'+
  953. 'py $(FILES) to $(DEST)'#013#010+
  954. ' Property Move : String Read FMove Write FMove; // Move'+
  955. ' $(FILES) to $(DEST)'#013#010+
  956. ' Property Remove : String Read FRemove Write FRemove; // Dele'+
  957. 'te $(FILES)'#013#010+
  958. ' Property ','RemoveDir : String Read FRemoveDir Write FRemoveDir; '+
  959. ' // Delete $(FILES)'#013#010+
  960. ' Property RemoveTree : String Read FRemoveTree Write FRemoveTree; '+
  961. ' // removes $(DIRECTORY)'#013#010+
  962. ' Property MkDir : String Read FMkDir write FMkDir; ',' // Ma'+
  963. 'ke $(DIRECTORY)'#013#010+
  964. ' Property Archive : String Read FArchive Write FArchive; // zip '+
  965. '$(ARCHIVE) $(FILESORDIRS)'#013#010+
  966. ' // Misc'#013#010+
  967. ' Property UseEnvironment : Boolean read FUseEnvironment write FUseE'+
  968. 'nvironment;'#013#010+
  969. ' Property IgnoreInva','lidOptions: Boolean read FIgnoreInvalidOption'+
  970. 's write FIgnoreInvalidOptions;'#013#010+
  971. ' Property BuildMode: TBuildMode read FBuildMode write FBuildMode;'#013+
  972. #010+
  973. ' // Installation optioms'#013#010+
  974. ' Property InstallExamples: Boolean read FInstallExamples writ','e FI'+
  975. 'nstallExamples;'#013#010+
  976. ' end;'#013#010+
  977. #013#010+
  978. ' { TBasicDefaults }'#013#010+
  979. #013#010+
  980. ' TBasicDefaults = Class(TCustomDefaults)'#013#010+
  981. ' end;'#013#010+
  982. #013#010+
  983. ' { TFPCDefaults }'#013#010+
  984. #013#010+
  985. ' TFPCDefaults = Class(TCustomDefaults)'#013#010+
  986. ' public'#013#010+
  987. ' procedure CompilerDefaults; override;'#013#010+
  988. ' end;'#013#010+
  989. #013#010+
  990. ' { TB','uildEngine }'#013#010+
  991. #013#010+
  992. ' TBuildEngine = Class(TComponent)'#013#010+
  993. ' private'#013#010+
  994. ' // general variables'#013#010+
  995. ' FCompiler : String;'#013#010+
  996. ' FStartDir : String;'#013#010+
  997. ' FForceCompile : Boolean;'#013#010+
  998. ' FListMode : Boolean;'#013#010+
  999. ' FVerbose : boolean;'#013#010+
  1000. ' FProgressMax : i','nteger;'#013#010+
  1001. ' FProgressCount : integer;'#013#010+
  1002. '{$ifdef HAS_UNIT_ZIPPER}'#013#010+
  1003. ' FZipFile: TZipper;'#013#010+
  1004. '{$endif HAS_UNIT_ZIPPER}'#013#010+
  1005. ' FExternalPackages : TPackages;'#013#010+
  1006. ' // Logging'#013#010+
  1007. ' FLogPrefix : String;'#013#010+
  1008. ' // Events'#013#010+
  1009. ' FOnLog: TLogEvent;'#013#010+
  1010. ' FAf','terArchive: TNotifyEvent;'#013#010+
  1011. ' FAfterClean: TNotifyEvent;'#013#010+
  1012. ' FAfterCompile: TNotifyEvent;'#013#010+
  1013. ' FAfterInstall: TNotifyEvent;'#013#010+
  1014. ' FAfterManifest: TNotifyEvent;'#013#010+
  1015. ' FBeforeArchive: TNotifyEvent;'#013#010+
  1016. ' FBeforeClean: TNotifyEvent;'#013#010+
  1017. ' FBefor','eCompile: TNotifyEvent;'#013#010+
  1018. ' FBeforeInstall: TNotifyEvent;'#013#010+
  1019. ' FBeforeManifest: TNotifyEvent;'#013#010+
  1020. ' Protected'#013#010+
  1021. ' Procedure Error(const Msg : String);'#013#010+
  1022. ' Procedure Error(const Fmt : String; const Args : Array of const);'#013+
  1023. #010+
  1024. ' // Internal co','py/delete/move/archive/mkdir files'#013#010+
  1025. ' Function SysDirectoryExists(const ADir:string):Boolean;'#013#010+
  1026. ' Function SysFileExists(const AFileName:string):Boolean;'#013#010+
  1027. ' Procedure SysCopyFile(Const Src,Dest : String); virtual;'#013#010+
  1028. ' Procedure SysM','oveFile(Const Src,Dest : String); virtual;'#013#010+
  1029. ' Procedure SysDeleteFile(Const AFileName : String); virtual;'#013#010+
  1030. ' Procedure SysDeleteDirectory(Const ADirectoryName : String); virtu'+
  1031. 'al;'#013#010+
  1032. ' Procedure SysDeleteTree(Const ADirectoryName : Strin','g); virtual;'+
  1033. #013#010+
  1034. ' Procedure SysArchiveFiles(List : TStrings; Const AFileName : Strin'+
  1035. 'g); virtual;'#013#010+
  1036. ' procedure LogIndent;'#013#010+
  1037. ' procedure LogUnIndent;'#013#010+
  1038. ' Procedure EnterDir(ADir : String);'#013#010+
  1039. ' Function GetCompiler : String;'#013#010+
  1040. ' Function',' InstallPackageFiles(APAckage : TPackage; tt : TTargetTy'+
  1041. 'pe; Const Dest : String):Boolean;'#013#010+
  1042. ' Procedure InstallUnitConfigFile(APAckage : TPackage; Const Dest : '+
  1043. 'String);'#013#010+
  1044. ' Function InstallPackageSourceFiles(APAckage : TPackage; stt : TSo',
  1045. 'urceTypes; ttt : TTargetTypes; Const Dest : String):Boolean;'#013#010+
  1046. ' Function FileNewer(const Src,Dest : String) : Boolean;'#013#010+
  1047. ' Procedure LogSearchPath(const ASearchPathName:string;Path:TConditi'+
  1048. 'onalStrings; ACPU:TCPU;AOS:TOS);'#013#010+
  1049. ' Function F','indFileInPath(Path:TConditionalStrings; AFileName:Stri'+
  1050. 'ng; var FoundPath:String;ACPU:TCPU;AOS:TOS):Boolean;'#013#010+
  1051. #013#010+
  1052. ' procedure GetDirectoriesFromFilelist(const AFileList, ADirectoryLi'+
  1053. 'st: TStringList);'#013#010+
  1054. ' //package commands'#013#010+
  1055. ' function Get','UnitDir(APackage:TPackage):String;'#013#010+
  1056. ' procedure AddDependencyPaths(L: TStrings; DependencyType: TDepende'+
  1057. 'ncyType; ATarget: TTarget);'#013#010+
  1058. ' procedure AddDependencyUnitPaths(L:TStrings;APackage: TPackage);'#013+
  1059. #010+
  1060. ' Public'#013#010+
  1061. ' Constructor Create(AO','wner : TComponent); override;'#013#010+
  1062. ' destructor Destroy;override;'#013#010+
  1063. #013#010+
  1064. ' property Verbose : boolean read FVerbose write FVerbose;'#013#010+
  1065. ' Procedure ResolveFileNames(APackage : TPackage; ACPU:TCPU;AOS:TOS;'+
  1066. 'DoChangeDir:boolean=true);'#013#010+
  1067. #013#010+
  1068. ' // Publ','ic Copy/delete/Move/Archive/Mkdir Commands.'#013#010+
  1069. ' Procedure ExecuteCommand(const Cmd,Args : String; const Env: TStri'+
  1070. 'ngs = nil; IgnoreError : Boolean = False); virtual;'#013#010+
  1071. ' Procedure CmdCopyFiles(List : TStrings; Const DestDir : String);'#013+
  1072. #010+
  1073. ' ',' Procedure CmdCreateDir(const DestDir : String);'#013#010+
  1074. ' Procedure CmdMoveFiles(List : TStrings; Const DestDir : String);'#013+
  1075. #010+
  1076. ' Procedure CmdDeleteFiles(List : TStrings);'#013#010+
  1077. ' Procedure CmdArchiveFiles(List : TStrings; Const ArchiveFile : Str'+
  1078. 'i','ng);'#013#010+
  1079. ' Procedure CmdRenameFile(SourceName, DestName : String);'#013#010+
  1080. ' Procedure CmdRemoveDirs(List: TStrings);'#013#010+
  1081. ' Procedure CmdRemoveTrees(List: TStrings);'#013#010+
  1082. ' Procedure ExecuteCommands(Commands : TCommands; At : TCommandAt);'#013+
  1083. #010+
  1084. ' // De','pendency commands'#013#010+
  1085. ' Function DependencyOK(ADependency : TDependency) : Boolean;'#013#010+
  1086. ' // Target commands'#013#010+
  1087. ' Function GetCompilerCommand(APackage : TPackage; ATarget : TTarge'+
  1088. 't; Env: TStrings) : String;'#013#010+
  1089. ' Function TargetOK(ATarget :',' TTarget) : Boolean;'#013#010+
  1090. ' Function NeedsCompile(APackage:TPackage; ATarget : TTarget) : Boo'+
  1091. 'lean;'#013#010+
  1092. ' Procedure Compile(APackage:TPackage; ATarget : TTarget); virtual;'+
  1093. #013#010+
  1094. ' Procedure MaybeCompile(APackage:TPackage; ATarget: TTarget);'#013#010+
  1095. ' ',' Procedure CompileDependencies(APackage:TPackage; ATarget: TTarge'+
  1096. 't);'#013#010+
  1097. ' // Package commands'#013#010+
  1098. '{ Function GetPackageDir(APackage : TPackage; AbsolutePath : Boole'+
  1099. 'an = False) : String;'#013#010+
  1100. ' Function GetUnitsOutputDir(APackage : TPackage;',' AbsolutePath : '+
  1101. 'Boolean = False) : String;'#013#010+
  1102. ' Function GetBinOutputDir(APackage : TPackage; AbsolutePath : Bool'+
  1103. 'ean = False) : String; }'#013#010+
  1104. ' Function PackageOK(APackage : TPackage) : Boolean; virtual;'#013#010+
  1105. ' Procedure DoBeforeCompile(APa','ckage : TPackage);virtual;'#013#010+
  1106. ' Procedure DoAfterCompile(APackage : TPackage);virtual;'#013#010+
  1107. ' Procedure DoBeforeInstall(APackage : TPackage);virtual;'#013#010+
  1108. ' Procedure DoAfterInstall(APackage : TPackage);virtual;'#013#010+
  1109. ' Procedure DoBeforeArchive(A','Package : TPackage);virtual;'#013#010+
  1110. ' Procedure DoAfterArchive(APackage : TPackage);virtual;'#013#010+
  1111. ' Procedure DoBeforeClean(APackage : TPackage);virtual;'#013#010+
  1112. ' Procedure DoAfterClean(APackage : TPackage);virtual;'#013#010+
  1113. ' Function NeedsCompile(APacka','ge : TPackage) : Boolean; virtual;'#013+
  1114. #010+
  1115. ' Procedure Compile(APackage : TPackage);'#013#010+
  1116. ' Procedure MaybeCompile(APackage:TPackage);'#013#010+
  1117. ' Procedure Install(APackage : TPackage);'#013#010+
  1118. ' Procedure Archive(APackage : TPackage);'#013#010+
  1119. ' Procedure Manifes','t(APackage : TPackage);'#013#010+
  1120. ' Procedure Clean(APackage : TPackage; AllTargets: boolean);'#013#010+
  1121. ' Procedure Clean(APackage : TPackage; ACPU:TCPU; AOS : TOS);'#013#010+
  1122. ' Procedure CompileDependencies(APackage : TPackage);'#013#010+
  1123. ' Function CheckExternalPa','ckage(Const APackageName : String):TPac'+
  1124. 'kage;'#013#010+
  1125. ' procedure CreateOutputDir(APackage: TPackage);'#013#010+
  1126. ' // Packages commands'#013#010+
  1127. ' Procedure Compile(Packages : TPackages);'#013#010+
  1128. ' Procedure Install(Packages : TPackages);'#013#010+
  1129. ' Procedure Archive(Pa','ckages : TPackages);'#013#010+
  1130. ' procedure Manifest(Packages: TPackages);'#013#010+
  1131. ' Procedure Clean(Packages : TPackages; AllTargets: boolean);'#013#010+
  1132. #013#010+
  1133. ' Procedure Log(Level : TVerboseLevel; Const Msg : String);'#013#010+
  1134. ' Procedure Log(Level : TVerboseLevel; C','onst Fmt : String; const A'+
  1135. 'rgs : Array Of Const);'#013#010+
  1136. #013#010+
  1137. ' Property ListMode : Boolean Read FListMode Write FListMode;'#013#010+
  1138. ' Property ForceCompile : Boolean Read FForceCompile Write FForceCom'+
  1139. 'pile;'#013#010+
  1140. ' Property ExternalPackages: TPackages Read ','FExternalPackages;'#013+
  1141. #010+
  1142. ' Property StartDir: String Read FStartDir;'#013#010+
  1143. ' // Events'#013#010+
  1144. ' Property BeforeCompile : TNotifyEvent Read FBeforeCompile Write FB'+
  1145. 'eforeCompile;'#013#010+
  1146. ' Property AfterCompile : TNotifyEvent Read FAfterCompile Write FAft'+
  1147. 'erC','ompile;'#013#010+
  1148. ' Property BeforeInstall : TNotifyEvent Read FBeforeInstall Write FB'+
  1149. 'eforeInstall;'#013#010+
  1150. ' Property AfterInstall : TNotifyEvent Read FAfterInstall Write FAft'+
  1151. 'erInstall;'#013#010+
  1152. ' Property BeforeClean : TNotifyEvent Read FBeforeClean Write ','FBef'+
  1153. 'oreClean;'#013#010+
  1154. ' Property AfterClean : TNotifyEvent Read FAfterClean Write FAfterCl'+
  1155. 'ean;'#013#010+
  1156. ' Property BeforeArchive : TNotifyEvent Read FBeforeArchive Write FB'+
  1157. 'eforeArchive;'#013#010+
  1158. ' Property AfterArchive : TNotifyEvent Read FAfterArchive Writ','e FA'+
  1159. 'fterArchive;'#013#010+
  1160. ' Property BeforeManifest : TNotifyEvent Read FBeforeManifest Write '+
  1161. 'FBeforeManifest;'#013#010+
  1162. ' Property AfterManifest : TNotifyEvent Read FAfterManifest Write FA'+
  1163. 'fterManifest;'#013#010+
  1164. ' Property OnLog : TLogEvent Read FOnLog Write ','FOnlog;'#013#010+
  1165. ' end;'#013#010+
  1166. #013#010+
  1167. ' { TCustomInstaller }'#013#010+
  1168. #013#010+
  1169. ' TCustomInstaller = Class(TComponent)'#013#010+
  1170. ' private'#013#010+
  1171. ' FBuildEngine: TBuildEngine;'#013#010+
  1172. ' FPackages: TPackages;'#013#010+
  1173. ' FRunMode: TRunMode;'#013#010+
  1174. ' FListMode : Boolean;'#013#010+
  1175. ' FLogLevels : TVerboseLevels;'#013,#010+
  1176. ' FFPMakeOptionsString: string;'#013#010+
  1177. ' Protected'#013#010+
  1178. ' Procedure Log(Level : TVerboseLevel; Const Msg : String);'#013#010+
  1179. ' Procedure CreatePackages; virtual;'#013#010+
  1180. ' Procedure FreePackages; virtual;'#013#010+
  1181. ' function GetPackages: TPackages; virtual;'#013#010+
  1182. ' ',' Procedure CheckPackages; virtual;'#013#010+
  1183. ' Procedure CreateBuildEngine; virtual;'#013#010+
  1184. ' Procedure Error(const Msg : String);'#013#010+
  1185. ' Procedure Error(const Fmt : String; Args : Array of const);'#013#010+
  1186. ' Procedure AnalyzeOptions;'#013#010+
  1187. ' Procedure Usage(con','st FMT : String; Args : Array of const);'#013#010+
  1188. ' Procedure Compile(Force : Boolean); virtual;'#013#010+
  1189. ' Procedure Clean(AllTargets: boolean); virtual;'#013#010+
  1190. ' Procedure Install; virtual;'#013#010+
  1191. ' Procedure Archive; virtual;'#013#010+
  1192. ' Procedure Manifest; virtua','l;'#013#010+
  1193. ' Public'#013#010+
  1194. ' Constructor Create(AOwner : TComponent); virtual;'#013#010+
  1195. ' Destructor destroy; override;'#013#010+
  1196. ' Function AddPackage(Const AName : String) : TPackage;'#013#010+
  1197. ' Function Run : Boolean;'#013#010+
  1198. ' Property FPMakeOptionsString: string read FF','PMakeOptionsString;'#013+
  1199. #010+
  1200. ' Property BuildEngine : TBuildEngine Read FBuildEngine;'#013#010+
  1201. ' //files in package'#013#010+
  1202. ' Property Packages : TPackages Read GetPackages;'#013#010+
  1203. ' Property RunMode : TRunMode Read FRunMode;'#013#010+
  1204. ' Property ListMode : Boolean Re','ad FListMode;'#013#010+
  1205. ' end;'#013#010+
  1206. #013#010+
  1207. ' { TFPCInstaller }'#013#010+
  1208. ' TFPCInstaller = class(TCustomInstaller)'#013#010+
  1209. ' public'#013#010+
  1210. ' Constructor Create(AOwner : TComponent); override;'#013#010+
  1211. ' end;'#013#010+
  1212. #013#010+
  1213. ' { TBasicInstaller }'#013#010+
  1214. ' TBasicInstaller = class(TCustomInstaller)'#013#010+
  1215. ' Con','structor Create(AOwner : TComponent); override;'#013#010+
  1216. ' end;'#013#010+
  1217. #013#010+
  1218. ' TReplaceFunction = Function (Const AName,Args : String) : String of '+
  1219. 'Object;'#013#010+
  1220. #013#010+
  1221. ' { TValueItem }'#013#010+
  1222. #013#010+
  1223. ' TValueItem = Class(TObject)'#013#010+
  1224. ' FValue : String;'#013#010+
  1225. ' Constructor Create(AVal','ue : String);'#013#010+
  1226. ' end;'#013#010+
  1227. #013#010+
  1228. ' { TFunctionItem }'#013#010+
  1229. #013#010+
  1230. ' TFunctionItem = Class(TObject)'#013#010+
  1231. ' FFunc : TReplaceFunction;'#013#010+
  1232. ' Constructor Create(AFunc : TReplaceFunction);'#013#010+
  1233. ' end;'#013#010+
  1234. #013#010+
  1235. ' { TDictionary }'#013#010+
  1236. #013#010+
  1237. ' TDictionary = Class(TComponent)'#013#010+
  1238. ' FList ',': TStringList;'#013#010+
  1239. ' Public'#013#010+
  1240. ' Constructor Create(AOwner : TComponent); override;'#013#010+
  1241. ' Destructor Destroy;override;'#013#010+
  1242. ' Procedure AddVariable(Const AName,Value : String);'#013#010+
  1243. ' Procedure AddFunction(Const AName : String; FReplacement : TRepl','a'+
  1244. 'ceFunction);'#013#010+
  1245. ' Procedure RemoveItem(Const AName : String);'#013#010+
  1246. ' Function GetValue(Const AName : String) : String;'#013#010+
  1247. ' Function GetValue(Const AName,Args : String) : String; virtual;'#013+
  1248. #010+
  1249. ' Function ReplaceStrings(Const ASource : String) ',': String; virtua'+
  1250. 'l;'#013#010+
  1251. ' end;'#013#010+
  1252. #013#010+
  1253. ' ECollectionError = Class(Exception);'#013#010+
  1254. ' EDictionaryError = Class(Exception);'#013#010+
  1255. ' EInstallerError = Class(Exception);'#013#010+
  1256. #013#010+
  1257. ' TInstallerClass = Class of TCustomInstaller;'#013#010+
  1258. ' TDictionaryClass = Class of TDictionary',';'#013#010+
  1259. #013#010+
  1260. 'Type'#013#010+
  1261. ' TArchiveEvent = Procedure (Const AFileName : String; List : TStrings'+
  1262. ') of Object;'#013#010+
  1263. ' TArchiveProc = Procedure (Const AFileName : String; List : TStrings)'+
  1264. ';'#013#010+
  1265. #013#010+
  1266. 'Var'#013#010+
  1267. ' DictionaryClass : TDictionaryClass = TDictionary;'#013#010+
  1268. ' OnArchiveF','iles : TArchiveEvent = Nil;'#013#010+
  1269. ' ArchiveFilesProc : TArchiveProc = Nil;'#013#010+
  1270. #013#010+
  1271. ' Defaults : TCustomDefaults; // Set by installer.'#013#010+
  1272. ' Dictionary : TDictionary;'#013#010+
  1273. #013#010+
  1274. #013#010+
  1275. 'Function CurrentOS : String;'#013#010+
  1276. 'Function CurrentCPU : String;'#013#010+
  1277. #013#010+
  1278. 'Function Installer(','InstallerClass: TInstallerClass) : TCustomInstall'+
  1279. 'er; overload;'#013#010+
  1280. 'Function Installer : TCustomInstaller; overload;'#013#010+
  1281. #013#010+
  1282. 'Function OSToString(OS: TOS) : String;'#013#010+
  1283. 'Function OSesToString(OSes: TOSes) : String;'#013#010+
  1284. 'Function CPUToString(CPU: TCPU) : Stri','ng;'#013#010+
  1285. 'Function CPUSToString(CPUS: TCPUS) : String;'#013#010+
  1286. 'Function StringToOS(const S : String) : TOS;'#013#010+
  1287. 'Function OSesToString(const S : String) : TOSes;'#013#010+
  1288. 'Function StringToCPU(const S : String) : TCPU;'#013#010+
  1289. 'Function StringToCPUS(const S : String) : TCP','US;'#013#010+
  1290. 'Function ModeToString(Mode: TCompilerMode) : String;'#013#010+
  1291. 'Function StringToMode(const S : String) : TCompilerMode;'#013#010+
  1292. 'Function MakeTargetString(CPU : TCPU;OS: TOS) : String;'#013#010+
  1293. 'Procedure StringToCPUOS(const S : String; Var CPU : TCPU; Var OS: ','TO'+
  1294. 'S);'#013#010+
  1295. 'Function FixPath (const APath : String) : String;'#013#010+
  1296. 'Function IsRelativePath(const APath : String) : boolean;'#013#010+
  1297. 'Procedure ChangeDir(const APath : String);'#013#010+
  1298. 'Function Substitute(Const Source : String; Macros : Array of string) :'+
  1299. ' String;'#013#010,
  1300. 'Procedure SplitCommand(Const Cmd : String; Var Exe,Options : String);'#013+
  1301. #010+
  1302. 'Procedure AddCustomFpmakeCommandlineOption(const ACommandLineOption, H'+
  1303. 'elpMessage : string);'#013#010+
  1304. 'Function GetCustomFpmakeCommandlineOptionValue(const ACommandLineOptio'+
  1305. 'n : st','ring) : string;'#013#010+
  1306. #013#010+
  1307. 'procedure SearchFiles(const AFileName: string; Recursive: boolean; var'+
  1308. ' List: TStrings);'#013#010+
  1309. #013#010+
  1310. 'Implementation'#013#010+
  1311. #013#010+
  1312. 'uses typinfo, rtlconsts;'#013#010+
  1313. #013#010+
  1314. 'type'#013#010+
  1315. ' TUnsortedDuplicatesStringList = class(TStringList)'#013#010+
  1316. ' public'#013#010+
  1317. ' function A','dd(const S: string): Integer; override;'#013#010+
  1318. ' end;'#013#010+
  1319. #013#010+
  1320. 'var'#013#010+
  1321. ' CustomFpmakeCommandlineOptions: TStrings;'#013#010+
  1322. ' CustomFpMakeCommandlineValues: TStrings;'#013#010+
  1323. #013#010+
  1324. 'ResourceString'#013#010+
  1325. ' SErrInvalidCPU = '#039'Invalid CPU name "%s"'#039';'#013#010+
  1326. ' SErrInvalidOS =',' '#039'Invalid OS name "%s"'#039';'#013#010+
  1327. ' SErrInvalidMode = '#039'Invalid compiler mode "%s"'#039';'#013#010+
  1328. ' SErrInvalidTarget = '#039'Invalid compiler target "%s"'#039';'#013#010+
  1329. ' SErrNameExists = '#039'Name "%s" already exists in the collect'+
  1330. 'ion.'#039';'#013#010+
  1331. ' SErrNoSuchName ','= '#039'Could not find item with name "%s" in'+
  1332. ' the collection.'#039';'#013#010+
  1333. ' SErrInValidArgument = '#039'Invalid command-line argument at positi'+
  1334. 'on %d: %s'#039';'#013#010+
  1335. ' SErrNeedArgument = '#039'Option at position %d (%s) needs an arg'+
  1336. 'ument'#039';'#013#010+
  1337. ' SErrNoPackagesDefined = ',#039'No action possible: No packages were de'+
  1338. 'fined.'#039';'#013#010+
  1339. ' SErrInstaller = '#039'The installer encountered the following'+
  1340. ' error:'#039';'#013#010+
  1341. ' SErrDepUnknownTarget = '#039'Unknown target for unit "%s" in depende'+
  1342. 'ncies for %s in package %s'#039';'#013#010+
  1343. ' SErrExternalCom','mandFailed = '#039'External command "%s" failed with'+
  1344. ' exit code %d. Console output:'#039'+LineEnding+'#039'%s'#039';'#013#010+
  1345. ' SErrCreatingDirectory = '#039'Failed to create directory "%s"'#039';'#013+
  1346. #010+
  1347. ' SErrDeletingFile = '#039'Failed to delete file "%s"'#039';'#013#010+
  1348. ' SErrRemovingDirectory ','= '#039'Failed to remove directory "%s"'#039';'+
  1349. #013#010+
  1350. ' SErrMovingFile = '#039'Failed to move file "%s" to "%s"'#039';'#013+
  1351. #010+
  1352. ' SErrCopyingFile = '#039'Failed to copy file "%s" to "%s"'#039';'#013+
  1353. #010+
  1354. ' SErrChangeDirFailed = '#039'Failed to enter directory "%s"'#039';'#013+
  1355. #010+
  1356. ' SErrInvalidAr','gumentToSubstitute = '#039'Invalid number of arguments'+
  1357. ' to Substitute'#039';'#013#010+
  1358. ' SErrNoArchiveSupport = '#039'This binary contains no archive support'+
  1359. '. Please recompile with archive support'#039';'#013#010+
  1360. ' SErrNoDictionaryItem = '#039'No item called "%s" in the dictionary',#039+
  1361. ';'#013#010+
  1362. ' SErrNoDictionaryValue = '#039'The item "%s" in the dictionary is not '+
  1363. 'a value'#039';'#013#010+
  1364. ' SErrNoDictionaryFunc = '#039'The item "%s" in the dictionary is not '+
  1365. 'a function'#039';'#013#010+
  1366. ' SErrInvalidFPCInfo = '#039'Compiler returns invalid information, c'+
  1367. 'heck if fpc -','iV works'#039';'#013#010+
  1368. ' SErrDependencyNotFound = '#039'Could not find unit directory for depe'+
  1369. 'ndency package "%s"'#039';'#013#010+
  1370. ' SErrAlreadyInitialized = '#039'Installer can only be initialized once'+
  1371. #039';'#013#010+
  1372. ' SErrInvalidState = '#039'Invalid state for target %s'#039';'#013#010+
  1373. ' SErrCould','NotCompile = '#039'Could not compile target %s from pack'+
  1374. 'age %s'#039';'#013#010+
  1375. ' SErrUnsupportedBuildmode = '#039'Package does not support this buildm'+
  1376. 'ode'#039';'#013#010+
  1377. #013#010+
  1378. ' SWarnCircularTargetDependency = '#039'Warning: Circular dependency de'+
  1379. 'tected when compiling target %s with',' target %s'#039';'#013#010+
  1380. ' SWarnCircularPackageDependency = '#039'Warning: Circular dependency d'+
  1381. 'etected when compiling package %s with package %s'#039';'#013#010+
  1382. ' SWarnFailedToSetTime = '#039'Warning: Failed to set timestamp on f'+
  1383. 'ile "%s"'#039';'#013#010+
  1384. ' SWarnFailedToGetTime = '#039,'Warning: Failed to get timestamp fro'+
  1385. 'm file "%s"'#039';'#013#010+
  1386. ' SWarnAttemptingToCompileNonNeutralTarget = '#039'Warning: Attempting '+
  1387. 'to compile non-neutral target %s'#039';'#013#010+
  1388. ' SWarnSourceFileNotFound = '#039'Warning: Source file "%s" from packa'+
  1389. 'ge %s not found for %','s'#039';'#013#010+
  1390. ' SWarnIncludeFileNotFound = '#039'Warning: Include file "%s" from pack'+
  1391. 'age %s not found for %s'#039';'#013#010+
  1392. ' SWarnDepUnitNotFound = '#039'Warning: Dependency on unit %s is no'+
  1393. 't supported for %s'#039';'#013#010+
  1394. ' SWarnTargetDependsOnPackage = '#039'Warning: Target %s of',' package %'+
  1395. 's depends on another package (%s). These kind of dependencies are not '+
  1396. 'processed'#039';'#013#010+
  1397. ' SWarnDependOnOtherPlatformPackage = '#039'Warning: Package %s depends'+
  1398. ' on package %s which is not available for the %s platform'#039';'#013#010+
  1399. ' SWarnStartCompilin','gPackage = '#039'Start compiling package %s for t'+
  1400. 'arget %s.'#039';'#013#010+
  1401. ' SWarnCompilingPackagecompleteProgress = '#039'[%3.0f%%] Compiled pack'+
  1402. 'age %s'#039';'#013#010+
  1403. ' SWarnCompilingPackagecomplete = '#039'Compiled package %s'#039';'#013#010+
  1404. ' SWarnSkipPackageTargetProgress = '#039'[%3.0f%%] Ski','pped package %s'+
  1405. ' which has been disabled for target %s'#039';'#013#010+
  1406. ' SWarnSkipPackageTarget = '#039'Skipped package %s which has been disa'+
  1407. 'bled for target %s'#039';'#013#010+
  1408. ' SWarnInstallationPackagecomplete = '#039'Installation package %s for '+
  1409. 'target %s succeeded'#039';'#013#010+
  1410. ' SWar','nCleanPackagecomplete = '#039'Clean of package %s completed'#039+
  1411. ';'#013#010+
  1412. #013#010+
  1413. ' SInfoPackageAlreadyProcessed = '#039'Package %s is already processed'#039+
  1414. ';'#013#010+
  1415. ' SInfoCompilingTarget = '#039'Compiling target %s'#039';'#013#010+
  1416. ' SInfoExecutingCommand = '#039'Executing command "%s %s"'#039';'#013#010+
  1417. ' ',' SInfoCreatingOutputDir = '#039'Creating output dir "%s"'#039';'#013#010+
  1418. ' SInfoInstallingPackage = '#039'Installing package %s'#039';'#013#010+
  1419. ' SInfoArchivingPackage = '#039'Archiving package %s in "%s"'#039';'#013+
  1420. #010+
  1421. ' SInfoCleaningPackage = '#039'Cleaning package %s'#039';'#013#010+
  1422. ' SInfoManifestPa','ckage = '#039'Creating manifest for package %s'#039+
  1423. ';'#013#010+
  1424. ' SInfoCopyingFile = '#039'Copying file "%s" to "%s"'#039';'#013#010+
  1425. ' SInfoSourceNewerDest = '#039'Source file "%s" (%s) is newer than d'+
  1426. 'estination "%s" (%s).'#039';'#013#010+
  1427. ' SInfoFallbackBuildmode = '#039'Buildmode not ','spported by package, '+
  1428. 'falling back to one by one unit compilation'#039';'#013#010+
  1429. #013#010+
  1430. ' SDbgComparingFileTimes = '#039'Comparing file "%s" time "%s" to "%'+
  1431. 's" time "%s".'#039';'#013#010+
  1432. ' SDbgCompilingDependenciesOfTarget = '#039'Compiling dependencies of t'+
  1433. 'arget %s'#039';'#013#010+
  1434. ' SDbgRes','olvingSourcesOfTarget = '#039'Resolving filenames of target '+
  1435. '%s for %s'#039';'#013#010+
  1436. ' SDbgResolvedSourceFile = '#039'Resolved source file %s to "%s"'#039+
  1437. ';'#013#010+
  1438. ' SDbgResolvedIncludeFile = '#039'Resolved include file %s to "%s"'#039+
  1439. ';'#013#010+
  1440. ' SDbgOutputNotYetAvailable = '#039'Output f','ile %s not available'#039';'+
  1441. #013#010+
  1442. ' SDbgDependencyOnUnit = '#039'Dependency of %s on unit %s'#039';'#013+
  1443. #010+
  1444. ' SDbgDependencyUnitRecompiled = '#039'Dependent unit %s is being recom'+
  1445. 'piled'#039';'#013#010+
  1446. ' SDbgMustCompile = '#039'Must compile %s'#039';'#013#010+
  1447. ' SDbgSkippingTargetWrongCPU ','= '#039'Skipping target %s, different CP'+
  1448. 'U (%s)'#039';'#013#010+
  1449. ' SDbgSkippingTargetWrongOS = '#039'Skipping target %s, different OS ('+
  1450. '%s)'#039';'#013#010+
  1451. ' SDbgTargetIsNotAUnitOrProgram = '#039'Skipping Target %s, not an unit'+
  1452. ' or program'#039';'#013#010+
  1453. ' SDbgConsideringTarget = '#039'Considerin','g target %s'#039';'#013#010+
  1454. ' SDbgConsideringPackage = '#039'Considering package %s'#039';'#013#010+
  1455. ' SDbgExternalDependency = '#039'External dependency %s found in "%s'+
  1456. '"'#039';'#013#010+
  1457. ' SDbgBuildEngineArchiving = '#039'Build engine archiving'#039';'#013#010+
  1458. ' SDbgBuildEngineGenerateManifests = '#039'Bu','ild engine generating ma'+
  1459. 'nifests'#039';'#013#010+
  1460. ' SDbgBuildEngineCleaning = '#039'Build engine cleaning'#039';'#013#010+
  1461. ' SDbgGenerating = '#039'Generating "%s"'#039';'#013#010+
  1462. ' SDbgLoading = '#039'Loading "%s"'#039';'#013#010+
  1463. ' SDbgFound = '#039'Found'#039';'#013#010+
  1464. ' SDbgNotFou','nd = '#039'Not Found'#039';'#013#010+
  1465. ' SDbgDirectoryExists = '#039'Directory "%s" %s'#039';'#013#010+
  1466. ' SDbgFileExists = '#039'File "%s" %s'#039';'#013#010+
  1467. ' SDbgArchivingFile = '#039'Archiving "%s"'#039';'#013#010+
  1468. ' SDbgSearchPath = '#039'Using %s path "%s"'#039';'#013#010+
  1469. ' SDbgE','nterDir = '#039'Entering directory "%s"'#039';'#013+
  1470. #010+
  1471. ' SDbgPackageChecksumChanged = '#039'Dependent package %s is modified'#039+
  1472. ';'#013#010+
  1473. ' SDbgFileDoesNotExist = '#039'File "%s" does not exist'#039';'#013#010+
  1474. ' SDbgDirectoryDoesNotExist = '#039'Directory "%s" does not exist'#039';',
  1475. #013#010+
  1476. ' SDbgDirectoryNotEmpty = '#039'Directory "%s" is not empty. Will n'+
  1477. 'ot remove'#039';'#013#010+
  1478. ' SDbgGenerateBuildUnit = '#039'Generate build-unit %s'#039';'#013#010+
  1479. #013#010+
  1480. ' // Help messages for usage'#013#010+
  1481. ' SValue = '#039'Value'#039';'#013#010+
  1482. ' SHelpUsage = '#039'Usage: %s c','ommand [options]'#039';'#013#010+
  1483. ' SHelpCommand = '#039'Where command is one of the following:'#039+
  1484. ';'#013#010+
  1485. ' SHelpCompile = '#039'Compile all units in the package(s).'#039';'+
  1486. #013#010+
  1487. ' SHelpBuild = '#039'Build all units in the package(s).'#039';'#013+
  1488. #010+
  1489. ' SHelpInstall = '#039,'Install all units in the package(s).'#039+
  1490. ';'#013#010+
  1491. ' SHelpClean = '#039'Clean (remove) all units in the package(s'+
  1492. ').'#039';'#013#010+
  1493. ' SHelpArchive = '#039'Create archive (zip) with all units in th'+
  1494. 'e package(s).'#039';'#013#010+
  1495. ' SHelpHelp = '#039'This message.'#039';'#013#010+
  1496. ' S','HelpManifest = '#039'Create a manifest suitable for import i'+
  1497. 'n repository.'#039';'#013#010+
  1498. ' SHelpCmdOptions = '#039'Where options is one or more of the follo'+
  1499. 'wing:'#039';'#013#010+
  1500. ' SHelpCPU = '#039'Compile for indicated CPU.'#039';'#013#010+
  1501. ' SHelpOS = '#039'Compile',' for indicated OS'#039';'#013#010+
  1502. ' SHelpTarget = '#039'Compile for indicated target'#039';'#013#010+
  1503. ' SHelpList = '#039'list commands instead of actually executi'+
  1504. 'ng them.'#039';'#013#010+
  1505. ' SHelpPrefix = '#039'Use indicated prefix directory for all co'+
  1506. 'mmands.'#039';'#013#010+
  1507. ' SHelp','NoFPCCfg = '#039'Compiler will not use fpc.cfg'#039';'#013+
  1508. #010+
  1509. ' SHelpBaseInstallDir = '#039'Use indicated directory as base install d'+
  1510. 'ir.'#039';'#013#010+
  1511. ' SHelpLocalUnitDir = '#039'Use indicated directory as local (user) u'+
  1512. 'nit dir.'#039';'#013#010+
  1513. ' SHelpGlobalUnitDir = '#039'Use indicated',' directory as global unit '+
  1514. 'dir.'#039';'#013#010+
  1515. ' SHelpUnitInstallDir = '#039'Use indicated directory to install units '+
  1516. 'into.'#039';'#013#010+
  1517. ' SHelpCompiler = '#039'Use indicated binary as compiler'#039';'#013+
  1518. #010+
  1519. ' SHelpConfig = '#039'Use indicated config file when compiling.'+
  1520. #039';'#013#010,
  1521. ' SHelpOptions = '#039'Pass extra options to the compiler.'#039';'+
  1522. #013#010+
  1523. ' SHelpVerbose = '#039'Be verbose when working.'#039';'#013#010+
  1524. ' SHelpInstExamples = '#039'Install the example-sources.'#039';'#013#010+
  1525. ' SHelpIgnoreInvOpt = '#039'Ignore further invalid options.'#039';'#013+
  1526. #010+
  1527. ' sHel','pFpdocOutputDir = '#039'Use indicated directory as fpdoc output'+
  1528. ' folder.'#039';'#013#010+
  1529. ' sHelpUseEnvironment = '#039'Use environment to pass options to compil'+
  1530. 'er.'#039';'#013#010+
  1531. ' SHelpUseBuildUnit = '#039'Compile package in Build-unit mode.'#039';'+
  1532. #013#010+
  1533. #013#010+
  1534. #013#010+
  1535. 'Const'#013#010+
  1536. ' // Keys for Defaults',' file. Do not localize.'#013#010+
  1537. ' KeyCompiler = '#039'Compiler'#039';'#013#010+
  1538. ' KeyArchive = '#039'Archive'#039';'#013#010+
  1539. ' KeyCopy = '#039'Copy'#039';'#013#010+
  1540. ' KeyMkDir = '#039'MkDir'#039';'#013#010+
  1541. ' KeyMove = '#039'Move'#039';'#013#010+
  1542. ' KeyRemove = '#039'Remove'#039';'#013#010+
  1543. ' KeyRemoveDir= '#039'RemoveDir'#039';'#013#010+
  1544. ' KeyRemoveTree= '#039'RemoveT','ree'#039';'#013#010+
  1545. ' KeyOptions = '#039'Options'#039';'#013#010+
  1546. ' KeyCPU = '#039'CPU'#039';'#013#010+
  1547. ' KeyOS = '#039'OS'#039';'#013#010+
  1548. ' KeyMode = '#039'Mode'#039';'#013#010+
  1549. ' KeyPrefix = '#039'Prefix'#039';'#013#010+
  1550. ' KeyTarget = '#039'Target'#039';'#013#010+
  1551. ' KeyNoFPCCfg = '#039'NoFPCCfg'#039';'#013#010+
  1552. ' KeyUseEnv = '#039'UseEnv'#039';'#013#010+
  1553. ' KeyLocalUnitDir ',' = '#039'LocalUnitDir'#039';'#013#010+
  1554. ' KeyGlobalUnitDir = '#039'GlobalUnitDir'#039';'#013#010+
  1555. ' KeyBaseInstallDir = '#039'BaseInstallDir'#039';'#013#010+
  1556. ' KeyUnitInstallDir = '#039'UnitInstallDir'#039';'#013#010+
  1557. ' KeyBinInstallDir = '#039'BinInstallDir'#039';'#013#010+
  1558. ' KeyDocInstallDir = '#039'DocInstallDir'#039';',#013#010+
  1559. ' KeyExamplesInstallDir = '#039'ExamplesInstallDir'#039';'#013#010+
  1560. ' KeyInstallExamples = '#039'InstallExamples'#039';'#013#010+
  1561. ' // Keys for unit config'#013#010+
  1562. ' KeyName = '#039'Name'#039';'#013#010+
  1563. ' KeyVersion = '#039'Version'#039';'#013#010+
  1564. ' KeyChecksum = '#039'Checksum'#039';'#013#010+
  1565. ' KeyNeedLibC = '#039'NeedLibC'#039';'#013#010+
  1566. ' Key','Depends = '#039'Depends'#039';'#013#010+
  1567. ' KeyAddIn = '#039'FPMakeAddIn'#039';'#013#010+
  1568. ' KeySourcePath = '#039'SourcePath'#039';'#013#010+
  1569. ' KeyFPMakeOptions = '#039'FPMakeOptions'#039';'#013#010+
  1570. #013#010+
  1571. '{*********************************************************************'+
  1572. '*******'#013#010+
  1573. ' ','Helpers'#013#010+
  1574. '**********************************************************************'+
  1575. '******}'#013#010+
  1576. #013#010+
  1577. '{$ifdef HAS_UNIT_PROCESS}'#013#010+
  1578. 'function ExecuteFPC(Verbose: boolean; const Path: string; const ComLin'+
  1579. 'e: string; const Env: TStrings; ConsoleOutput: TMemor','yStream): integ'+
  1580. 'er;'#013#010+
  1581. 'var'#013#010+
  1582. ' P: TProcess;'#013#010+
  1583. ' BytesRead: longint;'#013#010+
  1584. #013#010+
  1585. ' function ReadFromStream: longint;'#013#010+
  1586. #013#010+
  1587. ' const'#013#010+
  1588. ' READ_BYTES = 2048;'#013#010+
  1589. #013#010+
  1590. ' type'#013#010+
  1591. ' TMessages = (mCompiling, mLinking);'#013#010+
  1592. #013#010+
  1593. ' var'#013#010+
  1594. ' //ifdef the MsgNum so it contains the ','correct message numbers fo'+
  1595. 'r each compiler version.'#013#010+
  1596. ' MsgNum : array [TMessages] of integer = (3104, 9015);'#013#010+
  1597. #013#010+
  1598. ' n: longint;'#013#010+
  1599. ' BuffPos: longint;'#013#010+
  1600. ' sLine: string;'#013#010+
  1601. ' ch: char;'#013#010+
  1602. ' msg: TMessages;'#013#010+
  1603. ' ipos: integer;'#013#010+
  1604. ' snum: s','tring;'#013#010+
  1605. ' begin'#013#010+
  1606. ' // make sure we have room'#013#010+
  1607. ' ConsoleOutput.SetSize(BytesRead + READ_BYTES);'#013#010+
  1608. #013#010+
  1609. ' // try reading it'#013#010+
  1610. ' n := P.Output.Read((ConsoleOutput.Memory + BytesRead)^, READ_BYTES'+
  1611. ');'#013#010+
  1612. ' if n > 0 then'#013#010+
  1613. ' begin'#013#010+
  1614. ' Inc(B','ytesRead, n);'#013#010+
  1615. #013#010+
  1616. ' sLine := '#039#039';'#013#010+
  1617. ' BuffPos := ConsoleOutput.Position;'#013#010+
  1618. #013#010+
  1619. ' //read lines from the stream'#013#010+
  1620. ' repeat'#013#010+
  1621. ' ConsoleOutput.Read(ch,1);'#013#010+
  1622. #013#010+
  1623. ' if ch in [#10, #13] then'#013#010+
  1624. ' begin'#013#010+
  1625. ' if Verbose th','en'#013#010+
  1626. ' writeln(sLine)'#013#010+
  1627. ' else'#013#010+
  1628. ' begin'#013#010+
  1629. ' for msg := Low(TMessages) to High(TMessages) do'#013#010+
  1630. ' begin'#013#010+
  1631. ' snum := Format('#039'(%d)'#039', [MsgNum[msg]]);'#013#010+
  1632. ' ipos := Pos(snum,',' sLine);'#013#010+
  1633. ' if ipos = 1 then'#013#010+
  1634. ' writeln('#039' '#039', Copy(sLine, ipos + Length('+
  1635. 'snum), Length(sLine) - ipos - Length(snum) + 1));'#013#010+
  1636. ' end;'#013#010+
  1637. ' end;'#013#010+
  1638. #013#010+
  1639. ' sLine := '#039#039';'#013#010+
  1640. ' BuffPos :','= ConsoleOutput.Position;'#013#010+
  1641. ' end'#013#010+
  1642. ' else'#013#010+
  1643. ' sLine := sLine + ch;'#013#010+
  1644. #013#010+
  1645. ' until ConsoleOutput.Position >= BytesRead;'#013#010+
  1646. #013#010+
  1647. ' ConsoleOutput.Position := BuffPos;'#013#010+
  1648. ' end'#013#010+
  1649. ' else'#013#010+
  1650. ' begin'#013#010+
  1651. ' // no data, wait 100 m','s'#013#010+
  1652. ' Sleep(100);'#013#010+
  1653. ' end;'#013#010+
  1654. #013#010+
  1655. ' Result := n;'#013#010+
  1656. ' end;'#013#010+
  1657. #013#010+
  1658. 'begin'#013#010+
  1659. ' result := -1;'#013#010+
  1660. ' BytesRead := 0;'#013#010+
  1661. ' P := TProcess.Create(nil);'#013#010+
  1662. ' try'#013#010+
  1663. ' P.CommandLine := Path + '#039' '#039' + ComLine;'#013#010+
  1664. ' if assigned(Env) then'#013#010+
  1665. ' P.Environment.Assign(','Env);'#013#010+
  1666. #013#010+
  1667. ' P.Options := [poUsePipes];'#013#010+
  1668. #013#010+
  1669. ' P.Execute;'#013#010+
  1670. ' while P.Running do'#013#010+
  1671. ' ReadFromStream;'#013#010+
  1672. #013#010+
  1673. ' // read last part'#013#010+
  1674. ' repeat'#013#010+
  1675. ' until ReadFromStream = 0;'#013#010+
  1676. ' ConsoleOutput.SetSize(BytesRead);'#013#010+
  1677. #013#010+
  1678. ' result := P.ExitStatu','s;'#013#010+
  1679. ' finally'#013#010+
  1680. ' P.Free;'#013#010+
  1681. ' end;'#013#010+
  1682. 'end;'#013#010+
  1683. '{$endif HAS_UNIT_PROCESS}'#013#010+
  1684. #013#010+
  1685. 'function IsDirectoryEmpty(const directory : string) : boolean;'#013#010+
  1686. 'var'#013#010+
  1687. ' searchRec: TSearchRec;'#013#010+
  1688. ' SearchResult: longint;'#013#010+
  1689. 'begin'#013#010+
  1690. ' result := true;'#013#010+
  1691. ' SearchResult := Find','First(IncludeTrailingPathDelimiter(directory)+'+
  1692. 'AllFilesMask, faAnyFile+faSymLink, searchRec);'#013#010+
  1693. ' try'#013#010+
  1694. ' while SearchResult=0 do'#013#010+
  1695. ' begin'#013#010+
  1696. ' if (searchRec.Name<>'#039'.'#039') and (searchRec.Name<>'#039'..'#039+
  1697. ') then'#013#010+
  1698. ' begin'#013#010+
  1699. ' ','result := false;'#013#010+
  1700. ' break;'#013#010+
  1701. ' end;'#013#010+
  1702. ' SearchResult := FindNext(searchRec);'#013#010+
  1703. ' end;'#013#010+
  1704. ' finally'#013#010+
  1705. ' FindClose(searchRec);'#013#010+
  1706. ' end;'#013#010+
  1707. 'end;'#013#010+
  1708. #013#010+
  1709. 'function ParsecompilerOutput(M: TMemoryStream; Verbose: boolean): stri'+
  1710. 'ng',';'#013#010+
  1711. 'type'#013#010+
  1712. ' TParseCompilerOutputState = (cosBeginOfLine, cosSearchColon, cosPars'+
  1713. 'eNumber, cosOther);'#013#010+
  1714. #013#010+
  1715. 'var'#013#010+
  1716. ' presult: pchar;'#013#010+
  1717. ' state: TParseCompilerOutputState;'#013#010+
  1718. ' ch: char;'#013#010+
  1719. ' eolchar: char;'#013#010+
  1720. 'begin'#013#010+
  1721. ' m.Seek(0, soBeginning);'#013#010+
  1722. ' setlength(','Result,M.Size);'#013#010+
  1723. #013#010+
  1724. ' if verbose then'#013#010+
  1725. ' begin'#013#010+
  1726. ' m.Read(Result[1],M.Size);'#013#010+
  1727. ' Exit;'#013#010+
  1728. ' end;'#013#010+
  1729. #013#010+
  1730. ' presult := @Result[1];'#013#010+
  1731. ' eolchar := RightStr(LineEnding,1)[1];'#013#010+
  1732. ' m.Seek(0,soBeginning);'#013#010+
  1733. ' state := cosBeginOfLine;'#013#010+
  1734. ' while m.Po','sition<m.Size do'#013#010+
  1735. ' begin'#013#010+
  1736. ' ch := char(m.ReadByte);'#013#010+
  1737. ' case state of'#013#010+
  1738. ' cosBeginOfLine:'#013#010+
  1739. ' begin'#013#010+
  1740. ' if ch='#039'('#039' then'#013#010+
  1741. ' state := cosParseNumber'#013#010+
  1742. ' else if ch='#039' '#039' then'#013#010+
  1743. ' beg','in'#013#010+
  1744. ' presult^ := ch;'#013#010+
  1745. ' inc(presult);'#013#010+
  1746. ' end'#013#010+
  1747. ' else'#013#010+
  1748. ' begin'#013#010+
  1749. ' presult^ := ch;'#013#010+
  1750. ' inc(presult);'#013#010+
  1751. ' state := cosSearchColon;'#013#010+
  1752. ' ',' end;'#013#010+
  1753. ' end;'#013#010+
  1754. ' cosParseNumber:'#013#010+
  1755. ' begin'#013#010+
  1756. ' if ch='#039')'#039' then'#013#010+
  1757. ' begin'#013#010+
  1758. ' state := cosOther;'#013#010+
  1759. ' // Omit the space behind the number'#013#010+
  1760. ' ch := char(m.ReadByte)',';'#013#010+
  1761. ' assert(ch='#039' '#039');'#013#010+
  1762. ' end;'#013#010+
  1763. ' end;'#013#010+
  1764. ' cosOther:'#013#010+
  1765. ' begin'#013#010+
  1766. ' presult^ := ch;'#013#010+
  1767. ' inc(presult);'#013#010+
  1768. ' if ch=eolchar then'#013#010+
  1769. ' state := cosBeginOfLine;'#013#010+
  1770. ' ',' end;'#013#010+
  1771. ' cosSearchColon:'#013#010+
  1772. ' begin'#013#010+
  1773. ' presult^ := ch;'#013#010+
  1774. ' inc(presult);'#013#010+
  1775. ' if (ch='#039':'#039') or (ch=eolchar) then'#013#010+
  1776. ' state := cosBeginOfLine;'#013#010+
  1777. ' end;'#013#010+
  1778. ' end;'#013#010+
  1779. ' end;'#013#010+
  1780. ' setlen','gth(Result,presult-@result[1]);'#013#010+
  1781. 'end;'#013#010+
  1782. #013#010+
  1783. 'Function QuoteXML(S : String) : string;'#013#010+
  1784. #013#010+
  1785. ' Procedure W(Var J : Integer; Var R : String; T : String);'#013#010+
  1786. ' Var'#013#010+
  1787. ' I: integer;'#013#010+
  1788. ' begin'#013#010+
  1789. ' If J+Length(T)>Length(R) then'#013#010+
  1790. ' SetLength(R,J+Length(','T));'#013#010+
  1791. ' For I:=1 to Length(t) do'#013#010+
  1792. ' begin'#013#010+
  1793. ' R[J]:=T[i];'#013#010+
  1794. ' If I<Length(T) then'#013#010+
  1795. ' Inc(J);'#013#010+
  1796. ' end;'#013#010+
  1797. ' end;'#013#010+
  1798. #013#010+
  1799. 'const'#013#010+
  1800. ' QuotStr = '#039'&quot;'#039';'#013#010+
  1801. ' AmpStr = '#039'&amp;'#039';'#013#010+
  1802. ' ltStr = '#039'&lt;'#039';'#013#010+
  1803. ' gtStr = '#039'&gt;'#039';'#013#010+
  1804. 'Var'#013#010+
  1805. ' I,J : Inte','ger;'#013#010+
  1806. 'begin'#013#010+
  1807. ' SetLength(Result,Length(S));'#013#010+
  1808. ' J:=0;'#013#010+
  1809. ' For I:=1 to Length(S) do'#013#010+
  1810. ' begin'#013#010+
  1811. ' Inc(J);'#013#010+
  1812. ' case S[i] of'#013#010+
  1813. ' '#039'"'#039': W(j,Result,QuotStr);'#013#010+
  1814. ' '#039'&'#039': W(J,Result,AmpStr);'#013#010+
  1815. ' '#039'<'#039': W(J,Result,ltStr);'#013#010+
  1816. ' '#039'>'#039': W(J,Resul','t,gtStr);'#013#010+
  1817. ' // Escape whitespace using CharRefs to be consistent with W3 spe'+
  1818. 'c X 3.3.3'#013#010+
  1819. ' #9: w(J,Result,'#039'&#x9;'#039');'#013#010+
  1820. '{ #10: wrtStr('#039'&#xA;'#039');'#013#010+
  1821. ' #13: wrtStr('#039'&#xD;'#039');}'#013#010+
  1822. ' else'#013#010+
  1823. ' Result[J]:=S[i];'#013#010+
  1824. ' end;'#013#010+
  1825. ' If (J=','Length(Result)) and (I<Length(S)) then'#013#010+
  1826. ' SetLength(Result,J+Length(S)-I);'#013#010+
  1827. ' end;'#013#010+
  1828. ' If J<>Length(Result) then'#013#010+
  1829. ' SetLength(Result,J);'#013#010+
  1830. 'end;'#013#010+
  1831. #013#010+
  1832. #013#010+
  1833. 'function maybequoted(const s:string):string;'#013#010+
  1834. 'const'#013#010+
  1835. ' {$IFDEF MSWINDOWS}'#013#010+
  1836. ' FORBID','DEN_CHARS = ['#039'!'#039', '#039'@'#039', '#039'#'#039', '#039'$'+
  1837. #039', '#039'%'#039', '#039'^'#039', '#039'&'#039', '#039'*'#039', '#039'('#039', '+
  1838. #039')'#039','#013#010+
  1839. ' '#039'{'#039', '#039'}'#039', '#039#039#039#039', '#039'`'+
  1840. #039', '#039'~'#039'];'#013#010+
  1841. ' {$ELSE}'#013#010+
  1842. ' FORBIDDEN_CHARS = ['#039'!'#039', '#039'@'#039', '#039'#'#039', '#039'$'#039+
  1843. ', '#039'%'#039', '#039'^'#039', '#039'&'#039', '#039'*'#039', '#039'('#039', '#039+
  1844. ')'#039','#013#010+
  1845. ' '#039'{'#039', '#039'}'#039', '#039#039#039#039', '#039,
  1846. ':'#039', '#039'\'#039', '#039'`'#039', '#039'~'#039'];'#013#010+
  1847. ' {$ENDIF}'#013#010+
  1848. 'var'#013#010+
  1849. ' s1 : string;'#013#010+
  1850. ' i : integer;'#013#010+
  1851. ' quoted : boolean;'#013#010+
  1852. 'begin'#013#010+
  1853. ' quoted:=false;'#013#010+
  1854. ' s1:='#039'"'#039';'#013#010+
  1855. ' for i:=1 to length(s) do'#013#010+
  1856. ' begin'#013#010+
  1857. ' case s[i] of'#013#010+
  1858. ' '#039'"'#039' :'#013#010+
  1859. ' begin'#013#010+
  1860. ' quoted:=true;',#013#010+
  1861. ' s1:=s1+'#039'\"'#039';'#013#010+
  1862. ' end;'#013#010+
  1863. ' '#039' '#039','#013#010+
  1864. ' #128..#255 :'#013#010+
  1865. ' begin'#013#010+
  1866. ' quoted:=true;'#013#010+
  1867. ' s1:=s1+s[i];'#013#010+
  1868. ' end;'#013#010+
  1869. ' else begin'#013#010+
  1870. ' if s[i] in FORBIDDEN_CHARS then'#013#010+
  1871. ' quoted:=Tr','ue;'#013#010+
  1872. ' s1:=s1+s[i];'#013#010+
  1873. ' end;'#013#010+
  1874. ' end;'#013#010+
  1875. ' end;'#013#010+
  1876. ' if quoted then'#013#010+
  1877. ' maybequoted:=s1+'#039'"'#039#013#010+
  1878. ' else'#013#010+
  1879. ' maybequoted:=s;'#013#010+
  1880. 'end;'#013#010+
  1881. #013#010+
  1882. #013#010+
  1883. 'procedure ReadIniFile(Const AFileName: String;L:TStrings);'#013#010+
  1884. 'Var'#013#010+
  1885. ' F : TFileStream;'#013#010+
  1886. ' Line : Str','ing;'#013#010+
  1887. ' I,P,PC : Integer;'#013#010+
  1888. 'begin'#013#010+
  1889. ' F:=TFileStream.Create(AFileName,fmOpenRead);'#013#010+
  1890. ' Try'#013#010+
  1891. ' L.LoadFromStream(F);'#013#010+
  1892. ' // Fix lines.'#013#010+
  1893. ' For I:=L.Count-1 downto 0 do'#013#010+
  1894. ' begin'#013#010+
  1895. ' Line:=L[I];'#013#010+
  1896. ' P:=Pos('#039'='#039',Line);'#013#010+
  1897. ' PC:','=Pos('#039';'#039',Line); // Comment line.'#013#010+
  1898. ' If (P=0) or ((PC<>0) and (PC<P)) then'#013#010+
  1899. ' L.Delete(I)'#013#010+
  1900. ' else'#013#010+
  1901. ' L[i]:=Trim(System.Copy(Line,1,P-1)+'#039'='#039'+Trim(System.C'+
  1902. 'opy(Line,P+1,Length(Line)-P)));'#013#010+
  1903. ' end;'#013#010+
  1904. ' Finally'#013#010+
  1905. ' ',' F.Free;'#013#010+
  1906. ' end;'#013#010+
  1907. 'end;'#013#010+
  1908. #013#010+
  1909. #013#010+
  1910. '// Callback for Sysutils getapplicationname.'#013#010+
  1911. 'Function GetFPMakeName : String;'#013#010+
  1912. #013#010+
  1913. 'begin'#013#010+
  1914. ' Result:='#039'fpmake'#039';'#013#010+
  1915. 'end;'#013#010+
  1916. #013#010+
  1917. #013#010+
  1918. 'Function CurrentOS : String;'#013#010+
  1919. #013#010+
  1920. 'begin'#013#010+
  1921. ' Result:=OSToString(Defaults.OS);'#013#010+
  1922. 'end;'#013#010+
  1923. #013#010+
  1924. 'Function ','CurrentCPU : String;'#013#010+
  1925. #013#010+
  1926. 'begin'#013#010+
  1927. ' Result:=CPUToString(Defaults.CPU);'#013#010+
  1928. 'end;'#013#010+
  1929. #013#010+
  1930. 'Function OSToString(OS: TOS) : String;'#013#010+
  1931. #013#010+
  1932. 'begin'#013#010+
  1933. ' Result:=LowerCase(GetenumName(TypeInfo(TOS),Ord(OS)));'#013#010+
  1934. 'end;'#013#010+
  1935. #013#010+
  1936. 'Function OSesToString(OSes: TOSes) : String;'#013#010+
  1937. #013#010,
  1938. 'begin'#013#010+
  1939. ' Result:=LowerCase(SetToString(PtypeInfo(TypeInfo(TOSes)),Integer(OSe'+
  1940. 's),False));'#013#010+
  1941. 'end;'#013#010+
  1942. #013#010+
  1943. 'Function CPUToString(CPU: TCPU) : String;'#013#010+
  1944. #013#010+
  1945. 'begin'#013#010+
  1946. ' Result:=LowerCase(GetenumName(TypeInfo(TCPU),Ord(CPU)));'#013#010+
  1947. 'end;'#013#010+
  1948. #013#010+
  1949. 'Function CPUSToString(','CPUS: TCPUS) : String;'#013#010+
  1950. #013#010+
  1951. 'begin'#013#010+
  1952. ' Result:=LowerCase(SetToString(PTypeInfo(TypeInfo(TCPUS)),Integer(CPU'+
  1953. 'S),False));'#013#010+
  1954. 'end;'#013#010+
  1955. #013#010+
  1956. 'Function StringToOS(const S : String) : TOS;'#013#010+
  1957. #013#010+
  1958. 'Var'#013#010+
  1959. ' I : Integer;'#013#010+
  1960. #013#010+
  1961. 'begin'#013#010+
  1962. ' I:=GetEnumValue(TypeInfo(TOS),S);'#013#010+
  1963. ' ',' if (I=-1) then'#013#010+
  1964. ' Raise EInstallerError.CreateFmt(SErrInvalidOS,[S]);'#013#010+
  1965. ' Result:=TOS(I);'#013#010+
  1966. 'end;'#013#010+
  1967. #013#010+
  1968. #013#010+
  1969. 'Function OSesToString(const S : String) : TOSes;'#013#010+
  1970. #013#010+
  1971. 'begin'#013#010+
  1972. ' Result:=TOSes(StringToSet(PTypeInfo(TypeInfo(TOSes)),S));'#013#010+
  1973. 'end;'#013#010+
  1974. #013#010+
  1975. 'Function ','StringToCPU(const S : String) : TCPU;'#013#010+
  1976. #013#010+
  1977. 'Var'#013#010+
  1978. ' I : Integer;'#013#010+
  1979. #013#010+
  1980. 'begin'#013#010+
  1981. ' I:=GetEnumValue(TypeInfo(TCPU),S);'#013#010+
  1982. ' if (I=-1) then'#013#010+
  1983. ' Raise EInstallerError.CreateFmt(SErrInvalidCPU,[S]);'#013#010+
  1984. ' Result:=TCPU(I);'#013#010+
  1985. 'end;'#013#010+
  1986. #013#010+
  1987. 'Function StringToCPUS(const',' S : String) : TCPUS;'#013#010+
  1988. #013#010+
  1989. 'begin'#013#010+
  1990. ' Result:=TCPUS(StringToSet(PTypeInfo(TypeInfo(TCPUS)),S));'#013#010+
  1991. 'end;'#013#010+
  1992. #013#010+
  1993. 'Function ModeToString(Mode: TCompilerMode) : String;'#013#010+
  1994. #013#010+
  1995. 'begin'#013#010+
  1996. ' Result:=LowerCase(GetenumName(TypeInfo(TCompilerMode),Ord(Mode)));'#013+
  1997. #010+
  1998. ' Dele','te(Result,1,2);'#013#010+
  1999. 'end;'#013#010+
  2000. #013#010+
  2001. 'Function StringToMode(const S : String) : TCompilerMode;'#013#010+
  2002. #013#010+
  2003. 'Var'#013#010+
  2004. ' I : Integer;'#013#010+
  2005. #013#010+
  2006. 'begin'#013#010+
  2007. ' I:=GetEnumValue(TypeInfo(TCompilerMode),S);'#013#010+
  2008. ' if (I=-1) then'#013#010+
  2009. ' Raise EInstallerError.CreateFmt(SErrInvalidMode,[S]);'#013#010+
  2010. ' ',' Result:=TCompilerMode(I);'#013#010+
  2011. 'end;'#013#010+
  2012. #013#010+
  2013. #013#010+
  2014. 'Function MakeTargetString(CPU : TCPU;OS: TOS) : String;'#013#010+
  2015. #013#010+
  2016. 'begin'#013#010+
  2017. ' if OS in AllLimit83fsOses then'#013#010+
  2018. ' Result := OSToString(OS)'#013#010+
  2019. ' else'#013#010+
  2020. ' Result:=CPUToString(CPU)+'#039'-'#039'+OSToString(OS);'#013#010+
  2021. 'end;'#013#010+
  2022. #013#010+
  2023. 'Proced','ure StringToCPUOS(const S : String; Var CPU : TCPU; Var OS: TO'+
  2024. 'S);'#013#010+
  2025. #013#010+
  2026. 'Var'#013#010+
  2027. ' P : integer;'#013#010+
  2028. #013#010+
  2029. 'begin'#013#010+
  2030. ' P:=Pos('#039'-'#039',S);'#013#010+
  2031. ' If (P=0) then'#013#010+
  2032. ' Raise EInstallerError.CreateFmt(SErrInvalidTarget,[S]);'#013#010+
  2033. ' CPU:=StringToCPU(Copy(S,1,P-1));'#013#010+
  2034. ' OS:=Str','ingToOs(Copy(S,P+1,Length(S)-P));'#013#010+
  2035. 'end;'#013#010+
  2036. #013#010+
  2037. #013#010+
  2038. 'Procedure ResolveDependencies(L : TDependencies; P : TNamedCollection)'+
  2039. ';'#013#010+
  2040. 'Var'#013#010+
  2041. ' I,J : Integer;'#013#010+
  2042. ' C : TDependency;'#013#010+
  2043. 'begin'#013#010+
  2044. ' If Assigned(L) then'#013#010+
  2045. ' For I:=0 to L.Count-1 do'#013#010+
  2046. ' begin'#013#010+
  2047. ' ',' C:=L[i];'#013#010+
  2048. ' if C.DependencyType in [depPackage,depUnit] then'#013#010+
  2049. ' begin'#013#010+
  2050. ' J:=P.IndexOfName(C.Value);'#013#010+
  2051. ' If J<>-1 then'#013#010+
  2052. ' C.Target:=P.Items[J];'#013#010+
  2053. ' end;'#013#010+
  2054. ' end;'#013#010+
  2055. 'end;'#013#010+
  2056. #013#010+
  2057. #013#010+
  2058. 'function Ad','dConditionalStrings(Dest : TStrings; Src : TConditionalSt'+
  2059. 'rings;ACPU:TCPU;AOS:TOS; Const APrefix : String='#039#039') : Integer ;'#013+
  2060. #010+
  2061. 'Var'#013#010+
  2062. ' I : Integer;'#013#010+
  2063. ' C : TConditionalString;'#013#010+
  2064. ' S : String;'#013#010+
  2065. 'begin'#013#010+
  2066. ' Result:=0;'#013#010+
  2067. ' Dictionary.AddVariable('#039'CPU'#039',CPU','ToString(ACPU));'#013#010+
  2068. ' Dictionary.AddVariable('#039'OS'#039',OSToString(AOS));'#013#010+
  2069. ' For I:=0 to Src.Count-1 do'#013#010+
  2070. ' begin'#013#010+
  2071. ' C:=Src[I];'#013#010+
  2072. ' if (ACPU in C.CPUs) and (AOS in C.OSes) then'#013#010+
  2073. ' begin'#013#010+
  2074. ' If (APrefix<>'#039#039') then'#013#010+
  2075. ' S:','=APrefix+C.Value'#013#010+
  2076. ' else'#013#010+
  2077. ' S:=C.Value;'#013#010+
  2078. ' Dest.Add(Dictionary.ReplaceStrings(S));'#013#010+
  2079. ' Inc(Result);'#013#010+
  2080. ' end;'#013#010+
  2081. ' end;'#013#010+
  2082. 'end;'#013#010+
  2083. #013#010+
  2084. #013#010+
  2085. 'function FileListToString(List : TStrings; const APrefix : String) : S'+
  2086. 'tr','ing;'#013#010+
  2087. 'Var'#013#010+
  2088. ' I : integer;'#013#010+
  2089. ' S : String;'#013#010+
  2090. 'begin'#013#010+
  2091. ' Result:='#039#039';'#013#010+
  2092. ' For I:=0 to List.Count-1 do'#013#010+
  2093. ' begin'#013#010+
  2094. ' If (I>0) then'#013#010+
  2095. ' Result:=Result+'#039' '#039';'#013#010+
  2096. ' S:=APrefix+List[i];'#013#010+
  2097. ' If (Pos('#039' '#039',S)<>0) then'#013#010+
  2098. ' S:='#039'"'#039'+S+'#039'"'#039';'#013#010+
  2099. ' ',' Result:=Result+S;'#013#010+
  2100. ' end;'#013#010+
  2101. 'end;'#013#010+
  2102. #013#010+
  2103. #013#010+
  2104. 'function FixPath (const APath : String) : String;'#013#010+
  2105. 'Var'#013#010+
  2106. ' P : PChar;'#013#010+
  2107. 'begin'#013#010+
  2108. ' Result:=APath;'#013#010+
  2109. ' If (result<>'#039#039') then'#013#010+
  2110. ' begin'#013#010+
  2111. ' UniqueString(Result);'#013#010+
  2112. ' P:=PChar(Result);'#013#010+
  2113. ' While (P','^<>#0) do'#013#010+
  2114. ' begin'#013#010+
  2115. ' If P^ in ['#039'/'#039','#039'\'#039'] then'#013#010+
  2116. ' P^:=PathDelim;'#013#010+
  2117. ' Inc(P);'#013#010+
  2118. ' end;'#013#010+
  2119. ' end;'#013#010+
  2120. 'end;'#013#010+
  2121. #013#010+
  2122. 'function IsRelativePath(const APath: String): boolean;'#013#010+
  2123. 'begin'#013#010+
  2124. ' if APath='#039#039' then'#013#010+
  2125. ' result := tru','e'#013#010+
  2126. '{$ifdef unix}'#013#010+
  2127. ' else if APath[1] in AllowDirectorySeparators then'#013#010+
  2128. ' result := false'#013#010+
  2129. '{$else}'#013#010+
  2130. ' else if ExtractFileDrive(APath)<>'#039#039' then'#013#010+
  2131. ' result := false'#013#010+
  2132. '{$endif}'#013#010+
  2133. ' else'#013#010+
  2134. ' result := true;'#013#010+
  2135. 'end;'#013#010+
  2136. #013#010+
  2137. 'procedure ChangeDir(const A','Path : String);'#013#010+
  2138. 'begin'#013#010+
  2139. ' if Not SetCurrentDir(APath) then'#013#010+
  2140. ' Raise EInstallerError.CreateFmt(SErrChangeDirFailed,[APath]);'#013#010+
  2141. 'end;'#013#010+
  2142. #013#010+
  2143. #013#010+
  2144. 'procedure SearchFiles(const AFileName: string; Recursive: boolean; var'+
  2145. ' List: TStrings);'#013#010+
  2146. #013#010+
  2147. ' procedure ','AddRecursiveFiles(const SearchDir, FileMask: string; Rec'+
  2148. 'ursive: boolean);'#013#010+
  2149. ' const'#013#010+
  2150. ' IgnoreCase = {$ifdef UNIX}False{$else}True{$endif};'#013#010+
  2151. ' var'#013#010+
  2152. ' Info : TSearchRec;'#013#010+
  2153. ' begin'#013#010+
  2154. ' if FindFirst(SearchDir+'#039'*'#039',faAnyFile and faDirectory,In','f'+
  2155. 'o)=0 then'#013#010+
  2156. ' begin'#013#010+
  2157. ' repeat'#013#010+
  2158. ' if ((Info.Attr and faDirectory) = faDirectory) and (Info.Nam'+
  2159. 'e <> '#039'.'#039') and (Info.Name <> '#039'..'#039') and (Recursive) then'+
  2160. #013#010+
  2161. ' AddRecursiveFiles(SearchDir + Info.Name + PathDelim, FileM'+
  2162. 'ask, Re','cursive);'#013#010+
  2163. ' if ((Info.Attr and faDirectory) <> faDirectory) and IsWild(I'+
  2164. 'nfo.Name, FileMask, IgnoreCase) then'#013#010+
  2165. ' List.Add(SearchDir + Info.Name);'#013#010+
  2166. ' until FindNext(Info)<>0;'#013#010+
  2167. ' end;'#013#010+
  2168. ' FindClose(Info);'#013#010+
  2169. ' end;'#013#010+
  2170. #013#010+
  2171. 'v','ar'#013#010+
  2172. ' CurrDir,'#013#010+
  2173. ' BasePath: string;'#013#010+
  2174. ' i: integer;'#013#010+
  2175. 'begin'#013#010+
  2176. ' BasePath := ExtractFilePath(ExpandFileName(AFileName));'#013#010+
  2177. ' AddRecursiveFiles(BasePath, ExtractFileName(AFileName), Recursive);'#013+
  2178. #010+
  2179. #013#010+
  2180. ' CurrDir:=GetCurrentDir;'#013#010+
  2181. ' for i := 0 to Pred(L','ist.Count) do'#013#010+
  2182. ' List[i] := ExtractRelativepath(IncludeTrailingPathDelimiter(CurrDi'+
  2183. 'r), List[i]);'#013#010+
  2184. 'end;'#013#010+
  2185. #013#010+
  2186. 'Const'#013#010+
  2187. ' WhiteSpace = [#9,#10,#13,'#039' '#039'];'#013#010+
  2188. ' QuoteChars = ['#039#039#039#039','#039'"'#039'];'#013#010+
  2189. #013#010+
  2190. 'procedure SplitCommand(const Cmd : String; var Exe, Options :',' String'+
  2191. ');'#013#010+
  2192. #013#010+
  2193. 'Var'#013#010+
  2194. ' I : Integer;'#013#010+
  2195. ' InQuote : Boolean;'#013#010+
  2196. ' LastQuote : Char;'#013#010+
  2197. ' S : String;'#013#010+
  2198. #013#010+
  2199. 'begin'#013#010+
  2200. ' S:=Trim(Cmd);'#013#010+
  2201. ' InQuote:=False;'#013#010+
  2202. ' LastQuote:=#0;'#013#010+
  2203. ' I:=1;'#013#010+
  2204. ' While (I<=Length(S)) and (Inquote or not (S[I] in whiteSpace)) do'#013+
  2205. #010+
  2206. ' beg','in'#013#010+
  2207. ' If S[i] in QuoteChars then'#013#010+
  2208. ' begin'#013#010+
  2209. ' InQuote:=Not (S[i]=LastQuote);'#013#010+
  2210. ' If InQuote then'#013#010+
  2211. ' LastQuote:=S[i]'#013#010+
  2212. ' else'#013#010+
  2213. ' LastQuote:=#0;'#013#010+
  2214. ' end;'#013#010+
  2215. ' Inc(I);'#013#010+
  2216. ' end;'#013#010+
  2217. ' Exe:=Copy(S,1,I-1);'#013#010+
  2218. ' Delete','(S,1,I);'#013#010+
  2219. ' Options:=Trim(S);'#013#010+
  2220. 'end;'#013#010+
  2221. #013#010+
  2222. 'procedure AddCustomFpmakeCommandlineOption(const ACommandLineOption, H'+
  2223. 'elpMessage : string);'#013#010+
  2224. 'begin'#013#010+
  2225. ' if not assigned(CustomFpmakeCommandlineOptions) then'#013#010+
  2226. ' CustomFpmakeCommandlineOptions := TString','List.Create;'#013#010+
  2227. ' CustomFpmakeCommandlineOptions.Values[ACommandLineOption]:=HelpMessa'+
  2228. 'ge;'#013#010+
  2229. 'end;'#013#010+
  2230. #013#010+
  2231. 'function GetCustomFpmakeCommandlineOptionValue(const ACommandLineOptio'+
  2232. 'n: string): string;'#013#010+
  2233. 'begin'#013#010+
  2234. ' if not assigned(CustomFpMakeCommandlineValu','es) then'#013#010+
  2235. ' result := '#039#039#013#010+
  2236. ' else'#013#010+
  2237. ' result := CustomFpMakeCommandlineValues.Values[ACommandLineOption]'+
  2238. ';'#013#010+
  2239. 'end;'#013#010+
  2240. #013#010+
  2241. 'Function OptionListToString(L : TStrings) : String;'#013#010+
  2242. #013#010+
  2243. 'var'#013#010+
  2244. ' I : Integer;'#013#010+
  2245. ' S : String;'#013#010+
  2246. #013#010+
  2247. 'begin'#013#010+
  2248. ' Result:='#039#039';'#013#010+
  2249. ' For I:','=0 to L.Count-1 do'#013#010+
  2250. ' begin'#013#010+
  2251. ' If (Result<>'#039#039') then'#013#010+
  2252. ' Result:=Result+'#039' '#039';'#013#010+
  2253. ' S:=L[I];'#013#010+
  2254. ' If (Pos('#039' '#039',S)<>0) or (S='#039#039') then'#013#010+
  2255. ' Result:='#039'"'#039'+S+'#039'"'#039';'#013#010+
  2256. ' end;'#013#010+
  2257. 'end;'#013#010+
  2258. #013#010+
  2259. 'Function OptionsToStringList(S : String) : TStrings;'#013#010+
  2260. #013#010+
  2261. 'Var'#013,#010+
  2262. ' P : Integer;'#013#010+
  2263. #013#010+
  2264. 'begin'#013#010+
  2265. ' Result:=Nil;'#013#010+
  2266. ' If (S='#039#039') then'#013#010+
  2267. ' Exit;'#013#010+
  2268. ' Result:=TStringList.Create;'#013#010+
  2269. ' Repeat'#013#010+
  2270. ' P:=Pos('#039' '#039',S);'#013#010+
  2271. ' If P=0 then'#013#010+
  2272. ' P:=Length(S)+1;'#013#010+
  2273. ' Result.Add(Copy(S,1,P-1));'#013#010+
  2274. ' Delete(S,1,P);'#013#010+
  2275. ' S:=Trim(S);'#013,#010+
  2276. ' Until Length(S)=0;'#013#010+
  2277. ' If Result.Count=0 then'#013#010+
  2278. ' FreeAndNil(Result);'#013#010+
  2279. 'end;'#013#010+
  2280. #013#010+
  2281. #013#010+
  2282. '{$ifdef HAS_UNIT_PROCESS}'#013#010+
  2283. 'function GetCompilerInfo(const ACompiler,AOptions:string):string;'#013#010+
  2284. 'const'#013#010+
  2285. ' BufSize = 1024;'#013#010+
  2286. 'var'#013#010+
  2287. ' S: TProcess;'#013#010+
  2288. ' Buf: array [0','..BufSize - 1] of char;'#013#010+
  2289. ' Count: longint;'#013#010+
  2290. 'begin'#013#010+
  2291. ' S:=TProcess.Create(Nil);'#013#010+
  2292. ' S.Commandline:=ACompiler+'#039' '#039'+AOptions;'#013#010+
  2293. ' S.Options:=[poUsePipes];'#013#010+
  2294. ' S.execute;'#013#010+
  2295. ' Count:=s.output.read(buf,BufSize);'#013#010+
  2296. ' S.Free;'#013#010+
  2297. ' SetLength(Result,Count);'#013#010,
  2298. ' Move(Buf,Result[1],Count);'#013#010+
  2299. 'end;'#013#010+
  2300. '{$endif HAS_UNIT_PROCESS}'#013#010+
  2301. #013#010+
  2302. #013#010+
  2303. '{*********************************************************************'+
  2304. '*******'#013#010+
  2305. ' TUnsortedDuplicatesStringList'#013#010+
  2306. '************************************','********************************'+
  2307. '********}'#013#010+
  2308. #013#010+
  2309. 'function TUnsortedDuplicatesStringList.Add(const S: string): Integer;'#013+
  2310. #010+
  2311. #013#010+
  2312. 'begin'#013#010+
  2313. ' result := IndexOf(S);'#013#010+
  2314. ' If result > -1 then'#013#010+
  2315. ' Case DUplicates of'#013#010+
  2316. ' DupIgnore : Exit;'#013#010+
  2317. ' DupError : E','rror(SDuplicateString,0)'#013#010+
  2318. ' end;'#013#010+
  2319. ' inherited Add(S);'#013#010+
  2320. 'end;'#013#010+
  2321. #013#010+
  2322. '{*********************************************************************'+
  2323. '*******'#013#010+
  2324. ' TNamedItem'#013#010+
  2325. '****************************************************','****************'+
  2326. '********}'#013#010+
  2327. #013#010+
  2328. 'procedure TNamedItem.SetName(const AValue: String);'#013#010+
  2329. #013#010+
  2330. 'begin'#013#010+
  2331. ' if FName=AValue then exit;'#013#010+
  2332. ' With TNamedCollection(Collection) do'#013#010+
  2333. ' If UniqueNames then'#013#010+
  2334. ' If (IndexOfName(AVAlue)<>-1) then'#013#010+
  2335. ' Raise',' ECollectionError.CreateFmt(SErrNameExists,[AValue]);'#013+
  2336. #010+
  2337. ' FName:=AValue;'#013#010+
  2338. 'end;'#013#010+
  2339. #013#010+
  2340. #013#010+
  2341. '{*********************************************************************'+
  2342. '*******'#013#010+
  2343. ' TNamedCollection'#013#010+
  2344. '****************************','****************************************'+
  2345. '********}'#013#010+
  2346. #013#010+
  2347. 'function TNamedCollection.IndexOfName(const AName: String): Integer;'#013+
  2348. #010+
  2349. #013#010+
  2350. 'begin'#013#010+
  2351. ' Result:=Count-1;'#013#010+
  2352. ' While (Result>=0) and (CompareText(TNamedItem(Items[Result]).FName,A'+
  2353. 'Name)<>0) do'#013#010+
  2354. ' ','Dec(Result);'#013#010+
  2355. 'end;'#013#010+
  2356. #013#010+
  2357. 'function TNamedCollection.ItemByName(const AName: String): TNamedItem;'+
  2358. #013#010+
  2359. #013#010+
  2360. 'Var'#013#010+
  2361. ' I : Integer;'#013#010+
  2362. #013#010+
  2363. 'begin'#013#010+
  2364. ' I:=IndexOfName(AName);'#013#010+
  2365. ' If (I=-1) Then'#013#010+
  2366. ' Raise ECollectionError.CreateFmt(SErrNoSuchName,[AName]);'#013#010+
  2367. ' Resul','t:=TNamedItem(Items[i]);'#013#010+
  2368. 'end;'#013#010+
  2369. #013#010+
  2370. #013#010+
  2371. '{*********************************************************************'+
  2372. '*******'#013#010+
  2373. ' TNamedItemList'#013#010+
  2374. '**********************************************************************'+
  2375. '******}'#013#010+
  2376. #013,#010+
  2377. 'function TNamedItemList.GetNamedItem(Index : Integer): TNamedItem;'#013+
  2378. #010+
  2379. 'begin'#013#010+
  2380. ' Result:=TNamedItem(Items[Index]);'#013#010+
  2381. 'end;'#013#010+
  2382. #013#010+
  2383. #013#010+
  2384. 'procedure TNamedItemList.SetNamedItem(Index : Integer; const AValue: T'+
  2385. 'NamedItem);'#013#010+
  2386. 'begin'#013#010+
  2387. ' Items[Index]:=AValue;'#013#010+
  2388. 'en','d;'#013#010+
  2389. #013#010+
  2390. #013#010+
  2391. 'function TNamedItemList.IndexOfName(const AName: String): Integer;'#013+
  2392. #010+
  2393. 'begin'#013#010+
  2394. ' Result:=Count-1;'#013#010+
  2395. ' While (Result>=0) and (CompareText(GetNamedItem(Result).Name,AName)<'+
  2396. '>0) do'#013#010+
  2397. ' Dec(Result);'#013#010+
  2398. 'end;'#013#010+
  2399. #013#010+
  2400. #013#010+
  2401. 'function TNamedItemList.ItemByN','ame(const ANAme: String): TNamedItem;'+
  2402. #013#010+
  2403. 'Var'#013#010+
  2404. ' I : Integer;'#013#010+
  2405. 'begin'#013#010+
  2406. ' I:=IndexOfName(AName);'#013#010+
  2407. ' If (I=-1) Then'#013#010+
  2408. ' Raise ECollectionError.CreateFmt(SErrNoSuchName,[AName]);'#013#010+
  2409. ' Result:=TNamedItem(Items[i]);'#013#010+
  2410. 'end;'#013#010+
  2411. #013#010+
  2412. #013#010+
  2413. '{**********************','*********************************************'+
  2414. '*********'#013#010+
  2415. ' TTargets'#013#010+
  2416. '**********************************************************************'+
  2417. '******}'#013#010+
  2418. #013#010+
  2419. 'function TTargets.GetTargetItem(Index : Integer): TTarget;'#013#010+
  2420. 'b','egin'#013#010+
  2421. ' Result:=TTarget(Items[Index]);'#013#010+
  2422. 'end;'#013#010+
  2423. #013#010+
  2424. #013#010+
  2425. 'function TTargets.GetTarget(const AName : String): TTarget;'#013#010+
  2426. 'begin'#013#010+
  2427. ' Result:=TTarget(ItemByName(AName));'#013#010+
  2428. 'end;'#013#010+
  2429. #013#010+
  2430. #013#010+
  2431. 'procedure TTargets.SetTargetItem(Index : Integer; const AValue: TTarge'+
  2432. 't);',#013#010+
  2433. 'begin'#013#010+
  2434. ' Items[Index]:=AValue;'#013#010+
  2435. 'end;'#013#010+
  2436. #013#010+
  2437. 'function TTargets.AddFPDoc(const AUnitName, AXMLName: String): TTarget'+
  2438. ';'#013#010+
  2439. 'begin'#013#010+
  2440. ' Result:=Add as TTarget;'#013#010+
  2441. ' Result.Name:=AUnitName;'#013#010+
  2442. ' Result.XML:=AXMLName;'#013#010+
  2443. ' Result.TargetType:=ttFPDoc;'#013#010+
  2444. 'end;'#013#010+
  2445. #013#010,
  2446. 'Function TTargets.AddUnit(Const AUnitName : String) : TTarget;'#013#010+
  2447. 'begin'#013#010+
  2448. ' Result:=AddUnit(AUnitName,AllCPUs,AllOSes);'#013#010+
  2449. 'end;'#013#010+
  2450. #013#010+
  2451. #013#010+
  2452. 'Function TTargets.AddUnit(Const AUnitName : String;const OSes:TOSes) :'+
  2453. ' TTarget;'#013#010+
  2454. 'begin'#013#010+
  2455. ' Result:=AddUnit(AUnitN','ame,AllCPUs,OSes);'#013#010+
  2456. 'end;'#013#010+
  2457. #013#010+
  2458. #013#010+
  2459. '{$ifdef cpu_only_overloads}'#013#010+
  2460. 'Function TTargets.AddUnit(Const AUnitName : String;const CPUs:TCPUs) :'+
  2461. ' TTarget;'#013#010+
  2462. 'begin'#013#010+
  2463. ' Result:=AddUnit(AUnitName,CPUs,AllOSes);'#013#010+
  2464. 'end;'#013#010+
  2465. '{$endif cpu_only_overloads}'#013#010+
  2466. #013#010+
  2467. #013#010+
  2468. 'Function T','Targets.AddUnit(Const AUnitName : String;const CPUs:TCPUs;'+
  2469. 'const OSes:TOSes) : TTarget;'#013#010+
  2470. 'begin'#013#010+
  2471. ' Result:=Add as TTarget;'#013#010+
  2472. ' Result.Name:=AUnitName;'#013#010+
  2473. ' Result.TargetType:=TTUnit;'#013#010+
  2474. ' Result.CPUs:=CPUs;'#013#010+
  2475. ' Result.OSes:=OSes;'#013#010+
  2476. 'end;'#013#010+
  2477. #013#010+
  2478. #013#010+
  2479. 'Functio','n TTargets.AddImplicitUnit(Const AUnitName : String;InstallUn'+
  2480. 'it:boolean=true) : TTarget;'#013#010+
  2481. 'begin'#013#010+
  2482. ' Result:=AddImplicitUnit(AUnitName,AllCPUs,AllOSes,InstallUnit);'#013#010+
  2483. 'end;'#013#010+
  2484. #013#010+
  2485. #013#010+
  2486. 'Function TTargets.AddImplicitUnit(Const AUnitName : String;const O','Se'+
  2487. 's:TOSes;InstallUnit:boolean=true) : TTarget;'#013#010+
  2488. 'begin'#013#010+
  2489. ' Result:=AddImplicitUnit(AUnitName,AllCPUs,OSes,InstallUnit);'#013#010+
  2490. 'end;'#013#010+
  2491. #013#010+
  2492. #013#010+
  2493. 'Function TTargets.AddImplicitUnit(Const AUnitName : String;const CPUs:'+
  2494. 'TCPUs;InstallUnit:boolean=true) : TTarget',';'#013#010+
  2495. 'begin'#013#010+
  2496. ' Result:=AddImplicitUnit(AUnitName,CPUs,AllOSes,InstallUnit);'#013#010+
  2497. 'end;'#013#010+
  2498. #013#010+
  2499. #013#010+
  2500. 'Function TTargets.AddImplicitUnit(Const AUnitName : String;const CPUs:'+
  2501. 'TCPUs;const OSes:TOSes;InstallUnit:boolean=true) : TTarget;'#013#010+
  2502. 'begin'#013#010+
  2503. ' Result:=Add as T','Target;'#013#010+
  2504. ' Result.Name:=AUnitName;'#013#010+
  2505. ' Result.CPUs:=CPUs;'#013#010+
  2506. ' Result.OSes:=OSes;'#013#010+
  2507. ' if InstallUnit then'#013#010+
  2508. ' Result.TargetType:=TTImplicitUnit'#013#010+
  2509. ' else'#013#010+
  2510. ' Result.TargetType:=TTCleanOnlyUnit;'#013#010+
  2511. 'end;'#013#010+
  2512. #013#010+
  2513. #013#010+
  2514. 'Function TTargets.AddProgram(Const APro','gramName : String) : TTarget;'+
  2515. #013#010+
  2516. 'begin'#013#010+
  2517. ' Result:=AddProgram(AProgramName,AllCPUs,AllOSes);'#013#010+
  2518. 'end;'#013#010+
  2519. #013#010+
  2520. #013#010+
  2521. 'Function TTargets.AddProgram(Const AProgramName : String;const OSes:TO'+
  2522. 'Ses) : TTarget;'#013#010+
  2523. 'begin'#013#010+
  2524. ' Result:=AddProgram(AProgramName,AllCPUs,OSe','s);'#013#010+
  2525. 'end;'#013#010+
  2526. #013#010+
  2527. #013#010+
  2528. '{$ifdef cpu_only_overloads}'#013#010+
  2529. 'Function TTargets.AddProgram(Const AProgramName : String;const CPUs:TC'+
  2530. 'PUs) : TTarget;'#013#010+
  2531. 'begin'#013#010+
  2532. ' Result:=AddProgram(AProgramName,CPUs,AllOSes);'#013#010+
  2533. 'end;'#013#010+
  2534. '{$endif cpu_only_overloads}'#013#010+
  2535. #013#010+
  2536. #013#010+
  2537. 'Function TTar','gets.AddProgram(Const AProgramName : String;const CPUs:'+
  2538. 'TCPUs;const OSes:TOSes) : TTarget;'#013#010+
  2539. 'begin'#013#010+
  2540. ' Result:=Add as TTarget;'#013#010+
  2541. ' Result.Name:=AProgramName;'#013#010+
  2542. ' Result.CPUs:=CPUs;'#013#010+
  2543. ' Result.OSes:=OSes;'#013#010+
  2544. ' Result.TargetType:=ttProgram;'#013#010+
  2545. 'end;'#013#010+
  2546. #013#010,
  2547. #013#010+
  2548. 'Function TTargets.AddExampleUnit(Const AUnitName : String) : TTarget;'#013+
  2549. #010+
  2550. 'begin'#013#010+
  2551. ' Result:=AddExampleUnit(AUnitName,AllCPUs,AllOSes);'#013#010+
  2552. 'end;'#013#010+
  2553. #013#010+
  2554. #013#010+
  2555. 'Function TTargets.AddExampleUnit(Const AUnitName : String;const OSes:T'+
  2556. 'OSes) : TTarget;'#013#010+
  2557. 'begin'#013#010+
  2558. ' ',' Result:=AddExampleUnit(AUnitName,AllCPUs,OSes);'#013#010+
  2559. 'end;'#013#010+
  2560. #013#010+
  2561. #013#010+
  2562. '{$ifdef cpu_only_overloads}'#013#010+
  2563. 'Function TTargets.AddExampleUnit(Const AUnitName : String;const CPUs:T'+
  2564. 'CPUs) : TTarget;'#013#010+
  2565. 'begin'#013#010+
  2566. ' Result:=AddExampleUnit(AUnitName,CPUs,AllOSes);'#013#010+
  2567. 'end;'#013,#010+
  2568. '{$endif cpu_only_overloads}'#013#010+
  2569. #013#010+
  2570. #013#010+
  2571. 'Function TTargets.AddExampleUnit(Const AUnitName : String;const CPUs:T'+
  2572. 'CPUs;const OSes:TOSes) : TTarget;'#013#010+
  2573. 'begin'#013#010+
  2574. ' Result:=Add as TTarget;'#013#010+
  2575. ' Result.Name:=AUnitName;'#013#010+
  2576. ' Result.CPUs:=CPUs;'#013#010+
  2577. ' Result.OSes:=OSe','s;'#013#010+
  2578. ' Result.TargetType:=ttExampleUnit;'#013#010+
  2579. 'end;'#013#010+
  2580. #013#010+
  2581. #013#010+
  2582. 'Function TTargets.AddExampleProgram(Const AProgramName : String) : TTa'+
  2583. 'rget;'#013#010+
  2584. 'begin'#013#010+
  2585. ' Result:=AddExampleProgram(AProgramName,AllCPUs,AllOSes);'#013#010+
  2586. 'end;'#013#010+
  2587. #013#010+
  2588. #013#010+
  2589. 'Function TTargets.AddExampleProgram','(Const AProgramName : String;cons'+
  2590. 't OSes:TOSes) : TTarget;'#013#010+
  2591. 'begin'#013#010+
  2592. ' Result:=AddExampleProgram(AProgramName,AllCPUs,OSes);'#013#010+
  2593. 'end;'#013#010+
  2594. #013#010+
  2595. #013#010+
  2596. '{$ifdef cpu_only_overloads}'#013#010+
  2597. 'Function TTargets.AddExampleProgram(Const AProgramName : String;const '+
  2598. 'CPUs:TCP','Us) : TTarget;'#013#010+
  2599. 'begin'#013#010+
  2600. ' Result:=AddExampleProgram(AProgramName,CPUs,AllOSes);'#013#010+
  2601. 'end;'#013#010+
  2602. '{$endif cpu_only_overloads}'#013#010+
  2603. #013#010+
  2604. #013#010+
  2605. 'Function TTargets.AddExampleProgram(Const AProgramName : String;const '+
  2606. 'CPUs:TCPUs;const OSes:TOSes) : TTarget;'#013#010+
  2607. 'begin'#013#010+
  2608. ' R','esult:=Add as TTarget;'#013#010+
  2609. ' Result.Name:=AProgramName;'#013#010+
  2610. ' Result.CPUs:=CPUs;'#013#010+
  2611. ' Result.OSes:=OSes;'#013#010+
  2612. ' Result.TargetType:=ttExampleProgram;'#013#010+
  2613. 'end;'#013#010+
  2614. #013#010+
  2615. #013#010+
  2616. '{*********************************************************************'+
  2617. '*******'#013#010+
  2618. ' ',' TSources'#013#010+
  2619. '**********************************************************************'+
  2620. '******}'#013#010+
  2621. #013#010+
  2622. 'function TSources.GetSourceItem(Index : Integer): TSource;'#013#010+
  2623. 'begin'#013#010+
  2624. ' Result:=TSource(Items[Index]);'#013#010+
  2625. 'end;'#013#010+
  2626. #013#010+
  2627. #013#010+
  2628. 'procedure TSources.','SetSourceItem(Index : Integer; const AValue: TSou'+
  2629. 'rce);'#013#010+
  2630. 'begin'#013#010+
  2631. ' Items[Index]:=AValue;'#013#010+
  2632. 'end;'#013#010+
  2633. #013#010+
  2634. #013#010+
  2635. 'function TSources.AddDoc (const AFiles : String) : TSource;'#013#010+
  2636. 'begin'#013#010+
  2637. ' Result:=Add as TSource;'#013#010+
  2638. ' Result.Name:=AFiles;'#013#010+
  2639. ' Result.FSourceType:=s','tDoc;'#013#010+
  2640. 'end;'#013#010+
  2641. #013#010+
  2642. #013#010+
  2643. 'function TSources.AddDoc(const AFiles: String; AInstallSourcePath: Str'+
  2644. 'ing): TSource;'#013#010+
  2645. 'begin'#013#010+
  2646. ' Result:=Add as TSource;'#013#010+
  2647. ' Result.Name:=AFiles;'#013#010+
  2648. ' Result.FInstallSourcePath:=AInstallSourcePath;'#013#010+
  2649. ' Result.FSourceType:=stDoc;'#013,#010+
  2650. 'end;'#013#010+
  2651. #013#010+
  2652. #013#010+
  2653. 'function TSources.AddSrc(const AFiles : String) : TSource;'#013#010+
  2654. 'begin'#013#010+
  2655. ' Result:=Add as TSource;'#013#010+
  2656. ' Result.Name:=AFiles;'#013#010+
  2657. ' Result.FSourceType:=stSrc;'#013#010+
  2658. 'end;'#013#010+
  2659. #013#010+
  2660. #013#010+
  2661. 'function TSources.AddExample(const AFiles : String) : TSource;'#013#010+
  2662. 'begin'#013#010,
  2663. ' Result:=Add as TSource;'#013#010+
  2664. ' Result.Name:=AFiles;'#013#010+
  2665. ' Result.FSourceType:=stExample;'#013#010+
  2666. 'end;'#013#010+
  2667. #013#010+
  2668. 'function TSources.AddExample(const AFiles: String; AInstallSourcePath:'+
  2669. ' String): TSource;'#013#010+
  2670. 'begin'#013#010+
  2671. ' Result:=Add as TSource;'#013#010+
  2672. ' Result.Name:=AFiles;'#013,#010+
  2673. ' Result.FInstallSourcePath:=AInstallSourcePath;'#013#010+
  2674. ' Result.FSourceType:=stExample;'#013#010+
  2675. 'end;'#013#010+
  2676. #013#010+
  2677. #013#010+
  2678. 'function TSources.AddTest(const AFiles : String) : TSource;'#013#010+
  2679. 'begin'#013#010+
  2680. ' Result:=Add as TSource;'#013#010+
  2681. ' Result.Name:=AFiles;'#013#010+
  2682. ' Result.FSourceType:=stTe','st;'#013#010+
  2683. 'end;'#013#010+
  2684. #013#010+
  2685. #013#010+
  2686. 'procedure TSources.AddDocFiles(const AFileMask: string; Recursive: boo'+
  2687. 'lean; AInstallSourcePath : String = '#039#039');'#013#010+
  2688. 'var'#013#010+
  2689. ' List : TStrings;'#013#010+
  2690. ' i: integer;'#013#010+
  2691. 'begin'#013#010+
  2692. ' List := TStringList.Create;'#013#010+
  2693. ' SearchFiles(AFileMask, Recursive,',' List);'#013#010+
  2694. ' for i:= 0 to Pred(List.Count) do'#013#010+
  2695. ' AddDoc(List[i], AInstallSourcePath);'#013#010+
  2696. ' List.Free;'#013#010+
  2697. 'end;'#013#010+
  2698. #013#010+
  2699. #013#010+
  2700. 'procedure TSources.AddSrcFiles(const AFileMask: string; Recursive: boo'+
  2701. 'lean);'#013#010+
  2702. 'var'#013#010+
  2703. ' List : TStrings;'#013#010+
  2704. ' i: integer;'#013#010+
  2705. 'begin'#013#010+
  2706. ' Li','st := TStringList.Create;'#013#010+
  2707. ' SearchFiles(AFileMask, Recursive, List);'#013#010+
  2708. ' for i:= 0 to Pred(List.Count) do'#013#010+
  2709. ' AddSrc(List[i]);'#013#010+
  2710. ' List.Free;'#013#010+
  2711. 'end;'#013#010+
  2712. #013#010+
  2713. #013#010+
  2714. 'procedure TSources.AddExampleFiles(const AFileMask: string; Recursive:'+
  2715. ' boolean; AInstal','lSourcePath : String = '#039#039');'#013#010+
  2716. 'var'#013#010+
  2717. ' List : TStrings;'#013#010+
  2718. ' i: integer;'#013#010+
  2719. 'begin'#013#010+
  2720. ' List := TStringList.Create;'#013#010+
  2721. ' SearchFiles(AFileMask, Recursive, List);'#013#010+
  2722. ' for i:= 0 to Pred(List.Count) do'#013#010+
  2723. ' AddExample(List[i], AInstallSourcePath);'#013#010+
  2724. ' List.','Free;'#013#010+
  2725. 'end;'#013#010+
  2726. #013#010+
  2727. #013#010+
  2728. 'procedure TSources.AddTestFiles(const AFileMask: string; Recursive: bo'+
  2729. 'olean);'#013#010+
  2730. 'var'#013#010+
  2731. ' List : TStrings;'#013#010+
  2732. ' i: integer;'#013#010+
  2733. 'begin'#013#010+
  2734. ' List := TStringList.Create;'#013#010+
  2735. ' SearchFiles(AFileMask, Recursive, List);'#013#010+
  2736. ' for i:= 0 to Pred(Li','st.Count) do'#013#010+
  2737. ' AddTest(List[i]);'#013#010+
  2738. ' List.Free;'#013#010+
  2739. 'end;'#013#010+
  2740. #013#010+
  2741. #013#010+
  2742. '{*********************************************************************'+
  2743. '*******'#013#010+
  2744. ' TPackage'#013#010+
  2745. '*************************************************************','*******'+
  2746. '********}'#013#010+
  2747. #013#010+
  2748. 'constructor TPackage.Create(ACollection: TCollection);'#013#010+
  2749. 'begin'#013#010+
  2750. ' inherited Create(ACollection);'#013#010+
  2751. ' FVersion:=TFPVersion.Create;'#013#010+
  2752. ' FTargets:=TTargets.Create(TTarget);'#013#010+
  2753. ' FSources:=TSources.Create(TSource);'#013#010+
  2754. ' FDependenci','es:=TDependencies.Create(TDependency);'#013#010+
  2755. ' FInstallFiles:=TConditionalStrings.Create(TConditionalString);'#013#010+
  2756. ' FCleanFiles:=TConditionalStrings.Create(TConditionalString);'#013#010+
  2757. ' FUnitPath:=TConditionalStrings.Create(TConditionalString);'#013#010+
  2758. ' FObjec','tPath:=TConditionalStrings.Create(TConditionalString);'#013#010+
  2759. ' FIncludePath:=TConditionalStrings.Create(TConditionalString);'#013#010+
  2760. ' FSourcePath:=TConditionalStrings.Create(TConditionalString);'#013#010+
  2761. ' FExamplePath:=TConditionalStrings.Create(TConditional','String);'#013#010+
  2762. ' FTestPath:=TConditionalStrings.Create(TConditionalString);'#013#010+
  2763. ' FCommands:=TCommands.Create(TCommand);'#013#010+
  2764. ' FCPUs:=AllCPUs;'#013#010+
  2765. ' FOSes:=AllOSes;'#013#010+
  2766. ' FInstalledChecksum:=$ffffffff;'#013#010+
  2767. ' // Implicit dependency on RTL'#013#010+
  2768. ' FDependencies.Add('#039,'rtl'#039');'#013#010+
  2769. ' FSupportBuildModes:=[bmBuildUnit, bmOneByOne];'#013#010+
  2770. 'end;'#013#010+
  2771. #013#010+
  2772. #013#010+
  2773. 'destructor TPackage.destroy;'#013#010+
  2774. 'begin'#013#010+
  2775. ' FreeAndNil(FDependencies);'#013#010+
  2776. ' FreeAndNil(FInstallFiles);'#013#010+
  2777. ' FreeAndNil(FCleanFiles);'#013#010+
  2778. ' FreeAndNil(FIncludePath);'#013#010+
  2779. ' FreeAndNil(FSour','cePath);'#013#010+
  2780. ' FreeAndNil(FExamplePath);'#013#010+
  2781. ' FreeAndNil(FTestPath);'#013#010+
  2782. ' FreeAndNil(FObjectPath);'#013#010+
  2783. ' FreeAndNil(FUnitPath);'#013#010+
  2784. ' FreeAndNil(FSources);'#013#010+
  2785. ' FreeAndNil(FTargets);'#013#010+
  2786. ' FreeAndNil(FVersion);'#013#010+
  2787. ' FreeAndNil(FOptions);'#013#010+
  2788. ' inherited destroy;'#013,#010+
  2789. 'end;'#013#010+
  2790. #013#010+
  2791. 'function TPackage.HaveOptions: Boolean;'#013#010+
  2792. 'begin'#013#010+
  2793. ' Result:=(FOptions<>Nil);'#013#010+
  2794. 'end;'#013#010+
  2795. #013#010+
  2796. #013#010+
  2797. 'procedure TPackage.SetName(const AValue: String);'#013#010+
  2798. 'begin'#013#010+
  2799. ' inherited SetName(AValue);'#013#010+
  2800. ' // RTL should not have any dependencies'#013#010+
  2801. ' if AValue='#039'r','tl'#039' then'#013#010+
  2802. ' FDependencies.Clear;'#013#010+
  2803. 'end;'#013#010+
  2804. #013#010+
  2805. #013#010+
  2806. 'Function TPackage.GetUnitsOutputDir(ACPU:TCPU; AOS : TOS):String;'#013#010+
  2807. 'begin'#013#010+
  2808. ' Result:='#039'units'#039'+PathDelim+MakeTargetString(ACPU,AOS);'#013#010+
  2809. 'end;'#013#010+
  2810. #013#010+
  2811. #013#010+
  2812. 'Function TPackage.GetBinOutputDir(ACPU:TCPU; AOS : TO','S) : String;'#013+
  2813. #010+
  2814. 'begin'#013#010+
  2815. ' Result:='#039'bin'#039'+PathDelim+MakeTargetString(ACPU,AOS);'#013#010+
  2816. 'end;'#013#010+
  2817. #013#010+
  2818. #013#010+
  2819. 'procedure TPackage.GetCleanFiles(List: TStrings; ACPU:TCPU; AOS : TOS)'+
  2820. ';'#013#010+
  2821. 'Var'#013#010+
  2822. ' OB,OU : String;'#013#010+
  2823. ' I : Integer;'#013#010+
  2824. 'begin'#013#010+
  2825. ' OB:=IncludeTrailingPathDelimiter','(GetBinOutputDir(ACPU,AOS));'#013#010+
  2826. ' OU:=IncludeTrailingPathDelimiter(GetUnitsOutputDir(ACPU,AOS));'#013#010+
  2827. ' AddConditionalStrings(List,CleanFiles,ACPU,AOS);'#013#010+
  2828. ' For I:=0 to FTargets.Count-1 do'#013#010+
  2829. ' FTargets.TargetItems[I].GetCleanFiles(List, OU, OB, A','CPU, AOS);'#013+
  2830. #010+
  2831. 'end;'#013#010+
  2832. #013#010+
  2833. #013#010+
  2834. 'procedure TPackage.GetInstallFiles(List: TStrings;Types : TTargetTypes'+
  2835. ';ACPU:TCPU; AOS : TOS);'#013#010+
  2836. 'Var'#013#010+
  2837. ' OB,OU : String;'#013#010+
  2838. ' I : Integer;'#013#010+
  2839. ' T : TTarget;'#013#010+
  2840. 'begin'#013#010+
  2841. ' OB:=IncludeTrailingPathDelimiter(GetBinOutputDir(Defaults.','CPU,Defa'+
  2842. 'ults.OS));'#013#010+
  2843. ' OU:=IncludeTrailingPathDelimiter(GetUnitsOutputDir(Defaults.CPU,Defa'+
  2844. 'ults.OS));'#013#010+
  2845. ' AddConditionalStrings(List,InstallFiles,ACPU,AOS);'#013#010+
  2846. ' For I:=0 to FTargets.Count-1 do'#013#010+
  2847. ' begin'#013#010+
  2848. ' T:=FTargets.TargetItems[I];'#013#010+
  2849. ' ',' if (T.TargetType in Types) and (T.Install) then'#013#010+
  2850. ' T.GetInstallFiles(List, OU, OB, ACPU, AOS);'#013#010+
  2851. ' end;'#013#010+
  2852. 'end;'#013#010+
  2853. #013#010+
  2854. #013#010+
  2855. 'procedure TPackage.GetInstallSourceFiles(List: TStrings; SourceTypes :'+
  2856. ' TSourceTypes; TargetTypes : TTargetTypes);'#013#010,
  2857. 'Var'#013#010+
  2858. ' I : Integer;'#013#010+
  2859. ' S : TSource;'#013#010+
  2860. ' T : TTarget;'#013#010+
  2861. 'begin'#013#010+
  2862. ' For I:=0 to FSources.Count-1 do'#013#010+
  2863. ' begin'#013#010+
  2864. ' S:=FSources.SourceItems[I];'#013#010+
  2865. ' if (S.SourceType in SourceTypes) then'#013#010+
  2866. ' S.GetInstallFiles(List);'#013#010+
  2867. ' end;'#013#010+
  2868. ' For I:=0',' to FTargets.Count-1 do'#013#010+
  2869. ' begin'#013#010+
  2870. ' T:=FTargets.TargetItems[I];'#013#010+
  2871. ' if (T.TargetType in TargetTypes) then'#013#010+
  2872. ' T.GetArchiveFiles(List,Defaults.CPU,Defaults.OS);'#013#010+
  2873. ' end;'#013#010+
  2874. 'end;'#013#010+
  2875. #013#010+
  2876. #013#010+
  2877. 'procedure TPackage.GetArchiveFiles(List: TStr','ings; ACPU:TCPU; AOS : '+
  2878. 'TOS);'#013#010+
  2879. 'Var'#013#010+
  2880. ' I : Integer;'#013#010+
  2881. 'begin'#013#010+
  2882. ' // Targets only'#013#010+
  2883. ' For I:=0 to FTargets.Count-1 do'#013#010+
  2884. ' FTargets.TargetItems[I].GetArchiveFiles(List,ACPU,AOS);'#013#010+
  2885. 'end;'#013#010+
  2886. #013#010+
  2887. 'procedure TPackage.GetArchiveSourceFiles(List: TStrings);'#013#010,
  2888. 'var'#013#010+
  2889. ' i : integer;'#013#010+
  2890. 'begin'#013#010+
  2891. ' for i := 0 to Sources.Count-1 do'#013#010+
  2892. ' List.Add(Sources[i].Name);'#013#010+
  2893. 'end;'#013#010+
  2894. #013#010+
  2895. 'Function TPackage.GetDescription : string;'#013#010+
  2896. 'Var'#013#010+
  2897. ' FN : String;'#013#010+
  2898. ' L : TStringList;'#013#010+
  2899. 'begin'#013#010+
  2900. ' If (FDescription<>'#039#039') then'#013#010+
  2901. ' Result:=FD','escription'#013#010+
  2902. ' else'#013#010+
  2903. ' If (FDescriptionFile<>'#039#039') then'#013#010+
  2904. ' begin'#013#010+
  2905. ' // Always relative to binary name.'#013#010+
  2906. ' FN:=ExtractFilePath(ParamStr(0));'#013#010+
  2907. ' FN:=FN+FDescriptionFile;'#013#010+
  2908. ' If FileExists(FN) then'#013#010+
  2909. ' begin'#013#010+
  2910. ' ',' L:=TStringList.Create;'#013#010+
  2911. ' Try'#013#010+
  2912. ' L.LoadFromFile(FN);'#013#010+
  2913. ' Result:=L.Text;'#013#010+
  2914. ' Finally'#013#010+
  2915. ' L.Free;'#013#010+
  2916. ' end;'#013#010+
  2917. ' end;'#013#010+
  2918. ' end;'#013#010+
  2919. 'end;'#013#010+
  2920. #013#010+
  2921. #013#010+
  2922. 'Function TPackage.GetV','ersion : string;'#013#010+
  2923. 'begin'#013#010+
  2924. ' result:=FVersion.AsString;'#013#010+
  2925. 'end;'#013#010+
  2926. #013#010+
  2927. 'procedure TPackage.SetOptions(const AValue: TStrings);'#013#010+
  2928. 'begin'#013#010+
  2929. ' If (AValue=Nil) or (AValue.Count=0) then'#013#010+
  2930. ' FreeAndNil(Foptions)'#013#010+
  2931. ' else'#013#010+
  2932. ' Options.Assign(AValue);'#013#010+
  2933. 'end;'#013#010+
  2934. #013,#010+
  2935. #013#010+
  2936. 'Procedure TPackage.SetVersion(const V : string);'#013#010+
  2937. 'begin'#013#010+
  2938. ' FVersion.AsString:=V;'#013#010+
  2939. 'end;'#013#010+
  2940. #013#010+
  2941. #013#010+
  2942. 'Function TPackage.GetFileName : string;'#013#010+
  2943. 'begin'#013#010+
  2944. ' If (FFileName<>'#039#039') then'#013#010+
  2945. ' Result:=FFileName'#013#010+
  2946. ' else'#013#010+
  2947. ' if not FVersion.Empty then'#013#010+
  2948. ' R','esult := Name + '#039'-'#039' + FVersion.AsString'#013#010+
  2949. ' else'#013#010+
  2950. ' Result := Name;'#013#010+
  2951. 'end;'#013#010+
  2952. #013#010+
  2953. 'function TPackage.GetOptions: TStrings;'#013#010+
  2954. 'begin'#013#010+
  2955. ' If (FOptions=Nil) then'#013#010+
  2956. ' FOptions:=TStringList.Create;'#013#010+
  2957. ' Result:=FOptions;'#013#010+
  2958. 'end;'#013#010+
  2959. #013#010+
  2960. #013#010+
  2961. 'Procedure TPackage','.GetManifest(Manifest : TStrings);'#013#010+
  2962. #013#010+
  2963. ' procedure AddOSes(const AIndent:string;AOSes:TOSes);'#013#010+
  2964. ' var'#013#010+
  2965. ' IOS : TOS;'#013#010+
  2966. ' begin'#013#010+
  2967. ' if (AOSes=AllOSes) then'#013#010+
  2968. ' exit;'#013#010+
  2969. ' Manifest.Add(AIndent+'#039'<oses>'#039');'#013#010+
  2970. ' for IOS:=low(TOSes) to high(TOS','es) do'#013#010+
  2971. ' if IOS in AOSes then'#013#010+
  2972. ' Manifest.Add(Format(AIndent+'#039' <os name="%s"/>'#039',[OSToSt'+
  2973. 'ring(IOS)]));'#013#010+
  2974. ' Manifest.Add(AIndent+'#039'</oses>'#039');'#013#010+
  2975. ' end;'#013#010+
  2976. #013#010+
  2977. ' procedure AddCPUs(const AIndent:string;ACPUs:TCPUs);'#013#010+
  2978. ' var'#013#010+
  2979. ' ICPU : TCPU;',#013#010+
  2980. ' begin'#013#010+
  2981. ' if (ACPUs=AllCPUs) then'#013#010+
  2982. ' exit;'#013#010+
  2983. ' Manifest.Add(AIndent+'#039'<cpus>'#039');'#013#010+
  2984. ' for ICPU:=low(TCPUs) to high(TCPUs) do'#013#010+
  2985. ' if ICPU in ACPUs then'#013#010+
  2986. ' Manifest.Add(Format(AIndent+'#039' <cpu name="%s"/>'#039',[CPUTo'+
  2987. 'String(ICPU)]))',';'#013#010+
  2988. ' Manifest.Add(AIndent+'#039'</cpus>'#039');'#013#010+
  2989. ' end;'#013#010+
  2990. #013#010+
  2991. ' function GetXMLVersionString(sMajor, sMinor, sMicro, sBuild: integer'+
  2992. '): string;'#013#010+
  2993. ' begin'#013#010+
  2994. ' Result := '#039'<version'#039';'#013#010+
  2995. ' if sMajor <> -1 then'#013#010+
  2996. ' Result := Result + '#039' major="'#039' + IntToSt','r(sMajor) + '#039+
  2997. '"'#039';'#013#010+
  2998. ' if sMinor <> -1 then'#013#010+
  2999. ' Result := Result + '#039' minor="'#039' + IntToStr(sMinor) + '#039'"'+
  3000. #039';'#013#010+
  3001. ' if sMicro <> -1 then'#013#010+
  3002. ' Result := Result + '#039' micro="'#039' + IntToStr(sMicro) + '#039'"'+
  3003. #039';'#013#010+
  3004. ' if sBuild <> -1 then'#013#010+
  3005. ' Result := Re','sult + '#039' build="'#039' + IntToStr(sBuild) + '#039+
  3006. '"'#039';'#013#010+
  3007. #013#010+
  3008. ' Result := Result + '#039'/>'#039';'#013#010+
  3009. ' end;'#013#010+
  3010. #013#010+
  3011. 'Var'#013#010+
  3012. ' S : String;'#013#010+
  3013. ' i : Integer;'#013#010+
  3014. ' D : TDependency;'#013#010+
  3015. 'begin'#013#010+
  3016. ' With Manifest do'#013#010+
  3017. ' begin'#013#010+
  3018. ' Add(Format('#039'<package name="%s">'#039',[QuoteXml(Name)]));'#013#010+
  3019. #013,#010+
  3020. ' Add('#039' '#039' + GetXMLVersionString(FVersion.Major,FVersion.Mino'+
  3021. 'r,FVersion.Micro,FVersion.Build));'#013#010+
  3022. ' AddOSes('#039' '#039',OSes);'#013#010+
  3023. ' AddCPUs('#039' '#039',CPUs);'#013#010+
  3024. ' Add(Format('#039' <filename>%s</filename>'#039',[QuoteXml(FileName +'+
  3025. ' ZipExt)]));'#013#010+
  3026. ' Add(Format('#039' ','<author>%s</author>'#039',[QuoteXml(Author)]));'#013+
  3027. #010+
  3028. ' Add(Format('#039' <license>%s</license>'#039',[QuoteXml(License)]));'+
  3029. #013#010+
  3030. ' if HomepageURL<>'#039#039' then'#013#010+
  3031. ' Add(Format('#039' <homepageurl>%s</homepageurl>'#039',[QuoteXml(Ho'+
  3032. 'mepageURL)]));'#013#010+
  3033. ' if DownloadURL<>'#039#039' th','en'#013#010+
  3034. ' Add(Format('#039' <downloadurl>%s</downloadurl>'#039',[QuoteXml(Do'+
  3035. 'wnloadURL)]));'#013#010+
  3036. ' Add(Format('#039' <email>%s</email>'#039',[QuoteXMl(Email)]));'#013#010+
  3037. ' S:=Description;'#013#010+
  3038. ' If (S<>'#039#039') then'#013#010+
  3039. ' Add(Format('#039' <description>%s</description>'#039',[QuoteXM','L('+
  3040. 'S)]));'#013#010+
  3041. ' If (Dependencies.Count>0) then'#013#010+
  3042. ' begin'#013#010+
  3043. ' Add('#039' <dependencies>'#039');'#013#010+
  3044. ' for I:=0 to Dependencies.Count-1 do'#013#010+
  3045. ' begin'#013#010+
  3046. ' D:=Dependencies[i];'#013#010+
  3047. ' Add('#039' <dependency>'#039');'#013#010+
  3048. ' Add(F','ormat('#039' <package packagename="%s"/>'#039',[Quo'+
  3049. 'teXML(D.Value)]));'#013#010+
  3050. ' if not D.FVersion.Empty then'#013#010+
  3051. ' Add('#039' '#039' + GetXMLVersionString(D.FVersion.Major'+
  3052. ',D.FVersion.Minor,D.FVersion.Micro,D.FVersion.Build));'#013#010+
  3053. ' AddOS','es('#039' '#039',D.OSes);'#013#010+
  3054. ' AddCPUs('#039' '#039',D.CPUs);'#013#010+
  3055. ' Add('#039' </dependency>'#039');'#013#010+
  3056. ' end;'#013#010+
  3057. ' Add('#039' </dependencies>'#039');'#013#010+
  3058. ' end;'#013#010+
  3059. ' Add('#039'</package>'#039');'#013#010+
  3060. ' end;'#013#010+
  3061. 'end;'#013#010+
  3062. #013#010+
  3063. #013#010+
  3064. 'procedure TPackage.LoadUnitConfigFromFile(','Const AFileName: String);'#013+
  3065. #010+
  3066. 'var'#013#010+
  3067. ' L,L2 : TStrings;'#013#010+
  3068. ' VOS : TOS;'#013#010+
  3069. ' VCPU : TCPU;'#013#010+
  3070. ' i,k : Integer;'#013#010+
  3071. ' DepChecksum : Cardinal;'#013#010+
  3072. ' DepName : String;'#013#010+
  3073. ' D : TDependency;'#013#010+
  3074. 'begin'#013#010+
  3075. ' L:=TStringList.Create;'#013#010+
  3076. ' Try'#013#010+
  3077. ' ReadIniFile(AFileName,L);'#013#010+
  3078. ' ',' With L do'#013#010+
  3079. ' begin'#013#010+
  3080. ' Version:=Values[KeyVersion];'#013#010+
  3081. ' InstalledChecksum:=Cardinal(StrToInt64Def(Values[KeyChecksum],'+
  3082. '$ffffffff));'#013#010+
  3083. ' VCPU:=StringToCPU(Values[KeyCPU]);'#013#010+
  3084. ' VOS:=StringToOS(Values[KeyOS]);'#013#010+
  3085. ' ',' OSes:=[VOS];'#013#010+
  3086. ' CPUs:=[VCPU];'#013#010+
  3087. ' L2:=TStringList.Create;'#013#010+
  3088. ' L2.CommaText:=Values[KeyDepends];'#013#010+
  3089. ' for i:=0 to L2.Count-1 do'#013#010+
  3090. ' begin'#013#010+
  3091. ' DepName:=L2[i];'#013#010+
  3092. ' k:=Pos('#039'|'#039',DepName);'#013#010+
  3093. ' ',' if k>0 then'#013#010+
  3094. ' begin'#013#010+
  3095. ' DepChecksum:=StrToInt(Copy(DepName,k+1,Length(DepName)'+
  3096. '-k));'#013#010+
  3097. ' DepName:=Copy(DepName,1,k-1);'#013#010+
  3098. ' end'#013#010+
  3099. ' else'#013#010+
  3100. ' DepChecksum:=$ffffffff;'#013#010+
  3101. ' ',' D:=Dependencies.Add(DepName,CPUs,OSes);'#013#010+
  3102. ' D.RequireChecksum:=DepChecksum;'#013#010+
  3103. ' end;'#013#010+
  3104. ' FreeAndNil(L2);'#013#010+
  3105. ' NeedLibC:=Upcase(Values[KeyNeedLibC])='#039'Y'#039';'#013#010+
  3106. ' IsFPMakeAddIn:=Upcase(Values[KeyAddIn])='#039'Y'#039';'#013,#010+
  3107. ' end;'#013#010+
  3108. ' Finally'#013#010+
  3109. ' L.Free;'#013#010+
  3110. ' end;'#013#010+
  3111. 'end;'#013#010+
  3112. #013#010+
  3113. 'procedure TPackage.SaveUnitConfigToStringList(const AStringList: TStri'+
  3114. 'ngs; ACPU: TCPU; AOS: TOS);'#013#010+
  3115. 'Var'#013#010+
  3116. ' Deps : String;'#013#010+
  3117. ' i : integer;'#013#010+
  3118. ' D : TDependency;'#013#010+
  3119. ' p : TPackage;'#013#010+
  3120. 'begin'#013#010+
  3121. ' wit','h AStringList do'#013#010+
  3122. ' begin'#013#010+
  3123. ' Values[KeyName]:=Name;'#013#010+
  3124. ' Values[KeyVersion]:=Version;'#013#010+
  3125. ' // TODO Generate checksum based on PPUs'#013#010+
  3126. ' Values[KeyChecksum]:=IntToStr(DateTimeToFileDate(Now));'#013#010+
  3127. ' Values[KeyCPU]:=CPUToString(A','CPU);'#013#010+
  3128. ' Values[KeyOS]:=OSToString(AOS);'#013#010+
  3129. ' //Installer;'#013#010+
  3130. ' Values[KeySourcePath]:=IncludeTrailingPathDelimiter(IncludeTrail'+
  3131. 'ingPathDelimiter(Installer.BuildEngine.FStartDir)+Directory);'#013#010+
  3132. ' Values[KeyFPMakeOptions]:=trim(Inst','aller.FPMakeOptionsString);'+
  3133. #013#010+
  3134. ' Deps:='#039#039';'#013#010+
  3135. ' for i:=0 to Dependencies.Count-1 do'#013#010+
  3136. ' begin'#013#010+
  3137. ' D:=Dependencies[i];'#013#010+
  3138. ' if (ACPU in D.CPUs) and (AOS in D.OSes) then'#013#010+
  3139. ' begin'#013#010+
  3140. ' if Deps<>'#039#039' then',#013#010+
  3141. ' Deps:=Deps+'#039','#039';'#013#010+
  3142. ' Deps:=Deps+D.Value;'#013#010+
  3143. ' P:=TPackage(D.Target);'#013#010+
  3144. ' if assigned(P) and (P.InstalledChecksum<>$ffffffff) then'+
  3145. #013#010+
  3146. ' Deps:=Deps+'#039'|'#039'+IntToStr(P.InstalledChecksum)',';'+
  3147. #013#010+
  3148. ' end;'#013#010+
  3149. ' end;'#013#010+
  3150. ' Values[KeyDepends]:=Deps;'#013#010+
  3151. ' if NeedLibC then'#013#010+
  3152. ' Values[KeyNeedLibC]:='#039'Y'#039#013#010+
  3153. ' else'#013#010+
  3154. ' Values[KeyNeedLibC]:='#039'N'#039';'#013#010+
  3155. ' if IsFPMakeAddIn then'#013#010+
  3156. ' Values[KeyAddIn]:='#039'Y'#039#013#010+
  3157. ' e','lse'#013#010+
  3158. ' Values[KeyAddIn]:='#039'N'#039';'#013#010+
  3159. ' end;'#013#010+
  3160. 'end;'#013#010+
  3161. #013#010+
  3162. 'procedure TPackage.SaveUnitConfigToFile(Const AFileName: String;ACPU:T'+
  3163. 'CPU;AOS:TOS);'#013#010+
  3164. 'Var'#013#010+
  3165. ' F : TFileStream;'#013#010+
  3166. ' L : TStringList;'#013#010+
  3167. 'begin'#013#010+
  3168. ' F:=TFileStream.Create(AFileName,fmCreate);'#013#010+
  3169. ' ','L:=TStringList.Create;'#013#010+
  3170. ' try'#013#010+
  3171. ' SaveUnitConfigToStringList(L,ACPU,AOS);'#013#010+
  3172. ' L.SaveToStream(F);'#013#010+
  3173. ' Finally'#013#010+
  3174. ' L.Free;'#013#010+
  3175. ' F.Free;'#013#010+
  3176. ' end;'#013#010+
  3177. 'end;'#013#010+
  3178. #013#010+
  3179. #013#010+
  3180. #013#010+
  3181. '{*********************************************************************'+
  3182. '*******'#013#010+
  3183. ' ',' TPackages'#013#010+
  3184. '**********************************************************************'+
  3185. '******}'#013#010+
  3186. #013#010+
  3187. 'function TPackages.GetPackage(const AName : String): TPackage;'#013#010+
  3188. 'begin'#013#010+
  3189. ' Result:=TPackage(ItemByName(AName))'#013#010+
  3190. 'end;'#013#010+
  3191. #013#010+
  3192. 'func','tion TPackages.GetPackageItem(AIndex : Integer): TPackage;'#013#010+
  3193. 'begin'#013#010+
  3194. ' Result:=TPackage(Items[AIndex]);'#013#010+
  3195. 'end;'#013#010+
  3196. #013#010+
  3197. #013#010+
  3198. 'procedure TPackages.SetPackageItem(AIndex : Integer; const AValue: TPa'+
  3199. 'ckage);'#013#010+
  3200. 'begin'#013#010+
  3201. ' Items[AIndex]:=AValue;'#013#010+
  3202. 'end;'#013#010+
  3203. #013#010+
  3204. #013#010+
  3205. 'funct','ion TPackages.AddPackage(const AName: String): TPackage;'#013#010+
  3206. 'begin'#013#010+
  3207. ' Result:=Add as TPackage;'#013#010+
  3208. ' Result.Name:=AName;'#013#010+
  3209. 'end;'#013#010+
  3210. #013#010+
  3211. #013#010+
  3212. '{*********************************************************************'+
  3213. '*******'#013#010+
  3214. ' TCusto','mDefaults'#013#010+
  3215. '**********************************************************************'+
  3216. '******}'#013#010+
  3217. #013#010+
  3218. 'procedure TCustomDefaults.SetCPU(const AValue: TCPU);'#013#010+
  3219. 'begin'#013#010+
  3220. ' FCPU:=AValue;'#013#010+
  3221. ' RecalcTarget;'#013#010+
  3222. 'end;'#013#010+
  3223. #013#010+
  3224. 'procedure TCustomDefaults.SetOptions(const A','Value: TStrings);'#013#010+
  3225. 'begin'#013#010+
  3226. ' If (AValue=Nil) or (AValue.Count=0) then'#013#010+
  3227. ' FreeAndNil(Foptions)'#013#010+
  3228. ' else'#013#010+
  3229. ' Options.Assign(AValue)'#013#010+
  3230. 'end;'#013#010+
  3231. #013#010+
  3232. #013#010+
  3233. 'function TCustomDefaults.GetBaseInstallDir: String;'#013#010+
  3234. 'begin'#013#010+
  3235. ' If (FBaseInstallDir<>'#039#039') then'#013#010+
  3236. ' R','esult:=FBaseInstallDir'#013#010+
  3237. ' else'#013#010+
  3238. ' if UnixPaths then'#013#010+
  3239. ' Result:=Prefix +'#039'lib'#039' + PathDelim + '#039'fpc'#039' + Path'+
  3240. 'Delim + FCompilerVersion + PathDelim'#013#010+
  3241. ' else'#013#010+
  3242. ' Result:=Prefix;'#013#010+
  3243. 'end;'#013#010+
  3244. #013#010+
  3245. #013#010+
  3246. 'function TCustomDefaults.GetBinInstallDir: String;',#013#010+
  3247. 'begin'#013#010+
  3248. ' If (FBinInstallDir<>'#039#039') then'#013#010+
  3249. ' Result:=FBinInstallDir'#013#010+
  3250. ' else'#013#010+
  3251. ' If UnixPaths then'#013#010+
  3252. ' Result:=Prefix+'#039'bin'#039#013#010+
  3253. ' else'#013#010+
  3254. ' Result:=BaseInstallDir+'#039'bin'#039';'#013#010+
  3255. 'end;'#013#010+
  3256. #013#010+
  3257. #013#010+
  3258. 'function TCustomDefaults.GetCompiler: String;'#013#010+
  3259. 'begin'#013#010+
  3260. ' ',' If (FCompiler<>'#039#039') then'#013#010+
  3261. ' Result:=FCompiler'#013#010+
  3262. ' else'#013#010+
  3263. ' Result:='#039'fpc'#039';'#013#010+
  3264. 'end;'#013#010+
  3265. #013#010+
  3266. #013#010+
  3267. 'function TCustomDefaults.GetDocInstallDir: String;'#013#010+
  3268. 'begin'#013#010+
  3269. ' If (FDocInstallDir<>'#039#039') then'#013#010+
  3270. ' Result:=FDocInstallDir'#013#010+
  3271. ' else'#013#010+
  3272. ' If UnixPaths then'#013#010+
  3273. ' ',' Result:=Prefix+'#039'share'#039'+PathDelim+'#039'doc'#039#013#010+
  3274. ' else'#013#010+
  3275. ' Result:=BaseInstallDir+'#039'docs'#039';'#013#010+
  3276. 'end;'#013#010+
  3277. #013#010+
  3278. #013#010+
  3279. 'function TCustomDefaults.GetExamplesInstallDir: String;'#013#010+
  3280. 'begin'#013#010+
  3281. ' If (FExamplesInstallDir<>'#039#039') then'#013#010+
  3282. ' Result:=FExamplesInstallDir'#013#010+
  3283. ' els','e'#013#010+
  3284. ' If UnixPaths then'#013#010+
  3285. ' Result:=Prefix+'#039'share'#039'+PathDelim+'#039'doc'#039#013#010+
  3286. ' else'#013#010+
  3287. ' Result:=BaseInstallDir+'#039'examples'#039';'#013#010+
  3288. 'end;'#013#010+
  3289. #013#010+
  3290. 'function TCustomDefaults.GetOptions: TStrings;'#013#010+
  3291. 'begin'#013#010+
  3292. ' If (FOptions=Nil) then'#013#010+
  3293. ' FOptions:=TStringList.C','reate;'#013#010+
  3294. ' Result:=FOptions;'#013#010+
  3295. 'end;'#013#010+
  3296. #013#010+
  3297. #013#010+
  3298. 'function TCustomDefaults.GetUnitInstallDir: String;'#013#010+
  3299. 'begin'#013#010+
  3300. ' Dictionary.AddVariable('#039'target'#039',Target);'#013#010+
  3301. ' Dictionary.AddVariable('#039'BaseInstallDir'#039',BaseInstallDir);'#013+
  3302. #010+
  3303. ' result := FixPath(Dictionary.Replac','eStrings(FUnitInstallDir));'#013+
  3304. #010+
  3305. 'end;'#013#010+
  3306. #013#010+
  3307. #013#010+
  3308. 'function TCustomDefaults.GetLocalUnitDir: String;'#013#010+
  3309. 'begin'#013#010+
  3310. ' Result:=FLocalUnitDir;'#013#010+
  3311. 'end;'#013#010+
  3312. #013#010+
  3313. 'function TCustomDefaults.GetFPDocOutputDir: String;'#013#010+
  3314. 'begin'#013#010+
  3315. ' If (FFPDocOutputDir<>'#039#039') then'#013#010+
  3316. ' Result:=Incl','udeTrailingPathDelimiter(FixPath(FFPDocOutputDir))'#013+
  3317. #010+
  3318. ' else'#013#010+
  3319. ' Result:=IncludeTrailingPathDelimiter(FixPath('#039'.'#039'+PathDelim'+
  3320. '+'#039'docs'#039'));'#013#010+
  3321. 'end;'#013#010+
  3322. #013#010+
  3323. #013#010+
  3324. 'function TCustomDefaults.GetGlobalUnitDir: String;'#013#010+
  3325. 'begin'#013#010+
  3326. ' If (FGlobalUnitDir<>'#039#039') then'#013#010+
  3327. ' R','esult:=FGlobalUnitDir'#013#010+
  3328. ' else'#013#010+
  3329. ' Result:=UnitInstallDir;'#013#010+
  3330. 'end;'#013#010+
  3331. #013#010+
  3332. #013#010+
  3333. 'procedure TCustomDefaults.SetLocalUnitDir(const AValue: String);'#013#010+
  3334. 'begin'#013#010+
  3335. ' // Use ExpandFileName to support ~/ expansion'#013#010+
  3336. ' if AValue<>'#039#039' then'#013#010+
  3337. ' FLocalUnitDir:=Include','TrailingPathDelimiter(ExpandFileName(AValu'+
  3338. 'e))'#013#010+
  3339. ' else'#013#010+
  3340. ' FLocalUnitDir:='#039#039';'#013#010+
  3341. 'end;'#013#010+
  3342. #013#010+
  3343. #013#010+
  3344. 'procedure TCustomDefaults.SetGlobalUnitDir(const AValue: String);'#013#010+
  3345. 'begin'#013#010+
  3346. ' // Use ExpandFileName to support ~/ expansion'#013#010+
  3347. ' if AValue<>'#039#039' then'#013#010+
  3348. ' FG','lobalUnitDir:=IncludeTrailingPathDelimiter(ExpandFileName(AVal'+
  3349. 'ue))'#013#010+
  3350. ' else'#013#010+
  3351. ' FGlobalUnitDir:='#039#039';'#013#010+
  3352. 'end;'#013#010+
  3353. #013#010+
  3354. #013#010+
  3355. 'procedure TCustomDefaults.SetBaseInstallDir(const AValue: String);'#013+
  3356. #010+
  3357. 'begin'#013#010+
  3358. ' // Use ExpandFileName to support ~/ expansion'#013#010+
  3359. ' if ','AValue<>'#039#039' then'#013#010+
  3360. ' FBaseInstallDir:=IncludeTrailingPathDelimiter(ExpandFileName(AValu'+
  3361. 'e))'#013#010+
  3362. ' else'#013#010+
  3363. ' FBaseInstallDir:='#039#039';'#013#010+
  3364. ' BinInstallDir:='#039#039';'#013#010+
  3365. ' ExamplesInstallDir:='#039#039';'#013#010+
  3366. 'end;'#013#010+
  3367. #013#010+
  3368. #013#010+
  3369. 'procedure TCustomDefaults.SetOS(const AValue: TOS);'#013#010+
  3370. 'be','gin'#013#010+
  3371. ' FOS:=AValue;'#013#010+
  3372. ' Recalctarget;'#013#010+
  3373. 'end;'#013#010+
  3374. #013#010+
  3375. #013#010+
  3376. 'procedure TCustomDefaults.SetPrefix(const AValue: String);'#013#010+
  3377. 'begin'#013#010+
  3378. ' if FPrefix=AValue then exit;'#013#010+
  3379. ' FPrefix:=IncludeTrailingPathDelimiter(AValue);'#013#010+
  3380. ' BaseInstallDir:='#039#039';'#013#010+
  3381. 'end;'#013#010+
  3382. #013#010+
  3383. #013#010+
  3384. 'procedure ','TCustomDefaults.SetTarget(const AValue: String);'#013#010+
  3385. 'Var'#013#010+
  3386. ' P : Integer;'#013#010+
  3387. 'begin'#013#010+
  3388. ' if FTarget<>AValue then'#013#010+
  3389. ' begin'#013#010+
  3390. ' P:=Pos('#039'-'#039',AValue);'#013#010+
  3391. ' If (P<>0) then'#013#010+
  3392. ' begin'#013#010+
  3393. ' FOS:=StringToOS(System.Copy(Avalue,P+1,Length(AVal','ue)-P));'+
  3394. #013#010+
  3395. ' FCPU:=StringToCPU(System.Copy(Avalue,1,P-1));'#013#010+
  3396. ' end'#013#010+
  3397. ' else'#013#010+
  3398. ' FOS:=StringToOS(AValue);'#013#010+
  3399. ' FTarget:=AValue;'#013#010+
  3400. ' end;'#013#010+
  3401. 'end;'#013#010+
  3402. #013#010+
  3403. 'procedure TCustomDefaults.SetUnitInstallDir(const AValue: String);'#013+
  3404. #010+
  3405. 'begi','n'#013#010+
  3406. ' if AValue<>'#039#039' then'#013#010+
  3407. ' FUnitInstallDir:=IncludeTrailingPathDelimiter(AValue)'#013#010+
  3408. ' else'#013#010+
  3409. ' FUnitInstallDir:='#039#039';'#013#010+
  3410. 'end;'#013#010+
  3411. #013#010+
  3412. #013#010+
  3413. 'procedure TCustomDefaults.RecalcTarget;'#013#010+
  3414. 'begin'#013#010+
  3415. ' Ftarget:=CPUToString(FCPU)+'#039'-'#039'+OStoString(FOS);'#013#010+
  3416. 'end;'#013#010+
  3417. #013#010+
  3418. 'funct','ion TCustomDefaults.CmdLineOptions: String;'#013#010+
  3419. 'begin'#013#010+
  3420. ' If Haveoptions then'#013#010+
  3421. ' Result:=OptionListToString(FOptions);'#013#010+
  3422. 'end;'#013#010+
  3423. #013#010+
  3424. #013#010+
  3425. 'constructor TCustomDefaults.Create;'#013#010+
  3426. 'begin'#013#010+
  3427. ' InitDefaults;'#013#010+
  3428. 'end;'#013#010+
  3429. #013#010+
  3430. #013#010+
  3431. 'procedure TCustomDefaults.InitDefaults;'#013#010,
  3432. 'begin'#013#010+
  3433. '{$ifdef unix}'#013#010+
  3434. ' UnixPaths:=True;'#013#010+
  3435. '{$else}'#013#010+
  3436. ' UnixPaths:=False;'#013#010+
  3437. '{$endif}'#013#010+
  3438. ' FNoFPCCfg:=False;'#013#010+
  3439. ' FCPU:=cpuNone;'#013#010+
  3440. ' FOS:=osNone;'#013#010+
  3441. ' FUnitInstallDir:='#039'$(BaseInstallDir)units/$(target)/$(packagename'+
  3442. ')'#039';'#013#010+
  3443. ' FBuildMode:=bmOneByOne;'#013#010+
  3444. 'end;'#013,#010+
  3445. #013#010+
  3446. 'function TCustomDefaults.HaveOptions: Boolean;'#013#010+
  3447. 'begin'#013#010+
  3448. ' Result:=Assigned(FOptions);'#013#010+
  3449. 'end;'#013#010+
  3450. #013#010+
  3451. #013#010+
  3452. 'procedure TCustomDefaults.LocalInit(Const AFileName : String);'#013#010+
  3453. 'Var'#013#010+
  3454. ' FN : String;'#013#010+
  3455. 'begin'#013#010+
  3456. ' FN:=AFileName;'#013#010+
  3457. ' If (FN='#039#039') then'#013#010+
  3458. ' begin'#013#010+
  3459. ' ',' // Environment variable.'#013#010+
  3460. ' FN:=GetEnvironmentVariable('#039'FPMAKECFG'#039');'#013#010+
  3461. ' If (FN<>'#039#039') then'#013#010+
  3462. ' If not FileExists(FN) then'#013#010+
  3463. ' FN:='#039#039';'#013#010+
  3464. ' // User config file fpmake.cfg'#013#010+
  3465. ' If (FN='#039#039') then'#013#010+
  3466. ' begin'#013#010+
  3467. ' FN:=GetAppConfig','File(False);'#013#010+
  3468. ' If Not FileExists(FN) then'#013#010+
  3469. ' FN:='#039#039';'#013#010+
  3470. ' end;'#013#010+
  3471. ' // Global config file fpmake.cfg'#013#010+
  3472. ' If (FN='#039#039') then'#013#010+
  3473. ' begin'#013#010+
  3474. ' FN:=GetAppConfigFile(True);'#013#010+
  3475. ' If Not FileExists(FN) then'#013#010+
  3476. ' FN:='#039#039';'#013#010+
  3477. ' ',' end;'#013#010+
  3478. ' end;'#013#010+
  3479. ' If (FN<>'#039#039') and FileExists(FN) then'#013#010+
  3480. ' LoadFromFile(FN);'#013#010+
  3481. 'end;'#013#010+
  3482. #013#010+
  3483. #013#010+
  3484. 'procedure TCustomDefaults.CompilerDefaults;'#013#010+
  3485. '{$ifdef HAS_UNIT_PROCESS}'#013#010+
  3486. 'var'#013#010+
  3487. ' infoSL : TStringList;'#013#010+
  3488. '{$endif HAS_UNIT_PROCESS}'#013#010+
  3489. 'begin'#013#010+
  3490. ' if (CPU=cpuNo','ne) or (OS=osNone) or (FCompilerVersion='#039#039') the'+
  3491. 'n'#013#010+
  3492. ' begin'#013#010+
  3493. '{$ifdef HAS_UNIT_PROCESS}'#013#010+
  3494. ' // Detect compiler version/target from -i option'#013#010+
  3495. ' infosl:=TStringList.Create;'#013#010+
  3496. ' infosl.Delimiter:='#039' '#039';'#013#010+
  3497. ' infosl.DelimitedText:=Get','CompilerInfo(GetCompiler,'#039'-iVTPTO'+
  3498. #039');'#013#010+
  3499. ' if infosl.Count<>3 then'#013#010+
  3500. ' Raise EInstallerError.Create(SErrInvalidFPCInfo);'#013#010+
  3501. ' if FCompilerVersion='#039#039' then'#013#010+
  3502. ' FCompilerVersion:=infosl[0];'#013#010+
  3503. ' if CPU=cpuNone then'#013#010+
  3504. ' CPU:','=StringToCPU(infosl[1]);'#013#010+
  3505. ' if OS=osNone then'#013#010+
  3506. ' OS:=StringToOS(infosl[2]);'#013#010+
  3507. '{$else HAS_UNIT_PROCESS}'#013#010+
  3508. ' // Defaults taken from compiler used to build fpmake'#013#010+
  3509. ' if CPU=cpuNone then'#013#010+
  3510. ' CPU:=StringToCPU({$I %FPCTARGETC','PU%});'#013#010+
  3511. ' if OS=osNone then'#013#010+
  3512. ' OS:=StringToOS({$I %FPCTARGETOS%});'#013#010+
  3513. ' if FCompilerVersion='#039#039' then'#013#010+
  3514. ' FCompilerVersion:={$I %FPCVERSION%};'#013#010+
  3515. '{$endif HAS_UNIT_PROCESS}'#013#010+
  3516. ' end;'#013#010+
  3517. 'end;'#013#010+
  3518. #013#010+
  3519. #013#010+
  3520. 'procedure TCustomDefaults.LoadFrom','File(Const AFileName: String);'#013+
  3521. #010+
  3522. 'Var'#013#010+
  3523. ' F : TFileStream;'#013#010+
  3524. 'begin'#013#010+
  3525. ' F:=TFileStream.Create(AFileName,fmOpenRead);'#013#010+
  3526. ' Try'#013#010+
  3527. ' LoadFromStream(F);'#013#010+
  3528. ' Finally'#013#010+
  3529. ' F.Free;'#013#010+
  3530. ' end;'#013#010+
  3531. 'end;'#013#010+
  3532. #013#010+
  3533. #013#010+
  3534. 'procedure TCustomDefaults.SaveToFile(Const AFileName: S','tring);'#013#010+
  3535. 'Var'#013#010+
  3536. ' F : TFileStream;'#013#010+
  3537. 'begin'#013#010+
  3538. ' F:=TFileStream.Create(AFileName,fmCreate);'#013#010+
  3539. ' Try'#013#010+
  3540. ' SaveToStream(F);'#013#010+
  3541. ' Finally'#013#010+
  3542. ' F.Free;'#013#010+
  3543. ' end;'#013#010+
  3544. 'end;'#013#010+
  3545. #013#010+
  3546. #013#010+
  3547. 'procedure TCustomDefaults.SaveToStream(S : TStream);'#013#010+
  3548. 'Var'#013#010+
  3549. ' L : TStringList;'#013#010+
  3550. 'beg','in'#013#010+
  3551. ' L:=TStringList.Create;'#013#010+
  3552. ' try'#013#010+
  3553. ' With L do'#013#010+
  3554. ' begin'#013#010+
  3555. ' Values[KeyArchive]:=FArchive;'#013#010+
  3556. ' Values[KeyCompiler]:=FCompiler;'#013#010+
  3557. ' Values[KeyCopy]:=FCopy;'#013#010+
  3558. ' Values[KeyMkDir]:=FMkDir;'#013#010+
  3559. ' Values[KeyMove]:=FMove;'#013#010+
  3560. ' ',' Values[KeyOptions]:=CmdLineOptions;'#013#010+
  3561. ' Values[KeyCPU]:=CPUToString(FCPU);'#013#010+
  3562. ' Values[KeyOS]:=OSToString(FOS);'#013#010+
  3563. ' Values[KeyMode]:=ModeToString(FMode);'#013#010+
  3564. ' Values[KeyLocalUnitDir]:=FLocalUnitDir;'#013#010+
  3565. ' Values[KeyGlobalUnitDi','r]:=FGlobalUnitDir;'#013#010+
  3566. ' Values[KeyPrefix]:=FPrefix;'#013#010+
  3567. ' Values[KeyBaseInstallDir]:=FBaseInstallDir;'#013#010+
  3568. ' Values[KeyUnitInstallDir]:=FUnitInstallDir;'#013#010+
  3569. ' Values[KeyBinInstallDir]:=FBinInstallDir;'#013#010+
  3570. ' Values[KeyDocInstallDir]:=F','DocInstallDir;'#013#010+
  3571. ' Values[KeyExamplesInstallDir]:=FExamplesInstallDir;'#013#010+
  3572. ' Values[KeyRemove]:=FRemove;'#013#010+
  3573. ' Values[KeyRemoveDir]:=FRemoveDir;'#013#010+
  3574. ' Values[KeyRemoveTree]:=FRemoveTree;'#013#010+
  3575. ' Values[KeyTarget]:=FTarget;'#013#010+
  3576. ' if FN','oFPCCfg then'#013#010+
  3577. ' Values[KeyNoFPCCfg]:='#039'Y'#039';'#013#010+
  3578. ' if FUseEnvironment then'#013#010+
  3579. ' Values[KeyUseEnv]:='#039'Y'#039';'#013#010+
  3580. ' if FInstallExamples then'#013#010+
  3581. ' Values[KeyInstallExamples]:='#039'Y'#039';'#013#010+
  3582. ' end;'#013#010+
  3583. ' L.SaveToStream(S);'#013#010+
  3584. ' Finally'#013#010+
  3585. ' ','L.Free;'#013#010+
  3586. ' end;'#013#010+
  3587. 'end;'#013#010+
  3588. #013#010+
  3589. #013#010+
  3590. 'procedure TCustomDefaults.LoadFromStream(S: TStream);'#013#010+
  3591. 'Var'#013#010+
  3592. ' L : TStrings;'#013#010+
  3593. ' Line : String;'#013#010+
  3594. ' I,P,PC : Integer;'#013#010+
  3595. 'begin'#013#010+
  3596. ' L:=TStringList.Create;'#013#010+
  3597. ' Try'#013#010+
  3598. ' L.LoadFromStream(S);'#013#010+
  3599. ' // Fix lines.'#013#010+
  3600. ' For I:=L','.Count-1 downto 0 do'#013#010+
  3601. ' begin'#013#010+
  3602. ' Line:=L[I];'#013#010+
  3603. ' P:=Pos('#039'='#039',Line);'#013#010+
  3604. ' PC:=Pos('#039';'#039',Line); // Comment line.'#013#010+
  3605. ' If (P=0) or ((PC<>0) and (PC<P)) then'#013#010+
  3606. ' L.Delete(I)'#013#010+
  3607. ' else'#013#010+
  3608. ' L[i]:=Trim(System.Copy(Line,1,P','-1)+'#039'='#039'+Trim(System.C'+
  3609. 'opy(Line,P+1,Length(Line)-P)));'#013#010+
  3610. ' end;'#013#010+
  3611. ' With L do'#013#010+
  3612. ' begin'#013#010+
  3613. ' FArchive:=Values[KeyArchive];'#013#010+
  3614. ' FCompiler:=Values[KeyCompiler];'#013#010+
  3615. ' FCopy:=Values[KeyCopy];'#013#010+
  3616. ' FMkDir:=Values[KeyMkDir];'#013#010+
  3617. ' ','FMove:=Values[KeyMove];'#013#010+
  3618. ' FRemove:=Values[KeyRemove];'#013#010+
  3619. ' FRemoveDir:=Values[KeyRemoveDir];'#013#010+
  3620. ' FRemoveTree:=Values[KeyRemoveTree];'#013#010+
  3621. ' Options:=OptionsToStringList(Values[KeyOptions]);'#013#010+
  3622. ' Line:=Values[KeyCPU];'#013#010+
  3623. ' If (','Line<>'#039#039') then'#013#010+
  3624. ' FCPU:=StringToCPU(Line);'#013#010+
  3625. ' Line:=Values[KeyOS];'#013#010+
  3626. ' If (Line<>'#039#039') then'#013#010+
  3627. ' FOS:=StringToOS(Line);'#013#010+
  3628. ' Line:=Values[KeyMode];'#013#010+
  3629. ' If (Line<>'#039#039') then'#013#010+
  3630. ' FMode:=StringToMode(Line);'#013#010+
  3631. ' FTarge','t:=Values[KeyTarget];'#013#010+
  3632. ' FLocalUnitDir:=Values[KeyLocalUnitDir];'#013#010+
  3633. ' FGlobalUnitDir:=Values[KeyGlobalUnitDir];'#013#010+
  3634. ' FPrefix:=Values[KeyPrefix];'#013#010+
  3635. ' FBaseInstallDir:=Values[KeyBaseInstallDir];'#013#010+
  3636. ' FUnitInstallDir:=Values[KeyUn','itInstallDir];'#013#010+
  3637. ' FBinInstallDir:=Values[KeyBinInstallDir];'#013#010+
  3638. ' FDocInstallDir:=Values[KeyDocInstallDir];'#013#010+
  3639. ' FExamplesInstallDir:=Values[KeyExamplesInstallDir];'#013#010+
  3640. ' FInstallExamples:=(Upcase(Values[KeyInstallExamples])='#039'Y'#039+
  3641. ');'#013#010,
  3642. ' FNoFPCCfg:=(Upcase(Values[KeyNoFPCCfg])='#039'Y'#039');'#013#010+
  3643. ' FUseEnvironment:=(Upcase(Values[KeyUseEnv])='#039'Y'#039');'#013#010+
  3644. ' end;'#013#010+
  3645. ' Finally'#013#010+
  3646. ' L.Free;'#013#010+
  3647. ' end;'#013#010+
  3648. 'end;'#013#010+
  3649. #013#010+
  3650. #013#010+
  3651. '{*********************************************************************'+
  3652. '******','*'#013#010+
  3653. ' TFPCDefaults'#013#010+
  3654. '**********************************************************************'+
  3655. '******}'#013#010+
  3656. #013#010+
  3657. 'procedure TFPCDefaults.CompilerDefaults;'#013#010+
  3658. 'var'#013#010+
  3659. ' BD : String;'#013#010+
  3660. 'begin'#013#010+
  3661. ' inherited CompilerDefaults;'#013#010+
  3662. #013#010+
  3663. ' // Use t','he same algorithm as the compiler, see options.pas'#013#010+
  3664. '{$ifdef Unix}'#013#010+
  3665. ' BD:=FixPath(GetEnvironmentVariable('#039'FPCDIR'#039'));'#013#010+
  3666. ' if BD='#039#039' then'#013#010+
  3667. ' begin'#013#010+
  3668. ' BD:='#039'/usr/local/lib/fpc/'#039'+FCompilerVersion;'#013#010+
  3669. ' if not DirectoryExists(BD) and'#013#010+
  3670. ' ',' DirectoryExists('#039'/usr/lib/fpc/'#039'+FCompilerVersion) t'+
  3671. 'hen'#013#010+
  3672. ' BD:='#039'/usr/lib/fpc/'#039'+FCompilerVersion;'#013#010+
  3673. ' end;'#013#010+
  3674. '{$else unix}'#013#010+
  3675. ' BD:=FixPath(GetEnvironmentVariable('#039'FPCDIR'#039'));'#013#010+
  3676. ' if BD='#039#039' then'#013#010+
  3677. ' begin'#013#010+
  3678. ' BD:=ExtractFilePath(FCompi','ler)+'#039'..'#039';'#013#010+
  3679. ' if not(DirectoryExists(BD+'#039'/units'#039')) and'#013#010+
  3680. ' not(DirectoryExists(BD+'#039'/rtl'#039')) then'#013#010+
  3681. ' BD:=FBaseInstallDir+'#039'..'#039';'#013#010+
  3682. ' end;'#013#010+
  3683. '{$endif unix}'#013#010+
  3684. #013#010+
  3685. ' // Where to install by default'#013#010+
  3686. ' if (FBaseInstallDir='#039#039') and (FPrefi','x='#039#039') then'#013#010+
  3687. ' BaseInstallDir:=BD;'#013#010+
  3688. #013#010+
  3689. ' // Where to find the units by default'#013#010+
  3690. ' if (FGlobalUnitDir='#039#039') then'#013#010+
  3691. ' GlobalUnitDir:=IncludeTrailingPathDelimiter(BD)+'#039'units'#039'+Pa'+
  3692. 'thDelim+Target;'#013#010+
  3693. 'end;'#013#010+
  3694. #013#010+
  3695. #013#010+
  3696. '{***************************************','****************************'+
  3697. '*********'#013#010+
  3698. ' TCustomInstaller'#013#010+
  3699. '**********************************************************************'+
  3700. '******}'#013#010+
  3701. #013#010+
  3702. 'constructor TCustomInstaller.Create(AOwner: TComponent);'#013#010+
  3703. 'begin'#013#010+
  3704. ' Diction','ary:=DictionaryClass.Create(Nil);'#013#010+
  3705. ' AnalyzeOptions;'#013#010+
  3706. ' CreatePackages;'#013#010+
  3707. 'end;'#013#010+
  3708. #013#010+
  3709. #013#010+
  3710. 'destructor TCustomInstaller.Destroy;'#013#010+
  3711. 'begin'#013#010+
  3712. ' FreePackages;'#013#010+
  3713. ' FreeAndNil(Defaults);'#013#010+
  3714. ' FreeAndNil(Dictionary);'#013#010+
  3715. ' inherited destroy;'#013#010+
  3716. 'end;'#013#010+
  3717. #013#010+
  3718. 'function TCus','tomInstaller.GetPackages: TPackages;'#013#010+
  3719. 'begin'#013#010+
  3720. ' result := FPackages;'#013#010+
  3721. 'end;'#013#010+
  3722. #013#010+
  3723. 'procedure TCustomInstaller.Log(Level: TVerboseLevel; const Msg: String'+
  3724. ');'#013#010+
  3725. 'begin'#013#010+
  3726. ' If Level in FLogLevels then'#013#010+
  3727. ' Writeln(StdOut,Msg);'#013#010+
  3728. 'end;'#013#010+
  3729. #013#010+
  3730. #013#010+
  3731. 'procedure TCust','omInstaller.CreatePackages;'#013#010+
  3732. 'begin'#013#010+
  3733. ' FPackages:=TPackages.Create(TPackage);'#013#010+
  3734. 'end;'#013#010+
  3735. #013#010+
  3736. 'procedure TCustomInstaller.FreePackages;'#013#010+
  3737. 'begin'#013#010+
  3738. ' FreeAndNil(FPackages);'#013#010+
  3739. 'end;'#013#010+
  3740. #013#010+
  3741. #013#010+
  3742. 'procedure TCustomInstaller.CreateBuildEngine;'#013#010+
  3743. 'begin'#013#010+
  3744. ' FBuildEngine:','=TBuildEngine.Create(Self);'#013#010+
  3745. '// FBuildEngine.Defaults:=Defaults;'#013#010+
  3746. ' FBuildEngine.ListMode:=FListMode;'#013#010+
  3747. ' FBuildEngine.Verbose := (FLogLevels = AllMessages);'#013#010+
  3748. ' FBuildEngine.OnLog:[email protected];'#013#010+
  3749. 'end;'#013#010+
  3750. #013#010+
  3751. #013#010+
  3752. 'procedure TCustomInstaller.Error(cons','t Msg: String);'#013#010+
  3753. 'begin'#013#010+
  3754. ' Raise EInstallerError.Create(Msg);'#013#010+
  3755. 'end;'#013#010+
  3756. #013#010+
  3757. #013#010+
  3758. 'procedure TCustomInstaller.Error(const Fmt: String; Args: array of con'+
  3759. 'st);'#013#010+
  3760. 'begin'#013#010+
  3761. ' Raise EInstallerError.CreateFmt(Fmt,Args);'#013#010+
  3762. 'end;'#013#010+
  3763. #013#010+
  3764. #013#010+
  3765. 'Function TCustomInstaller.Add','Package(const AName: String) : TPackage'+
  3766. ';'#013#010+
  3767. 'begin'#013#010+
  3768. ' result:=Packages.AddPackage(AName);'#013#010+
  3769. 'end;'#013#010+
  3770. #013#010+
  3771. #013#010+
  3772. 'procedure TCustomInstaller.AnalyzeOptions;'#013#010+
  3773. #013#010+
  3774. ' Function CheckOption(Index : Integer;const Short,Long : String; AddT'+
  3775. 'oOptionString: boolean = t','rue): Boolean;'#013#010+
  3776. ' var'#013#010+
  3777. ' O : String;'#013#010+
  3778. ' begin'#013#010+
  3779. ' O:=Paramstr(Index);'#013#010+
  3780. ' Result:=(O='#039'-'#039'+short) or (O='#039'--'#039'+long) or (copy(O,'+
  3781. '1,Length(Long)+3)=('#039'--'#039'+long+'#039'='#039'));'#013#010+
  3782. ' if AddToOptionString and Result then FFPMakeOptionsString := FFPMa'+
  3783. 'keOpt','ionsString+'#039' '#039'+O;'#013#010+
  3784. ' end;'#013#010+
  3785. #013#010+
  3786. ' Function CheckCustomOption(Index : Integer; out CustOptName: string)'+
  3787. ': Boolean;'#013#010+
  3788. ' var'#013#010+
  3789. ' O : String;'#013#010+
  3790. ' i : integer;'#013#010+
  3791. ' begin'#013#010+
  3792. ' result := false;'#013#010+
  3793. ' CustOptName:='#039#039';'#013#010+
  3794. ' O:=Paramstr(Index);'#013#010+
  3795. ' if co','py(O,1,2)<>'#039'--'#039' then'#013#010+
  3796. ' Exit;'#013#010+
  3797. ' i := pos('#039'='#039',O);'#013#010+
  3798. ' if i=0 then'#013#010+
  3799. ' Exit;'#013#010+
  3800. ' O:=copy(O,3,i-3);'#013#010+
  3801. ' CustOptName:=O;'#013#010+
  3802. ' Result:=CustomFpmakeCommandlineOptions.IndexOfName(O)>-1;'#013#010+
  3803. ' if Result then FFPMakeOptionsString := FFP','MakeOptionsString+'#039+
  3804. ' '#039'+Paramstr(Index);'#013#010+
  3805. ' end;'#013#010+
  3806. #013#010+
  3807. #013#010+
  3808. ' Function CheckCommand(Index : Integer;const Short,Long : String): Bo'+
  3809. 'olean;'#013#010+
  3810. ' var'#013#010+
  3811. ' O : String;'#013#010+
  3812. ' begin'#013#010+
  3813. ' O:=Paramstr(Index);'#013#010+
  3814. ' Result:=(O='#039'-'#039'+short) or (O=long);'#013#010+
  3815. ' end;'#013#010+
  3816. #013#010+
  3817. ' ','Function OptionArg(Var Index : Integer) : String;'#013#010+
  3818. ' Var'#013#010+
  3819. ' P : Integer;'#013#010+
  3820. ' begin'#013#010+
  3821. ' if (Length(ParamStr(Index))>1) and (Paramstr(Index)[2]<>'#039'-'#039+
  3822. ') then'#013#010+
  3823. ' begin'#013#010+
  3824. ' If Index<ParamCount then'#013#010+
  3825. ' begin'#013#010+
  3826. ' Inc(Index);'#013#010+
  3827. ' ',' Result:=Paramstr(Index);'#013#010+
  3828. ' end'#013#010+
  3829. ' else'#013#010+
  3830. ' Error(SErrNeedArgument,[Index,ParamStr(Index)]);'#013#010+
  3831. ' end'#013#010+
  3832. ' else If length(ParamStr(Index))>2 then'#013#010+
  3833. ' begin'#013#010+
  3834. ' P:=Pos('#039'='#039',Paramstr(Index));'#013#010+
  3835. ' If (P=0) then'#013#010+
  3836. ' ',' Error(SErrNeedArgument,[Index,ParamStr(Index)])'#013#010+
  3837. ' else'#013#010+
  3838. ' begin'#013#010+
  3839. ' Result:=Paramstr(Index);'#013#010+
  3840. ' Delete(Result,1,P);'#013#010+
  3841. ' end;'#013#010+
  3842. ' end;'#013#010+
  3843. ' end;'#013#010+
  3844. #013#010+
  3845. ' function SplitSpaces(var SplitString: string) : string;'#013,#010+
  3846. ' var i : integer;'#013#010+
  3847. ' begin'#013#010+
  3848. ' i := pos('#039' '#039',SplitString);'#013#010+
  3849. ' if i > 0 then'#013#010+
  3850. ' begin'#013#010+
  3851. ' result := copy(SplitString,1,i-1);'#013#010+
  3852. ' delete(SplitString,1,i);'#013#010+
  3853. ' end'#013#010+
  3854. ' else'#013#010+
  3855. ' begin'#013#010+
  3856. ' result := SplitString;'#013#010+
  3857. ' ',' SplitString:='#039#039';'#013#010+
  3858. ' end;'#013#010+
  3859. ' end;'#013#010+
  3860. #013#010+
  3861. 'Var'#013#010+
  3862. ' I : Integer;'#013#010+
  3863. ' DefaultsFileName : string;'#013#010+
  3864. ' OptString : string;'#013#010+
  3865. ' CustOptName : string;'#013#010+
  3866. 'begin'#013#010+
  3867. ' I:=0;'#013#010+
  3868. ' FListMode:=False;'#013#010+
  3869. ' FLogLevels:=DefaultMessages;'#013#010+
  3870. ' While (I<ParamCount) do'#013,#010+
  3871. ' begin'#013#010+
  3872. ' Inc(I);'#013#010+
  3873. ' if CheckOption(I,'#039'v'#039','#039'verbose'#039',false) then'#013#010+
  3874. ' FLogLevels:=AllMessages'#013#010+
  3875. ' else if CheckOption(I,'#039'd'#039','#039'debug'#039',false) then'#013#010+
  3876. ' FLogLevels:=AllMessages+[vlDebug]'#013#010+
  3877. ' else if CheckCommand(I,'#039'm'#039','#039'compile'#039') th','en'#013#010+
  3878. ' FRunMode:=rmCompile'#013#010+
  3879. ' else if CheckCommand(I,'#039'b'#039','#039'build'#039') then'#013#010+
  3880. ' FRunMode:=rmBuild'#013#010+
  3881. ' else if CheckCommand(I,'#039'i'#039','#039'install'#039') then'#013#010+
  3882. ' FRunMode:=rmInstall'#013#010+
  3883. ' else if CheckCommand(I,'#039'c'#039','#039'clean'#039') then'#013#010+
  3884. ' FRunMode:=r','mClean'#013#010+
  3885. ' else if CheckCommand(I,'#039'dc'#039','#039'distclean'#039') then'#013#010+
  3886. ' FRunMode:=rmDistClean'#013#010+
  3887. ' else if CheckCommand(I,'#039'a'#039','#039'archive'#039') then'#013#010+
  3888. ' FRunMode:=rmarchive'#013#010+
  3889. ' else if CheckCommand(I,'#039'M'#039','#039'manifest'#039') then'#013#010+
  3890. ' FRunMode:=rmManifest'#013#010,
  3891. ' else if CheckOption(I,'#039'h'#039','#039'help'#039') then'#013#010+
  3892. ' Usage('#039#039',[])'#013#010+
  3893. ' else if Checkoption(I,'#039'C'#039','#039'cpu'#039') then'#013#010+
  3894. ' Defaults.CPU:=StringToCPU(OptionArg(I))'#013#010+
  3895. ' else if Checkoption(I,'#039'O'#039','#039'os'#039') then'#013#010+
  3896. ' Defaults.OS:=StringToOS(OptionArg(I))'#013,#010+
  3897. ' else if Checkoption(I,'#039't'#039','#039'target'#039') then'#013#010+
  3898. ' Defaults.Target:=OptionArg(I)'#013#010+
  3899. ' else if CheckOption(I,'#039'l'#039','#039'list-commands'#039') then'#013+
  3900. #010+
  3901. ' FListMode:=True'#013#010+
  3902. ' else if Checkoption(I,'#039'P'#039','#039'prefix'#039') then'#013#010+
  3903. ' Defaults.Prefix:=OptionArg(I',')'#013#010+
  3904. ' else if Checkoption(I,'#039'n'#039','#039'nofpccfg'#039') then'#013#010+
  3905. ' Defaults.NoFPCCfg:=true'#013#010+
  3906. '{$ifdef HAS_UNIT_PROCESS}'#013#010+
  3907. ' else if Checkoption(I,'#039'e'#039','#039'useenv'#039') then'#013#010+
  3908. ' Defaults.UseEnvironment:=true'#013#010+
  3909. '{$endif}'#013#010+
  3910. ' else if CheckOption(I,'#039'B'#039','#039'baseins','talldir'#039') then'+
  3911. #013#010+
  3912. ' Defaults.BaseInstallDir:=OptionArg(I)'#013#010+
  3913. ' else if CheckOption(I,'#039'U'#039','#039'unitinstalldir'#039') then'#013+
  3914. #010+
  3915. ' Defaults.UnitInstallDir:=OptionArg(I)'#013#010+
  3916. ' else if CheckOption(I,'#039'UL'#039','#039'localunitdir'#039') then'#013+
  3917. #010+
  3918. ' Defaults.LocalUnitDir',':=OptionArg(I)'#013#010+
  3919. ' else if CheckOption(I,'#039'UG'#039','#039'globalunitdir'#039') then'#013+
  3920. #010+
  3921. ' Defaults.GlobalUnitDir:=OptionArg(I)'#013#010+
  3922. ' else if CheckOption(I,'#039'o'#039','#039'options'#039') then'#013#010+
  3923. ' begin'#013#010+
  3924. ' OptString := OptionArg(I);'#013#010+
  3925. ' while OptString <> '#039#039' ','do'#013#010+
  3926. ' Defaults.Options.Add(SplitSpaces(OptString));'#013#010+
  3927. ' end'#013#010+
  3928. ' else if CheckOption(I,'#039'r'#039','#039'compiler'#039') then'#013#010+
  3929. ' Defaults.Compiler:=OptionArg(I)'#013#010+
  3930. ' else if CheckOption(I,'#039'f'#039','#039'config'#039') then'#013#010+
  3931. ' DefaultsFileName:=OptionArg(I',')'#013#010+
  3932. ' else if CheckOption(I,'#039'ie'#039','#039'installexamples'#039') then'+
  3933. #013#010+
  3934. ' Defaults.InstallExamples:=true'#013#010+
  3935. ' else if CheckOption(I,'#039'bu'#039','#039'buildunit'#039') then'#013#010+
  3936. ' Defaults.BuildMode:=bmBuildUnit'#013#010+
  3937. ' else if CheckOption(I,'#039'io'#039','#039'ignoreinvalidoption'#039') ',
  3938. 'then'#013#010+
  3939. ' Defaults.IgnoreInvalidOptions:=true'#013#010+
  3940. ' else if CheckOption(I,'#039'd'#039','#039'doc-folder'#039') then'#013#010+
  3941. ' Defaults.FPDocOutputDir:=OptionArg(I)'#013#010+
  3942. ' else if assigned(CustomFpmakeCommandlineOptions) and CheckCustomOp'+
  3943. 'tion(I,CustOptName) then'#013#010,
  3944. ' begin'#013#010+
  3945. ' if not assigned(CustomFpMakeCommandlineValues) then'#013#010+
  3946. ' CustomFpMakeCommandlineValues := TStringList.Create;'#013#010+
  3947. ' CustomFpMakeCommandlineValues.Values[CustOptName]:=OptionArg(I)'#013+
  3948. #010+
  3949. ' end'#013#010+
  3950. ' else if not Defaults','.IgnoreInvalidOptions then'#013#010+
  3951. ' begin'#013#010+
  3952. ' Usage(SErrInValidArgument,[I,ParamStr(I)]);'#013#010+
  3953. ' end;'#013#010+
  3954. ' end;'#013#010+
  3955. ' If DefaultsFileName<>'#039#039' then'#013#010+
  3956. ' Defaults.LocalInit(DefaultsFileName);'#013#010+
  3957. ' Defaults.CompilerDefaults;'#013#010+
  3958. 'end;'#013#010+
  3959. #013#010+
  3960. #013#010+
  3961. 'procedure T','CustomInstaller.Usage(const FMT: String; Args: array of c'+
  3962. 'onst);'#013#010+
  3963. #013#010+
  3964. ' Procedure LogCmd(const LC,Msg : String);'#013#010+
  3965. ' begin'#013#010+
  3966. ' Log(vlInfo,Format('#039' %-12s %s'#039',[LC,MSG]));'#013#010+
  3967. ' end;'#013#010+
  3968. #013#010+
  3969. ' Procedure LogOption(const C,LC,Msg : String);'#013#010+
  3970. ' begin'#013#010+
  3971. ' L','og(vlInfo,Format('#039' -%s --%-16s %s'#039',[C,LC,MSG]));'#013#010+
  3972. ' end;'#013#010+
  3973. #013#010+
  3974. ' Procedure LogArgOption(const C,LC,Msg : String);'#013#010+
  3975. ' begin'#013#010+
  3976. ' Log(vlInfo,Format('#039' -%s --%-20s %s'#039',[C,LC+'#039'='#039'+SVal'+
  3977. 'ue,MSG]));'#013#010+
  3978. ' end;'#013#010+
  3979. #013#010+
  3980. 'var'#013#010+
  3981. ' i: Integer;'#013#010+
  3982. 'begin'#013#010+
  3983. ' // Force the U','sage to be displayed'#013#010+
  3984. ' Include(FLogLevels,vlInfo);'#013#010+
  3985. ' If (FMT<>'#039#039') then'#013#010+
  3986. ' Log(vlInfo,Format(Fmt,Args));'#013#010+
  3987. ' Log(vlInfo,Format(SHelpUsage,[Paramstr(0)]));'#013#010+
  3988. ' Log(vlInfo,SHelpCommand);'#013#010+
  3989. ' LogCmd('#039'compile'#039',SHelpCompile);'#013#010+
  3990. ' LogCmd('#039'build'#039',S','HelpBuild);'#013#010+
  3991. ' LogCmd('#039'install'#039',SHelpInstall);'#013#010+
  3992. ' LogCmd('#039'clean'#039',SHelpClean);'#013#010+
  3993. ' LogCmd('#039'archive'#039',SHelpArchive);'#013#010+
  3994. ' LogCmd('#039'manifest'#039',SHelpManifest);'#013#010+
  3995. ' Log(vlInfo,SHelpCmdOptions);'#013#010+
  3996. ' LogOption('#039'h'#039','#039'help'#039',SHelpHelp);'#013#010+
  3997. ' LogOption('#039'l'#039','#039'list','-commands'#039',SHelpList);'#013#010+
  3998. ' LogOption('#039'n'#039','#039'nofpccfg'#039',SHelpNoFPCCfg);'#013#010+
  3999. ' LogOption('#039'v'#039','#039'verbose'#039',SHelpVerbose);'#013#010+
  4000. '{$ifdef HAS_UNIT_PROCESS}'#013#010+
  4001. ' LogOption('#039'e'#039', '#039'useenv'#039', sHelpUseEnvironment);'#013#010+
  4002. '{$endif}'#013#010+
  4003. ' LogOption('#039'ie'#039','#039'installexamples'#039',SHelpIns','tExamples'+
  4004. ');'#013#010+
  4005. ' LogOption('#039'bu'#039','#039'buildunit'#039',SHelpUseBuildUnit);'#013#010+
  4006. ' LogArgOption('#039'C'#039','#039'cpu'#039',SHelpCPU);'#013#010+
  4007. ' LogArgOption('#039'O'#039','#039'os'#039',SHelpOS);'#013#010+
  4008. ' LogArgOption('#039't'#039','#039'target'#039',SHelpTarget);'#013#010+
  4009. ' LogArgOption('#039'P'#039','#039'prefix'#039',SHelpPrefix);'#013#010+
  4010. ' LogArgOption('#039'B'#039',',#039'baseinstalldir'#039',SHelpBaseInstalldi'+
  4011. 'r);'#013#010+
  4012. ' LogArgOption('#039'UL'#039','#039'localunitdir'#039',SHelpLocalUnitdir);'+
  4013. #013#010+
  4014. ' LogArgOption('#039'UG'#039','#039'globalunitdir'#039',SHelpGlobalUnitdir'+
  4015. ');'#013#010+
  4016. ' LogArgOption('#039'U'#039','#039'unitinstalldir'#039',SHelpUnitInstallDi'+
  4017. 'r);'#013#010+
  4018. ' LogArgOption('#039'r'#039','#039'compile','r'#039',SHelpCompiler);'#013#010+
  4019. ' LogArgOption('#039'f'#039','#039'config'#039',SHelpConfig);'#013#010+
  4020. ' LogArgOption('#039'o'#039','#039'options'#039',SHelpOptions);'#013#010+
  4021. ' LogArgOption('#039'io'#039','#039'ignoreinvalidoption'#039',SHelpIgnoreI'+
  4022. 'nvOpt);'#013#010+
  4023. ' LogArgOption('#039'd'#039', '#039'doc-folder'#039', sHelpFpdocOutputDir)'+
  4024. ';'#013#010+
  4025. ' if assigne','d(CustomFpmakeCommandlineOptions) then for i := 0 to Cu'+
  4026. 'stomFpmakeCommandlineOptions.Count-1 do'#013#010+
  4027. ' LogArgOption('#039' '#039',CustomFpmakeCommandlineOptions.Names[i],C'+
  4028. 'ustomFpmakeCommandlineOptions.ValueFromIndex[i]);'#013#010+
  4029. ' Log(vlInfo,'#039#039');'#013#010+
  4030. ' If (FMT<>',#039#039') then'#013#010+
  4031. ' halt(1)'#013#010+
  4032. ' else'#013#010+
  4033. ' halt(0);'#013#010+
  4034. 'end;'#013#010+
  4035. #013#010+
  4036. #013#010+
  4037. 'procedure TCustomInstaller.Compile(Force: Boolean);'#013#010+
  4038. 'begin'#013#010+
  4039. ' FBuildEngine.ForceCompile:=Force;'#013#010+
  4040. ' FBuildEngine.Compile(Packages);'#013#010+
  4041. 'end;'#013#010+
  4042. #013#010+
  4043. #013#010+
  4044. 'procedure TCustomInstaller.Clean(AllTargets',': boolean);'#013#010+
  4045. 'begin'#013#010+
  4046. ' BuildEngine.Clean(Packages, AllTargets);'#013#010+
  4047. 'end;'#013#010+
  4048. #013#010+
  4049. #013#010+
  4050. 'procedure TCustomInstaller.Install;'#013#010+
  4051. 'begin'#013#010+
  4052. ' BuildEngine.Install(Packages);'#013#010+
  4053. 'end;'#013#010+
  4054. #013#010+
  4055. #013#010+
  4056. 'procedure TCustomInstaller.Archive;'#013#010+
  4057. 'begin'#013#010+
  4058. ' // Force generation of manifest.','xml, this is required for the repo'+
  4059. 'sitory'#013#010+
  4060. ' BuildEngine.Manifest(Packages);'#013#010+
  4061. ' BuildEngine.Archive(Packages);'#013#010+
  4062. 'end;'#013#010+
  4063. #013#010+
  4064. #013#010+
  4065. 'procedure TCustomInstaller.Manifest;'#013#010+
  4066. 'begin'#013#010+
  4067. ' BuildEngine.Manifest(Packages);'#013#010+
  4068. 'end;'#013#010+
  4069. #013#010+
  4070. #013#010+
  4071. 'procedure TCustomInstaller.Ch','eckPackages;'#013#010+
  4072. 'begin'#013#010+
  4073. ' If (Packages.Count=0) then'#013#010+
  4074. ' Error(SErrNoPackagesDefined);'#013#010+
  4075. ' // Check for other obvious errors ?'#013#010+
  4076. 'end;'#013#010+
  4077. #013#010+
  4078. #013#010+
  4079. 'Function TCustomInstaller.Run : Boolean;'#013#010+
  4080. 'begin'#013#010+
  4081. ' Result:=True;'#013#010+
  4082. ' try'#013#010+
  4083. ' CheckPackages;'#013#010+
  4084. ' CreateBu','ildEngine;'#013#010+
  4085. ' Case RunMode of'#013#010+
  4086. ' rmCompile : Compile(False);'#013#010+
  4087. ' rmBuild : Compile(True);'#013#010+
  4088. ' rmInstall : Install;'#013#010+
  4089. ' rmArchive : Archive;'#013#010+
  4090. ' rmClean : Clean(False);'#013#010+
  4091. ' rmDistClean: Clean(True);'#013#010+
  4092. ' rmManifes','t : Manifest;'#013#010+
  4093. ' end;'#013#010+
  4094. ' except'#013#010+
  4095. ' On E : Exception do'#013#010+
  4096. ' begin'#013#010+
  4097. ' Log(vlError,SErrInstaller);'#013#010+
  4098. ' Log(vlError,E.Message);'#013#010+
  4099. ' Result:=False;'#013#010+
  4100. ' end;'#013#010+
  4101. ' end;'#013#010+
  4102. ' // Force returning an exitcode to the shell'#013#010+
  4103. ' if not Res','ult then'#013#010+
  4104. ' ExitCode:=1;'#013#010+
  4105. 'end;'#013#010+
  4106. #013#010+
  4107. #013#010+
  4108. '{*********************************************************************'+
  4109. '*******'#013#010+
  4110. ' TFPCInstaller'#013#010+
  4111. '**********************************************************************'+
  4112. '******','}'#013#010+
  4113. #013#010+
  4114. 'constructor TFPCInstaller.Create(AOwner: TComponent);'#013#010+
  4115. 'begin'#013#010+
  4116. ' if assigned(Defaults) then'#013#010+
  4117. ' Error(SErrAlreadyInitialized);'#013#010+
  4118. ' Defaults:=TFPCDefaults.Create;'#013#010+
  4119. ' inherited Create(AOwner);'#013#010+
  4120. 'end;'#013#010+
  4121. #013#010+
  4122. #013#010+
  4123. '{*********************************','**********************************'+
  4124. '*********'#013#010+
  4125. ' TBasicInstaller'#013#010+
  4126. '**********************************************************************'+
  4127. '******}'#013#010+
  4128. #013#010+
  4129. 'constructor TBasicInstaller.Create(AOwner: TComponent);'#013#010+
  4130. 'begin'#013#010,
  4131. ' if assigned(Defaults) then'#013#010+
  4132. ' Error(SErrAlreadyInitialized);'#013#010+
  4133. ' Defaults:=TBasicDefaults.Create;'#013#010+
  4134. ' inherited Create(AOwner);'#013#010+
  4135. 'end;'#013#010+
  4136. #013#010+
  4137. #013#010+
  4138. '{*********************************************************************'+
  4139. '*******'#013#010+
  4140. ' ',' TBuildEngine'#013#010+
  4141. '**********************************************************************'+
  4142. '******}'#013#010+
  4143. #013#010+
  4144. 'constructor TBuildEngine.Create(AOwner: TComponent);'#013#010+
  4145. 'begin'#013#010+
  4146. ' inherited Create(AOwner);'#013#010+
  4147. ' // Maybe this should be the current dire','ctory ?'#013#010+
  4148. ' // Or have it as a command-line option.'#013#010+
  4149. ' // Would allow to put all '#039'installers'#039' in one dir and call t'+
  4150. 'hem'#013#010+
  4151. ' // With --start-dir=/path/to/sources.'#013#010+
  4152. ' FStartDir:=includeTrailingPathDelimiter(GetCurrentDir);'#013#010+
  4153. ' FExternalPackages:=','TPackages.Create(TPackage);'#013#010+
  4154. 'end;'#013#010+
  4155. #013#010+
  4156. #013#010+
  4157. 'destructor TBuildEngine.Destroy;'#013#010+
  4158. 'begin'#013#010+
  4159. ' FreeAndNil(FExternalPackages);'#013#010+
  4160. ' inherited Destroy;'#013#010+
  4161. 'end;'#013#010+
  4162. #013#010+
  4163. #013#010+
  4164. 'procedure TBuildEngine.Error(const Msg: String);'#013#010+
  4165. 'begin'#013#010+
  4166. ' Raise EInstallerError.Create(Msg);'#013,#010+
  4167. 'end;'#013#010+
  4168. #013#010+
  4169. #013#010+
  4170. 'procedure TBuildEngine.Error(const Fmt: String; const Args: array of c'+
  4171. 'onst);'#013#010+
  4172. 'begin'#013#010+
  4173. ' Raise EInstallerError.CreateFmt(Fmt,Args);'#013#010+
  4174. 'end;'#013#010+
  4175. #013#010+
  4176. #013#010+
  4177. 'procedure TBuildEngine.ExecuteCommand(const Cmd,Args : String; const E'+
  4178. 'nv: TStrings = nil','; IgnoreError : Boolean = False);'#013#010+
  4179. 'Var'#013#010+
  4180. ' E : Integer;'#013#010+
  4181. ' cmdLine: string;'#013#010+
  4182. ' ConsoleOutput: TMemoryStream;'#013#010+
  4183. ' s: string;'#013#010+
  4184. 'begin'#013#010+
  4185. ' Log(vlInfo,SInfoExecutingCommand,[Cmd,Args]);'#013#010+
  4186. ' if ListMode then'#013#010+
  4187. ' Log(vlCommand,'#039'%s %s'#039',[Cmd,Args])'#013#010+
  4188. ' ','else'#013#010+
  4189. ' begin'#013#010+
  4190. ' // We should check cmd for spaces, and move all after first spac'+
  4191. 'e to args.'#013#010+
  4192. ' ConsoleOutput := TMemoryStream.Create;'#013#010+
  4193. ' try'#013#010+
  4194. ' {$ifdef HAS_UNIT_PROCESS}'#013#010+
  4195. ' E:=ExecuteFPC(Verbose, cmd, args, env, Co','nsoleOutput);'#013#010+
  4196. ' {$else}'#013#010+
  4197. ' E:=ExecuteProcess(cmd,args);'#013#010+
  4198. ' {$endif}'#013#010+
  4199. ' If (E<>0) and (not IgnoreError) then'#013#010+
  4200. ' begin'#013#010+
  4201. ' if trim(Args)<>'#039#039' then'#013#010+
  4202. ' cmdLine := cmd + '#039' '#039' + trim(args)'#013#010+
  4203. ' ',' else'#013#010+
  4204. ' cmdline := cmd;'#013#010+
  4205. ' s := ParsecompilerOutput(ConsoleOutput,Verbose);'#013#010+
  4206. ' Error(SErrExternalCommandFailed,[cmdLine,E,s]);'#013#010+
  4207. ' end;'#013#010+
  4208. ' finally'#013#010+
  4209. ' ConsoleOutput.Free;'#013#010+
  4210. ' end;'#013#010,
  4211. ' end;'#013#010+
  4212. 'end;'#013#010+
  4213. #013#010+
  4214. #013#010+
  4215. 'Function TBuildEngine.SysDirectoryExists(const ADir:string):Boolean;'#013+
  4216. #010+
  4217. 'begin'#013#010+
  4218. ' result:=SysUtils.DirectoryExists(ADir);'#013#010+
  4219. ' if result then'#013#010+
  4220. ' Log(vlDebug,SDbgDirectoryExists,[ADir,SDbgFound])'#013#010+
  4221. ' else'#013#010+
  4222. ' Log(vlDebug,SDb','gDirectoryExists,[ADir,SDbgNotFound]);'#013#010+
  4223. 'end;'#013#010+
  4224. #013#010+
  4225. #013#010+
  4226. 'Function TBuildEngine.SysFileExists(const AFileName:string):Boolean;'#013+
  4227. #010+
  4228. 'begin'#013#010+
  4229. ' result:=SysUtils.FileExists(AFileName);'#013#010+
  4230. ' if result then'#013#010+
  4231. ' Log(vlDebug,SDbgFileExists,[AFileName,SDbgFound]',')'#013#010+
  4232. ' else'#013#010+
  4233. ' Log(vlDebug,SDbgFileExists,[AFileName,SDbgNotFound]);'#013#010+
  4234. 'end;'#013#010+
  4235. #013#010+
  4236. #013#010+
  4237. 'procedure TBuildEngine.SysCopyFile(Const Src,Dest : String);'#013#010+
  4238. 'Var'#013#010+
  4239. ' D,S : String;'#013#010+
  4240. ' Fin,FOut : TFileStream;'#013#010+
  4241. ' Count : Int64;'#013#010+
  4242. ' A : Integer;'#013#010+
  4243. 'begin'#013#010+
  4244. ' Log(vl','Info,SInfoCopyingFile,[Src,Dest]);'#013#010+
  4245. ' FIn:=TFileStream.Create(Src,fmopenRead);'#013#010+
  4246. ' Try'#013#010+
  4247. ' D:=IncludeTrailingPathDelimiter(Dest);'#013#010+
  4248. ' If DirectoryExists(D) then'#013#010+
  4249. ' S:=D+ExtractFileName(Src)'#013#010+
  4250. ' else'#013#010+
  4251. ' S:=Dest;'#013#010+
  4252. ' FOut:=TFileStr','eam.Create(S,fmCreate);'#013#010+
  4253. ' Try'#013#010+
  4254. ' Count:=Fout.CopyFrom(FIn,0);'#013#010+
  4255. ' If (Count<>Fin.Size) then'#013#010+
  4256. ' Error(SErrCopyingFile,[Src,S]);'#013#010+
  4257. ' Finally'#013#010+
  4258. ' FreeAndNil(Fout);'#013#010+
  4259. ' end;'#013#010+
  4260. ' A:=FileGetDate(FIn.Handle);'#013#010+
  4261. ' If (A=-1) t','hen'#013#010+
  4262. ' log(vlWarning,SWarnFailedToGetTime,[Src])'#013#010+
  4263. ' else'#013#010+
  4264. ' if FileSetDate(S,A)<>0 then'#013#010+
  4265. ' Log(vlWarning,SWarnFailedToSetTime,[S]);'#013#010+
  4266. ' finally'#013#010+
  4267. ' FreeAndNil(Fin);'#013#010+
  4268. ' end;'#013#010+
  4269. 'end;'#013#010+
  4270. #013#010+
  4271. #013#010+
  4272. 'procedure TBuildEngine.SysMoveFile(Const',' Src,Dest : String);'#013#010+
  4273. 'Var'#013#010+
  4274. ' S : String;'#013#010+
  4275. 'begin'#013#010+
  4276. ' If DirectoryExists(IncludeTrailingPathDelimiter(Dest)) then'#013#010+
  4277. ' S:=IncludeTrailingPathDelimiter(Dest)+ExtractFileName(Src)'#013#010+
  4278. ' else'#013#010+
  4279. ' S:=Dest;'#013#010+
  4280. ' If Not RenameFile(Src,S) then'#013#010+
  4281. ' begin',#013#010+
  4282. ' Try'#013#010+
  4283. ' SysCopyFile(Src,S);'#013#010+
  4284. ' SysDeleteFile(Src);'#013#010+
  4285. ' Except'#013#010+
  4286. ' On E : Exception Do'#013#010+
  4287. ' Error(SErrMovingFile,[Src,S]);'#013#010+
  4288. ' end;'#013#010+
  4289. ' end;'#013#010+
  4290. 'end;'#013#010+
  4291. #013#010+
  4292. #013#010+
  4293. 'procedure TBuildEngine.SysDeleteFile(Const AFileName',' : String);'#013#010+
  4294. 'begin'#013#010+
  4295. ' if not FileExists(AFileName) then'#013#010+
  4296. ' Log(vldebug,SDbgFileDoesNotExist,[AFileName])'#013#010+
  4297. ' else If Not DeleteFile(AFileName) then'#013#010+
  4298. ' Error(SErrDeletingFile,[AFileName]);'#013#010+
  4299. 'end;'#013#010+
  4300. #013#010+
  4301. 'procedure TBuildEngine.SysDeleteDirector','y(const ADirectoryName: Stri'+
  4302. 'ng);'#013#010+
  4303. 'begin'#013#010+
  4304. ' if not DirectoryExists(ADirectoryName) then'#013#010+
  4305. ' Log(vldebug,SDbgDirectoryDoesNotExist,[ADirectoryName])'#013#010+
  4306. ' else if not IsDirectoryEmpty(ADirectoryName) then'#013#010+
  4307. ' Log(vldebug,SDbgDirectoryNotEmpty,','[ADirectoryName])'#013#010+
  4308. ' else If Not RemoveDir(ADirectoryName) then'#013#010+
  4309. ' Error(SErrRemovingDirectory,[ADirectoryName]);'#013#010+
  4310. 'end;'#013#010+
  4311. #013#010+
  4312. #013#010+
  4313. 'procedure TBuildEngine.SysDeleteTree(const ADirectoryName: String);'#013+
  4314. #010+
  4315. #013#010+
  4316. ' function IntRemoveTree(const ADirectoryN','ame: String) : boolean;'#013+
  4317. #010+
  4318. ' var'#013#010+
  4319. ' searchRec: TSearchRec;'#013#010+
  4320. ' SearchResult: longint;'#013#010+
  4321. ' begin'#013#010+
  4322. ' result := true;'#013#010+
  4323. ' SearchResult := FindFirst(IncludeTrailingPathDelimiter(ADirectoryN'+
  4324. 'ame)+AllFilesMask, faAnyFile+faSymLink, searchRec);'#013,#010+
  4325. ' try'#013#010+
  4326. ' while SearchResult=0 do'#013#010+
  4327. ' begin'#013#010+
  4328. ' if (searchRec.Name<>'#039'.'#039') and (searchRec.Name<>'#039'.'+
  4329. '.'#039') then'#013#010+
  4330. ' begin'#013#010+
  4331. ' if (searchRec.Attr and faDirectory)=faDirectory then'#013+
  4332. #010+
  4333. ' begin'#013#010+
  4334. ' ',' if not IntRemoveTree(IncludeTrailingPathDelimiter'+
  4335. '(ADirectoryName)+searchRec.Name) then'#013#010+
  4336. ' result := false;'#013#010+
  4337. ' end'#013#010+
  4338. ' else if not DeleteFile(IncludeTrailingPathDelimiter(ADi'+
  4339. 'recto','ryName)+searchRec.Name) then'#013#010+
  4340. ' result := False;'#013#010+
  4341. ' end;'#013#010+
  4342. ' SearchResult := FindNext(searchRec);'#013#010+
  4343. ' end;'#013#010+
  4344. ' finally'#013#010+
  4345. ' FindClose(searchRec);'#013#010+
  4346. ' end;'#013#010+
  4347. ' if not RemoveDir(ADirectoryName) then'#013,#010+
  4348. ' result := false;'#013#010+
  4349. ' end;'#013#010+
  4350. #013#010+
  4351. 'begin'#013#010+
  4352. ' if not DirectoryExists(ADirectoryName) then'#013#010+
  4353. ' Log(vldebug,SDbgDirectoryDoesNotExist,[ADirectoryName])'#013#010+
  4354. ' else If Not IntRemoveTree(ADirectoryName) then'#013#010+
  4355. ' Error(SErrRemovingDirectory,[ADirect','oryName]);'#013#010+
  4356. 'end;'#013#010+
  4357. #013#010+
  4358. #013#010+
  4359. 'procedure TBuildEngine.SysArchiveFiles(List: TStrings;Const AFileName:'+
  4360. ' String);'#013#010+
  4361. 'begin'#013#010+
  4362. ' If Not (Assigned(OnArchivefiles) or Assigned(ArchiveFilesProc)) then'+
  4363. #013#010+
  4364. ' Raise EInstallerError.Create(SErrNoArchiveSupport);'#013#010+
  4365. ' ',' If Assigned(ArchiveFilesProc) then'#013#010+
  4366. ' ArchiveFilesProc(AFileName,List)'#013#010+
  4367. ' else'#013#010+
  4368. ' OnArchiveFiles(AFileName,List);'#013#010+
  4369. 'end;'#013#010+
  4370. #013#010+
  4371. #013#010+
  4372. 'procedure TBuildEngine.LogIndent;'#013#010+
  4373. 'begin'#013#010+
  4374. ' FLogPrefix:=FLogPrefix+'#039' '#039';'#013#010+
  4375. 'end;'#013#010+
  4376. #013#010+
  4377. #013#010+
  4378. 'procedure TBuildEngine.Log','UnIndent;'#013#010+
  4379. 'begin'#013#010+
  4380. ' Delete(FLogPrefix,1,2);'#013#010+
  4381. 'end;'#013#010+
  4382. #013#010+
  4383. #013#010+
  4384. 'procedure TBuildEngine.Log(Level: TVerboseLevel; const Msg: String);'#013+
  4385. #010+
  4386. 'begin'#013#010+
  4387. ' If Assigned(FOnLog) then'#013#010+
  4388. ' begin'#013#010+
  4389. ' if Level in [vlInfo,vlDebug] then'#013#010+
  4390. ' FOnLog(Level,FLogPre','fix+Msg)'#013#010+
  4391. ' else'#013#010+
  4392. ' FOnLog(Level,Msg);'#013#010+
  4393. ' end;'#013#010+
  4394. 'end;'#013#010+
  4395. #013#010+
  4396. #013#010+
  4397. 'procedure TBuildEngine.Log(Level: TVerboseLevel; const Fmt: String;con'+
  4398. 'st Args: array of const);'#013#010+
  4399. 'begin'#013#010+
  4400. ' Log(Level,Format(Fmt,Args));'#013#010+
  4401. 'end;'#013#010+
  4402. #013#010+
  4403. #013#010+
  4404. 'procedure TBuildEngine.E','nterDir(ADir: String);'#013#010+
  4405. 'Var'#013#010+
  4406. ' D : String;'#013#010+
  4407. 'begin'#013#010+
  4408. ' D:=FStartDir;'#013#010+
  4409. ' D:=D+ADir;'#013#010+
  4410. ' Log(vlDebug,SDbgEnterDir,[D]);'#013#010+
  4411. ' If Not SetCurrentDir(D) then'#013#010+
  4412. ' Error(SErrChangeDirFailed,[D]);'#013#010+
  4413. 'end;'#013#010+
  4414. #013#010+
  4415. #013#010+
  4416. 'procedure TBuildEngine.CmdCopyFiles(List: TSt','rings; Const DestDir: S'+
  4417. 'tring);'#013#010+
  4418. #013#010+
  4419. 'Var'#013#010+
  4420. ' Args : String;'#013#010+
  4421. ' I : Integer;'#013#010+
  4422. ' DestFileName : String;'#013#010+
  4423. #013#010+
  4424. 'begin'#013#010+
  4425. ' CmdCreateDir(DestDir);'#013#010+
  4426. ' If (Defaults.Copy<>'#039#039') then'#013#010+
  4427. ' begin'#013#010+
  4428. ' Args:=FileListToString(List,'#039#039');'#013#010+
  4429. ' Args:=Args+'#039' '#039'+Des','tDir;'#013#010+
  4430. ' ExecuteCommand(Defaults.Copy,Args);'#013#010+
  4431. ' end'#013#010+
  4432. ' else'#013#010+
  4433. ' For I:=0 to List.Count-1 do'#013#010+
  4434. ' if List.Names[i]<>'#039#039' then'#013#010+
  4435. ' begin'#013#010+
  4436. ' if IsRelativePath(list.ValueFromIndex[i]) then'#013#010+
  4437. ' DestFileName:=DestDir+','list.ValueFromIndex[i]'#013#010+
  4438. ' else'#013#010+
  4439. ' DestFileName:=list.ValueFromIndex[i];'#013#010+
  4440. ' CmdCreateDir(ExtractFilePath(DestFileName));'#013#010+
  4441. ' SysCopyFile(List.names[i],DestFileName)'#013#010+
  4442. ' end'#013#010+
  4443. ' else'#013#010+
  4444. ' SysCopyFi','le(List[i],DestDir);'#013#010+
  4445. 'end;'#013#010+
  4446. #013#010+
  4447. #013#010+
  4448. 'procedure TBuildEngine.CmdCreateDir(const DestDir: String);'#013#010+
  4449. 'begin'#013#010+
  4450. ' If (Defaults.MkDir<>'#039#039') then'#013#010+
  4451. ' ExecuteCommand(Defaults.MkDir,DestDir)'#013#010+
  4452. ' else'#013#010+
  4453. ' If not ForceDirectories(DestDir) then'#013#010+
  4454. ' Error(S','ErrCreatingDirectory,[DestDir]);'#013#010+
  4455. 'end;'#013#010+
  4456. #013#010+
  4457. #013#010+
  4458. 'procedure TBuildEngine.CmdMoveFiles(List: TStrings; Const DestDir: Str'+
  4459. 'ing);'#013#010+
  4460. 'Var'#013#010+
  4461. ' Args : String;'#013#010+
  4462. ' I : Integer;'#013#010+
  4463. 'begin'#013#010+
  4464. ' CmdCreateDir(DestDir);'#013#010+
  4465. ' If (Defaults.Move<>'#039#039') then'#013#010+
  4466. ' begin'#013#010+
  4467. ' ',' Args:=FileListToString(List,'#039#039');'#013#010+
  4468. ' Args:=Args+'#039' '#039'+DestDir;'#013#010+
  4469. ' ExecuteCommand(Defaults.Move,Args);'#013#010+
  4470. ' end'#013#010+
  4471. ' else'#013#010+
  4472. ' For I:=0 to List.Count-1 do'#013#010+
  4473. ' SysMoveFile(List[i],DestDir);'#013#010+
  4474. 'end;'#013#010+
  4475. #013#010+
  4476. #013#010+
  4477. 'procedure TBuildEngine.CmdDeleteFi','les(List: TStrings);'#013#010+
  4478. 'Var'#013#010+
  4479. ' Args : String;'#013#010+
  4480. ' I : Integer;'#013#010+
  4481. 'begin'#013#010+
  4482. ' If (Defaults.Remove<>'#039#039') then'#013#010+
  4483. ' begin'#013#010+
  4484. ' Args:=FileListToString(List,'#039#039');'#013#010+
  4485. ' ExecuteCommand(Defaults.Remove,Args);'#013#010+
  4486. ' end'#013#010+
  4487. ' else'#013#010+
  4488. ' For I:=0 to List.Count','-1 do'#013#010+
  4489. ' SysDeleteFile(List[i]);'#013#010+
  4490. 'end;'#013#010+
  4491. #013#010+
  4492. #013#010+
  4493. 'procedure TBuildEngine.CmdArchiveFiles(List: TStrings; Const ArchiveFi'+
  4494. 'le: String);'#013#010+
  4495. 'Var'#013#010+
  4496. ' S,C,O : String;'#013#010+
  4497. 'begin'#013#010+
  4498. ' If (Defaults.Archive='#039#039') then'#013#010+
  4499. ' SysArchiveFiles(List,ArchiveFile)'#013#010+
  4500. ' els','e'#013#010+
  4501. ' begin'#013#010+
  4502. ' S:=FileListToString(List,'#039#039');'#013#010+
  4503. ' SplitCommand(Defaults.Archive,C,O);'#013#010+
  4504. ' If (O='#039#039') then'#013#010+
  4505. ' O:=ArchiveFile+'#039' '#039'+S'#013#010+
  4506. ' else'#013#010+
  4507. ' O:=Substitute(O,['#039'ARCHIVE'#039',ArchiveFile,'#039'FILESORDIR'+
  4508. 'S'#039']);'#013#010+
  4509. ' ExecuteComm','and(C,O);'#013#010+
  4510. ' end;'#013#010+
  4511. 'end;'#013#010+
  4512. #013#010+
  4513. 'procedure TBuildEngine.CmdRenameFile(SourceName, DestName: String);'#013+
  4514. #010+
  4515. 'var'#013#010+
  4516. ' Args: string;'#013#010+
  4517. 'begin'#013#010+
  4518. ' If (Defaults.Move<>'#039#039') then'#013#010+
  4519. ' begin'#013#010+
  4520. ' Args:=SourceName;'#013#010+
  4521. ' Args:=Args+'#039' '#039'+DestName;'#013#010+
  4522. ' ExecuteC','ommand(Defaults.Move,Args);'#013#010+
  4523. ' end'#013#010+
  4524. ' else'#013#010+
  4525. ' SysMoveFile(SourceName,DestName);'#013#010+
  4526. 'end;'#013#010+
  4527. #013#010+
  4528. 'procedure TBuildEngine.CmdRemoveDirs(List: TStrings);'#013#010+
  4529. 'Var'#013#010+
  4530. ' Args : String;'#013#010+
  4531. ' I : Integer;'#013#010+
  4532. 'begin'#013#010+
  4533. ' If (Defaults.RemoveDir<>'#039#039') then'#013#010+
  4534. ' begin'#013,#010+
  4535. ' Args:=FileListToString(List,'#039#039');'#013#010+
  4536. ' ExecuteCommand(Defaults.RemoveDir,Args);'#013#010+
  4537. ' end'#013#010+
  4538. ' else'#013#010+
  4539. ' For I:=0 to List.Count-1 do'#013#010+
  4540. ' SysDeleteDirectory(List[i]);'#013#010+
  4541. 'end;'#013#010+
  4542. #013#010+
  4543. 'procedure TBuildEngine.CmdRemoveTrees(List: TStrings);'#013#010+
  4544. 'V','ar'#013#010+
  4545. ' Args : String;'#013#010+
  4546. ' I : Integer;'#013#010+
  4547. 'begin'#013#010+
  4548. ' If (Defaults.RemoveTree<>'#039#039') then'#013#010+
  4549. ' begin'#013#010+
  4550. ' Args:=FileListToString(List,'#039#039');'#013#010+
  4551. ' ExecuteCommand(Defaults.RemoveTree,Args);'#013#010+
  4552. ' end'#013#010+
  4553. ' else'#013#010+
  4554. ' For I:=0 to List.Count-1 do'#013#010+
  4555. ' Sy','sDeleteTree(List[i]);'#013#010+
  4556. 'end;'#013#010+
  4557. #013#010+
  4558. 'Function TBuildEngine.FileNewer(const Src,Dest : String) : Boolean;'#013+
  4559. #010+
  4560. #013#010+
  4561. 'Var'#013#010+
  4562. ' DS,DD : Longint;'#013#010+
  4563. ' D1,D2 : TDateTime;'#013#010+
  4564. #013#010+
  4565. 'begin'#013#010+
  4566. ' DS:=FileAge(Src);'#013#010+
  4567. ' DD:=FileAge(Dest);'#013#010+
  4568. ' D1:=FileDateToDateTime(DS);'#013#010+
  4569. ' D2:=Fi','leDateToDateTime(DD);'#013#010+
  4570. ' Log(vlDebug,SDbgComparingFileTimes,[Src,DateTimeToStr(D1),Dest,DateT'+
  4571. 'imeToStr(D2)]);'#013#010+
  4572. ' Result:=D1>=D2;'#013#010+
  4573. ' If Result then'#013#010+
  4574. ' Log(vlInfo,SInfoSourceNewerDest,[Src,DateTimeToStr(D1),Dest,DateTi'+
  4575. 'meToStr(D2)]);'#013#010+
  4576. 'end;'#013#010+
  4577. #013,#010+
  4578. #013#010+
  4579. 'procedure TBuildEngine.ExecuteCommands(Commands: TCommands; At: TComma'+
  4580. 'ndAt);'#013#010+
  4581. 'Var'#013#010+
  4582. ' C : TCommand;'#013#010+
  4583. ' I : Integer;'#013#010+
  4584. ' Cmd,O : String;'#013#010+
  4585. ' E : Boolean;'#013#010+
  4586. 'begin'#013#010+
  4587. ' For I:=0 to Commands.Count-1 do'#013#010+
  4588. ' begin'#013#010+
  4589. ' C:=Commands.CommandItems[i]',';'#013#010+
  4590. ' if (C.At=At) then'#013#010+
  4591. ' begin'#013#010+
  4592. ' E:=True;'#013#010+
  4593. ' If (C.SourceFile<>'#039#039') and (C.DestFile<>'#039#039') then'+
  4594. #013#010+
  4595. ' E:=FileNewer(C.SourceFile,IncludeTrailingPathDelimiter(Dic'+
  4596. 'tionary.GetValue('#039'OUTPUTDIR'#039'))+C.DestFile);'#013#010+
  4597. ' ',' If E then'#013#010+
  4598. ' begin'#013#010+
  4599. ' If Assigned(C.BeforeCommand) then'#013#010+
  4600. ' C.BeforeCommand(C);'#013#010+
  4601. ' O:=Substitute(C.CmdLineOptions,['#039'SOURCE'#039',C.SourceF'+
  4602. 'ile,'#039'DEST'#039',C.DestFile]);'#013#010+
  4603. ' Cmd:=C.Command;'#013#010+
  4604. ' ',' If (ExtractFilePath(Cmd)='#039#039') then'#013#010+
  4605. ' Cmd:=ExeSearch(Cmd,GetEnvironmentvariable('#039'PATH'#039')'+
  4606. ');'#013#010+
  4607. ' ExecuteCommand(Cmd,O,nil,C.IgnoreResult);'#013#010+
  4608. ' If Assigned(C.AfterCommand) then'#013#010+
  4609. ' C.AfterCommand','(C);'#013#010+
  4610. ' end;'#013#010+
  4611. ' end;'#013#010+
  4612. ' end;'#013#010+
  4613. 'end;'#013#010+
  4614. #013#010+
  4615. #013#010+
  4616. 'Procedure TBuildEngine.LogSearchPath(const ASearchPathName:string;Path'+
  4617. ':TConditionalStrings; ACPU:TCPU;AOS:TOS);'#013#010+
  4618. 'var'#013#010+
  4619. ' S : String;'#013#010+
  4620. ' I : Integer;'#013#010+
  4621. ' C : TConditionalString;'#013#010+
  4622. 'begin'#013,#010+
  4623. ' S:='#039#039';'#013#010+
  4624. ' for i:=0 to Path.Count-1 do'#013#010+
  4625. ' begin'#013#010+
  4626. ' C:=Path[I];'#013#010+
  4627. ' if (ACPU in C.CPUs) and (AOS in C.OSes) then'#013#010+
  4628. ' begin'#013#010+
  4629. ' if S<>'#039#039' then'#013#010+
  4630. ' S:=S+PathSeparator;'#013#010+
  4631. ' S:=S+Dictionary.ReplaceStrings(C.','Value)'#013#010+
  4632. ' end;'#013#010+
  4633. ' end;'#013#010+
  4634. ' if S<>'#039#039' then'#013#010+
  4635. ' Log(vlDebug,SDbgSearchPath,[ASearchPathName,S]);'#013#010+
  4636. 'end;'#013#010+
  4637. #013#010+
  4638. #013#010+
  4639. 'Function TBuildEngine.FindFileInPath(Path:TConditionalStrings; AFileNa'+
  4640. 'me:String; var FoundPath:String;ACPU:TCPU;AOS:TOS):Boolea','n;'#013#010+
  4641. 'var'#013#010+
  4642. ' I : Integer;'#013#010+
  4643. ' C : TConditionalString;'#013#010+
  4644. 'begin'#013#010+
  4645. ' Result:=false;'#013#010+
  4646. ' for i:=0 to Path.Count-1 do'#013#010+
  4647. ' begin'#013#010+
  4648. ' C:=Path[I];'#013#010+
  4649. ' if (ACPU in C.CPUs) and (AOS in C.OSes) then'#013#010+
  4650. ' begin'#013#010+
  4651. ' FoundPath:=IncludeTrailin','gPathDelimiter(Dictionary.Replace'+
  4652. 'Strings(C.Value));'#013#010+
  4653. ' if FileExists(FoundPath+AFileName) then'#013#010+
  4654. ' begin'#013#010+
  4655. ' result:=true;'#013#010+
  4656. ' exit;'#013#010+
  4657. ' end;'#013#010+
  4658. ' end;'#013#010+
  4659. ' end;'#013#010+
  4660. ' FoundPath:='#039#039';'#013#010+
  4661. 'end;'#013#010+
  4662. #013,#010+
  4663. 'procedure TBuildEngine.GetDirectoriesFromFilelist(const AFileList, ADi'+
  4664. 'rectoryList: TStringList);'#013#010+
  4665. 'var'#013#010+
  4666. ' i: integer;'#013#010+
  4667. 'begin'#013#010+
  4668. ' ADirectoryList.Sorted:=true;'#013#010+
  4669. ' ADirectoryList.Duplicates:=dupIgnore;'#013#010+
  4670. ' for i := 0 to AFileList.Count-1 do'#013#010+
  4671. ' ',' ADirectoryList.Add(ExtractFileDir(AFileList.Strings[i]));'#013#010+
  4672. 'end;'#013#010+
  4673. #013#010+
  4674. #013#010+
  4675. 'Procedure TBuildEngine.ResolveFileNames(APackage : TPackage; ACPU:TCPU'+
  4676. ';AOS:TOS;DoChangeDir:boolean=true);'#013#010+
  4677. #013#010+
  4678. ' procedure FindMainSource(T:TTarget);'#013#010+
  4679. ' var'#013#010+
  4680. ' SD,SF : S','tring;'#013#010+
  4681. ' begin'#013#010+
  4682. ' LogSearchPath('#039'package source'#039',APackage.SourcePath,ACPU,AO'+
  4683. 'S);'#013#010+
  4684. ' SD:=Dictionary.ReplaceStrings(T.Directory);'#013#010+
  4685. ' SF:=Dictionary.ReplaceStrings(T.SourceFileName);'#013#010+
  4686. ' if SD='#039#039' then'#013#010+
  4687. ' FindFileInPath(APackage.Sour','cePath,SF,SD,ACPU,AOS);'#013#010+
  4688. ' if SD<>'#039#039' then'#013#010+
  4689. ' SD:=IncludeTrailingPathDelimiter(SD);'#013#010+
  4690. ' T.FTargetSourceFileName:=SD+SF;'#013#010+
  4691. ' if FileExists(T.TargetSourceFileName) then'#013#010+
  4692. ' Log(vlDebug,SDbgResolvedSourceFile,[T.SourceFileName,T.Targ','etS'+
  4693. 'ourceFileName])'#013#010+
  4694. ' else'#013#010+
  4695. ' begin'#013#010+
  4696. ' Log(vlWarning,SWarnSourceFileNotFound,[T.SourceFileName,APacka'+
  4697. 'ge.Name,MakeTargetString(ACPU,AOS)]);'#013#010+
  4698. ' T.FTargetSourceFileName:='#039#039';'#013#010+
  4699. ' end;'#013#010+
  4700. ' end;'#013#010+
  4701. #013#010+
  4702. ' procedure FindIncludeSourc','es(T:TTarget);'#013#010+
  4703. ' var'#013#010+
  4704. ' SD,SF : String;'#013#010+
  4705. ' D : TDependency;'#013#010+
  4706. ' j : integer;'#013#010+
  4707. ' begin'#013#010+
  4708. ' LogSearchPath('#039'target include'#039',T.IncludePath,ACPU,AOS);'#013+
  4709. #010+
  4710. ' LogSearchPath('#039'package include'#039',APackage.IncludePath,ACPU,'+
  4711. 'AOS);'#013#010+
  4712. ' for j:=0 to ','T.Dependencies.Count-1 do'#013#010+
  4713. ' begin'#013#010+
  4714. ' D:=T.Dependencies[j];'#013#010+
  4715. ' if (D.DependencyType=depInclude) then'#013#010+
  4716. ' begin'#013#010+
  4717. ' D.TargetFileName:='#039#039';'#013#010+
  4718. ' if (ACPU in D.CPUs) and (AOS in D.OSes) then'#013#010+
  4719. ' ',' begin'#013#010+
  4720. ' if ExtractFilePath(D.Value)='#039#039' then'#013#010+
  4721. ' begin'#013#010+
  4722. ' SF:=Dictionary.ReplaceStrings(D.Value);'#013#010+
  4723. ' SD:='#039#039';'#013#010+
  4724. ' // first check the target specific path'#013#010+
  4725. ' ',' if not FindFileInPath(T.IncludePath,SF,SD,ACPU,A'+
  4726. 'OS) then'#013#010+
  4727. ' FindFileInPath(APackage.IncludePath,SF,SD,ACPU,A'+
  4728. 'OS);'#013#010+
  4729. ' if SD<>'#039#039' then'#013#010+
  4730. ' SD:=IncludeTrailingPathDelim','iter(SD);'#013#010+
  4731. ' D.TargetFileName:=SD+SF;'#013#010+
  4732. ' end'#013#010+
  4733. ' else'#013#010+
  4734. ' D.TargetFileName:=D.Value;'#013#010+
  4735. ' if FileExists(D.TargetFileName) then'#013#010+
  4736. ' Log(vlDebug,SDbgRes','olvedIncludeFile,[D.Value,D.Tar'+
  4737. 'getFileName])'#013#010+
  4738. ' else'#013#010+
  4739. ' begin'#013#010+
  4740. ' Log(vlWarning,SWarnIncludeFileNotFound,[D.Value, A'+
  4741. 'Package.Name, MakeTargetString(ACPU,AOS)]);'#013#010+
  4742. ' D.TargetFile','Name:='#039#039';'#013#010+
  4743. ' end;'#013#010+
  4744. ' end;'#013#010+
  4745. ' end;'#013#010+
  4746. ' end;'#013#010+
  4747. ' end;'#013#010+
  4748. #013#010+
  4749. ' procedure FindExampleSource(T:TTarget);'#013#010+
  4750. ' var'#013#010+
  4751. ' SD,SF : String;'#013#010+
  4752. ' begin'#013#010+
  4753. ' LogSearchPath('#039'package example'#039',APackage.ExamplePath,ACPU,'+
  4754. 'AOS)',';'#013#010+
  4755. ' SD:=Dictionary.ReplaceStrings(T.Directory);'#013#010+
  4756. ' SF:=Dictionary.ReplaceStrings(T.SourceFileName);'#013#010+
  4757. ' if SD='#039#039' then'#013#010+
  4758. ' FindFileInPath(APackage.ExamplePath,SF,SD,ACPU,AOS);'#013#010+
  4759. ' if SD<>'#039#039' then'#013#010+
  4760. ' SD:=IncludeTrailingPathDelimi','ter(SD);'#013#010+
  4761. ' T.FTargetSourceFileName:=SD+SF;'#013#010+
  4762. ' if FileExists(T.TargetSourceFileName) then'#013#010+
  4763. ' Log(vlDebug,SDbgResolvedSourceFile,[T.SourceFileName,T.TargetSou'+
  4764. 'rceFileName])'#013#010+
  4765. ' else'#013#010+
  4766. ' begin'#013#010+
  4767. ' Log(vlWarning,SWarnSourceFile','NotFound,[T.SourceFileName, APa'+
  4768. 'ckage.Name, MakeTargetString(ACPU,AOS)]);'#013#010+
  4769. ' T.FTargetSourceFileName:='#039#039';'#013#010+
  4770. ' end;'#013#010+
  4771. ' end;'#013#010+
  4772. #013#010+
  4773. 'var'#013#010+
  4774. ' T : TTarget;'#013#010+
  4775. ' i : Integer;'#013#010+
  4776. 'begin'#013#010+
  4777. ' if not((ACPU in APackage.CPUs) and (AOS in APackage.OSes)) t','hen'#013+
  4778. #010+
  4779. ' exit;'#013#010+
  4780. ' try'#013#010+
  4781. ' if DoChangeDir and (APackage.Directory<>'#039#039') then'#013#010+
  4782. ' EnterDir(APackage.Directory);'#013#010+
  4783. ' Dictionary.AddVariable('#039'CPU'#039',CPUToString(ACPU));'#013#010+
  4784. ' Dictionary.AddVariable('#039'OS'#039',OSToString(AOS));'#013#010+
  4785. ' For I:=0 to APack','age.Targets.Count-1 do'#013#010+
  4786. ' begin'#013#010+
  4787. ' T:=APackage.FTargets.TargetItems[I];'#013#010+
  4788. ' if (ACPU in T.CPUs) and (AOS in T.OSes) then'#013#010+
  4789. ' begin'#013#010+
  4790. ' // Debug information'#013#010+
  4791. ' Log(vlDebug,SDbgResolvingSourcesOfTarget',',[T.Name,MakeTar'+
  4792. 'getString(ACPU,AOS)]);'#013#010+
  4793. ' LogIndent;'#013#010+
  4794. #013#010+
  4795. ' case T.TargetType of'#013#010+
  4796. ' ttProgram,'#013#010+
  4797. ' ttUnit,'#013#010+
  4798. ' ttImplicitUnit :'#013#010+
  4799. ' begin'#013#010+
  4800. ' FindMainSource(T);',#013#010+
  4801. ' if T.Dependencies.Count>0 then'#013#010+
  4802. ' FindIncludeSources(T);'#013#010+
  4803. ' end;'#013#010+
  4804. ' ttExampleUnit,'#013#010+
  4805. ' ttExampleProgram :'#013#010+
  4806. ' begin'#013#010+
  4807. ' FindExampleSource','(T);'#013#010+
  4808. ' end;'#013#010+
  4809. ' end;'#013#010+
  4810. #013#010+
  4811. ' LogUnIndent;'#013#010+
  4812. ' end;'#013#010+
  4813. ' end;'#013#010+
  4814. ' finally'#013#010+
  4815. ' If DoChangeDir and (APackage.Directory<>'#039#039') then'#013#010+
  4816. ' EnterDir('#039#039');'#013#010+
  4817. ' end;'#013#010+
  4818. 'end;'#013#010+
  4819. #013#010+
  4820. #013#010+
  4821. 'function TBuildEngine.GetUnitDir(A','Package:TPackage):String;'#013#010+
  4822. 'begin'#013#010+
  4823. ' if APackage.UnitDir='#039#039' then'#013#010+
  4824. ' begin'#013#010+
  4825. ' // Retrieve Full directory name where to find the units.'#013#010+
  4826. ' // The search order is:'#013#010+
  4827. ' // - Package in this fpmake.pp'#013#010+
  4828. ' // - LocalUnitDir'#013#010+
  4829. ' ',' // - GlobalUnitDir'#013#010+
  4830. ' if (APackage.State in [tsCompiled, tsNoCompile, tsInstalled]) th'+
  4831. 'en'#013#010+
  4832. ' begin'#013#010+
  4833. ' APackage.UnitDir:=IncludeTrailingPathDelimiter(FStartDir)+In'+
  4834. 'cludeTrailingPathDelimiter(APackage.Directory)+APackage.Ge','tUnitsOutp'+
  4835. 'utDir(Defaults.CPU,Defaults.OS);'#013#010+
  4836. ' end;'#013#010+
  4837. ' if (APackage.UnitDir='#039#039') and'#013#010+
  4838. ' (Defaults.LocalUnitDir<>'#039#039') then'#013#010+
  4839. ' begin'#013#010+
  4840. ' APackage.UnitDir:=IncludeTrailingPathDelimiter(Defaults.Loca'+
  4841. 'lUnitDir)+APackage','.Name;'#013#010+
  4842. ' if not SysDirectoryExists(APackage.UnitDir) then'#013#010+
  4843. ' APackage.UnitDir:='#039#039';'#013#010+
  4844. ' end;'#013#010+
  4845. ' if APackage.UnitDir='#039#039' then'#013#010+
  4846. ' begin'#013#010+
  4847. ' APackage.UnitDir:=IncludeTrailingPathDelimiter(Defaults.Glob'+
  4848. 'alU','nitDir)+APackage.Name;'#013#010+
  4849. ' if not SysDirectoryExists(APackage.UnitDir) then'#013#010+
  4850. ' APackage.UnitDir:=DirNotFound;'#013#010+
  4851. ' end;'#013#010+
  4852. #013#010+
  4853. ' if (APackage.UnitDir<>DirNotFound) then'#013#010+
  4854. ' begin'#013#010+
  4855. ' if FileExists(IncludeTra','ilingPathDelimiter(APackage.UnitDi'+
  4856. 'r)+FPMakePPFile) then'#013#010+
  4857. ' begin'#013#010+
  4858. ' // The package is not installed, but the source-path is '+
  4859. 'detected.'#013#010+
  4860. ' // It is an external package so it is impossible to comp'+
  4861. 'ile it, so'#013#010+
  4862. ' ',' // assume that it has been compiled earlier.'#013#010+
  4863. ' APackage.UnitDir := IncludeTrailingPathDelimiter(APackag'+
  4864. 'e.UnitDir) + APackage.GetUnitsOutputDir(Defaults.CPU,Defaults.OS);'#013+
  4865. #010+
  4866. ' // If the unit-directory does',' not exist, you know for '+
  4867. 'sure that'#013#010+
  4868. ' // the package is not compiled'#013#010+
  4869. ' if not SysDirectoryExists(APackage.UnitDir) then'#013#010+
  4870. ' APackage.UnitDir:=DirNotFound'#013#010+
  4871. ' else'#013#010+
  4872. ' // Set the ','state to tsNoCompile and not tsCompiled. '+
  4873. 'Because packages'#013#010+
  4874. ' // in the tsCompiled state trigger a rebuild of packag'+
  4875. 'es that depend'#013#010+
  4876. ' // on it.'#013#010+
  4877. ' APackage.FTargetState:=tsNoCompile;'#013#010+
  4878. ' end',#013#010+
  4879. ' else if not (APackage.FTargetState in [tsCompiled, tsNoCompi'+
  4880. 'le]) then'#013#010+
  4881. ' begin'#013#010+
  4882. ' APackage.FTargetState:=tsInstalled;'#013#010+
  4883. ' end;'#013#010+
  4884. ' end;'#013#010+
  4885. ' end;'#013#010+
  4886. #013#010+
  4887. ' // Special error marker to prevent search','es in case of error'#013#010+
  4888. ' if APackage.UnitDir=DirNotFound then'#013#010+
  4889. ' Result:='#039#039#013#010+
  4890. ' else'#013#010+
  4891. ' Result:=APackage.UnitDir;'#013#010+
  4892. 'end;'#013#010+
  4893. #013#010+
  4894. #013#010+
  4895. 'procedure TBuildEngine.AddDependencyPaths(L: TStrings; DependencyType:'+
  4896. ' TDependencyType; ATarget: TTarget);'#013#010+
  4897. 'Var'#013#010+
  4898. ' ',' I : Integer;'#013#010+
  4899. ' D : TDependency;'#013#010+
  4900. ' SD : String;'#013#010+
  4901. 'begin'#013#010+
  4902. ' For I:=0 to ATarget.Dependencies.Count-1 do'#013#010+
  4903. ' begin'#013#010+
  4904. ' D:=ATarget.Dependencies[i];'#013#010+
  4905. ' if (D.DependencyType=DependencyType) and'#013#010+
  4906. ' (Defaults.CPU in D.CPUs) and (De','faults.OS in D.OSes) then'#013+
  4907. #010+
  4908. ' begin'#013#010+
  4909. ' SD:=ExcludeTrailingPathDelimiter(ExtractFilePath(D.TargetFil'+
  4910. 'eName));'#013#010+
  4911. ' if SD<>'#039#039' then'#013#010+
  4912. ' L.Add(SD);'#013#010+
  4913. ' end;'#013#010+
  4914. ' end;'#013#010+
  4915. 'end;'#013#010+
  4916. #013#010+
  4917. #013#010+
  4918. 'procedure TBuildEngine.AddDependen','cyUnitPaths(L:TStrings;APackage: T'+
  4919. 'Package);'#013#010+
  4920. 'Var'#013#010+
  4921. ' I : Integer;'#013#010+
  4922. ' P : TPackage;'#013#010+
  4923. ' D : TDependency;'#013#010+
  4924. ' S : String;'#013#010+
  4925. 'begin'#013#010+
  4926. ' For I:=0 to APackage.Dependencies.Count-1 do'#013#010+
  4927. ' begin'#013#010+
  4928. ' D:=APackage.Dependencies[i];'#013#010+
  4929. ' if (D.Dependen','cyType=depPackage) and'#013#010+
  4930. ' (Defaults.CPU in D.CPUs) and (Defaults.OS in D.OSes) then'#013+
  4931. #010+
  4932. ' begin'#013#010+
  4933. ' P:=TPackage(D.Target);'#013#010+
  4934. ' If Assigned(P) then'#013#010+
  4935. ' begin'#013#010+
  4936. ' // Already processed?'#013#010+
  4937. ' ',' S:=GetUnitDir(P);'#013#010+
  4938. ' if L.IndexOf(S)=-1 then'#013#010+
  4939. ' begin'#013#010+
  4940. ' // Add this package and then dependencies'#013#010+
  4941. ' L.Add(S);'#013#010+
  4942. ' AddDependencyUnitPaths(L,P);'#013#010+
  4943. ' end',';'#013#010+
  4944. ' end;'#013#010+
  4945. ' end;'#013#010+
  4946. ' end;'#013#010+
  4947. 'end;'#013#010+
  4948. #013#010+
  4949. #013#010+
  4950. 'Function TBuildEngine.GetCompilerCommand(APackage : TPackage; ATarget '+
  4951. ': TTarget; Env: TStrings) : String;'#013#010+
  4952. 'Var'#013#010+
  4953. ' L : TUnsortedDuplicatesStringList;'#013#010+
  4954. ' Args : TStringList;'#013#010+
  4955. ' s : string',';'#013#010+
  4956. ' i : Integer;'#013#010+
  4957. 'begin'#013#010+
  4958. ' if ATarget.TargetSourceFileName = '#039#039' then'#013#010+
  4959. ' Error(SErrCouldNotCompile,[ATarget.Name, APackage.Name]);'#013#010+
  4960. #013#010+
  4961. ' Args:=TStringList.Create;'#013#010+
  4962. ' Args.Duplicates:=dupIgnore;'#013#010+
  4963. #013#010+
  4964. ' Result := '#039#039';'#013#010+
  4965. #013#010+
  4966. ' //compiler configurat','ion'#013#010+
  4967. ' if Defaults.NoFPCCfg then'#013#010+
  4968. ' Args.Add('#039'-n'#039');'#013#010+
  4969. #013#010+
  4970. ' // Target OS'#013#010+
  4971. ' Args.Add('#039'-T'#039'+OSToString(Defaults.OS));'#013#010+
  4972. #013#010+
  4973. ' // Compile mode'#013#010+
  4974. ' If ATarget.Mode<>cmFPC then'#013#010+
  4975. ' Args.Add('#039'-M'#039'+ModeToString(ATarget.Mode))'#013#010+
  4976. ' else If Defaults.Mode<>','cmFPC then'#013#010+
  4977. ' Args.Add('#039'-M'#039'+ModeToString(Defaults.Mode));'#013#010+
  4978. ' // Output file paths'#013#010+
  4979. ' If ATarget.TargetType in ProgramTargets then'#013#010+
  4980. ' Args.Add('#039'-FE'#039'+APackage.GetBinOutputDir(Defaults.CPU,Defau'+
  4981. 'lts.OS));'#013#010+
  4982. ' Args.Add('#039'-FU'#039'+APackage.GetUnits','OutputDir(Defaults.CPU,Def'+
  4983. 'aults.OS));'#013#010+
  4984. ' // Object Path'#013#010+
  4985. ' L:=TUnsortedDuplicatesStringList.Create;'#013#010+
  4986. ' L.Duplicates:=dupIgnore;'#013#010+
  4987. ' AddConditionalStrings(L,APackage.ObjectPath,Defaults.CPU,Defaults.OS'+
  4988. ');'#013#010+
  4989. ' AddConditionalStrings(L,ATarget.Obj','ectPath,Defaults.CPU,Defaults.O'+
  4990. 'S);'#013#010+
  4991. ' for i:=0 to L.Count-1 do'#013#010+
  4992. ' Args.Add('#039'-Fo'#039'+L[i]);'#013#010+
  4993. ' FreeAndNil(L);'#013#010+
  4994. ' // Unit Dirs'#013#010+
  4995. ' L:=TUnsortedDuplicatesStringList.Create;'#013#010+
  4996. ' L.Duplicates:=dupIgnore;'#013#010+
  4997. ' AddDependencyUnitPaths(L,APackage);'#013#010+
  4998. ' Ad','dDependencyPaths(L,depUnit,ATarget);'#013#010+
  4999. ' AddConditionalStrings(L,APackage.UnitPath,Defaults.CPU,Defaults.OS);'+
  5000. #013#010+
  5001. ' AddConditionalStrings(L,ATarget.UnitPath,Defaults.CPU,Defaults.OS);'#013+
  5002. #010+
  5003. ' for i:=0 to L.Count-1 do'#013#010+
  5004. ' Args.Add('#039'-Fu'#039'+L[i]);'#013#010+
  5005. ' Fr','eeAndNil(L);'#013#010+
  5006. ' // Include Path'#013#010+
  5007. ' L:=TUnsortedDuplicatesStringList.Create;'#013#010+
  5008. ' L.Duplicates:=dupIgnore;'#013#010+
  5009. ' AddDependencyPaths(L,depInclude,ATarget);'#013#010+
  5010. ' AddConditionalStrings(L,APackage.IncludePath,Defaults.CPU,Defaults.O'+
  5011. 'S);'#013#010+
  5012. ' AddConditiona','lStrings(L,ATarget.IncludePath,Defaults.CPU,Defaults.'+
  5013. 'OS);'#013#010+
  5014. ' for i:=0 to L.Count-1 do'#013#010+
  5015. ' Args.Add('#039'-Fi'#039'+L[i]);'#013#010+
  5016. ' FreeAndNil(L);'#013#010+
  5017. ' // Custom Options'#013#010+
  5018. ' If (Defaults.HaveOptions) then'#013#010+
  5019. ' Args.AddStrings(Defaults.Options);'#013#010+
  5020. ' If (APackag','e.HaveOptions) then'#013#010+
  5021. ' Args.AddStrings(APackage.Options);'#013#010+
  5022. ' If (ATarget.HaveOptions) then'#013#010+
  5023. ' Args.AddStrings(ATarget.Options);'#013#010+
  5024. #013#010+
  5025. ' {$ifdef HAS_UNIT_PROCESS}'#013#010+
  5026. ' // Force the compiler-output to be easy parseable'#013#010+
  5027. ' if not Verbose then'#013#010,
  5028. ' args.Add('#039'-viq'#039');'#013#010+
  5029. ' {$endif}'#013#010+
  5030. #013#010+
  5031. ' // Convert to string'#013#010+
  5032. ' Result:='#039#039';'#013#010+
  5033. ' for i:=0 to Args.Count-1 do'#013#010+
  5034. ' Result:=Result+'#039' '#039'+maybequoted(Args[i]);'#013#010+
  5035. ' Delete(result,1,1);'#013#010+
  5036. #013#010+
  5037. ' if Defaults.UseEnvironment and assigned(Env) then'#013#010+
  5038. ' begin',#013#010+
  5039. ' env.Values['#039'FPCEXTCMD'#039'] := Result;'#013#010+
  5040. ' result := '#039'!FPCEXTCMD'#039';'#013#010+
  5041. ' // Make sure that this process'#039' environment variables are pa'+
  5042. 'ssed to the'#013#010+
  5043. ' // compiler'#039's environment'#013#010+
  5044. ' for i := 0 to GetEnvironmentVariableCount-1 do'#013,#010+
  5045. ' env.Add(GetEnvironmentString(i));'#013#010+
  5046. ' end;'#013#010+
  5047. #013#010+
  5048. ' // Add Filename to compile'#013#010+
  5049. ' result := result + '#039' '#039' + ATarget.TargetSourceFileName;'#013#010+
  5050. #013#010+
  5051. ' Args.Free;'#013#010+
  5052. 'end;'#013#010+
  5053. #013#010+
  5054. #013#010+
  5055. 'Function TBuildEngine.GetCompiler : String;'#013#010+
  5056. 'Var'#013#010+
  5057. ' S : String;'#013#010+
  5058. 'begin',#013#010+
  5059. ' // Cache in FCompiler for speed.'#013#010+
  5060. ' If (FCompiler='#039#039') then'#013#010+
  5061. ' begin'#013#010+
  5062. ' FCompiler:=Defaults.Compiler;'#013#010+
  5063. ' If (ExtractFilePath(FCompiler)='#039#039') then'#013#010+
  5064. ' begin'#013#010+
  5065. ' S:=ExeSearch(FCompiler,GetEnvironmentVariable('#039'PATH'#039'));'#013+
  5066. #010+
  5067. ' If ','(S<>'#039#039') then'#013#010+
  5068. ' FCompiler:=S;'#013#010+
  5069. ' end;'#013#010+
  5070. ' end;'#013#010+
  5071. ' Result:=FCompiler;'#013#010+
  5072. 'end;'#013#010+
  5073. #013#010+
  5074. #013#010+
  5075. 'procedure TBuildEngine.CreateOutputDir(APackage: TPackage);'#013#010+
  5076. 'Var'#013#010+
  5077. ' D : String;'#013#010+
  5078. ' i: integer;'#013#010+
  5079. 'begin'#013#010+
  5080. ' //create a units directory'#013#010+
  5081. ' D:=APackage.G','etUnitsOutputDir(Defaults.CPU,Defaults.OS);'#013#010+
  5082. ' If not SysDirectoryExists(D) then'#013#010+
  5083. ' begin'#013#010+
  5084. ' Log(vlInfo,SInfoCreatingOutputDir,[D]);'#013#010+
  5085. ' CmdCreateDir(D);'#013#010+
  5086. ' end;'#013#010+
  5087. #013#010+
  5088. ' //also create a bin directory for programtargets'#013#010+
  5089. ' For i := 0',' to Pred(APackage.Targets.Count) do'#013#010+
  5090. ' begin'#013#010+
  5091. ' if APackage.Targets.TargetItems[i].TargetType in (ProgramTargets'+
  5092. '-[ttExampleProgram]) then'#013#010+
  5093. ' begin'#013#010+
  5094. ' D:=APackage.GetBinOutputDir(Defaults.CPU,Defaults.OS);'#013#010+
  5095. ' If n','ot SysDirectoryExists(D) then'#013#010+
  5096. ' begin'#013#010+
  5097. ' Log(vlInfo,SInfoCreatingOutputDir,[D]);'#013#010+
  5098. ' CmdCreateDir(D);'#013#010+
  5099. ' end;'#013#010+
  5100. ' //do not continue loop, directory is made anyway'#013#010+
  5101. ' break;'#013#010+
  5102. ' ',' end;'#013#010+
  5103. ' end;'#013#010+
  5104. 'end;'#013#010+
  5105. #013#010+
  5106. #013#010+
  5107. 'Function TBuildEngine.DependencyOK(ADependency : TDependency) : Boolea'+
  5108. 'n;'#013#010+
  5109. 'begin'#013#010+
  5110. ' Result:=(Defaults.CPU in ADependency.CPUs) and (Defaults.OS in ADepe'+
  5111. 'ndency.OSes);'#013#010+
  5112. 'end;'#013#010+
  5113. #013#010+
  5114. #013#010+
  5115. 'Function TBuildEngine.TargetOK(ATarge','t : TTarget) : Boolean;'#013#010+
  5116. 'begin'#013#010+
  5117. ' Result:=(Defaults.CPU in ATarget.CPUs) and (Defaults.OS in ATarget.O'+
  5118. 'Ses);'#013#010+
  5119. 'end;'#013#010+
  5120. #013#010+
  5121. #013#010+
  5122. 'Function TBuildEngine.PackageOK(APackage : TPackage) : Boolean;'#013#010+
  5123. 'begin'#013#010+
  5124. ' Result:=(Defaults.CPU in APackage.CPUs) and (De','faults.OS in APacka'+
  5125. 'ge.OSes);'#013#010+
  5126. 'end;'#013#010+
  5127. #013#010+
  5128. #013#010+
  5129. 'procedure TBuildEngine.DoBeforeCompile(APackage: TPackage);'#013#010+
  5130. 'begin'#013#010+
  5131. ' ExecuteCommands(APackage.Commands,caBeforeCompile);'#013#010+
  5132. ' If Assigned(APackage.BeforeCompile) then'#013#010+
  5133. ' APackage.BeforeCompile(APacka','ge);'#013#010+
  5134. ' If Assigned(APackage.BeforeCompileProc) then'#013#010+
  5135. ' APackage.BeforeCompileProc(APackage);'#013#010+
  5136. 'end;'#013#010+
  5137. #013#010+
  5138. #013#010+
  5139. 'procedure TBuildEngine.DoAfterCompile(APackage: TPackage);'#013#010+
  5140. 'begin'#013#010+
  5141. ' If Assigned(APackage.AfterCompile) then'#013#010+
  5142. ' APackage.AfterCompi','le(APackage);'#013#010+
  5143. ' If Assigned(APackage.AfterCompileProc) then'#013#010+
  5144. ' APackage.AfterCompileProc(APackage);'#013#010+
  5145. ' ExecuteCommands(APackage.Commands,caAfterCompile);'#013#010+
  5146. 'end;'#013#010+
  5147. #013#010+
  5148. #013#010+
  5149. 'Function TBuildEngine.NeedsCompile(APackage:TPackage;ATarget: TTarget)'+
  5150. ': ','Boolean;'#013#010+
  5151. 'Var'#013#010+
  5152. ' I : Integer;'#013#010+
  5153. ' D : TDependency;'#013#010+
  5154. ' T : TTarget;'#013#010+
  5155. ' OD,OFN : String;'#013#010+
  5156. 'begin'#013#010+
  5157. ' Result:=False;'#013#010+
  5158. #013#010+
  5159. ' // Forced recompile?'#013#010+
  5160. ' if FForceCompile then'#013#010+
  5161. ' Result:=true;'#013#010+
  5162. #013#010+
  5163. ' // For now examples are not compiled at all'#013#010+
  5164. ' if ATar','get.TargetType in [ttExampleUnit, ttExampleProgram] then'#013+
  5165. #010+
  5166. ' Exit;'#013#010+
  5167. #013#010+
  5168. ' // Check output file'#013#010+
  5169. ' if not result and TargetOK(ATarget) then'#013#010+
  5170. ' begin'#013#010+
  5171. ' if ATarget.TargetType in ProgramTargets then'#013#010+
  5172. ' OD:=APackage.GetBinOutputDir(D','efaults.CPU,Defaults.OS)'#013#010+
  5173. ' else'#013#010+
  5174. ' OD:=APackage.GetUnitsOutputDir(Defaults.CPU,Defaults.OS);'#013#010+
  5175. ' If (OD<>'#039#039') then'#013#010+
  5176. ' OD:=IncludeTrailingPathDelimiter(OD);'#013#010+
  5177. ' OFN:=OD+ATarget.GetOutPutFileName(Defaults.OS);'#013#010+
  5178. ' Res','ult:=Not FileExists(OFN);'#013#010+
  5179. ' if Result then'#013#010+
  5180. ' Log(vlDebug,SDbgOutputNotYetAvailable,[OFN]);'#013#010+
  5181. ' end;'#013#010+
  5182. #013#010+
  5183. ' // Check main source'#013#010+
  5184. ' If not Result then'#013#010+
  5185. ' begin'#013#010+
  5186. ' if FileExists(ATarget.TargetSourceFileName) then'#013#010+
  5187. ' Res','ult:=FileNewer(ATarget.TargetSourceFileName,OFN)'#013#010+
  5188. ' end;'#013#010+
  5189. #013#010+
  5190. ' // Check unit and include dependencies'#013#010+
  5191. ' If not Result then'#013#010+
  5192. ' begin'#013#010+
  5193. ' ResolveDependencies(ATarget.Dependencies,ATarget.Collection as T'+
  5194. 'Targets);'#013#010+
  5195. ' I:=0;'#013#010+
  5196. ' for',' i:=0 to ATarget.Dependencies.Count-1 do'#013#010+
  5197. ' begin'#013#010+
  5198. ' D:=ATarget.Dependencies[i];'#013#010+
  5199. ' if (Defaults.CPU in D.CPUs) and (Defaults.OS in D.OSes) then'+
  5200. #013#010+
  5201. ' begin'#013#010+
  5202. ' case D.DependencyType of'#013#010+
  5203. ' ',' depUnit :'#013#010+
  5204. ' begin'#013#010+
  5205. ' T:=TTarget(D.Target);'#013#010+
  5206. ' If (T=Nil) then'#013#010+
  5207. ' Error(SErrDepUnknownTarget,[D.Value, ATarget.Nam'+
  5208. 'e, APackage.Name]);'#013#010+
  5209. ' // If a de','pendent package is compiled we always '+
  5210. 'need to recompile'#013#010+
  5211. ' Log(vldebug, SDbgDependencyOnUnit, [ATarget.Name,T'+
  5212. '.Name]);'#013#010+
  5213. ' Result:=(T.State=tsCompiled);'#013#010+
  5214. ' if Result then'#013#010+
  5215. ' ',' Log(vldebug, SDbgDependencyUnitRecompiled, [T.'+
  5216. 'Name]);'#013#010+
  5217. ' end;'#013#010+
  5218. ' depInclude :'#013#010+
  5219. ' begin'#013#010+
  5220. ' if D.TargetFileName<>'#039#039' then'#013#010+
  5221. ' Result:=FileNewer(D.TargetFi','leName,OFN)'#013#010+
  5222. ' end;'#013#010+
  5223. ' depPackage :'#013#010+
  5224. ' begin'#013#010+
  5225. ' log(vlWarning,SWarnTargetDependsOnPackage,[ATarget'+
  5226. '.Name, APackage.Name, d.Value]);'#013#010+
  5227. ' end;'#013#010+
  5228. ' end;'#013#010,
  5229. ' if result then'#013#010+
  5230. ' break;'#013#010+
  5231. ' end;'#013#010+
  5232. ' end;'#013#010+
  5233. ' end;'#013#010+
  5234. #013#010+
  5235. ' if result then'#013#010+
  5236. ' Log(vlDebug,SDbgMustCompile,[ATarget.Name]);'#013#010+
  5237. 'end;'#013#010+
  5238. #013#010+
  5239. #013#010+
  5240. 'procedure TBuildEngine.Compile(APackage: TPackage; ATarget: TTar','get)'+
  5241. ';'#013#010+
  5242. 'Var'#013#010+
  5243. ' S : String;'#013#010+
  5244. ' Env : TStrings;'#013#010+
  5245. 'begin'#013#010+
  5246. ' Log(vlInfo,SInfoCompilingTarget,[ATarget.Name]);'#013#010+
  5247. ' LogIndent;'#013#010+
  5248. ' ExecuteCommands(ATarget.Commands,caBeforeCompile);'#013#010+
  5249. ' If Assigned(ATarget.BeforeCompile) then'#013#010+
  5250. ' ATarget.BeforeCompil','e(ATarget);'#013#010+
  5251. #013#010+
  5252. ' if APackage.BuildMode=bmBuildUnit then'#013#010+
  5253. ' begin'#013#010+
  5254. ' APackage.FBUTarget.Dependencies.AddUnit(ATarget.Name).FTargetFil'+
  5255. 'eName:=ATarget.TargetSourceFileName;'#013#010+
  5256. ' end'#013#010+
  5257. ' else'#013#010+
  5258. ' begin'#013#010+
  5259. ' if Defaults.UseEnvironment the','n'#013#010+
  5260. ' begin'#013#010+
  5261. ' Env := TStringList.Create;'#013#010+
  5262. ' try'#013#010+
  5263. ' S:=GetCompilerCommand(APackage,ATarget,Env);'#013#010+
  5264. ' ExecuteCommand(GetCompiler,S,Env);'#013#010+
  5265. ' finally'#013#010+
  5266. ' Env.Free;'#013#010+
  5267. ' end;'#013#010+
  5268. ' ',' end'#013#010+
  5269. ' else'#013#010+
  5270. ' begin'#013#010+
  5271. ' S:=GetCompilerCommand(APackage,ATarget,Env);'#013#010+
  5272. ' ExecuteCommand(GetCompiler,S,nil);'#013#010+
  5273. ' end;'#013#010+
  5274. ' If Assigned(ATarget.AfterCompile) then'#013#010+
  5275. ' ATarget.AfterCompile(ATarget);'#013#010+
  5276. ' ',' ExecuteCommands(ATarget.Commands,caAfterCompile);'#013#010+
  5277. ' end;'#013#010+
  5278. ' LogUnIndent;'#013#010+
  5279. 'end;'#013#010+
  5280. #013#010+
  5281. #013#010+
  5282. 'procedure TBuildEngine.CompileDependencies(APackage:TPackage; ATarget:'+
  5283. ' TTarget);'#013#010+
  5284. 'Var'#013#010+
  5285. ' I : Integer;'#013#010+
  5286. ' T : TTarget;'#013#010+
  5287. ' D : TDependency;'#013#010+
  5288. 'begin'#013#010+
  5289. ' Lo','g(vlDebug, Format(SDbgCompilingDependenciesOfTarget, [ATarget.Na'+
  5290. 'me]));'#013#010+
  5291. ' LogIndent;'#013#010+
  5292. ' For I:=0 to ATarget.Dependencies.Count-1 do'#013#010+
  5293. ' begin'#013#010+
  5294. ' D:=ATarget.Dependencies[i];'#013#010+
  5295. ' if (D.DependencyType=depPackage) then'#013#010+
  5296. ' log(vlWa','rning,SWarnTargetDependsOnPackage,[ATarget.Name, APa'+
  5297. 'ckage.Name, d.Value])'#013#010+
  5298. ' else if (D.DependencyType=depUnit) and'#013#010+
  5299. ' (Defaults.CPU in D.CPUs) and (Defaults.OS in D.OSes) then'#013+
  5300. #010+
  5301. ' begin'#013#010+
  5302. ' T:=TTarget(D.Target);'#013#010+
  5303. ' ',' if Assigned(T) and (T<>ATarget) then'#013#010+
  5304. ' begin'#013#010+
  5305. ' if TargetOK(T) then'#013#010+
  5306. ' begin'#013#010+
  5307. ' // We don'#039't need to compile implicit units, they'+
  5308. ' are only'#013#010+
  5309. ' // used for dependency ','checking'#013#010+
  5310. ' if (T.TargetType<>ttImplicitUnit) then'#013#010+
  5311. ' begin'#013#010+
  5312. ' case T.State of'#013#010+
  5313. ' tsNeutral :'#013#010+
  5314. ' MaybeCompile(APackage,T);'#013#010+
  5315. ' ',' tsConsidering :'#013#010+
  5316. ' Log(vlWarning,SWarnCircularTargetDependency,'+
  5317. '[ATarget.Name,T.Name]);'#013#010+
  5318. ' end;'#013#010+
  5319. ' end;'#013#010+
  5320. ' end'#013#010+
  5321. ' else'#013#010+
  5322. ' Log(vlWar','ning, Format(SWarnDepUnitNotFound, [T.Name,'+
  5323. ' MakeTargetString(Defaults.CPU,Defaults.OS)]));'#013#010+
  5324. ' end'#013#010+
  5325. ' else'#013#010+
  5326. ' Error(SErrDepUnknownTarget,[D.Value, ATarget.Name, APackag'+
  5327. 'e.Name]);'#013#010+
  5328. ' end;'#013#010+
  5329. ' end;'#013#010+
  5330. ' LogUnInd','ent;'#013#010+
  5331. 'end;'#013#010+
  5332. #013#010+
  5333. #013#010+
  5334. 'procedure TBuildEngine.MaybeCompile(APackage: TPackage; ATarget: TTarg'+
  5335. 'et);'#013#010+
  5336. 'begin'#013#010+
  5337. ' if ATarget.State<>tsNeutral then'#013#010+
  5338. ' Error(SErrInvalidState,[ATarget.Name]);'#013#010+
  5339. ' Log(vlDebug, Format(SDbgConsideringTarget, [ATarget.Name])',');'#013#010+
  5340. ' LogIndent;'#013#010+
  5341. ' ATarget.FTargetState:=tsConsidering;'#013#010+
  5342. ' ResolveDependencies(ATarget.Dependencies,ATarget.Collection as TTarg'+
  5343. 'ets);'#013#010+
  5344. ' CompileDependencies(APackage, ATarget);'#013#010+
  5345. ' if NeedsCompile(APackage, ATarget) then'#013#010+
  5346. ' begin'#013#010+
  5347. ' Co','mpile(APackage,ATarget);'#013#010+
  5348. ' ATarget.FTargetState:=tsCompiled;'#013#010+
  5349. ' end'#013#010+
  5350. ' else'#013#010+
  5351. ' ATarget.FTargetState:=tsNoCompile;'#013#010+
  5352. ' LogUnIndent;'#013#010+
  5353. 'end;'#013#010+
  5354. #013#010+
  5355. #013#010+
  5356. 'function TBuildEngine.NeedsCompile(APackage: TPackage): Boolean;'#013#010+
  5357. 'Var'#013#010+
  5358. ' I : Integer;'#013#010+
  5359. ' P',' : TPackage;'#013#010+
  5360. ' D : TDependency;'#013#010+
  5361. 'begin'#013#010+
  5362. ' Result:=False;'#013#010+
  5363. #013#010+
  5364. ' // Forced recompile?'#013#010+
  5365. ' if FForceCompile then'#013#010+
  5366. ' Result:=true;'#013#010+
  5367. #013#010+
  5368. ' // Recompile because of Package Dependencies?'#013#010+
  5369. ' if not Result then'#013#010+
  5370. ' begin'#013#010+
  5371. ' I:=0;'#013#010+
  5372. ' For I:','=0 to APackage.Dependencies.Count-1 do'#013#010+
  5373. ' begin'#013#010+
  5374. ' D:=APackage.Dependencies[i];'#013#010+
  5375. ' if (D.DependencyType=depPackage) and'#013#010+
  5376. ' (Defaults.CPU in D.CPUs) and (Defaults.OS in D.OSes) the'+
  5377. 'n'#013#010+
  5378. ' begin'#013#010+
  5379. ' ',' P:=TPackage(D.Target);'#013#010+
  5380. ' if Assigned(P) then'#013#010+
  5381. ' begin'#013#010+
  5382. ' Result:=(P.State=tsCompiled);'#013#010+
  5383. ' if Result then'#013#010+
  5384. ' break;'#013#010+
  5385. ' end;'#013#010+
  5386. ' ',' end;'#013#010+
  5387. ' end;'#013#010+
  5388. ' end;'#013#010+
  5389. #013#010+
  5390. ' // Recompile a Target of this package?'#013#010+
  5391. ' If Not Result then'#013#010+
  5392. ' begin'#013#010+
  5393. ' try'#013#010+
  5394. ' If (APackage.Directory<>'#039#039') then'#013#010+
  5395. ' EnterDir(APackage.Directory);'#013#010+
  5396. ' for i:=0 to APackage.T','argets.Count-1 do'#013#010+
  5397. ' begin'#013#010+
  5398. ' Result:=NeedsCompile(APackage,APackage.Targets.TargetItems'+
  5399. '[i]);'#013#010+
  5400. ' if Result then'#013#010+
  5401. ' break;'#013#010+
  5402. ' end;'#013#010+
  5403. ' Finally'#013#010+
  5404. ' If (APackage.Directory<>'#039#039') then'#013#010+
  5405. ' ',' EnterDir('#039#039');'#013#010+
  5406. ' end;'#013#010+
  5407. ' end;'#013#010+
  5408. #013#010+
  5409. ' if result then'#013#010+
  5410. ' Log(vlDebug,SDbgMustCompile,[APackage.Name]);'#013#010+
  5411. 'end;'#013#010+
  5412. #013#010+
  5413. #013#010+
  5414. 'function TBuildEngine.CheckExternalPackage(Const APackageName : String'+
  5415. '):TPackage;'#013#010+
  5416. 'var'#013#010+
  5417. ' S : String;'#013#010+
  5418. ' F : String;',#013#010+
  5419. ' I : Integer;'#013#010+
  5420. 'begin'#013#010+
  5421. ' // Already checked?'#013#010+
  5422. ' I:=ExternalPackages.IndexOfName(APackageName);'#013#010+
  5423. ' if I<>-1 then'#013#010+
  5424. ' begin'#013#010+
  5425. ' result:=ExternalPackages.PackageItems[I];'#013#010+
  5426. ' exit;'#013#010+
  5427. ' end;'#013#010+
  5428. ' // Create new external package'#013#010+
  5429. ' Result',':=ExternalPackages.AddPackage(APackageName);'#013#010+
  5430. ' Result.FTargetState:=tsNotFound;'#013#010+
  5431. ' // Load unit config'#013#010+
  5432. ' S:=GetUnitDir(Result);'#013#010+
  5433. ' if S<>'#039#039' then'#013#010+
  5434. ' begin'#013#010+
  5435. ' Log(vldebug, SDbgExternalDependency, [APackageName,S]);'#013#010+
  5436. ' // Load unit',' config if it exists'#013#010+
  5437. ' F:=IncludeTrailingPathDelimiter(S)+UnitConfigFile;'#013#010+
  5438. ' if FileExists(F) then'#013#010+
  5439. ' begin'#013#010+
  5440. ' Log(vlDebug, Format(SDbgLoading, [F]));'#013#010+
  5441. ' Result.LoadUnitConfigFromFile(F);'#013#010+
  5442. ' end;'#013#010+
  5443. ' ','// Check recursive implicit dependencies'#013#010+
  5444. ' CompileDependencies(Result);'#013#010+
  5445. ' end'#013#010+
  5446. ' else'#013#010+
  5447. ' Error(SErrDependencyNotFound,[APackageName]);'#013#010+
  5448. 'end;'#013#010+
  5449. #013#010+
  5450. #013#010+
  5451. 'procedure TBuildEngine.CompileDependencies(APackage: TPackage);'#013#010+
  5452. 'Var'#013#010+
  5453. ' I : Integer;',#013#010+
  5454. ' P : TPackage;'#013#010+
  5455. ' D : TDependency;'#013#010+
  5456. 'begin'#013#010+
  5457. ' For I:=0 to APackage.Dependencies.Count-1 do'#013#010+
  5458. ' begin'#013#010+
  5459. ' D:=APackage.Dependencies[i];'#013#010+
  5460. ' if (D.DependencyType=depPackage) and'#013#010+
  5461. ' (Defaults.CPU in D.CPUs) and (Defaults.OS in D','.OSes) then'#013+
  5462. #010+
  5463. ' begin'#013#010+
  5464. ' P:=TPackage(D.Target);'#013#010+
  5465. ' If Assigned(P) then'#013#010+
  5466. ' begin'#013#010+
  5467. ' if (Defaults.CPU in P.CPUs) and (Defaults.OS in P.OSes) '+
  5468. 'then'#013#010+
  5469. ' begin'#013#010+
  5470. ' case P.Stat','e of'#013#010+
  5471. ' tsNeutral :'#013#010+
  5472. ' MaybeCompile(P);'#013#010+
  5473. ' tsConsidering :'#013#010+
  5474. ' Log(vlWarning,SWarnCircularPackageDependency,[AP'+
  5475. 'ackage.Name,P.Name]);'#013#010+
  5476. ' end;'#013#010+
  5477. ' ',' end'#013#010+
  5478. ' else'#013#010+
  5479. ' Log(vlWarning,SWarnDependOnOtherPlatformPackage,[APack'+
  5480. 'age.Name, D.Value, MakeTargetString(Defaults.CPU, Defaults.OS)]);'#013#010+
  5481. ' end'#013#010+
  5482. ' else'#013#010+
  5483. ' begin'#013#010+
  5484. ' D.T','arget:=CheckExternalPackage(D.Value);'#013#010+
  5485. ' P:=TPackage(D.Target);'#013#010+
  5486. ' end;'#013#010+
  5487. ' if (D.RequireChecksum<>$ffffffff) and'#013#010+
  5488. ' (P.InstalledChecksum<>$ffffffff) and'#013#010+
  5489. ' (P.InstalledChecksum<>D.RequireC','hecksum) then'#013#010+
  5490. ' Log(vlDebug,SDbgPackageChecksumChanged,[P.Name]);'#013#010+
  5491. ' end;'#013#010+
  5492. ' end;'#013#010+
  5493. 'end;'#013#010+
  5494. #013#010+
  5495. #013#010+
  5496. 'procedure TBuildEngine.Compile(APackage: TPackage);'#013#010+
  5497. 'Var'#013#010+
  5498. ' T : TTarget;'#013#010+
  5499. ' I : Integer;'#013#010+
  5500. ' Cmd: string;'#013#010+
  5501. ' cmdOpts: string;'#013#010+
  5502. ' ','sFPDocFormat: string;'#013#010+
  5503. ' IFPDocFormat: TFPDocFormat;'#013#010+
  5504. ' d: integer;'#013#010+
  5505. ' UC: string;'#013#010+
  5506. ' dep: TDependency;'#013#010+
  5507. ' RegenerateUnitconfigFile: boolean;'#013#010+
  5508. ' BUName: string;'#013#010+
  5509. #013#010+
  5510. ' procedure CompileBuildUnit;'#013#010+
  5511. ' var'#013#010+
  5512. ' I: Integer;'#013#010+
  5513. ' T: TTarget;'#013#010+
  5514. ' ','L: TStrings;'#013#010+
  5515. ' F: Text;'#013#010+
  5516. #013#010+
  5517. ' begin'#013#010+
  5518. ' if (APackage.FBUTarget.Dependencies.Count>0) then'#013#010+
  5519. ' begin'#013#010+
  5520. ' Log(vldebug, Format(SDbgGenerateBuildUnit, [APackage.FBUTarget'+
  5521. '.Name]));'#013#010+
  5522. ' system.Assign(F,APackage.FBUTarget.FTargetSo','urceFileName);'#013+
  5523. #010+
  5524. ' Rewrite(F);'#013#010+
  5525. ' writeln(F,'#039'unit '#039' + APackage.FBUTarget.Name +'#039';'#039+
  5526. ');'#013#010+
  5527. ' writeln(F,'#039'interface'#039');'#013#010+
  5528. ' writeln(F,'#039'uses'#039');'#013#010+
  5529. ' for i := 0 to APackage.FBUTarget.Dependencies.Count-1 do'#013#010+
  5530. ' begin'#013,#010+
  5531. ' if i<>0 then'#013#010+
  5532. ' write(F,'#039','#039');'#013#010+
  5533. ' writeln(F,APackage.FBUTarget.Dependencies.Dependencies[i].'+
  5534. 'Value);'#013#010+
  5535. ' end;'#013#010+
  5536. ' writeln(F,'#039';'#039');'#013#010+
  5537. ' writeln(F,'#039'implementation'#039');'#013#010+
  5538. ' writeln(F,'#039'end.'#039');',#013#010+
  5539. #013#010+
  5540. ' system.close(F);'#013#010+
  5541. #013#010+
  5542. ' APackage.FBuildMode:=bmOneByOne;'#013#010+
  5543. ' try'#013#010+
  5544. ' Compile(APackage,APackage.FBUTarget);'#013#010+
  5545. ' finally'#013#010+
  5546. ' // Delete temporary build-unit files'#013#010+
  5547. ' L := TStringList.Create;'#013#010+
  5548. ' ',' try'#013#010+
  5549. ' APackage.FBUTarget.GetCleanFiles(L,IncludeTrailingPathDeli'+
  5550. 'miter(APackage.GetUnitsOutputDir(Defaults.CPU,Defaults.OS)),'#039#039',D'+
  5551. 'efaults.CPU,Defaults.OS);'#013#010+
  5552. ' L.Add(APackage.FBUTarget.SourceFileName);'#013#010+
  5553. ' ','CmdDeleteFiles(L);'#013#010+
  5554. ' finally'#013#010+
  5555. ' L.Free;'#013#010+
  5556. ' end;'#013#010+
  5557. ' end;'#013#010+
  5558. ' end;'#013#010+
  5559. #013#010+
  5560. ' For I:=0 to APackage.Targets.Count-1 do'#013#010+
  5561. ' begin'#013#010+
  5562. ' T:=APackage.Targets.TargetItems[i];'#013#010+
  5563. ' if (T.TargetType = ttUnit',') and (TargetOK(T)) then'#013#010+
  5564. ' begin'#013#010+
  5565. ' If Assigned(T.AfterCompile) then'#013#010+
  5566. ' T.AfterCompile(T);'#013#010+
  5567. ' ExecuteCommands(T.Commands,caAfterCompile);'#013#010+
  5568. ' end'#013#010+
  5569. ' end;'#013#010+
  5570. ' end;'#013#010+
  5571. #013#010+
  5572. ' procedure ProcessComp','ileTarget;'#013#010+
  5573. ' begin'#013#010+
  5574. ' if TargetOK(T) then'#013#010+
  5575. ' begin'#013#010+
  5576. ' if T.State=tsNeutral then'#013#010+
  5577. ' MaybeCompile(APackage,T);'#013#010+
  5578. ' // If a target is compiled, re-generate the UnitConfigFile'#013+
  5579. #010+
  5580. ' if T.FTargetState<>tsNoCompile th','en'#013#010+
  5581. ' RegenerateUnitconfigFile:= True;'#013#010+
  5582. ' end'#013#010+
  5583. ' else'#013#010+
  5584. ' begin'#013#010+
  5585. ' if not(Defaults.CPU in T.CPUs) then'#013#010+
  5586. ' Log(vldebug, Format(SDbgSkippingTargetWrongCPU, [T.Name, CPU'+
  5587. 'sToString(T.CPUs)]));'#013#010+
  5588. ' if not(Defau','lts.OS in T.OSes) then'#013#010+
  5589. ' Log(vldebug, Format(SDbgSkippingTargetWrongOS, [T.Name, OSes'+
  5590. 'ToString(T.OSes)]));'#013#010+
  5591. ' end;'#013#010+
  5592. ' end;'#013#010+
  5593. #013#010+
  5594. 'begin'#013#010+
  5595. ' cmdOpts := '#039#039';'#013#010+
  5596. #013#010+
  5597. ' log(vlWarning,SWarnStartCompilingPackage,[APackage.Name, Defaults.Ta'+
  5598. 'rget]',');'#013#010+
  5599. #013#010+
  5600. ' case Defaults.BuildMode of'#013#010+
  5601. ' bmOneByOne: begin'#013#010+
  5602. ' if bmOneByOne in APackage.SupportBuildModes then'#013+
  5603. #010+
  5604. ' APackage.FBuildMode:=bmOneByOne'#013#010+
  5605. ' else'#013#010+
  5606. ' raise excep','tion.create(SErrUnsupportedBuildmode'+
  5607. ');'#013#010+
  5608. ' end;'#013#010+
  5609. ' bmBuildUnit: begin'#013#010+
  5610. ' // When bmBuildUnit is supported by the package use'+
  5611. ' a buildunit.'#013#010+
  5612. ' // Unless there is only one target and bmOneByOne',' '+
  5613. 'is also supported'#013#010+
  5614. ' if (bmBuildUnit in APackage.SupportBuildModes) and'#013+
  5615. #010+
  5616. ' not ((APackage.Targets.Count=1) and (bmOneByOne '+
  5617. 'in APackage.SupportBuildModes)) then'#013#010+
  5618. ' APackage.FBuildMode:','=bmBuildUnit'#013#010+
  5619. ' else if bmOneByOne in APackage.SupportBuildModes th'+
  5620. 'en'#013#010+
  5621. ' begin'#013#010+
  5622. ' log(vlInfo,SInfoFallbackBuildmode);'#013#010+
  5623. ' APackage.FBuildMode:=bmOneByOne'#013#010+
  5624. ' ',' end'#013#010+
  5625. ' else'#013#010+
  5626. ' raise exception.create(SErrUnsupportedBuildmode);'+
  5627. #013#010+
  5628. ' end;'#013#010+
  5629. ' end;'#013#010+
  5630. #013#010+
  5631. ' Try'#013#010+
  5632. ' If (APackage.Directory<>'#039#039') then'#013#010+
  5633. ' EnterDir(APackage.Directory);'#013#010+
  5634. ' Create','OutputDir(APackage);'#013#010+
  5635. ' Dictionary.AddVariable('#039'UNITSOUTPUTDIR'#039',APackage.GetUnitsO'+
  5636. 'utputDir(Defaults.CPU,Defaults.OS));'#013#010+
  5637. ' Dictionary.AddVariable('#039'BINOUTPUTDIR'#039',APackage.GetBinOutpu'+
  5638. 'tDir(Defaults.CPU,Defaults.OS));'#013#010+
  5639. ' DoBeforeCompile(AP','ackage);'#013#010+
  5640. ' RegenerateUnitconfigFile:=False;'#013#010+
  5641. ' if APackage.BuildMode=bmBuildUnit then'#013#010+
  5642. ' begin'#013#010+
  5643. ' APackage.FBUTargets := TTargets.Create(TTarget);'#013#010+
  5644. ' if Defaults.OS in AllLimit83fsOses then'#013#010+
  5645. ' BUName := '#039'BUnit.p','p'#039#013#010+
  5646. ' else'#013#010+
  5647. ' BUName := '#039'BuildUnit_'#039'+StringReplace(APackage.Name,'#039+
  5648. '-'#039','#039'_'#039',[rfReplaceAll])+'#039'.pp'#039';'#013#010+
  5649. ' APackage.FBUTarget := APackage.FBUTargets.AddUnit(BUName);'#013+
  5650. #010+
  5651. ' APackage.FBUTarget.FTargetSourceFileName := APackage.','FBUTarg'+
  5652. 'et.SourceFileName;'#013#010+
  5653. ' end;'#013#010+
  5654. ' For I:=0 to APackage.Targets.Count-1 do'#013#010+
  5655. ' begin'#013#010+
  5656. ' T:=APackage.Targets.TargetItems[i];'#013#010+
  5657. ' case T.TargetType of'#013#010+
  5658. ' ttUnit:'#013#010+
  5659. ' begin'#013#010+
  5660. ' ProcessCompileTarget;'#013,#010+
  5661. ' end;'#013#010+
  5662. ' ttProgram:'#013#010+
  5663. ' begin // do nothing, are compiled later'#013#010+
  5664. ' end;'#013#010+
  5665. ' ttFPDoc:'#013#010+
  5666. ' begin'#013#010+
  5667. ' for d := 0 to T.Dependencies.Count - 1 do'#013#010+
  5668. ' begin'#013#010+
  5669. ' dep := TDepen','dency(T.Dependencies[d]);'#013#010+
  5670. #013#010+
  5671. ' //add unit dependencies'#013#010+
  5672. ' if dep.DependencyType = depUnit then'#013#010+
  5673. ' cmdOpts := cmdOpts + '#039' --input='#039' + dep.Value;'#013+
  5674. #010+
  5675. ' end;'#013#010+
  5676. #013#010+
  5677. ' //check if a documentatio','n target is given'#013#010+
  5678. ' cmdOpts := cmdOpts + '#039' --input='#039' + T.Directory + T'+
  5679. '.Name + T.Extension + '#039' --descr='#039'+ T.XML;'#013#010+
  5680. ' end'#013#010+
  5681. ' else'#013#010+
  5682. ' log(vldebug, SDbgTargetIsNotAUnitOrProgram,[T.Name]);'#013#010+
  5683. ' end;'#013#010+
  5684. ' en','d;'#013#010+
  5685. #013#010+
  5686. ' if APackage.BuildMode=bmBuildUnit then'#013#010+
  5687. ' CompileBuildUnit;'#013#010+
  5688. #013#010+
  5689. ' FreeAndNil(APackage.FBUTarget);'#013#010+
  5690. #013#010+
  5691. ' For I:=0 to APackage.Targets.Count-1 do'#013#010+
  5692. ' begin'#013#010+
  5693. ' T:=APackage.Targets.TargetItems[i];'#013#010+
  5694. ' if T.TargetTy','pe=ttProgram then'#013#010+
  5695. ' begin'#013#010+
  5696. ' ProcessCompileTarget;'#013#010+
  5697. ' end;'#013#010+
  5698. ' end;'#013#010+
  5699. #013#010+
  5700. ' if RegenerateUnitconfigFile then'#013#010+
  5701. ' begin'#013#010+
  5702. ' UC:=IncludeTrailingPathDelimiter(APackage.GetUnitsOutputDir(De'+
  5703. 'faults.CPU,Default','s.OS))+UnitConfigFile;'#013#010+
  5704. ' Log(vlInfo, Format(SDbgGenerating, [UC]));'#013#010+
  5705. ' APackage.SaveUnitConfigToFile(UC,Defaults.CPU,Defaults.OS);'#013+
  5706. #010+
  5707. ' end;'#013#010+
  5708. #013#010+
  5709. ' //compile documentation, because options were found'#013#010+
  5710. ' if cmdOpts <> '#039#039' the','n'#013#010+
  5711. ' begin'#013#010+
  5712. ' //append package name'#013#010+
  5713. ' cmdOpts := cmdOpts + '#039' --package='#039' + APackage.Name;'#013#010+
  5714. #013#010+
  5715. ' for IFPDocFormat:=Low(TFPDocFormat) to High(TFPDocFormat) do'#013+
  5716. #010+
  5717. ' begin'#013#010+
  5718. ' if IFPDocFormat in APackage.FPDocFormat then'#013#010+
  5719. ' ',' begin'#013#010+
  5720. ' //prepend output format'#013#010+
  5721. ' case IFPDocFormat of'#013#010+
  5722. ' ffHtml: sFPDocFormat := '#039'--format=html --output='#039+
  5723. ' + Defaults.FPDocOutputDir;'#013#010+
  5724. ' ffHtm: sFPDocFormat := '#039'--format=htm --output=',#039+
  5725. ' + Defaults.FPDocOutputDir;'#013#010+
  5726. ' ffXHtml: sFPDocFormat := '#039'--format=xhtml --output='+
  5727. #039' + Defaults.FPDocOutputDir;'#013#010+
  5728. ' ffLaTex: sFPDocFormat := '#039'--format=latex --output='+
  5729. #039' + Defaults.FPDocOutputDir + APackage.Name + '#039'.','tex'#039';'#013#010+
  5730. ' ffXMLStruct: sFPDocFormat := '#039'--format=xml-struct --ou'+
  5731. 'tput='#039' + Defaults.FPDocOutputDir;'#013#010+
  5732. ' ffChm: sFPDocFormat := '#039'--format=chm --output='#039+
  5733. ' + Defaults.FPDocOutputDir + APackage.Name + '#039'.chm'#039';'#013#010+
  5734. ' end',';'#013#010+
  5735. #013#010+
  5736. ' //execute fpdoc'#013#010+
  5737. ' Cmd:=ExeSearch('#039'fpdoc'#039',GetEnvironmentvariable('#039'P'+
  5738. 'ATH'#039'));'#013#010+
  5739. ' if Cmd = '#039#039' then Cmd := '#039'fpdoc'#039';'#013#010+
  5740. ' ExecuteProcess(Cmd, sFPDocFormat + cmdOpts);'#013#010+
  5741. ' end;'#013#010+
  5742. ' end;'#013#010+
  5743. ' end;'#013#010+
  5744. #013#010+
  5745. ' ',' DoAfterCompile(APackage);'#013#010+
  5746. ' Finally'#013#010+
  5747. ' If (APackage.Directory<>'#039#039') then'#013#010+
  5748. ' EnterDir('#039#039');'#013#010+
  5749. ' end;'#013#010+
  5750. ' inc(FProgressCount);'#013#010+
  5751. ' if FProgressMax>0 then'#013#010+
  5752. ' log(vlWarning,SWarnCompilingPackagecompleteProgress,[(FProgressCou'+
  5753. 'nt)/FProgressM','ax * 100, APackage.Name])'#013#010+
  5754. ' else'#013#010+
  5755. ' log(vlWarning,SWarnCompilingPackagecomplete,[APackage.Name]);'#013#010+
  5756. 'end;'#013#010+
  5757. #013#010+
  5758. #013#010+
  5759. 'procedure TBuildEngine.MaybeCompile(APackage: TPackage);'#013#010+
  5760. 'begin'#013#010+
  5761. ' if APackage.State in [tsCompiled, tsNoCompile] then'#013#010+
  5762. ' begi','n'#013#010+
  5763. ' Log(vlInfo,SInfoPackageAlreadyProcessed,[APackage.Name]);'#013#010+
  5764. ' Exit;'#013#010+
  5765. ' end;'#013#010+
  5766. ' if APackage.State<>tsNeutral then'#013#010+
  5767. ' Error(SErrInvalidState,[APackage.Name]);'#013#010+
  5768. ' Log(vlDebug,SDbgConsideringPackage,[APackage.Name]);'#013#010+
  5769. ' LogInden','t;'#013#010+
  5770. ' APackage.FTargetState:=tsConsidering;'#013#010+
  5771. ' ResolveDependencies(APackage.Dependencies,(APackage.Collection as TP'+
  5772. 'ackages));'#013#010+
  5773. ' CompileDependencies(APackage);'#013#010+
  5774. ' ResolveFileNames(APackage,Defaults.CPU,Defaults.OS);'#013#010+
  5775. ' If NeedsCompile(APack','age) then'#013#010+
  5776. ' begin'#013#010+
  5777. ' Compile(APackage);'#013#010+
  5778. ' APackage.FTargetState:=tsCompiled;'#013#010+
  5779. ' end'#013#010+
  5780. ' else'#013#010+
  5781. ' begin'#013#010+
  5782. ' APackage.FTargetState:=tsNoCompile;'#013#010+
  5783. ' inc(FProgressCount);'#013#010+
  5784. ' end;'#013#010+
  5785. ' LogUnIndent;'#013#010+
  5786. 'end;'#013#010+
  5787. #013#010+
  5788. #013#010+
  5789. 'Function TBuild','Engine.InstallPackageFiles(APAckage : TPackage; tt : '+
  5790. 'TTargetType; Const Dest : String):Boolean;'#013#010+
  5791. 'Var'#013#010+
  5792. ' List : TStringList;'#013#010+
  5793. 'begin'#013#010+
  5794. ' Result:=False;'#013#010+
  5795. ' List:=TStringList.Create;'#013#010+
  5796. ' Try'#013#010+
  5797. ' APackage.GetInstallFiles(List,[tt],Defaults.CPU, D','efaults.OS);'#013+
  5798. #010+
  5799. ' if (List.Count>0) then'#013#010+
  5800. ' begin'#013#010+
  5801. ' Result:=True;'#013#010+
  5802. ' CmdCopyFiles(List,Dest);'#013#010+
  5803. ' end;'#013#010+
  5804. ' Finally'#013#010+
  5805. ' List.Free;'#013#010+
  5806. ' end;'#013#010+
  5807. 'end;'#013#010+
  5808. #013#010+
  5809. 'procedure TBuildEngine.InstallUnitConfigFile(APAckage: TPackage; const'+
  5810. ' De','st: String);'#013#010+
  5811. 'Var'#013#010+
  5812. ' List : TStringList;'#013#010+
  5813. 'begin'#013#010+
  5814. ' List:=TStringList.Create;'#013#010+
  5815. ' Try'#013#010+
  5816. ' List.add(IncludeTrailingPathDelimiter(APackage.GetUnitsOutputDir(D'+
  5817. 'efaults.CPU,Defaults.OS))+UnitConfigFile);'#013#010+
  5818. ' CmdCopyFiles(List,Dest);'#013#010+
  5819. ' Finally'#013#010,
  5820. ' List.Free;'#013#010+
  5821. ' end;'#013#010+
  5822. 'end;'#013#010+
  5823. #013#010+
  5824. 'function TBuildEngine.InstallPackageSourceFiles(APAckage : TPackage; s'+
  5825. 'tt : TSourceTypes; ttt : TTargetTypes; Const Dest : String): Boolean;'#013+
  5826. #010+
  5827. 'Var'#013#010+
  5828. ' List : TStringList;'#013#010+
  5829. 'begin'#013#010+
  5830. ' Result:=False;'#013#010+
  5831. ' List:=TStrin','gList.Create;'#013#010+
  5832. ' Try'#013#010+
  5833. ' APackage.GetInstallSourceFiles(List,stt,ttt);'#013#010+
  5834. ' if (List.Count>0) then'#013#010+
  5835. ' begin'#013#010+
  5836. ' Result:=True;'#013#010+
  5837. ' CmdCopyFiles(List,Dest);'#013#010+
  5838. ' end;'#013#010+
  5839. ' Finally'#013#010+
  5840. ' List.Free;'#013#010+
  5841. ' end;'#013#010+
  5842. 'end;'#013#010+
  5843. #013#010+
  5844. #013#010+
  5845. 'procedure TB','uildEngine.DoBeforeInstall(APackage: TPackage);'#013#010+
  5846. 'begin'#013#010+
  5847. ' ExecuteCommands(APackage.Commands,caBeforeInstall);'#013#010+
  5848. ' If Assigned(APackage.BeforeInstall) then'#013#010+
  5849. ' APackage.BeforeInstall(APackage);'#013#010+
  5850. ' If Assigned(APackage.BeforeInstallProc) then',#013#010+
  5851. ' APackage.BeforeInstallProc(APackage);'#013#010+
  5852. 'end;'#013#010+
  5853. #013#010+
  5854. #013#010+
  5855. 'procedure TBuildEngine.DoAfterInstall(APackage: TPackage);'#013#010+
  5856. 'begin'#013#010+
  5857. ' If Assigned(APackage.AfterInstall) then'#013#010+
  5858. ' APackage.AfterInstall(APackage);'#013#010+
  5859. ' If Assigned(APackage.AfterInstallPr','oc) then'#013#010+
  5860. ' APackage.AfterInstallProc(APackage);'#013#010+
  5861. ' ExecuteCommands(APackage.Commands,caAfterInstall);'#013#010+
  5862. 'end;'#013#010+
  5863. #013#010+
  5864. #013#010+
  5865. 'procedure TBuildEngine.Install(APackage: TPackage);'#013#010+
  5866. 'Var'#013#010+
  5867. ' UC,D : String;'#013#010+
  5868. ' B : Boolean;'#013#010+
  5869. 'begin'#013#010+
  5870. ' If (Apackage.State<>tsC','ompiled) then'#013#010+
  5871. ' MaybeCompile(APackage);'#013#010+
  5872. ' try'#013#010+
  5873. ' Log(vlInfo,SInfoInstallingPackage,[APackage.Name]);'#013#010+
  5874. ' If (APackage.Directory<>'#039#039') then'#013#010+
  5875. ' EnterDir(APackage.Directory);'#013#010+
  5876. ' DoBeforeInstall(APackage);'#013#010+
  5877. ' // units'#013#010+
  5878. ' B:=fals','e;'#013#010+
  5879. ' Dictionary.AddVariable('#039'PackageName'#039',APackage.Name);'#013#010+
  5880. ' D:=IncludeTrailingPathDelimiter(Defaults.UnitInstallDir);'#013#010+
  5881. ' if InstallPackageFiles(APAckage,ttUnit,D) then'#013#010+
  5882. ' B:=true;'#013#010+
  5883. ' if InstallPackageFiles(APAckage,ttImplicitU','nit,D) then'#013#010+
  5884. ' B:=true;'#013#010+
  5885. ' // By default do not install the examples. Maybe add an option for'+
  5886. ' this later'#013#010+
  5887. ' //if InstallPackageFiles(APAckage,ttExampleUnit,D) then'#013#010+
  5888. ' // B:=true;'#013#010+
  5889. ' // Unit (dependency) configuration if there w','ere units installed'+
  5890. #013#010+
  5891. ' if B then'#013#010+
  5892. ' InstallUnitConfigFile(APackage,D);'#013#010+
  5893. ' // Programs'#013#010+
  5894. ' D:=IncludeTrailingPathDelimiter(Defaults.BinInstallDir);'#013#010+
  5895. ' InstallPackageFiles(APAckage,ttProgram,D);'#013#010+
  5896. ' //InstallPackageFiles(APAckage,','ttExampleProgram,D);'#013#010+
  5897. ' // Documentation'#013#010+
  5898. ' D:=IncludeTrailingPathDelimiter(Defaults.DocInstallDir)+'#039'fpc-'#039+
  5899. '+APackage.FileName+PathDelim;'#013#010+
  5900. ' InstallPackageSourceFiles(APackage,[stDoc],[],D);'#013#010+
  5901. ' // Examples'#013#010+
  5902. ' if Defaults.InstallExam','ples then'#013#010+
  5903. ' begin'#013#010+
  5904. ' D:=IncludeTrailingPathDelimiter(Defaults.ExamplesInstallDir)+'#039+
  5905. 'fpc-'#039'+APackage.FileName+PathDelim+'#039'examples'#039'+PathDelim;'#013+
  5906. #010+
  5907. ' InstallPackageSourceFiles(APackage,[stExample],[ttExampleProgr'+
  5908. 'am,ttExampleUnit],D',');'#013#010+
  5909. ' end;'#013#010+
  5910. ' // Done.'#013#010+
  5911. ' APackage.FTargetState:=tsInstalled;'#013#010+
  5912. ' DoAfterInstall(APackage);'#013#010+
  5913. ' Finally'#013#010+
  5914. ' If (APackage.Directory<>'#039#039') then'#013#010+
  5915. ' EnterDir('#039#039');'#013#010+
  5916. ' end;'#013#010+
  5917. 'end;'#013#010+
  5918. #013#010+
  5919. #013#010+
  5920. 'procedure TBuildEngine.DoBeforeArchive(APackage: T','Package);'#013#010+
  5921. 'begin'#013#010+
  5922. ' ExecuteCommands(APackage.Commands,caBeforeArchive);'#013#010+
  5923. ' If Assigned(APackage.BeforeArchive) then'#013#010+
  5924. ' APackage.BeforeArchive(APackage);'#013#010+
  5925. ' If Assigned(APackage.BeforeArchiveProc) then'#013#010+
  5926. ' APackage.BeforeArchiveProc(APack','age);'#013#010+
  5927. 'end;'#013#010+
  5928. #013#010+
  5929. #013#010+
  5930. 'procedure TBuildEngine.DoAfterArchive(APackage: TPackage);'#013#010+
  5931. 'begin'#013#010+
  5932. ' If Assigned(APackage.AfterArchive) then'#013#010+
  5933. ' APackage.AfterArchive(APackage);'#013#010+
  5934. ' If Assigned(APackage.AfterArchiveProc) then'#013#010+
  5935. ' APackage.AfterArchivePro','c(APackage);'#013#010+
  5936. ' ExecuteCommands(APackage.Commands,caAfterArchive);'#013#010+
  5937. 'end;'#013#010+
  5938. #013#010+
  5939. #013#010+
  5940. 'procedure TBuildEngine.Archive(APackage: TPackage);'#013#010+
  5941. 'Var'#013#010+
  5942. ' L : TStringList;'#013#010+
  5943. ' A : String;'#013#010+
  5944. ' i: integer;'#013#010+
  5945. ' ICPU : TCPU;'#013#010+
  5946. ' IOS : TOS;'#013#010+
  5947. 'begin'#013#010+
  5948. ' A:=FStartDir+ ','APackage.FileName + ZipExt;'#013#010+
  5949. ' Log(vlInfo,SInfoArchivingPackage,[APackage.Name,A]);'#013#010+
  5950. ' try'#013#010+
  5951. ' If (APackage.Directory<>'#039#039') then'#013#010+
  5952. ' EnterDir(APackage.Directory);'#013#010+
  5953. ' DoBeforeArchive(Apackage);'#013#010+
  5954. ' L:=TStringList.Create;'#013#010+
  5955. ' L.Sorted:','=true;'#013#010+
  5956. ' L.Duplicates:=dupIgnore;'#013#010+
  5957. ' Try'#013#010+
  5958. ' // Add fpmake.pp & manifest.xml always'#013#010+
  5959. ' L.Add(FPMakePPFile);'#013#010+
  5960. ' L.Add(ManifestFile);'#013#010+
  5961. ' //get all files from all targets'#013#010+
  5962. ' for ICPU:=Low(TCPU) to high(TCPU) do'#013#010+
  5963. ' ',' for IOS:=Low(TOS) to high(TOS) do'#013#010+
  5964. ' if OSCPUSupported[IOS,ICPU] then'#013#010+
  5965. ' begin'#013#010+
  5966. ' ResolveFileNames(APackage,ICPU,IOS,false);'#013#010+
  5967. ' APackage.GetArchiveFiles(L, ICPU, IOS);'#013#010+
  5968. ' end;'#013#010+
  5969. ' //fr','om sources'#013#010+
  5970. ' APackage.GetArchiveSourceFiles(L);'#013#010+
  5971. #013#010+
  5972. ' //show all files'#013#010+
  5973. ' for i := 0 to L.Count-1 do'#013#010+
  5974. ' Log(vlDebug, Format(SDbgArchivingFile, [L[i]]));'#013#010+
  5975. #013#010+
  5976. '{$ifdef HAS_UNIT_ZIPPER}'#013#010+
  5977. ' if not Assigned(ArchiveFilesProc) ','then'#013#010+
  5978. ' begin'#013#010+
  5979. ' FZipFile := TZipper.Create;'#013#010+
  5980. ' FZipFile.ZipFiles(A, L);'#013#010+
  5981. ' end'#013#010+
  5982. ' else'#013#010+
  5983. '{$endif HAS_UNIT_ZIPPER}'#013#010+
  5984. ' CmdArchiveFiles(L,A);'#013#010+
  5985. ' Finally'#013#010+
  5986. ' L.Free;'#013#010+
  5987. #013#010+
  5988. '{$ifdef HAS_UNIT_ZIPPER}'#013#010+
  5989. ' ','if not Assigned(ArchiveFilesProc) then'#013#010+
  5990. ' FreeAndNil(FZipFile);'#013#010+
  5991. '{$endif HAS_UNIT_ZIPPER}'#013#010+
  5992. ' end;'#013#010+
  5993. ' DoAfterArchive(Apackage);'#013#010+
  5994. ' Finally'#013#010+
  5995. ' If (APackage.Directory<>'#039#039') then'#013#010+
  5996. ' EnterDir('#039#039');'#013#010+
  5997. ' end;'#013#010+
  5998. 'end;'#013#010+
  5999. #013#010+
  6000. #013#010+
  6001. 'procedure TBui','ldEngine.DoBeforeClean(APackage: TPackage);'#013#010+
  6002. 'begin'#013#010+
  6003. ' ExecuteCommands(APackage.Commands,caBeforeClean);'#013#010+
  6004. ' If Assigned(APackage.BeforeClean) then'#013#010+
  6005. ' APackage.BeforeClean(APackage);'#013#010+
  6006. ' If Assigned(APackage.BeforeCleanProc) then'#013#010+
  6007. ' APacka','ge.BeforeCleanProc(APackage);'#013#010+
  6008. 'end;'#013#010+
  6009. #013#010+
  6010. #013#010+
  6011. 'procedure TBuildEngine.DoAfterClean(APackage: TPackage);'#013#010+
  6012. 'begin'#013#010+
  6013. ' If Assigned(APackage.AfterClean) then'#013#010+
  6014. ' APackage.AfterClean(APackage);'#013#010+
  6015. ' If Assigned(APackage.AfterInstallProc) then'#013#010+
  6016. ' APacka','ge.AfterCleanProc(APackage);'#013#010+
  6017. ' ExecuteCommands(APackage.Commands,caAfterClean);'#013#010+
  6018. 'end;'#013#010+
  6019. #013#010+
  6020. #013#010+
  6021. 'procedure TBuildEngine.Clean(APackage: TPackage; AllTargets: boolean);'+
  6022. #013#010+
  6023. 'var'#013#010+
  6024. '// ACPU: TCpu;'#013#010+
  6025. '// AOS: TOS;'#013#010+
  6026. ' DirectoryList : TStringList;'#013#010+
  6027. 'begin'#013#010,
  6028. ' Log(vlInfo,SInfoCleaningPackage,[APackage.Name]);'#013#010+
  6029. ' try'#013#010+
  6030. ' If (APackage.Directory<>'#039#039') then'#013#010+
  6031. ' EnterDir(APackage.Directory);'#013#010+
  6032. ' DoBeforeClean(Apackage);'#013#010+
  6033. ' if AllTargets then'#013#010+
  6034. ' begin'#013#010+
  6035. ' // Remove the unit-directory c','ompletely. This is safer in ca'+
  6036. 'se of files'#013#010+
  6037. ' // being renamed and such. See also bug 19655'#013#010+
  6038. ' DirectoryList := TStringList.Create;'#013#010+
  6039. ' try'#013#010+
  6040. ' DirectoryList.Add(ExtractFileDir(APackage.GetUnitsOutputDir('+
  6041. 'Defaults.CPU,','Defaults.OS)));'#013#010+
  6042. ' CmdRemoveTrees(DirectoryList);'#013#010+
  6043. ' finally'#013#010+
  6044. ' DirectoryList.Free;'#013#010+
  6045. ' end;'#013#010+
  6046. '{ for ACPU:=low(TCpu) to high(TCpu) do'#013#010+
  6047. ' for AOS:=low(TOS) to high(TOS) do'#013#010+
  6048. ' begin'#013#010+
  6049. ' ',' if FileExists(APackage.GetUnitsOutputDir(ACPU,AOS)) or'+
  6050. #013#010+
  6051. ' FileExists(APackage.GetBinOutputDir(ACPU,AOS)) then'#013+
  6052. #010+
  6053. ' Clean(APackage,ACPU,AOS);'#013#010+
  6054. ' end;}'#013#010+
  6055. ' end'#013#010+
  6056. ' else'#013#010+
  6057. ' Clean(APackage, Def','aults.CPU, Defaults.OS);'#013#010+
  6058. ' DoAfterClean(Apackage);'#013#010+
  6059. ' Finally'#013#010+
  6060. ' If (APackage.Directory<>'#039#039') then'#013#010+
  6061. ' EnterDir('#039#039');'#013#010+
  6062. ' end;'#013#010+
  6063. 'end;'#013#010+
  6064. #013#010+
  6065. 'procedure TBuildEngine.Clean(APackage: TPackage; ACPU: TCPU; AOS: TOS)'+
  6066. ';'#013#010+
  6067. 'Var'#013#010+
  6068. ' List : TStringList;',#013#010+
  6069. ' DirectoryList : TStringList;'#013#010+
  6070. 'begin'#013#010+
  6071. ' List:=TStringList.Create;'#013#010+
  6072. ' try'#013#010+
  6073. ' List.Add(APackage.GetUnitsOutputDir(ACPU,AOS) + PathDelim + UnitCo'+
  6074. 'nfigFile);'#013#010+
  6075. ' APackage.GetCleanFiles(List,ACPU,AOS);'#013#010+
  6076. ' if (List.Count>0) then'#013#010+
  6077. ' beg','in'#013#010+
  6078. ' CmdDeleteFiles(List);'#013#010+
  6079. ' DirectoryList := TStringList.Create;'#013#010+
  6080. ' try'#013#010+
  6081. ' GetDirectoriesFromFilelist(List,DirectoryList);'#013#010+
  6082. ' CmdRemoveDirs(DirectoryList);'#013#010+
  6083. #013#010+
  6084. ' DirectoryList.Clear;'#013#010+
  6085. ' if DirectoryExis','ts(APackage.GetBinOutputDir(ACPU,AOS)) then'#013+
  6086. #010+
  6087. ' DirectoryList.Add(APackage.GetBinOutputDir(ACPU,AOS));'#013#010+
  6088. ' if DirectoryExists(APackage.GetUnitsOutputDir(ACPU,AOS)) then'#013+
  6089. #010+
  6090. ' DirectoryList.Add(APackage.GetUnitsOutputDir(ACP','U,AOS));'#013+
  6091. #010+
  6092. ' CmdRemoveDirs(DirectoryList);'#013#010+
  6093. #013#010+
  6094. ' DirectoryList.Clear;'#013#010+
  6095. ' if DirectoryExists(ExtractFileDir(APackage.GetBinOutputDir(ACP'+
  6096. 'U,AOS))) then'#013#010+
  6097. ' DirectoryList.Add(ExtractFileDir(APackage.GetBinOutputDir(AC'+
  6098. 'PU,A','OS)));'#013#010+
  6099. ' if DirectoryExists(ExtractFileDir(APackage.GetUnitsOutputDir(A'+
  6100. 'CPU,AOS))) then'#013#010+
  6101. ' DirectoryList.Add(ExtractFileDir(APackage.GetUnitsOutputDir('+
  6102. 'ACPU,AOS)));'#013#010+
  6103. ' CmdRemoveDirs(DirectoryList);'#013#010+
  6104. ' finally'#013#010+
  6105. ' ',' DirectoryList.Free;'#013#010+
  6106. ' end;'#013#010+
  6107. ' end;'#013#010+
  6108. ' Finally'#013#010+
  6109. ' List.Free;'#013#010+
  6110. ' end;'#013#010+
  6111. 'end;'#013#010+
  6112. #013#010+
  6113. #013#010+
  6114. 'Procedure TBuildEngine.Manifest(APackage : TPackage);'#013#010+
  6115. 'Var'#013#010+
  6116. ' L : TStrings;'#013#010+
  6117. ' PD,'#013#010+
  6118. ' MF : String;'#013#010+
  6119. 'begin'#013#010+
  6120. ' L:=TStringList.Create;'#013#010+
  6121. ' Try'#013#010+
  6122. ' Log(v','lInfo, Format(SInfoManifestPackage,[APackage.Name]));'#013#010+
  6123. ' PD:=APackage.Directory;'#013#010+
  6124. ' if PD<>'#039#039' then'#013#010+
  6125. ' PD:=IncludeTrailingPathDelimiter(PD);'#013#010+
  6126. ' MF:=PD+ManifestFile;'#013#010+
  6127. ' Log(vlDebug, Format(SDbgGenerating, [MF]));'#013#010+
  6128. ' L.Add('#039'<?xml',' version="1.0"?>'#039');'#013#010+
  6129. ' L.Add('#039'<packages>'#039');'#013#010+
  6130. ' APackage.GetManifest(L);'#013#010+
  6131. ' L.Add('#039'</packages>'#039');'#013#010+
  6132. ' L.SaveToFile(MF);'#013#010+
  6133. ' Finally'#013#010+
  6134. ' L.Free;'#013#010+
  6135. ' end;'#013#010+
  6136. 'end;'#013#010+
  6137. #013#010+
  6138. #013#010+
  6139. 'procedure TBuildEngine.Compile(Packages: TPackages);'#013#010+
  6140. 'Var'#013#010+
  6141. ' I : Intege','r;'#013#010+
  6142. ' P : TPackage;'#013#010+
  6143. 'begin'#013#010+
  6144. ' If Assigned(BeforeCompile) then'#013#010+
  6145. ' BeforeCompile(Self);'#013#010+
  6146. ' FProgressMax:=Packages.Count;'#013#010+
  6147. ' FProgressCount:=0;'#013#010+
  6148. ' For I:=0 to Packages.Count-1 do'#013#010+
  6149. ' begin'#013#010+
  6150. ' P:=Packages.PackageItems[i];'#013#010+
  6151. ' If Packa','geOK(P) then'#013#010+
  6152. ' MaybeCompile(P)'#013#010+
  6153. ' else'#013#010+
  6154. ' begin'#013#010+
  6155. ' inc(FProgressCount);'#013#010+
  6156. ' log(vlWarning,SWarnSkipPackageTargetProgress,[(FProgressCount)'+
  6157. '/FProgressMax * 100, P.Name, Defaults.Target]);'#013#010+
  6158. ' end;'#013#010+
  6159. ' end;'#013#010+
  6160. ' ',' If Assigned(AfterCompile) then'#013#010+
  6161. ' AfterCompile(Self);'#013#010+
  6162. 'end;'#013#010+
  6163. #013#010+
  6164. #013#010+
  6165. 'procedure TBuildEngine.Install(Packages: TPackages);'#013#010+
  6166. 'Var'#013#010+
  6167. ' I : Integer;'#013#010+
  6168. ' P : TPackage;'#013#010+
  6169. 'begin'#013#010+
  6170. ' If Assigned(BeforeInstall) then'#013#010+
  6171. ' BeforeInstall(Self);'#013#010+
  6172. ' For I:=0 t','o Packages.Count-1 do'#013#010+
  6173. ' begin'#013#010+
  6174. ' P:=Packages.PackageItems[i];'#013#010+
  6175. ' If PackageOK(P) then'#013#010+
  6176. ' begin'#013#010+
  6177. ' Install(P);'#013#010+
  6178. ' log(vlWarning, SWarnInstallationPackagecomplete, [P.Name, De'+
  6179. 'faults.Target]);'#013#010+
  6180. ' end'#013#010+
  6181. ' ',' else'#013#010+
  6182. ' log(vlWarning,SWarnSkipPackageTarget,[P.Name, Defaults.Target]'+
  6183. ');'#013#010+
  6184. ' end;'#013#010+
  6185. ' If Assigned(AfterInstall) then'#013#010+
  6186. ' AfterInstall(Self);'#013#010+
  6187. 'end;'#013#010+
  6188. #013#010+
  6189. #013#010+
  6190. 'procedure TBuildEngine.Archive(Packages: TPackages);'#013#010+
  6191. 'Var'#013#010+
  6192. ' I : Integer;'#013#010+
  6193. ' P',' : TPackage;'#013#010+
  6194. 'begin'#013#010+
  6195. ' If Assigned(BeforeArchive) then'#013#010+
  6196. ' BeforeArchive(Self);'#013#010+
  6197. ' Log(vlDebug, SDbgBuildEngineArchiving);'#013#010+
  6198. ' For I:=0 to Packages.Count-1 do'#013#010+
  6199. ' begin'#013#010+
  6200. ' P:=Packages.PackageItems[i];'#013#010+
  6201. ' Archive(P);'#013#010+
  6202. ' end;'#013#010+
  6203. ' If',' Assigned(AfterArchive) then'#013#010+
  6204. ' AfterArchive(Self);'#013#010+
  6205. 'end;'#013#010+
  6206. #013#010+
  6207. #013#010+
  6208. 'procedure TBuildEngine.Manifest(Packages: TPackages);'#013#010+
  6209. 'Var'#013#010+
  6210. ' I : Integer;'#013#010+
  6211. ' P : TPackage;'#013#010+
  6212. 'begin'#013#010+
  6213. ' If Assigned(BeforeManifest) then'#013#010+
  6214. ' BeforeManifest(Self);'#013#010+
  6215. ' Log(vlDebu','g, SDbgBuildEngineGenerateManifests);'#013#010+
  6216. ' For I:=0 to Packages.Count-1 do'#013#010+
  6217. ' begin'#013#010+
  6218. ' P:=Packages.PackageItems[i];'#013#010+
  6219. ' Manifest(P);'#013#010+
  6220. ' end;'#013#010+
  6221. ' If Assigned(AfterManifest) then'#013#010+
  6222. ' AfterManifest(Self);'#013#010+
  6223. 'end;'#013#010+
  6224. #013#010+
  6225. #013#010+
  6226. 'procedure TBuildEn','gine.Clean(Packages: TPackages; AllTargets: boolea'+
  6227. 'n);'#013#010+
  6228. 'Var'#013#010+
  6229. ' I : Integer;'#013#010+
  6230. ' P : TPackage;'#013#010+
  6231. 'begin'#013#010+
  6232. ' If Assigned(BeforeClean) then'#013#010+
  6233. ' BeforeClean(Self);'#013#010+
  6234. ' Log(vldebug, SDbgBuildEngineCleaning);'#013#010+
  6235. ' For I:=0 to Packages.Count-1 do'#013#010+
  6236. ' be','gin'#013#010+
  6237. ' P:=Packages.PackageItems[i];'#013#010+
  6238. ' If AllTargets or PackageOK(P) then'#013#010+
  6239. ' Clean(P, AllTargets);'#013#010+
  6240. ' log(vlWarning, SWarnCleanPackagecomplete, [P.Name]);'#013#010+
  6241. ' end;'#013#010+
  6242. ' If Assigned(AfterClean) then'#013#010+
  6243. ' AfterClean(Self);'#013#010+
  6244. 'end;'#013#010+
  6245. #013#010+
  6246. #013,#010+
  6247. '{*********************************************************************'+
  6248. '*******'#013#010+
  6249. ' TFPVersion'#013#010+
  6250. '**********************************************************************'+
  6251. '******}'#013#010+
  6252. #013#010+
  6253. 'function TFPVersion.GetAsString: Str','ing;'#013#010+
  6254. 'begin'#013#010+
  6255. ' if Empty then'#013#010+
  6256. ' Result:='#039'<none>'#039#013#010+
  6257. ' else'#013#010+
  6258. ' begin'#013#010+
  6259. ' Result := '#039#039';'#013#010+
  6260. ' if Major <> -1 then'#013#010+
  6261. ' Result := Result + IntToStr(Major);'#013#010+
  6262. ' if Minor <> -1 then'#013#010+
  6263. ' Result := Result + '#039'.'#039' + IntToStr(Minor);'#013#010+
  6264. ' if Mic','ro <> -1 then'#013#010+
  6265. ' Result := Result + '#039'.'#039' + IntToStr(Micro);'#013#010+
  6266. ' if Build <> -1 then'#013#010+
  6267. ' Result := Result + '#039'-'#039' + IntToStr(Build);'#013#010+
  6268. ' end;'#013#010+
  6269. 'end;'#013#010+
  6270. #013#010+
  6271. 'function TFPVersion.GetEmpty: Boolean;'#013#010+
  6272. 'begin'#013#010+
  6273. ' Result:=(Major=0) and (Minor=0) and ','(Micro=0) and (Build=0);'#013#010+
  6274. 'end;'#013#010+
  6275. #013#010+
  6276. 'procedure TFPVersion.SetAsString(const AValue: String);'#013#010+
  6277. #013#010+
  6278. ' Function NextDigit(sep : Char; var V : string) : integer;'#013#010+
  6279. ' Var'#013#010+
  6280. ' P : Integer;'#013#010+
  6281. ' begin'#013#010+
  6282. ' P:=Pos(Sep,V);'#013#010+
  6283. ' If (P=0) then'#013#010+
  6284. ' P:=Leng','th(V)+1;'#013#010+
  6285. ' Result:=StrToIntDef(Copy(V,1,P-1),-1);'#013#010+
  6286. ' If Result<>-1 then'#013#010+
  6287. ' Delete(V,1,P);'#013#010+
  6288. ' end;'#013#010+
  6289. #013#010+
  6290. 'Var'#013#010+
  6291. ' V : String;'#013#010+
  6292. 'begin'#013#010+
  6293. ' Clear;'#013#010+
  6294. ' // Special support for empty version string'#013#010+
  6295. ' if (AValue='#039#039') or (AValue='#039'<none>'#039') then'#013#010+
  6296. ' ',' exit;'#013#010+
  6297. ' V:=AValue;'#013#010+
  6298. ' Major:=NextDigit('#039'.'#039',V);'#013#010+
  6299. ' Minor:=NextDigit('#039'.'#039',V);'#013#010+
  6300. ' Micro:=NextDigit('#039'-'#039',V);'#013#010+
  6301. ' Build:=NextDigit(#0,V);'#013#010+
  6302. 'end;'#013#010+
  6303. #013#010+
  6304. 'procedure TFPVersion.Clear;'#013#010+
  6305. 'begin'#013#010+
  6306. ' Micro:=-1;'#013#010+
  6307. ' Major:=-1;'#013#010+
  6308. ' Minor:=-1;'#013#010+
  6309. ' Build:=-1;'#013#010+
  6310. 'end;'#013#010,
  6311. #013#010+
  6312. 'procedure TFPVersion.Assign(Source: TPersistent);'#013#010+
  6313. 'Var'#013#010+
  6314. ' V : TFPVersion;'#013#010+
  6315. 'begin'#013#010+
  6316. ' if Source is TFPVersion then'#013#010+
  6317. ' begin'#013#010+
  6318. ' V:=Source as TFPVersion;'#013#010+
  6319. ' Major:=V.Major;'#013#010+
  6320. ' Minor:=V.Minor;'#013#010+
  6321. ' Micro:=V.Micro;'#013#010+
  6322. ' Build:=V.Build;'#013,#010+
  6323. ' end'#013#010+
  6324. ' else'#013#010+
  6325. ' inherited Assign(Source);'#013#010+
  6326. 'end;'#013#010+
  6327. #013#010+
  6328. 'function TFPVersion.CompareVersion(AVersion: TFPVersion): Integer;'#013+
  6329. #010+
  6330. 'begin'#013#010+
  6331. ' Result:=Major-AVersion.Major;'#013#010+
  6332. ' If (Result=0) then'#013#010+
  6333. ' begin'#013#010+
  6334. ' Result:=Minor-AVersion.Minor;'#013#010+
  6335. ' ',' if (Result=0) then'#013#010+
  6336. ' begin'#013#010+
  6337. ' Result:=Micro-AVersion.Micro;'#013#010+
  6338. ' If (Result=0) then'#013#010+
  6339. ' Result:=Build-AVersion.Build;'#013#010+
  6340. ' end;'#013#010+
  6341. ' end;'#013#010+
  6342. 'end;'#013#010+
  6343. #013#010+
  6344. 'function TFPVersion.SameVersion(AVersion: TFPVersion): Boo','lean;'#013#010+
  6345. 'begin'#013#010+
  6346. ' Result:=CompareVersion(AVersion)=0;'#013#010+
  6347. 'end;'#013#010+
  6348. #013#010+
  6349. #013#010+
  6350. '{*********************************************************************'+
  6351. '*******'#013#010+
  6352. ' TTarget'#013#010+
  6353. '********************************************************','************'+
  6354. '********}'#013#010+
  6355. #013#010+
  6356. 'constructor TTarget.Create(ACollection: TCollection);'#013#010+
  6357. 'begin'#013#010+
  6358. ' inherited Create(ACollection);'#013#010+
  6359. ' FInstall:=True;'#013#010+
  6360. ' FCPUs:=AllCPUs;'#013#010+
  6361. ' FOSes:=AllOSes;'#013#010+
  6362. ' FUnitPath:=TConditionalStrings.Create(TConditionalString);'#013#010,
  6363. ' FIncludePath:=TConditionalStrings.Create(TConditionalString);'#013#010+
  6364. ' FObjectPath:=TConditionalStrings.Create(TConditionalString);'#013#010+
  6365. ' FDependencies:=TDependencies.Create(TDependency);'#013#010+
  6366. ' FCommands:=TCOmmands.Create(TCommand);'#013#010+
  6367. 'end;'#013#010+
  6368. #013#010+
  6369. #013#010+
  6370. 'destru','ctor TTarget.Destroy;'#013#010+
  6371. 'begin'#013#010+
  6372. ' FreeAndNil(FUnitPath);'#013#010+
  6373. ' FreeAndNil(FObjectPath);'#013#010+
  6374. ' FreeAndNil(FIncludePath);'#013#010+
  6375. ' FreeAndNil(FDependencies);'#013#010+
  6376. ' FreeAndNil(FCommands);'#013#010+
  6377. ' FreeAndNil(Foptions);'#013#010+
  6378. ' inherited Destroy;'#013#010+
  6379. 'end;'#013#010+
  6380. #013#010+
  6381. 'function TTarget','.GetOptions: TStrings;'#013#010+
  6382. 'begin'#013#010+
  6383. ' If Foptions=Nil then'#013#010+
  6384. ' FOptions:=TStringList.Create;'#013#010+
  6385. ' Result:=FOptions;'#013#010+
  6386. 'end;'#013#010+
  6387. #013#010+
  6388. 'function TTarget.GetUnitLibFileName: String;'#013#010+
  6389. 'begin'#013#010+
  6390. ' Result:='#039'libp'#039'+Name+LibExt;'#013#010+
  6391. 'end;'#013#010+
  6392. #013#010+
  6393. 'procedure TTarget.SetOptions(','const AValue: TStrings);'#013#010+
  6394. 'begin'#013#010+
  6395. ' If (AValue=Nil) or (AValue.Count=0) then'#013#010+
  6396. ' FreeAndNil(FOptions)'#013#010+
  6397. ' else'#013#010+
  6398. ' Options.Assign(AValue);'#013#010+
  6399. 'end;'#013#010+
  6400. #013#010+
  6401. 'function TTarget.GetSourceFileName: String;'#013#010+
  6402. 'begin'#013#010+
  6403. ' Result:=Name+FExtension;'#013#010+
  6404. 'end;'#013#010+
  6405. #013#010+
  6406. #013#010+
  6407. 'fu','nction TTarget.GetUnitFileName: String;'#013#010+
  6408. 'begin'#013#010+
  6409. ' Result:=Name+UnitExt;'#013#010+
  6410. 'end;'#013#010+
  6411. #013#010+
  6412. #013#010+
  6413. 'function TTarget.GetObjectFileName: String;'#013#010+
  6414. 'begin'#013#010+
  6415. ' Result:=Name+ObjExt;'#013#010+
  6416. 'end;'#013#010+
  6417. #013#010+
  6418. #013#010+
  6419. 'function TTarget.GetRSTFileName: String;'#013#010+
  6420. 'begin'#013#010+
  6421. ' Result:=Name+RSText;',#013#010+
  6422. 'end;'#013#010+
  6423. #013#010+
  6424. #013#010+
  6425. 'function TTarget.GetProgramFileName(AOS : TOS): String;'#013#010+
  6426. 'begin'#013#010+
  6427. ' if AOS in [Go32v2,Win32,Win64,OS2] then'#013#010+
  6428. ' Result:=Name+ExeExt'#013#010+
  6429. ' else'#013#010+
  6430. ' Result:=Name;'#013#010+
  6431. 'end;'#013#010+
  6432. #013#010+
  6433. #013#010+
  6434. 'function TTarget.GetOutputFileName(AOs: TOS): String;'#013#010+
  6435. 'begi','n'#013#010+
  6436. ' if TargetType in UnitTargets then'#013#010+
  6437. ' Result:=GetUnitFileName'#013#010+
  6438. ' else'#013#010+
  6439. ' Result:=GetProgramFileName(AOs);'#013#010+
  6440. 'end;'#013#010+
  6441. #013#010+
  6442. 'function TTarget.HaveOptions: Boolean;'#013#010+
  6443. 'begin'#013#010+
  6444. ' Result:=(FOptions<>Nil);'#013#010+
  6445. 'end;'#013#010+
  6446. #013#010+
  6447. #013#010+
  6448. 'procedure TTarget.SetName(const ','AValue: String);'#013#010+
  6449. 'Var'#013#010+
  6450. ' D,N,E : String;'#013#010+
  6451. 'begin'#013#010+
  6452. ' N:=FixPath(AValue);'#013#010+
  6453. ' D:=ExtractFilePath(N);'#013#010+
  6454. ' E:=ExtractFileExt(N);'#013#010+
  6455. ' N:=ExtractFileName(N);'#013#010+
  6456. ' inherited SetName(Copy(N,1,Length(N)-Length(E)));'#013#010+
  6457. ' FExtension:=E;'#013#010+
  6458. ' FDirectory:=D;'#013#010+
  6459. 'en','d;'#013#010+
  6460. #013#010+
  6461. 'procedure TTarget.SetXML(const AValue: string);'#013#010+
  6462. 'begin'#013#010+
  6463. ' FXML:=FixPath(AValue);'#013#010+
  6464. 'end;'#013#010+
  6465. #013#010+
  6466. 'procedure TTarget.GetCleanFiles(List: TStrings; const APrefixU, APrefi'+
  6467. 'xB : String; ACPU: TCPU; AOS : TOS);'#013#010+
  6468. 'begin'#013#010+
  6469. ' If not(ACPU in CPUs) or not','(AOS in OSes) then'#013#010+
  6470. ' exit;'#013#010+
  6471. ' List.Add(APrefixU + ObjectFileName);'#013#010+
  6472. ' If (TargetType in [ttUnit,ttImplicitUnit,ttExampleUnit, ttCleanOnlyU'+
  6473. 'nit]) then'#013#010+
  6474. ' begin'#013#010+
  6475. ' List.Add(APrefixU + UnitFileName);'#013#010+
  6476. ' if (AOS in AllSmartLinkLibra','ryOSes) and FileExists(APrefixU + '+
  6477. 'UnitLibFileName) then'#013#010+
  6478. ' List.Add(APrefixU + UnitLibFileName);'#013#010+
  6479. ' end'#013#010+
  6480. ' else If (TargetType in [ttProgram,ttExampleProgram]) then'#013#010+
  6481. ' List.Add(APrefixB + GetProgramFileName(AOS));'#013#010+
  6482. ' If ResourceSt','rings then'#013#010+
  6483. ' List.Add(APrefixU + RSTFileName);'#013#010+
  6484. ' // Maybe add later ? AddConditionalStrings(List,CleanFiles);'#013#010+
  6485. 'end;'#013#010+
  6486. #013#010+
  6487. #013#010+
  6488. 'procedure TTarget.GetInstallFiles(List: TStrings; const APrefixU, APre'+
  6489. 'fixB: String; ACPU: TCPU; AOS : TOS);'#013#010+
  6490. 'begin',#013#010+
  6491. ' If not(ACPU in CPUs) or not(AOS in OSes) then'#013#010+
  6492. ' exit;'#013#010+
  6493. ' If Not (TargetType in [ttProgram,ttExampleProgram]) then'#013#010+
  6494. ' List.Add(APrefixU + ObjectFileName);'#013#010+
  6495. ' If (TargetType in [ttUnit,ttImplicitUnit,ttExampleUnit]) then'#013#010+
  6496. ' begin'#013#010,
  6497. ' List.Add(APrefixU + UnitFileName);'#013#010+
  6498. ' if (AOS in AllSmartLinkLibraryOSes) and FileExists(APrefixU + Unit'+
  6499. 'LibFileName) then'#013#010+
  6500. ' List.Add(APrefixU + UnitLibFileName);'#013#010+
  6501. ' end'#013#010+
  6502. ' else If (TargetType in [ttProgram,ttExampleProgram]) th','en'#013#010+
  6503. ' List.Add(APrefixB + GetProgramFileName(AOS));'#013#010+
  6504. ' If ResourceStrings then'#013#010+
  6505. ' List.Add(APrefixU + RSTFileName);'#013#010+
  6506. ' // Maybe add later ? AddConditionalStrings(List,InstallFiles);'#013#010+
  6507. 'end;'#013#010+
  6508. #013#010+
  6509. #013#010+
  6510. 'procedure TTarget.GetArchiveFiles(List: TS','trings; ACPU: TCPU; AOS : '+
  6511. 'TOS);'#013#010+
  6512. 'var'#013#010+
  6513. ' i : integer;'#013#010+
  6514. ' D : TDependency;'#013#010+
  6515. 'begin'#013#010+
  6516. ' If not(ACPU in CPUs) or not(AOS in OSes) then'#013#010+
  6517. ' exit;'#013#010+
  6518. ' // Main source'#013#010+
  6519. ' if TargetSourceFileName<>'#039#039' then'#013#010+
  6520. ' List.Add(TargetSourceFileName);'#013#010+
  6521. ' // Inc','ludes'#013#010+
  6522. ' for i:=0 to Dependencies.Count-1 do'#013#010+
  6523. ' begin'#013#010+
  6524. ' D:=Dependencies[i];'#013#010+
  6525. ' if (D.DependencyType=depInclude) and'#013#010+
  6526. ' (D.TargetFileName<>'#039#039') then'#013#010+
  6527. ' List.Add(D.TargetFileName);'#013#010+
  6528. ' end;'#013#010+
  6529. ' // FPDoc files'#013#010+
  6530. ' if XML ','<> '#039#039' then'#013#010+
  6531. ' begin'#013#010+
  6532. ' List.Add(Directory + Name + Extension);'#013#010+
  6533. ' List.Add(XML);'#013#010+
  6534. ' end;'#013#010+
  6535. 'end;'#013#010+
  6536. #013#010+
  6537. #013#010+
  6538. '{*********************************************************************'+
  6539. '*******'#013#010+
  6540. ' TSource'#013#010+
  6541. '***************','*****************************************************'+
  6542. '********}'#013#010+
  6543. #013#010+
  6544. 'function TSource.GetInstallSourcePath: string;'#013#010+
  6545. 'begin'#013#010+
  6546. ' if FInstallSourcePath<>'#039#039' then'#013#010+
  6547. ' result := FInstallSourcePath'#013#010+
  6548. ' else if SourceType=stExample then'#013#010+
  6549. ' result := ',#039'examples'#039#013#010+
  6550. ' else'#013#010+
  6551. ' result := '#039#039';'#013#010+
  6552. 'end;'#013#010+
  6553. #013#010+
  6554. 'constructor TSource.Create(ACollection: TCollection);'#013#010+
  6555. 'begin'#013#010+
  6556. ' inherited Create(ACollection);'#013#010+
  6557. 'end;'#013#010+
  6558. #013#010+
  6559. #013#010+
  6560. 'destructor TSource.Destroy;'#013#010+
  6561. 'begin'#013#010+
  6562. ' inherited Destroy;'#013#010+
  6563. 'end;'#013#010+
  6564. #013#010+
  6565. 'procedure TSource.Get','InstallFiles(List: TStrings);'#013#010+
  6566. 'begin'#013#010+
  6567. ' if InstallSourcePath<>'#039#039' then'#013#010+
  6568. ' list.Values[name] := (IncludeTrailingPathDelimiter(InstallSourcePa'+
  6569. 'th)+ExtractFileName(Name))'#013#010+
  6570. ' else'#013#010+
  6571. ' list.add(Name);'#013#010+
  6572. 'end;'#013#010+
  6573. #013#010+
  6574. #013#010+
  6575. '{*******************************','************************************'+
  6576. '*********'#013#010+
  6577. ' TCommands'#013#010+
  6578. '**********************************************************************'+
  6579. '******}'#013#010+
  6580. #013#010+
  6581. 'function TCommands.GetCommand(const Dest : String): TCommand;'#013#010+
  6582. 'begin',#013#010+
  6583. ' Result:=TCommand(ItemByName(Dest));'#013#010+
  6584. 'end;'#013#010+
  6585. #013#010+
  6586. 'function TCommands.GetCommandItem(Index : Integer): TCommand;'#013#010+
  6587. 'begin'#013#010+
  6588. ' Result:=TCommand(Items[Index]);'#013#010+
  6589. 'end;'#013#010+
  6590. #013#010+
  6591. #013#010+
  6592. 'procedure TCommands.SetCommandItem(Index : Integer; const AValue: TCom'+
  6593. 'mand);',#013#010+
  6594. 'begin'#013#010+
  6595. ' Items[Index]:=AValue;'#013#010+
  6596. 'end;'#013#010+
  6597. #013#010+
  6598. #013#010+
  6599. 'Function TCommands.AddCommand(const Cmd: String) : TCommand;'#013#010+
  6600. 'begin'#013#010+
  6601. ' Result:=AddCommand(fdefaultAt,Cmd,'#039#039','#039#039','#039#039');'#013#010+
  6602. 'end;'#013#010+
  6603. #013#010+
  6604. #013#010+
  6605. 'function TCommands.AddCommand(const Cmd, Options: String): TCommand;'#013,
  6606. #010+
  6607. 'begin'#013#010+
  6608. ' Result:=AddCommand(fdefaultAt,Cmd,Options,'#039#039','#039#039');'#013#010+
  6609. 'end;'#013#010+
  6610. #013#010+
  6611. #013#010+
  6612. 'function TCommands.AddCommand(const Cmd, Options, Dest, Source: String'+
  6613. ' ): TCommand;'#013#010+
  6614. 'begin'#013#010+
  6615. ' Result:=AddCommand(fdefaultAt,Cmd,options,Dest,Source);'#013#010+
  6616. 'end;'#013#010+
  6617. #013#010+
  6618. #013#010+
  6619. 'Function',' TCommands.AddCommand(At: TCommandAt; const Cmd: String) : T'+
  6620. 'Command;'#013#010+
  6621. 'begin'#013#010+
  6622. ' Result:=AddCommand(At,Cmd,'#039#039','#039#039','#039#039');'#013#010+
  6623. 'end;'#013#010+
  6624. #013#010+
  6625. #013#010+
  6626. 'function TCommands.AddCommand(At: TCommandAt; const Cmd, Options: Stri'+
  6627. 'ng ): TCommand;'#013#010+
  6628. 'begin'#013#010+
  6629. ' Result:=AddComma','nd(At,Cmd,Options,'#039#039','#039#039');'#013#010+
  6630. 'end;'#013#010+
  6631. #013#010+
  6632. #013#010+
  6633. 'function TCommands.AddCommand(At: TCommandAt; const Cmd, Options, Dest'+
  6634. ', Source: String): TCommand;'#013#010+
  6635. 'begin'#013#010+
  6636. ' Result:=Add as TCommand;'#013#010+
  6637. ' Result.Command:=Cmd;'#013#010+
  6638. ' If (Options<>'#039#039') then'#013#010+
  6639. ' Result.ParseOpt','ions(Options);'#013#010+
  6640. ' Result.At:=At;'#013#010+
  6641. ' Result.SourceFile:=Source;'#013#010+
  6642. ' Result.DestFile:=Dest;'#013#010+
  6643. 'end;'#013#010+
  6644. #013#010+
  6645. #013#010+
  6646. '{*********************************************************************'+
  6647. '*******'#013#010+
  6648. ' TConditionalString'#013#010+
  6649. '**************','******************************************************'+
  6650. '********}'#013#010+
  6651. #013#010+
  6652. 'Constructor TConditionalString.Create;'#013#010+
  6653. 'begin'#013#010+
  6654. ' inherited Create;'#013#010+
  6655. 'end;'#013#010+
  6656. #013#010+
  6657. #013#010+
  6658. '{*********************************************************************'+
  6659. '*******'#013#010+
  6660. ' ',' TConditionalStrings'#013#010+
  6661. '**********************************************************************'+
  6662. '******}'#013#010+
  6663. #013#010+
  6664. 'Constructor TConditionalStrings.Create(AClass:TConditionalStringClass)'+
  6665. ';'#013#010+
  6666. 'begin'#013#010+
  6667. ' inherited Create;'#013#010+
  6668. ' FCSClass:=AClass;'#013#010+
  6669. 'end;'#013,#010+
  6670. #013#010+
  6671. #013#010+
  6672. 'function TConditionalStrings.GetConditionalString(Index : Integer): TC'+
  6673. 'onditionalString;'#013#010+
  6674. 'begin'#013#010+
  6675. ' Result:=TConditionalString(Items[Index]);'#013#010+
  6676. 'end;'#013#010+
  6677. #013#010+
  6678. #013#010+
  6679. 'procedure TConditionalStrings.SetConditionalString(Index : Integer; co'+
  6680. 'nst AValue: TC','onditionalString);'#013#010+
  6681. 'begin'#013#010+
  6682. ' Items[Index]:=AValue;'#013#010+
  6683. 'end;'#013#010+
  6684. #013#010+
  6685. #013#010+
  6686. 'Function TConditionalStrings.Add(Const Value : String) : TConditionalS'+
  6687. 'tring;'#013#010+
  6688. 'begin'#013#010+
  6689. ' result:=Add(Value,AllCPUs,AllOSes);'#013#010+
  6690. 'end;'#013#010+
  6691. #013#010+
  6692. #013#010+
  6693. '{$ifdef cpu_only_overloads}'#013#010+
  6694. 'Function TCondi','tionalStrings.Add(Const Value : String;const CPUs:TCP'+
  6695. 'Us) : TConditionalString;'#013#010+
  6696. 'begin'#013#010+
  6697. ' result:=Add(Value,CPUs,AllOSes);'#013#010+
  6698. 'end;'#013#010+
  6699. '{$endif cpu_only_overloads}'#013#010+
  6700. #013#010+
  6701. #013#010+
  6702. 'Function TConditionalStrings.Add(Const Value : String;const OSes:TOSes'+
  6703. ') : TCon','ditionalString;'#013#010+
  6704. 'begin'#013#010+
  6705. ' result:=Add(Value,AllCPUs,OSes);'#013#010+
  6706. 'end;'#013#010+
  6707. #013#010+
  6708. #013#010+
  6709. 'Function TConditionalStrings.Add(Const Value : String;const CPUs:TCPUs'+
  6710. ';const OSes:TOSes) : TConditionalString;'#013#010+
  6711. 'begin'#013#010+
  6712. ' Result:=FCSClass.Create;'#013#010+
  6713. ' Result.Value:=Value;'#013,#010+
  6714. ' Result.OSes:=OSes;'#013#010+
  6715. ' Result.CPUs:=CPUs;'#013#010+
  6716. ' inherited Add(Result);'#013#010+
  6717. 'end;'#013#010+
  6718. #013#010+
  6719. #013#010+
  6720. '{*********************************************************************'+
  6721. '*******'#013#010+
  6722. ' TDependency'#013#010+
  6723. '***********************************','*********************************'+
  6724. '********}'#013#010+
  6725. #013#010+
  6726. 'Constructor TDependency.Create;'#013#010+
  6727. 'begin'#013#010+
  6728. ' inherited Create;'#013#010+
  6729. ' FVersion:=TFPVersion.Create;'#013#010+
  6730. 'end;'#013#010+
  6731. #013#010+
  6732. #013#010+
  6733. 'Destructor TDependency.Destroy;'#013#010+
  6734. 'begin'#013#010+
  6735. ' FreeAndNil(FVersion);'#013#010+
  6736. 'end;'#013#010+
  6737. #013#010+
  6738. #013#010+
  6739. 'Function TDepend','ency.GetVersion : string;'#013#010+
  6740. 'begin'#013#010+
  6741. ' result:=FVersion.AsString;'#013#010+
  6742. 'end;'#013#010+
  6743. #013#010+
  6744. #013#010+
  6745. 'Procedure TDependency.SetVersion(const V : string);'#013#010+
  6746. 'begin'#013#010+
  6747. ' FVersion.AsString:=V;'#013#010+
  6748. 'end;'#013#010+
  6749. #013#010+
  6750. #013#010+
  6751. '{*********************************************************************'+
  6752. '*','******'#013#010+
  6753. ' TDependencies'#013#010+
  6754. '**********************************************************************'+
  6755. '******}'#013#010+
  6756. #013#010+
  6757. 'function TDependencies.GetDependency(Index : Integer): TDependency;'#013+
  6758. #010+
  6759. 'begin'#013#010+
  6760. ' Result:=TDependency(Items[','Index]);'#013#010+
  6761. 'end;'#013#010+
  6762. #013#010+
  6763. #013#010+
  6764. 'procedure TDependencies.SetDependency(Index : Integer; const AValue: T'+
  6765. 'Dependency);'#013#010+
  6766. 'begin'#013#010+
  6767. ' Items[Index]:=AValue;'#013#010+
  6768. 'end;'#013#010+
  6769. #013#010+
  6770. #013#010+
  6771. 'Function TDependencies.Add(Const Value : String) : TDependency;'#013#010+
  6772. 'begin'#013#010+
  6773. ' result:=Add(Value,Al','lCPUs,AllOSes);'#013#010+
  6774. 'end;'#013#010+
  6775. #013#010+
  6776. #013#010+
  6777. '{$ifdef cpu_only_overloads}'#013#010+
  6778. 'Function TDependencies.Add(Const Value : String;const CPUs:TCPUs) : TD'+
  6779. 'ependency;'#013#010+
  6780. 'begin'#013#010+
  6781. ' result:=Add(Value,CPUs,AllOSes);'#013#010+
  6782. 'end;'#013#010+
  6783. '{$endif cpu_only_overloads}'#013#010+
  6784. #013#010+
  6785. #013#010+
  6786. 'Function TDependenci','es.Add(Const Value : String;const OSes:TOSes) : '+
  6787. 'TDependency;'#013#010+
  6788. 'begin'#013#010+
  6789. ' result:=Add(Value,AllCPUs,OSes);'#013#010+
  6790. 'end;'#013#010+
  6791. #013#010+
  6792. #013#010+
  6793. 'Function TDependencies.Add(Const Value : String;const CPUs:TCPUs;const'+
  6794. ' OSes:TOSes) : TDependency;'#013#010+
  6795. 'begin'#013#010+
  6796. ' Result:=inherited',' Add(Value,CPUs,OSes) as TDependency;'#013#010+
  6797. ' Result.Target:=nil;'#013#010+
  6798. ' Result.FDependencyType:=depPackage;'#013#010+
  6799. 'end;'#013#010+
  6800. #013#010+
  6801. #013#010+
  6802. 'Function TDependencies.AddUnit(Const Value : String) : TDependency;'#013+
  6803. #010+
  6804. 'begin'#013#010+
  6805. ' result:=AddUnit(Value,AllCPUs,AllOSes);'#013#010+
  6806. 'end;'#013#010+
  6807. #013#010+
  6808. #013#010,
  6809. '{$ifdef cpu_only_overloads}'#013#010+
  6810. 'Function TDependencies.AddUnit(Const Value : String;const CPUs:TCPUs) '+
  6811. ': TDependency;'#013#010+
  6812. 'begin'#013#010+
  6813. ' result:=AddUnit(Value,CPUs,AllOSes);'#013#010+
  6814. 'end;'#013#010+
  6815. '{$endif cpu_only_overloads}'#013#010+
  6816. #013#010+
  6817. #013#010+
  6818. 'Function TDependencies.AddUnit(Const Va','lue : String;const OSes:TOSes'+
  6819. ') : TDependency;'#013#010+
  6820. 'begin'#013#010+
  6821. ' result:=AddUnit(Value,AllCPUs,OSes);'#013#010+
  6822. 'end;'#013#010+
  6823. #013#010+
  6824. #013#010+
  6825. 'Function TDependencies.AddUnit(Const Value : String;const CPUs:TCPUs;c'+
  6826. 'onst OSes:TOSes) : TDependency;'#013#010+
  6827. 'begin'#013#010+
  6828. ' Result:=inherited Add(Va','lue,CPUs,OSes) as TDependency;'#013#010+
  6829. ' Result.Target:=nil;'#013#010+
  6830. ' Result.FDependencyType:=depUnit;'#013#010+
  6831. 'end;'#013#010+
  6832. #013#010+
  6833. #013#010+
  6834. 'Function TDependencies.AddInclude(Const Value : String) : TDependency;'+
  6835. #013#010+
  6836. 'begin'#013#010+
  6837. ' result:=AddInclude(Value,AllCPUs,AllOSes);'#013#010+
  6838. 'end;'#013#010+
  6839. #013#010+
  6840. #013#010+
  6841. '{$if','def cpu_only_overloads}'#013#010+
  6842. 'Function TDependencies.AddInclude(Const Value : String;const CPUs:TCPU'+
  6843. 's) : TDependency;'#013#010+
  6844. 'begin'#013#010+
  6845. ' result:=AddInclude(Value,CPUs,AllOSes);'#013#010+
  6846. 'end;'#013#010+
  6847. '{$endif cpu_only_overloads}'#013#010+
  6848. #013#010+
  6849. #013#010+
  6850. 'Function TDependencies.AddInclude(Con','st Value : String;const OSes:TO'+
  6851. 'Ses) : TDependency;'#013#010+
  6852. 'begin'#013#010+
  6853. ' result:=AddInclude(Value,AllCPUs,OSes);'#013#010+
  6854. 'end;'#013#010+
  6855. #013#010+
  6856. #013#010+
  6857. 'Function TDependencies.AddInclude(Const Value : String;const CPUs:TCPU'+
  6858. 's;const OSes:TOSes) : TDependency;'#013#010+
  6859. 'Var'#013#010+
  6860. ' N : String;'#013#010+
  6861. 'be','gin'#013#010+
  6862. ' N:=FixPath(Value);'#013#010+
  6863. ' if ExtractFileExt(N)='#039#039' then'#013#010+
  6864. ' ChangeFileExt(N,IncExt);'#013#010+
  6865. ' Result:=inherited Add(N,CPUs,OSes) as TDependency;'#013#010+
  6866. ' Result.FDependencyType:=depInclude;'#013#010+
  6867. 'end;'#013#010+
  6868. #013#010+
  6869. #013#010+
  6870. '{***********************************************','********************'+
  6871. '*********'#013#010+
  6872. ' TValueItem'#013#010+
  6873. '**********************************************************************'+
  6874. '******}'#013#010+
  6875. #013#010+
  6876. 'constructor TValueItem.Create(AValue: String);'#013#010+
  6877. 'begin'#013#010+
  6878. ' FValue:=AValue;'#013#010+
  6879. 'end;'#013#010+
  6880. #013#010+
  6881. #013#010+
  6882. '{','*******************************************************************'+
  6883. '*********'#013#010+
  6884. ' TFunctionItem'#013#010+
  6885. '**********************************************************************'+
  6886. '******}'#013#010+
  6887. #013#010+
  6888. 'constructor TFunctionItem.Create(AFu','nc: TReplaceFunction);'#013#010+
  6889. 'begin'#013#010+
  6890. ' FFunc:=AFunc;'#013#010+
  6891. 'end;'#013#010+
  6892. #013#010+
  6893. #013#010+
  6894. '{*********************************************************************'+
  6895. '*******'#013#010+
  6896. ' TDictionary'#013#010+
  6897. '*********************************************************','***********'+
  6898. '********}'#013#010+
  6899. #013#010+
  6900. 'constructor TDictionary.Create(AOwner: TComponent);'#013#010+
  6901. 'begin'#013#010+
  6902. ' inherited Create(AOwner);'#013#010+
  6903. ' FList:=TStringList.Create;'#013#010+
  6904. ' FList.Sorted:=True;'#013#010+
  6905. ' FList.Duplicates:=dupError;'#013#010+
  6906. 'end;'#013#010+
  6907. #013#010+
  6908. #013#010+
  6909. 'destructor TDictionary.Destroy;'#013#010,
  6910. 'Var'#013#010+
  6911. ' I : Integer;'#013#010+
  6912. 'begin'#013#010+
  6913. ' For I:=0 to Flist.Count-1 do'#013#010+
  6914. ' FList.Objects[i].Free;'#013#010+
  6915. ' FreeAndNil(FList);'#013#010+
  6916. ' inherited Destroy;'#013#010+
  6917. 'end;'#013#010+
  6918. #013#010+
  6919. #013#010+
  6920. 'procedure TDictionary.AddVariable(const AName, Value: String);'#013#010+
  6921. 'Var'#013#010+
  6922. ' I : Integer;'#013#010+
  6923. 'begin'#013#010+
  6924. ' I:=F','list.IndexOf(AName);'#013#010+
  6925. ' If I=-1 then'#013#010+
  6926. ' I:=FList.Add(Aname)'#013#010+
  6927. ' else'#013#010+
  6928. ' Flist.Objects[i].Free;'#013#010+
  6929. ' Flist.Objects[i]:=TValueItem.Create(Value);'#013#010+
  6930. 'end;'#013#010+
  6931. #013#010+
  6932. #013#010+
  6933. 'procedure TDictionary.AddFunction(const AName: String; FReplacement: T'+
  6934. 'ReplaceFunctio','n);'#013#010+
  6935. 'Var'#013#010+
  6936. ' I : Integer;'#013#010+
  6937. 'begin'#013#010+
  6938. ' I:=Flist.IndexOf(AName);'#013#010+
  6939. ' If I=-1 then'#013#010+
  6940. ' I:=Flist.Add(AName)'#013#010+
  6941. ' else'#013#010+
  6942. ' Flist.Objects[i].Free;'#013#010+
  6943. ' Flist.Objects[i]:=TFunctionItem.Create(FReplacement);'#013#010+
  6944. 'end;'#013#010+
  6945. #013#010+
  6946. #013#010+
  6947. 'procedure TDictionary.RemoveItem(co','nst AName: String);'#013#010+
  6948. 'Var'#013#010+
  6949. ' I : Integer;'#013#010+
  6950. 'begin'#013#010+
  6951. ' I:=Flist.IndexOf(AName);'#013#010+
  6952. ' If (I<>-1) then'#013#010+
  6953. ' begin'#013#010+
  6954. ' FList.Objects[i].Free;'#013#010+
  6955. ' FList.Delete(I);'#013#010+
  6956. ' end;'#013#010+
  6957. 'end;'#013#010+
  6958. #013#010+
  6959. #013#010+
  6960. 'function TDictionary.GetValue(const AName: String): String;'#013#010+
  6961. 'be','gin'#013#010+
  6962. ' Result:=GetValue(AName,'#039#039');'#013#010+
  6963. 'end;'#013#010+
  6964. #013#010+
  6965. #013#010+
  6966. 'function TDictionary.GetValue(const AName,Args: String): String;'#013#010+
  6967. 'Var'#013#010+
  6968. ' O : TObject;'#013#010+
  6969. ' I : Integer;'#013#010+
  6970. 'begin'#013#010+
  6971. ' I:=Flist.IndexOf(AName);'#013#010+
  6972. ' If (I=-1) then'#013#010+
  6973. ' Raise EDictionaryError.CreateFmt(S','ErrNoDictionaryItem,[AName]);'#013+
  6974. #010+
  6975. ' O:=Flist.Objects[I];'#013#010+
  6976. ' If O is TValueItem then'#013#010+
  6977. ' Result:=TValueItem(O).FValue'#013#010+
  6978. ' else'#013#010+
  6979. ' Result:=TFunctionItem(O).FFunc(AName,Args);'#013#010+
  6980. 'end;'#013#010+
  6981. #013#010+
  6982. #013#010+
  6983. 'function TDictionary.ReplaceStrings(Const ASource: String','): String;'#013+
  6984. #010+
  6985. 'Var'#013#010+
  6986. ' S,FN,FV : String;'#013#010+
  6987. ' P: Integer;'#013#010+
  6988. 'begin'#013#010+
  6989. ' Result:='#039#039';'#013#010+
  6990. ' S:=ASource;'#013#010+
  6991. ' P:=Pos('#039'$('#039',S);'#013#010+
  6992. ' While (P<>0) do'#013#010+
  6993. ' begin'#013#010+
  6994. ' Result:=Result+Copy(S,1,P-1);'#013#010+
  6995. ' Delete(S,1,P+1);'#013#010+
  6996. ' P:=Pos('#039')'#039',S);'#013#010+
  6997. ' FN:=Copy(S,1',',P-1);'#013#010+
  6998. ' Delete(S,1,P);'#013#010+
  6999. ' P:=Pos('#039' '#039',FN);'#013#010+
  7000. ' If (P<>0) then // function arguments ?'#013#010+
  7001. ' begin'#013#010+
  7002. ' FV:=FN;'#013#010+
  7003. ' FN:=Copy(FN,1,P);'#013#010+
  7004. ' System.Delete(FV,1,P);'#013#010+
  7005. ' end'#013#010+
  7006. ' else'#013#010+
  7007. ' FV:='#039#039';'#013#010+
  7008. ' Re','sult:=Result+GetValue(FN,FV);'#013#010+
  7009. ' P:=Pos('#039'$('#039',S);'#013#010+
  7010. ' end;'#013#010+
  7011. ' Result:=Result+S;'#013#010+
  7012. 'end;'#013#010+
  7013. #013#010+
  7014. #013#010+
  7015. 'Function Substitute(Const Source : String; Macros : Array of string) :'+
  7016. ' String;'#013#010+
  7017. 'Var'#013#010+
  7018. ' I : Integer;'#013#010+
  7019. 'begin'#013#010+
  7020. ' I:=0;'#013#010+
  7021. ' While I<High(Macros) do'#013#010+
  7022. ' ',' begin'#013#010+
  7023. ' Dictionary.AddVariable(Macros[i],Macros[I+1]);'#013#010+
  7024. ' Inc(I,2);'#013#010+
  7025. ' end;'#013#010+
  7026. ' Result:=Dictionary.ReplaceStrings(Source);'#013#010+
  7027. ' While I<High(Macros) do'#013#010+
  7028. ' begin'#013#010+
  7029. ' Dictionary.RemoveItem(Macros[i]);'#013#010+
  7030. ' Inc(I,2);'#013#010+
  7031. ' end',';'#013#010+
  7032. 'end;'#013#010+
  7033. #013#010+
  7034. '{*********************************************************************'+
  7035. '*******'#013#010+
  7036. ' Default Instances'#013#010+
  7037. '**********************************************************************'+
  7038. '******}'#013#010+
  7039. #013#010+
  7040. 'var'#013#010+
  7041. ' DefInstall','er : TCustomInstaller;'#013#010+
  7042. #013#010+
  7043. 'Function Installer(InstallerClass: TInstallerClass): TCustomInstaller;'+
  7044. #013#010+
  7045. 'begin'#013#010+
  7046. ' If Not Assigned(DefInstaller) then'#013#010+
  7047. ' DefInstaller:=InstallerClass.Create(Nil);'#013#010+
  7048. ' Result:=DefInstaller;'#013#010+
  7049. 'end;'#013#010+
  7050. #013#010+
  7051. #013#010+
  7052. 'Function Instal','ler: TCustomInstaller;'#013#010+
  7053. 'begin'#013#010+
  7054. ' Result := Installer(TFPCInstaller);'#013#010+
  7055. 'end;'#013#010+
  7056. #013#010+
  7057. #013#010+
  7058. #013#010+
  7059. '{ TCommand }'#013#010+
  7060. #013#010+
  7061. 'function TCommand.GetOptions: TStrings;'#013#010+
  7062. 'begin'#013#010+
  7063. ' If (FOptions=Nil) then'#013#010+
  7064. ' FOptions:=TStringList.Create;'#013#010+
  7065. ' Result:=FOptions;'#013#010+
  7066. 'end;'#013#010+
  7067. #013#010+
  7068. 'proc','edure TCommand.SetOptions(const Value: TStrings);'#013#010+
  7069. 'begin'#013#010+
  7070. ' If (Value=Nil) or (Value.Count=0) then'#013#010+
  7071. ' FreeAndNil(FOptions)'#013#010+
  7072. ' else'#013#010+
  7073. ' Options.Assign(Value);'#013#010+
  7074. 'end;'#013#010+
  7075. #013#010+
  7076. 'destructor TCommand.Destroy;'#013#010+
  7077. 'begin'#013#010+
  7078. ' FreeAndNil(FOptions);'#013#010+
  7079. ' inheri','ted Destroy;'#013#010+
  7080. 'end;'#013#010+
  7081. #013#010+
  7082. 'function TCommand.HaveOptions: Boolean;'#013#010+
  7083. 'begin'#013#010+
  7084. ' Result:=(FOptions<>Nil);'#013#010+
  7085. 'end;'#013#010+
  7086. #013#010+
  7087. #013#010+
  7088. 'function TCommand.CmdLineOptions: String;'#013#010+
  7089. 'begin'#013#010+
  7090. ' If HaveOptions then'#013#010+
  7091. ' Result:=OptionListToString(Options);'#013#010+
  7092. 'end;'#013#010+
  7093. #013#010+
  7094. 'procedure',' TCommand.ParseOptions(S: String);'#013#010+
  7095. #013#010+
  7096. 'begin'#013#010+
  7097. ' Options:=OptionsToStringList(S);'#013#010+
  7098. 'end;'#013#010+
  7099. #013#010+
  7100. 'Initialization'#013#010+
  7101. ' OnGetApplicationName:=@GetFPMakeName;'#013#010+
  7102. ' CustomFpmakeCommandlineOptions:=nil;'#013#010+
  7103. ' CustomFpMakeCommandlineValues:=nil;'#013#010+
  7104. #013#010+
  7105. 'Finalization'#013,#010+
  7106. ' FreeAndNil(CustomFpMakeCommandlineValues);'#013#010+
  7107. ' FreeAndNil(CustomFpmakeCommandlineOptions);'#013#010+
  7108. ' FreeAndNil(DefInstaller);'#013#010+
  7109. ' FreeAndNil(Dictionary);'#013#010+
  7110. ' FreeAndNil(Defaults);'#013#010+
  7111. 'end.'#013#010
  7112. );