diff --git a/A/AcousticsToolbox/build_tarballs.jl b/A/AcousticsToolbox/build_tarballs.jl index b938df59900..4584ff9f969 100644 --- a/A/AcousticsToolbox/build_tarballs.jl +++ b/A/AcousticsToolbox/build_tarballs.jl @@ -3,16 +3,17 @@ using BinaryBuilder, Pkg name = "AcousticsToolbox" -version = v"2020.11.4" +version_string = "2022_4_20" +version = VersionNumber(replace(version_string, "_" => ".")) # Collection of sources required to complete build sources = [ - ArchiveSource("http://oalib.hlsresearch.com/AcousticsToolbox/at_2020_11_4.zip", "6f9fe5d3d7fd99fc34fb2a2c3308f2e660a1cc0ea93f0651111af698acf442f0") + ArchiveSource("http://oalib.hlsresearch.com/AcousticsToolbox/at_$(version_string).zip", "ff3494c8a0c696dca17ddacb9a2a412eaf664c3204f4a424afe77e66edefc950") ] # Bash recipe for building across all platforms script = raw""" -cd $WORKSPACE/srcdir/at_* +cd $WORKSPACE/srcdir/at rm -rf ../__MACOSX perl -p -i -e 's/\-march=native//; s/\-ffast\-math//; s/\-mtune=native//;' Makefile find . -name *.exe -exec rm {} \; diff --git a/A/autoconf/build_tarballs.jl b/A/autoconf/build_tarballs.jl new file mode 100644 index 00000000000..f36cde80cfb --- /dev/null +++ b/A/autoconf/build_tarballs.jl @@ -0,0 +1,27 @@ +using BinaryBuilder + +name = "autoconf" +version = v"2.71" + +# Collection of sources required to complete build +sources = [ + ArchiveSource("https://ftp.gnu.org/gnu/autoconf/autoconf-$(version.major).$(version.minor).tar.xz", + "f14c83cfebcc9427f2c3cea7258bd90df972d92eb26752da4ddad81c87a0faa4") +] + +# Bash recipe for building across all platforms +script = raw""" +cd $WORKSPACE/srcdir/autoconf*/ +./configure --prefix=${prefix} --build=${MACHTYPE} --host=${target} PERL="/usr/bin/env perl" +make -j${nproc} +make install +""" + +platforms = [AnyPlatform()] +products = [ + FileProduct("bin/autoconf", :autoconf), +] + +dependencies = Dependency[ +] +build_tarballs(ARGS, name, version, sources, script, platforms, products, dependencies; julia_compat="1.6") diff --git a/A/automake/build_tarballs.jl b/A/automake/build_tarballs.jl new file mode 100644 index 00000000000..7f0cca80de8 --- /dev/null +++ b/A/automake/build_tarballs.jl @@ -0,0 +1,28 @@ +using BinaryBuilder + +name = "automake" +version = v"1.16.5" + +# Collection of sources required to complete build +sources = [ + ArchiveSource("https://ftp.gnu.org/gnu/automake/automake-$(version).tar.xz", + "f01d58cd6d9d77fbdca9eb4bbd5ead1988228fdb73d6f7a201f5f8d6b118b469") +] + +# Bash recipe for building across all platforms +script = raw""" +cd $WORKSPACE/srcdir/automake*/ +./configure --prefix=${prefix} --build=${MACHTYPE} --host=${target} PERL="/usr/bin/env perl" +make -j${nproc} +make install +""" + +platforms = [AnyPlatform()] +products = [ + FileProduct("bin/aclocal", :aclocal), +] + +dependencies = [ + Dependency("autoconf_jll"), +] +build_tarballs(ARGS, name, version, sources, script, platforms, products, dependencies; julia_compat="1.6") diff --git a/B/Bison/build_tarballs.jl b/B/Bison/build_tarballs.jl index 8758d274ef7..d2d7d5f23f0 100644 --- a/B/Bison/build_tarballs.jl +++ b/B/Bison/build_tarballs.jl @@ -13,7 +13,7 @@ sources = [ # Bash recipe for building across all platforms script = raw""" cd $WORKSPACE/srcdir/bison-* -./configure --prefix=${prefix} --build=${MACHTYPE} --host=${target} +./configure --prefix=${prefix} --build=${MACHTYPE} --host=${target} --enable-relocatable make -j${nproc} make install """ diff --git a/C/CUTENSOR/build_tarballs.jl b/C/CUTENSOR/build_tarballs.jl index 5548c858172..afa0c4987c0 100644 --- a/C/CUTENSOR/build_tarballs.jl +++ b/C/CUTENSOR/build_tarballs.jl @@ -56,3 +56,5 @@ for build in builds skip_audit=true, dont_dlopen=true) end end + +# bump diff --git a/E/Enzyme/build_tarballs.jl b/E/Enzyme/build_tarballs.jl index c8c3ccde5eb..7688e22898f 100644 --- a/E/Enzyme/build_tarballs.jl +++ b/E/Enzyme/build_tarballs.jl @@ -8,14 +8,14 @@ include(joinpath(YGGDRASIL_DIR, "platforms", "llvm.jl")) name = "Enzyme" repo = "https://github.com/EnzymeAD/Enzyme.git" -auto_version = "refs/tags/v0.0.52" +auto_version = "refs/tags/v0.0.53" version = VersionNumber(split(auto_version, "/")[end]) llvm_versions = [v"11.0.1", v"12.0.1", v"13.0.1", v"14.0.2", v"15.0.7"] # Collection of sources required to build attr sources = [ - GitSource(repo, "ae0eb382878a556abd6af2749644631c6cd48370"), + GitSource(repo, "1b0f69089fd5c81365f731a140c26767b9546f0d"), ArchiveSource("https://github.com/phracker/MacOSX-SDKs/releases/download/10.15/MacOSX10.14.sdk.tar.xz", "0f03869f72df8705b832910517b47dd5b79eb4e160512602f593ed243b28715f"), ] diff --git a/F/FireFly/build_tarballs.jl b/F/FireFly/build_tarballs.jl new file mode 100644 index 00000000000..e0c380fa38a --- /dev/null +++ b/F/FireFly/build_tarballs.jl @@ -0,0 +1,79 @@ +# 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 +using Base.BinaryPlatforms +const YGGDRASIL_DIR = (dirname∘dirname∘dirname)(@__FILE__) +(include∘joinpath)(YGGDRASIL_DIR, "platforms", "mpi.jl") + +name = "FireFly" +version = v"2.0.3" + +# Collection of sources required to complete build +sources = [ + GitSource("https://gitlab.com/firefly-library/firefly.git", "f0b0b316790fbe23b88dd7b759220944bc77302d") +] + +# Bash recipe for building across all platforms +script = raw""" +mkdir $WORKSPACE/srcdir/FireFly-build +cd ${WORKSPACE}/srcdir/firefly +sed -i "s/TARGETS FireFly_static FireFly_shared/TARGETS FireFly_shared/g" CMakeLists.txt +cd $WORKSPACE/srcdir/FireFly-build + +cmake -DWITH_FLINT=true \ + -DWITH_JEMALLOC=true \ + -DWITH_MPI=true \ + -DCMAKE_INSTALL_PREFIX=$prefix \ + -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TARGET_TOOLCHAIN} \ + -DCMAKE_BUILD_TYPE=Release \ + ${EXTRA_CMAKE_FLAGS} \ + ${WORKSPACE}/srcdir/firefly + +cmake --build . -j${nproc} -t install + +install_license ${WORKSPACE}/srcdir/firefly/LICENSE +""" + +augment_platform_block = """ + using Base.BinaryPlatforms + $(MPI.augment) + augment_platform!(platform::Platform) = augment_mpi!(platform) +""" + +# These are the platforms we will build for by default, unless further +# platforms are passed in on the command line +platforms = supported_platforms(; exclude=Sys.iswindows) +filter!(p -> nbits(p) ≠ 32, platforms) +platforms = expand_cxxstring_abis(platforms) +platforms, platform_dependencies = MPI.augment_platforms(platforms) + +# Avoid platforms where the MPI implementation isn't supported +# OpenMPI +platforms = filter(p -> !(p["mpi"] == "openmpi" && arch(p) == "armv6l" && libc(p) == "glibc"), platforms) +# MPItrampoline +platforms = filter(p -> !(p["mpi"] == "mpitrampoline" && libc(p) == "musl"), platforms) +platforms = filter(p -> !(p["mpi"] == "mpitrampoline" && Sys.isfreebsd(p)), platforms) + +# The products that we will ensure are always built +products = [ + LibraryProduct("libfirefly", :libfirefly) +] + +# Dependencies that must be installed before this package can be built +dependencies = [ + Dependency(PackageSpec(name="CompilerSupportLibraries_jll", uuid="e66e0078-7015-5450-92f7-15fbd957f2ae")) # ensure that the correct version of libatomic @ x86_64-linux-gnu-cxx11-mpi+openmpi + Dependency(PackageSpec(name="FLINT_jll", uuid="e134572f-a0d5-539d-bddf-3cad8db41a82")) + Dependency(PackageSpec(name="GMP_jll", uuid="781609d7-10c4-51f6-84f2-b8444358ff6d"); compat="6.2.0") + Dependency(PackageSpec(name="Zlib_jll", uuid="83775a58-1f1d-513f-b197-d71354ab007a")) + Dependency(PackageSpec(name="jemalloc_jll", uuid="454a8cc1-5e0e-5123-92d5-09b094f0e876")) +] +append!(dependencies, platform_dependencies) + +# Build the tarballs, and possibly a `build.jl` as well. +build_tarballs(ARGS, name, version, sources, script, platforms, products, dependencies; + augment_platform_block, + julia_compat="1.6", + # preferred_gcc_version = v"5.2.0" # for std=c++14 + # preferred_gcc_version = v"6.1.0" # for making the target example + preferred_gcc_version = v"7.1.0" # for avoiding unexpected segmentation fault on x86_64-linux-gnu-cxx11 @ Buildkite.com +) diff --git a/F/file/build_tarballs.jl b/F/file/build_tarballs.jl new file mode 100644 index 00000000000..512fcab72c6 --- /dev/null +++ b/F/file/build_tarballs.jl @@ -0,0 +1,41 @@ +using BinaryBuilder + +name = "file" + +# NOTE: the cross-compilation story of `file` is kind of broken +# and requires a two-step build; we dodge this by providing `file` +# in the rootfs right now, but this locks us to exactly this version. +version = v"5.41" + +# Collection of sources required to complete build +sources = [ + GitSource("https://github.com/file/file.git", + "504206e53a89fd6eed71aeaf878aa3512418eab1") +] + +# Bash recipe for building across all platforms +script = raw""" +cd $WORKSPACE/srcdir/file/ + +autoreconf -i -f +./configure --prefix=${prefix} --host=${target} +make -j${nproc} +make install + +install_license COPYING +""" + +# Disable windows for now, as that requires `libgnurx`. +platforms = filter(!Sys.iswindows, supported_platforms()) +# Disable i686-linux-musl because we end up in dynamic linker hell +platforms = filter(p -> !(libc(p) == "musl" && arch(p) == "i686"), platforms) + +products = [ + ExecutableProduct("file", :file) +] +dependencies = [ + Dependency("Bzip2_jll"), + Dependency("XZ_jll"), + Dependency("Zlib_jll"), +] +build_tarballs(ARGS, name, version, sources, script, platforms, products, dependencies; julia_compat="1.6") diff --git a/G/GMT/build_tarballs.jl b/G/GMT/build_tarballs.jl index fa96dd86cb9..6b60afe8af1 100644 --- a/G/GMT/build_tarballs.jl +++ b/G/GMT/build_tarballs.jl @@ -10,7 +10,7 @@ DCW_VERSION="2.1.1" # Collection of sources required to complete build sources = [ GitSource("https://github.com/GenericMappingTools/gmt", - "02d24df3402a20e23100920ede49285a9594e2a7"), + "02adf702a73d5e2ce0772fc6be69a934ff5b4719"), ArchiveSource("https://github.com/GenericMappingTools/gshhg-gmt/releases/download/$GSHHG_VERSION/gshhg-gmt-$GSHHG_VERSION.tar.gz", "9bb1a956fca0718c083bef842e625797535a00ce81f175df08b042c2a92cfe7f"), @@ -70,7 +70,7 @@ products = [ # Dependencies that must be installed before this package can be built dependencies = [ - Dependency(PackageSpec(name="LibCURL_jll", uuid="deac9b47-8bc7-5906-a0fe-35ac56dc84c0"); compat="7.73.0") + Dependency(PackageSpec(name="LibCURL_jll", uuid="deac9b47-8bc7-5906-a0fe-35ac56dc84c0"); compat="7.73.0, 8.0.1") Dependency("NetCDF_jll", compat="400.902.5") Dependency("PROJ_jll", compat="900.100.0") Dependency(PackageSpec(name="GDAL_jll", uuid="a7073274-a066-55f0-b90d-d619367d196c"); compat="301.600.200") diff --git a/G/gawk/build_tarballs.jl b/G/gawk/build_tarballs.jl new file mode 100644 index 00000000000..a6f4e0440fd --- /dev/null +++ b/G/gawk/build_tarballs.jl @@ -0,0 +1,34 @@ +using BinaryBuilder + +name = "gawk" +version = v"5.2.1" + +# Collection of sources required to complete build +sources = [ + ArchiveSource("https://ftp.gnu.org/gnu/gawk/gawk-$(version).tar.xz", + "673553b91f9e18cc5792ed51075df8d510c9040f550a6f74e09c9add243a7e4f") +] + +# Bash recipe for building across all platforms +script = raw""" +cd $WORKSPACE/srcdir/gawk*/ + +CONFIGURE_ARGS=() +if [[ ${target} == aarch64-apple-darwin* ]]; then + # See https://git.savannah.gnu.org/cgit/gawk.git/tree/README_d/README.macosx?h=gawk-5.2.1#n1 + CONFIGURE_ARGS+=( --disable-pma ) +fi + +./configure --prefix=${prefix} --host=${target} ${CONFIGURE_ARGS[@]} +make -j${nproc} +make install +install_license COPYING +""" + +# Windows currently fails due to a problem with mingw headers (langinfo.h) not being found +platforms = filter(!Sys.iswindows, supported_platforms()) +products = [ + ExecutableProduct("gawk", :gawk) +] +dependencies = Dependency[] +build_tarballs(ARGS, name, version, sources, script, platforms, products, dependencies; julia_compat="1.6") diff --git a/H/HSL/build_tarballs.jl b/H/HSL/build_tarballs.jl new file mode 100644 index 00000000000..a7d39be9f56 --- /dev/null +++ b/H/HSL/build_tarballs.jl @@ -0,0 +1,34 @@ +# 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 + +name = "HSL" +version = v"1.0.0" + +# Collection of sources required to complete build +sources = [ + GitSource("https://github.com/ralna/JuliaHSL.git", "3461aed2e62f6588098692891403d8737407131c") +] + +# Bash recipe for building across all platforms +script = raw""" +cd $WORKSPACE/srcdir/JuliaHSL/dummy +meson setup builddir --cross-file=${MESON_TARGET_TOOLCHAIN} --buildtype=release +meson compile -C builddir +meson install -C builddir +""" + +# These are the platforms we will build for by default, unless further +# platforms are passed in on the command line +platforms = supported_platforms() + +# The products that we will ensure are always built +products = [ + LibraryProduct("libhsl", :libhsl) +] + +# Dependencies that must be installed before this package can be built +dependencies = [] + +# Build the tarballs, and possibly a `build.jl` as well. +build_tarballs(ARGS, name, version, sources, script, platforms, products, dependencies; julia_compat="1.6") diff --git a/J/JlrsLedger/build_tarballs.jl b/J/JlrsLedger/build_tarballs.jl index 98f7968d2bc..816d529fe6c 100644 --- a/J/JlrsLedger/build_tarballs.jl +++ b/J/JlrsLedger/build_tarballs.jl @@ -3,30 +3,25 @@ using BinaryBuilder, Pkg name = "JlrsLedger" -version = v"0.0.2" +version = v"0.0.3" # Collection of sources required to complete build sources = [ GitSource("https://github.com/Taaitaaiger/jlrs_ledger.git", - "5ff67d8b0f6b6eea50904290e9888e8779e7cd8f"), + "0f1b3ab293445a53f68582302f2d50265507edbe"), ] # Bash recipe for building across all platforms script = raw""" cd $WORKSPACE/srcdir/jlrs_ledger - -if [[ "${target}" == *-musl* ]]; then - rust_flags="-C target-feature=-crt-static" -fi - -RUSTFLAGS=$rust_flags cargo build --release --verbose +cargo build --release --verbose install_license LICENSE install -Dvm 0755 "target/${rust_target}/release/"*jlrs_ledger".${dlext}" "${libdir}/libjlrs_ledger.${dlext}" """ -# Rust toolchain for i686 Windows is unusable -is_excluded(p) = Sys.iswindows(p) && nbits(p) != 64 -platforms = supported_platforms(; exclude=is_excluded) +# These are the platforms we will build for by default, unless further +# platforms are passed in on the command line +platforms = supported_platforms() # The products that we will ensure are always built products = [ diff --git a/K/Kira/build_tarballs.jl b/K/Kira/build_tarballs.jl new file mode 100644 index 00000000000..32a18d54859 --- /dev/null +++ b/K/Kira/build_tarballs.jl @@ -0,0 +1,81 @@ +# 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 +using Base.BinaryPlatforms +const YGGDRASIL_DIR = (dirname∘dirname∘dirname)(@__FILE__) +(include∘joinpath)(YGGDRASIL_DIR, "platforms", "mpi.jl") + +name = "Kira" +version = v"2.3.0" + +# Collection of sources required to complete build +sources = [ + GitSource("https://gitlab.com/kira-pyred/kira.git", "8001d64f23406d6c4cb06578b89011c1a0c04c65"), +] + +# Bash recipe for building across all platforms +script = raw""" +pip3 install -U meson + +mkdir ${WORKSPACE}/srcdir/Kira-build +cd ${WORKSPACE}/srcdir/Kira-build/ + +meson setup \ + -Dfirefly=true \ + -Djemalloc=true \ + --cross-file=${MESON_TARGET_TOOLCHAIN} \ + --buildtype=release \ + ${WORKSPACE}/srcdir/kira/ \ + ${WORKSPACE}/srcdir/Kira-build/ +sed -i "s?/workspace/destdir/opt?/opt?g" build.ninja + +meson install +install_license ${WORKSPACE}/srcdir/kira/COPYING +""" + +# augment_platform_block = """ +# using Base.BinaryPlatforms +# $(MPI.augment) +# augment_platform!(platform::Platform) = augment_mpi!(platform) +# """ + +# These are the platforms we will build for by default, unless further +# platforms are passed in on the command line +platforms = [ + Platform("aarch64", "macos"; ), + Platform("x86_64", "linux"; libc = "glibc"), + Platform("x86_64", "macos"; ) +] # Fermat may only support these platforms, which is the external program required to run Kira. + # Therefore, I do not build Kira for other platforms, while Kira could be compliled on them. + # Notice that aarch64 MacOS is running the Fermat via Rosetta 2. + # It would be helpful if someone would be willing to help compile Fermat on more platforms. +platforms = expand_cxxstring_abis(platforms) +platforms, platform_dependencies = MPI.augment_platforms(platforms) + +# Avoid platforms where the MPI implementation isn't supported +# OpenMPI +# platforms = filter(p -> !(p["mpi"] == "openmpi" && arch(p) == "armv6l" && libc(p) == "glibc"), platforms) +# MPItrampoline +# platforms = filter(p -> !(p["mpi"] == "mpitrampoline" && libc(p) == "musl"), platforms) +# platforms = filter(p -> !(p["mpi"] == "mpitrampoline" && Sys.isfreebsd(p)), platforms) + + +# The products that we will ensure are always built +products = [ + ExecutableProduct("kira", :kira) +] + +# Dependencies that must be installed before this package can be built +dependencies = [ + Dependency(PackageSpec(name="FireFly_jll", uuid="8ecac4f1-ae1f-5ff6-b30b-37d818d8e8b3")) + Dependency(PackageSpec(name="GiNaC_jll", uuid="f695d788-2582-5101-a7df-1403a8f3a07a")) + Dependency(PackageSpec(name="jemalloc_jll", uuid="454a8cc1-5e0e-5123-92d5-09b094f0e876")) + Dependency(PackageSpec(name="Zlib_jll", uuid="83775a58-1f1d-513f-b197-d71354ab007a")) + Dependency(PackageSpec(name="yaml_cpp_jll", uuid="01fea8cc-7d33-533a-824e-56a766f4ffe8")) +] + +# Build the tarballs, and possibly a `build.jl` as well. +build_tarballs(ARGS, name, version, sources, script, platforms, products, dependencies; + julia_compat="1.6", + preferred_gcc_version = v"7.1.0" # For `FireFly_jll` +) diff --git a/L/LLVM/LLVM_full@14/build_tarballs.jl b/L/LLVM/LLVM_full@14/build_tarballs.jl index 02193bf1d87..f514f0e1126 100644 --- a/L/LLVM/LLVM_full@14/build_tarballs.jl +++ b/L/LLVM/LLVM_full@14/build_tarballs.jl @@ -1,6 +1,5 @@ version = v"14.0.6" - include("../common.jl") build_tarballs(ARGS, configure_build(ARGS, version; experimental_platforms=true)...; diff --git a/L/LLVM/LLVM_full_assert@14/build_tarballs.jl b/L/LLVM/LLVM_full_assert@14/build_tarballs.jl index 7f6892f0365..5552ac1d51e 100644 --- a/L/LLVM/LLVM_full_assert@14/build_tarballs.jl +++ b/L/LLVM/LLVM_full_assert@14/build_tarballs.jl @@ -1,6 +1,5 @@ version = v"14.0.6" - include("../common.jl") build_tarballs(ARGS, configure_build(ARGS, version; assert=true, experimental_platforms=true)...; diff --git a/L/LLVM/common.jl b/L/LLVM/common.jl index 02f069cdfe3..1390c5ac6bb 100644 --- a/L/LLVM/common.jl +++ b/L/LLVM/common.jl @@ -14,7 +14,7 @@ const llvm_tags = Dict( v"12.0.0" => "d28af7c654d8db0b68c175db5ce212d74fb5e9bc", v"12.0.1" => "980d2f60a8524c5546397db9e8bbb7d6ea56c1b7", # julia-12.0.1-4 v"13.0.1" => "8a2ae8c8064a0544814c6fac7dd0c4a9aa29a7e6", # julia-13.0.1-3 - v"14.0.6" => "ad0184c1a2ee9508319db7c97d635a75d5336cf8", # julia-14.0.6-2 + v"14.0.6" => "5c82f5309b10fab0adf6a94969e0dddffdb3dbce", # julia-14.0.6-3 v"15.0.7" => "90e1c629f21fe3a8d66d06ebdc5dde62aa6203be", # julia-15.0.7-0 ) diff --git a/L/LaMEM/build_tarballs.jl b/L/LaMEM/build_tarballs.jl index 24d88d1e9e4..27ffe4dc8a0 100644 --- a/L/LaMEM/build_tarballs.jl +++ b/L/LaMEM/build_tarballs.jl @@ -6,14 +6,15 @@ const YGGDRASIL_DIR = "../.." include(joinpath(YGGDRASIL_DIR, "platforms", "mpi.jl")) name = "LaMEM" -version = v"1.2.3" +version = v"1.2.4" + PETSc_COMPAT_VERSION = "3.16.8" # Note: this is the version of the PETSc_jll package, which is sometimes larger than the PETSc version # Collection of sources required to complete build sources = [ GitSource("https://bitbucket.org/bkaus/lamem.git", - "f5bb722b6a57ac4b21e15ea8c70d960ac9609d0e") + "e106f62e19a90b4153564a1dd07bc8778245936c") ] # Bash recipe for building across all platforms diff --git a/L/LibTracyClient/LibTracyClient@0.9.1/build_tarballs.jl b/L/LibTracyClient/LibTracyClient@0.9.1/build_tarballs.jl index 8fc7fa09805..ad37ab3d8d1 100644 --- a/L/LibTracyClient/LibTracyClient@0.9.1/build_tarballs.jl +++ b/L/LibTracyClient/LibTracyClient@0.9.1/build_tarballs.jl @@ -23,12 +23,12 @@ fi atomic_patch -p1 ${WORKSPACE}/srcdir/patches/libTracyClient-freebsd-elfw.patch atomic_patch -p1 ${WORKSPACE}/srcdir/patches/libTracyClient-plot-config.patch atomic_patch -p1 ${WORKSPACE}/srcdir/patches/libTracyClient-no-sampling.patch -cmake -B static -DCMAKE_INSTALL_PREFIX=$prefix -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TARGET_TOOLCHAIN} -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF -DTRACY_FIBERS=ON -DTRACY_NO_BROADCAST=ON -DTRACY_ONLY_LOCALHOST=ON -DTRACY_NO_CODE_TRANSFER=ON -DTRACY_NO_FRAME_IMAGE=ON -DTRACY_NO_CRASH_HANDLER=ON -DTRACY_ON_DEMAND=ON -DTRACY_NO_SAMPLING=ON . +cmake -B static -DCMAKE_INSTALL_PREFIX=$prefix -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TARGET_TOOLCHAIN} -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF -DTRACY_FIBERS=ON -DTRACY_ONLY_LOCALHOST=ON -DTRACY_NO_CODE_TRANSFER=ON -DTRACY_NO_FRAME_IMAGE=ON -DTRACY_NO_CRASH_HANDLER=ON -DTRACY_ON_DEMAND=ON -DTRACY_NO_SAMPLING=ON . cd static make -j${nproc} make install cd .. -cmake -B shared -DCMAKE_INSTALL_PREFIX=$prefix -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TARGET_TOOLCHAIN} -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON -DTRACY_FIBERS=ON -DTRACY_NO_BROADCAST=ON -DTRACY_ONLY_LOCALHOST=ON -DTRACY_NO_CODE_TRANSFER=ON -DTRACY_NO_FRAME_IMAGE=ON -DTRACY_NO_CRASH_HANDLER=ON -DTRACY_ON_DEMAND=ON -DTRACY_NO_SAMPLING=ON . +cmake -B shared -DCMAKE_INSTALL_PREFIX=$prefix -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TARGET_TOOLCHAIN} -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON -DTRACY_FIBERS=ON -DTRACY_ONLY_LOCALHOST=ON -DTRACY_NO_CODE_TRANSFER=ON -DTRACY_NO_FRAME_IMAGE=ON -DTRACY_NO_CRASH_HANDLER=ON -DTRACY_ON_DEMAND=ON -DTRACY_NO_SAMPLING=ON . cd shared make -j${nproc} make install diff --git a/L/Libtool/build_tarballs.jl b/L/Libtool/build_tarballs.jl index 2b2b51b596a..b32a60b3bb0 100644 --- a/L/Libtool/build_tarballs.jl +++ b/L/Libtool/build_tarballs.jl @@ -7,31 +7,33 @@ version = v"2.4.6" # Collection of sources required to complete build sources = [ - ArchiveSource("http://gnu.mirrors.hoobly.com/libtool/libtool-2.4.6.tar.gz", "e3bd4d5d3d025a36c21dd6af7ea818a2afcd4dfc1ea5a17b39d7854bcd0c06e3") + ArchiveSource("https://ftpmirror.gnu.org/libtool/libtool-$(version).tar.gz", + "e3bd4d5d3d025a36c21dd6af7ea818a2afcd4dfc1ea5a17b39d7854bcd0c06e3") ] # Bash recipe for building across all platforms script = raw""" -cd $WORKSPACE/srcdir -cd libtool-2.4.6 +cd $WORKSPACE/srcdir/libtool-* ./configure --prefix=${prefix} --build=${MACHTYPE} --host=${target} make make install -exit """ # These are the platforms we will build for by default, unless further # platforms are passed in on the command line platforms = supported_platforms() +# TODO: in next release include the "experimental" platforms +filter!(p -> !(Sys.isapple(p) && arch(p) == "aarch64") && !(arch(p) == "armv6l"), platforms) # The products that we will ensure are always built products = [ - LibraryProduct("libltdl", :libltdl) + FileProduct("bin/libtool", :libtool), + FileProduct("bin/libtoolize", :libtoolize), + LibraryProduct("libltdl", :libltdl), ] # Dependencies that must be installed before this package can be built -dependencies = Dependency[ -] +dependencies = Dependency[] # Build the tarballs, and possibly a `build.jl` as well. build_tarballs(ARGS, name, version, sources, script, platforms, products, dependencies) diff --git a/L/llama_cpp/build_tarballs.jl b/L/llama_cpp/build_tarballs.jl index b23422a6e71..da03602821c 100644 --- a/L/llama_cpp/build_tarballs.jl +++ b/L/llama_cpp/build_tarballs.jl @@ -6,7 +6,7 @@ version = v"0.0.6" # fake version number # url = "https://github.com/ggerganov/llama.cpp" # description = "Port of Facebook's LLaMA model in C/C++" -# TODO +# NOTES # - missing architectures: powerpc64le, armv6l, arm7vl # versions: fake_version to github_version mapping @@ -18,10 +18,11 @@ version = v"0.0.6" # fake version number # 0.0.4 25.03.2023 master-1972616 https://github.com/ggerganov/llama.cpp/releases/tag/master-1972616 # 0.0.5 30.03.2023 master-3bcc129 https://github.com/ggerganov/llama.cpp/releases/tag/master-3bcc129 # 0.0.6 03.04.2023 master-437e778 https://github.com/ggerganov/llama.cpp/releases/tag/master-437e778 +# 0.0.7 16.04.2023 master-47f61aa https://github.com/ggerganov/llama.cpp/releases/tag/master-47f61aa sources = [ GitSource("https://github.com/ggerganov/llama.cpp.git", - "437e77855a54e69c86fe03bc501f63d9a3fddb0e"), + "47f61aaa5f76d04286792e2fbd0c95b659ab2af0"), DirectorySource("./bundled"), ] @@ -30,8 +31,6 @@ cd $WORKSPACE/srcdir/llama.cpp* # remove -march=native from cmake files atomic_patch -p1 ../patches/cmake-remove-mcpu-native.patch -# fix compilation (include Windows.h) on w64-mingw32 -atomic_patch -p1 ../patches/fix-mingw32-windows-include.patch EXTRA_CMAKE_ARGS= if [[ "${target}" == *-linux-* ]]; then diff --git a/L/llama_cpp/bundled/patches/fix-mingw32-windows-include.patch b/L/llama_cpp/bundled/patches/fix-mingw32-windows-include.patch deleted file mode 100644 index 8d79cd46d17..00000000000 --- a/L/llama_cpp/bundled/patches/fix-mingw32-windows-include.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/llama.cpp b/llama.cpp -index 854bb89..78cf939 100644 ---- a/llama.cpp -+++ b/llama.cpp -@@ -14,7 +14,7 @@ - - #if defined(_WIN32) && !defined(_POSIX_MAPPED_FILES) - #define WIN32_LEAN_AND_MEAN --#include -+#include - #else - #include - #include diff --git a/M/M4/build_tarballs.jl b/M/M4/build_tarballs.jl new file mode 100644 index 00000000000..b189bc8ab6e --- /dev/null +++ b/M/M4/build_tarballs.jl @@ -0,0 +1,32 @@ +using BinaryBuilder + +name = "M4" +version = v"1.4.19" + +sources = [ + ArchiveSource("https://ftp.gnu.org/gnu/m4/m4-$(version).tar.xz", + "63aede5c6d33b6d9b13511cd0be2cac046f2e70fd0a07aa9573a04a82783af96"), +] + +script = raw""" +cd $WORKSPACE/srcdir/m4-*/ + +if [[ "${target}" == *mingw* ]]; then + export CFLAGS="-fstack-protector ${CFLAGS}" +fi + +./configure --prefix=${prefix} --host=${target} +make -j${nprocs} +make install +""" + +platforms = supported_platforms() + +products = [ + ExecutableProduct("m4", :m4), +] + +dependencies = Dependency[ +] + +build_tarballs(ARGS, name, version, sources, script, platforms, products, dependencies; julia_compat="1.6") diff --git a/M/MMG/build_tarballs.jl b/M/MMG/build_tarballs.jl index a0e6a284641..cf5f3e16ae9 100644 --- a/M/MMG/build_tarballs.jl +++ b/M/MMG/build_tarballs.jl @@ -7,15 +7,14 @@ version = v"5.6.0" # Collection of sources required to build MMG sources = [ - ArchiveSource("https://github.com/MmgTools/mmg/archive/refs/tags/v$(version).tar.gz", - "bbf9163d65bc6e0f81dd3acc5a51e4a8c47a7fdae849abc26277e01154fe2437"), + GitSource("https://github.com/MmgTools/mmg", "889d408419b5c48833c249695987cf6ec699d399"), DirectorySource("./bundled") ] # Bash recipe for building across all platforms script = raw""" # Install genheader for host platform -cp -r ${WORKSPACE}/srcdir/mmg-* ${WORKSPACE}/srcdir/mmg-genheader +cp -r ${WORKSPACE}/srcdir/mmg ${WORKSPACE}/srcdir/mmg-genheader cd ${WORKSPACE}/srcdir/mmg-genheader atomic_patch -p1 "${WORKSPACE}/srcdir/patches/genheader.patch" mkdir build @@ -29,7 +28,7 @@ make install cd ${WORKSPACE}/srcdir && rm -r ${WORKSPACE}/srcdir/mmg-genheader # Install MMG -cd ${WORKSPACE}/srcdir/mmg-* +cd ${WORKSPACE}/srcdir/mmg if [[ "${target}" == *mingw* ]]; then atomic_patch -p1 "${WORKSPACE}/srcdir/patches/MMG.mingw.patch" USE_SCOTCH=OFF @@ -73,7 +72,7 @@ scotch_platforms = filter(!Sys.iswindows, platforms) # Dependencies that must be installed before this package can be built dependencies = [ Dependency("LinearElasticity_jll"), - Dependency("SCOTCH_jll", platforms=scotch_platforms) + Dependency("SCOTCH_jll", platforms=scotch_platforms, compat="6.1.3") ] # Build the tarballs, and possibly a `build.jl` as well. diff --git a/M/MPItrampoline/build_tarballs.jl b/M/MPItrampoline/build_tarballs.jl index 649df277f77..92b2f2b2105 100644 --- a/M/MPItrampoline/build_tarballs.jl +++ b/M/MPItrampoline/build_tarballs.jl @@ -7,19 +7,19 @@ include(joinpath(YGGDRASIL_DIR, "platforms", "mpi.jl")) name = "MPItrampoline" -mpitrampoline_version = v"5.2.1" +mpitrampoline_version = v"5.2.3" version = mpitrampoline_version mpich_version_str = "4.1.1" mpiconstants_version = v"1.5.0" -mpiwrapper_version = v"2.10.1" +mpiwrapper_version = v"2.10.3" # Collection of sources required to complete build sources = [ - GitSource("https://github.com/eschnett/MPItrampoline", "95e75cb2a484085977f76675743e5a4e2abb229c"), + GitSource("https://github.com/eschnett/MPItrampoline", "4c6b91ec53d466ab774c2f1ca7e985b5c0f5a8e7"), GitSource("https://github.com/eschnett/MPIconstants", "d2763908c4d69c03f77f5f9ccc546fe635d068cb"), ArchiveSource("https://www.mpich.org/static/downloads/$(mpich_version_str)/mpich-$(mpich_version_str).tar.gz", "ee30471b35ef87f4c88f871a5e2ad3811cd9c4df32fd4f138443072ff4284ca2"), - GitSource("https://github.com/eschnett/MPIwrapper", "aaefda8d03745b3aeda7e5bbd3f2a6e602e085da"), + GitSource("https://github.com/eschnett/MPIwrapper", "7c09c12e601fd0faa2ae84c37f97a05e23795141"), ] # Bash recipe for building across all platforms diff --git a/M/MParT/build_tarballs.jl b/M/MParT/build_tarballs.jl index f8f081ccd8c..64cb6a333c2 100644 --- a/M/MParT/build_tarballs.jl +++ b/M/MParT/build_tarballs.jl @@ -9,12 +9,12 @@ delete!(Pkg.Types.get_last_stdlibs(v"1.6.3"), uuid) julia_versions = [v"1.6.3", v"1.7", v"1.8", v"1.9", v"1.10"] name = "MParT" -version = v"1.2.0" +version = v"2.0.2" # Collection of sources required to complete build sources = [ GitSource("https://github.com/MeasureTransport/MParT.git", - "8d5c3b9a635aa3b8552e8d02f94352f9b4cd3fb4") + "37a54a787d9ecaf6a02d20587ec675add27308ef") ] # Bash recipe for building across all platforms diff --git a/M/MUMPS/MUMPS@5/build_tarballs.jl b/M/MUMPS/MUMPS@5/build_tarballs.jl index cc28ee11d9c..1660264c190 100644 --- a/M/MUMPS/MUMPS@5/build_tarballs.jl +++ b/M/MUMPS/MUMPS@5/build_tarballs.jl @@ -121,7 +121,7 @@ products = [ dependencies = [ Dependency(PackageSpec(name="CompilerSupportLibraries_jll", uuid="e66e0078-7015-5450-92f7-15fbd957f2ae")), Dependency(PackageSpec(name="METIS_jll", uuid="d00139f3-1899-568f-a2f0-47f597d42d70")), - Dependency(PackageSpec(name="SCOTCH_jll", uuid="a8d0f55d-b80e-548d-aff6-1a04c175f0f9")), + Dependency(PackageSpec(name="SCOTCH_jll", uuid="a8d0f55d-b80e-548d-aff6-1a04c175f0f9"); compat="6.1.3"), Dependency(PackageSpec(name="PARMETIS_jll", uuid="b247a4be-ddc1-5759-8008-7e02fe3dbdaa")), Dependency(PackageSpec(name="SCALAPACK32_jll", uuid="aabda75e-bfe4-5a37-92e3-ffe54af3c273")), Dependency(PackageSpec(name="OpenBLAS32_jll", uuid="656ef2d0-ae68-5445-9ca0-591084a874a2")) diff --git a/N/neper/build_tarballs.jl b/N/neper/build_tarballs.jl index f6766f9838d..22ae2689967 100644 --- a/N/neper/build_tarballs.jl +++ b/N/neper/build_tarballs.jl @@ -4,11 +4,11 @@ name = "neper" version = v"4.5.0" sources = [ - ArchiveSource("https://github.com/neperfepx/neper/archive/refs/tags/v$(version).tar.gz", "db80dd89e02207e9b056b05fb9fbe493199ce7c3736b2039104c595b4dcd02a9") + GitSource("https://github.com/neperfepx/neper", "dc5ae599fbab702bdbd9bc55ec0074b0dbaf28c0") ] script = raw""" -cd $WORKSPACE/srcdir/neper-* +cd $WORKSPACE/srcdir/neper mkdir build && cd build CXXFLAGS="-lz" cmake -DCMAKE_INSTALL_PREFIX=$prefix \ @@ -46,7 +46,7 @@ dependencies = [ Dependency(PackageSpec(name="LLVMOpenMP_jll", uuid="1d63c593-3942-5779-bab2-d838dc0a180e"); platforms=filter(Sys.isbsd, platforms)), Dependency(PackageSpec(name="GSL_jll", uuid="1b77fbbe-d8ee-58f0-85f9-836ddc23a7a4"); compat="~2.7.2"), Dependency(PackageSpec(name="NLopt_jll", uuid="079eb43e-fd8e-5478-9966-2cf3e3edb778")), - Dependency(PackageSpec(name="SCOTCH_jll", uuid="a8d0f55d-b80e-548d-aff6-1a04c175f0f9")), + Dependency(PackageSpec(name="SCOTCH_jll", uuid="a8d0f55d-b80e-548d-aff6-1a04c175f0f9"); compat="6.1.3"), RuntimeDependency(PackageSpec(name="gmsh_jll", uuid="630162c2-fc9b-58b3-9910-8442a8a132e6")), ] diff --git a/P/PETSc/build_tarballs.jl b/P/PETSc/build_tarballs.jl index e285ed7f80e..92ee061f079 100644 --- a/P/PETSc/build_tarballs.jl +++ b/P/PETSc/build_tarballs.jl @@ -4,21 +4,18 @@ const YGGDRASIL_DIR = "../.." include(joinpath(YGGDRASIL_DIR, "platforms", "mpi.jl")) name = "PETSc" -version = v"3.16.8" -petsc_version = v"3.16.6" -PARMETIS_COMPAT_VERSION = "4.0.5" +version = v"3.18.6" +petsc_version = v"3.18.6" MUMPS_COMPAT_VERSION = "5.5.1" SUITESPARSE_COMPAT_VERSION = "5.10.1" -SUPERLUDIST_COMPAT_VERSION = "8.0.1" -METIS_COMPAT_VERSION = "5.1.1" -SCOTCH_COMPAT_VERSION = "6.1.3" -SCALAPACK_COMPAT_VERSION = "2.2.1" +SUPERLUDIST_COMPAT_VERSION = "8.1.2" +MPItrampoline_compat_version="5.2.1" # Collection of sources required to build PETSc. Avoid using the git repository, it will # require building SOWING which fails in all non-linux platforms. sources = [ ArchiveSource("https://www.mcs.anl.gov/petsc/mirror/release-snapshots/petsc-$(petsc_version).tar.gz", - "bfc836b52f57686b583c16ab7fae0c318a7b28141ca01656ad673c8ca23037fa"), + "8b53c8b6652459ba0bbe6361b5baf8c4d17c1d04b6654a76e3b6a9ab4a576680"), DirectorySource("./bundled"), ] @@ -27,11 +24,16 @@ script = raw""" cd $WORKSPACE/srcdir/petsc* atomic_patch -p1 $WORKSPACE/srcdir/patches/petsc_name_mangle.patch -BLAS_LAPACK_LIB="${libdir}/libopenblas.${dlext}" +if [[ "${target}" == *-apple* ]]; then + BLAS_LAPACK_LIB= +else + BLAS_LAPACK_LIB="${libdir}/libopenblas.${dlext}" +fi if [[ "${target}" == *-mingw* ]]; then #atomic_patch -p1 $WORKSPACE/srcdir/patches/fix-header-cases.patch MPI_LIBS="${libdir}/msmpi.${dlext}" + else if grep -q MPICH_NAME $prefix/include/mpi.h; then MPI_FFLAGS= @@ -46,16 +48,27 @@ else MPI_FFLAGS= MPI_LIBS= fi + fi + atomic_patch -p1 $WORKSPACE/srcdir/patches/mingw-version.patch -atomic_patch -p1 $WORKSPACE/srcdir/patches/mpi-constants.patch -atomic_patch -p1 $WORKSPACE/srcdir/patches/sosuffix.patch +atomic_patch -p1 $WORKSPACE/srcdir/patches/mpi-constants.patch +atomic_patch -p1 $WORKSPACE/srcdir/patches/macos_version.patch +atomic_patch -p1 $WORKSPACE/srcdir/patches/sosuffix.patch mkdir $libdir/petsc build_petsc() { - PETSC_CONFIG="${1}_${2}_${3}" + # Compile a debug version? + DEBUG_FLAG=0 + if [[ "${4}" == "deb" ]]; then + PETSC_CONFIG="${1}_${2}_${3}_deb" + DEBUG_FLAG=1 + else + PETSC_CONFIG="${1}_${2}_${3}" + fi + if [[ "${3}" == "Int64" ]]; then USE_INT64=1 else @@ -66,12 +79,12 @@ build_petsc() USE_SUPERLU_DIST=0 SUPERLU_DIST_LIB="" SUPERLU_DIST_INCLUDE="" - if [ -d "${libdir}/superlu_dist" ] && [ "${1}" == "double" ]; - then + if [ -f "${libdir}/libsuperlu_dist_Int32.${dlext}" ] && [ "${1}" == "double" ] && [ "${3}" == "Int64" ]; then USE_SUPERLU_DIST=1 - SUPERLU_DIR="${libdir}/superlu_dist/${3}" - SUPERLU_DIST_LIB="--with-superlu_dist-lib=${SUPERLU_DIR}/lib/libsuperlu_dist_${3}.${dlext}" - SUPERLU_DIST_INCLUDE="--with-superlu_dist-include=${SUPERLU_DIR}/include" + #SUPERLU_DIST_LIB="--with-superlu_dist-lib=${libdir}/libsuperlu_dist_${3}.${dlext}" + SUPERLU_DIST_LIB="--with-superlu_dist-lib=${libdir}/libsuperlu_dist_Int32.${dlext}" + + SUPERLU_DIST_INCLUDE="--with-superlu_dist-include=${includedir}" fi USE_SUITESPARSE=0 @@ -96,7 +109,7 @@ build_petsc() # See if we can install MUMPS USE_MUMPS=0 - if [ -f "${libdir}/libdmumps.${dlext}" ] && [ "${1}" == "double" ]; then + if [ -f "${libdir}/libdmumps.${dlext}" ] && [ "${1}" == "double" ] && [ "${2}" == "real" ]; then USE_MUMPS=1 MUMPS_LIB="--with-mumps-lib=${libdir}/libdmumps.${dlext} --with-scalapack-lib=${libdir}/libscalapack32.${dlext}" MUMPS_INCLUDE="--with-mumps-include=${includedir} --with-scalapack-include=${includedir}" @@ -104,6 +117,25 @@ build_petsc() MUMPS_LIB="" MUMPS_INCLUDE="" fi + + LIBFLAGS="-L${libdir}" + if [[ "${target}" == *-mingw* ]]; then + LIBFLAGS="-L${libdir} -lssp" + fi + + if [[ "${target}" == *-apple* ]]; then + LIBFLAGS="-L${libdir} -framework Accelerate" + fi + + if [ ${DEBUG_FLAG} == 1 ]; then + _COPTFLAGS='-O0 -g' + _CXXOPTFLAGS='-O0 -g' + _FOPTFLAGS='-O0' + else + _COPTFLAGS='-O3 -g' + _CXXOPTFLAGS='-O3 -g' + _FOPTFLAGS='-O3' + fi echo "USE_SUPERLU_DIST="$USE_SUPERLU_DIST echo "USE_SUITESPARSE="$USE_SUITESPARSE @@ -111,25 +143,39 @@ build_petsc() echo "1="${1} echo "2="${2} echo "3="${3} + echo "4="${4} echo "USE_INT64"=$USE_INT64 echo "Machine_name="$Machine_name - + echo "LIBFLAGS="$LIBFLAGS + echo "target="$target + echo "DEBUG="${DEBUG_FLAG} + echo "COPTFLAGS="${_COPTFLAGS} + echo "BLAS_LAPACK_LIB="$BLAS_LAPACK_LIB + mkdir $libdir/petsc/${PETSC_CONFIG} ./configure --prefix=${libdir}/petsc/${PETSC_CONFIG} \ CC=${CC} \ FC=${FC} \ CXX=${CXX} \ - COPTFLAGS='-O3' \ - CXXOPTFLAGS='-O3' \ - CFLAGS='-fno-stack-protector' \ - FFLAGS="${MPI_FFLAGS}" \ - LDFLAGS="-L${libdir}" \ - FOPTFLAGS='-O3' \ - --with-64-bit-indices=${USE_INT64} \ - --with-debugging=0 \ + COPTFLAGS=${_COPTFLAGS} \ + CXXOPTFLAGS=${_CXXOPTFLAGS} \ + FOPTFLAGS=${_FOPTFLAGS} \ + --with-blaslapack-lib=${BLAS_LAPACK_LIB} \ + --with-blaslapack-suffix="" \ + CFLAGS='-fno-stack-protector ' \ + FFLAGS="${MPI_FFLAGS}" \ + LDFLAGS="${LIBFLAGS}" \ + --with-64-bit-indices=${USE_INT64} \ + --with-debugging=${DEBUG_FLAG} \ --with-batch \ - --with-blaslapack-lib=$BLAS_LAPACK_LIB \ - --with-blaslapack-suffix="" \ + --with-mpi-lib="${MPI_LIBS}" \ + --known-mpi-int64_t=0 \ + --with-mpi-include="${includedir}" \ + --with-sowing=0 \ + --with-precision=${1} \ + --with-scalar-type=${2} \ + --with-pthread=0 \ + --PETSC_ARCH=${target}_${PETSC_CONFIG} \ --with-superlu_dist=${USE_SUPERLU_DIST} \ ${SUPERLU_DIST_LIB} \ ${SUPERLU_DIST_INCLUDE} \ @@ -137,15 +183,8 @@ build_petsc() ${MUMPS_LIB} \ ${MUMPS_INCLUDE} \ --with-suitesparse=${USE_SUITESPARSE} \ - --known-64-bit-blas-indices=0 \ - --with-mpi-lib="${MPI_LIBS}" \ - --known-mpi-int64_t=0 \ - --with-mpi-include="${includedir}" \ - --with-sowing=0 \ - --with-precision=${1} \ - --with-scalar-type=${2} \ - --PETSC_ARCH=${target}_${PETSC_CONFIG} \ - --SOSUFFIX=${PETSC_CONFIG} + --SOSUFFIX=${PETSC_CONFIG} \ + --with-clean=1 if [[ "${target}" == *-mingw* ]]; then export CPPFLAGS="-Dpetsc_EXPORTS" @@ -165,18 +204,38 @@ build_petsc() # sed -i -e "s/-lpetsc/-lpetsc_${PETSC_CONFIG}/g" "$libdir/petsc/${PETSC_CONFIG}/lib/pkgconfig/petsc.pc" # cp $libdir/petsc/${PETSC_CONFIG}/lib/pkgconfig/petsc.pc ${prefix}/lib/pkgconfig/petsc_${PETSC_CONFIG}.pc + if [ "${1}" == "double" ] && [ "${2}" == "real" ] && [ "${3}" == "Int64" ] && [ "${4}" == "opt" ]; then + + # Compile two examples (to allow testing the installation). + # This can later be run with: + # julia> run(`$(PETSc_jll.ex42()) -stokes_ksp_monitor -log_view` ) + workdir=${libdir}/petsc/${PETSC_CONFIG}/share/petsc/examples/src/ksp/ksp/tutorials/ + make --directory=${workdir} PETSC_DIR=${libdir}/petsc/${PETSC_CONFIG} PETSC_ARCH=${target}_${PETSC_CONFIG} ex42 + install -Dvm 755 ${workdir}/ex42* "${bindir}/ex42${exeext}" + + # This is a staggered grid Stokes example, as discussed in https://joss.theoj.org/papers/10.21105/joss.04531 + # This can later be run with: + # julia> run(`$(PETSc_jll.ex4()) -ksp_monitor -log_view` ) + workdir=${libdir}/petsc/${PETSC_CONFIG}/share/petsc/examples/src/dm/impls/stag/tutorials/ + make --directory=$workdir PETSC_DIR=${libdir}/petsc/${PETSC_CONFIG} PETSC_ARCH=${target}_${PETSC_CONFIG} ex4 + install -Dvm 755 ${workdir}/ex4* "${bindir}/ex4${exeext}" + + fi + # we don't particularly care about the examples rm -r ${libdir}/petsc/${PETSC_CONFIG}/share/petsc/examples + } -build_petsc double real Int32 -build_petsc single real Int32 -build_petsc double complex Int32 -build_petsc single complex Int32 -build_petsc double real Int64 -build_petsc single real Int64 -build_petsc double complex Int64 -build_petsc single complex Int64 +build_petsc double real Int64 opt +build_petsc double real Int64 deb # compile at least one debug version +build_petsc double real Int32 opt +build_petsc single real Int32 opt +build_petsc double complex Int32 opt +build_petsc single complex Int32 opt +build_petsc single real Int64 opt +build_petsc double complex Int64 opt +build_petsc single complex Int64 opt """ augment_platform_block = """ @@ -186,8 +245,10 @@ augment_platform_block = """ """ # We attempt to build for all defined platforms -platforms = expand_gfortran_versions(supported_platforms(exclude=[Platform("i686", "windows")])) -platforms, platform_dependencies = MPI.augment_platforms(platforms) +platforms = expand_gfortran_versions(supported_platforms(exclude=[Platform("i686", "windows"), + Platform("i686","linux"; libc="musl"), + Platform("aarch64","linux"; libc="musl")])) +platforms, platform_dependencies = MPI.augment_platforms(platforms; MPItrampoline_compat=MPItrampoline_compat_version) # Avoid platforms where the MPI implementation isn't supported # OpenMPI @@ -198,28 +259,33 @@ platforms = filter(p -> !(p["mpi"] == "mpitrampoline" && libc(p) == "musl"), pla platforms = filter(p -> !(p["mpi"] == "mpitrampoline" && Sys.isfreebsd(p)), platforms) products = [ + ExecutableProduct("ex4", :ex4) + ExecutableProduct("ex42", :ex42) + # Current default build, equivalent to Float64_Real_Int32 - LibraryProduct("libpetsc_double_real_Int32", :libpetsc, "\$libdir/petsc/double_real_Int32/lib") + LibraryProduct("libpetsc_double_real_Int64", :libpetsc, "\$libdir/petsc/double_real_Int64/lib") + LibraryProduct("libpetsc_double_real_Int64", :libpetsc_Float64_Real_Int64, "\$libdir/petsc/double_real_Int64/lib") + LibraryProduct("libpetsc_double_real_Int64_deb", :libpetsc_Float64_Real_Int64_deb, "\$libdir/petsc/double_real_Int64_deb/lib") LibraryProduct("libpetsc_double_real_Int32", :libpetsc_Float64_Real_Int32, "\$libdir/petsc/double_real_Int32/lib") LibraryProduct("libpetsc_single_real_Int32", :libpetsc_Float32_Real_Int32, "\$libdir/petsc/single_real_Int32/lib") LibraryProduct("libpetsc_double_complex_Int32", :libpetsc_Float64_Complex_Int32, "\$libdir/petsc/double_complex_Int32/lib") LibraryProduct("libpetsc_single_complex_Int32", :libpetsc_Float32_Complex_Int32, "\$libdir/petsc/single_complex_Int32/lib") - LibraryProduct("libpetsc_double_real_Int64", :libpetsc_Float64_Real_Int64, "\$libdir/petsc/double_real_Int64/lib") LibraryProduct("libpetsc_single_real_Int64", :libpetsc_Float32_Real_Int64, "\$libdir/petsc/single_real_Int64/lib") LibraryProduct("libpetsc_double_complex_Int64", :libpetsc_Float64_Complex_Int64, "\$libdir/petsc/double_complex_Int64/lib") LibraryProduct("libpetsc_single_complex_Int64", :libpetsc_Float32_Complex_Int64, "\$libdir/petsc/single_complex_Int64/lib") + ] dependencies = [ - Dependency("OpenBLAS32_jll"), + Dependency("OpenBLAS32_jll"; platforms=filter(!Sys.isapple, platforms)), Dependency("CompilerSupportLibraries_jll"), Dependency("SuperLU_DIST_jll"; compat=SUPERLUDIST_COMPAT_VERSION), Dependency("SuiteSparse_jll"; compat=SUITESPARSE_COMPAT_VERSION), Dependency("MUMPS_jll"; compat=MUMPS_COMPAT_VERSION), - Dependency("SCALAPACK32_jll"; compat=SCALAPACK_COMPAT_VERSION), - Dependency("METIS_jll"; compat=METIS_COMPAT_VERSION), - Dependency("SCOTCH_jll"; compat=SCOTCH_COMPAT_VERSION), - Dependency("PARMETIS_jll"; compat=PARMETIS_COMPAT_VERSION), + Dependency("SCALAPACK32_jll"), + Dependency("METIS_jll"), + Dependency("SCOTCH_jll"), + Dependency("PARMETIS_jll"), ] append!(dependencies, platform_dependencies) diff --git a/P/PETSc/bundled/patches/macos_version.patch b/P/PETSc/bundled/patches/macos_version.patch new file mode 100644 index 00000000000..7fba751f277 --- /dev/null +++ b/P/PETSc/bundled/patches/macos_version.patch @@ -0,0 +1,21 @@ +--- a/config/BuildSystem/config/setCompilers.py 2023-04-06 09:30:14 ++++ b/config/BuildSystem/config/setCompilers.py 2023-04-06 09:30:53 +@@ -627,10 +627,14 @@ + if log: log.write('Detected Darwin') + isDarwin_value = True + import platform +- v = tuple([int(a) for a in platform.mac_ver()[0].split('.')]) +- if v >= (10,15,0): +- if log: log.write('Detected Darwin/MacOSX Catalina OS\n') +- isDarwinCatalina_value = True ++ try: ++ v = tuple([int(a) for a in platform.mac_ver()[0].split('.')]) ++ if v >= (10,15,0): ++ if log: log.write('Detected Darwin/MacOSX Catalina OS\n') ++ isDarwinCatalina_value = True ++ except: ++ if log: log.write('MacOS version detecton failed!\n') ++ pass + if output.find('freebsd') >= 0: + if log: log.write('Detected FreeBSD') + isFreeBSD_value = True diff --git a/P/PETSc/bundled/patches/mpi-constants.patch b/P/PETSc/bundled/patches/mpi-constants.patch index a9c44b6786b..c0fbc2f8c65 100644 --- a/P/PETSc/bundled/patches/mpi-constants.patch +++ b/P/PETSc/bundled/patches/mpi-constants.patch @@ -107,42 +107,44 @@ diff --git a/src/sys/fileio/fretrieve.c b/src/sys/fileio/fretrieve.c index d214c66aef..1ec946fd49 100644 --- a/src/sys/fileio/fretrieve.c +++ b/src/sys/fileio/fretrieve.c -@@ -123,10 +123,17 @@ PetscErrorCode PetscSharedTmp(MPI_Comm comm,PetscBool *shared) - PetscMPIInt size,rank,*tagvalp,sum,cnt,i; - PetscBool flg,iflg; - FILE *fd; +--- fretrieve.c 2022-10-01 06:12:21 ++++ fretrieve_new.c 2023-04-06 11:32:03 +@@ -119,10 +119,17 @@ + PetscMPIInt size, rank, *tagvalp, sum, cnt, i; + PetscBool flg, iflg; + FILE *fd; - static PetscMPIInt Petsc_Tmp_keyval = MPI_KEYVAL_INVALID; + static int have_Petsc_Tmp_keyval = 0; + static PetscMPIInt Petsc_Tmp_keyval; int err; PetscFunctionBegin; -+ ++ + if (!have_Petsc_Tmp_keyval) { + have_Petsc_Tmp_keyval = 1; + Petsc_Tmp_keyval = MPI_KEYVAL_INVALID; + } + - ierr = MPI_Comm_size(comm,&size);CHKERRMPI(ierr); + PetscCallMPI(MPI_Comm_size(comm, &size)); if (size == 1) { *shared = PETSC_TRUE; -@@ -244,10 +251,17 @@ PetscErrorCode PetscSharedWorkingDirectory(MPI_Comm comm,PetscBool *shared) - PetscMPIInt size,rank,*tagvalp,sum,cnt,i; - PetscBool flg,iflg; - FILE *fd; +@@ -234,10 +241,17 @@ + PetscMPIInt size, rank, *tagvalp, sum, cnt, i; + PetscBool flg, iflg; + FILE *fd; - static PetscMPIInt Petsc_WD_keyval = MPI_KEYVAL_INVALID; + static int have_Petsc_WD_keyval = 0; + static PetscMPIInt Petsc_WD_keyval; int err; PetscFunctionBegin; -+ ++ + if (!have_Petsc_WD_keyval) { + have_Petsc_WD_keyval = 1; + Petsc_WD_keyval = MPI_KEYVAL_INVALID; + } + - ierr = MPI_Comm_size(comm,&size);CHKERRMPI(ierr); + PetscCallMPI(MPI_Comm_size(comm, &size)); if (size == 1) { *shared = PETSC_TRUE; diff --git a/src/sys/objects/optionsyaml.c b/src/sys/objects/optionsyaml.c @@ -163,8 +165,8 @@ diff --git a/src/sys/objects/pinit.c b/src/sys/objects/pinit.c index 94b152c014..7f18938bb1 100644 --- a/src/sys/objects/pinit.c +++ b/src/sys/objects/pinit.c -@@ -56,17 +56,28 @@ PETSC_INTERN PetscErrorCode PetscSequentialPhaseEnd_Private(MPI_Comm,int); - PETSC_INTERN PetscErrorCode PetscCloseHistoryFile(FILE**); +@@ -43,19 +43,32 @@ + PETSC_INTERN PetscErrorCode PetscCloseHistoryFile(FILE **); /* user may set these BEFORE calling PetscInitialize() */ -MPI_Comm PETSC_COMM_WORLD = MPI_COMM_NULL; @@ -175,6 +177,8 @@ index 94b152c014..7f18938bb1 100644 +PetscMPIInt Petsc_InnerComm_keyval; +PetscMPIInt Petsc_OuterComm_keyval; +PetscMPIInt Petsc_ShmComm_keyval; ++PetscMPIInt Petsc_CreationIdx_keyval; ++PetscMPIInt Petsc_Garbage_HMap_keyval; + +__attribute__((__constructor__)) static void init_PETSC_COMM_WORLD() +{ @@ -187,28 +191,34 @@ index 94b152c014..7f18938bb1 100644 + PETSC_MPI_THREAD_REQUIRED = 0; #endif --PetscMPIInt Petsc_Counter_keyval = MPI_KEYVAL_INVALID; --PetscMPIInt Petsc_InnerComm_keyval = MPI_KEYVAL_INVALID; --PetscMPIInt Petsc_OuterComm_keyval = MPI_KEYVAL_INVALID; --PetscMPIInt Petsc_ShmComm_keyval = MPI_KEYVAL_INVALID; -+ Petsc_Counter_keyval = MPI_KEYVAL_INVALID; -+ Petsc_InnerComm_keyval = MPI_KEYVAL_INVALID; -+ Petsc_OuterComm_keyval = MPI_KEYVAL_INVALID; -+ Petsc_ShmComm_keyval = MPI_KEYVAL_INVALID; +-PetscMPIInt Petsc_Counter_keyval = MPI_KEYVAL_INVALID; +-PetscMPIInt Petsc_InnerComm_keyval = MPI_KEYVAL_INVALID; +-PetscMPIInt Petsc_OuterComm_keyval = MPI_KEYVAL_INVALID; +-PetscMPIInt Petsc_ShmComm_keyval = MPI_KEYVAL_INVALID; +-PetscMPIInt Petsc_CreationIdx_keyval = MPI_KEYVAL_INVALID; +-PetscMPIInt Petsc_Garbage_HMap_keyval = MPI_KEYVAL_INVALID; ++ Petsc_Counter_keyval = MPI_KEYVAL_INVALID; ++ Petsc_InnerComm_keyval = MPI_KEYVAL_INVALID; ++ Petsc_OuterComm_keyval = MPI_KEYVAL_INVALID; ++ Petsc_ShmComm_keyval = MPI_KEYVAL_INVALID; ++ Petsc_CreationIdx_keyval = MPI_KEYVAL_INVALID; ++ Petsc_Garbage_HMap_keyval = MPI_KEYVAL_INVALID; +} /* Declare and set all the string names of the PETSc enums -@@ -393,7 +404,8 @@ PETSC_EXTERN PetscMPIInt PetscDataRep_read_conv_fn(void*, MPI_Datatype,PetscMPII - PETSC_EXTERN PetscMPIInt PetscDataRep_write_conv_fn(void*, MPI_Datatype,PetscMPIInt,void*,MPI_Offset,void*); +@@ -419,8 +432,9 @@ + PETSC_EXTERN PetscMPIInt PetscDataRep_write_conv_fn(void *, MPI_Datatype, PetscMPIInt, void *, MPI_Offset, void *); #endif --PetscMPIInt PETSC_MPI_ERROR_CLASS=MPI_ERR_LASTCODE,PETSC_MPI_ERROR_CODE; +-PetscMPIInt PETSC_MPI_ERROR_CLASS = MPI_ERR_LASTCODE, PETSC_MPI_ERROR_CODE; +- +PetscMPIInt PETSC_MPI_ERROR_CLASS,PETSC_MPI_ERROR_CODE; +__attribute__((__constructor__)) static void init_PETSC_MPI_ERROR_CLASS() { PETSC_MPI_ERROR_CLASS=MPI_ERR_LASTCODE; } - - PETSC_INTERN int PetscGlobalArgc; ++ + PETSC_INTERN int PetscGlobalArgc; PETSC_INTERN char **PetscGlobalArgs; + int PetscGlobalArgc = 0; diff --git a/src/sys/utils/mpiu.c b/src/sys/utils/mpiu.c index a28ea3dc51..15247372d9 100644 --- a/src/sys/utils/mpiu.c @@ -223,21 +233,6 @@ index a28ea3dc51..15247372d9 100644 /*@ PetscSequentialPhaseBegin - Begins a sequential section of code. -diff --git a/src/vec/vec/utils/comb.c b/src/vec/vec/utils/comb.c -index 9422402d2e..e15cea0ba6 100644 ---- a/src/vec/vec/utils/comb.c -+++ b/src/vec/vec/utils/comb.c -@@ -271,7 +271,8 @@ PetscErrorCode PetscSplitReductionDestroy(PetscSplitReduction *sr) - PetscFunctionReturn(0); - } - --PetscMPIInt Petsc_Reduction_keyval = MPI_KEYVAL_INVALID; -+PetscMPIInt Petsc_Reduction_keyval; -+__attribute__((__constructor__)) static void init_Petsc_Reduction_keyval() { Petsc_Reduction_keyval = MPI_KEYVAL_INVALID; } - - /* - Private routine to delete internal storage when a communicator is freed. - diff --git a/src/mat/impls/scalapack/matscalapack.c b/src/mat/impls/scalapack/matscalapack.c index 9422402d2e..e15cea0ba6 100644 --- a/src/mat/impls/scalapack/matscalapack.c @@ -252,3 +247,19 @@ index 9422402d2e..e15cea0ba6 100644 static PetscErrorCode Petsc_ScaLAPACK_keyval_free(void) { + +diff --git a/src/vec/vec/utils/comb.c b/src/vec/vec/utils/comb.c +index 9422402d2e..e15cea0ba6 100644 +--- a/src/vec/vec/utils/comb.c ++++ b/src/vec/vec/utils/comb.c +@@ -271,7 +271,9 @@ + PetscFunctionReturn(0); + } + +-PetscMPIInt Petsc_Reduction_keyval = MPI_KEYVAL_INVALID; ++PetscMPIInt Petsc_Reduction_keyval; ++__attribute__((__constructor__)) static void init_Petsc_Reduction_keyval() { Petsc_Reduction_keyval = MPI_KEYVAL_INVALID; } ++ + + /* + Private routine to delete internal storage when a communicator is freed. diff --git a/P/PTSCOTCH/build_tarballs.jl b/P/PTSCOTCH/build_tarballs.jl index 355c977b16d..29183cb8567 100644 --- a/P/PTSCOTCH/build_tarballs.jl +++ b/P/PTSCOTCH/build_tarballs.jl @@ -7,13 +7,11 @@ include(joinpath(YGGDRASIL_DIR, "platforms", "mpi.jl")) name = "PTSCOTCH" version = v"6.1.5" -ptscotch_version = v"6.1.3" -scotch_jll_version = v"6.1.3" +scotch_jll_version = "6.1.3" # Collection of sources required to complete build sources = [ - ArchiveSource("https://gitlab.inria.fr/scotch/scotch/-/archive/v$(ptscotch_version)/scotch-v$(ptscotch_version).tar.gz", - "4e54f056199e6c23d46581d448fcfe2285987e5554a0aa527f7931684ef2809e"), + GitSource("https://gitlab.inria.fr/scotch/scotch", "40b60f8965913178cd66e3572eb23efa6ce18ade"), # <-- v"6.1.3" DirectorySource("./bundled") ] @@ -47,7 +45,7 @@ augment_platform_block = """ # platforms are passed in on the command line platforms = supported_platforms(; exclude=Sys.iswindows) -platforms, platform_dependencies = MPI.augment_platforms(platforms) +platforms, platform_dependencies = MPI.augment_platforms(platforms; MPItrampoline_compat="5.2.1") # Avoid platforms where the MPI implementation isn't supported # OpenMPI @@ -68,7 +66,7 @@ products = [ # Dependencies that must be installed before this package can be built dependencies = [ Dependency(PackageSpec(name="Zlib_jll", uuid="83775a58-1f1d-513f-b197-d71354ab007a")), - Dependency("SCOTCH_jll", scotch_jll_version) + Dependency("SCOTCH_jll"; compat=scotch_jll_version) ] append!(dependencies, platform_dependencies) diff --git a/P/patch/build_tarballs.jl b/P/patch/build_tarballs.jl new file mode 100644 index 00000000000..e15fa301558 --- /dev/null +++ b/P/patch/build_tarballs.jl @@ -0,0 +1,26 @@ +using BinaryBuilder + +name = "patch" +version = v"2.7.6" + +# Collection of sources required to complete build +sources = [ + ArchiveSource("https://ftp.gnu.org/gnu/patch/patch-$(version).tar.xz", + "ac610bda97abe0d9f6b7c963255a11dcb196c25e337c61f94e4778d632f1d8fd"), +] + +# Bash recipe for building across all platforms +script = raw""" +cd $WORKSPACE/srcdir/patch* +./configure --prefix=${prefix} --host=${target} +make -j${nproc} +make install +""" + +# Windows build fails spectacularly; some patching required +platforms = filter(!Sys.iswindows, supported_platforms()) +products = [ + ExecutableProduct("patch", :patch), +] +dependencies = Dependency[] +build_tarballs(ARGS, name, version, sources, script, platforms, products, dependencies; julia_compat="1.6") diff --git a/Q/qr_mumps/build_tarballs.jl b/Q/qr_mumps/build_tarballs.jl index e589d380648..4249001e24e 100644 --- a/Q/qr_mumps/build_tarballs.jl +++ b/Q/qr_mumps/build_tarballs.jl @@ -8,8 +8,6 @@ version = v"3.0.4" # Collection of sources required to complete build sources = [ GitSource("https://gitlab.com/qr_mumps/qr_mumps.git" ,"66e9b6c97959343362d4f1b22cd4307813752df5"), - # ArchiveSource("http://buttari.perso.enseeiht.fr/qr_mumps/releases/qr_mumps-$version.tgz", - # "f78524dcc58f597c9255e162fa17a7aabe5d2ce0ef5f0d7dcd71221cf4bdf231") ] # Bash recipe for building across all platforms @@ -62,7 +60,7 @@ dependencies = [ Dependency(PackageSpec(name="CompilerSupportLibraries_jll", uuid="e66e0078-7015-5450-92f7-15fbd957f2ae")), Dependency(PackageSpec(name="SuiteSparse_jll", uuid="bea87d4a-7f5b-5778-9afe-8cc45184846c")), Dependency(PackageSpec(name="METIS_jll", uuid="d00139f3-1899-568f-a2f0-47f597d42d70")), - Dependency(PackageSpec(name="SCOTCH_jll", uuid="a8d0f55d-b80e-548d-aff6-1a04c175f0f9")) + Dependency(PackageSpec(name="SCOTCH_jll", uuid="a8d0f55d-b80e-548d-aff6-1a04c175f0f9"); compat="6.1.3") # Dependency(PackageSpec(name="libblastrampoline_jll", uuid="8e850b90-86db-534c-a0d3-1478176c7d93")) for Julia ≥ v"1.9" # Dependency(PackageSpec(name="StarPU_jll", uuid="e3ad0b27-b140-5312-a56e-059adfc55eb4")) ] diff --git a/S/SCOTCH/build_tarballs.jl b/S/SCOTCH/build_tarballs.jl index bc3d7642f80..d56b43cce9c 100644 --- a/S/SCOTCH/build_tarballs.jl +++ b/S/SCOTCH/build_tarballs.jl @@ -3,49 +3,89 @@ using BinaryBuilder, Pkg name = "SCOTCH" -version = v"6.1.3" +version = v"7.0.3" # Collection of sources required to complete build sources = [ - ArchiveSource("https://gitlab.inria.fr/scotch/scotch/-/archive/v$(version)/scotch-v$(version).tar.gz","4e54f056199e6c23d46581d448fcfe2285987e5554a0aa527f7931684ef2809e"), - DirectorySource("./bundled") + GitSource("https://gitlab.inria.fr/scotch/scotch", "b43864123e820e3ca541bfecd3738aed385a4c47"), + DirectorySource("./bundled"), ] # Bash recipe for building across all platforms script = raw""" -cd $WORKSPACE/srcdir/scotch* -atomic_patch -p1 "${WORKSPACE}/srcdir/patches/native_build.patch" -atomic_patch -p1 "${WORKSPACE}/srcdir/patches/Makefile.patch" -if [[ "${target}" == *apple* || "${target}" == *freebsd* ]]; then - atomic_patch -p1 "${WORKSPACE}/srcdir/patches/OSX_FreeBSD.patch" +cd ${WORKSPACE}/srcdir/scotch* + +# https://github.com/conda-forge/scotch-feedstock +for f in ${WORKSPACE}/srcdir/patches/*.patch; do + atomic_patch -p1 ${f} +done + +mkdir -p src/dummysizes/build-host +cd src/dummysizes/build-host +cp ${WORKSPACE}/srcdir/patches/CMakeLists-dummysizes.txt ../CMakeLists.txt + +CC=${CC_BUILD} cmake .. \ + -DBUILD_PTSCOTCH=OFF \ + -DCMAKE_BUILD_TYPE=Release + +make -j${nproc} + +cd ${WORKSPACE}/srcdir/scotch* +mkdir build +cd build + +FLAGS="" +if [[ "${target}" == *linux* ]]; then + FLAGS="-lrt" +fi +if [[ "${target}" == *linux-musl* ]]; then + FLAGS="-lrt -D_GNU_SOURCE" fi + +CFLAGS=$FLAGS cmake .. \ + -DBUILD_SHARED_LIBS=ON \ + -DCMAKE_INSTALL_PREFIX=$prefix \ + -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TARGET_TOOLCHAIN} \ + -DCMAKE_BUILD_TYPE=Release \ + -DINTSIZE="32" \ + -DTHREADS=ON \ + -DMPI_THREAD_MULTIPLE=OFF \ + -DBUILD_PTSCOTCH=OFF \ + -DBUILD_LIBESMUMPS=ON \ + -DBUILD_LIBSCOTCHMETIS=ON \ + -DBUILD_DUMMYSIZES=OFF \ + -DINSTALL_METIS_HEADERS=OFF + +make -j${nproc} +make install + if [[ "${target}" == *mingw* ]]; then - atomic_patch -p1 "${WORKSPACE}/srcdir/patches/Windows.patch" + cp bin/*.dll $libdir fi -cd src -make scotch -make esmumps -make prefix=$prefix install + install_license ../LICENSE_en.txt -exit """ # These are the platforms we will build for by default, unless further # platforms are passed in on the command line -platforms = supported_platforms(; exclude=Sys.iswindows) +platforms = supported_platforms(; exclude=Sys.isfreebsd) # The products that we will ensure are always built products = [ + LibraryProduct("libscotch", :libscotch), + LibraryProduct("libesmumps", :libesmumps), LibraryProduct("libscotcherr", :libscotcherr), LibraryProduct("libscotcherrexit", :libscotcherrexit), - LibraryProduct("libscotchmetis", :libscotchmetis), - LibraryProduct("libscotch", :libscotch), - LibraryProduct("libesmumps", :libesmumps) + LibraryProduct("libscotchmetisv3", :libscotchmetisv3), + LibraryProduct("libscotchmetisv5", :libscotchmetisv5) ] # Dependencies that must be installed before this package can be built dependencies = [ - Dependency(PackageSpec(name="Zlib_jll", uuid="83775a58-1f1d-513f-b197-d71354ab007a")) + Dependency(PackageSpec(name="CompilerSupportLibraries_jll", uuid="e66e0078-7015-5450-92f7-15fbd957f2ae")), + Dependency(PackageSpec(name="Zlib_jll", uuid="83775a58-1f1d-513f-b197-d71354ab007a")), + Dependency(PackageSpec(name="Bzip2_jll", uuid="6e34b625-4abd-537c-b88f-471c36dfa7a0"); compat="1.0.8"), + Dependency(PackageSpec(name="XZ_jll", uuid="ffd25f8a-64ca-5728-b0f7-c24cf3aae800")) ] # Build the tarballs, and possibly a `build.jl` as well. diff --git a/S/SCOTCH/bundled/patches/0001-Remove-unconditional-testing.patch b/S/SCOTCH/bundled/patches/0001-Remove-unconditional-testing.patch new file mode 100644 index 00000000000..6e275610c02 --- /dev/null +++ b/S/SCOTCH/bundled/patches/0001-Remove-unconditional-testing.patch @@ -0,0 +1,27 @@ +From 54ec81fd5f5da27ba489ba833e9c8dbfa215f53a Mon Sep 17 00:00:00 2001 +From: Min RK +Date: Fri, 20 May 2022 14:34:24 +0200 +Subject: [PATCH 1/4] Remove unconditional testing + +Normally invoked by ctest +--- + CMakeLists.txt | 3 --- + 1 file changed, 3 deletions(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index d63fe21..4531d15 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -80,9 +80,6 @@ option(BUILD_LIBSCOTCHMETIS "Build ScotchMeTiS library" ON) + # Install our MeTiS header stubs + option(INSTALL_METIS_HEADERS "Install libScotchMeTiS headers in destination directory" ON) + +-# Allow for testing +-enable_testing() +- + add_subdirectory(src) + + # Install man pages +-- +2.35.3 + diff --git a/S/SCOTCH/bundled/patches/0002-add-COMPONENT-labels-for-easier-split-installation.patch b/S/SCOTCH/bundled/patches/0002-add-COMPONENT-labels-for-easier-split-installation.patch new file mode 100644 index 00000000000..70c27dbff91 --- /dev/null +++ b/S/SCOTCH/bundled/patches/0002-add-COMPONENT-labels-for-easier-split-installation.patch @@ -0,0 +1,179 @@ +From a18e395cafa2fb3ebd551449b3b23b950d191361 Mon Sep 17 00:00:00 2001 +From: Min RK +Date: Fri, 20 May 2022 15:11:19 +0200 +Subject: [PATCH 2/4] add COMPONENT labels for easier split installation + +--- + CMakeLists.txt | 2 +- + src/CMakeLists.txt | 1 + + src/esmumps/CMakeLists.txt | 2 ++ + src/libscotch/CMakeLists.txt | 20 +++++++++++++++++--- + src/libscotchmetis/CMakeLists.txt | 6 ++++++ + src/scotch/CMakeLists.txt | 4 ++-- + 6 files changed, 29 insertions(+), 6 deletions(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 4531d15..f829e15 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -83,4 +83,4 @@ option(INSTALL_METIS_HEADERS "Install libScotchMeTiS headers in destination dire + add_subdirectory(src) + + # Install man pages +-install(DIRECTORY man/man1 DESTINATION man FILES_MATCHING PATTERN "*.1") ++install(DIRECTORY man/man1 DESTINATION man COMPONENT scotch FILES_MATCHING PATTERN "*.1") +diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt +index 3a924e6..253ea15 100644 +--- a/src/CMakeLists.txt ++++ b/src/CMakeLists.txt +@@ -184,4 +184,5 @@ write_basic_package_version_file(SCOTCHConfigVersion.cmake + # Install config files + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/SCOTCHConfig.cmake + ${CMAKE_CURRENT_BINARY_DIR}/SCOTCHConfigVersion.cmake ++ COMPONENT scotch + DESTINATION ${LIBRARY_INSTALL_DIR}/cmake/scotch) +diff --git a/src/esmumps/CMakeLists.txt b/src/esmumps/CMakeLists.txt +index 62114b5..2b78e71 100644 +--- a/src/esmumps/CMakeLists.txt ++++ b/src/esmumps/CMakeLists.txt +@@ -123,11 +123,13 @@ add_dependencies(test_fax scotch_h) + + # libEsMUMPS targets install + install(EXPORT esmumpsTargets ++ COMPONENT libscotch + FILE esmumpsTargets.cmake + NAMESPACE SCOTCH:: + DESTINATION lib/cmake/scotch) + + install(TARGETS esmumps ++ COMPONENT libscotch + EXPORT esmumpsTargets + ARCHIVE DESTINATION lib + LIBRARY DESTINATION lib +@@ -148,11 +150,13 @@ add_dependencies(ptesmumps scotch_h) + + # libptesmumps targets install + install(EXPORT ptesmumpsTargets ++ COMPONENT libptscotch + FILE ptesmumpsTargets.cmake + NAMESPACE SCOTCH:: + DESTINATION lib/cmake/scotch) + + install(TARGETS ptesmumps ++ COMPONENT libptscotch + EXPORT ptesmumpsTargets + ARCHIVE DESTINATION lib + LIBRARY DESTINATION lib + +diff --git a/src/libscotch/CMakeLists.txt b/src/libscotch/CMakeLists.txt +index d1ca5b7..c2e0e3a 100644 +--- a/src/libscotch/CMakeLists.txt ++++ b/src/libscotch/CMakeLists.txt +@@ -785,19 +785,33 @@ if(BUILD_PTSCOTCH) + endif(BUILD_PTSCOTCH) + + set(TARGETS_LIST "scotch;scotcherr;scotcherrexit") +-if(BUILD_PTSCOTCH) +- set(TARGETS_LIST ${TARGETS_LIST} "ptscotch;ptscotcherr;ptscotcherrexit") +-endif(BUILD_PTSCOTCH) + + foreach(_target ${TARGETS_LIST}) + install(EXPORT ${_target}Targets ++ COMPONENT libscotch + FILE ${_target}Targets.cmake + NAMESPACE SCOTCH:: + DESTINATION lib/cmake/scotch) + + install(TARGETS ${_target} ++ COMPONENT libscotch + EXPORT ${_target}Targets + ARCHIVE DESTINATION lib + LIBRARY DESTINATION lib + PUBLIC_HEADER DESTINATION include) ++ ++ if (BUILD_PTSCOTCH) ++ install(EXPORT pt${_target}Targets ++ COMPONENT libptscotch ++ FILE pt${_target}Targets.cmake ++ NAMESPACE SCOTCH:: ++ DESTINATION lib/cmake/scotch) ++ ++ install(TARGETS pt${_target} ++ COMPONENT libptscotch ++ EXPORT pt${_target}Targets ++ ARCHIVE DESTINATION lib ++ LIBRARY DESTINATION lib ++ PUBLIC_HEADER DESTINATION include) ++ endif() + endforeach() +diff --git a/src/libscotchmetis/CMakeLists.txt b/src/libscotchmetis/CMakeLists.txt +index 80cc2ac..981d93a 100644 +--- a/src/libscotchmetis/CMakeLists.txt ++++ b/src/libscotchmetis/CMakeLists.txt +@@ -108,17 +108,20 @@ foreach(version 3 5) + + # libScotchMeTiS targets install + install(EXPORT scotchmetisTargets ++ COMPONENT libscotch + FILE scotchmetisTargets.cmake + NAMESPACE SCOTCH:: + DESTINATION lib/cmake/scotch) + if(INSTALL_METIS_HEADERS) + install(TARGETS scotchmetisv${version} ++ COMPONENT libscotch + EXPORT scotchmetisTargets + ARCHIVE DESTINATION lib + LIBRARY DESTINATION lib + PUBLIC_HEADER DESTINATION include) + else() + install(TARGETS scotchmetisv${version} ++ COMPONENT libscotch + EXPORT scotchmetisTargets + ARCHIVE DESTINATION lib + LIBRARY DESTINATION lib) +@@ -172,18 +175,21 @@ if(BUILD_PTSCOTCH) + + # libPTScotchParMeTiS targets install + install(EXPORT ptscotchparmetisTargets ++ COMPONENT libptscotch + FILE ptscotchparmetisTargets.cmake + NAMESPACE SCOTCH:: + DESTINATION lib/cmake/scotch) + + if(INSTALL_METIS_HEADERS) + install(TARGETS ptscotchparmetisv${version} ++ COMPONENT libptscotch + EXPORT ptscotchparmetisTargets + ARCHIVE DESTINATION lib + LIBRARY DESTINATION lib + PUBLIC_HEADER DESTINATION include) + else() + install(TARGETS ptscotchparmetisv${version} ++ COMPONENT libptscotch + EXPORT ptscotchparmetisTargets + ARCHIVE DESTINATION lib + LIBRARY DESTINATION lib) +diff --git a/src/scotch/CMakeLists.txt b/src/scotch/CMakeLists.txt +index 3974f4f..0c7800d 100644 +--- a/src/scotch/CMakeLists.txt ++++ b/src/scotch/CMakeLists.txt +@@ -118,7 +118,7 @@ target_compile_definitions(gpart PRIVATE SCOTCH_COMPILE_PART) + + # Install all Scotch executables + foreach(target ${scotch_exe}) +- install(TARGETS ${target} RUNTIME DESTINATION bin) ++ install(TARGETS ${target} COMPONENT scotch RUNTIME DESTINATION bin) + endforeach() + + # Executables linked against the libPTScotch library +@@ -165,6 +165,6 @@ if(BUILD_PTSCOTCH) + target_compile_definitions(dgpart PRIVATE SCOTCH_COMPILE_PART) + # Install all PT-Scotch executables + foreach(target ${ptscotch_exe}) +- install(TARGETS ${target} RUNTIME DESTINATION bin) ++ install(TARGETS ${target} COMPONENT ptscotch RUNTIME DESTINATION bin) + endforeach() + endif(BUILD_PTSCOTCH) +-- +2.35.3 + diff --git a/S/SCOTCH/bundled/patches/0003-put-metis-headers-in-include-scotch.patch b/S/SCOTCH/bundled/patches/0003-put-metis-headers-in-include-scotch.patch new file mode 100644 index 00000000000..46fe35f4b0f --- /dev/null +++ b/S/SCOTCH/bundled/patches/0003-put-metis-headers-in-include-scotch.patch @@ -0,0 +1,34 @@ +From 52c739d29ab088604b577ab6377e30d683bda77a Mon Sep 17 00:00:00 2001 +From: Min RK +Date: Fri, 20 May 2022 20:32:45 +0200 +Subject: [PATCH 3/4] put metis headers in include/scotch + +--- + src/libscotchmetis/CMakeLists.txt | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/src/libscotchmetis/CMakeLists.txt b/src/libscotchmetis/CMakeLists.txt +index 981d93a..df0e3b7 100644 +--- a/src/libscotchmetis/CMakeLists.txt ++++ b/src/libscotchmetis/CMakeLists.txt +@@ -118,7 +118,7 @@ foreach(version 3 5) + EXPORT scotchmetisTargets + ARCHIVE DESTINATION lib + LIBRARY DESTINATION lib +- PUBLIC_HEADER DESTINATION include) ++ PUBLIC_HEADER DESTINATION include/scotch) + else() + install(TARGETS scotchmetisv${version} + COMPONENT libscotch +@@ -186,7 +186,7 @@ if(BUILD_PTSCOTCH) + EXPORT ptscotchparmetisTargets + ARCHIVE DESTINATION lib + LIBRARY DESTINATION lib +- PUBLIC_HEADER DESTINATION include) ++ PUBLIC_HEADER DESTINATION include/scotch) + else() + install(TARGETS ptscotchparmetisv${version} + COMPONENT libptscotch +-- +2.35.3 + diff --git a/S/SCOTCH/bundled/patches/0004-fix-language-requirement.patch b/S/SCOTCH/bundled/patches/0004-fix-language-requirement.patch new file mode 100644 index 00000000000..7799dded1a2 --- /dev/null +++ b/S/SCOTCH/bundled/patches/0004-fix-language-requirement.patch @@ -0,0 +1,29 @@ +From 4ab42f5df76192c1137ea91d69ef57ad1ca512ec Mon Sep 17 00:00:00 2001 +From: Min RK +Date: Fri, 20 May 2022 20:41:46 +0200 +Subject: [PATCH 4/4] fix language requirement + +avoids check for c++ compiler +--- + CMakeLists.txt | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index f829e15..2dafd78 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -41,9 +41,9 @@ + ## ## + ############################################################ + +-project(SCOTCH) + cmake_minimum_required(VERSION 3.10) +-enable_language(C Fortran) ++project(SCOTCH LANGUAGES C Fortran) ++ + + # Add module directory + list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules) +-- +2.35.3 + diff --git a/S/SCOTCH/bundled/patches/0005-use-external-dummysizes.patch b/S/SCOTCH/bundled/patches/0005-use-external-dummysizes.patch new file mode 100644 index 00000000000..bf789a09b5f --- /dev/null +++ b/S/SCOTCH/bundled/patches/0005-use-external-dummysizes.patch @@ -0,0 +1,65 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 6b64a15..08cf2f8 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -68,6 +68,9 @@ option(THREADS "Use multi-threading in Scotch and PT-Scotch" ON) + # Use MPI with threads + option(MPI_THREAD_MULTIPLE "Use multi-threading with MPI in PT-Scotch" ON) + ++# Build Dummysizes ++option(BUILD_DUMMYSIZES "Build Dummysizes" ON) ++ + # Build PT-Scotch + option(BUILD_PTSCOTCH "Build PT-Scotch" ON) + +diff --git a/src/libscotch/CMakeLists.txt b/src/libscotch/CMakeLists.txt +index 7e5b479..6285b2f 100644 +--- a/src/libscotch/CMakeLists.txt ++++ b/src/libscotch/CMakeLists.txt +@@ -45,24 +45,32 @@ + ## ## + ############################################################ + ++ + ################ + # dummysizes # + ################ + +-add_executable(dummysizes dummysizes.c) +-set_target_properties(dummysizes PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) +-if(BUILD_PTSCOTCH) +- find_package(MPI COMPONENTS C) +- if(NOT MPI_C_FOUND) +- message(FATAL_ERROR "MPI required to compile PT-Scotch") +- endif() +- add_executable(ptdummysizes dummysizes.c) +- set_target_properties(ptdummysizes PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) +- target_link_libraries(ptdummysizes PRIVATE MPI::MPI_C) +- add_dependencies(ptdummysizes scotch_h) +- set_target_properties(ptdummysizes PROPERTIES +- COMPILE_FLAGS -DSCOTCH_PTSCOTCH) +-endif(BUILD_PTSCOTCH) ++if(BUILD_DUMMYSIZES) ++ add_executable(dummysizes dummysizes.c) ++ set_target_properties(dummysizes PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) ++ if(BUILD_PTSCOTCH) ++ find_package(MPI COMPONENTS C) ++ if(NOT MPI_C_FOUND) ++ message(FATAL_ERROR "MPI required to compile PT-Scotch") ++ endif() ++ add_executable(ptdummysizes dummysizes.c) ++ set_target_properties(ptdummysizes PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) ++ target_link_libraries(ptdummysizes PRIVATE MPI::MPI_C) ++ add_dependencies(ptdummysizes scotch_h) ++ set_target_properties(ptdummysizes PROPERTIES ++ COMPILE_FLAGS -DSCOTCH_PTSCOTCH) ++ endif(BUILD_PTSCOTCH) ++else() ++ add_executable(dummysizes IMPORTED GLOBAL) ++ set_property(TARGET dummysizes PROPERTY IMPORTED_LOCATION "${CMAKE_SOURCE_DIR}/src/dummysizes/build-host/dummysizes") ++ add_executable(ptdummysizes IMPORTED GLOBAL) ++ set_property(TARGET ptdummysizes PROPERTY IMPORTED_LOCATION "${CMAKE_SOURCE_DIR}/src/dummysizes/build-host/ptdummysizes") ++endif(BUILD_DUMMYSIZES) + + ############## + # scotch.h # diff --git a/S/SCOTCH/bundled/patches/0006-fix-ptesmumps.h.patch b/S/SCOTCH/bundled/patches/0006-fix-ptesmumps.h.patch new file mode 100644 index 00000000000..42b2687e814 --- /dev/null +++ b/S/SCOTCH/bundled/patches/0006-fix-ptesmumps.h.patch @@ -0,0 +1,29 @@ +diff --git a/src/esmumps/CMakeLists.txt b/src/esmumps/CMakeLists.txt +index 62114b5..b4de67b 100644 +--- a/src/esmumps/CMakeLists.txt ++++ b/src/esmumps/CMakeLists.txt +@@ -134,9 +134,22 @@ install(TARGETS esmumps + PUBLIC_HEADER DESTINATION include) + + # Dummy PTEsMUMPS library file +-add_library(ptesmumps ${esmumps_src} ${esmumps_headers}) ++# ptesmumps.h ++add_custom_command(OUTPUT ${GENERATED_INCLUDE_DIR}/ptesmumps.h ++ COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/library.h ${GENERATED_INCLUDE_DIR}/ptesmumps.h ++ DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/library.h ++ COMMENT "Copy ptesmumps.h to include directory") ++ ++add_custom_target(ptesmumps_h ++ DEPENDS "${GENERATED_INCLUDE_DIR}/ptesmumps.h") ++ ++set(ptesmumps_headers ${esmumps_headers}) ++list(REMOVE_ITEM ptesmumps_headers "${GENERATED_INCLUDE_DIR}/esmumps.h") ++list(APPEND ptesmumps_headers "${GENERATED_INCLUDE_DIR}/ptesmumps.h") ++ ++add_library(ptesmumps ${esmumps_src} ${ptesmumps_headers}) + +-set_target_properties(ptesmumps PROPERTIES PUBLIC_HEADER "${GENERATED_INCLUDE_DIR}/esmumps.h") ++set_target_properties(ptesmumps PROPERTIES PUBLIC_HEADER "${GENERATED_INCLUDE_DIR}/ptesmumps.h") + + target_include_directories(ptesmumps PRIVATE + $ diff --git a/S/SCOTCH/bundled/patches/0007-fix-empty-union.patch b/S/SCOTCH/bundled/patches/0007-fix-empty-union.patch new file mode 100644 index 00000000000..f64059f2602 --- /dev/null +++ b/S/SCOTCH/bundled/patches/0007-fix-empty-union.patch @@ -0,0 +1,18 @@ +diff --git a/src/libscotch/common_thread.h b/src/libscotch/common_thread.h +index 235d920..ed47fe1 100644 +--- a/src/libscotch/common_thread.h ++++ b/src/libscotch/common_thread.h +@@ -78,11 +78,11 @@ typedef struct ThreadContext_ { + volatile unsigned int bainnum; /*+ Number of barrier instance +*/ + pthread_mutex_t lockdat; /*+ Lock for updating status +*/ + pthread_cond_t conddat; /*+ Wakeup condition for slave threads +*/ +- union { /*+ Context save area for main thread +*/ + #ifdef COMMON_PTHREAD_AFFINITY_LINUX ++ union { /*+ Context save area for main thread +*/ + cpu_set_t cpusdat; /*+ Original thread mask of main thread +*/ +-#endif /* COMMON_PTHREAD_AFFINITY_LINUX */ + } savedat; ++#endif /* COMMON_PTHREAD_AFFINITY_LINUX */ + #endif /* COMMON_PTHREAD */ + } ThreadContext; + diff --git a/S/SCOTCH/bundled/patches/0008-win-fix-ssize_t.patch b/S/SCOTCH/bundled/patches/0008-win-fix-ssize_t.patch new file mode 100644 index 00000000000..d4830c55d3a --- /dev/null +++ b/S/SCOTCH/bundled/patches/0008-win-fix-ssize_t.patch @@ -0,0 +1,30 @@ +diff --git a/src/libscotch/common_file_compress.c b/src/libscotch/common_file_compress.c +index e1ccff5..e8e36ad 100644 +--- a/src/libscotch/common_file_compress.c ++++ b/src/libscotch/common_file_compress.c +@@ -69,6 +69,10 @@ + #include "lzma.h" + #endif /* COMMON_FILE_COMPRESS_LZMA */ + ++#if defined COMMON_OS_WINDOWS ++#define ssize_t SSIZE_T ++#endif ++ + /* + ** The static definitions. + */ +diff --git a/src/libscotch/common_file_decompress.c b/src/libscotch/common_file_decompress.c +index 648b6f0..9188eb0 100644 +--- a/src/libscotch/common_file_decompress.c ++++ b/src/libscotch/common_file_decompress.c +@@ -69,6 +69,10 @@ + #include "lzma.h" + #endif /* COMMON_FILE_COMPRESS_LZMA */ + ++#if defined COMMON_OS_WINDOWS ++#define ssize_t SSIZE_T ++#endif ++ + /* + ** The static definitions. + */ diff --git a/S/SCOTCH/bundled/patches/0009-win-fix-context.c.patch b/S/SCOTCH/bundled/patches/0009-win-fix-context.c.patch new file mode 100644 index 00000000000..2bd32dd83d9 --- /dev/null +++ b/S/SCOTCH/bundled/patches/0009-win-fix-context.c.patch @@ -0,0 +1,24 @@ +diff --git a/src/libscotch/context.c b/src/libscotch/context.c +index 6becac0..aa78fae 100644 +--- a/src/libscotch/context.c ++++ b/src/libscotch/context.c +@@ -70,7 +70,7 @@ static struct ContextValuesData_ { + #else /* ((defined SCOTCH_DETERMINISTIC) || (defined COMMON_RANDOM_FIXED_SEED)) */ + 0 + #endif /* ((defined SCOTCH_DETERMINISTIC) || (defined COMMON_RANDOM_FIXED_SEED)) */ +- }, { } }; ++ } }; + + /***********************************/ + /* */ +@@ -88,7 +88,7 @@ int + contextOptionsInit ( + Context * const contptr) + { +- return (contextValuesInit (contptr, &contextvaluesdat, sizeof (contextvaluesdat), +- CONTEXTOPTIONNUMNBR, (void *) &contextvaluesdat.vinttab - (void *) &contextvaluesdat, +- CONTEXTOPTIONDBLNBR, (void *) &contextvaluesdat.vdbltab - (void *) &contextvaluesdat)); ++ size_t offset = sizeof(contextvaluesdat.vinttab); ++ return contextValuesInit(contptr, &contextvaluesdat, sizeof(contextvaluesdat), CONTEXTOPTIONNUMNBR, ++ offset, CONTEXTOPTIONDBLNBR, offset + sizeof(contextvaluesdat.vinttab)); + } diff --git a/S/SCOTCH/bundled/patches/0011-win-do-not-link-m.patch b/S/SCOTCH/bundled/patches/0011-win-do-not-link-m.patch new file mode 100644 index 00000000000..d4e9c87e1d4 --- /dev/null +++ b/S/SCOTCH/bundled/patches/0011-win-do-not-link-m.patch @@ -0,0 +1,35 @@ +diff --git a/src/libscotch/CMakeLists.txt b/src/libscotch/CMakeLists.txt +index e3b0cb9..480306f 100644 +--- a/src/libscotch/CMakeLists.txt ++++ b/src/libscotch/CMakeLists.txt +@@ -505,10 +511,14 @@ set(SCOTCH_C_SOURCES + + add_library(scotch + ${SCOTCH_C_SOURCES}) ++ + set_target_properties(scotch PROPERTIES VERSION + ${SCOTCH_VERSION}.${SCOTCH_RELEASE}.${SCOTCH_PATCHLEVEL}) + add_dependencies(scotch parser_yy_c parser_ll_c) +-target_link_libraries(scotch PUBLIC m) ++if(NOT WIN32) ++ target_link_libraries(scotch PUBLIC m) ++endif() ++target_link_libraries(scotch PUBLIC scotcherr) + target_include_directories(scotch PUBLIC + $ + $ +diff --git a/src/scotch/CMakeLists.txt b/src/scotch/CMakeLists.txt +index 3974f4f..30143cb 100644 +--- a/src/scotch/CMakeLists.txt ++++ b/src/scotch/CMakeLists.txt +@@ -110,7 +110,9 @@ endforeach() + + # Targets which need special source lists + add_scotch_exe(gout gout_c.c gout_o.c) +-target_link_libraries(gout PRIVATE m) ++if(NOT WIN32) ++ target_link_libraries(gout PRIVATE m) ++endif() + + # gpart is a special target (same source as gmap) + add_scotch_exe(gpart gmap.c gmap.h) diff --git a/S/SCOTCH/bundled/patches/0012-win-fix-threads.patch b/S/SCOTCH/bundled/patches/0012-win-fix-threads.patch new file mode 100644 index 00000000000..4ea23eee83b --- /dev/null +++ b/S/SCOTCH/bundled/patches/0012-win-fix-threads.patch @@ -0,0 +1,44 @@ +diff --git a/src/libscotch/CMakeLists.txt b/src/libscotch/CMakeLists.txt +index e3b0cb9..006be7d 100644 +--- a/src/libscotch/CMakeLists.txt ++++ b/src/libscotch/CMakeLists.txt +@@ -541,7 +549,7 @@ endif() + # Add thread library + if(Threads_FOUND) + target_compile_definitions(scotch PUBLIC COMMON_PTHREAD SCOTCH_PTHREAD) +- target_link_libraries(scotch PUBLIC Threads::Threads) ++ target_link_libraries(scotch PUBLIC Threads::Threads ${THREADS_PTHREADS_WIN32_LIBRARY}) + endif(Threads_FOUND) + + # Include files +@@ -771,7 +779,7 @@ if(BUILD_PTSCOTCH) + + if(Threads_FOUND) + target_compile_definitions(ptscotch PUBLIC SCOTCH_PTHREAD COMMON_PTHREAD) +- target_link_libraries(ptscotch PUBLIC Threads::Threads) ++ target_link_libraries(ptscotch PUBLIC Threads::Threads ${THREADS_PTHREADS_WIN32_LIBRARY}) + endif(Threads_FOUND) + + add_library(ptscotcherr library_error.c) +diff --git a/src/scotch/CMakeLists.txt b/src/scotch/CMakeLists.txt +index 3974f4f..94c0080 100644 +--- a/src/scotch/CMakeLists.txt ++++ b/src/scotch/CMakeLists.txt +@@ -69,7 +69,7 @@ function(add_scotch_exe) + target_compile_definitions(${file_we} PUBLIC "SCOTCH_CODENAME=\"${SCOTCH_CODENAME}\"") + if(Threads_FOUND) + target_compile_definitions(${file_we} PUBLIC SCOTCH_PTHREAD COMMON_PTHREAD) +- target_link_libraries(${file_we} PUBLIC Threads::Threads) ++ target_link_libraries(${file_we} PUBLIC Threads::Threads ${THREADS_PTHREADS_WIN32_LIBRARY}) + endif(Threads_FOUND) + target_link_libraries(${file_we} PUBLIC scotch scotcherrexit) + endfunction(add_scotch_exe) +@@ -144,7 +146,7 @@ if(BUILD_PTSCOTCH) + target_compile_definitions(${file_we} PUBLIC "SCOTCH_CODENAME=\"${SCOTCH_CODENAME}\"") + if(Threads_FOUND) + target_compile_definitions(${file_we} PUBLIC SCOTCH_PTHREAD COMMON_PTHREAD) +- target_link_libraries(${file_we} PUBLIC Threads::Threads) ++ target_link_libraries(${file_we} PUBLIC Threads::Threads ${THREADS_PTHREADS_WIN32_LIBRARY}) + endif(Threads_FOUND) + target_include_directories(${file_we} PRIVATE ${GENERATED_INCLUDE_DIR}) + target_link_libraries(${file_we} PUBLIC scotch ptscotch ptscotcherrexit) diff --git a/S/SCOTCH/bundled/patches/0013-win-fix-graph-match-scan.patch b/S/SCOTCH/bundled/patches/0013-win-fix-graph-match-scan.patch new file mode 100644 index 00000000000..156ea911b51 --- /dev/null +++ b/S/SCOTCH/bundled/patches/0013-win-fix-graph-match-scan.patch @@ -0,0 +1,32 @@ +diff --git a/src/libscotch/graph_match_scan.c b/src/libscotch/graph_match_scan.c +index ec13821..23d20af 100644 +--- a/src/libscotch/graph_match_scan.c ++++ b/src/libscotch/graph_match_scan.c +@@ -173,6 +173,7 @@ GraphCoarsenThread * restrict const thrdptr) + } + + #ifndef GRAPHMATCHSCANSEQ ++#ifndef _WIN32 + if (__sync_lock_test_and_set (&locktax[finevertnum], 1)) /* If could not acquire local vertex (always succeeds for isolated) */ + continue; /* Do not remember it as some other vertex has already acquired both */ + +@@ -184,6 +185,19 @@ GraphCoarsenThread * restrict const thrdptr) + } + finematetax[finevertbst] = finevertnum; /* Match other vertex with us */ + } ++#else /*_WIN32*/ ++ if (_InterlockedExchange(&locktax[finevertnum], 1) != 0) /* If could not acquire local vertex (always succeeds for isolated) */ ++ continue; /* Do not remember it as some other vertex has already acquired both */ ++ ++ if (finevertbst != finevertnum) { /* If we matched with another vertex */ ++ if (_InterlockedExchange(&locktax[finevertbst], 1) != 0) { /* If we could not acquire vertex */ ++ _InterlockedExchange(&locktax[finevertnum], 0); /* Release lock on local vertex */ ++ finequeutab[finequeunew++] = finevertnum; /* Postpone processing to next pass */ ++ continue; ++ } ++ finematetax[finevertbst] = finevertnum; /* Match other vertex with us */ ++ } ++#endif /*_WIN32*/ + #else /* GRAPHMATCHSCANSEQ */ + finematetax[finevertbst] = finevertnum; /* Match other vertex with us */ + #endif /* GRAPHMATCHSCANSEQ */ diff --git a/S/SCOTCH/bundled/patches/0014-win-disable-fortran-test.patch b/S/SCOTCH/bundled/patches/0014-win-disable-fortran-test.patch new file mode 100644 index 00000000000..982ee777d7e --- /dev/null +++ b/S/SCOTCH/bundled/patches/0014-win-disable-fortran-test.patch @@ -0,0 +1,13 @@ +diff --git a/src/check/CMakeLists.txt b/src/check/CMakeLists.txt +index 3f67aac..d45f685 100644 +--- a/src/check/CMakeLists.txt ++++ b/src/check/CMakeLists.txt +@@ -130,7 +130,7 @@ if(BUILD_LIBSCOTCHMETIS) + target_include_directories(test_libmetis_dualv${version} PRIVATE ${GENERATED_INCLUDE_DIR}) + target_link_libraries(test_libmetis_dualv${version} scotchmetisv${version} scotch scotcherr) + add_test(NAME test_libmetis_dualv${version} COMMAND test_libmetis_dualv${version}) +- if(${CMAKE_Fortran_COMPILER_SUPPORTS_F90}) # Safeguard to avoid x77 compilers ++ if(${CMAKE_Fortran_COMPILER_SUPPORTS_F90} AND NOT WIN32) # Safeguard to avoid x77 compilers + add_executable(test_libmetis_dual_f_v${version} test_libmetis_dual_f.f90) + target_compile_definitions(test_libmetis_dual_f_v${version} PRIVATE SCOTCH_METIS_VERSION=${version}) + target_include_directories(test_libmetis_dual_f_v${version} PRIVATE ${GENERATED_INCLUDE_DIR}) diff --git a/S/SCOTCH/bundled/patches/0015-win-fix-unistd-time-include.patch b/S/SCOTCH/bundled/patches/0015-win-fix-unistd-time-include.patch new file mode 100644 index 00000000000..91fa2d0da2d --- /dev/null +++ b/S/SCOTCH/bundled/patches/0015-win-fix-unistd-time-include.patch @@ -0,0 +1,193 @@ +diff --git a/src/scotch/dgmap.c b/src/scotch/dgmap.c +index 572d936..21a20e8 100644 +--- a/src/scotch/dgmap.c ++++ b/src/scotch/dgmap.c +@@ -56,7 +56,9 @@ + + #define SCOTCH_PTSCOTCH + ++#if ((defined COMMON_TIMING_OLD) || (defined HAVE_SYS_TIME_H)) + #include ++#endif /* ((defined COMMON_TIMING_OLD) || (defined HAVE_SYS_TIME_H)) */ + + #include "module.h" + #include "common.h" +diff --git a/src/scotch/dgord.c b/src/scotch/dgord.c +index 5a8b464..f1232b7 100644 +--- a/src/scotch/dgord.c ++++ b/src/scotch/dgord.c +@@ -57,7 +57,9 @@ + + #define SCOTCH_PTSCOTCH + ++#if ((defined COMMON_TIMING_OLD) || (defined HAVE_SYS_TIME_H)) + #include ++#endif /* ((defined COMMON_TIMING_OLD) || (defined HAVE_SYS_TIME_H)) */ + + #include "module.h" + #include "common.h" +diff --git a/src/check/test_common_file_compress.c b/src/check/test_common_file_compress.c +index 1e67f37..0e9f411 100644 +--- a/src/check/test_common_file_compress.c ++++ b/src/check/test_common_file_compress.c +@@ -57,7 +57,9 @@ + #include + #include + #include ++#if ((! defined COMMON_OS_WINDOWS) && (! defined HAVE_NOT_UNISTD_H)) + #include ++#endif /* ((! defined COMMON_OS_WINDOWS) && (! defined HAVE_NOT_UNISTD_H)) */ + + #include "../libscotch/module.h" + #include "../libscotch/common.h" +diff --git a/src/check/test_common_random.c b/src/check/test_common_random.c +index f03f496..a6ddf15 100644 +--- a/src/check/test_common_random.c ++++ b/src/check/test_common_random.c +@@ -59,7 +59,9 @@ + #include + #include + #include ++#if ((! defined COMMON_OS_WINDOWS) && (! defined HAVE_NOT_UNISTD_H)) + #include ++#endif /* ((! defined COMMON_OS_WINDOWS) && (! defined HAVE_NOT_UNISTD_H)) */ + + #include "../libscotch/module.h" + #include "../libscotch/common.h" +@@ -141,8 +143,11 @@ char * argv[]) + SCOTCH_errorPrint ("Could not save random state"); + break; + } +- ++#ifndef _WIN32 + sleep (2); /* Next run will not get the same time() value */ ++#else ++ Sleep (2000); ++#endif + } + else { /* Second pass */ + char * charptr; + +diff --git a/src/check/test_fibo.c b/src/check/test_fibo.c +index b301c2d..f6459b8 100644 +--- a/src/check/test_fibo.c ++++ b/src/check/test_fibo.c +@@ -59,7 +59,9 @@ + #include + #include + #include ++#if ((! defined COMMON_OS_WINDOWS) && (! defined HAVE_NOT_UNISTD_H)) + #include ++#endif /* ((! defined COMMON_OS_WINDOWS) && (! defined HAVE_NOT_UNISTD_H)) */ + + #include "../libscotch/module.h" + #include "../libscotch/common.h" +diff --git a/src/check/test_scotch_dgraph_band.c b/src/check/test_scotch_dgraph_band.c +index 639188e..942b87a 100644 +--- a/src/check/test_scotch_dgraph_band.c ++++ b/src/check/test_scotch_dgraph_band.c +@@ -55,10 +55,14 @@ + #include + #endif /* (((defined __STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || (defined HAVE_STDINT_H)) */ + #include ++#if ((defined COMMON_TIMING_OLD) || (defined HAVE_SYS_TIME_H)) + #include ++#endif /* ((defined COMMON_TIMING_OLD) || (defined HAVE_SYS_TIME_H)) */ + #include + #include ++#if ((! defined COMMON_OS_WINDOWS) && (! defined HAVE_NOT_UNISTD_H)) + #include ++#endif /* ((! defined COMMON_OS_WINDOWS) && (! defined HAVE_NOT_UNISTD_H)) */ + + #include "ptscotch.h" + +diff --git a/src/check/test_scotch_dgraph_check.c b/src/check/test_scotch_dgraph_check.c +index dcc7acb..04ea117 100644 +--- a/src/check/test_scotch_dgraph_check.c ++++ b/src/check/test_scotch_dgraph_check.c +@@ -55,10 +55,14 @@ + #include + #endif /* (((defined __STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || (defined HAVE_STDINT_H)) */ + #include ++#if ((defined COMMON_TIMING_OLD) || (defined HAVE_SYS_TIME_H)) + #include ++#endif /* ((defined COMMON_TIMING_OLD) || (defined HAVE_SYS_TIME_H)) */ + #include + #include ++#if ((! defined COMMON_OS_WINDOWS) && (! defined HAVE_NOT_UNISTD_H)) + #include ++#endif /* ((! defined COMMON_OS_WINDOWS) && (! defined HAVE_NOT_UNISTD_H)) */ + + #include "ptscotch.h" + +diff --git a/src/check/test_scotch_dgraph_coarsen.c b/src/check/test_scotch_dgraph_coarsen.c +index 85c816e..4fa9aea 100644 +--- a/src/check/test_scotch_dgraph_coarsen.c ++++ b/src/check/test_scotch_dgraph_coarsen.c +@@ -55,10 +55,14 @@ + #include + #endif /* (((defined __STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || (defined HAVE_STDINT_H)) */ + #include ++#if ((defined COMMON_TIMING_OLD) || (defined HAVE_SYS_TIME_H)) + #include ++#endif /* ((defined COMMON_TIMING_OLD) || (defined HAVE_SYS_TIME_H)) */ + #include + #include ++#if ((! defined COMMON_OS_WINDOWS) && (! defined HAVE_NOT_UNISTD_H)) + #include ++#endif /* ((! defined COMMON_OS_WINDOWS) && (! defined HAVE_NOT_UNISTD_H)) */ + + #include "ptscotch.h" + +diff --git a/src/check/test_scotch_dgraph_grow.c b/src/check/test_scotch_dgraph_grow.c +index 50d0a9c..e61eb2f 100644 +--- a/src/check/test_scotch_dgraph_grow.c ++++ b/src/check/test_scotch_dgraph_grow.c +@@ -58,10 +58,14 @@ + #endif /* (((defined __STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || (defined HAVE_STDINT_H)) */ + #include + #include ++#if ((defined COMMON_TIMING_OLD) || (defined HAVE_SYS_TIME_H)) + #include ++#endif /* ((defined COMMON_TIMING_OLD) || (defined HAVE_SYS_TIME_H)) */ + #include + #include ++#if ((! defined COMMON_OS_WINDOWS) && (! defined HAVE_NOT_UNISTD_H)) + #include ++#endif /* ((! defined COMMON_OS_WINDOWS) && (! defined HAVE_NOT_UNISTD_H)) */ + + #include "scotch.h" + #include "ptscotch.h" +diff --git a/src/check/test_scotch_dgraph_induce.c b/src/check/test_scotch_dgraph_induce.c +index fc1757a..308fe69 100644 +--- a/src/check/test_scotch_dgraph_induce.c ++++ b/src/check/test_scotch_dgraph_induce.c +@@ -57,7 +57,9 @@ + #endif /* (((defined __STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || (defined HAVE_STDINT_H)) */ + #include + #include ++#if ((! defined COMMON_OS_WINDOWS) && (! defined HAVE_NOT_UNISTD_H)) + #include ++#endif /* ((! defined COMMON_OS_WINDOWS) && (! defined HAVE_NOT_UNISTD_H)) */ + + #include "scotch.h" + #include "ptscotch.h" +diff --git a/src/check/test_scotch_dgraph_redist.c b/src/check/test_scotch_dgraph_redist.c +index 7758f91..b5a5d7c 100644 +--- a/src/check/test_scotch_dgraph_redist.c ++++ b/src/check/test_scotch_dgraph_redist.c +@@ -53,10 +53,14 @@ + #include + #endif /* (((defined __STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || (defined HAVE_STDINT_H)) */ + #include ++#if ((defined COMMON_TIMING_OLD) || (defined HAVE_SYS_TIME_H)) + #include ++#endif /* ((defined COMMON_TIMING_OLD) || (defined HAVE_SYS_TIME_H)) */ + #include + #include ++#if ((! defined COMMON_OS_WINDOWS) && (! defined HAVE_NOT_UNISTD_H)) + #include ++#endif /* ((! defined COMMON_OS_WINDOWS) && (! defined HAVE_NOT_UNISTD_H)) */ + + #include "ptscotch.h" + diff --git a/S/SCOTCH/bundled/patches/CMakeLists-dummysizes.txt b/S/SCOTCH/bundled/patches/CMakeLists-dummysizes.txt new file mode 100644 index 00000000000..78d3d37a68c --- /dev/null +++ b/S/SCOTCH/bundled/patches/CMakeLists-dummysizes.txt @@ -0,0 +1,34 @@ +cmake_minimum_required(VERSION 3.10) +project(dummysizes LANGUAGES C) + +set(GENERATED_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR}/include) +file(MAKE_DIRECTORY ${GENERATED_INCLUDE_DIR}) + +option(BUILD_PTSCOTCH "Build PT-Scotch" ON) + +add_executable(dummysizes ../libscotch/dummysizes.c) +set_target_properties(dummysizes PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) +if(BUILD_PTSCOTCH) + find_package(MPI COMPONENTS C) + if(NOT MPI_C_FOUND) + message(FATAL_ERROR "MPI required to compile PT-Scotch") + endif() + add_executable(ptdummysizes ../libscotch/dummysizes.c) + set_target_properties(ptdummysizes PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + target_link_libraries(ptdummysizes PRIVATE MPI::MPI_C) + add_dependencies(ptdummysizes scotch_h) + set_target_properties(ptdummysizes PROPERTIES + COMPILE_FLAGS -DSCOTCH_PTSCOTCH) +endif(BUILD_PTSCOTCH) + +############## +# scotch.h # +############## + +# Generate scotch.h +add_custom_command(OUTPUT ${GENERATED_INCLUDE_DIR}/scotch.h + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/../libscotch/library.h ${CMAKE_CURRENT_BINARY_DIR} + COMMAND $ ${CMAKE_CURRENT_BINARY_DIR}/library.h ${GENERATED_INCLUDE_DIR}/scotch.h DEPENDS dummysizes + COMMENT "Generate scotch.h") +add_custom_target(scotch_h + DEPENDS "${GENERATED_INCLUDE_DIR}/scotch.h") diff --git a/S/SCOTCH/bundled/patches/Makefile.patch b/S/SCOTCH/bundled/patches/Makefile.patch deleted file mode 100644 index d2e25ad89c8..00000000000 --- a/S/SCOTCH/bundled/patches/Makefile.patch +++ /dev/null @@ -1,24 +0,0 @@ ---- /dev/null -+++ b/src/Makefile.inc -@@ -0,0 +1,21 @@ -+EXE = -+LIB = .$(dlext) -+OBJ = .o -+ -+MAKE = make -+AR = $(CC) -+ARFLAGS = -shared -o -+CAT = cat -+CCS = $(CC) -+CCP = mpicc -+CCD = $(CC) -+CFLAGS = -O3 -fPIC -Drestrict=__restrict -DCOMMON_PTHREAD_BARRIER -DCOMMON_PTHREAD -DSCOTCH_CHECK_AUTO -DCOMMON_RANDOM_FIXED_SEED -DCOMMON_TIMING_OLD -DSCOTCH_RENAME -DCOMMON_FILE_COMPRESS_GZ -DIDXSIZE64 -+CLIBFLAGS = -shared -fPIC -+LDFLAGS = -lz -lm -pthread -+CP = cp -+LEX = flex -Pscotchyy -olex.yy.c -+LN = ln -+MKDIR = mkdir -p -+MV = mv -+RANLIB = echo -+YACC = bison -pscotchyy -y -b y diff --git a/S/SCOTCH/bundled/patches/OSX_FreeBSD.patch b/S/SCOTCH/bundled/patches/OSX_FreeBSD.patch deleted file mode 100644 index 277a46daad2..00000000000 --- a/S/SCOTCH/bundled/patches/OSX_FreeBSD.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/src/Makefile.inc -+++ b/src/Makefile.inc -@@ -4,7 +4,7 @@ - - MAKE = make - AR = $(CC) --ARFLAGS = -shared -o -+ARFLAGS = -shared -o -dynamic -undefined dynamic_lookup -o - CAT = cat - CCS = $(CC) - CCP = mpicc diff --git a/S/SCOTCH/bundled/patches/Windows.patch b/S/SCOTCH/bundled/patches/Windows.patch deleted file mode 100644 index 8f9496abd60..00000000000 --- a/S/SCOTCH/bundled/patches/Windows.patch +++ /dev/null @@ -1,14 +0,0 @@ ---- a/src/Makefile.inc -+++ b/src/Makefile.inc -@@ -9,9 +9,9 @@ - CCS = $(CC) - CCP = mpicc - CCD = $(CC) --CFLAGS = -O3 -fPIC -Drestrict=__restrict -DCOMMON_PTHREAD_BARRIER -DCOMMON_PTHREAD -DSCOTCH_CHECK_AUTO -DCOMMON_RANDOM_FIXED_SEED -DCOMMON_TIMING_OLD -DSCOTCH_RENAME -DCOMMON_FILE_COMPRESS_GZ -DIDXSIZE64 -+CFLAGS = -O3 -fPIC -DCOMMON_RANDOM_FIXED_SEED -DSCOTCH_RENAME -DCOMMON_STUB_FORK -DCOMMON_WINDOWS -DIDXSIZE64 - CLIBFLAGS = -shared -fPIC --LDFLAGS = -lz -lm -pthread -+LDFLAGS = -lz -lm - CP = cp - LEX = flex -Pscotchyy -olex.yy.c - LN = ln diff --git a/S/SCOTCH/bundled/patches/native_build.patch b/S/SCOTCH/bundled/patches/native_build.patch deleted file mode 100644 index fbff0647961..00000000000 --- a/S/SCOTCH/bundled/patches/native_build.patch +++ /dev/null @@ -1,19 +0,0 @@ ---- a/src/libscotch/Makefile -+++ b/src/libscotch/Makefile -@@ -3096,14 +3096,14 @@ - mapping.h \ - order.h \ - parser.h -- $(CCD) $(CCDFLAGS) -DSCOTCH_VERSION_NUM=$(VERSION) -DSCOTCH_RELEASE_NUM=$(RELEASE) -DSCOTCH_PATCHLEVEL_NUM=$(PATCHLEVEL) $(<) -o $(@) $(LDFLAGS) -+ $(CC_BUILD) -DSCOTCH_VERSION_NUM=$(VERSION) -DSCOTCH_RELEASE_NUM=$(RELEASE) -DSCOTCH_PATCHLEVEL_NUM=$(PATCHLEVEL) $(<) -o $(@) $(LDFLAGS) - - ptdummysizes$(EXE) : dummysizes.c \ - module.h \ - common.h \ - dgraph.h \ - dorder.h -- $(CCD) $(CCDFLAGS) -DSCOTCH_VERSION_NUM=$(VERSION) -DSCOTCH_RELEASE_NUM=$(RELEASE) -DSCOTCH_PATCHLEVEL_NUM=$(PATCHLEVEL) $(<) -o $(@) $(LDFLAGS) -+ $(CC_BUILD) -DSCOTCH_VERSION_NUM=$(VERSION) -DSCOTCH_RELEASE_NUM=$(RELEASE) -DSCOTCH_PATCHLEVEL_NUM=$(PATCHLEVEL) $(<) -o $(@) $(LDFLAGS) - - scotch.h : dummysizes$(EXE) \ - library.h diff --git a/S/SCS_GPU/build_tarballs.jl b/S/SCS_GPU/build_tarballs.jl index 62fbd2c26e3..ce5ec6b5fbc 100644 --- a/S/SCS_GPU/build_tarballs.jl +++ b/S/SCS_GPU/build_tarballs.jl @@ -6,7 +6,7 @@ version = v"3.2.3" # Collection of sources required to build SCSBuilder sources = [ - GitSource("https://github.com/cvxgrp/scs.git", "f0c23340da03bcd663072dc4a90cf1aab8968c61") + GitSource("https://github.com/cvxgrp/scs.git", "f5f054be7dd71ee0d80c4c0eec0df1e9f0ccb123") ] # Bash recipe for building across all platforms diff --git a/S/Singular/build_tarballs.jl b/S/Singular/build_tarballs.jl index ad5b4711572..4c780b200f1 100644 --- a/S/Singular/build_tarballs.jl +++ b/S/Singular/build_tarballs.jl @@ -27,15 +27,15 @@ import Pkg.Types: VersionSpec # to all components. # name = "Singular" -upstream_version = v"4.3.2-0" # 4.3.2p1 plus some changes -version_offset = v"0.1.0" +upstream_version = v"4.3.2-0" # 4.3.2p1 plus depth patches +version_offset = v"0.1.1" version = VersionNumber(upstream_version.major * 100 + upstream_version.minor + version_offset.major, upstream_version.patch * 100 + version_offset.minor, Int(upstream_version.prerelease[1]) * 100 + version_offset.patch) # Collection of sources required to build normaliz sources = [ - GitSource("https://github.com/Singular/Singular.git", "a800fe4b3e9d37a38c5a10cc0ae9dfa0c15a4ee6"), + GitSource("https://github.com/Singular/Singular.git", "66f5ae358a7571a5c19042637b640c51c8e19176"), #ArchiveSource("https://www.mathematik.uni-kl.de/ftp/pub/Math/Singular/SOURCES/$(upstream_version.major)-$(upstream_version.minor)-$(upstream_version.patch)/singular-$(upstream_version).tar.gz", # "5b0f6c036b4a6f58bf620204b004ec6ca3a5007acc8352fec55eade2fc9d63f6"), #DirectorySource("./bundled") diff --git a/T/TracyProfiler/build_tarballs.jl b/T/TracyProfiler/build_tarballs.jl index e7f5ea90b4e..f2b37c56ed1 100644 --- a/T/TracyProfiler/build_tarballs.jl +++ b/T/TracyProfiler/build_tarballs.jl @@ -3,96 +3,96 @@ using BinaryBuilder, Pkg name = "TracyProfiler" -version = v"0.7.8" +version = v"0.9.1" + +# Collection of sources required to complete build sources = [ - ArchiveSource("https://github.com/wolfpld/tracy/archive/refs/tags/v$(version).tar.gz", - "4021940a2620570ac767eee84e58d572a3faf1570edfaf5309c609752146e950"), - ArchiveSource("https://github.com/phracker/MacOSX-SDKs/releases/download/10.15/MacOSX10.15.sdk.tar.xz", - "2408d07df7f324d3beea818585a6d990ba99587c218a3969f924dfcc4de93b62"), - DirectorySource("./bundled") + GitSource("https://github.com/wolfpld/tracy.git", + "897aec5b062664d2485f4f9a213715d2e527e0ca"), # v0.9.1 + ArchiveSource("https://github.com/phracker/MacOSX-SDKs/releases/download/11.3/MacOSX11.0.sdk.tar.xz", + "d3feee3ef9c6016b526e1901013f264467bb927865a03422a9cb925991cc9783"), + DirectorySource("./bundled"), ] script = raw""" mkdir -vp $bindir -mkdir -vp $libdir - -cd ${WORKSPACE}/srcdir/tracy* -# Apply patches to disable forcing -march -atomic_patch -p1 ../patches/unix_library_release.patch -atomic_patch -p1 ../patches/unix_common_make.patch -atomic_patch -p1 ../patches/library_extension.patch +cd $WORKSPACE/srcdir/tracy*/ + +export TRACY_NO_ISA_EXTENSIONS=1 +export DEFINES="-D__STDC_FORMAT_MACROS -DNO_PARALLEL_SORT" +if [[ "${target}" == *-mingw* ]]; then + export TRACY_NO_LTO=1 + export DEFINES="-DWINVER=0x0601 -D_WIN32_WINNT=0x0601 -DNO_PARALLEL_SORT" + atomic_patch -p1 ../patches/TracyProfiler-mingw32-win.patch +elif [[ "${target}" == *-apple-darwin* ]]; then + export TRACY_NO_LTO=1 + export MACOSX_DEPLOYMENT_TARGET=11.0 +fi -# Need full c++17 support so upgrade min osx version and install newer SDK if [[ "${target}" == x86_64-apple-darwin* ]]; then - echo "Installing newer MacOS 10.15 SDK" + echo "Installing newer MacOS 11.0 SDK" - pushd $WORKSPACE/srcdir/MacOSX10.*.sdk + pushd $WORKSPACE/srcdir/MacOSX11.*.sdk rm -rf /opt/${target}/${target}/sys-root/System + rm -rf /opt/${target}/${target}/sys-root/usr/include/libxml2/libxml cp -ra usr/* "/opt/${target}/${target}/sys-root/usr/." cp -ra System "/opt/${target}/${target}/sys-root/." popd - - # append flag to mkfile for macos target min version - echo "CFLAGS += -mmacosx-version-min=10.15" >> common/unix-release.mk - # Disable link-time optimization, we have some mess in our macOS toolchain. - sed -i 's/ -flto//' {profiler,update,capture,csvexport,import-chrome}/build/unix/release.mk fi -# Build / install the library -make -j${nproc} -C library/unix release -cp -v "./library/unix/libtracy-release.${dlext}" ${libdir} +atomic_patch -p1 ../patches/TracyProfiler-nfd-extended-1.0.2.patch # Build / install the profiler GUI -make -j${nproc} -C profiler/build/unix release -cp -v ./profiler/build/unix/Tracy-release* $bindir +make -e -j${nproc} -C profiler/build/unix LEGACY=1 IMAGE=tracy release +cp -v ./profiler/build/unix/tracy* $bindir -# Build / install update utility -make -j${nproc} -C update/build/unix release -cp -v ./update/build/unix/update-release* $bindir +# Build / install the update utility +make -e -j${nproc} -C update/build/unix IMAGE=tracy-update release +cp -v ./update/build/unix/tracy* $bindir -# Build / install capture utility -make -j${nproc} -C capture/build/unix release -cp -v ./capture/build/unix/capture-release* $bindir +# Build / install the capture utility +make -e -j${nproc} -C capture/build/unix IMAGE=tracy-capture release +cp -v ./capture/build/unix/tracy* $bindir -# Build / install csvexport utility -make -j${nproc} -C csvexport/build/unix release -cp -v ./csvexport/build/unix/csvexport-release* $bindir +# Build / install the csvexport utility +make -e -j${nproc} -C csvexport/build/unix IMAGE=tracy-csvexport release +cp -v ./csvexport/build/unix/tracy* $bindir -# Build / install import-chrome utility -make -j${nproc} -C import-chrome/build/unix release -cp -v ./import-chrome/build/unix/import-chrome-release* $bindir +# Build / install the import-chrome utility +make -e -j${nproc} -C import-chrome/build/unix IMAGE=tracy-import-chrome release +cp -v ./import-chrome/build/unix/tracy* $bindir install_license LICENSE """ -# Only supports x86_64 builds for Linux / Unix -platforms = [ - Platform("x86_64", "linux"; libc="glibc"), - Platform("x86_64", "macos"), -] -platforms = expand_cxxstring_abis(platforms) - -products = Product[ - LibraryProduct("libtracy-release", :libtracy), - ExecutableProduct("Tracy-release", :tracy_profiler_exe), - ExecutableProduct("update-release", :tracy_update_exe), - ExecutableProduct("capture-release", :tracy_capture_exe), - ExecutableProduct("csvexport-release", :tracy_csvexport_exe), - ExecutableProduct("import-chrome-release", :tracy_import_chrome_exe), +platforms = expand_cxxstring_abis(supported_platforms(; exclude=[ + Platform("armv6l", "linux"), + Platform("armv6l", "linux"; libc=:musl), + Platform("armv7l", "linux"), + Platform("armv7l", "linux"; libc=:musl), + Platform("x86_64", "freebsd"), +])) + +products = [ + ExecutableProduct("tracy", :tracy), + ExecutableProduct("tracy-capture", :capture), + ExecutableProduct("tracy-csvexport", :csvexport), + ExecutableProduct("tracy-update", :update), + ExecutableProduct("tracy-import-chrome", :import_chrome), ] +x11_platforms = filter(p ->Sys.islinux(p) || Sys.isfreebsd(p), platforms) + dependencies = [ - Dependency("GLFW_jll"), - Dependency("FreeType2_jll"), Dependency("Capstone_jll"), - # GTK3 is only needed for the system file dialog on Linux - Dependency("GTK3_jll", platforms=filter(Sys.islinux, platforms)), - BuildDependency("Xorg_xorgproto_jll"), + Dependency("FreeType2_jll"), + Dependency("Dbus_jll", platforms=filter(Sys.islinux, platforms)), + Dependency("GLFW_jll"), + # Needed for `pkg-config glfw3` + Dependency("Xorg_xproto_jll", platforms=x11_platforms), + Dependency("Xorg_kbproto_jll", platforms=x11_platforms), ] # requires std-c++17, full support in gcc 7+, clang 8+ -build_tarballs(ARGS, name, version, sources, script, platforms, products, dependencies; - julia_compat="1.6", - preferred_gcc_version=v"8", -) +build_tarballs(ARGS, name, version, sources, script, platforms, products, dependencies; julia_compat="1.6", preferred_gcc_version=v"8") diff --git a/T/TracyProfiler/bundled/patches/TracyProfiler-mingw32-win.patch b/T/TracyProfiler/bundled/patches/TracyProfiler-mingw32-win.patch new file mode 100644 index 00000000000..b35cfd512ff --- /dev/null +++ b/T/TracyProfiler/bundled/patches/TracyProfiler-mingw32-win.patch @@ -0,0 +1,103 @@ +diff --git a/common/unix.mk b/common/unix.mk +index f836bdfc..136c7382 100644 +--- a/common/unix.mk ++++ b/common/unix.mk +@@ -16,6 +16,11 @@ else ifeq (0,$(shell ld -ltbb -o /dev/null 2>/dev/null; echo $$?)) + endif + endif + ++UNAME_OS := $(shell uname -o) ++ifeq ($(UNAME_OS),Cygwin) ++ LIBS += -lole32 -lws2_32 -luuid ++endif ++ + OBJDIRBASE := obj/$(BUILD) + OBJDIR := $(OBJDIRBASE)/o/o/o + +diff --git a/profiler/build/unix/legacy.mk b/profiler/build/unix/legacy.mk +index 24765f1a..aed688e5 100644 +--- a/profiler/build/unix/legacy.mk ++++ b/profiler/build/unix/legacy.mk +@@ -2,30 +2,41 @@ CFLAGS += + CXXFLAGS := $(CFLAGS) -std=c++17 + DEFINES += -DIMGUI_ENABLE_FREETYPE + INCLUDES := $(shell pkg-config --cflags glfw3 freetype2 capstone) -I../../../imgui +-LIBS := $(shell pkg-config --libs glfw3 freetype2 capstone) -lpthread -ldl ++LIBS := $(shell pkg-config --libs freetype2 capstone) -lglfw3dll -lpthread + + PROJECT := Tracy + IMAGE := $(PROJECT)-$(BUILD) + +-FILTER := ../../../nfd/nfd_win.cpp ++UNAME_OS := $(shell uname -o) ++ ++ifeq ($(UNAME_OS),Cygwin) ++ CXXFLAGS += -Wa,-mbig-obj ++ FILTER := ++else ++ FILTER := ../../../nfd/nfd_win.cpp ++ LIBS += -ldl ++endif ++ + include ../../../common/src-from-vcxproj.mk + + ifdef TRACY_NO_FILESELECTOR + CXXFLAGS += -DTRACY_NO_FILESELECTOR + else + UNAME := $(shell uname -s) +- ifeq ($(UNAME),Darwin) +- SRC3 += ../../../nfd/nfd_cocoa.m +- LIBS += -framework CoreFoundation -framework AppKit -framework UniformTypeIdentifiers +- else +- ifdef TRACY_GTK_FILESELECTOR +- SRC += ../../../nfd/nfd_gtk.cpp +- INCLUDES += $(shell pkg-config --cflags gtk+-3.0) +- LIBS += $(shell pkg-config --libs gtk+-3.0) ++ ifneq ($(UNAME_OS),Cygwin) ++ ifeq ($(UNAME),Darwin) ++ SRC3 += ../../../nfd/nfd_cocoa.m ++ LIBS += -framework CoreFoundation -framework AppKit -framework UniformTypeIdentifiers + else +- SRC += ../../../nfd/nfd_portal.cpp +- INCLUDES += $(shell pkg-config --cflags dbus-1) +- LIBS += $(shell pkg-config --libs dbus-1) ++ ifdef TRACY_GTK_FILESELECTOR ++ SRC += ../../../nfd/nfd_gtk.cpp ++ INCLUDES += $(shell pkg-config --cflags gtk+-3.0) ++ LIBS += $(shell pkg-config --libs gtk+-3.0) ++ else ++ SRC += ../../../nfd/nfd_portal.cpp ++ INCLUDES += $(shell pkg-config --cflags dbus-1) ++ LIBS += $(shell pkg-config --libs dbus-1) ++ endif + endif + endif + endif +diff --git a/server/TracyPopcnt.hpp b/server/TracyPopcnt.hpp +index 945324fd..07b98fd8 100644 +--- a/server/TracyPopcnt.hpp ++++ b/server/TracyPopcnt.hpp +@@ -4,11 +4,7 @@ + #include + #include + +-#if defined _WIN64 +-# include +-# define TracyCountBits __popcnt64 +-# define TracyLzcnt __lzcnt64 +-#elif defined __GNUC__ || defined __clang__ ++#if defined __GNUC__ || defined __clang__ + static inline uint64_t TracyCountBits( uint64_t i ) + { + return uint64_t( __builtin_popcountll( i ) ); +@@ -17,6 +13,10 @@ static inline uint64_t TracyLzcnt( uint64_t i ) + { + return uint64_t( __builtin_clzll( i ) ); + } ++#elif defined _WIN64 ++# include ++# define TracyCountBits __popcnt64 ++# define TracyLzcnt __lzcnt64 + #else + static inline uint64_t TracyCountBits( uint64_t i ) + { diff --git a/T/TracyProfiler/bundled/patches/TracyProfiler-nfd-extended-1.0.2.patch b/T/TracyProfiler/bundled/patches/TracyProfiler-nfd-extended-1.0.2.patch new file mode 100644 index 00000000000..717c3c0250e --- /dev/null +++ b/T/TracyProfiler/bundled/patches/TracyProfiler-nfd-extended-1.0.2.patch @@ -0,0 +1,1987 @@ +commit eb8f485f99f1ca23187edc72db7fe0ed54d12583 +Author: Bartosz Taudul +Date: Wed Apr 5 17:19:23 2023 +0200 + + Update nfd-extended to 1.0.2. + +diff --git a/nfd/nfd_cocoa.m b/nfd/nfd_cocoa.m +index f7024356..aeffb1c4 100644 +--- a/nfd/nfd_cocoa.m ++++ b/nfd/nfd_cocoa.m +@@ -180,6 +180,10 @@ const char* NFD_GetError(void) { + return g_errorstr; + } + ++void NFD_ClearError(void) { ++ NFDi_SetError(NULL); ++} ++ + void NFD_FreePathN(nfdnchar_t* filePath) { + NFDi_Free((void*)filePath); + } +diff --git a/nfd/nfd_portal.cpp b/nfd/nfd_portal.cpp +index 8ef9158f..f37e0916 100644 +--- a/nfd/nfd_portal.cpp ++++ b/nfd/nfd_portal.cpp +@@ -14,8 +14,16 @@ + #include + #include + #include +-#include // for the random token string +-#include // for access() ++#include // for access() ++ ++#if !defined(__has_include) || !defined(__linux__) ++#include // for getrandom() - the random token string ++#elif __has_include() ++#include ++#else // for GLIBC < 2.25 ++#include ++#define getrandom(buf, sz, flags) syscall(SYS_getrandom, buf, sz, flags) ++#endif + + #include "nfd.h" + +diff --git a/nfd/nfd_win.cpp b/nfd/nfd_win.cpp +index 991e5071..772dfb27 100644 +--- a/nfd/nfd_win.cpp ++++ b/nfd/nfd_win.cpp +@@ -1,969 +1,969 @@ +-/* +- Native File Dialog Extended +- Repository: https://github.com/btzy/nativefiledialog-extended +- License: Zlib +- Author: Bernard Teo +- */ +- +-/* only locally define UNICODE in this compilation unit */ +-#ifndef UNICODE +-#define UNICODE +-#endif +- +-#ifdef __MINGW32__ +-// Explicitly setting NTDDI version, this is necessary for the MinGW compiler +-#define NTDDI_VERSION NTDDI_VISTA +-#define _WIN32_WINNT _WIN32_WINNT_VISTA +-#endif +- +-#if _MSC_VER +-// see +-// https://developercommunity.visualstudio.com/content/problem/185399/error-c2760-in-combaseapih-with-windows-sdk-81-and.html +-struct IUnknown; // Workaround for "combaseapi.h(229): error C2187: syntax error: 'identifier' was +- // unexpected here" when using /permissive- +-#endif +- +-#include +-#include +-#include +-#include +-#include +-#include "nfd.h" +- +-namespace { +- +-/* current error */ +-const char* g_errorstr = nullptr; +- +-void NFDi_SetError(const char* msg) { +- g_errorstr = msg; +-} +- +-template +-T* NFDi_Malloc(size_t bytes) { +- void* ptr = malloc(bytes); +- if (!ptr) NFDi_SetError("NFDi_Malloc failed."); +- +- return static_cast(ptr); +-} +- +-template +-void NFDi_Free(T* ptr) { +- assert(ptr); +- free(static_cast(ptr)); +-} +- +-/* guard objects */ +-template +-struct Release_Guard { +- T* data; +- Release_Guard(T* releasable) noexcept : data(releasable) {} +- ~Release_Guard() { data->Release(); } +-}; +- +-template +-struct Free_Guard { +- T* data; +- Free_Guard(T* freeable) noexcept : data(freeable) {} +- ~Free_Guard() { NFDi_Free(data); } +-}; +- +-template +-struct FreeCheck_Guard { +- T* data; +- FreeCheck_Guard(T* freeable = nullptr) noexcept : data(freeable) {} +- ~FreeCheck_Guard() { +- if (data) NFDi_Free(data); +- } +-}; +- +-/* helper functions */ +-nfdresult_t AddFiltersToDialog(::IFileDialog* fileOpenDialog, +- const nfdnfilteritem_t* filterList, +- nfdfiltersize_t filterCount) { +- /* filterCount plus 1 because we hardcode the *.* wildcard after the while loop */ +- COMDLG_FILTERSPEC* specList = +- NFDi_Malloc(sizeof(COMDLG_FILTERSPEC) * (filterCount + 1)); +- if (!specList) { +- return NFD_ERROR; +- } +- +- /* ad-hoc RAII object to free memory when destructing */ +- struct COMDLG_FILTERSPEC_Guard { +- COMDLG_FILTERSPEC* _specList; +- nfdfiltersize_t index; +- COMDLG_FILTERSPEC_Guard(COMDLG_FILTERSPEC* specList) noexcept +- : _specList(specList), index(0) {} +- ~COMDLG_FILTERSPEC_Guard() { +- for (--index; index != static_cast(-1); --index) { +- NFDi_Free(const_cast(_specList[index].pszSpec)); +- } +- NFDi_Free(_specList); +- } +- }; +- +- COMDLG_FILTERSPEC_Guard specListGuard(specList); +- +- if (filterCount) { +- assert(filterList); +- +- // we have filters to add ... format and add them +- +- // use the index that comes from the RAII object (instead of making a copy), so the RAII +- // object will know which memory to free +- nfdfiltersize_t& index = specListGuard.index; +- +- for (; index != filterCount; ++index) { +- // set the friendly name of this filter +- specList[index].pszName = filterList[index].name; +- +- // set the specification of this filter... +- +- // count number of file extensions +- size_t sep = 1; +- for (const nfdnchar_t* p_spec = filterList[index].spec; *p_spec; ++p_spec) { +- if (*p_spec == L',') { +- ++sep; +- } +- } +- +- // calculate space needed (including the trailing '\0') +- size_t specSize = sep * 2 + wcslen(filterList[index].spec) + 1; +- +- // malloc the required memory and populate it +- nfdnchar_t* specBuf = NFDi_Malloc(sizeof(nfdnchar_t) * specSize); +- +- if (!specBuf) { +- // automatic freeing of memory via COMDLG_FILTERSPEC_Guard +- return NFD_ERROR; +- } +- +- // convert "png,jpg" to "*.png;*.jpg" as required by Windows ... +- nfdnchar_t* p_specBuf = specBuf; +- *p_specBuf++ = L'*'; +- *p_specBuf++ = L'.'; +- for (const nfdnchar_t* p_spec = filterList[index].spec; *p_spec; ++p_spec) { +- if (*p_spec == L',') { +- *p_specBuf++ = L';'; +- *p_specBuf++ = L'*'; +- *p_specBuf++ = L'.'; +- } else { +- *p_specBuf++ = *p_spec; +- } +- } +- *p_specBuf++ = L'\0'; +- +- // assert that we had allocated exactly the correct amount of memory that we used +- assert(static_cast(p_specBuf - specBuf) == specSize); +- +- // save the buffer to the guard object +- specList[index].pszSpec = specBuf; +- } +- } +- +- /* Add wildcard */ +- specList[filterCount].pszName = L"All files"; +- specList[filterCount].pszSpec = L"*.*"; +- +- // add the filter to the dialog +- if (!SUCCEEDED(fileOpenDialog->SetFileTypes(filterCount + 1, specList))) { +- NFDi_SetError("Failed to set the allowable file types for the drop-down menu."); +- return NFD_ERROR; +- } +- +- // automatic freeing of memory via COMDLG_FILTERSPEC_Guard +- return NFD_OKAY; +-} +- +-/* call after AddFiltersToDialog */ +-nfdresult_t SetDefaultExtension(::IFileDialog* fileOpenDialog, +- const nfdnfilteritem_t* filterList, +- nfdfiltersize_t filterCount) { +- // if there are no filters, then don't set default extensions +- if (!filterCount) { +- return NFD_OKAY; +- } +- +- assert(filterList); +- +- // set the first item as the default index, and set the default extension +- if (!SUCCEEDED(fileOpenDialog->SetFileTypeIndex(1))) { +- NFDi_SetError("Failed to set the selected file type index."); +- return NFD_ERROR; +- } +- +- // set the first item as the default file extension +- const nfdnchar_t* p_spec = filterList[0].spec; +- for (; *p_spec; ++p_spec) { +- if (*p_spec == ',') { +- break; +- } +- } +- if (*p_spec) { +- // multiple file extensions for this type (need to allocate memory) +- size_t numChars = p_spec - filterList[0].spec; +- // allocate one more char space for the '\0' +- nfdnchar_t* extnBuf = NFDi_Malloc(sizeof(nfdnchar_t) * (numChars + 1)); +- if (!extnBuf) { +- return NFD_ERROR; +- } +- Free_Guard extnBufGuard(extnBuf); +- +- // copy the extension +- for (size_t i = 0; i != numChars; ++i) { +- extnBuf[i] = filterList[0].spec[i]; +- } +- // pad with trailing '\0' +- extnBuf[numChars] = L'\0'; +- +- if (!SUCCEEDED(fileOpenDialog->SetDefaultExtension(extnBuf))) { +- NFDi_SetError("Failed to set default extension."); +- return NFD_ERROR; +- } +- } else { +- // single file extension for this type (no need to allocate memory) +- if (!SUCCEEDED(fileOpenDialog->SetDefaultExtension(filterList[0].spec))) { +- NFDi_SetError("Failed to set default extension."); +- return NFD_ERROR; +- } +- } +- +- return NFD_OKAY; +-} +- +-nfdresult_t SetDefaultPath(IFileDialog* dialog, const nfdnchar_t* defaultPath) { +- if (!defaultPath || !*defaultPath) return NFD_OKAY; +- +- IShellItem* folder; +- HRESULT result = SHCreateItemFromParsingName(defaultPath, nullptr, IID_PPV_ARGS(&folder)); +- +- // Valid non results. +- if (result == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) || +- result == HRESULT_FROM_WIN32(ERROR_INVALID_DRIVE)) { +- return NFD_OKAY; +- } +- +- if (!SUCCEEDED(result)) { +- NFDi_SetError("Failed to create ShellItem for setting the default path."); +- return NFD_ERROR; +- } +- +- Release_Guard folderGuard(folder); +- +- // SetDefaultFolder() might use another recently used folder if available, so the user doesn't +- // need to keep navigating back to the default folder (recommended by Windows). change to +- // SetFolder() if you always want to use the default folder +- if (!SUCCEEDED(dialog->SetDefaultFolder(folder))) { +- NFDi_SetError("Failed to set default path."); +- return NFD_ERROR; +- } +- +- return NFD_OKAY; +-} +- +-nfdresult_t SetDefaultName(IFileDialog* dialog, const nfdnchar_t* defaultName) { +- if (!defaultName || !*defaultName) return NFD_OKAY; +- +- if (!SUCCEEDED(dialog->SetFileName(defaultName))) { +- NFDi_SetError("Failed to set default file name."); +- return NFD_ERROR; +- } +- +- return NFD_OKAY; +-} +- +-nfdresult_t AddOptions(IFileDialog* dialog, FILEOPENDIALOGOPTIONS options) { +- FILEOPENDIALOGOPTIONS existingOptions; +- if (!SUCCEEDED(dialog->GetOptions(&existingOptions))) { +- NFDi_SetError("Failed to get options."); +- return NFD_ERROR; +- } +- if (!SUCCEEDED(dialog->SetOptions(existingOptions | options))) { +- NFDi_SetError("Failed to set options."); +- return NFD_ERROR; +- } +- return NFD_OKAY; +-} +-} // namespace +- +-const char* NFD_GetError(void) { +- return g_errorstr; +-} +- +-void NFD_ClearError(void) { +- NFDi_SetError(nullptr); +-} +- +-/* public */ +- +-namespace { +-// The user might have initialized with COINIT_MULTITHREADED before, +-// in which case we will fail to do CoInitializeEx(), but file dialogs will still work. +-// See https://github.com/mlabbe/nativefiledialog/issues/72 for more information. +-bool needs_uninitialize; +-} // namespace +- +-nfdresult_t NFD_Init(void) { +- // Init COM library. +- HRESULT result = +- ::CoInitializeEx(nullptr, ::COINIT_APARTMENTTHREADED | ::COINIT_DISABLE_OLE1DDE); +- +- if (SUCCEEDED(result)) { +- needs_uninitialize = true; +- return NFD_OKAY; +- } else if (result == RPC_E_CHANGED_MODE) { +- // If this happens, the user already initialized COM using COINIT_MULTITHREADED, +- // so COM will still work, but we shouldn't uninitialize it later. +- needs_uninitialize = false; +- return NFD_OKAY; +- } else { +- NFDi_SetError("Failed to initialize COM."); +- return NFD_ERROR; +- } +-} +-void NFD_Quit(void) { +- if (needs_uninitialize) ::CoUninitialize(); +-} +- +-void NFD_FreePathN(nfdnchar_t* filePath) { +- assert(filePath); +- ::CoTaskMemFree(filePath); +-} +- +-nfdresult_t NFD_OpenDialogN(nfdnchar_t** outPath, +- const nfdnfilteritem_t* filterList, +- nfdfiltersize_t filterCount, +- const nfdnchar_t* defaultPath) { +- ::IFileOpenDialog* fileOpenDialog; +- +- // Create dialog +- HRESULT result = ::CoCreateInstance(::CLSID_FileOpenDialog, +- nullptr, +- CLSCTX_ALL, +- ::IID_IFileOpenDialog, +- reinterpret_cast(&fileOpenDialog)); +- +- if (!SUCCEEDED(result)) { +- NFDi_SetError("Could not create dialog."); +- return NFD_ERROR; +- } +- +- // make sure we remember to free the dialog +- Release_Guard<::IFileOpenDialog> fileOpenDialogGuard(fileOpenDialog); +- +- // Build the filter list +- if (!AddFiltersToDialog(fileOpenDialog, filterList, filterCount)) { +- return NFD_ERROR; +- } +- +- // Set auto-completed default extension +- if (!SetDefaultExtension(fileOpenDialog, filterList, filterCount)) { +- return NFD_ERROR; +- } +- +- // Set the default path +- if (!SetDefaultPath(fileOpenDialog, defaultPath)) { +- return NFD_ERROR; +- } +- +- // Only show file system items +- if (!AddOptions(fileOpenDialog, ::FOS_FORCEFILESYSTEM)) { +- return NFD_ERROR; +- } +- +- // Show the dialog. +- result = fileOpenDialog->Show(nullptr); +- if (SUCCEEDED(result)) { +- // Get the file name +- ::IShellItem* psiResult; +- result = fileOpenDialog->GetResult(&psiResult); +- if (!SUCCEEDED(result)) { +- NFDi_SetError("Could not get shell item from dialog."); +- return NFD_ERROR; +- } +- Release_Guard<::IShellItem> psiResultGuard(psiResult); +- +- nfdnchar_t* filePath; +- result = psiResult->GetDisplayName(::SIGDN_FILESYSPATH, &filePath); +- if (!SUCCEEDED(result)) { +- NFDi_SetError("Could not get file path from shell item returned by dialog."); +- return NFD_ERROR; +- } +- +- *outPath = filePath; +- +- return NFD_OKAY; +- } else if (result == HRESULT_FROM_WIN32(ERROR_CANCELLED)) { +- return NFD_CANCEL; +- } else { +- NFDi_SetError("File dialog box show failed."); +- return NFD_ERROR; +- } +-} +- +-nfdresult_t NFD_OpenDialogMultipleN(const nfdpathset_t** outPaths, +- const nfdnfilteritem_t* filterList, +- nfdfiltersize_t filterCount, +- const nfdnchar_t* defaultPath) { +- ::IFileOpenDialog* fileOpenDialog(nullptr); +- +- // Create dialog +- HRESULT result = ::CoCreateInstance(::CLSID_FileOpenDialog, +- nullptr, +- CLSCTX_ALL, +- ::IID_IFileOpenDialog, +- reinterpret_cast(&fileOpenDialog)); +- +- if (!SUCCEEDED(result)) { +- NFDi_SetError("Could not create dialog."); +- return NFD_ERROR; +- } +- +- // make sure we remember to free the dialog +- Release_Guard<::IFileOpenDialog> fileOpenDialogGuard(fileOpenDialog); +- +- // Build the filter list +- if (!AddFiltersToDialog(fileOpenDialog, filterList, filterCount)) { +- return NFD_ERROR; +- } +- +- // Set auto-completed default extension +- if (!SetDefaultExtension(fileOpenDialog, filterList, filterCount)) { +- return NFD_ERROR; +- } +- +- // Set the default path +- if (!SetDefaultPath(fileOpenDialog, defaultPath)) { +- return NFD_ERROR; +- } +- +- // Set a flag for multiple options and file system items only +- if (!AddOptions(fileOpenDialog, ::FOS_FORCEFILESYSTEM | ::FOS_ALLOWMULTISELECT)) { +- return NFD_ERROR; +- } +- +- // Show the dialog. +- result = fileOpenDialog->Show(nullptr); +- if (SUCCEEDED(result)) { +- ::IShellItemArray* shellItems; +- result = fileOpenDialog->GetResults(&shellItems); +- if (!SUCCEEDED(result)) { +- NFDi_SetError("Could not get shell items."); +- return NFD_ERROR; +- } +- +- // save the path set to the output +- *outPaths = static_cast(shellItems); +- +- return NFD_OKAY; +- } else if (result == HRESULT_FROM_WIN32(ERROR_CANCELLED)) { +- return NFD_CANCEL; +- } else { +- NFDi_SetError("File dialog box show failed."); +- return NFD_ERROR; +- } +-} +- +-nfdresult_t NFD_SaveDialogN(nfdnchar_t** outPath, +- const nfdnfilteritem_t* filterList, +- nfdfiltersize_t filterCount, +- const nfdnchar_t* defaultPath, +- const nfdnchar_t* defaultName) { +- ::IFileSaveDialog* fileSaveDialog; +- +- // Create dialog +- HRESULT result = ::CoCreateInstance(::CLSID_FileSaveDialog, +- nullptr, +- CLSCTX_ALL, +- ::IID_IFileSaveDialog, +- reinterpret_cast(&fileSaveDialog)); +- +- if (!SUCCEEDED(result)) { +- NFDi_SetError("Could not create dialog."); +- return NFD_ERROR; +- } +- +- // make sure we remember to free the dialog +- Release_Guard<::IFileSaveDialog> fileSaveDialogGuard(fileSaveDialog); +- +- // Build the filter list +- if (!AddFiltersToDialog(fileSaveDialog, filterList, filterCount)) { +- return NFD_ERROR; +- } +- +- // Set default extension +- if (!SetDefaultExtension(fileSaveDialog, filterList, filterCount)) { +- return NFD_ERROR; +- } +- +- // Set the default path +- if (!SetDefaultPath(fileSaveDialog, defaultPath)) { +- return NFD_ERROR; +- } +- +- // Set the default name +- if (!SetDefaultName(fileSaveDialog, defaultName)) { +- return NFD_ERROR; +- } +- +- // Only show file system items +- if (!AddOptions(fileSaveDialog, ::FOS_FORCEFILESYSTEM)) { +- return NFD_ERROR; +- } +- +- // Show the dialog. +- result = fileSaveDialog->Show(nullptr); +- if (SUCCEEDED(result)) { +- // Get the file name +- ::IShellItem* psiResult; +- result = fileSaveDialog->GetResult(&psiResult); +- if (!SUCCEEDED(result)) { +- NFDi_SetError("Could not get shell item from dialog."); +- return NFD_ERROR; +- } +- Release_Guard<::IShellItem> psiResultGuard(psiResult); +- +- nfdnchar_t* filePath; +- result = psiResult->GetDisplayName(::SIGDN_FILESYSPATH, &filePath); +- if (!SUCCEEDED(result)) { +- NFDi_SetError("Could not get file path from shell item returned by dialog."); +- return NFD_ERROR; +- } +- +- *outPath = filePath; +- +- return NFD_OKAY; +- } else if (result == HRESULT_FROM_WIN32(ERROR_CANCELLED)) { +- return NFD_CANCEL; +- } else { +- NFDi_SetError("File dialog box show failed."); +- return NFD_ERROR; +- } +-} +- +-nfdresult_t NFD_PickFolderN(nfdnchar_t** outPath, const nfdnchar_t* defaultPath) { +- ::IFileOpenDialog* fileOpenDialog; +- +- // Create dialog +- if (!SUCCEEDED(::CoCreateInstance(::CLSID_FileOpenDialog, +- nullptr, +- CLSCTX_ALL, +- ::IID_IFileOpenDialog, +- reinterpret_cast(&fileOpenDialog)))) { +- NFDi_SetError("Could not create dialog."); +- return NFD_ERROR; +- } +- +- Release_Guard<::IFileOpenDialog> fileOpenDialogGuard(fileOpenDialog); +- +- // Set the default path +- if (!SetDefaultPath(fileOpenDialog, defaultPath)) { +- return NFD_ERROR; +- } +- +- // Only show items that are folders and on the file system +- if (!AddOptions(fileOpenDialog, ::FOS_FORCEFILESYSTEM | ::FOS_PICKFOLDERS)) { +- return NFD_ERROR; +- } +- +- // Show the dialog to the user +- const HRESULT result = fileOpenDialog->Show(nullptr); +- if (result == HRESULT_FROM_WIN32(ERROR_CANCELLED)) { +- return NFD_CANCEL; +- } else if (!SUCCEEDED(result)) { +- NFDi_SetError("File dialog box show failed."); +- return NFD_ERROR; +- } +- +- // Get the shell item result +- ::IShellItem* psiResult; +- if (!SUCCEEDED(fileOpenDialog->GetResult(&psiResult))) { +- return NFD_ERROR; +- } +- +- Release_Guard<::IShellItem> psiResultGuard(psiResult); +- +- // Finally get the path +- nfdnchar_t* filePath; +- // Why are we not using SIGDN_FILESYSPATH? +- if (!SUCCEEDED(psiResult->GetDisplayName(::SIGDN_DESKTOPABSOLUTEPARSING, &filePath))) { +- NFDi_SetError("Could not get file path from shell item returned by dialog."); +- return NFD_ERROR; +- } +- +- *outPath = filePath; +- +- return NFD_OKAY; +-} +- +-nfdresult_t NFD_PathSet_GetCount(const nfdpathset_t* pathSet, nfdpathsetsize_t* count) { +- assert(pathSet); +- // const_cast because methods on IShellItemArray aren't const, but it should act like const to +- // the caller +- ::IShellItemArray* psiaPathSet = +- const_cast<::IShellItemArray*>(static_cast(pathSet)); +- +- DWORD numPaths; +- if (!SUCCEEDED(psiaPathSet->GetCount(&numPaths))) { +- NFDi_SetError("Could not get path count."); +- return NFD_ERROR; +- } +- *count = numPaths; +- return NFD_OKAY; +-} +- +-nfdresult_t NFD_PathSet_GetPathN(const nfdpathset_t* pathSet, +- nfdpathsetsize_t index, +- nfdnchar_t** outPath) { +- assert(pathSet); +- // const_cast because methods on IShellItemArray aren't const, but it should act like const to +- // the caller +- ::IShellItemArray* psiaPathSet = +- const_cast<::IShellItemArray*>(static_cast(pathSet)); +- +- ::IShellItem* psiPath; +- if (!SUCCEEDED(psiaPathSet->GetItemAt(index, &psiPath))) { +- NFDi_SetError("Could not get shell item."); +- return NFD_ERROR; +- } +- +- Release_Guard<::IShellItem> psiPathGuard(psiPath); +- +- nfdnchar_t* name; +- if (!SUCCEEDED(psiPath->GetDisplayName(::SIGDN_FILESYSPATH, &name))) { +- NFDi_SetError("Could not get file path from shell item."); +- return NFD_ERROR; +- } +- +- *outPath = name; +- return NFD_OKAY; +-} +- +-nfdresult_t NFD_PathSet_GetEnum(const nfdpathset_t* pathSet, nfdpathsetenum_t* outEnumerator) { +- assert(pathSet); +- // const_cast because methods on IShellItemArray aren't const, but it should act like const to +- // the caller +- ::IShellItemArray* psiaPathSet = +- const_cast<::IShellItemArray*>(static_cast(pathSet)); +- +- ::IEnumShellItems* pesiPaths; +- if (!SUCCEEDED(psiaPathSet->EnumItems(&pesiPaths))) { +- NFDi_SetError("Could not get enumerator."); +- return NFD_ERROR; +- } +- +- outEnumerator->ptr = static_cast(pesiPaths); +- return NFD_OKAY; +-} +- +-void NFD_PathSet_FreeEnum(nfdpathsetenum_t* enumerator) { +- assert(enumerator->ptr); +- +- ::IEnumShellItems* pesiPaths = static_cast<::IEnumShellItems*>(enumerator->ptr); +- +- // free the enumerator memory +- pesiPaths->Release(); +-} +- +-nfdresult_t NFD_PathSet_EnumNextN(nfdpathsetenum_t* enumerator, nfdnchar_t** outPath) { +- assert(enumerator->ptr); +- +- ::IEnumShellItems* pesiPaths = static_cast<::IEnumShellItems*>(enumerator->ptr); +- +- ::IShellItem* psiPath; +- HRESULT res = pesiPaths->Next(1, &psiPath, NULL); +- if (!SUCCEEDED(res)) { +- NFDi_SetError("Could not get next item of enumerator."); +- return NFD_ERROR; +- } +- if (res != S_OK) { +- *outPath = nullptr; +- return NFD_OKAY; +- } +- +- Release_Guard<::IShellItem> psiPathGuard(psiPath); +- +- nfdnchar_t* name; +- if (!SUCCEEDED(psiPath->GetDisplayName(::SIGDN_FILESYSPATH, &name))) { +- NFDi_SetError("Could not get file path from shell item."); +- return NFD_ERROR; +- } +- +- *outPath = name; +- return NFD_OKAY; +-} +- +-void NFD_PathSet_Free(const nfdpathset_t* pathSet) { +- assert(pathSet); +- // const_cast because methods on IShellItemArray aren't const, but it should act like const to +- // the caller +- ::IShellItemArray* psiaPathSet = +- const_cast<::IShellItemArray*>(static_cast(pathSet)); +- +- // free the path set memory +- psiaPathSet->Release(); +-} +- +-namespace { +-// allocs the space in outStr -- call NFDi_Free() +-nfdresult_t CopyCharToWChar(const nfdu8char_t* inStr, nfdnchar_t*& outStr) { +- int charsNeeded = MultiByteToWideChar(CP_UTF8, 0, inStr, -1, nullptr, 0); +- assert(charsNeeded); +- +- nfdnchar_t* tmp_outStr = NFDi_Malloc(sizeof(nfdnchar_t) * charsNeeded); +- if (!tmp_outStr) { +- return NFD_ERROR; +- } +- +- int ret = MultiByteToWideChar(CP_UTF8, 0, inStr, -1, tmp_outStr, charsNeeded); +- assert(ret && ret == charsNeeded); +- (void)ret; // prevent warning in release build +- outStr = tmp_outStr; +- return NFD_OKAY; +-} +- +-// allocs the space in outPath -- call NFDi_Free() +-nfdresult_t CopyWCharToNFDChar(const nfdnchar_t* inStr, nfdu8char_t*& outStr) { +- int bytesNeeded = WideCharToMultiByte(CP_UTF8, 0, inStr, -1, nullptr, 0, nullptr, nullptr); +- assert(bytesNeeded); +- +- nfdu8char_t* tmp_outStr = NFDi_Malloc(sizeof(nfdu8char_t) * bytesNeeded); +- if (!tmp_outStr) { +- return NFD_ERROR; +- } +- +- int ret = WideCharToMultiByte(CP_UTF8, 0, inStr, -1, tmp_outStr, bytesNeeded, nullptr, nullptr); +- assert(ret && ret == bytesNeeded); +- (void)ret; // prevent warning in release build +- outStr = tmp_outStr; +- return NFD_OKAY; +-} +- +-struct FilterItem_Guard { +- nfdnfilteritem_t* data; +- nfdfiltersize_t index; +- FilterItem_Guard() noexcept : data(nullptr), index(0) {} +- ~FilterItem_Guard() { +- assert(data || index == 0); +- for (--index; index != static_cast(-1); --index) { +- NFDi_Free(const_cast(data[index].spec)); +- NFDi_Free(const_cast(data[index].name)); +- } +- if (data) NFDi_Free(data); +- } +-}; +- +-nfdresult_t CopyFilterItem(const nfdu8filteritem_t* filterList, +- nfdfiltersize_t count, +- FilterItem_Guard& filterItemsNGuard) { +- if (count) { +- nfdnfilteritem_t*& filterItemsN = filterItemsNGuard.data; +- filterItemsN = NFDi_Malloc(sizeof(nfdnfilteritem_t) * count); +- if (!filterItemsN) { +- return NFD_ERROR; +- } +- +- nfdfiltersize_t& index = filterItemsNGuard.index; +- for (; index != count; ++index) { +- nfdresult_t res = CopyCharToWChar(filterList[index].name, +- const_cast(filterItemsN[index].name)); +- if (!res) { +- return NFD_ERROR; +- } +- res = CopyCharToWChar(filterList[index].spec, +- const_cast(filterItemsN[index].spec)); +- if (!res) { +- // remember to free the name, because we also created it (and it won't be protected +- // by the guard, because we have not incremented the index) +- NFDi_Free(const_cast(filterItemsN[index].name)); +- return NFD_ERROR; +- } +- } +- } +- return NFD_OKAY; +-} +-nfdresult_t ConvertU8ToNative(const nfdu8char_t* u8Text, FreeCheck_Guard& nativeText) { +- if (u8Text) { +- nfdresult_t res = CopyCharToWChar(u8Text, nativeText.data); +- if (!res) { +- return NFD_ERROR; +- } +- } +- return NFD_OKAY; +-} +-void NormalizePathSeparator(nfdnchar_t* path) { +- if (path) { +- for (; *path; ++path) { +- if (*path == L'/') *path = L'\\'; +- } +- } +-} +-} // namespace +- +-void NFD_FreePathU8(nfdu8char_t* outPath) { +- NFDi_Free(outPath); +-} +- +-nfdresult_t NFD_OpenDialogU8(nfdu8char_t** outPath, +- const nfdu8filteritem_t* filterList, +- nfdfiltersize_t count, +- const nfdu8char_t* defaultPath) { +- // populate the real nfdnfilteritem_t +- FilterItem_Guard filterItemsNGuard; +- if (!CopyFilterItem(filterList, count, filterItemsNGuard)) { +- return NFD_ERROR; +- } +- +- // convert and normalize the default path, but only if it is not nullptr +- FreeCheck_Guard defaultPathNGuard; +- ConvertU8ToNative(defaultPath, defaultPathNGuard); +- NormalizePathSeparator(defaultPathNGuard.data); +- +- // call the native function +- nfdnchar_t* outPathN; +- nfdresult_t res = +- NFD_OpenDialogN(&outPathN, filterItemsNGuard.data, count, defaultPathNGuard.data); +- +- if (res != NFD_OKAY) { +- return res; +- } +- +- // convert the outPath to UTF-8 +- res = CopyWCharToNFDChar(outPathN, *outPath); +- +- // free the native out path, and return the result +- NFD_FreePathN(outPathN); +- return res; +-} +- +-/* multiple file open dialog */ +-/* It is the caller's responsibility to free `outPaths` via NFD_PathSet_Free() if this function +- * returns NFD_OKAY */ +-nfdresult_t NFD_OpenDialogMultipleU8(const nfdpathset_t** outPaths, +- const nfdu8filteritem_t* filterList, +- nfdfiltersize_t count, +- const nfdu8char_t* defaultPath) { +- // populate the real nfdnfilteritem_t +- FilterItem_Guard filterItemsNGuard; +- if (!CopyFilterItem(filterList, count, filterItemsNGuard)) { +- return NFD_ERROR; +- } +- +- // convert and normalize the default path, but only if it is not nullptr +- FreeCheck_Guard defaultPathNGuard; +- ConvertU8ToNative(defaultPath, defaultPathNGuard); +- NormalizePathSeparator(defaultPathNGuard.data); +- +- // call the native function +- return NFD_OpenDialogMultipleN(outPaths, filterItemsNGuard.data, count, defaultPathNGuard.data); +-} +- +-/* save dialog */ +-/* It is the caller's responsibility to free `outPath` via NFD_FreePathU8() if this function returns +- * NFD_OKAY */ +-nfdresult_t NFD_SaveDialogU8(nfdu8char_t** outPath, +- const nfdu8filteritem_t* filterList, +- nfdfiltersize_t count, +- const nfdu8char_t* defaultPath, +- const nfdu8char_t* defaultName) { +- // populate the real nfdnfilteritem_t +- FilterItem_Guard filterItemsNGuard; +- if (!CopyFilterItem(filterList, count, filterItemsNGuard)) { +- return NFD_ERROR; +- } +- +- // convert and normalize the default path, but only if it is not nullptr +- FreeCheck_Guard defaultPathNGuard; +- ConvertU8ToNative(defaultPath, defaultPathNGuard); +- NormalizePathSeparator(defaultPathNGuard.data); +- +- // convert the default name, but only if it is not nullptr +- FreeCheck_Guard defaultNameNGuard; +- ConvertU8ToNative(defaultName, defaultNameNGuard); +- +- // call the native function +- nfdnchar_t* outPathN; +- nfdresult_t res = NFD_SaveDialogN( +- &outPathN, filterItemsNGuard.data, count, defaultPathNGuard.data, defaultNameNGuard.data); +- +- if (res != NFD_OKAY) { +- return res; +- } +- +- // convert the outPath to UTF-8 +- res = CopyWCharToNFDChar(outPathN, *outPath); +- +- // free the native out path, and return the result +- NFD_FreePathN(outPathN); +- return res; +-} +- +-/* select folder dialog */ +-/* It is the caller's responsibility to free `outPath` via NFD_FreePathU8() if this function returns +- * NFD_OKAY */ +-nfdresult_t NFD_PickFolderU8(nfdu8char_t** outPath, const nfdu8char_t* defaultPath) { +- // convert and normalize the default path, but only if it is not nullptr +- FreeCheck_Guard defaultPathNGuard; +- ConvertU8ToNative(defaultPath, defaultPathNGuard); +- NormalizePathSeparator(defaultPathNGuard.data); +- +- // call the native function +- nfdnchar_t* outPathN; +- nfdresult_t res = NFD_PickFolderN(&outPathN, defaultPathNGuard.data); +- +- if (res != NFD_OKAY) { +- return res; +- } +- +- // convert the outPath to UTF-8 +- res = CopyWCharToNFDChar(outPathN, *outPath); +- +- // free the native out path, and return the result +- NFD_FreePathN(outPathN); +- return res; +-} +- +-/* Get the UTF-8 path at offset index */ +-/* It is the caller's responsibility to free `outPath` via NFD_FreePathU8() if this function returns +- * NFD_OKAY */ +-nfdresult_t NFD_PathSet_GetPathU8(const nfdpathset_t* pathSet, +- nfdpathsetsize_t index, +- nfdu8char_t** outPath) { +- // call the native function +- nfdnchar_t* outPathN; +- nfdresult_t res = NFD_PathSet_GetPathN(pathSet, index, &outPathN); +- +- if (res != NFD_OKAY) { +- return res; +- } +- +- // convert the outPath to UTF-8 +- res = CopyWCharToNFDChar(outPathN, *outPath); +- +- // free the native out path, and return the result +- NFD_FreePathN(outPathN); +- return res; +-} +- +-nfdresult_t NFD_PathSet_EnumNextU8(nfdpathsetenum_t* enumerator, nfdu8char_t** outPath) { +- // call the native function +- nfdnchar_t* outPathN; +- nfdresult_t res = NFD_PathSet_EnumNextN(enumerator, &outPathN); +- +- if (res != NFD_OKAY) { +- return res; +- } +- +- if (outPathN) { +- // convert the outPath to UTF-8 +- res = CopyWCharToNFDChar(outPathN, *outPath); +- +- // free the native out path, and return the result +- NFD_FreePathN(outPathN); +- } else { +- *outPath = nullptr; +- res = NFD_OKAY; +- } +- +- return res; +-} ++/* ++ Native File Dialog Extended ++ Repository: https://github.com/btzy/nativefiledialog-extended ++ License: Zlib ++ Author: Bernard Teo ++ */ ++ ++/* only locally define UNICODE in this compilation unit */ ++#ifndef UNICODE ++#define UNICODE ++#endif ++ ++#ifdef __MINGW32__ ++// Explicitly setting NTDDI version, this is necessary for the MinGW compiler ++#define NTDDI_VERSION NTDDI_VISTA ++#define _WIN32_WINNT _WIN32_WINNT_VISTA ++#endif ++ ++#if _MSC_VER ++// see ++// https://developercommunity.visualstudio.com/content/problem/185399/error-c2760-in-combaseapih-with-windows-sdk-81-and.html ++struct IUnknown; // Workaround for "combaseapi.h(229): error C2187: syntax error: 'identifier' was ++ // unexpected here" when using /permissive- ++#endif ++ ++#include ++#include ++#include ++#include ++#include ++#include "nfd.h" ++ ++namespace { ++ ++/* current error */ ++const char* g_errorstr = nullptr; ++ ++void NFDi_SetError(const char* msg) { ++ g_errorstr = msg; ++} ++ ++template ++T* NFDi_Malloc(size_t bytes) { ++ void* ptr = malloc(bytes); ++ if (!ptr) NFDi_SetError("NFDi_Malloc failed."); ++ ++ return static_cast(ptr); ++} ++ ++template ++void NFDi_Free(T* ptr) { ++ assert(ptr); ++ free(static_cast(ptr)); ++} ++ ++/* guard objects */ ++template ++struct Release_Guard { ++ T* data; ++ Release_Guard(T* releasable) noexcept : data(releasable) {} ++ ~Release_Guard() { data->Release(); } ++}; ++ ++template ++struct Free_Guard { ++ T* data; ++ Free_Guard(T* freeable) noexcept : data(freeable) {} ++ ~Free_Guard() { NFDi_Free(data); } ++}; ++ ++template ++struct FreeCheck_Guard { ++ T* data; ++ FreeCheck_Guard(T* freeable = nullptr) noexcept : data(freeable) {} ++ ~FreeCheck_Guard() { ++ if (data) NFDi_Free(data); ++ } ++}; ++ ++/* helper functions */ ++nfdresult_t AddFiltersToDialog(::IFileDialog* fileOpenDialog, ++ const nfdnfilteritem_t* filterList, ++ nfdfiltersize_t filterCount) { ++ /* filterCount plus 1 because we hardcode the *.* wildcard after the while loop */ ++ COMDLG_FILTERSPEC* specList = ++ NFDi_Malloc(sizeof(COMDLG_FILTERSPEC) * (filterCount + 1)); ++ if (!specList) { ++ return NFD_ERROR; ++ } ++ ++ /* ad-hoc RAII object to free memory when destructing */ ++ struct COMDLG_FILTERSPEC_Guard { ++ COMDLG_FILTERSPEC* _specList; ++ nfdfiltersize_t index; ++ COMDLG_FILTERSPEC_Guard(COMDLG_FILTERSPEC* specList) noexcept ++ : _specList(specList), index(0) {} ++ ~COMDLG_FILTERSPEC_Guard() { ++ for (--index; index != static_cast(-1); --index) { ++ NFDi_Free(const_cast(_specList[index].pszSpec)); ++ } ++ NFDi_Free(_specList); ++ } ++ }; ++ ++ COMDLG_FILTERSPEC_Guard specListGuard(specList); ++ ++ if (filterCount) { ++ assert(filterList); ++ ++ // we have filters to add ... format and add them ++ ++ // use the index that comes from the RAII object (instead of making a copy), so the RAII ++ // object will know which memory to free ++ nfdfiltersize_t& index = specListGuard.index; ++ ++ for (; index != filterCount; ++index) { ++ // set the friendly name of this filter ++ specList[index].pszName = filterList[index].name; ++ ++ // set the specification of this filter... ++ ++ // count number of file extensions ++ size_t sep = 1; ++ for (const nfdnchar_t* p_spec = filterList[index].spec; *p_spec; ++p_spec) { ++ if (*p_spec == L',') { ++ ++sep; ++ } ++ } ++ ++ // calculate space needed (including the trailing '\0') ++ size_t specSize = sep * 2 + wcslen(filterList[index].spec) + 1; ++ ++ // malloc the required memory and populate it ++ nfdnchar_t* specBuf = NFDi_Malloc(sizeof(nfdnchar_t) * specSize); ++ ++ if (!specBuf) { ++ // automatic freeing of memory via COMDLG_FILTERSPEC_Guard ++ return NFD_ERROR; ++ } ++ ++ // convert "png,jpg" to "*.png;*.jpg" as required by Windows ... ++ nfdnchar_t* p_specBuf = specBuf; ++ *p_specBuf++ = L'*'; ++ *p_specBuf++ = L'.'; ++ for (const nfdnchar_t* p_spec = filterList[index].spec; *p_spec; ++p_spec) { ++ if (*p_spec == L',') { ++ *p_specBuf++ = L';'; ++ *p_specBuf++ = L'*'; ++ *p_specBuf++ = L'.'; ++ } else { ++ *p_specBuf++ = *p_spec; ++ } ++ } ++ *p_specBuf++ = L'\0'; ++ ++ // assert that we had allocated exactly the correct amount of memory that we used ++ assert(static_cast(p_specBuf - specBuf) == specSize); ++ ++ // save the buffer to the guard object ++ specList[index].pszSpec = specBuf; ++ } ++ } ++ ++ /* Add wildcard */ ++ specList[filterCount].pszName = L"All files"; ++ specList[filterCount].pszSpec = L"*.*"; ++ ++ // add the filter to the dialog ++ if (!SUCCEEDED(fileOpenDialog->SetFileTypes(filterCount + 1, specList))) { ++ NFDi_SetError("Failed to set the allowable file types for the drop-down menu."); ++ return NFD_ERROR; ++ } ++ ++ // automatic freeing of memory via COMDLG_FILTERSPEC_Guard ++ return NFD_OKAY; ++} ++ ++/* call after AddFiltersToDialog */ ++nfdresult_t SetDefaultExtension(::IFileDialog* fileOpenDialog, ++ const nfdnfilteritem_t* filterList, ++ nfdfiltersize_t filterCount) { ++ // if there are no filters, then don't set default extensions ++ if (!filterCount) { ++ return NFD_OKAY; ++ } ++ ++ assert(filterList); ++ ++ // set the first item as the default index, and set the default extension ++ if (!SUCCEEDED(fileOpenDialog->SetFileTypeIndex(1))) { ++ NFDi_SetError("Failed to set the selected file type index."); ++ return NFD_ERROR; ++ } ++ ++ // set the first item as the default file extension ++ const nfdnchar_t* p_spec = filterList[0].spec; ++ for (; *p_spec; ++p_spec) { ++ if (*p_spec == ',') { ++ break; ++ } ++ } ++ if (*p_spec) { ++ // multiple file extensions for this type (need to allocate memory) ++ size_t numChars = p_spec - filterList[0].spec; ++ // allocate one more char space for the '\0' ++ nfdnchar_t* extnBuf = NFDi_Malloc(sizeof(nfdnchar_t) * (numChars + 1)); ++ if (!extnBuf) { ++ return NFD_ERROR; ++ } ++ Free_Guard extnBufGuard(extnBuf); ++ ++ // copy the extension ++ for (size_t i = 0; i != numChars; ++i) { ++ extnBuf[i] = filterList[0].spec[i]; ++ } ++ // pad with trailing '\0' ++ extnBuf[numChars] = L'\0'; ++ ++ if (!SUCCEEDED(fileOpenDialog->SetDefaultExtension(extnBuf))) { ++ NFDi_SetError("Failed to set default extension."); ++ return NFD_ERROR; ++ } ++ } else { ++ // single file extension for this type (no need to allocate memory) ++ if (!SUCCEEDED(fileOpenDialog->SetDefaultExtension(filterList[0].spec))) { ++ NFDi_SetError("Failed to set default extension."); ++ return NFD_ERROR; ++ } ++ } ++ ++ return NFD_OKAY; ++} ++ ++nfdresult_t SetDefaultPath(IFileDialog* dialog, const nfdnchar_t* defaultPath) { ++ if (!defaultPath || !*defaultPath) return NFD_OKAY; ++ ++ IShellItem* folder; ++ HRESULT result = SHCreateItemFromParsingName(defaultPath, nullptr, IID_PPV_ARGS(&folder)); ++ ++ // Valid non results. ++ if (result == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) || ++ result == HRESULT_FROM_WIN32(ERROR_INVALID_DRIVE)) { ++ return NFD_OKAY; ++ } ++ ++ if (!SUCCEEDED(result)) { ++ NFDi_SetError("Failed to create ShellItem for setting the default path."); ++ return NFD_ERROR; ++ } ++ ++ Release_Guard folderGuard(folder); ++ ++ // SetDefaultFolder() might use another recently used folder if available, so the user doesn't ++ // need to keep navigating back to the default folder (recommended by Windows). change to ++ // SetFolder() if you always want to use the default folder ++ if (!SUCCEEDED(dialog->SetDefaultFolder(folder))) { ++ NFDi_SetError("Failed to set default path."); ++ return NFD_ERROR; ++ } ++ ++ return NFD_OKAY; ++} ++ ++nfdresult_t SetDefaultName(IFileDialog* dialog, const nfdnchar_t* defaultName) { ++ if (!defaultName || !*defaultName) return NFD_OKAY; ++ ++ if (!SUCCEEDED(dialog->SetFileName(defaultName))) { ++ NFDi_SetError("Failed to set default file name."); ++ return NFD_ERROR; ++ } ++ ++ return NFD_OKAY; ++} ++ ++nfdresult_t AddOptions(IFileDialog* dialog, FILEOPENDIALOGOPTIONS options) { ++ FILEOPENDIALOGOPTIONS existingOptions; ++ if (!SUCCEEDED(dialog->GetOptions(&existingOptions))) { ++ NFDi_SetError("Failed to get options."); ++ return NFD_ERROR; ++ } ++ if (!SUCCEEDED(dialog->SetOptions(existingOptions | options))) { ++ NFDi_SetError("Failed to set options."); ++ return NFD_ERROR; ++ } ++ return NFD_OKAY; ++} ++} // namespace ++ ++const char* NFD_GetError(void) { ++ return g_errorstr; ++} ++ ++void NFD_ClearError(void) { ++ NFDi_SetError(nullptr); ++} ++ ++/* public */ ++ ++namespace { ++// The user might have initialized with COINIT_MULTITHREADED before, ++// in which case we will fail to do CoInitializeEx(), but file dialogs will still work. ++// See https://github.com/mlabbe/nativefiledialog/issues/72 for more information. ++bool needs_uninitialize; ++} // namespace ++ ++nfdresult_t NFD_Init(void) { ++ // Init COM library. ++ HRESULT result = ++ ::CoInitializeEx(nullptr, ::COINIT_APARTMENTTHREADED | ::COINIT_DISABLE_OLE1DDE); ++ ++ if (SUCCEEDED(result)) { ++ needs_uninitialize = true; ++ return NFD_OKAY; ++ } else if (result == RPC_E_CHANGED_MODE) { ++ // If this happens, the user already initialized COM using COINIT_MULTITHREADED, ++ // so COM will still work, but we shouldn't uninitialize it later. ++ needs_uninitialize = false; ++ return NFD_OKAY; ++ } else { ++ NFDi_SetError("Failed to initialize COM."); ++ return NFD_ERROR; ++ } ++} ++void NFD_Quit(void) { ++ if (needs_uninitialize) ::CoUninitialize(); ++} ++ ++void NFD_FreePathN(nfdnchar_t* filePath) { ++ assert(filePath); ++ ::CoTaskMemFree(filePath); ++} ++ ++nfdresult_t NFD_OpenDialogN(nfdnchar_t** outPath, ++ const nfdnfilteritem_t* filterList, ++ nfdfiltersize_t filterCount, ++ const nfdnchar_t* defaultPath) { ++ ::IFileOpenDialog* fileOpenDialog; ++ ++ // Create dialog ++ HRESULT result = ::CoCreateInstance(::CLSID_FileOpenDialog, ++ nullptr, ++ CLSCTX_ALL, ++ ::IID_IFileOpenDialog, ++ reinterpret_cast(&fileOpenDialog)); ++ ++ if (!SUCCEEDED(result)) { ++ NFDi_SetError("Could not create dialog."); ++ return NFD_ERROR; ++ } ++ ++ // make sure we remember to free the dialog ++ Release_Guard<::IFileOpenDialog> fileOpenDialogGuard(fileOpenDialog); ++ ++ // Build the filter list ++ if (!AddFiltersToDialog(fileOpenDialog, filterList, filterCount)) { ++ return NFD_ERROR; ++ } ++ ++ // Set auto-completed default extension ++ if (!SetDefaultExtension(fileOpenDialog, filterList, filterCount)) { ++ return NFD_ERROR; ++ } ++ ++ // Set the default path ++ if (!SetDefaultPath(fileOpenDialog, defaultPath)) { ++ return NFD_ERROR; ++ } ++ ++ // Only show file system items ++ if (!AddOptions(fileOpenDialog, ::FOS_FORCEFILESYSTEM)) { ++ return NFD_ERROR; ++ } ++ ++ // Show the dialog. ++ result = fileOpenDialog->Show(nullptr); ++ if (SUCCEEDED(result)) { ++ // Get the file name ++ ::IShellItem* psiResult; ++ result = fileOpenDialog->GetResult(&psiResult); ++ if (!SUCCEEDED(result)) { ++ NFDi_SetError("Could not get shell item from dialog."); ++ return NFD_ERROR; ++ } ++ Release_Guard<::IShellItem> psiResultGuard(psiResult); ++ ++ nfdnchar_t* filePath; ++ result = psiResult->GetDisplayName(::SIGDN_FILESYSPATH, &filePath); ++ if (!SUCCEEDED(result)) { ++ NFDi_SetError("Could not get file path from shell item returned by dialog."); ++ return NFD_ERROR; ++ } ++ ++ *outPath = filePath; ++ ++ return NFD_OKAY; ++ } else if (result == HRESULT_FROM_WIN32(ERROR_CANCELLED)) { ++ return NFD_CANCEL; ++ } else { ++ NFDi_SetError("File dialog box show failed."); ++ return NFD_ERROR; ++ } ++} ++ ++nfdresult_t NFD_OpenDialogMultipleN(const nfdpathset_t** outPaths, ++ const nfdnfilteritem_t* filterList, ++ nfdfiltersize_t filterCount, ++ const nfdnchar_t* defaultPath) { ++ ::IFileOpenDialog* fileOpenDialog(nullptr); ++ ++ // Create dialog ++ HRESULT result = ::CoCreateInstance(::CLSID_FileOpenDialog, ++ nullptr, ++ CLSCTX_ALL, ++ ::IID_IFileOpenDialog, ++ reinterpret_cast(&fileOpenDialog)); ++ ++ if (!SUCCEEDED(result)) { ++ NFDi_SetError("Could not create dialog."); ++ return NFD_ERROR; ++ } ++ ++ // make sure we remember to free the dialog ++ Release_Guard<::IFileOpenDialog> fileOpenDialogGuard(fileOpenDialog); ++ ++ // Build the filter list ++ if (!AddFiltersToDialog(fileOpenDialog, filterList, filterCount)) { ++ return NFD_ERROR; ++ } ++ ++ // Set auto-completed default extension ++ if (!SetDefaultExtension(fileOpenDialog, filterList, filterCount)) { ++ return NFD_ERROR; ++ } ++ ++ // Set the default path ++ if (!SetDefaultPath(fileOpenDialog, defaultPath)) { ++ return NFD_ERROR; ++ } ++ ++ // Set a flag for multiple options and file system items only ++ if (!AddOptions(fileOpenDialog, ::FOS_FORCEFILESYSTEM | ::FOS_ALLOWMULTISELECT)) { ++ return NFD_ERROR; ++ } ++ ++ // Show the dialog. ++ result = fileOpenDialog->Show(nullptr); ++ if (SUCCEEDED(result)) { ++ ::IShellItemArray* shellItems; ++ result = fileOpenDialog->GetResults(&shellItems); ++ if (!SUCCEEDED(result)) { ++ NFDi_SetError("Could not get shell items."); ++ return NFD_ERROR; ++ } ++ ++ // save the path set to the output ++ *outPaths = static_cast(shellItems); ++ ++ return NFD_OKAY; ++ } else if (result == HRESULT_FROM_WIN32(ERROR_CANCELLED)) { ++ return NFD_CANCEL; ++ } else { ++ NFDi_SetError("File dialog box show failed."); ++ return NFD_ERROR; ++ } ++} ++ ++nfdresult_t NFD_SaveDialogN(nfdnchar_t** outPath, ++ const nfdnfilteritem_t* filterList, ++ nfdfiltersize_t filterCount, ++ const nfdnchar_t* defaultPath, ++ const nfdnchar_t* defaultName) { ++ ::IFileSaveDialog* fileSaveDialog; ++ ++ // Create dialog ++ HRESULT result = ::CoCreateInstance(::CLSID_FileSaveDialog, ++ nullptr, ++ CLSCTX_ALL, ++ ::IID_IFileSaveDialog, ++ reinterpret_cast(&fileSaveDialog)); ++ ++ if (!SUCCEEDED(result)) { ++ NFDi_SetError("Could not create dialog."); ++ return NFD_ERROR; ++ } ++ ++ // make sure we remember to free the dialog ++ Release_Guard<::IFileSaveDialog> fileSaveDialogGuard(fileSaveDialog); ++ ++ // Build the filter list ++ if (!AddFiltersToDialog(fileSaveDialog, filterList, filterCount)) { ++ return NFD_ERROR; ++ } ++ ++ // Set default extension ++ if (!SetDefaultExtension(fileSaveDialog, filterList, filterCount)) { ++ return NFD_ERROR; ++ } ++ ++ // Set the default path ++ if (!SetDefaultPath(fileSaveDialog, defaultPath)) { ++ return NFD_ERROR; ++ } ++ ++ // Set the default name ++ if (!SetDefaultName(fileSaveDialog, defaultName)) { ++ return NFD_ERROR; ++ } ++ ++ // Only show file system items ++ if (!AddOptions(fileSaveDialog, ::FOS_FORCEFILESYSTEM)) { ++ return NFD_ERROR; ++ } ++ ++ // Show the dialog. ++ result = fileSaveDialog->Show(nullptr); ++ if (SUCCEEDED(result)) { ++ // Get the file name ++ ::IShellItem* psiResult; ++ result = fileSaveDialog->GetResult(&psiResult); ++ if (!SUCCEEDED(result)) { ++ NFDi_SetError("Could not get shell item from dialog."); ++ return NFD_ERROR; ++ } ++ Release_Guard<::IShellItem> psiResultGuard(psiResult); ++ ++ nfdnchar_t* filePath; ++ result = psiResult->GetDisplayName(::SIGDN_FILESYSPATH, &filePath); ++ if (!SUCCEEDED(result)) { ++ NFDi_SetError("Could not get file path from shell item returned by dialog."); ++ return NFD_ERROR; ++ } ++ ++ *outPath = filePath; ++ ++ return NFD_OKAY; ++ } else if (result == HRESULT_FROM_WIN32(ERROR_CANCELLED)) { ++ return NFD_CANCEL; ++ } else { ++ NFDi_SetError("File dialog box show failed."); ++ return NFD_ERROR; ++ } ++} ++ ++nfdresult_t NFD_PickFolderN(nfdnchar_t** outPath, const nfdnchar_t* defaultPath) { ++ ::IFileOpenDialog* fileOpenDialog; ++ ++ // Create dialog ++ if (!SUCCEEDED(::CoCreateInstance(::CLSID_FileOpenDialog, ++ nullptr, ++ CLSCTX_ALL, ++ ::IID_IFileOpenDialog, ++ reinterpret_cast(&fileOpenDialog)))) { ++ NFDi_SetError("Could not create dialog."); ++ return NFD_ERROR; ++ } ++ ++ Release_Guard<::IFileOpenDialog> fileOpenDialogGuard(fileOpenDialog); ++ ++ // Set the default path ++ if (!SetDefaultPath(fileOpenDialog, defaultPath)) { ++ return NFD_ERROR; ++ } ++ ++ // Only show items that are folders and on the file system ++ if (!AddOptions(fileOpenDialog, ::FOS_FORCEFILESYSTEM | ::FOS_PICKFOLDERS)) { ++ return NFD_ERROR; ++ } ++ ++ // Show the dialog to the user ++ const HRESULT result = fileOpenDialog->Show(nullptr); ++ if (result == HRESULT_FROM_WIN32(ERROR_CANCELLED)) { ++ return NFD_CANCEL; ++ } else if (!SUCCEEDED(result)) { ++ NFDi_SetError("File dialog box show failed."); ++ return NFD_ERROR; ++ } ++ ++ // Get the shell item result ++ ::IShellItem* psiResult; ++ if (!SUCCEEDED(fileOpenDialog->GetResult(&psiResult))) { ++ return NFD_ERROR; ++ } ++ ++ Release_Guard<::IShellItem> psiResultGuard(psiResult); ++ ++ // Finally get the path ++ nfdnchar_t* filePath; ++ // Why are we not using SIGDN_FILESYSPATH? ++ if (!SUCCEEDED(psiResult->GetDisplayName(::SIGDN_DESKTOPABSOLUTEPARSING, &filePath))) { ++ NFDi_SetError("Could not get file path from shell item returned by dialog."); ++ return NFD_ERROR; ++ } ++ ++ *outPath = filePath; ++ ++ return NFD_OKAY; ++} ++ ++nfdresult_t NFD_PathSet_GetCount(const nfdpathset_t* pathSet, nfdpathsetsize_t* count) { ++ assert(pathSet); ++ // const_cast because methods on IShellItemArray aren't const, but it should act like const to ++ // the caller ++ ::IShellItemArray* psiaPathSet = ++ const_cast<::IShellItemArray*>(static_cast(pathSet)); ++ ++ DWORD numPaths; ++ if (!SUCCEEDED(psiaPathSet->GetCount(&numPaths))) { ++ NFDi_SetError("Could not get path count."); ++ return NFD_ERROR; ++ } ++ *count = numPaths; ++ return NFD_OKAY; ++} ++ ++nfdresult_t NFD_PathSet_GetPathN(const nfdpathset_t* pathSet, ++ nfdpathsetsize_t index, ++ nfdnchar_t** outPath) { ++ assert(pathSet); ++ // const_cast because methods on IShellItemArray aren't const, but it should act like const to ++ // the caller ++ ::IShellItemArray* psiaPathSet = ++ const_cast<::IShellItemArray*>(static_cast(pathSet)); ++ ++ ::IShellItem* psiPath; ++ if (!SUCCEEDED(psiaPathSet->GetItemAt(index, &psiPath))) { ++ NFDi_SetError("Could not get shell item."); ++ return NFD_ERROR; ++ } ++ ++ Release_Guard<::IShellItem> psiPathGuard(psiPath); ++ ++ nfdnchar_t* name; ++ if (!SUCCEEDED(psiPath->GetDisplayName(::SIGDN_FILESYSPATH, &name))) { ++ NFDi_SetError("Could not get file path from shell item."); ++ return NFD_ERROR; ++ } ++ ++ *outPath = name; ++ return NFD_OKAY; ++} ++ ++nfdresult_t NFD_PathSet_GetEnum(const nfdpathset_t* pathSet, nfdpathsetenum_t* outEnumerator) { ++ assert(pathSet); ++ // const_cast because methods on IShellItemArray aren't const, but it should act like const to ++ // the caller ++ ::IShellItemArray* psiaPathSet = ++ const_cast<::IShellItemArray*>(static_cast(pathSet)); ++ ++ ::IEnumShellItems* pesiPaths; ++ if (!SUCCEEDED(psiaPathSet->EnumItems(&pesiPaths))) { ++ NFDi_SetError("Could not get enumerator."); ++ return NFD_ERROR; ++ } ++ ++ outEnumerator->ptr = static_cast(pesiPaths); ++ return NFD_OKAY; ++} ++ ++void NFD_PathSet_FreeEnum(nfdpathsetenum_t* enumerator) { ++ assert(enumerator->ptr); ++ ++ ::IEnumShellItems* pesiPaths = static_cast<::IEnumShellItems*>(enumerator->ptr); ++ ++ // free the enumerator memory ++ pesiPaths->Release(); ++} ++ ++nfdresult_t NFD_PathSet_EnumNextN(nfdpathsetenum_t* enumerator, nfdnchar_t** outPath) { ++ assert(enumerator->ptr); ++ ++ ::IEnumShellItems* pesiPaths = static_cast<::IEnumShellItems*>(enumerator->ptr); ++ ++ ::IShellItem* psiPath; ++ HRESULT res = pesiPaths->Next(1, &psiPath, NULL); ++ if (!SUCCEEDED(res)) { ++ NFDi_SetError("Could not get next item of enumerator."); ++ return NFD_ERROR; ++ } ++ if (res != S_OK) { ++ *outPath = nullptr; ++ return NFD_OKAY; ++ } ++ ++ Release_Guard<::IShellItem> psiPathGuard(psiPath); ++ ++ nfdnchar_t* name; ++ if (!SUCCEEDED(psiPath->GetDisplayName(::SIGDN_FILESYSPATH, &name))) { ++ NFDi_SetError("Could not get file path from shell item."); ++ return NFD_ERROR; ++ } ++ ++ *outPath = name; ++ return NFD_OKAY; ++} ++ ++void NFD_PathSet_Free(const nfdpathset_t* pathSet) { ++ assert(pathSet); ++ // const_cast because methods on IShellItemArray aren't const, but it should act like const to ++ // the caller ++ ::IShellItemArray* psiaPathSet = ++ const_cast<::IShellItemArray*>(static_cast(pathSet)); ++ ++ // free the path set memory ++ psiaPathSet->Release(); ++} ++ ++namespace { ++// allocs the space in outStr -- call NFDi_Free() ++nfdresult_t CopyCharToWChar(const nfdu8char_t* inStr, nfdnchar_t*& outStr) { ++ int charsNeeded = MultiByteToWideChar(CP_UTF8, 0, inStr, -1, nullptr, 0); ++ assert(charsNeeded); ++ ++ nfdnchar_t* tmp_outStr = NFDi_Malloc(sizeof(nfdnchar_t) * charsNeeded); ++ if (!tmp_outStr) { ++ return NFD_ERROR; ++ } ++ ++ int ret = MultiByteToWideChar(CP_UTF8, 0, inStr, -1, tmp_outStr, charsNeeded); ++ assert(ret && ret == charsNeeded); ++ (void)ret; // prevent warning in release build ++ outStr = tmp_outStr; ++ return NFD_OKAY; ++} ++ ++// allocs the space in outPath -- call NFDi_Free() ++nfdresult_t CopyWCharToNFDChar(const nfdnchar_t* inStr, nfdu8char_t*& outStr) { ++ int bytesNeeded = WideCharToMultiByte(CP_UTF8, 0, inStr, -1, nullptr, 0, nullptr, nullptr); ++ assert(bytesNeeded); ++ ++ nfdu8char_t* tmp_outStr = NFDi_Malloc(sizeof(nfdu8char_t) * bytesNeeded); ++ if (!tmp_outStr) { ++ return NFD_ERROR; ++ } ++ ++ int ret = WideCharToMultiByte(CP_UTF8, 0, inStr, -1, tmp_outStr, bytesNeeded, nullptr, nullptr); ++ assert(ret && ret == bytesNeeded); ++ (void)ret; // prevent warning in release build ++ outStr = tmp_outStr; ++ return NFD_OKAY; ++} ++ ++struct FilterItem_Guard { ++ nfdnfilteritem_t* data; ++ nfdfiltersize_t index; ++ FilterItem_Guard() noexcept : data(nullptr), index(0) {} ++ ~FilterItem_Guard() { ++ assert(data || index == 0); ++ for (--index; index != static_cast(-1); --index) { ++ NFDi_Free(const_cast(data[index].spec)); ++ NFDi_Free(const_cast(data[index].name)); ++ } ++ if (data) NFDi_Free(data); ++ } ++}; ++ ++nfdresult_t CopyFilterItem(const nfdu8filteritem_t* filterList, ++ nfdfiltersize_t count, ++ FilterItem_Guard& filterItemsNGuard) { ++ if (count) { ++ nfdnfilteritem_t*& filterItemsN = filterItemsNGuard.data; ++ filterItemsN = NFDi_Malloc(sizeof(nfdnfilteritem_t) * count); ++ if (!filterItemsN) { ++ return NFD_ERROR; ++ } ++ ++ nfdfiltersize_t& index = filterItemsNGuard.index; ++ for (; index != count; ++index) { ++ nfdresult_t res = CopyCharToWChar(filterList[index].name, ++ const_cast(filterItemsN[index].name)); ++ if (!res) { ++ return NFD_ERROR; ++ } ++ res = CopyCharToWChar(filterList[index].spec, ++ const_cast(filterItemsN[index].spec)); ++ if (!res) { ++ // remember to free the name, because we also created it (and it won't be protected ++ // by the guard, because we have not incremented the index) ++ NFDi_Free(const_cast(filterItemsN[index].name)); ++ return NFD_ERROR; ++ } ++ } ++ } ++ return NFD_OKAY; ++} ++nfdresult_t ConvertU8ToNative(const nfdu8char_t* u8Text, FreeCheck_Guard& nativeText) { ++ if (u8Text) { ++ nfdresult_t res = CopyCharToWChar(u8Text, nativeText.data); ++ if (!res) { ++ return NFD_ERROR; ++ } ++ } ++ return NFD_OKAY; ++} ++void NormalizePathSeparator(nfdnchar_t* path) { ++ if (path) { ++ for (; *path; ++path) { ++ if (*path == L'/') *path = L'\\'; ++ } ++ } ++} ++} // namespace ++ ++void NFD_FreePathU8(nfdu8char_t* outPath) { ++ NFDi_Free(outPath); ++} ++ ++nfdresult_t NFD_OpenDialogU8(nfdu8char_t** outPath, ++ const nfdu8filteritem_t* filterList, ++ nfdfiltersize_t count, ++ const nfdu8char_t* defaultPath) { ++ // populate the real nfdnfilteritem_t ++ FilterItem_Guard filterItemsNGuard; ++ if (!CopyFilterItem(filterList, count, filterItemsNGuard)) { ++ return NFD_ERROR; ++ } ++ ++ // convert and normalize the default path, but only if it is not nullptr ++ FreeCheck_Guard defaultPathNGuard; ++ ConvertU8ToNative(defaultPath, defaultPathNGuard); ++ NormalizePathSeparator(defaultPathNGuard.data); ++ ++ // call the native function ++ nfdnchar_t* outPathN; ++ nfdresult_t res = ++ NFD_OpenDialogN(&outPathN, filterItemsNGuard.data, count, defaultPathNGuard.data); ++ ++ if (res != NFD_OKAY) { ++ return res; ++ } ++ ++ // convert the outPath to UTF-8 ++ res = CopyWCharToNFDChar(outPathN, *outPath); ++ ++ // free the native out path, and return the result ++ NFD_FreePathN(outPathN); ++ return res; ++} ++ ++/* multiple file open dialog */ ++/* It is the caller's responsibility to free `outPaths` via NFD_PathSet_Free() if this function ++ * returns NFD_OKAY */ ++nfdresult_t NFD_OpenDialogMultipleU8(const nfdpathset_t** outPaths, ++ const nfdu8filteritem_t* filterList, ++ nfdfiltersize_t count, ++ const nfdu8char_t* defaultPath) { ++ // populate the real nfdnfilteritem_t ++ FilterItem_Guard filterItemsNGuard; ++ if (!CopyFilterItem(filterList, count, filterItemsNGuard)) { ++ return NFD_ERROR; ++ } ++ ++ // convert and normalize the default path, but only if it is not nullptr ++ FreeCheck_Guard defaultPathNGuard; ++ ConvertU8ToNative(defaultPath, defaultPathNGuard); ++ NormalizePathSeparator(defaultPathNGuard.data); ++ ++ // call the native function ++ return NFD_OpenDialogMultipleN(outPaths, filterItemsNGuard.data, count, defaultPathNGuard.data); ++} ++ ++/* save dialog */ ++/* It is the caller's responsibility to free `outPath` via NFD_FreePathU8() if this function returns ++ * NFD_OKAY */ ++nfdresult_t NFD_SaveDialogU8(nfdu8char_t** outPath, ++ const nfdu8filteritem_t* filterList, ++ nfdfiltersize_t count, ++ const nfdu8char_t* defaultPath, ++ const nfdu8char_t* defaultName) { ++ // populate the real nfdnfilteritem_t ++ FilterItem_Guard filterItemsNGuard; ++ if (!CopyFilterItem(filterList, count, filterItemsNGuard)) { ++ return NFD_ERROR; ++ } ++ ++ // convert and normalize the default path, but only if it is not nullptr ++ FreeCheck_Guard defaultPathNGuard; ++ ConvertU8ToNative(defaultPath, defaultPathNGuard); ++ NormalizePathSeparator(defaultPathNGuard.data); ++ ++ // convert the default name, but only if it is not nullptr ++ FreeCheck_Guard defaultNameNGuard; ++ ConvertU8ToNative(defaultName, defaultNameNGuard); ++ ++ // call the native function ++ nfdnchar_t* outPathN; ++ nfdresult_t res = NFD_SaveDialogN( ++ &outPathN, filterItemsNGuard.data, count, defaultPathNGuard.data, defaultNameNGuard.data); ++ ++ if (res != NFD_OKAY) { ++ return res; ++ } ++ ++ // convert the outPath to UTF-8 ++ res = CopyWCharToNFDChar(outPathN, *outPath); ++ ++ // free the native out path, and return the result ++ NFD_FreePathN(outPathN); ++ return res; ++} ++ ++/* select folder dialog */ ++/* It is the caller's responsibility to free `outPath` via NFD_FreePathU8() if this function returns ++ * NFD_OKAY */ ++nfdresult_t NFD_PickFolderU8(nfdu8char_t** outPath, const nfdu8char_t* defaultPath) { ++ // convert and normalize the default path, but only if it is not nullptr ++ FreeCheck_Guard defaultPathNGuard; ++ ConvertU8ToNative(defaultPath, defaultPathNGuard); ++ NormalizePathSeparator(defaultPathNGuard.data); ++ ++ // call the native function ++ nfdnchar_t* outPathN; ++ nfdresult_t res = NFD_PickFolderN(&outPathN, defaultPathNGuard.data); ++ ++ if (res != NFD_OKAY) { ++ return res; ++ } ++ ++ // convert the outPath to UTF-8 ++ res = CopyWCharToNFDChar(outPathN, *outPath); ++ ++ // free the native out path, and return the result ++ NFD_FreePathN(outPathN); ++ return res; ++} ++ ++/* Get the UTF-8 path at offset index */ ++/* It is the caller's responsibility to free `outPath` via NFD_FreePathU8() if this function returns ++ * NFD_OKAY */ ++nfdresult_t NFD_PathSet_GetPathU8(const nfdpathset_t* pathSet, ++ nfdpathsetsize_t index, ++ nfdu8char_t** outPath) { ++ // call the native function ++ nfdnchar_t* outPathN; ++ nfdresult_t res = NFD_PathSet_GetPathN(pathSet, index, &outPathN); ++ ++ if (res != NFD_OKAY) { ++ return res; ++ } ++ ++ // convert the outPath to UTF-8 ++ res = CopyWCharToNFDChar(outPathN, *outPath); ++ ++ // free the native out path, and return the result ++ NFD_FreePathN(outPathN); ++ return res; ++} ++ ++nfdresult_t NFD_PathSet_EnumNextU8(nfdpathsetenum_t* enumerator, nfdu8char_t** outPath) { ++ // call the native function ++ nfdnchar_t* outPathN; ++ nfdresult_t res = NFD_PathSet_EnumNextN(enumerator, &outPathN); ++ ++ if (res != NFD_OKAY) { ++ return res; ++ } ++ ++ if (outPathN) { ++ // convert the outPath to UTF-8 ++ res = CopyWCharToNFDChar(outPathN, *outPath); ++ ++ // free the native out path, and return the result ++ NFD_FreePathN(outPathN); ++ } else { ++ *outPath = nullptr; ++ res = NFD_OKAY; ++ } ++ ++ return res; ++} diff --git a/T/TracyProfiler/bundled/patches/library_extension.patch b/T/TracyProfiler/bundled/patches/library_extension.patch deleted file mode 100644 index 2929d0b5df7..00000000000 --- a/T/TracyProfiler/bundled/patches/library_extension.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/library/unix/build.mk -+++ b/library/unix/build.mk -@@ -4,7 +4,7 @@ - INCLUDES := - LIBS := -lpthread -ldl - PROJECT := libtracy --IMAGE := $(PROJECT)-$(BUILD).so -+IMAGE := $(PROJECT)-$(BUILD).$(dlext) - SHARED_LIBRARY := yes - - SRC := ../../TracyClient.cpp diff --git a/T/TracyProfiler/bundled/patches/unix_common_make.patch b/T/TracyProfiler/bundled/patches/unix_common_make.patch deleted file mode 100644 index 39e65882465..00000000000 --- a/T/TracyProfiler/bundled/patches/unix_common_make.patch +++ /dev/null @@ -1,13 +0,0 @@ ---- a/common/unix-release.mk -+++ b/common/unix-release.mk -@@ -5,9 +5,4 @@ - else - LDFLAGS := -s - endif -- -+DEFINES += -D__STDC_FORMAT_MACROS --ifneq (,$(filter $(ARCH),aarch64 arm64)) --CFLAGS += -mcpu=native --else --CFLAGS += -march=native --endif diff --git a/T/TracyProfiler/bundled/patches/unix_library_release.patch b/T/TracyProfiler/bundled/patches/unix_library_release.patch deleted file mode 100644 index 35da355ba6b..00000000000 --- a/T/TracyProfiler/bundled/patches/unix_library_release.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/library/unix/release.mk -+++ b/library/unix/release.mk -@@ -1,7 +1,7 @@ - ARCH := $(shell uname -m) - - CFLAGS := -O3 -s --DEFINES := -DNDEBUG -+DEFINES := -DNDEBUG -D__STDC_FORMAT_MACROS - BUILD := release - - ifeq ($(ARCH),x86_64) diff --git a/T/Typst/build_tarballs.jl b/T/Typst/build_tarballs.jl new file mode 100644 index 00000000000..cc70577a66c --- /dev/null +++ b/T/Typst/build_tarballs.jl @@ -0,0 +1,35 @@ +# 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 + +name = "Typst" +version = v"0.2.0" + +# Collection of sources required to complete build +sources = [ + GitSource("https://github.com/typst/typst.git", "fe2640c55268f167d8749f77b37e52b7b17f21dd") +] + +# Bash recipe for building across all platforms +script = raw""" +cd $WORKSPACE/srcdir/typst +cargo build -p typst-cli --release +install -Dvm 755 "target/${rust_target}/release/typst${exeext}" "${bindir}/typst${exeext}" +install_license LICENSE +""" + +# These are the platforms we will build for by default, unless further +# platforms are passed in on the command line +platforms = filter(p -> !(Sys.iswindows(p) && arch(p) == "i686"), supported_platforms()) + +# The products that we will ensure are always built +products = [ + ExecutableProduct("typst", :typst), +] + +# Dependencies that must be installed before this package can be built +dependencies = Dependency[ +] + +# Build the tarballs, and possibly a `build.jl` as well. +build_tarballs(ARGS, name, version, sources, script, platforms, products, dependencies; julia_compat="1.6", compilers=[:rust, :c])