summaryrefslogtreecommitdiff
path: root/var/spack/repos/builtin/packages/jogl/package.py
blob: 7b7b04987e810e184438dc36a5345a11e8f7dca4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# Copyright 2013-2023 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)

import os

from spack.package import *


class Jogl(Package):
    """JOGL provides full access to the APIs in the OpenGL specification
    as well as nearly all vendor extensions."""

    homepage = "https://jogamp.org/jogl/www/"
    git = "https://github.com/WadeWalker/jogl.git"

    license("Apache-2.0")

    version("java-11-fixes", branch="java-11-fixes", submodules=True)

    depends_on("ant", type="build")
    depends_on("java", type=("build", "run"))
    depends_on("gluegen", type=("build", "run"))
    depends_on("gl", type="link")
    depends_on("glu", type="link")
    depends_on("libxcursor", type="link")

    # Xfree86 Video mode extentions is deprecated
    patch("noxf86vm.patch")

    phases = ["edit", "build", "install"]

    def edit(self, spec, prefix):
        common = join_path("make", "build-common.xml")
        filter_file("../../gluegen", spec["gluegen"].prefix, common)
        for target in ["nativewindow", "jogl", "newt"]:
            conf = join_path("make", "build-{0}.xml".format(target))
            filter_file(r'syslibset dir="\${env.TARGET_PLATFORM_ROOT}[^"]*"', "syslibset", conf)
            filter_file("/usr/include", spec["libxcursor"].prefix.include, conf)

    compiler_mapping = {"gcc": "gcc", "clang": "clang", "fj": "fcc"}

    def build(self, spec, prefix):
        cname = spec.compiler.name
        compiler = self.compiler_mapping.get(cname, "gcc")
        ant = spec["ant"].command
        antarg = ["-Dcommon.gluegen.build.done=true", "-Dgcc.compat.compiler={0}".format(compiler)]
        with working_dir("make"):
            ant(*antarg)

    def install(self, spec, prefix):
        mkdirp(prefix.lib)
        with working_dir(join_path("build", "jar")):
            install("*.jar", prefix.lib)
        with working_dir(join_path("build", "lib")):
            install("*.so", prefix.lib)

    def setup_build_environment(self, env):
        env.unset("CLASSPATH")

    def setup_run_environment(self, env):
        class_paths = find(prefix.lib, "*.jar")
        classpath = os.pathsep.join(class_paths)
        env.prepend_path("CLASSPATH", classpath)

    def setup_dependent_build_environment(self, env, dependent_spec):
        class_paths = find(prefix.lib, "*.jar")
        classpath = os.pathsep.join(class_paths)
        env.prepend_path("CLASSPATH", classpath)