Skip to content
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
71 changes: 71 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Bazel configuration for djinni-support-lib

# Import common configs
import %workspace%/.bazelrc.common

# Build optimizations
build --compilation_mode=opt
build --copt=-O2
build --copt=-DNDEBUG

# C++ Configuration
build --cxxopt=-std=c++17
build --host_cxxopt=-std=c++17
build --copt=-Wall
build --copt=-Wextra
build --copt=-Werror

# Platform-specific configurations
build:linux --copt=-fPIC
build:linux --linkopt=-ldl

build:macos --copt=-fPIC
build:macos --linkopt=-framework Foundation
build:macos --apple_platform_type=macos

build:ios --apple_platform_type=ios
build:ios --copt=-fobjc-arc
build:ios --linkopt=-framework Foundation

build:windows --copt=/std:c++17
build:windows --host_copt=/std:c++17

# JNI Configuration
build --define=with_jni=true

# Objective-C Configuration (when building on macOS/iOS)
build:objc --copt=-fobjc-arc
build:objc --copt=-x
build:objc --copt=objective-c++

# Python Configuration
build:python --define=with_python=true

# C++/CLI Configuration (Windows only)
build:cppcli --define=with_cppcli=true
build:cppcli --copt=/clr

# Test Configuration
test --test_output=errors
test --test_summary=detailed
test --test_verbose_timeout_warnings

# Coverage
coverage --combined_report=lcov
coverage --coverage_report_generator=@bazel_tools//tools/test:coverage_report_generator

# Debug Configuration
build:debug --compilation_mode=dbg
build:debug --copt=-g
build:debug --strip=never
build:debug --linkopt=-g

# Fast build (for development)
build:fastbuild --compilation_mode=fastbuild

# Remote execution (if using remote build execution)
build:remote --remote_executor=...
build:remote --remote_cache=...

# Try to import user-specific .bazelrc.user file if it exists
try-import %workspace%/.bazelrc.user
200 changes: 61 additions & 139 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,155 +2,77 @@ name: build-all-configs
on: [push, pull_request]
jobs:
build-on-osx-for-objectiveC:
runs-on: macos-11
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- uses: asdf-vm/actions/install@v1
- name: Report cmake version
run: cmake --version
- name: Configure cmake
run: cmake -S . -B build -DDJINNI_WITH_OBJC=ON -G Xcode
- name: Build release
run: cmake --build build --parallel $(sysctl -n hw.ncpu) --config Release
- name: Run tests
working-directory: build/test-suite
run: ctest -C Release -V
- name: Install files
run: cmake --build build --parallel $(sysctl -n hw.ncpu) --config Release --target install -- DESTDIR=check_install_root
- name: List installed files
working-directory: build/check_install_root
run: du -a | tail -r | awk -F ' ' '{print $2}'
- name: Test if expected files have been installed
working-directory: build/check_install_root
run: diff -u ../../test/objc_list.txt <(du -a | tail -r | awk -F ' ' '{print $2}')

build-on-osx-for-python:
runs-on: macos-11
strategy:
matrix:
python-version: ["3.7.12", "3.10.4"] # oldest and newest, rest assumed to work
steps:
- uses: actions/checkout@v2
- uses: asdf-vm/actions/install@v1
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install Python dependencies
uses: py-actions/py-dependency-install@v3
with:
path: "requirements.txt"
- name: Report cmake version
run: cmake --version
- name: Configure cmake
run: cmake -S . -B build -DDJINNI_WITH_PYTHON=ON
- name: Build release
run: cmake --build build --parallel $(sysctl -n hw.ncpu) --config Release
- name: Run tests
working-directory: build/test-suite
run: ctest -C Release -V
- uses: actions/checkout@v2
- uses: asdf-vm/actions/install@v4
- name: Report cmake version
run: cmake --version
- name: Configure cmake
run: cmake -S . -B build -DDJINNI_WITH_OBJC=ON -DCMAKE_OSX_SYSROOT=$(xcodebuild -version -sdk macosx Path) -G Xcode
- name: Build release
run: cmake --build build --parallel $(sysctl -n hw.ncpu) --config Release
- name: Run tests
working-directory: build/test-suite
run: ctest -C Release -V
- name: Install files
run: cmake --build build --parallel $(sysctl -n hw.ncpu) --config Release --target install -- DESTDIR=check_install_root
- name: List installed files
working-directory: build/check_install_root
run: du -a | tail -r | awk -F ' ' '{print $2}'
- name: Test if expected files have been installed
working-directory: build/check_install_root
run: diff -u ../../test/objc_list.txt <(du -a | tail -r | awk -F ' ' '{print $2}')

build-on-ubuntu-for-jni:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: asdf-vm/actions/install@v1
- name: Report cmake version
run: cmake --version
- name: Configure cmake
run: cmake -S . -B build -DDJINNI_WITH_JNI=ON
- name: Build release
run: cmake --build build --parallel $(nproc) --config Release
- name: Run tests
working-directory: build/test-suite
run: ctest -C Release -V
- name: Install files
run: cmake --build build --parallel $(nproc) --config Release --target install -- DESTDIR=check_install_root
- name: List installed files
working-directory: build/check_install_root
run: du -a | tac | awk -F ' ' '{print $2}' | sort
- name: Test if expected files have been installed
working-directory: build/check_install_root
run: diff -u ../../test/jni_list.txt <(du -a | tac | awk -F ' ' '{print $2}' | sort)
- uses: actions/checkout@v2
- uses: asdf-vm/actions/install@v4
- name: Report cmake version
run: cmake --version
- name: Configure cmake
run: cmake -S . -B build -DDJINNI_WITH_JNI=ON
- name: Build release
run: cmake --build build --parallel $(nproc) --config Release
- name: Run tests
working-directory: build/test-suite
run: ctest -C Release -V
- name: Install files
run: cmake --build build --parallel $(nproc) --config Release --target install -- DESTDIR=check_install_root
- name: List installed files
working-directory: build/check_install_root
run: du -a | tac | awk -F ' ' '{print $2}' | sort
- name: Test if expected files have been installed
working-directory: build/check_install_root
run: diff -u ../../test/jni_list.txt <(du -a | tac | awk -F ' ' '{print $2}' | sort)

build-on-ubuntu-for-jni-with-thread-attach:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: asdf-vm/actions/install@v1
- name: Report cmake version
run: cmake --version
- name: Configure cmake
run: cmake -S . -B build -DDJINNI_WITH_JNI=ON -DJNI_CPP_THREAD_ATTACH=ON -DCMAKE_BUILD_TYPE=Release
- name: Build release
run: cmake --build build --parallel $(nproc)
- name: Run tests
working-directory: build/test-suite
run: ctest -C Release -V

- uses: actions/checkout@v2
- uses: asdf-vm/actions/install@v4
- name: Report cmake version
run: cmake --version
- name: Configure cmake
run: cmake -S . -B build -DDJINNI_WITH_JNI=ON -DJNI_CPP_THREAD_ATTACH=ON -DCMAKE_BUILD_TYPE=Release
- name: Build release
run: cmake --build build --parallel $(nproc)
- name: Run tests
working-directory: build/test-suite
run: ctest -C Release -V

build-on-ubuntu-for-android_arm32-with-thread-attach:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: asdf-vm/actions/install@v1
- uses: ashutoshvarma/setup-ninja@master
with:
version: 1.10.2
- name: Report cmake version
run: cmake --version
- name: Configure cmake
run: cmake -S . -B build -DDJINNI_WITH_JNI=ON -DJNI_CPP_THREAD_ATTACH=ON -DCMAKE_BUILD_TYPE=Release -DJINNI_BUILD_TESTING=OFF -DCMAKE_TOOLCHAIN_FILE=${ANDROID_SDK_ROOT}/ndk/$(ls ${ANDROID_SDK_ROOT}/ndk -C1 | sort -r | head -1)/build/cmake/android.toolchain.cmake -DANDROID_PLATFORM=android-26 -DANDROID_NATIVE_API_LEVEL=26 -DANDROID_ABI=armeabi-v7a -G Ninja
- name: Build release
run: cmake --build build --parallel $(nproc)

build-on-ubuntu-for-python:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: asdf-vm/actions/install@v1
- name: Install dependencies
uses: py-actions/py-dependency-install@v3
with:
path: "requirements.txt"
- name: Report cmake version
run: cmake --version
- name: Configure cmake
run: cmake -S . -B build -DDJINNI_WITH_PYTHON=ON
- name: Build release
run: cmake --build build --parallel $(nproc) --config Release
- name: Run tests
working-directory: build/test-suite
run: ctest -C Release -V


build-on-windows-for-cppcli:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- name: install djinni
run: |
$VERSION = 'v' + [regex]::Match((Get-Content .tool-versions), '^djinni (\d+.\d+.\d+)').captures.groups[1].value
$URL = 'https://github.com/cross-language-cpp/djinni-generator/releases/download/' + $VERSION + '/djinni.bat'
Invoke-WebRequest -Uri $URL -OutFile djinni.bat
- name: Report cmake version
run: cmake --version
- name: Configure cmake
run: cmake -S . -B build -DDJINNI_WITH_CPPCLI=ON -DCMAKE_INSTALL_PREFIX=build/check_install_root -DDJINNI_EXECUTABLE="$(((Get-Location).Path) -replace "\\","/")/djinni.bat" -G "Visual Studio 17 2022"
- name: Install nuget dependencies
working-directory: build/test-suite
run: dotnet restore DjinniCppCliTest.csproj --runtime win-x64
- name: Build release
run: cmake --build build --config Release
- name: Run tests
working-directory: build/test-suite
run: dotnet test Release/DjinniCppCliTest.dll
- name: Install files
run: cmake --build build --config Release --target install
- name: List installed files
working-directory: build/check_install_root
run: Resolve-Path -Path (Get-ChildItem -Recurse).FullName -Relative
- name: Test if expected files have been installed
working-directory: build/check_install_root
run: if((Compare-Object (Get-Content ..\..\test\cppcli_list.txt) (Resolve-Path -Path (Get-ChildItem -Recurse).FullName -Relative))) { Write-Error "file list not equal" }

- uses: actions/checkout@v2
- uses: asdf-vm/actions/install@v4
- uses: ashutoshvarma/setup-ninja@master
with:
version: 1.10.2
- name: Report cmake version
run: cmake --version
- name: Configure cmake
run: cmake -S . -B build -DDJINNI_WITH_JNI=ON -DJNI_CPP_THREAD_ATTACH=ON -DCMAKE_BUILD_TYPE=Release -DJINNI_BUILD_TESTING=OFF -DCMAKE_TOOLCHAIN_FILE=${ANDROID_SDK_ROOT}/ndk/$(ls ${ANDROID_SDK_ROOT}/ndk -C1 | sort -r | head -1)/build/cmake/android.toolchain.cmake -DANDROID_PLATFORM=android-26 -DANDROID_NATIVE_API_LEVEL=26 -DANDROID_ABI=armeabi-v7a -G Ninja
- name: Build release
run: cmake --build build --parallel $(nproc)
4 changes: 2 additions & 2 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
djinni 1.3.1
java zulu-11.41.23
djinni 1.4.1
java openjdk-25
71 changes: 3 additions & 68 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
cmake_minimum_required(VERSION 3.6.0)
cmake_minimum_required(VERSION 3.10.0)

if(DJINNI_WITH_OBJC)
set(PROJECT_LANGUAGES OBJC OBJCXX)
elseif(DJINNI_WITH_CPPCLI)
set(PROJECT_LANGUAGES CSharp)
endif()

project(djinni_support_lib CXX ${PROJECT_LANGUAGES})
Expand Down Expand Up @@ -32,22 +30,6 @@ set(SRC_OBJC
"djinni/objc/DJIProxyCaches.mm"
)

set(SRC_C_WRAPPER
"djinni/cwrapper/wrapper_marshal.cpp"
"djinni/cwrapper/wrapper_marshal.h"
"djinni/cwrapper/wrapper_marshal.hpp"
)

set(SRC_CPPCLI
"djinni/cppcli/Assert.hpp"
"djinni/cppcli/AutoPtr.hpp"
"djinni/cppcli/Error.hpp"
"djinni/cppcli/Error.cpp"
"djinni/cppcli/Marshal.hpp"
"djinni/cppcli/WrapperCache.hpp"
"djinni/cppcli/WrapperCache.cpp"
)

# set `DJINNI_LIBRARY_TYPE` to `STATIC` or `SHARED` to define the type of library.
# If undefined, the type will be determined based on `BUILD_SHARED_LIBS`
add_library(djinni_support_lib ${DJINNI_LIBRARY_TYPE} ${SRC_SHARED})
Expand Down Expand Up @@ -133,55 +115,8 @@ if(DJINNI_WITH_JNI)
endif()
endif()

# Python support
option(DJINNI_WITH_PYTHON "Include the Python support code in Djinni support library." OFF)
if(DJINNI_WITH_PYTHON)
set_target_properties(djinni_support_lib PROPERTIES
POSITION_INDEPENDENT_CODE ON)
target_sources(djinni_support_lib PRIVATE ${SRC_C_WRAPPER})
source_group("cwrapper" FILES ${SRC_C_WRAPPER})
# these files might be delivered in future per default
install(
FILES
"djinni/cwrapper/wrapper_marshal.h"
"djinni/cwrapper/wrapper_marshal.hpp"
DESTINATION
${CMAKE_INSTALL_INCLUDEDIR}/djinni/cwrapper
)
endif()

option(DJINNI_WITH_CPPCLI "Include the C++/CLI support code in Djinni support library." OFF)
if(DJINNI_WITH_CPPCLI)

if(NOT MSVC)
message(FATAL_ERROR "Enabling DJINNI_WITH_CPPCLI without MSVC is not supported")
endif()

if(DJINNI_WITH_OBJC OR DJINNI_WITH_JNI OR DJINNI_WITH_PYTHON)
message(FATAL_ERROR "DJINNI_WITH_CPPCLI can not be used with other bindings enabled.")
endif()

target_sources(djinni_support_lib PRIVATE ${SRC_CPPCLI})
source_group("cppcli" FILES ${SRC_CPPCLI})
set_target_properties(djinni_support_lib PROPERTIES
VS_DOTNET_REFERENCES "System;System.Core"
COMMON_LANGUAGE_RUNTIME ""
)

install(
FILES
"djinni/cppcli/Assert.hpp"
"djinni/cppcli/AutoPtr.hpp"
"djinni/cppcli/Error.hpp"
"djinni/cppcli/Marshal.hpp"
"djinni/cppcli/WrapperCache.hpp"
DESTINATION
${CMAKE_INSTALL_INCLUDEDIR}/djinni/cppcli
)
endif()

if(NOT (DJINNI_WITH_OBJC OR DJINNI_WITH_JNI OR DJINNI_WITH_PYTHON OR DJINNI_WITH_CPPCLI))
message(FATAL_ERROR "At least one of DJINNI_WITH_OBJC or DJINNI_WITH_JNI or DJINNI_WITH_PYTHON or DJINNI_WITH_CPPCLI must be enabled.")
if(NOT (DJINNI_WITH_OBJC OR DJINNI_WITH_JNI))
message(FATAL_ERROR "At least one of DJINNI_WITH_OBJC or DJINNI_WITH_JNI must be enabled.")
endif()

option(DJINNI_BUILD_TESTING "Build tests" ON)
Expand Down
Loading