diff --git a/.github/backup/.travis.yml b/.github/backup/.travis.yml deleted file mode 100644 index e89b1120..00000000 --- a/.github/backup/.travis.yml +++ /dev/null @@ -1,59 +0,0 @@ -language: julia - -os: -- linux -- osx - -julia: -# - 0.7 -- 1.0 -- 1.1 -- 1.2 -- 1.3 -- nightly - -matrix: - allow_failures: - - julia: nightly - - julia: 0.7 - fast_finish: true - -notifications: - email: false - -cache: - timeout: 1000 - directories: - - downloads - -env: - global: - - BINARYBUILDER_DOWNLOADS_CACHE=downloads - - BINARYBUILDER_AUTOMATIC_APPLE=true - -stages: -- name: dylib -- name: test - -jobs: - include: - - stage: dylib - julia: 1.0 - script: - - julia -e 'using Pkg; Pkg.add("BinaryProvider"); Pkg.add("BinaryBuilder");' - - julia deps/build_tarballs.jl - deploy: - provider: releases - api_key: - secure: Bgz6GD7kcWQQRijf/zn8nD8wcyhjrjm9c4YBIDAdxPENiem3UOgmUjQCUieGxHFAjyCqmITyjNv9I4xPtjJqJQG1dpH9tlnzPmFGz2YqdYOyh6c9GbSLuMSy+ypVX88VA9KAahCgtPnF7MT07MX4JfMZo8X9piyRTPEV/0AX8P5EPNvg9PjdRtTk0zowMXlF30TYmsZb6vu+j4Ry9Bmn2oQhzGfqEgzoMI+Zp0w0ySjjKtHwoVerGB4zEAysq+RUcoCb3BxXROyD9mj6hL66KZCjlsTUAZ3paFDVqVTOy+b5Rul/7RM0iUKPpYAv0FDyw1rPhtbQpHFUY1VJmHJRWVCudrywJXiqti6IllTteR6RB1yb3a8KP7pX6cg2/zr96yXKiUtNcV5mzt1Ubaue2aESW1r3JoMmvHj7i9vjvW+IazPkY4Sx3iQ5TmCNMNnXZg1EzFFlEkn3DM206Ao9AVyxbGnjf63zNB5FSRh6MLGP4RKeSGTdYdryTPEt30Jhu9wPIT7d2cC2lIt2fqU8aS8PCL03NYHw6MOITM/xqFYYusC+XYSxt7WvQIYHyvIkNUjA7LxbMEuEy9Nd/HlWWQsxuegYb9jKInWiTfdUIEn5/eG7hvJ5XfpMZlaNZODeId+0MTq1foQTehriXrnkSJrWeRjyOXFAEWGs67EJwAQ= - file_glob: true - skip_cleanup: true - file: products/* - on: - repo: TuringLang/Libtask.jl - tags: true - - stage: test - script: - - if [[ -a .git/shallow ]]; then git fetch --unshallow; fi - - julia -e 'using Pkg; Pkg.build("Libtask"); Pkg.test("Libtask", coverage=true)' - # - julia -e 'using Pkg; cd(Pkg.dir("Libtask")); Pkg.add("Coverage"); using Coverage; Coveralls.submit(process_folder())' diff --git a/.github/backup/appveyor.yml b/.github/backup/appveyor.yml deleted file mode 100644 index 3149dbf0..00000000 --- a/.github/backup/appveyor.yml +++ /dev/null @@ -1,38 +0,0 @@ -environment: - matrix: - - julia_version: 1.0 - - julia_version: 1.1 - - julia_version: 1.2 - - julia_version: nightly - -platform: - - x86 # 32-bit - - x64 # 64-bit - -# # Uncomment the following lines to allow failures on nightly julia -# # (tests will run but not make your overall status red) -matrix: - allow_failures: - - julia_version: nightly - -branches: - only: - - master -# - /release-.*/ - -notifications: - - provider: Email - on_build_success: false - on_build_failure: false - on_build_status_changed: false - -install: - - ps: iex ((new-object net.webclient).DownloadString("https://raw.githubusercontent.com/JuliaCI/Appveyor.jl/version-1/bin/install.ps1")) - -build_script: - - echo "%JL_BUILD_SCRIPT%" - - C:\julia\bin\julia -e "%JL_BUILD_SCRIPT%" - -test_script: - - echo "%JL_TEST_SCRIPT%" - - C:\julia\bin\julia -e "%JL_TEST_SCRIPT%" diff --git a/.github/workflows/BuildDylib.yaml b/.github/workflows/BuildDylib.yaml index 746f917f..4427a47a 100644 --- a/.github/workflows/BuildDylib.yaml +++ b/.github/workflows/BuildDylib.yaml @@ -2,14 +2,11 @@ name: Build Dylib on: push: - branches: - - master - # tags: '*' - release: - types: - - created - pull_request: - types: [opened, synchronize, reopened] + paths: + - 'deps/Makefile' + - 'deps/task.c' + - 'deps/build_tarballs.jl' + - 'deps/build_dylib.sh' jobs: build: @@ -25,10 +22,6 @@ jobs: uses: julia-actions/setup-julia@latest with: version: ${{ matrix.julia-version }} - - name: Tag commit - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: deps/gh-auto-tag - name: Install dependencies run: julia -e 'using Pkg; Pkg.add("BinaryProvider"); Pkg.add("BinaryBuilder");' - name: Build @@ -36,7 +29,3 @@ jobs: BINARYBUILDER_DOWNLOADS_CACHE: downloads BINARYBUILDER_AUTOMATIC_APPLE: true run: julia deps/build_tarballs.jl - - name: Upload to release - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: deps/gh-update-to-release diff --git a/deps/build.jl b/deps/build.jl index bdf9eb52..2c072b31 100644 --- a/deps/build.jl +++ b/deps/build.jl @@ -1,65 +1,58 @@ -function find_prev_tag(tag) - project_root = (@__DIR__) |> dirname |> abspath - run(`git -C $project_root fetch --tags`) - tags = readlines(`git -C $project_root tag`) - sort!(tags) - idx = indexin([tag], tags)[1] - if idx == nothing return "NO-PREV-TAG" end - return get(tags, idx - 1, "NO-PREV-TAG") -end +### +### This file is generated by running +### ` julia generate_buildjl.jl L/Libtask/build_tarballs.jl` +### in the Yggdrasil root directory, with 2 updates: +### 1. add prefix tp products, see https://github.com/JuliaPackaging/Yggdrasil#binaryproviderjl, +### 2. products filter +### + +using BinaryProvider # requires BinaryProvider 0.3.0 or later + +# Parse some basic command-line arguments +const verbose = "--verbose" in ARGS +const prefix = Prefix(get([a for a in ARGS if a != "--verbose"], 1, joinpath(@__DIR__, "usr"))) +products = [ + LibraryProduct(prefix, ["libtask_v1_0"], :libtask_v1_0), + LibraryProduct(prefix, ["libtask_v1_1"], :libtask_v1_1), + LibraryProduct(prefix, ["libtask_v1_2"], :libtask_v1_2), + LibraryProduct(prefix, ["libtask_v1_3"], :libtask_v1_3), +] -# modify build-tmp.jl to only check correct version libs -function install_products_filter(build_file) - prod_filter = raw"""products_tmp = filter(products) do prod +products_tmp = filter(products) do prod endswith(prod.libnames[1], "$(VERSION.major)_$(VERSION.minor)") end length(products_tmp) == 0 && (products_tmp = [products[end]]) products = products_tmp -""" - lines = open(build_file) do io - read(io, String) |> x -> split(x, "\n") - end - prod_in, prod_out, filter_written = false, false, false - open(build_file, "w") do io - for line in lines - if occursin("products = [", line) - prod_in = true - end - if prod_in && line == "]" - prod_out = true - end - write(io, line * "\n") - if prod_out && !filter_written - write(io, prod_filter * "\n") - filter_written = true - end - end - end -end -function include_build_script(version_str, try_prev=false) - build_script_url = "https://github.com/TuringLang/Libtask.jl/releases/download/v$(version_str)/build_LibtaskDylib.v$(version_str).jl" - build_script = joinpath(@__DIR__, "tmp-build.jl") - build_script = try download(build_script_url, build_script) catch end - if build_script == nothing && try_prev # no such file - version_str = find_prev_tag("v$version_str") |> strip |> (x) -> lstrip(x, ['v']) - return include_build_script(version_str, false) - end - install_products_filter(build_script) - include(build_script) +# Download binaries from hosted location +bin_prefix = "https://github.com/JuliaBinaryWrappers/Libtask_jll.jl/releases/download/Libtask-v0.3.0+0" + +# Listing of files generated by BinaryBuilder: +download_info = Dict( + Linux(:aarch64, libc=:glibc) => ("$bin_prefix/Libtask.v0.3.0.aarch64-linux-gnu.tar.gz", "e541c0df11d48b45e9334018c014ae0d012b75f92ffbc49fc4ab6eed35593731"), + Linux(:i686, libc=:glibc) => ("$bin_prefix/Libtask.v0.3.0.i686-linux-gnu.tar.gz", "7f68bd21609adf35878f9b16f56151ab5f6f609999a40291ed270c1a4d0331a0"), + Windows(:i686) => ("$bin_prefix/Libtask.v0.3.0.i686-w64-mingw32.tar.gz", "62950b53a892fb8c699ddbb4ccc9f19b12681f64fbf85a546345d5b0f23dc8d7"), + MacOS(:x86_64) => ("$bin_prefix/Libtask.v0.3.0.x86_64-apple-darwin14.tar.gz", "fff6523dde93e6dc12b96a8bf1e3c35a78d8dba7cdc95cd0e5dd13225d1972df"), + Linux(:x86_64, libc=:glibc) => ("$bin_prefix/Libtask.v0.3.0.x86_64-linux-gnu.tar.gz", "be4c590e8f13df31855be20f31c1c4ce98f499fc5173cd35c8e8b72b79e0dc5a"), + Windows(:x86_64) => ("$bin_prefix/Libtask.v0.3.0.x86_64-w64-mingw32.tar.gz", "267473eb211e5060b98cede7f30336d2a7453542617521f27941d353dcfe42e8"), +) + +# Install unsatisfied or updated dependencies: +unsatisfied = any(!satisfied(p; verbose=verbose) for p in products) +dl_info = choose_download(download_info, platform_key_abi()) +if dl_info === nothing && unsatisfied + # If we don't have a compatible .tar.gz to download, complain. + # Alternatively, you could attempt to install from a separate provider, + # build from source or something even more ambitious here. + error("Your platform (\"$(Sys.MACHINE)\", parsed as \"$(triplet(platform_key_abi()))\") is not supported by this package!") end -function get_version_str() - path = joinpath(@__DIR__, "../Project.toml") - version_reg = r"version\s*=\s*\"(.*)\"" - open(path) do file - lines = readlines(file) - for line in lines - m = match(version_reg, line) - if isa(m, RegexMatch) return m.captures[1] end - end - end +# If we have a download, and we are unsatisfied (or the version we're +# trying to install is not itself installed) then load it up! +if unsatisfied || !isinstalled(dl_info...; prefix=prefix) + # Download and install binaries + install(dl_info...; prefix=prefix, force=true, verbose=verbose) end -version_str = get_version_str() |> strip |> (x) -> lstrip(x, ['v']) -include_build_script(version_str, true) +# Write out a deps.jl file that will contain mappings for our products +write_deps_file(joinpath(@__DIR__, "deps.jl"), products, verbose=verbose) diff --git a/deps/gh-auto-tag b/deps/gh-auto-tag deleted file mode 100755 index b98a38d1..00000000 --- a/deps/gh-auto-tag +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash - -git fetch --tags - -TAGS=($(git tag)) -CTAG=$(perl -ne 'print "v$1" if m#version\s*=\s*"(.*)"#' Project.toml) -COMMIT=$(git rev-parse HEAD) - -if [[ ! " ${TAGS[@]} " =~ " ${CTAG} " ]]; then - GIT_REFS_URL=$(jq .repository.git_refs_url $GITHUB_EVENT_PATH | tr -d '"' | sed 's/{\/sha}//g') - - curl -s -X POST $GIT_REFS_URL \ - -H "Authorization: token ${GITHUB_TOKEN}" \ - -d @- << EOF -{ - "ref": "refs/tags/$CTAG", - "sha": "$COMMIT" -} -EOF - -fi diff --git a/deps/gh-update-to-release b/deps/gh-update-to-release deleted file mode 100755 index 3553e16c..00000000 --- a/deps/gh-update-to-release +++ /dev/null @@ -1,49 +0,0 @@ -#!/bin/bash -# -*- mode: sh -*- - -# orginal code copied from: -# https://github.com/JasonEtco/upload-to-release/blob/master/upload-to-release - -set -e -set -o pipefail - -# Ensure that the GITHUB_TOKEN secret is included -if [[ -z "$GITHUB_TOKEN" ]]; then - echo "Set the GITHUB_TOKEN env variable." - exit 1 -fi - -# Only upload to non-draft releases -IS_DRAFT=$(jq --raw-output '.release.draft' $GITHUB_EVENT_PATH) -if [ "$IS_DRAFT" = true ]; then - echo "This is a draft, so nothing to do!" - exit 0 -fi - -# Build the Upload URL from the various pieces -RELEASE_ID=$(jq --raw-output '.release.id' $GITHUB_EVENT_PATH) -if [[ -z "${RELEASE_ID}" || "${RELEASE_ID}" = null ]]; then - echo "There was no release ID in the GitHub event. Are you using the release event type?" - exit 0 -fi - -for FILE in $(ls products); do - # Prepare the headers - AUTH_HEADER="Authorization: token ${GITHUB_TOKEN}" - CONTENT_TYPE_HEADER="Content-Type: application/gzip" - CONTENT_LENGTH_HEADER="Content-Length: $(stat -c%s "products/${FILE}")" - - UPLOAD_URL="https://uploads.github.com/repos/${GITHUB_REPOSITORY}/releases/${RELEASE_ID}/assets?name=${FILE}" - echo "$UPLOAD_URL" - - # Upload the file - curl \ - -f \ - -sSL \ - -XPOST \ - -H "${AUTH_HEADER}" \ - -H "${CONTENT_LENGTH_HEADER}" \ - -H "${CONTENT_TYPE_HEADER}" \ - --upload-file "products/${FILE}" \ - "${UPLOAD_URL}" -done diff --git a/src/Libtask.jl b/src/Libtask.jl index 644254ea..83c46927 100644 --- a/src/Libtask.jl +++ b/src/Libtask.jl @@ -3,12 +3,25 @@ module Libtask export CTask, consume, produce, TArray, get, tzeros, tfill, TRef # Try to load the binary dependency -if isfile(joinpath(@__DIR__, ".." , "deps", "deps.jl")) - include("../deps/deps.jl") - check_deps() -else +const depsjl_path = joinpath(@__DIR__, "..", "deps", "deps.jl") +if !isfile(depsjl_path) error("Libtask is not properly installed. Please run `import Pkg; Pkg.build(\"Libtask\")`") end +include(depsjl_path) + +function __init__() + check_deps() +end + +@static if VERSION < v"1.0.9999" # (-, v1.1) + const libtask = libtask_v1_0 +elseif VERSION < v"1.1.9999" # [v1.1, v1.2) + const libtask = libtask_v1_1 +elseif VERSION < v"1.2.9999" # [v1.2, v1.3) + const libtask = libtask_v1_2 +else # [v1.3, +) + const libtask = libtask_v1_3 +end include("taskcopy.jl") include("tarray.jl") diff --git a/src/taskcopy.jl b/src/taskcopy.jl index 640a0b2c..dd94daca 100644 --- a/src/taskcopy.jl +++ b/src/taskcopy.jl @@ -1,15 +1,5 @@ # Utility function for self-copying mechanism -@static if VERSION < v"1.0.9999" # (-, v1.1) - const libtask = libtask_v1_0 -elseif VERSION < v"1.1.9999" # [v1.1, v1.2) - const libtask = libtask_v1_1 -elseif VERSION < v"1.2.9999" # [v1.2, v1.3) - const libtask = libtask_v1_2 -else # [v1.3, +) - const libtask = libtask_v1_3 -end - n_copies() = n_copies(current_task()) n_copies(t::Task) = begin isa(t.storage, Nothing) && (t.storage = IdDict())