Skip to content

Commit b9cfcd8

Browse files
committed
travis: check python files with pycodestyle and pyflakes
Signed-off-by: Jingru Wang <jingru@synopsys.com>
1 parent cb9beea commit b9cfcd8

File tree

3 files changed

+39
-54
lines changed

3 files changed

+39
-54
lines changed

.ci/build.py

Lines changed: 33 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from xlsxwriter.workbook import Workbook
1313
from xlsxwriter.worksheet import Worksheet
1414
from xlsxwriter.worksheet import convert_cell_args
15-
from embarc_tools.download_manager import cd, getcwd, delete_dir_files
15+
from embarc_tools.download_manager import cd, delete_dir_files
1616
from embarc_tools.osp import osp
1717
from embarc_tools.builder import build
1818
import collections
@@ -31,6 +31,7 @@
3131

3232
MakefileNames = ['Makefile', 'makefile', 'GNUMakefile']
3333

34+
3435
def excel_string_width(str):
3536
string_width = len(str)
3637
if string_width == 0:
@@ -69,7 +70,6 @@ def close(self):
6970
return super(MyWorkbook, self).close()
7071

7172

72-
7373
def get_cache(osp_path):
7474
cache = ".cache/result"
7575
cache_path = os.path.join(osp_path, cache)
@@ -78,7 +78,6 @@ def get_cache(osp_path):
7878
return cache_path
7979

8080

81-
8281
def generate_json_file(data, path):
8382
with open(path, "w") as f:
8483
json.dump(data, f, indent=4)
@@ -104,7 +103,6 @@ def result_json_artifacts(osp_path, result, file=None):
104103
generate_json_file(result, file_path)
105104

106105

107-
108106
def takeApp(elem):
109107
return elem["app_path"]
110108

@@ -118,22 +116,21 @@ def dict_to_excel(datas):
118116
filename = toolchain_config + ".xlsx"
119117
workbook = MyWorkbook(filename)
120118
sheet_dict = dict()
121-
merge_format = workbook.add_format({'bold': True, "align": "center","valign": "vcenter"})
122-
119+
merge_format = workbook.add_format({'bold': True, "align": "center", "valign": "vcenter"})
123120

124-
for build in results:
125-
config = build.get("config", None)
121+
for build_result in results:
122+
config = build_result.get("config", None)
126123
if config:
127124
board_config = config["BOARD"] + "_" + config["BD_VER"]
128125
if not results_board_config.get(board_config, None):
129-
results_board_config[board_config] = [build]
126+
results_board_config[board_config] = [build_result]
130127
else:
131-
results_board_config[board_config].append(build)
128+
results_board_config[board_config].append(build_result)
132129
for board_config in results_board_config:
133130
worksheet = workbook.add_worksheet(board_config)
134131
sheet_dict[board_config] = worksheet
135-
for board_config, build in results_board_config.items():
136-
build.sort(key=takeApp)
132+
for board_config, build_result in results_board_config.items():
133+
build_result.sort(key=takeApp)
137134
worksheet = sheet_dict[board_config]
138135
worksheet.merge_range(0, 0, 1, 0, "APP", merge_format)
139136
worksheet.set_column(0, 7, 10)
@@ -153,7 +150,7 @@ def dict_to_excel(datas):
153150
same_app = dict()
154151
failed_count = dict()
155152
same_app = collections.OrderedDict()
156-
for app_build in build:
153+
for app_build in build_result:
157154
app_name = app_build["app_path"]
158155
if same_app.get(app_name, None):
159156
same_app[app_name] = same_app[app_name] + 1
@@ -162,7 +159,7 @@ def dict_to_excel(datas):
162159
same_app[app_name] = 1
163160
failed_count[app_name] = 0
164161

165-
cell_format = workbook.add_format({"align": "center","valign": "vcenter"})
162+
cell_format = workbook.add_format({"align": "center", "valign": "vcenter"})
166163
failed = "No"
167164
if not app_build["code"]:
168165
failed = "Yes"
@@ -181,8 +178,8 @@ def dict_to_excel(datas):
181178
row += 1
182179
s = 2
183180
for app, value in same_app.items():
184-
merge_format_app = workbook.add_format({"align": "center","valign": "vcenter"})
185-
if value==failed_count[app]:
181+
merge_format_app = workbook.add_format({"align": "center", "valign": "vcenter"})
182+
if value == failed_count[app]:
186183
if not failed_summarize.get(toolchain_config, None):
187184
failed_summarize[toolchain_config] = dict()
188185
if not failed_summarize[toolchain_config].get(board_config, None):
@@ -196,28 +193,27 @@ def dict_to_excel(datas):
196193
return failed_summarize
197194

198195

199-
200196
def result_excel_artifacts(osp_path):
201197
cache_path = get_cache(osp_path)
202198
files = os.listdir(cache_path)
203199
datas = dict()
204200
failed_summarize = None
205201
for file in files:
206202
filename, filesuffix = os.path.splitext(file)
207-
if not filesuffix == ".json" or filename =="results":
203+
if not filesuffix == ".json" or filename == "results":
208204
continue
209205
file_path = os.path.join(cache_path, file)
210206
with open(file_path, "r") as f:
211207
results = json.load(f)
212208
for app, build_status in results.items():
213-
for build in build_status:
214-
config = build.get("config", None)
209+
for build_result in build_status:
210+
config = build_result.get("config", None)
215211
if config:
216212
toolchain_config = config["TOOLCHAIN"] + "_" + config["TOOLCHAIN_VER"]
217213
if not datas.get(toolchain_config, None):
218-
datas[toolchain_config] = [build]
214+
datas[toolchain_config] = [build_result]
219215
else:
220-
datas[toolchain_config].append(build)
216+
datas[toolchain_config].append(build_result)
221217
else:
222218
continue
223219
f.close()
@@ -228,7 +224,6 @@ def result_excel_artifacts(osp_path):
228224
result_json_artifacts(osp_path, failed_summarize, file="failed_results")
229225

230226

231-
232227
class TailRecurseException(Exception):
233228
def __init__(self, args, kwargs):
234229
self.args = args
@@ -251,7 +246,6 @@ def func(*args, **kwargs):
251246
return func
252247

253248

254-
255249
def parse_config(config):
256250
make_configs = config
257251
core_key = "CUR_CORE"
@@ -270,7 +264,6 @@ def parse_config(config):
270264
delete_dir_files(json_path, dir=True)
271265
embarc_osp = osp.OSP()
272266

273-
274267
core_key = "CORE" if "CORE" in make_configs else "CUR_CORE"
275268
if "PARALLEL" in make_configs and make_configs["PARALLEL"] is not None:
276269
parallel = make_configs["PARALLEL"]
@@ -290,7 +283,6 @@ def parse_config(config):
290283
board_input = make_configs["BOARD"]
291284
support_boards = embarc_osp.supported_boards(osp_root)
292285

293-
294286
boards = [board_input] if board_input in support_boards else support_boards
295287
if "BD_VER" in make_configs and make_configs["BD_VER"] is not None:
296288
bd_ver_input = make_configs["BD_VER"]
@@ -310,13 +302,12 @@ def parse_config(config):
310302
current_configs["core_key"] = core_key
311303
current_configs["parallel"] = parallel
312304
current_configs["osp_root"] = osp_root
313-
current_configs["toolchain"] = {"name":toolchain, "version": toolchain_ver}
305+
current_configs["toolchain"] = {"name": toolchain, "version": toolchain_ver}
314306
current_configs["EXPECTED"] = expected_file
315307
current_configs["COVERITY"] = coverity
316308
return current_configs
317309

318310

319-
320311
def is_embarc_makefile(makefile_path):
321312
with open(makefile_path) as f:
322313
embarc_root = False
@@ -332,7 +323,6 @@ def is_embarc_makefile(makefile_path):
332323
return False
333324

334325

335-
336326
def get_config(config):
337327
make_configs = dict()
338328
if type(config) == list:
@@ -347,7 +337,6 @@ def get_config(config):
347337
return make_configs
348338

349339

350-
351340
def get_expected_result(expected_file, app_path, board, bd_ver):
352341
result = False
353342
filesuffix = os.path.splitext(expected_file)[1]
@@ -372,21 +361,20 @@ def get_expected_result(expected_file, app_path, board, bd_ver):
372361
return result
373362

374363

375-
376364
def send_pull_request_comment(columns, results):
377365
job = os.environ.get("NAME")
378366
pr_number = os.environ.get("TRAVIS_PULL_REQUEST")
379367
if all([job, pr_number]):
380368
comment_job = "## " + job + "\n"
381-
if len(results)>0:
369+
if len(results) > 0:
382370
head = "|".join(columns) + "\n"
383-
table_format = "|".join(["---"]*len(columns)) + "\n"
384-
table_head =head +table_format
371+
table_format = "|".join(["---"]*len(columns)) + "\n"
372+
table_head = head + table_format
385373
comments = ""
386374
comment = ""
387375
for result in results:
388376
for k in result:
389-
comment += (k.replace(Fore.RED, "")).replace("\n", "<br>") +" |"
377+
comment += (k.replace(Fore.RED, "")).replace("\n", "<br>") + " |"
390378
comment = comment.rstrip("|") + "\n"
391379
comments += comment
392380
comment_on_pull_request(comment_job + table_head + comments)
@@ -397,7 +385,7 @@ def send_pull_request_comment(columns, results):
397385

398386

399387
def show_results(results, expected=None):
400-
columns = [ 'TOOLCHAIN',"TOOLCHAIN_VER", 'APP', 'CONF', 'PASS']
388+
columns = ['TOOLCHAIN', "TOOLCHAIN_VER", 'APP', 'CONF', 'PASS']
401389
failed_pt = PrettyTable(columns)
402390
failed_results = []
403391
success_results = []
@@ -476,7 +464,6 @@ def build_result_combine(results=None, formal_result=None):
476464
return formal_result
477465

478466

479-
480467
def get_apps(path):
481468
result = []
482469
for root, dirs, files in os.walk(path):
@@ -506,7 +493,6 @@ def build_result_combine_tail(results):
506493
return results_list
507494

508495

509-
510496
def get_applications(config):
511497
app_paths = None
512498
if "EXAMPLES" in config and config["EXAMPLES"]:
@@ -519,7 +505,6 @@ def get_applications(config):
519505
return app_paths
520506

521507

522-
523508
def startBuild(app, config, builder):
524509

525510
for opt in build.BUILD_OPTION_NAMES:
@@ -533,15 +518,14 @@ def startBuild(app, config, builder):
533518

534519
# builder.build_target(app, target=str("clean"), parallel=config["PARALLEL"])
535520
if os.environ.get("COVERITY", None) == "true":
536-
build_status = builder.build_target(app, target=str("all"), parallel=config["PARALLEL"], coverity=True, silent = True) # builder.get_build_size(app, parallel=config["PARALLEL"], silent = True)
537-
521+
build_status = builder.build_target(app, target=str("all"), parallel=config["PARALLEL"], coverity=True, silent=True)
538522
else:
539-
build_status = builder.get_build_size(app, parallel=config["PARALLEL"], silent = True)
523+
build_status = builder.get_build_size(app, parallel=config["PARALLEL"], silent=True)
540524

541525
board = builder.buildopts.get("BOARD")
542526
bd_ver = builder.buildopts.get("BD_VER")
543527
core = builder.buildopts.get("CUR_CORE")
544-
build_conf = board + "_" + bd_ver + "_" + core
528+
build_conf = board + "_" + bd_ver + "_" + core
545529

546530
build_status["commit_sha"] = os.environ.get("CI_COMMIT_SHA") or os.environ.get("TRAVIS_COMMIT")
547531
build_status["JOB"] = os.environ.get("CI_JOB_NAME") or os.environ.get("NAME")
@@ -550,7 +534,6 @@ def startBuild(app, config, builder):
550534
return build_status
551535

552536

553-
554537
def BuildApp(app, config):
555538

556539
BuildOptions = config["make_options"]
@@ -581,7 +564,7 @@ def BuildApp(app, config):
581564
CurrentBuildConfig[core_key] = cur_core
582565
CurrentBuildConfig["TOOLCHAIN"] = toolchain["name"]
583566
CurrentBuildConfig["TOOLCHAIN_VER"] = toolchain["version"]
584-
CurrentBuildConfig["PARALLEL"] = None if parallel=="" else parallel
567+
CurrentBuildConfig["PARALLEL"] = None if parallel == "" else parallel
585568

586569
build_status = startBuild(app, CurrentBuildConfig, builder)
587570
if not app_build_status.get(app, None):
@@ -616,12 +599,10 @@ def BuildApp(app, config):
616599
return app_build_results, expected_different, app_build_status
617600

618601

619-
620-
621602
def comment_on_pull_request(comment):
622603

623604
pr_number = os.environ.get("TRAVIS_PULL_REQUEST")
624-
slug = os.environ.get("TRAVIS_REPO_SLUG")
605+
slug = os.environ.get("TRAVIS_REPO_SLUG")
625606
token = os.environ.get("GH_TOKEN")
626607
request_config = [pr_number, slug, token, comment]
627608
for i in range(len(request_config)):
@@ -636,15 +617,14 @@ def comment_on_pull_request(comment):
636617
return response.json()
637618

638619

639-
640620
def get_options_parser():
641621
configs = dict()
642622
toolchainlist = ["gnu", "mw"]
643623
boardlist = ["emsk", "nsim", "axs", "hsdk"]
644624
parser = argparse.ArgumentParser()
645625
parser.add_argument("--osp_root", dest="osp_root", default=".", help=("the path of embarc_osp"), metavar="OSP_ROOT")
646-
parser.add_argument("--toolchain", dest="toolchain", default=None, help=("build using the given TOOLCHAIN (%s)" %', '.join(toolchainlist)), metavar="TOOLCHAIN")
647-
parser.add_argument("--board", dest="board", default=None, help=("build using the given BOARD (%s)" %', '.join(boardlist)), metavar="BOARD")
626+
parser.add_argument("--toolchain", dest="toolchain", default=None, help=("build using the given TOOLCHAIN (%s)" % ', '.join(toolchainlist)), metavar="TOOLCHAIN")
627+
parser.add_argument("--board", dest="board", default=None, help=("build using the given BOARD (%s)" % ', '.join(boardlist)), metavar="BOARD")
648628
parser.add_argument("--bd_ver", dest="bd_ver", default=None, help=("build using the given BOARD VERSION"), metavar="BOARD VERSION")
649629
parser.add_argument("--core", dest="cur_core", default=None, help=("build using the given core"), metavar="CUR_CORE")
650630
parser.add_argument("--toolchain_ver", dest="toolchain_ver", default=None, help=("build using the given toolchian verion"), metavar="TOOLCHAIN_VER")
@@ -716,11 +696,12 @@ def main(config):
716696
comment_on_pull_request(comment)
717697
sys.exit(1)
718698

699+
719700
if __name__ == '__main__':
720701

721702
cwd_path = os.getcwd()
722703
osp_path = os.path.dirname(cwd_path)
723704
make_config = get_config(sys.argv[1:])
724705
with cd(osp_path):
725706
main(make_config)
726-
print("The end")
707+
print("The end")

.ci/toolchain.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ def is_number(s):
1313
return True
1414
except ValueError:
1515
pass
16-
16+
1717
try:
1818
import unicodedata
1919
unicodedata.numeric(s)
2020
return True
2121
except (TypeError, ValueError):
2222
pass
23-
23+
2424
return False
2525

2626
def store_gnu_toolchain(version, path):

board/iotdk/configs/core_configs.mk

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
CORE_TCF_DIR = $(BOARD_CORE_DIR)/tcf
33
CORE_CONFIG_MK = $(BOARD_CORE_DIR)/core_config.mk
44

5+
## Current Supported Core Configurations
6+
CORE_TCF_FILES = $(wildcard $(CORE_TCF_DIR)/*.tcf)
7+
SUPPORTED_CORES := $(basename $(notdir $(CORE_TCF_FILES)))
8+
59
#### core_config.mk existed in sub version folder of the board
610
COMMON_COMPILE_PREREQUISITES += $(CORE_CONFIG_MK)
711
include $(CORE_CONFIG_MK)

0 commit comments

Comments
 (0)