fpmkunitsrc.inc 177 KB

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