├── .gitignore ├── docs └── assets │ └── logo_and_name.png ├── Makefile ├── rootfs ├── viceroycc-windows ├── viceroycc-darwin ├── viceroycc-freebsd ├── viceroycc-linux └── viceroycc ├── CHANGELOG.md ├── README.md ├── .github └── workflows │ └── container.yml ├── Dockerfile └── LICENSE /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | -------------------------------------------------------------------------------- /docs/assets/logo_and_name.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rfratto/viceroy/HEAD/docs/assets/logo_and_name.png -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | ROOT=$(shell git rev-parse --show-toplevel) 2 | CONTAINER_NAME ?= rfratto/viceroy:latest 3 | 4 | .PHONY: all 5 | all: build 6 | 7 | .PHONY: build 8 | build: 9 | docker build -t ${CONTAINER_NAME} --build-arg OSXCROSS_SDK_URL=${OSXCROSS_SDK_URL} . 10 | -------------------------------------------------------------------------------- /rootfs/viceroycc-windows: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | FOUND_CC="" 3 | 4 | case "$VICEROYARCH" in 5 | 386) FOUND_CC="i686-w64-mingw32-gcc" ;; 6 | amd64) FOUND_CC="x86_64-w64-mingw32-gcc" ;; 7 | *) 8 | echo "fatal: unsupported \$VICEROYARCH $VICEROYARCH for windows. Must be one of: 386, amd64" >&2 9 | exit 1 10 | ;; 11 | esac 12 | 13 | exec "$FOUND_CC" "$@" 14 | -------------------------------------------------------------------------------- /rootfs/viceroycc-darwin: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | FOUND_CC="" 3 | 4 | case "$VICEROYARCH" in 5 | amd64) 6 | FOUND_CC="x86_64-apple-darwin21.4-clang" 7 | ;; 8 | arm64) 9 | FOUND_CC="arm64-apple-darwin21.4-clang" 10 | ;; 11 | *) 12 | echo "fatal: unsupported \$VICEROYARCH $VICEROYARCH for darwin. Must be one of: amd64, arm64" >&2 13 | exit 1 14 | ;; 15 | esac 16 | 17 | export LD_LIBRARY_PATH="/usr/osxcross/lib:$LD_LIBRARY_PATH" 18 | exec "$FOUND_CC" "$@" 19 | -------------------------------------------------------------------------------- /rootfs/viceroycc-freebsd: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | CC_EXTRA="" 4 | 5 | case "$GOARCH" in 6 | amd64) 7 | CC_EXTRA="-B/usr/freebsd/bin -target x86_64-pc-freebsd12 --sysroot=/usr/freebsd/x86_64-pc-freebsd12" 8 | ;; 9 | 386) 10 | CC_EXTRA="-B/usr/freebsd/bin -target i386-pc-freebsd12 --sysroot=/usr/freebsd/i386-pc-freebsd12" 11 | ;; 12 | arm64) 13 | CC_EXTRA="-B/usr/freebsd/bin -target aarch64-pc-freebsd12 --sysroot=/usr/freebsd/aarch64-pc-freebsd12" 14 | ;; 15 | *) 16 | echo "fatal: unsupported \$GOARCH $GOARCH for freebsd. Must be one of: amd64, 386, arm64" >&2 17 | exit 1 18 | ;; 19 | esac 20 | 21 | exec clang $CC_EXTRA "$@" 22 | -------------------------------------------------------------------------------- /rootfs/viceroycc-linux: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | TOOLCHAIN_PREFIX="" 3 | 4 | case "$VICEROYARCH" in 5 | amd64) TOOLCHAIN_PREFIX="x86_64-linux-gnu-" ;; 6 | 386) TOOLCHAIN_PREFIX="i686-linux-gnu-" ;; 7 | arm) TOOLCHAIN_PREFIX="arm-linux-gnueabi-" ;; 8 | arm64) TOOLCHAIN_PREFIX="aarch64-linux-gnu-" ;; 9 | ppc64le) TOOLCHAIN_PREFIX="powerpc64le-linux-gnu-" ;; 10 | s390x) TOOLCHAIN_PREFIX="s390x-linux-gnu-" ;; 11 | *) 12 | echo "fatal: unsupported \$VICEROYARCH $VICEROYARCH for linux. Must be one of: amd64, 386, arm, arm64, ppc64le, s390x" >&2 13 | exit 1 14 | ;; 15 | esac 16 | 17 | if [ "$VICEROYARCH" == "arm" ] && [ "$VICEROYARM" == "7" ]; then 18 | TOOLCHAIN_PREFIX="arm-linux-gnueabihf-" 19 | fi 20 | 21 | exec "${TOOLCHAIN_PREFIX}gcc" "$@" 22 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | v0.4.0 (2023-05-18) 2 | ------------------- 3 | 4 | ### Enhancements 5 | 6 | * Update macOS SDK to macOS 12.3. 7 | * Update FreeBSD SDK to 12.4. 8 | 9 | v0.3.0 (2023-02-27) 10 | ------------------- 11 | 12 | ### Enhancements 13 | 14 | * Support s390x for Linux. 15 | 16 | v0.2.1 (2022-08-22) 17 | ------------------- 18 | 19 | ### Bug fixes 20 | 21 | * Invocations of viceroycc for amd64 Darwin will now work properly. 22 | 23 | v0.2.0 (2022-08-20) 24 | ------------------- 25 | 26 | > **NOTE**: As of this release, per-architecture images are pushed as 27 | > `-`. These images are artifacts of the build process and can 28 | > be ignored in favor of the `` image, which will be a manifest 29 | > containing all supported architectures. 30 | 31 | ### Enhancements 32 | 33 | * Include ARM64 images. 34 | 35 | v0.1.0 (2022-08-19) 36 | ------------------- 37 | 38 | Initial release! 39 | 40 | ### Features 41 | 42 | * Expose `viceroycc` binary which proxies build commands to one of many C 43 | compilers depending on values of the `VICEROYOS`/`GOOS`, `VICEROYARCH`/`GOARCH`, 44 | and `VICEROYARM`/`GOARM` environment variables. 45 | -------------------------------------------------------------------------------- /rootfs/viceroycc: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # This is the viceroycc bash script installed on Viceroy containers, which 4 | # wraps around a cross-compiler toolchain (e.g., gcc or clang). It fills out 5 | # appropriate values for VICEROYOS, VICEROYARM, and VICEROYARCH, and invokes 6 | # the appropriate toolchain if it's installed. There is expected to be one 7 | # viceroycc-$VICEROYOS binary for every supported OS. 8 | 9 | VICEROYOS=${VICEROYOS:-$GOOS} 10 | if [ -z "$VICEROYOS" ]; then 11 | # VICEROYOS and GOOS aren't set, fall back to host OS (linux) 12 | VICEROYOS=linux 13 | fi 14 | 15 | VICEROYARM=${VICEROYARM:-$GOARM} 16 | VICEROYARCH=${VICEROYARCH:-$GOARCH} 17 | if [ -z "$VICEROYARCH" ]; then 18 | # VICEROYARCH and GOARCH aren't set, fall back to host arch 19 | HOSTARCH=$(dpkg --print-architecture) 20 | case "$HOSTARCH" in 21 | amd64) VICEROYARCH=amd64 ;; 22 | i386) VICEROYARCH=386 ;; 23 | armel) VICEROYARCH=arm ;; 24 | armhf) VICEROYARCH=arm VICEROYARM=7 ;; 25 | arm64) VICEROYARCH=arm64 ;; 26 | *) 27 | echo "fatal: unrecognized host architecture $HOSTARCH" >&2 28 | exit 1 29 | ;; 30 | esac 31 | fi 32 | 33 | if [ -z "$(command -v "viceroycc-$VICEROYOS")" ]; then 34 | echo "fatal: viceroycc-$VICEROYOS not installed" >&2 35 | exit 1 36 | fi 37 | 38 | export VICEROYOS 39 | export VICEROYARM 40 | export VICEROYARCH 41 | exec "viceroycc-$VICEROYOS" "$@" 42 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

Viceroy logo

2 | 3 | Viceroy is a base Docker image which provides a `viceroycc` binary to cross 4 | compile to multiple architectures. It was designed to help ease the burden of 5 | cross compiling Go projects which have C dependencies. 6 | 7 | Viceroy is not very useful on its own; it should be extended to add libraries 8 | and other tools needed to build projects. 9 | 10 | ## Supported Platforms 11 | 12 | Viceroy examines the following environment variables to determine which target 13 | system to cross-compile for: 14 | 15 | * `VICEROYOS` (or `GOOS`) 16 | * `VICEROYARCH` (or `GOARCH`) 17 | * `VICEROYARM` (or `GOARM`) 18 | 19 | These environment variables determine which compiler toolchain to use and some 20 | defaults for environment variables (such as `LD_LIBRARY_PATH`). The environment 21 | variables will default to values appropriate for the worker container's 22 | environment when unspecified. 23 | 24 | The following target platforms are currently supported: 25 | 26 | | | linux | darwin | freebsd | windows | 27 | | -------- | ----- | ------ | ------- | ------- | 28 | | amd64 | x | x | x | x | 29 | | 386 | x | | x | x | 30 | | armv5 | x | | | | 31 | | armv6 | x | | | | 32 | | armv7 | x | | | | 33 | | arm64 | x | x | x | | 34 | | ppc64le | x | | | | 35 | | s390x | x | | | | 36 | 37 | ## Usage 38 | 39 | 1. Use `rfratto/viceroy` as your Docker base image. 40 | 2. Set `CC=viceroycc`. 41 | 3. Set `VICEROYOS`, `VICEROYARCH`, and `VICEROYARM` as appropriate. 42 | 4. Compile! 43 | 44 | ## Building locally 45 | 46 | The Viceroy image can be built for your local platform by running `make build`. 47 | 48 | The `OSXCROSS_SDK_URL` environment variable should be set to a URL or path on 49 | the host machine to a .tar.xz of an [osxcross][] packaged macOS 11.1 SDK. 50 | 51 | [osxcross]: https://github.com/tpoechtrager/osxcross 52 | 53 | ## Legal note 54 | 55 | OSX/Darwin/Apple builds: 56 | **[Please ensure you have read and understood the Xcode license 57 | terms before continuing.](https://www.apple.com/legal/sla/docs/xcode.pdf)** 58 | 59 | -------------------------------------------------------------------------------- /.github/workflows/container.yml: -------------------------------------------------------------------------------- 1 | # We need to use two separate build hosts for each architecture because of how 2 | # slow everything is here. Unfortunately, that means we lose the tooling which 3 | # allows us to push everything as one single manifest. 4 | # 5 | # For now, we're forced to push per-architecture images and then create a 6 | # manifest from them. This can be replaced once the Docker CLI supports pushing 7 | # images by reference instead of by tag, though it could also be done by 8 | # creating new tooling which interacts with the Docker registry API directly. 9 | 10 | name: Container 11 | on: 12 | push: 13 | tags: 14 | - 'v*' 15 | jobs: 16 | build_amd64: 17 | name: Build AMD64 Container 18 | runs-on: ubuntu-latest 19 | steps: 20 | - name: Checkout code 21 | uses: actions/checkout@v2 22 | - name: Build container 23 | run: | 24 | docker build \ 25 | -t rfratto/viceroy:latest-amd64 \ 26 | --build-arg OSXCROSS_SDK_URL=${{ secrets.OSXCROSS_SDK_URL }} \ 27 | . 28 | - name: Login to Docker Hub 29 | run: docker login -u rfratto -p "${{ secrets.DOCKER_PASS }}" 30 | - name: Push container 31 | run: | 32 | docker tag rfratto/viceroy:latest-amd64 rfratto/viceroy:${{ github.ref_name }}-amd64 33 | docker push rfratto/viceroy:latest-amd64 34 | docker push rfratto/viceroy:${{ github.ref_name }}-amd64 35 | 36 | build_arm64: 37 | name: Build ARM64 Container 38 | runs-on: [Linux, ARM64] 39 | steps: 40 | - name: Checkout code 41 | uses: actions/checkout@v2 42 | - name: Build container 43 | run: | 44 | docker build \ 45 | -t rfratto/viceroy:latest-arm64 \ 46 | --build-arg OSXCROSS_SDK_URL=${{ secrets.OSXCROSS_SDK_URL }} \ 47 | . 48 | - name: Login to Docker Hub 49 | run: docker login -u rfratto -p "${{ secrets.DOCKER_PASS }}" 50 | - name: Push container 51 | run: | 52 | docker tag rfratto/viceroy:latest-arm64 rfratto/viceroy:${{ github.ref_name }}-arm64 53 | docker push rfratto/viceroy:latest-arm64 54 | docker push rfratto/viceroy:${{ github.ref_name }}-arm64 55 | 56 | bundle-manifests: 57 | name: Bundle manifests 58 | needs: [build_amd64, build_arm64] 59 | runs-on: ubuntu-latest 60 | steps: 61 | - name: Login to Docker Hub 62 | run: docker login -u rfratto -p "${{ secrets.DOCKER_PASS }}" 63 | - name: Create manifests 64 | run: | 65 | docker buildx imagetools create \ 66 | -t rfratto/viceroy:${{ github.ref_name }} -t rfratto/viceroy:latest \ 67 | rfratto/viceroy:${{ github.ref_name }}-amd64 \ 68 | rfratto/viceroy:${{ github.ref_name }}-arm64 69 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM debian:bullseye-slim as environment 2 | 3 | RUN export HOST=$(dpkg --print-architecture) \ 4 | && dpkg --add-architecture amd64 \ 5 | && dpkg --add-architecture i386 \ 6 | && dpkg --add-architecture armel \ 7 | && dpkg --add-architecture armhf \ 8 | && dpkg --add-architecture arm64 \ 9 | && dpkg --add-architecture ppc64el \ 10 | && dpkg --add-architecture s390x \ 11 | && apt-get update \ 12 | && apt-get install -yq \ 13 | clang:$HOST \ 14 | llvm:$HOST \ 15 | lld:$HOST \ 16 | crossbuild-essential-amd64 \ 17 | crossbuild-essential-i386 \ 18 | crossbuild-essential-armel \ 19 | crossbuild-essential-armhf \ 20 | crossbuild-essential-arm64 \ 21 | crossbuild-essential-ppc64el \ 22 | crossbuild-essential-s390x \ 23 | libssl-dev \ 24 | openssl \ 25 | mingw-w64:$HOST \ 26 | && apt-get clean && rm -rf /var/lib/apt/lists/* 27 | 28 | FROM environment as freebsd 29 | 30 | RUN export HOST=$(dpkg --print-architecture) \ 31 | && apt-get update \ 32 | && apt-get install -yq \ 33 | curl:$HOST \ 34 | libarchive-tools:$HOST \ 35 | xz-utils:$HOST \ 36 | && apt-get clean && rm -rf /var/lib/apt/lists/* 37 | 38 | ENV FREEBSD_AMD64_URL=https://download.freebsd.org/releases/amd64/amd64/ISO-IMAGES/12.4/FreeBSD-12.4-RELEASE-amd64-dvd1.iso.xz \ 39 | FREEBSD_I386_URL=https://download.freebsd.org/releases/i386/i386/ISO-IMAGES/12.4/FreeBSD-12.4-RELEASE-i386-dvd1.iso.xz \ 40 | FREEBSD_ARM64_URL=https://download.freebsd.org/releases/arm64/aarch64/ISO-IMAGES/12.4/FreeBSD-12.4-RELEASE-arm64-aarch64-dvd1.iso.xz 41 | 42 | # Unpack amd64 toolchain /usr/freebsd/x86_64-pc-freebsd12 43 | RUN mkdir -p /tmp/freebsd-amd64 \ 44 | && curl -fsSL "${FREEBSD_AMD64_URL}" -o /tmp/freebsd-amd64/dvd1.iso.xz \ 45 | && mkdir -p /usr/freebsd/x86_64-pc-freebsd12 \ 46 | && cd /tmp/freebsd-amd64 \ 47 | && xz -d dvd1.iso.xz \ 48 | && bsdtar -xf dvd1.iso lib usr/include usr/lib \ 49 | && mv lib /usr/freebsd/x86_64-pc-freebsd12/ \ 50 | && mv usr /usr/freebsd/x86_64-pc-freebsd12/ \ 51 | && rm -rf /tmp/freebsd-amd64 52 | 53 | # Unpack i386 toolchain to /usr/freebsd/i386-pc-freebsd12 54 | RUN mkdir -p /tmp/freebsd-i386 \ 55 | && curl -fsSL "${FREEBSD_I386_URL}" -o /tmp/freebsd-i386/dvd1.iso.xz \ 56 | && mkdir -p /usr/freebsd/i386-pc-freebsd12 \ 57 | && cd /tmp/freebsd-i386 \ 58 | && xz -d dvd1.iso.xz \ 59 | && bsdtar -xf dvd1.iso lib usr/include usr/lib \ 60 | && mv lib /usr/freebsd/i386-pc-freebsd12/ \ 61 | && mv usr /usr/freebsd/i386-pc-freebsd12/ \ 62 | && rm -rf /tmp/freebsd-i386 63 | 64 | # Unpack arm64 toolchain to /usr/freebsd/aarch64-pc-freebsd12 65 | RUN mkdir -p /tmp/freebsd-arm64 \ 66 | && curl -fsSL "${FREEBSD_ARM64_URL}" -o /tmp/freebsd-arm64/dvd1.iso.xz \ 67 | && mkdir -p /usr/freebsd/aarch64-pc-freebsd12 \ 68 | && cd /tmp/freebsd-arm64 \ 69 | && xz -d dvd1.iso.xz \ 70 | && bsdtar -xf dvd1.iso lib usr/include usr/lib \ 71 | && mv lib /usr/freebsd/aarch64-pc-freebsd12/ \ 72 | && mv usr /usr/freebsd/aarch64-pc-freebsd12/ \ 73 | && rm -rf /tmp/freebsd-arm64 74 | 75 | # Create binutils to use for building FreeBSD targets. Specifically, we do this 76 | # to pass to the -B flag of clang to ensure that builds for FreeBSD always use 77 | # ld.lld. 78 | # 79 | # See https://mcilloni.ovh/2021/02/09/cxx-cross-clang/ 80 | RUN mkdir -p /usr/freebsd/bin \ 81 | && ln -sf /usr/bin/llvm-ar-11 /usr/freebsd/bin/ar \ 82 | && ln -sf /usr/bin/ld.lld /usr/freebsd/bin/ld \ 83 | && ln -sf /usr/bin/llvm-objcopy-11 /usr/freebsd/bin/objcopy \ 84 | && ln -sf /usr/bin/llvm-objdump-11 /usr/freebsd/bin/objdump \ 85 | && ln -sf /usr/bin/llvm-ranlib-11 /usr/freebsd/bin/ranlib \ 86 | && ln -sf /usr/bin/llvm-strings-11 /usr/freebsd/bin/strings 87 | 88 | FROM environment as osxcross 89 | 90 | # osxcross-specific deps 91 | RUN export HOST=$(dpkg --print-architecture) \ 92 | && apt-get update \ 93 | && apt-get install -yq \ 94 | cmake:$HOST \ 95 | curl:$HOST \ 96 | git:$HOST \ 97 | liblzma-dev:$HOST \ 98 | libxml2-dev:$HOST \ 99 | llvm-dev:$HOST \ 100 | make:$HOST \ 101 | patch:$HOST \ 102 | tar:$HOST \ 103 | xz-utils:$HOST \ 104 | zlib1g-dev:$HOST \ 105 | && apt-get clean && rm -rf /var/lib/apt/lists/* 106 | 107 | ARG OSXCROSS_SDK_URL 108 | ENV OSXCROSS_REV=50e86ebca7d14372febd0af8cd098705049161b9 \ 109 | OSXCROSS_SDK_NAME=MacOSX12.3.sdk.tar.xz 110 | 111 | ADD ${OSXCROSS_SDK_URL} /tmp/${OSXCROSS_SDK_NAME} 112 | 113 | RUN mkdir -p /tmp/osxcross && cd /tmp/osxcross \ 114 | && curl -sSL "https://codeload.github.com/tpoechtrager/osxcross/tar.gz/${OSXCROSS_REV}" \ 115 | | tar -C /tmp/osxcross --strip=1 -xzf - \ 116 | && mv /tmp/${OSXCROSS_SDK_NAME} tarballs/${OSXCROSS_SDK_NAME} \ 117 | && UNATTENDED=yes ./build.sh \ 118 | && mv target /usr/osxcross 119 | 120 | FROM environment 121 | 122 | COPY --from=freebsd /usr/freebsd /usr/freebsd 123 | COPY --from=osxcross /usr/osxcross /usr/osxcross 124 | ENV PATH /usr/osxcross/bin:$PATH 125 | 126 | COPY rootfs/viceroycc /usr/bin/viceroycc 127 | COPY rootfs/viceroycc-darwin /usr/bin/viceroycc-darwin 128 | COPY rootfs/viceroycc-freebsd /usr/bin/viceroycc-freebsd 129 | COPY rootfs/viceroycc-linux /usr/bin/viceroycc-linux 130 | COPY rootfs/viceroycc-windows /usr/bin/viceroycc-windows 131 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | --------------------------------------------------------------------------------