fpmkunitsrc.inc 205 KB

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