Exemple #1
0
def main():
    """Provide main entrypoint for test execution."""
    parser = argparse.ArgumentParser(
        description='run the units (installed or in tree)')
    parser.add_argument(
        '-i',
        '--installed',
        action='store_false',
        dest='in_tree',
        help='run tests using installed library',
    )
    parser.add_argument(
        '-t',
        '--in-tree',
        action='store_true',
        dest='in_tree',
        help='run tests using devel tree',
    )

    parser.set_defaults(in_tree=False, )

    options = parser.parse_args()

    if options.in_tree:
        # Run the tests 'in the tree'
        # Rather than testing with installed versions run the test
        # with the package built in this tree.

        build_dir = get_build_dir()
        if build_dir and os.path.exists(build_dir):
            print("Using local libraries from tree, located here:\n%s\n" %
                  build_dir)
            sys.path.insert(0, build_dir)
        else:
            print('ERROR: Unable to locate in tree libraries', file=sys.stderr)
            return 2
    else:
        print('Using installed libraries')

    num_failures = run_tests()

    if num_failures == 0:
        return 0
    else:
        return 1
Exemple #2
0
    def __init__(self, target, machine, build, toolchain, available_features=[]):
        self.available_features = available_features
        self.host_platform = self.detect_platform()
        self.host_machine = self.detect_machine()
        self.flags = {}

        if target is None:
            target = self.host_platform

        if machine is None:
            machine = self.host_machine

        if toolchain is None:
            if self.host_platform == 'windows':
                raise Exception(
                    'must specify toolchain on Windows (msvs or gnu)')
            else:
                toolchain = 'gnu'

        if build is None:
            build = 'debug'

        if not build in ['debug', 'release']:
            raise Exception("invalid build type")

        if target not in ['windows', 'osx', 'linux', 'bsd']:
            raise Exception("invalid target platform")

        if machine.lower() not in ['x86_64', 'x86', 'i686', 'i586',
                                   'alpha', 'hppa', 'mips', 'mipsel', 's390',
                                   'sparc', 'ia64', 'armel', 'armhf', 'hurd-i386',
                                   'sh3', 'sh4',
                                   'kfreebsd-amd64', 'kfreebsd-i386',
                                   'i486', 'i386', 'ppc', 'ppc64', 'powerpc',
                                   'powerpc64', 'powerpcspe', 's390x',
                                   'amd64', 'em64t', 'intel64', 'arm64',
                                   'ppc64el']:
            raise Exception("invalid machine type")

        if toolchain not in ['gnu', 'msvs']:
            raise Exception('invalid toolchain type')

        if toolchain == 'msvs' and self.host_platform != 'windows':
            raise Exception(
                'cannot use msvs toolchain on non-windows platform')

        self.platform = target
        self.platform_is_posix = self.platform in ['linux', 'osx', 'bsd']
        self.platform_is_linux = self.platform == 'linux'
        self.platform_is_osx = self.platform == 'osx'
        self.platform_is_bsd = self.platform == 'bsd'
        self.platform_is_windows = self.platform == 'windows'

        self.machine = machine
        self.build = build
        self.build_is_debug = build == 'debug'
        self.build_is_release = build == 'release'

        self.toolchain = toolchain
        self.toolchain_is_gnu = self.toolchain == 'gnu'
        self.toolchain_is_msvs = self.toolchain == 'msvs'

        self.crosscompile = self.host_platform != self.platform

        flags_force32 = int(Script.ARGUMENTS.get('force32', 0))
        flags_force64 = int(Script.ARGUMENTS.get('force64', 0))
        if flags_force32 and flags_force64:
            logging.error('Both force32 and force64 cannot be enabled at once')
            Script.Exit(1)

        if flags_force32:
            if self.machine in ['powerpc', 'powerpc64', 'ppc', 'ppc64']:
                self.machine = 'powerpc'
            else:
                self.machine = 'x86'
        elif flags_force64:
            if self.machine in ['powerpc', 'powerpc64', 'ppc', 'ppc64']:
                self.machine = 'powerpc64'
            else:
                self.machine = 'x86_64'
        self.machine_is_64bit = self.machine.lower(
            ) in ['x86_64', 'powerpc64', 'ppc64', 'amd64', 'em64t', 'intel64']
        self.bitwidth = 64 if self.machine_is_64bit else 32
        self.architecture_is_x86 = self.machine.lower(
            ) in ['x86', 'x86_64', 'i386', 'i486', 'i586', 'i686', 'em64t',
                  'intel64', 'amd64']
        self.architecture_is_powerpc = self.machine.lower(
            ) in ['powerpc', 'powerpc64', 'ppc', 'ppc64']
        self.architecture_is_arm = self.machine.lower().startswith('arm')

        self.build_dir = util.get_build_dir(self.platform, self.bitwidth)

        # Currently this only works for Windows
        self.static_dependencies = int(Script.ARGUMENTS.get('staticlibs', 0))

        logging.info("Target Platform: %s" % self.platform)
        logging.info("Target Machine: %s" % self.machine)
        logging.info("Build: %s" % self.build)
        logging.info("Toolchain: %s" % self.toolchain)
        logging.info(
            "Crosscompile: %s" % ("YES" if self.crosscompile else "NO"))
        if self.platform_is_windows:
            logging.info("Static dependencies: %s" % (
                "YES" if self.static_dependencies else "NO"))

        if self.crosscompile:
            logging.info("Host Platform: %s" % self.host_platform)
            logging.info("Host Machine: %s" % self.host_machine)

        if self.crosscompile and self.host_platform != 'linux':
            raise Exception(
                'Cross-compiling on a non-Linux host not currently supported')

        tools = ['default']
        toolpath = ['#build/']
        extra_arguments = {}
        import depends
        if int(Script.ARGUMENTS.get('qt5', 0)):
            tools.append('qt5')
            if self.machine_is_64bit:
                default_qtdir = depends.Qt.DEFAULT_QT5DIRS64.get(
                    self.platform, '')
            else:
                default_qtdir = depends.Qt.DEFAULT_QT5DIRS32.get(
                    self.platform, '')
        else:
            tools.append('qt4')
            default_qtdir = depends.Qt.DEFAULT_QT4DIRS.get(self.platform, '')
        tools.append('protoc')

        # Ugly hack to check the qtdir argument
        qtdir = Script.ARGUMENTS.get('qtdir',
                                     os.environ.get('QTDIR', default_qtdir))

        # Validate the specified qtdir exists
        if not os.path.exists(qtdir):
            logging.error("QT path does not exist or QT4 is not installed.")
            logging.error(
                "Please specify your QT path by running 'scons qtdir=[path]'")
            Script.Exit(1)
        # And that it doesn't contain qt3
        elif qtdir.find("qt3") != -1 or qtdir.find("qt/3") != -1:
            logging.error("Mixxx now requires QT4 instead of QT3 - please use your QT4 path with the qtdir build flag.")
            Script.Exit(1)
        logging.info("Qt path: %s" % qtdir)

        # Previously this wasn't done for OSX, but I'm not sure why
        # -- rryan 6/8/2011
        extra_arguments['QTDIR'] = qtdir

        if self.platform_is_osx:
            tools.append('OSConsX')
            toolpath.append('#/build/osx/')
        if self.platform_is_windows and self.toolchain_is_msvs:
            # NOTE(rryan): Don't use the SCons mssdk tool since it does not
            # support x64.
            # In SConscript.env we use the MSVS tool to let you generate a
            # Visual Studio solution. Consider removing this.
            tools.extend(['msvs'])
            # SCons's built-in Qt tool attempts to link 'qt' into your binary if
            # you don't do this.
            extra_arguments['QT_LIB'] = ''
            # Causes SCons to bypass MSVC environment detection altogether
            # and depend on environment variables.
            # TODO(rryan): Expose SCons MSVC auto-detection options.
            extra_arguments['MSVC_USE_SCRIPT'] = None

        # Setup the appropriate toolchains for cross-compiling
        if self.crosscompile:
            if self.platform_is_windows:
                tools.append('crossmingw')
            if self.platform_is_osx:
                tools.append('crossosx')

        self.env = Script.Environment(
            tools=tools, toolpath=toolpath, ENV=os.environ,
            **extra_arguments)
        self.read_environment_variables()

        # Now that environment variables have been read, we can detect the compiler.
        self.compiler_is_gcc = 'gcc' in self.env['CC']
        self.compiler_is_clang = 'clang' in self.env['CC']

        self.virtualize_build_dir()

        if self.toolchain_is_gnu:
            if flags_force32:
                self.env.Append(CCFLAGS='-m32')
            elif flags_force64:
                self.env.Append(CCFLAGS='-m64')

        self.setup_platform_sdk()

        if self.platform_is_osx:
            if self.architecture_is_powerpc:
                self.env.Append(CCFLAGS='-arch ppc')
                self.env.Append(LINKFLAGS='-arch ppc')
            else:
                if self.bitwidth == 32:
                    self.env.Append(CCFLAGS='-arch i386')
                    self.env.Append(LINKFLAGS='-arch i386')
                elif self.bitwidth == 64:
                    self.env.Append(CCFLAGS='-arch x86_64')
                    self.env.Append(LINKFLAGS='-arch x86_64')

        if self.crosscompile:
            crosscompile_root = Script.ARGUMENTS.get('crosscompile_root', '')

            if crosscompile_root == '':
                print "Your build setup indicates this is a cross-compile, but you did not specify 'crosscompile_root', which is required."
                Script.Exit(1)

            crosscompile_root = os.path.abspath(crosscompile_root)
            self.env.Append(CPPPATH=os.path.join(crosscompile_root, 'include'))
            self.env.Append(LIBPATH=os.path.join(crosscompile_root, 'lib'))
            self.env.Append(LIBPATH=os.path.join(crosscompile_root, 'bin'))

        self.install_options()
Exemple #3
0
    def __init__(self, target, machine, build, toolchain, available_features=[]):
        self.available_features = available_features
        self.host_platform = self.detect_platform()
        self.host_machine = self.detect_machine()
        self.flags = {}

        if target is None:
            target = self.host_platform

        if machine is None:
            machine = self.host_machine

        if toolchain is None:
            if self.host_platform == 'windows':
                raise Exception('must specify toolchain on Windows (msvs or gnu)')
            else:
                toolchain = 'gnu'

        if build is None:
            build = 'debug'

        if not build in ['debug', 'release']:
            raise Exception("invalid build type")

        if target not in ['windows', 'osx', 'linux', 'bsd']:
            raise Exception("invalid target platform")

        if machine not in ['x86_64', 'x86', 'i686', 'i586',
                           'alpha', 'hppa', 'mips', 'mipsel', 's390',
                           'sparc', 'ia64', 'armel', 'armhf', 'hurd-i386',
                           'sh3', 'sh4',
                           'kfreebsd-amd64', 'kfreebsd-i386',
                           'i486', 'i386', 'powerpc', 'powerpc64',
                           'powerpcspe', 's390x',
                           'amd64', 'AMD64', 'EM64T', 'INTEL64']:
            raise Exception("invalid machine type")

        if toolchain not in ['gnu', 'msvs']:
            raise Exception('invalid toolchain type')

        if toolchain == 'msvs' and self.host_platform != 'windows':
            raise Exception('cannot use msvs toolchain on non-windows platform')

        self.platform = target
        self.platform_is_posix = self.platform in ['linux', 'osx', 'bsd']
        self.platform_is_linux = self.platform == 'linux'
        self.platform_is_osx = self.platform == 'osx'
        self.platform_is_bsd = self.platform == 'bsd'
        self.platform_is_windows = self.platform == 'windows'

        self.machine = machine
        self.build = build
        self.build_is_debug = build == 'debug'
        self.build_is_release = build == 'release'

        self.toolchain = toolchain
        self.toolchain_is_gnu = self.toolchain == 'gnu'
        self.toolchain_is_msvs = self.toolchain == 'msvs'

        self.crosscompile = self.host_platform != self.platform

        flags_force32 = int(Script.ARGUMENTS.get('force32', 0))
        flags_force64 = int(Script.ARGUMENTS.get('force64', 0))
        if flags_force32 and flags_force64:
            logging.error('Both force32 and force64 cannot be enabled at once')
            Script.Exit(1)

        if flags_force32:
            if self.machine in ['powerpc', 'powerpc64']:
                self.machine = 'powerpc'
            else:
                self.machine = 'x86'
        elif flags_force64:
            if self.machine in ['powerpc', 'powerpc64']:
                self.machine = 'powerpc64'
            else:
                self.machine = 'x86_64'
        self.machine_is_64bit = self.machine in ['x86_64', 'powerpc64', 'AMD64', 'EM64T', 'INTEL64']
        self.bitwidth = 64 if self.machine_is_64bit else 32
        self.architecture_is_x86 = self.machine.lower() in ['x86', 'x86_64', 'i386', 'i486', 'i586', 'i686', 'EM64T', 'INTEL64']
        self.architecture_is_powerpc = self.machine.lower() in ['powerpc', 'powerpc64']

        self.build_dir = util.get_build_dir(self.platform, self.bitwidth)

        # Currently this only works for Windows
        self.static_dependencies = int(Script.ARGUMENTS.get('staticlibs', 0))
        self.msvcdebug = int(Script.ARGUMENTS.get('msvcdebug', 0))

        logging.info("Target Platform: %s" % self.platform)
        logging.info("Target Machine: %s" % self.machine)
        logging.info("Build: %s" % self.build)
        logging.info("Toolchain: %s" % self.toolchain)
        logging.info("Crosscompile: %s" % ("YES" if self.crosscompile else "NO"))
        if self.platform_is_windows:
            logging.info("Static dependencies: %s" % ("YES" if self.static_dependencies else "NO"))
            logging.info("MSVC Debug build: %s" % ("YES" if self.msvcdebug else "NO"))

        if self.crosscompile:
            logging.info("Host Platform: %s" % self.host_platform)
            logging.info("Host Machine: %s" % self.host_machine)

        if self.crosscompile and self.host_platform != 'linux':
            raise Exception('Cross-compiling on a non-Linux host not currently supported')

        tools = ['default']
        toolpath = ['#build/']
        extra_arguments = {}
        tools.append('qt4')
        tools.append('protoc')

        # Ugly hack to check the qtdir argument
        import depends
        default_qtdir = depends.Qt.DEFAULT_QTDIRS.get(self.platform, '')
        qtdir = Script.ARGUMENTS.get('qtdir',
                                    os.environ.get('QTDIR', default_qtdir))

        # Validate the specified qtdir exists
        if not os.path.exists(qtdir):
            logging.error("QT path does not exist or QT4 is not installed.")
            logging.error("Please specify your QT path by running 'scons qtdir=[path]'")
            Script.Exit(1)
        # And that it doesn't contain qt3
        elif qtdir.find("qt3") != -1 or qtdir.find("qt/3") != -1:
            logging.error("Mixxx now requires QT4 instead of QT3 - please use your QT4 path with the qtdir build flag.")
            Script.Exit(1)
        logging.info("Qt path: %s" % qtdir)

        # Previously this wasn't done for OSX, but I'm not sure why
        # -- rryan 6/8/2011
        extra_arguments['QTDIR'] = qtdir

        if self.platform == 'osx':
            tools.append('OSConsX')
            toolpath.append('#/build/osx/')
        if self.platform_is_windows and self.toolchain == 'msvs':
            toolpath.append('msvs')
            extra_arguments['VCINSTALLDIR'] = os.getenv('VCInstallDir') # TODO(XXX) Why?
            extra_arguments['QT_LIB'] = '' # TODO(XXX) Why?

        # Setup the appropriate toolchains for cross-compiling
        if self.crosscompile:
            if self.platform_is_windows:
                tools.append('crossmingw')
            if self.platform == 'osx':
                tools.append('crossosx')

        self.env = Script.Environment(tools=tools, toolpath=toolpath, ENV=os.environ,
                                     **extra_arguments)

        self.read_environment_variables()

        if self.toolchain_is_gnu:
            if flags_force32:
                self.env.Append(CCFLAGS = '-m32')
            elif flags_force64:
                self.env.Append(CCFLAGS = '-m64')

        if self.platform == 'osx':
            if self.machine == 'powerpc':
                self.env.Append(CCFLAGS = '-arch ppc')
                self.env.Append(LINKFLAGS = '-arch ppc')
            else:
                if self.bitwidth == 32:
                    self.env.Append(CCFLAGS = '-arch i386')
                    self.env.Append(LINKFLAGS = '-arch i386')
                elif self.bitwidth == 64:
                    self.env.Append(CCFLAGS = '-arch x86_64')
                    self.env.Append(LINKFLAGS = '-arch x86_64')

        if self.crosscompile:
            crosscompile_root = Script.ARGUMENTS.get('crosscompile_root', '')

            if crosscompile_root == '':
                print "Your build setup indicates this is a cross-compile, but you did not specify 'crosscompile_root', which is required."
                Script.Exit(1)

            crosscompile_root = os.path.abspath(crosscompile_root)
            self.env.Append(CPPPATH=os.path.join(crosscompile_root, 'include'))
            self.env.Append(LIBPATH=os.path.join(crosscompile_root, 'lib'))
            self.env.Append(LIBPATH=os.path.join(crosscompile_root, 'bin'))

        self.install_options()
        self.virtualize_build_dir()
Exemple #4
0
    def __init__(self, target, machine, build, toolchain, available_features):
        self.available_features = available_features
        self.host_platform = self.detect_platform()
        self.host_machine = self.detect_machine()
        self.flags = {}

        if target is None:
            target = self.host_platform

        if machine is None:
            machine = self.host_machine

        if toolchain is None:
            if self.host_platform == "windows":
                raise Exception("must specify toolchain on Windows (msvs or gnu)")
            else:
                toolchain = "gnu"

        if build is None:
            build = "debug"

        if not build in ["debug", "release"]:
            raise Exception("invalid build type")

        if target not in ["windows", "osx", "linux", "bsd"]:
            raise Exception("invalid target platform")

        if machine.lower() not in [
            "x86_64",
            "x86",
            "i686",
            "i586",
            "alpha",
            "hppa",
            "mips",
            "mipsel",
            "s390",
            "sparc",
            "ia64",
            "armel",
            "armhf",
            "hurd-i386",
            "sh3",
            "sh4",
            "kfreebsd-amd64",
            "kfreebsd-i386",
            "i486",
            "i386",
            "ppc",
            "ppc64",
            "powerpc",
            "powerpc64",
            "powerpcspe",
            "s390x",
            "amd64",
            "em64t",
            "intel64",
            "arm64",
            "ppc64el",
        ]:
            raise Exception("invalid machine type")

        if toolchain not in ["gnu", "msvs"]:
            raise Exception("invalid toolchain type")

        if toolchain == "msvs" and self.host_platform != "windows":
            raise Exception("cannot use msvs toolchain on non-windows platform")

        self.platform = target
        self.platform_is_posix = self.platform in ["linux", "osx", "bsd"]
        self.platform_is_linux = self.platform == "linux"
        self.platform_is_osx = self.platform == "osx"
        self.platform_is_bsd = self.platform == "bsd"
        self.platform_is_windows = self.platform == "windows"

        self.machine = machine
        self.build = build
        self.build_is_debug = build == "debug"
        self.build_is_release = build == "release"

        self.toolchain = toolchain
        self.toolchain_is_gnu = self.toolchain == "gnu"
        self.toolchain_is_msvs = self.toolchain == "msvs"

        self.crosscompile = self.host_platform != self.platform

        flags_force32 = int(Script.ARGUMENTS.get("force32", 0))
        flags_force64 = int(Script.ARGUMENTS.get("force64", 0))
        if flags_force32 and flags_force64:
            logging.error("Both force32 and force64 cannot be enabled at once")
            Script.Exit(1)

        if flags_force32:
            if self.machine in ["powerpc", "powerpc64", "ppc", "ppc64"]:
                self.machine = "powerpc"
            else:
                self.machine = "x86"
        elif flags_force64:
            if self.machine in ["powerpc", "powerpc64", "ppc", "ppc64"]:
                self.machine = "powerpc64"
            else:
                self.machine = "x86_64"
        self.machine_is_64bit = self.machine.lower() in ["x86_64", "powerpc64", "ppc64", "amd64", "em64t", "intel64"]
        self.bitwidth = 64 if self.machine_is_64bit else 32
        self.architecture_is_x86 = self.machine.lower() in [
            "x86",
            "x86_64",
            "i386",
            "i486",
            "i586",
            "i686",
            "em64t",
            "intel64",
            "amd64",
        ]
        self.architecture_is_powerpc = self.machine.lower() in ["powerpc", "powerpc64", "ppc", "ppc64"]
        self.architecture_is_arm = self.machine.lower().startswith("arm")

        self.build_dir = util.get_build_dir(self.platform, self.bitwidth)

        # Currently this only works for Windows
        self.static_dependencies = int(Script.ARGUMENTS.get("staticlibs", 0))

        logging.info("Target Platform: %s" % self.platform)
        logging.info("Target Machine: %s" % self.machine)
        logging.info("Build: %s" % self.build)
        logging.info("Toolchain: %s" % self.toolchain)
        logging.info("Crosscompile: %s" % ("YES" if self.crosscompile else "NO"))
        if self.platform_is_windows:
            logging.info("Static dependencies: %s" % ("YES" if self.static_dependencies else "NO"))

        if self.crosscompile:
            logging.info("Host Platform: %s" % self.host_platform)
            logging.info("Host Machine: %s" % self.host_machine)

        if self.crosscompile and self.host_platform != "linux":
            raise Exception("Cross-compiling on a non-Linux host not currently supported")

        tools = ["default"]
        toolpath = ["#build/"]
        extra_arguments = {}
        import depends

        if int(Script.ARGUMENTS.get("qt5", 0)):
            tools.append("qt5")
            if self.machine_is_64bit:
                default_qtdir = depends.Qt.DEFAULT_QT5DIRS64.get(self.platform, "")
            else:
                default_qtdir = depends.Qt.DEFAULT_QT5DIRS32.get(self.platform, "")
        else:
            tools.append("qt4")
            default_qtdir = depends.Qt.DEFAULT_QT4DIRS.get(self.platform, "")
        tools.append("protoc")

        # Ugly hack to check the qtdir argument
        qtdir = Script.ARGUMENTS.get("qtdir", os.environ.get("QTDIR", default_qtdir))

        # Validate the specified qtdir exists
        if not os.path.exists(qtdir):
            logging.error("QT path does not exist or QT4 is not installed.")
            logging.error("Please specify your QT path by running 'scons qtdir=[path]'")
            Script.Exit(1)
        # And that it doesn't contain qt3
        elif qtdir.find("qt3") != -1 or qtdir.find("qt/3") != -1:
            logging.error("Mixxx now requires QT4 instead of QT3 - please use your QT4 path with the qtdir build flag.")
            Script.Exit(1)
        logging.info("Qt path: %s" % qtdir)

        # Previously this wasn't done for OSX, but I'm not sure why
        # -- rryan 6/8/2011
        extra_arguments["QTDIR"] = qtdir

        if self.platform_is_osx:
            tools.append("OSConsX")
            toolpath.append("#/build/osx/")
        if self.platform_is_windows and self.toolchain_is_msvs:
            # NOTE(rryan): Don't use the SCons mssdk tool since it does not
            # support x64.
            # In SConscript.env we use the MSVS tool to let you generate a
            # Visual Studio solution. Consider removing this.
            tools.extend(["msvs"])
            # SCons's built-in Qt tool attempts to link 'qt' into your binary if
            # you don't do this.
            extra_arguments["QT_LIB"] = ""
            # Causes SCons to bypass MSVC environment detection altogether
            # and depend on environment variables.
            # TODO(rryan): Expose SCons MSVC auto-detection options.
            extra_arguments["MSVC_USE_SCRIPT"] = None

        # Setup the appropriate toolchains for cross-compiling
        if self.crosscompile:
            if self.platform_is_windows:
                tools.append("crossmingw")
            if self.platform_is_osx:
                tools.append("crossosx")

        self.env = Script.Environment(tools=tools, toolpath=toolpath, ENV=os.environ, **extra_arguments)
        self.read_environment_variables()

        # Now that environment variables have been read, we can detect the compiler.
        self.compiler_is_gcc = "gcc" in self.env["CC"]
        self.compiler_is_clang = "clang" in self.env["CC"]

        self.virtualize_build_dir()

        if self.toolchain_is_gnu:
            if flags_force32:
                self.env.Append(CCFLAGS="-m32")
            elif flags_force64:
                self.env.Append(CCFLAGS="-m64")

        self.setup_platform_sdk()

        if self.platform_is_osx:
            if self.architecture_is_powerpc:
                self.env.Append(CCFLAGS="-arch ppc")
                self.env.Append(LINKFLAGS="-arch ppc")
            else:
                if self.bitwidth == 32:
                    self.env.Append(CCFLAGS="-arch i386")
                    self.env.Append(LINKFLAGS="-arch i386")
                elif self.bitwidth == 64:
                    self.env.Append(CCFLAGS="-arch x86_64")
                    self.env.Append(LINKFLAGS="-arch x86_64")

        if self.crosscompile:
            crosscompile_root = Script.ARGUMENTS.get("crosscompile_root", "")

            if crosscompile_root == "":
                print "Your build setup indicates this is a cross-compile, but you did not specify 'crosscompile_root', which is required."
                Script.Exit(1)

            crosscompile_root = os.path.abspath(crosscompile_root)
            self.env.Append(CPPPATH=os.path.join(crosscompile_root, "include"))
            self.env.Append(LIBPATH=os.path.join(crosscompile_root, "lib"))
            self.env.Append(LIBPATH=os.path.join(crosscompile_root, "bin"))

        self.install_options()
Exemple #5
0
    def __init__(self,
                 target,
                 machine,
                 build,
                 toolchain,
                 available_features=[]):
        self.available_features = available_features
        self.host_platform = self.detect_platform()
        self.host_machine = self.detect_machine()
        self.flags = {}

        if target is None:
            target = self.host_platform

        if machine is None:
            machine = self.host_machine

        if toolchain is None:
            if self.host_platform == 'windows':
                raise Exception(
                    'must specify toolchain on Windows (msvs or gnu)')
            else:
                toolchain = 'gnu'

        if build is None:
            build = 'debug'

        if not build in ['debug', 'release']:
            raise Exception("invalid build type")

        if target not in ['windows', 'osx', 'linux', 'bsd']:
            raise Exception("invalid target platform")

        if machine not in [
                'x86_64', 'x86', 'i686', 'i586', 'alpha', 'hppa', 'mips',
                'mipsel', 's390', 'sparc', 'ia64', 'armel', 'armhf',
                'hurd-i386', 'sh3', 'sh4', 'kfreebsd-amd64', 'kfreebsd-i386',
                'i486', 'i386', 'powerpc', 'powerpc64', 'powerpcspe', 's390x',
                'amd64', 'AMD64', 'EM64T', 'INTEL64'
        ]:
            raise Exception("invalid machine type")

        if toolchain not in ['gnu', 'msvs']:
            raise Exception('invalid toolchain type')

        if toolchain == 'msvs' and self.host_platform != 'windows':
            raise Exception(
                'cannot use msvs toolchain on non-windows platform')

        self.platform = target
        self.platform_is_posix = self.platform in ['linux', 'osx', 'bsd']
        self.platform_is_linux = self.platform == 'linux'
        self.platform_is_osx = self.platform == 'osx'
        self.platform_is_bsd = self.platform == 'bsd'
        self.platform_is_windows = self.platform == 'windows'

        self.machine = machine
        self.build = build
        self.build_is_debug = build == 'debug'
        self.build_is_release = build == 'release'

        self.toolchain = toolchain
        self.toolchain_is_gnu = self.toolchain == 'gnu'
        self.toolchain_is_msvs = self.toolchain == 'msvs'

        self.crosscompile = self.host_platform != self.platform

        flags_force32 = int(Script.ARGUMENTS.get('force32', 0))
        flags_force64 = int(Script.ARGUMENTS.get('force64', 0))
        if flags_force32 and flags_force64:
            logging.error('Both force32 and force64 cannot be enabled at once')
            Script.Exit(1)

        if flags_force32:
            if self.machine in ['powerpc', 'powerpc64']:
                self.machine = 'powerpc'
            else:
                self.machine = 'x86'
        elif flags_force64:
            if self.machine in ['powerpc', 'powerpc64']:
                self.machine = 'powerpc64'
            else:
                self.machine = 'x86_64'
        self.machine_is_64bit = self.machine in [
            'x86_64', 'powerpc64', 'AMD64', 'EM64T', 'INTEL64'
        ]
        self.bitwidth = 64 if self.machine_is_64bit else 32
        self.architecture_is_x86 = self.machine.lower() in [
            'x86', 'x86_64', 'i386', 'i486', 'i586', 'i686', 'EM64T', 'INTEL64'
        ]
        self.architecture_is_powerpc = self.machine.lower() in [
            'powerpc', 'powerpc64'
        ]

        self.build_dir = util.get_build_dir(self.platform, self.bitwidth)

        # Currently this only works for Windows
        self.static_dependencies = int(Script.ARGUMENTS.get('staticlibs', 0))
        self.msvcdebug = int(Script.ARGUMENTS.get('msvcdebug', 0))

        logging.info("Target Platform: %s" % self.platform)
        logging.info("Target Machine: %s" % self.machine)
        logging.info("Build: %s" % self.build)
        logging.info("Toolchain: %s" % self.toolchain)
        logging.info("Crosscompile: %s" %
                     ("YES" if self.crosscompile else "NO"))
        if self.platform_is_windows:
            logging.info("Static dependencies: %s" %
                         ("YES" if self.static_dependencies else "NO"))
            logging.info("MSVC Debug build: %s" %
                         ("YES" if self.msvcdebug else "NO"))

        if self.crosscompile:
            logging.info("Host Platform: %s" % self.host_platform)
            logging.info("Host Machine: %s" % self.host_machine)

        if self.crosscompile and self.host_platform != 'linux':
            raise Exception(
                'Cross-compiling on a non-Linux host not currently supported')

        tools = ['default']
        toolpath = ['#build/']
        extra_arguments = {}
        tools.append('qt4')
        tools.append('protoc')

        # Ugly hack to check the qtdir argument
        import depends
        default_qtdir = depends.Qt.DEFAULT_QTDIRS.get(self.platform, '')
        qtdir = Script.ARGUMENTS.get('qtdir',
                                     os.environ.get('QTDIR', default_qtdir))

        # Validate the specified qtdir exists
        if not os.path.exists(qtdir):
            logging.error("QT path does not exist or QT4 is not installed.")
            logging.error(
                "Please specify your QT path by running 'scons qtdir=[path]'")
            Script.Exit(1)
        # And that it doesn't contain qt3
        elif qtdir.find("qt3") != -1 or qtdir.find("qt/3") != -1:
            logging.error(
                "Mixxx now requires QT4 instead of QT3 - please use your QT4 path with the qtdir build flag."
            )
            Script.Exit(1)
        logging.info("Qt path: %s" % qtdir)

        # Previously this wasn't done for OSX, but I'm not sure why
        # -- rryan 6/8/2011
        extra_arguments['QTDIR'] = qtdir

        if self.platform == 'osx':
            tools.append('OSConsX')
            toolpath.append('#/build/osx/')
        if self.platform_is_windows and self.toolchain == 'msvs':
            toolpath.append('msvs')
            extra_arguments['VCINSTALLDIR'] = os.getenv(
                'VCInstallDir')  # TODO(XXX) Why?
            extra_arguments['QT_LIB'] = ''  # TODO(XXX) Why?

        # Setup the appropriate toolchains for cross-compiling
        if self.crosscompile:
            if self.platform_is_windows:
                tools.append('crossmingw')
            if self.platform == 'osx':
                tools.append('crossosx')

        self.env = Script.Environment(tools=tools,
                                      toolpath=toolpath,
                                      ENV=os.environ,
                                      **extra_arguments)
        self.read_environment_variables()
        self.virtualize_build_dir()

        if self.toolchain_is_gnu:
            if flags_force32:
                self.env.Append(CCFLAGS='-m32')
            elif flags_force64:
                self.env.Append(CCFLAGS='-m64')

        if self.platform == 'osx':
            if self.machine == 'powerpc':
                self.env.Append(CCFLAGS='-arch ppc')
                self.env.Append(LINKFLAGS='-arch ppc')
            else:
                if self.bitwidth == 32:
                    self.env.Append(CCFLAGS='-arch i386')
                    self.env.Append(LINKFLAGS='-arch i386')
                elif self.bitwidth == 64:
                    self.env.Append(CCFLAGS='-arch x86_64')
                    self.env.Append(LINKFLAGS='-arch x86_64')

        if self.crosscompile:
            crosscompile_root = Script.ARGUMENTS.get('crosscompile_root', '')

            if crosscompile_root == '':
                print "Your build setup indicates this is a cross-compile, but you did not specify 'crosscompile_root', which is required."
                Script.Exit(1)

            crosscompile_root = os.path.abspath(crosscompile_root)
            self.env.Append(CPPPATH=os.path.join(crosscompile_root, 'include'))
            self.env.Append(LIBPATH=os.path.join(crosscompile_root, 'lib'))
            self.env.Append(LIBPATH=os.path.join(crosscompile_root, 'bin'))

        self.install_options()