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

Add meson build system #52311

Closed
wants to merge 17 commits into from
Closed
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/actions/meson_build/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: 'Build Godot'
description: 'Build Godot with the provided options'
inputs:
buildtype:
description: 'The meson buildtype (debug/debugoptimized/optimized/minsize)'
required: true
default: 'debugoptimized'
tools:
description: 'If tools are to be built'
required: true
default: true
platform:
description: 'The Godot platform to build. This is currently unused'
required: false
meson:
description: 'The meson binary to run (in case we need upstream/downstram patches to the build system).'
required: true
default: 'meson'
destination:
required: true
default: 'builddir'
mesonflags:
default: ''
runs:
using: "composite"
steps:
- name: Meson Configure
shell: bash
run: |
${{ inputs.meson }} ${{ inputs.destination }} ${{ inputs.mesonflags }} -Dbuildtype=${{ inputs.buildtype }} -Dtools=${{ inputs.tools }}
- name: Meson compile
shell: bash
run: |
${{ inputs.meson }} compile -C ${{ inputs.destination }}
30 changes: 30 additions & 0 deletions .github/actions/meson_install/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: 'Setup python meson ninja.'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should these be capitalized? Also, the quotes are inconsistent. Other places in the file use ', ", or no quotes.

description: 'Setup python installation, and install pip version of meson and ninja.'
inputs:
python-version:
description: 'The python version to use'
required: true
default: '3.x'
python-arch:
description: 'The python architecture'
required: true
default: 'x64'
runs:
using: "composite"
steps:
# Use python 3.x release (works cross platform)
- name: Set up Python 3.x
uses: actions/setup-python@v2
with:
# Semantic version range syntax or exact version of a Python version
python-version: ${{ inputs.python-version }}
# Optional - x64 or x86 architecture, defaults to x64
architecture: ${{ inputs.python-arch }}
- name: Setup meson and ninja
shell: bash
run: |
python -c "import sys; print(sys.version)"
python -m pip install meson ninja
python --version
meson --version
ninja --version
200 changes: 200 additions & 0 deletions .github/workflows/meson.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
name: 💠 Meson Builds
on: [push, pull_request]

# Global Settings
env:
GODOT_BASE_BRANCH: master
MESONFLAGS: ''
EM_VERSION: 2.0.27
EM_CACHE_FOLDER: 'emsdk-cache'

concurrency:
group: ci-${{github.actor}}-${{github.head_ref || github.run_number}}-${{github.ref}}-meson
cancel-in-progress: true

jobs:
meson:
strategy:
fail-fast: false
matrix:
include:
- name: 🤖 Android (release, armv7a)
os: ubuntu-20.04
platform: android
target: release
tools: false
mesonflags: '--cross-file cross/android.gen.txt'
arch: armv7a

- name: 🤖 Android (release, armv64v8)
os: ubuntu-20.04
platform: android
target: release
tools: false
mesonflags: '--cross-file cross/android.gen.txt'
arch: aarch64

- name: 🍏 iOS (release)
os: macos-latest
platform: iphone
target: release
tools: false
mesonflags: '--cross-file cross/iphone.txt'

- name: 🌐 JavaScript (minsize)
os: ubuntu-20.04
platform: javascript
target: minsize
tools: false
meson: './meson-upstream/'
mesonflags: '--cross-file cross/emscripten -Dbuiltin_pcre2_with_jit=false'

- name: 🐧 Linux (debug, asan+ubsan, tests)
os: ubuntu-20.04
platform: linuxbsd
target: debug
tools: true
tests: true
mesonflags: -Dtests=true -Duse_asan=true -Duse_ubsan=true

- name: 🐧 Linux (release_debug, tests)
os: ubuntu-20.04
platform: linuxbsd
target: debugoptimized
tools: true
tests: true
mesonflags: -Dtests=true

- name: 🐧 Linux (release)
os: ubuntu-20.04
platform: linuxbsd
target: release
tools: false

- name: 🍎 macOS (release_debug, tests)
os: macos-latest
platform: osx
target: debugoptimized
tools: true
tests: true
mesonflags: -Dtests=true

- name: 🍎 macOS (release)
os: macos-latest
platform: osx
target: debugoptimized
tools: false

- name: 🏁 Windows (release_debug, tests)
os: windows-latest
platform: windows
target: debugoptimized
tools: true
tests: true
mesonflags: -Dtests=true

- name: 🏁 Windows (release)
os: windows-latest
platform: windows
target: release
tools: false

name: ${{ matrix.name }}
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v2

- name: Set up Java 8
uses: actions/setup-java@v1
if: ${{ matrix.platform == 'android' }}
with:
java-version: 8

- name: Setup python and meson
uses: ./.github/actions/meson_install

- name: Generate meson cross compilation file (${{ matrix.arch }}).
if: ${{ matrix.platform == 'android' }}
run: |
python3 misc/scripts/make_android_cross.py "$ANDROID_NDK_ROOT" -m ${{ matrix.arch }} -o cross/android.gen.txt

# Additional cache for Emscripten generated system libraries
- name: Load Emscripten cache
id: javascript-template-emscripten-cache
if: ${{ matrix.platform == 'javascript' }}
uses: actions/cache@v2
with:
path: ${{env.EM_CACHE_FOLDER}}
key: ${{env.EM_VERSION}}-${{github.job}}

- name: Set up Emscripten ${{env.EM_VERSION}}
if: ${{ matrix.platform == 'javascript' }}
uses: mymindstorm/setup-emsdk@v10
with:
version: ${{env.EM_VERSION}}
actions-cache-folder: ${{env.EM_CACHE_FOLDER}}

- name: Verify Emscripten setup
if: ${{ matrix.platform == 'javascript' }}
run: |
emcc -v

# TODO remove once meson in pip is updated to master
- name: Download meson upstream branch (pip version does not support godot)
if: ${{ matrix.platform == 'javascript' }}
run: |
git clone https://github.com/mesonbuild/meson.git meson-upstream
cd meson-upstream
cp meson.py meson

# Azure repositories are not reliable, we need to prevent azure giving us packages.
- name: Make apt sources.list use the default Ubuntu repositories
if: ${{ matrix.platform == 'linuxbsd' }}
run: |
sudo rm -f /etc/apt/sources.list.d/*
sudo cp -f misc/ci/sources.list /etc/apt/sources.list
sudo apt-get update

# Install all packages (except scons)
- name: Configure dependencies
if: ${{ matrix.platform == 'linuxbsd' }}
run: |
sudo apt-get install build-essential pkg-config libx11-dev libxcursor-dev \
libxinerama-dev libgl1-mesa-dev libglu-dev libasound2-dev libpulse-dev libdbus-1-dev libudev-dev libxi-dev libxrandr-dev yasm \
xvfb wget unzip

- name: Setup MSVC.
if: ${{ matrix.platform == 'windows' }}
uses: ilammy/msvc-dev-cmd@v1
with:
arch: amd64

- name: Compilation (${{ matrix.platform }} ${{ matrix.arch }})
if: ${{ matrix.platform != 'windows' }}
uses: ./.github/actions/meson_build
with:
mesonflags: ${{ env.MESONFLAGS }} ${{ matrix.mesonflags }}
buildtype: ${{ matrix.target }}
meson: ${{ matrix.meson }}meson
tools: ${{ matrix.tools }}

# Differnt build for windows due to github/MSVC messing up shell vars.
- name: Meson configure (win)
if: ${{ matrix.platform == 'windows' }}
run: |
meson builddir ${{ env.MESONFLAGS }} ${{ matrix.mesonflags }} -Dbuildtype=${{ matrix.target }} -Dtools=${{ matrix.tools }}

- name: Meson build (win)
if: ${{ matrix.platform == 'windows' }}
run: |
meson compile -C builddir

# Execute unit tests for the editor
- name: Unit Tests
if: ${{ matrix.tests && matrix.platform == 'linuxbsd' }}
run: |
./builddir/godot --headless --test

#- name: Upload Artifact
# uses: ./.github/actions/upload-artifact
1 change: 1 addition & 0 deletions core/config/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SOURCES += files(run_command(GLOB, '*.cpp').stdout().split('\n'))
2 changes: 2 additions & 0 deletions core/core_builders.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/python3

"""Functions used to generate source files during build time

All such functions are invoked in a subprocess on Windows to prevent build flakiness.
Expand Down
1 change: 1 addition & 0 deletions core/crypto/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SOURCES += files(run_command(GLOB, '*.cpp').stdout().split('\n'))
1 change: 1 addition & 0 deletions core/debugger/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SOURCES += files(run_command(GLOB, '*.cpp').stdout().split('\n'))
1 change: 1 addition & 0 deletions core/error/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SOURCES += files(run_command(GLOB, '*.cpp').stdout().split('\n'))
1 change: 1 addition & 0 deletions core/extension/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SOURCES += files(run_command(GLOB, '*.cpp').stdout().split('\n'))
2 changes: 2 additions & 0 deletions core/input/input_builders.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/python3

"""Functions used to generate source files during build time

All such functions are invoked in a subprocess on Windows to prevent build flakiness.
Expand Down
13 changes: 13 additions & 0 deletions core/input/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# generated input mappings
_default_controller_mappings_target = custom_target(
'default_controller_mappings',
output: ['default_controller_mappings.gen.cpp'],
input: ['gamecontrollerdb.txt', 'godotcontrollerdb.txt'],
env: SCRIPTS_ENV,
command: [SCRIPT_COMPAT, 'make_default_controller_mappings', SCRIPT_INPUT_BUILDERS, '-i', '@INPUT@', '-o', '@OUTPUT@'],
build_by_default: true
)

SOURCES += [_default_controller_mappings_target]

SOURCES += files(run_command(GLOB, '*.cpp').stdout().split('\n'))
16 changes: 16 additions & 0 deletions core/io/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# generated certs

_certs_target = custom_target(
'certs',
output: ['certs_compressed.gen.h'],
input: [meson.project_source_root() + '/thirdparty/certs/ca-certificates.crt'],
env: SCRIPTS_ENV,
command: [SCRIPT_COMPAT, 'make_certs_header', SCRIPT_CORE_BUILDERS, '-i', '@INPUT@', '-o', '@OUTPUT@', '-e',
'builtin_certs=' + (get_option('builtin_certs') ? 'true' : 'false'),
'system_certs_path=' + get_option('system_certs_path')],
build_by_default: true
)

SOURCES += [_certs_target]

SOURCES += files(run_command(GLOB, '*.cpp').stdout().split('\n'))
1 change: 1 addition & 0 deletions core/math/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SOURCES += files(run_command(GLOB, '*.cpp').stdout().split('\n'))
Loading