2014-05-18 23:38:59 +03:00
|
|
|
# Copyright (C) Ivan Kravets <me@ikravets.com>
|
|
|
|
# See LICENSE for details.
|
|
|
|
|
|
|
|
from os.path import isdir, join
|
|
|
|
|
|
|
|
from SCons.Script import (DefaultEnvironment, Exit, SConscript,
|
|
|
|
SConscriptChdir, Variables)
|
|
|
|
|
|
|
|
from platformio.util import get_home_dir, get_project_dir, get_source_dir
|
|
|
|
|
|
|
|
# AllowSubstExceptions()
|
|
|
|
|
2014-06-02 20:53:36 +03:00
|
|
|
# allow common variables from INI file
|
|
|
|
commonvars = Variables(None)
|
|
|
|
commonvars.AddVariables(
|
2014-05-18 23:38:59 +03:00
|
|
|
("PIOENV",),
|
|
|
|
("PLATFORM",),
|
2014-06-02 20:53:36 +03:00
|
|
|
("FRAMEWORK",),
|
|
|
|
|
|
|
|
# board options
|
2014-05-18 23:38:59 +03:00
|
|
|
("BOARD",),
|
2014-06-02 20:53:36 +03:00
|
|
|
("BOARD_MCU",),
|
|
|
|
("BOARD_F_CPU",),
|
2014-05-18 23:38:59 +03:00
|
|
|
|
2014-06-02 20:53:36 +03:00
|
|
|
# upload options
|
|
|
|
("UPLOAD_PORT",),
|
|
|
|
("UPLOAD_PROTOCOL",),
|
|
|
|
("UPLOAD_SPEED",)
|
|
|
|
)
|
2014-05-18 23:38:59 +03:00
|
|
|
|
|
|
|
DefaultEnvironment(
|
|
|
|
tools=["default", "platformio"],
|
2014-06-02 20:53:36 +03:00
|
|
|
toolpath=[join("$PIOBUILDER_DIR", "tools")],
|
|
|
|
variables=commonvars,
|
2014-05-18 23:38:59 +03:00
|
|
|
|
2014-06-02 20:53:36 +03:00
|
|
|
PIOBUILDER_DIR=join(get_source_dir(), "builder"),
|
2014-05-18 23:38:59 +03:00
|
|
|
PROJECT_DIR=get_project_dir(),
|
|
|
|
|
|
|
|
PLATFORMIOHOME_DIR=get_home_dir(),
|
2014-06-02 20:53:36 +03:00
|
|
|
PLATFORM_DIR=join("$PLATFORMIOHOME_DIR", "$PLATFORM"),
|
|
|
|
PLATFORMFW_DIR=join("$PLATFORM_DIR", "frameworks", "$FRAMEWORK"),
|
2014-05-18 23:38:59 +03:00
|
|
|
PLATFORMTOOLS_DIR=join("$PLATFORM_DIR", "tools"),
|
|
|
|
|
2014-06-02 20:53:36 +03:00
|
|
|
BUILD_DIR=join("$PROJECT_DIR", ".pioenvs", "$PIOENV")
|
2014-05-18 23:38:59 +03:00
|
|
|
)
|
|
|
|
|
2014-06-02 20:53:36 +03:00
|
|
|
env = DefaultEnvironment()
|
2014-05-18 23:38:59 +03:00
|
|
|
|
2014-06-02 20:53:36 +03:00
|
|
|
if not isdir(env['PLATFORMIOHOME_DIR']):
|
|
|
|
Exit("You haven't installed any platforms yet. Please use "
|
2014-05-18 23:38:59 +03:00
|
|
|
"`platformio install` command")
|
2014-06-02 20:53:36 +03:00
|
|
|
elif not isdir(env.subst("$PLATFORM_DIR")):
|
2014-05-18 23:38:59 +03:00
|
|
|
Exit("An '%s' platform hasn't been installed yet. Please use "
|
2014-06-02 20:53:36 +03:00
|
|
|
"`platformio install %s` command" % (env['PLATFORM'].upper(),
|
|
|
|
env['PLATFORM']))
|
2014-05-18 23:38:59 +03:00
|
|
|
|
|
|
|
SConscriptChdir(0)
|
2014-06-02 20:53:36 +03:00
|
|
|
SConscript(env.subst(join("$PIOBUILDER_DIR", "scripts", "${PLATFORM}.py")))
|