-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(cedar_ffi): Windows bundling workarounds (#104)
Workaround for: dart-lang/sdk#55207
- Loading branch information
Showing
12 changed files
with
359 additions
and
136 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
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,28 @@ | ||
name: CedarFfiBundled | ||
description: C bindings to the Cedar policy engine (bundled native asset) | ||
ffi-native: | ||
language: c | ||
headers: | ||
entry-points: | ||
- "src/include/bindings.h" | ||
compiler-opts: | ||
# Suppress nullability warnings on macOS | ||
- "-Wno-nullability-completeness" | ||
# Ignore warnings about availability macro | ||
- "-Wno-availability" | ||
output: | ||
bindings: "lib/src/ffi/cedar_bindings.bundled.ffi.dart" | ||
comments: | ||
style: any | ||
length: full | ||
exclude-all-by-default: true | ||
import: | ||
symbol-files: | ||
- 'package:cedar_ffi/src/ffi/symbols.yaml' | ||
functions: | ||
include: | ||
- "cedar_.*" | ||
leaf: | ||
# All C APIs are leaf functions (e.g. they do not call into Dart) | ||
include: | ||
- ".*" |
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,31 @@ | ||
name: CedarFfiLoaded | ||
description: C bindings to the Cedar policy engine (process native asset) | ||
ffi-native: | ||
language: c | ||
headers: | ||
entry-points: | ||
- "src/include/bindings.h" | ||
compiler-opts: | ||
# Suppress nullability warnings on macOS | ||
- "-Wno-nullability-completeness" | ||
# Ignore warnings about availability macro | ||
- "-Wno-availability" | ||
output: | ||
bindings: "lib/src/ffi/cedar_bindings.loaded.ffi.dart" | ||
comments: | ||
style: any | ||
length: full | ||
exclude-all-by-default: true | ||
import: | ||
symbol-files: | ||
- 'package:cedar_ffi/src/ffi/symbols.yaml' | ||
functions: | ||
include: | ||
- "cedar_.*" | ||
expose-typedefs: | ||
include: | ||
- "cedar_.*" | ||
leaf: | ||
# All C APIs are leaf functions (e.g. they do not call into Dart) | ||
include: | ||
- ".*" |
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,27 @@ | ||
name: CedarFfiSymbols | ||
description: C bindings to the Cedar policy engine (symbols-only) | ||
ffi-native: | ||
language: c | ||
headers: | ||
entry-points: | ||
- "src/include/bindings.h" | ||
compiler-opts: | ||
# Suppress nullability warnings on macOS | ||
- "-Wno-nullability-completeness" | ||
# Ignore warnings about availability macro | ||
- "-Wno-availability" | ||
output: | ||
bindings: "lib/src/ffi/cedar_bindings.symbols.ffi.dart" | ||
symbol-file: | ||
output: 'package:cedar_ffi/src/ffi/symbols.yaml' | ||
import-path: 'package:cedar_ffi/src/ffi/cedar_bindings.symbols.ffi.dart' | ||
comments: | ||
style: any | ||
length: full | ||
exclude-all-by-default: true | ||
structs: | ||
include: | ||
- "CCedar.*" | ||
- "CedarStore" | ||
- "CInitResult" | ||
- "CAuthorizationDecision" |
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
55 changes: 55 additions & 0 deletions
55
packages/cedar_ffi/lib/src/ffi/cedar_bindings.bundled.ffi.dart
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,47 @@ | ||
// ignore_for_file: non_constant_identifier_names | ||
|
||
import 'dart:ffi'; | ||
|
||
import 'package:cedar_ffi/src/ffi/cedar_bindings.bundled.ffi.dart' as bundled; | ||
import 'package:cedar_ffi/src/ffi/cedar_bindings.loaded.ffi.dart' as loaded; | ||
|
||
export 'package:cedar_ffi/src/ffi/cedar_bindings.symbols.ffi.dart'; | ||
|
||
final bindings = CedarBindings._(); | ||
|
||
enum _LinkMode { bundled, loaded } | ||
|
||
final class CedarBindings { | ||
CedarBindings._() { | ||
try { | ||
Native.addressOf<NativeFunction<loaded.NativeCedar_init>>( | ||
loaded.cedar_init); | ||
_linkMode = _LinkMode.loaded; | ||
} on Object { | ||
Native.addressOf<NativeFunction<loaded.NativeCedar_init>>( | ||
bundled.cedar_init); | ||
_linkMode = _LinkMode.bundled; | ||
} | ||
} | ||
|
||
late final _LinkMode _linkMode; | ||
|
||
late final cedar_init = | ||
_linkMode == _LinkMode.loaded ? loaded.cedar_init : bundled.cedar_init; | ||
|
||
late final cedar_deinit = _linkMode == _LinkMode.loaded | ||
? loaded.cedar_deinit | ||
: bundled.cedar_deinit; | ||
|
||
late final cedar_is_authorized = _linkMode == _LinkMode.loaded | ||
? loaded.cedar_is_authorized | ||
: bundled.cedar_is_authorized; | ||
|
||
late final cedar_link_policy_template = _linkMode == _LinkMode.loaded | ||
? loaded.cedar_link_policy_template | ||
: bundled.cedar_link_policy_template; | ||
|
||
late final cedar_parse_policy_set = _linkMode == _LinkMode.loaded | ||
? loaded.cedar_parse_policy_set | ||
: bundled.cedar_parse_policy_set; | ||
} |
Oops, something went wrong.