Skip to content

Refactor package building and GUIProperty #12

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

Merged
merged 2 commits into from
Dec 12, 2024
Merged
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
157 changes: 146 additions & 11 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
strategy:
matrix:
triplet: ["x64-linux"]
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
env:
VCPKG_DEFAULT_TRIPLET: ${{matrix.triplet}}
VCPKG_DEFAULT_HOST_TRIPLET: ${{matrix.triplet}}
Expand Down Expand Up @@ -112,20 +112,19 @@ jobs:
cmake -GNinja -S . -B build-debug -DBRISK_TESTS=OFF -DBRISK_EXAMPLES=OFF -DCMAKE_INSTALL_PREFIX=dist -DVCPKG_MANIFEST_MODE=OFF -DCMAKE_OSX_ARCHITECTURES=${{matrix.arch}} -DVCPKG_INSTALLED_DIR=vcpkg_installed -DCMAKE_TOOLCHAIN_FILE=$VCPKG_INSTALLATION_ROOT/scripts/buildsystems/vcpkg.cmake -DCMAKE_BUILD_TYPE=Debug
cmake --build build-debug --target install
cd dist
cmake -E tar cJ "${{github.workspace}}/Brisk-${{github.ref_type == 'tag' && github.ref_name || github.sha}}-${{matrix.triplet}}.tar.xz" .
cmake -E tar cJ "${{github.workspace}}/Brisk-Prebuilt-${{github.ref_type == 'tag' && github.ref_name || github.sha}}-${{matrix.triplet}}.tar.xz" .
- name: Binaries
uses: actions/upload-artifact@v4
with:
name: ${{matrix.triplet}}
path: |
Brisk-*.tar.xz
Brisk-Dependencies-*.7z

build-linux:
strategy:
matrix:
triplet: ["x64-linux"]
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
needs: deps-linux
env:
VCPKG_DEFAULT_TRIPLET: ${{matrix.triplet}}
Expand All @@ -147,14 +146,13 @@ jobs:
cmake -GNinja -S . -B build-debug -DBRISK_TESTS=OFF -DBRISK_EXAMPLES=OFF -DCMAKE_INSTALL_PREFIX=dist -DVCPKG_MANIFEST_MODE=OFF -DVCPKG_INSTALLED_DIR=vcpkg_installed -DCMAKE_TOOLCHAIN_FILE=$VCPKG_INSTALLATION_ROOT/scripts/buildsystems/vcpkg.cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_COMPILER=clang++-19 -DCMAKE_C_COMPILER=clang-19
cmake --build build-debug --target install
cd dist
cmake -E tar cJ "${{github.workspace}}/Brisk-${{github.ref_type == 'tag' && github.ref_name || github.sha}}-${{matrix.triplet}}.tar.xz" .
cmake -E tar cJ "${{github.workspace}}/Brisk-Prebuilt-${{github.ref_type == 'tag' && github.ref_name || github.sha}}-${{matrix.triplet}}.tar.xz" .
- name: Binaries
uses: actions/upload-artifact@v4
with:
name: ${{matrix.triplet}}
path: |
Brisk-*.tar.xz
Brisk-Dependencies-*.7z

build-windows:
strategy:
Expand Down Expand Up @@ -195,17 +193,16 @@ jobs:
cmake -GNinja -S . -B build-debug -DBRISK_TESTS=OFF -DBRISK_EXAMPLES=OFF -DCMAKE_INSTALL_PREFIX=dist -DVCPKG_MANIFEST_MODE=OFF -DVCPKG_TARGET_TRIPLET=%VCPKG_DEFAULT_TRIPLET% -DVCPKG_INSTALLED_DIR=vcpkg_installed -DCMAKE_TOOLCHAIN_FILE=%VCPKG_INSTALLATION_ROOT%/scripts/buildsystems/vcpkg.cmake -DBRISK_WEBGPU=ON -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_COMPILER="%LLVM_DIR%/bin/clang-cl.exe" -DCMAKE_C_COMPILER="%LLVM_DIR%/bin/clang-cl.exe" -DCMAKE_LINKER="%LLVM_DIR%/bin/lld-link.exe"
cmake --build build-debug --target install
cd dist
cmake -E tar cJ "${{github.workspace}}/Brisk-${{github.ref_type == 'tag' && github.ref_name || github.sha}}-${{matrix.triplet}}.tar.xz" .
cmake -E tar cJ "${{github.workspace}}/Brisk-Prebuilt-${{github.ref_type == 'tag' && github.ref_name || github.sha}}-${{matrix.triplet}}.tar.xz" .
- name: Binaries
uses: actions/upload-artifact@v4
with:
name: ${{matrix.triplet}}
path: |
Brisk-*.tar.xz
Brisk-Dependencies-*.7z

ubuntu-ninja-clang-x86_64:
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
needs: deps-linux
env:
VCPKG_DEFAULT_TRIPLET: x64-linux
Expand Down Expand Up @@ -417,7 +414,7 @@ jobs:
uses: actions/checkout@v4
- name: Install prerequisites
run: |
brew install ninja autoconf automake autoconf-archive
brew install ninja automake autoconf-archive
- name: Acquire dependencies
run: |
cmake -DDEP_BUILD=OFF -P acquire-deps.cmake
Expand All @@ -439,9 +436,147 @@ jobs:
build/*.png
build/*.log

usage-linux:
strategy:
fail-fast: false
matrix:
triplet: ["x64-linux"]
runs-on: ubuntu-24.04
needs: build-linux
steps:
- name: Install prerequisites
run: >
sudo apt-get update && sudo apt-get install -y ninja-build wget xorg-dev
libgl-dev libgl1-mesa-dev libvulkan-dev autoconf autoconf-archive libxrandr-dev
libxinerama-dev libxcursor-dev mesa-common-dev libx11-xcb-dev libwayland-dev libxkbcommon-dev
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: ${{matrix.triplet}}
- name: Extract Brisk
run: |
mkdir brisk-dist && cd brisk-dist
cmake -E tar xvf ../Brisk-Prebuilt-*.tar.xz
- name: Extract dependencies
run: |
mkdir vcpkg_exported && cd vcpkg_exported
cmake -E tar xvf ../Brisk-Dependencies-*.tar.xz
- name: Checkout
uses: actions/checkout@v4
with:
path: repo
- name: Configure
run: >
cmake -G"Unix Makefiles"
-S repo/examples/showcase
-B build
-DCMAKE_BUILD_TYPE=Release
-DVCPKG_TARGET_TRIPLET=${{matrix.triplet}}
-DCMAKE_PREFIX_PATH=${{github.workspace}}/brisk-dist/lib/cmake
-DVCPKG_INSTALLED_DIR=${{github.workspace}}/vcpkg_exported/installed
-DCMAKE_TOOLCHAIN_FILE=${{github.workspace}}/vcpkg_exported/scripts/buildsystems/vcpkg.cmake
- name: Build
run: |
cmake --build build
- name: Upload usage artifacts
uses: actions/upload-artifact@v4
with:
name: showcase-${{matrix.triplet}}
path: |
build/showcase

usage-macos:
strategy:
fail-fast: false
matrix:
triplet: ["x64-osx", "arm64-osx"]
runs-on: macos-latest
needs: build-macos
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: ${{matrix.triplet}}
- name: Extract Brisk
run: |
mkdir brisk-dist && cd brisk-dist
cmake -E tar xvf ../Brisk-Prebuilt-*.tar.xz
- name: Extract dependencies
run: |
mkdir vcpkg_exported && cd vcpkg_exported
cmake -E tar xvf ../Brisk-Dependencies-*.tar.xz
- name: Checkout
uses: actions/checkout@v4
with:
path: repo
- name: Configure
run: >
cmake -GXcode
-S repo/examples/showcase
-DCMAKE_OSX_ARCHITECTURES=${{ startsWith(matrix.triplet, 'x64') && 'x86_64' || 'arm64' }}
-B build
-DVCPKG_TARGET_TRIPLET=${{matrix.triplet}}
-DCMAKE_PREFIX_PATH=${{github.workspace}}/brisk-dist/lib/cmake
-DVCPKG_INSTALLED_DIR=${{github.workspace}}/vcpkg_exported/installed
-DCMAKE_TOOLCHAIN_FILE=${{github.workspace}}/vcpkg_exported/scripts/buildsystems/vcpkg.cmake
- name: Build
run: |
cmake --build build --config Release
- name: Upload usage artifacts
uses: actions/upload-artifact@v4
with:
name: showcase-${{matrix.triplet}}
path: |
build/Release/showcase.app

usage-windows:
strategy:
fail-fast: false
matrix:
triplet: ["x64-windows-static-md", "x86-windows-static-md", "x64-windows-static", "x86-windows-static"]
runs-on: windows-latest
needs: build-windows
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: ${{matrix.triplet}}
- name: Extract Brisk
run: |
mkdir brisk-dist && cd brisk-dist
cmake -E tar xvf (Get-ChildItem ../Brisk-Prebuilt-*.tar.xz).FullName
- name: Extract dependencies
run: |
mkdir vcpkg_exported && cd vcpkg_exported
cmake -E tar xvf (Get-ChildItem ../Brisk-Dependencies-*.tar.xz).FullName
- name: Checkout
uses: actions/checkout@v4
with:
path: repo
- name: Configure
run: >
cmake -G"Visual Studio 17 2022"
-A ${{ startsWith(matrix.triplet, 'x86') && 'Win32' || 'x64' }}
-S repo/examples/showcase
-B build
-DVCPKG_TARGET_TRIPLET=${{matrix.triplet}}
-DCMAKE_PREFIX_PATH=${{github.workspace}}/brisk-dist/lib/cmake
-DVCPKG_INSTALLED_DIR=${{github.workspace}}/vcpkg_exported/installed
-DCMAKE_TOOLCHAIN_FILE=${{github.workspace}}/vcpkg_exported/scripts/buildsystems/vcpkg.cmake
"-DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded$<$<CONFIG:Debug>:Debug>${{ endsWith(matrix.triplet, '-md') && 'DLL' || '' }}"
- name: Build
run: |
cmake --build build --config Release
- name: Upload usage artifacts
uses: actions/upload-artifact@v4
with:
name: showcase-${{matrix.triplet}}
path: |
build/Release/showcase.exe

upload-release:
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
permissions:
contents: write
needs: [build-windows, build-linux, build-macos]
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ vcpkg_cache
vcpkg_exported
dist
deps-*
Brisk-Prebuilt-*
Brisk-Dependencies-*
11 changes: 9 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -261,9 +261,16 @@ install(
set(DEP_HASH_SILENT ON)
include(dep-hash.cmake)

configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/Package-README.me.in ${CMAKE_CURRENT_BINARY_DIR}/Package-README.me)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/Package-README.md.in ${CMAKE_CURRENT_BINARY_DIR}/Package-README.md)

write_file(${CMAKE_CURRENT_BINARY_DIR}/DEP_HASH ${DEP_HASH})
write_file(${CMAKE_CURRENT_BINARY_DIR}/VCPKG_TARGET_TRIPLET ${VCPKG_TARGET_TRIPLET})

install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/Package-README.me
FILES ${CMAKE_CURRENT_BINARY_DIR}/Package-README.md
RENAME README.md
DESTINATION .)

install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/DEP_HASH ${CMAKE_CURRENT_BINARY_DIR}/VCPKG_TARGET_TRIPLET
DESTINATION ${BRISK_INSTALL_CMAKEDIR})
11 changes: 2 additions & 9 deletions acquire-deps.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
set(ROOT ${CMAKE_CURRENT_LIST_DIR})

set(URL https://download.brisklib.com/brisk-deps/{TRIPLET}-{DEP_HASH}.7z)
set(URL https://download.brisklib.com/brisk-deps/{TRIPLET}-{DEP_HASH}.tar.xz)

if (DEFINED ENV{VCPKG_TARGET_TRIPLET})
set(VCPKG_TARGET_TRIPLET $ENV{VCPKG_TARGET_TRIPLET})
Expand All @@ -17,7 +17,7 @@ include(${ROOT}/dep-hash.cmake)
# Define the URL and destination file for download
string(REPLACE "{DEP_HASH}" "${DEP_HASH}" URL "${URL}")
string(REPLACE "{TRIPLET}" "${VCPKG_TARGET_TRIPLET}" URL "${URL}")
set(DEST_FILE ${ROOT}/Brisk-Dependencies-${VCPKG_TARGET_TRIPLET}-${DEP_HASH}.7z)
set(DEST_FILE ${ROOT}/Brisk-Dependencies-${DEP_HASH}-${VCPKG_TARGET_TRIPLET}.tar.xz)

if (NOT EXISTS ${DEST_FILE})

Expand Down Expand Up @@ -67,13 +67,6 @@ if (NOT EXISTS ${ROOT}/vcpkg_exported)
message(FATAL_ERROR "cmake -E tar failed with exit code ${RESULT}")
endif ()

# Move all contents of extracted folder to the root of vcpkg_exported
file(GLOB EXTRACTED_CONTENTS "${ROOT}/vcpkg_exported/*/*")
foreach (FILE IN LISTS EXTRACTED_CONTENTS)
get_filename_component(ONLY_NAME ${FILE} NAME)
file(RENAME ${FILE} ${ROOT}/vcpkg_exported/${ONLY_NAME})
endforeach ()

file(GLOB VCPKG_INSTALLED_CONTENTS ${ROOT}/vcpkg_installed/*)
if (NOT VCPKG_INSTALLED_CONTENTS STREQUAL "")
message(
Expand Down
5 changes: 4 additions & 1 deletion cmake/Package-README.me.in → cmake/Package-README.md.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

## Dependencies

This package is built with the `@VCPKG_TARGET_TRIPLET@` vcpkg triplet.
Ensure your application's selected triplet matches the one used to build Brisk.

You can download dependencies that are required for building Brisk applications here:

https://download.brisklib.com/brisk-deps/@VCPKG_TARGET_TRIPLET@-@DEP_HASH@.7z
https://download.brisklib.com/brisk-deps/@VCPKG_TARGET_TRIPLET@-@DEP_HASH@.tar.xz

3 changes: 3 additions & 0 deletions dep-hash.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ if (NOT DEFINED DEP_HASH_SILENT)
endif ()

string(SHA256 DEP_HASH "${HASHES}")

string(SUBSTRING "${DEP_HASH}" 0 8 DEP_HASH)

if (NOT DEFINED DEP_HASH_SILENT)
message(STATUS ${DEP_HASH})
endif ()
5 changes: 5 additions & 0 deletions examples/calc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,14 @@
# If you do not wish to be bound by the GPL-2.0+ license, you must purchase a commercial license. For commercial
# licensing options, please visit: https://brisklib.com
#
cmake_minimum_required(VERSION 3.16)

project(calc)

if (NOT _BRISK_INCLUDE_DIR)
find_package(Brisk CONFIG REQUIRED)
endif ()

add_subdirectory(decNumber)

add_executable(calc calc.cpp)
Expand Down
7 changes: 6 additions & 1 deletion examples/showcase/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,14 @@
# If you do not wish to be bound by the GPL-2.0+ license, you must purchase a commercial license. For commercial
# licensing options, please visit: https://brisklib.com
#
cmake_minimum_required(VERSION 3.16)

project(showcase)

if (NOT _BRISK_INCLUDE_DIR)
find_package(Brisk CONFIG REQUIRED)
endif ()

add_executable(
showcase
src/showcase.cpp
Expand All @@ -42,7 +47,7 @@ add_executable(
src/Messenger.hpp
src/Messenger.cpp)

target_link_libraries(showcase PRIVATE brisk-widgets brisk-executable)
target_link_libraries(showcase PRIVATE Brisk::Widgets Brisk::Executable)

brisk_metadata(
VENDOR "Brisk"
Expand Down
8 changes: 5 additions & 3 deletions include/brisk/core/Binding.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ template <typename... Args>
struct Trigger {
using Type = typename Internal::TriggerArgs<Args...>::Type;

constexpr static bool isTrigger = true;

std::optional<Type> arg;

operator Type() const {
Expand Down Expand Up @@ -183,9 +185,9 @@ using ValueArgument = typename Internal::ValueArgumentImpl<T>::Type;
* @tparam T The type to check.
*/
template <typename T>
concept PropertyLike = requires(T t, const T ct, typename T::Type v) {
requires std::copy_constructible<typename T::Type>;
{ ct.get() } -> std::convertible_to<typename T::Type>;
concept PropertyLike = requires(T t, const T ct, typename T::ValueType v) {
requires std::copy_constructible<typename T::ValueType>;
{ ct.get() } -> std::convertible_to<typename T::ValueType>;
t.set(v);
{ ct.address() } -> std::convertible_to<BindingAddress>;
{ t.this_pointer = nullptr };
Expand Down
9 changes: 9 additions & 0 deletions include/brisk/core/Reflection.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,15 @@ constexpr void forEachField(Fn&& fn) {
reflection);
}

template <HasReflection T, size_t index>
using FieldType =
std::remove_reference_t<decltype(std::declval<T>().*std::get<index>(reflectionOf<T>()).pointerToField)>;

template <size_t index, HasReflection T>
constexpr decltype(auto) accessField(T&& obj) {
return obj.*(std::get<index>(reflectionOf(std::forward<T>(obj))).pointerToField);
}

/**
* @brief Returns the number of enum values based on the last enum value.
*
Expand Down
Loading