Added test for makefile generation running the script from system.
This commit is contained in:
parent
400476f3fb
commit
32310ba1fa
|
|
@ -360,14 +360,14 @@ def gen_global_targets(f, pre_targets, out_targets, type):
|
|||
return extra_targets
|
||||
|
||||
|
||||
def generate_makefile(makefile, cfg_file, outputs):
|
||||
def generate_makefile(makefile, cfg_file, outputs, kibot_sys=False):
|
||||
cfg_file = os.path.relpath(cfg_file)
|
||||
logger.info('- Creating makefile `{}` from `{}`'.format(makefile, cfg_file))
|
||||
with open(makefile, 'wt') as f:
|
||||
f.write('#!/usr/bin/make\n')
|
||||
f.write('# Automatically generated by KiBot from `{}`\n'.format(cfg_file))
|
||||
fname = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'src', 'kibot'))
|
||||
if not os.path.isfile(fname):
|
||||
if kibot_sys or not os.path.isfile(fname):
|
||||
fname = 'kibot'
|
||||
f.write('KIBOT={}\n'.format(fname))
|
||||
dbg = ''
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ from kibot.layer import Layer
|
|||
from kibot.pre_base import BasePreFlight
|
||||
from kibot.out_base import BaseOutput
|
||||
from kibot.gs import GS
|
||||
from kibot.kiplot import load_actions, _import, load_board, search_as_plugin
|
||||
from kibot.kiplot import load_actions, _import, load_board, search_as_plugin, generate_makefile
|
||||
from kibot.registrable import RegOutput, RegFilter
|
||||
from kibot.misc import (MISSING_TOOL, WRONG_INSTALL, BOM_ERROR, DRC_ERROR, ERC_ERROR, PDF_PCB_PRINT, CMD_PCBNEW_PRINT_LAYERS,
|
||||
KICAD2STEP_ERR)
|
||||
|
|
@ -317,3 +317,14 @@ def test_layer_no_id():
|
|||
la.description = 'Top'
|
||||
la.suffix = 'F_Cu'
|
||||
assert str(la) == "F.Cu ('Top' F_Cu)"
|
||||
|
||||
|
||||
def test_makefile_kibot_sys(test_dir):
|
||||
ctx = context.TestContext(test_dir, 'test_makefile_kibot_sys', 'test_v5', 'empty_zip', '')
|
||||
GS.sch_file = 'foo.sch'
|
||||
GS.pcb_file = 'bar.kicad_pcb'
|
||||
GS.out_dir = ctx.get_out_path('')
|
||||
with context.cover_it(cov):
|
||||
generate_makefile(ctx.get_out_path('Makefile'), 'pp', [], kibot_sys=True)
|
||||
ctx.search_in_file('Makefile', ['KIBOT=kibot'])
|
||||
ctx.clean_up()
|
||||
|
|
|
|||
Loading…
Reference in New Issue