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

windows support + ci #43

Merged
merged 2 commits into from
Dec 6, 2022
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
34 changes: 34 additions & 0 deletions .github/workflows/build-windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: build-windows

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
windows:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-2022, windows-2019]
swift: [5.6.2]
steps:
- name: checkout
uses: actions/checkout@v2

- name: toolchain
uses: compnerd/gha-setup-swift@v0.0.1
with:
branch: swift-${{ matrix.swift }}-release
tag: ${{ matrix.swift }}-RELEASE
- name: build
run: |
swift --version
swift build
- name: test
run: |
swift --version
swift run -c debug PNGTests
swift run -c release PNGIntegrationTests
swift run -c release PNGCompressionTests
26 changes: 13 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<p align="center">
<a href="https://swift.org"><img alt="platforms: all" src="https://img.shields.io/badge/platforms-all-lightgrey.svg"/></a>
<a href="https://github.com/kelvin13/swift-png/releases"><img alt="releases" src="https://img.shields.io/github/v/release/kelvin13/swift-png"/></a>
<a href="https://github.com/kelvin13/swift-png/actions?query=workflow%3Abuild"><img alt="build status" src="https://img.shields.io/github/workflow/status/kelvin13/swift-png/documentation/master?label=build"/></a>
<a href="https://github.com/kelvin13/swift-png/actions?query=workflow%3Adocumentation"><img alt="documentation status" src="https://img.shields.io/github/workflow/status/kelvin13/swift-png/documentation/master?label=build%20docs"/></a>
<a href="https://github.com/kelvin13/swift-png/issues?state=open"><img alt="issues" src="https://img.shields.io/github/issues/kelvin13/swift-png"/></a>
<a href="https://swift.org"><img alt="language" src="https://img.shields.io/badge/version-swift_5.5-ffa020.svg"/></a>
<a href="https://github.com/kelvin13/swift-png/blob/master/LICENSE"><img alt="license: mpl2" src="https://img.shields.io/badge/license-MPL2-ff3079.svg"/></a>
</p>

<p align="center">
<em><code>png</code></em><br/><code>4.0.2</code>
</p>
<div align="center">

***`png`***<br>`4.1.0`

[![ci status](https://github.com/kelvin13/swift-png/actions/workflows/build.yml/badge.svg)](https://github.com/kelvin13/swift-png/actions/workflows/build.yml)
[![ci status](https://github.com/kelvin13/swift-png/actions/workflows/build-devices.yml/badge.svg)](https://github.com/kelvin13/swift-png/actions/workflows/build-devices.yml)
[![ci status](https://github.com/kelvin13/swift-png/actions/workflows/build-windows.yml/badge.svg)](https://github.com/kelvin13/swift-png/actions/workflows/build-windows.yml)


[![swift package index versions](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fkelvin13%2Fswift-hash%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/kelvin13/swift-png)
[![swift package index platforms](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fkelvin13%2Fswift-hash%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/kelvin13/swift-png)

</div>

*Swift PNG* is a pure, cross-platform Swift framework for decoding, inspecting, editing, and encoding PNG images. The framework does not depend on *Foundation* or any other packages, and will compile and provide consistent behavior on all Swift platforms. *Swift PNG* also comes with built-in file system support on Linux and MacOS.

Expand Down
4 changes: 3 additions & 1 deletion Sources/PNG/LZ77/General.Dictionary.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#if arch(x86_64) && !NO_INTRINSICS
// https://github.com/apple/swift/issues/60534
// https://forums.swift.org/t/builtin-intrinsics-intel-module-is-not-available-on-windows-pc-with-intel-cpu/61862
#if arch(x86_64) && !NO_INTRINSICS && !os(Windows)

import _Builtin_intrinsics.intel

Expand Down
15 changes: 14 additions & 1 deletion Sources/PNG/System.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@
import Darwin
#elseif os(Linux)
import Glibc
#elseif os(Windows)
#warning("Windows in not oficially supported and is untested platform (please open an issue at https://github.com/kelvin13/swift-png/issues)")
import ucrt
#else
#warning("unsupported or untested platform (please open an issue at https://github.com/kelvin13/swift-png/issues)")
#endif

#if os(macOS) || os(Linux)
#if os(macOS) || os(Linux) || os(Windows)

/// enum System
/// A namespace for platform-dependent functionality.
Expand Down Expand Up @@ -155,13 +158,23 @@ extension System.File.Source
return nil
}

#if os(Windows)
switch Int32.init(status.st_mode) & S_IFMT
{
case S_IFREG:
break
default:
return nil
}
#else
switch status.st_mode & S_IFMT
{
case S_IFREG, S_IFLNK:
break
default:
return nil
}
#endif

return Int.init(status.st_size)
}
Expand Down