mirror of
https://github.com/espruino/Espruino.git
synced 2025-12-08 19:06:15 +00:00
84 lines
2.6 KiB
Python
84 lines
2.6 KiB
Python
#!/usr/bin/env python
|
|
|
|
# This file is part of Espruino, a JavaScript interpreter for Microcontrollers
|
|
#
|
|
# Copyright (C) 2013 Gordon Williams <gw@pur3.co.uk>
|
|
#
|
|
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
#
|
|
# ----------------------------------------------------------------------------------------
|
|
# Script to extract the correct decls from boards/BOARDNAME.py
|
|
# ----------------------------------------------------------------------------------------
|
|
|
|
import subprocess;
|
|
import re;
|
|
import json;
|
|
import sys;
|
|
import os;
|
|
import importlib;
|
|
|
|
scriptdir = os.path.dirname(os.path.realpath(__file__))
|
|
basedir = scriptdir+"/../"
|
|
sys.path.append(basedir+"scripts");
|
|
sys.path.append(basedir+"boards");
|
|
|
|
import common;
|
|
import pinutils;
|
|
|
|
# -----------------------------------------------------------------------------------------
|
|
|
|
# Now scan AF file
|
|
if len(sys.argv)!=2:
|
|
print("ERROR, USAGE: get_makefile_decls.py BOARD_NAME")
|
|
exit(1)
|
|
boardname = sys.argv[1]
|
|
# import the board def
|
|
board = importlib.import_module(boardname)
|
|
#print(json.dumps(board.info))
|
|
|
|
print("# Generated with scripts/get_makefile_decls.py "+boardname);
|
|
print("BOARD="+boardname)
|
|
|
|
#allow to override board name so we can build for same board from multiple board files
|
|
if "boardname" in board.info:
|
|
boardname = board.info["boardname"]
|
|
print("# board.info.boardname set to "+boardname)
|
|
|
|
print("DEFINES+= -D"+boardname)
|
|
|
|
binaryName=common.get_board_binary_name(board)
|
|
if binaryName.find('.bin')>=0:
|
|
binaryName = binaryName[:binaryName.find('.bin')]
|
|
if binaryName.find('.hex')>=0:
|
|
binaryName = binaryName[:binaryName.find('.hex')]
|
|
if binaryName.find('.uf2')>=0:
|
|
binaryName = binaryName[:binaryName.find('.uf2')]
|
|
print("CREATE_UF2=1")
|
|
print("PROJ_NAME=$(BINDIR)/"+binaryName)
|
|
|
|
if board.chip["family"]!="LINUX":
|
|
print("EMBEDDED=1")
|
|
print("FAMILY="+board.chip['family'])
|
|
print("CHIP="+board.chip['part'])
|
|
|
|
if "optimizeflags" in board.info["build"]:
|
|
if board.info["build"]["optimizeflags"]:
|
|
print("OPTIMIZEFLAGS+="+board.info["build"]["optimizeflags"])
|
|
|
|
for lib in board.info["build"]["libraries"]:
|
|
print("USE_"+lib+"?=1")
|
|
|
|
if "makefile" in board.info["build"]:
|
|
for mfLine in board.info["build"]["makefile"]:
|
|
print(mfLine)
|
|
|
|
if 'USB' in board.devices:
|
|
print("USB:=1")
|
|
|
|
if 'bootloader' in board.info and board.info['bootloader']==1:
|
|
print("USE_BOOTLOADER:=1")
|
|
print("BOOTLOADER_PROJ_NAME:=$(BINDIR)/bootloader_"+binaryName)
|
|
print("DEFINES+=-DUSE_BOOTLOADER")
|