Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
iamsergio committed Apr 9, 2024
0 parents commit bbb36b4
Show file tree
Hide file tree
Showing 230 changed files with 44,327 additions and 0 deletions.
66 changes: 66 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
---
BasedOnStyle: WebKit
Language: Cpp
Standard: Cpp11

IndentWidth: 4
SpacesBeforeTrailingComments: 1
UseTab: Never
TabWidth: 4
ContinuationIndentWidth: 4
MaxEmptyLinesToKeep: 3
BreakBeforeBinaryOperators: NonAssignment
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: BeforeColon
BreakConstructorInitializersBeforeComma: true

BreakBeforeBraces: Custom
BraceWrapping:
AfterClass: true
AfterControlStatement: false
AfterEnum: false
AfterFunction: true
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: true
AfterUnion: false
BeforeCatch: false
BeforeElse: false
IndentBraces: false

AccessModifierOffset: -4
ExperimentalAutoDetectBinPacking: false
IndentFunctionDeclarationAfterType: false
ConstructorInitializerIndentWidth: 4
AlignEscapedNewlinesLeft: false
AlignTrailingComments: false
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AllowShortFunctionsOnASingleLine: false
AllowShortEnumsOnASingleLine: false # requires clang-format 11
AlignAfterOpenBracket: true
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: true
BinPackParameters: true
ColumnLimit: 100
Cpp11BracedListStyle: false
DerivePointerBinding: false
IndentCaseLabels: false
NamespaceIndentation: None
ObjCSpaceBeforeProtocolList: true
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 60
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
PointerBindsToType: false
SpaceAfterTemplateKeyword: false
SpaceAfterControlStatementKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceInEmptyParentheses: false
SpacesInAngles: false
SpacesInCStyleCastParentheses: true
SpacesInParentheses: false
...
49 changes: 49 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#
# This file is part of Dartagnan.
#
# SPDX-FileCopyrightText: 2023 Klarälvdalens Datakonsult AB, a KDAB Group company <[email protected]>
# Author: Sérgio Martins <[email protected]>
#
# SPDX-License-Identifier: MIT

# Instructions:
# docker build -t dartagnan .
# docker run -it -v /data/sources/dart/dartagnan/:/dartagnan/ -u 1000:1000 dartagnan
# cd /dartagnan/ && cmake --preset=dev -DCMAKE_INSTALL_PREFIX=/dartagnan/build-dev/installed/
# cd build-dev && ninja && ninja install
# cd .. && dart pub get && dart run_tests.dart

# To publish in docker hub:
# docker build -t dartagnan .
# docker run -it dartagnan # and exit
# docker ps # to check sha
# docker export -o mycontainer.tar <container_sha>
# docker import mycontainer.tar
# docker images # to check sha
# docker tag <image_sha> iamsergio/ci-dartagnan
# docker push iamsergio/ci-dartagnan

FROM ubuntu:23.04
MAINTAINER Sergio Martins ([email protected])

ENV TZ=Europe/Berlin
ENV LC_CTYPE=C.UTF-8
ENV PATH=$PATH:/home/ubuntu/flutter/bin/:/home/ubuntu/flutter/bin/cache/dart-sdk/bin/:/dartagnan/build-dev/installed/bin/
ENV LD_LIBRARY_PATH=/dartagnan/build-dev/tests/generated/TestBindings/
ENV DARTAGNAN_CLANG_FORMAT=clang-format-15

RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

RUN apt update -qq && apt install -y vim build-essential software-properties-common lld git cmake ninja-build python3 \
python3-dev clang llvm libclang-15-dev libxslt-dev mesa-common-dev libglu1-mesa-dev libglib2.0-dev libfontconfig \
libxkbcommon-dev mesa-utils libgl1-mesa-dev libglu1-mesa-dev nlohmann-json3-dev clang-format-15 qt6-base-dev wget curl \
file unzip zip which xz-utils

RUN ln -sf /usr/lib/x86_64-linux-gnu/libasan.so.8 /usr/lib/libasan.so
RUN ln -sf /usr/bin/qmake6 /usr/bin/qmake

WORKDIR /home/ubuntu
USER ubuntu
RUN git config --global advice.detachedHead false
RUN git clone https://github.com/flutter/flutter.git -b 3.19.5
RUN flutter --version
37 changes: 37 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"name": "dartagnan",
"build": {
"dockerfile": "Dockerfile"
},
"runArgs": [
"--cap-add=SYS_PTRACE",
"--security-opt",
"seccomp=unconfined"
],
"workspaceMount": "source=${localWorkspaceFolder}/,target=/dartagnan/,type=bind",
"workspaceFolder": "/dartagnan",
"customizations": {
"vscode": {
"extensions": [
"vadimcn.vscode-lldb",
"llvm-vs-code-extensions.vscode-clangd",
"Dart-Code.dart-code",
"Dart-Code.flutter",
"mhutchie.git-graph",
"Gruntfuggly.todo-tree",
"ms-vscode.cmake-tools"
],
"settings": {
"terminal.integrated.shell.linux": "/bin/bash",
"workbench.colorTheme": "Visual Studio Light"
}
}
},
"mounts": [
"source=${localEnv:HOME}/Qt/6.3.1/gcc_64/,target=/Qt/,type=bind",
"source=/data/installation/flutter/flutter-3.13/,target=/flutter/,type=bind",
"source=/data/sources/kddockwidgets/,target=/kddockwidgets/,type=bind",
"source=${localEnv:HOME}/.pub-cache/,target=/home/user/.pub-cache/,type=bind"
],
"remoteUser": "ubuntu"
}
16 changes: 16 additions & 0 deletions .github/actions/dartagnan/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#
# This file is part of Dartagnan.
#
# SPDX-FileCopyrightText: 2024 Klarälvdalens Datakonsult AB, a KDAB Group company <[email protected]>
# Author: Sérgio Martins <[email protected]>
#
# SPDX-License-Identifier: MIT

# Dockerfile for dartagnan GitHub Action
# Based over .devcontainer/Dockerfile

FROM iamsergio/ci-dartagnan
MAINTAINER Sergio Martins ([email protected])

COPY entrypoint.sh /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
9 changes: 9 additions & 0 deletions .github/actions/dartagnan/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# SPDX-FileCopyrightText: 2024 Klarälvdalens Datakonsult AB, a KDAB Group company <[email protected]>
#
# SPDX-License-Identifier: MIT

name: 'build-dartagnan'
description: 'Builds Dartagnan'
runs:
using: 'docker'
image: 'Dockerfile'
16 changes: 16 additions & 0 deletions .github/actions/dartagnan/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/sh -l

# SPDX-FileCopyrightText: 2024 Klarälvdalens Datakonsult AB, a KDAB Group company <[email protected]>
#
# SPDX-License-Identifier: MIT
cd /github/workspace/ || exit 1

export TZ=Europe/Berlin
export LC_CTYPE=C.UTF-8
export PATH=$PATH:/home/ubuntu/flutter/bin/:/home/ubuntu/flutter/bin/cache/dart-sdk/bin/:/dartagnan/build-dev/installed/bin/
export LD_LIBRARY_PATH=/dartagnan/build-dev/tests/generated/TestBindings/
export DARTAGNAN_CLANG_FORMAT=clang-format-15

cmake --preset=dev -DCMAKE_INSTALL_PREFIX=/dartagnan/build-dev/installed/ && \
cd build-dev && ninja && ninja install && ctest -j1 --output-on-failure

25 changes: 25 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# SPDX-FileCopyrightText: 2024 Klarälvdalens Datakonsult AB, a KDAB Group company <[email protected]>
#
# SPDX-License-Identifier: MIT

name: Build

on:
schedule:
- cron: '0 3 * * *'
workflow_dispatch:
pull_request:
push:
branches: [main]

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4
with:
submodules: true

- name: Build and Test
uses: ./.github/actions/dartagnan
25 changes: 25 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
*.log
.ninja_deps
.ninja_log
build.ninja
.vscode/launch.json
*depends
qrc_dartagnan.cpp
libdartagnan.a
CMakeFiles/
cmake_install.cmake
CMakeCache.txt
build/
.packages
libTestTarget.so
libMyBindings.so
.dart_tool
/build-dev
/build-release
CMakeLists.txt.user
/a
*.exe
compile_commands.json
.cache
main.aot
CTestCostData.txt
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "3rdparty/shiboken"]
path = 3rdparty/shiboken
url = https://github.com/KDABLabs/pyside2-setup.git
1 change: 1 addition & 0 deletions 3rdparty/shiboken
Submodule shiboken added at b6de22
80 changes: 80 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# This file is part of Dartagnan.
#
# SPDX-FileCopyrightText: 2023 Klarälvdalens Datakonsult AB, a KDAB Group company <[email protected]>
# SPDX-License-Identifier: MIT

cmake_minimum_required(VERSION 3.9)
project(dartagnan)


set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)

add_subdirectory(3rdparty/shiboken)

find_package(Qt6Core 6.1 REQUIRED)

set(dartagnan_SRCS
src/dartagnan.cpp
src/dart_ffi_typedefs.cpp

src/Logging.cpp

# Generators
src/generator_base.cpp
src/generator_dart.cpp
src/generator_cppwrapper_impl.cpp
src/generator_cppwrapper_header.cpp

# Helpers to convert types between languages
src/type_conversions/to_dart.cpp
src/type_conversions/to_C.cpp
src/type_conversions/to_CppWrapper.cpp

# The actual printers
src/printers/printers.cpp
src/printers/ExternC_HeaderPrinter.cpp
src/printers/ExternC_ImplPrinter.cpp
src/printers/Dart_printer.cpp
src/printers/Cpp_ImplPrinter.cpp
src/printers/Cpp_HeaderPrinter.cpp
)

qt_add_resources(DARTAGNAN_RESOURCES dartagnan.qrc)

add_library(dartagnanlib STATIC ${dartagnan_SRCS} ${DARTAGNAN_RESOURCES})

target_include_directories(dartagnanlib
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/src/type_conversions/
${CMAKE_CURRENT_SOURCE_DIR}/src/printers
${CMAKE_CURRENT_SOURCE_DIR}/src
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/shiboken/sources/shiboken6/generator/
3rdparty/shiboken/sources/shiboken6/ApiExtractor/ )

target_link_libraries(dartagnanlib Qt${QT_MAJOR_VERSION}::Core)

option(DARTAGNAN_DEVELOPER_BUILD "Enables tests" OFF)

if (DARTAGNAN_DEVELOPER_BUILD)
option(RUN_DART_PUB_GET "Runs \"dart pub get\" for convenience. Required for running run_tests.dart" ON)
enable_testing()
add_subdirectory(tests)
add_test(NAME tests COMMAND dart run_tests.dart ${CMAKE_BINARY_DIR} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
if (RUN_DART_PUB_GET)
add_custom_command(
TARGET dartagnanlib
POST_BUILD
COMMAND dart
ARGS pub get
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
endif()
endif()

add_executable(dartagnan src/main.cpp)
target_link_libraries(dartagnan Qt6::Core)
install(TARGETS dartagnan
DESTINATION "${CMAKE_INSTALL_PREFIX}/bin")
26 changes: 26 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"version": 2,
"configurePresets": [
{
"name": "dev",
"displayName": "dev",
"generator": "Ninja",
"binaryDir": "${sourceDir}/build-dev",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON",
"DARTAGNAN_DEVELOPER_BUILD": "ON"
}
},
{
"name": "release",
"displayName": "release",
"generator": "Ninja",
"binaryDir": "${sourceDir}/build-release",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON"
}
}
]
}
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 Sergio Martins

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Loading

0 comments on commit bbb36b4

Please sign in to comment.