Exemplo n.º 1
0
def interrogate():
    """ Runs interrogate over the source directory """

    # Collect source files and convert them to a relative path
    all_sources = find_sources(".")

    # Create the interrogate command
    cmd = [join(get_panda_bin_path(), 'interrogate')]

    if VERBOSE_LVL == 1:
        cmd += ["-v"]
    elif VERBOSE_LVL == 2:
        cmd += ["-vv"]

    cmd += ["-fnames", "-string", "-refcount", "-assert", "-python-native"]
    cmd += ["-S" + get_panda_include_path() + "/parser-inc"]
    cmd += ["-S" + get_panda_include_path() + "/"]

    # Add all subdirectories
    for pth in listdir("."):
        if isdir(pth):
            cmd += ["-I" + pth]

    cmd += ["-srcdir", "."]
    cmd += ["-oc", "interrogate_wrapper.cpp"]
    cmd += ["-od", "interrogate.in"]
    cmd += ["-module", MODULE_NAME]
    cmd += ["-library", MODULE_NAME]

    if PandaSystem.get_major_version() > 1 or PandaSystem.get_minor_version() > 9:
        # Add nomangle option, but only for recent builds
        cmd += ["-nomangle"]

    if PandaSystem.get_major_version() == 1 and PandaSystem.get_minor_version() < 10:
        # Old interrogate options cant handle volatile
        cmd += ["-Dvolatile="]

    # Defines required to parse the panda source
    defines = ["INTERROGATE", "CPPPARSER", "__STDC__=1", "__cplusplus=201103L"]

    if get_compiler_name() == "MSC":
        defines += ["__inline", "_X86_", "WIN32_VC", "WIN32", "_WIN32"]
        if is_64_bit():
            defines += ["WIN64_VC", "WIN64", "_WIN64"]
        # NOTE: this 1600 value is the version number for VC2010.
        defines += ["_MSC_VER=1600", '"__declspec(param)="', "__cdecl", "_near",
                    "_far", "__near", "__far", "__stdcall"]

    if get_compiler_name() == "GCC":
        defines += ['__attribute__\(x\)=']
        if is_64_bit():
            defines += ['_LP64']
        else:
            defines += ['__i386__']

    for define in defines:
        cmd += ["-D" + define]

    cmd += all_sources
    try_execute(*cmd, verbose=VERBOSE_LVL != 0)
Exemplo n.º 2
0
def interrogate_module():
    """ Runs the interrogate module command """

    # Create module command
    cmd = [join_abs(get_panda_bin_path(), "interrogate_module")]
    cmd += ["-python-native"]

    if PandaSystem.get_major_version() > 1 or PandaSystem.get_minor_version() > 9:
        # Older panda3d versions don't have this
        cmd += ["-import", "panda3d.core"]

    cmd += ["-module", MODULE_NAME]
    cmd += ["-library", MODULE_NAME]
    cmd += ["-oc", "interrogate_module.cpp"]
    cmd += ["interrogate.in"]

    try_execute(*cmd, verbose=VERBOSE_LVL != 0)
Exemplo n.º 3
0
def interrogate_module():
    """ Runs the interrogate module command """

    # Create module command
    cmd = [join_abs(get_panda_bin_path(), "interrogate_module")]
    cmd += ["-python-native"]

    if PandaSystem.get_major_version() > 1 or PandaSystem.get_minor_version(
    ) > 9:
        # Older panda3d versions don't have this
        cmd += ["-import", "panda3d.core"]

    cmd += ["-module", MODULE_NAME]
    cmd += ["-library", MODULE_NAME]
    cmd += ["-oc", "interrogate_module.cpp"]
    cmd += ["interrogate.in"]
    try_execute(*cmd)
Exemplo n.º 4
0
def interrogate():
    """ Runs interrogate over the source directory """

    # Collect source files and convert them to a relative path
    all_sources = find_sources(".")

    # Create the interrogate command
    cmd = [join(get_panda_bin_path(), 'interrogate')]

    if VERBOSE_LVL == 1:
        cmd += ["-v"]
    elif VERBOSE_LVL == 2:
        cmd += ["-vv"]

    cmd += ["-fnames", "-string", "-refcount", "-assert", "-python-native"]
    cmd += ["-S" + get_panda_include_path() + "/parser-inc"]
    cmd += ["-S" + get_panda_include_path() + "/"]

    # Add all subdirectories
    for pth in listdir("."):
        if isdir(pth):
            cmd += ["-I" + pth]

    cmd += ["-srcdir", "."]
    cmd += ["-oc", "interrogate_wrapper.cpp"]
    cmd += ["-od", "interrogate.in"]
    cmd += ["-module", MODULE_NAME]
    cmd += ["-library", MODULE_NAME]

    if PandaSystem.get_major_version() > 1 or PandaSystem.get_minor_version(
    ) > 9:
        # Add nomangle option, but only for recent builds
        cmd += ["-nomangle"]

    if PandaSystem.get_major_version(
    ) == 1 and PandaSystem.get_minor_version() < 10:
        # Old interrogate options cant handle volatile
        cmd += ["-Dvolatile="]

    # Defines required to parse the panda source
    defines = ["INTERROGATE", "CPPPARSER", "__STDC__=1", "__cplusplus=201103L"]

    if get_compiler_name() == "MSC":
        defines += ["__inline", "_X86_", "WIN32_VC", "WIN32", "_WIN32"]
        if is_64_bit():
            defines += ["WIN64_VC", "WIN64", "_WIN64"]
        # NOTE: this 1600 value is the version number for VC2010.
        defines += [
            "_MSC_VER=1600", '"__declspec(param)="', "__cdecl", "_near",
            "_far", "__near", "__far", "__stdcall"
        ]

    if get_compiler_name() == "GCC":
        defines += ['__attribute__\(x\)=']
        if is_64_bit():
            defines += ['_LP64']
        else:
            defines += ['__i386__']

    for define in defines:
        cmd += ["-D" + define]

    cmd += all_sources
    try_execute(*cmd)
Exemplo n.º 5
0
def run_cmake(config, args):
    """ Runs cmake in the output dir """

    configuration = "Release"
    if config["generate_pdb"].lower() in ["1", "true", "yes", "y"]:
        configuration = "RelWithDebInfo"

    cmake_args = ["-DCMAKE_BUILD_TYPE=" + configuration]
    cmake_args += ["-DPYTHON_EXECUTABLE:STRING=" + sys.executable]
    cmake_args += ["-DPROJECT_NAME:STRING=" + config["module_name"]]

    lib_prefix = "lib" if is_windows() else ""

    # Check for the right interrogate lib
    if PandaSystem.get_major_version() > 1 or PandaSystem.get_minor_version(
    ) > 9:
        cmake_args += [
            "-DINTERROGATE_LIB:STRING=" + lib_prefix + "p3interrogatedb"
        ]
    else:

        # Buildbot versions do not have the core lib, instead try using libpanda
        if not isfile(join_abs(get_panda_lib_path(), "core.lib")):
            cmake_args += ["-DINTERROGATE_LIB:STRING=" + lib_prefix + "panda"]
        else:
            cmake_args += ["-DINTERROGATE_LIB:STRING=core"]

    if is_windows():
        # Specify 64-bit compiler when using a 64 bit panda sdk build
        bit_suffix = " Win64" if is_64_bit() else ""
        cmake_args += ["-G" + get_panda_mscv_version().cmake_str + bit_suffix]
    elif is_macos():
        # Panda is 64-bit only on macOS.
        cmake_args += ["-DCMAKE_CL_64:STRING=1"]

    # Specify python version, once as integer, once seperated by a dot
    pyver = "{}{}".format(sys.version_info.major, sys.version_info.minor)
    pyver_dot = "{}.{}".format(sys.version_info.major, sys.version_info.minor)

    if is_windows():
        cmake_args += ["-DPYTHONVER:STRING=" + pyver]

    if is_linux() or is_freebsd() or is_macos():
        cmake_args += ["-DPYTHONVERDOT:STRING=" + pyver_dot]

    # Libraries
    def is_required(lib):
        if "require_lib_" + lib in config and config["require_lib_" +
                                                     lib] in ["1", "yes", "y"]:
            return True
        return False

    """
    if is_required("eigen"):
        if not have_eigen():
            fatal_error("Your Panda3D build was not compiled with eigen support, but it is required!")
    """
    # Eigen is always included in 1.9.1 and up
    cmake_args += ["-DHAVE_LIB_EIGEN=TRUE"]

    if is_required("bullet"):
        if not have_bullet():
            fatal_error(
                "Your Panda3D build was not compiled with bullet support, but it is required!"
            )
        cmake_args += ["-DHAVE_LIB_BULLET=TRUE"]

    if is_required("freetype"):
        if not have_freetype():
            fatal_error(
                "Your Panda3D build was not compiled with freetype support, but it is required!"
            )
        cmake_args += ["-DHAVE_LIB_FREETYPE=TRUE"]

    # Optimization level
    optimize = 3

    if args.optimize is None:
        # No optimization level set. Try to find it in the config
        if "optimize" in config:
            optimize = config["optimize"]
    else:
        optimize = args.optimize

    # Verbose level
    if "verbose_igate" in config:
        cmake_args += ["-DIGATE_VERBOSE=" + str(config["verbose_igate"])]
    else:
        cmake_args += ["-DIGATE_VERBOSE=0"]

    cmake_args += ["-DOPTIMIZE=" + str(optimize)]

    output = try_execute("cmake",
                         join_abs(get_script_dir(), ".."),
                         *cmake_args,
                         error_formatter=handle_cmake_error)
Exemplo n.º 6
0
def run_cmake(config, args):
    """ Runs cmake in the output dir """

    configuration = "Release"
    if config["generate_pdb"].lower() in ["1", "true", "yes", "y"]:
        configuration = "RelWithDebInfo"

    cmake_args = ["-DCMAKE_BUILD_TYPE=" + configuration]
    cmake_args += ["-DPYTHON_EXECUTABLE:STRING=" + sys.executable]
    cmake_args += ["-DPROJECT_NAME:STRING=" + config["module_name"]]

    lib_prefix = "lib" if is_windows() else ""

    # Check for the right interrogate lib
    if PandaSystem.get_major_version() > 1 or PandaSystem.get_minor_version() > 9:
        cmake_args += ["-DINTERROGATE_LIB:STRING=" + lib_prefix + "p3interrogatedb"]
    else:

        # Buildbot versions do not have the core lib, instead try using libpanda
        if not isfile(join_abs(get_panda_lib_path(), "core.lib")):
            cmake_args += ["-DINTERROGATE_LIB:STRING=" + lib_prefix + "panda"]
        else:
            cmake_args += ["-DINTERROGATE_LIB:STRING=core"]

    if is_windows():
        # Specify 64-bit compiler when using a 64 bit panda sdk build
        bit_suffix = " Win64" if is_64_bit() else ""
        cmake_args += ["-G" + get_panda_mscv_version().cmake_str + bit_suffix]
    elif is_macos():
        # Panda is 64-bit only on macOS.
        cmake_args += ["-DCMAKE_CL_64:STRING=1"]

    # Specify python version, once as integer, once seperated by a dot
    pyver = "{}{}".format(sys.version_info.major, sys.version_info.minor)
    pyver_dot = "{}.{}".format(sys.version_info.major, sys.version_info.minor)

    if is_windows():
        cmake_args += ["-DPYTHONVER:STRING=" + pyver]

    if is_linux() or is_freebsd():
        cmake_args += ["-DPYTHONVERDOT:STRING=" + pyver_dot]

    # Libraries
    def is_required(lib):
        if "require_lib_" + lib in config and config["require_lib_" + lib] in ["1", "yes", "y"]:
            return True
        return False

    """
    if is_required("eigen"):
        if not have_eigen():
            fatal_error("Your Panda3D build was not compiled with eigen support, but it is required!")
    """
    # Eigen is always included in 1.9.1 and up
    cmake_args += ["-DHAVE_LIB_EIGEN=FALSE"]

    if is_required("bullet"):
        if not have_bullet():
            fatal_error("Your Panda3D build was not compiled with bullet support, but it is required!")
        cmake_args += ["-DHAVE_LIB_BULLET=TRUE"]

    if is_required("freetype"):
        if not have_freetype():
             fatal_error("Your Panda3D build was not compiled with freetype support, but it is required!")
        cmake_args += ["-DHAVE_LIB_FREETYPE=TRUE"]

    # Optimization level
    optimize = 3

    if args.optimize is None:
        # No optimization level set. Try to find it in the config
        if "optimize" in config:
            optimize = config["optimize"]
    else:
        optimize = args.optimize

    # Verbose level
    if "verbose_igate" in config:
        cmake_args += ["-DIGATE_VERBOSE=" + str(config["verbose_igate"])]
    else:
        cmake_args += ["-DIGATE_VERBOSE=0"]

    cmake_args += ["-DOPTIMIZE=" + str(optimize)]
    print("="*80)
    print( cmake_args )


    e = dict_as_nt(**os.environ)

    #cmake_args.append( f"-DCMAKE_REQUIRED_INCLUDES={PDK}/built/include" )
    print("="*80)
    cmake_args.append( f"-DPANDA_INCLUDE_DIR={e.PDK_PANDA3D}/built/include")
    cmake_args.append( f"-DPANDA_LIBRARY_DIRS={e.PDK_LIB_PANDA3D}")
    cmake_args.append( f"-DPANDA_LIBRARY_DIR={e.PDK_LIB_PANDA3D}")
    cmake_args.append( f"-DLOCAL_PANDA_PATH={e.DEV_APPDIR}/usr" )
    cmake_args.append( f"-DCMAKE_TOOLCHAIN_FILE={e.SDK}/build.{e.BITS}/toolchain.android.cmake" )
    cmake_args.append( f"-DFREETYPE_LIBRARY={e.PDK_LIB_PANDA3D}" )
    cmake_args.append( f"-DFREETYPE_INCLUDE_DIRS={e.PDK_FREETYPE}/include" )


    #====================================================
    #FIXME: target specific !
    cmake_args.append( f"-DCMAKE_MULTILIB_PATH=armv7" )
    cmake_args.append( f"-DPYTHON_INCLUDE_DIRS={e.PDK_PANDA3D}/thirdparty/android-libs-armv7a/python/include/python3.7m" )
    cmake_args.append( f"-DPYTHON_LIBRARIES={e.PDK_LIB_PYTHON}/libpython3.7m.so" )
    #-O3 -ffast-math
    cmake_args.append( f"-DPANDA_LDFLAGS=-fPIE -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -Wl,--fix-cortex-a8")
    cmake_args.append( f"-DPANDA_FLAGS=-fno-rtti -march=armv7-a")
    cmake_args.append( f"-DPANDA_CORE_PATH={e.PDK_LIB_PYTHON}/../lib/python3.7/site-packages/panda3d/core.cpython-37m.so")
    #======================================================================

    cmake_args.append( f"-DPYTHON_EXECUTABLE={e.PDK_PYTHON}" )
    #cmake_args.append( f"-DHAVE_LIB_EIGEN=0")
    cmake_args.append( f"-DPYTHONVERDOT=3.7m")
    cmake_args.append( f"-DOPTIMIZE=3" )
    cmake_args.append( f"-DSTDFLOAT_DOUBLE=1")

    #
    for libname in "panda pandaexpress p3dtool p3dtoolconfig p3direct p3interrogatedb p3framework".split(' '):
        cmake_args.append( f"-DPANDA_LIBRARY_{libname}={e.PDK_LIB_PANDA3D}/lib{libname}.so" )
    for arg in cmake_args:
        print(arg)
    print("="*80)
    print(f"LD_LIBRARY_PATH={e.LD_LIBRARY_PATH}", os.popen('which interrogate').read() )
    #raise SystemExit
    output = try_execute("cmake", join_abs(get_script_dir(), ".."), *cmake_args, error_formatter=handle_cmake_error)
Exemplo n.º 7
0
def interrogate(*cmd, includes=[]):
    """ Runs interrogate over the source directory """

    MAJ = PandaSystem.get_major_version()
    MIN = PandaSystem.get_minor_version()

    print(f"Panda3D {MAJ}.{MIN}")

    cmd = list(cmd)

    if VERBOSE_LVL == 1:
        cmd.append("-v")

    elif VERBOSE_LVL == 2:
        cmd.append("-vv")

    for include in includes:
        cmd.append("-S")
        cmd.append(include)

    # Add all subdirectories
    for pth in listdir(MODULE_PATH):
        if isdir(pth):
            cmd.append(f"-I{pth}")

    cmd.append("--oc")

    if "-c" in cmd:
        cmd.append(f"{BUILD_PATH}/interrogate_temp.cpp")
    else:
        cmd.append(f"{BUILD_PATH}/interrogate_wrapper.cpp")

    cmd.append("-srcdir")
    cmd.append(MODULE_PATH)

    if MAJ > 1 or MIN > 9:
        # Add nomangle option, but only for recent builds
        cmd += ["-nomangle"]

    cmd += ["-od", f"{BUILD_PATH}/interrogate.in"]
    cmd += ["-module", MODULE_NAME]
    cmd += ["-library", MODULE_NAME]

    if MAJ == 1 and MIN < 10:
        # Old interrogate options cant handle volatile
        cmd += ["-Dvolatile="]

    # Defines required to parse the panda source
    defines = ["INTERROGATE", "CPPPARSER", "__STDC__=1", "__cplusplus=201103L"]

    if get_compiler_name() == "MSC":
        print("Using MSC")
        defines += ["__inline", "_X86_", "WIN32_VC", "WIN32", "_WIN32"]
        if is_64_bit():
            defines += ["WIN64_VC", "WIN64", "_WIN64"]
        # NOTE: this 1600 value is the version number for VC2010.
        defines += [
            "_MSC_VER=1600", '"__declspec(param)="', "__cdecl", "_near",
            "_far", "__near", "__far", "__stdcall"
        ]
    elif get_compiler_name() == "GCC":
        print("Using gcc")
        defines += ['__attribute__\(x\)=']
        defines += ['__x86_64__', '_LP64']
        if 0:
            defines += ['__i386__']

    for define in defines:
        cmd += ["-D" + define]

    # Collect source files and convert them to a relative path
    all_sources = find_sources(MODULE_PATH)

    cmd += all_sources

    #print( ' '.join(cmd))
    #print()

    try_execute(*cmd)
Exemplo n.º 8
0
def run_cmake(config, args):
    """ Runs cmake in the output dir """

    configuration = "Release"
    if config["generate_pdb"].lower() in ["1", "true", "yes", "y"]:
        configuration = "RelWithDebInfo"

    cmake_args = ["-DCMAKE_BUILD_TYPE=" + configuration]
    cmake_args += ["-DPYTHON_EXECUTABLE:STRING=" + sys.executable]
    cmake_args += ["-DPROJECT_NAME:STRING=" + config["module_name"]]

    lib_prefix = "lib" if is_windows() else ""

    # Check for the right interrogate lib
    if PandaSystem.get_major_version() > 1 or PandaSystem.get_minor_version(
    ) > 9:
        cmake_args += [
            "-DINTERROGATE_LIB:STRING=" + lib_prefix + "p3interrogatedb"
        ]
    else:

        # Buildbot versions do not have the core lib, instead try using libpanda
        if not isfile(join_abs(get_panda_lib_path(), "core.lib")):
            cmake_args += ["-DINTERROGATE_LIB:STRING=" + lib_prefix + "panda"]
        else:
            cmake_args += ["-DINTERROGATE_LIB:STRING=core"]

    if is_windows():
        # Specify 64-bit compiler when using a 64 bit panda sdk build
        bit_suffix = " Win64" if is_64_bit() else ""
        cmake_args += ["-G" + config["vc_version"] + bit_suffix]

    # Specify python version, once as integer, once seperated by a dot
    pyver = "{}{}".format(sys.version_info.major, sys.version_info.minor)
    pyver_dot = "{}.{}".format(sys.version_info.major, sys.version_info.minor)

    if is_windows():
        cmake_args += ["-DPYTHONVER:STRING=" + pyver]

    if is_linux():
        cmake_args += ["-DPYTHONVERDOT:STRING=" + pyver_dot]

    # Libraries
    for lib in ["freetype", "bullet", "eigen"]:
        if "use_lib_" + lib in config and config["use_lib_" +
                                                 lib] in ["1", "yes", "y"]:
            cmake_args += ["-DUSE_LIB_" + lib.upper() + "=TRUE"]

    # Optimization level
    optimize = 3
    if args.optimize is None:
        # No optimization level set. Try to find it in the config
        if "optimize" in config:
            optimize = config["optimize"]
    else:
        optimize = args.optimize

    # Verbose level
    if "verbose_igate" in config:
        cmake_args += ["-DIGATE_VERBOSE=" + str(config["verbose_igate"])]
    else:
        cmake_args += ["-DIGATE_VERBOSE=0"]

    cmake_args += ["-DOPTIMIZE=" + str(optimize)]

    try_execute("C:\\Program Files (x86)\\CMake\\bin\\cmake",
                join_abs(get_script_dir(), ".."), *cmake_args)
Exemplo n.º 9
0
def run_cmake(config, args):
    """ Runs cmake in the output dir """

    configuration = "Release"
    if config["generate_pdb"].lower() in ["1", "true", "yes", "y"]:
        configuration = "RelWithDebInfo"

    cmake_args = ["-DCMAKE_BUILD_TYPE=" + configuration]
    cmake_args += ["-DPYTHON_EXECUTABLE:STRING=" + sys.executable]
    cmake_args += ["-DPROJECT_NAME:STRING=" + config["module_name"]]

    lib_prefix = "lib" if is_windows() else ""

    # Check for the right interrogate lib
    if PandaSystem.get_major_version() > 1 or PandaSystem.get_minor_version() > 9:
        cmake_args += ["-DINTERROGATE_LIB:STRING=" + lib_prefix + "p3interrogatedb"]
    else:

        # Buildbot versions do not have the core lib, instead try using libpanda
        if not isfile(join_abs(get_panda_lib_path(), "core.lib")):
            cmake_args += ["-DINTERROGATE_LIB:STRING=" + lib_prefix + "panda"]
        else:
            cmake_args += ["-DINTERROGATE_LIB:STRING=core"]

    if is_windows():
        # Specify 64-bit compiler when using a 64 bit panda sdk build
        bit_suffix = " Win64" if is_64_bit() else ""
        cmake_args += ["-G" + config["vc_version"] + bit_suffix]

    # Specify python version, once as integer, once seperated by a dot
    pyver = "{}{}".format(sys.version_info.major, sys.version_info.minor)
    pyver_dot = "{}.{}".format(sys.version_info.major, sys.version_info.minor)

    if is_windows():
        cmake_args += ["-DPYTHONVER:STRING=" + pyver]

    if is_linux():
        cmake_args += ["-DPYTHONVERDOT:STRING=" + pyver_dot]

    # Libraries
    for lib in ["freetype", "bullet", "eigen"]:
        if "use_lib_" + lib in config and config["use_lib_" + lib] in ["1", "yes", "y"]:
            cmake_args += ["-DUSE_LIB_" + lib.upper() + "=TRUE"]

    # Optimization level
    optimize = 3
    if args.optimize is None:
        # No optimization level set. Try to find it in the config
        if "optimize" in config:
            optimize = config["optimize"]
    else:
        optimize = args.optimize

    # Verbose level
    if "verbose_igate" in config:
        cmake_args += ["-DIGATE_VERBOSE=" + str(config["verbose_igate"])]
    else:
        cmake_args += ["-DIGATE_VERBOSE=0"]

    cmake_args += ["-DOPTIMIZE=" + str(optimize)]

    try_execute("cmake", join_abs(get_script_dir(), ".."), *cmake_args)