Blob Blame Raw
name: Build

on: [push, pull_request]

jobs:
  Ubuntu:
    runs-on: ubuntu-18.04
    strategy:
      matrix:
        compiler: [gcc, clang]
        include:
          - compiler: gcc
            cc: gcc
            cxx: g++
          - compiler: clang
            cc: clang
            cxx: clang++
    steps:
    - uses: actions/checkout@v2
    - name: Install libraries
      run: |
        sudo apt-get update
        sudo apt-get install build-essential cmake pkg-config ninja-build ccache libboost-all-dev qt5-default qtbase5-dev libqt5svg5-dev qtscript5-dev qttools5-dev qttools5-dev-tools libqt5opengl5-dev qtmultimedia5-dev libqt5multimedia5-plugins libsuperlu-dev liblz4-dev libusb-1.0-0-dev liblzo2-dev libpng-dev libjpeg-dev libglew-dev freeglut3-dev libfreetype6-dev libjson-c-dev qtwayland5 libmypaint-dev

    - uses: actions/cache@v1
      with:
        path: /home/runner/.ccache
        key: ${{ runner.os }}-${{ matrix.compiler }}-${{ github.sha }}
        restore-keys: ${{ runner.os }}-${{ matrix.compiler }}-

    - name: Build libtiff
      run: |
        cd thirdparty/tiff-4.0.3
        CFLAGS='-fPIC' CXXFLAGS='-fPIC' ./configure --disable-jbig
        make -j $(nproc)

    - name: Build
      run: |
        cd toonz
        mkdir build
        cd build
        cmake ../sources -G Ninja -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER=${{ matrix.cxx }} -DCMAKE_C_COMPILER=${{ matrix.cc }}
        ninja

    - name: Create Artifact
      run: |
        cd toonz/build
        sudo ninja install

        mkdir -p appdir/usr
        cp -r /opt/opentoonz/* appdir/usr
        cp appdir/usr/share/applications/*.desktop appdir
        cp appdir/usr/share/icons/hicolor/*/apps/*.png appdir

        mkdir -p artifact/OpenToonzPortable
        mv appdir/usr/share/opentoonz/stuff artifact/OpenToonzPortable/portablestuff
        rmdir appdir/usr/share/opentoonz

        wget -q -c 'https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage'
        wget -q -c 'https://github.com/linuxdeploy/linuxdeploy-plugin-qt/releases/download/continuous/linuxdeploy-plugin-qt-x86_64.AppImage'
        wget -q -c 'https://github.com/linuxdeploy/linuxdeploy-plugin-appimage/releases/download/continuous/linuxdeploy-plugin-appimage-x86_64.AppImage'
        chmod 755 linuxdeploy-x86_64.AppImage
        chmod 755 linuxdeploy-plugin-qt-x86_64.AppImage
        chmod 755 linuxdeploy-plugin-appimage-x86_64.AppImage

        cat << EOF > apprun.sh
        #!/usr/bin/env bash
        exec "\${APPDIR}/usr/bin/OpenToonz"
        EOF
        chmod 755 apprun.sh

        export LD_LIBRARY_PATH='appdir/usr/lib/opentoonz'
        ./linuxdeploy-x86_64.AppImage --appdir=appdir --plugin=qt --output=appimage --custom-apprun=apprun.sh \
        --executable=appdir/usr/bin/lzocompress \
        --executable=appdir/usr/bin/lzodecompress \
        --executable=appdir/usr/bin/tcleanup \
        --executable=appdir/usr/bin/tcomposer \
        --executable=appdir/usr/bin/tconverter \
        --executable=appdir/usr/bin/tfarmcontroller \
        --executable=appdir/usr/bin/tfarmserver
        mv OpenToonz*.AppImage artifact/OpenToonzPortable/OpenToonz.AppImage

    - uses: actions/upload-artifact@v1
      with:
        name: Opentoonz-${{ runner.os }}-${{ matrix.compiler }}-${{ github.sha }}
        path: toonz/build/artifact

  macOS:
    runs-on: macos-latest
    steps:
    - uses: actions/checkout@v2

    - name: Install libraries
      run: |
        brew update
        brew install pkg-config ninja glew lz4 libjpeg libpng lzo qt boost libusb libmypaint ccache

    - uses: actions/cache@v1
      with:
        path: /Users/runner/.ccache
        key: ${{ runner.os }}-${{ github.sha }}
        restore-keys: ${{ runner.os }}-

    - name: Build libtiff
      run: |
        export PATH="/usr/local/opt/ccache/libexec:$PATH"
        cd thirdparty/tiff-4.0.3
        CFLAGS='-fPIC' CXXFLAGS='-fPIC' ./configure --disable-lzma
        make -j $(nproc)

    - name: Build
      run: |
        cd toonz
        mkdir build
        cd build
        cmake ../sources -G Ninja -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DQT_PATH='/usr/local/opt/qt/lib'
        ninja -w dupbuild=warn

    - name: Create Artifact
      run: |
        cd toonz/build/toonz
        cp -pr ../../../stuff OpenToonz.app/portablestuff
        /usr/local/opt/qt/bin/macdeployqt OpenToonz.app -dmg -verbose=1 -always-overwrite \
        -executable=OpenToonz.app/Contents/MacOS/lzocompress \
        -executable=OpenToonz.app/Contents/MacOS/lzodecompress \
        -executable=OpenToonz.app/Contents/MacOS/tcleanup \
        -executable=OpenToonz.app/Contents/MacOS/tcomposer \
        -executable=OpenToonz.app/Contents/MacOS/tconverter \
        -executable=OpenToonz.app/Contents/MacOS/tfarmcontroller \
        -executable=OpenToonz.app/Contents/MacOS/tfarmserver

    - uses: actions/upload-artifact@v1
      with:
        name: Opentoonz-${{ runner.os }}-${{ github.sha }}
        path: toonz/build/toonz/OpenToonz.dmg

  Windows:
    runs-on: windows-2019
    env:
      vcpkg_ref: d989ad416b923a9f895c4bddc446d1ef370a3af8
      CLCACHE_CL: 'C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Tools/MSVC/14.24.28314/bin/Hostx64/x64/cl_original.exe'
    steps:
    - uses: actions/checkout@v2

    - name: Checkout mypaint/libmypaint
      uses: actions/checkout@v2
      with:
        repository: 'mypaint/libmypaint'
        ref: '70f7686db792fa4953dc60f28a322bf2cd388ed7'
        path: 'libmypaint'

    - name: Checkout xiaoyeli/superlu
      uses: actions/checkout@v2
      with:
        repository: 'xiaoyeli/superlu'
        ref: 'a3d5233770f0caad4bc4578b46d3b26af99e9c19'
        path: 'superlu'

    - name: Install vcpkg
      run: |
        rm -r -fo C:/vcpkg
        cd C:/
        git clone https://github.com/Microsoft/vcpkg
        cd vcpkg
        git checkout "$env:vcpkg_ref"
        ./bootstrap-vcpkg.bat

    - uses: actions/cache@v1
      with:
       path: C:/vcpkg/installed
       key: ${{ runner.os }}-vcpkg-${{ env.vcpkg_ref }}-${{ github.sha }}
       restore-keys: ${{ runner.os }}-vcpkg-${{ env.vcpkg_ref }}-

    - name: Install libraries
      run: |
        vcpkg install --clean-after-build --triplet x64-windows icu
        vcpkg install --clean-after-build --triplet x64-windows-static json-c libjpeg-turbo libpng lz4 lzo openblas zlib
        vcpkg install --clean-after-build --triplet x64-windows freeglut glew
        vcpkg install --clean-after-build --triplet x64-windows qt5-base qt5-multimedia qt5-script qt5-svg qt5-tools

    - name: Install clcache
      run: |
        pip install clcache
        Rename-Item -Path 'C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Tools/MSVC/14.24.28314/bin/Hostx64/x64/cl.exe' -NewName 'cl_original.exe'
        Rename-Item -Path 'C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Tools/MSVC/14.24.28314/bin/Hostx64/x64/cl.exe.config' -NewName 'cl_original.exe.config'
        cp 'C:/hostedtoolcache/windows/Python/3.6.8/x64/Scripts/clcache.exe' 'C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Tools/MSVC/14.24.28314/bin/Hostx64/x64/cl.exe'

    - uses: actions/cache@v1
      with:
       path: C:/Users/runneradmin/clcache
       key: ${{ runner.os }}-clcache-${{ github.sha }}
       restore-keys: ${{ runner.os }}-clcache-

    - name: Build libtiff
      run: |
        cd thirdparty/tiff-4.0.3
        cp libtiff/tif_config.vc.h libtiff/tif_config.h
        cp libtiff/tiffconf.vc.h libtiff/tiffconf.h
        cd prj/LibTIFF
        $env:Path += ';C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/MSBuild/Current/Bin'
        $env:CLCACHE_CL = '${{ env.CLCACHE_CL }}'
        msbuild LibTIFF.vcxproj /p:PlatformToolset=v142 /p:Platform=x64 /p:Configuration=Release -maxcpucount:3

    - name: Build mypaint/libmypaint
      run: |
        cd libmypaint
        cp ../.github/workflows/CMakeLists.txt .
        echo '#define MYPAINT_CONFIG_USE_GLIB 0' > config.h
        python generate.py mypaint-brush-settings-gen.h brushsettings-gen.h
        mkdir build | Out-Null
        cd build
        $env:CLCACHE_CL = '${{ env.CLCACHE_CL }}'
        cmake ../ -G 'Visual Studio 16 2019' -Ax64 -Djson-c_DIR='C:/vcpkg/installed/x64-windows-static/share/json-c/' -DJSON-C_INCLUDE_DIR='C:/vcpkg/installed/x64-windows-static/include/json-c/'
        cmake --build . --config Release
        cp C:/vcpkg/installed/x64-windows-static/lib/json-c.lib .
        $env:Path += ';C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Tools/MSVC/14.24.28314/bin/Hostx64/x64'
        lib /OUT:libmypaint.lib Release/libmypaint.lib json-c.lib
        cp libmypaint.lib Release/libmypaint.lib

    - name: Build xiaoyeli/superlu
      run: |
        cd superlu
        mkdir build | Out-Null
        cd build
        $env:CLCACHE_CL = '${{ env.CLCACHE_CL }}'
        cmake ../ -G 'Visual Studio 16 2019' -Ax64 -DXSDK_ENABLE_Fortran=OFF -Denable_tests=OFF
        cmake --build . --config Release

    - name: Workaround
      run: |
        cd thirdparty
        cp C:/vcpkg/installed/x64-windows-static/lib/jpeg.lib LibJPEG/jpeg-9/lib/LibJPEG-9_2015_64.lib
        cp C:/vcpkg/installed/x64-windows-static/lib/libpng16.lib libpng-1.6.21/lib/libpng16_2015_64.lib
        cp C:/vcpkg/installed/x64-windows-static/lib/lz4.lib Lz4/Lz4_131/lz4_64.lib
        cp C:/vcpkg/installed/x64-windows-static/lib/lzo2.lib lzo/2.03/LZO_lib/lzo2_64.lib
        cp C:/vcpkg/installed/x64-windows-static/lib/openblas.lib openblas/libopenblas_64.lib
        cp C:/vcpkg/installed/x64-windows-static/lib/zlib.lib zlib-1.2.8/lib/zlib-1.2.8_2015_64.lib
        cp C:/vcpkg/installed/x64-windows/lib/freeglut.lib glut/3.7.6/lib/glut64.lib
        cp C:/vcpkg/installed/x64-windows/lib/glew32.lib glew/glew-1.9.0/lib/glew64.lib
        cp D:/a/opentoonz/opentoonz/libmypaint/build/Release/libmypaint.lib libmypaint/dist/64/libmypaint.lib
        cp D:/a/opentoonz/opentoonz/superlu/build/SRC/Release/superlu.lib superlu/SuperLU_2015_64.lib
        cp D:/a/opentoonz/opentoonz/thirdparty/tiff-4.0.3/prj/LibTIFF/x64/Release/LibTIFF.lib tiff-4.0.3/lib/LibTIFF-4.0.3_2015_64.lib

    - name: Copy headers
      run: |
        cd thirdparty
        cp LibJPEG/jpeg-9/jconfig.vc LibJPEG/jpeg-9/jconfig.h
        cp libpng-1.6.21/scripts/pnglibconf.h.prebuilt libpng-1.6.21/pnglibconf.h

    - name: Build
      run: |
        cd toonz
        mkdir build | Out-Null
        cd build
        $env:CLCACHE_CL = '${{ env.CLCACHE_CL }}'
        cmake ../sources -G 'Visual Studio 16 2019' -Ax64 -DQT_PATH='C:/vcpkg/installed/x64-windows/bin' -DQt5_DIR='C:/vcpkg/installed/x64-windows/share/cmake/Qt5' -DBOOST_ROOT="$env:BOOST_ROOT_1_69_0"
        cmake --build . --config Release

    - name: Create Artifact
      run: |
        mkdir artifact | Out-Null
        cd artifact
        cp -Recurse ../stuff portablestuff
        cp ../toonz/build/Release/* .
        cp C:/vcpkg/installed/x64-windows/bin/freeglut.dll .
        cp C:/vcpkg/installed/x64-windows/bin/glew32.dll .
        cp C:/vcpkg/installed/x64-windows/bin/Qt5Core.dll .
        cp C:/vcpkg/installed/x64-windows/bin/Qt5Gui.dll .
        cp C:/vcpkg/installed/x64-windows/bin/Qt5Multimedia.dll .
        cp C:/vcpkg/installed/x64-windows/bin/Qt5Network.dll .
        cp C:/vcpkg/installed/x64-windows/bin/Qt5OpenGL.dll .
        cp C:/vcpkg/installed/x64-windows/bin/Qt5PrintSupport.dll .
        cp C:/vcpkg/installed/x64-windows/bin/Qt5Script.dll .
        cp C:/vcpkg/installed/x64-windows/bin/Qt5Svg.dll .
        cp C:/vcpkg/installed/x64-windows/bin/Qt5Widgets.dll .
        cp C:/vcpkg/installed/x64-windows/bin/bz2.dll .
        cp C:/vcpkg/installed/x64-windows/bin/freetype.dll .
        cp C:/vcpkg/installed/x64-windows/bin/harfbuzz.dll .
        cp C:/vcpkg/installed/x64-windows/bin/icudt61.dll .
        cp C:/vcpkg/installed/x64-windows/bin/icuin61.dll .
        cp C:/vcpkg/installed/x64-windows/bin/icuuc61.dll .
        cp C:/vcpkg/installed/x64-windows/bin/libpng16.dll .
        cp C:/vcpkg/installed/x64-windows/bin/pcre2-16.dll .
        cp C:/vcpkg/installed/x64-windows/bin/zlib1.dll .
        cp -Recurse C:/vcpkg/installed/x64-windows/plugins/audio .
        cp -Recurse C:/vcpkg/installed/x64-windows/plugins/bearer .
        cp -Recurse C:/vcpkg/installed/x64-windows/plugins/iconengines .
        cp -Recurse C:/vcpkg/installed/x64-windows/plugins/imageformats .
        cp -Recurse C:/vcpkg/installed/x64-windows/plugins/mediaservice .
        cp -Recurse C:/vcpkg/installed/x64-windows/plugins/platforms .
        cp -Recurse C:/vcpkg/installed/x64-windows/plugins/playlistformats .
        cp -Recurse C:/vcpkg/installed/x64-windows/plugins/printsupport .

    - uses: actions/upload-artifact@v1
      with:
        name: Opentoonz-${{ runner.os }}-${{ github.sha }}
        path: artifact