{
    "app-id": "au.edu.uq.esys.escript",
    "runtime": "org.freedesktop.Platform",
    "runtime-version": "18.08",
    "sdk": "org.freedesktop.Sdk",
    "command": "run-escript",
    "cleanup": [
        "/app/man",
        "/app/share"
    ],
    "build-options" : {
        "cflags": "-O3 -fPIC",
        "cxxflags": "-O3 -fPIC"
    },
    "modules": [
                {
            "name": "python",
            "builddir": true,
            "buildsystem": "simple",
            "build-commands": [
                "./configure --prefix=/app --exec-prefix=/app --enable-shared",
                "make install -j`nproc --all`",
                "chmod 755 /app/lib/*"
            ],
            "sources": [
                {
                    "type": "archive",
                    "url": "https://www.python.org/ftp/python/3.7.2/Python-3.7.2.tgz",
                    "sha256": "f09d83c773b9cc72421abba2c317e4e6e05d919f9bcf34468e192b6a6c8e328d"
                }
            ]
        },
        {
            "name": "boost",
            "buildsystem": "simple",
            "build-commands": [
                "echo import sys > v.py",
                "echo ver=sys.version_info >> v.py",
                "echo \"print(\\\"%d.%d\\\"%(ver.major,ver.minor))\" >> v.py",
                "python3 v.py > VERSION",
                "sed -i 's+include/python$(version)+include/python$(version)m+g' ./tools/build/src/tools/python.jam",
                "./bootstrap.sh --with-python-version=`cat VERSION` --prefix=/app",
                "./b2 cxxflags=\"-fPIC\" --with-python --with-iostreams --with-random -j`nproc --all` install"
            ],
            "sources": [
                {
                    "type": "archive",
                    "url": "https://dl.bintray.com/boostorg/release/1.72.0/source/boost_1_72_0.tar.gz",
                    "sha256": "c66e88d5786f2ca4dbebb14e06b566fb642a1a6947ad8cc9091f9f445134143f"
                }
            ]
        },
        {
            "name": "hdf5",
            "sources": [
                {
                    "type": "git",
                    "url": "https://bitbucket.hdfgroup.org/scm/hdffv/hdf5.git",
                    "tag": "hdf5-1_10_5",
                    "commit": "dc9412f73acfd0f887f7a112533ea078fedd1f19"
                }
            ]
        },
        {
            "name": "netcdf-c",
            "sources": [
                {
                    "type": "archive",
                    "url": "https://mirror.sobukus.de/files/src/netcdf/netcdf-c-4.7.3.tar.gz",
                    "sha256": "8e8c9f4ee15531debcf83788594744bd6553b8489c06a43485a15c93b4e0448b"
                }
            ]
        },
        {
            "name": "netcdf-cxx",
            "sources": [
                {
                    "type": "archive",
                    "url":  "https://mirror.sobukus.de/files/src/netcdf/netcdf-cxx4-4.3.0.tar.gz",
                    "sha256": "e34fbc6aba243ec82c23e9ee99db2430555ada849c54c1f3ab081b0ddd0f5f30"
                }
            ]
        },
        {
            "name": "python3-numpy",
            "buildsystem": "simple",
            "build-commands": [
                "pip3 install --no-index --find-links=\"file://${PWD}\" --prefix=${FLATPAK_DEST} numpy"
            ],
            "sources": [
                {
                    "type": "file",
                    "url": "https://files.pythonhosted.org/packages/2b/26/07472b0de91851b6656cbc86e2f0d5d3a3128e7580f23295ef58b6862d6c/numpy-1.16.1.zip",
                    "sha256": "31d3fe5b673e99d33d70cfee2ea8fe8dccd60f265c3ed990873a88647e3dd288"
                }
            ]
        },
        {
            "name": "python3-pyproj",
            "buildsystem": "simple",
            "build-commands": [
                "pip3 install --no-index --find-links=\"file://${PWD}\" --prefix=${FLATPAK_DEST} pyproj"
            ],
            "sources": [
                {
                    "type": "file",
                    "url": "https://files.pythonhosted.org/packages/26/8c/1da0580f334718e04f8bbf74f0515a7fb8185ff96b2560ce080c11aa145b/pyproj-1.9.6.tar.gz",
                    "sha256": "e0c02b1554b20c710d16d673817b2a89ff94738b0b537aead8ecb2edc4c4487b"
                }
            ]
        },
        {
            "name": "python3-matplotlib",
            "buildsystem": "simple",
            "build-commands": [
                "pip3 install --no-index --find-links=\"file://${PWD}\" --prefix=${FLATPAK_DEST} matplotlib"
            ],
            "sources": [
                {
                    "type": "file",
                    "url": "https://files.pythonhosted.org/packages/c2/f7/c7b501b783e5a74cf1768bc174ee4fb0a8a6ee5af6afa92274ff964703e0/setuptools-40.8.0.zip",
                    "sha256": "6e4eec90337e849ade7103723b9a99631c1f0d19990d6e8412dc42f5ae8b304d"
                },
                {
                    "type": "file",
                    "url": "https://files.pythonhosted.org/packages/89/0c/653aec68e9cfb775c4fbae8f71011206e5e7fe4d60fcf01ea1a9d3bc957f/matplotlib-3.0.2.tar.gz",
                    "sha256": "c94b792af431f6adb6859eb218137acd9a35f4f7442cea57e4a59c54751c36af"
                },
                {
                    "type": "file",
                    "url": "https://files.pythonhosted.org/packages/c2/4b/137dea450d6e1e3d474e1d873cd1d4f7d3beed7e0dc973b06e8e10d32488/cycler-0.10.0.tar.gz",
                    "sha256": "cd7b2d1018258d7247a71425e9f26463dfb444d411c39569972f4ce586b0c9d8"
                },
                {
                    "type": "file",
                    "url": "https://files.pythonhosted.org/packages/b9/b8/6b32b3e84014148dcd60dd05795e35c2e7f4b72f918616c61fdce83d27fc/pyparsing-2.3.1.tar.gz",
                    "sha256": "66c9268862641abcac4a96ba74506e594c884e3f57690a696d21ad8210ed667a"
                },
                {
                    "type": "file",
                    "url": "https://files.pythonhosted.org/packages/ad/99/5b2e99737edeb28c71bcbec5b5dda19d0d9ef3ca3e92e3e925e7c0bb364c/python-dateutil-2.8.0.tar.gz",
                    "sha256": "c89805f6f4d64db21ed966fda138f8a5ed7a4fdbc1a8ee329ce1b74e3c74da9e"
                },
                {
                    "type": "file",
                    "url": "https://files.pythonhosted.org/packages/31/60/494fcce70d60a598c32ee00e71542e52e27c978e5f8219fae0d4ac6e2864/kiwisolver-1.0.1.tar.gz",
                    "sha256": "ce3be5d520b4d2c3e5eeb4cd2ef62b9b9ab8ac6b6fedbaa0e39cdb6f50644278"
                },
                {
                    "type": "file",
                    "url": "https://files.pythonhosted.org/packages/dd/bf/4138e7bfb757de47d1f4b6994648ec67a51efe58fa907c1e11e350cddfca/six-1.12.0.tar.gz",
                    "sha256": "d16a0141ec1a18405cd4ce8b4613101da75da0e9a7aec5bdd4fa804d0e0eba73"
                },
                {
                    "type": "file",
                    "url": "https://files.pythonhosted.org/packages/54/85/514ba3ca2a022bddd68819f187ae826986051d130ec5b972076e4f58a9f3/setuptools_scm-3.2.0.tar.gz",
                    "sha256": "52ab47715fa0fc7d8e6cd15168d1a69ba995feb1505131c3e814eb7087b57358"
                },
                {
                    "type": "file",
                    "url": "https://files.pythonhosted.org/packages/d9/7d/86df15e317027f6e87aa68ea854abf8437e796b4c0fadd3ae5ee67b77cb2/wheel-0.33.0.tar.gz",
                    "sha256": "12363e6df5678ecf9daf8429f06f97e7106e701405898f24318ce7f0b79c611a"
                }
            ]
        },
        {
            "name": "python3-sympy",
            "buildsystem": "simple",
            "build-commands": [
                "pip3 install --no-index --find-links=\"file://${PWD}\" --prefix=${FLATPAK_DEST} sympy"
            ],
            "sources": [
                {
                    "type": "file",
                    "url": "https://files.pythonhosted.org/packages/ca/63/3384ebb3b51af9610086b23ea976e6d27d6d97bf140a76a365bd77a3eb32/mpmath-1.1.0.tar.gz",
                    "sha256": "fc17abe05fbab3382b61a123c398508183406fa132e0223874578e20946499f6"
                },
                {
                    "type": "file",
                    "url": "https://files.pythonhosted.org/packages/dd/f6/ed485ff22efdd7b371d0dbbf6d77ad61c3b3b7e0815a83c89cbb38ce35de/sympy-1.3.tar.gz",
                    "sha256": "e1319b556207a3758a0efebae14e5e52c648fc1db8975953b05fff12b6871b54"
                }
            ]
        },
        {
            "name": "gmsh",
            "buildsystem": "cmake",
            "config-opts": [
                "-DDEFAULT=0",
                "-DENABLE_BUILD_LIB=1",
                "-DENABLE_POST=1",
                "-DENABLE_PARSER=1"
            ],
            "sources": [
                {
                    "type": "archive",
                    "url": "http://gmsh.info/src/gmsh-4.1.5-source.tgz",
                    "sha256": "654d38203f76035a281006b77dcb838987a44fd549287f11c53a1e9cdf598f46"
                }
            ]
        },
        {
            "name": "scons",
            "buildsystem": "simple",
            "build-commands": [
                "python3 bootstrap.py build/scons",
                "python3 build/scons/setup.py install --prefix=/app"
            ],
            "sources": [
                {
                    "type": "git",
                    "url": "https://github.com/SCons/scons",
                    "tag": "3.0.4",
                    "commit": "73b2c02d7088c6d6490fdede8396d88103b00482"
                }
            ]
        },
        {
            "name": "escript",
            "buildsystem": "simple",
            "build-commands": [
                "mkdir -p /app/share/icons/hicolor/64x64/apps",
                "mkdir -p /app/share/icons/hicolor/128x128/apps/",
                "mkdir -p /app/share/icons/hicolor/256x256/apps/",
                "mkdir -p /app/share/applications/",
                "mkdir -p /app/share/metainfo",
                "cp ./tools/flatpak/64x64_au.edu.uq.esys.escript.png /app/share/icons/hicolor/64x64/apps/au.edu.uq.esys.escript.png",
                "cp ./tools/flatpak/128x128_au.edu.uq.esys.escript.png /app/share/icons/hicolor/128x128/apps/au.edu.uq.esys.escript.png",
                "cp ./tools/flatpak/256x256_au.edu.uq.esys.escript.png /app/share/icons/hicolor/256x256/apps/au.edu.uq.esys.escript.png",
                "cp ./tools/flatpak/au.edu.uq.esys.escript.desktop /app/share/applications/au.edu.uq.esys.escript.desktop",
                "cp ./tools/flatpak/au.edu.uq.esys.escript.appdata.xml /app/share/metainfo/au.edu.uq.esys.escript.appdata.xml",
                "scons options_file=scons/flatpak_options.py umfpack=0 trilinos=0 werror=0 silo=0 cxx_extra='-fPIC -Wno-psabi' -j`nproc --all`"
            ],
            "sources": [
                {
                    "type": "git",
                    "url": "https://github.com/esys-escript/esys-escript.github.io"
                }
            ]
        }
    ],
    "finish-args": [
        "--filesystem=home",
        "--share=network"
    ]
}
