Skip to content

Commit

Permalink
improve Windows and Mac releases
Browse files Browse the repository at this point in the history
  • Loading branch information
kupix committed Nov 19, 2024
1 parent dbef55a commit b0189dd
Show file tree
Hide file tree
Showing 8 changed files with 125 additions and 100 deletions.
69 changes: 34 additions & 35 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,38 +22,39 @@ jobs:

- name: 🛠️ Configure, build and install presets
env:
GITHUB_REF: ${{github.ref}}
GITHUB_REF_NAME: ${{github.ref_name}}
CMAKE_BUILD_PARALLEL_LEVEL: 2
ANDROID_NDK: /usr/local/lib/android/sdk/ndk/26.3.11579264
run: |
sudo apt-get -y install mingw-w64
for PRESET in \
linux-x86_64 \
windows-x86_64 \
android-armeabi-v7a \
android-arm64-v8a \
android-x86 \
android-x86_64 \
; do
BUNGEE_VERSION=${GITHUB_REF//v} \
cmake \
--preset ${PRESET} \
-S ${{github.workspace}}/bungee \
-B ${{github.workspace}}/builds/${PRESET} \
-D CMAKE_INSTALL_PREFIX=${{github.workspace}}/ubuntu/ \
-D BUNGEE_ABI_NAME=${PRESET} \
-D BUNGEE_VERSION=${BUNGEE_VERSION} \
-D CMAKE_INSTALL_PREFIX=${{github.workspace}}/install/bungee-${PRESET} \
-D BUNGEE_VERSION=${GITHUB_REF_NAME//v} \
-G "Unix Makefiles"
cmake \
--build ${{github.workspace}}/builds/${PRESET}/ \
--target install
--build ${{github.workspace}}/builds/${PRESET} \
--target install
touch ${{github.workspace}}/install/bungee-${PRESET}/${{github.ref_name}}
done
- name: 🗜️ Prepare archives
working-directory: ${{github.workspace}}/install
run: |
cd bungee-windows-x86_64
zip -r ../bungee-windows.zip *
- name: ✈️ Upload artifact
uses: actions/upload-artifact@v4
with:
name: ubuntu-latest-install
path: ${{github.workspace}}/ubuntu/
path: ${{github.workspace}}/install


build_macos:
runs-on: macos-latest
Expand All @@ -71,43 +72,41 @@ jobs:
uses: actions/download-artifact@v4
with:
name: ubuntu-latest-install
path: ${{github.workspace}}/bungee-${{ github.ref_name }}
path: ${{github.workspace}}/install

- name: 🛠️ Configure, build and install Apple presets
env:
GITHUB_REF: ${{github.ref}}
GITHUB_REF_NAME: ${{github.ref_name}}
CMAKE_BUILD_PARALLEL_LEVEL: 2
run: |
for PRESET in \
apple-mac-arm64 \
apple-mac-x86_64 \
apple-ios-arm64 \
apple-ios-x86_64 \
apple-mac \
; do
BUNGEE_VERSION=${GITHUB_REF//v} \
cmake \
--preset ${PRESET} \
-S ${{github.workspace}}/bungee \
-B ${{github.workspace}}/builds/${PRESET} \
-D CMAKE_INSTALL_PREFIX=${{github.workspace}}/bungee-${{ github.ref_name }} \
-D BUNGEE_ABI_NAME=${PRESET} \
-D BUNGEE_VERSION=${BUNGEE_VERSION}
-S bungee \
-B builds/${PRESET} \
-D CMAKE_INSTALL_PREFIX=bungee-${PRESET} \
-D BUNGEE_VERSION=${GITHUB_REF_NAME//v}
cmake \
--build ${{github.workspace}}/builds/${PRESET} \
--build builds/${PRESET} \
--config Release
cmake \
--install ${{github.workspace}}/builds/${PRESET}
--install builds/${PRESET}
done
- name: 🗜️ Prepare archive
- name: 🗜️ Prepare archives
run: |
tar -cvzf ${{github.workspace}}/bungee-${{ github.ref_name }}.tgz -C ${{github.workspace}} bungee-${{ github.ref_name }}
mv bungee-apple-mac bungee-mac
tar -cvzf ${{github.workspace}}/install/bungee-mac.tgz bungee-mac/*
- name: ⭐ Create release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
run: |
gh release create "${{ github.ref_name }}" \
--repo="${{ github.repository }}" \
--title="Bungee ${{ github.ref_name }}" \
${{github.workspace}}/bungee-${{ github.ref_name }}.tgz
gh release create "${{github.ref_name}}" \
--repo="${{github.repository}}" \
--title="Bungee ${{github.ref_name}}" \
${{github.workspace}}/install/bungee-windows.zip \
${{github.workspace}}/install/bungee-mac.tgz
116 changes: 70 additions & 46 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
project(bungee)

set(BUNGEE_VERSION 0.0.0 CACHE STRING "Bungee version string")
set(BUNGEE_SELF_TEST 0 CACHE STRING "Enable Bungee self tests (0=off, 1=fast, 2=full)")
option(BUNGEE_BUILD_STATIC_LIBRARIES "Build static, not dynamic, Bungee libraries" OFF)

cmake_minimum_required(VERSION 3.30...3.31)

project(bungee VERSION ${BUNGEE_VERSION})
set(CMAKE_CXX_STANDARD 20)
set(BUNGEE_SELF_TEST 0 CACHE STRING "Enable self tests (0=off, 1=fast, 2=full)")
option(BUNGEE_BUILD_STATIC_LIBRARIES "Build static libraries" OFF)
cmake_minimum_required(VERSION 3.30)

# Bungee library target: "bungee_library"
file(GLOB BUNGEE_LIBRARY_HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/bungee/*.h")
Expand All @@ -27,65 +31,85 @@ if(BUNGEE_BUILD_STATIC_LIBRARIES)
else()
add_library(bungee_library SHARED ${BUNGEE_LIBRARY_HEADERS} ${BUNGEE_LIBRARY_SOURCES})
endif()
set_target_properties(bungee_library PROPERTIES OUTPUT_NAME bungee)
target_include_directories(bungee_library PUBLIC .)
target_include_directories(bungee_library PRIVATE submodules submodules/eigen)
#set_target_properties(bungee_library PROPERTIES
# OUTPUT_NAME bungee)
target_include_directories(bungee_library PUBLIC
.)
target_include_directories(bungee_library PRIVATE
submodules
submodules/eigen)
target_compile_definitions(bungee_library PRIVATE
BUNGEE_SELF_TEST=${BUNGEE_SELF_TEST}
eigen_assert=BUNGEE_ASSERT1
EIGEN_DONT_PARALLELIZE=1)
target_compile_options(bungee_library PRIVATE $<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-fwrapv>)
target_compile_options(bungee_library PRIVATE
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-fwrapv>)
set_target_properties(bungee_library PROPERTIES
PUBLIC_HEADER "${BUNGEE_LIBRARY_HEADERS}"
OUTPUT_NAME bungee)
target_link_libraries(bungee_library PRIVATE kissfft)
target_link_libraries(bungee_library PRIVATE
kissfft)

# Bungee command-line executable target: "bungee_executable"
add_executable(bungee_executable cmd/main.cpp)
target_link_libraries(bungee_executable PRIVATE bungee_library)
target_include_directories(bungee_executable PRIVATE submodules/cxxopts/include .)
set_target_properties(bungee_executable
PROPERTIES OUTPUT_NAME bungee)
add_executable(bungee_executable
cmd/main.cpp)
target_link_libraries(bungee_executable PRIVATE
bungee_library)
target_include_directories(bungee_executable PRIVATE
submodules/cxxopts/include
.)
set_target_properties(bungee_executable PROPERTIES
OUTPUT_NAME bungee)

# KissFFT build
set(CMAKE_WARN_DEPRECATED OFF CACHE BOOL "" FORCE)
set(KISSFFT_PKGCONFIG OFF CACHE INTERNAL "" FORCE)
set(KISSFFT_STATIC ON CACHE INTERNAL "" FORCE)
set(KISSFFT_TEST OFF CACHE INTERNAL "" FORCE)
set(KISSFFT_TOOLS OFF CACHE INTERNAL "" FORCE)
add_subdirectory(submodules/kissfft EXCLUDE_FROM_ALL)

# Further optimisation and hygiene for Release mode
if(CMAKE_BUILD_TYPE STREQUAL "Release")
include(CheckIPOSupported)
check_ipo_supported(RESULT supported OUTPUT error)
if(supported)
message(STATUS "IPO / LTO enabled")
set_property(TARGET bungee_library PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
set_property(TARGET bungee_executable PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
else()
message(STATUS "IPO / LTO not supported: <${error}>")
endif()
target_compile_options(bungee_library PRIVATE -fno-rtti)
target_link_options(bungee_library PRIVATE -s)
target_link_options(bungee_executable PRIVATE -s)
include(CheckIPOSupported)
check_ipo_supported(RESULT supported OUTPUT error)
if(supported)
message(STATUS "IPO / LTO enabled")
set_property(TARGET bungee_library PROPERTY INTERPROCEDURAL_OPTIMIZATION $<CONFIG:Release>>)
set_property(TARGET bungee_executable PROPERTY INTERPROCEDURAL_OPTIMIZATION $<CONFIG:Release>)
else()
message(STATUS "IPO / LTO not supported: <${error}>")
endif()
target_compile_options(bungee_library PRIVATE $<$<CONFIG:Release>:-fno-rtti -fvisibility=hidden>)
add_custom_command(TARGET bungee_library POST_BUILD
COMMAND $<$<CONFIG:Release>:${CMAKE_STRIP}>
ARGS $<IF:$<BOOL:${APPLE}>,-u,-s> $<TARGET_FILE:bungee_library>)
add_custom_command(TARGET bungee_executable POST_BUILD
COMMAND $<$<CONFIG:Release>:${CMAKE_STRIP}>
ARGS $<IF:$<BOOL:${APPLE}>,,-s> $<TARGET_FILE:bungee_executable>)

# Installation
set(BUNGEE_VERSION 0.0 CACHE STRING "Bungee framework version string")
set_target_properties(bungee_library PROPERTIES
FRAMEWORK TRUE
MACOSX_FRAMEWORK_IDENTIFIER com.parabolaresearch.bungee
XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "iPhone Developer"
MACOSX_FRAMEWORK_BUNDLE_VERSION ${BUNGEE_VERSION}
MACOSX_FRAMEWORK_SHORT_VERSION_STRING ${BUNGEE_VERSION}
)

install(FILES cmd/main.cpp DESTINATION ${CMAKE_INSTALL_PREFIX}/sample)

install(TARGETS bungee_library bungee_executable
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_PREFIX}/${BUNGEE_ABI_NAME}/include/bungee
ARCHIVE DESTINATION ${CMAKE_INSTALL_PREFIX}/${BUNGEE_ABI_NAME}/library
LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/${BUNGEE_ABI_NAME}/library
RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/${BUNGEE_ABI_NAME}/runtime
BUNDLE DESTINATION ${CMAKE_INSTALL_PREFIX}/${BUNGEE_ABI_NAME}/bundle
FRAMEWORK DESTINATION ${CMAKE_INSTALL_PREFIX}/${BUNGEE_ABI_NAME}/framework)
if (APPLE)
set_target_properties(bungee_library PROPERTIES
FRAMEWORK TRUE
XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "iPhone Developer"
MACOSX_FRAMEWORK_BUNDLE_VERSION ${BUNGEE_VERSION}
MACOSX_FRAMEWORK_SHORT_VERSION_STRING ${BUNGEE_VERSION}
VERSION ${BUNGEE_VERSION}
)
set_source_files_properties(
${BUNGEE_LIBRARY_HEADERS}
PROPERTIES
MACOSX_PACKAGE_LOCATION Headers/bungee)
else()
install(FILES
${BUNGEE_LIBRARY_HEADERS}
DESTINATION ${CMAKE_INSTALL_PREFIX}/include/bungee)
endif()
install(TARGETS bungee_library
ARCHIVE DESTINATION ${CMAKE_INSTALL_PREFIX}/library
LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/library
RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/runtime
FRAMEWORK DESTINATION ${CMAKE_INSTALL_PREFIX})
install(FILES
cmd/main.cpp
submodules/cxxopts/include/cxxopts.hpp
DESTINATION ${CMAKE_INSTALL_PREFIX}/sample)
18 changes: 7 additions & 11 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,11 @@
"CMAKE_CXX_COMPILER": "x86_64-w64-mingw32-g++",
"CMAKE_FIND_ROOT_PATH_MODE_PROGRAM": "NEVER",
"CMAKE_FIND_ROOT_PATH_MODE_INCLUDE": "ONLY",
"CMAKE_EXE_LINKER_FLAGS":"-static-libgcc -static-libstdc++ -static",
"CMAKE_SHARED_LINKER_FLAGS":"-static-libgcc -static-libstdc++ -static"
"CMAKE_EXE_LINKER_FLAGS": "-static-libgcc -static-libstdc++ -static ",
"CMAKE_SHARED_LINKER_FLAGS": "-static-libgcc -static-libstdc++ -static",
"CMAKE_SHARED_LIBRARY_PREFIX_CXX": "",
"CMAKE_IMPORT_LIBRARY_PREFIX_CXX": "",
"CMAKE_IMPORT_LIBRARY_SUFFIX_CXX": ".lib"
}
},
{
Expand Down Expand Up @@ -96,17 +99,10 @@
}
},
{
"name": "apple-mac-arm64",
"name": "apple-mac",
"inherits": "apple",
"cacheVariables": {
"PLATFORM": "MAC_ARM64"
}
},
{
"name": "apple-mac-x86_64",
"inherits": "apple",
"cacheVariables": {
"PLATFORM": "MAC"
"PLATFORM": "MAC_UNIVERSAL"
}
},
{
Expand Down
10 changes: 8 additions & 2 deletions bungee/Bungee.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,21 @@ struct Bungee_Stretcher_FunctionTable
bool (*isFlushed)(const void *implementation);
};

#if defined(_WIN32) && defined(bungee_library_EXPORTS)
# define BUNGEE_C_API __declspec(dllexport)
#if defined(bungee_library_EXPORTS)
# if defined(_WIN32)
# define BUNGEE_C_API __declspec(dllexport)
# else
# define BUNGEE_C_API __attribute__((visibility("default")))
# endif
#else
# define BUNGEE_C_API
#endif

extern "C" BUNGEE_C_API Bungee_Stretcher_FunctionTable Bungee_Stretcher_getFunctionTable();
extern "C" BUNGEE_C_API Bungee_Stretcher_FunctionTable BungeePro_Stretcher_getFunctionTable();

#undef BUNGEE_C_API

namespace Bungee {

typedef ::Bungee_Request Request;
Expand Down
4 changes: 2 additions & 2 deletions bungee/CommandLine.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Copyright (C) 2024 Parabola Research Limited
// SPDX-License-Identifier: MPL-2.0

#include "bungee/Bungee.h"
#include "bungee/Push.h"
#include <bungee/Bungee.h>
#include <bungee/Push.h>

#define CXXOPTS_NO_EXCEPTIONS
#include "cxxopts.hpp"
Expand Down
2 changes: 1 addition & 1 deletion bungee/Push.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include <cassert>
#include <vector>

#include "Bungee.h"
#include <bungee/Bungee.h>

namespace Bungee::Push {

Expand Down
4 changes: 2 additions & 2 deletions cmd/main.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Copyright (C) 2024 Parabola Research Limited
// SPDX-License-Identifier: MPL-2.0

#include "bungee/Bungee.h"
#include "bungee/CommandLine.h"
#include <bungee/Bungee.h>
#include <bungee/CommandLine.h>

int main(int argc, const char *argv[])
{
Expand Down
2 changes: 1 addition & 1 deletion src/Assert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

namespace Bungee::Assert {

#if BUNGEE_SELF_TEST
#ifndef BUNGEE_ASSERT_FAIL_EXTERNAL
void fail(int level, const char *message, const char *file, int line)
{
Expand All @@ -17,7 +18,6 @@ void fail(int level, const char *message, const char *file, int line)
}
#endif

#if BUNGEE_SELF_TEST
FloatingPointExceptions::FloatingPointExceptions(int allowed) :
allowed(allowed)
{
Expand Down

0 comments on commit b0189dd

Please sign in to comment.