From: Chris Johns <chr...@rtems.org> The command python has been removed from upstream python and python2 and python3 is now used. This patch wraps the commands in a shell script that locates a suitable python to run.
Updates #3537 --- source-builder/pkg-config | 241 +++----------------------- source-builder/sb-bootstrap | 24 ++- source-builder/sb-builder | 24 ++- source-builder/sb-check | 24 ++- source-builder/sb-defaults | 24 ++- source-builder/sb-reports | 24 ++- source-builder/sb-rtems-config | 24 ++- source-builder/sb-set-builder | 25 ++- source-builder/sb/cmd-bootstrap.py | 29 ++++ source-builder/sb/cmd-builder.py | 29 ++++ source-builder/sb/cmd-check.py | 29 ++++ source-builder/sb/cmd-defaults.py | 29 ++++ source-builder/sb/cmd-pkg-config.py | 220 +++++++++++++++++++++++ source-builder/sb/cmd-reports.py | 29 ++++ source-builder/sb/cmd-rtems-config.py | 29 ++++ source-builder/sb/cmd-set-builder.py | 29 ++++ source-builder/sb/options.py | 7 +- source-builder/sb/python-wrapper.sh | 39 +++++ 18 files changed, 559 insertions(+), 320 deletions(-) create mode 100755 source-builder/sb/cmd-bootstrap.py create mode 100755 source-builder/sb/cmd-builder.py create mode 100755 source-builder/sb/cmd-check.py create mode 100755 source-builder/sb/cmd-defaults.py create mode 100755 source-builder/sb/cmd-pkg-config.py create mode 100755 source-builder/sb/cmd-reports.py create mode 100755 source-builder/sb/cmd-rtems-config.py create mode 100755 source-builder/sb/cmd-set-builder.py create mode 100644 source-builder/sb/python-wrapper.sh diff --git a/source-builder/pkg-config b/source-builder/pkg-config index fa251e5..65ee307 100755 --- a/source-builder/pkg-config +++ b/source-builder/pkg-config @@ -1,226 +1,27 @@ -#! /usr/bin/env python +#! /bin/sh # # RTEMS Tools Project (http://www.rtems.org/) -# Copyright 2014-2016 Chris Johns (chr...@rtems.org) +# Copyright 2018 Chris Johns (chr...@rtems.org) # All rights reserved. # # This file is part of the RTEMS Tools package in 'rtems-tools'. # -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# 1. Redistributions of source code must retain the above copyright notice, -# this list of conditions and the following disclaimer. -# -# 2. Redistributions in binary form must reproduce the above copyright notice, -# this list of conditions and the following disclaimer in the documentation -# and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# - -from __future__ import print_function - -import os -import sys - -base = os.path.dirname(sys.argv[0]) -sys.path.insert(0, base + '/sb') - -try: - import argparse -except: - sys.path.insert(0, base + '/sb/imports') - try: - import argparse - except: - print("Incorrect Source Builder installation", file = sys.stderr) - sys.exit(1) - -try: - import pkgconfig -except ImportError: - print("Incorrect Source Builder installation", file = sys.stderr) - sys.exit(1) - -# -# Make trace true to get a file of what happens and what is being asked. -# -trace = True -trace_stdout = False -logfile = 'pkg-config.log' -out = None -srcfd = None - -# -# Write all the package source parsed to a single file. -# -trace_src = True -if trace_src: - srcfd = open('pkg-src.txt', 'w') - -def src(text): - if srcfd: - srcfd.writelines(text) - -def log(s, lf = True): - global trace, logfile, out - if trace: - if out is None: - if logfile: - out = open(logfile, 'a') - else: - out = sys.stdout - if lf: - if out != sys.stdout and trace_stdout: - print(s) - print(s, file = out) - else: - if out != sys.stdout and trace_stdout: - print(s, end = '') - sys.stdout.flush() - print(s, end = '', file = out) - -def run(argv): - - class version_action(argparse.Action): - def __call__(self, parser, namespace, values, option_string = None): - parts = values[0].strip().split('.') - for p in parts: - if not p.isdigit(): - raise error('invalid version value: %s' % (values)) - setattr(namespace, self.dest, '.'.join(parts)) - - ec = 0 - - opts = argparse.ArgumentParser(prog = 'pkg-config', description = 'Package Configuration.') - opts.add_argument('libraries', metavar='lib', type = str, help = 'a library', nargs = '*') - opts.add_argument('--modversion', dest = 'modversion', action = 'store', default = None, - help = 'Requests that the version information of the libraries.') - opts.add_argument('--print-errors', dest = 'print_errors', action = 'store_true', - default = False, - help = 'Print any errors.') - opts.add_argument('--short-errors', dest = 'short_errors', action = 'store_true', - default = False, - help = 'Make error messages short.') - opts.add_argument('--silence-errors', dest = 'silence_errors', action = 'store_true', - default = False, - help = 'Do not print any errors.') - opts.add_argument('--errors-to-stdout', dest = 'errors_to_stdout', action = 'store_true', - default = False, - help = 'Print errors to stdout rather than stderr.') - opts.add_argument('--cflags', dest = 'cflags', action = 'store_true', - default = False, - help = 'This prints pre-processor and compile flags required to' \ - ' compile the package(s)') - opts.add_argument('--libs', dest = 'libs', action = 'store_true', - default = False, - help = 'This option is identical to "--cflags", only it prints the' \ - ' link flags.') - opts.add_argument('--libs-only-L', dest = 'libs_only_L', action = 'store_true', - default = False, - help = 'This prints the -L/-R part of "--libs".') - opts.add_argument('--libs-only-l', dest = 'libs_only_l', action = 'store_true', - default = False, - help = 'This prints the -l part of "--libs".') - opts.add_argument('--variable', dest = 'variable', action = 'store', - nargs = 1, default = None, - help = 'This returns the value of a variable.') - opts.add_argument('--define-variable', dest = 'define_variable', action = 'store', - nargs = 1, default = None, - help = 'This sets a global value for a variable') - opts.add_argument('--uninstalled', dest = 'uninstalled', action = 'store_true', - default = False, - help = 'Ignored') - opts.add_argument('--atleast-pkgconfig-version', dest = 'atleast_pkgconfig_version', - action = 'store', nargs = 1, default = None, - help = 'Check the version of package config. Always ok.') - opts.add_argument('--exists', dest = 'exists', action = 'store_true', - default = False, - help = 'Test if a library is present') - opts.add_argument('--atleast-version', dest = 'atleast_version', - action = version_action, nargs = 1, default = None, - help = 'The package is at least this version.') - opts.add_argument('--exact-version', dest = 'exact_version', action = version_action, - nargs = 1, default = None, - help = 'The package is the exact version.') - opts.add_argument('--max-version', dest = 'max_version', action = version_action, - nargs = 1, default = None, - help = 'The package is no later than this version.') - opts.add_argument('--msvc-syntax', dest = 'msvc_syntax', action = 'store_true', - default = False, - help = 'Ignored') - opts.add_argument('--dont-define-prefix', dest = 'dont_define_prefix', action = 'store_true', - default = False, - help = 'Ignored') - opts.add_argument('--prefix-variable', dest = 'prefix', action = 'store', - nargs = 1, default = pkgconfig.default_prefix(), - help = 'Define the prefix.') - opts.add_argument('--static', dest = 'static', action = 'store_true', - default = False, - help = 'Output libraries suitable for static linking') - opts.add_argument('--dump', dest = 'dump', action = 'store_true', - default = False, - help = 'Dump the package if one is found.') - - args = opts.parse_args(argv[1:]) - - if (args.exists and (args.exact_version or args.max_version)) or \ - (args.exact_version and (args.exists or args.max_version)) or \ - (args.max_version and (args.exists or args.exact_version)): - raise error('only one of --exists, --exact-version, or --max-version') - - if args.dont_define_prefix: - args.prefix = pkgconfig.default_prefix(False) - - exists = False - - ec = 1 - - if args.atleast_pkgconfig_version: - ec = 0 - else: - ec, pkg, flags = pkgconfig.check_package(args.libraries, args, log, src) - if ec == 0: - if args.cflags: - if len(flags['cflags']): - print(flags['cflags']) - log('cflags: %s' % (flags['cflags'])) - else: - log('cflags: empty') - if args.libs: - if len(flags['libs']): - print(flags['libs']) - log('libs: %s' % (flags['libs'])) - else: - log('libs: empty') - - #pkgconfig.package.dump_loaded() - - return ec - -try: - log('-' * 40) - log('pkg-config', lf = False) - for a in sys.argv[1:]: - log(' "%s"' % (a), lf = False) - log('') - ec = run(sys.argv) - log('ec = %d' % (ec)) -except ImportError: - print("incorrect package config installation", file = sys.stderr) - sys.exit(1) -except pkgconfig.error as e: - print('error: %s' % (e), file = sys.stderr) - sys.exit(1) -sys.exit(ec) +# Permission to use, copy, modify, and/or distribute this software for any +# purpose with or without fee is hereby granted, provided that the above +# copyright notice and this permission notice appear in all copies. +# +# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +# +set -e +base=$(dirname $0) +PYTHON_CMD=${base}/sb/cmd-pkg-config.py +if test -f ${base}/sb/python-wrapper.sh; then + . ${base}/sb/python-wrapper.sh +fi +echo "error: python wrapper not found" diff --git a/source-builder/sb-bootstrap b/source-builder/sb-bootstrap index a1ee9a7..618e2bb 100755 --- a/source-builder/sb-bootstrap +++ b/source-builder/sb-bootstrap @@ -1,7 +1,7 @@ -#! /usr/bin/env python +#! /bin/sh # # RTEMS Tools Project (http://www.rtems.org/) -# Copyright 2013 Chris Johns (chr...@rtems.org) +# Copyright 2018 Chris Johns (chr...@rtems.org) # All rights reserved. # # This file is part of the RTEMS Tools package in 'rtems-tools'. @@ -17,15 +17,11 @@ # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -from __future__ import print_function - -import sys, os -base = os.path.dirname(sys.argv[0]) -sys.path.insert(0, base + '/sb') -try: - import bootstrap - bootstrap.run(sys.argv) -except ImportError: - print("Incorrect Source Builder installation", file = sys.stderr) - sys.exit(1) +# +set -e +base=$(dirname $0) +PYTHON_CMD=${base}/sb/cmd-bootstrap.py +if test -f ${base}/sb/python-wrapper.sh; then + . ${base}/sb/python-wrapper.sh +fi +echo "error: python wrapper not found" diff --git a/source-builder/sb-builder b/source-builder/sb-builder index 8721b56..be3d205 100755 --- a/source-builder/sb-builder +++ b/source-builder/sb-builder @@ -1,7 +1,7 @@ -#! /usr/bin/env python +#! /bin/sh # # RTEMS Tools Project (http://www.rtems.org/) -# Copyright 2010-2012 Chris Johns (chr...@rtems.org) +# Copyright 2018 Chris Johns (chr...@rtems.org) # All rights reserved. # # This file is part of the RTEMS Tools package in 'rtems-tools'. @@ -17,15 +17,11 @@ # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -from __future__ import print_function - -import sys, os -base = os.path.dirname(sys.argv[0]) -sys.path.insert(0, base + '/sb') -try: - import build - build.run(sys.argv) -except ImportError: - print("Incorrect Source Builder installation", file = sys.stderr) - sys.exit(1) +# +set -e +base=$(dirname $0) +PYTHON_CMD=${base}/sb/cmd-builder.py +if test -f ${base}/sb/python-wrapper.sh; then + . ${base}/sb/python-wrapper.sh +fi +echo "error: python wrapper not found" diff --git a/source-builder/sb-check b/source-builder/sb-check index d23b799..b092697 100755 --- a/source-builder/sb-check +++ b/source-builder/sb-check @@ -1,7 +1,7 @@ -#! /usr/bin/env python +#! /bin/sh # # RTEMS Tools Project (http://www.rtems.org/) -# Copyright 2010-2012 Chris Johns (chr...@rtems.org) +# Copyright 2018 Chris Johns (chr...@rtems.org) # All rights reserved. # # This file is part of the RTEMS Tools package in 'rtems-tools'. @@ -17,15 +17,11 @@ # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -from __future__ import print_function - -import sys, os -base = os.path.dirname(sys.argv[0]) -sys.path.insert(0, base + '/sb') -try: - import check - check.run() -except ImportError: - print("Incorrect Source Builder installation", file = sys.stderr) - sys.exit(1) +# +set -e +base=$(dirname $0) +PYTHON_CMD=${base}/sb/cmd-check.py +if test -f ${base}/sb/python-wrapper.sh; then + . ${base}/sb/python-wrapper.sh +fi +echo "error: python wrapper not found" diff --git a/source-builder/sb-defaults b/source-builder/sb-defaults index 790a5e5..25437ba 100755 --- a/source-builder/sb-defaults +++ b/source-builder/sb-defaults @@ -1,7 +1,7 @@ -#! /usr/bin/env python +#! /bin/sh # # RTEMS Tools Project (http://www.rtems.org/) -# Copyright 2010-2013 Chris Johns (chr...@rtems.org) +# Copyright 2018 Chris Johns (chr...@rtems.org) # All rights reserved. # # This file is part of the RTEMS Tools package in 'rtems-tools'. @@ -17,15 +17,11 @@ # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -from __future__ import print_function - -import sys, os -base = os.path.dirname(sys.argv[0]) -sys.path.insert(0, base + '/sb') -try: - import options - options.run(sys.argv) -except ImportError: - print("Incorrect Source Builder installation", file = sys.stderr) - sys.exit(1) +# +set -e +base=$(dirname $0) +PYTHON_CMD=${base}/sb/cmd-defaults.py +if test -f ${base}/sb/python-wrapper.sh; then + . ${base}/sb/python-wrapper.sh +fi +echo "error: python wrapper not found" diff --git a/source-builder/sb-reports b/source-builder/sb-reports index 3330be3..5fb02d1 100755 --- a/source-builder/sb-reports +++ b/source-builder/sb-reports @@ -1,7 +1,7 @@ -#! /usr/bin/env python +#! /bin/sh # # RTEMS Tools Project (http://www.rtems.org/) -# Copyright 2010-2013 Chris Johns (chr...@rtems.org) +# Copyright 2018 Chris Johns (chr...@rtems.org) # All rights reserved. # # This file is part of the RTEMS Tools package in 'rtems-tools'. @@ -17,15 +17,11 @@ # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -from __future__ import print_function - -import sys, os -base = os.path.dirname(sys.argv[0]) -sys.path.insert(0, base + '/sb') -try: - import reports - reports.run(sys.argv) -except ImportError: - print("Incorrect Source Builder installation", file = sys.stderr) - sys.exit(1) +# +set -e +base=$(dirname $0) +PYTHON_CMD=${base}/sb/cmd-reports.py +if test -f ${base}/sb/python-wrapper.sh; then + . ${base}/sb/python-wrapper.sh +fi +echo "error: python wrapper not found" diff --git a/source-builder/sb-rtems-config b/source-builder/sb-rtems-config index 1633b6b..66a95f7 100755 --- a/source-builder/sb-rtems-config +++ b/source-builder/sb-rtems-config @@ -1,7 +1,7 @@ -#! /usr/bin/env python +#! /bin/sh # # RTEMS Tools Project (http://www.rtems.org/) -# Copyright 2010-2012 Chris Johns (chr...@rtems.org) +# Copyright 2018 Chris Johns (chr...@rtems.org) # All rights reserved. # # This file is part of the RTEMS Tools package in 'rtems-tools'. @@ -17,15 +17,11 @@ # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -from __future__ import print_function - -import sys, os -base = os.path.dirname(sys.argv[0]) -sys.path.insert(0, base + '/sb') -try: - import rtemsconfig - rtemsconfig.run(sys.argv) -except ImportError: - print("Incorrect Source Builder installation", file = sys.stderr) - sys.exit(1) +# +set -e +base=$(dirname $0) +PYTHON_CMD=${base}/sb/cmd-rtems-config.py +if test -f ${base}/sb/python-wrapper.sh; then + . ${base}/sb/python-wrapper.sh +fi +echo "error: python wrapper not found" diff --git a/source-builder/sb-set-builder b/source-builder/sb-set-builder index 561199e..6a196fe 100755 --- a/source-builder/sb-set-builder +++ b/source-builder/sb-set-builder @@ -1,7 +1,7 @@ -#! /usr/bin/env python +#! /bin/sh # # RTEMS Tools Project (http://www.rtems.org/) -# Copyright 2010-2012 Chris Johns (chr...@rtems.org) +# Copyright 2018 Chris Johns (chr...@rtems.org) # All rights reserved. # # This file is part of the RTEMS Tools package in 'rtems-tools'. @@ -17,16 +17,11 @@ # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -from __future__ import print_function - -import sys, os -base = os.path.dirname(sys.argv[0]) -sys.path.insert(0, base + '/sb') - -try: - import setbuilder - setbuilder.run() -except ImportError: - print("Incorrect Source Builder installation", file = sys.stderr) - sys.exit(1) +# +set -e +base=$(dirname $0) +PYTHON_CMD=${base}/sb/cmd-set-builder.py +if test -f ${base}/sb/python-wrapper.sh; then + . ${base}/sb/python-wrapper.sh +fi +echo "error: python wrapper not found" diff --git a/source-builder/sb/cmd-bootstrap.py b/source-builder/sb/cmd-bootstrap.py new file mode 100755 index 0000000..0243237 --- /dev/null +++ b/source-builder/sb/cmd-bootstrap.py @@ -0,0 +1,29 @@ +# +# RTEMS Tools Project (http://www.rtems.org/) +# Copyright 2013 Chris Johns (chr...@rtems.org) +# All rights reserved. +# +# This file is part of the RTEMS Tools package in 'rtems-tools'. +# +# Permission to use, copy, modify, and/or distribute this software for any +# purpose with or without fee is hereby granted, provided that the above +# copyright notice and this permission notice appear in all copies. +# +# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +from __future__ import print_function + +import sys, os + +try: + import bootstrap + bootstrap.run(sys.argv) +except ImportError: + print("Incorrect Source Builder installation", file = sys.stderr) + sys.exit(1) diff --git a/source-builder/sb/cmd-builder.py b/source-builder/sb/cmd-builder.py new file mode 100755 index 0000000..437b81a --- /dev/null +++ b/source-builder/sb/cmd-builder.py @@ -0,0 +1,29 @@ +# +# RTEMS Tools Project (http://www.rtems.org/) +# Copyright 2010-2012 Chris Johns (chr...@rtems.org) +# All rights reserved. +# +# This file is part of the RTEMS Tools package in 'rtems-tools'. +# +# Permission to use, copy, modify, and/or distribute this software for any +# purpose with or without fee is hereby granted, provided that the above +# copyright notice and this permission notice appear in all copies. +# +# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +from __future__ import print_function + +import sys, os + +try: + import build + build.run(sys.argv) +except ImportError: + print("Incorrect Source Builder installation", file = sys.stderr) + sys.exit(1) diff --git a/source-builder/sb/cmd-check.py b/source-builder/sb/cmd-check.py new file mode 100755 index 0000000..4525dbb --- /dev/null +++ b/source-builder/sb/cmd-check.py @@ -0,0 +1,29 @@ +# +# RTEMS Tools Project (http://www.rtems.org/) +# Copyright 2010-2012 Chris Johns (chr...@rtems.org) +# All rights reserved. +# +# This file is part of the RTEMS Tools package in 'rtems-tools'. +# +# Permission to use, copy, modify, and/or distribute this software for any +# purpose with or without fee is hereby granted, provided that the above +# copyright notice and this permission notice appear in all copies. +# +# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +from __future__ import print_function + +import sys, os + +try: + import check + check.run() +except ImportError: + print("Incorrect Source Builder installation", file = sys.stderr) + sys.exit(1) diff --git a/source-builder/sb/cmd-defaults.py b/source-builder/sb/cmd-defaults.py new file mode 100755 index 0000000..0b2b357 --- /dev/null +++ b/source-builder/sb/cmd-defaults.py @@ -0,0 +1,29 @@ +# +# RTEMS Tools Project (http://www.rtems.org/) +# Copyright 2010-2013 Chris Johns (chr...@rtems.org) +# All rights reserved. +# +# This file is part of the RTEMS Tools package in 'rtems-tools'. +# +# Permission to use, copy, modify, and/or distribute this software for any +# purpose with or without fee is hereby granted, provided that the above +# copyright notice and this permission notice appear in all copies. +# +# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +from __future__ import print_function + +import sys, os + +try: + import options + options.run(sys.argv) +except ImportError: + print("Incorrect Source Builder installation", file = sys.stderr) + sys.exit(1) diff --git a/source-builder/sb/cmd-pkg-config.py b/source-builder/sb/cmd-pkg-config.py new file mode 100755 index 0000000..c2f485c --- /dev/null +++ b/source-builder/sb/cmd-pkg-config.py @@ -0,0 +1,220 @@ +# +# RTEMS Tools Project (http://www.rtems.org/) +# Copyright 2014-2016 Chris Johns (chr...@rtems.org) +# All rights reserved. +# +# This file is part of the RTEMS Tools package in 'rtems-tools'. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# + +from __future__ import print_function + +import os +import sys + +base = os.path.dirname(sys.argv[0]) + +try: + import argparse +except: + sys.path.insert(0, base + '/sb/imports') + try: + import argparse + except: + print("Incorrect Source Builder installation", file = sys.stderr) + sys.exit(1) + +import pkgconfig + +# +# Make trace true to get a file of what happens and what is being asked. +# +trace = True +trace_stdout = False +logfile = 'pkg-config.log' +out = None +srcfd = None + +# +# Write all the package source parsed to a single file. +# +trace_src = True +if trace_src: + srcfd = open('pkg-src.txt', 'w') + +def src(text): + if srcfd: + srcfd.writelines(text) + +def log(s, lf = True): + global trace, logfile, out + if trace: + if out is None: + if logfile: + out = open(logfile, 'a') + else: + out = sys.stdout + if lf: + if out != sys.stdout and trace_stdout: + print(s) + print(s, file = out) + else: + if out != sys.stdout and trace_stdout: + print(s, end = '') + sys.stdout.flush() + print(s, end = '', file = out) + +def run(argv): + + class version_action(argparse.Action): + def __call__(self, parser, namespace, values, option_string = None): + parts = values[0].strip().split('.') + for p in parts: + if not p.isdigit(): + raise error('invalid version value: %s' % (values)) + setattr(namespace, self.dest, '.'.join(parts)) + + ec = 0 + + opts = argparse.ArgumentParser(prog = 'pkg-config', description = 'Package Configuration.') + opts.add_argument('libraries', metavar='lib', type = str, help = 'a library', nargs = '*') + opts.add_argument('--modversion', dest = 'modversion', action = 'store', default = None, + help = 'Requests that the version information of the libraries.') + opts.add_argument('--print-errors', dest = 'print_errors', action = 'store_true', + default = False, + help = 'Print any errors.') + opts.add_argument('--short-errors', dest = 'short_errors', action = 'store_true', + default = False, + help = 'Make error messages short.') + opts.add_argument('--silence-errors', dest = 'silence_errors', action = 'store_true', + default = False, + help = 'Do not print any errors.') + opts.add_argument('--errors-to-stdout', dest = 'errors_to_stdout', action = 'store_true', + default = False, + help = 'Print errors to stdout rather than stderr.') + opts.add_argument('--cflags', dest = 'cflags', action = 'store_true', + default = False, + help = 'This prints pre-processor and compile flags required to' \ + ' compile the package(s)') + opts.add_argument('--libs', dest = 'libs', action = 'store_true', + default = False, + help = 'This option is identical to "--cflags", only it prints the' \ + ' link flags.') + opts.add_argument('--libs-only-L', dest = 'libs_only_L', action = 'store_true', + default = False, + help = 'This prints the -L/-R part of "--libs".') + opts.add_argument('--libs-only-l', dest = 'libs_only_l', action = 'store_true', + default = False, + help = 'This prints the -l part of "--libs".') + opts.add_argument('--variable', dest = 'variable', action = 'store', + nargs = 1, default = None, + help = 'This returns the value of a variable.') + opts.add_argument('--define-variable', dest = 'define_variable', action = 'store', + nargs = 1, default = None, + help = 'This sets a global value for a variable') + opts.add_argument('--uninstalled', dest = 'uninstalled', action = 'store_true', + default = False, + help = 'Ignored') + opts.add_argument('--atleast-pkgconfig-version', dest = 'atleast_pkgconfig_version', + action = 'store', nargs = 1, default = None, + help = 'Check the version of package config. Always ok.') + opts.add_argument('--exists', dest = 'exists', action = 'store_true', + default = False, + help = 'Test if a library is present') + opts.add_argument('--atleast-version', dest = 'atleast_version', + action = version_action, nargs = 1, default = None, + help = 'The package is at least this version.') + opts.add_argument('--exact-version', dest = 'exact_version', action = version_action, + nargs = 1, default = None, + help = 'The package is the exact version.') + opts.add_argument('--max-version', dest = 'max_version', action = version_action, + nargs = 1, default = None, + help = 'The package is no later than this version.') + opts.add_argument('--msvc-syntax', dest = 'msvc_syntax', action = 'store_true', + default = False, + help = 'Ignored') + opts.add_argument('--dont-define-prefix', dest = 'dont_define_prefix', action = 'store_true', + default = False, + help = 'Ignored') + opts.add_argument('--prefix-variable', dest = 'prefix', action = 'store', + nargs = 1, default = pkgconfig.default_prefix(), + help = 'Define the prefix.') + opts.add_argument('--static', dest = 'static', action = 'store_true', + default = False, + help = 'Output libraries suitable for static linking') + opts.add_argument('--dump', dest = 'dump', action = 'store_true', + default = False, + help = 'Dump the package if one is found.') + + args = opts.parse_args(argv[1:]) + + if (args.exists and (args.exact_version or args.max_version)) or \ + (args.exact_version and (args.exists or args.max_version)) or \ + (args.max_version and (args.exists or args.exact_version)): + raise error('only one of --exists, --exact-version, or --max-version') + + if args.dont_define_prefix: + args.prefix = pkgconfig.default_prefix(False) + + exists = False + + ec = 1 + + if args.atleast_pkgconfig_version: + ec = 0 + else: + ec, pkg, flags = pkgconfig.check_package(args.libraries, args, log, src) + if ec == 0: + if args.cflags: + if len(flags['cflags']): + print(flags['cflags']) + log('cflags: %s' % (flags['cflags'])) + else: + log('cflags: empty') + if args.libs: + if len(flags['libs']): + print(flags['libs']) + log('libs: %s' % (flags['libs'])) + else: + log('libs: empty') + + #pkgconfig.package.dump_loaded() + + return ec + +try: + log('-' * 40) + log('pkg-config', lf = False) + for a in sys.argv[1:]: + log(' "%s"' % (a), lf = False) + log('') + ec = run(sys.argv) + log('ec = %d' % (ec)) +except ImportError: + print("incorrect package config installation", file = sys.stderr) + sys.exit(1) +except pkgconfig.error as e: + print('error: %s' % (e), file = sys.stderr) + sys.exit(1) +sys.exit(ec) diff --git a/source-builder/sb/cmd-reports.py b/source-builder/sb/cmd-reports.py new file mode 100755 index 0000000..4c41e33 --- /dev/null +++ b/source-builder/sb/cmd-reports.py @@ -0,0 +1,29 @@ +# +# RTEMS Tools Project (http://www.rtems.org/) +# Copyright 2010-2013 Chris Johns (chr...@rtems.org) +# All rights reserved. +# +# This file is part of the RTEMS Tools package in 'rtems-tools'. +# +# Permission to use, copy, modify, and/or distribute this software for any +# purpose with or without fee is hereby granted, provided that the above +# copyright notice and this permission notice appear in all copies. +# +# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +from __future__ import print_function + +import sys, os + +try: + import reports + reports.run(sys.argv) +except ImportError: + print("Incorrect Source Builder installation", file = sys.stderr) + sys.exit(1) diff --git a/source-builder/sb/cmd-rtems-config.py b/source-builder/sb/cmd-rtems-config.py new file mode 100755 index 0000000..f29ef04 --- /dev/null +++ b/source-builder/sb/cmd-rtems-config.py @@ -0,0 +1,29 @@ +# +# RTEMS Tools Project (http://www.rtems.org/) +# Copyright 2010-2012 Chris Johns (chr...@rtems.org) +# All rights reserved. +# +# This file is part of the RTEMS Tools package in 'rtems-tools'. +# +# Permission to use, copy, modify, and/or distribute this software for any +# purpose with or without fee is hereby granted, provided that the above +# copyright notice and this permission notice appear in all copies. +# +# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +from __future__ import print_function + +import sys, os + +try: + import rtemsconfig + rtemsconfig.run(sys.argv) +except ImportError: + print("Incorrect Source Builder installation", file = sys.stderr) + sys.exit(1) diff --git a/source-builder/sb/cmd-set-builder.py b/source-builder/sb/cmd-set-builder.py new file mode 100755 index 0000000..56114cd --- /dev/null +++ b/source-builder/sb/cmd-set-builder.py @@ -0,0 +1,29 @@ +# +# RTEMS Tools Project (http://www.rtems.org/) +# Copyright 2010-2012 Chris Johns (chr...@rtems.org) +# All rights reserved. +# +# This file is part of the RTEMS Tools package in 'rtems-tools'. +# +# Permission to use, copy, modify, and/or distribute this software for any +# purpose with or without fee is hereby granted, provided that the above +# copyright notice and this permission notice appear in all copies. +# +# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +from __future__ import print_function + +import sys, os + +try: + import setbuilder + setbuilder.run() +except ImportError: + print("Incorrect Source Builder installation", file = sys.stderr) + sys.exit(1) diff --git a/source-builder/sb/options.py b/source-builder/sb/options.py index 5767c48..afba28f 100644 --- a/source-builder/sb/options.py +++ b/source-builder/sb/options.py @@ -601,10 +601,15 @@ def load(args, optargs = None, defaults = '%{_sbdir}/defaults.mc', logfile = Tru global host_windows global host_posix + # + # Adjust the args to remove the wrapper. + # + args = args[1:] + # # The path to this command. # - command_path = path.dirname(args[0]) + command_path = path.dirname(path.abspath(args[0])) if len(command_path) == 0: command_path = '.' diff --git a/source-builder/sb/python-wrapper.sh b/source-builder/sb/python-wrapper.sh new file mode 100644 index 0000000..82afc7d --- /dev/null +++ b/source-builder/sb/python-wrapper.sh @@ -0,0 +1,39 @@ +# +# RTEMS Tools Project (http://www.rtems.org/) +# Copyright 2018 Chris Johns (chr...@rtems.org) +# All rights reserved. +# +# This file is part of the RTEMS Tools package in 'rtems-tools'. +# +# Permission to use, copy, modify, and/or distribute this software for any +# purpose with or without fee is hereby granted, provided that the above +# copyright notice and this permission notice appear in all copies. +# +# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +set -e +if test ! -f $PYTHON_CMD; then + echo "error: python command not found: $PYTHON_CMD" + exit 5 +fi +for py in python2 python3 python +do + set +e + py_cmd=$(command -v $py) + set -e + if test -n "$RTEMS_PYTHON_OVERRIDE"; then + if test "$RTEMS_PYTHON_OVERRIDE" != "$pycmd"; then + py_cmd="" + fi + fi + if test -n "$py_cmd"; then + exec $py_cmd $PYTHON_CMD $0 $* + fi +done +echo "error: no valid python found" +exit 5 -- 2.17.1 (Apple Git-112) _______________________________________________ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel