Skip to content

Commit

Permalink
Fixing clang-format on unwanted files and adding automatic builds
Browse files Browse the repository at this point in the history
  • Loading branch information
BastiaanOlij committed Nov 30, 2020
1 parent 41a7879 commit 15d0abb
Show file tree
Hide file tree
Showing 10 changed files with 170 additions and 11 deletions.
154 changes: 154 additions & 0 deletions .github/workflows/build-on-push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@

# Workflow to automatically compile a Linux/Windows library on commit/push
name: Build on push

# Controls when the action will run. Triggers the workflow on push or pull request
# events, but only for the master branch we'll create .zip files
on:
[push, pull_request]

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This job builds the plugin for our target platforms
build:
name: Building for ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
include:
- os: ubuntu-20.04
platform: linux
- os: windows-latest
platform: windows

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
with:
submodules: 'recursive'

- name: Get OpenXR loader (Ubuntu)
run: |
sudo add-apt-repository ppa:monado-xr/monado
sudo apt-get update
sudo apt install libopenxr-loader1 libopenxr-dev
if: matrix.os == 'ubuntu-20.04'

- name: Get OpenGL (Ubuntu)
run: |
sudo apt install libgl1-mesa-dev
if: matrix.os == 'ubuntu-20.04'

- name: Install scons (Ubuntu)
run: |
sudo apt install scons
if: matrix.os == 'ubuntu-20.04'

- name: Install scons (Windows)
run: |
pip install scons
if: matrix.os == 'windows-latest'

- name: Run the build for godot-cpp
run: |
cd $GITHUB_WORKSPACE/godot-cpp
scons platform=${{ matrix.platform }} -j2 target=release generate_bindings=yes bits=64 custom_api_file=../api.json
if: matrix.os != 'windows-latest'

- name: Run the build for godot_openxr
run: |
cd $GITHUB_WORKSPACE
scons platform=${{ matrix.platform }} -j2 target=release bits=64
if: matrix.os != 'windows-latest'

- name: Run the build for godot-cpp (Windows)
run: |
cd ${env:GITHUB_WORKSPACE}/godot-cpp
scons platform=${{ matrix.platform }} -j2 target=release generate_bindings=yes bits=64 custom_api_file=../api.json
if: matrix.os == 'windows-latest'

- name: Run the build for godot_openxr (Windows)
run: |
cd ${env:GITHUB_WORKSPACE}
scons platform=${{ matrix.platform }} -j2 target=release bits=64
if: matrix.os == 'windows-latest'

- name: Upload build files (artifacts) (Linux)
uses: actions/upload-artifact@v2
with:
name: build-files-linux
path: |
demo/addons/godot-openxr/bin/linux/libgodot_openxr.so
if: matrix.os == 'ubuntu-20.04'

- name: Upload build files (artifacts) (Windows)
uses: actions/upload-artifact@v2
with:
name: build-files-windows
path: |
demo/addons/godot-openxr/bin/win64/libgodot_openxr.dll
openxr_loader_windows/1.0.12/x64/bin/openxr_loader.dll
if: matrix.os == 'windows-latest'

# This job collects the build output and assembles the final asset (artifact)
asset:
name: Assembling the asset (artifact)
runs-on: ubuntu-20.04
needs: build
if: github.event_name == 'push' && github.ref == 'refs/heads/master'

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- uses: actions/checkout@v2
with:
repository: 'GodotVR/godot_openxr'
path: godot_openxr
- name: Download all workflow run artifacts
uses: actions/download-artifact@v2
- name: Copy files to destination
run: |
mkdir addons
cp -r godot_openxr/demo/addons/godot-openxr addons
cp build-files-linux/libgodot_openxr.so addons/godot-openxr/bin/linux/libgodot_openxr.so
cp build-files-windows/demo/addons/godot-openxr/bin/win64/libgodot_openxr.dll addons/godot-openxr/bin/win64/libgodot_openxr.dll
cp build-files-windows/openxr_loader_windows/1.0.12/x64/bin/openxr_loader.dll addons/godot-openxr/bin/win64/openxr_loader.dll
- name: Calculate GIT short ref
run: |
cd godot_openxr
echo "GITHUB_SHA_SHORT=$(git rev-parse --short ${{ github.sha }})" >> $GITHUB_ENV
cd ..
- name: Clean up extracted files
run: |
rm -rf build-files-linux
rm -rf build-files-windows
rm -rf godot_openxr
rm -rf .git
rm addons/godot-openxr/bin/win64/.gitignore
rm addons/godot-openxr/bin/linux/.gitignore
- name: Zip asset
run: |
zip -qq -r godot-openxr.zip .
- name: Create release for asset
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.GITHUB_SHA_SHORT }}
release_name: Automatic build for changeset ${{ env.GITHUB_SHA_SHORT }}
body: |
This is an automated build for changeset ${{ env.GITHUB_SHA_SHORT }}
draft: false
prerelease: true
- name: Upload asset
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ./godot-openxr.zip
asset_name: godot-openxr.zip
asset_content_type: application/zip
4 changes: 3 additions & 1 deletion .github/workflows/scripts/clang_format.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ while IFS= read -rd '' f; do
# Exclude some files.
if [[ "$f" == "glad"* ]]; then
continue
elif [[ "$f" == "godot_headers"* ]]; then
elif [[ "$f" == "godot-cpp"* ]]; then
continue
elif [[ "$f" == "openxr_loader_windows"* ]]; then
continue
elif [[ "$f" == ".github"* ]]; then
continue
fi
for extension in ${CLANG_FORMAT_FILE_EXTS[@]}; do
if [[ "$f" == *"$extension" ]]; then
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/scripts/file_format.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ while IFS= read -rd '' f; do
# Exclude some files.
if [[ "$f" == "glad"* ]]; then
continue
elif [[ "$f" == "godot_headers"* ]]; then
elif [[ "$f" == "godot-cpp"* ]]; then
continue
elif [[ "$f" == "openxr_loader_windows"* ]]; then
continue
elif [[ "$f" == "api.json" ]]; then
continue
fi
# Ensure that files are UTF-8 formatted.
recode UTF-8 "$f" 2> /dev/null
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,18 @@ git submodule update --init --recursive
To download the required version.
This will also include the `godot-headers` submodule.

This submodule needs to be compiled with the following
This submodule needs to be compiled with the following
```
cd godot-cpp
scons platform=<platform> target=release generate_bindings=yes
cd ..
```
Replace `<platform>` with `linux` or `windows` depending on your platform.
Replace `<platform>` with `linux` or `windows` depending on your platform.

**note** As we rely on Godot 3.2.4 which is still in beta `godot-headers` hasn't been updated with a new `api.json` file. For now add `custom_api_file=../api.json` to the scons command up above so:
```
scons platform=windows target=release generate_bindings=yes custom_api_file=../api.json
```
```

### OpenXR SDK loader
OpenXR on desktop PCs usually requires using a loader provided by Khronos, you can find the source here: https://github.com/KhronosGroup/OpenXR-SDK
Expand Down
10 changes: 5 additions & 5 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ customs = ['../custom.py']
opts = Variables(customs, ARGUMENTS)

# Gets the standard flags CC, CCX, etc.
env = DefaultEnvironment()
env = Environment(ENV = os.environ)

# Define our parameters
opts.Add(EnumVariable('platform', "Platform", 'windows', ['linux', 'windows']))
opts.Add(EnumVariable('target', "Compilation target", 'release', ['d', 'debug', 'r', 'release']))
opts.AddVariables(
PathVariable('target_path', 'The path where the lib is installed.', 'demo/addons/godot-openxr/bin/'),
PathVariable('target_name', 'The library name.', 'godot_openxr', PathVariable.PathAccept),
PathVariable('target_name', 'The library name.', 'libgodot_openxr', PathVariable.PathAccept),
)
opts.Add(BoolVariable('use_llvm', "Use the LLVM / Clang compiler", 'no'))

Expand Down Expand Up @@ -48,7 +48,7 @@ if env['platform'] == "windows":
if env['target'] in ('debug', 'd'):
env.Append(CCFLAGS = ['-fPIC', '-g3','-Og', '-std=c++17'])
else:
env.Append(CCFLAGS = ['-fPIC', '-g','-O3', '-std=c++17'])
env.Append(CCFLAGS = ['-fPIC','-O3', '-std=c++17'])
else:
# This makes sure to keep the session environment variables on windows,
# that way you can run scons in a vs 2017 prompt and it will find all the required tools
Expand Down Expand Up @@ -107,8 +107,8 @@ else:
# and add our main project

env.Append(CPPPATH=[
'.',
'src/',
'.',
'src/',
godot_headers_path,
godot_cpp_path + 'include/',
godot_cpp_path + 'include/core/',
Expand Down
Empty file.
1 change: 1 addition & 0 deletions demo/addons/godot-openxr/bin/win64/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.dll
Binary file removed demo/addons/godot-openxr/bin/win64/godot_openxr.dll
Binary file not shown.
Binary file removed demo/addons/godot-openxr/bin/win64/openxr_loader.dll
Binary file not shown.
2 changes: 1 addition & 1 deletion demo/addons/godot-openxr/godot_openxr.gdnlib
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ reloadable=false

[entry]

Windows.64="res://addons/godot-openxr/bin/win64/godot_openxr.dll"
Windows.64="res://addons/godot-openxr/bin/win64/libgodot_openxr.dll"
X11.64="res://addons/godot-openxr/bin/linux/libgodot_openxr.so"

[dependencies]
Expand Down

0 comments on commit 15d0abb

Please sign in to comment.