effective-limits-0.5.5/.cargo_vcs_info.json0000644000000001360000000000100143020ustar { "git": { "sha1": "d333a61f297499a026728a9abe48a1534574545d" }, "path_in_vcs": "" }effective-limits-0.5.5/.github/renovate.json000064400000000000000000000005161046102023000171520ustar 00000000000000{ "$schema": "https://docs.renovatebot.com/renovate-schema.json", "extends": [ "config:base" ], "git-submodules": { "enabled": true }, "labels": [ "dependencies" ], "prCreation": "not-pending", "stabilityDays": 3, "lockFileMaintenance": { "enabled": true } }effective-limits-0.5.5/.github/workflows/centos-fmt-clippy-on-all.yaml000064400000000000000000000057211046102023000241150ustar 00000000000000# This is ci/actions-templates/centos-fmt-clippy.yaml # Do not edit this file in .github/workflows name: General Checks on: pull_request: branches: - "*" push: branches: - master - stable schedule: - cron: "30 0 * * 1" # Every Monday at half past midnight jobs: check: name: Checks runs-on: ubuntu-latest strategy: fail-fast: false steps: - uses: actions/checkout@v2 with: # v2 defaults to a shallow checkout, but we need at least to the previous tag fetch-depth: 0 - name: Acquire tags for the repo run: | git fetch --no-tags --prune --depth=1 origin +refs/tags/*:refs/tags/* - name: Display the current git status run: | git status git describe - name: Prep cargo dirs run: | mkdir -p ~/.cargo/{registry,git} - name: Set environment variables appropriately for the build run: | echo "$HOME/.cargo/bin" >> $GITHUB_PATH - name: Cache cargo registry and git trees uses: actions/cache@v2 with: path: | ~/.cargo/registry ~/.cargo/git key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - name: Get rustc commit hash id: cargo-target-cache run: | echo "::set-output name=rust_hash::$(rustc -Vv | grep commit-hash | awk '{print $2}')" shell: bash - name: Cache cargo build uses: actions/cache@v2 with: path: target key: ${{ github.base_ref }}-${{ github.head_ref }}-${{ runner.os }}-cargo-clippy-target-dir-${{ steps.cargo-target-cache.outputs.rust_hash }}-${{ hashFiles('**/Cargo.lock') }} restore-keys: ${{ github.base_ref }}-${{ runner.os }}-cargo-clippy-target-dir-${{ steps.cargo-target-cache.outputs.rust_hash }}-${{ hashFiles('**/Cargo.lock') }} - name: Install Rustup run: | curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain=none --profile=minimal -y - name: Ensure Beta is up to date run: | if rustc +beta -vV >/dev/null 2>/dev/null; then rustup toolchain uninstall beta fi rustup toolchain install --profile=minimal beta rustup default beta - name: Ensure we have the components we need run: | rustup component add rustfmt rustup component add clippy - name: Run the centos check within the docker image run: | docker run \ --volume "$PWD":/checkout:ro \ --workdir /checkout \ --tty \ --init \ --rm \ centos:6 \ sh ./ci/raw_init.sh - name: Run formatting checks run: | cargo fmt --all --check - name: Run cargo check and clippy run: | cargo check --all --all-targets git ls-files -- '*.rs' | xargs touch cargo clippy --all --all-targets effective-limits-0.5.5/.github/workflows/linux-builds-on-master.yaml000064400000000000000000000135201046102023000236760ustar 00000000000000# This is ci/actions-templates/linux-builds-template.yaml # Do not edit this file in .github/workflows name: Linux (master) # skip-pr skip-stable on: push: # skip-pr branches: # skip-pr - master # skip-pr skip-stable schedule: # skip-pr skip-stable - cron: "30 0 * * 1" # Every Monday at half past midnight UTC skip-pr skip-stable jobs: build: name: Build runs-on: ubuntu-latest strategy: fail-fast: false matrix: target: - x86_64-unknown-linux-gnu - armv7-unknown-linux-gnueabihf - aarch64-linux-android - aarch64-unknown-linux-gnu # skip-pr - powerpc64-unknown-linux-gnu # skip-pr - x86_64-unknown-linux-musl # skip-pr include: - target: x86_64-unknown-linux-gnu run_tests: YES #snap_arch: amd64 - target: aarch64-unknown-linux-gnu # skip-pr #snap_arch: arm64 # skip-pr - target: armv7-unknown-linux-gnueabihf #snap_arch: armhf steps: - name: Clone repo uses: actions/checkout@v2 with: # v2 defaults to a shallow checkout, but we need at least to the previous tag fetch-depth: 0 - name: Acquire tags for the repo run: | git fetch --no-tags --prune --depth=1 origin +refs/tags/*:refs/tags/* - name: Display the current git status run: | git status git describe - name: Prep cargo dirs run: | mkdir -p ~/.cargo/{registry,git} - name: Set environment variables appropriately for the build run: | echo "$HOME/.cargo/bin" >> $GITHUB_PATH echo "TARGET=${{ matrix.target }}" >> $GITHUB_ENV - name: Skip tests run: | echo "SKIP_TESTS=yes" >> $GITHUB_ENV if: matrix.run_tests == '' - name: Cache cargo registry and git trees uses: actions/cache@v2 with: path: | ~/.cargo/registry ~/.cargo/git key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - name: Get rustc commit hash id: cargo-target-cache run: | echo "::set-output name=rust_hash::$(rustc -Vv | grep commit-hash | awk '{print $2}')" shell: bash - name: Cache cargo build uses: actions/cache@v2 with: path: target key: ${{ github.base_ref }}-${{ github.head_ref }}-${{ matrix.target }}-cargo-target-dir-${{ steps.cargo-target-cache.outputs.rust_hash }}-${{ hashFiles('**/Cargo.lock') }} restore-keys: ${{ github.base_ref }}-${{ matrix.target }}-cargo-target-dir-${{ steps.cargo-target-cache.outputs.rust_hash }}-${{ hashFiles('**/Cargo.lock') }} - name: Install Rustup run: | curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain=none --profile=minimal -y - name: Ensure Stable is up to date run: | if rustc +stable -vV >/dev/null 2>/dev/null; then rustup toolchain uninstall stable fi rustup toolchain install --profile=minimal stable - name: Ensure we have our goal target installed run: | rustup target install "$TARGET" - name: Determine which docker we need to run in run: | case "$TARGET" in *-linux-android*) DOCKER=android ;; # Android uses a local docker image *) DOCKER="$TARGET" ;; esac echo "DOCKER=$DOCKER" >> $GITHUB_ENV - name: Fetch the docker run: bash ci/fetch-rust-docker.bash "${TARGET}" - name: Maybe build a docker from there run: | if [ -f "ci/docker/$DOCKER/Dockerfile" ]; then docker build -t "$DOCKER" -f "ci/docker/${DOCKER}/Dockerfile" . fi - name: Run the build within the docker image run: | mkdir -p "${PWD}/target" chown -R "$(id -u)":"$(id -g)" "${PWD}/target" docker run \ --entrypoint sh \ --user "$(id -u)":"$(id -g)" \ --volume "$(rustc --print sysroot)":/rustc-sysroot:ro \ --volume "${PWD}":/checkout:ro \ --volume "${PWD}"/target:/checkout/target \ --workdir /checkout \ --env TARGET="${TARGET}" \ --env SKIP_TESTS="${SKIP_TESTS}" \ --volume "${HOME}/.cargo:/cargo" \ --env CARGO_HOME=/cargo \ --env CARGO_TARGET_DIR=/checkout/target \ --env LIBZ_SYS_STATIC=1 \ --tty \ --init \ --rm \ "${DOCKER}" \ -c 'PATH="${PATH}":/rustc-sysroot/bin bash ci/run.bash' - name: Upload the built artifact if: false uses: actions/upload-artifact@v2 with: name: rustup-init-${{ matrix.target }} path: | target/${{ matrix.target }}/release/rustup-init retention-days: 7 - name: Acquire the AWS tooling run: | pip3 install -U setuptools pip3 install awscli if: false && github.event_name == 'push' && github.ref == 'refs/heads/stable' - name: Prepare the dist run: | bash ci/prepare-deploy.bash if: false && github.event_name == 'push' && github.ref == 'refs/heads/stable' - name: Deploy build to dev-static dist tree for release team run: | aws s3 cp --recursive deploy/ s3://dev-static-rust-lang-org/rustup/ env: AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} AWS_DEFAULT_REGION: us-west-1 if: false && github.event_name == 'push' && github.ref == 'refs/heads/stable' - name: Clear the cargo caches run: | cargo install cargo-cache --no-default-features --features ci-autoclean cargo-cache effective-limits-0.5.5/.github/workflows/linux-builds-on-pr.yaml000064400000000000000000000131601046102023000230240ustar 00000000000000# This is ci/actions-templates/linux-builds-template.yaml # Do not edit this file in .github/workflows name: Linux (PR) # skip-master skip-stable on: pull_request: # skip-master skip-stable branches: # skip-master skip-stable - "*" # skip-master skip-stable jobs: build: name: Build runs-on: ubuntu-latest strategy: fail-fast: false matrix: target: - x86_64-unknown-linux-gnu - armv7-unknown-linux-gnueabihf - aarch64-linux-android - x86_64-unknown-freebsd # skip-master - x86_64-unknown-netbsd # skip-master include: - target: x86_64-unknown-linux-gnu run_tests: YES #snap_arch: amd64 - target: armv7-unknown-linux-gnueabihf #snap_arch: armhf steps: - name: Clone repo uses: actions/checkout@v2 with: # v2 defaults to a shallow checkout, but we need at least to the previous tag fetch-depth: 0 - name: Acquire tags for the repo run: | git fetch --no-tags --prune --depth=1 origin +refs/tags/*:refs/tags/* - name: Display the current git status run: | git status git describe - name: Prep cargo dirs run: | mkdir -p ~/.cargo/{registry,git} - name: Set environment variables appropriately for the build run: | echo "$HOME/.cargo/bin" >> $GITHUB_PATH echo "TARGET=${{ matrix.target }}" >> $GITHUB_ENV - name: Skip tests run: | echo "SKIP_TESTS=yes" >> $GITHUB_ENV if: matrix.run_tests == '' - name: Cache cargo registry and git trees uses: actions/cache@v2 with: path: | ~/.cargo/registry ~/.cargo/git key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - name: Get rustc commit hash id: cargo-target-cache run: | echo "::set-output name=rust_hash::$(rustc -Vv | grep commit-hash | awk '{print $2}')" shell: bash - name: Cache cargo build uses: actions/cache@v2 with: path: target key: ${{ github.base_ref }}-${{ github.head_ref }}-${{ matrix.target }}-cargo-target-dir-${{ steps.cargo-target-cache.outputs.rust_hash }}-${{ hashFiles('**/Cargo.lock') }} restore-keys: ${{ github.base_ref }}-${{ matrix.target }}-cargo-target-dir-${{ steps.cargo-target-cache.outputs.rust_hash }}-${{ hashFiles('**/Cargo.lock') }} - name: Install Rustup run: | curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain=none --profile=minimal -y - name: Ensure Stable is up to date run: | if rustc +stable -vV >/dev/null 2>/dev/null; then rustup toolchain uninstall stable fi rustup toolchain install --profile=minimal stable - name: Ensure we have our goal target installed run: | rustup target install "$TARGET" - name: Determine which docker we need to run in run: | case "$TARGET" in *-linux-android*) DOCKER=android ;; # Android uses a local docker image *) DOCKER="$TARGET" ;; esac echo "DOCKER=$DOCKER" >> $GITHUB_ENV - name: Fetch the docker run: bash ci/fetch-rust-docker.bash "${TARGET}" - name: Maybe build a docker from there run: | if [ -f "ci/docker/$DOCKER/Dockerfile" ]; then docker build -t "$DOCKER" -f "ci/docker/${DOCKER}/Dockerfile" . fi - name: Run the build within the docker image run: | mkdir -p "${PWD}/target" chown -R "$(id -u)":"$(id -g)" "${PWD}/target" docker run \ --entrypoint sh \ --user "$(id -u)":"$(id -g)" \ --volume "$(rustc --print sysroot)":/rustc-sysroot:ro \ --volume "${PWD}":/checkout:ro \ --volume "${PWD}"/target:/checkout/target \ --workdir /checkout \ --env TARGET="${TARGET}" \ --env SKIP_TESTS="${SKIP_TESTS}" \ --volume "${HOME}/.cargo:/cargo" \ --env CARGO_HOME=/cargo \ --env CARGO_TARGET_DIR=/checkout/target \ --env LIBZ_SYS_STATIC=1 \ --tty \ --init \ --rm \ "${DOCKER}" \ -c 'PATH="${PATH}":/rustc-sysroot/bin bash ci/run.bash' - name: Upload the built artifact if: false uses: actions/upload-artifact@v2 with: name: rustup-init-${{ matrix.target }} path: | target/${{ matrix.target }}/release/rustup-init retention-days: 7 - name: Acquire the AWS tooling run: | pip3 install -U setuptools pip3 install awscli if: false && github.event_name == 'push' && github.ref == 'refs/heads/stable' - name: Prepare the dist run: | bash ci/prepare-deploy.bash if: false && github.event_name == 'push' && github.ref == 'refs/heads/stable' - name: Deploy build to dev-static dist tree for release team run: | aws s3 cp --recursive deploy/ s3://dev-static-rust-lang-org/rustup/ env: AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} AWS_DEFAULT_REGION: us-west-1 if: false && github.event_name == 'push' && github.ref == 'refs/heads/stable' - name: Clear the cargo caches run: | cargo install cargo-cache --no-default-features --features ci-autoclean cargo-cache effective-limits-0.5.5/.github/workflows/linux-builds-on-stable.yaml000064400000000000000000000163631046102023000236650ustar 00000000000000# This is ci/actions-templates/linux-builds-template.yaml # Do not edit this file in .github/workflows name: Linux (stable) # skip-master skip-pr on: push: # skip-pr branches: # skip-pr - stable # skip-pr skip-master jobs: build: name: Build runs-on: ubuntu-latest strategy: fail-fast: false matrix: target: - x86_64-unknown-linux-gnu - armv7-unknown-linux-gnueabihf - aarch64-linux-android - aarch64-unknown-linux-gnu # skip-pr - aarch64-unknown-linux-musl # skip-pr skip-master - powerpc64-unknown-linux-gnu # skip-pr - x86_64-unknown-linux-musl # skip-pr - i686-unknown-linux-gnu # skip-pr skip-master - arm-unknown-linux-gnueabi # skip-pr skip-master - arm-unknown-linux-gnueabihf # skip-pr skip-master - x86_64-unknown-freebsd # skip-master - x86_64-unknown-netbsd # skip-master - x86_64-unknown-illumos # skip-pr skip-master - powerpc-unknown-linux-gnu # skip-pr skip-master - powerpc64le-unknown-linux-gnu # skip-pr skip-master - mips-unknown-linux-gnu # skip-pr skip-master - mips64-unknown-linux-gnuabi64 # skip-pr skip-master - mipsel-unknown-linux-gnu # skip-pr skip-master - mips64el-unknown-linux-gnuabi64 # skip-pr skip-master - s390x-unknown-linux-gnu # skip-pr skip-master - arm-linux-androideabi # skip-pr skip-master - armv7-linux-androideabi # skip-pr skip-master - i686-linux-android # skip-pr skip-master - x86_64-linux-android # skip-pr skip-master - riscv64gc-unknown-linux-gnu # skip-pr skip-master include: - target: x86_64-unknown-linux-gnu run_tests: YES #snap_arch: amd64 - target: i686-unknown-linux-gnu # skip-pr skip-master #snap_arch: i386 # skip-pr skip-master - target: aarch64-unknown-linux-gnu # skip-pr #snap_arch: arm64 # skip-pr - target: armv7-unknown-linux-gnueabihf #snap_arch: armhf - target: powerpc64le-unknown-linux-gnu # skip-pr skip-master #snap_arch: ppc64el # skip-pr skip-master - target: s390x-unknown-linux-gnu # skip-pr skip-master #snap_arch: s390x # skip-pr skip-master steps: - name: Clone repo uses: actions/checkout@v2 with: # v2 defaults to a shallow checkout, but we need at least to the previous tag fetch-depth: 0 - name: Acquire tags for the repo run: | git fetch --no-tags --prune --depth=1 origin +refs/tags/*:refs/tags/* - name: Display the current git status run: | git status git describe - name: Prep cargo dirs run: | mkdir -p ~/.cargo/{registry,git} - name: Set environment variables appropriately for the build run: | echo "$HOME/.cargo/bin" >> $GITHUB_PATH echo "TARGET=${{ matrix.target }}" >> $GITHUB_ENV - name: Skip tests run: | echo "SKIP_TESTS=yes" >> $GITHUB_ENV if: matrix.run_tests == '' - name: Cache cargo registry and git trees uses: actions/cache@v2 with: path: | ~/.cargo/registry ~/.cargo/git key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - name: Get rustc commit hash id: cargo-target-cache run: | echo "::set-output name=rust_hash::$(rustc -Vv | grep commit-hash | awk '{print $2}')" shell: bash - name: Cache cargo build uses: actions/cache@v2 with: path: target key: ${{ github.base_ref }}-${{ github.head_ref }}-${{ matrix.target }}-cargo-target-dir-${{ steps.cargo-target-cache.outputs.rust_hash }}-${{ hashFiles('**/Cargo.lock') }} restore-keys: ${{ github.base_ref }}-${{ matrix.target }}-cargo-target-dir-${{ steps.cargo-target-cache.outputs.rust_hash }}-${{ hashFiles('**/Cargo.lock') }} - name: Install Rustup run: | curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain=none --profile=minimal -y - name: Ensure Stable is up to date run: | if rustc +stable -vV >/dev/null 2>/dev/null; then rustup toolchain uninstall stable fi rustup toolchain install --profile=minimal stable - name: Ensure we have our goal target installed run: | rustup target install "$TARGET" - name: Determine which docker we need to run in run: | case "$TARGET" in *-linux-android*) DOCKER=android ;; # Android uses a local docker image *) DOCKER="$TARGET" ;; esac echo "DOCKER=$DOCKER" >> $GITHUB_ENV - name: Fetch the docker run: bash ci/fetch-rust-docker.bash "${TARGET}" - name: Maybe build a docker from there run: | if [ -f "ci/docker/$DOCKER/Dockerfile" ]; then docker build -t "$DOCKER" -f "ci/docker/${DOCKER}/Dockerfile" . fi - name: Run the build within the docker image run: | mkdir -p "${PWD}/target" chown -R "$(id -u)":"$(id -g)" "${PWD}/target" docker run \ --entrypoint sh \ --user "$(id -u)":"$(id -g)" \ --volume "$(rustc --print sysroot)":/rustc-sysroot:ro \ --volume "${PWD}":/checkout:ro \ --volume "${PWD}"/target:/checkout/target \ --workdir /checkout \ --env TARGET="${TARGET}" \ --env SKIP_TESTS="${SKIP_TESTS}" \ --volume "${HOME}/.cargo:/cargo" \ --env CARGO_HOME=/cargo \ --env CARGO_TARGET_DIR=/checkout/target \ --env LIBZ_SYS_STATIC=1 \ --tty \ --init \ --rm \ "${DOCKER}" \ -c 'PATH="${PATH}":/rustc-sysroot/bin bash ci/run.bash' - name: Upload the built artifact if: false uses: actions/upload-artifact@v2 with: name: rustup-init-${{ matrix.target }} path: | target/${{ matrix.target }}/release/rustup-init retention-days: 7 - name: Acquire the AWS tooling run: | pip3 install -U setuptools pip3 install awscli if: false && github.event_name == 'push' && github.ref == 'refs/heads/stable' - name: Prepare the dist run: | bash ci/prepare-deploy.bash if: false && github.event_name == 'push' && github.ref == 'refs/heads/stable' - name: Deploy build to dev-static dist tree for release team run: | aws s3 cp --recursive deploy/ s3://dev-static-rust-lang-org/rustup/ env: AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} AWS_DEFAULT_REGION: us-west-1 if: false && github.event_name == 'push' && github.ref == 'refs/heads/stable' - name: Clear the cargo caches run: | cargo install cargo-cache --no-default-features --features ci-autoclean cargo-cache effective-limits-0.5.5/.github/workflows/macos-builds-on-all.yaml000064400000000000000000000107101046102023000231140ustar 00000000000000# This is ci/actions-templates/macos-builds-template.yaml # Do not edit this file in .github/workflows name: macOS on: pull_request: branches: - "*" push: branches: - master - stable schedule: - cron: "30 0 * * 1" # Every Monday at half past midnight UTC jobs: build: name: Build runs-on: macos-latest strategy: matrix: target: - x86_64-apple-darwin - aarch64-apple-darwin steps: - uses: actions/checkout@v2 with: # v2 defaults to a shallow checkout, but we need at least to the previous tag fetch-depth: 0 - name: Acquire tags for the repo run: | git fetch --no-tags --prune --depth=1 origin +refs/tags/*:refs/tags/* - name: Display the current git status run: | git status git describe - name: Prep cargo dirs run: | mkdir -p ~/.cargo/{registry,git} - name: Set environment variables appropriately for the build run: | echo "$HOME/.cargo/bin" >> $GITHUB_PATH echo "TARGET=${{ matrix.target }}" >> $GITHUB_ENV echo "SKIP_TESTS=" >> $GITHUB_ENV echo "LZMA_API_STATIC=1" >> $GITHUB_ENV - name: Cache cargo registry and git trees uses: actions/cache@v2 with: path: | ~/.cargo/registry ~/.cargo/git key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - name: Get rustc commit hash id: cargo-target-cache run: | echo "::set-output name=rust_hash::$(rustc -Vv | grep commit-hash | awk '{print $2}')" shell: bash - name: Cache cargo build uses: actions/cache@v2 with: path: target key: ${{ github.base_ref }}-${{ github.head_ref }}-${{ matrix.target }}-cargo-target-dir-${{ steps.cargo-target-cache.outputs.rust_hash }}-${{ hashFiles('**/Cargo.lock') }}-3 restore-keys: ${{ github.base_ref }}-${{ matrix.target }}-cargo-target-dir-${{ steps.cargo-target-cache.outputs.rust_hash }}-${{ hashFiles('**/Cargo.lock') }}-3 - name: Install Rustup run: | curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain=none --profile=minimal -y - name: Ensure Stable is up to date run: | if rustc +stable -vV >/dev/null 2>/dev/null; then rustup toolchain uninstall stable fi rustup toolchain install --profile=minimal stable - name: aarch64-specific items run: | # Use nightly for now rustup toolchain install --profile=minimal nightly rustup default nightly # Can't run tests: cross-compiling echo "SKIP_TESTS=yes" >> $GITHUB_ENV if: matrix.target == 'aarch64-apple-darwin' - name: Ensure we have our goal target installed run: | rustup target install "$TARGET" - name: Run a full build and test run: bash ci/run.bash - name: Dump dynamic link targets if: false run: | otool -L target/${TARGET}/release/rustup-init if otool -L target/${TARGET}/release/rustup-init | grep -q -F /usr/local/; then echo >&2 "Unfortunately there are /usr/local things in the link. Fail." exit 1 fi - name: Upload the built artifact if: false uses: actions/upload-artifact@v2 with: name: rustup-init-${{ matrix.target }} path: | target/${{ matrix.target }}/release/rustup-init retention-days: 7 - name: Acquire the AWS tooling run: | pip3 install awscli if: false && github.event_name == 'push' && github.ref == 'refs/heads/stable' - name: Prepare the dist run: | bash ci/prepare-deploy.bash if: false && github.event_name == 'push' && github.ref == 'refs/heads/stable' - name: Deploy build to dev-static dist tree for release team run: | aws s3 cp --recursive deploy/ s3://dev-static-rust-lang-org/rustup/ env: AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} AWS_DEFAULT_REGION: us-west-1 if: false && github.event_name == 'push' && github.ref == 'refs/heads/stable' - name: Clear the cargo caches run: | cargo install cargo-cache --no-default-features --features ci-autoclean cargo-cache effective-limits-0.5.5/.github/workflows/publish.yaml000064400000000000000000000021211046102023000210150ustar 00000000000000name: Publish to Cargo on: push: branches: [main, master] jobs: publish: runs-on: ubuntu-latest name: "publish" # Reference your environment variables environment: cargo steps: - name: checkout uses: actions/checkout@master # Use caching to speed up your build - name: Cache publish-action bin id: cache-publish-action uses: actions/cache@v3 env: cache-name: cache-publish-action with: path: ~/.cargo key: ${{ runner.os }}-build-${{ env.cache-name }}-v0.1.13 # install publish-action by cargo in github action - name: Install publish-action if: steps.cache-publish-action.outputs.cache-hit != 'true' run: cargo install publish-action --version=0.1.13 - name: Publish to cargo run: publish-action env: # This can help you tagging the github repository GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This can help you publish to crates.io CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}effective-limits-0.5.5/.github/workflows/windows-builds-on-master.yaml000064400000000000000000000130061046102023000242300ustar 00000000000000# This is ci/actions-templates/windows-builds-template.yaml # Do not edit this file in .github/workflows name: Windows (master) # skip-pr skip-stable on: push: # skip-pr branches: # skip-pr - master # skip-pr skip-stable schedule: # skip-pr skip-stable - cron: "30 0 * * 1" # Every Monday at half past midnight UTC skip-pr skip-stable jobs: build: name: Build runs-on: windows-latest env: RUSTFLAGS: -Ctarget-feature=+crt-static strategy: fail-fast: false matrix: target: - x86_64-pc-windows-msvc - aarch64-pc-windows-msvc # skip-pr skip-stable - x86_64-pc-windows-gnu # skip-pr include: - target: x86_64-pc-windows-gnu mingw: https://ci-mirrors.rust-lang.org/rustc/x86_64-6.3.0-release-posix-seh-rt_v5-rev2.7z mingwdir: mingw64 - target: i686-pc-windows-gnu mingwdir: mingw32 mingw: https://ci-mirrors.rust-lang.org/rustc/i686-6.3.0-release-posix-dwarf-rt_v5-rev2.7z - target: aarch64-pc-windows-msvc # skip-pr skip-stable skip_tests: yes # skip-pr skip-stable steps: - uses: actions/checkout@v2 # v2 defaults to a shallow checkout, but we need at least to the previous tag with: fetch-depth: 0 - name: Acquire tags for the repo run: | git fetch --no-tags --prune --depth=1 origin +refs/tags/*:refs/tags/* - name: Display the current git status run: | git status git describe - name: Prep cargo dirs run: | New-Item "${env:USERPROFILE}\.cargo\registry" -ItemType Directory -Force New-Item "${env:USERPROFILE}\.cargo\git" -ItemType Directory -Force shell: powershell - name: Install mingw run: | # We retrieve mingw from the Rust CI buckets # Disable the download progress bar which can cause perf issues $ProgressPreference = "SilentlyContinue" Invoke-WebRequest ${{ matrix.mingw }} -OutFile mingw.7z 7z x -y mingw.7z -oC:\msys64 | Out-Null del mingw.7z echo "C:\msys64\usr\bin" | Out-File -Append -FilePath $env:GITHUB_PATH -Encoding utf8 echo "C:\msys64\${{ matrix.mingwdir }}\bin" | Out-File -Append -FilePath $env:GITHUB_PATH -Encoding utf8 shell: powershell if: matrix.mingw != '' - name: Set environment variables appropriately for the build run: | echo "%USERPROFILE%\.cargo\bin" | Out-File -Append -FilePath $env:GITHUB_PATH -Encoding utf8 echo "TARGET=${{ matrix.target }}" | Out-File -Append -FilePath $env:GITHUB_ENV -Encoding utf8 echo "SKIP_TESTS=${{ matrix.skip_tests }}" | Out-File -Append -FilePath $env:GITHUB_ENV -Encoding utf8 - name: Cache cargo registry and git trees uses: actions/cache@v2 with: path: | ~/.cargo/registry ~/.cargo/git key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - name: Get rustc commit hash id: cargo-target-cache run: | echo "::set-output name=rust_hash::$(rustc -Vv | grep commit-hash | awk '{print $2}')" shell: bash - name: Cache cargo build uses: actions/cache@v2 with: path: target key: ${{ github.base_ref }}-${{ github.head_ref }}-${{ matrix.target }}-cargo-target-dir-${{ steps.cargo-target-cache.outputs.rust_hash }}-${{ hashFiles('**/Cargo.lock') }} restore-keys: ${{ github.base_ref }}-${{ matrix.target }}-cargo-target-dir-${{ steps.cargo-target-cache.outputs.rust_hash }}-${{ hashFiles('**/Cargo.lock') }} - name: Install Rustup using win.rustup.rs run: | # Disable the download progress bar which can cause perf issues $ProgressPreference = "SilentlyContinue" Invoke-WebRequest https://win.rustup.rs/ -OutFile rustup-init.exe .\rustup-init.exe -y --default-host=x86_64-pc-windows-msvc --profile=minimal del rustup-init.exe shell: powershell - name: Ensure stable toolchain is up to date run: rustup update stable shell: bash - name: Install the target run: | rustup target install ${{ matrix.target }} - name: Run a full build run: bash ci/run.bash - name: Upload the built artifact if: false uses: actions/upload-artifact@v2 with: name: rustup-init-${{ matrix.target }} path: | target/${{ matrix.target }}/release/rustup-init.exe retention-days: 7 - name: Acquire the AWS tooling run: | choco upgrade awscli if: false && github.event_name == 'push' && github.ref == 'refs/heads/stable' - name: Prepare the dist run: | .\ci\prepare-deploy.ps1 shell: powershell if: false && github.event_name == 'push' && github.ref == 'refs/heads/stable' - name: Deploy build to dev-static dist tree for release team run: | aws --debug s3 cp --recursive dist s3://dev-static-rust-lang-org/rustup/dist env: AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} AWS_DEFAULT_REGION: us-west-1 if: false && github.event_name == 'push' && github.ref == 'refs/heads/stable' - name: Clear the cargo caches run: | cargo install cargo-cache --no-default-features --features ci-autoclean cargo-cache effective-limits-0.5.5/.github/workflows/windows-builds-on-pr.yaml000064400000000000000000000123301046102023000233550ustar 00000000000000# This is ci/actions-templates/windows-builds-template.yaml # Do not edit this file in .github/workflows name: Windows (PR) # skip-master skip-stable on: pull_request: # skip-master skip-stable branches: # skip-master skip-stable - "*" # skip-master skip-stable jobs: build: name: Build runs-on: windows-latest env: RUSTFLAGS: -Ctarget-feature=+crt-static strategy: fail-fast: false matrix: target: - x86_64-pc-windows-msvc include: - target: x86_64-pc-windows-gnu mingw: https://ci-mirrors.rust-lang.org/rustc/x86_64-6.3.0-release-posix-seh-rt_v5-rev2.7z mingwdir: mingw64 - target: i686-pc-windows-gnu mingwdir: mingw32 mingw: https://ci-mirrors.rust-lang.org/rustc/i686-6.3.0-release-posix-dwarf-rt_v5-rev2.7z steps: - uses: actions/checkout@v2 # v2 defaults to a shallow checkout, but we need at least to the previous tag with: fetch-depth: 0 - name: Acquire tags for the repo run: | git fetch --no-tags --prune --depth=1 origin +refs/tags/*:refs/tags/* - name: Display the current git status run: | git status git describe - name: Prep cargo dirs run: | New-Item "${env:USERPROFILE}\.cargo\registry" -ItemType Directory -Force New-Item "${env:USERPROFILE}\.cargo\git" -ItemType Directory -Force shell: powershell - name: Install mingw run: | # We retrieve mingw from the Rust CI buckets # Disable the download progress bar which can cause perf issues $ProgressPreference = "SilentlyContinue" Invoke-WebRequest ${{ matrix.mingw }} -OutFile mingw.7z 7z x -y mingw.7z -oC:\msys64 | Out-Null del mingw.7z echo "C:\msys64\usr\bin" | Out-File -Append -FilePath $env:GITHUB_PATH -Encoding utf8 echo "C:\msys64\${{ matrix.mingwdir }}\bin" | Out-File -Append -FilePath $env:GITHUB_PATH -Encoding utf8 shell: powershell if: matrix.mingw != '' - name: Set environment variables appropriately for the build run: | echo "%USERPROFILE%\.cargo\bin" | Out-File -Append -FilePath $env:GITHUB_PATH -Encoding utf8 echo "TARGET=${{ matrix.target }}" | Out-File -Append -FilePath $env:GITHUB_ENV -Encoding utf8 echo "SKIP_TESTS=${{ matrix.skip_tests }}" | Out-File -Append -FilePath $env:GITHUB_ENV -Encoding utf8 - name: Cache cargo registry and git trees uses: actions/cache@v2 with: path: | ~/.cargo/registry ~/.cargo/git key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - name: Get rustc commit hash id: cargo-target-cache run: | echo "::set-output name=rust_hash::$(rustc -Vv | grep commit-hash | awk '{print $2}')" shell: bash - name: Cache cargo build uses: actions/cache@v2 with: path: target key: ${{ github.base_ref }}-${{ github.head_ref }}-${{ matrix.target }}-cargo-target-dir-${{ steps.cargo-target-cache.outputs.rust_hash }}-${{ hashFiles('**/Cargo.lock') }} restore-keys: ${{ github.base_ref }}-${{ matrix.target }}-cargo-target-dir-${{ steps.cargo-target-cache.outputs.rust_hash }}-${{ hashFiles('**/Cargo.lock') }} - name: Install Rustup using win.rustup.rs run: | # Disable the download progress bar which can cause perf issues $ProgressPreference = "SilentlyContinue" Invoke-WebRequest https://win.rustup.rs/ -OutFile rustup-init.exe .\rustup-init.exe -y --default-host=x86_64-pc-windows-msvc --profile=minimal del rustup-init.exe shell: powershell - name: Ensure stable toolchain is up to date run: rustup update stable shell: bash - name: Install the target run: | rustup target install ${{ matrix.target }} - name: Run a full build run: bash ci/run.bash - name: Upload the built artifact if: false uses: actions/upload-artifact@v2 with: name: rustup-init-${{ matrix.target }} path: | target/${{ matrix.target }}/release/rustup-init.exe retention-days: 7 - name: Acquire the AWS tooling run: | choco upgrade awscli if: false && github.event_name == 'push' && github.ref == 'refs/heads/stable' - name: Prepare the dist run: | .\ci\prepare-deploy.ps1 shell: powershell if: false && github.event_name == 'push' && github.ref == 'refs/heads/stable' - name: Deploy build to dev-static dist tree for release team run: | aws --debug s3 cp --recursive dist s3://dev-static-rust-lang-org/rustup/dist env: AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} AWS_DEFAULT_REGION: us-west-1 if: false && github.event_name == 'push' && github.ref == 'refs/heads/stable' - name: Clear the cargo caches run: | cargo install cargo-cache --no-default-features --features ci-autoclean cargo-cache effective-limits-0.5.5/.github/workflows/windows-builds-on-stable.yaml000064400000000000000000000125151046102023000242130ustar 00000000000000# This is ci/actions-templates/windows-builds-template.yaml # Do not edit this file in .github/workflows name: Windows (stable) # skip-master skip-pr on: push: # skip-pr branches: # skip-pr - stable # skip-pr skip-master jobs: build: name: Build runs-on: windows-latest env: RUSTFLAGS: -Ctarget-feature=+crt-static strategy: fail-fast: false matrix: target: - x86_64-pc-windows-msvc - i686-pc-windows-msvc # skip-pr skip-master - x86_64-pc-windows-gnu # skip-pr - i686-pc-windows-gnu # skip-pr skip-master include: - target: x86_64-pc-windows-gnu mingw: https://ci-mirrors.rust-lang.org/rustc/x86_64-6.3.0-release-posix-seh-rt_v5-rev2.7z mingwdir: mingw64 - target: i686-pc-windows-gnu mingwdir: mingw32 mingw: https://ci-mirrors.rust-lang.org/rustc/i686-6.3.0-release-posix-dwarf-rt_v5-rev2.7z steps: - uses: actions/checkout@v2 # v2 defaults to a shallow checkout, but we need at least to the previous tag with: fetch-depth: 0 - name: Acquire tags for the repo run: | git fetch --no-tags --prune --depth=1 origin +refs/tags/*:refs/tags/* - name: Display the current git status run: | git status git describe - name: Prep cargo dirs run: | New-Item "${env:USERPROFILE}\.cargo\registry" -ItemType Directory -Force New-Item "${env:USERPROFILE}\.cargo\git" -ItemType Directory -Force shell: powershell - name: Install mingw run: | # We retrieve mingw from the Rust CI buckets # Disable the download progress bar which can cause perf issues $ProgressPreference = "SilentlyContinue" Invoke-WebRequest ${{ matrix.mingw }} -OutFile mingw.7z 7z x -y mingw.7z -oC:\msys64 | Out-Null del mingw.7z echo "C:\msys64\usr\bin" | Out-File -Append -FilePath $env:GITHUB_PATH -Encoding utf8 echo "C:\msys64\${{ matrix.mingwdir }}\bin" | Out-File -Append -FilePath $env:GITHUB_PATH -Encoding utf8 shell: powershell if: matrix.mingw != '' - name: Set environment variables appropriately for the build run: | echo "%USERPROFILE%\.cargo\bin" | Out-File -Append -FilePath $env:GITHUB_PATH -Encoding utf8 echo "TARGET=${{ matrix.target }}" | Out-File -Append -FilePath $env:GITHUB_ENV -Encoding utf8 echo "SKIP_TESTS=${{ matrix.skip_tests }}" | Out-File -Append -FilePath $env:GITHUB_ENV -Encoding utf8 - name: Cache cargo registry and git trees uses: actions/cache@v2 with: path: | ~/.cargo/registry ~/.cargo/git key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - name: Get rustc commit hash id: cargo-target-cache run: | echo "::set-output name=rust_hash::$(rustc -Vv | grep commit-hash | awk '{print $2}')" shell: bash - name: Cache cargo build uses: actions/cache@v2 with: path: target key: ${{ github.base_ref }}-${{ github.head_ref }}-${{ matrix.target }}-cargo-target-dir-${{ steps.cargo-target-cache.outputs.rust_hash }}-${{ hashFiles('**/Cargo.lock') }} restore-keys: ${{ github.base_ref }}-${{ matrix.target }}-cargo-target-dir-${{ steps.cargo-target-cache.outputs.rust_hash }}-${{ hashFiles('**/Cargo.lock') }} - name: Install Rustup using win.rustup.rs run: | # Disable the download progress bar which can cause perf issues $ProgressPreference = "SilentlyContinue" Invoke-WebRequest https://win.rustup.rs/ -OutFile rustup-init.exe .\rustup-init.exe -y --default-host=x86_64-pc-windows-msvc --profile=minimal del rustup-init.exe shell: powershell - name: Ensure stable toolchain is up to date run: rustup update stable shell: bash - name: Install the target run: | rustup target install ${{ matrix.target }} - name: Run a full build run: bash ci/run.bash - name: Upload the built artifact if: false uses: actions/upload-artifact@v2 with: name: rustup-init-${{ matrix.target }} path: | target/${{ matrix.target }}/release/rustup-init.exe retention-days: 7 - name: Acquire the AWS tooling run: | choco upgrade awscli if: false && github.event_name == 'push' && github.ref == 'refs/heads/stable' - name: Prepare the dist run: | .\ci\prepare-deploy.ps1 shell: powershell if: false && github.event_name == 'push' && github.ref == 'refs/heads/stable' - name: Deploy build to dev-static dist tree for release team run: | aws --debug s3 cp --recursive dist s3://dev-static-rust-lang-org/rustup/dist env: AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} AWS_DEFAULT_REGION: us-west-1 if: false && github.event_name == 'push' && github.ref == 'refs/heads/stable' - name: Clear the cargo caches run: | cargo install cargo-cache --no-default-features --features ci-autoclean cargo-cache effective-limits-0.5.5/.gitignore000064400000000000000000000000231046102023000150550ustar 00000000000000/target Cargo.lock effective-limits-0.5.5/Cargo.lock0000644000000060460000000000100122630ustar # This file is automatically @generated by Cargo. # It is not intended for manual editing. version = 3 [[package]] name = "cc" version = "1.0.55" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b1be3409f94d7bdceeb5f5fac551039d9b3f00e25da7a74fc4d33400a0d96368" [[package]] name = "cfg-if" version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" [[package]] name = "effective-limits" version = "0.5.5" dependencies = [ "cfg-if", "libc", "sys-info", "thiserror", "winapi", ] [[package]] name = "libc" version = "0.2.137" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fc7fcc620a3bff7cdd7a365be3376c97191aeaccc2a603e600951e452615bf89" [[package]] name = "proc-macro2" version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "beae6331a816b1f65d04c45b078fd8e6c93e8071771f41b8163255bbd8d7c8fa" dependencies = [ "unicode-xid", ] [[package]] name = "quote" version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "aa563d17ecb180e500da1cfd2b028310ac758de548efdd203e18f283af693f37" dependencies = [ "proc-macro2", ] [[package]] name = "syn" version = "1.0.33" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e8d5d96e8cbb005d6959f119f773bfaebb5684296108fb32600c00cde305b2cd" dependencies = [ "proc-macro2", "quote", "unicode-xid", ] [[package]] name = "sys-info" version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b3a0d0aba8bf96a0e1ddfdc352fc53b3df7f39318c71854910c3c4b024ae52c" dependencies = [ "cc", "libc", ] [[package]] name = "thiserror" version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7dfdd070ccd8ccb78f4ad66bf1982dc37f620ef696c6b5028fe2ed83dd3d0d08" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bd80fc12f73063ac132ac92aceea36734f04a1d93c1240c6944e23a3b8841793" dependencies = [ "proc-macro2", "quote", "syn", ] [[package]] name = "unicode-xid" version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564" [[package]] name = "winapi" version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" dependencies = [ "winapi-i686-pc-windows-gnu", "winapi-x86_64-pc-windows-gnu", ] [[package]] name = "winapi-i686-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" effective-limits-0.5.5/Cargo.toml0000644000000032760000000000100123100ustar # THIS FILE IS AUTOMATICALLY GENERATED BY CARGO # # When uploading crates to the registry Cargo will automatically # "normalize" Cargo.toml files for maximal compatibility # with all versions of Cargo and also rewrite `path` dependencies # to registry (e.g., crates.io) dependencies. # # If you are reading this file be aware that the original Cargo.toml # will likely look very different (and much more reasonable). # See Cargo.toml.orig for the original contents. [package] edition = "2018" name = "effective-limits" version = "0.5.5" authors = ["Robert Collins "] description = "Estimate effective resource limits for a process e.g. how much RAM is available for use." readme = "README.md" keywords = [ "mem", "limits", "effective", "resource", ] categories = [ "config", "memory-management", ] license = "Apache-2.0" repository = "https://github.com/rbtcollins/effective-limits.rs" [dependencies.cfg-if] version = "0.1.10" [dependencies.thiserror] version = "1.0.20" [target."cfg(any(windows, target_os=\"macos\", target_os=\"linux\", target_os=\"freebsd\", target_os=\"illumos\", target_os=\"solaris\", target_os=\"netbsd\"))".dependencies.sys-info] version = "0.9.0" [target."cfg(unix)".dependencies.libc] version = "0.2.78" [target."cfg(windows)".dependencies.winapi] version = "0.3.9" features = [ "combaseapi", "errhandlingapi", "fileapi", "handleapi", "impl-default", "ioapiset", "jobapi", "jobapi2", "minwindef", "processthreadsapi", "psapi", "shlobj", "shtypes", "synchapi", "sysinfoapi", "tlhelp32", "userenv", "winbase", "winerror", "winioctl", "winnt", "winuser", ] effective-limits-0.5.5/Cargo.toml.orig000064400000000000000000000023741046102023000157670ustar 00000000000000[package] authors = ["Robert Collins "] categories = ["config", "memory-management"] description = "Estimate effective resource limits for a process e.g. how much RAM is available for use." edition = "2018" keywords = ["mem", "limits", "effective", "resource"] license = "Apache-2.0" name = "effective-limits" readme = "README.md" repository = "https://github.com/rbtcollins/effective-limits.rs" version = "0.5.5" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] cfg-if = "0.1.10" thiserror = "1.0.20" [target.'cfg(any(windows, target_os="macos", target_os="linux", target_os="freebsd", target_os="illumos", target_os="solaris", target_os="netbsd"))'.dependencies] sys-info = "0.9.0" [target.'cfg(unix)'.dependencies] libc = "0.2.78" [target."cfg(windows)".dependencies] winapi = { version = "0.3.9", features = [ "combaseapi", "errhandlingapi", "fileapi", "handleapi", "impl-default", "ioapiset", "jobapi", "jobapi2", "minwindef", "processthreadsapi", "psapi", "shlobj", "shtypes", "synchapi", "sysinfoapi", "tlhelp32", "userenv", "winbase", "winerror", "winioctl", "winnt", "winuser", ] } effective-limits-0.5.5/LICENSE-APACHE.txt000064400000000000000000000251421046102023000156400ustar 00000000000000 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. effective-limits-0.5.5/README.md000064400000000000000000000015121046102023000143500ustar 00000000000000# Estimate effective resource limits for a process `effective-limits` is a mid-level API for determining the effective limits upon a process. It combines e.g. `mem_info` and `getrlimit`. The goal is to have a good chance of avoiding failed allocations without requiring either developer or user a-priori selection of memory limits. That is, how much memory is effectively available for this process to use, considering the physical machine and ulimits, but not the impact of noisy neighbours, swappiness and so on. This limit can then be used to inform the size of in memory caches, put a threshold on in or output file buffers and so on. ```rust #![warn(clippy::all)] extern crate effective_limits; fn main() -> effective_limits::Result<()> { println!("Effective mem limit: {}", effective_limits::memory_limit()?); Ok(()) } ``` effective-limits-0.5.5/ci/README.md000064400000000000000000000001201046102023000147350ustar 00000000000000# CI support This CI glue is copied liberally from rust-lang/rustup's CI glue. effective-limits-0.5.5/ci/actions-templates/README.md000064400000000000000000000123361046102023000204050ustar 00000000000000# Rustup GitHub Actions Workflows This directory contains all the workflows we use in Rustup for GitHub Actions. ## Triggers for CI builds Rustup has four situations in which we perform CI builds: 1. On PR changes 2. On merge to master 3. Time-based rebuilds of master 4. Pushes to the stable branch The goals for each of those situations are subtly different. For PR changes, we want to know as quickly as possible if the change is likely to be an issue. Once a change hits master, we want to know that all our targets build. Time based rebuilds of master are about determining if updates to the toolchain have caused us problems, and also to try and hilight if we have flaky tests. The stable branch is about making releases. Builds from that branch are uploaded to S3 so that we can then make a release of rustup. ## Targets we need to build We build for all the Tier one targets and a non-trivial number of the tier two targets of Rust. We do not even attempt tier three builds. We don't run the tests on all the targets because many are cross-built. If we cross-build we don't run the tests. All the builds which aren't mac or windows are built on an x86_64 system because that's the easiest way to get a performant system. | Target | Cross | Tier | On PR? | On master? | | ----------------------------- | ---------- | ----- | ------ | ---------- | | x86_64-unknown-linux-gnu | No | One | Yes | Yes | | armv7-unknown-linux-gnueabihf | Yes | Two | Yes | Yes | | aarch64-linux-android | Yes | Two | Yes | Yes | | aarch64-unknown-linux-gnu | Yes | Two | No | Yes | | aarch64-unknown-linux-musl | Yes | Two | No | Yes | | powerpc64-unknown-linux-gnu | Yes | Two | No | Yes | | x86_64-unknown-linux-musl | Yes | Two | No | Yes | | i686-unknown-linux-gnu | Yes | One | No | No | | arm-unknown-linux-gnueabi | Yes | Two | No | No | | arm-unknown-linux-gnueabihf | Yes | Two | No | No | | x86_64-unknown-freebsd | Yes | Two | No | No | | x86_64-unknown-netbsd | Yes | Two | No | No | | x86_64-unknown-illumos | Yes | Two | No | No | | powerpc-unknown-linux-gnu | Yes | Two | No | No | | powerpc64le-unknown-linux-gnu | Yes | Two | No | No | | mips-unknown-linux-gnu | Yes | Two | No | No | | mips64-unknown-linux-gnu | Yes | Two | No | No | | mipsel-unknown-linux-gnu | Yes | Two | No | No | | mips64el-unknown-linux-gnu | Yes | Two | No | No | | s390x-unknown-linux-gnu | Yes | Two | No | No | | arm-linux-androideabi | Yes | Two | No | No | | armv7-linux-androideabi | Yes | Two | No | No | | i686-linux-android | Yes | Two | No | No | | x86_64-linux-android | Yes | Two | No | No | | riscv64gc-unknown-linux-gnu | Yes | --- | No | No | | ----------------------------- | ---------- | ----- | ------ | ---------- | | aarch64-apple-darwin | Yes | Two | Yes | Yes | | x86_64-apple-darwin | No | One | Yes | Yes | | ----------------------------- | ---------- | ----- | ------ | ---------- | | x86_64-pc-windows-msvc | No | One | Yes | Yes | | x86_64-pc-windows-gnu | No | One | No | Yes | | i686-pc-windows-msvc | No | One | No | No | | i686-pc-windows-gnu | No | One | No | No | | aarch64-pc-windows-msvc | Yes | Two | No | Yes | We also have a clippy/shellcheck target which runs on x86_64 linux and is run in all cases. It does a `cargo fmt` check, a `cargo clippy` check on the beta toolchain, and also runs `rustup-init.sh` through to completion inside a centos 6 docker to ensure that we continue to work on there OK. ## Useful notes about how we run builds For the builds which run on x86_64 linux, we deliberately run inside a docker image which comes from `rust-lang/rust`'s CI so that we know we're linking against the same libc etc as the release of Rust. For the builds which run on Windows, we retrieve mingw from Rust's CI as well so that we're clearly using the right version of that. In all cases, we attempt to use the `rustup-init.sh` from the branch under test where at all possible, so that we spot errors in that ASAP. Given that, we prefer to not use a preinstalled rust/rustup at all if we can, so we start from as bare a VM as makes sense. For Windows builds, we use a Visual Studio 2017 image if we can. ## The workflows Due to limitations in how github workflows work, we have to create our workflows from template files and then commit them. The templates are in this directory, and the built workflows end up in the `.github/workflows` directory. `-all` always runs, `-on-pr` `-on-master` and `-on-stable` do the obvious. effective-limits-0.5.5/ci/actions-templates/centos-fmt-clippy-template.yaml000064400000000000000000000057211046102023000252000ustar 00000000000000# This is ci/actions-templates/centos-fmt-clippy.yaml # Do not edit this file in .github/workflows name: General Checks on: pull_request: branches: - "*" push: branches: - master - stable schedule: - cron: "30 0 * * 1" # Every Monday at half past midnight jobs: check: name: Checks runs-on: ubuntu-latest strategy: fail-fast: false steps: - uses: actions/checkout@v2 with: # v2 defaults to a shallow checkout, but we need at least to the previous tag fetch-depth: 0 - name: Acquire tags for the repo run: | git fetch --no-tags --prune --depth=1 origin +refs/tags/*:refs/tags/* - name: Display the current git status run: | git status git describe - name: Prep cargo dirs run: | mkdir -p ~/.cargo/{registry,git} - name: Set environment variables appropriately for the build run: | echo "$HOME/.cargo/bin" >> $GITHUB_PATH - name: Cache cargo registry and git trees uses: actions/cache@v2 with: path: | ~/.cargo/registry ~/.cargo/git key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - name: Get rustc commit hash id: cargo-target-cache run: | echo "::set-output name=rust_hash::$(rustc -Vv | grep commit-hash | awk '{print $2}')" shell: bash - name: Cache cargo build uses: actions/cache@v2 with: path: target key: ${{ github.base_ref }}-${{ github.head_ref }}-${{ runner.os }}-cargo-clippy-target-dir-${{ steps.cargo-target-cache.outputs.rust_hash }}-${{ hashFiles('**/Cargo.lock') }} restore-keys: ${{ github.base_ref }}-${{ runner.os }}-cargo-clippy-target-dir-${{ steps.cargo-target-cache.outputs.rust_hash }}-${{ hashFiles('**/Cargo.lock') }} - name: Install Rustup run: | curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain=none --profile=minimal -y - name: Ensure Beta is up to date run: | if rustc +beta -vV >/dev/null 2>/dev/null; then rustup toolchain uninstall beta fi rustup toolchain install --profile=minimal beta rustup default beta - name: Ensure we have the components we need run: | rustup component add rustfmt rustup component add clippy - name: Run the centos check within the docker image run: | docker run \ --volume "$PWD":/checkout:ro \ --workdir /checkout \ --tty \ --init \ --rm \ centos:6 \ sh ./ci/raw_init.sh - name: Run formatting checks run: | cargo fmt --all --check - name: Run cargo check and clippy run: | cargo check --all --all-targets git ls-files -- '*.rs' | xargs touch cargo clippy --all --all-targets effective-limits-0.5.5/ci/actions-templates/gen-workflows.sh000064400000000000000000000011011046102023000222520ustar 00000000000000#!/bin/sh INPATH=$(dirname "$0") OUTPATH="${INPATH}/../../.github/workflows" gen_workflow () { grep -v "skip-$2" "$INPATH/$1-template.yaml" > "$OUTPATH/$1-on-$2.yaml" } mkdir -p "$OUTPATH" # macOS only has a single target so single flow gen_workflow macos-builds all gen_workflow windows-builds pr gen_workflow windows-builds master gen_workflow windows-builds stable gen_workflow linux-builds pr gen_workflow linux-builds master gen_workflow linux-builds stable # The clippy checks only have a single target and thus single flow gen_workflow centos-fmt-clippy all effective-limits-0.5.5/ci/actions-templates/linux-builds-template.yaml000064400000000000000000000171451046102023000242450ustar 00000000000000# This is ci/actions-templates/linux-builds-template.yaml # Do not edit this file in .github/workflows name: Linux (PR) # skip-master skip-stable name: Linux (master) # skip-pr skip-stable name: Linux (stable) # skip-master skip-pr on: pull_request: # skip-master skip-stable branches: # skip-master skip-stable - "*" # skip-master skip-stable push: # skip-pr branches: # skip-pr - master # skip-pr skip-stable - stable # skip-pr skip-master schedule: # skip-pr skip-stable - cron: "30 0 * * 1" # Every Monday at half past midnight UTC skip-pr skip-stable jobs: build: name: Build runs-on: ubuntu-latest strategy: fail-fast: false matrix: target: - x86_64-unknown-linux-gnu - armv7-unknown-linux-gnueabihf - aarch64-linux-android - aarch64-unknown-linux-gnu # skip-pr - aarch64-unknown-linux-musl # skip-pr skip-master - powerpc64-unknown-linux-gnu # skip-pr - x86_64-unknown-linux-musl # skip-pr - i686-unknown-linux-gnu # skip-pr skip-master - arm-unknown-linux-gnueabi # skip-pr skip-master - arm-unknown-linux-gnueabihf # skip-pr skip-master - x86_64-unknown-freebsd # skip-master - x86_64-unknown-netbsd # skip-master - x86_64-unknown-illumos # skip-pr skip-master - powerpc-unknown-linux-gnu # skip-pr skip-master - powerpc64le-unknown-linux-gnu # skip-pr skip-master - mips-unknown-linux-gnu # skip-pr skip-master - mips64-unknown-linux-gnuabi64 # skip-pr skip-master - mipsel-unknown-linux-gnu # skip-pr skip-master - mips64el-unknown-linux-gnuabi64 # skip-pr skip-master - s390x-unknown-linux-gnu # skip-pr skip-master - arm-linux-androideabi # skip-pr skip-master - armv7-linux-androideabi # skip-pr skip-master - i686-linux-android # skip-pr skip-master - x86_64-linux-android # skip-pr skip-master - riscv64gc-unknown-linux-gnu # skip-pr skip-master include: - target: x86_64-unknown-linux-gnu run_tests: YES #snap_arch: amd64 - target: i686-unknown-linux-gnu # skip-pr skip-master #snap_arch: i386 # skip-pr skip-master - target: aarch64-unknown-linux-gnu # skip-pr #snap_arch: arm64 # skip-pr - target: armv7-unknown-linux-gnueabihf #snap_arch: armhf - target: powerpc64le-unknown-linux-gnu # skip-pr skip-master #snap_arch: ppc64el # skip-pr skip-master - target: s390x-unknown-linux-gnu # skip-pr skip-master #snap_arch: s390x # skip-pr skip-master steps: - name: Clone repo uses: actions/checkout@v2 with: # v2 defaults to a shallow checkout, but we need at least to the previous tag fetch-depth: 0 - name: Acquire tags for the repo run: | git fetch --no-tags --prune --depth=1 origin +refs/tags/*:refs/tags/* - name: Display the current git status run: | git status git describe - name: Prep cargo dirs run: | mkdir -p ~/.cargo/{registry,git} - name: Set environment variables appropriately for the build run: | echo "$HOME/.cargo/bin" >> $GITHUB_PATH echo "TARGET=${{ matrix.target }}" >> $GITHUB_ENV - name: Skip tests run: | echo "SKIP_TESTS=yes" >> $GITHUB_ENV if: matrix.run_tests == '' - name: Cache cargo registry and git trees uses: actions/cache@v2 with: path: | ~/.cargo/registry ~/.cargo/git key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - name: Get rustc commit hash id: cargo-target-cache run: | echo "::set-output name=rust_hash::$(rustc -Vv | grep commit-hash | awk '{print $2}')" shell: bash - name: Cache cargo build uses: actions/cache@v2 with: path: target key: ${{ github.base_ref }}-${{ github.head_ref }}-${{ matrix.target }}-cargo-target-dir-${{ steps.cargo-target-cache.outputs.rust_hash }}-${{ hashFiles('**/Cargo.lock') }} restore-keys: ${{ github.base_ref }}-${{ matrix.target }}-cargo-target-dir-${{ steps.cargo-target-cache.outputs.rust_hash }}-${{ hashFiles('**/Cargo.lock') }} - name: Install Rustup run: | curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain=none --profile=minimal -y - name: Ensure Stable is up to date run: | if rustc +stable -vV >/dev/null 2>/dev/null; then rustup toolchain uninstall stable fi rustup toolchain install --profile=minimal stable - name: Ensure we have our goal target installed run: | rustup target install "$TARGET" - name: Determine which docker we need to run in run: | case "$TARGET" in *-linux-android*) DOCKER=android ;; # Android uses a local docker image *) DOCKER="$TARGET" ;; esac echo "DOCKER=$DOCKER" >> $GITHUB_ENV - name: Fetch the docker run: bash ci/fetch-rust-docker.bash "${TARGET}" - name: Maybe build a docker from there run: | if [ -f "ci/docker/$DOCKER/Dockerfile" ]; then docker build -t "$DOCKER" -f "ci/docker/${DOCKER}/Dockerfile" . fi - name: Run the build within the docker image run: | mkdir -p "${PWD}/target" chown -R "$(id -u)":"$(id -g)" "${PWD}/target" docker run \ --entrypoint sh \ --user "$(id -u)":"$(id -g)" \ --volume "$(rustc --print sysroot)":/rustc-sysroot:ro \ --volume "${PWD}":/checkout:ro \ --volume "${PWD}"/target:/checkout/target \ --workdir /checkout \ --env TARGET="${TARGET}" \ --env SKIP_TESTS="${SKIP_TESTS}" \ --volume "${HOME}/.cargo:/cargo" \ --env CARGO_HOME=/cargo \ --env CARGO_TARGET_DIR=/checkout/target \ --env LIBZ_SYS_STATIC=1 \ --tty \ --init \ --rm \ "${DOCKER}" \ -c 'PATH="${PATH}":/rustc-sysroot/bin bash ci/run.bash' - name: Upload the built artifact if: false uses: actions/upload-artifact@v2 with: name: rustup-init-${{ matrix.target }} path: | target/${{ matrix.target }}/release/rustup-init retention-days: 7 - name: Acquire the AWS tooling run: | pip3 install -U setuptools pip3 install awscli if: false && github.event_name == 'push' && github.ref == 'refs/heads/stable' - name: Prepare the dist run: | bash ci/prepare-deploy.bash if: false && github.event_name == 'push' && github.ref == 'refs/heads/stable' - name: Deploy build to dev-static dist tree for release team run: | aws s3 cp --recursive deploy/ s3://dev-static-rust-lang-org/rustup/ env: AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} AWS_DEFAULT_REGION: us-west-1 if: false && github.event_name == 'push' && github.ref == 'refs/heads/stable' - name: Clear the cargo caches run: | cargo install cargo-cache --no-default-features --features ci-autoclean cargo-cache effective-limits-0.5.5/ci/actions-templates/macos-builds-template.yaml000064400000000000000000000107071046102023000242050ustar 00000000000000# This is ci/actions-templates/macos-builds-template.yaml # Do not edit this file in .github/workflows name: macOS on: pull_request: branches: - "*" push: branches: - master - stable schedule: - cron: "30 0 * * 1" # Every Monday at half past midnight UTC jobs: build: name: Build runs-on: macos-latest strategy: matrix: target: - x86_64-apple-darwin - aarch64-apple-darwin steps: - uses: actions/checkout@v2 with: # v2 defaults to a shallow checkout, but we need at least to the previous tag fetch-depth: 0 - name: Acquire tags for the repo run: | git fetch --no-tags --prune --depth=1 origin +refs/tags/*:refs/tags/* - name: Display the current git status run: | git status git describe - name: Prep cargo dirs run: | mkdir -p ~/.cargo/{registry,git} - name: Set environment variables appropriately for the build run: | echo "$HOME/.cargo/bin" >> $GITHUB_PATH echo "TARGET=${{ matrix.target }}" >> $GITHUB_ENV echo "SKIP_TESTS=" >> $GITHUB_ENV echo "LZMA_API_STATIC=1" >> $GITHUB_ENV - name: Cache cargo registry and git trees uses: actions/cache@v2 with: path: | ~/.cargo/registry ~/.cargo/git key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - name: Get rustc commit hash id: cargo-target-cache run: | echo "::set-output name=rust_hash::$(rustc -Vv | grep commit-hash | awk '{print $2}')" shell: bash - name: Cache cargo build uses: actions/cache@v2 with: path: target key: ${{ github.base_ref }}-${{ github.head_ref }}-${{ matrix.target }}-cargo-target-dir-${{ steps.cargo-target-cache.outputs.rust_hash }}-${{ hashFiles('**/Cargo.lock') }}-3 restore-keys: ${{ github.base_ref }}-${{ matrix.target }}-cargo-target-dir-${{ steps.cargo-target-cache.outputs.rust_hash }}-${{ hashFiles('**/Cargo.lock') }}-3 - name: Install Rustup run: | curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain=none --profile=minimal -y - name: Ensure Stable is up to date run: | if rustc +stable -vV >/dev/null 2>/dev/null; then rustup toolchain uninstall stable fi rustup toolchain install --profile=minimal stable - name: aarch64-specific items run: | # Use nightly for now rustup toolchain install --profile=minimal nightly rustup default nightly # Can't run tests: cross-compiling echo "SKIP_TESTS=yes" >> $GITHUB_ENV if: matrix.target == 'aarch64-apple-darwin' - name: Ensure we have our goal target installed run: | rustup target install "$TARGET" - name: Run a full build and test run: bash ci/run.bash - name: Dump dynamic link targets if: false run: | otool -L target/${TARGET}/release/rustup-init if otool -L target/${TARGET}/release/rustup-init | grep -q -F /usr/local/; then echo >&2 "Unfortunately there are /usr/local things in the link. Fail." exit 1 fi - name: Upload the built artifact if: false uses: actions/upload-artifact@v2 with: name: rustup-init-${{ matrix.target }} path: | target/${{ matrix.target }}/release/rustup-init retention-days: 7 - name: Acquire the AWS tooling run: | pip3 install awscli if: false && github.event_name == 'push' && github.ref == 'refs/heads/stable' - name: Prepare the dist run: | bash ci/prepare-deploy.bash if: false && github.event_name == 'push' && github.ref == 'refs/heads/stable' - name: Deploy build to dev-static dist tree for release team run: | aws s3 cp --recursive deploy/ s3://dev-static-rust-lang-org/rustup/ env: AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} AWS_DEFAULT_REGION: us-west-1 if: false && github.event_name == 'push' && github.ref == 'refs/heads/stable' - name: Clear the cargo caches run: | cargo install cargo-cache --no-default-features --features ci-autoclean cargo-cacheeffective-limits-0.5.5/ci/actions-templates/windows-builds-template.yaml000064400000000000000000000135611046102023000245760ustar 00000000000000# This is ci/actions-templates/windows-builds-template.yaml # Do not edit this file in .github/workflows name: Windows (PR) # skip-master skip-stable name: Windows (master) # skip-pr skip-stable name: Windows (stable) # skip-master skip-pr on: pull_request: # skip-master skip-stable branches: # skip-master skip-stable - "*" # skip-master skip-stable push: # skip-pr branches: # skip-pr - master # skip-pr skip-stable - stable # skip-pr skip-master schedule: # skip-pr skip-stable - cron: "30 0 * * 1" # Every Monday at half past midnight UTC skip-pr skip-stable jobs: build: name: Build runs-on: windows-latest env: RUSTFLAGS: -Ctarget-feature=+crt-static strategy: fail-fast: false matrix: target: - x86_64-pc-windows-msvc - i686-pc-windows-msvc # skip-pr skip-master - aarch64-pc-windows-msvc # skip-pr skip-stable - x86_64-pc-windows-gnu # skip-pr - i686-pc-windows-gnu # skip-pr skip-master include: - target: x86_64-pc-windows-gnu mingw: https://ci-mirrors.rust-lang.org/rustc/x86_64-6.3.0-release-posix-seh-rt_v5-rev2.7z mingwdir: mingw64 - target: i686-pc-windows-gnu mingwdir: mingw32 mingw: https://ci-mirrors.rust-lang.org/rustc/i686-6.3.0-release-posix-dwarf-rt_v5-rev2.7z - target: aarch64-pc-windows-msvc # skip-pr skip-stable skip_tests: yes # skip-pr skip-stable steps: - uses: actions/checkout@v2 # v2 defaults to a shallow checkout, but we need at least to the previous tag with: fetch-depth: 0 - name: Acquire tags for the repo run: | git fetch --no-tags --prune --depth=1 origin +refs/tags/*:refs/tags/* - name: Display the current git status run: | git status git describe - name: Prep cargo dirs run: | New-Item "${env:USERPROFILE}\.cargo\registry" -ItemType Directory -Force New-Item "${env:USERPROFILE}\.cargo\git" -ItemType Directory -Force shell: powershell - name: Install mingw run: | # We retrieve mingw from the Rust CI buckets # Disable the download progress bar which can cause perf issues $ProgressPreference = "SilentlyContinue" Invoke-WebRequest ${{ matrix.mingw }} -OutFile mingw.7z 7z x -y mingw.7z -oC:\msys64 | Out-Null del mingw.7z echo "C:\msys64\usr\bin" | Out-File -Append -FilePath $env:GITHUB_PATH -Encoding utf8 echo "C:\msys64\${{ matrix.mingwdir }}\bin" | Out-File -Append -FilePath $env:GITHUB_PATH -Encoding utf8 shell: powershell if: matrix.mingw != '' - name: Set environment variables appropriately for the build run: | echo "%USERPROFILE%\.cargo\bin" | Out-File -Append -FilePath $env:GITHUB_PATH -Encoding utf8 echo "TARGET=${{ matrix.target }}" | Out-File -Append -FilePath $env:GITHUB_ENV -Encoding utf8 echo "SKIP_TESTS=${{ matrix.skip_tests }}" | Out-File -Append -FilePath $env:GITHUB_ENV -Encoding utf8 - name: Cache cargo registry and git trees uses: actions/cache@v2 with: path: | ~/.cargo/registry ~/.cargo/git key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - name: Get rustc commit hash id: cargo-target-cache run: | echo "::set-output name=rust_hash::$(rustc -Vv | grep commit-hash | awk '{print $2}')" shell: bash - name: Cache cargo build uses: actions/cache@v2 with: path: target key: ${{ github.base_ref }}-${{ github.head_ref }}-${{ matrix.target }}-cargo-target-dir-${{ steps.cargo-target-cache.outputs.rust_hash }}-${{ hashFiles('**/Cargo.lock') }} restore-keys: ${{ github.base_ref }}-${{ matrix.target }}-cargo-target-dir-${{ steps.cargo-target-cache.outputs.rust_hash }}-${{ hashFiles('**/Cargo.lock') }} - name: Install Rustup using win.rustup.rs run: | # Disable the download progress bar which can cause perf issues $ProgressPreference = "SilentlyContinue" Invoke-WebRequest https://win.rustup.rs/ -OutFile rustup-init.exe .\rustup-init.exe -y --default-host=x86_64-pc-windows-msvc --profile=minimal del rustup-init.exe shell: powershell - name: Ensure stable toolchain is up to date run: rustup update stable shell: bash - name: Install the target run: | rustup target install ${{ matrix.target }} - name: Run a full build run: bash ci/run.bash - name: Upload the built artifact if: false uses: actions/upload-artifact@v2 with: name: rustup-init-${{ matrix.target }} path: | target/${{ matrix.target }}/release/rustup-init.exe retention-days: 7 - name: Acquire the AWS tooling run: | choco upgrade awscli if: false && github.event_name == 'push' && github.ref == 'refs/heads/stable' - name: Prepare the dist run: | .\ci\prepare-deploy.ps1 shell: powershell if: false && github.event_name == 'push' && github.ref == 'refs/heads/stable' - name: Deploy build to dev-static dist tree for release team run: | aws --debug s3 cp --recursive dist s3://dev-static-rust-lang-org/rustup/dist env: AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} AWS_DEFAULT_REGION: us-west-1 if: false && github.event_name == 'push' && github.ref == 'refs/heads/stable' - name: Clear the cargo caches run: | cargo install cargo-cache --no-default-features --features ci-autoclean cargo-cache effective-limits-0.5.5/ci/docker/aarch64-unknown-linux-gnu/Dockerfile000064400000000000000000000002661046102023000236030ustar 00000000000000FROM rust-aarch64-unknown-linux-gnu ENV CC_aarch64_unknown_linux_gnu=aarch64-unknown-linux-gnu-gcc \ CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-unknown-linux-gnu-gcc effective-limits-0.5.5/ci/docker/aarch64-unknown-linux-musl/Dockerfile000064400000000000000000000003551046102023000237710ustar 00000000000000FROM rust-aarch64-unknown-linux-musl ENV CC_aarch64_unknown_linux_musl=aarch64-linux-musl-gcc \ CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER=aarch64-linux-musl-gcc \ RUSTFLAGS="-C target-feature=+crt-static -C link-arg=-lgcc" effective-limits-0.5.5/ci/docker/android/Dockerfile000064400000000000000000000020761046102023000203530ustar 00000000000000FROM rust-android ENV PATH=$PATH:/android/ndk/toolchains/llvm/prebuilt/linux-x86_64/bin \ CC_arm_linux_androideabi=arm-linux-androideabi21-clang \ CC_armv7_linux_androideabi=arm-linux-androideabi21-clang \ CC_aarch64_linux_android=aarch64-linux-android21-clang \ CC_i686_linux_android=i686-linux-android21-clang \ CC_x86_64_linux_android=x86_64-linux-android21-clang \ CXX_arm_linux_androideabi=arm-linux-androideabi21-clang++ \ CXX_armv7_linux_androideabi=arm-linux-androideabi21-clang++ \ CXX_aarch64_linux_android=aarch64-linux-android21-clang++ \ CXX_i686_linux_android=i686-linux-android21-clang++ \ CXX_x86_64_linux_android=x86_64-linux-android21-clang++ \ CARGO_TARGET_ARM_LINUX_ANDROIDEABI_LINKER=arm-linux-androideabi21-clang \ CARGO_TARGET_ARMV7_LINUX_ANDROIDEABI_LINKER=arm-linux-androideabi21-clang \ CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER=aarch64-linux-android21-clang \ CARGO_TARGET_I686_LINUX_ANDROID_LINKER=i686-linux-android21-clang \ CARGO_TARGET_X86_64_LINUX_ANDROID_LINKER=x86_64-linux-android21-clang effective-limits-0.5.5/ci/docker/arm-unknown-linux-gnueabi/Dockerfile000064400000000000000000000002661046102023000237530ustar 00000000000000FROM rust-arm-unknown-linux-gnueabi ENV CC_arm_unknown_linux_gnueabi=arm-unknown-linux-gnueabi-gcc \ CARGO_TARGET_ARM_UNKNOWN_LINUX_GNUEABI_LINKER=arm-unknown-linux-gnueabi-gcc effective-limits-0.5.5/ci/docker/arm-unknown-linux-gnueabihf/Dockerfile000064400000000000000000000003001046102023000242560ustar 00000000000000FROM rust-arm-unknown-linux-gnueabihf ENV CC_arm_unknown_linux_gnueabihf=arm-unknown-linux-gnueabihf-gcc \ CARGO_TARGET_ARM_UNKNOWN_LINUX_GNUEABIHF_LINKER=arm-unknown-linux-gnueabihf-gcc effective-limits-0.5.5/ci/docker/armv7-unknown-linux-gnueabihf/Dockerfile000064400000000000000000000003121046102023000245360ustar 00000000000000FROM rust-armv7-unknown-linux-gnueabihf ENV CC_armv7_unknown_linux_gnueabihf=armv7-unknown-linux-gnueabihf-gcc \ CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER=armv7-unknown-linux-gnueabihf-gcc effective-limits-0.5.5/ci/docker/i686-unknown-linux-gnu/Dockerfile000064400000000000000000000000411046102023000230360ustar 00000000000000FROM rust-i686-unknown-linux-gnu effective-limits-0.5.5/ci/docker/mips-unknown-linux-gnu/Dockerfile000064400000000000000000000002271046102023000233200ustar 00000000000000FROM rust-mips-unknown-linux-gnu ENV CC_mips_unknown_linux_gnu=mips-linux-gnu-gcc \ CARGO_TARGET_MIPS_UNKNOWN_LINUX_GNU_LINKER=mips-linux-gnu-gcc effective-limits-0.5.5/ci/docker/mips64-unknown-linux-gnuabi64/Dockerfile000064400000000000000000000002721046102023000243200ustar 00000000000000FROM rust-mips64-unknown-linux-gnuabi64 ENV CC_mips64_unknown_linux_gnuabi64=mips64-linux-gnuabi64-gcc \ CARGO_TARGET_MIPS64_UNKNOWN_LINUX_GNUABI64_LINKER=mips64-linux-gnuabi64-gcc effective-limits-0.5.5/ci/docker/mips64el-unknown-linux-gnuabi64/Dockerfile000064400000000000000000000003041046102023000246350ustar 00000000000000FROM rust-mips64el-unknown-linux-gnuabi64 ENV CC_mips64el_unknown_linux_gnuabi64=mips64el-linux-gnuabi64-gcc \ CARGO_TARGET_MIPS64EL_UNKNOWN_LINUX_GNUABI64_LINKER=mips64el-linux-gnuabi64-gcc effective-limits-0.5.5/ci/docker/mipsel-unknown-linux-gnu/Dockerfile000064400000000000000000000002411046102023000236350ustar 00000000000000FROM rust-mipsel-unknown-linux-gnu ENV CC_mipsel_unknown_linux_gnu=mipsel-linux-gnu-gcc \ CARGO_TARGET_MIPSEL_UNKNOWN_LINUX_GNU_LINKER=mipsel-linux-gnu-gcc effective-limits-0.5.5/ci/docker/powerpc-unknown-linux-gnu/Dockerfile000064400000000000000000000002661046102023000240320ustar 00000000000000FROM rust-powerpc-unknown-linux-gnu ENV CC_powerpc_unknown_linux_gnu=powerpc-unknown-linux-gnu-gcc \ CARGO_TARGET_POWERPC_UNKNOWN_LINUX_GNU_LINKER=powerpc-unknown-linux-gnu-gcc effective-limits-0.5.5/ci/docker/powerpc64-unknown-linux-gnu/Dockerfile000064400000000000000000000003001046102023000241710ustar 00000000000000FROM rust-powerpc64-unknown-linux-gnu ENV CC_powerpc64_unknown_linux_gnu=powerpc64-unknown-linux-gnu-gcc \ CARGO_TARGET_POWERPC64_UNKNOWN_LINUX_GNU_LINKER=powerpc64-unknown-linux-gnu-gcc effective-limits-0.5.5/ci/docker/powerpc64le-unknown-linux-gnu/Dockerfile000064400000000000000000000002721046102023000245220ustar 00000000000000FROM rust-powerpc64le-unknown-linux-gnu ENV CC_powerpc64le_unknown_linux_gnu=powerpc64le-linux-gnu-gcc \ CARGO_TARGET_POWERPC64LE_UNKNOWN_LINUX_GNU_LINKER=powerpc64le-linux-gnu-gcc effective-limits-0.5.5/ci/docker/riscv64gc-unknown-linux-gnu/Dockerfile000064400000000000000000000002741046102023000241640ustar 00000000000000FROM rust-riscv64gc-unknown-linux-gnu ENV CC_riscv64gc_unknown_linux_gnu=riscv64-unknown-linux-gnu-gcc \ CARGO_TARGET_RISCV64GC_UNKNOWN_LINUX_GNU_LINKER=riscv64-unknown-linux-gnu-gcc effective-limits-0.5.5/ci/docker/s390x-unknown-linux-gnu/Dockerfile000064400000000000000000000002441046102023000232350ustar 00000000000000FROM rust-s390x-unknown-linux-gnu ENV CC_s390x_unknown_linux_gnu=s390x-ibm-linux-gnu-gcc \ CARGO_TARGET_S390X_UNKNOWN_LINUX_GNU_LINKER=s390x-ibm-linux-gnu-gcc effective-limits-0.5.5/ci/docker/scripts/sccache.bash000064400000000000000000000011151046102023000206510ustar 00000000000000#!/bin/bash set -xe VERSION=0.2.12 TARGET=x86_64-unknown-linux-musl # from https://github.com/mozilla/sccache/releases SHA="26fd04c1273952cc2a0f359a71c8a1857137f0ee3634058b3f4a63b69fc8eb7f" DL_URL="https://github.com/mozilla/sccache/releases/download" BIN_DIR=/usr/local/bin TEMP_DIR=$(mktemp -d) TAR_NAME="sccache-${VERSION}-${TARGET}.tar.gz" cd "${TEMP_DIR}" mkdir -p "${BIN_DIR}" curl -sSL -O "${DL_URL}/${VERSION}/${TAR_NAME}" echo "${SHA} ${TAR_NAME}" | sha256sum --check - tar -xzf "${TAR_NAME}" --strip-components 1 cp sccache "${BIN_DIR}/sccache" chmod +x "${BIN_DIR}/sccache" effective-limits-0.5.5/ci/docker/x86_64-unknown-freebsd/Dockerfile000064400000000000000000000002571046102023000227750ustar 00000000000000FROM rust-x86_64-unknown-freebsd ENV CC_x86_64_unknown_freebsd=x86_64-unknown-freebsd12-clang \ CARGO_TARGET_X86_64_UNKNOWN_FREEBSD_LINKER=x86_64-unknown-freebsd12-clang effective-limits-0.5.5/ci/docker/x86_64-unknown-illumos/Dockerfile000064400000000000000000000004031046102023000230400ustar 00000000000000FROM rust-x86_64-unknown-illumos ENV \ AR_x86_64_unknown_illumos=x86_64-illumos-ar \ CC_x86_64_unknown_illumos=x86_64-illumos-gcc \ CXX_x86_64_unknown_illumos=x86_64-illumos-g++ \ CARGO_TARGET_X86_64_UNKNOWN_ILLUMOS_LINKER=x86_64-illumos-gcc effective-limits-0.5.5/ci/docker/x86_64-unknown-linux-gnu/Dockerfile000064400000000000000000000000431046102023000233020ustar 00000000000000FROM rust-x86_64-unknown-linux-gnu effective-limits-0.5.5/ci/docker/x86_64-unknown-linux-musl/Dockerfile000064400000000000000000000003671046102023000235020ustar 00000000000000FROM ubuntu:18.04 COPY ci/docker/scripts/sccache.bash /scripts/ RUN \ apt-get update && \ apt-get install -qy \ musl-dev \ musl-tools \ curl \ ca-certificates \ perl \ make \ gcc && \ bash /scripts/sccache.bash effective-limits-0.5.5/ci/docker/x86_64-unknown-netbsd/Dockerfile000064400000000000000000000001521046102023000226340ustar 00000000000000FROM rust-x86_64-unknown-netbsd ENV CARGO_TARGET_X86_64_UNKNOWN_NETBSD_LINKER=x86_64--netbsd-gcc-sysroot effective-limits-0.5.5/ci/fetch-rust-docker.bash000064400000000000000000000043141046102023000176570ustar 00000000000000#!/bin/bash script_dir=$(cd "$(dirname "$0")" && pwd) . "$script_dir/shared.bash" set -e # Disable cause it makes shared script not to work properly #set -x TARGET="$1" RUST_REPO="https://github.com/rust-lang/rust" ARTIFACTS_BASE_URL="https://ci-artifacts.rust-lang.org/rustc-builds" LOCAL_DOCKER_TAG="rust-$TARGET" # Use images from rustc master case "$TARGET" in aarch64-unknown-linux-gnu) image=dist-aarch64-linux ;; aarch64-unknown-linux-musl) image=dist-arm-linux ;; arm-unknown-linux-gnueabi) image=dist-arm-linux ;; arm-unknown-linux-gnueabihf) image=dist-armhf-linux ;; armv7-unknown-linux-gnueabihf) image=dist-armv7-linux ;; i686-unknown-linux-gnu) image=dist-i686-linux ;; *-linux-android*) image=dist-android; LOCAL_DOCKER_TAG=rust-android ;; mips-unknown-linux-gnu) image=dist-mips-linux ;; mips64-unknown-linux-gnuabi64) image=dist-mips64-linux ;; mips64el-unknown-linux-gnuabi64) image=dist-mips64el-linux ;; mipsel-unknown-linux-gnu) image=dist-mipsel-linux ;; powerpc-unknown-linux-gnu) image=dist-powerpc-linux ;; powerpc64-unknown-linux-gnu) image=dist-powerpc64-linux ;; powerpc64le-unknown-linux-gnu) image=dist-powerpc64le-linux ;; s390x-unknown-linux-gnu) image=dist-s390x-linux ;; x86_64-unknown-freebsd) image=dist-x86_64-freebsd ;; x86_64-unknown-illumos) image=dist-x86_64-illumos ;; x86_64-unknown-linux-gnu) image=dist-x86_64-linux ;; x86_64-unknown-netbsd) image=dist-x86_64-netbsd ;; riscv64gc-unknown-linux-gnu) image=dist-riscv64-linux ;; *) exit ;; esac master=$(git ls-remote "$RUST_REPO" refs/heads/master | cut -f1) image_url="$ARTIFACTS_BASE_URL/$master/image-$image.txt" info="/tmp/image-$image.txt" rm -f "$info" curl -o "$info" "$image_url" digest=$(grep -m1 ^sha "$info") if [ -z "$(docker images -q "${LOCAL_DOCKER_TAG}")" ]; then url=$(grep -m1 ^https "$info") cache=/tmp/rustci_docker_cache echo "Attempting to download $url" rm -f "$cache" set +e command_retry curl -y 30 -Y 10 --connect-timeout 30 -f -L -C - -o "$cache" "$url" set -e docker load --quiet -i "$cache" docker tag "$digest" "${LOCAL_DOCKER_TAG}" fi effective-limits-0.5.5/ci/raw_init.sh000064400000000000000000000001721046102023000156350ustar 00000000000000#!/bin/sh set -ex curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain none -y . "$HOME"/.cargo/env rustup -Vv effective-limits-0.5.5/ci/run.bash000064400000000000000000000013101046102023000151230ustar 00000000000000#!/bin/bash set -ex export RUST_BACKTRACE=1 rustc -vV cargo -vV FEATURES=() case "$(uname -s)" in *NT* ) ;; # Windows NT * ) FEATURES+=() ;; esac case "$TARGET" in # these platforms aren't supported by ring: powerpc* ) ;; mips* ) ;; riscv* ) ;; s390x* ) ;; aarch64-pc-windows-msvc ) ;; # default case, build with rustls enabled * ) FEATURES+=() ;; esac # rustc only supports armv7: https://doc.rust-lang.org/nightly/rustc/platform-support.html if [ "$TARGET" = arm-linux-androideabi ]; then export CFLAGS='-march=armv7' fi cargo build --release --target "$TARGET" "${FEATURES[@]}" if [ -z "$SKIP_TESTS" ]; then cargo test --locked --release --target "$TARGET" "${FEATURES[@]}" fi effective-limits-0.5.5/ci/shared.bash000064400000000000000000000020231046102023000155670ustar 00000000000000#!/bin/bash # # This file is intended to be sourced, so it is not being marked as # an executable file in git. # This is modified from # https://github.com/travis-ci/travis-build/blob/master/lib/travis/build/bash/travis_setup_env.bash export ANSI_RED='\033[31;1m' export ANSI_GREEN='\033[32;1m' export ANSI_YELLOW='\033[33;1m' export ANSI_RESET='\033[0m' export ANSI_CLEAR='\033[0K' # This is modified loop version of # https://github.com/travis-ci/travis-build/blob/master/lib/travis/build/bash/travis_retry.bash command_retry() { local result=0 local count=1 local max=5 while [ "${count}" -le "${max}" ]; do [ "${result}" -ne 0 ] && { printf "${ANSI_RED}"'The command "%s" failed. Retrying, %s of %s.'"${ANSI_RESET}"'\n' "${*}" "${count}" "${max}" >&2 } "${@}" && { result=0 && break; } || result="${?}" : $((count=count+1)) sleep 1 done [ "${count}" -gt "${max}" ] && { printf "${ANSI_RED}"'The command "%s" failed %s times.'"${ANSI_RESET}"'\n' "${*}" "${max}" >&2 } return "${result}" } effective-limits-0.5.5/examples/memory.rs000064400000000000000000000002741046102023000165710ustar 00000000000000#![warn(clippy::all)] extern crate effective_limits; fn main() -> effective_limits::Result<()> { println!("Effective mem limit: {}", effective_limits::memory_limit()?); Ok(()) } effective-limits-0.5.5/src/bin/test-limited.rs000064400000000000000000000003521046102023000174030ustar 00000000000000#![warn(clippy::all)] extern crate effective_limits; // Functional test helper for the library, not an end user script. fn main() -> effective_limits::Result<()> { println!("{}", effective_limits::memory_limit()?); Ok(()) } effective-limits-0.5.5/src/lib.rs000064400000000000000000000372001046102023000147770ustar 00000000000000#![warn(clippy::all)] // for error_chain! #![recursion_limit = "1024"] use std::cmp::min; use cfg_if::cfg_if; cfg_if! { if #[cfg(any(windows, target_os="macos", target_os="linux", target_os="freebsd", target_os="illumos", target_os="solaris", target_os="netbsd", ))] { #[derive(thiserror::Error, Debug)] pub enum Error { #[error("sysinfo failure")] SysInfo(#[from] ::sys_info::Error), #[error("io error")] IoError(#[from] std::io::Error), #[error("io error {1} ({0:?})")] IoExplainedError(#[source] std::io::Error, String), #[error("utf8 error")] Utf8Error(#[from] std::str::Utf8Error), #[error("u64 parse error on '{1}' ({0:?})")] U64Error(#[source] std::num::ParseIntError, String), } } else { #[derive(thiserror::Error, Debug)] pub enum Error { #[error("no system information on this platform")] SysInfo, #[error("io error")] IoError(#[from] std::io::Error), #[error("io error {1} ({0:?})")] IoExplainedError(#[source] std::io::Error, String), #[error("utf8 error")] Utf8Error(#[from] std::str::Utf8Error), #[error("u64 parse error on '{1}' ({0:?})")] U64Error(#[source] std::num::ParseIntError, String), } } } pub type Result = std::result::Result; #[allow(dead_code)] fn min_opt(left: u64, right: Option) -> u64 { match right { None => left, Some(right) => min(left, right), } } #[allow(dead_code)] #[cfg(unix)] fn ulimited_memory() -> Result> { let mut out = libc::rlimit { rlim_cur: 0, rlim_max: 0, }; // https://github.com/rust-lang/libc/pull/1919 cfg_if!( if #[cfg( target_os="netbsd")] { // https://github.com/NetBSD/src/blob/f869ef2144970023b53d335d9a23ecf100d4b973/sys/sys/resource.h#L98 let rlimit_as = 10; } else { let rlimit_as = libc::RLIMIT_AS; } ); match unsafe { libc::getrlimit(rlimit_as, &mut out as *mut libc::rlimit) } { 0 => Ok(()), _ => Err(std::io::Error::last_os_error()), }?; let address_limit = match out.rlim_cur { libc::RLIM_INFINITY => None, _ => Some(out.rlim_cur as u64), }; let mut out = libc::rlimit { rlim_cur: 0, rlim_max: 0, }; match unsafe { libc::getrlimit(libc::RLIMIT_DATA, &mut out as *mut libc::rlimit) } { 0 => Ok(()), _ => Err(std::io::Error::last_os_error()), }?; let data_limit = match out.rlim_cur { libc::RLIM_INFINITY => address_limit, _ => Some(out.rlim_cur as u64), }; Ok(address_limit .or(data_limit) .map(|left| min_opt(left, data_limit))) } #[cfg(not(unix))] fn win_err(fn_name: &str) -> Result { Err(Error::IoExplainedError( std::io::Error::last_os_error(), fn_name.into(), )) } #[cfg(not(unix))] fn ulimited_memory() -> Result> { use std::mem::size_of; use winapi::shared::minwindef::{FALSE, LPVOID}; use winapi::shared::ntdef::NULL; use winapi::um::jobapi::IsProcessInJob; use winapi::um::jobapi2::QueryInformationJobObject; use winapi::um::processthreadsapi::GetCurrentProcess; use winapi::um::winnt::{ JobObjectExtendedLimitInformation, JOBOBJECT_EXTENDED_LIMIT_INFORMATION, JOB_OBJECT_LIMIT_PROCESS_MEMORY, }; let mut in_job = 0; match unsafe { IsProcessInJob(GetCurrentProcess(), NULL, &mut in_job) } { FALSE => win_err("IsProcessInJob"), _ => Ok(()), }?; if in_job == FALSE { return Ok(None); } let mut job_info = winapi::um::winnt::JOBOBJECT_EXTENDED_LIMIT_INFORMATION { ..Default::default() }; let mut written: u32 = 0; match unsafe { QueryInformationJobObject( NULL, JobObjectExtendedLimitInformation, &mut job_info as *mut JOBOBJECT_EXTENDED_LIMIT_INFORMATION as LPVOID, size_of::() as u32, &mut written, ) } { FALSE => win_err("QueryInformationJobObject"), _ => Ok(()), }?; if job_info.BasicLimitInformation.LimitFlags & JOB_OBJECT_LIMIT_PROCESS_MEMORY == JOB_OBJECT_LIMIT_PROCESS_MEMORY { Ok(Some(job_info.ProcessMemoryLimit as u64)) } else { Ok(None) } } /// How much memory is effectively available for this process to use, /// considering the physical machine and ulimits, but not the impact of noisy /// neighbours, swappiness and so on. The goal is to have a good chance of /// avoiding failed allocations without requiring either developer or user /// a-priori selection of memory limits. pub fn memory_limit() -> Result { cfg_if! { if #[cfg(any(windows, target_os="macos", target_os="linux", target_os="freebsd", target_os="illumos", target_os="solaris", target_os="netbsd", ))] { let info = sys_info::mem_info()?; let total_ram = info.total * 1024; let ulimit_mem = ulimited_memory()?; Ok(min_opt(total_ram, ulimit_mem)) } else { // https://github.com/FillZpp/sys-info-rs/issues/72 Err(Error::SysInfo) } } } #[cfg(test)] mod tests { use std::env; #[cfg(unix)] use std::os::unix::process::CommandExt; #[cfg(windows)] use std::os::windows::process::CommandExt; use std::path::PathBuf; use std::process::Command; use std::str; #[cfg(windows)] use winapi::shared::minwindef::{DWORD, FALSE, LPVOID}; #[cfg(windows)] use winapi::shared::ntdef::NULL; use super::*; #[cfg(any( windows, target_os = "macos", target_os = "linux", target_os = "freebsd", target_os = "illumos", target_os = "solaris", target_os = "netbsd", ))] #[test] fn it_works() -> Result<()> { assert_ne!(0, memory_limit()?); Ok(()) } #[test] fn test_min_opt() { assert_eq!(0, min_opt(0, None)); assert_eq!(0, min_opt(0, Some(1))); assert_eq!(1, min_opt(2, Some(1))); } fn test_process_path() -> Option { env::current_exe().ok().and_then(|p| { p.parent().map(|p| { p.with_file_name("test-limited") .with_extension(env::consts::EXE_EXTENSION) }) }) } fn read_test_process(ulimit: Option) -> Result { // Spawn the test helper and read it's result. let path = test_process_path().unwrap(); let mut cmd = Command::new(&path); let output = match ulimit { Some(ulimit) => { #[cfg(windows)] { use std::mem::size_of; use std::process::Stdio; cmd.creation_flags(winapi::um::winbase::CREATE_SUSPENDED); let job = match unsafe { winapi::um::winbase::CreateJobObjectA( NULL as *mut winapi::um::minwinbase::SECURITY_ATTRIBUTES, NULL as *const i8, ) } { NULL => win_err("CreateJobObjectA"), handle => Ok(handle), }?; let mut job_info = winapi::um::winnt::JOBOBJECT_EXTENDED_LIMIT_INFORMATION { BasicLimitInformation: winapi::um::winnt::JOBOBJECT_BASIC_LIMIT_INFORMATION { LimitFlags: winapi::um::winnt::JOB_OBJECT_LIMIT_PROCESS_MEMORY, ..Default::default() }, ProcessMemoryLimit: ulimit as usize, ..Default::default() }; match unsafe { winapi::um::jobapi2::SetInformationJobObject( job, winapi::um::winnt::JobObjectExtendedLimitInformation, &mut job_info as *mut winapi::um::winnt::JOBOBJECT_EXTENDED_LIMIT_INFORMATION as LPVOID, size_of::() as u32, ) } { FALSE => win_err("SetInformationJobObject"), _ => Ok(()), }?; let child = cmd .stdin(Stdio::null()) .stdout(Stdio::piped()) .stderr(Stdio::piped()) .spawn() .map_err(|e| { crate::Error::IoExplainedError(e, "error spawning helper".into()) })?; let childhandle = match unsafe { winapi::um::processthreadsapi::OpenProcess( winapi::um::winnt::JOB_OBJECT_ASSIGN_PROCESS // The docs say only JOB_OBJECT_ASSIGN_PROCESS is // needed, but access denied is returned unless more // permissions are requested, and the actual set needed // is not documented. | winapi::um::winnt::PROCESS_ALL_ACCESS, FALSE, child.id(), ) } { NULL => win_err("OpenProcess"), handle => Ok(handle), }?; println!("assigning job {} pid {}", job as u32, childhandle as u32); let res = unsafe { winapi::um::jobapi2::AssignProcessToJobObject(job, childhandle) }; match res { FALSE => win_err("AssignProcessToJobObject"), _ => Ok(()), }?; let mut tid: DWORD = 0; let tool = match unsafe { winapi::um::tlhelp32::CreateToolhelp32Snapshot( winapi::um::tlhelp32::TH32CS_SNAPTHREAD, 0, ) } { winapi::um::handleapi::INVALID_HANDLE_VALUE => { win_err("CreateToolhelp32Snapshot") } handle => Ok(handle), }?; let mut te = winapi::um::tlhelp32::THREADENTRY32 { dwSize: size_of::() as u32, ..Default::default() }; match unsafe { winapi::um::tlhelp32::Thread32First(tool, &mut te) } { FALSE => win_err("Thread32First"), _ => Ok(()), }?; while { if te.dwSize >= 16 /* owner proc id field offset */ &&te.th32OwnerProcessID == child.id() { tid = te.th32ThreadID; // a break here would be nice. }; te.dwSize = size_of::() as u32; match unsafe { winapi::um::tlhelp32::Thread32Next(tool, &mut te) } { FALSE => { let err = unsafe { winapi::um::errhandlingapi::GetLastError() }; match err { winapi::shared::winerror::ERROR_NO_MORE_FILES => Ok(false), _ => win_err("Thread32Next"), } } _ => Ok(true), }? } {} match unsafe { winapi::um::handleapi::CloseHandle(tool) } { FALSE => win_err("CloseHandle"), _ => Ok(()), }?; let thread = match unsafe { winapi::um::processthreadsapi::OpenThread( winapi::um::winnt::THREAD_SUSPEND_RESUME, FALSE, tid, ) } { NULL => win_err("OpenThread"), handle => Ok(handle), }?; match unsafe { winapi::um::processthreadsapi::ResumeThread(thread) } { std::u32::MAX => win_err("ResumeThread"), _ => Ok(()), }?; child.wait_with_output().map_err(|e| { crate::Error::IoExplainedError(e, "error waiting for child".into()) })? } #[cfg(unix)] { use std::io::Error; // https://github.com/rust-lang/libc/pull/1919 cfg_if!( if #[cfg( target_os="netbsd")] { let rlimit_as = 10; } else { let rlimit_as = libc::RLIMIT_AS; } ); unsafe { cmd.pre_exec(move || { let lim = libc::rlimit { rlim_cur: ulimit, rlim_max: libc::RLIM_INFINITY, }; match libc::setrlimit(rlimit_as, &lim as *const libc::rlimit) { 0 => Ok(()), _ => Err(Error::last_os_error()), } }); } cmd.output().map_err(|e| { crate::Error::IoExplainedError(e, "error running helper".into()) })? } } None => cmd .output() .map_err(|e| crate::Error::IoExplainedError(e, "error running helper".into()))?, }; assert_eq!(true, output.status.success()); eprintln!("stderr {}", str::from_utf8(&output.stderr).unwrap()); let limit_bytes = output.stdout; let limit: u64 = str::from_utf8(&limit_bytes)? .trim() .parse() .map_err(|e| Error::U64Error(e, str::from_utf8(&limit_bytes).unwrap().into()))?; Ok(limit) } #[cfg(any( windows, target_os = "macos", target_os = "linux", target_os = "freebsd", target_os = "illumos", target_os = "solaris", ))] #[test] fn test_no_ulimit() -> Result<()> { // This test depends on the dev environment being run uncontained. let info = sys_info::mem_info()?; let total_ram = info.total * 1024; let limit = read_test_process(None)?; assert_eq!(total_ram, limit); Ok(()) } #[test] fn test_ulimit() -> Result<()> { // Page size rounding let limit = read_test_process(Some(99_999_744))?; assert_eq!(99_999_744, limit); Ok(()) } }