# Path: progSpec.py
# def cdlog(lvl, mesg):
#     global MaxLogLevelToShow
#     global lastLogMesgs
#     global highestLvl
#     highestLvl=lvl
#     resizeLogArray(lvl)
#     lastLogMesgs[lvl]=mesg
#     for i in range(highestLvl+1, len(lastLogMesgs)):
#         lastLogMesgs[i]=''
#     if(lvl<=MaxLogLevelToShow):
#         if(lvl==0): print('')
#         printAtLvl(lvl, mesg, '|    ')
# 
# def cdErr(mesg):
#     global lastLogMesgs
#     global highestLvl
#     highestLvl+=1
#     lastLogMesgs[highestLvl]="\n\nError: "+mesg
#     exit(1)


import progSpec
import os
import subprocess
import buildAndroid
import buildMac
import errno
import shutil
import checkSys
import environmentMngr as emgr
    import urllib.request
from progSpec import cdlog, cdErr
from pathlib import Path
    from git import Repo
                        else:
                            emgr.getPackageManagerCMD(toolName, packageManager)
                        runCmdStreaming(actualBuildCmd, downloadedFolder)

            if 'installFiles' in buildCmdMap:
                installfileList = buildCmdMap['installFiles'][1]
                # ~ installFiles = progSpec.extractListFromTagList(installfileList)
                # ~ print("    DATA:", str(installFiles)[:100])
                LibsFolder = os.path.join(packageDirectory, packageName, 'INSTALL').replace("\\","/")
                makeDirs(LibsFolder)
                importantFolders[packageName+'@Install'] = LibsFolder
                importantFolders[packageName] = packageDirectory + '/' + packageName + '/' + packageName
                includeFolders += "     '"+LibsFolder+"',\n"
                libFolders     += "     '"+LibsFolder+"',\n"
                for filenameX in installfileList:
                    filename = downloadedFolder+'/'+filenameX[0][0][1:-1]
                    cdlog(1, "Install: "+filename)
                    copyRecursive(filename, LibsFolder)

    return [includeFolders, libFolders]


def gitClone(cloneUrl, packageName, packageDirectory):
    checkSys.CheckPipModules({'GitPython':'3.1'})
    packagePath = packageDirectory + '/' + packageName + '/' + packageName
    checkRepo = os.path.isdir(packagePath)
    if not checkRepo:
        try:
            urllib.request.urlopen(cloneUrl)
        except (urllib.error.URLError, urllib.error.HTTPError):

# Path: progSpec.py
# def cdlog(lvl, mesg):
#     global MaxLogLevelToShow
#     global lastLogMesgs
#     global highestLvl
#     highestLvl=lvl
#     resizeLogArray(lvl)
#     lastLogMesgs[lvl]=mesg
#     for i in range(highestLvl+1, len(lastLogMesgs)):
#         lastLogMesgs[i]=''
#     if(lvl<=MaxLogLevelToShow):
#         if(lvl==0): print('')
#         printAtLvl(lvl, mesg, '|    ')
# 
# def cdErr(mesg):
#     global lastLogMesgs
#     global highestLvl
#     highestLvl+=1
#     lastLogMesgs[highestLvl]="\n\nError: "+mesg
#     exit(1)


# Path: buildDog.py
import progSpec
import os
import subprocess
import buildAndroid
import buildMac
import errno
import shutil
import checkSys
import environmentMngr as emgr
    import urllib.request
from progSpec import cdlog, cdErr
from pathlib import Path
    from git import Repo

                        else:
                            emgr.getPackageManagerCMD(toolName, packageManager)
                        runCmdStreaming(actualBuildCmd, downloadedFolder)

            if 'installFiles' in buildCmdMap:
                installfileList = buildCmdMap['installFiles'][1]
                # ~ installFiles = progSpec.extractListFromTagList(installfileList)
                # ~ print("    DATA:", str(installFiles)[:100])
                LibsFolder = os.path.join(packageDirectory, packageName, 'INSTALL').replace("\\","/")
                makeDirs(LibsFolder)
                importantFolders[packageName+'@Install'] = LibsFolder
                importantFolders[packageName] = packageDirectory + '/' + packageName + '/' + packageName
                includeFolders += "     '"+LibsFolder+"',\n"
                libFolders     += "     '"+LibsFolder+"',\n"
                for filenameX in installfileList:
                    filename = downloadedFolder+'/'+filenameX[0][0][1:-1]
                    cdlog(1, "Install: "+filename)
                    copyRecursive(filename, LibsFolder)

    return [includeFolders, libFolders]


def gitClone(cloneUrl, packageName, packageDirectory):
    checkSys.CheckPipModules({'GitPython':'3.1'})
    packagePath = packageDirectory + '/' + packageName + '/' + packageName
    checkRepo = os.path.isdir(packagePath)
    if not checkRepo:
        try:
            urllib.request.urlopen(cloneUrl)
        except (urllib.error.URLError, urllib.error.HTTPError):

            cdErr("URL not found: " + cloneUrl)