[PATCH] sb: Use shebang env python
chrisj at rtems.org
chrisj at rtems.org
Tue Aug 25 11:24:25 UTC 2020
From: Chris Johns <chrisj at rtems.org>
Closes #4037
---
source-builder/pkg-config | 236 +++++++++++++++++++++++---
source-builder/sb-check | 24 +--
source-builder/sb-defaults | 23 +--
source-builder/sb-get-sources | 23 +--
source-builder/sb-reports | 23 +--
source-builder/sb-rtems-config | 23 +--
source-builder/sb-set-builder | 22 +--
source-builder/sb-track | 22 +--
source-builder/sb/build.py | 22 +--
source-builder/sb/check.py | 16 +-
source-builder/sb/cmd-check.py | 29 ----
source-builder/sb/cmd-defaults.py | 29 ----
source-builder/sb/cmd-get-sources.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/cmd-track.py | 29 ----
source-builder/sb/config.py | 16 +-
source-builder/sb/cvs.py | 10 +-
source-builder/sb/darwin.py | 2 +-
source-builder/sb/download.py | 14 +-
source-builder/sb/ereport.py | 4 +-
source-builder/sb/execute.py | 4 +-
source-builder/sb/freebsd.py | 6 +-
source-builder/sb/getsources.py | 12 +-
source-builder/sb/git.py | 13 +-
source-builder/sb/linux.py | 4 +-
source-builder/sb/log.py | 2 +-
source-builder/sb/macros.py | 4 +-
source-builder/sb/mailer.py | 6 +-
source-builder/sb/netbsd.py | 4 +-
source-builder/sb/options.py | 44 +++--
source-builder/sb/path.py | 4 +-
source-builder/sb/pkgconfig.py | 9 +-
source-builder/sb/python-wrapper.sh | 39 -----
source-builder/sb/reports.py | 22 +--
source-builder/sb/rtemsconfig.py | 10 +-
source-builder/sb/setbuilder.py | 22 +--
source-builder/sb/shell.py | 8 +-
source-builder/sb/simhost.py | 36 ++--
source-builder/sb/solaris.py | 6 +-
source-builder/sb/sources.py | 2 +-
source-builder/sb/track.py | 14 +-
source-builder/sb/version.py | 6 +-
source-builder/sb/windows.py | 6 +-
46 files changed, 471 insertions(+), 715 deletions(-)
delete mode 100755 source-builder/sb/cmd-check.py
delete mode 100755 source-builder/sb/cmd-defaults.py
delete mode 100755 source-builder/sb/cmd-get-sources.py
delete mode 100755 source-builder/sb/cmd-pkg-config.py
delete mode 100755 source-builder/sb/cmd-reports.py
delete mode 100755 source-builder/sb/cmd-rtems-config.py
delete mode 100755 source-builder/sb/cmd-set-builder.py
delete mode 100755 source-builder/sb/cmd-track.py
delete mode 100644 source-builder/sb/python-wrapper.sh
diff --git a/source-builder/pkg-config b/source-builder/pkg-config
index 65ee307..10db546 100755
--- a/source-builder/pkg-config
+++ b/source-builder/pkg-config
@@ -1,27 +1,221 @@
-#! /bin/sh
+#! /usr/bin/env python
#
# RTEMS Tools Project (http://www.rtems.org/)
-# Copyright 2018 Chris Johns (chrisj at rtems.org)
+# Copyright 2014-2016 Chris Johns (chrisj at 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
-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"
+# 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 sb.pkgconfig
+
+#
+# Make trace true to get a file of what happens and what is being asked.
+#
+trace = False
+trace_stdout = False
+logfile = 'pkg-config.log'
+out = None
+srcfd = None
+
+#
+# Write all the package source parsed to a single file.
+#
+trace_src = False
+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 = sb.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)
+
+ 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 = sb.pkgconfig.default_prefix(False)
+
+ exists = False
+
+ ec = 1
+
+ if args.atleast_pkgconfig_version:
+ ec = 0
+ else:
+ ec, pkg, flags = sb.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[2:]:
+ log(' "%s"' % (a), lf = False)
+ log('')
+ ec = run(sys.argv[1:])
+ log('ec = %d' % (ec))
+except ImportError:
+ print("incorrect package config installation", file = sys.stderr)
+ sys.exit(1)
+except sb.pkgconfig.error as e:
+ print('error: %s' % (e), file = sys.stderr)
+ sys.exit(1)
+sys.exit(ec)
diff --git a/source-builder/sb-check b/source-builder/sb-check
index b092697..b75767e 100755
--- a/source-builder/sb-check
+++ b/source-builder/sb-check
@@ -1,7 +1,7 @@
-#! /bin/sh
+#! /usr/bin/env python
#
# RTEMS Tools Project (http://www.rtems.org/)
-# Copyright 2018 Chris Johns (chrisj at rtems.org)
+# Copyright 2010-2012 Chris Johns (chrisj at rtems.org)
# All rights reserved.
#
# This file is part of the RTEMS Tools package in 'rtems-tools'.
@@ -17,11 +17,15 @@
# 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-check.py
-if test -f ${base}/sb/python-wrapper.sh; then
- . ${base}/sb/python-wrapper.sh
-fi
-echo "error: python wrapper not found"
+
+from __future__ import print_function
+
+import sb.check
+
+try:
+ import sb.check
+ sb.check.run()
+except ImportError:
+ import sys
+ print("Incorrect Source Builder installation", file = sys.stderr)
+ sys.exit(1)
diff --git a/source-builder/sb-defaults b/source-builder/sb-defaults
index 25437ba..2fd2121 100755
--- a/source-builder/sb-defaults
+++ b/source-builder/sb-defaults
@@ -1,7 +1,7 @@
-#! /bin/sh
+#! /usr/bin/env python
#
# RTEMS Tools Project (http://www.rtems.org/)
-# Copyright 2018 Chris Johns (chrisj at rtems.org)
+# Copyright 2010-2013 Chris Johns (chrisj at rtems.org)
# All rights reserved.
#
# This file is part of the RTEMS Tools package in 'rtems-tools'.
@@ -17,11 +17,14 @@
# 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-defaults.py
-if test -f ${base}/sb/python-wrapper.sh; then
- . ${base}/sb/python-wrapper.sh
-fi
-echo "error: python wrapper not found"
+
+from __future__ import print_function
+
+import sys
+
+try:
+ import sb.options
+ sb.options.run(sys.argv)
+except ImportError:
+ print("Incorrect Source Builder installation", file = sys.stderr)
+ sys.exit(1)
diff --git a/source-builder/sb-get-sources b/source-builder/sb-get-sources
index d9f03b7..97ee419 100755
--- a/source-builder/sb-get-sources
+++ b/source-builder/sb-get-sources
@@ -1,7 +1,7 @@
-#! /bin/sh
+#! /usr/bin/env python
#
# RTEMS Tools Project (http://www.rtems.org/)
-# Copyright 2019 Chris Johns (chrisj at rtems.org)
+# Copyright 2010-2019 Chris Johns (chrisj at rtems.org)
# All rights reserved.
#
# This file is part of the RTEMS Tools package in 'rtems-tools'.
@@ -17,11 +17,14 @@
# 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-get-sources.py
-if test -f ${base}/sb/python-wrapper.sh; then
- . ${base}/sb/python-wrapper.sh
-fi
-echo "error: python wrapper not found"
+
+from __future__ import print_function
+
+
+try:
+ import sb.getsources
+ sb.getsources.run()
+except ImportError:
+ import sys
+ print("Incorrect Source Builder installation", file = sys.stderr)
+ sys.exit(1)
diff --git a/source-builder/sb-reports b/source-builder/sb-reports
index 5fb02d1..194c4ab 100755
--- a/source-builder/sb-reports
+++ b/source-builder/sb-reports
@@ -1,7 +1,7 @@
-#! /bin/sh
+#! /usr/bin/env python
#
# RTEMS Tools Project (http://www.rtems.org/)
-# Copyright 2018 Chris Johns (chrisj at rtems.org)
+# Copyright 2010-2013 Chris Johns (chrisj at rtems.org)
# All rights reserved.
#
# This file is part of the RTEMS Tools package in 'rtems-tools'.
@@ -17,11 +17,14 @@
# 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-reports.py
-if test -f ${base}/sb/python-wrapper.sh; then
- . ${base}/sb/python-wrapper.sh
-fi
-echo "error: python wrapper not found"
+
+from __future__ import print_function
+
+import sys
+
+try:
+ import sb.reports
+ sb.reports.run(sys.argv)
+except ImportError:
+ print("Incorrect Source Builder installation", file = sys.stderr)
+ sys.exit(1)
diff --git a/source-builder/sb-rtems-config b/source-builder/sb-rtems-config
index 66a95f7..a84b9c8 100755
--- a/source-builder/sb-rtems-config
+++ b/source-builder/sb-rtems-config
@@ -1,7 +1,7 @@
-#! /bin/sh
+#! /usr/bin/env python
#
# RTEMS Tools Project (http://www.rtems.org/)
-# Copyright 2018 Chris Johns (chrisj at rtems.org)
+# Copyright 2010-2012 Chris Johns (chrisj at rtems.org)
# All rights reserved.
#
# This file is part of the RTEMS Tools package in 'rtems-tools'.
@@ -17,11 +17,14 @@
# 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-rtems-config.py
-if test -f ${base}/sb/python-wrapper.sh; then
- . ${base}/sb/python-wrapper.sh
-fi
-echo "error: python wrapper not found"
+
+from __future__ import print_function
+
+import sys
+
+try:
+ import sb.rtemsconfig
+ sb.rtemsconfig.run(sys.argv)
+except ImportError:
+ print("Incorrect Source Builder installation", file = sys.stderr)
+ sys.exit(1)
diff --git a/source-builder/sb-set-builder b/source-builder/sb-set-builder
index 6a196fe..96dd919 100755
--- a/source-builder/sb-set-builder
+++ b/source-builder/sb-set-builder
@@ -1,7 +1,7 @@
-#! /bin/sh
+#! /usr/bin/env python
#
# RTEMS Tools Project (http://www.rtems.org/)
-# Copyright 2018 Chris Johns (chrisj at rtems.org)
+# Copyright 2010-2012 Chris Johns (chrisj at rtems.org)
# All rights reserved.
#
# This file is part of the RTEMS Tools package in 'rtems-tools'.
@@ -17,11 +17,13 @@
# 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-set-builder.py
-if test -f ${base}/sb/python-wrapper.sh; then
- . ${base}/sb/python-wrapper.sh
-fi
-echo "error: python wrapper not found"
+
+from __future__ import print_function
+
+try:
+ import sb.setbuilder
+ sb.setbuilder.run()
+except ImportError:
+ import sys
+ print("Incorrect Source Builder installation", file = sys.stderr)
+ sys.exit(1)
diff --git a/source-builder/sb-track b/source-builder/sb-track
index a739978..64daeb8 100755
--- a/source-builder/sb-track
+++ b/source-builder/sb-track
@@ -1,7 +1,7 @@
-#! /bin/sh
+#! /usr/bin/env python
#
# RTEMS Tools Project (http://www.rtems.org/)
-# Copyright 2019 Chris Johns (chrisj at rtems.org)
+# Copyright 2010-2019 Chris Johns (chrisj at rtems.org)
# All rights reserved.
#
# This file is part of the RTEMS Tools package in 'rtems-tools'.
@@ -17,11 +17,13 @@
# 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-track.py
-if test -f ${base}/sb/python-wrapper.sh; then
- . ${base}/sb/python-wrapper.sh
-fi
-echo "error: python wrapper not found"
+
+from __future__ import print_function
+
+try:
+ import sb.track
+ sb.track.run()
+except ImportError:
+ import sys
+ print("Incorrect Source Builder installation", file = sys.stderr)
+ sys.exit(1)
diff --git a/source-builder/sb/build.py b/source-builder/sb/build.py
index cfb7d8c..f3253dd 100644
--- a/source-builder/sb/build.py
+++ b/source-builder/sb/build.py
@@ -33,17 +33,17 @@ import stat
import sys
try:
- import check
- import config
- import download
- import error
- import ereport
- import execute
- import log
- import options
- import path
- import sources
- import version
+ from . import check
+ from . import config
+ from . import download
+ from . import error
+ from . import ereport
+ from . import execute
+ from . import log
+ from . import options
+ from . import path
+ from . import sources
+ from . import version
except KeyboardInterrupt:
print('abort: user terminated')
sys.exit(1)
diff --git a/source-builder/sb/check.py b/source-builder/sb/check.py
index be808ea..7e23223 100644
--- a/source-builder/sb/check.py
+++ b/source-builder/sb/check.py
@@ -23,16 +23,16 @@
from __future__ import print_function
-import os
-
-import error
-import execute
import fnmatch
-import log
-import options
-import path
+import os
import re
-import version
+
+from . import error
+from . import execute
+from . import log
+from . import options
+from . import path
+from . import version
def _check_none(_opts, macro, value, constraint):
return True
diff --git a/source-builder/sb/cmd-check.py b/source-builder/sb/cmd-check.py
deleted file mode 100755
index 4525dbb..0000000
--- a/source-builder/sb/cmd-check.py
+++ /dev/null
@@ -1,29 +0,0 @@
-#
-# RTEMS Tools Project (http://www.rtems.org/)
-# Copyright 2010-2012 Chris Johns (chrisj at 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
deleted file mode 100755
index 0b2b357..0000000
--- a/source-builder/sb/cmd-defaults.py
+++ /dev/null
@@ -1,29 +0,0 @@
-#
-# RTEMS Tools Project (http://www.rtems.org/)
-# Copyright 2010-2013 Chris Johns (chrisj at 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-get-sources.py b/source-builder/sb/cmd-get-sources.py
deleted file mode 100755
index 480e81d..0000000
--- a/source-builder/sb/cmd-get-sources.py
+++ /dev/null
@@ -1,29 +0,0 @@
-#
-# RTEMS Tools Project (http://www.rtems.org/)
-# Copyright 2010-2019 Chris Johns (chrisj at 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 getsources
- getsources.run()
-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
deleted file mode 100755
index 68c67cf..0000000
--- a/source-builder/sb/cmd-pkg-config.py
+++ /dev/null
@@ -1,220 +0,0 @@
-#
-# RTEMS Tools Project (http://www.rtems.org/)
-# Copyright 2014-2016 Chris Johns (chrisj at 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[1])
-
-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 = False
-trace_stdout = False
-logfile = 'pkg-config.log'
-out = None
-srcfd = None
-
-#
-# Write all the package source parsed to a single file.
-#
-trace_src = False
-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[2:]:
- log(' "%s"' % (a), lf = False)
- log('')
- ec = run(sys.argv[1:])
- 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
deleted file mode 100755
index 4c41e33..0000000
--- a/source-builder/sb/cmd-reports.py
+++ /dev/null
@@ -1,29 +0,0 @@
-#
-# RTEMS Tools Project (http://www.rtems.org/)
-# Copyright 2010-2013 Chris Johns (chrisj at 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
deleted file mode 100755
index f29ef04..0000000
--- a/source-builder/sb/cmd-rtems-config.py
+++ /dev/null
@@ -1,29 +0,0 @@
-#
-# RTEMS Tools Project (http://www.rtems.org/)
-# Copyright 2010-2012 Chris Johns (chrisj at 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
deleted file mode 100755
index 56114cd..0000000
--- a/source-builder/sb/cmd-set-builder.py
+++ /dev/null
@@ -1,29 +0,0 @@
-#
-# RTEMS Tools Project (http://www.rtems.org/)
-# Copyright 2010-2012 Chris Johns (chrisj at 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/cmd-track.py b/source-builder/sb/cmd-track.py
deleted file mode 100755
index 82615a5..0000000
--- a/source-builder/sb/cmd-track.py
+++ /dev/null
@@ -1,29 +0,0 @@
-#
-# RTEMS Tools Project (http://www.rtems.org/)
-# Copyright 2010-2019 Chris Johns (chrisj at 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 track
- track.run()
-except ImportError:
- print("Incorrect Source Builder installation", file = sys.stderr)
- sys.exit(1)
diff --git a/source-builder/sb/config.py b/source-builder/sb/config.py
index f8854a5..db795b3 100644
--- a/source-builder/sb/config.py
+++ b/source-builder/sb/config.py
@@ -34,13 +34,13 @@ import re
import sys
try:
- import error
- import execute
- import log
- import options
- import path
- import pkgconfig
- import sources
+ from . import error
+ from . import execute
+ from . import log
+ from . import options
+ from . import path
+ from . import pkgconfig
+ from . import sources
except KeyboardInterrupt:
print('user terminated', file = sys.stderr)
sys.exit(1)
@@ -500,6 +500,7 @@ class file:
except pkgconfig.error as pe:
self._error('pkgconfig: check: %s' % (pe))
except:
+ raise
raise error.internal('pkgconfig failure')
if ok:
return '1'
@@ -524,6 +525,7 @@ class file:
except pkgconfig.error as pe:
self._error('pkgconfig: %s: %s' % (flags, pe))
except:
+ raise
raise error.internal('pkgconfig failure')
if pkg_flags is None:
pkg_flags = ''
diff --git a/source-builder/sb/cvs.py b/source-builder/sb/cvs.py
index 2ff7417..673488e 100644
--- a/source-builder/sb/cvs.py
+++ b/source-builder/sb/cvs.py
@@ -25,11 +25,10 @@ from __future__ import print_function
import os
-import error
-import execute
-import log
-import options
-import path
+from . import error
+from . import execute
+from . import log
+from . import path
class repo:
"""An object to manage a cvs repo."""
@@ -147,6 +146,7 @@ class repo:
if __name__ == '__main__':
import sys
+ from . import options
opts = options.load(sys.argv, defaults = 'defaults.mc')
ldir = 'cvs-test-rm-me'
c = repo(ldir, opts)
diff --git a/source-builder/sb/darwin.py b/source-builder/sb/darwin.py
index a21a6bc..95a2a4e 100644
--- a/source-builder/sb/darwin.py
+++ b/source-builder/sb/darwin.py
@@ -24,7 +24,7 @@
import os
-import execute
+from . import execute
def load():
uname = os.uname()
diff --git a/source-builder/sb/download.py b/source-builder/sb/download.py
index 3aaa701..410edeb 100644
--- a/source-builder/sb/download.py
+++ b/source-builder/sb/download.py
@@ -37,13 +37,13 @@ except ImportError:
import urllib2 as urllib_request
import urlparse as urllib_parse
-import cvs
-import error
-import git
-import log
-import path
-import sources
-import version
+from . import cvs
+from . import error
+from . import git
+from . import log
+from . import path
+from . import sources
+from . import version
def _do_download(opts):
download = True
diff --git a/source-builder/sb/ereport.py b/source-builder/sb/ereport.py
index 475eff7..d8fb5f6 100755
--- a/source-builder/sb/ereport.py
+++ b/source-builder/sb/ereport.py
@@ -25,8 +25,8 @@ from __future__ import print_function
import os
-import error
-import log
+from . import error
+from . import log
def generate(name, opts, header = None, footer = None):
label, result = opts.with_arg('error-report')
diff --git a/source-builder/sb/execute.py b/source-builder/sb/execute.py
index 06f9b7d..3db9abc 100755
--- a/source-builder/sb/execute.py
+++ b/source-builder/sb/execute.py
@@ -36,8 +36,8 @@ import threading
import time
import traceback
-import error
-import log
+from . import error
+from . import log
# Trace exceptions
trace_threads = False
diff --git a/source-builder/sb/freebsd.py b/source-builder/sb/freebsd.py
index 5497e75..472f670 100644
--- a/source-builder/sb/freebsd.py
+++ b/source-builder/sb/freebsd.py
@@ -27,9 +27,9 @@
import pprint
import os
-import check
-import error
-import execute
+from . import check
+from . import error
+from . import execute
def load():
uname = os.uname()
diff --git a/source-builder/sb/getsources.py b/source-builder/sb/getsources.py
index 7d76038..0ccf257 100644
--- a/source-builder/sb/getsources.py
+++ b/source-builder/sb/getsources.py
@@ -31,11 +31,11 @@ import os
import sys
try:
- import build
- import error
- import log
- import simhost
- import version
+ from . import build
+ from . import error
+ from . import log
+ from . import simhost
+ from . import version
except KeyboardInterrupt:
print('abort: user terminated', file = sys.stderr)
sys.exit(1)
@@ -76,7 +76,7 @@ def run(args = sys.argv):
action = 'store_true')
argsp.add_argument('bsets', nargs='*', help = 'Build sets.')
- argopts = argsp.parse_args(args[2:])
+ argopts = argsp.parse_args(args[1:])
simhost.load_log(argopts.log)
log.notice('RTEMS Source Builder - Get Sources, %s' % (version.string()))
diff --git a/source-builder/sb/git.py b/source-builder/sb/git.py
index 52bcb83..237e690 100644
--- a/source-builder/sb/git.py
+++ b/source-builder/sb/git.py
@@ -25,11 +25,10 @@ from __future__ import print_function
import os
-import error
-import execute
-import log
-import options
-import path
+from . import error
+from . import execute
+from . import log
+from . import path
class repo:
"""An object to manage a git repo."""
@@ -230,7 +229,9 @@ class repo:
if __name__ == '__main__':
import os.path
import sys
- defaults = path.join(path.dirname(path.dirname(path.shell(sys.argv[0]))), 'defaults.mc')
+ from . import options
+ defaults = path.join(path.dirname(path.dirname(path.shell(sys.argv[0]))),
+ 'defaults.mc')
opts = options.load(sys.argv, defaults = defaults)
g = repo('.', opts)
print('g.git_version():', g.git_version())
diff --git a/source-builder/sb/linux.py b/source-builder/sb/linux.py
index 791bbd6..d773818 100644
--- a/source-builder/sb/linux.py
+++ b/source-builder/sb/linux.py
@@ -26,8 +26,8 @@ import multiprocessing
import pprint
import os
-import platform
-import path
+from . import platform
+from . import path
def load():
uname = os.uname()
diff --git a/source-builder/sb/log.py b/source-builder/sb/log.py
index 788160e..7ad4763 100755
--- a/source-builder/sb/log.py
+++ b/source-builder/sb/log.py
@@ -26,7 +26,7 @@ from __future__ import print_function
import os
import sys
-import error
+from . import error
#
# A global log.
diff --git a/source-builder/sb/macros.py b/source-builder/sb/macros.py
index 5a639b8..6ca87ed 100644
--- a/source-builder/sb/macros.py
+++ b/source-builder/sb/macros.py
@@ -27,8 +27,8 @@ import re
import os
import string
-import error
-import path
+from . import error
+from . import path
#
# Macro tables
diff --git a/source-builder/sb/mailer.py b/source-builder/sb/mailer.py
index 42b4fa6..ff25df5 100644
--- a/source-builder/sb/mailer.py
+++ b/source-builder/sb/mailer.py
@@ -27,9 +27,9 @@ import os
import smtplib
import socket
-import error
-import options
-import path
+from . import error
+from . import options
+from . import path
def append_options(opts):
opts['--mail'] = 'Send email report or results.'
diff --git a/source-builder/sb/netbsd.py b/source-builder/sb/netbsd.py
index c7420c3..3398290 100644
--- a/source-builder/sb/netbsd.py
+++ b/source-builder/sb/netbsd.py
@@ -27,8 +27,8 @@
import pprint
import os
-import check
-import execute
+from . import check
+from . import execute
def load():
uname = os.uname()
diff --git a/source-builder/sb/options.py b/source-builder/sb/options.py
index fe4182d..d6bffd0 100644
--- a/source-builder/sb/options.py
+++ b/source-builder/sb/options.py
@@ -29,18 +29,17 @@ import pprint
import re
import os
import string
-
-import download
-import error
-import execute
-import git
-import log
-import macros
-import path
-import sources
import sys
-import version
+from . import download
+from . import error
+from . import execute
+from . import git
+from . import log
+from . import macros
+from . import path
+from . import sources
+from . import version
basepath = 'sb'
@@ -624,11 +623,6 @@ 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.
#
@@ -649,7 +643,7 @@ def load(args, optargs = None, defaults = '%{_sbdir}/defaults.mc', logfile = Tru
overrides = None
if os.name == 'nt':
try:
- import windows
+ from . import windows
overrides = windows.load()
host_windows = True
host_posix = False
@@ -659,26 +653,26 @@ def load(args, optargs = None, defaults = '%{_sbdir}/defaults.mc', logfile = Tru
uname = os.uname()
try:
if uname[0].startswith('MINGW64_NT'):
- import windows
+ from . import windows
overrides = windows.load()
host_windows = True
elif uname[0].startswith('CYGWIN_NT'):
- import windows
+ from . import windows
overrides = windows.load()
elif uname[0] == 'Darwin':
- import darwin
+ from . import darwin
overrides = darwin.load()
elif uname[0] == 'FreeBSD':
- import freebsd
+ from . import freebsd
overrides = freebsd.load()
elif uname[0] == 'NetBSD':
- import netbsd
+ from . import netbsd
overrides = netbsd.load()
elif uname[0] == 'Linux':
- import linux
+ from . import linux
overrides = linux.load()
elif uname[0] == 'SunOS':
- import solaris
+ from . import solaris
overrides = solaris.load()
except error.general as ge:
raise error.general('failed to load %s host support: %s' % (uname[0], ge))
@@ -721,7 +715,9 @@ def load(args, optargs = None, defaults = '%{_sbdir}/defaults.mc', logfile = Tru
def run(args):
try:
- _opts = load(args = args, defaults = 'defaults.mc')
+ dpath = path.dirname(args[0])
+ _opts = load(args = args,
+ defaults = path.join(dpath, 'defaults.mc'))
log.notice('RTEMS Source Builder - Defaults, %s' % (version.string()))
_opts.log_info()
log.notice('Options:')
diff --git a/source-builder/sb/path.py b/source-builder/sb/path.py
index 93852c8..b27cf14 100644
--- a/source-builder/sb/path.py
+++ b/source-builder/sb/path.py
@@ -25,14 +25,14 @@
from __future__ import print_function
-import log
import os
import shutil
import stat
import string
import sys
-import error
+from . import error
+from . import log
windows_posix = sys.platform == 'msys'
windows = os.name == 'nt'
diff --git a/source-builder/sb/pkgconfig.py b/source-builder/sb/pkgconfig.py
index 99646f7..89b4d5c 100755
--- a/source-builder/sb/pkgconfig.py
+++ b/source-builder/sb/pkgconfig.py
@@ -43,7 +43,7 @@ import re
import shlex
import sys
-import path
+from . import path
def default_prefix(common = True):
paths = []
@@ -214,7 +214,12 @@ class package(object):
prefix = default_prefix()
if prefix:
self._log('prefix: %s' % (prefix))
- if type(prefix) is str or type(prefix) is unicode:
+ try:
+ if type(prefix) is unicode:
+ prefix = prefix.decode("utf-8", "ignore")
+ except:
+ pass
+ if type(prefix) is str:
prefix = str(prefix)
self.prefix = []
for p in prefix.split(os.pathsep):
diff --git a/source-builder/sb/python-wrapper.sh b/source-builder/sb/python-wrapper.sh
deleted file mode 100644
index c736a66..0000000
--- a/source-builder/sb/python-wrapper.sh
+++ /dev/null
@@ -1,39 +0,0 @@
-#
-# RTEMS Tools Project (http://www.rtems.org/)
-# Copyright 2018 Chris Johns (chrisj at 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 python2.7 python3 python
-do
- set +e
- py_cmd=$(command -v $py)
- set -e
- if test -n "$RTEMS_PYTHON_OVERRIDE"; then
- if test "$RTEMS_PYTHON_OVERRIDE" != "$py"; 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
diff --git a/source-builder/sb/reports.py b/source-builder/sb/reports.py
index e7870c4..34474f3 100644
--- a/source-builder/sb/reports.py
+++ b/source-builder/sb/reports.py
@@ -34,17 +34,17 @@ import pprint
pp = pprint.PrettyPrinter(indent = 2)
try:
- import build
- import check
- import config
- import error
- import git
- import log
- import options
- import path
- import setbuilder
- import sources
- import version
+ from . import build
+ from . import check
+ from . import config
+ from . import error
+ from . import git
+ from . import log
+ from . import options
+ from . import path
+ from . import setbuilder
+ from . import sources
+ from . import version
except KeyboardInterrupt:
print('user terminated', file = sys.stderr)
sys.exit(1)
diff --git a/source-builder/sb/rtemsconfig.py b/source-builder/sb/rtemsconfig.py
index 97ede7f..0ad6c5c 100644
--- a/source-builder/sb/rtemsconfig.py
+++ b/source-builder/sb/rtemsconfig.py
@@ -28,11 +28,11 @@ import sys
import threading
import time
-import error
-import log
-import options
-import path
-import version
+from . import error
+from . import log
+from . import options
+from . import path
+from . import version
def _collect(path_, file):
confs = []
diff --git a/source-builder/sb/setbuilder.py b/source-builder/sb/setbuilder.py
index a6efd75..02901d4 100644
--- a/source-builder/sb/setbuilder.py
+++ b/source-builder/sb/setbuilder.py
@@ -33,17 +33,17 @@ import sys
import textwrap
try:
- import build
- import check
- import error
- import log
- import mailer
- import options
- import path
- import reports
- import shell
- import sources
- import version
+ from . import build
+ from . import check
+ from . import error
+ from . import log
+ from . import mailer
+ from . import options
+ from . import path
+ from . import reports
+ from . import shell
+ from . import sources
+ from . import version
except KeyboardInterrupt:
print('abort: user terminated', file = sys.stderr)
sys.exit(1)
diff --git a/source-builder/sb/shell.py b/source-builder/sb/shell.py
index bebbe8a..f1e669a 100644
--- a/source-builder/sb/shell.py
+++ b/source-builder/sb/shell.py
@@ -25,10 +25,10 @@
from __future__ import print_function
try:
- import error
- import execute
- import log
- import options
+ from . import error
+ from . import execute
+ from . import log
+ from . import options
except KeyboardInterrupt:
print('abort: user terminated', file = sys.stderr)
sys.exit(1)
diff --git a/source-builder/sb/simhost.py b/source-builder/sb/simhost.py
index 13ab157..e3f759b 100644
--- a/source-builder/sb/simhost.py
+++ b/source-builder/sb/simhost.py
@@ -29,15 +29,15 @@ import datetime
import os
try:
- import build
- import check
- import error
- import git
- import log
- import macros
- import path
- import sources
- import version
+ from . import build
+ from . import check
+ from . import error
+ from . import git
+ from . import log
+ from . import macros
+ from . import path
+ from . import sources
+ from . import version
except KeyboardInterrupt:
print('abort: user terminated', file = sys.stderr)
sys.exit(1)
@@ -160,7 +160,7 @@ def find_bset_config(bset_config, macros):
#
class options(object):
def __init__(self, argv, argopts, defaults, extras):
- command_path = path.dirname(path.abspath(argv[1]))
+ command_path = path.dirname(path.abspath(argv[0]))
if len(command_path) == 0:
command_path = '.'
self.command_path = command_path
@@ -190,7 +190,7 @@ class options(object):
overrides = None
if os.name == 'nt':
try:
- import windows
+ from . import windows
overrides = windows.load()
host_windows = True
host_posix = False
@@ -200,26 +200,26 @@ class options(object):
uname = os.uname()
try:
if uname[0].startswith('MINGW64_NT'):
- import windows
+ from . import windows
overrides = windows.load()
host_windows = True
elif uname[0].startswith('CYGWIN_NT'):
- import windows
+ from . import windows
overrides = windows.load()
elif uname[0] == 'Darwin':
- import darwin
+ from . import darwin
overrides = darwin.load()
elif uname[0] == 'FreeBSD':
- import freebsd
+ from . import freebsd
overrides = freebsd.load()
elif uname[0] == 'NetBSD':
- import netbsd
+ from . import netbsd
overrides = netbsd.load()
elif uname[0] == 'Linux':
- import linux
+ from . import linux
overrides = linux.load()
elif uname[0] == 'SunOS':
- import solaris
+ from . import solaris
overrides = solaris.load()
except error.general as ge:
raise error.general('failed to load %s host support: %s' % (uname[0], ge))
diff --git a/source-builder/sb/solaris.py b/source-builder/sb/solaris.py
index 8d9498a..231fd34 100644
--- a/source-builder/sb/solaris.py
+++ b/source-builder/sb/solaris.py
@@ -25,9 +25,9 @@
import pprint
import os
-import check
-import error
-import execute
+from . import check
+from . import error
+from . import execute
def load():
uname = os.uname()
diff --git a/source-builder/sb/sources.py b/source-builder/sb/sources.py
index a619778..1d62cb7 100644
--- a/source-builder/sb/sources.py
+++ b/source-builder/sb/sources.py
@@ -21,7 +21,7 @@
# Manage sources and patches
#
-import log
+from . import log
def _args(args):
return [i for s in [ii.split() for ii in args] for i in s]
diff --git a/source-builder/sb/track.py b/source-builder/sb/track.py
index aef25b9..49344fe 100644
--- a/source-builder/sb/track.py
+++ b/source-builder/sb/track.py
@@ -31,12 +31,12 @@ import os
import sys
try:
- import build
- import error
- import git
- import log
- import simhost
- import version
+ from . import build
+ from . import error
+ from . import git
+ from . import log
+ from . import simhost
+ from . import version
except KeyboardInterrupt:
print('abort: user terminated', file = sys.stderr)
sys.exit(1)
@@ -138,7 +138,7 @@ def run(args = sys.argv):
action = 'store_true')
argsp.add_argument('bsets', nargs='*', help = 'Build sets.')
- argopts = argsp.parse_args(args[2:])
+ argopts = argsp.parse_args(args[1:])
simhost.load_log(argopts.log)
log.notice('RTEMS Source Builder - Track Dependencies, %s' % (version.string()))
diff --git a/source-builder/sb/version.py b/source-builder/sb/version.py
index 721c459..29d2dc5 100644
--- a/source-builder/sb/version.py
+++ b/source-builder/sb/version.py
@@ -76,9 +76,9 @@ from __future__ import print_function
import os
import sys
-import error
-import git
-import path
+from . import error
+from . import git
+from . import path
#
# Default to an internal string.
diff --git a/source-builder/sb/windows.py b/source-builder/sb/windows.py
index 1eb51a0..ceca24f 100644
--- a/source-builder/sb/windows.py
+++ b/source-builder/sb/windows.py
@@ -24,9 +24,9 @@
import os
import sys
-import error
-import execute
-import path
+from . import error
+from . import execute
+from . import path
def load():
# Default to the native Windows Python.
--
2.24.1
More information about the devel
mailing list