Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
118 changes: 59 additions & 59 deletions Artifacts.toml
Original file line number Diff line number Diff line change
Expand Up @@ -128,65 +128,6 @@ os = "linux"
sha256 = "8121c8d7d9152a835c84bf6b586c107ae582ed051780d37cb1e6f4f9bdad23aa"
url = "https://static.rust-lang.org/dist/rust-1.91.0-loongarch64-unknown-linux-gnu.tar.gz"
[[RustToolChain]]
arch = "aarch64"
git-tree-sha1 = "93b440f452efaef4bc8030218a79bc6c039c95b6"
lazy = true
os = "macos"

[[RustToolChain.download]]
sha256 = "630349bd157632ff65aafd1b5753e6a09153278cdac8196e8678b40b30cf1ecb"
url = "https://static.rust-lang.org/dist/rust-1.94.1-aarch64-apple-darwin.tar.gz"
[[RustToolChain]]
arch = "x86_64"
git-tree-sha1 = "bea533b32d99b7554f9c9f046d84498ba56dbbe2"
lazy = true
os = "macos"

[[RustToolChain.download]]
sha256 = "6d9c5a4bf9962987d616417e2669a50b52cc7ecbfa682d56e9ce8244a57d7b60"
url = "https://static.rust-lang.org/dist/rust-1.94.1-x86_64-apple-darwin.tar.gz"
[[RustToolChain]]
arch = "i686"
git-tree-sha1 = "b4e32a7d8d9cf59163eacd7761eb26f0e0feae0a"
lazy = true
libc = "glibc"
os = "linux"

[[RustToolChain.download]]
sha256 = "b458db6cf8366fa9f830bf05b15e3866fbb2b7e0a1921b91fd52aff9accfb405"
url = "https://static.rust-lang.org/dist/rust-1.94.1-i686-unknown-linux-gnu.tar.gz"
[[RustToolChain]]
arch = "x86_64"
git-tree-sha1 = "9c769251be2fe1312b6cb5efbc73326683cc542a"
lazy = true
libc = "glibc"
os = "linux"

[[RustToolChain.download]]
sha256 = "ea7866c5cab0d8c99e7416bcc5f9ecf0e122d396b85c7e7dee5669f10ee80194"
url = "https://static.rust-lang.org/dist/rust-1.94.1-x86_64-unknown-linux-gnu.tar.gz"
[[RustToolChain]]
arch = "aarch64"
git-tree-sha1 = "fa2d990a11c67d428c7a991af2a97281baa85a9a"
lazy = true
libc = "glibc"
os = "linux"

[[RustToolChain.download]]
sha256 = "99dba6decb780158b2b94f0054ec15c8cd4a04a497c84349fb86fb7a70722c78"
url = "https://static.rust-lang.org/dist/rust-1.94.1-aarch64-unknown-linux-gnu.tar.gz"
[[RustToolChain]]
arch = "armv6l"
call_abi = "eabihf"
git-tree-sha1 = "36e7bcb4eefc3eb0ab1572de6e10c4c14fcb5f64"
lazy = true
libc = "glibc"
os = "linux"

[[RustToolChain.download]]
sha256 = "0b5d43c00ef1a72352f7b08937018ab52f624047f1403e0d2c4d7c67456eff16"
url = "https://static.rust-lang.org/dist/rust-1.94.1-arm-unknown-linux-gnueabihf.tar.gz"
[[RustToolChain]]
arch = "armv7l"
call_abi = "eabihf"
git-tree-sha1 = "579ef58b0051123bccc4b685ecd6adc5ef616e14"
Expand Down Expand Up @@ -264,3 +205,62 @@ os = "windows"
[[RustToolChain.download]]
sha256 = "3b19e5264498b303127532b8497165c7c94968161b1a7fcf693a75826ff26d31"
url = "https://static.rust-lang.org/dist/rust-1.94.1-x86_64-pc-windows-msvc.tar.gz"
[[RustToolChain]]
arch = "aarch64"
git-tree-sha1 = "63a2cec15ef25f7e0bad09e243056570317a995b"
lazy = true
os = "macos"

[[RustToolChain.download]]
sha256 = "ec23ad2e0e15a7397d2c3c232356149cc871b7df7f47e25c2acb1070157f5398"
url = "https://static.rust-lang.org/dist/rust-1.95.0-aarch64-apple-darwin.tar.gz"
[[RustToolChain]]
arch = "x86_64"
git-tree-sha1 = "45d00a22f1575daad2d25d5f2ceb41915fd82c77"
lazy = true
os = "macos"

[[RustToolChain.download]]
sha256 = "3f3d9f29f8eb7aa821bd8531cb9b1c3c74c3976aa558dfabfcc15c2febb3cfb8"
url = "https://static.rust-lang.org/dist/rust-1.95.0-x86_64-apple-darwin.tar.gz"
[[RustToolChain]]
arch = "i686"
git-tree-sha1 = "69fb6c134be01b50876cd89f5ebe612c9f845173"
lazy = true
libc = "glibc"
os = "linux"

[[RustToolChain.download]]
sha256 = "3ef2320bdfa9b69b19c6ca42f950b6bfb9d2af3b925b0c43a6bfecc4d355a66e"
url = "https://static.rust-lang.org/dist/rust-1.95.0-i686-unknown-linux-gnu.tar.gz"
[[RustToolChain]]
arch = "x86_64"
git-tree-sha1 = "9d2c0cddc073eb558221929c81df69c1c8d214e7"
lazy = true
libc = "glibc"
os = "linux"

[[RustToolChain.download]]
sha256 = "a47ac940abd12399d59ad15c877e7113fa35f2b9ec7e6a8a045d4fd8b9741dea"
url = "https://static.rust-lang.org/dist/rust-1.95.0-x86_64-unknown-linux-gnu.tar.gz"
[[RustToolChain]]
arch = "aarch64"
git-tree-sha1 = "a52ca872c7d7c75357385df9319cc3b988f96c92"
lazy = true
libc = "glibc"
os = "linux"

[[RustToolChain.download]]
sha256 = "3b9385d3144ac57616befa0ccbac524f857ba1b4ab074226e73a24d43568a98e"
url = "https://static.rust-lang.org/dist/rust-1.95.0-aarch64-unknown-linux-gnu.tar.gz"
[[RustToolChain]]
arch = "armv6l"
call_abi = "eabihf"
git-tree-sha1 = "134938e77fb845aba19b473fce1873af5925c154"
lazy = true
libc = "glibc"
os = "linux"

[[RustToolChain.download]]
sha256 = "7d742098e8bb0d10415775634eed83240ae88c1bae6bc73b470ccf0be4629b4c"
url = "https://static.rust-lang.org/dist/rust-1.95.0-arm-unknown-linux-gnueabihf.tar.gz"
4 changes: 3 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ Pkg = "1"
julia = "1.10"

[extras]
Downloads = "f43a241f-c20a-4ad4-852c-f6b1247861c6"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
TOML = "fa267f1f-6049-4f14-aa54-33bafae1ed76"

[targets]
test = ["Test"]
test = ["Downloads", "TOML", "Test"]
2 changes: 2 additions & 0 deletions gen/Project.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
[deps]
ArtifactUtils = "8b73e784-e7d8-4ea5-973d-377fed4e3bce"
Downloads = "f43a241f-c20a-4ad4-852c-f6b1247861c6"
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
TOML = "fa267f1f-6049-4f14-aa54-33bafae1ed76"
68 changes: 19 additions & 49 deletions gen/generate_Artifacts_toml.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
using Base.BinaryPlatforms: Platform
using ArtifactUtils
using Pkg.Artifacts

include(joinpath(@__DIR__, "rust_dist_targets.jl"))

const RUST_VERSION = if length(ARGS) > 0
strip(ARGS[1])
else
Expand All @@ -10,61 +11,30 @@ end
const ARTIFACTS_TOML = joinpath(dirname(@__DIR__), "Artifacts.toml")
const ARTIFACT_NAME = "RustToolChain"

# バージョン形式の検証(X.Y.Z 形式のみ)
function validate_version(version::AbstractString)::Bool
return match(r"^\d+\.\d+\.\d+$", version) !== nothing
# バージョン形式の検証
if !validate_version(RUST_VERSION)
error("Invalid Rust version format: '$RUST_VERSION'. Expected format: X.Y.Z (e.g., 1.92.0)")
end

# Rust triplet から Julia Platform へのマッピング
const PLATFORM_MAPPINGS = [
# Apple platforms
("aarch64-apple-darwin", Platform("aarch64", "macos")),
("x86_64-apple-darwin", Platform("x86_64", "macos")),

# Linux - GNU libc
("i686-unknown-linux-gnu", Platform("i686", "linux")),
("x86_64-unknown-linux-gnu", Platform("x86_64", "linux")),
("aarch64-unknown-linux-gnu", Platform("aarch64", "linux")),
("arm-unknown-linux-gnueabihf", Platform("armv6l", "linux")),
("armv7-unknown-linux-gnueabihf", Platform("armv7l", "linux")),
("powerpc64le-unknown-linux-gnu", Platform("powerpc64le", "linux")),
("riscv64gc-unknown-linux-gnu", Platform("riscv64", "linux")),
@info "Generating Artifacts.toml for Rust $RUST_VERSION"

# Linux - musl libc
# ("i686-unknown-linux-musl", Platform("i686", "linux"; libc="musl")),
("x86_64-unknown-linux-musl", Platform("x86_64", "linux"; libc="musl")),
("aarch64-unknown-linux-musl", Platform("aarch64", "linux"; libc="musl")),
("arm-unknown-linux-musleabihf", Platform("armv6l", "linux"; libc="musl")),
("armv7-unknown-linux-musleabihf", Platform("armv7l", "linux"; libc="musl")),
const SUPPORTED_PLATFORM_MAPPINGS = supported_platform_mappings_for_version(RUST_VERSION)

# FreeBSD
("x86_64-unknown-freebsd", Platform("x86_64", "freebsd")),
# ("aarch64-unknown-freebsd", Platform("aarch64", "freebsd")),
if isempty(SUPPORTED_PLATFORM_MAPPINGS)
error("No supported Rust installer targets found for Rust $RUST_VERSION")
end

# Windows
("i686-pc-windows-msvc", Platform("i686", "windows")),
("x86_64-pc-windows-msvc", Platform("x86_64", "windows")),
const SKIPPED_PLATFORM_TRIPLETS = [
triplet for (triplet, _) in PLATFORM_MAPPINGS
if triplet ∉ Set(first.(SUPPORTED_PLATFORM_MAPPINGS))
]

function rust_triplet_to_platform(triplet::String)
for (rust_triplet, platform) in PLATFORM_MAPPINGS
if rust_triplet == triplet
return platform
end
end
error("Unknown platform triplet: $triplet")
if !isempty(SKIPPED_PLATFORM_TRIPLETS)
@warn "Skipping targets missing from Rust distribution manifest" version=RUST_VERSION triplets=SKIPPED_PLATFORM_TRIPLETS
end

# バージョン形式の検証
if !validate_version(RUST_VERSION)
error("Invalid Rust version format: '$RUST_VERSION'. Expected format: X.Y.Z (e.g., 1.92.0)")
end

@info "Generating Artifacts.toml for Rust $RUST_VERSION"

function add_rust_toolchain_for_platform(triplet::String)
function add_rust_toolchain_for_platform(triplet::String, platform)
url = "https://static.rust-lang.org/dist/rust-$(RUST_VERSION)-$(triplet).tar.gz"
platform = rust_triplet_to_platform(triplet)

@info "Adding Rust toolchain for $triplet" platform url

Expand All @@ -80,12 +50,12 @@ function add_rust_toolchain_for_platform(triplet::String)
end

# すべてのプラットフォームを追加
for (triplet, _) in PLATFORM_MAPPINGS
for (triplet, platform) in SUPPORTED_PLATFORM_MAPPINGS
try
add_rust_toolchain_for_platform(triplet)
add_rust_toolchain_for_platform(triplet, platform)
catch e
@warn "Failed to add platform $triplet" exception=(e, catch_backtrace())
end
end

@info "Finished adding Rust toolchains to $ARTIFACTS_TOML"
@info "Finished adding Rust toolchains to $ARTIFACTS_TOML"
67 changes: 67 additions & 0 deletions gen/rust_dist_targets.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
using Base.BinaryPlatforms: Platform
using Downloads
using TOML

# Rust triplet から Julia Platform へのマッピング
const PLATFORM_MAPPINGS = [
# Apple platforms
("aarch64-apple-darwin", Platform("aarch64", "macos")),
("x86_64-apple-darwin", Platform("x86_64", "macos")),

# Linux - GNU libc
("i686-unknown-linux-gnu", Platform("i686", "linux")),
("x86_64-unknown-linux-gnu", Platform("x86_64", "linux")),
("aarch64-unknown-linux-gnu", Platform("aarch64", "linux")),
("arm-unknown-linux-gnueabihf", Platform("armv6l", "linux")),
("armv7-unknown-linux-gnueabihf", Platform("armv7l", "linux")),
("powerpc64le-unknown-linux-gnu", Platform("powerpc64le", "linux")),
("riscv64gc-unknown-linux-gnu", Platform("riscv64", "linux")),

# Linux - musl libc
("x86_64-unknown-linux-musl", Platform("x86_64", "linux"; libc="musl")),
("aarch64-unknown-linux-musl", Platform("aarch64", "linux"; libc="musl")),

# FreeBSD
("x86_64-unknown-freebsd", Platform("x86_64", "freebsd")),

# Windows
("i686-pc-windows-msvc", Platform("i686", "windows")),
("x86_64-pc-windows-msvc", Platform("x86_64", "windows")),
]

function validate_version(version::AbstractString)::Bool
return match(r"^\d+\.\d+\.\d+$", version) !== nothing
end

function rust_channel_manifest_url(version::AbstractString)::String
return "https://static.rust-lang.org/dist/channel-rust-$(version).toml"
end

function available_rust_targets(manifest_text::AbstractString)::Set{String}
parsed = TOML.parse(manifest_text)
pkg = get(parsed, "pkg", Dict{String, Any}())
rust = get(pkg, "rust", Dict{String, Any}())
targets = get(rust, "target", Dict{String, Any}())

return Set(
String(triplet) for (triplet, metadata) in pairs(targets)
if get(metadata, "available", false)
)
end

function supported_platform_mappings(manifest_text::AbstractString)
available_targets = available_rust_targets(manifest_text)
return [
(triplet, platform) for (triplet, platform) in PLATFORM_MAPPINGS
if triplet in available_targets
]
end

function supported_platform_mappings_for_version(version::AbstractString)
validate_version(version) || error(
"Invalid Rust version format: '$version'. Expected format: X.Y.Z (e.g., 1.92.0)",
)

manifest_text = read(Downloads.download(rust_channel_manifest_url(version)), String)
return supported_platform_mappings(manifest_text)
end
25 changes: 25 additions & 0 deletions test/generator_platforms.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using Test
using RustToolChain: RustToolChain

include(joinpath(pkgdir(RustToolChain), "gen", "rust_dist_targets.jl"))

@testset "Rust dist target filtering" begin
manifest = """
[pkg.rust.target.aarch64-apple-darwin]
available = true

[pkg.rust.target.x86_64-unknown-linux-musl]
available = true

[pkg.rust.target.armv7-unknown-linux-musleabihf]
available = true
"""

mappings = supported_platform_mappings(manifest)
triplets = first.(mappings)

@test "aarch64-apple-darwin" in triplets
@test "x86_64-unknown-linux-musl" in triplets
@test "armv7-unknown-linux-musleabihf" ∉ triplets
@test "arm-unknown-linux-musleabihf" ∉ triplets
end
2 changes: 2 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
using Test
using RustToolChain: RustToolChain, cargo, rustc

include("generator_platforms.jl")

@testset "RustToolChain" begin
@test cargo() isa Cmd
@test rustc() isa Cmd
Expand Down
Loading