Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: get_config.py
- Revision:
- 9:2d27d77ada5c
- Child:
- 13:ab47a20b66f0
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/get_config.py Tue Jun 14 11:07:30 2016 +0100
@@ -0,0 +1,94 @@
+#! /usr/bin/env python2
+"""
+mbed SDK
+Copyright (c) 2011-2013 ARM Limited
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+"""
+import sys
+from os.path import isdir, abspath, dirname, join
+from os import _exit
+
+# Be sure that the tools directory is in the search path
+ROOT = abspath(join(dirname(__file__), ".."))
+sys.path.insert(0, ROOT)
+
+from tools.utils import args_error
+from tools.options import get_default_options_parser
+from tools.build_api import get_config
+from config import Config
+try:
+ import tools.private_settings as ps
+except:
+ ps = object()
+
+if __name__ == '__main__':
+ # Parse Options
+ parser = get_default_options_parser(add_clean=False, add_options=False)
+ parser.add_option("--source", dest="source_dir",
+ default=None, help="The source (input) directory", action="append")
+ parser.add_option("--prefix", dest="prefix", action="append",
+ default=None, help="Restrict listing to parameters that have this prefix")
+ parser.add_option("-v", "--verbose", action="store_true", dest="verbose",
+ default=False, help="Verbose diagnostic output")
+
+ (options, args) = parser.parse_args()
+
+ for path in options.source_dir :
+ if not isdir(path) :
+ args_error(parser, "[ERROR] you passed \"{}\" to --source, which does not exist".
+ format(path))
+ # Target
+ if options.mcu is None :
+ args_error(parser, "[ERROR] You should specify an MCU")
+ target = options.mcu
+
+ # Toolchain
+ if options.tool is None:
+ args_error(parser, "[ERROR] You should specify a TOOLCHAIN")
+ toolchain = options.tool
+
+ options.prefix = options.prefix or [""]
+
+ try:
+ params, macros = get_config(options.source_dir, target, toolchain)
+ if not params and not macros:
+ print "No configuration data available."
+ _exit(0)
+ if params:
+ print "Configuration parameters"
+ print "------------------------"
+ for p in params:
+ for s in options.prefix:
+ if p.startswith(s):
+ print(str(params[p]) if not options.verbose else params[p].get_verbose_description())
+ break
+ print ""
+
+ print "Macros"
+ print "------"
+ if macros:
+ print 'Defined with "macros":', macros
+ print "Generated from configuration parameters:", Config.parameters_to_macros(params)
+
+ except KeyboardInterrupt, e:
+ print "\n[CTRL+c] exit"
+ except Exception,e:
+ if options.verbose:
+ import traceback
+ traceback.print_exc(file=sys.stdout)
+ else:
+ print "[ERROR] %s" % str(e)
+
+ sys.exit(1)
