Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Make builds use only one Package.swift #34

Merged
merged 3 commits into from
Nov 3, 2024
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
11 changes: 4 additions & 7 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,11 @@ jobs:

- name: Build with FFmpeg
run: |
mv Package.swift Package.standalone.swift
mv Package.ffmpeg.swift Package.swift
sha=$(git rev-parse --short HEAD)
xcrun swift build -Xswiftc -DFFMPEG --configuration release --arch arm64
USE_FFMPEG=1 xcrun swift build -Xswiftc -DFFMPEG --configuration release --arch arm64
tar -cvJf macSubtitleOCR-nightly-ffmpeg-${sha}.tar.xz -C .build/release/ macSubtitleOCR
gpg --detach-sign --armor macSubtitleOCR-nightly-ffmpeg-${sha}.tar.xz
gpg --verify macSubtitleOCR-nightly-ffmpeg-${sha}.tar.xz.asc macSubtitleOCR-nightly-ffmpeg-${sha}.tar.xz

gpg --detach-sign --armor macSubtitleOCR-ffmpeg-nightly-${sha}.tar.xz
gpg --verify macSubtitleOCR-nightly-ffmpeg-${sha}.tar.xz.asc macSubtitleOCR-ffmpeg-nightly-${sha}.tar.xz

- name: Publish
uses: softprops/action-gh-release@v2
Expand All @@ -96,4 +93,4 @@ jobs:
prerelease: true
files: |
macSubtitleOCR-nightly-*.tar.xz
macSubtitleOCR-nightly-*.tar.xz.asc
macSubtitleOCR-ffmpeg-nightly-*.tar.xz.asc
7 changes: 2 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,16 @@ jobs:
id: build
run: |
TAG=${{ github.ref_name }}
echo "::set-output name=version::${TAG#v}"
echo "version=${TAG#v}" >> $GITHUB_ENV
xcrun swift build --configuration release --arch arm64
tar -cvJf macSubtitleOCR-${TAG}.tar.xz -C .build/release/ macSubtitleOCR
gpg --detach-sign --armor macSubtitleOCR-${TAG}.tar.xz
gpg --verify macSubtitleOCR-${TAG}.tar.xz.asc macSubtitleOCR-${TAG}.tar.xz

- name: Build with FFmpeg
run: |
mv Package.swift Package.standalone.swift
mv Package.ffmpeg.swift Package.swift
TAG=${{ github.ref_name }}
echo "::set-output name=version::${TAG#v}"
xcrun swift build -Xswiftc -DFFMPEG --configuration release --arch arm64
USE_FFMPEG=1 xcrun swift build -Xswiftc -DFFMPEG --configuration release --arch arm64
tar -cvJf macSubtitleOCR-ffmpeg-${TAG}.tar.xz -C .build/release/ macSubtitleOCR
gpg --detach-sign --armor macSubtitleOCR-ffmpeg-${TAG}.tar.xz
gpg --verify macSubtitleOCR-ffmpeg-${TAG}.tar.xz.asc macSubtitleOCR-ffmpeg-${TAG}.tar.xz
Expand Down
8 changes: 3 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ jobs:

- name: Install Dependencies
run: |
mv Package.swift Package.standalone.swift
mv Package.ffmpeg.swift Package.swift
brew install ffmpeg peripheryapp/periphery/periphery
brew install ffmpeg peripheryapp/periphery/periphery --quiet

- name: Select Xcode
uses: mxcl/xcodebuild@v3
Expand All @@ -32,7 +30,7 @@ jobs:
action: none

- name: Build Tests
run: xcrun swift test -Xswiftc -DGITHUB_ACTIONS -Xswiftc -DFFMPEG list
run: USE_FFMPEG=1 xcrun swift test -Xswiftc -DGITHUB_ACTIONS -Xswiftc -DFFMPEG list

- name: Test FFmpeg Decoder
timeout-minutes: 5
Expand All @@ -43,4 +41,4 @@ jobs:
run: xcrun swift test --skip-build --filter internalDecoder

- name: Periphery
run: periphery scan --skip-build --index-store-path .build/debug/index/store
run: periphery scan --skip-build --format github-actions --relative-results --strict
3 changes: 0 additions & 3 deletions .periphery.yml

This file was deleted.

34 changes: 0 additions & 34 deletions Package.ffmpeg.swift

This file was deleted.

26 changes: 24 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
// swift-tools-version: 6.0

import Foundation
import PackageDescription

let hasFFmpeg = ProcessInfo.processInfo.environment["USE_FFMPEG"] == "1"

#if arch(arm64)
let includePath = "-I/opt/homebrew/include"
let libPath = "-L/opt/homebrew/lib"
#else
let includePath = "-I/usr/local/include"
let libPath = "-L/usr/local/lib"
#endif
let cSettings: [CSetting] = (hasFFmpeg ? [CSetting.unsafeFlags([includePath])] : [CSetting.unsafeFlags([])])
let linkerSettings: [LinkerSetting] = (hasFFmpeg ? [LinkerSetting.unsafeFlags([libPath])] : [LinkerSetting.unsafeFlags([])])

let package = Package(
name: "macSubtitleOCR",
platforms: [
Expand All @@ -15,7 +28,9 @@ let package = Package(
name: "macSubtitleOCR",
dependencies: [
.product(name: "ArgumentParser", package: "swift-argument-parser")
]),
] + (hasFFmpeg ? ["CFFmpeg"] : []),
cSettings: cSettings,
linkerSettings: linkerSettings),
.testTarget(
name: "macSubtitleOCRTests",
dependencies: [
Expand All @@ -24,4 +39,11 @@ let package = Package(
resources: [
.process("Resources")
])
])
] + (hasFFmpeg ? [
.systemLibrary(
name: "CFFmpeg",
pkgConfig: "libavformat libavcodec libavutil",
providers: [
.brew(["ffmpeg"])
])
] : []))
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ Currently PGS and VobSub subtitles are supported.

For more details on OCR accuracy, refer to the [Accuracy](#accuracy) section below.

An Apple M series processor is required for macSubtitleOCR, PRs adding additional support are welcomed.
[Release](https://github.com/ecdye/macSubtitleOCR/releases/latest) and [Nightly](https://github.com/ecdye/macSubtitleOCR/releases/tag/nightly) builds are provided for arm64.
Unfortunately, GitHub Actions doesn't provide a runner I can build x86_64 binaries on, sorry.
However, you should be able to compile for x86_64 on you own machine by following the directions in the [Building the Project](#building-the-project) section below.

### Features

Expand All @@ -39,8 +41,7 @@ To build macSubtitleOCR, follow these steps:
``` shell
git clone https://github.com/ecdye/macSubtitleOCR
cd macSubtitleOCR
make
sudo make install
swift build --configuration release
```

### Build With FFmpeg Decoder
Expand All @@ -51,8 +52,7 @@ To build with FFmpeg support, follow these steps:
brew install ffmpeg
git clone https://github.com/ecdye/macSubtitleOCR
cd macSubtitleOCR
make ffmpeg
sudo make install_ffmpeg
USE_FFMPEG=1 swift build --configuration release -Xswiftc -DFFMPEG
```

## Running Tests
Expand Down
8 changes: 8 additions & 0 deletions Sources/CFFmpeg/CFFmpeg.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#ifndef CFFmpeg_h
#define CFFmpeg_h

#include <libavformat/avformat.h>
#include <libavcodec/avcodec.h>
#include <libavutil/avutil.h>

#endif
4 changes: 1 addition & 3 deletions Sources/CFFmpeg/module.modulemap
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
module CFFmpeg [system] {
header "/opt/homebrew/include/libavformat/avformat.h"
header "/opt/homebrew/include/libavcodec/avcodec.h"
header "/opt/homebrew/include/libavutil/avutil.h"
header "CFFmpeg.h"
link "avformat"
link "avcodec"
link "avutil"
Expand Down
1 change: 0 additions & 1 deletion Sources/macSubtitleOCR/Subtitles/VobSub/VobSubParser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ struct VobSubParser {

let subtitle: Subtitle
private let masterPalette: [UInt8]
private let fps = 24.0 // TODO: Make this configurable / dynamic
private let minimumControlHeaderSize = 22

// MARK: - Lifecycle
Expand Down
67 changes: 0 additions & 67 deletions makefile

This file was deleted.

Loading