Skip to content

Commit

Permalink
Merge pull request #4 from fireblade-engine/update
Browse files Browse the repository at this point in the history
Update project
  • Loading branch information
ctreffs authored Oct 28, 2021
1 parent 8b785d8 commit a3a675d
Show file tree
Hide file tree
Showing 41 changed files with 2,242 additions and 2,106 deletions.
12 changes: 12 additions & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# This file is a list of the people responsible for ensuring that contributions
# to this projected are reviewed, either by themselves or by someone else.
# They are also the gatekeepers for their part of this project, with the final
# word on what goes in or not.
# The code owners file uses a .gitignore-like syntax to specify which parts of
# the codebase is associated with an owner. See
# <https://docs.github.com/github/creating-cloning-and-archiving-repositories/about-code-owners>
# for details.
# The following lines are used by GitHub to automatically recommend reviewers.
# Each line is a file pattern followed by one or more owners.

* @ctreffs
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2018-2021 Christian Treffs

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
65 changes: 55 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,20 +1,52 @@
SWIFT_PACKAGE_VERSION := $(shell swift package tools-version)

# Delete package build artifacts.
.PHONY: clean
clean:
swift package clean

# Lint fix and format code.
.PHONY: lint-fix
lint-fix:
swiftlint --fix --format
swiftlint lint --quiet
swiftlint --fix --quiet
swiftformat --quiet --swiftversion ${SWIFT_PACKAGE_VERSION} .

.PHONY: test
test:
swift test -v --skip-update --parallel --enable-test-discovery --enable-code-coverage
.PHONY: pre-push
pre-push: genLinuxTests update-fileheaders lint-fix

# Build debug version
.PHONY: build-debug
build-debug:
swift build -c debug

# Build release version
.PHONY: build-release
build-release:
swift build -c release
swift build -c release --skip-update

# Reset the complete cache/build directory and Package.resolved files
.PHONY: reset
swift package reset
-rm Package.resolved
-rm rdf *.xcworkspace/xcshareddata/swiftpm/Package.resolved
-rm -rdf .swiftpm/xcode/*

.PHONY: resolve
resolve:
swift package resolve

.PHONY: brew-setup
brew-setup:
which -s brew || /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
brew update
.PHONY: open-proj-xcode
open-proj-xcode:
open -b com.apple.dt.Xcode Package.swift

.PHONY: open-proj-vscode
open-proj-vscode:
code .

.PHONY: setup-brew
setup-brew:
@which -s brew || /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
@brew update

.PHONY: install-dependencies
install-dependencies: brew-setup
Expand All @@ -23,3 +55,16 @@ install-dependencies: brew-setup
.PHONY: open-proj
open-proj:
open Package.swift

.PHONY: test
test:
swift test -v --skip-update --enable-test-discovery

.PHONY: genLinuxTests
genLinuxTests:
swift test --generate-linuxmain
swiftlint --fix --format --path Tests/

.PHONY: update-fileheaders
update-fileheaders:
Scripts/update-fileheaders.sh
12 changes: 6 additions & 6 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@
"repositoryURL": "https://github.com/fireblade-engine/math.git",
"state": {
"branch": null,
"revision": "b6700cf9ddfe00423f789f88f2c3a79132cb2eba",
"version": "0.10.0"
"revision": "65aa6b5045d8dd59bc8512b87ab4ec25a18dd82d",
"version": "0.11.0"
}
},
{
"package": "SDL2",
"repositoryURL": "https://github.com/ctreffs/SwiftSDL2.git",
"state": {
"branch": null,
"revision": "886e6552f18240c2403fea2e66435e3bf82d3ef5",
"version": "1.2.0"
"revision": "dc30ee99e4fb5bb4272bfed2e6336d6bc48d8aba",
"version": "1.3.1"
}
},
{
Expand All @@ -33,8 +33,8 @@
"repositoryURL": "https://github.com/fireblade-engine/time.git",
"state": {
"branch": null,
"revision": "cf1bd291364f57e7583bbf49e77b7d5f8fb5927e",
"version": "0.1.1"
"revision": "529c0e27108f2b22d864f61ff3e789dd938ee16c",
"version": "0.2.0"
}
}
]
Expand Down
52 changes: 29 additions & 23 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,16 @@ let platformDefines: [SwiftSetting] = {
// FRB_PLATFORM_APPL
let isApplePlatform: Bool
#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS)
isApplePlatform = false /* disabled for now */
isApplePlatform = false /* disabled for now */
#else
isApplePlatform = false
isApplePlatform = false
#endif
if Env.get(bool: .FRB_ENABLE_PLATFORM_APPL, orElse: isApplePlatform) {
settings.append(.define("FRB_PLATFORM_APPL"))
#if os(macOS)
settings.append(.define("FRB_PLATFORM_APPL_MACOS"))
settings.append(.define("FRB_PLATFORM_APPL_MACOS"))
#elseif os(iOS) || os(tvOS)
settings.append(.define("FRB_PLATFORM_APPL_IOS"))
settings.append(.define("FRB_PLATFORM_APPL_IOS"))
#endif
}

Expand All @@ -54,9 +54,9 @@ let renderingAPIDefines: [SwiftSetting] = {
// FRB_GRAPHICS_METAL
let isMetalDefaultEnabled: Bool
#if canImport(Metal)
isMetalDefaultEnabled = true
isMetalDefaultEnabled = true
#else
isMetalDefaultEnabled = false
isMetalDefaultEnabled = false
#endif
if Env.get(bool: .FRB_ENABLE_GRAPHICS_METAL, orElse: isMetalDefaultEnabled) {
swiftSettings.append(.define("FRB_GRAPHICS_METAL"))
Expand All @@ -65,9 +65,9 @@ let renderingAPIDefines: [SwiftSetting] = {
// FRB_GRAPHICS_VULKAN
let isVulkanDefaultEnabled: Bool
#if os(Linux) || os(macOS)
isVulkanDefaultEnabled = true
isVulkanDefaultEnabled = true
#else
isVulkanDefaultEnabled = false
isVulkanDefaultEnabled = false
#endif
if Env.get(bool: .FRB_ENABLE_GRAPHICS_VULKAN, orElse: isVulkanDefaultEnabled) {
swiftSettings.append(.define("FRB_GRAPHICS_VULKAN"))
Expand All @@ -89,25 +89,28 @@ let package = Package(
platforms: [
.macOS(.v11),
.iOS(.v13),
.tvOS(.v13)
.tvOS(.v13),
],
products: [
.library(
name: "FirebladePAL",
type: .static,
targets: ["FirebladePAL"]),
targets: ["FirebladePAL"]
),
.executable(
name: "CPUBackendDemoApp",
targets: ["CPUBackendDemoApp"]),
targets: ["CPUBackendDemoApp"]
),
.executable(
name: "VulkanBackendDemoApp",
targets: ["VulkanBackendDemoApp"])
targets: ["VulkanBackendDemoApp"]
),
],
dependencies: [
.firebladeMath,
.firebladeTime,
.vulkan,
.sdl2
.sdl2,
],
targets: [
.target(
Expand All @@ -116,25 +119,28 @@ let package = Package(
.firebladeMath,
.firebladeTime,
.sdl2,
.vulkan
.vulkan,
],
swiftSettings: swiftSettings),
swiftSettings: swiftSettings
),
.target(
name: "CPUBackendDemoApp",
dependencies: ["FirebladePAL"]),
dependencies: ["FirebladePAL"]
),
.target(
name: "VulkanBackendDemoApp",
dependencies: ["FirebladePAL", .vulkan],
swiftSettings: swiftSettings),
swiftSettings: swiftSettings
),
.testTarget(name: "FirebladePALTests",
dependencies: ["FirebladePAL"])
dependencies: ["FirebladePAL"]),
]
)

extension Package.Dependency {
static let firebladeMath = Package.Dependency.package(name: "FirebladeMath", url: "https://github.com/fireblade-engine/math.git", from: "0.10.0")
static let firebladeTime = Package.Dependency.package(name: "FirebladeTime", url: "https://github.com/fireblade-engine/time.git", from: "0.1.1")
static let sdl2 = Package.Dependency.package(name: "SDL2", url: "https://github.com/ctreffs/SwiftSDL2.git", from: "1.2.0")
static let firebladeMath = Package.Dependency.package(name: "FirebladeMath", url: "https://github.com/fireblade-engine/math.git", from: "0.11.0")
static let firebladeTime = Package.Dependency.package(name: "FirebladeTime", url: "https://github.com/fireblade-engine/time.git", from: "0.2.0")
static let sdl2 = Package.Dependency.package(name: "SDL2", url: "https://github.com/ctreffs/SwiftSDL2.git", from: "1.3.1")
static let vulkan = Package.Dependency.package(name: "Vulkan", url: "https://github.com/ctreffs/SwiftVulkan", from: "0.1.2")
}

Expand Down Expand Up @@ -216,11 +222,11 @@ extension Env {
}
}

extension Bool {
public extension Bool {
/// Initialize boolean from string representations.
/// - Parameter value: "true" or "1" result in `true`; "false" or "0" result in `false`.
/// All other values return `nil`.
public init?(string value: String?) {
init?(string value: String?) {
switch value?.lowercased() {
case "true",
"1":
Expand Down
28 changes: 23 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[![macOS](https://github.com/fireblade-engine/pal/actions/workflows/ci-macos.yml/badge.svg)](https://github.com/fireblade-engine/pal/actions/workflows/ci-macos.yml)
[![Linux](https://github.com/fireblade-engine/pal/actions/workflows/ci-linux.yml/badge.svg)](https://github.com/fireblade-engine/pal/actions/workflows/ci-linux.yml)

t.b.d description
A lightweight platform abstraction layer in Swift. It is developed and maintained as part of the Fireblade Game Engine project.

## 🚀 Getting Started

Expand All @@ -13,15 +13,33 @@ These instructions will get you a copy of the project up and running on your loc
### 📋 Prerequisites

* [Swift Package Manager (SPM)](https://github.com/apple/swift-package-manager)
* [SwiftFormat](https://github.com/nicklockwood/SwiftFormat) for formatting
* [Swiftlint](https://github.com/realm/SwiftLint) for linting - (optional)

### 💻 Installing

t.b.d.
Fireblade PAL is available for all platforms that support [Swift 5.3](https://swift.org/) and higher and the [Swift Package Manager (SPM)](https://github.com/apple/swift-package-manager).

## 📝 Code Example
Extend the following lines in your `Package.swift` file or use it to create a new project.

t.b.d.
```swift
// swift-tools-version:5.3

import PackageDescription

let package = Package(
name: "YourPackageName",
dependencies: [
.package(url: "https://github.com/fireblade-engine/pal.git", from: "0.1.0")
],
targets: [
.target(
name: "YourTargetName",
dependencies: ["FirebladePAL"])
]
)

```


## 💁 How to contribute
Expand All @@ -36,7 +54,7 @@ To start your project contribution run these in your command line:

Before commiting code please ensure to run:

- `make precommit`
- `make pre-push`

This project is currently maintained by [Christian Treffs](https://github.com/ctreffs).
See also the list of [contributors](https://github.com/fireblade-engine/pal/contributors) who participated in this project.
Expand Down
7 changes: 7 additions & 0 deletions Scripts/update-fileheaders.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash

SOURCES_DIR="${PWD}/Sources"
FILEHEADER="\n{file}\nFireblade PAL\n\nCopyright © 2018-{year} Fireblade Team. All rights reserved.\nLicensed under MIT License. See LICENSE file for details."

# Format header
swiftformat $SOURCES_DIR --exclude **/*.generated.swift --header "$FILEHEADER" --swiftversion `swift package tools-version`
11 changes: 5 additions & 6 deletions Sources/CPUBackendDemoApp/main.swift
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
//
// main.swift
// Fireblade Engine
// Fireblade PAL
//
// Created by Christian Treffs on 14.04.2021.
//
// Copyright © 2021 Fireblade Team. All rights reserved.
// Licensed under GNU General Public License v3.0. See LICENSE file for details.
// Copyright © 2018-2021 Fireblade Team. All rights reserved.
// Licensed under MIT License. See LICENSE file for details.

import FirebladePAL

Expand All @@ -17,7 +15,8 @@ print("Platform version: \(Platform.version)")
// let surface = CPUSurface()
let window = try Window(
properties: WindowProperties(title: "Title", frame: .init(0, 0, 800, 600)),
surface: { try CPUWindowSurface(in: $0) })
surface: { try CPUWindowSurface(in: $0) }
)

guard let surface = window.surface as? CPUWindowSurface else {
fatalError("no window surface")
Expand Down
Loading

0 comments on commit a3a675d

Please sign in to comment.