'''
Created on 19 lut 2020

@author: fpawlak
'''

from Classes.ProjectCompiller import ProjectCompiller
from Classes.CodesysLibsScriptsException import CodesysLibsScriptsException
from Classes.Config import Config
from Classes.TemporaryFiles import TempDir
from Classes.LibrariesInstaller import LibrariesInstaller
import sys
import os
import traceback

config = Config(os.path.dirname(__file__) + '\\config.cfg');
tempDir = TempDir()
print(tempDir)

try:
    with TempDir() as tempDir:
        compiler = ProjectCompiller(projects)
        lib = compiler.compile(config, tempDir)
        
        installer = LibrariesInstaller(librarymanager)
        repository = installer.getRepository(config.developRepository)
        installer.installLib(repository, tempDir + '\\' + lib.path)
        
except CodesysLibsScriptsException as e:
    print(e.mainException)
    traceback.print_exc()
    sys.exit(-1)