diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9d5051a..12c0f08 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -53,18 +53,15 @@ jobs: set_env('BUILD_VERSION', buildVersion) set_env('RELEASE_VERSION', releaseVersion) - - name: Build Rust + - name: Install nightly Rust run: | - git clone https://github.com/rust-lang/rust.git -b 1.91.0 - cd rust - ./x check - ./x build --stage 2 + rustup toolchain install nightly --profile complete + rustup default nightly - rustup toolchain link stage0 build/host/stage0-sysroot - rustup toolchain link stage1 build/host/stage1 - rustup toolchain link stage2 build/host/stage2 - rustc +stage2 -vV + rustc -vV which rustc + rustc --print target-list|grep vision + rustc --print target-list|grep tvos - name: Install cargo-c run: | @@ -72,10 +69,6 @@ jobs: - name: Build run: | - rustc +stage2 -vV - which rustc - rustc +stage2 --print target-list|grep vision - rustc +stage2 --print target-list|grep tvos make build version=${{ env.RELEASE_VERSION }} - name: Update Package.swift diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..644eb4b --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,71 @@ +name: Build and Release + +on: + push: + branches: + - ci + workflow_dispatch: + +jobs: + build: + permissions: + contents: write + runs-on: macos-14 + steps: + - uses: actions/checkout@v4 + + - name: Install dependencies + run: | + brew install autoconf + brew install automake + brew install libtool + python -m pip install meson==1.4.2 + brew install ninja + + + - name: Setup Xcode to support visionOS + run: | + sudo xcode-select -s /Applications/Xcode_15.4.app/Contents/Developer + xcodebuild -showsdks + + - name: Check version to release + uses: jannekem/run-python-script-action@v1 + with: + script: | + import re + + def normalize_version(version_string): + version_string = re.sub(r'[^.0-9]+|-.+', '', version_string) + parts = re.split(r'\.', version_string) + major = int(parts[0]) + minor = int(parts[1]) if len(parts) > 1 else 0 + patch = int(parts[2]) if len(parts) > 2 else 0 + return f"{major}.{minor}.{patch}" + + file_path = './Sources/BuildScripts/XCFrameworkBuild/main.swift' + with open(file_path, 'r', encoding='utf-8') as file: + content = file.read() + buildVersion = re.search(r'(case .libdovi[^"]+?)"(.+?)"', content).group(2) + print(f'build version: {buildVersion}') + releaseVersion = '${{ github.event.inputs.version }}' or normalize_version(buildVersion) + print(f'release version: {releaseVersion}') + set_env('BUILD_VERSION', buildVersion) + set_env('RELEASE_VERSION', releaseVersion) + + - name: Install nightly Rust + run: | + rustup toolchain install nightly --profile complete + rustup default nightly + + rustc -vV + which rustc + rustc --print target-list|grep vision + rustc --print target-list|grep tvos + + - name: Install cargo-c + run: | + cargo install cargo-c + + - name: Build + run: | + make build version=${{ env.RELEASE_VERSION }} diff --git a/README.md b/README.md index 1b45d6e..a8e8604 100644 --- a/README.md +++ b/README.md @@ -18,19 +18,14 @@ https://github.com/mpvkit/libdovi-build.git curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh ``` -### build rustc support tvOS arm64e target +### install nightly version to support tvOS arm64e target ``` -git clone https://github.com/rust-lang/rust.git -b ${{ github.event.inputs.version }} -cd rust -git apply ../patch/rust/01-tvos_arm64e_support.patch -./x check -./x build --stage 2 +# install +rustup toolchain install nightly --profile complete +rustup default nightly -rustup toolchain link stage0 build/host/stage0-sysroot -rustup toolchain link stage1 build/host/stage1 -rustup toolchain link stage2 build/host/stage2 -rustc +stage2 -vV +rustc -vV ``` diff --git a/Sources/BuildScripts/XCFrameworkBuild/main.swift b/Sources/BuildScripts/XCFrameworkBuild/main.swift index a719ba0..f87e943 100644 --- a/Sources/BuildScripts/XCFrameworkBuild/main.swift +++ b/Sources/BuildScripts/XCFrameworkBuild/main.swift @@ -72,7 +72,7 @@ private class BuildDovi: BaseBuild { let environ = environment(platform: platform, arch: arch) let cargo = Utility.shell("which cargo", isOutput: true, environment: environ)! - try Utility.launch(path: cargo, arguments: ["+stage2", "cinstall", "-Zbuild-std=std,panic_abort", "--release", "--prefix=\(prefix.path)", "--target=\(target)"] , currentDirectoryURL: currentDirectoryURL, environment: environ) + try Utility.launch(path: cargo, arguments: ["cinstall", "-Zbuild-std=std,panic_abort", "--release", "--prefix=\(prefix.path)", "--target=\(target)"] , currentDirectoryURL: currentDirectoryURL, environment: environ) } } diff --git a/patch/cargo-c/01-add-visionos-support.patch b/patch/cargo-c/01-add-visionos-support.patch deleted file mode 100644 index b40c73b..0000000 --- a/patch/cargo-c/01-add-visionos-support.patch +++ /dev/null @@ -1,53 +0,0 @@ -From b18bf33dc494bc0e9feb90ad3af93411020be98d Mon Sep 17 00:00:00 2001 -From: cxfksword <718792+cxfksword@users.noreply.github.com> -Date: Sun, 14 Jul 2024 15:49:13 +0800 -Subject: [PATCH] Add visionOS support - ---- - src/build_targets.rs | 2 +- - src/install.rs | 2 +- - src/target.rs | 2 +- - 3 files changed, 3 insertions(+), 3 deletions(-) - -diff --git a/src/build_targets.rs b/src/build_targets.rs -index eb10d8d..a2b0d6c 100644 ---- a/src/build_targets.rs -+++ b/src/build_targets.rs -@@ -96,7 +96,7 @@ impl BuildTargets { - let shared_lib = targetdir.join(format!("lib{lib_name}.so")); - (shared_lib, static_lib, None, None, None) - } -- ("macos", _) | ("ios", _) | ("tvos", _) => { -+ ("macos", _) | ("ios", _) | ("tvos", _) | ("visionos", _) => { - let static_lib = targetdir.join(format!("lib{lib_name}.a")); - let shared_lib = targetdir.join(format!("lib{lib_name}.dylib")); - (shared_lib, static_lib, None, None, None) -diff --git a/src/install.rs b/src/install.rs -index 92eb8cb..eee4db7 100644 ---- a/src/install.rs -+++ b/src/install.rs -@@ -92,7 +92,7 @@ impl LibType { - | ("haiku", _) - | ("illumos", _) - | ("emscripten", _) => LibType::So, -- ("macos", _) | ("ios", _) | ("tvos", _) => LibType::Dylib, -+ ("macos", _) | ("ios", _) | ("tvos", _) | ("visionos", _) => LibType::Dylib, - ("windows", _) => LibType::Windows, - _ => unimplemented!("The target {}-{} is not supported yet", os, env), - } -diff --git a/src/target.rs b/src/target.rs -index 0b28bd3..3a070a0 100644 ---- a/src/target.rs -+++ b/src/target.rs -@@ -93,7 +93,7 @@ impl Target { - } else { - format!("-Wl,-soname,lib{lib_name}.so") - }); -- } else if os == "macos" || os == "ios" || os == "tvos" { -+ } else if os == "macos" || os == "ios" || os == "tvos" || os == "visionos" { - let line = if capi_config.library.versioning { - format!("-Wl,-install_name,{1}/lib{0}.{5}.dylib,-current_version,{2}.{3}.{4},-compatibility_version,{5}", - lib_name, libdir.display(), major, minor, patch, sover) --- -2.37.5 - diff --git a/patch/rust/01-tvos_arm64e_support.patch b/patch/rust/01-tvos_arm64e_support.patch deleted file mode 100644 index 7f15336..0000000 --- a/patch/rust/01-tvos_arm64e_support.patch +++ /dev/null @@ -1,114 +0,0 @@ -From 7a365bc05bc8651230c580c8ef638d5ab07033ff Mon Sep 17 00:00:00 2001 -From: cxfksword <718792+cxfksword@users.noreply.github.com> -Date: Sun, 14 Jul 2024 18:23:18 +0800 -Subject: [PATCH] add tvos arm64e target - ---- - .../rustc_target/src/spec/base/apple/mod.rs | 20 +++++++++----- - compiler/rustc_target/src/spec/mod.rs | 1 + - .../src/spec/targets/arm64e_apple_tvos.rs | 27 +++++++++++++++++++ - 3 files changed, 41 insertions(+), 7 deletions(-) - create mode 100644 compiler/rustc_target/src/spec/targets/arm64e_apple_tvos.rs - -diff --git a/compiler/rustc_target/src/spec/base/apple/mod.rs b/compiler/rustc_target/src/spec/base/apple/mod.rs -index 05542009083..c78079a6d7d 100644 ---- a/compiler/rustc_target/src/spec/base/apple/mod.rs -+++ b/compiler/rustc_target/src/spec/base/apple/mod.rs -@@ -104,7 +104,7 @@ fn pre_link_args(os: &'static str, arch: Arch, abi: TargetAbi) -> LinkArgs { - let min_version: StaticCow = { - let (major, minor) = match os { - "ios" => ios_deployment_target(arch, abi.target_abi()), -- "tvos" => tvos_deployment_target(), -+ "tvos" => tvos_deployment_target(arch), - "watchos" => watchos_deployment_target(), - "visionos" => visionos_deployment_target(), - "macos" => macos_deployment_target(arch), -@@ -247,7 +247,13 @@ pub fn deployment_target(target: &Target) -> Option<(u32, u32)> { - ios_deployment_target(arch, &target.abi) - } - "watchos" => watchos_deployment_target(), -- "tvos" => tvos_deployment_target(), -+ "tvos" => { -+ let arch = match target.arch.as_ref() { -+ "arm64e" => Arm64e, -+ _ => Arm64, -+ }; -+ tvos_deployment_target(arch) -+ }, - "visionos" => visionos_deployment_target(), - _ => return None, - }; -@@ -352,19 +358,19 @@ pub fn ios_sim_llvm_target(arch: Arch) -> String { - format!("{}-apple-ios{}.{}.0-simulator", arch.target_name(), major, minor) - } - --fn tvos_deployment_target() -> (u32, u32) { -+fn tvos_deployment_target(arch: Arch) -> (u32, u32) { - // If you are looking for the default deployment target, prefer `rustc --print deployment-target`. -- // Note: If bumping this version, remember to update it in the rustc platform-support docs. -- from_set_deployment_target("TVOS_DEPLOYMENT_TARGET").unwrap_or((10, 0)) -+ let (major, minor) = if arch == Arm64e { (14, 0) } else { (10, 0) }; -+ from_set_deployment_target("TVOS_DEPLOYMENT_TARGET").unwrap_or((major, minor)) - } - - pub fn tvos_llvm_target(arch: Arch) -> String { -- let (major, minor) = tvos_deployment_target(); -+ let (major, minor) = tvos_deployment_target(arch); - format!("{}-apple-tvos{}.{}.0", arch.target_name(), major, minor) - } - - pub fn tvos_sim_llvm_target(arch: Arch) -> String { -- let (major, minor) = tvos_deployment_target(); -+ let (major, minor) = tvos_deployment_target(arch); - format!("{}-apple-tvos{}.{}.0-simulator", arch.target_name(), major, minor) - } - -diff --git a/compiler/rustc_target/src/spec/mod.rs b/compiler/rustc_target/src/spec/mod.rs -index fe07d116726..fe1e3091ec0 100644 ---- a/compiler/rustc_target/src/spec/mod.rs -+++ b/compiler/rustc_target/src/spec/mod.rs -@@ -1660,6 +1660,7 @@ fn $module() { - ("aarch64-apple-tvos", aarch64_apple_tvos), - ("aarch64-apple-tvos-sim", aarch64_apple_tvos_sim), - ("x86_64-apple-tvos", x86_64_apple_tvos), -+ ("arm64e-apple-tvos", arm64e_apple_tvos), - - ("armv7k-apple-watchos", armv7k_apple_watchos), - ("arm64_32-apple-watchos", arm64_32_apple_watchos), -diff --git a/compiler/rustc_target/src/spec/targets/arm64e_apple_tvos.rs b/compiler/rustc_target/src/spec/targets/arm64e_apple_tvos.rs -new file mode 100644 -index 00000000000..087bc8bfde1 ---- /dev/null -+++ b/compiler/rustc_target/src/spec/targets/arm64e_apple_tvos.rs -@@ -0,0 +1,27 @@ -+use crate::spec::base::apple::{tvos_llvm_target, opts, Arch, TargetAbi}; -+use crate::spec::{FramePointer, SanitizerSet, Target, TargetOptions}; -+ -+pub fn target() -> Target { -+ let arch = Arch::Arm64e; -+ let mut base = opts("tvos", arch, TargetAbi::Normal); -+ base.supported_sanitizers = SanitizerSet::ADDRESS | SanitizerSet::THREAD; -+ -+ Target { -+ llvm_target: tvos_llvm_target(arch).into(), -+ metadata: crate::spec::TargetMetadata { -+ description: None, -+ tier: None, -+ host_tools: None, -+ std: None, -+ }, -+ pointer_width: 64, -+ data_layout: "e-m:o-i64:64-i128:128-n32:64-S128".into(), -+ arch: arch.target_arch(), -+ options: TargetOptions { -+ features: "+neon,+fp-armv8,+apple-a12,+v8.3a,+pauth".into(), -+ max_atomic_width: Some(128), -+ frame_pointer: FramePointer::NonLeaf, -+ ..base -+ }, -+ } -+} -\ No newline at end of file --- -2.37.5 -