Skip to content

Commit

Permalink
add CI build config
Browse files Browse the repository at this point in the history
  • Loading branch information
KurtGokhan committed Apr 7, 2024
1 parent 194f83d commit e48846e
Show file tree
Hide file tree
Showing 5 changed files with 105 additions and 5 deletions.
81 changes: 81 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: Build Binaries

on: [push, pull_request]

jobs:
build:
name: Build ${{ matrix.os }}
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash
strategy:
fail-fast: false
matrix:
os: [macOS-latest, ubuntu-latest, windows-latest]

steps:
- uses: actions/checkout@v3

- name: Setup
uses: ./.github/actions/setup-cpp
with:
toolchain: ${{ startsWith(matrix.os, 'windows') && 'MSVC' || 'Clang' }}

- name: Build
run: ./generate_build

- name: Move Windows files
if: startsWith(matrix.os, 'windows')
run: |
mkdir -p dist/win-x64
cp build/Release/yogacore.dll dist/win-x64/yoga.dll
- name: Build (x86)
if: startsWith(matrix.os, 'windows')
run: ./generate_build -A Win32

- name: Move Windows files (x86)
if: startsWith(matrix.os, 'windows')
run: |
mkdir -p dist/win-x86
cp build/Release/yogacore.dll dist/win-x86/yoga.dll
- name: Move MacOS files
if: startsWith(matrix.os, 'macOS')
run: |
mkdir -p dist/osx
cp build/Release/libyogacore.dylib dist/osx/libyoga.dylib
- name: Move Ubuntu files
if: startsWith(matrix.os, 'ubuntu')
run: |
mkdir -p dist/linux
cp build/Release/libyogacore.so dist/linux/libyoga.so
- name: Upload Binaries
uses: actions/upload-artifact@v3
if: github.event_name == 'push'
with:
path: dist/**
name: prebuilt_yoga_binaries

build-android:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/setup-android

- name: Build
run: |
./gradlew :yoga:assembleRelease
mkdir -p dist/android
cp java/build/outputs/aar/yoga-release.aar dist/android/yoga.aar
- name: Upload Binaries
uses: actions/upload-artifact@v3
if: github.event_name == 'push'
with:
path: dist/**
name: prebuilt_yoga_binaries

3 changes: 1 addition & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
{
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
"source.fixAll.eslint": "explicit"
},
"eslint.format.enable": true,
"eslint.packageManager": "yarn",
"eslint.enable": true,
"eslint.validate": [
"javascript",
Expand Down
2 changes: 0 additions & 2 deletions cmake/project-defaults.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ add_compile_options(
/EHsc
# Enable warnings and warnings as errors
/W4
/WX
# Disable RTTI
$<$<COMPILE_LANGUAGE:CXX>:/GR->
# Use /O2 (Maximize Speed)
Expand All @@ -33,7 +32,6 @@ add_compile_options(
-fexceptions
# Enable warnings and warnings as errors
-Wall
-Werror
# Disable RTTI
$<$<COMPILE_LANGUAGE:CXX>:-fno-rtti>
# Use -O2 (prioritize speed)
Expand Down
17 changes: 17 additions & 0 deletions generate_build
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/sh
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

rm -rf build

if which ninja; then
set -e
cmake -B build -S yoga -D CMAKE_BUILD_TYPE=Release -D BUILD_SHARED_LIBS=ON -G Ninja "$@"
else
set -e
cmake -B build -S yoga -D CMAKE_BUILD_TYPE=Release -D BUILD_SHARED_LIBS=ON "$@"
fi

cmake --build build --config Release
7 changes: 6 additions & 1 deletion yoga/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

option(BUILD_SHARED_LIBS "Build shared libraries (DLLs) instead of static libraries" OFF)

cmake_minimum_required(VERSION 3.13...3.26)
project(yogacore)
Expand All @@ -22,7 +23,11 @@ file(GLOB SOURCES CONFIGURE_DEPENDS
${CMAKE_CURRENT_SOURCE_DIR}/*.cpp
${CMAKE_CURRENT_SOURCE_DIR}/**/*.cpp)

add_library(yogacore STATIC ${SOURCES})
if(BUILD_SHARED_LIBS)
add_library(yogacore SHARED ${SOURCES})
else()
add_library(yogacore STATIC ${SOURCES})
endif()

# Yoga conditionally uses <android/log> when building for Android
if (ANDROID)
Expand Down

0 comments on commit e48846e

Please sign in to comment.