From e48846e074c72a9f21639c57408188092b055583 Mon Sep 17 00:00:00 2001 From: Gokhan Kurt Date: Sun, 7 Apr 2024 15:28:58 +0300 Subject: [PATCH] add CI build config --- .github/workflows/build.yml | 81 ++++++++++++++++++++++++++++++++++++ .vscode/settings.json | 3 +- cmake/project-defaults.cmake | 2 - generate_build | 17 ++++++++ yoga/CMakeLists.txt | 7 +++- 5 files changed, 105 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/build.yml create mode 100644 generate_build diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000000..8616d0e535 --- /dev/null +++ b/.github/workflows/build.yml @@ -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 + diff --git a/.vscode/settings.json b/.vscode/settings.json index 9339156445..ce4cacff77 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -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", diff --git a/cmake/project-defaults.cmake b/cmake/project-defaults.cmake index 987529c549..e65ff3aa66 100644 --- a/cmake/project-defaults.cmake +++ b/cmake/project-defaults.cmake @@ -18,7 +18,6 @@ add_compile_options( /EHsc # Enable warnings and warnings as errors /W4 - /WX # Disable RTTI $<$:/GR-> # Use /O2 (Maximize Speed) @@ -33,7 +32,6 @@ add_compile_options( -fexceptions # Enable warnings and warnings as errors -Wall - -Werror # Disable RTTI $<$:-fno-rtti> # Use -O2 (prioritize speed) diff --git a/generate_build b/generate_build new file mode 100644 index 0000000000..75ef48efaa --- /dev/null +++ b/generate_build @@ -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 diff --git a/yoga/CMakeLists.txt b/yoga/CMakeLists.txt index b6eca1ac72..8670095c17 100644 --- a/yoga/CMakeLists.txt +++ b/yoga/CMakeLists.txt @@ -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) @@ -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 when building for Android if (ANDROID)