Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for exec_async #185

Merged
merged 3 commits into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
570 changes: 570 additions & 0 deletions .ci/Manifest.toml

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions .ci/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[deps]
BinaryBuilder = "12aac903-9f7c-5d81-afc2-d9565ea332ae"
BinaryBuilderBase = "7f725544-6523-48cd-82d1-3fa08ff4056e"
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
Downloads = "f43a241f-c20a-4ad4-852c-f6b1247861c6"
LocalRegistry = "89398ba2-070a-4b16-a995-9893c55d93cf"
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
Registrator = "4418983a-e44d-11e8-3aec-9789530b3b3e"
RegistryTools = "d1eb7eb1-105f-429d-abf5-b0f65cb9e2c4"
TOML = "fa267f1f-6049-4f14-aa54-33bafae1ed76"
squashfs_tools_jll = "eed32e3e-a7c5-5bf9-9121-5cf3ab653887"

[compat]
RegistryTools = "1.3.4"
97 changes: 97 additions & 0 deletions .ci/build_tarballs.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
# Adapted from the Yggdrasil build script
# Note that this script can accept some limited command-line arguments, run
# `julia build_tarballs.jl --help` to see a usage message.
using BinaryBuilder, Pkg, TOML
import LibGit2

# See https://github.com/JuliaLang/Pkg.jl/issues/2942
# Once this Pkg issue is resolved, this must be removed
uuid = Base.UUID("a83860b7-747b-57cf-bf1f-3e79990d037f")
delete!(Pkg.Types.get_last_stdlibs(v"1.6.3"), uuid)

function getversion(cmakefile)
a = b = c = 0
for l in readlines(cmakefile)
if startswith(l, "set(JlQML_VERSION")
a, b, c = parse.(Int, split(replace(split(l)[end], ")" => ""),'.'))
end
end
return VersionNumber(a, b, c)
end

name = "jlqml"

LibGit2.clone("https://github.com/JuliaGraphics/jlqml.git", name)

version = getversion(joinpath(name, "CMakeLists.txt"))

julia_versions = [v"1.6.3", v"1.9", v"1.11"]

# Collection of sources required to complete build
sources = [
DirectorySource(name; target = name)
]

# Bash recipe for building across all platforms
script = raw"""
# Override compiler ID to silence the horrible "No features found" cmake error
if [[ $target == *"apple-darwin"* ]]; then
macos_extra_flags="-DCMAKE_CXX_COMPILER_ID=AppleClang -DCMAKE_CXX_COMPILER_VERSION=10.0.0 -DCMAKE_CXX_STANDARD_COMPUTED_DEFAULT=11"
fi

mkdir build
cd build
cmake \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_FIND_ROOT_PATH=${prefix} \
-DCMAKE_INSTALL_PREFIX=$prefix \
-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TARGET_TOOLCHAIN} \
-DJulia_PREFIX=${prefix} \
$macos_extra_flags \
../jlqml/
VERBOSE=ON cmake --build . --config Release --target install -- -j${nproc}
install_license $WORKSPACE/srcdir/jlqml*/LICENSE.md
"""

# These are the platforms we will build for by default, unless further
# platforms are passed in on the command line

function libjulia_platforms(julia_version)
platforms = supported_platforms(; experimental = julia_version ≥ v"1.7")

filter!(p -> libc(p) != "musl" && arch(p) != "i686" && !contains(arch(p), "arm") && arch(p) != "aarch64" && arch(p) != "powerpc64le" && !Sys.isfreebsd(p), platforms)

for p in platforms
p["julia_version"] = string(julia_version)
end

platforms = expand_cxxstring_abis(platforms)

filter!(p -> cxxstring_abi(p) != "cxx03", platforms)

return platforms
end

platforms = vcat(libjulia_platforms.(julia_versions)...)

# The products that we will ensure are always built
products = [
LibraryProduct("libjlqml", :libjlqml),
]

# Dependencies that must be installed before this package can be built
dependencies = [
Dependency("libcxxwrap_julia_jll"),
Dependency("Qt6Declarative_jll"; compat="~6.5.2"),
HostBuildDependency("Qt6Declarative_jll"),
Dependency("Qt6Svg_jll"; compat="~6.5.2"),
BuildDependency("Libglvnd_jll"),
BuildDependency("libjulia_jll"),
]

deployingargs = deepcopy(ARGS)
push!(deployingargs, "--deploy=local")

# Build the tarballs, and possibly a `build.jl` as well.
build_tarballs(deployingargs, name, version, sources, script, platforms, products, dependencies;
preferred_gcc_version = v"10", julia_compat = "1.6")
24 changes: 24 additions & 0 deletions .ci/override-jll.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using Tar, jlqml_jll, CodecZlib

tarball = "undefined"

julia_version = "julia_version+$(Int(VERSION.major)).$(Int(VERSION.minor))"

for fname in readdir()
if !startswith(fname, "jlqml.")
continue
end
if occursin(julia_version,fname) && (
(Sys.islinux() && occursin("linux", fname)) ||
(Sys.isapple() && occursin("apple", fname)) ||
(Sys.iswindows() && occursin("mingw32", fname)))
global tarball = fname
end
end

mv(jlqml_jll.artifact_dir, jlqml_jll.artifact_dir*"_")
mkdir(jlqml_jll.artifact_dir)

open(GzipDecompressorStream, tarball) do io
Tar.extract(io, jlqml_jll.artifact_dir)
end
60 changes: 46 additions & 14 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,39 @@
name: test
on:
- push
- pull_request

defaults:
run:
shell: bash

jobs:
buildjll:
name: Build JLL
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: julia-actions/setup-julia@latest
with:
version: '1.8'
arch: x64
- uses: julia-actions/cache@v1
- name: Build JLLs
env:
BINARYBUILDER_RUNNER: privileged
BINARYBUILDER_USE_SQUASHFS: true
BINARYBUILDER_AUTOMATIC_APPLE: true
run: |
cd .ci
julia --project -e "using Pkg; Pkg.instantiate()"
julia --project build_tarballs.jl --verbose
- name: Upload JLL artifact
uses: actions/upload-artifact@v3
with:
name: jlqml-binaries
path: .ci/products
test:
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }}
needs: buildjll
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
Expand Down Expand Up @@ -39,29 +63,37 @@ jobs:
"C:\Program Files\7-Zip\7z.exe" x mesa.7z
mklink opengl32.dll "x64\opengl32.dll"
mklink libglapi.dll "x64\libglapi.dll"
- name: Cache artifacts
uses: actions/cache@v1
env:
cache-name: cache-artifacts
with:
path: ~/.julia/artifacts
key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }}
restore-keys: |
${{ runner.os }}-test-${{ env.cache-name }}-
${{ runner.os }}-test-
${{ runner.os }}-
- uses: julia-actions/cache@v1
- uses: julia-actions/julia-buildpkg@v1
- name: Download built jlqml artifact
uses: actions/download-artifact@v3
with:
name: jlqml-binaries
- name: Dev jlqml_jll
run: |
julia --project -e "using Pkg; Pkg.develop(\"jlqml_jll\"); import jlqml_jll; jlqml_jll.dev_jll(); Pkg.add(\"CodecZlib\")"
julia --project .ci/override-jll.jl
- name: install-xfvb
if: runner.os == 'Linux'
run: sudo apt-get install xvfb libxkbcommon-x11-0
run: sudo apt-get install xvfb libxkbcommon-x11-0 libgl1-mesa-dri
- name: test-linux
if: runner.os == 'Linux' && matrix.version != '1.6'
if: runner.os == 'Linux'
run: xvfb-run --auto-servernum julia --color=yes --check-bounds=yes --project -e 'using Pkg; Pkg.test(coverage=true)'
env:
XDG_RUNTIME_DIR: /tmp/runtime-runner
- name: test-win-mac
if: runner.os != 'Linux'
uses: julia-actions/julia-runtest@v1
- name: examples-linux
if: runner.os == 'Linux'
run: xvfb-run --auto-servernum julia --project test/runexamples.jl
env:
XDG_RUNTIME_DIR: /tmp/runtime-runner
continue-on-error: true
- name: examples-win-mac
if: runner.os != 'Linux'
run: julia --project test/runexamples.jl
continue-on-error: true
- uses: julia-actions/julia-processcoverage@v1
env:
DISABLE_AMEND_COVERAGE_FROM_SRC: yes
Expand Down
31 changes: 19 additions & 12 deletions src/QML.jl
Original file line number Diff line number Diff line change
Expand Up @@ -363,13 +363,19 @@

@cxxdereference value(::Type{JuliaPropertyMap}, qvar::QVariant) = getpropertymap(qvar)

const _queued_properties = []

# Functor to update a QML property when an Observable is changed in Julia
struct QmlPropertyUpdater
propertymap::QQmlPropertyMap
key::String
active::Bool
end
function (updater::QmlPropertyUpdater)(x)
if Base.current_task() != Base.roottask
push!(_queued_properties, (updater, x))
return

Check warning on line 377 in src/QML.jl

View check run for this annotation

Codecov / codecov/patch

src/QML.jl#L376-L377

Added lines #L376 - L377 were not covered by tests
end
updater.propertymap[updater.key] = x
end

Expand Down Expand Up @@ -594,19 +600,20 @@

global _async_timer

# Stop the async loop (called on quit from C++)
function _stoptimer()
if !isdefined(QML, :_async_timer)
return
end
global _async_timer
if isopen(_async_timer)
close(_async_timer)
end
end

function exec_async()
global _async_timer = Timer((t) -> process_events(), 0.015; interval=0.015)
newrepl = @async Base.run_main_repl(true,true,true,true,true)
while !istaskdone(newrepl)
for (updater, x) in _queued_properties
updater.propertymap[updater.key] = x
end
empty!(_queued_properties)
process_events()
sleep(0.015)
end
QML.quit(QML.get_qmlengine())
QML.quit()
QML.cleanup()
QML.process_events()
return
end

Expand Down
38 changes: 38 additions & 0 deletions test/runexamples.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import QML
import LibGit2

withenv("JULIA_LOAD_PATH" => nothing, "JULIA_GR_PROVIDER" => "BinaryBuilder") do
mktempdir() do tmpd
cd(tmpd) do
examplesdir = mkdir("QmlJuliaExamples")
LibGit2.clone("https://github.com/barche/QmlJuliaExamples.git", examplesdir)
cd(examplesdir) do
for d in ["basic", "images", "opengl", "plots"]
cd(d) do
allowmakie = true
if get(ENV, "CI", "false") == "true" && (Sys.isapple() || Sys.iswindows())
allowmakie = false
filtered = filter(l -> !contains(l, "Makie"), collect(eachline("Project.toml")))
open("Project.toml", "w") do output
for l in filtered
println(output, l)
end
end
end

qmlpath = replace(dirname(dirname(pathof(QML))), "\\" => "/")
cxxpath = replace(dirname(dirname(pathof(QML.CxxWrap))), "\\" => "/")
updatecommand = """
using Pkg
Pkg.develop([PackageSpec(path="$qmlpath"), PackageSpec(path="$cxxpath")])
Pkg.precompile()
"""
run(`$(Base.julia_cmd()) --project -e "$updatecommand"`)
QML.runexamples(allowmakie)
end
end
end
end
println(pwd())
end
end
38 changes: 0 additions & 38 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,41 +18,3 @@ testfiles = filter(fname -> fname ∉ excluded, readdir(@__DIR__))
end

doctest(QML)

import LibGit2

withenv("JULIA_LOAD_PATH" => nothing, "JULIA_GR_PROVIDER" => "BinaryBuilder") do
mktempdir() do tmpd
cd(tmpd) do
examplesdir = mkdir("QmlJuliaExamples")
LibGit2.clone("https://github.com/barche/QmlJuliaExamples.git", examplesdir)
cd(examplesdir) do
for d in ["basic", "images", "opengl", "plots"]
cd(d) do
allowmakie = true
if get(ENV, "CI", "false") == "true" && (Sys.isapple() || Sys.iswindows())
allowmakie = false
filtered = filter(l -> !contains(l, "Makie"), collect(eachline("Project.toml")))
open("Project.toml", "w") do output
for l in filtered
println(output, l)
end
end
end

qmlpath = replace(dirname(dirname(pathof(QML))), "\\" => "/")
cxxpath = replace(dirname(dirname(pathof(QML.CxxWrap))), "\\" => "/")
updatecommand = """
using Pkg
Pkg.develop([PackageSpec(path="$qmlpath"), PackageSpec(path="$cxxpath")])
Pkg.precompile()
"""
run(`$(Base.julia_cmd()) --project -e "$updatecommand"`)
QML.runexamples(allowmakie)
end
end
end
end
println(pwd())
end
end
Loading