Skip to content

Commit 556e317

Browse files
committed
Initial commit
0 parents  commit 556e317

File tree

106 files changed

+48356
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

106 files changed

+48356
-0
lines changed

.editorconfig

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
insert_final_newline = true
7+
indent_style = space
8+
indent_size = 4
9+
trim_trailing_whitespace = true
10+
11+
[*.md]
12+
trim_trailing_whitespace = false
13+
14+
[*.yml]
15+
indent_size = 2

.gitattributes

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
* text=auto
2+
3+
/.github export-ignore
4+
/tests export-ignore
5+
6+
.editorconfig export-ignore
7+
.gitattributes export-ignore
8+
.gitignore export-ignore
9+
.styleci.yml export-ignore
10+
.travis.yml export-ignore
11+
12+
monorepo-builder.php export-ignore
13+
phpunit.xml export-ignore

.github/workflows/main.yml

+162
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
name: build
2+
3+
on:
4+
push:
5+
pull_request:
6+
schedule:
7+
- cron: '0 0 * * *'
8+
9+
env:
10+
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
11+
12+
jobs:
13+
security:
14+
name: Security
15+
runs-on: ${{ matrix.os }}
16+
17+
strategy:
18+
fail-fast: false
19+
matrix:
20+
php: [ '8.1' ] # Note: This workflow requires only the LATEST version of PHP
21+
os: [ ubuntu-latest ]
22+
23+
steps: # General Steps
24+
- name: Set Git To Use LF
25+
run: |
26+
git config --global core.autocrlf false
27+
git config --global core.eol lf
28+
- name: Checkout
29+
uses: actions/checkout@v2
30+
31+
# Install PHP Dependencies
32+
- name: Setup PHP ${{ matrix.php }}
33+
uses: shivammathur/setup-php@v2
34+
with:
35+
php-version: ${{ matrix.php }}
36+
- name: Validate Composer
37+
run: composer validate
38+
- name: Get Composer Cache Directory
39+
# Docs: <https://github.com/actions/cache/blob/master/examples.md#php---composer>
40+
id: composer-cache
41+
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
42+
- name: Restore Composer Cache
43+
uses: actions/cache@v1
44+
with:
45+
path: ${{ steps.composer-cache.outputs.dir }}
46+
key: ${{ runner.os }}-${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }}
47+
restore-keys: ${{ runner.os }}-${{ matrix.php }}-composer-
48+
- name: Install Dependencies
49+
uses: nick-invision/retry@v1
50+
with:
51+
timeout_minutes: 5
52+
max_attempts: 5
53+
command: composer update --prefer-dist --no-interaction --no-progress
54+
55+
# Execution
56+
- name: Security Advisories
57+
run: composer require --dev roave/security-advisories:dev-latest
58+
59+
psalm:
60+
name: Psalm
61+
runs-on: ${{ matrix.os }}
62+
63+
strategy:
64+
fail-fast: false
65+
matrix:
66+
php: [ '8.1' ] # Note: This workflow requires only the LATEST version of PHP
67+
os: [ ubuntu-latest ]
68+
69+
steps: # General Steps
70+
- name: Set Git To Use LF
71+
run: |
72+
git config --global core.autocrlf false
73+
git config --global core.eol lf
74+
- name: Checkout
75+
uses: actions/checkout@v2
76+
77+
# Install PHP Dependencies
78+
- name: Setup PHP ${{ matrix.php }}
79+
uses: shivammathur/setup-php@v2
80+
with:
81+
php-version: ${{ matrix.php }}
82+
- name: Validate Composer
83+
run: composer validate
84+
- name: Get Composer Cache Directory
85+
# Docs: <https://github.com/actions/cache/blob/master/examples.md#php---composer>
86+
id: composer-cache
87+
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
88+
- name: Restore Composer Cache
89+
uses: actions/cache@v1
90+
with:
91+
path: ${{ steps.composer-cache.outputs.dir }}
92+
key: ${{ runner.os }}-${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }}
93+
restore-keys: ${{ runner.os }}-${{ matrix.php }}-composer-
94+
- name: Install Dependencies
95+
uses: nick-invision/retry@v1
96+
with:
97+
timeout_minutes: 5
98+
max_attempts: 5
99+
command: composer update --prefer-dist --no-interaction --no-progress
100+
101+
# Execution
102+
- name: Static Analysis
103+
continue-on-error: true
104+
run: vendor/bin/psalm --no-cache
105+
106+
unit-tests:
107+
name: Build (${{matrix.php}}, ${{ matrix.os }}, ${{ matrix.stability }})
108+
runs-on: ${{ matrix.os }}
109+
110+
strategy:
111+
fail-fast: false
112+
matrix:
113+
php: [ '8.1' ]
114+
os: [ ubuntu-latest, macos-latest, windows-latest ]
115+
stability: [ prefer-lowest, prefer-stable ]
116+
117+
steps: # General Steps
118+
- name: Set Git To Use LF
119+
run: |
120+
git config --global core.autocrlf false
121+
git config --global core.eol lf
122+
- name: Checkout
123+
uses: actions/checkout@v2
124+
125+
# Install PHP Dependencies
126+
- name: Setup PHP ${{ matrix.php }}
127+
uses: shivammathur/setup-php@v2
128+
with:
129+
php-version: ${{ matrix.php }}
130+
# PHP Extras
131+
coverage: pcov
132+
tools: pecl
133+
ini-values: "memory_limit=-1"
134+
extensions: phar, ffi
135+
- name: Validate Composer
136+
run: composer validate
137+
- name: Get Composer Cache Directory
138+
# Docs: <https://github.com/actions/cache/blob/master/examples.md#php---composer>
139+
id: composer-cache
140+
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
141+
- name: Restore Composer Cache
142+
uses: actions/cache@v1
143+
with:
144+
path: ${{ steps.composer-cache.outputs.dir }}
145+
key: ${{ runner.os }}-${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }}
146+
restore-keys: ${{ runner.os }}-${{ matrix.php }}-composer-
147+
- name: Install Dependencies
148+
uses: nick-invision/retry@v1
149+
with:
150+
timeout_minutes: 5
151+
max_attempts: 5
152+
command: composer update --${{ matrix.stability }} --prefer-dist --no-interaction --no-progress
153+
- name: Install Linux GLFW3
154+
if: runner.os == 'Linux'
155+
run: sudo apt-get install -y libglfw3
156+
- name: Install MacOS GLFW3
157+
if: runner.os == 'macOS'
158+
run: brew install glfw
159+
160+
# Execution
161+
- name: Execute Tests
162+
run: vendor/bin/phpunit --testdox --verbose

.gitignore

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.idea/
2+
vendor/
3+
4+
# Local testing
5+
include/
6+
test.php
7+
8+
composer.lock
9+
.phpunit.result.cache

LICENSE.md

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright © Kirill Nesmeyanov
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<p align="center">
2+
<a href="https://github.com/ffi-libs">
3+
<img src="https://avatars.githubusercontent.com/u/101121010?s=256" width="128" alt="Phplrt" />
4+
</a>
5+
</p>
6+
7+
<p align="center">
8+
<a href="https://github.com/php-ffi-libs/glfw3-headers/actions"><img src="https://github.com/php-ffi-libs/glfw3-headers/workflows/build/badge.svg"></a>
9+
<a href="https://packagist.org/packages/ffi-libs/glfw3-headers"><img src="https://img.shields.io/badge/PHP-8.1+-ff0140.svg" alt="PHP 7.1+"></a>
10+
<a href="https://packagist.org/packages/ffi-libs/glfw3-headers"><img src="https://poser.pugx.org/ffi-libs/glfw3-headers/version" alt="Latest Stable Version"></a>
11+
<a href="https://packagist.org/packages/ffi-libs/glfw3-headers"><img src="https://poser.pugx.org/ffi-libs/glfw3-headers/v/unstable" alt="Latest Unstable Version"></a>
12+
<a href="https://packagist.org/packages/ffi-libs/glfw3-headers"><img src="https://poser.pugx.org/ffi-libs/glfw3-headers/downloads" alt="Total Downloads"></a>
13+
<a href="https://raw.githubusercontent.com/php-ffi-libs/glfw3-headers/master/LICENSE.md"><img src="https://poser.pugx.org/ffi-libs/glfw3-headers/license" alt="License MIT"></a>
14+
</p>
15+
16+
# GLFW3 Headers
17+
18+
This is a C headers of the [GLFW3](https://www.glfw.org/) adopted for PHP.
19+
20+
## Requirements
21+
22+
- PHP >= 8.1
23+
24+
## Installation
25+
26+
Library is available as composer repository and can be installed using the
27+
following command in a root of your project.
28+
29+
```sh
30+
$ composer require ffi-libs/glfw3-headers
31+
```
32+
33+
## Usage
34+
35+
```php
36+
use FFI\Headers\SDL2;
37+
38+
$headers = SDL2::create(
39+
GLFW3\WindowPlatform::X11, // Window API
40+
GLFW3\ContextPlatform::GLX, // Context API
41+
GLFW3\Version::V3_3_6, // GLFW Headers Version
42+
);
43+
44+
echo $headers;
45+
```
46+
47+

composer.json

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
{
2+
"name": "ffi-libs/sdl2-headers",
3+
"type": "library",
4+
"description": "PHP FFI SDL2 Headers",
5+
"license": "MIT",
6+
"keywords": ["ffi", "headers", "sdl2", "sdl", "c", "windows", "macos", "linux", "unix", "opengl", "vulkan", "opengl-es"],
7+
"support": {
8+
"source": "https://github.com/php-ffi-libs/sdl2-headers",
9+
"issues": "https://github.com/php-ffi-libs/sdl2-headers/issues",
10+
"docs": "https://github.com/php-ffi-libs/sdl2-headers/blob/master/README.md"
11+
},
12+
"authors": [
13+
{
14+
"name": "Nesmeyanov Kirill",
15+
"email": "[email protected]",
16+
"homepage": "https://serafimarts.ru",
17+
"role": "maintainer"
18+
}
19+
],
20+
"require": {
21+
"php": "^8.1",
22+
"ffi/preprocessor": "^0.2|^1.0",
23+
"ffi-libs/headers-contracts": "^1.0"
24+
},
25+
"autoload": {
26+
"psr-4": {
27+
"FFI\\Headers\\": "src"
28+
}
29+
},
30+
"require-dev": {
31+
"ext-phar": "*",
32+
"ffi/env": "^0.1|^1.0",
33+
"ffi/location": "^0.1|^1.0",
34+
"vimeo/psalm": "^4.22",
35+
"phpunit/phpunit": "^9.5"
36+
},
37+
"autoload-dev": {
38+
"psr-4": {
39+
"FFI\\Headers\\SDL2\\Tests\\": "tests"
40+
}
41+
},
42+
"conflict": {
43+
"phpunit/phpunit": "9.5.17"
44+
},
45+
"config": {
46+
"sort-packages": true,
47+
"allow-plugins": {
48+
"composer/package-versions-deprecated": true,
49+
"phing/phing-composer-configurator": false
50+
}
51+
},
52+
"provide": {
53+
"ffi-libs/headers-contracts-implementation": "^1.0"
54+
},
55+
"extra": {
56+
"branch-alias": {
57+
"dev-master": "1.0.x-dev"
58+
}
59+
},
60+
"minimum-stability": "dev",
61+
"prefer-stable": true
62+
}

phpunit.xml

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
4+
colors="true"
5+
backupGlobals="true"
6+
stopOnFailure="false"
7+
processIsolation="false"
8+
backupStaticAttributes="false"
9+
bootstrap="vendor/autoload.php"
10+
convertErrorsToExceptions="true"
11+
convertNoticesToExceptions="true"
12+
convertWarningsToExceptions="true"
13+
>
14+
<coverage>
15+
<include>
16+
<directory suffix=".php">src</directory>
17+
</include>
18+
</coverage>
19+
<testsuites>
20+
<testsuite name="Test Suite">
21+
<directory suffix="TestCase.php">tests</directory>
22+
</testsuite>
23+
</testsuites>
24+
<php>
25+
<ini name="error_reporting" value="-1"/>
26+
<ini name="memory_limit" value="-1"/>
27+
</php>
28+
</phpunit>

psalm.xml

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0"?>
2+
<psalm
3+
errorLevel="1"
4+
resolveFromConfigFile="true"
5+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
6+
xmlns="https://getpsalm.org/schema/config"
7+
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
8+
xmlns:xi="http://www.w3.org/2001/XInclude"
9+
>
10+
<projectFiles>
11+
<directory name="src" />
12+
<ignoreFiles>
13+
<directory name="vendor" />
14+
</ignoreFiles>
15+
</projectFiles>
16+
</psalm>

resources/headers/.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
*
2+
!.gitignore
3+
!2.0.20/

0 commit comments

Comments
 (0)