-
Notifications
You must be signed in to change notification settings - Fork 233
/
autoload.py
80 lines (63 loc) · 2.69 KB
/
autoload.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import os
import sys
import shutil
from javax.swing import JPanel, JLabel , JTextField, BoxLayout
from java.awt import BorderLayout
from shutil import copyfile
log.setShowOutput(False)
# log.info("Java version: " + System.getProperty("java.version"))
# log.info("Jython version: " + sys.version)
# log.info("Script path:" + os.path.dirname(os.path.abspath("__file__")))
# log.info("Autoload SYS_PATH:" + '\n'.join(sys.path))
for key in sys.modules.keys():
if "mpconfig" in key:
del sys.modules[key]
from scripts.mpconfig.mpconfig import MPConfig
from scripts.mpconfig import defconfig
from scripts.mpconfig import genconfig
from scripts import addpmecchead
def mplab_configure_Kconfig(confName):
global app
global project_dir
if os.getcwd() != project_dir:
os.chdir(project_dir)
# log.info("mplab_configure_Kconfig: " + confName)
dot_config_file = os.path.join(project_dir, confName + ".config")
if not os.path.isfile(dot_config_file):
# Create empty default.config file if it does not exist
open(dot_config_file, 'a').close()
kconfig_file = os.path.join(os.getcwd(), "Kconfig")
# Set up GUI
mpconfigPanel = JPanel()
if os.path.isfile(kconfig_file):
app = MPConfig(kconfig_file, dot_config_file, log)
mpconfigPanel = app.getPane()
rootPanel = JPanel()
rootPanel.setLayout(BorderLayout())
rootPanel.add(mpconfigPanel, BorderLayout.CENTER)
return rootPanel
def save_mplab_configure_Kconfig(confName):
global app
global project_dir
# log.info("save_mplab_configure_Kconfig: " + confName)
try:
dot_config_file = os.path.join(project_dir, confName + ".config")
app.writeConfig(dot_config_file)
if confName == active_config:
if os.path.isdir(os.path.join(project_dir, "config", "at91bootstrap-config")):
shutil.rmtree(os.path.join(project_dir, "config", "at91bootstrap-config"))
os.makedirs(os.path.join(project_dir, "config", "at91bootstrap-config"))
defconfig.main([dot_config_file])
genconfig.main(["--sync-deps", os.path.join("config", "at91bootstrap-config"), "--header-path", os.path.join("config", "at91bootstrap-config", "autoconf.h")])
shutil.copyfile(dot_config_file, os.path.join(project_dir, ".config"))
except:
pass
def onload(ide):
# Load any stored settings
global project_dir
project_dir = ide.expandProjectMacros("${ProjectName}", "${ProjectDir}")
def on_project_build(e):
global project_dir
dot_config_path = os.path.join(project_dir, ".config")
binaries_path = os.path.join(project_dir, "build", "binaries")
addpmecchead.pmecchead(dot_config_path, binaries_path)