[
  {
    "path": ".gitignore",
    "content": "/*/\n/*.tar.*\n"
  },
  {
    "path": "LICENSE",
    "content": "This is free and unencumbered software released into the public domain.\n\nAnyone is free to copy, modify, publish, use, compile, sell, or\ndistribute this software, either in source code form or as a compiled\nbinary, for any purpose, commercial or non-commercial, and by any\nmeans.\n\nIn jurisdictions that recognize copyright laws, the author or authors\nof this software dedicate any and all copyright interest in the\nsoftware to the public domain. We make this dedication for the benefit\nof the public at large and to the detriment of our heirs and\nsuccessors. We intend this dedication to be an overt act of\nrelinquishment in perpetuity of all present and future rights to this\nsoftware under copyright law.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR\nOTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,\nARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\nOTHER DEALINGS IN THE SOFTWARE.\n\nFor more information, please refer to <http://unlicense.org>\n"
  },
  {
    "path": "README.md",
    "content": "This repository is meant to help create Cairo DLLs for Windows. Both 32-bit and 64-bit versions can be built. The resulting `cairo.dll` file is fully self-contained and does not depend on any other third-party DLLs. FreeType support is included. See [this blog post](http://preshing.com/20170529/heres-a-standalone-cairo-dll-for-windows) for more information.\n\nBinary releases are available [here](https://github.com/preshing/cairo-windows/releases).\n\n# Build Steps\n\nThe `build-cairo-windows.sh` shell script will download, extract, and build all the necessary libraries to link a self-contained `cairo.dll` with FreeType support. It uses the existing build pipelines of each library as much as possible. It was adapted from https://www.cairographics.org/end_to_end_build_for_win32/\n\nThe Visual Studio 2017 compiler is used. Either MSYS, MSYS2 or Cygwin must be used to drive the build environment. So far it has only been tested with MSYS2. If using MSYS2, you'll need to install `tar` and `make` first:\n\n    $ pacman -S tar make\n\n## Building 32-bit\n\nYou'll need to create an MSYS2 (for example) shell that has all the correct environment variables set for Visual Studio 2017, including `INCLUDE`, `LIB` and `PATH`.\n\nAs of this writing, this can be achieved by opening \"x86 Native Tools Command Prompt for VS 2017\" from the start menu, and entering commands similar to the following. The final command runs the `build-cairo-windows.sh` script.\n\n```\n(from an x86 Native Tools Command Prompt for VS 2017)\n> set PATH=C:\\msys64;%PATH%\n> msys2_shell.cmd -use-full-path\n$ unset TMP\n$ unset TEMP\n$ ./build-cairo-windows.sh\n```\n\nSome notes:\n\n* `msys2_shell.cmd -use-full-path` opens an MSYS2 terminal while [inheriting the PATH](https://sourceforge.net/p/msys2/discussion/general/thread/dbe17030/#3f85) from the x86 Native Tools Command Prompt.\n* `unset TMP` and `unset TEMP` are currently needed to avoid `error MSB6001: Invalid command line switch for \"CL.exe\". Item has already been added. Key in dictionary: 'TMP' Key being added: 'tmp'`, which is caused by the MSYS2 environment block [having multiple `TMP` entries due to case sensitivty](https://cmake.org/Bug/print_bug_page.php?bug_id=13131).\n\nWhen it's done, you'll find a self-contained package in a subdirectory named `output/cairo-windows-x.x.x`.\n\n## Building 64-bit\n\n1. First build 32-bit.\n2. Open `libpng\\projects\\vstudio\\vstudio.sln` in Visual Studio, then add the \"x64\" platform to the solution as follows:\n   * Build &rarr; Configuration Manager\n   * Active solution platform: &rarr; <New...>\n   * Select x64, click OK, close the Configuration Manager\n   * File &rarr; Save All\n3. Perform similar steps as for 32-bit, but open an \"**x64** Native Tools Command Prompt for VS 2017\" instead, and pass `x64` as an argument to the script:\n\n```\n(from an x64 Native Tools Command Prompt for VS 2017)\n> set PATH=C:\\msys64;%PATH%\n> msys2_shell.cmd -use-full-path\n$ unset TMP\n$ unset TEMP\n$ ./build-cairo-windows.sh x64\n```\n\n# Updating dependencies\n\nThe repo contains a deps.yml which can update cairo, freetype etc using dependencies.io\n\n\nTo run this locally, install the commandline tool from https://deps.app/local/\n\n```\n$ curl https://deps.app/install.sh | bash -s -- -b $HOME/bin\n```\n\nThen run it, accepting all the prompts:\n```\n$ yes | deps run\n```\n\n"
  },
  {
    "path": "build-cairo-windows.sh",
    "content": "#! bash\nset -e\ntrap 'previous_command=$this_command; this_command=$BASH_COMMAND' DEBUG\ntrap 'echo FAILED COMMAND: $previous_command' EXIT\n\n# Versions used\nUSE_FREETYPE=1\nCAIRO_VERSION=cairo-1.17.2\nPIXMAN_VERSION=pixman-0.40.0\nLIBPNG_VERSION=libpng-1.6.37\nZLIB_VERSION=zlib-1.2.11\nFREETYPE_VERSION=freetype-2.10.2\n\n# Set variables according to command line argument\nif [ ${1:-x86} = x64 ]; then\n    MSVC_PLATFORM_NAME=x64\n    OUTPUT_PLATFORM_NAME=x64\nelse\n    MSVC_PLATFORM_NAME=Win32\n    OUTPUT_PLATFORM_NAME=x86\nfi\n\n# Make sure the MSVC linker appears first in the path\nMSVC_LINK_PATH=`whereis link | sed \"s| /usr/bin/link.exe||\" | sed \"s|.*\\(/c.*\\)link.exe.*|\\1|\"`\nexport PATH=\"$MSVC_LINK_PATH:$PATH\"\n\n# Download packages if not already\nwget -nc https://www.cairographics.org/snapshots/$CAIRO_VERSION.tar.xz\nwget -nc https://www.cairographics.org/releases/$PIXMAN_VERSION.tar.gz\nwget -nc https://download.sourceforge.net/libpng/$LIBPNG_VERSION.tar.gz\nwget -nc http://www.zlib.net/$ZLIB_VERSION.tar.gz\nif [ $USE_FREETYPE -ne 0 ]; then\n    wget -nc http://download.savannah.gnu.org/releases/freetype/$FREETYPE_VERSION.tar.gz\nfi    \n\n# Extract packages if not already\nif [ ! -d cairo ]; then\n    echo \"Extracting $CAIRO_VERSION...\"\n    tar -xJf $CAIRO_VERSION.tar.xz\n    mv $CAIRO_VERSION cairo\nfi\nif [ ! -d pixman ]; then\n    echo \"Extracting $PIXMAN_VERSION...\"\n    tar -xzf $PIXMAN_VERSION.tar.gz\n    mv $PIXMAN_VERSION pixman\nfi\nif [ ! -d libpng ]; then\n    echo \"Extracting $LIBPNG_VERSION...\"\n    tar -xzf $LIBPNG_VERSION.tar.gz\n    mv $LIBPNG_VERSION libpng\nfi\nif [ ! -d zlib ]; then\n    echo \"Extracting $ZLIB_VERSION...\"\n    tar -xzf $ZLIB_VERSION.tar.gz\n    mv $ZLIB_VERSION zlib\nfi\nif [ $USE_FREETYPE -ne 0 ] && [ ! -d freetype ]; then\n    echo \"Extracting $FREETYPE_VERSION...\"\n    tar -xzf $FREETYPE_VERSION.tar.gz\n    mv $FREETYPE_VERSION freetype\nfi\n\n# Build libpng and zlib\ncd libpng\nsed 's#4996</Disable#4996;5045</Disable#' projects/vstudio/zlib.props > zlib.props.fixed\nmv zlib.props.fixed projects/vstudio/zlib.props\nif [ ! -d \"projects\\vstudio\\Backup\" ]; then\n    # Upgrade solution if not already\n    devenv.com \"projects\\vstudio\\vstudio.sln\" -upgrade\nfi\ndevenv.com \"projects\\vstudio\\vstudio.sln\" -build \"Release Library|$MSVC_PLATFORM_NAME\" -project libpng\ncd ..\nif [ $MSVC_PLATFORM_NAME = x64 ]; then\n    cp \"libpng/projects/vstudio/x64/Release Library/libpng16.lib\" libpng/libpng.lib\n    cp \"libpng/projects/vstudio/x64/Release Library/zlib.lib\" zlib/zlib.lib\nelse\n    cp \"libpng/projects/vstudio/Release Library/libpng16.lib\" libpng/libpng.lib\n    cp \"libpng/projects/vstudio/Release Library/zlib.lib\" zlib/zlib.lib\nfi\n\n# Build pixman\ncd pixman\nsed s/-MD/-MT/ Makefile.win32.common > Makefile.win32.common.fixed\nmv Makefile.win32.common.fixed Makefile.win32.common\nif [ $MSVC_PLATFORM_NAME = x64 ]; then\n    # pass -B for switching between x86/x64\n    make pixman -B -f Makefile.win32 \"CFG=release\" \"MMX=off\"\nelse\n    make pixman -B -f Makefile.win32 \"CFG=release\"\nfi\ncd ..\n\nif [ $USE_FREETYPE -ne 0 ]; then\n    cd freetype\n    # Build freetype\n    if [ ! -d \"builds/windows/vc2010/Backup\" ]; then\n        # Upgrade solution if not already\n        devenv.com \"builds/windows/vc2010/freetype.sln\" -upgrade\n    fi\n    devenv.com \"builds/windows/vc2010/freetype.sln\" -build \"Release Static|$MSVC_PLATFORM_NAME\"\n    cp \"`ls -1d \"objs/$MSVC_PLATFORM_NAME/Release Static/freetype.lib\"`\" .\n    cd ..\nfi\n\n# Build cairo\ncd cairo\nsed 's/-MD/-MT/;s/zdll.lib/zlib.lib/' build/Makefile.win32.common > Makefile.win32.common.fixed\nmv Makefile.win32.common.fixed build/Makefile.win32.common\nif [ $USE_FREETYPE -ne 0 ]; then\n    sed '/^CAIRO_LIBS =/s/$/ $(top_builddir)\\/..\\/freetype\\/freetype.lib/;/^DEFAULT_CFLAGS =/s/$/ -I$(top_srcdir)\\/..\\/freetype\\/include/' build/Makefile.win32.common > Makefile.win32.common.fixed\nelse\n    sed '/^CAIRO_LIBS =/s/ $(top_builddir)\\/..\\/freetype\\/freetype.lib//;/^DEFAULT_CFLAGS =/s/ -I$(top_srcdir)\\/..\\/freetype\\/include//' build/Makefile.win32.common > Makefile.win32.common.fixed\nfi\nmv Makefile.win32.common.fixed build/Makefile.win32.common\nsed \"s/CAIRO_HAS_FT_FONT=./CAIRO_HAS_FT_FONT=$USE_FREETYPE/\" build/Makefile.win32.features > Makefile.win32.features.fixed\nmv Makefile.win32.features.fixed build/Makefile.win32.features\n# pass -B for switching between x86/x64\nmake -B -f Makefile.win32 cairo \"CFG=release\"\ncd ..\n\n# Package headers with DLL\nOUTPUT_FOLDER=output/${CAIRO_VERSION/cairo-/cairo-windows-}\nmkdir -p $OUTPUT_FOLDER/include\nfor file in cairo/cairo-version.h \\\n            cairo/src/cairo-features.h \\\n            cairo/src/cairo.h \\\n            cairo/src/cairo-deprecated.h \\\n            cairo/src/cairo-win32.h \\\n            cairo/src/cairo-script.h \\\n            cairo/src/cairo-ps.h \\\n            cairo/src/cairo-pdf.h \\\n            cairo/src/cairo-svg.h; do\n    cp $file $OUTPUT_FOLDER/include\ndone\nif [ $USE_FREETYPE -ne 0 ]; then\n    cp cairo/src/cairo-ft.h $OUTPUT_FOLDER/include\nfi\nmkdir -p $OUTPUT_FOLDER/lib/$OUTPUT_PLATFORM_NAME\ncp cairo/src/release/cairo.lib $OUTPUT_FOLDER/lib/$OUTPUT_PLATFORM_NAME\ncp cairo/src/release/cairo.dll $OUTPUT_FOLDER/lib/$OUTPUT_PLATFORM_NAME\ncp cairo/COPYING* $OUTPUT_FOLDER\n\ntrap - EXIT\necho 'Success!'\n"
  },
  {
    "path": "deps.yml",
    "content": "version: 3\ndependencies:\n- type: git\n  settings:\n    remotes:\n      git://anongit.freedesktop.org/git/cairo:\n         replace_in_files:\n         - filename: build-cairo-windows.sh\n           pattern: CAIRO_VERSION=cairo-(\\S+)\n      https://github.com/freedesktop/pixman.git:\n        replace_in_files:\n        - filename: build-cairo-windows.sh\n          pattern: PIXMAN_VERSION=pixman-(\\S+)\n          tag_prefix: pixman-\n      https://github.com/glennrp/libpng.git:\n        replace_in_files:\n        - filename: build-cairo-windows.sh\n          pattern: LIBPNG_VERSION=libpng-(\\S+)\n          tag_prefix: v\n      git://git.sv.nongnu.org/freetype/freetype2.git:\n        replace_in_files:\n        - filename: build-cairo-windows.sh\n          pattern: FREETYPE_VERSION=freetype-(\\S+)\n          tag_filter:\n            matching: 'VER-(\\d+)-(\\d+)-(\\d+)'\n            output_as: '$1.$2.$3'  # output and sort as a semver-compatible \n"
  }
]