-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FindRust upgrades, integrate c/bindgen w. build.rs
`FindRust.cmake` no longer attempts to guess at the Rust platform target triple by evaluating the OS, Architecture, and pointer-size of the target except on Windows (for cross-compiling to x86) and on macOS (for universal binary builds). Instead, it uses Rust's host target triple obtained with the command `rustc -vV`. If you want to cross-compile, you can set the `RUST_COMPILER_TARGET` variable. `FindRust.cmake` now sets the Rust build type to Release for CMake's MinSizeRel and RelWithDebInfo builds, using the `-g` RUSTFLAG for the latter so that debug symbols are provided. Renamed a bunch of things to make it more intuitive. Namely the demo library is now called "demo" instead of "CMakeRust", and the C and Rust sources are now in separate directories such that the Rust stuff follows the traditional Rust project layout. Demo now integrates the bindgen and cbindgen processes into a `build.rs` file that automatically runs at build time and does not depend on having bindgen or cbindgen pre-installed. Generating C bindings with cbindgen works everywhere, but generating the Rust bindings from the C code appears to require libclang and may not be present on all systems - so we only run it when MAINTAINER_MODE is ON. Demo now installs the Rust-built static library. The demo app is linked with the static libs so we don't have to make a temporary install on Windows so the app can load the DLL. Similarly, we link with the static libs for Rust unit test executable, so we don't need a temporary install to run the test executable. Also add clang-format spec for convenience in maintaining the C bits. For Github Actions: switched to using CMake manually.
- Loading branch information
Showing
35 changed files
with
884 additions
and
275 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
--- | ||
Language: Cpp | ||
AccessModifierOffset: -2 | ||
AlignAfterOpenBracket: Align | ||
AlignConsecutiveMacros: false | ||
AlignConsecutiveAssignments: true | ||
AlignConsecutiveBitFields: false | ||
AlignConsecutiveDeclarations: false | ||
AlignEscapedNewlines: Left | ||
AlignOperands: Align | ||
AlignTrailingComments: true | ||
AllowAllArgumentsOnNextLine: true | ||
AllowAllConstructorInitializersOnNextLine: true | ||
AllowAllParametersOfDeclarationOnNextLine: true | ||
AllowShortEnumsOnASingleLine: true | ||
AllowShortBlocksOnASingleLine: Never | ||
AllowShortCaseLabelsOnASingleLine: false | ||
AllowShortFunctionsOnASingleLine: Empty | ||
AllowShortLambdasOnASingleLine: All | ||
AllowShortIfStatementsOnASingleLine: WithoutElse | ||
AllowShortLoopsOnASingleLine: true | ||
AlwaysBreakAfterDefinitionReturnType: None | ||
AlwaysBreakAfterReturnType: None | ||
AlwaysBreakBeforeMultilineStrings: false | ||
AlwaysBreakTemplateDeclarations: MultiLine | ||
BinPackArguments: true | ||
BinPackParameters: true | ||
BraceWrapping: | ||
AfterCaseLabel: false | ||
AfterClass: true | ||
AfterControlStatement: Never | ||
AfterEnum: false | ||
AfterFunction: true | ||
AfterNamespace: true | ||
AfterObjCDeclaration: false | ||
AfterStruct: false | ||
AfterUnion: false | ||
AfterExternBlock: false | ||
BeforeCatch: false | ||
BeforeElse: false | ||
BeforeLambdaBody: false | ||
BeforeWhile: false | ||
IndentBraces: false | ||
SplitEmptyFunction: true | ||
SplitEmptyRecord: true | ||
SplitEmptyNamespace: true | ||
BreakBeforeBinaryOperators: None | ||
BreakBeforeBraces: Linux | ||
BreakBeforeInheritanceComma: false | ||
BreakInheritanceList: BeforeColon | ||
BreakBeforeTernaryOperators: true | ||
BreakConstructorInitializersBeforeComma: false | ||
BreakConstructorInitializers: BeforeColon | ||
BreakAfterJavaFieldAnnotations: false | ||
BreakStringLiterals: true | ||
ColumnLimit: 0 | ||
CommentPragmas: '^ IWYU pragma:' | ||
CompactNamespaces: false | ||
ConstructorInitializerAllOnOneLineOrOnePerLine: false | ||
ConstructorInitializerIndentWidth: 4 | ||
ContinuationIndentWidth: 4 | ||
Cpp11BracedListStyle: true | ||
DeriveLineEnding: true | ||
DerivePointerAlignment: true | ||
DisableFormat: false | ||
ExperimentalAutoDetectBinPacking: false | ||
FixNamespaceComments: true | ||
ForEachMacros: | ||
- foreach | ||
- Q_FOREACH | ||
- BOOST_FOREACH | ||
IncludeBlocks: Preserve | ||
IncludeCategories: | ||
- Regex: '^"(llvm|llvm-c|clang|clang-c)/' | ||
Priority: 2 | ||
SortPriority: 0 | ||
- Regex: '^(<|"(gtest|gmock|isl|json)/)' | ||
Priority: 3 | ||
SortPriority: 0 | ||
- Regex: '.*' | ||
Priority: 1 | ||
SortPriority: 0 | ||
IncludeIsMainRegex: '(Test)?$' | ||
IncludeIsMainSourceRegex: '' | ||
IndentCaseLabels: true | ||
IndentCaseBlocks: false | ||
IndentGotoLabels: true | ||
IndentPPDirectives: None | ||
IndentExternBlock: AfterExternBlock | ||
IndentWidth: 4 | ||
IndentWrappedFunctionNames: false | ||
InsertTrailingCommas: None | ||
JavaScriptQuotes: Leave | ||
JavaScriptWrapImports: true | ||
KeepEmptyLinesAtTheStartOfBlocks: true | ||
MacroBlockBegin: '' | ||
MacroBlockEnd: '' | ||
MaxEmptyLinesToKeep: 1 | ||
NamespaceIndentation: None | ||
ObjCBinPackProtocolList: Auto | ||
ObjCBlockIndentWidth: 2 | ||
ObjCBreakBeforeNestedBlockParam: true | ||
ObjCSpaceAfterProperty: false | ||
ObjCSpaceBeforeProtocolList: true | ||
PenaltyBreakAssignment: 2 | ||
PenaltyBreakBeforeFirstCallParameter: 19 | ||
PenaltyBreakComment: 300 | ||
PenaltyBreakFirstLessLess: 120 | ||
PenaltyBreakString: 1000 | ||
PenaltyBreakTemplateDeclaration: 10 | ||
PenaltyExcessCharacter: 1000000 | ||
PenaltyReturnTypeOnItsOwnLine: 60 | ||
PointerAlignment: Right | ||
ReflowComments: true | ||
SortIncludes: false | ||
SortUsingDeclarations: true | ||
SpaceAfterCStyleCast: false | ||
SpaceAfterLogicalNot: false | ||
SpaceAfterTemplateKeyword: true | ||
SpaceBeforeAssignmentOperators: true | ||
SpaceBeforeCpp11BracedList: false | ||
SpaceBeforeCtorInitializerColon: true | ||
SpaceBeforeInheritanceColon: true | ||
SpaceBeforeParens: ControlStatements | ||
SpaceBeforeRangeBasedForLoopColon: true | ||
SpaceInEmptyBlock: false | ||
SpaceInEmptyParentheses: false | ||
SpacesBeforeTrailingComments: 1 | ||
SpacesInAngles: false | ||
SpacesInConditionalStatement: false | ||
SpacesInContainerLiterals: true | ||
SpacesInCStyleCastParentheses: false | ||
SpacesInParentheses: false | ||
SpacesInSquareBrackets: false | ||
SpaceBeforeSquareBrackets: false | ||
Standard: Latest | ||
StatementMacros: | ||
- Q_UNUSED | ||
- QT_REQUIRE_VERSION | ||
TabWidth: 8 | ||
UseCRLF: false | ||
UseTab: Never | ||
WhitespaceSensitiveMacros: | ||
- STRINGIZE | ||
- PP_STRINGIZE | ||
- BOOST_PP_STRINGIZE | ||
... | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,14 +4,14 @@ name: Build Test | |
# events but only for the main branch | ||
on: | ||
push: | ||
branches: [ main ] | ||
branches: [main] | ||
pull_request: | ||
branches: [ main ] | ||
branches: [main] | ||
|
||
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | ||
jobs: | ||
build_and_test: | ||
name: '${{ matrix.os }}: build and test' | ||
name: "${{ matrix.os }}: build and test" | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
fail-fast: false | ||
|
@@ -29,24 +29,23 @@ jobs: | |
- name: get-cmake | ||
uses: lukka/get-cmake@latest | ||
|
||
- name: run-cmake | ||
uses: lukka/[email protected] | ||
with: | ||
cmakeGenerator: 'Ninja' | ||
cmakeListsOrSettingsJson: 'CMakeListsTxtBasic' | ||
buildDirectory: '${{ runner.workspace }}/build/ninja/' | ||
- name: Build project | ||
working-directory: "${{ runner.workspace }}/" | ||
run: | | ||
cmake -B ./build -S ./cmake-rust-demo | ||
cmake --build ./build | ||
- name: Run tests | ||
working-directory: '${{ runner.workspace }}/build/ninja/' | ||
working-directory: "${{ runner.workspace }}/build/" | ||
run: | | ||
ctest -VV | ||
- name: Run the app | ||
run: | | ||
${{ runner.workspace }}/build/ninja/app/app | ||
${{ runner.workspace }}/build/app/app | ||
build_and_test_windows: | ||
name: 'windows-latest: build and test' | ||
name: "windows-latest: build and test" | ||
runs-on: windows-latest | ||
|
||
steps: | ||
|
@@ -60,18 +59,17 @@ jobs: | |
- name: get-cmake | ||
uses: lukka/get-cmake@latest | ||
|
||
- name: run-cmake | ||
uses: lukka/[email protected] | ||
with: | ||
cmakeGenerator: 'VS16Win64' | ||
cmakeListsOrSettingsJson: 'CMakeListsTxtBasic' | ||
buildDirectory: '${{ runner.workspace }}/build/vs2019/' | ||
- name: Build project | ||
working-directory: "${{ runner.workspace }}/" | ||
run: | | ||
cmake -B ./build -S ./cmake-rust-demo -A x64 | ||
cmake --build ./build | ||
- name: Run tests | ||
working-directory: '${{ runner.workspace }}/build/vs2019/' | ||
working-directory: "${{ runner.workspace }}/build/" | ||
run: | | ||
ctest -VV -C Debug | ||
- name: Run the app | ||
run: | | ||
${{ runner.workspace }}\\build\\vs2019\\app\\Debug\\app.exe | ||
${{ runner.workspace }}\\build\\app\\Debug\\app.exe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -88,3 +88,4 @@ build/* | |
|
||
# Rust / Cargo files | ||
Cargo.lock | ||
target/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[workspace] | ||
|
||
members = ["lib/rust", "common/gen_uuid"] | ||
|
||
[profile.dev.package."*"] | ||
opt-level = 2 |
Oops, something went wrong.