1 Star 2 Fork 0

LibQQt应用程序开发组织/Multi-building Technology (PyAutoMake)

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
pyautomake.py 221.06 KB
一键复制 编辑 原始数据 按行查看 历史
tianduanrui 提交于 2021-07-01 10:23 +08:00 . clean command-line version.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790
# -*- coding: utf-8 -*-
# !/usr/bin/env python
"""PyAutoMake 1.0
Usage:
pyautomake.py source
pyautomake.py env [ <name> ] [ -r | --raw ] [ -a | --all ]
pyautomake.py environ [ <name> ] [ -r | --raw ] [ -a | --all ]
pyautomake.py vc env [ <name> ] [ -r | --raw ] [ -a | --all ]
pyautomake.py vc environ [ <name> ] [ -r | --raw ] [ -a | --all ]
pyautomake.py stat
pyautomake.py status
pyautomake.py info
pyautomake.py information
pyautomake.py list [ -r | --raw ]
pyautomake.py show [ -r | --raw ]
pyautomake.py chk [ -r | --raw ]
pyautomake.py check [ -r | --raw ]
pyautomake.py toolchain show [ <env-name> ]
pyautomake.py initialize toolchain [ <env-name> ] [ -a | --all ] [ -f | --force ]
pyautomake.py toolchain [ stat | status ]
pyautomake.py toolchain [ info | information ]
pyautomake.py project
pyautomake.py initialize project [ -f | --force ]
pyautomake.py project [ stat | status ]
pyautomake.py project [ info | information ]
pyautomake.py build <project-name> [ -r | --release ] [ -d | --debug ] [ -p | --profile ]
pyautomake.py use <env-name> build <project-file> [ -r | --release ] [ -d | --debug ] [ -p | --profile ]
pyautomake.py (-h | --help)
pyautomake.py --version
"""
from __future__ import unicode_literals
import os
import re
import sys
import uuid
import shutil
import time
import json
import copy
import types
# ===============================================================================================
# NOTICE:
# __file__ only can be used at startup position! [before os.chdir()]
# behind os.chdir(), __file__ relative to os.getcwd(), it maybe an error value!
# Dont use it later!
#
# THAT:
# __file__ maybe a relative path to os.getcwd(), it is its defination from python.
# It is a const value in its life term.
# Only at startup position, user can get its correct abs path.
# behind os.chdir(), user cannot get its correct abs path.
# Dont use it later!
# --------------------
# ===============================================================================================
# relative to project root. [relative to pymake.py]
# --------------------
pymakerelativepath = '.'
# ===============================================================================================
# load module helper
# --------------------
def load_rpath_for_local(path=''):
# add rpath. [HEADER ROOT] [LIBRARY ROOT] [MODULE ROOT]
# find module when execute.
# 1, realpath, fake_file
# 2, __file__
# 3, sys.argv[0]
basicpath = os.path.split(os.path.realpath(__file__))[0]
paths = []
if (isinstance(path, str)):
paths.append(path)
if (isinstance(path, list)):
paths.extend(path)
syspath1 = []
for key in sys.path:
temppath = key.replace('\\', '/')
syspath1.append(temppath)
for path in paths:
module_path = os.path.join(basicpath, path)
module_path = os.path.realpath(module_path)
temppath = module_path.replace('\\', '/')
if(syspath1.__contains__(temppath)):
continue
sys.path.insert(0, module_path)
return
load_rpath_for_local(pymakerelativepath)
# print(sys.path)
# ===============================================================================================
# import module
# --------------------
# common
from pycore.pycore import *
# ===============================================================================================
# PYMAKE INITIAL CODE
# --------------------
def main_function():
d = {
"tips": {
"variable.tips": [
"QQt",
"LibQQt",
"${root.build}/${qqt.proj.name}/${qt.sys.mac}/${build.release}",
"${root.src}/${qqt.proj.name}",
"${qqt.proj.name}.pro",
"${qqt.build.path}/src/bin",
"${root.prod}/QQt",
"qqtframe",
"${qqt.build.path}/examples/${qqtframe.prod.name}/bin",
"${qqt.build.path}/src/bin/QQt.framework",
"QQt.framework/Versions/1/QQt",
"${root.tool}/Source/qt5",
"${root.build}/qt5",
"androiddeployqt",
"macdeployqt",
"DownloadQueue",
"/Users/abel/Develop/c1-webrc/DownloadQueue/DownloadQueue.pro",
"${root.build}/${app.name}",
"macdeployqt ${app.path.build}/${app.name}.app",
"${prod.name}.app",
"${mac.app}/Contents",
"${mac.app.content}/MacOS",
"${mac.app.content}/Frameworks",
"${mac.app.content}/Resources",
"${mac.app.content}/PlugIns",
"${prod.name}.framework",
"${prod.name}.framework/Versions",
"${prod.name}.framework/Resources",
"macdeployqt ${}"
],
"command.tips": [
"I'm not similar to these command, so list them here, rather than forgotten them",
"cl-command, sys-command",
"replace? no, append? easy!",
"help you to remeber these command.",
"mkdir -p ${qqt.build.path}",
"cd ${build-path}",
"cmake -G\"Unix Makefiles\" -DCMAKE_INSTALL_PREFIX=${prod-root} ${source-path}",
"cmake -GXCode -DCMAKE_INSTALL_PREFIX=${prod-root} ${source-path}",
"rm -f CMakeCache.txt",
"qmake ${source-path}/${qmake-file} -spec $QTSPEC CONFIG+=$QTCONFIG && make qmake_all",
"make -j4",
"make clean in ${build-path}",
"make install",
"${deployqt} ${bin-path}/${app-bundle} -verbose=1",
"${deployqt} -dmg",
"${deployqt} --help",
"cp -fr ${lib-dep} ${lib-native}",
"install_name_tool -change ${lib-dep-name} @rpath/${lib-dep-name} ${app-native}/${prod-name} ",
"install_name_tool -change $LibDep @rpath/$LibDep ${app-native}/${prod-name} ",
"${source-path}/configure -prefix ${install-path} -hostprefix ${install-path} -xplatform android-g++ -release -nomake tests -nomake examples -android-ndk $ANDROID_NDK_ROOT -android-sdk $ANDROID_SDK_ROOT -android-ndk-host $ANDROID_NDK_HOST -android-toolchain-version $ANDROID_NDK_TOOLCHAIN_VERSION -skip qtwebkit-examples -no-warnings-are-errors",
"${qt5.path.source}/configure -prefix ${qt5.path.install} -hostprefix ${qt5.path.install} -xplatform android-g++ -release -nomake tests -nomake examples -android-ndk $ANDROID_NDK_ROOT -android-sdk $ANDROID_SDK_ROOT -android-ndk-host $ANDROID_NDK_HOST -android-toolchain-version $ANDROID_NDK_TOOLCHAIN_VERSION -skip qtwebkit-examples -no-warnings-are-errors"
],
},
"path-assemblage": {
"root": "/Users/abel/Develop",
"root.src": "${root}/a0-develop",
"root.prod": "${root}/d0-product",
"root.sdk": "${root}/d1-sdks",
"root.tool": "${root}/b0-toolskits",
"root.build": "${root}/c0-buildstation",
"root.test": "${root}/f0-test",
"root.webrc": "${root}/e0-webrc",
"cc": "${root.tool}/a0-compiler",
"pymake": "${cc}/PyMake",
"wincc": "${root.tool}/macCompilers",
"cmake.bin": "${wincc}/CMake.app/Contents/bin",
"qt": "${root.tool}/macLibraries/Qt",
"qt4.version": "4.8.6",
"qt4.clang": "${qt}/${qt4.version}/clang_64",
"qt4.clang.bin": "${qt4.clang}/bin",
"qt5.version": "5.9.2",
"qt5.ios": "${qt}/${qt5.version}/ios",
"qt5.ios.bin": "${qt}/${qt5.version}/ios/bin",
"qt5.clang": "${qt}/${qt5.version}/clang_64",
"qt5.clang.bin": "${qt}/${qt5.version}/clang_64/bin",
"qt5.android_arm": "${qt}/${qt5.version}/android_armv7",
"qt5.android_arm.bin": "${qt}/${qt5.version}/android_armv7/bin",
"qt5.android_x86": "${qt}/${qt5.version}/android_x86",
"qt5.android_x86.bin": "${qt}/${qt5.version}/android_x86/bin",
"android": "${root.tool}/macAndroidLibraries",
"android.sdk": "${android}/android-sdk-macosx",
"android.ndk": "${android}/android-ndk-r13b",
"android.ant": "${android}/apache-ant-1.10.1",
"android.java": "${android}/java-macosx/Java/JavaVirtualMachines",
"sdk.plat.tool": "${android.sdk}/platform-tools",
"sdk.build.tool": "${android.sdk}/build-tools",
"sdk.tool": "${android.sdk}/tools",
"java1.7.home": "${android.java}/jdk1.7.0_79.jdk/Contents/Home",
"java1.8.home": "${android.java}/jdk1.8.0_111.jdk/Contents/Home",
"java1.9.home": "${android.java}/jdk9.jdk/Contents/Home",
"java1.7.bin": "${java1.7.home}/bin",
"java1.8.bin": "${java1.8.home}/bin",
"java1.9.bin": "${java1.9.home}/bin",
"ant.bin": "${android.ant}/bin",
"ndk.arm": "${android.ndk}/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64",
"ndk.x86": "${android.ndk}/toolchains/x86-4.9/prebuilt/darwin-x86_64",
"ndk.x86_64": "${android.ndk}/toolchains/x86_64-4.9/prebuilt/darwin-x86_64",
"ndk.arm.bin": "${ndk.arm}/bin",
"ndk.x86.bin": "${ndk.x86}/bin",
"ndk.x86_64.bin": "${ndk.x86_64}/bin",
"ios.simulator.sysroot": "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk",
"xcode.bin": "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin",
"mac.sysroot": "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk"
},
"environ": {
"android.mobile": {
"path+": [
"${qt5.android_arm.bin}",
"${java1.8.bin}",
"${android.sdk}",
"${sdk.plat.tool}",
"${sdk.build.tool}",
"${sdk.tool}",
"${ant.bin}",
"${ndk.arm.bin}"
],
"makex": "make",
"CMAKEGENERATOR": "Unix Makefiles",
"ANDROID_API_VERSION": "android-23",
"ANDROID_SDK_ROOT": "${android.sdk}",
"ANDROID_NDK_ROOT": "${android.ndk}",
"ANDROID_NDK_HOST": "darwin-x86_64",
"ANDROID_NDK_TOOLCHAIN_PREFIX": "arm-linux-androideabi",
"ANDROID_NDK_TOOLCHAIN_VERSION": "4.9",
"ANDROID_NDK_PLATFORM": "android-23",
"NDK_TOOLCHAIN_PATH": "${ndk.arm.bin}",
"NDK_TOOLS_PREFIX": "arm-linux-androideabi",
"QTVERSION": "${qt5.version}",
"QTDIR": "${qt5.android_arm}",
"QTSPEC": "-spec android-g++",
"QTCONFIG": "",
"JAVA_HOME": "${java1.8.home}",
"CLASSPATH": ".:${JAVA_HOME}/lib/dt.jar:${JAVA_HOME}/lib/tools.jar",
"PYMAKE_MYNAME": "T.D.R",
"a_special_var_const": "hello world",
"QKIT": "ANDROID",
"QSYS": "Android"
},
"android.x86": {
"path+": [
"${qt5.android_x86.bin}",
"${java1.8.bin}",
"${android.sdk}",
"${sdk.plat.tool}",
"${sdk.build.tool}",
"${sdk.tool}",
"${ant.bin}",
"${ndk.x86.bin}"
],
"makex": "make",
"CMAKEGENERATOR": "Unix Makefiles",
"CLICOLOR": "1",
"ANDROID_API_VERSION": "android-23",
"ANDROID_HOME": "${android.sdk}",
"ANDROID_SDK_ROOT": "${android.sdk}",
"ANDROID_NDK_PLATFORM": "android-23",
"ANDROID_NDK_ROOT": "${android.ndk}",
"ANDROID_NDK_HOST": "darwin-x86_64",
"ANDROID_NDK_TOOLCHAIN_PREFIX": "x86",
"ANDROID_NDK_TOOLCHAIN_VERSION": "4.9",
"ANDROID_NDK_TOOLS_PREFIX": "i686-linux-android",
"NDK_TOOLCHAIN_PATH": "${ndk.x86.bin}",
"NDK_TOOLS_PREFIX": "i686-linux-android",
"PYMAKE_MYNAME": "T.D.R",
"a_special_var_const": "hello world",
"QTDIR": "${qt5.android_x86}",
"QTSPEC": "-spec android-g++",
"QTCONFIG": "",
"JAVA_HOME": "${java1.8.home}",
"CLASSPATH": ".:${JAVA_HOME}/lib/dt.jar:${JAVA_HOME}/lib/tools.jar",
"QTVERSION": "${qt5.version}",
"QKIT": "ANDROIDX86",
"QSYS": "AndroidX86"
},
"qt4": {
"path+": [
"${qt4.clang.bin}"
],
"makex": "make",
"CMAKEGENERATOR": "Unix Makefiles",
"QTVERSION": "${qt4.version}",
"QTDIR": "${qt4.clang}",
"QTSPEC": "-spec macx-llvm",
"QTCONFIG": "CONFIG+=x86_64",
"QKIT": "macOS",
"QSYS": "macOS"
},
"ios": {
"path+": [
"${qt5.ios.bin}"
],
"makex": "make",
"CMAKEGENERATOR": "Unix Makefiles",
"QTVERSION": "${qt5.version}",
"QTDIR": "${qt5.ios}",
"QTSPEC": "-spec macx-ios-clang",
"QTCONFIG": "CONFIG+=iphoneos CONFIG+=device -after QMAKE_MAC_XCODE_SETTINGS+=qteam qteam.name=DEVELOPMENT_TEAM qteam.value=4EGMLT3G6T",
"QKIT": "iOS",
"QSYS": "iOS"
},
"iossimulator": {
"path+": [
"${qt5.ios.bin}"
],
"makex": "make",
"CMAKEGENERATOR": "Unix Makefiles",
"QTVERSION": "${qt5.version}",
"QTDIR": "${qt5.ios}",
"QTSPEC": "-spec macx-ios-clang",
"QTCONFIG": "CONFIG+=iphonesimulator CONFIG+=simulator",
"QKIT": "iOSSimulator",
"QSYS": "iOSSimulator"
},
"macos": {
"path+": [
"${qt5.clang.bin}"
],
"makex": "make",
"CMAKEGENERATOR": "Unix Makefiles",
"QTVERSION": "${qt5.version}",
"QTDIR": "${qt5.clang}",
"QTSPEC": "-spec macx-clang",
"QTCONFIG": "CONFIG+=x86_64",
"QKIT": "macOS",
"QSYS": "macOS"
},
"current": "macos"
},
"command": {
"test": [
"echo $(pwd)"
],
"test.2": [
"#echo $*",
"param=$*",
"ping 127.0.0.1 $param"
],
"test.3": [
"#echo $*",
"ping $*"
],
"test.4": [
"echo param1: $1",
"echo param2: $2",
"echo param3: $3",
"echo param4: $4"
],
"test.5": [
"exit 0"
],
"test.6": [
"echo 中文"
],
"test.7": [
"echo $PATH"
],
"open.env": [
"open $(pymake source)",
"open $(pymake source root)/custom.path+.ini",
"open $(pymake source root)/custom.var+.ini"
],
"qt": [
"open \"/Applications/Qt Creator.app\""
],
"cmake-app": [
"open ${wincc}/CMake.app"
],
"prod": [
"open /Users/abel/Develop/d0-product/ProductExecTool/macOS/ProductExecTool_debug.app"
],
"libtool": [
"open /Users/abel/Develop/d0-product/AddLibraryTool/macOS/AddLibraryTool_debug.app"
],
"android.sdk": [
"/Users/abel/Develop/b0-toolskits/macAndroidLibraries/android-sdk-macosx/tools/android"
],
"open-dir": [
"open $1"
],
"qtdir": [
"echo $QTDIR"
],
"build.info": [
"while [ 1 ]",
"do",
"src_path=$(pwd)",
"profilename=$1",
"if [ \"$profilename\" == \"\" ]; then",
" echo please input a project name",
" break",
"fi",
"if [ -f \"$1.pro\" ]; then",
" echo $1.pro existed.",
"else",
" echo has $1.pro? please add here command to restrict.",
" break",
"fi",
"src=$src_path/$profilename.pro",
"build=${root.build}/$profilename/$QSYS/$QTVERSION/Debug",
"prod=${root.prod}/$profilename/$QSYS",
"sdk=${root.sdk}/$profilename/$QSYS",
"echo src file: $src",
"echo src path: $src_path",
"echo sdk at: $sdk",
"echo prod at: $prod",
"echo build at: $build",
"echo build inf $QTSPEC $QTCONFIG",
"endtime=`date +'%Y-%m-%d %H:%M:%S'`",
"echo 现在时间:$endtime",
"break",
"done"
],
"build.qmake": [
"while [ 1 ]",
"do",
"src_path=$(pwd)",
"profilename=$1",
"if [ \"$profilename\" == \"\" ]; then",
" echo please input a project name",
" break",
"fi",
"if [ -f \"$1.pro\" ]; then",
" echo $1.pro existed.",
"else",
" echo has $1.pro? please add here command to restrict.",
" break",
"fi",
"src=$src_path/$profilename.pro",
"build=${root.build}/$profilename/$QSYS/$QTVERSION/Debug",
"prod=${root.prod}/$profilename/$QSYS",
"sdk=${root.sdk}/$profilename/$QSYS",
"mkdir -p $build",
"cd $build",
"echo src file: $src",
"echo src path: $src_path",
"echo sdk at: $sdk",
"echo prod at: $prod",
"echo build at: $build",
"echo $QTSPEC $QTCONFIG",
"#starttime=`date +'%Y-%m-%d %H:%M:%S'`",
"qmake $src $QTSPEC CONFIG+=debug CONFIG+=qml_debug $QTCONFIG && make qmake_all",
"make -j4",
"echo build inf $QTSPEC $QTCONFIG",
"echo src file: $src",
"echo src path: $src_path",
"echo build at: $build",
"echo sdk at: $sdk",
"echo prod at: $prod",
"#endtime=`date +'%Y-%m-%d %H:%M:%S'`",
"#start_seconds=$(date --date=\"$starttime\" +%s);",
"#end_seconds=$(date --date=\"$endtime\" +%s);",
"#echo \"本次运行时间: \"$((end_seconds-start_seconds))\"s\"",
"break",
"done"
],
"build.qmake.all": [
"while [ 1 ]",
"do",
"src_path=$(pwd)",
"profilename=$1",
"if [ \"$profilename\" == \"\" ]; then",
" echo please input a project name",
" break",
"fi",
"if [ -f \"$1.pro\" ]; then",
" echo $1.pro existed.",
"else",
" echo has $1.pro? please add here command to restrict.",
" break",
"fi",
"echo You must use pymake system ccvp here command to execute this command!",
"envlist=(\"macos\" \"iossimulator\" \"android.mobile\" \"android.x86\")",
"length=${#envlist[@]}",
"cmd0=${envlist[0]}",
"#for envname in $envlist 这个是个bug",
"for envname in ${envlist[@]}",
"do",
" #echo $envname",
" #echo pymake use $envname ccvp here build.qmake $profilename",
" #export aiya=$envname",
" #echo $aiya",
" #osascript -e \"",
" # set a to \\\"$aiya\\\"",
" # tell application \\\"Terminal\\\" to do script \\\"echo - $a - \\\" & a & - \\\"$aiya\\\"",
" #\"",
" #osascript",
" #set a to POSIX file \"$envname\"",
" #env",
" #osascript -e 'tell application \"Terminal\" to do script \"echo $aiya\"'",
" osascript -e \"",
" tell application \\\"Terminal\\\" to do script \\\"cd $src_path && echo $profilename - $envname && pymake use $envname ccvp here build.qmake $profilename\\\"",
" \"",
"done",
"break",
"done"
],
"build.cmake.gui": [
"while [ 1 ]",
"do",
"src_path=$(pwd)",
"profilename=$1",
"if [ \"$profilename\" == \"\" ]; then",
" echo please input a project name",
" break",
"fi",
"if [ -f \"CMakeLists.txt\" ]; then",
" echo CMakeLists.txt existed.",
"else",
" echo has CMakeLists.txt? please add here command to restrict.",
" break",
"fi",
"src=$src_path/CMakeLists.txt",
"build=${root.build}/$profilename/$QSYS/$QTVERSION/Debug",
"prod=${root.prod}/$profilename/$QSYS",
"sdk=${root.sdk}/$profilename/$QSYS",
"mkdir -p $build",
"cd $build",
"echo src file: $src",
"echo src path: $src_path",
"echo sdk at: $sdk",
"echo prod at: $prod",
"echo build at: $build",
"echo $QTSPEC $QTCONFIG",
"open ${wincc}/CMake.app",
"errorlevel=$?",
"if [ $errorlevel -ne 0 ]; then",
" echo cmake exit code: $errorlevel",
" break",
"fi",
"echo build inf $QTSPEC $QTCONFIG",
"echo src file: $src",
"echo src path: $src_path",
"echo build at: $build",
"echo sdk at: $sdk",
"echo prod at: $prod",
"break",
"done"
],
"build.cmake.sdk": [
"while [ 1 ]",
"do",
"src_path=$(pwd)",
"profilename=$1",
"if [ \"$profilename\" == \"\" ]; then",
" echo please input a project name",
" break",
"fi",
"if [ -f \"CMakeLists.txt\" ]; then",
" echo CMakeLists.txt existed.",
"else",
" echo has CMakeLists.txt? please add here command to restrict.",
" break",
"fi",
"src=$src_path/CMakeLists.txt",
"build=${root.build}/$profilename/$QSYS/$QTVERSION/Debug",
"prod=${root.prod}/$profilename/$QSYS",
"sdk=${root.sdk}/$profilename/$QSYS",
"mkdir -p $build",
"cd $build",
"echo src file: $src",
"echo src path: $src_path",
"echo sdk at: $sdk",
"echo prod at: $prod",
"echo build at: $build",
"echo $QTSPEC $QTCONFIG",
"cmake $src_path -G\"$CMAKEGENERATOR\" -DCMAKE_INSTALL_PREFIX=${root.sdk}/$profilename/$QSYS -DCMAKE_BUILD_TYPE=Debug",
"errorlevel=$?",
"if [ $errorlevel -ne 0 ]; then",
" echo cmake exit code: $errorlevel",
" break",
"fi",
"echo build inf $QTSPEC $QTCONFIG",
"echo src file: $src",
"echo src path: $src_path",
"echo build at: $build",
"echo sdk at: $sdk",
"echo prod at: $prod",
"break",
"done"
],
"build.cmake.app": [
"while [ 1 ]",
"do",
"src_path=$(pwd)",
"profilename=$1",
"if [ \"$profilename\" == \"\" ]; then",
" echo please input a project name",
" break",
"fi",
"if [ -f \"CMakeLists.txt\" ]; then",
" echo CMakeLists.txt existed.",
"else",
" echo has CMakeLists.txt? please add here command to restrict.",
" break",
"fi",
"src=$src_path/CMakeLists.txt",
"build=${root.build}/$profilename/$QSYS/$QTVERSION/Debug",
"prod=${root.prod}/$profilename/$QSYS",
"sdk=${root.sdk}/$profilename/$QSYS",
"mkdir -p $build",
"cd $build",
"echo src file: $src",
"echo src path: $src_path",
"echo sdk at: $sdk",
"echo prod at: $prod",
"echo build at: $build",
"echo $QTSPEC $QTCONFIG",
"cmake $src_path -G\"$CMAKEGENERATOR\" -DCMAKE_INSTALL_PREFIX=${root.prod}/$profilename/$QSYS -DCMAKE_BUILD_TYPE=Debug",
"errorlevel=$?",
"if [ $errorlevel -ne 0 ]; then",
" echo cmake exit code: $errorlevel",
" break",
"fi",
"echo build inf $QTSPEC $QTCONFIG",
"echo src file: $src",
"echo src path: $src_path",
"echo build at: $build",
"echo sdk at: $sdk",
"echo prod at: $prod",
"break",
"done"
],
"build.make": [
"while [ 1 ]",
"do",
"src_path=$(pwd)",
"profilename=$1",
"if [ \"$profilename\" == \"\" ]; then",
" echo please input a project name",
" break",
"fi",
"src=$src_path/$profilename.pro",
"build=${root.build}/$profilename/$QSYS/$QTVERSION/Debug",
"prod=${root.prod}/$profilename/$QSYS",
"sdk=${root.sdk}/$profilename/$QSYS",
"#mkdir -p $build",
"cd $build",
"echo src file: $src",
"echo src path: $src_path",
"echo sdk at: $sdk",
"echo prod at: $prod",
"echo build at: $build",
"echo $QTSPEC $QTCONFIG",
"#qmake $src $QTSPEC CONFIG+=debug CONFIG+=qml_debug $QTCONFIG && $makex qmake_all",
"$makex",
"echo build inf $QTSPEC $QTCONFIG",
"echo src file: $src",
"echo src path: $src_path",
"echo build at: $build",
"echo sdk at: $sdk",
"echo prod at: $prod",
"break",
"done"
],
"build.make.install": [
"while [ 1 ]",
"do",
"src_path=$(pwd)",
"profilename=$1",
"if [ \"$profilename\" == \"\" ]; then",
" echo please input a project name",
" break",
"fi",
"src=$src_path/$profilename.pro",
"build=${root.build}/$profilename/$QSYS/$QTVERSION/Debug",
"prod=${root.prod}/$profilename/$QSYS",
"sdk=${root.sdk}/$profilename/$QSYS",
"#mkdir -p $build",
"cd $build",
"echo src file: $src",
"echo src path: $src_path",
"echo sdk at: $sdk",
"echo prod at: $prod",
"echo build at: $build",
"echo $QTSPEC $QTCONFIG",
"#qmake $src $QTSPEC CONFIG+=debug CONFIG+=qml_debug $QTCONFIG && $makex qmake_all",
"$makex install",
"echo build inf $QTSPEC $QTCONFIG",
"echo src file: $src",
"echo src path: $src_path",
"echo build at: $build",
"echo sdk at: $sdk",
"echo prod at: $prod",
"break",
"done"
],
"build.make.clean": [
"while [ 1 ]",
"do",
"src_path=$(pwd)",
"profilename=$1",
"if [ \"$profilename\" == \"\" ]; then",
" echo please input a project name",
" break",
"fi",
"src=$src_path/$profilename.pro",
"build=${root.build}/$profilename/$QSYS/$QTVERSION/Debug",
"prod=${root.prod}/$profilename/$QSYS",
"sdk=${root.sdk}/$profilename/$QSYS",
"#mkdir -p $build",
"cd $build",
"echo src file: $src",
"echo src path: $src_path",
"echo sdk at: $sdk",
"echo prod at: $prod",
"echo build at: $build",
"echo $QTSPEC $QTCONFIG",
"#qmake $src $QTSPEC CONFIG+=debug CONFIG+=qml_debug $QTCONFIG && $makex qmake_all",
"$makex clean",
"echo build inf $QTSPEC $QTCONFIG",
"echo src file: $src",
"echo src path: $src_path",
"echo build at: $build",
"echo sdk at: $sdk",
"echo prod at: $prod",
"break",
"done"
],
"build.go": [
"while [ 1 ]",
"do",
"src_path=$(pwd)",
"profilename=$1",
"if [ \"$profilename\" == \"\" ]; then",
" echo please input a project name",
" break",
"fi",
"if [ -f \"$1.go\" ]; then",
" echo $1.go existed.",
"else",
" echo has $1.go? please add here command to restrict.",
" break",
"fi",
"src=$src_path/$profilename.go",
"build=${root.build}/$profilename/$QSYS/$QTVERSION/Debug",
"prod=${root.prod}/$profilename/$QSYS",
"sdk=${root.sdk}/$profilename/$QSYS",
"mkdir -p $build",
"cd $build",
"echo src file: $src",
"echo src path: $src_path",
"echo sdk at: $sdk",
"echo prod at: $prod",
"echo build at: $build",
"echo $QTSPEC $QTCONFIG",
"#qmake $src $QTSPEC CONFIG+=debug CONFIG+=qml_debug $QTCONFIG && make qmake_all",
"#make -j4",
"go build $src",
"echo build inf $QTSPEC $QTCONFIG",
"echo src file: $src",
"echo src path: $src_path",
"echo build at: $build",
"echo sdk at: $sdk",
"echo prod at: $prod",
"break",
"done"
],
"build.configure": [
"while [ 1 ]",
"do",
"src_path=$(pwd)",
"profilename=$1",
"if [ \"$profilename\" == \"\" ]; then",
" echo please input a project name",
" break",
"fi",
"if [ -f \"configure\" ]; then",
" echo configure existed.",
"else",
" echo has configure? please add here command to restrict.",
" break",
"fi",
"src=$src_path/configure",
"build=${root.build}/$profilename/$QSYS/$QTVERSION/Debug",
"prod=${root.prod}/$profilename/$QSYS",
"sdk=${root.sdk}/$profilename/$QSYS",
"mkdir -p $build",
"cd $build",
"echo src file: $src",
"echo src path: $src_path",
"echo sdk at: $sdk",
"echo prod at: $prod",
"echo build at: $build",
"echo $QTSPEC $QTCONFIG",
"#qmake $src $QTSPEC CONFIG+=debug CONFIG+=qml_debug $QTCONFIG && make qmake_all",
"#make -j4",
"configure \"$@\"",
"echo build inf $QTSPEC $QTCONFIG",
"echo src file: $src",
"echo src path: $src_path",
"echo build at: $build",
"echo sdk at: $sdk",
"echo prod at: $prod",
"break",
"done"
],
"build.autogen": [
"while [ 1 ]",
"do",
"src_path=$(pwd)",
"profilename=$1",
"if [ \"$profilename\" == \"\" ]; then",
" echo please input a project name",
" break",
"fi",
"if [ -f \"autogen.sh\" ]; then",
" echo autogen.sh existed.",
"else",
" echo has autogen.sh? please add here command to restrict.",
" break",
"fi",
"src=$src_path/autogen.sh",
"build=${root.build}/$profilename/$QSYS/$QTVERSION/Debug",
"prod=${root.prod}/$profilename/$QSYS",
"sdk=${root.sdk}/$profilename/$QSYS",
"mkdir -p $build",
"cd $build",
"echo src file: $src",
"echo src path: $src_path",
"echo sdk at: $sdk",
"echo prod at: $prod",
"echo build at: $build",
"echo $QTSPEC $QTCONFIG",
"#qmake $src $QTSPEC CONFIG+=debug CONFIG+=qml_debug $QTCONFIG && make qmake_all",
"#make -j4",
"autogen.sh \"$@\"",
"echo build inf $QTSPEC $QTCONFIG",
"echo src file: $src",
"echo src path: $src_path",
"echo build at: $build",
"echo sdk at: $sdk",
"echo prod at: $prod",
"break",
"done"
],
"Qt.move": [
"while [ 1 ]",
"do",
"srcdir=$1",
"srcver=$2",
"if [ \"$1\" = \"\" ]; then",
" echo please input old qtdir.",
" break",
"fi",
"if [ \"$2\" = \"\" ]; then",
" echo please input old qtversion.",
" break",
"fi",
"mv -f $srcdir/$srcver/* Qt2/$srcver/",
"mv -f $srcdir/Docs/* Qt2/Docs/",
"mv -f $srcdir/Examples/* Qt2/Examples/",
"mv -f $srcdir/*.zip Qt2/",
"break",
"done"
],
"qt4.build": [
"src=${root.tool}/z0-Source/qt",
"build=${root.build}/qt",
"install=${root.tool}/macLibraries/Qt/4.8/gcc_64",
"mkdir -p $build",
"cd $build",
"echo build $(pwd)",
"CXXFLAGS=-stdlib=libc++",
"${src}/configure -prefix ${install}",
"make -j4",
"make install"
],
"qtsoap.build": [
"src=/Users/abel/Develop/c1-webrc/qt-solutions/qtsoap",
"build=${root.build}/qtsoap",
"install=/Users/abel/Develop/d1-product/QtSoap",
"cd $build",
"${src}/configure -library"
],
"qqt.build.all": [
"osascript -e 'tell application \"Terminal\" to do script \"echo hello\"'"
],
"qqt.daily": [
"src_path=/Users/abel/Develop/a0-develop/LibQQt",
"src=$src_path/QQt.pro",
"build=/Users/abel/Develop/c0-buildstation/QQt/$QSYS/$QTVERSION/Debug",
"mkdir -p $build",
"cd $build",
"rm -rf src examples",
"qmake $src $QTSPEC $QTCONFIG CONFIG+=debug CONFIG+=qml_debug && make qmake_all",
"make -j4"
],
"qqt.daily.release": [
"src_path=/Users/abel/Develop/a0-develop/LibQQt",
"src=$src_path/QQt.pro",
"build=/Users/abel/Develop/c0-buildstation/QQt/$QSYS/$QTVERSION/Release",
"mkdir -p $build",
"cd $build",
"rm -rf src examples",
"qmake $src $QTSPEC $QTCONFIG CONFIG+=release && make qmake_all",
"make -j4"
],
"qqt.build.release": [
"src_path=/Users/abel/Develop/a0-develop/LibQQt",
"src=$src_path/QQt.pro",
"build=/Users/abel/Develop/c0-buildstation/QQt/$QSYS/$QTVERSION/Release",
"mkdir -p $build",
"cd $build",
"qmake $src $QTSPEC $QTCONFIG CONFIG+=release && make qmake_all",
"make -j4"
],
"qqt.build": [
"src_path=${root.src}/LibQQt",
"src=${root.src}/LibQQt/QQt.pro",
"build=${root.build}/QQt/$QSYS/$QTVERSION/Debug",
"mkdir -p $build",
"cd $build",
"echo build $(pwd)",
"qmake ${src} $QTSPEC CONFIG+=debug CONFIG+=qml_debug $QTCONFIG && make qmake_all",
"make -j4"
],
"qqt.clean": [
"src=${root.src}/LibQQt/QQt.pro",
"build=${root.build}/QQt/$QSYS/$QTVERSION/Debug",
"cd $build",
"make clean"
],
"qqt.clean.release": [
"src=/Users/abel/Develop/a0-develop/LibQQt/QQt.pro",
"build=/Users/abel/Develop/c0-buildstation/QQt/$QSYS/$QTVERSION/Release",
"cd $build",
"make clean"
],
"qt.check": [
"src=${root.tool}/z0-Source/qt-everywhere-opensource-src-4.8.7",
"build=${root.build}/qt4.7",
"install=${root.tool}/macLibraries/Qt/4.8.7/gcc_64",
"mkdir -p $build",
"cd $build",
"echo build $(pwd)",
"${src}/configure --help"
],
"qt.build": [
"src=/Users/abel/Develop/b0-toolskits/z0-Source/qt",
"build=/Users/abel/Develop/c0-buildstation/qt",
"install=/Users/abel/Develop/b0-toolskits/macLibraries/Qt/4.8/gcc_64",
"mkdir -p $build",
"cd $build",
"echo build $(pwd)",
"CXXFLAGS=-stdlib=libc++",
"${src}/configure -prefix ${install}",
"make -j4",
"make install"
],
"qt4.7.build": [
"src=${root.tool}/z0-Source/qt-everywhere-opensource-src-4.8.7",
"build=${root.build}/qt4.7",
"install=${root.tool}/macLibraries/Qt/4.8.7/gcc_64",
"mkdir -p $build",
"cd $build",
"echo build $(pwd)",
"${src}/configure -prefix ${install}",
"make -j4",
"make install"
],
"soap.build": [
"src=/Users/abel/Develop/c1-webrc/qt-solutions/qtsoap",
"build=/Users/abel/Develop/c0-buildstation/qtsoap",
"install=/Users/abel/Develop/d1-product/QtSoap",
"cd $build",
"${src}/configure -library"
],
"qqt.push": [
"src=${root.src}/LibQQt",
"cd $src",
"git push",
"git push --tag"
],
"qqt.pull": [
"src=${root.src}/LibQQt",
"cd $src",
"git pull"
],
"qqt.cloc": [
"src=${root.src}/LibQQt",
"cd $src",
"perl ${pymake}/demo/cloc-1.74.pl .",
"date"
],
"light.cloc": [
"src=${root.src}/LightUnderWater/App",
"cd $src",
"perl ${pymake}/demo/cloc-1.74.pl .",
"date"
]
}
}
# record current directory [pwd, execute path]
startupworkdirectory = os.getcwd()
# print( "pymake start up work directory:", startupworkdirectory )
# here work root
# use __file__ , but ... [relative path]
# record pymake file directory, program file path.
pymakefile = os.path.realpath(__file__)
pymakefileroot = os.path.dirname(os.path.realpath(__file__))
pymakefilename = os.path.basename(os.path.realpath(__file__))
# print( "pymake file :", pymakefile )
# print( "pymake file root:", pymakefileroot )
# print( "pymake file name:", pymakefilename )
# record pymake project root, project files root.
# important relative path. [relative to pymake.py] [relative to project root] [relative to caller file]
pymakeprojectroot = os.path.join(pymakefileroot, pymakerelativepath)
pymakeprojectroot = os.path.realpath(pymakeprojectroot)
# print( "pymake project root:", pymakeprojectroot )
# record pymake user source root [env, *.json] [ + auto create ]
pymakedefaultsourceroot = pymakeprojectroot + os.path.sep + 'UserSource'
if (not os.path.exists(pymakedefaultsourceroot)):
os.makedirs(pymakedefaultsourceroot)
# print( "pymake default source root:", pymakedefaultsourceroot )
# record default user source config file name
pymakedefaultsourcefile = 'pymake.json'
# print( "pymake default source file:", pymakedefaultsourcefile )
# print( "pymake default source config:", os.path.join(pymakedefaultsourceroot, pymakedefaultsourcefile) )
# print( "pymake default source root :", pymakedefaultsourceroot )
# print( "pymake default source file :", pymakedefaultsourcefile )
# record pymake user shell root [ dynamic work path ]
# default work directory
pymakedefaultshellroot = pymakedefaultsourceroot + os.path.sep + 'UserShell'
if (not os.path.exists(pymakedefaultshellroot)):
os.makedirs(pymakedefaultshellroot)
# print( "pymake default shell path:", pymakedefaultshellroot )
# ===============================================================================================
# PYMAKE PROGRAM CONFIGURE INITIAL CODE
# --------------------
"""
[pymake]
[source]
root = $pymakedefaultsourceroot
config = $pymakedefaultsourcefile
"""
userroot = getuserroot()
configroot = getconfigroot()
plat = getplatform()
# record pymake configure directory. [ in user config path ]
pymakeconfigureroot = userroot + os.path.sep + '.pymake'
if (not os.path.exists(pymakeconfigureroot)):
os.makedirs(pymakeconfigureroot)
# initial pymake.ini
pymakeconfigureini = pymakeconfigureroot + os.path.sep + 'pymake.ini'
# add green ability
# pymakegreenconfigureroot = pymakeprojectroot
# pymakegreenconfigureini = os.path.join(pymakegreenconfigureroot, 'pymake.ini')
# if (os.path.exists(pymakegreenconfigureini)):
# pymakeconfigureroot = pymakegreenconfigureroot
# pymakeconfigureini = pymakegreenconfigureini
# print(pymakeconfigureroot)
# print(pymakeconfigureini)
# return
conf = MyConfigParser()
conf.read(pymakeconfigureini)
if (not conf.has_section('pymake')):
conf.add_section('pymake')
conf.write(open(pymakeconfigureini, 'w'))
if (not conf.has_section('source')):
conf.add_section('source')
conf.write(open(pymakeconfigureini, 'w'))
if (not conf.has_option('source', 'root')):
conf.set('source', 'root', pymakedefaultsourceroot)
conf.write(open(pymakeconfigureini, 'w'))
if (not conf.has_option('source', 'config')):
conf.set('source', 'config', pymakedefaultsourcefile)
conf.write(open(pymakeconfigureini, 'w'))
# ===============================================================================================
# PYMAKE ARGS COMMAND INITIAL CODE
# --------------------
args = {}
args = docopt(__doc__, version='pyautomake.py v1.0')
# print(args)
# ===============================================================================================
# PYMAKE INITIALIZE COMMAND INITIAL CODE
# --------------------
# initialize
# ===============================================================================================
# PYMAKE SOURCE ROOT INITIAL CODE
# --------------------
# init pymake.json in sourceroot [ + program create ]
# record user source root directory
sourceroot = conf.get('source', 'root')
# record source config file name
sourcefile = conf.get('source', 'config')
# record source config file
sourceconfigfile = sourceroot + os.path.sep + sourcefile
# print("root: %s, config: %s" % (sourceroot, sourcefile))
# print("use source config: %s" % (sourceconfigfile) )
# record default source config file
defaultsourceconfigfile = sourceroot + os.path.sep + pymakedefaultsourcefile
# print ("root: %s, default config: %s" % (sourceroot, pymakedefaultsourcefile))
# print("default source config: %s" % (defaultsourceconfigfile) )
# print("user default source config: %s" % (defaultsourceconfigfile) )
# print("user default source root : %s" % (sourceroot))
# print("user default source file : %s" % (pymakedefaultsourcefile) )
# check source root
# prepare to user source root
if (not os.path.exists(sourceroot)):
os.makedirs(sourceroot)
os.chdir(sourceroot)
# check default source file [default:d]
if (os.path.exists(sourceroot)):
if (os.path.abspath(sourceroot) != os.path.abspath(pymakeconfigureroot)
and os.path.abspath(sourceroot) != os.path.abspath(pymakeprojectroot)
and os.path.abspath(sourceroot) != os.path.abspath(pymakefileroot)):
if (not os.path.exists(defaultsourceconfigfile)):
writeJsonData(defaultsourceconfigfile, d)
# check source file [default:d]
if (os.path.exists(sourceroot)):
if (os.path.abspath(sourceroot) != os.path.abspath(pymakeconfigureroot)
and os.path.abspath(sourceroot) != os.path.abspath(pymakeprojectroot)
and os.path.abspath(sourceroot) != os.path.abspath(pymakefileroot)):
if (not os.path.exists(sourceconfigfile)):
writeJsonData(sourceconfigfile, d)
def open_file(file0):
plat = getplatform()
cmd0 = ''
if (plat == "Windows"):
if (file0.__contains__(' ')):
cmd0 = 'start "" ' + '"%s"' % file0
else:
cmd0 = "start " + file0
elif (plat == "Darwin"):
if (file0.__contains__(' ')):
cmd0 = 'open ' + '"%s"' % file0
else:
cmd0 = "open " + file0
else:
if (file0.__contains__(' ')):
cmd0 = 'xdg-open ' + '"%s" ' % file0 + ">/dev/null 2>&1"
else:
cmd0 = "xdg-open " + '%s ' % file0 + ">/dev/null 2>&1"
return cmd0
# record source config file postfix
pymakesourcesuffix = '.json'
# ===============================================================================================
# PYMAKE SOURCE COMMAND INITIAL CODE
# --------------------
# source
# ===============================================================================================
# PYMAKE SOURCE ROOT INITIAL 2 CODE
# --------------------
# check source root directory
if (os.path.exists(sourceroot) is False):
print("You have changed sourceroot manually, please change it using source command")
return
# check source root .json file
if (os.path.abspath(sourceroot) == os.path.abspath(pymakeconfigureroot)
or os.path.abspath(sourceroot) == os.path.abspath(pymakeprojectroot)
or os.path.abspath(sourceroot) == os.path.abspath(pymakefileroot)):
print("I checked you use pymakeconfigureroot or pymakeprojectroot to be sourceroot, I suggest you use source command changing one.")
print("This progrom can store building env and building command forever, please repleace source root then using it.")
return
elif (os.path.abspath(sourceroot) != os.path.abspath(pymakeconfigureroot)):
if (not os.path.exists(defaultsourceconfigfile)):
writeJsonData(defaultsourceconfigfile, d)
print("initialize pymake.json in source root %s." % sourceroot)
if (not os.path.exists(sourceconfigfile)):
print("source config file %s is not existed." % sourceconfigfile)
print("You can use source command to fix it.")
return
# ===============================================================================================
# PYMAKE INITIALIZE COMMAND INITIAL CODE
# --------------------
# initialize
# ===============================================================================================
# PYMAKE SHELL ROOT INITIAL CODE
# --------------------
# record user shell root directory [default]
defaultshellroot = sourceroot + os.path.sep + "UserShell"
# print("execute directory: %s" % (defaultshellroot) )
if (not os.path.exists(defaultshellroot)):
os.makedirs(defaultshellroot)
# support pymake default shell root, pymake custom shell root, pymake current shell root.
pymakeexecini = sourceroot + os.path.sep + 'exec.ini'
execconf = MyConfigParser()
execconf.read(pymakeexecini)
if (not execconf.has_section('exec')):
execconf.add_section('exec')
execconf.write(open(pymakeexecini, 'w'))
if (not execconf.has_section('work')):
execconf.add_section('work')
execconf.write(open(pymakeexecini, 'w'))
if (not execconf.has_section('root')):
execconf.add_section('root')
execconf.write(open(pymakeexecini, 'w'))
if (not execconf.has_option('work', 'where')):
execconf.set('work', 'where', 'default')
execconf.write(open(pymakeexecini, 'w'))
if (not execconf.has_option('root', 'default')):
execconf.set('root', 'default', defaultshellroot)
execconf.write(open(pymakeexecini, 'w'))
if (not execconf.has_option('root', 'there')):
execconf.set('root', 'there', defaultshellroot)
execconf.write(open(pymakeexecini, 'w'))
if (not execconf.has_option('root', 'here')):
execconf.set('root', 'here', '')
execconf.write(open(pymakeexecini, 'w'))
# record pymake work root type [ where is the work root ? default, there, here ]
workroottype = execconf.get('work', 'where')
# record pymake custom shell root [ user custom work path ]
customshellroot = execconf.get('root', 'there')
if (not os.path.exists(customshellroot)):
os.makedirs(customshellroot)
# custom work root
# record user shell root directory [starting] [1/3 maybe startup directory]
shellroot = defaultshellroot
if (workroottype == 'default'):
shellroot = defaultshellroot
elif (workroottype == 'here'):
shellroot = startupworkdirectory
elif (workroottype == 'there'):
shellroot = customshellroot
# if(workroottype == 'default'):
# print("WORK STARTING : %s" % (defaultshellroot))
# elif (workroottype == 'here'):
# print("WORK STARTING : %s" % (startupworkdirectory))
# elif (workroottype == 'there'):
# print("WORK STARTING : %s" % (customshellroot))
# print("execute root type: %s" % (workroottype) )
# print("execute directory: %s" % (shellroot) )
# I set this,
# pymake execute user bat/sh in shellroot,
# user can use here param to restrict exec action.
# cd user shell root [ default shell execute path ]
# prepare to user shell root
if (not os.path.exists(shellroot)):
os.makedirs(shellroot)
os.chdir(shellroot)
# print( "pymake user shell root:", pymakeshellroot )
# ===============================================================================================
# PYMAKE BACKUP COMMAND INITIAL CODE
# --------------------
# backup
# recovery
# ===============================================================================================
# PYMAKE PORT INITIAL CODE
# --------------------
# port translate function
portdefaultsourceconfig = pymakedefaultsourcefile
portdefaulttargetconfig = 'temporary-target.json'
portiniconfig = 'port.ini'
portinifile = os.path.join(sourceroot, "port.ini")
def init_portconf():
portconf = MyConfigParser()
portconf.read(portinifile)
if (not portconf.has_section('port')):
portconf.add_section('port')
portconf.write(open(portinifile, 'w'))
if (not portconf.has_option('port', 'sourceroot')):
portconf.set('port', 'sourceroot', sourceroot)
portconf.write(open(portinifile, 'w'))
if (not portconf.has_option('port', 'sourceconfig')):
portconf.set('port', 'sourceconfig', portdefaultsourceconfig)
portconf.write(open(portinifile, 'w'))
if (not portconf.has_option('port', 'targetroot')):
portconf.set('port', 'targetroot', sourceroot)
portconf.write(open(portinifile, 'w'))
if (not portconf.has_option('port', 'targetconfig')):
portconf.set('port', 'targetconfig', portdefaulttargetconfig)
portconf.write(open(portinifile, 'w'))
# print (portinifile)
# print ("sourceroot :", portconf['port']['sourceroot'])
# print ("sourceconfig:", portconf['port']['sourceconfig'])
# print ("targetroot :", portconf['port']['targetroot'])
# print ("targetconfig:", portconf['port']['targetconfig'])
return portconf, portinifile
def init_portconfig(portconf=MyConfigParser()):
portsourceconfigfile = os.path.join(portconf['port']['sourceroot'], portconf['port']['sourceconfig'])
porttargetconfigfile = os.path.join(portconf['port']['targetroot'], portconf['port']['targetconfig'])
d_temp = {
"path-assemblage": {
},
"environ": {
"default": {
"path+": [
]
},
"current": "default"
},
"command": {
}
}
if (not os.path.exists(portsourceconfigfile)):
writeJsonData(portsourceconfigfile, d_temp)
if (not os.path.exists(porttargetconfigfile)):
writeJsonData(porttargetconfigfile, d_temp)
srcsize = os.path.getsize(portsourceconfigfile)
tarsize = os.path.getsize(porttargetconfigfile)
if (srcsize < 166):
writeJsonData(portsourceconfigfile, d_temp)
if (tarsize < 166):
writeJsonData(porttargetconfigfile, d_temp)
portconfig = readJsonData(portsourceconfigfile)
porttargetconfig = readJsonData(porttargetconfigfile)
# hard
if (portconfig.__contains__("path-assemblage") is False):
portconfig['path-assemblage'] = {}
writeJsonData(portsourceconfigfile, portconfig)
if (portconfig.__contains__("environ") is False):
portconfig['environ'] = {}
writeJsonData(portsourceconfigfile, portconfig)
if (portconfig.__contains__("command") is False):
portconfig['command'] = {}
writeJsonData(portsourceconfigfile, portconfig)
# soft
# if(portconfig['environ'].__contains__("default") is False):
# portconfig['environ']['default']={"path+":[]}
# writeJsonData(portsourceconfigfile, portconfig)
# if(portconfig['environ']['default'].__contains__("path+") is False):
# portconfig['environ']['default']['path+']=[]
# writeJsonData(portsourceconfigfile, portconfig)
# if(portconfig['environ'].__contains__("current") is False):
# portconfig['environ']['current']='default'
# writeJsonData(portsourceconfigfile, portconfig)
# hard
if (porttargetconfig.__contains__("path-assemblage") is False):
porttargetconfig['path-assemblage'] = {}
writeJsonData(porttargetconfigfile, porttargetconfig)
if (porttargetconfig.__contains__("environ") is False):
porttargetconfig['environ'] = {}
writeJsonData(porttargetconfigfile, porttargetconfig)
if (porttargetconfig.__contains__("command") is False):
porttargetconfig['command'] = {}
writeJsonData(porttargetconfigfile, porttargetconfig)
# soft
order_of_keys = porttargetconfig['environ'].keys()
list_of_tuples = [key for key in order_of_keys]
if (list_of_tuples.__len__() < 2):
if (porttargetconfig['environ'].__contains__("default") is False):
porttargetconfig['environ']['default'] = {"path+": []}
writeJsonData(porttargetconfigfile, porttargetconfig)
if (porttargetconfig['environ']['default'].__contains__("path+") is False):
porttargetconfig['environ']['default']['path+'] = []
writeJsonData(porttargetconfigfile, porttargetconfig)
if (porttargetconfig['environ'].__contains__("current") is False):
porttargetconfig['environ']['current'] = 'default'
writeJsonData(porttargetconfigfile, porttargetconfig)
# move 'current' to be last key
order_of_keys = porttargetconfig['environ'].keys()
list_of_tuples = [key for key in order_of_keys]
# print(order_of_keys)
# print(list_of_tuples)
# print(list_of_tuples[-1])
if (list_of_tuples[-1] != 'current'):
# print(".....")
current_var = porttargetconfig['environ']['current']
porttargetconfig['environ'].__delitem__('current')
porttargetconfig['environ']['current'] = current_var
writeJsonData(porttargetconfigfile, porttargetconfig)
return portconfig, porttargetconfig
# initialize when need port function? no case.
portconf, temp_var = init_portconf()
init_portconfig(portconf)
# port translate
# set this command here .
# program
# ===============================================================================================
# PYMAKE DEBUG INITIAL CODE
# --------------------
# debug.
debugini = sourceroot + os.path.sep + "debug.ini"
debugconf = MyConfigParser()
debugconf.read(debugini)
if (not debugconf.has_section('debug')):
debugconf.add_section('debug')
debugconf.write(open(debugini, 'w'))
if (not debugconf.has_option('debug', 'switch')):
debugconf.set('debug', 'switch', '0')
debugconf.write(open(debugini, 'w'))
debugswitch = debugconf['debug']['switch']
if (debugswitch != '0' and debugswitch != '1'):
debugswitch = '0'
debugconf.set('debug', 'switch', debugswitch)
debugconf.write(open(debugini, 'w'))
# debug
# ===============================================================================================
# PYMAKE SOURCE CONFIG INITIAL CODE
# --------------------
config = readJsonData(sourceconfigfile)
# print(config)
def check_config():
# hard
if (config.__contains__("path-assemblage") is False):
config['path-assemblage'] = {}
writeJsonData(sourceconfigfile, config)
if (config.__contains__("environ") is False):
config['environ'] = {}
writeJsonData(sourceconfigfile, config)
if (config.__contains__("command") is False):
config['command'] = {}
writeJsonData(sourceconfigfile, config)
# soft
# if(portconfig['environ'].__contains__("default") is False):
# portconfig['environ']['default']={"path+":[]}
# writeJsonData(portsourceconfigfile, portconfig)
# if(portconfig['environ']['default'].__contains__("path+") is False):
# portconfig['environ']['default']['path+']=[]
# writeJsonData(portsourceconfigfile, portconfig)
# if(portconfig['environ'].__contains__("current") is False):
# portconfig['environ']['current']='default'
# writeJsonData(portsourceconfigfile, portconfig)
# soft
order_of_keys = config['environ'].keys()
list_of_tuples = [key for key in order_of_keys]
if (list_of_tuples.__len__() < 2):
if (config['environ'].__contains__("default") is False):
config['environ']['default'] = {"path+": []}
writeJsonData(sourceconfigfile, config)
if (config['environ']['default'].__contains__("path+") is False):
config['environ']['default']['path+'] = []
writeJsonData(sourceconfigfile, config)
if (config['environ'].__contains__("current") is False):
config['environ']['current'] = 'default'
writeJsonData(sourceconfigfile, config)
# move 'current' to be last key
order_of_keys = config['environ'].keys()
list_of_tuples = [key for key in order_of_keys]
# print(order_of_keys)
# print(list_of_tuples)
# print(list_of_tuples[-1])
if (list_of_tuples[-1] != 'current'):
# print(".....")
current_var = config['environ']['current']
config['environ'].__delitem__('current')
config['environ']['current'] = current_var
writeJsonData(sourceconfigfile, config)
return
check_config()
# ===============================================================================================
# PYMAKE IMPORT COMMAND INITIAL CODE
# --------------------
# import command
# set
# set
# get
# ===============================================================================================
# PYMAKE SOURCE RAW CONFIG INITIAL CODE
# --------------------
# record system environ
pymakesystemenviron = copy.deepcopy(os.environ)
### config -> raw config
rawconfig = copy.deepcopy(config)
# print ( config )
# print ( rawconfig )
# replace path
for (key, value) in rawconfig["path-assemblage"].items():
# print (key) #...
startpos = 0
while (True):
# print (startpos)
index = value.find('${', startpos)
if (index == -1):
break
index2 = value.find('}', index)
startpos = index2
key_replace = value[index:index2 + 1]
# print ( key0 ) #${...}
key_from = key_replace.split('{')[1].split('}')[0].strip()
# print ( key1 ) #...
for (find_key, find_value) in rawconfig["path-assemblage"].items():
if (key == find_key):
break
if (find_key == key_from):
rawconfig["path-assemblage"][key] = rawconfig["path-assemblage"][key].replace(
key_replace, rawconfig["path-assemblage"][key_from])
# print("xxx %s" % rawconfig["path-assemblage"][key])
break
# NO! ignore [in command, has various interpretations]
# for (find_key, find_value) in pymakesystemenviron.items():
# if (key == find_key):
# break
# if (str(find_key).lower() == 'path'):
# continue
# if (find_key == key_from):
# rawconfig["path-assemblage"][key] = rawconfig["path-assemblage"][key].replace(
# key_replace, pymakesystemenviron[key_from])
# # print("xxx %s" % rawconfig["path-assemblage"][key])
# break
# fix windows platform path sep
# but no nessesary
plat = getplatform()
if (plat == "Windows"):
""
# rawconfig["path-assemblage"][key] = rawconfig["path-assemblage"][key].replace('/', os.path.sep)
# replace env
# from path var env
for current_var in rawconfig["environ"].keys():
if (current_var == "current"):
continue
# replace path+
step = 0
for value in rawconfig["environ"][current_var]['path+']:
startpos = 0
while (True):
# print (startpos)
# print (value)
index = value.find('${', startpos)
if (index == -1):
break
index2 = value.find('}', index)
startpos = index2
key_replace = value[index:index2 + 1]
# print ( key0 ) #${...}
key_from = key_replace.split('{')[1].split('}')[0].strip()
# print ( key1 ) #...
for (find_key, find_value) in rawconfig["path-assemblage"].items():
if (find_key == key_from):
rawconfig["environ"][current_var]['path+'][step] = rawconfig["environ"][current_var]['path+'][step].replace(
key_replace, rawconfig["path-assemblage"][key_from])
break
step += 1
for (key, value) in rawconfig["environ"][current_var].items():
# print (key) #...
if (key == "path+"):
continue
startpos = 0
while (True):
# print (startpos)
index = value.find('${', startpos)
if (index == -1):
break
index2 = value.find('}', index)
startpos = index2
key_replace = value[index:index2 + 1]
# print ( key0 ) #${...}
key_from = key_replace.split('{')[1].split('}')[0].strip()
# print ( key1 ) #...
for (find_key, find_value) in rawconfig["path-assemblage"].items():
if (find_key == key_from):
rawconfig["environ"][current_var][key] = rawconfig["environ"][current_var][key].replace(
key_replace, rawconfig["path-assemblage"][key_from])
break
for (find_key, find_value) in rawconfig["environ"][current_var].items():
if (key == find_key):
break
if (find_key == key_from):
rawconfig["environ"][current_var][key] = rawconfig["environ"][current_var][key].replace(
key_replace, rawconfig["environ"][current_var][key_from])
break
# replace cmd
# from path env
for (cmd, stream) in rawconfig["command"].items():
# print (key) #...
step = 0
for value in stream:
startpos = 0
while (True):
# print (startpos)
# print (value)
index = value.find('${', startpos)
if (index == -1):
break
index2 = value.find('}', index)
startpos = index2
key_replace = value[index:index2 + 1]
# print ( key0 ) #${...}
key_from = key_replace.split('{')[1].split('}')[0].strip()
# print ( key1 ) #...
for (find_key, find_value) in rawconfig["path-assemblage"].items():
if (find_key == key_from):
rawconfig['command'][cmd][step] = rawconfig['command'][cmd][step].replace(
key_replace, rawconfig["path-assemblage"][key_from])
break
current_env_var = rawconfig["environ"]["current"]
for (find_key, find_value) in rawconfig["environ"][current_env_var].items():
if (find_key == key_from):
rawconfig['command'][cmd][step] = rawconfig['command'][cmd][step].replace(
key_replace, rawconfig["environ"][current_env_var][key_from])
break
step += 1
# raw path function, parse custom path tuple
def raw_path(pathgroup0):
pathgroup = copy.deepcopy(pathgroup0)
# replace path
for (key, value) in enumerate(pathgroup):
# print (key) #...
startpos = 0
while (True):
# print (startpos)
index = value.find('${', startpos)
if (index == -1):
break
index2 = value.find('}', index)
startpos = index2
key_replace = value[index:index2 + 1]
# print ( key0 ) #${...}
key_from = key_replace.split('{')[1].split('}')[0].strip()
# print ( key1 ) #...
for (find_key, find_value) in rawconfig["path-assemblage"].items():
if (key == find_key):
break
if (find_key == key_from):
pathgroup[key] = pathgroup[key].replace(key_replace, rawconfig["path-assemblage"][key_from])
# print("xxx %s" % pathgroup[key])
break
return pathgroup
# custom command function
# custom command stream from rawconfig
def raw_command(env_name=None):
command_dict = copy.deepcopy(config['command'])
# replace cmd
# from path env
for (cmd, stream) in command_dict.items():
# print (key) #...
step = 0
for value in stream:
startpos = 0
while (True):
# print (startpos)
# print (value)
index = value.find('${', startpos)
if (index == -1):
break
index2 = value.find('}', index)
startpos = index2
key_replace = value[index:index2 + 1]
# print ( key0 ) #${...}
key_from = key_replace.split('{')[1].split('}')[0].strip()
# print ( key1 ) #...
for (find_key, find_value) in rawconfig["path-assemblage"].items():
if (find_key == key_from):
command_dict[cmd][step] = command_dict[cmd][step].replace(
key_replace, rawconfig["path-assemblage"][key_from])
break
current_env_var = env_name
if (env_name is None):
current_env_var = config["environ"]["current"]
for (find_key, find_value) in rawconfig["environ"][current_env_var].items():
if (find_key == key_from):
command_dict[cmd][step] = command_dict[cmd][step].replace(
key_replace, rawconfig["environ"][current_env_var][key_from])
break
step += 1
return command_dict
# custom string dict -> raw dict
def raw_string(pathgroup0, env_name=None):
pathgroup = {k: v for k, v in pathgroup0.items()}
# print(pathgroup)
dict0 = {k: v for k, v in rawconfig['path-assemblage'].items()}
dict1 = {}
current_env = env_name
if (current_env == "current"):
current_env = rawconfig['environ']['current']
if (env_name is not None):
dict1 = {k: v for k, v in rawconfig['environ'][current_env].items()}
dict2 = {k: v for k, v in os.environ.items()}
# replace path
for (key, value) in pathgroup.items():
# print (key, value) #...
if (instanceof(value) != 'str'):
continue
if (dict0.__contains__(value) is True):
pathgroup[key] = dict0[value]
# print(pathgroup[key])
continue
if (dict2.__contains__(value) is True):
pathgroup[key] = dict2[value]
continue
if (dict1.__contains__(value) is True):
pathgroup[key] = dict1[value]
continue
startpos = 0
while (True):
# print (startpos)
index = value.find('${', startpos)
if (index == -1):
break
index2 = value.find('}', index)
startpos = index2
key_replace = value[index:index2 + 1]
# print ( key0 ) #${...}
key_from = key_replace.split('{')[1].split('}')[0].strip()
# print ( key1 ) #...
for (find_key, find_value) in dict0.items():
# print("%-30s, %-30s, %-30s, path-assemblage" % (key, key_from, find_key))
if (key == find_key):
break
# if (find_key == 'path+'):
# continue
# if (find_key == "path"):
# continue
if (find_key == key_from):
pathgroup[key] = pathgroup[key].replace(key_replace, dict0[key_from])
# print("path-assemblage %s" % pathgroup[key])
break
for (find_key, find_value) in dict2.items():
# print("%-30s, %-30s, %-30s, system env" % (key, key_from, find_key))
if (key == find_key):
break
# if (find_key == 'path+'):
# continue
if (find_key == "path"):
continue
if (find_key == key_from):
pathgroup[key] = pathgroup[key].replace(key_replace, dict2[key_from])
# print("system env %s" % pathgroup[key])
break
for (find_key, find_value) in dict1.items():
# print("%-30s, %-30s, %-30s, separate env" % (key, key_from, find_key))
if (key == find_key):
break
if (find_key == 'path+'):
continue
# if (find_key == "path"):
# continue
if (find_key == key_from):
pathgroup[key] = pathgroup[key].replace(key_replace, dict1[key_from])
# print("separate env %s" % pathgroup[key])
break
return pathgroup
# custom string dict -> raw dict [ignore case]
def raw_string1(pathgroup0, env_name=None):
# pathgroup = {k: v.lower() for k, v in pathgroup0.items()}
pathgroup1 = {k: v for k, v in pathgroup0.items()}
# print(pathgroup)
dict0 = {k.lower(): v for k, v in rawconfig['path-assemblage'].items()}
dict1 = {}
current_env = env_name
if (current_env == "current"):
current_env = rawconfig['environ']['current']
if (env_name is not None):
dict1 = {k.lower(): v for k, v in rawconfig['environ'][current_env].items()}
dict2 = {k.lower(): v for k, v in os.environ.items()}
# replace path
for (key, value) in pathgroup0.items():
# print (key, value) #...
if (instanceof(value) != 'str'):
continue
if (dict0.__contains__(value.lower()) is True):
pathgroup1[key] = dict0[value.lower()]
# print(pathgroup1[key])
continue
if (dict2.__contains__(value.lower()) is True):
pathgroup1[key] = dict2[value.lower()]
continue
if (dict1.__contains__(value.lower()) is True):
pathgroup1[key] = dict1[value.lower()]
continue
startpos = 0
while (True):
# print (startpos)
index = value.find('${', startpos)
if (index == -1):
break
index2 = value.find('}', index)
startpos = index2
key_replace = value[index:index2 + 1]
# print ( key0 ) #${...}
key_from = key_replace.split('{')[1].split('}')[0].strip()
# print ( key1 ) #...
for (find_key, find_value) in dict0.items():
# print("%-30s, %-30s, %-30s, path-assemblage" % (key, key_from, find_key))
if (key.lower() == find_key):
break
# if (find_key == 'path+'):
# continue
# if (find_key == "path"):
# continue
if (find_key == key_from.lower()):
pathgroup1[key] = pathgroup1[key].replace(key_replace, key_replace.lower())
pathgroup1[key] = pathgroup1[key].replace(key_replace.lower(), dict0[key_from.lower()])
# print("path-assemblage %s" % pathgroup1[key])
break
for (find_key, find_value) in dict2.items():
# print("%-30s, %-30s, %-30s, system env" % (key, key_from, find_key))
if (key.lower() == find_key):
break
# if (find_key == 'path+'):
# continue
if (find_key == "path"):
continue
if (find_key == key_from.lower()):
pathgroup1[key] = pathgroup1[key].replace(key_replace, key_replace.lower())
pathgroup1[key] = pathgroup1[key].replace(key_replace.lower(), dict2[key_from.lower()])
# print("system env %s" % pathgroup1[key])
break
for (find_key, find_value) in dict1.items():
# print("%-30s, %-30s, %-30s, separate env" % (key, key_from, find_key))
if (key.lower() == find_key):
break
if (find_key == 'path+'):
continue
# if (find_key == "path"):
# continue
if (find_key == key_from.lower()):
pathgroup1[key] = pathgroup1[key].replace(key_replace, key_replace.lower())
pathgroup1[key] = pathgroup1[key].replace(key_replace.lower(), dict1[key_from.lower()])
# print("separate env %s" % pathgroup1[key])
break
return pathgroup1
# which command [internal]
def which_command(env_name=None, name='', postfix=[]):
if (name is None or name == ''):
return None
# get python command.
pycmd = name
# get path ext
pathext = []
pathext.append('')
pathext.extend(postfix)
plat = getplatform()
if (plat == "Windows"):
pathext.extend(os.environ['PATHEXT'].split(os.path.pathsep))
else:
pathext.extend(['.sh', '.out', '.cmd'])
# find in current path
specialpath = [
startupworkdirectory,
os.getcwd()
]
list0 = copy.deepcopy(specialpath)
list0.reverse()
for path0a in list0:
for path0 in path0a.split(os.path.pathsep):
path0 = path0.strip()
# print(path0)
path1 = ''
for pext0 in pathext:
path1 = path0 + os.path.sep + pycmd + pext0
if (os.path.isfile(path1)):
if (plat == "Windows"):
return path1.replace('/', '\\')
else:
return path1.replace('\\', '/')
if (env_name is not None):
if (rawconfig['environ'].__contains__(env_name) is False):
print("Fault Error! .json file is broken, env %s is losing!" % env_name)
return None
# find in separate env
list0 = copy.deepcopy(rawconfig['environ'][env_name]['path+'])
list0.reverse()
for path0a in list0:
for path0 in path0a.split(os.path.pathsep):
path0 = path0.strip()
# print(path0)
path1 = ''
for pext0 in pathext:
path1 = path0 + os.path.sep + pycmd + pext0
if (os.path.isfile(path1)):
if (plat == "Windows"):
return path1.replace('/', '\\')
else:
return path1.replace('\\', '/')
# find in env. [custom+, local+, system]
env = os.environ
# for pathA in env['PATH'].split(os.path.pathsep):
# print(pathA)
list0 = copy.deepcopy(env['PATH'].split(os.path.pathsep))
# list0.reverse()
for path0a in list0:
for path0 in path0a.split(os.path.pathsep):
path0 = path0.strip()
# print(path0)
path1 = ''
for pext0 in pathext:
path1 = path0 + os.path.sep + pycmd + pext0
# print("[%s]" % path1)
if (os.path.isfile(path1)):
if (plat == "Windows"):
return path1.replace('/', '\\')
else:
return path1.replace('\\', '/')
return None
# which file [internal]
def which_file(env_name=None, name='', postfix=[]):
if (name is None or name == ''):
return None
# get python command.
pycmd = name
# get path ext
pathext = []
pathext.append('')
pathext.extend(postfix)
plat = getplatform()
if (plat == "Windows"):
pathext.extend([])
else:
pathext.extend([])
# find in current path
specialpath = [
startupworkdirectory,
os.getcwd()
]
list0 = copy.deepcopy(specialpath)
list0.reverse()
for path0a in list0:
for path0 in path0a.split(os.path.pathsep):
path0 = path0.strip()
# print(path0)
path1 = ''
for pext0 in pathext:
path1 = path0 + os.path.sep + pycmd + pext0
if (os.path.isfile(path1)):
if (plat == "Windows"):
return path1.replace('/', '\\')
else:
return path1.replace('\\', '/')
if (env_name is not None):
if (rawconfig['environ'].__contains__(env_name) is False):
print("Fault Error! .json file is broken, env %s is losing!" % env_name)
return None
# find in separate env
list0 = copy.deepcopy(rawconfig['environ'][env_name]['path+'])
list0.reverse()
for path0a in list0:
for path0 in path0a.split(os.path.pathsep):
path0 = path0.strip()
# print(path0)
path1 = ''
for pext0 in pathext:
path1 = path0 + os.path.sep + pycmd + pext0
if (os.path.isfile(path1)):
if (plat == "Windows"):
return path1.replace('/', '\\')
else:
return path1.replace('\\', '/')
# find in env. [custom+, local+, system]
env = os.environ
# for pathA in env['PATH'].split(os.path.pathsep):
# print(pathA)
list0 = copy.deepcopy(env['PATH'].split(os.path.pathsep))
# list0.reverse()
for path0a in list0:
for path0 in path0a.split(os.path.pathsep):
path0 = path0.strip()
# print(path0)
path1 = ''
for pext0 in pathext:
path1 = path0 + os.path.sep + pycmd + pext0
# print("[%s]" % path1)
if (os.path.isfile(path1)):
if (plat == "Windows"):
return path1.replace('/', '\\')
else:
return path1.replace('\\', '/')
return None
# pymake expand command-line.
# current_var = args['<env-name>']
# args = raw_string(args, current_var)
# print(args)
# for (k, v) in args.items():
# if(isinstance(v, str)):
# print(k, v)
# return
# system command function
# system command stream from rawconfig path-assemblage
def raw_command_system():
command_dict = copy.deepcopy(config['command'])
# replace cmd
# from path env
for (cmd, stream) in command_dict.items():
# print (key) #...
step = 0
for value in stream:
startpos = 0
while (True):
# print (startpos)
# print (value)
index = value.find('${', startpos)
if (index == -1):
break
index2 = value.find('}', index)
startpos = index2
key_replace = value[index:index2 + 1]
# print ( key0 ) #${...}
key_from = key_replace.split('{')[1].split('}')[0].strip()
# print ( key1 ) #...
for (find_key, find_value) in rawconfig["path-assemblage"].items():
if (find_key == key_from):
command_dict[cmd][step] = command_dict[cmd][step].replace(
key_replace, rawconfig["path-assemblage"][key_from])
break
step += 1
return command_dict
# .bat .sh, windows, unix, system
def createCmdList06(env_name=None, local=True, list0=[], params0=[]):
cmd_list = []
name = uuid.uuid4().__str__()
name = name.split('-')[0]
# print (name)
plat = getplatform()
if (plat == "Windows"):
cmd_status = "echo pymake-command-status:%ERRORLEVEL%"
cmd_sep = '&'
cmd_codec = "ansi"
if (getplatform_release() == "XP"):
cmd_codec = None
# but windows, it is \r\n, python helpping me?
cmd_return = "\n"
cmd_exit = 'exit /b %ERRORLEVEL%'
cmd_suffix = ".bat"
cmd_header = "@echo off"
cmd_call = "call "
# window close echo, close promot
cmd_list.append(cmd_header)
# os.system("type env_effect.bat > cmd_exec.bat")
if (env_name != None):
cmd_list.append("call %s_effect.bat" % name)
else:
cmd_status = "echo pymake-command-status:$?"
cmd_sep = ';'
cmd_suffix = ".sh"
cmd_exit = 'exit $?'
cmd_codec = "utf8"
cmd_return = "\n"
cmd_header = "#!/usr/bin/env bash"
cmd_call = "./"
cmd_list.append(cmd_header)
if (env_name != None):
cmd_list.append("source %s_effect.sh" % name)
params_string = ""
for param in params0:
if (str(param).__contains__(' ')):
params_string += '"' + param + '"' + ' '
else:
params_string += param + ' '
# print(params_string)
if (local is True):
for cmd in list0:
cmd_list.append(cmd)
else:
for cmd in list0:
if (str(cmd).__contains__(' ')):
pycmd = which_command(env_name, str(cmd))
# print(pycmd)
if (pycmd is not None and os.path.isfile(pycmd)):
cmd_list.append('"' + cmd + '"' + ' ' + params_string)
else:
cmd_list.append(cmd + ' ' + params_string)
else:
cmd_list.append(cmd + ' ' + params_string)
# append exit 0
cmd_list.append(cmd_exit)
# print( cmd_list )
cmd_execute = name + "_exec" + cmd_suffix
with open(cmd_execute, "w", encoding=cmd_codec) as f:
for line in cmd_list:
f.write(line + cmd_return)
# print(cmd_execute)
if (debugswitch == '1'):
print("IN: execute file: %s" % cmd_execute)
for cmd in cmd_list:
print(cmd)
print("---------------------------")
if (plat == "Windows"):
""
else:
os.system("chmod +x " + cmd_execute)
cmd_list.clear()
if (plat == "Windows"):
cmd_list.append(cmd_header + ' ' + cmd_sep + ' ' + cmd_status)
# cmd_list.append("call " + cmd_execute + cmd_sep + ' ' + cmd_status)
cmd_list.append("call " + cmd_execute + ' ' + params_string + cmd_sep + ' ' + cmd_status)
else:
# cmd_list.append(cmd_header + ' ' + cmd_sep + ' ' + cmd_status)
# cmd_list.append("./" + cmd_execute + cmd_sep + ' ' + cmd_status)
cmd_list.append("./" + cmd_execute + ' ' + params_string + cmd_sep + ' ' + cmd_status)
cmd_list.append(cmd_exit)
# print (cmd_list)
if (debugswitch == '1'):
print("CMD: call execute file: %s" % cmd_execute)
for cmd in cmd_list:
print(cmd)
print("---------------------------")
return cmd_list, name
# system export function
def system_env_export(env_name=None, file_name=None):
if (env_name == None):
return env_name, '', ''
# select env
current_var = rawconfig['environ']['current']
if (env_name is not None):
current_var = env_name
dict0 = copy.deepcopy(rawconfig['environ'][current_var])
plat = getplatform()
if (plat == "Windows"):
cmd_suffix = ".bat"
cmd_codec = "ansi"
if (getplatform_release() == "XP"):
cmd_codec = None
cmd_return = "\n"
cmd_header = "@echo off" + cmd_return
env_set = 'set '
else:
cmd_suffix = ".sh"
cmd_codec = "utf8"
cmd_return = "\n"
cmd_header = "#!/usr/bin/env bash" + cmd_return
env_set = 'export '
# export effect env
cmd_effect = 'env'
if (file_name is not None):
cmd_effect = file_name
cmd_effect += '_effect' + cmd_suffix
# export path
lines = ""
for (key) in dict0["path+"]:
if (plat == "Windows"):
lines += (env_set + 'PATH=' + key + os.path.pathsep + '%PATH%' + cmd_return)
else:
lines += (env_set + 'PATH="' + key + '"' + os.path.pathsep + '$PATH' + cmd_return)
# export var
for (key, value) in dict0.items():
if (key == 'path+'):
continue
if (plat == "Windows"):
lines += (env_set + key + '=' + value + cmd_return)
else:
lines += (env_set + key + '=\"' + value + '\"' + cmd_return)
with open(cmd_effect, 'w', encoding=cmd_codec) as f:
f.write(cmd_header)
f.write(lines)
# export unset env
cmd_unset = 'env'
if (file_name is not None):
cmd_unset = file_name
cmd_unset += '_unset' + cmd_suffix
# export unset path
lines = ""
for (key) in dict0["path+"]:
if (plat == "Windows"):
lines += (env_set + 'PATH=%PATH:' + key + ';=%' + cmd_return)
else:
lines += (env_set + 'PATH=$(' + 'echo ${PATH//' + key.replace('/', '\/') + ':/})' + cmd_return)
# export unset var
for (key, value) in dict0.items():
if (key == 'path+'):
continue
if (plat == "Windows"):
lines += ('set ' + key + '=' + cmd_return)
else:
lines += ('unset ' + key + cmd_return)
with open(cmd_unset, 'w', encoding=cmd_codec) as f:
f.write(cmd_header)
f.write(lines)
if (plat == "Windows"):
""
else:
os.system("chmod +x " + cmd_effect)
os.system("chmod +x " + cmd_unset)
# return file name
return current_var, cmd_effect, cmd_unset
# ===============================================================================================
# PYMAKE SYSTEM COMMAND INITIAL CODE
# --------------------
# print(args)
# system ccvp
# outport command
# get open path's cmd list
def open_command(pathlist0, env_name=None):
pathgroup0 = {}
for (k, v) in enumerate(pathlist0):
pathgroup0[str('-pymake-open-p%d' % k)] = str(v)
cmd_list = []
pathgroup1 = {}
# if(args['-i'] or args['--ignorecase'] is True):
# pathgroup1 = raw_string1(pathgroup0, env_name)
# else:
# pathgroup1 = raw_string(pathgroup0, env_name)
pathgroup1 = raw_string1(pathgroup0, env_name)
plat = getplatform()
for (k, v) in pathgroup1.items():
path0 = str(v)
pathslist = path0.split(os.path.pathsep)
while (pathslist.__contains__('')):
pathslist.remove('')
# print(pathslist)
for path0 in pathslist:
cmd0 = ''
if (plat == "Windows"):
if (path0.__contains__(' ')):
cmd0 = 'start "" ' + '"%s"' % path0
else:
cmd0 = "start " + path0
elif (plat == "Darwin"):
if (path0.__contains__(' ')):
cmd0 = 'open ' + '"%s"' % path0
else:
cmd0 = "open " + path0
else:
if (path0.__contains__(' ')):
cmd0 = 'xdg-open ' + '"%s" ' % path0 + ">/dev/null 2>&1"
else:
cmd0 = "xdg-open " + '%s ' % path0 + ">/dev/null 2>&1"
cmd_list.append(cmd0)
return cmd_list
# print(args)
# open command
# ===============================================================================================
# PYMAKE LOCAL ENV INITIAL CODE
# --------------------
# pymake local const variable.
localini = sourceroot + os.path.sep + "local.ini"
localconf = MyConfigParser()
localconf.read(localini)
if (not localconf.has_section('local')):
localconf.add_section('local')
localconf.write(open(localini, 'w'))
if (not localconf.has_section('path+')):
localconf.add_section('path+')
localconf.write(open(localini, 'w'))
if (not localconf.has_section('variable')):
localconf.add_section('variable')
localconf.write(open(localini, 'w'))
# status readonly
# if( not localconf.has_option('local', 'status') ):
# localconf.set('local', 'status', 'readonly')
# localconf.write(open(localini, 'w'))
# localswitch = localconf['local']['status']
# if(localswitch != 'readonly'):
# localswitch = 'readonly'
# localconf.set('local', 'status', localswitch)
# localconf.write(open(localini, 'w'))
# switch [1, default]
if (not localconf.has_option('local', 'switch')):
localconf.set('local', 'switch', '1')
localconf.write(open(localini, 'w'))
localswitch = localconf['local']['switch']
if (localswitch != '0' and localswitch != '1'):
localswitch = '1'
localconf.set('local', 'switch', localswitch)
localconf.write(open(localini, 'w'))
localenv = {}
localenv['path+'] = []
# set into env [no effect to system environ]
while (True):
if (int(localswitch) == 0):
break
env = os.environ
localenv['PYMAKEDEFAULTSOURCEROOT'] = pymakedefaultsourceroot
localenv['PYMAKEDEFAULTSOURCECONFIG'] = pymakedefaultsourcefile
localenv['PYMAKESOURCEFILE'] = sourceconfigfile
localenv['PYMAKESOURCEROOT'] = sourceroot
localenv['PYMAKESOURCECONFIG'] = sourcefile
localenv['PYMAKEDEFAULTWORKROOT'] = defaultshellroot
localenv['PYMAKETHEREWORKROOT'] = customshellroot
localenv['PYMAKEHEREWORKROOT'] = startupworkdirectory
localenv['PYMAKEWORKROOT'] = shellroot
# localenv['PYMAKEWORKROOTTYPE'] = workroottype
if ((args.__contains__('here') or args.__contains__('hh')) and (args['here'] or args['hh'] is True)):
localenv['PYMAKEWORKROOT'] = startupworkdirectory
elif ((args.__contains__('there') or args.__contains__('tt')) and (args['there'] or args['tt'] is True)):
localenv['PYMAKEWORKROOT'] = customshellroot
elif ((args.__contains__('default') or args.__contains__('dd')) and (args['default'] or args['dd'] is True)):
localenv['PYMAKEWORKROOT'] = defaultshellroot
if (args.__contains__('--workroot') and args['--workroot'] is not None):
if (os.path.isdir(args['--workroot'])
and os.path.isabs(args['--workroot'])):
localenv['PYMAKEWORKROOT'] = args['--workroot']
# os.chdir(args['--workroot'])
else:
print('please input a legal work root.')
return
localenv['PYMAKEPROGRAM'] = pymakefile
localenv['PYMAKEPROGRAMROOT'] = pymakefileroot
localenv['PYMAKEPROGRAMFILE'] = pymakefilename
localenv['PYMAKEPROGRAMCONFIGURE'] = os.path.realpath(pymakeconfigureini)
localenv['PYMAKEPROGRAMCONFIGUREROOT'] = os.path.split(os.path.realpath(pymakeconfigureini))[0]
localenv['PYMAKEPROGRAMCONFIGUREFILE'] = os.path.split(os.path.realpath(pymakeconfigureini))[1]
if (getplatform() == 'Windows'):
localenv['PYMAKEINSTALLROOT'] = env['windir']
else:
localenv['PYMAKEINSTALLROOT'] = '/usr/local/bin'
localenv['path+'].append(localenv['PYMAKEPROGRAMROOT'])
localenv['path+'].append(localenv['PYMAKESOURCEROOT'])
localenv['path+'].append(localenv['PYMAKEDEFAULTWORKROOT'])
# if(localenv['path+'].__contains__(localenv['PYMAKETHEREWORKROOT']) is False):
localenv['path+'].append(localenv['PYMAKETHEREWORKROOT'])
# if(localenv['path+'].__contains__(localenv['PYMAKEHEREWORKROOT']) is False):
localenv['path+'].append(localenv['PYMAKEHEREWORKROOT'])
# if(localenv['path+'].__contains__(localenv['PYMAKEWORKROOT']) is False):
localenv['path+'].append(localenv['PYMAKEWORKROOT'])
# store to file
for (key, value) in enumerate(localenv["path+"]):
localconf.set('path+', str("%d" % key), value)
for (key, value) in localenv.items():
if (key == 'path+'):
continue
localconf.set('variable', key, value)
localconf.write(open(localini, 'w'))
# set into env
for (key) in localenv["path+"]:
env["PATH"] = key + os.path.pathsep + env["PATH"]
for (key, value) in localenv.items():
if (key == 'path+'):
continue
env[key] = value
# print(json.dumps(localenv, indent=4, sort_keys=False, ensure_ascii=False))
break
# local command
# ===============================================================================================
# PYMAKE CUSTOM ENV INITIAL CODE
# --------------------
# initial custom environ module
pymakecustomini = sourceroot + os.path.sep + "custom.ini"
customconf = MyConfigParser()
customconf.read(pymakecustomini)
if (not customconf.has_section('custom')):
customconf.add_section('custom')
customconf.write(open(pymakecustomini, 'w'))
if (not customconf.has_option('custom', 'switch')):
customconf.set('custom', 'switch', '1')
customconf.write(open(pymakecustomini, 'w'))
switch0 = customconf['custom']['switch']
if (switch0 != '0' and switch0 != '1'):
switch0 = '1'
customconf.set('custom', 'switch', switch0)
customconf.write(open(pymakecustomini, 'w'))
custompathfile = sourceroot + os.path.sep + "custom.path+.ini"
customenvfile = sourceroot + os.path.sep + "custom.var+.ini"
storecustompaths = []
storecustomvars = []
envcustomlistpaths = []
envcustomlistvars = {}
envcustomlistrawpaths = []
envcustomlistrawvars = {}
plat = getplatform()
cmd_codec = "utf8"
cmd_return = "\n"
if (plat == "Windows"):
cmd_codec = "ansi"
if (getplatform_release() == "XP"):
cmd_codec = None
# but windows, it is \r\n, python helpping me?
cmd_return = "\n"
else:
cmd_codec = "utf8"
cmd_return = "\n"
# custom environ
# user can use custom environ to effect pymake basic environment.
# it will effect every executing environment.
while (True):
if (int(switch0) == 0):
break
# print("open custom environ.")
# set custom path+ to env.
# print(sourceroot)
# print(shellroot)
# init file
# custompathfile = sourceroot + os.path.sep + "custom.path+.ini"
if (os.path.exists(custompathfile) is False):
with open(custompathfile, 'w', encoding=cmd_codec) as f:
''
# read all
custompaths = []
with open(custompathfile, 'r', encoding=cmd_codec) as f:
for l in f.readlines():
# important format
# l = l.strip()
while (l.endswith('\r') or l.endswith('\n') or l.endswith('\r\n')):
l = l.rstrip('\r\n')
l = l.rstrip('\n')
l = l.rstrip('\r')
# if(l == ''):
# continue
custompaths.append(l)
# while(custompaths.__contains__('') is True):
# custompaths.remove('')
# print(custompaths)
# print(os.linesep)
# for l in custompaths:
# print("AAAA:" + l)
# write back
# strip
storecustompaths = copy.deepcopy(custompaths)
for (i, l) in enumerate(storecustompaths):
# import format
l = l.strip()
storecustompaths[i] = l
# added by local, ignore
'''
# default [ fixed ]
# add pymake default source root to environ.
if (storecustompaths.__contains__(pymakedefaultsourceroot) is False):
storecustompaths.append(pymakedefaultsourceroot)
# add pymake default shell root to environ.
if (storecustompaths.__contains__(pymakedefaultshellroot) is False):
storecustompaths.append(pymakedefaultshellroot)
# default [ movable, follow user source root ]
# add user source root to environ.
if (sourceroot != pymakedefaultsourceroot and storecustompaths.__contains__(sourceroot) is False):
storecustompaths.append(sourceroot)
# add user shell root to environ.
if (customshellroot != defaultshellroot and storecustompaths.__contains__(customshellroot) is False):
storecustompaths.append(customshellroot)
if (startupworkdirectory != defaultshellroot and storecustompaths.__contains__(startupworkdirectory) is False):
storecustompaths.append(startupworkdirectory)
if (shellroot != defaultshellroot and storecustompaths.__contains__(shellroot) is False):
storecustompaths.append(shellroot)
'''
# clean repeat path [for store]
clean_list = []
temp_list = []
for l in storecustompaths:
if (l == ''):
continue
if (os.path.isabs(l) is False):
continue
if (temp_list.__contains__(str(l).replace('\\', '/').lower())):
clean_list.append(l)
continue
else:
temp_list.append(str(l).replace('\\', '/').lower())
# print(clean_list)
storecustompaths.reverse()
for l in clean_list:
if (storecustompaths.__contains__(l) is True):
storecustompaths.remove(l)
storecustompaths.reverse()
if (custompaths != storecustompaths):
with open(custompathfile, 'w', encoding=cmd_codec) as f:
for l in storecustompaths:
f.write(l + cmd_return)
# set into env
# raw
envcustompaths = copy.deepcopy(storecustompaths)
envcustomrawpaths = raw_path(envcustompaths)
# print(envcustompaths)
# print(envcustomrawpaths)
# envcustomlistpaths
for (key, l) in zip(envcustompaths, envcustomrawpaths):
if (l == ''):
continue
# print(os.path.isabs(l), l)
if (os.path.isabs(l) is False):
continue
envcustomlistpaths.append(key)
# clean illgal path
clean_list = []
for l in envcustomrawpaths:
if (l == ''):
clean_list.append(l)
continue
if (os.path.isabs(l) is False):
clean_list.append(l)
continue
# print(clean_list)
for l in clean_list:
if (envcustomrawpaths.__contains__(l) is True):
envcustomrawpaths.remove(l)
env = os.environ
for l in envcustomrawpaths:
env["PATH"] = l + os.path.pathsep + env["PATH"]
for l in envcustomrawpaths:
envcustomlistrawpaths.append(l)
# set custom env+ to env.
# customenvfile = sourceroot + os.path.sep + "custom.var+.ini"
# print(customenvfile)
# init
if (os.path.exists(customenvfile) is False):
with open(customenvfile, 'w', encoding=cmd_codec) as f:
''
# read all
customenvs = []
with open(customenvfile, 'r', encoding=cmd_codec) as f:
for l in f.readlines():
# important format
# l = l.strip()
while (l.endswith('\r') or l.endswith('\n') or l.endswith('\r\n')):
l = l.rstrip('\r\n')
l = l.rstrip('\n')
l = l.rstrip('\r')
# if(l == ''):
# continue
customenvs.append(l)
# write back
# strip
storecustomvars = copy.deepcopy(customenvs)
for (i, l) in enumerate(storecustomvars):
# important format
l = l.strip()
storecustomvars[i] = l
avarkeyvalue = "PYMAKEAUTHOR=T.D.R."
if (storecustomvars.__contains__(avarkeyvalue) is False):
storecustomvars.append(avarkeyvalue)
# clean repeat var [for store]
clean_list = []
temp_list = []
for l in storecustomvars:
if (l == ''):
continue
if (str(l).__contains__('=') is False):
continue
if (temp_list.__contains__(str(l).split('=')[0].strip().lower())):
clean_list.append(l)
continue
else:
temp_list.append(str(l).split('=')[0].strip().lower())
# print(clean_list)
storecustomvars.reverse()
for l in clean_list:
if (storecustomvars.__contains__(l) is True):
storecustomvars.remove(l)
storecustomvars.reverse()
if (storecustomvars != customenvs):
with open(customenvfile, 'w', encoding=cmd_codec) as f:
for l in storecustomvars:
f.write(l + cmd_return)
# set into env
# raw
envcustomvars = copy.deepcopy(storecustomvars)
envcustomrawvars = raw_path(envcustomvars)
# print(envcustomvars)
# print(envcustomrawvars)
for (key0, l) in zip(envcustomvars, envcustomrawvars):
if (l == ''):
continue
if (str(l).__contains__('=') is False):
continue
key = str(key0).split('=')[0].strip()
value = '='.join(str(key0).split('=')[1:]).strip()
envcustomlistvars[key] = value
# clean illgal var
clean_list = []
for l in envcustomrawvars:
if (l == ''):
clean_list.append(l)
continue
if (str(l).__contains__('=') is False):
clean_list.append(l)
continue
# print(clean_list)
for l in clean_list:
if (envcustomrawvars.__contains__(l) is True):
envcustomrawvars.remove(l)
env = os.environ
for l in envcustomrawvars:
key = str(l).split('=')[0].strip()
value = '='.join(str(l).split('=')[1:]).strip()
env[key] = value
for l in envcustomrawvars:
key = str(l).split('=')[0].strip()
value = '='.join(str(l).split('=')[1:]).strip()
envcustomlistrawvars[key] = value
break
# ===============================================================================================
# PYMAKE VC MODULE INITIAL CODE
# --------------------
# initial vc module
# record vc shell root.
vcroot = sourceroot + os.path.sep + "VCShell"
if (not os.path.exists(vcroot)):
os.mkdir(vcroot)
d_vc = {
'environ': {
}
}
pymakevcconfigfile = vcroot + os.path.sep + 'pymake-vc-command.json'
# print(pymakevcconfigfile)
if (not os.path.exists(pymakevcconfigfile)):
writeJsonData(pymakevcconfigfile, d_vc)
pymakevcdict = readJsonData(pymakevcconfigfile)
if (pymakevcdict.__contains__('environ') is False):
# print('Fault error: %s is broken, please delete it manully.' % pymakevcconfigfile)
# return
pymakevcdict['environ'] = {}
writeJsonData(pymakevcconfigfile, pymakevcdict)
# print(pymakevcdict)
# check command
def vc_createCmdList08(shellenvname=None, env_name=None, local=True, list0=[], params0=[]):
cmd_list = []
if (env_name is None):
env_name = rawconfig['environ']['current']
# print(env_name)
name = uuid.uuid4().__str__()
name = name.split('-')[0]
# print (name)
plat = getplatform()
if (plat == "Windows"):
cmd_status = "echo pymake-command-status:%ERRORLEVEL%"
cmd_sep = '&'
cmd_codec = "ansi"
if (getplatform_release() == "XP"):
cmd_codec = None
# but windows, it is \r\n, python helpping me?
cmd_return = "\n"
cmd_exit = 'exit /b %ERRORLEVEL%'
cmd_suffix = ".bat"
cmd_header = "@echo off"
cmd_call = "call "
# window close echo, close promot
cmd_list.append(cmd_header)
# os.system("type env_effect.bat > cmd_exec.bat")
cmd_list.append("call %s_effect.bat" % name)
if (shellenvname is not None):
cmd_list.append('call \"%s_effect%s\"' % (shellenvname, cmd_suffix))
else:
cmd_status = "echo pymake-command-status:$?"
cmd_sep = ';'
cmd_suffix = ".sh"
cmd_exit = 'exit $?'
cmd_codec = "utf8"
cmd_return = "\n"
cmd_header = "#!/usr/bin/env bash"
cmd_call = "./"
cmd_list.append(cmd_header)
cmd_list.append("source %s_effect.sh" % name)
if (shellenvname is not None):
cmd_list.append('source \"%s_effect%s\"' % (shellenvname, cmd_suffix))
# print(params0)
params_string = ""
for param in params0:
# print(param)
if (str(param).__contains__(' ')):
params_string += '"' + param + '"' + ' '
else:
params_string += param + ' '
# print(params_string)
if (local is True):
for cmd in list0:
cmd_list.append(cmd)
else:
for cmd in list0:
if (str(cmd).__contains__(' ')):
pycmd = which_command(env_name, str(cmd))
# print(str(cmd))
# print(Fore.RED + "which command:", pycmd)
if (pycmd is not None and os.path.isfile(pycmd)):
cmd_list.append('"' + cmd + '"' + ' ' + params_string)
else:
cmd_list.append(cmd + ' ' + params_string)
else:
cmd_list.append(cmd + ' ' + params_string)
# append exit 0
cmd_list.append(cmd_exit)
# print( cmd_list )
cmd_execute = name + "_exec" + cmd_suffix
with open(cmd_execute, "w", encoding=cmd_codec) as f:
for line in cmd_list:
f.write(line + cmd_return)
# print(cmd_execute)
if (debugswitch == '1'):
print("IN: execute file: %s" % cmd_execute)
for cmd in cmd_list:
print(cmd)
print("---------------------------")
if (plat == "Windows"):
""
else:
os.system("chmod +x " + cmd_execute)
cmd_list.clear()
if (plat == "Windows"):
cmd_list.append(cmd_header + ' ' + cmd_sep + ' ' + cmd_status)
# cmd_list.append("call " + cmd_execute + cmd_sep + ' ' + cmd_status)
cmd_list.append("call " + cmd_execute + ' ' + params_string + cmd_sep + ' ' + cmd_status)
else:
# cmd_list.append(cmd_header + ' ' + cmd_sep + ' ' + cmd_status)
# cmd_list.append("./" + cmd_execute + cmd_sep + ' ' + cmd_status)
cmd_list.append("./" + cmd_execute + ' ' + params_string + cmd_sep + ' ' + cmd_status)
cmd_list.append(cmd_exit)
# print (cmd_list)
if (debugswitch == '1'):
print("CMD: call execute file: %s" % cmd_execute)
for cmd in cmd_list:
print(cmd)
print("---------------------------")
return cmd_list, name
def vc_powershell_createCmdList08(shellenvname=None, env_name=None, local=True, list0=[], params0=[]):
cmd_list = []
if (env_name is None):
env_name = rawconfig['environ']['current']
name = uuid.uuid4().__str__()
name = name.split('-')[0]
# print (name)
# plat = getplatform()
cmd_status = "echo pymake-command-status:$LASTEXITCODE"
cmd_sep = ';'
cmd_suffix = ".ps1"
cmd_suffix_powershell = cmd_suffix
cmd_exit = 'exit $LASTEXITCODE'
cmd_codec = 'ansi'
if (getplatform_release() == "XP"):
cmd_codec = None
# but windows, it is \r\n, python helpping me?
cmd_return = "\n"
cmd_header = "#!/usr/bin/env bash"
cmd_call = "./"
# cmd_list.append(cmd_header)
cmd_list.append("./%s_effect%s" % (name, cmd_suffix))
if (shellenvname is not None):
cmd_list.append('. \"%s_effect%s\"' % (shellenvname, cmd_suffix))
params_string = ""
for param in params0:
if (str(param).__contains__(' ')):
params_string += '"' + param + '"' + ' '
else:
params_string += param + ' '
# print(params_string)
if (local is True):
for cmd in list0:
cmd_list.append(cmd)
else:
# actually now has only one command.
for cmd in list0:
# warning: now pymake is in user setted workroot.
if (str(cmd).endswith(cmd_suffix_powershell)):
cmd_suffix_powershell = ''
powershellexecfile = ""
while (True):
# find in current path [+workroot]
powershellexecfile = os.getcwd() + os.path.sep + cmd + cmd_suffix_powershell
if (os.path.exists(powershellexecfile)):
break
powershellexecfile = startupworkdirectory + os.path.sep + cmd + cmd_suffix_powershell
if (os.path.exists(powershellexecfile)):
break
# find in .json environ
separateenvlistpath = os.path.pathsep.join(rawconfig['environ'][env_name]['path+'])
separateenvlistpath = separateenvlistpath.split(os.path.pathsep)
separateenvlistpath.reverse()
# for path0 in separateenvlistpath:
# print(path0)
find_flag = 0
for path0 in separateenvlistpath:
powershellexecfile = path0 + os.path.sep + cmd + cmd_suffix_powershell
if (os.path.exists(powershellexecfile)):
find_flag = 1
break
if (find_flag == 1):
break
# find in basic environ [+custom]
env = os.environ
find_flag = 0
for path0 in env["PATH"].split(os.path.pathsep):
powershellexecfile = path0 + os.path.sep + cmd + cmd_suffix_powershell
if (os.path.exists(powershellexecfile)):
find_flag = 1
break
if (find_flag == 1):
break
# none? a powershell command, or powershell command-line.
powershellexecfile = cmd
break
# print(powershellexecfile)
# wow
# cmd_list.append(powershellexecfile + ' ' + params_string)
if (str(powershellexecfile).__contains__(' ')):
if (os.path.isfile(powershellexecfile)):
powershellexecfile = powershellexecfile.replace('/', os.path.sep)
powershellexecfile = powershellexecfile.replace('\\', os.path.sep)
cmd_list.append(". \"%s\" @args" % powershellexecfile)
else:
cmd_list.append("%s" % powershellexecfile)
else:
if (os.path.isfile(powershellexecfile)):
powershellexecfile = powershellexecfile.replace('/', os.path.sep)
powershellexecfile = powershellexecfile.replace('\\', os.path.sep)
cmd_list.append(". %s @args" % powershellexecfile)
else:
cmd_list.append("%s" % powershellexecfile)
# append exit 0
cmd_list.append(cmd_exit)
# print( cmd_list )
cmd_execute = "" + name + "_exec" + cmd_suffix
with open(cmd_execute, "w", encoding=cmd_codec) as f:
for line in cmd_list:
f.write(line + cmd_return)
# print(cmd_execute)
if (debugswitch == '1'):
print("IN: execute file: %s" % cmd_execute)
for cmd in cmd_list:
print(cmd)
print("---------------------------")
# if (plat == "Windows"):
# ""
# else:
# os.system("chmod +x " + cmd_execute)
cmd_list.clear()
cmd_list.append(cmd_call + cmd_execute + ' ' + params_string + cmd_sep + ' ' + cmd_status)
cmd_list.append(cmd_exit)
# print (cmd_list)
if (debugswitch == '1'):
print("CMD: call execute file: %s" % cmd_execute)
for cmd in cmd_list:
print(cmd)
print("---------------------------")
return cmd_list, name
def vc_python_createCmdList08(shellenvname=None, env_name=None, local=True, list0=[], params0=[]):
cmd_list = []
if (env_name is None):
env_name = rawconfig['environ']['current']
name = uuid.uuid4().__str__()
name = name.split('-')[0]
# print (name)
plat = getplatform()
if (plat == "Windows"):
cmd_status = "echo pymake-command-status:%ERRORLEVEL%"
cmd_sep = '&'
cmd_codec = "ansi"
if (getplatform_release() == "XP"):
cmd_codec = None
# but windows, it is \r\n, python helpping me?
cmd_return = "\n"
cmd_exit = 'exit /b %ERRORLEVEL%'
cmd_suffix = ".bat"
cmd_header = "@echo off"
cmd_call = "call "
# window close echo, close promot
cmd_list.append(cmd_header)
# os.system("type env_effect.bat > cmd_exec.bat")
cmd_list.append("call %s_effect.bat" % name)
if (shellenvname is not None):
cmd_list.append('call \"%s_effect%s\"' % (shellenvname, cmd_suffix))
else:
cmd_status = "echo pymake-command-status:$?"
cmd_sep = ';'
cmd_suffix = ".sh"
cmd_exit = 'exit $?'
cmd_codec = "utf8"
cmd_return = "\n"
cmd_header = "#!/usr/bin/env bash"
cmd_call = "./"
cmd_list.append(cmd_header)
cmd_list.append("source %s_effect.sh" % name)
if (shellenvname is not None):
cmd_list.append('source \"%s_effect%s\"' % (shellenvname, cmd_suffix))
cmd_suffix_python = '.py'
cmd_codec_python = "utf8"
cmd_return_python = "\n"
params_string = ""
for param in params0:
if (str(param).__contains__(' ')):
params_string += '"' + param + '"' + ' '
else:
params_string += param + ' '
# print(params_string)
pythonexecfile = ''
if (local is True):
# fixed
pythonexecfile = name + '_exec' + cmd_suffix_python
with open(pythonexecfile, 'w', encoding=cmd_codec_python) as f:
for cmd in list0:
f.write(cmd + cmd_return_python)
# print(1, pythonexecfile)
else:
# actually now has only one command.
for cmd in list0:
# warning: now pymake is in user setted workroot.
if (str(cmd).endswith(cmd_suffix_python)):
cmd_suffix_python = ''
pythonexecfile = ""
while (True):
# find in current path [+workroot]
pythonexecfile = os.getcwd() + os.path.sep + cmd + cmd_suffix_python
# print(2, pythonexecfile)
if (os.path.exists(pythonexecfile)):
break
pythonexecfile = startupworkdirectory + os.path.sep + cmd + cmd_suffix_python
# print(2, pythonexecfile)
if (os.path.exists(pythonexecfile)):
break
# find in .json environ
separateenvlistpath = os.path.pathsep.join(rawconfig['environ'][env_name]['path+'])
separateenvlistpath = separateenvlistpath.split(os.path.pathsep)
separateenvlistpath.reverse()
# for path0 in separateenvlistpath:
# print(path0)
find_flag = 0
for path0 in separateenvlistpath:
pythonexecfile = path0 + os.path.sep + cmd + cmd_suffix_python
# print(2, pythonexecfile)
if (os.path.exists(pythonexecfile)):
find_flag = 1
break
if (find_flag == 1):
break
# find in basic environ [custom+]
env = os.environ
find_flag = 0
for path0 in env["PATH"].split(os.path.pathsep):
pythonexecfile = path0 + os.path.sep + cmd + cmd_suffix_python
# print(2, pythonexecfile)
if (os.path.exists(pythonexecfile)):
find_flag = 1
break
if (find_flag == 1):
break
# none? a python command, or python command-line.
pythonexecfile = cmd
break
# print(2, pythonexecfile)
# cmd_list.append(pythonexecfile + ' ' + params_string)
# print params.
# print(3, pythonexecfile)
# get python command.
pycmd = ''
if (plat == "Windows"):
pycmd = 'python.exe'
else:
pycmd = 'python3'
pycmd = which_command(env_name, pycmd)
# print(pycmd)
if (plat == "Windows"):
if (pycmd is None):
pycmd = 'py'
elif (pycmd != 'py'):
pycmd = 'python'
else:
pycmd = 'python3'
if (os.path.isfile(pythonexecfile)):
if (plat == "Windows"):
cmd_list.append("call %s \"%s\" %s" % (pycmd, pythonexecfile, '%*'))
else:
cmd_list.append("%s \"%s\" %s" % (pycmd, pythonexecfile, '"$@"'))
else:
if (plat == "Windows"):
cmd_list.append("call %s -c \"%s\" %s" % (pycmd, pythonexecfile, '%*'))
else:
cmd_list.append("%s -c \"%s\" %s" % (pycmd, pythonexecfile, '"$@"'))
# append exit 0
cmd_list.append(cmd_exit)
cmd_execute = name + "_exec" + cmd_suffix
with open(cmd_execute, "w", encoding=cmd_codec) as f:
for line in cmd_list:
f.write(line + cmd_return)
# print(cmd_execute)
if (debugswitch == '1'):
print("IN: execute file: %s" % cmd_execute)
for cmd in cmd_list:
print(cmd)
print("---------------------------")
if (plat == "Windows"):
""
else:
os.system("chmod +x " + cmd_execute)
cmd_list.clear()
if (plat == "Windows"):
cmd_list.append(cmd_header + ' ' + cmd_sep + ' ' + cmd_status)
# cmd_list.append("call " + cmd_execute + cmd_sep + ' ' + cmd_status)
cmd_list.append("call " + cmd_execute + ' ' + params_string + cmd_sep + ' ' + cmd_status)
else:
# cmd_list.append(cmd_header + ' ' + cmd_sep + ' ' + cmd_status)
# cmd_list.append("./" + cmd_execute + cmd_sep + ' ' + cmd_status)
cmd_list.append("./" + cmd_execute + ' ' + params_string + cmd_sep + ' ' + cmd_status)
cmd_list.append(cmd_exit)
if (debugswitch == '1'):
print("CMD: call execute file: %s" % cmd_execute)
for cmd in cmd_list:
print(cmd)
print("---------------------------")
return cmd_list, name
def vc_language_createCmdList08(shellenvname=None, suffix=None, encoding=None, env_name=None, local=True, list0=[], params0=[]):
cmd_list = []
name = uuid.uuid4().__str__()
name = name.split('-')[0]
# print (name)
plat = getplatform()
if (plat == "Windows"):
cmd_status = "echo pymake-command-status:%ERRORLEVEL%"
cmd_sep = '&'
cmd_codec = "ansi"
if (getplatform_release() == "XP"):
cmd_codec = None
# but windows, it is \r\n, python helpping me?
cmd_return = "\n"
cmd_exit = 'exit /b %ERRORLEVEL%'
cmd_suffix = ".bat"
cmd_header = "@echo off"
cmd_call = "call "
# window close echo, close promot
cmd_list.append(cmd_header)
# os.system("type env_effect.bat > cmd_exec.bat")
cmd_list.append("call %s_effect.bat" % name)
if (shellenvname is not None):
cmd_list.append('call \"%s_effect%s\"' % (shellenvname, cmd_suffix))
else:
cmd_status = "echo pymake-command-status:$?"
cmd_sep = ';'
cmd_suffix = ".sh"
cmd_exit = 'exit $?'
cmd_codec = "utf8"
cmd_return = "\n"
cmd_header = "#!/usr/bin/env bash"
cmd_call = "./"
cmd_list.append(cmd_header)
cmd_list.append("source %s_effect.sh" % name)
if (shellenvname is not None):
cmd_list.append('source \"%s_effect%s\"' % (shellenvname, cmd_suffix))
if (env_name is None):
env_name = rawconfig['environ']['current']
if (env_name == "current"):
env_name = rawconfig['environ']['current']
cmd_suffix_language = cmd_suffix
cmd_codec_language = cmd_codec
cmd_return_language = cmd_return
if (suffix is not None):
cmd_suffix_language = suffix
if (encoding is not None):
cmd_codec_language = encoding
list1 = []
# for current_var in str(args['<command-param>']).split():
# list1.append(current_var)
if (params0.__len__() > 0):
current_var = params0[0]
list1.append(current_var)
params0.pop(0)
# print(list1)
params_string = ""
for param in params0:
if (str(param).__contains__(' ')):
params_string += '"' + param + '"' + ' '
else:
params_string += param + ' '
# print(params_string)
local2 = True
if (list1.__len__() > 0):
current_var = list1[0]
if (current_var in rawconfig['command']):
local2 = True
else:
local2 = False
languageparams = ''
# actually only one param.
if (local2 is True):
for param1 in list1:
languageparams += param1
else:
for param1 in list1:
# warning: now pymake is in user setted workroot.
languageparams = ""
while (True):
# find in current path [+--workroot]
languageparams = os.getcwd() + os.path.sep + param1
# print(2, languageparams)
if (os.path.exists(languageparams)):
break
languageparams = startupworkdirectory + os.path.sep + param1
# print(2, languageparams)
if (os.path.exists(languageparams)):
break
# find in .json environ
separateenvlistpath = os.path.pathsep.join(rawconfig['environ'][env_name]['path+'])
separateenvlistpath = separateenvlistpath.split(os.path.pathsep)
separateenvlistpath.reverse()
# for path0 in separateenvlistpath:
# print(path0)
find_flag = 0
for path0 in separateenvlistpath:
languageparams = path0 + os.path.sep + param1
# print(2, languageparams)
if (os.path.exists(languageparams)):
find_flag = 1
break
if (find_flag == 1):
break
# find in basic environ [custom+]
env = os.environ
find_flag = 0
for path0 in env["PATH"].split(os.path.pathsep):
languageparams = path0 + os.path.sep + param1
# print(2, languageparams)
if (os.path.exists(languageparams)):
find_flag = 1
break
if (find_flag == 1):
break
# none? a language command, or language command-line.
languageparams = param1
break
# print(2, languageparams)
# cmd_list.append(languageparams + ' ' + params_string)
if (list1.__len__() > 0):
''
if (local2 is True):
''
current_var = env_name
local_command = raw_command(current_var)
dict0 = copy.deepcopy(local_command)
inside_name = name + '_2'
languageparams = inside_name + '_exec' + cmd_suffix_language
with open(languageparams, 'w', encoding=cmd_codec_language) as f:
for cmd1 in list1:
for cmd in dict0[cmd1]:
f.write(cmd + cmd_return_language)
# print(1, cmd_suffix_language)
# print(1, cmd_return_language)
# print(1, cmd_codec_language)
# print(1, languageparams)
else:
''
# print(3, languageparams)
if (list1.__len__() > 0):
if (local2 is True):
params_string = languageparams + ' ' + params_string
else:
if (str(languageparams).__contains__(' ')):
params_string = '"' + languageparams + '"' + ' ' + params_string
else:
params_string = languageparams + ' ' + params_string
# print(params_string)
languageexecfile = ''
if (local is True):
# fixed
# inside_name = name
# inside_name = hex( int( inside_name, 16 ) + 1).split('x')[1]
inside_name = name + '_1'
# print(inside_name)
languageexecfile = inside_name + '_exec' + cmd_suffix
with open(languageexecfile, 'w', encoding=cmd_codec) as f:
for cmd in list0:
f.write(cmd + cmd_return)
# print(1, languageexecfile)
else:
languageexecfile = ''
# actually now has only one command.
for cmd in list0:
# actually this is a command.
if (str(cmd).__contains__(' ')):
pycmd = which_command(env_name, str(cmd))
# print(cmd)
# print(pycmd)
if (pycmd is not None and os.path.isfile(pycmd)):
languageexecfile = '"' + cmd + '"'
else:
languageexecfile = cmd
else:
languageexecfile = cmd
# print(3, languageexecfile)
if (plat == "Windows"):
cmd_list.append("call %s %s" % (languageexecfile, '%*'))
else:
if (languageexecfile.endswith('.sh')):
cmd_list.append("sh %s %s" % (languageexecfile, '"$@"'))
else:
cmd_list.append("%s %s" % (languageexecfile, '"$@"'))
# append exit 0
cmd_list.append(cmd_exit)
cmd_execute = name + "_exec" + cmd_suffix
with open(cmd_execute, "w", encoding=cmd_codec) as f:
for line in cmd_list:
f.write(line + cmd_return)
if (debugswitch == '1'):
print("IN: execute file: %s" % cmd_execute)
for cmd in cmd_list:
print(cmd)
print("---------------------------")
if (plat == "Windows"):
""
else:
os.system("chmod +x " + cmd_execute)
cmd_list.clear()
if (plat == "Windows"):
cmd_list.append(cmd_header + ' ' + cmd_sep + ' ' + cmd_status)
# cmd_list.append("call " + cmd_execute + cmd_sep + ' ' + cmd_status)
cmd_list.append("call " + cmd_execute + ' ' + params_string + cmd_sep + ' ' + cmd_status)
else:
# cmd_list.append(cmd_header + ' ' + cmd_sep + ' ' + cmd_status)
# cmd_list.append("./" + cmd_execute + cmd_sep + ' ' + cmd_status)
cmd_list.append("./" + cmd_execute + ' ' + params_string + cmd_sep + ' ' + cmd_status)
cmd_list.append(cmd_exit)
if (debugswitch == '1'):
print("CMD: call execute file: %s" % cmd_execute)
for cmd in cmd_list:
print(cmd)
print("---------------------------")
return cmd_list, name, cmd_suffix, cmd_suffix_language
# vc json export function
def vc_json_export(dict0=None, env_name=None, file_name=None):
if (dict0 is None):
return "", "", ""
# select env
current_var = rawconfig['environ']['current']
if (env_name is not None):
current_var = env_name
cmd_suffix = ".json"
cmd_codec = 'utf8'
if (getplatform_release() == "XP"):
cmd_codec = None
# but windows, it is \r\n, python helpping me?
cmd_return = "\n"
cmd_header = "#!/usr/bin/env bash" + cmd_return
env_set = ''
# export effect env
cmd_effect = 'vcenv'
if (file_name is not None):
cmd_effect = file_name
cmd_effect += cmd_suffix
if (os.path.exists(cmd_effect) is False):
tempdict = {
'environ': {
}
}
writeJsonData(cmd_effect, tempdict)
vcdict = readJsonData(cmd_effect)
if (vcdict.__contains__('environ') is False):
vcdict['environ'] = {}
vcdict['environ'][current_var] = dict0
writeJsonData(cmd_effect, vcdict)
return cmd_effect
# vc powershell export function
def vc_powershell_export(dict0=None, env_name=None, file_name=None):
if (dict0 is None):
return "", "", ""
# select env
current_var = rawconfig['environ']['current']
if (env_name is not None):
current_var = env_name
cmd_suffix = ".ps1"
cmd_codec = 'ansi'
if (getplatform_release() == "XP"):
cmd_codec = None
# but windows, it is \r\n, python helpping me?
cmd_return = "\n"
cmd_header = "#!/usr/bin/env bash" + cmd_return
env_set = ''
# export effect env
cmd_effect = 'env'
if (file_name is not None):
cmd_effect = "" + file_name
cmd_effect += '_effect' + cmd_suffix
# export path
lines = ""
for (key) in dict0["path+"]:
lines += ("if ( !$env:Path.Contains(\"%s;\" ) ) { $env:Path = $env:Path.Insert(0, \"%s;\") }" % (key, key)) + cmd_return
# export var
for (key, value) in dict0.items():
if (key == 'path+'):
continue
lines += ("${env:" + key + '} = \'' + value + '\'' + cmd_return)
# print(lines.split('\n'))
with open(cmd_effect, 'w', encoding=cmd_codec) as f:
# f.write(cmd_header)
f.write(lines)
# export unset env
cmd_unset = 'env'
if (file_name is not None):
cmd_unset = "" + file_name
cmd_unset += '_unset' + cmd_suffix
# export unset path
lines = ""
for (key) in dict0["path+"]:
# lines += ("$env:Path = $env:Path.Replace(\"%s;\", \"\")" % key) + cmd_return
lines += ("if ( $env:Path.Contains(\"%s;\" ) ) { $env:Path = $env:Path.Replace(\"%s;\", \"\") }" % (key, key)) + cmd_return
# export unset var
for (key, value) in dict0.items():
if (key == 'path+'):
continue
lines += ("${env:%s} = \"\"" % key) + cmd_return
with open(cmd_unset, 'w', encoding=cmd_codec) as f:
# f.write(cmd_header)
f.write(lines)
return cmd_effect, cmd_unset
def vc_powershell_export2(dict0=None, env_name=None, file_name=None):
if (dict0 is None):
return "", "", ""
# select env
current_var = rawconfig['environ']['current']
if (env_name is not None):
current_var = env_name
cmd_suffix = ".ps1"
cmd_codec = 'ansi'
if (getplatform_release() == "XP"):
cmd_codec = None
# but windows, it is \r\n, python helpping me?
cmd_return = "\n"
cmd_header = "#!/usr/bin/env bash" + cmd_return
env_set = ''
# export effect env
cmd_effect = 'env'
if (file_name is not None):
cmd_effect = "" + file_name
cmd_effect += '_effect' + cmd_suffix
lines = ""
# +system
if (args['-s'] or args['--system'] is True):
# export path
# print(envcustomlistrawpaths)
for (key) in pymakesystemenviron['PATH'].split(os.path.pathsep):
lines += ("if ( !$env:Path.Contains(\"%s;\" ) ) { $env:Path = $env:Path.Insert(0, \"%s;\") }" % (key, key)) + cmd_return
# export var
for (key, value) in pymakesystemenviron.items():
if (key == 'path+'):
continue
if (str(key).lower() == "path"):
continue
lines += ("${env:" + key + '} = \'' + value + '\'' + cmd_return)
else:
''
# +local
if (args['-l'] or args['--local'] is True):
# export path
for (key) in localenv['path+']:
lines += ("if ( !$env:Path.Contains(\"%s;\" ) ) { $env:Path = $env:Path.Insert(0, \"%s;\") }" % (key, key)) + cmd_return
# export var
for (key, value) in localenv.items():
if (key == 'path+'):
continue
lines += ("${env:" + key + '} = \'' + value + '\'' + cmd_return)
else:
''
# +custom
if (args['-c'] or args['--custom'] is True):
# export path
# print(envcustomlistrawpaths)
for (key) in envcustomlistrawpaths:
lines += ("if ( !$env:Path.Contains(\"%s;\" ) ) { $env:Path = $env:Path.Insert(0, \"%s;\") }" % (key, key)) + cmd_return
# export var
for (key, value) in envcustomlistrawvars.items():
if (key == 'path+'):
continue
lines += ("${env:" + key + '} = \'' + value + '\'' + cmd_return)
else:
''
# export path
for (key) in dict0["path+"]:
lines += ("if ( !$env:Path.Contains(\"%s;\" ) ) { $env:Path = $env:Path.Insert(0, \"%s;\") }" % (key, key)) + cmd_return
# export var
for (key, value) in dict0.items():
if (key == 'path+'):
continue
lines += ("${env:" + key + '} = \'' + value + '\'' + cmd_return)
# print(lines.split('\n'))
with open(cmd_effect, 'w', encoding=cmd_codec) as f:
# f.write(cmd_header)
f.write(lines)
# export unset env
cmd_unset = 'env'
if (file_name is not None):
cmd_unset = "" + file_name
cmd_unset += '_unset' + cmd_suffix
lines = ""
# +system
if (args['-s'] or args['--system'] is True):
# export unset path
for (key) in pymakesystemenviron['PATH'].split(os.path.pathsep):
lines += ("if ( $env:Path.Contains(\"%s;\" ) ) { $env:Path = $env:Path.Replace(\"%s;\", \"\") }" % (key, key)) + cmd_return
# export unset var
for (key, value) in pymakesystemenviron.items():
if (key == 'path+'):
continue
if (str(key).lower() == "path"):
continue
lines += ("${env:%s} = \"\"" % key) + cmd_return
else:
''
# +local
if (args['-l'] or args['--local'] is True):
# export unset path
for (key) in localenv['path+']:
lines += ("if ( $env:Path.Contains(\"%s;\" ) ) { $env:Path = $env:Path.Replace(\"%s;\", \"\") }" % (key, key)) + cmd_return
# export unset var
for (key, value) in localenv.items():
if (key == 'path+'):
continue
lines += ("${env:%s} = \"\"" % key) + cmd_return
else:
''
# +custom
if (args['-c'] or args['--custom'] is True):
# export unset path
for (key) in envcustomlistrawpaths:
lines += ("if ( $env:Path.Contains(\"%s;\" ) ) { $env:Path = $env:Path.Replace(\"%s;\", \"\") }" % (key, key)) + cmd_return
# export unset var
for (key, value) in envcustomlistrawvars.items():
if (key == 'path+'):
continue
lines += ("${env:%s} = \"\"" % key) + cmd_return
else:
''
# export unset path
for (key) in dict0["path+"]:
# lines += ("$env:Path = $env:Path.Replace(\"%s;\", \"\")" % key) + cmd_return
lines += ("if ( $env:Path.Contains(\"%s;\" ) ) { $env:Path = $env:Path.Replace(\"%s;\", \"\") }" % (key, key)) + cmd_return
# export unset var
for (key, value) in dict0.items():
if (key == 'path+'):
continue
lines += ("${env:%s} = \"\"" % key) + cmd_return
with open(cmd_unset, 'w', encoding=cmd_codec) as f:
# f.write(cmd_header)
f.write(lines)
return cmd_effect, cmd_unset
# vc export function
# dict0: VC effect env
# env_name: separate env
# file_name: script name
def vc_export(dict0=None, env_name=None, file_name=None):
if (dict0 is None):
return "", "", ""
# select env
current_var = rawconfig['environ']['current']
if (env_name is not None):
current_var = env_name
plat = getplatform()
if (plat == "Windows"):
cmd_suffix = ".bat"
cmd_codec = "ansi"
if (getplatform_release() == "XP"):
cmd_codec = None
cmd_return = "\n"
cmd_header = "@echo off" + cmd_return
env_set = 'set '
else:
cmd_suffix = ".sh"
cmd_codec = "utf8"
cmd_return = "\n"
cmd_header = "#!/usr/bin/env bash" + cmd_return
env_set = 'export '
# export effect env
cmd_effect = 'env'
if (file_name is not None):
cmd_effect = file_name
cmd_effect += '_effect' + cmd_suffix
# export path
lines = ""
for (key) in dict0["path+"]:
if (plat == "Windows"):
lines += (env_set + 'PATH=' + key + os.path.pathsep + '%PATH%' + cmd_return)
else:
lines += (env_set + 'PATH="' + key + '"' + os.path.pathsep + '$PATH' + cmd_return)
# export var
for (key, value) in dict0.items():
if (key == 'path+'):
continue
if (plat == "Windows"):
lines += (env_set + key + '=' + value + cmd_return)
else:
lines += (env_set + key + '=\"' + value + '\"' + cmd_return)
with open(cmd_effect, 'w', encoding=cmd_codec) as f:
f.write(cmd_header)
f.write(lines)
# export unset env
cmd_unset = 'env'
if (file_name is not None):
cmd_unset = file_name
cmd_unset += '_unset' + cmd_suffix
# export unset path
lines = ""
for (key) in dict0["path+"]:
if (plat == "Windows"):
lines += (env_set + 'PATH=%PATH:' + key + ';=%' + cmd_return)
else:
lines += (env_set + 'PATH=$(' + 'echo ${PATH//' + key.replace('/', '\/') + ':/})' + cmd_return)
# export unset var
for (key, value) in dict0.items():
if (key == 'path+'):
continue
if (plat == "Windows"):
lines += ('set ' + key + '=' + cmd_return)
else:
lines += ('unset ' + key + cmd_return)
with open(cmd_unset, 'w', encoding=cmd_codec) as f:
f.write(cmd_header)
f.write(lines)
if (plat == "Windows"):
""
else:
os.system("chmod +x " + cmd_effect)
os.system("chmod +x " + cmd_unset)
# return file name
return cmd_effect, cmd_unset
def vc_export2(dict0=None, env_name=None, file_name=None):
if (dict0 is None):
return "", "", ""
# select env
current_var = rawconfig['environ']['current']
if (env_name is not None):
current_var = env_name
plat = getplatform()
if (plat == "Windows"):
cmd_suffix = ".bat"
cmd_codec = "ansi"
if (getplatform_release() == "XP"):
cmd_codec = None
cmd_return = "\n"
cmd_header = "@echo off" + cmd_return
env_set = 'set '
else:
cmd_suffix = ".sh"
cmd_codec = "utf8"
cmd_return = "\n"
cmd_header = "#!/usr/bin/env bash" + cmd_return
env_set = 'export '
# export effect env
cmd_effect = 'env'
if (file_name is not None):
cmd_effect = file_name
cmd_effect += '_effect' + cmd_suffix
lines = ""
# +system
if (args['-s'] or args['--system'] is True):
# export path
# print(envcustomlistrawpaths)
for (key) in pymakesystemenviron['PATH'].split(os.path.pathsep):
if (plat == "Windows"):
lines += (env_set + 'PATH=' + key + os.path.pathsep + '%PATH%' + cmd_return)
else:
lines += (env_set + 'PATH="' + key + '"' + os.path.pathsep + '$PATH' + cmd_return)
# export var
for (key, value) in pymakesystemenviron.items():
if (key == 'path+'):
continue
if (str(key).lower() == "path"):
continue
if (plat == "Windows"):
lines += (env_set + key + '=' + value + cmd_return)
else:
lines += (env_set + key + '=\"' + value + '\"' + cmd_return)
else:
''
# +local
if (args['-l'] or args['--local'] is True):
# export path
for (key) in localenv['path+']:
if (plat == "Windows"):
lines += (env_set + 'PATH=' + key + os.path.pathsep + '%PATH%' + cmd_return)
else:
lines += (env_set + 'PATH="' + key + '"' + os.path.pathsep + '$PATH' + cmd_return)
# export var
for (key, value) in localenv.items():
if (key == 'path+'):
continue
if (plat == "Windows"):
lines += (env_set + key + '=' + value + cmd_return)
else:
lines += (env_set + key + '=\"' + value + '\"' + cmd_return)
else:
''
# +custom
if (args['-c'] or args['--custom'] is True):
# export path
# print(envcustomlistrawpaths)
for (key) in envcustomlistrawpaths:
if (plat == "Windows"):
lines += (env_set + 'PATH=' + key + os.path.pathsep + '%PATH%' + cmd_return)
else:
lines += (env_set + 'PATH="' + key + '"' + os.path.pathsep + '$PATH' + cmd_return)
# export var
for (key, value) in envcustomlistrawvars.items():
if (key == 'path+'):
continue
if (plat == "Windows"):
lines += (env_set + key + '=' + value + cmd_return)
else:
lines += (env_set + key + '=\"' + value + '\"' + cmd_return)
else:
''
# export path
for (key) in dict0["path+"]:
if (plat == "Windows"):
lines += (env_set + 'PATH=' + key + os.path.pathsep + '%PATH%' + cmd_return)
else:
lines += (env_set + 'PATH="' + key + '"' + os.path.pathsep + '$PATH' + cmd_return)
# export var
for (key, value) in dict0.items():
if (key == 'path+'):
continue
if (plat == "Windows"):
lines += (env_set + key + '=' + value + cmd_return)
else:
lines += (env_set + key + '=\"' + value + '\"' + cmd_return)
with open(cmd_effect, 'w', encoding=cmd_codec) as f:
f.write(cmd_header)
f.write(lines)
# export unset env
cmd_unset = 'env'
if (file_name is not None):
cmd_unset = file_name
cmd_unset += '_unset' + cmd_suffix
lines = ""
# +system
if (args['-s'] or args['--system'] is True):
# export unset path
for (key) in pymakesystemenviron['PATH'].split(os.path.pathsep):
if (plat == "Windows"):
lines += (env_set + 'PATH=%PATH:' + key + ';=%' + cmd_return)
else:
lines += (env_set + 'PATH=$(' + 'echo ${PATH//' + key.replace('/', '\/') + ':/})' + cmd_return)
# export unset var
for (key, value) in pymakesystemenviron.items():
if (key == 'path+'):
continue
if (str(key).lower() == "path"):
continue
if (plat == "Windows"):
lines += ('set ' + key + '=' + cmd_return)
else:
lines += ('unset ' + key + cmd_return)
else:
''
# +local
if (args['-l'] or args['--local'] is True):
# export unset path
for (key) in localenv['path+']:
if (plat == "Windows"):
lines += (env_set + 'PATH=%PATH:' + key + ';=%' + cmd_return)
else:
lines += (env_set + 'PATH=$(' + 'echo ${PATH//' + key.replace('/', '\/') + ':/})' + cmd_return)
# export unset var
for (key, value) in localenv.items():
if (key == 'path+'):
continue
if (plat == "Windows"):
lines += ('set ' + key + '=' + cmd_return)
else:
lines += ('unset ' + key + cmd_return)
else:
''
# +custom
if (args['-c'] or args['--custom'] is True):
# export unset path
for (key) in envcustomlistrawpaths:
if (plat == "Windows"):
lines += (env_set + 'PATH=%PATH:' + key + ';=%' + cmd_return)
else:
lines += (env_set + 'PATH=$(' + 'echo ${PATH//' + key.replace('/', '\/') + ':/})' + cmd_return)
# export unset var
for (key, value) in envcustomlistrawvars.items():
if (key == 'path+'):
continue
if (plat == "Windows"):
lines += ('set ' + key + '=' + cmd_return)
else:
lines += ('unset ' + key + cmd_return)
else:
''
# export unset path
for (key) in dict0["path+"]:
if (plat == "Windows"):
lines += (env_set + 'PATH=%PATH:' + key + ';=%' + cmd_return)
else:
lines += (env_set + 'PATH=$(' + 'echo ${PATH//' + key.replace('/', '\/') + ':/})' + cmd_return)
# export unset var
for (key, value) in dict0.items():
if (key == 'path+'):
continue
if (plat == "Windows"):
lines += ('set ' + key + '=' + cmd_return)
else:
lines += ('unset ' + key + cmd_return)
with open(cmd_unset, 'w', encoding=cmd_codec) as f:
f.write(cmd_header)
f.write(lines)
if (plat == "Windows"):
""
else:
os.system("chmod +x " + cmd_effect)
os.system("chmod +x " + cmd_unset)
# return file name
return cmd_effect, cmd_unset
# vc settings function
def vc_settings(env_name=None):
current_env = env_name
if (env_name is None):
current_env = rawconfig['environ']['current']
print("source file: %s" % sourceconfigfile)
vcvarslist = [
'vcvarsall-1998',
'vcvarsall-2003',
'vcvarsall-2005',
'vcvarsall-2008',
'vcvarsall-2010',
'vcvarsall-2012',
'vcvarsall-2013',
'vcvarsall-2015',
'vcvarsall-2017',
'vcvarsall-2019',
'vcvarsall-20XX'
]
'''
vcvarslist = []
for key, vcconfig in rawconfig['path-assemblage'].items():
if(str(key).startswith('vcvarsall')):
vcvarslist.append(key)
'''
print('path-assemblage:')
for key in vcvarslist:
if (rawconfig['path-assemblage'].__contains__(key) is False):
rawconfig['path-assemblage'][key] = "<CAN SET>"
print(' "%s": "%s"' % (key, rawconfig['path-assemblage'][key]))
current_vcvarsall = 'vcvarsall'
current_vcvarsallparam = 'vcvarsallparam'
print('system env:')
if (pymakesystemenviron.__contains__(current_vcvarsall) is False):
pymakesystemenviron[current_vcvarsall] = "<CAN SET>"
print(' "%s" : "%s"' % (current_vcvarsall, pymakesystemenviron[current_vcvarsall]))
if (pymakesystemenviron.__contains__(current_vcvarsallparam) is False):
pymakesystemenviron[current_vcvarsallparam] = "<CAN SET>"
print(' "%s": "%s"' % (current_vcvarsallparam, pymakesystemenviron[current_vcvarsallparam]))
print('custom env:')
if (envcustomlistrawvars.__contains__(current_vcvarsall) is False):
envcustomlistrawvars[current_vcvarsall] = "<CAN SET>"
print(' "%s" : "%s"' % (current_vcvarsall, envcustomlistrawvars[current_vcvarsall]))
if (envcustomlistrawvars.__contains__(current_vcvarsallparam) is False):
envcustomlistrawvars[current_vcvarsallparam] = "<CAN SET>"
print(' "%s": "%s"' % (current_vcvarsallparam, envcustomlistrawvars[current_vcvarsallparam]))
print('env %s:' % current_env)
if (rawconfig['environ'][current_env].__contains__(current_vcvarsall) is False):
rawconfig['environ'][current_env][current_vcvarsall] = "<CAN SET>"
print(' "%s" : "%s"' % (current_vcvarsall, rawconfig['environ'][current_env][current_vcvarsall]))
if (rawconfig['environ'][current_env].__contains__(current_vcvarsallparam) is False):
rawconfig['environ'][current_env][current_vcvarsallparam] = "<CAN SET>"
print(' "%s": "%s"' % (current_vcvarsallparam, rawconfig['environ'][current_env][current_vcvarsallparam]))
return
# vc settings2 function
def vc_settings2(env_name = None):
print("source root: %s" % sourceroot)
current_vcvarsall = 'vcvarsall'
current_vcvarsallparam = 'vcvarsallparam'
print('system env:')
if (pymakesystemenviron.__contains__(current_vcvarsall) is False):
pymakesystemenviron[current_vcvarsall] = "<CAN SET>"
print(' "%s" : "%s"' % (current_vcvarsall, pymakesystemenviron[current_vcvarsall]))
if (pymakesystemenviron.__contains__(current_vcvarsallparam) is False):
pymakesystemenviron[current_vcvarsallparam] = "<CAN SET>"
print(' "%s": "%s"' % (current_vcvarsallparam, pymakesystemenviron[current_vcvarsallparam]))
print('custom env:')
if (envcustomlistrawvars.__contains__(current_vcvarsall) is False):
envcustomlistrawvars[current_vcvarsall] = "<CAN SET>"
print(' "%s" : "%s"' % (current_vcvarsall, envcustomlistrawvars[current_vcvarsall]))
if (envcustomlistrawvars.__contains__(current_vcvarsallparam) is False):
envcustomlistrawvars[current_vcvarsallparam] = "<CAN SET>"
print(' "%s": "%s"' % (current_vcvarsallparam, envcustomlistrawvars[current_vcvarsallparam]))
vcvarslist = []
for key, vcconfig in rawconfig['path-assemblage'].items():
if(str(key).startswith('vcvarsall')):
vcvarslist.append(key)
if(str(key).startswith('vcbuildtools')):
vcvarslist.append(key)
vcvarslist.append('vcvarsall-20XX')
print("source file: %s" % sourceconfigfile)
print('path-assemblage:')
for key in vcvarslist:
if (rawconfig['path-assemblage'].__contains__(key) is False):
rawconfig['path-assemblage'][key] = "<CAN SET>"
print(' %-24s: %s' % (key, rawconfig['path-assemblage'][key]))
print('environ:')
print(' %-30s %-30s %-30s %s' % ('[env]', '[status]', '[vcvarsall]', '[vcvarsallparam]'))
set_content = '<WAIT SET>'
set_content2 = '<CAN SET>'
set_content3 = '<INSTALLED>'
set_content4 = '<NEED INSTALL>'
for (k, v) in rawconfig['environ'].items():
current_env = k
if (current_env == 'current'):
continue
status = set_content
vcvarsall = set_content2
vcvarsallparam = set_content2
if (rawconfig['environ'].__contains__(current_env) is True):
if (rawconfig['environ'][current_env].__contains__(current_vcvarsall) is True):
if(os.path.exists(rawconfig['environ'][current_env][current_vcvarsall])):
status = set_content3
else:
status = set_content4
if (rawconfig['environ'][current_env].__contains__(current_vcvarsall) is True):
vcvarsall = rawconfig['environ'][current_env][current_vcvarsall]
if (rawconfig['environ'][current_env].__contains__(current_vcvarsallparam) is True):
vcvarsallparam = rawconfig['environ'][current_env][current_vcvarsallparam]
if (current_env == rawconfig['environ']['current']):
print(Fore.LIGHTMAGENTA_EX + ' %-30s %-30s %-30s %s' % (current_env, status, vcvarsall, vcvarsallparam))
continue
print(' %-30s %-30s %-30s %s' % (current_env, status, vcvarsall, vcvarsallparam))
return
# vc command
# vc init command
# ===============================================================================================
# PYMAKE LANGUAGE CCVP COMMAND INITIAL CODE
# --------------------
# export2 command
# powershell export env function
def powershell_environ_export(env_name=None, file_name=None):
# select env
current_var = rawconfig['environ']['current']
if (env_name is not None):
current_var = env_name
dict0 = copy.deepcopy(rawconfig['environ'][current_var])
cmd_suffix = ".ps1"
cmd_codec = 'ansi'
if (getplatform_release() == "XP"):
cmd_codec = None
# but windows, it is \r\n, python helpping me?
cmd_return = "\n"
cmd_header = "#!/usr/bin/env bash" + cmd_return
env_set = ''
# export effect env
cmd_effect = 'env'
if (file_name is not None):
cmd_effect = "" + file_name
cmd_effect += '_effect' + cmd_suffix
# export path
lines = ""
for (key) in dict0["path+"]:
lines += ("if ( !$env:Path.Contains(\"%s;\" ) ) { $env:Path = $env:Path.Insert(0, \"%s;\") }" % (key, key)) + cmd_return
# export var
for (key, value) in dict0.items():
if (key == 'path+'):
continue
lines += ("${env:" + key + '} = \'' + value + '\'' + cmd_return)
# print(lines.split('\n'))
with open(cmd_effect, 'w', encoding=cmd_codec) as f:
# f.write(cmd_header)
f.write(lines)
# export unset env
cmd_unset = 'env'
if (file_name is not None):
cmd_unset = "" + file_name
cmd_unset += '_unset' + cmd_suffix
# export unset path
lines = ""
for (key) in dict0["path+"]:
# lines += ("$env:Path = $env:Path.Replace(\"%s;\", \"\")" % key) + cmd_return
lines += ("if ( $env:Path.Contains(\"%s;\" ) ) { $env:Path = $env:Path.Replace(\"%s;\", \"\") }" % (key, key)) + cmd_return
# export unset var
for (key, value) in dict0.items():
if (key == 'path+'):
continue
lines += ("${env:%s} = \"\"" % key) + cmd_return
with open(cmd_unset, 'w', encoding=cmd_codec) as f:
# f.write(cmd_header)
f.write(lines)
return current_var, cmd_effect, cmd_unset
# powershell [windows, unix]
def createCmdList03(env_name=None, local=True, list0=[], params0=[]):
cmd_list = []
if (env_name is None):
env_name = rawconfig['environ']['current']
name = uuid.uuid4().__str__()
name = name.split('-')[0]
# print (name)
# plat = getplatform()
cmd_status = "echo pymake-command-status:$LASTEXITCODE"
cmd_sep = ';'
cmd_suffix = ".ps1"
cmd_suffix_powershell = cmd_suffix
cmd_exit = 'exit $LASTEXITCODE'
cmd_codec = 'ansi'
if (getplatform_release() == "XP"):
cmd_codec = None
# but windows, it is \r\n, python helpping me?
cmd_return = "\n"
cmd_header = "#!/usr/bin/env bash"
cmd_call = "./"
# cmd_list.append(cmd_header)
cmd_list.append("./%s_effect%s" % (name, cmd_suffix))
params_string = ""
for param in params0:
if (str(param).__contains__(' ')):
params_string += '"' + param + '"' + ' '
else:
params_string += param + ' '
# print(params_string)
if (local is True):
for cmd in list0:
cmd_list.append(cmd)
else:
# actually now has only one command.
for cmd in list0:
# warning: now pymake is in user setted workroot.
if (str(cmd).endswith(cmd_suffix_powershell)):
cmd_suffix_powershell = ''
powershellexecfile = ""
while (True):
# find in current path [+workroot]
powershellexecfile = os.getcwd() + os.path.sep + cmd + cmd_suffix_powershell
if (os.path.exists(powershellexecfile)):
break
powershellexecfile = startupworkdirectory + os.path.sep + cmd + cmd_suffix_powershell
if (os.path.exists(powershellexecfile)):
break
# find in .json environ
separateenvlistpath = os.path.pathsep.join(rawconfig['environ'][env_name]['path+'])
separateenvlistpath = separateenvlistpath.split(os.path.pathsep)
separateenvlistpath.reverse()
# for path0 in separateenvlistpath:
# print(path0)
find_flag = 0
for path0 in separateenvlistpath:
powershellexecfile = path0 + os.path.sep + cmd + cmd_suffix_powershell
if (os.path.exists(powershellexecfile)):
find_flag = 1
break
if (find_flag == 1):
break
# find in basic environ [+custom]
env = os.environ
find_flag = 0
for path0 in env["PATH"].split(os.path.pathsep):
powershellexecfile = path0 + os.path.sep + cmd + cmd_suffix_powershell
if (os.path.exists(powershellexecfile)):
find_flag = 1
break
if (find_flag == 1):
break
# none? a powershell command, or powershell command-line.
powershellexecfile = cmd
break
# print(powershellexecfile)
# wow
# cmd_list.append(powershellexecfile + ' ' + params_string)
if (str(powershellexecfile).__contains__(' ')):
if (os.path.isfile(powershellexecfile)):
powershellexecfile = powershellexecfile.replace('/', os.path.sep)
powershellexecfile = powershellexecfile.replace('\\', os.path.sep)
cmd_list.append(". \"%s\" @args" % powershellexecfile)
else:
cmd_list.append("%s" % powershellexecfile)
else:
if (os.path.isfile(powershellexecfile)):
powershellexecfile = powershellexecfile.replace('/', os.path.sep)
powershellexecfile = powershellexecfile.replace('\\', os.path.sep)
cmd_list.append(". %s @args" % powershellexecfile)
else:
cmd_list.append("%s" % powershellexecfile)
# append exit 0
cmd_list.append(cmd_exit)
# print( cmd_list )
cmd_execute = "" + name + "_exec" + cmd_suffix
with open(cmd_execute, "w", encoding=cmd_codec) as f:
for line in cmd_list:
f.write(line + cmd_return)
# print(cmd_execute)
if (debugswitch == '1'):
print("IN: execute file: %s" % cmd_execute)
for cmd in cmd_list:
print(cmd)
print("---------------------------")
# if (plat == "Windows"):
# ""
# else:
# os.system("chmod +x " + cmd_execute)
cmd_list.clear()
cmd_list.append(cmd_call + cmd_execute + ' ' + params_string + cmd_sep + ' ' + cmd_status)
cmd_list.append(cmd_exit)
# print (cmd_list)
if (debugswitch == '1'):
print("CMD: call execute file: %s" % cmd_execute)
for cmd in cmd_list:
print(cmd)
print("---------------------------")
return cmd_list, name
# print(args)
# print(args['powershell'])
# powershell is using basic, .json, and custom environ data.
# powershell command
# python export function
def python_env_export(env_name=None, file_name=None):
# select env
current_var = rawconfig['environ']['current']
if (env_name is not None):
current_var = env_name
dict0 = copy.deepcopy(rawconfig['environ'][current_var])
plat = getplatform()
if (plat == "Windows"):
cmd_suffix = ".bat"
cmd_codec = "ansi"
if (getplatform_release() == "XP"):
cmd_codec = None
cmd_return = "\n"
cmd_header = "@echo off" + cmd_return
env_set = 'set '
else:
cmd_suffix = ".sh"
cmd_codec = "utf8"
cmd_return = "\n"
cmd_header = "#!/usr/bin/env bash" + cmd_return
env_set = 'export '
# export effect env
cmd_effect = 'env'
if (file_name is not None):
cmd_effect = file_name
cmd_effect += '_effect' + cmd_suffix
# export path
lines = ""
for (key) in dict0["path+"]:
if (plat == "Windows"):
lines += (env_set + 'PATH=' + key + os.path.pathsep + '%PATH%' + cmd_return)
else:
lines += (env_set + 'PATH="' + key + '"' + os.path.pathsep + '$PATH' + cmd_return)
# export var
for (key, value) in dict0.items():
if (key == 'path+'):
continue
if (plat == "Windows"):
lines += (env_set + key + '=' + value + cmd_return)
else:
lines += (env_set + key + '=\"' + value + '\"' + cmd_return)
with open(cmd_effect, 'w', encoding=cmd_codec) as f:
f.write(cmd_header)
f.write(lines)
# export unset env
cmd_unset = 'env'
if (file_name is not None):
cmd_unset = file_name
cmd_unset += '_unset' + cmd_suffix
# export unset path
lines = ""
for (key) in dict0["path+"]:
if (plat == "Windows"):
lines += (env_set + 'PATH=%PATH:' + key + ';=%' + cmd_return)
else:
lines += (env_set + 'PATH=$(' + 'echo ${PATH//' + key.replace('/', '\/') + ':/})' + cmd_return)
# export unset var
for (key, value) in dict0.items():
if (key == 'path+'):
continue
if (plat == "Windows"):
lines += ('set ' + key + '=' + cmd_return)
else:
lines += ('unset ' + key + cmd_return)
with open(cmd_unset, 'w', encoding=cmd_codec) as f:
f.write(cmd_header)
f.write(lines)
if (plat == "Windows"):
""
else:
os.system("chmod +x " + cmd_effect)
os.system("chmod +x " + cmd_unset)
# return file name
return current_var, cmd_effect, cmd_unset
# python [windows unix]
def createCmdList05(env_name=None, local=True, list0=[], params0=[]):
cmd_list = []
if (env_name is None):
env_name = rawconfig['environ']['current']
name = uuid.uuid4().__str__()
name = name.split('-')[0]
# print (name)
plat = getplatform()
if (plat == "Windows"):
cmd_status = "echo pymake-command-status:%ERRORLEVEL%"
cmd_sep = '&'
cmd_codec = "ansi"
if (getplatform_release() == "XP"):
cmd_codec = None
# but windows, it is \r\n, python helpping me?
cmd_return = "\n"
cmd_exit = 'exit /b %ERRORLEVEL%'
cmd_suffix = ".bat"
cmd_header = "@echo off"
cmd_call = "call "
# window close echo, close promot
cmd_list.append(cmd_header)
# os.system("type env_effect.bat > cmd_exec.bat")
cmd_list.append("call %s_effect.bat" % name)
else:
cmd_status = "echo pymake-command-status:$?"
cmd_sep = ';'
cmd_suffix = ".sh"
cmd_exit = 'exit $?'
cmd_codec = "utf8"
cmd_return = "\n"
cmd_header = "#!/usr/bin/env bash"
cmd_call = "./"
cmd_list.append(cmd_header)
cmd_list.append("source %s_effect.sh" % name)
cmd_suffix_python = '.py'
cmd_codec_python = "utf8"
cmd_return_python = "\n"
params_string = ""
for param in params0:
if (str(param).__contains__(' ')):
params_string += '"' + param + '"' + ' '
else:
params_string += param + ' '
# print(params_string)
pythonexecfile = ''
if (local is True):
# fixed
pythonexecfile = name + '_exec' + cmd_suffix_python
with open(pythonexecfile, 'w', encoding=cmd_codec_python) as f:
for cmd in list0:
f.write(cmd + cmd_return_python)
# print(1, pythonexecfile)
else:
# actually now has only one command.
for cmd in list0:
# warning: now pymake is in user setted workroot.
if (str(cmd).endswith(cmd_suffix_python)):
cmd_suffix_python = ''
pythonexecfile = ""
while (True):
# find in current path [+workroot]
pythonexecfile = os.getcwd() + os.path.sep + cmd + cmd_suffix_python
# print(2, pythonexecfile)
if (os.path.exists(pythonexecfile)):
break
pythonexecfile = startupworkdirectory + os.path.sep + cmd + cmd_suffix_python
# print(2, pythonexecfile)
if (os.path.exists(pythonexecfile)):
break
# find in .json environ
separateenvlistpath = os.path.pathsep.join(rawconfig['environ'][env_name]['path+'])
separateenvlistpath = separateenvlistpath.split(os.path.pathsep)
separateenvlistpath.reverse()
# for path0 in separateenvlistpath:
# print(path0)
find_flag = 0
for path0 in separateenvlistpath:
pythonexecfile = path0 + os.path.sep + cmd + cmd_suffix_python
# print(2, pythonexecfile)
if (os.path.exists(pythonexecfile)):
find_flag = 1
break
if (find_flag == 1):
break
# find in basic environ [custom+]
env = os.environ
find_flag = 0
for path0 in env["PATH"].split(os.path.pathsep):
pythonexecfile = path0 + os.path.sep + cmd + cmd_suffix_python
# print(2, pythonexecfile)
if (os.path.exists(pythonexecfile)):
find_flag = 1
break
if (find_flag == 1):
break
# none? a python command, or python command-line.
pythonexecfile = cmd
break
# print(2, pythonexecfile)
# cmd_list.append(pythonexecfile + ' ' + params_string)
# print params.
# print(3, pythonexecfile)
# get python command.
pycmd = ''
if (plat == "Windows"):
pycmd = 'python.exe'
else:
pycmd = 'python3'
pycmd = which_command(env_name, pycmd)
# print(pycmd)
if (plat == "Windows"):
if (pycmd is None):
pycmd = 'py'
elif (pycmd != 'py'):
pycmd = 'python'
else:
pycmd = 'python3'
if (os.path.isfile(pythonexecfile)):
if (plat == "Windows"):
cmd_list.append("call %s \"%s\" %s" % (pycmd, pythonexecfile, '%*'))
else:
cmd_list.append("%s \"%s\" %s" % (pycmd, pythonexecfile, '"$@"'))
else:
if (plat == "Windows"):
cmd_list.append("call %s -c \"%s\" %s" % (pycmd, pythonexecfile, '%*'))
else:
cmd_list.append("%s -c \"%s\" %s" % (pycmd, pythonexecfile, '"$@"'))
# append exit 0
cmd_list.append(cmd_exit)
cmd_execute = name + "_exec" + cmd_suffix
with open(cmd_execute, "w", encoding=cmd_codec) as f:
for line in cmd_list:
f.write(line + cmd_return)
# print(cmd_execute)
if (debugswitch == '1'):
print("IN: execute file: %s" % cmd_execute)
for cmd in cmd_list:
print(cmd)
print("---------------------------")
if (plat == "Windows"):
""
else:
os.system("chmod +x " + cmd_execute)
cmd_list.clear()
if (plat == "Windows"):
cmd_list.append(cmd_header + ' ' + cmd_sep + ' ' + cmd_status)
# cmd_list.append("call " + cmd_execute + cmd_sep + ' ' + cmd_status)
cmd_list.append("call " + cmd_execute + ' ' + params_string + cmd_sep + ' ' + cmd_status)
else:
# cmd_list.append(cmd_header + ' ' + cmd_sep + ' ' + cmd_status)
# cmd_list.append("./" + cmd_execute + cmd_sep + ' ' + cmd_status)
cmd_list.append("./" + cmd_execute + ' ' + params_string + cmd_sep + ' ' + cmd_status)
cmd_list.append(cmd_exit)
if (debugswitch == '1'):
print("CMD: call execute file: %s" % cmd_execute)
for cmd in cmd_list:
print(cmd)
print("---------------------------")
return cmd_list, name
# python command
# python ccvp command
# print(args)
# print(args['custom'])
# print(args['hh'])
# custom command
# system command
# language export function
def language_env_export(env_name=None, file_name=None):
# select env
current_var = rawconfig['environ']['current']
if (env_name is not None):
current_var = env_name
dict0 = copy.deepcopy(rawconfig['environ'][current_var])
plat = getplatform()
if (plat == "Windows"):
cmd_suffix = ".bat"
cmd_codec = "ansi"
if (getplatform_release() == "XP"):
cmd_codec = None
cmd_return = "\n"
cmd_header = "@echo off" + cmd_return
env_set = 'set '
else:
cmd_suffix = ".sh"
cmd_codec = "utf8"
cmd_return = "\n"
cmd_header = "#!/usr/bin/env bash" + cmd_return
env_set = 'export '
# export effect env
cmd_effect = 'env'
if (file_name is not None):
cmd_effect = file_name
cmd_effect += '_effect' + cmd_suffix
# export path
lines = ""
for (key) in dict0["path+"]:
if (plat == "Windows"):
lines += (env_set + 'PATH=' + key + os.path.pathsep + '%PATH%' + cmd_return)
else:
lines += (env_set + 'PATH="' + key + '"' + os.path.pathsep + '$PATH' + cmd_return)
# export var
for (key, value) in dict0.items():
if (key == 'path+'):
continue
if (plat == "Windows"):
lines += (env_set + key + '=' + value + cmd_return)
else:
lines += (env_set + key + '=\"' + value + '\"' + cmd_return)
with open(cmd_effect, 'w', encoding=cmd_codec) as f:
f.write(cmd_header)
f.write(lines)
# export unset env
cmd_unset = 'env'
if (file_name is not None):
cmd_unset = file_name
cmd_unset += '_unset' + cmd_suffix
# export unset path
lines = ""
for (key) in dict0["path+"]:
if (plat == "Windows"):
lines += (env_set + 'PATH=%PATH:' + key + ';=%' + cmd_return)
else:
lines += (env_set + 'PATH=$(' + 'echo ${PATH//' + key.replace('/', '\/') + ':/})' + cmd_return)
# export unset var
for (key, value) in dict0.items():
if (key == 'path+'):
continue
if (plat == "Windows"):
lines += ('set ' + key + '=' + cmd_return)
else:
lines += ('unset ' + key + cmd_return)
with open(cmd_unset, 'w', encoding=cmd_codec) as f:
f.write(cmd_header)
f.write(lines)
if (plat == "Windows"):
""
else:
os.system("chmod +x " + cmd_effect)
os.system("chmod +x " + cmd_unset)
# return file name
return current_var, cmd_effect, cmd_unset
# language [ .bat .sh .ps1 .py ...] [windows unix] --suffix --encoding
def createCmdList07(suffix=None, encoding=None, env_name=None, local=True, list0=[], params0=[]):
cmd_list = []
name = uuid.uuid4().__str__()
name = name.split('-')[0]
# print (name)
plat = getplatform()
if (plat == "Windows"):
cmd_status = "echo pymake-command-status:%ERRORLEVEL%"
cmd_sep = '&'
cmd_codec = "ansi"
if (getplatform_release() == "XP"):
cmd_codec = None
# but windows, it is \r\n, python helpping me?
cmd_return = "\n"
cmd_exit = 'exit /b %ERRORLEVEL%'
cmd_suffix = ".bat"
cmd_header = "@echo off"
cmd_call = "call "
# window close echo, close promot
cmd_list.append(cmd_header)
# os.system("type env_effect.bat > cmd_exec.bat")
cmd_list.append("call %s_effect.bat" % name)
else:
cmd_status = "echo pymake-command-status:$?"
cmd_sep = ';'
cmd_suffix = ".sh"
cmd_exit = 'exit $?'
cmd_codec = "utf8"
cmd_return = "\n"
cmd_header = "#!/usr/bin/env bash"
cmd_call = "./"
cmd_list.append(cmd_header)
cmd_list.append("source %s_effect.sh" % name)
if (env_name is None):
env_name = rawconfig['environ']['current']
if (env_name == "current"):
env_name = rawconfig['environ']['current']
cmd_suffix_language = cmd_suffix
cmd_codec_language = cmd_codec
cmd_return_language = cmd_return
if (suffix is not None):
cmd_suffix_language = suffix
if (encoding is not None):
cmd_codec_language = encoding
list1 = []
# for current_var in str(args['<command-param>']).split():
# list1.append(current_var)
if (params0.__len__() > 0):
current_var = params0[0]
list1.append(current_var)
params0.pop(0)
# print(list1)
params_string = ""
for param in params0:
if (str(param).__contains__(' ')):
params_string += '"' + param + '"' + ' '
else:
params_string += param + ' '
# print(params_string)
local2 = True
if (list1.__len__() > 0):
current_var = list1[0]
if (current_var in rawconfig['command']):
local2 = True
else:
local2 = False
languageparams = ''
# actually only one param.
if (local2 is True):
for param1 in list1:
languageparams += param1
else:
for param1 in list1:
# warning: now pymake is in user setted workroot.
languageparams = ""
while (True):
# find in current path [+--workroot]
languageparams = os.getcwd() + os.path.sep + param1
# print(2, languageparams)
if (os.path.exists(languageparams)):
break
languageparams = startupworkdirectory + os.path.sep + param1
# print(2, languageparams)
if (os.path.exists(languageparams)):
break
# find in .json environ
separateenvlistpath = os.path.pathsep.join(rawconfig['environ'][env_name]['path+'])
separateenvlistpath = separateenvlistpath.split(os.path.pathsep)
separateenvlistpath.reverse()
# for path0 in separateenvlistpath:
# print(path0)
find_flag = 0
for path0 in separateenvlistpath:
languageparams = path0 + os.path.sep + param1
# print(2, languageparams)
if (os.path.exists(languageparams)):
find_flag = 1
break
if (find_flag == 1):
break
# find in basic environ [custom+]
env = os.environ
find_flag = 0
for path0 in env["PATH"].split(os.path.pathsep):
languageparams = path0 + os.path.sep + param1
# print(2, languageparams)
if (os.path.exists(languageparams)):
find_flag = 1
break
if (find_flag == 1):
break
# none? a language command, or language command-line.
languageparams = param1
break
# print(2, languageparams)
# cmd_list.append(languageparams + ' ' + params_string)
if (list1.__len__() > 0):
''
if (local2 is True):
''
current_var = env_name
local_command = raw_command(current_var)
dict0 = copy.deepcopy(local_command)
inside_name = name + '_2'
languageparams = inside_name + '_exec' + cmd_suffix_language
with open(languageparams, 'w', encoding=cmd_codec_language) as f:
for cmd1 in list1:
for cmd in dict0[cmd1]:
f.write(cmd + cmd_return_language)
# print(1, cmd_suffix_language)
# print(1, cmd_return_language)
# print(1, cmd_codec_language)
# print(1, languageparams)
else:
''
# print(3, languageparams)
if (list1.__len__() > 0):
if (local2 is True):
params_string = languageparams + ' ' + params_string
else:
if (str(languageparams).__contains__(' ')):
params_string = '"' + languageparams + '"' + ' ' + params_string
else:
params_string = languageparams + ' ' + params_string
# print(params_string)
languageexecfile = ''
if (local is True):
# fixed
# inside_name = name
# inside_name = hex( int( inside_name, 16 ) + 1).split('x')[1]
inside_name = name + '_1'
# print(inside_name)
languageexecfile = inside_name + '_exec' + cmd_suffix
with open(languageexecfile, 'w', encoding=cmd_codec) as f:
for cmd in list0:
f.write(cmd + cmd_return)
# print(1, languageexecfile)
else:
languageexecfile = ''
# actually now has only one command.
for cmd in list0:
# actually this is a command.
if (str(cmd).__contains__(' ')):
pycmd = which_command(env_name, str(cmd))
# print(cmd)
# print(pycmd)
if (pycmd is not None and os.path.isfile(pycmd)):
languageexecfile = '"' + cmd + '"'
else:
languageexecfile = cmd
else:
languageexecfile = cmd
# print(3, languageexecfile)
if (plat == "Windows"):
cmd_list.append("call %s %s" % (languageexecfile, '%*'))
else:
if (languageexecfile.endswith('.sh')):
cmd_list.append("sh %s %s" % (languageexecfile, '"$@"'))
else:
cmd_list.append("%s %s" % (languageexecfile, '"$@"'))
# append exit 0
cmd_list.append(cmd_exit)
cmd_execute = name + "_exec" + cmd_suffix
with open(cmd_execute, "w", encoding=cmd_codec) as f:
for line in cmd_list:
f.write(line + cmd_return)
if (debugswitch == '1'):
print("IN: execute file: %s" % cmd_execute)
for cmd in cmd_list:
print(cmd)
print("---------------------------")
if (plat == "Windows"):
""
else:
os.system("chmod +x " + cmd_execute)
cmd_list.clear()
if (plat == "Windows"):
cmd_list.append(cmd_header + ' ' + cmd_sep + ' ' + cmd_status)
# cmd_list.append("call " + cmd_execute + cmd_sep + ' ' + cmd_status)
cmd_list.append("call " + cmd_execute + ' ' + params_string + cmd_sep + ' ' + cmd_status)
else:
# cmd_list.append(cmd_header + ' ' + cmd_sep + ' ' + cmd_status)
# cmd_list.append("./" + cmd_execute + cmd_sep + ' ' + cmd_status)
cmd_list.append("./" + cmd_execute + ' ' + params_string + cmd_sep + ' ' + cmd_status)
cmd_list.append(cmd_exit)
if (debugswitch == '1'):
print("CMD: call execute file: %s" % cmd_execute)
for cmd in cmd_list:
print(cmd)
print("---------------------------")
return cmd_list, name, cmd_suffix, cmd_suffix_language
# language command
# ===============================================================================================
# PYMAKE CCVP COMMAND INITIAL CODE
# --------------------
# cmd type2 function
def cmd_type2(cmd_name=None, file_name=None, env_name=None):
if (cmd_name is None):
for (key, value) in rawconfig['command'].items():
print(Fore.CYAN + "%s" % key)
return
if (rawconfig['command'].__contains__(cmd_name) is False):
print("please check your command name")
return
if (env_name is None or env_name == rawconfig['environ']['current']):
list0 = copy.deepcopy(rawconfig['command'][cmd_name])
else:
list0 = copy.deepcopy(raw_command(env_name)[cmd_name])
# for cmd in list0:
# print(Fore.RED + "%s" % (cmd))
temp_file_name = ""
if (file_name is None):
temp_file_name = "cmd"
else:
temp_file_name = "" + file_name
cmd_header = ""
cmd_codec = "utf8"
# but windows, it is \r\n, python helpping me?
cmd_return = "\n"
cmd_suffix = ""
if (getplatform() == "Windows"):
cmd_codec = "ansi"
if (getplatform_release() == "XP"):
cmd_codec = None
cmd_header = "@echo off"
cmd_suffix = ".bat"
else:
cmd_codec = 'utf8'
cmd_header = "#!/usr/bin/env bash"
cmd_suffix = ".sh"
suffix = args['--suffix']
if (suffix is not None):
cmd_suffix = str("%s" % suffix)
encoding = args['--encoding']
if (encoding is not None):
cmd_codec = encoding
cmd_exec = temp_file_name + cmd_suffix
with open(cmd_exec, 'w', encoding=cmd_codec, errors='ignore') as f:
# f.write(cmd_header + cmd_return)
cmd = ''
# add shebang line
if (list(list0).__len__() > 0):
cmd = list0[0]
# print(".....")
if (getplatform() == "Windows"):
if (cmd_suffix == '.bat'):
if (cmd.startswith('@echo') is False):
f.write(cmd_header + cmd_return)
else:
if (cmd_suffix == '.sh'):
if (cmd.startswith('#!') is False):
f.write(cmd_header + cmd_return)
for cmd in list0:
f.write(cmd + cmd_return)
if (plat == "Windows"):
""
else:
if (cmd_suffix == '.sh'):
os.system("chmod +x " + cmd_exec)
# print(cmd_codec)
# print(cmd_suffix)
# print(cmd_exec)
return cmd_exec
# type2 command
# open command
# clean *_effect *_unset *_exec .bat[.sh]
# list show
# have has
# need return, set return, default break.
# get
# get
# env environ
# cmd_type function
def cmd_type(cmd_name=None, file_name=None, env_name=None):
if (cmd_name is None):
for (key, value) in rawconfig['command'].items():
print(Fore.CYAN + "%s" % key)
return ""
if (rawconfig['command'].__contains__(cmd_name) is False):
print("please check your command name")
return ""
if (env_name is None or env_name == rawconfig['environ']['current']):
list0 = copy.deepcopy(rawconfig['command'][cmd_name])
else:
list0 = copy.deepcopy(raw_command(env_name)[cmd_name])
# for cmd in list0:
# print(Fore.RED + "%s" % (cmd))
temp_file_name = ""
if (file_name is None):
temp_file_name = "cmd"
else:
temp_file_name = file_name
if (getplatform() == "Windows"):
cmd_header = "@echo off"
cmd_suffix = "_exec.bat"
else:
cmd_header = "#!/usr/bin/env bash"
cmd_suffix = "_exec.sh"
cmd_exec = temp_file_name + cmd_suffix
with open(cmd_exec, 'w', encoding=cmd_codec) as f:
cmd = ''
# add shebang line
if (list(list0).__len__() > 0):
cmd = list0[0]
# print(".....")
if (getplatform() == "Windows"):
if (cmd.startswith('@echo') is False):
f.write(cmd_header + cmd_return)
else:
if (cmd.startswith('#!') is False):
f.write(cmd_header + cmd_return)
for cmd in list0:
f.write(cmd + cmd_return)
if (plat == "Windows"):
""
else:
os.system("chmod +x " + cmd_exec)
return cmd_exec
# use - see/ss/cmd
# see ss cmd
# use env type command
# type
# export function
def env_export(env_name=None, file_name=None):
# select env
current_var = rawconfig['environ']['current']
if (env_name is not None):
current_var = env_name
dict0 = copy.deepcopy(rawconfig['environ'][current_var])
plat = getplatform()
if (plat == "Windows"):
cmd_suffix = ".bat"
cmd_codec = "ansi"
if (getplatform_release() == "XP"):
cmd_codec = None
cmd_return = "\n"
cmd_header = "@echo off" + cmd_return
env_set = 'set '
else:
cmd_suffix = ".sh"
cmd_codec = "utf8"
cmd_return = "\n"
cmd_header = "#!/usr/bin/env bash" + cmd_return
env_set = 'export '
# export effect env
cmd_effect = 'env'
if (file_name is not None):
cmd_effect = file_name
cmd_effect += '_effect' + cmd_suffix
# export path
lines = ""
for (key) in dict0["path+"]:
if (plat == "Windows"):
lines += (env_set + 'PATH=' + key + os.path.pathsep + '%PATH%' + cmd_return)
else:
lines += (env_set + 'PATH="' + key + '"' + os.path.pathsep + '$PATH' + cmd_return)
# export var
for (key, value) in dict0.items():
if (key == 'path+'):
continue
if (plat == "Windows"):
lines += (env_set + key + '=' + value + cmd_return)
else:
lines += (env_set + key + '=\"' + value + '\"' + cmd_return)
with open(cmd_effect, 'w', encoding=cmd_codec) as f:
f.write(cmd_header)
f.write(lines)
# export unset env
cmd_unset = 'env'
if (file_name is not None):
cmd_unset = file_name
cmd_unset += '_unset' + cmd_suffix
# export unset path
lines = ""
for (key) in dict0["path+"]:
if (plat == "Windows"):
lines += (env_set + 'PATH=%PATH:' + key + ';=%' + cmd_return)
else:
lines += (env_set + 'PATH=$(' + 'echo ${PATH//' + key.replace('/', '\/') + ':/})' + cmd_return)
# export unset var
for (key, value) in dict0.items():
if (key == 'path+'):
continue
if (plat == "Windows"):
lines += ('set ' + key + '=' + cmd_return)
else:
lines += ('unset ' + key + cmd_return)
with open(cmd_unset, 'w', encoding=cmd_codec) as f:
f.write(cmd_header)
f.write(lines)
if (plat == "Windows"):
""
else:
os.system("chmod +x " + cmd_effect)
os.system("chmod +x " + cmd_unset)
# return file name
return current_var, cmd_effect, cmd_unset
# export
# get
# .bat .sh, windows unix
def createCmdList0(list0):
cmd_list = []
name = uuid.uuid4().__str__()
name = name.split('-')[0]
# print (name)
plat = getplatform()
if (plat == "Windows"):
cmd_status = "echo pymake-command-status:%ERRORLEVEL%"
cmd_sep = '&'
cmd_codec = "ansi"
if (getplatform_release() == "XP"):
cmd_codec = None
# but windows, it is \r\n, python helpping me?
cmd_return = "\n"
cmd_exit = 'exit /b %ERRORLEVEL%'
cmd_suffix = ".bat"
cmd_header = "@echo off"
# window close echo, close promot
cmd_list.append(cmd_header)
# os.system("type env_effect.bat > cmd_exec.bat")
cmd_list.append("call %s_effect.bat" % name)
else:
cmd_status = "echo pymake-command-status:$?"
cmd_sep = ';'
cmd_suffix = ".sh"
cmd_exit = 'exit $?'
cmd_codec = "utf8"
cmd_return = "\n"
cmd_header = "#!/usr/bin/env bash"
cmd_list.append(cmd_header)
cmd_list.append("source %s_effect.sh" % name)
for cmd in list0:
cmd_list.append(cmd)
# append exit 0
cmd_list.append(cmd_exit)
# print( cmd_list )
cmd_execute = name + "_exec" + cmd_suffix
with open(cmd_execute, "w", encoding=cmd_codec) as f:
for line in cmd_list:
f.write(line + cmd_return)
if (debugswitch == '1'):
print("IN: execute file: %s" % cmd_execute)
for cmd in cmd_list:
print(cmd)
print("---------------------------")
if (plat == "Windows"):
""
else:
os.system("chmod +x " + cmd_execute)
cmd_list.clear()
if (plat == "Windows"):
cmd_list.append(cmd_header + ' ' + cmd_sep + ' ' + cmd_status)
cmd_list.append("call " + cmd_execute + ' ' + cmd_sep + ' ' + cmd_status)
else:
# cmd_list.append(cmd_header + ' ' + cmd_sep + ' ' + cmd_status)
cmd_list.append("./" + cmd_execute + ' ' + cmd_sep + ' ' + cmd_status)
cmd_list.append(cmd_exit)
if (debugswitch == '1'):
print("CMD: call execute file: %s" % cmd_execute)
for cmd in cmd_list:
print(cmd)
print("---------------------------")
# print (cmd_list)
return cmd_list, name
# .bat .sh, windows not compatibility, unix only [ignore]
def createCmdList01(list0):
cmd_list = []
name = uuid.uuid4().__str__()
name = name.split('-')[0]
plat = getplatform()
if (plat == "Windows"):
cmd_status = "echo pymake-command-status:%errorlevel%"
cmd_sep = '&'
cmd_header = "@echo off"
cmd_exit = 'exit /b %ERRORLEVEL%'
# window close echo, close promot
cmd_list.append(cmd_header + ' ' + cmd_sep + ' ' + cmd_status)
cmd_list.append("call %s_effect.bat" % name + ' ' + cmd_sep + ' ' + cmd_status)
else:
cmd_status = "echo pymake-command-status:$?"
cmd_sep = ';'
cmd_exit = 'exit $?'
cmd_header = "#!/usr/bin/env bash"
cmd_list.append("source %s_effect.sh" % name + ' ' + cmd_sep + ' ' + cmd_status)
for cmd in list0:
cmd_list.append(cmd + ' ' + cmd_sep + ' ' + cmd_status)
# append exit 0
cmd_list.append(cmd_exit)
# print( cmd_list )
return cmd_list, name
# use env exec command
# cc exec
# .bat .sh, windows, unix
def createCmdList02(env_name=None, local=True, list0=[], params0=[]):
cmd_list = []
if (env_name is None):
env_name = rawconfig['environ']['current']
# print(env_name)
name = uuid.uuid4().__str__()
name = name.split('-')[0]
# print (name)
plat = getplatform()
if (plat == "Windows"):
cmd_status = "echo pymake-command-status:%ERRORLEVEL%"
cmd_sep = '&'
cmd_codec = "ansi"
if (getplatform_release() == "XP"):
cmd_codec = None
# but windows, it is \r\n, python helpping me?
cmd_return = "\n"
cmd_exit = 'exit /b %ERRORLEVEL%'
cmd_suffix = ".bat"
cmd_header = "@echo off"
cmd_call = "call "
# window close echo, close promot
cmd_list.append(cmd_header)
# os.system("type env_effect.bat > cmd_exec.bat")
cmd_list.append("call %s_effect.bat" % name)
else:
cmd_status = "echo pymake-command-status:$?"
cmd_sep = ';'
cmd_suffix = ".sh"
cmd_exit = 'exit $?'
cmd_codec = "utf8"
cmd_return = "\n"
cmd_header = "#!/usr/bin/env bash"
cmd_call = "./"
cmd_list.append(cmd_header)
cmd_list.append("source %s_effect.sh" % name)
# print(params0)
params_string = ""
for param in params0:
# print(param)
if (str(param).__contains__(' ')):
params_string += '"' + param + '"' + ' '
else:
params_string += param + ' '
# print(params_string)
if (local is True):
for cmd in list0:
cmd_list.append(cmd)
else:
for cmd in list0:
if (str(cmd).__contains__(' ')):
pycmd = which_command(env_name, str(cmd))
# print(str(cmd))
# print(Fore.RED + "which command:", pycmd)
if (pycmd is not None and os.path.isfile(pycmd)):
cmd_list.append('"' + cmd + '"' + ' ' + params_string)
else:
cmd_list.append(cmd + ' ' + params_string)
else:
cmd_list.append(cmd + ' ' + params_string)
# append exit 0
cmd_list.append(cmd_exit)
# print( cmd_list )
cmd_execute = name + "_exec" + cmd_suffix
with open(cmd_execute, "w", encoding=cmd_codec) as f:
for line in cmd_list:
f.write(line + cmd_return)
# print(cmd_execute)
if (debugswitch == '1'):
print("IN: execute file: %s" % cmd_execute)
for cmd in cmd_list:
print(cmd)
print("---------------------------")
if (plat == "Windows"):
""
else:
os.system("chmod +x " + cmd_execute)
cmd_list.clear()
if (plat == "Windows"):
cmd_list.append(cmd_header + ' ' + cmd_sep + ' ' + cmd_status)
# cmd_list.append("call " + cmd_execute + cmd_sep + ' ' + cmd_status)
cmd_list.append("call " + cmd_execute + ' ' + params_string + cmd_sep + ' ' + cmd_status)
else:
# cmd_list.append(cmd_header + ' ' + cmd_sep + ' ' + cmd_status)
# cmd_list.append("./" + cmd_execute + cmd_sep + ' ' + cmd_status)
cmd_list.append("./" + cmd_execute + ' ' + params_string + cmd_sep + ' ' + cmd_status)
cmd_list.append(cmd_exit)
# print (cmd_list)
if (debugswitch == '1'):
print("CMD: call execute file: %s" % cmd_execute)
for cmd in cmd_list:
print(cmd)
print("---------------------------")
return cmd_list, name
# use env exec-with-params/execvp/ccvp command
# exec-with-params ccvp execvp
# here [False]
# there [False]
# default [False]
# initialize
# ===============================================================================================
# pymake append function
# -------------------------
def env_export2(dict0=None, env_name=None, file_name=None):
if (dict0 is None):
return "", "", ""
# select env
current_var = rawconfig['environ']['current']
if (env_name is not None):
current_var = env_name
plat = getplatform()
if (plat == "Windows"):
cmd_suffix = ".bat"
cmd_codec = "ansi"
if (getplatform_release() == "XP"):
cmd_codec = None
cmd_return = "\n"
cmd_header = "@echo off" + cmd_return
env_set = 'set '
else:
cmd_suffix = ".sh"
cmd_codec = "utf8"
cmd_return = "\n"
cmd_header = "#!/usr/bin/env bash" + cmd_return
env_set = 'export '
# export effect env
cmd_effect = 'env'
if (file_name is not None):
cmd_effect = file_name
cmd_effect += '_effect' + cmd_suffix
lines = ""
# +system
if (args['-s'] or args['--system'] is True):
# export path
# print(envcustomlistrawpaths)
for (key) in pymakesystemenviron['PATH'].split(os.path.pathsep):
if (plat == "Windows"):
lines += (env_set + 'PATH=' + key + os.path.pathsep + '%PATH%' + cmd_return)
else:
lines += (env_set + 'PATH="' + key + '"' + os.path.pathsep + '$PATH' + cmd_return)
# export var
for (key, value) in pymakesystemenviron.items():
if (key == 'path+'):
continue
if (str(key).lower() == "path"):
continue
if (plat == "Windows"):
lines += (env_set + key + '=' + value + cmd_return)
else:
lines += (env_set + key + '=\"' + value + '\"' + cmd_return)
else:
''
# +local
if (args['-l'] or args['--local'] is True):
# export path
for (key) in localenv['path+']:
if (plat == "Windows"):
lines += (env_set + 'PATH=' + key + os.path.pathsep + '%PATH%' + cmd_return)
else:
lines += (env_set + 'PATH="' + key + '"' + os.path.pathsep + '$PATH' + cmd_return)
# export var
for (key, value) in localenv.items():
if (key == 'path+'):
continue
if (plat == "Windows"):
lines += (env_set + key + '=' + value + cmd_return)
else:
lines += (env_set + key + '=\"' + value + '\"' + cmd_return)
else:
''
# +custom
if (args['-c'] or args['--custom'] is True):
# export path
# print(envcustomlistrawpaths)
for (key) in envcustomlistrawpaths:
if (plat == "Windows"):
lines += (env_set + 'PATH=' + key + os.path.pathsep + '%PATH%' + cmd_return)
else:
lines += (env_set + 'PATH="' + key + '"' + os.path.pathsep + '$PATH' + cmd_return)
# export var
for (key, value) in envcustomlistrawvars.items():
if (key == 'path+'):
continue
if (plat == "Windows"):
lines += (env_set + key + '=' + value + cmd_return)
else:
lines += (env_set + key + '=\"' + value + '\"' + cmd_return)
else:
''
# export path
for (key) in dict0["path+"]:
if (plat == "Windows"):
lines += (env_set + 'PATH=' + key + os.path.pathsep + '%PATH%' + cmd_return)
else:
lines += (env_set + 'PATH="' + key + '"' + os.path.pathsep + '$PATH' + cmd_return)
# export var
for (key, value) in dict0.items():
if (key == 'path+'):
continue
if (plat == "Windows"):
lines += (env_set + key + '=' + value + cmd_return)
else:
lines += (env_set + key + '=\"' + value + '\"' + cmd_return)
with open(cmd_effect, 'w', encoding=cmd_codec) as f:
f.write(cmd_header)
f.write(lines)
# export unset env
cmd_unset = 'env'
if (file_name is not None):
cmd_unset = file_name
cmd_unset += '_unset' + cmd_suffix
lines = ""
# +system
if (args['-s'] or args['--system'] is True):
# export unset path
for (key) in pymakesystemenviron['PATH'].split(os.path.pathsep):
if (plat == "Windows"):
lines += (env_set + 'PATH=%PATH:' + key + ';=%' + cmd_return)
else:
lines += (env_set + 'PATH=$(' + 'echo ${PATH//' + key.replace('/', '\/') + ':/})' + cmd_return)
# export unset var
for (key, value) in pymakesystemenviron.items():
if (key == 'path+'):
continue
if (str(key).lower() == "path"):
continue
if (plat == "Windows"):
lines += ('set ' + key + '=' + cmd_return)
else:
lines += ('unset ' + key + cmd_return)
else:
''
# +local
if (args['-l'] or args['--local'] is True):
# export unset path
for (key) in localenv['path+']:
if (plat == "Windows"):
lines += (env_set + 'PATH=%PATH:' + key + ';=%' + cmd_return)
else:
lines += (env_set + 'PATH=$(' + 'echo ${PATH//' + key.replace('/', '\/') + ':/})' + cmd_return)
# export unset var
for (key, value) in localenv.items():
if (key == 'path+'):
continue
if (plat == "Windows"):
lines += ('set ' + key + '=' + cmd_return)
else:
lines += ('unset ' + key + cmd_return)
else:
''
# +custom
if (args['-c'] or args['--custom'] is True):
# export unset path
for (key) in envcustomlistrawpaths:
if (plat == "Windows"):
lines += (env_set + 'PATH=%PATH:' + key + ';=%' + cmd_return)
else:
lines += (env_set + 'PATH=$(' + 'echo ${PATH//' + key.replace('/', '\/') + ':/})' + cmd_return)
# export unset var
for (key, value) in envcustomlistrawvars.items():
if (key == 'path+'):
continue
if (plat == "Windows"):
lines += ('set ' + key + '=' + cmd_return)
else:
lines += ('unset ' + key + cmd_return)
else:
''
# export unset path
for (key) in dict0["path+"]:
if (plat == "Windows"):
lines += (env_set + 'PATH=%PATH:' + key + ';=%' + cmd_return)
else:
lines += (env_set + 'PATH=$(' + 'echo ${PATH//' + key.replace('/', '\/') + ':/})' + cmd_return)
# export unset var
for (key, value) in dict0.items():
if (key == 'path+'):
continue
if (plat == "Windows"):
lines += ('set ' + key + '=' + cmd_return)
else:
lines += ('unset ' + key + cmd_return)
with open(cmd_unset, 'w', encoding=cmd_codec) as f:
f.write(cmd_header)
f.write(lines)
if (plat == "Windows"):
""
else:
os.system("chmod +x " + cmd_effect)
os.system("chmod +x " + cmd_unset)
# return file name
return current_var, cmd_effect, cmd_unset
# ===============================================================================================
# pyautomake work flow
# -------------------------
# ===============================================================================================
# pyautomake command work flow
# -------------------------
# print(args['-r'], args['--raw'])
# print(args)
return
if __name__ == '__main__':
ret = main_function()
if(ret == None):
ret = 0
os._exit(ret)
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/drabel/PyAutoMake.git
git@gitee.com:drabel/PyAutoMake.git
drabel
PyAutoMake
Multi-building Technology (PyAutoMake)
master

搜索帮助