mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-02 12:05:50 +00:00
Compare commits
397 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
01834de25e | ||
|
|
6f9ea7c23c | ||
|
|
de9791e0a9 | ||
|
|
3e778aca4d | ||
|
|
01f4138618 | ||
|
|
b90cc35a10 | ||
|
|
79d6abb42e | ||
|
|
d1e4daa178 | ||
|
|
4a34cd70dc | ||
|
|
6a9cd4411f | ||
|
|
f7a75173f1 | ||
|
|
a56f9ec50e | ||
|
|
4c71f87619 | ||
|
|
6af83a7d05 | ||
|
|
535ead8d8c | ||
|
|
85aee1f5c3 | ||
|
|
f3a3f45159 | ||
|
|
02d7859f8b | ||
|
|
5785784c8a | ||
|
|
0fb5519585 | ||
|
|
f838017860 | ||
|
|
08ebd202e2 | ||
|
|
a6f4194489 | ||
|
|
7fb785fd89 | ||
|
|
ca71fdfb9a | ||
|
|
a105c26eca | ||
|
|
5b7a02d037 | ||
|
|
f5121615d9 | ||
|
|
34c821f4ad | ||
|
|
802a3a056a | ||
|
|
ee848a02e1 | ||
|
|
ef76b5ece4 | ||
|
|
1703662285 | ||
|
|
991b39edbe | ||
|
|
81799203f1 | ||
|
|
62e4d2e5b2 | ||
|
|
40758674b1 | ||
|
|
4e75867bd2 | ||
|
|
b17d59b18c | ||
|
|
b23493a7d2 | ||
|
|
b50b6be60a | ||
|
|
7bf83f5ea0 | ||
|
|
ca6381bcc8 | ||
|
|
3b8644d32c | ||
|
|
641fbe4658 | ||
|
|
5638a6a900 | ||
|
|
c2668fc0e2 | ||
|
|
b5802b57f2 | ||
|
|
06f2a3dce9 | ||
|
|
75af533e95 | ||
|
|
c95cf661af | ||
|
|
920f3827a0 | ||
|
|
81724e5b20 | ||
|
|
4d6a7aa8b7 | ||
|
|
e61b00359b | ||
|
|
74b5195089 | ||
|
|
07d9485146 | ||
|
|
82da3da3f6 | ||
|
|
a809a2d3f7 | ||
|
|
af9ceabeef | ||
|
|
3b2eb77595 | ||
|
|
6420fa5c88 | ||
|
|
01589630ba | ||
|
|
e0d68bdda2 | ||
|
|
e43a80c322 | ||
|
|
449d5649d6 | ||
|
|
96d438df47 | ||
|
|
4e396d47bc | ||
|
|
b47ba1d5ff | ||
|
|
a078130c87 | ||
|
|
9ed76559df | ||
|
|
9927747d4e | ||
|
|
52d1b77941 | ||
|
|
40aa964057 | ||
|
|
e1a2f688e0 | ||
|
|
c0797b22ae | ||
|
|
97ee210826 | ||
|
|
3be296ec8a | ||
|
|
acf39ff056 | ||
|
|
0e79e56427 | ||
|
|
aadc4cb8be | ||
|
|
b5ebd3fd78 | ||
|
|
11394575bc | ||
|
|
5b7b36e8be | ||
|
|
c0230d839b | ||
|
|
a8d49f2972 | ||
|
|
416c6020eb | ||
|
|
6d95867a8f | ||
|
|
2eaf790638 | ||
|
|
3b2ced0131 | ||
|
|
00af4e23b3 | ||
|
|
7e00b754f0 | ||
|
|
cf89d1e756 | ||
|
|
ad6054c600 | ||
|
|
c3a01c7228 | ||
|
|
533f75d91b | ||
|
|
fcab80f1bb | ||
|
|
5d2d0b92b1 | ||
|
|
ae6662374d | ||
|
|
7b6c9f4a3c | ||
|
|
5a42b2c76c | ||
|
|
8f625561d0 | ||
|
|
9d2c04d629 | ||
|
|
e000458bb1 | ||
|
|
60975d6f7e | ||
|
|
1cba8b2b49 | ||
|
|
eead6c6219 | ||
|
|
bb9b9dad5f | ||
|
|
ade9e19be0 | ||
|
|
eb1abb51ea | ||
|
|
1fa6091000 | ||
|
|
634c2ee7e3 | ||
|
|
6f895f54c2 | ||
|
|
41d6903294 | ||
|
|
7b038e3277 | ||
|
|
74756e5d1b | ||
|
|
879622fc57 | ||
|
|
83e7a98f69 | ||
|
|
f20b0a45b3 | ||
|
|
207708efef | ||
|
|
225578a8b3 | ||
|
|
459e8acc37 | ||
|
|
8aa8b9139e | ||
|
|
001adf782d | ||
|
|
dbc58ab77c | ||
|
|
2facfeec7e | ||
|
|
4de2814c7b | ||
|
|
37b1acdaff | ||
|
|
a22434e2a1 | ||
|
|
214cc94681 | ||
|
|
a4ff275d9b | ||
|
|
15f32c6907 | ||
|
|
051afd8825 | ||
|
|
728c033ad6 | ||
|
|
4c514483d8 | ||
|
|
c2d9c20803 | ||
|
|
e34ae4c6b6 | ||
|
|
e54536127c | ||
|
|
49d9f941c0 | ||
|
|
cefc21c1f9 | ||
|
|
3e64fa7246 | ||
|
|
b15f3c57ea | ||
|
|
ff802c6802 | ||
|
|
b401957d5f | ||
|
|
8c8151f8f9 | ||
|
|
ebb7c203d3 | ||
|
|
203241ed32 | ||
|
|
ac485609c4 | ||
|
|
de5b85aa66 | ||
|
|
de3df2d88b | ||
|
|
043a24f2e4 | ||
|
|
5a48b0d7d6 | ||
|
|
ce307556fb | ||
|
|
cb616e27cb | ||
|
|
a54ca1e759 | ||
|
|
5b3fadcc16 | ||
|
|
872a497464 | ||
|
|
e301702964 | ||
|
|
f7b734438d | ||
|
|
5792623df4 | ||
|
|
0edb275285 | ||
|
|
acc6a20d39 | ||
|
|
04cd037ba2 | ||
|
|
e1c5db988a | ||
|
|
b80142b901 | ||
|
|
54418f371b | ||
|
|
c92e78a9f8 | ||
|
|
d243b904cc | ||
|
|
374f8fb5fb | ||
|
|
dadbff5714 | ||
|
|
76ddae006f | ||
|
|
cfe157ec56 | ||
|
|
413115858c | ||
|
|
88046190ee | ||
|
|
72aa85a759 | ||
|
|
bfceebb7fb | ||
|
|
bc44fad352 | ||
|
|
4fca4dc60c | ||
|
|
036032373b | ||
|
|
89dfb43f3b | ||
|
|
c49aff4b6f | ||
|
|
56e60223c3 | ||
|
|
89b1f5aa1b | ||
|
|
b901598233 | ||
|
|
8cdc6a2885 | ||
|
|
a67e35aff9 | ||
|
|
f124e41ae6 | ||
|
|
4c954181cd | ||
|
|
7f7547737e | ||
|
|
a79d61ea85 | ||
|
|
d465b39c3e | ||
|
|
c5a609dc20 | ||
|
|
5634dc3d0d | ||
|
|
37e37b8cad | ||
|
|
8fd4534fbe | ||
|
|
d5427da52f | ||
|
|
06c5c7ed0b | ||
|
|
b190ce11b0 | ||
|
|
bf5d23230a | ||
|
|
ce382d6dd3 | ||
|
|
41d9add7ef | ||
|
|
6a87427540 | ||
|
|
694add668b | ||
|
|
7edf8c9084 | ||
|
|
b86387442e | ||
|
|
e2eb5ee670 | ||
|
|
994502b6dd | ||
|
|
fa41e83679 | ||
|
|
799cc8f7b9 | ||
|
|
b7eb441470 | ||
|
|
8d01c5859c | ||
|
|
237e8b71fe | ||
|
|
eeb8fd60d5 | ||
|
|
fef2ffc4d0 | ||
|
|
8367664f15 | ||
|
|
d6f06c33f7 | ||
|
|
627e8bf364 | ||
|
|
883c42b7db | ||
|
|
7aae0af305 | ||
|
|
b057aa917f | ||
|
|
f1b26ff7fb | ||
|
|
9610a666b1 | ||
|
|
1e0f75a647 | ||
|
|
82b75407a3 | ||
|
|
f7c511957f | ||
|
|
a66de58af9 | ||
|
|
a3508f36d5 | ||
|
|
137fec7164 | ||
|
|
214125e417 | ||
|
|
44a7dc9995 | ||
|
|
3cc2daa78f | ||
|
|
fa1174aa7b | ||
|
|
83d4e2a100 | ||
|
|
8a09f3fb0b | ||
|
|
9dbe819efd | ||
|
|
67c4149588 | ||
|
|
8b8c7dbdfc | ||
|
|
2ee20a5f3d | ||
|
|
4be605604e | ||
|
|
fc5d86f1e7 | ||
|
|
9dce287adb | ||
|
|
7798be3bb6 | ||
|
|
966362e074 | ||
|
|
a89c279ed6 | ||
|
|
a212b3c036 | ||
|
|
9230f600d7 | ||
|
|
c793621567 | ||
|
|
ee2ced236d | ||
|
|
468c00a3fe | ||
|
|
47c757f714 | ||
|
|
9a5ff89003 | ||
|
|
950444a343 | ||
|
|
30d76198c7 | ||
|
|
cce3a66f0d | ||
|
|
8d1cc6ac7d | ||
|
|
5b207639a1 | ||
|
|
359e0f9d66 | ||
|
|
ebbed05137 | ||
|
|
aa395e5a59 | ||
|
|
32328075d8 | ||
|
|
97e89c5acd | ||
|
|
5f6672be44 | ||
|
|
28e858c855 | ||
|
|
987bebe678 | ||
|
|
ec0129369c | ||
|
|
50dd385b30 | ||
|
|
da702cfd8f | ||
|
|
6e2791640e | ||
|
|
52fce5e532 | ||
|
|
b7f13cd8e8 | ||
|
|
e42985e5aa | ||
|
|
0a80646371 | ||
|
|
b9eea76a86 | ||
|
|
1b90300150 | ||
|
|
83a43fc797 | ||
|
|
5f01376027 | ||
|
|
9a1913a87a | ||
|
|
b4647beb8f | ||
|
|
d6060977ad | ||
|
|
987aa5b5ee | ||
|
|
42acdb63c3 | ||
|
|
0cc1aeb8ca | ||
|
|
ba6c671705 | ||
|
|
d2f33fc454 | ||
|
|
0d1b72cbc2 | ||
|
|
9fce2fbf2a | ||
|
|
a18ea40d6a | ||
|
|
090caa2809 | ||
|
|
49e1ea3335 | ||
|
|
11a1988705 | ||
|
|
967df08b1d | ||
|
|
9aa08a429e | ||
|
|
9e8c758f54 | ||
|
|
74a25536be | ||
|
|
12917af8a2 | ||
|
|
1ea2472f7a | ||
|
|
0fe13cb28c | ||
|
|
385dddc66a | ||
|
|
750dde7669 | ||
|
|
9917a168cd | ||
|
|
76d3cca19c | ||
|
|
c86e6d0e30 | ||
|
|
d34dc32c20 | ||
|
|
234d86c92a | ||
|
|
746c73b910 | ||
|
|
0bbfd4b2e3 | ||
|
|
7165219535 | ||
|
|
a45f564cf1 | ||
|
|
9d45a64036 | ||
|
|
ccfb4c20bf | ||
|
|
7bcd857b87 | ||
|
|
23c8ab34c1 | ||
|
|
70002dc5ca | ||
|
|
6e0e79f24f | ||
|
|
b856368d75 | ||
|
|
e37156a305 | ||
|
|
a10b0e5464 | ||
|
|
275b739944 | ||
|
|
9d1ce9a100 | ||
|
|
79afe6c3d2 | ||
|
|
c6dbb22300 | ||
|
|
18bacd3ea5 | ||
|
|
a2c913aec3 | ||
|
|
67b33b2942 | ||
|
|
7b5fd2bd05 | ||
|
|
7181d77700 | ||
|
|
7f663b1204 | ||
|
|
173ebb6944 | ||
|
|
d658239484 | ||
|
|
ab4bf59e8c | ||
|
|
eee44bbb26 | ||
|
|
a63fa51a15 | ||
|
|
2049e52101 | ||
|
|
832c618f5f | ||
|
|
14615699fa | ||
|
|
20aad0c41e | ||
|
|
f083b33f2a | ||
|
|
bf17df346e | ||
|
|
35281dedb5 | ||
|
|
c9651b7420 | ||
|
|
26c3b3adab | ||
|
|
da6e1b9856 | ||
|
|
ad27d751e3 | ||
|
|
0aab623cb1 | ||
|
|
6a446bdd83 | ||
|
|
21fb5cbbc9 | ||
|
|
0da6f94867 | ||
|
|
59e9713081 | ||
|
|
40866a8927 | ||
|
|
b71d968fad | ||
|
|
fac0d7be02 | ||
|
|
6c5603fd98 | ||
|
|
2d21853a7e | ||
|
|
fec1a8d015 | ||
|
|
7fd8576233 | ||
|
|
a4cb1599d8 | ||
|
|
ae4ce72651 | ||
|
|
e2be0c0b06 | ||
|
|
2ad408697f | ||
|
|
4213d91054 | ||
|
|
5a13f622cf | ||
|
|
23a7e4e0b0 | ||
|
|
eeb49c2757 | ||
|
|
824763b316 | ||
|
|
d3aeee32bb | ||
|
|
0bceba24db | ||
|
|
b8c77d4041 | ||
|
|
8468eab83b | ||
|
|
2b2e8d4aec | ||
|
|
b80b32bfaf | ||
|
|
e5f331db99 | ||
|
|
2f84c60385 | ||
|
|
d648396515 | ||
|
|
777e78d8dd | ||
|
|
4016c549d3 | ||
|
|
40827b21b2 | ||
|
|
65a10b6e32 | ||
|
|
8db2fef3f7 | ||
|
|
9ed1323044 | ||
|
|
1a4c405662 | ||
|
|
318594e4b4 | ||
|
|
3d903302c3 | ||
|
|
c9571d9897 | ||
|
|
3694b830a2 | ||
|
|
0471fa807c | ||
|
|
914344ea9b | ||
|
|
b40266c56f | ||
|
|
8a9303d464 | ||
|
|
30c4bf47f9 | ||
|
|
46ce45601b | ||
|
|
433312c55a | ||
|
|
9c52ec3744 | ||
|
|
70e2f49bff | ||
|
|
5ac0367ed3 | ||
|
|
5d101afb52 | ||
|
|
06f4af11b6 | ||
|
|
57e338f819 |
@@ -2,11 +2,29 @@
|
||||
buildifier: latest
|
||||
platforms:
|
||||
ubuntu1804:
|
||||
environment:
|
||||
CC: clang
|
||||
SWIFT_VERSION: "5.5.3"
|
||||
SWIFT_HOME: "$HOME/swift-$SWIFT_VERSION"
|
||||
PATH: "$PATH:$SWIFT_HOME/usr/bin"
|
||||
shell_commands:
|
||||
- "echo --- Downloading and extracting Swift $SWIFT_VERSION to $SWIFT_HOME"
|
||||
- "mkdir $SWIFT_HOME"
|
||||
- "curl https://download.swift.org/swift-${SWIFT_VERSION}-release/ubuntu1804/swift-${SWIFT_VERSION}-RELEASE/swift-${SWIFT_VERSION}-RELEASE-ubuntu18.04.tar.gz | tar xvz --strip-components=1 -C $SWIFT_HOME"
|
||||
build_targets:
|
||||
- "//..."
|
||||
test_targets:
|
||||
- "//..."
|
||||
ubuntu2004:
|
||||
environment:
|
||||
CC: clang
|
||||
SWIFT_VERSION: "5.5.3"
|
||||
SWIFT_HOME: "$HOME/swift-$SWIFT_VERSION"
|
||||
PATH: "$PATH:$SWIFT_HOME/usr/bin"
|
||||
shell_commands:
|
||||
- "echo --- Downloading and extracting Swift $SWIFT_VERSION to $SWIFT_HOME"
|
||||
- "mkdir $SWIFT_HOME"
|
||||
- "curl https://download.swift.org/swift-${SWIFT_VERSION}-release/ubuntu2004/swift-${SWIFT_VERSION}-RELEASE/swift-${SWIFT_VERSION}-RELEASE-ubuntu20.04.tar.gz | tar xvz --strip-components=1 -C $SWIFT_HOME"
|
||||
build_targets:
|
||||
- "//..."
|
||||
test_targets:
|
||||
|
||||
347
.clang-tidy
Normal file
347
.clang-tidy
Normal file
@@ -0,0 +1,347 @@
|
||||
---
|
||||
FormatStyle: "file"
|
||||
WarningsAsErrors: "*"
|
||||
HeaderFilterRegex: ".*"
|
||||
Checks: "google-build-explicit-make-pair,
|
||||
google-build-namespaces,
|
||||
google-build-using-namespace,
|
||||
google-default-arguments,
|
||||
google-explicit-constructor,
|
||||
google-global-names-in-headers,
|
||||
google-objc-avoid-nsobject-new,
|
||||
google-objc-avoid-throwing-exception,
|
||||
google-objc-function-naming,
|
||||
google-objc-global-variable-declaration,
|
||||
google-readability-avoid-underscore-in-googletest-name,
|
||||
google-readability-braces-around-statements,
|
||||
google-readability-casting,
|
||||
google-readability-function-size,
|
||||
google-readability-namespace-comments,
|
||||
google-runtime-int,
|
||||
google-runtime-operator,
|
||||
google-upgrade-googletest-case,
|
||||
clang-analyzer-apiModeling.StdCLibraryFunctions,
|
||||
clang-analyzer-apiModeling.TrustNonnull,
|
||||
clang-analyzer-apiModeling.google.GTest,
|
||||
clang-analyzer-apiModeling.llvm.CastValue,
|
||||
clang-analyzer-apiModeling.llvm.ReturnValue,
|
||||
clang-analyzer-core.CallAndMessage,
|
||||
clang-analyzer-core.CallAndMessageModeling,
|
||||
clang-analyzer-core.DivideZero,
|
||||
clang-analyzer-core.DynamicTypePropagation,
|
||||
clang-analyzer-core.NonNullParamChecker,
|
||||
clang-analyzer-core.NonnilStringConstants,
|
||||
clang-analyzer-core.NullDereference,
|
||||
clang-analyzer-core.StackAddrEscapeBase,
|
||||
clang-analyzer-core.StackAddressEscape,
|
||||
clang-analyzer-core.UndefinedBinaryOperatorResult,
|
||||
clang-analyzer-core.VLASize,
|
||||
clang-analyzer-core.builtin.BuiltinFunctions,
|
||||
clang-analyzer-core.builtin.NoReturnFunctions,
|
||||
clang-analyzer-core.uninitialized.ArraySubscript,
|
||||
clang-analyzer-core.uninitialized.Assign,
|
||||
clang-analyzer-core.uninitialized.Branch,
|
||||
clang-analyzer-core.uninitialized.CapturedBlockVariable,
|
||||
clang-analyzer-core.uninitialized.UndefReturn,
|
||||
clang-analyzer-cplusplus.InnerPointer,
|
||||
clang-analyzer-cplusplus.Move,
|
||||
clang-analyzer-cplusplus.NewDelete,
|
||||
clang-analyzer-cplusplus.NewDeleteLeaks,
|
||||
clang-analyzer-cplusplus.PlacementNew,
|
||||
clang-analyzer-cplusplus.PureVirtualCall,
|
||||
clang-analyzer-cplusplus.SelfAssignment,
|
||||
clang-analyzer-cplusplus.SmartPtrModeling,
|
||||
clang-analyzer-cplusplus.StringChecker,
|
||||
clang-analyzer-cplusplus.VirtualCallModeling,
|
||||
clang-analyzer-deadcode.DeadStores,
|
||||
clang-analyzer-fuchsia.HandleChecker,
|
||||
clang-analyzer-nullability.NullPassedToNonnull,
|
||||
clang-analyzer-nullability.NullReturnedFromNonnull,
|
||||
clang-analyzer-nullability.NullabilityBase,
|
||||
clang-analyzer-nullability.NullableDereferenced,
|
||||
clang-analyzer-nullability.NullablePassedToNonnull,
|
||||
clang-analyzer-nullability.NullableReturnedFromNonnull,
|
||||
clang-analyzer-optin.cplusplus.UninitializedObject,
|
||||
clang-analyzer-optin.cplusplus.VirtualCall,
|
||||
clang-analyzer-optin.mpi.MPI-Checker,
|
||||
clang-analyzer-optin.osx.OSObjectCStyleCast,
|
||||
clang-analyzer-optin.osx.cocoa.localizability.EmptyLocalizationContextChecker,
|
||||
clang-analyzer-optin.osx.cocoa.localizability.NonLocalizedStringChecker,
|
||||
clang-analyzer-optin.performance.GCDAntipattern,
|
||||
clang-analyzer-optin.performance.Padding,
|
||||
clang-analyzer-optin.portability.UnixAPI,
|
||||
clang-analyzer-osx.API,
|
||||
clang-analyzer-osx.MIG,
|
||||
clang-analyzer-osx.NSOrCFErrorDerefChecker,
|
||||
clang-analyzer-osx.NumberObjectConversion,
|
||||
clang-analyzer-osx.OSObjectRetainCount,
|
||||
clang-analyzer-osx.ObjCProperty,
|
||||
clang-analyzer-osx.SecKeychainAPI,
|
||||
clang-analyzer-osx.cocoa.AtSync,
|
||||
clang-analyzer-osx.cocoa.AutoreleaseWrite,
|
||||
clang-analyzer-osx.cocoa.ClassRelease,
|
||||
clang-analyzer-osx.cocoa.Dealloc,
|
||||
clang-analyzer-osx.cocoa.IncompatibleMethodTypes,
|
||||
clang-analyzer-osx.cocoa.Loops,
|
||||
clang-analyzer-osx.cocoa.MissingSuperCall,
|
||||
clang-analyzer-osx.cocoa.NSAutoreleasePool,
|
||||
clang-analyzer-osx.cocoa.NSError,
|
||||
clang-analyzer-osx.cocoa.NilArg,
|
||||
clang-analyzer-osx.cocoa.NonNilReturnValue,
|
||||
clang-analyzer-osx.cocoa.ObjCGenerics,
|
||||
clang-analyzer-osx.cocoa.RetainCount,
|
||||
clang-analyzer-osx.cocoa.RetainCountBase,
|
||||
clang-analyzer-osx.cocoa.RunLoopAutoreleaseLeak,
|
||||
clang-analyzer-osx.cocoa.SelfInit,
|
||||
clang-analyzer-osx.cocoa.SuperDealloc,
|
||||
clang-analyzer-osx.cocoa.UnusedIvars,
|
||||
clang-analyzer-osx.cocoa.VariadicMethodTypes,
|
||||
clang-analyzer-osx.coreFoundation.CFError,
|
||||
clang-analyzer-osx.coreFoundation.CFNumber,
|
||||
clang-analyzer-osx.coreFoundation.CFRetainRelease,
|
||||
clang-analyzer-osx.coreFoundation.containers.OutOfBounds,
|
||||
clang-analyzer-osx.coreFoundation.containers.PointerSizedValues,
|
||||
clang-analyzer-security.FloatLoopCounter,
|
||||
clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling,
|
||||
clang-analyzer-security.insecureAPI.SecuritySyntaxChecker,
|
||||
clang-analyzer-security.insecureAPI.UncheckedReturn,
|
||||
clang-analyzer-security.insecureAPI.bcmp,
|
||||
clang-analyzer-security.insecureAPI.bcopy,
|
||||
clang-analyzer-security.insecureAPI.bzero,
|
||||
clang-analyzer-security.insecureAPI.decodeValueOfObjCType,
|
||||
clang-analyzer-security.insecureAPI.getpw,
|
||||
clang-analyzer-security.insecureAPI.gets,
|
||||
clang-analyzer-security.insecureAPI.mkstemp,
|
||||
clang-analyzer-security.insecureAPI.mktemp,
|
||||
clang-analyzer-security.insecureAPI.rand,
|
||||
clang-analyzer-security.insecureAPI.strcpy,
|
||||
clang-analyzer-security.insecureAPI.vfork,
|
||||
clang-analyzer-unix.API,
|
||||
clang-analyzer-unix.DynamicMemoryModeling,
|
||||
clang-analyzer-unix.Malloc,
|
||||
clang-analyzer-unix.MallocSizeof,
|
||||
clang-analyzer-unix.MismatchedDeallocator,
|
||||
clang-analyzer-unix.Vfork,
|
||||
clang-analyzer-unix.cstring.BadSizeArg,
|
||||
clang-analyzer-unix.cstring.CStringModeling,
|
||||
clang-analyzer-unix.cstring.NullArg,
|
||||
clang-analyzer-valist.CopyToSelf,
|
||||
clang-analyzer-valist.Uninitialized,
|
||||
clang-analyzer-valist.Unterminated,
|
||||
clang-analyzer-valist.ValistBase,
|
||||
clang-analyzer-webkit.NoUncountedMemberChecker,
|
||||
clang-analyzer-webkit.RefCntblBaseVirtualDtor,
|
||||
clang-analyzer-webkit.UncountedLambdaCapturesChecker,
|
||||
|
||||
################################################ Optional checks ################################################
|
||||
|
||||
#google-readability-todo,
|
||||
#bugprone-argument-comment,
|
||||
#bugprone-assert-side-effect,
|
||||
#bugprone-bad-signal-to-kill-thread,
|
||||
#bugprone-bool-pointer-implicit-conversion,
|
||||
#bugprone-branch-clone,
|
||||
#bugprone-copy-constructor-init,
|
||||
#bugprone-dangling-handle,
|
||||
#bugprone-dynamic-static-initializers,
|
||||
#bugprone-easily-swappable-parameters,
|
||||
#bugprone-exception-escape,
|
||||
#bugprone-fold-init-type,
|
||||
#bugprone-forward-declaration-namespace,
|
||||
#bugprone-forwarding-reference-overload,
|
||||
#bugprone-implicit-widening-of-multiplication-result,
|
||||
#bugprone-inaccurate-erase,
|
||||
#bugprone-incorrect-roundings,
|
||||
#bugprone-infinite-loop,
|
||||
#bugprone-integer-division,
|
||||
#bugprone-lambda-function-name,
|
||||
#bugprone-macro-parentheses,
|
||||
#bugprone-macro-repeated-side-effects,
|
||||
#bugprone-misplaced-operator-in-strlen-in-alloc,
|
||||
#bugprone-misplaced-pointer-arithmetic-in-alloc,
|
||||
#bugprone-misplaced-widening-cast,
|
||||
#bugprone-move-forwarding-reference,
|
||||
#bugprone-multiple-statement-macro,
|
||||
#bugprone-narrowing-conversions,
|
||||
#bugprone-no-escape,
|
||||
#bugprone-not-null-terminated-result,
|
||||
#bugprone-parent-virtual-call,
|
||||
#bugprone-posix-return,
|
||||
#bugprone-redundant-branch-condition,
|
||||
#bugprone-reserved-identifier,
|
||||
#bugprone-signal-handler,
|
||||
#bugprone-signed-char-misuse,
|
||||
#bugprone-sizeof-container,
|
||||
#bugprone-sizeof-expression,
|
||||
#bugprone-spuriously-wake-up-functions,
|
||||
#bugprone-string-constructor,
|
||||
#bugprone-string-integer-assignment,
|
||||
#bugprone-string-literal-with-embedded-nul,
|
||||
#bugprone-stringview-nullptr,
|
||||
#bugprone-suspicious-enum-usage,
|
||||
#bugprone-suspicious-include,
|
||||
#bugprone-suspicious-memory-comparison,
|
||||
#bugprone-suspicious-memset-usage,
|
||||
#bugprone-suspicious-missing-comma,
|
||||
#bugprone-suspicious-semicolon,
|
||||
#bugprone-suspicious-string-compare,
|
||||
#bugprone-swapped-arguments,
|
||||
#bugprone-terminating-continue,
|
||||
#bugprone-throw-keyword-missing,
|
||||
#bugprone-too-small-loop-variable,
|
||||
#bugprone-undefined-memory-manipulation,
|
||||
#bugprone-undelegated-constructor,
|
||||
#bugprone-unhandled-exception-at-new,
|
||||
#bugprone-unhandled-self-assignment,
|
||||
#bugprone-unused-raii,
|
||||
#bugprone-unused-return-value,
|
||||
#bugprone-use-after-move,
|
||||
#bugprone-virtual-near-miss,
|
||||
#cppcoreguidelines-avoid-c-arrays,
|
||||
#cppcoreguidelines-avoid-goto,
|
||||
#cppcoreguidelines-avoid-magic-numbers,
|
||||
#cppcoreguidelines-avoid-non-const-global-variables,
|
||||
#cppcoreguidelines-c-copy-assignment-signature,
|
||||
#cppcoreguidelines-explicit-virtual-functions,
|
||||
#cppcoreguidelines-init-variables,
|
||||
#cppcoreguidelines-interfaces-global-init,
|
||||
#cppcoreguidelines-macro-usage,
|
||||
#cppcoreguidelines-narrowing-conversions,
|
||||
#cppcoreguidelines-no-malloc,
|
||||
#cppcoreguidelines-non-private-member-variables-in-classes,
|
||||
#cppcoreguidelines-owning-memory,
|
||||
#cppcoreguidelines-prefer-member-initializer,
|
||||
#cppcoreguidelines-pro-bounds-array-to-pointer-decay,
|
||||
#cppcoreguidelines-pro-bounds-constant-array-index,
|
||||
#cppcoreguidelines-pro-bounds-pointer-arithmetic,
|
||||
#cppcoreguidelines-pro-type-const-cast,
|
||||
#cppcoreguidelines-pro-type-cstyle-cast,
|
||||
#cppcoreguidelines-pro-type-member-init,
|
||||
#cppcoreguidelines-pro-type-reinterpret-cast,
|
||||
#cppcoreguidelines-pro-type-static-cast-downcast,
|
||||
#cppcoreguidelines-pro-type-union-access,
|
||||
#cppcoreguidelines-pro-type-vararg,
|
||||
#cppcoreguidelines-slicing,
|
||||
#cppcoreguidelines-special-member-functions,
|
||||
#cppcoreguidelines-virtual-class-destructor,
|
||||
#hicpp-avoid-c-arrays,
|
||||
#hicpp-avoid-goto,
|
||||
#hicpp-braces-around-statements,
|
||||
#hicpp-deprecated-headers,
|
||||
#hicpp-exception-baseclass,
|
||||
#hicpp-explicit-conversions,
|
||||
#hicpp-function-size,
|
||||
#hicpp-invalid-access-moved,
|
||||
#hicpp-member-init,
|
||||
#hicpp-move-const-arg,
|
||||
#hicpp-multiway-paths-covered,
|
||||
#hicpp-named-parameter,
|
||||
#hicpp-new-delete-operators,
|
||||
#hicpp-no-array-decay,
|
||||
#hicpp-no-assembler,
|
||||
#hicpp-no-malloc,
|
||||
#hicpp-noexcept-move,
|
||||
#hicpp-signed-bitwise,
|
||||
#hicpp-special-member-functions,
|
||||
#hicpp-static-assert,
|
||||
#hicpp-undelegated-constructor,
|
||||
#hicpp-uppercase-literal-suffix,
|
||||
#hicpp-use-auto,
|
||||
#hicpp-use-emplace,
|
||||
#hicpp-use-equals-default,
|
||||
#hicpp-use-equals-delete,
|
||||
#hicpp-use-noexcept,
|
||||
#hicpp-use-nullptr,
|
||||
#hicpp-use-override,
|
||||
#hicpp-vararg,
|
||||
#modernize-avoid-bind,
|
||||
#modernize-avoid-c-arrays,
|
||||
#modernize-concat-nested-namespaces,
|
||||
#modernize-deprecated-headers,
|
||||
#modernize-deprecated-ios-base-aliases,
|
||||
#modernize-loop-convert,
|
||||
#modernize-make-shared,
|
||||
#modernize-make-unique,
|
||||
#modernize-pass-by-value,
|
||||
#modernize-raw-string-literal,
|
||||
#modernize-redundant-void-arg,
|
||||
#modernize-replace-auto-ptr,
|
||||
#modernize-replace-disallow-copy-and-assign-macro,
|
||||
#modernize-replace-random-shuffle,
|
||||
#modernize-return-braced-init-list,
|
||||
#modernize-shrink-to-fit,
|
||||
#modernize-unary-static-assert,
|
||||
#modernize-use-auto,
|
||||
#modernize-use-bool-literals,
|
||||
#modernize-use-default-member-init,
|
||||
#modernize-use-emplace,
|
||||
#modernize-use-equals-default,
|
||||
#modernize-use-equals-delete,
|
||||
#modernize-use-nodiscard,
|
||||
#modernize-use-noexcept,
|
||||
#modernize-use-nullptr,
|
||||
#modernize-use-override,
|
||||
#modernize-use-trailing-return-type,
|
||||
#modernize-use-transparent-functors,
|
||||
#modernize-use-uncaught-exceptions,
|
||||
#modernize-use-using,
|
||||
#performance-faster-string-find,
|
||||
#performance-for-range-copy,
|
||||
#performance-implicit-conversion-in-loop,
|
||||
#performance-inefficient-algorithm,
|
||||
#performance-inefficient-string-concatenation,
|
||||
#performance-inefficient-vector-operation,
|
||||
#performance-move-const-arg,
|
||||
#performance-move-constructor-init,
|
||||
#performance-no-automatic-move,
|
||||
#performance-no-int-to-ptr,
|
||||
#performance-noexcept-move-constructor,
|
||||
#performance-trivially-destructible,
|
||||
#performance-type-promotion-in-math-fn,
|
||||
#performance-unnecessary-copy-initialization,
|
||||
#performance-unnecessary-value-param,
|
||||
#portability-restrict-system-includes,
|
||||
#portability-simd-intrinsics,
|
||||
#readability-avoid-const-params-in-decls,
|
||||
#readability-braces-around-statements,
|
||||
#readability-const-return-type,
|
||||
#readability-container-contains,
|
||||
#readability-container-data-pointer,
|
||||
#readability-container-size-empty,
|
||||
#readability-convert-member-functions-to-static,
|
||||
#readability-delete-null-pointer,
|
||||
#readability-duplicate-include,
|
||||
#readability-else-after-return,
|
||||
#readability-function-cognitive-complexity,
|
||||
#readability-function-size,
|
||||
#readability-identifier-length,
|
||||
#readability-identifier-naming,
|
||||
#readability-implicit-bool-conversion,
|
||||
#readability-inconsistent-declaration-parameter-name,
|
||||
#readability-isolate-declaration,
|
||||
#readability-magic-numbers,
|
||||
#readability-make-member-function-const,
|
||||
#readability-misleading-indentation,
|
||||
#readability-misplaced-array-index,
|
||||
#readability-named-parameter,
|
||||
#readability-non-const-parameter,
|
||||
#readability-qualified-auto,
|
||||
#readability-redundant-access-specifiers,
|
||||
#readability-redundant-control-flow,
|
||||
#readability-redundant-declaration,
|
||||
#readability-redundant-function-ptr-dereference,
|
||||
#readability-redundant-member-init,
|
||||
#readability-redundant-preprocessor,
|
||||
#readability-redundant-smartptr-get,
|
||||
#readability-redundant-string-cstr,
|
||||
#readability-redundant-string-init,
|
||||
#readability-simplify-boolean-expr,
|
||||
#readability-simplify-subscript-expr,
|
||||
#readability-static-accessed-through-instance,
|
||||
#readability-static-definition-in-anonymous-namespace,
|
||||
#readability-string-compare,
|
||||
#readability-suspicious-call-argument,
|
||||
#readability-uniqueptr-delete-release,
|
||||
#readability-uppercase-literal-suffix,
|
||||
#readability-use-anyofallof
|
||||
"
|
||||
@@ -5,3 +5,4 @@ root = true
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
2
.github/PULL_REQUEST_TEMPLATE.md
vendored
2
.github/PULL_REQUEST_TEMPLATE.md
vendored
@@ -3,7 +3,7 @@ Thank you for submitting a PR!
|
||||
Please delete this standard text once you've created your own description.
|
||||
|
||||
If you make changes to any of the code generators (`src/idl_gen*`) be sure to
|
||||
build your project, as it will generate code based on the changes. If necessary
|
||||
[build](https://google.github.io/flatbuffers/flatbuffers_guide_building.html) your project, as it will generate code based on the changes. If necessary
|
||||
the code generation script can be directly run (`scripts/generate_code.py`),
|
||||
requires Python3. This allows us to better see the effect of the PR.
|
||||
|
||||
|
||||
16
.github/labeler.yml
vendored
16
.github/labeler.yml
vendored
@@ -15,11 +15,15 @@ c#:
|
||||
swift:
|
||||
- '**/*.swift'
|
||||
- swift/**/*
|
||||
- tests/FlatBuffers.GRPC.Swift/**/*
|
||||
- tests/FlatBuffers.Benchmarks.swift/**/*
|
||||
- tests/FlatBuffers.Test.Swift/**/*
|
||||
- tests/swift/**
|
||||
- src/idl_gen_swift.cpp
|
||||
|
||||
nim:
|
||||
- '**/*.nim'
|
||||
- nim/**/*
|
||||
- src/idl_gen_nim.cpp
|
||||
- src/bfbs_gen_nim.cpp
|
||||
|
||||
javascript:
|
||||
- '**/*.js'
|
||||
- src/idl_gen_ts.cpp
|
||||
@@ -63,7 +67,7 @@ rust:
|
||||
- '**/*.rs'
|
||||
- rust/**/*
|
||||
- src/idl_gen_rust.cpp
|
||||
|
||||
|
||||
dart:
|
||||
- '**/*.dart'
|
||||
- src/idl_gen_dart.cpp
|
||||
@@ -86,10 +90,8 @@ documentation:
|
||||
|
||||
CI:
|
||||
- '.github/**/*'
|
||||
- '.travis/**/*'
|
||||
- '.bazelci/**/*'
|
||||
- .travis.yml
|
||||
|
||||
grpc:
|
||||
- grpc/**/*
|
||||
- src/idl_gen_grpc.cpp
|
||||
- src/idl_gen_grpc.cpp
|
||||
|
||||
436
.github/workflows/build.yml
vendored
436
.github/workflows/build.yml
vendored
@@ -1,7 +1,12 @@
|
||||
name: CI
|
||||
permissions: read-all
|
||||
|
||||
on:
|
||||
# For manual tests.
|
||||
workflow_dispatch:
|
||||
push:
|
||||
tags:
|
||||
- "*" # new tag version, like `0.8.4` or else
|
||||
branches:
|
||||
- master
|
||||
pull_request:
|
||||
@@ -10,57 +15,167 @@ on:
|
||||
|
||||
jobs:
|
||||
build-linux:
|
||||
permissions:
|
||||
contents: write
|
||||
outputs:
|
||||
digests-gcc: ${{ steps.hash-gcc.outputs.hashes }}
|
||||
digests-clang: ${{ steps.hash-clang.outputs.hashes }}
|
||||
name: Build Linux
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
cxx: [g++-10, clang++-12]
|
||||
fail-fast: false
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
- name: cmake
|
||||
run: CXX=${{ matrix.cxx }} cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release .
|
||||
run: CXX=${{ matrix.cxx }} cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_STRICT_MODE=ON .
|
||||
- name: build
|
||||
run: make -j4
|
||||
run: make -j
|
||||
- name: test
|
||||
run: ./flattests
|
||||
- name: make flatc executable
|
||||
run: |
|
||||
chmod +x flatc
|
||||
./flatc --version
|
||||
# - name: flatc tests
|
||||
# run: |
|
||||
# yarn global add esbuild
|
||||
# python3 tests/flatc/main.py
|
||||
- name: upload build artifacts
|
||||
uses: actions/upload-artifact@v1
|
||||
with:
|
||||
name: Linux flatc binary ${{ matrix.cxx }}
|
||||
path: flatc
|
||||
|
||||
build-windows:
|
||||
name: Build Windows 2019
|
||||
runs-on: windows-latest
|
||||
# Below if only for release.
|
||||
- name: Zip file
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
run: zip Linux.flatc.binary.${{ matrix.cxx }}.zip flatc
|
||||
- name: Release zip file
|
||||
uses: softprops/action-gh-release@v1
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
with:
|
||||
files: Linux.flatc.binary.${{ matrix.cxx }}.zip
|
||||
- name: Generate SLSA subjects - clang
|
||||
if: matrix.cxx == 'clang++-12' && startsWith(github.ref, 'refs/tags/')
|
||||
id: hash-clang
|
||||
run: echo "::set-output name=hashes::$(sha256sum Linux.flatc.binary.${{ matrix.cxx }}.zip | base64 -w0)"
|
||||
- name: Generate SLSA subjects - gcc
|
||||
if: matrix.cxx == 'g++-10' && startsWith(github.ref, 'refs/tags/')
|
||||
id: hash-gcc
|
||||
run: echo "::set-output name=hashes::$(sha256sum Linux.flatc.binary.${{ matrix.cxx }}.zip | base64 -w0)"
|
||||
|
||||
build-linux-no-file-tests:
|
||||
name: Build Linux with -DFLATBUFFERS_NO_FILE_TESTS
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
- name: cmake
|
||||
run: CXX=clang++-12 cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_STRICT_MODE=ON -DFLATBUFFERS_CXX_FLAGS="-DFLATBUFFERS_NO_FILE_TESTS" .
|
||||
- name: build
|
||||
run: make -j
|
||||
|
||||
build-linux-cpp-std:
|
||||
name: Build Linux C++
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
std: [11, 14, 17, 20, 23]
|
||||
cxx: [g++-10, clang++-12]
|
||||
exclude:
|
||||
# GCC 10.3.0 doesn't support std 23
|
||||
- cxx: g++-10
|
||||
std: 23
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: cmake
|
||||
run: >
|
||||
CXX=${{ matrix.cxx }} cmake -G "Unix Makefiles"
|
||||
-DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_STRICT_MODE=ON
|
||||
-DFLATBUFFERS_CPP_STD=${{ matrix.std }}
|
||||
-DFLATBUFFERS_BUILD_CPP17=${{ matrix.std >= 17 && 'On' || 'Off'}}
|
||||
- name: build
|
||||
run: make -j
|
||||
- name: test
|
||||
run: ./flattests
|
||||
- name: test C++17
|
||||
if: matrix.std >= 17
|
||||
run: ./flattests_cpp17
|
||||
|
||||
build-windows-cpp-std:
|
||||
name: Build Windows C++
|
||||
runs-on: windows-2019
|
||||
strategy:
|
||||
matrix:
|
||||
std: [11, 14, 17, 20, 23]
|
||||
fail-fast: false
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Add msbuild to PATH
|
||||
uses: microsoft/setup-msbuild@v1.1
|
||||
- name: cmake
|
||||
run: cmake -G "Visual Studio 16 2019" -A x64 -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_BUILD_CPP17=ON .
|
||||
run: >
|
||||
cmake -G "Visual Studio 16 2019" -A x64 -DCMAKE_BUILD_TYPE=Release
|
||||
-DFLATBUFFERS_STRICT_MODE=ON
|
||||
-DFLATBUFFERS_CPP_STD=${{ matrix.std }}
|
||||
-DFLATBUFFERS_BUILD_CPP17=${{ matrix.std >= 17 && 'On' || 'Off'}}
|
||||
- name: build
|
||||
run: msbuild.exe FlatBuffers.sln /p:Configuration=Release /p:Platform=x64
|
||||
- name: test
|
||||
run: Release\flattests.exe
|
||||
- name: test C++17
|
||||
if: matrix.std >= 17
|
||||
run: Release\flattests_cpp17.exe
|
||||
|
||||
build-windows:
|
||||
permissions:
|
||||
contents: write
|
||||
outputs:
|
||||
digests: ${{ steps.hash.outputs.hashes }}
|
||||
name: Build Windows 2019
|
||||
runs-on: windows-2019
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Add msbuild to PATH
|
||||
uses: microsoft/setup-msbuild@v1.1
|
||||
- name: cmake
|
||||
run: cmake -G "Visual Studio 16 2019" -A x64 -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_BUILD_CPP17=ON -DFLATBUFFERS_STRICT_MODE=ON .
|
||||
- name: build
|
||||
run: msbuild.exe FlatBuffers.sln /p:Configuration=Release /p:Platform=x64
|
||||
- name: test
|
||||
run: Release\flattests.exe
|
||||
# - name: flatc tests
|
||||
# run: python3 tests/flatc/main.py --flatc Release\flatc.exe
|
||||
- name: upload build artifacts
|
||||
uses: actions/upload-artifact@v1
|
||||
with:
|
||||
name: Windows flatc binary
|
||||
path: Release\flatc.exe
|
||||
# Below if only for release.
|
||||
- name: Zip file
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
run: move Release/flatc.exe . && Compress-Archive flatc.exe Windows.flatc.binary.zip
|
||||
- name: Release binary
|
||||
uses: softprops/action-gh-release@v1
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
with:
|
||||
files: Windows.flatc.binary.zip
|
||||
- name: Generate SLSA subjects
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
id: hash
|
||||
shell: bash
|
||||
run: echo "::set-output name=hashes::$(sha256sum Windows.flatc.binary.zip | base64 -w0)"
|
||||
|
||||
build-windows-2017:
|
||||
name: Build Windows 2017
|
||||
runs-on: windows-latest
|
||||
runs-on: windows-2019
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
- name: Add msbuild to PATH
|
||||
uses: microsoft/setup-msbuild@v1.1
|
||||
- name: cmake
|
||||
run: cmake -G "Visual Studio 16 2019" -A x64 -DCMAKE_BUILD_TYPE=Release .
|
||||
run: cmake -G "Visual Studio 16 2019" -A x64 -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_STRICT_MODE=ON .
|
||||
- name: build tool version 15 (VS 2017)
|
||||
run: msbuild.exe FlatBuffers.sln /p:Configuration=Release /p:Platform=x64 /p:VisualStudioVersion=15.0
|
||||
- name: test
|
||||
@@ -68,13 +183,13 @@ jobs:
|
||||
|
||||
build-windows-2015:
|
||||
name: Build Windows 2015
|
||||
runs-on: windows-latest
|
||||
runs-on: windows-2019
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
- name: Add msbuild to PATH
|
||||
uses: microsoft/setup-msbuild@v1.1
|
||||
- name: cmake
|
||||
run: cmake -G "Visual Studio 14 2015" -A x64 -DCMAKE_BUILD_TYPE=Release .
|
||||
run: cmake -G "Visual Studio 14 2015" -A x64 -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_STRICT_MODE=ON .
|
||||
- name: build tool version 14 (VS 2015)
|
||||
run: msbuild.exe FlatBuffers.sln /p:Configuration=Release /p:Platform=x64 /p:VisualStudioVersion=14.0
|
||||
- name: test
|
||||
@@ -82,7 +197,7 @@ jobs:
|
||||
|
||||
build-dotnet-windows:
|
||||
name: Build .NET Windows
|
||||
runs-on: windows-latest
|
||||
runs-on: windows-2019
|
||||
strategy:
|
||||
matrix:
|
||||
configuration: [
|
||||
@@ -92,9 +207,9 @@ jobs:
|
||||
#'-p:EnableSpanT=true,UnsafeByteBuffer=true'
|
||||
]
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
- name: Setup .NET Core SDK
|
||||
uses: actions/setup-dotnet@v1.9.0
|
||||
uses: actions/setup-dotnet@v3
|
||||
with:
|
||||
dotnet-version: '3.1.x'
|
||||
- name: Build
|
||||
@@ -108,50 +223,112 @@ jobs:
|
||||
cd tests\FlatBuffers.Test
|
||||
out\FlatBuffers.Core.Test.exe
|
||||
|
||||
build-mac:
|
||||
name: Build Mac
|
||||
build-mac-intel:
|
||||
permissions:
|
||||
contents: write
|
||||
outputs:
|
||||
digests: ${{ steps.hash.outputs.hashes }}
|
||||
name: Build Mac (for Intel)
|
||||
runs-on: macos-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
- name: cmake
|
||||
run: cmake -G "Xcode" -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_FLATC_EXECUTABLE=_build/Release/flatc .
|
||||
run: cmake -G "Xcode" -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_STRICT_MODE=ON .
|
||||
- name: build
|
||||
# NOTE: we need this _build dir to not have xcodebuild's default ./build dir clash with the BUILD file.
|
||||
run: xcodebuild -toolchain clang -configuration Release -target flattests SYMROOT=$(PWD)/_build
|
||||
- name: check that the binary is "universal"
|
||||
run: xcodebuild -toolchain clang -configuration Release -target flattests
|
||||
- name: check that the binary is x86_64
|
||||
run: |
|
||||
info=$(file _build/Release/flatc)
|
||||
info=$(file Release/flatc)
|
||||
echo $info
|
||||
echo $info | grep "universal binary with 2 architectures"
|
||||
echo $info | grep "Mach-O 64-bit executable x86_64"
|
||||
- name: test
|
||||
run: _build/Release/flattests
|
||||
run: Release/flattests
|
||||
- name: make flatc executable
|
||||
run: |
|
||||
chmod +x _build/Release/flatc
|
||||
./_build/Release/flatc --version
|
||||
chmod +x Release/flatc
|
||||
Release/flatc --version
|
||||
# - name: flatc tests
|
||||
# run: python3 tests/flatc/main.py --flatc Release/flatc
|
||||
- name: upload build artifacts
|
||||
uses: actions/upload-artifact@v1
|
||||
with:
|
||||
name: Mac flatc binary
|
||||
path: _build/Release/flatc
|
||||
path: Release/flatc
|
||||
# Below if only for release.
|
||||
- name: Zip file
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
run: mv Release/flatc . && zip MacIntel.flatc.binary.zip flatc
|
||||
- name: Release binary
|
||||
uses: softprops/action-gh-release@v1
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
with:
|
||||
files: MacIntel.flatc.binary.zip
|
||||
- name: Generate SLSA subjects
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
id: hash
|
||||
run: echo "::set-output name=hashes::$(shasum -a 256 MacIntel.flatc.binary.zip | base64)"
|
||||
|
||||
build-mac-universal:
|
||||
permissions:
|
||||
contents: write
|
||||
outputs:
|
||||
digests: ${{ steps.hash.outputs.hashes }}
|
||||
name: Build Mac (universal build)
|
||||
runs-on: macos-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: cmake
|
||||
run: cmake -G "Xcode" -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_STRICT_MODE=ON .
|
||||
- name: build
|
||||
run: xcodebuild -toolchain clang -configuration Release -target flattests
|
||||
- name: check that the binary is "universal"
|
||||
run: |
|
||||
info=$(file Release/flatc)
|
||||
echo $info
|
||||
echo $info | grep "Mach-O universal binary with 2 architectures"
|
||||
- name: test
|
||||
run: Release/flattests
|
||||
- name: make flatc executable
|
||||
run: |
|
||||
chmod +x Release/flatc
|
||||
Release/flatc --version
|
||||
- name: upload build artifacts
|
||||
uses: actions/upload-artifact@v1
|
||||
with:
|
||||
name: Mac flatc binary
|
||||
path: Release/flatc
|
||||
# Below if only for release.
|
||||
- name: Zip file
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
run: mv Release/flatc . && zip Mac.flatc.binary.zip flatc
|
||||
- name: Release binary
|
||||
uses: softprops/action-gh-release@v1
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
with:
|
||||
files: Mac.flatc.binary.zip
|
||||
- name: Generate SLSA subjects
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
id: hash
|
||||
run: echo "::set-output name=hashes::$(shasum -a 256 Mac.flatc.binary.zip | base64)"
|
||||
|
||||
build-android:
|
||||
name: Build Android (on Linux)
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: set up JDK 1.8
|
||||
uses: actions/setup-java@v1
|
||||
- uses: actions/checkout@v3
|
||||
- name: set up Java
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
java-version: 1.8
|
||||
distribution: 'temurin'
|
||||
java-version: '11'
|
||||
- name: set up flatc
|
||||
run: |
|
||||
cmake -DFLATBUFFERS_BUILD_TESTS=OFF -DFLATBUFFERS_BUILD_FLATLIB=OFF -DFLATBUFFERS_BUILD_FLATHASH=OFF .
|
||||
make
|
||||
cmake -DFLATBUFFERS_BUILD_TESTS=OFF -DFLATBUFFERS_BUILD_FLATLIB=OFF -DFLATBUFFERS_BUILD_FLATHASH=OFF -DFLATBUFFERS_STRICT_MODE=ON .
|
||||
make -j
|
||||
echo "${PWD}" >> $GITHUB_PATH
|
||||
- name: build
|
||||
working-directory: android
|
||||
run: bash ./gradlew clean build
|
||||
run: gradle clean build
|
||||
|
||||
build-generator:
|
||||
name: Check Generated Code
|
||||
@@ -160,13 +337,29 @@ jobs:
|
||||
matrix:
|
||||
cxx: [g++-10, clang++-12]
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
- name: cmake
|
||||
run: CXX=${{ matrix.cxx }} cmake -G "Unix Makefiles" -DFLATBUFFERS_BUILD_TESTS=OFF -DCMAKE_BUILD_TYPE=Release . && make -j4
|
||||
run: CXX=${{ matrix.cxx }} cmake -G "Unix Makefiles" -DFLATBUFFERS_BUILD_TESTS=OFF -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_STRICT_MODE=ON . && make -j
|
||||
- name: Generate
|
||||
run: scripts/check_generate_code.py
|
||||
- name: Generate gRPC
|
||||
run: bash scripts/check-grpc-generated-code.sh
|
||||
run: scripts/check-grpc-generated-code.py
|
||||
|
||||
build-generator-windows:
|
||||
name: Check Generated Code on Windows
|
||||
runs-on: windows-2019
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Add msbuild to PATH
|
||||
uses: microsoft/setup-msbuild@v1.1
|
||||
- name: cmake
|
||||
run: cmake -G "Visual Studio 16 2019" -A x64 -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_BUILD_CPP17=ON -DFLATBUFFERS_STRICT_MODE=ON .
|
||||
- name: build
|
||||
run: msbuild.exe FlatBuffers.sln /p:Configuration=Release /p:Platform=x64
|
||||
- name: Generate
|
||||
run: python3 scripts/check_generate_code.py --flatc Release\flatc.exe
|
||||
- name: Generate gRPC
|
||||
run: python3 scripts/check-grpc-generated-code.py --flatc Release\flatc.exe
|
||||
|
||||
build-benchmarks:
|
||||
name: Build Benchmarks (on Linux)
|
||||
@@ -175,9 +368,9 @@ jobs:
|
||||
matrix:
|
||||
cxx: [g++-10]
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
- name: cmake
|
||||
run: CXX=${{ matrix.cxx }} cmake -G "Unix Makefiles" -DFLATBUFFERS_CXX_FLAGS="-Wno-unused-parameter -fno-aligned-new" -DFLATBUFFERS_BUILD_BENCHMARKS=ON -DCMAKE_BUILD_TYPE=Release . && make -j4
|
||||
run: CXX=${{ matrix.cxx }} cmake -G "Unix Makefiles" -DFLATBUFFERS_CXX_FLAGS="-Wno-unused-parameter -fno-aligned-new" -DFLATBUFFERS_BUILD_BENCHMARKS=ON -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_STRICT_MODE=ON . && make -j
|
||||
- name: Run benchmarks
|
||||
run: ./flatbenchmark --benchmark_repetitions=5 --benchmark_display_aggregates_only=true --benchmark_out_format=console --benchmark_out=benchmarks/results_${{matrix.cxx}}
|
||||
- name: Upload benchmarks results
|
||||
@@ -190,57 +383,49 @@ jobs:
|
||||
name: Build Java
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
- name: test
|
||||
working-directory: tests
|
||||
run: bash JavaTest.sh
|
||||
working-directory: java
|
||||
run: mvn test
|
||||
|
||||
build-kotlin-macos:
|
||||
name: Build Kotlin MacOS
|
||||
runs-on: macos-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
- uses: actions/setup-java@v2
|
||||
uses: actions/checkout@v3
|
||||
- uses: gradle/wrapper-validation-action@v1.0.5
|
||||
- uses: actions/setup-java@v3
|
||||
with:
|
||||
distribution: 'adopt-hotspot'
|
||||
distribution: 'temurin'
|
||||
java-version: '11'
|
||||
- name: Build
|
||||
working-directory: kotlin
|
||||
run: ./gradlew clean iosX64Test macosX64Test jsTest jsBrowserTest
|
||||
run: ./gradlew clean iosX64Test macosX64Test
|
||||
|
||||
build-kotlin-linux:
|
||||
name: Build Kotlin Linux
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
- uses: actions/setup-java@v2
|
||||
uses: actions/checkout@v3
|
||||
- uses: actions/setup-java@v3
|
||||
with:
|
||||
distribution: 'adopt-hotspot'
|
||||
java-version: '8'
|
||||
distribution: 'temurin'
|
||||
java-version: '11'
|
||||
- uses: gradle/wrapper-validation-action@v1.0.5
|
||||
- name: Build
|
||||
working-directory: kotlin
|
||||
run: ./gradlew jvmMainClasses jvmTest
|
||||
- name: Run Benchmark
|
||||
working-directory: kotlin
|
||||
run: ./gradlew jvmBenchmark
|
||||
- name: Generate Benchmark Report
|
||||
working-directory: kotlin
|
||||
run: |
|
||||
./gradlew jmhReport;
|
||||
mv benchmark/build/reports/benchmarks/main/* benchmark_latest
|
||||
- name: Archive benchmark report
|
||||
uses: actions/upload-artifact@v1
|
||||
with:
|
||||
name: Kotlin Benchmark Report
|
||||
path: kotlin/benchmark_latest
|
||||
# we are using docker's version of gradle
|
||||
# so no need for wrapper validation or user
|
||||
# gradlew
|
||||
run: gradle jvmMainClasses jvmTest jsTest jsBrowserTest
|
||||
|
||||
build-rust:
|
||||
name: Build Rust
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
- name: test
|
||||
working-directory: tests
|
||||
run: bash RustTest.sh
|
||||
@@ -249,7 +434,7 @@ jobs:
|
||||
name: Build Python
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
- name: test
|
||||
working-directory: tests
|
||||
run: bash PythonTest.sh
|
||||
@@ -258,45 +443,134 @@ jobs:
|
||||
name: Build Go
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
- name: flatc
|
||||
# FIXME: make test script not rely on flatc
|
||||
run: cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_BUILD_TESTS=OFF -DFLATBUFFERS_INSTALL=OFF -DFLATBUFFERS_BUILD_FLATLIB=OFF -DFLATBUFFERS_BUILD_FLATHASH=OFF . && make -j4
|
||||
run: cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_BUILD_TESTS=OFF -DFLATBUFFERS_INSTALL=OFF -DFLATBUFFERS_BUILD_FLATLIB=OFF -DFLATBUFFERS_BUILD_FLATHASH=OFF -DFLATBUFFERS_STRICT_MODE=ON . && make -j
|
||||
- name: test
|
||||
working-directory: tests
|
||||
run: bash GoTest.sh
|
||||
|
||||
build-php:
|
||||
name: Build PHP
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: flatc
|
||||
# FIXME: make test script not rely on flatc
|
||||
run: cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_BUILD_TESTS=OFF -DFLATBUFFERS_INSTALL=OFF -DFLATBUFFERS_BUILD_FLATLIB=OFF -DFLATBUFFERS_BUILD_FLATHASH=OFF -DFLATBUFFERS_STRICT_MODE=ON . && make -j
|
||||
- name: test
|
||||
working-directory: tests
|
||||
run: |
|
||||
php phpTest.php
|
||||
sh phpUnionVectorTest.sh
|
||||
|
||||
build-swift:
|
||||
name: Build Swift
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
- name: test
|
||||
working-directory: tests/FlatBuffers.Test.Swift
|
||||
run: sh SwiftTest.sh
|
||||
working-directory: tests/swift/tests
|
||||
run: |
|
||||
swift build --build-tests
|
||||
swift test
|
||||
|
||||
build-swift-wasm:
|
||||
name: Build Swift Wasm
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: ghcr.io/swiftwasm/carton:0.15.3
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Setup Wasmer
|
||||
uses: wasmerio/setup-wasmer@v2
|
||||
- name: Test
|
||||
working-directory: tests/swift/Wasm.tests
|
||||
run: carton test
|
||||
|
||||
build-ts:
|
||||
name: Build TS
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
- name: flatc
|
||||
# FIXME: make test script not rely on flatc
|
||||
run: cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_BUILD_TESTS=OFF -DFLATBUFFERS_INSTALL=OFF -DFLATBUFFERS_BUILD_FLATLIB=OFF -DFLATBUFFERS_BUILD_FLATHASH=OFF . && make -j
|
||||
- name: deps
|
||||
run: yarn
|
||||
- name: compile
|
||||
run: npm run compile
|
||||
run: yarn compile
|
||||
- name: test
|
||||
working-directory: tests
|
||||
run: sh TypeScriptTest.sh
|
||||
working-directory: tests/ts
|
||||
run: |
|
||||
yarn global add esbuild
|
||||
python3 TypeScriptTest.py
|
||||
|
||||
build-dart:
|
||||
name: Build Dart
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
- uses: dart-lang/setup-dart@v1
|
||||
with:
|
||||
sdk: stable
|
||||
- name: flatc
|
||||
# FIXME: make test script not rely on flatc
|
||||
run: cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_BUILD_TESTS=OFF -DFLATBUFFERS_INSTALL=OFF -DFLATBUFFERS_BUILD_FLATLIB=OFF -DFLATBUFFERS_BUILD_FLATHASH=OFF . && make -j4
|
||||
run: cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_BUILD_TESTS=OFF -DFLATBUFFERS_INSTALL=OFF -DFLATBUFFERS_BUILD_FLATLIB=OFF -DFLATBUFFERS_BUILD_FLATHASH=OFF -DFLATBUFFERS_STRICT_MODE=ON . && make -j
|
||||
- name: test
|
||||
working-directory: tests
|
||||
run: bash DartTest.sh
|
||||
|
||||
build-nim:
|
||||
name: Build Nim
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: flatc
|
||||
# FIXME: make test script not rely on flatc
|
||||
run: cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_BUILD_TESTS=OFF -DFLATBUFFERS_INSTALL=OFF -DFLATBUFFERS_BUILD_FLATLIB=OFF -DFLATBUFFERS_BUILD_FLATHASH=OFF . && make -j
|
||||
- uses: jiro4989/setup-nim-action@v1
|
||||
- name: install library
|
||||
working-directory: nim
|
||||
run: nimble -y develop
|
||||
- name: test
|
||||
working-directory: tests/nim
|
||||
run: python3 testnim.py
|
||||
|
||||
release-digests:
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
needs: [build-linux, build-windows, build-mac-intel, build-mac-universal]
|
||||
outputs:
|
||||
digests: ${{ steps.hash.outputs.digests }}
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Merge results
|
||||
id: hash
|
||||
env:
|
||||
LINUXGCC_DIGESTS: "${{ needs.build-linux.outputs.digests-gcc }}"
|
||||
LINUXCLANG_DIGESTS: "${{ needs.build-linux.outputs.digests-clang }}"
|
||||
MAC_DIGESTS: "${{ needs.build-mac-universal.outputs.digests }}"
|
||||
MACINTEL_DIGESTS: "${{ needs.build-mac-intel.outputs.digests }}"
|
||||
WINDOWS_DIGESTS: "${{ needs.build-windows.outputs.digests }}"
|
||||
run: |
|
||||
set -euo pipefail
|
||||
echo "$LINUXGCC_DIGESTS" | base64 -d > checksums.txt
|
||||
echo "$LINUXCLANG_DIGESTS" | base64 -d >> checksums.txt
|
||||
echo "$MAC_DIGESTS" | base64 -d >> checksums.txt
|
||||
echo "$MACINTEL_DIGESTS" | base64 -d >> checksums.txt
|
||||
echo "$WINDOWS_DIGESTS" | base64 -d >> checksums.txt
|
||||
echo "::set-output name=digests::$(cat checksums.txt | base64 -w0)"
|
||||
|
||||
provenance:
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
needs: [release-digests]
|
||||
permissions:
|
||||
actions: read # To read the workflow path.
|
||||
id-token: write # To sign the provenance.
|
||||
contents: write # To add assets to a release.
|
||||
uses: slsa-framework/slsa-github-generator/.github/workflows/generator_generic_slsa3.yml@v1.2.1
|
||||
with:
|
||||
base64-subjects: "${{ needs.release-digests.outputs.digests }}"
|
||||
upload-assets: true # Optional: Upload to a new release
|
||||
compile-generator: true # Workaround for https://github.com/slsa-framework/slsa-github-generator/issues/1163
|
||||
|
||||
71
.github/workflows/codeql.yml
vendored
Normal file
71
.github/workflows/codeql.yml
vendored
Normal file
@@ -0,0 +1,71 @@
|
||||
# For most projects, this workflow file will not need changing; you simply need
|
||||
# to commit it to your repository.
|
||||
#
|
||||
# You may wish to alter this file to override the set of languages analyzed,
|
||||
# or to provide custom queries or build logic.
|
||||
#
|
||||
# ******** NOTE ********
|
||||
# We have attempted to detect the languages in your repository. Please check
|
||||
# the `language` matrix defined below to confirm you have the correct set of
|
||||
# supported CodeQL languages.
|
||||
#
|
||||
name: "CodeQL"
|
||||
permissions: read-all
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ master ]
|
||||
pull_request:
|
||||
# The branches below must be a subset of the branches above
|
||||
branches: [ master ]
|
||||
schedule:
|
||||
- cron: '16 20 * * 0'
|
||||
|
||||
jobs:
|
||||
analyze:
|
||||
name: Analyze
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
actions: read
|
||||
contents: read
|
||||
security-events: write
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
language: [ 'cpp' ]
|
||||
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
|
||||
# Learn more about CodeQL language support at https://git.io/codeql-language-support
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v3
|
||||
|
||||
# Initializes the CodeQL tools for scanning.
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v2
|
||||
with:
|
||||
languages: ${{ matrix.language }}
|
||||
# If you wish to specify custom queries, you can do so here or in a config file.
|
||||
# By default, queries listed here will override any specified in a config file.
|
||||
# Prefix the list here with "+" to use these queries and those in the config file.
|
||||
# queries: ./path/to/local/query, your-org/your-repo/queries@main
|
||||
|
||||
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
||||
# If this step fails, then you should remove it and run the build manually (see below)
|
||||
# - name: Autobuild
|
||||
# uses: github/codeql-action/autobuild@v2
|
||||
|
||||
# ℹ️ Command-line programs to run using the OS shell.
|
||||
# 📚 https://git.io/JvXDl
|
||||
|
||||
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
|
||||
# and modify them (or add more) to build your code if your project
|
||||
# uses a compiled language
|
||||
|
||||
- run: |
|
||||
cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_STRICT_MODE=ON .
|
||||
make -j
|
||||
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@v2
|
||||
35
.github/workflows/extrabuild.yml
vendored
Normal file
35
.github/workflows/extrabuild.yml
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
name: Build and unit tests that are more time consuming
|
||||
permissions: read-all
|
||||
|
||||
on:
|
||||
# For manual tests.
|
||||
workflow_dispatch:
|
||||
pull_request:
|
||||
types:
|
||||
- closed
|
||||
schedule:
|
||||
- cron: "30 20 * * *"
|
||||
|
||||
jobs:
|
||||
build-linux-s390x:
|
||||
name: Build Linux on s390x arch and run unit tests
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: uraimo/run-on-arch-action@v2
|
||||
name: Run commands
|
||||
id: runcmd
|
||||
with:
|
||||
arch: s390x
|
||||
distro: ubuntu_latest
|
||||
install: |
|
||||
apt-get update -q -y
|
||||
apt-get -y install cmake
|
||||
apt-get -y install make
|
||||
apt-get -y install g++
|
||||
run: |
|
||||
lscpu | grep Endian
|
||||
cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release
|
||||
make -j
|
||||
./flattests
|
||||
|
||||
7
.github/workflows/label.yml
vendored
7
.github/workflows/label.yml
vendored
@@ -6,11 +6,16 @@
|
||||
# https://github.com/actions/labeler
|
||||
|
||||
name: Labeler
|
||||
permissions: read-all
|
||||
|
||||
on: [pull_request_target]
|
||||
|
||||
jobs:
|
||||
label:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
pull-requests: write
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
|
||||
16
.github/workflows/main.yml
vendored
16
.github/workflows/main.yml
vendored
@@ -1,5 +1,15 @@
|
||||
name: CIFuzz
|
||||
on: [pull_request]
|
||||
name: OSS-Fuzz
|
||||
permissions: read-all
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
paths:
|
||||
- include/**
|
||||
- src/**
|
||||
- tests/**.cpp
|
||||
- tests/**.h
|
||||
jobs:
|
||||
Fuzzing:
|
||||
runs-on: ubuntu-latest
|
||||
@@ -15,7 +25,7 @@ jobs:
|
||||
with:
|
||||
oss-fuzz-project-name: 'flatbuffers'
|
||||
language: c++
|
||||
fuzz-seconds: 600
|
||||
fuzz-seconds: 60
|
||||
- name: Upload Crash
|
||||
uses: actions/upload-artifact@v1
|
||||
if: failure() && steps.build.outcome == 'success'
|
||||
|
||||
106
.github/workflows/release.yml
vendored
Normal file
106
.github/workflows/release.yml
vendored
Normal file
@@ -0,0 +1,106 @@
|
||||
name: Release
|
||||
permissions: read-all
|
||||
|
||||
on:
|
||||
# For manual tests.
|
||||
workflow_dispatch:
|
||||
release:
|
||||
types: [created]
|
||||
|
||||
jobs:
|
||||
publish-npm:
|
||||
name: Publish NPM
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: '16.x'
|
||||
registry-url: 'https://registry.npmjs.org'
|
||||
|
||||
- run: npm publish
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
|
||||
publish-pypi:
|
||||
name: Publish PyPi
|
||||
runs-on: ubuntu-latest
|
||||
defaults:
|
||||
run:
|
||||
working-directory: ./python
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: '3.10'
|
||||
|
||||
- name: Install Dependencies
|
||||
run: |
|
||||
python3 -m pip install --upgrade pip
|
||||
python3 -m pip install setuptools wheel twine
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
python3 setup.py sdist bdist_wheel
|
||||
|
||||
- name: Upload to PyPi
|
||||
run: |
|
||||
python3 -m twine upload dist/*
|
||||
env:
|
||||
TWINE_USERNAME: __token__
|
||||
TWINE_PASSWORD: ${{ secrets.TWINE_TOKEN }}
|
||||
|
||||
publish-nuget:
|
||||
name: Publish NuGet
|
||||
runs-on: windows-latest
|
||||
defaults:
|
||||
run:
|
||||
working-directory: ./net/flatbuffers
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-dotnet@v3
|
||||
with:
|
||||
dotnet-version: '6.0.x'
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
dotnet build Google.FlatBuffers.csproj -c Release
|
||||
|
||||
- name: Pack
|
||||
run: |
|
||||
dotnet pack Google.FlatBuffers.csproj -c Release
|
||||
|
||||
- name: Upload to NuGet
|
||||
run: |
|
||||
dotnet nuget push .\bin\Release\Google.FlatBuffers.*.nupkg -k ${{ secrets.NUGET_API_KEY }} -s https://api.nuget.org/v3/index.json
|
||||
|
||||
publish-maven:
|
||||
name: Publish Maven
|
||||
runs-on: ubuntu-latest
|
||||
defaults:
|
||||
run:
|
||||
working-directory: ./java
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Set up Maven Central Repository
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
java-version: '11'
|
||||
distribution: 'adopt'
|
||||
cache: 'maven'
|
||||
server-id: ossrh
|
||||
server-username: OSSRH_USERNAME
|
||||
server-password: OSSRH_PASSWORD
|
||||
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
|
||||
gpg-passphrase: MAVEN_GPG_PASSPHRASE # this needs to be an env var
|
||||
|
||||
- name: Publish Maven
|
||||
run: mvn --batch-mode clean deploy
|
||||
env:
|
||||
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
|
||||
OSSRH_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
|
||||
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
|
||||
|
||||
|
||||
|
||||
55
.github/workflows/scorecards.yml
vendored
Normal file
55
.github/workflows/scorecards.yml
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
name: Scorecards supply-chain security
|
||||
on:
|
||||
# Only the default branch is supported.
|
||||
branch_protection_rule:
|
||||
schedule:
|
||||
- cron: '21 2 * * 5'
|
||||
push:
|
||||
branches: [ master ]
|
||||
|
||||
# Declare default permissions as read only.
|
||||
permissions: read-all
|
||||
|
||||
jobs:
|
||||
analysis:
|
||||
name: Scorecards analysis
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
# Needed to upload the results to code-scanning dashboard.
|
||||
security-events: write
|
||||
actions: read
|
||||
contents: read
|
||||
|
||||
steps:
|
||||
- name: "Checkout code"
|
||||
uses: actions/checkout@a12a3943b4bdde767164f792f33f40b04645d846 # v3.0.0
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: "Run analysis"
|
||||
uses: ossf/scorecard-action@ce330fde6b1a5c9c75b417e7efc510b822a35564 # v1.1.2
|
||||
with:
|
||||
results_file: results.sarif
|
||||
results_format: sarif
|
||||
# Read-only PAT token. To create it,
|
||||
# follow the steps in https://github.com/ossf/scorecard-action#pat-token-creation.
|
||||
repo_token: ${{ secrets.SCORECARD_READ_TOKEN }}
|
||||
# Publish the results to enable scorecard badges. For more details, see
|
||||
# https://github.com/ossf/scorecard-action#publishing-results.
|
||||
# For private repositories, `publish_results` will automatically be set to `false`,
|
||||
# regardless of the value entered here.
|
||||
publish_results: true
|
||||
|
||||
# Upload the results as artifacts (optional).
|
||||
- name: "Upload artifact"
|
||||
uses: actions/upload-artifact@6673cd052c4cd6fcf4b4e6e60ea986c889389535 # v3.0.0
|
||||
with:
|
||||
name: SARIF file
|
||||
path: results.sarif
|
||||
retention-days: 5
|
||||
|
||||
# Upload the results to GitHub's code scanning dashboard.
|
||||
- name: "Upload to code-scanning"
|
||||
uses: github/codeql-action/upload-sarif@5f532563584d71fdef14ee64d17bafb34f751ce5 # v1.0.26
|
||||
with:
|
||||
sarif_file: results.sarif
|
||||
1
.github/workflows/stale.yml
vendored
1
.github/workflows/stale.yml
vendored
@@ -1,4 +1,5 @@
|
||||
name: Mark stale issues and pull requests
|
||||
permissions: read-all
|
||||
|
||||
on:
|
||||
schedule:
|
||||
|
||||
8
.gitignore
vendored
8
.gitignore
vendored
@@ -54,6 +54,8 @@ flathash
|
||||
flathash.exe
|
||||
flattests
|
||||
flattests.exe
|
||||
flattests_cpp17
|
||||
flattests_cpp17.exe
|
||||
flatsamplebinary
|
||||
flatsamplebinary.exe
|
||||
flatsampletext
|
||||
@@ -76,7 +78,7 @@ tests/php/
|
||||
CMakeLists.txt.user
|
||||
CMakeScripts/**
|
||||
CTestTestfile.cmake
|
||||
FlatbuffersConfigVersion.cmake
|
||||
flatbuffers-config-version.cmake
|
||||
FlatBuffers.cbp
|
||||
build/Xcode/FlatBuffers.xcodeproj/project.xcworkspace/**
|
||||
build/Xcode/FlatBuffers.xcodeproj/xcuserdata/**
|
||||
@@ -86,6 +88,7 @@ java/*.iml
|
||||
.idea
|
||||
*.iml
|
||||
target
|
||||
java/target
|
||||
**/*.pyc
|
||||
build/VS2010/FlatBuffers.sdf
|
||||
build/VS2010/FlatBuffers.opensdf
|
||||
@@ -146,4 +149,5 @@ flatbuffers.pc
|
||||
**/html/**
|
||||
**/latex/**
|
||||
# https://cmake.org/cmake/help/latest/module/FetchContent.html#variable:FETCHCONTENT_BASE_DIR
|
||||
_deps/
|
||||
cmake-build-debug/
|
||||
_deps/
|
||||
|
||||
215
.travis.yml
215
.travis.yml
@@ -1,215 +0,0 @@
|
||||
env:
|
||||
global:
|
||||
# Set at the root level as this is ignored when set under matrix.env.
|
||||
- GCC_VERSION="4.9"
|
||||
# Fail on first error if UBSAN or ASAN enabled for a target
|
||||
- UBSAN_OPTIONS=halt_on_error=1
|
||||
- ASAN_OPTIONS=halt_on_error=1
|
||||
# Travis machines have 2 cores
|
||||
- JOBS=2
|
||||
- MAKEFLAGS="-j 2"
|
||||
|
||||
conan-linux: &conan-linux
|
||||
os: linux
|
||||
dist: xenial
|
||||
language: python
|
||||
python: "3.7"
|
||||
services:
|
||||
- docker
|
||||
install:
|
||||
- ./conan/travis/install.sh
|
||||
script:
|
||||
- ./conan/travis/build.sh
|
||||
if: tag IS present
|
||||
|
||||
conan-linux-master: &conan-linux-master
|
||||
os: linux
|
||||
dist: xenial
|
||||
language: python
|
||||
python: "3.7"
|
||||
services:
|
||||
- docker
|
||||
install:
|
||||
- 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then bash ./conan/travis/install.sh; fi'
|
||||
script:
|
||||
- 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then bash ./conan/travis/build.sh; fi'
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
|
||||
conan-osx: &conan-osx
|
||||
os: osx
|
||||
language: generic
|
||||
install:
|
||||
- ./conan/travis/install.sh
|
||||
script:
|
||||
- ./conan/travis/build.sh
|
||||
if: tag IS present
|
||||
|
||||
matrix:
|
||||
include:
|
||||
#- language: python
|
||||
# python: "2.7"
|
||||
# install:
|
||||
# - "pip install wheel twine"
|
||||
# script:
|
||||
# - "cd python/"
|
||||
# - 'VERSION="$TRAVIS_TAG" python setup.py sdist bdist_wheel'
|
||||
# - "cd ../"
|
||||
# deploy:
|
||||
# # Checkpointed release builds.
|
||||
# - provider: script
|
||||
# script: .travis/deploy-python.sh
|
||||
# skip_cleanup: true
|
||||
# on:
|
||||
# tags: true
|
||||
# # all_branches must be set with tags: true. See below post:
|
||||
# # https://stackoverflow.com/a/27775257/1076585
|
||||
# all_branches: true
|
||||
# # Produce a new build for the cutting edge when master changes.
|
||||
# - provider: script
|
||||
# script: .travis/deploy-python.sh
|
||||
# skip_cleanup: true
|
||||
# on:
|
||||
# branch: master
|
||||
- language: cpp
|
||||
os:
|
||||
- linux
|
||||
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- docker-ce
|
||||
script:
|
||||
- bash .travis/build-and-run-docker-test-containers.sh
|
||||
|
||||
- language: cpp
|
||||
os:
|
||||
- linux
|
||||
|
||||
compiler:
|
||||
- gcc
|
||||
|
||||
env:
|
||||
matrix:
|
||||
- BUILD_TYPE=Debug
|
||||
- BUILD_TYPE=Release
|
||||
|
||||
before_install:
|
||||
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test; fi
|
||||
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo apt-get update -qq; fi
|
||||
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo apt-get install -qq g++-$GCC_VERSION; fi
|
||||
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo apt-get install -qq gcc-$GCC_VERSION; fi
|
||||
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo ln -s -v -f $(which g++-$GCC_VERSION) /usr/bin/g++; fi
|
||||
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo ln -s -v -f $(which gcc-$GCC_VERSION) /usr/bin/gcc; fi
|
||||
|
||||
script:
|
||||
- pip install cmake
|
||||
- bash .travis/check-sources.sh
|
||||
- bash grpc/build_grpc.sh
|
||||
- cmake .
|
||||
-DCMAKE_BUILD_TYPE=$BUILD_TYPE
|
||||
-DFLATBUFFERS_BUILD_GRPCTEST=ON
|
||||
-DGRPC_INSTALL_PATH=$TRAVIS_BUILD_DIR/google/grpc/install
|
||||
-DPROTOBUF_DOWNLOAD_PATH=$TRAVIS_BUILD_DIR/google/grpc/third_party/protobuf
|
||||
-DFLATBUFFERS_CODE_SANITIZE=ON
|
||||
- cmake --build . --target all --clean-first -- -j${JOBS}
|
||||
- LD_LIBRARY_PATH=$TRAVIS_BUILD_DIR/google/grpc/install/lib ctest --extra-verbose --output-on-failure
|
||||
|
||||
- language: cpp
|
||||
os: osx
|
||||
osx_image: xcode9.3
|
||||
env:
|
||||
matrix:
|
||||
- BUILD_TYPE=Debug
|
||||
- BUILD_TYPE=Release
|
||||
|
||||
script:
|
||||
- pip install --user cmake
|
||||
- mkdir ~/cmake_path
|
||||
- ln -s $(find ~/Library/Python -name cmake -type f | head -n 1) ~/cmake_path/cmake
|
||||
- ln -s $(find ~/Library/Python -name ctest -type f | head -n 1) ~/cmake_path/ctest
|
||||
- export PATH=~/cmake_path:${PATH}
|
||||
- bash grpc/build_grpc.sh
|
||||
- cmake .
|
||||
-DCMAKE_BUILD_TYPE=$BUILD_TYPE
|
||||
-DFLATBUFFERS_BUILD_GRPCTEST=ON
|
||||
-DGRPC_INSTALL_PATH=$TRAVIS_BUILD_DIR/google/grpc/install
|
||||
-DPROTOBUF_DOWNLOAD_PATH=$TRAVIS_BUILD_DIR/google/grpc/third_party/protobuf
|
||||
-DFLATBUFFERS_CODE_SANITIZE=ON
|
||||
- cmake --build . -- -j${JOBS}
|
||||
- DYLD_LIBRARY_PATH=$TRAVIS_BUILD_DIR/google/grpc/install/lib ctest --extra-verbose --output-on-failure
|
||||
|
||||
- <<: *conan-linux-master
|
||||
env: CONAN_GCC_VERSIONS=8 CONAN_DOCKER_IMAGE=conanio/gcc8
|
||||
- <<: *conan-linux
|
||||
env: CONAN_GCC_VERSIONS=4.9 CONAN_DOCKER_IMAGE=conanio/gcc49
|
||||
- <<: *conan-linux
|
||||
env: CONAN_GCC_VERSIONS=5 CONAN_DOCKER_IMAGE=conanio/gcc5
|
||||
- <<: *conan-linux
|
||||
env: CONAN_GCC_VERSIONS=6 CONAN_DOCKER_IMAGE=conanio/gcc6
|
||||
- <<: *conan-linux
|
||||
env: CONAN_GCC_VERSIONS=7 CONAN_DOCKER_IMAGE=conanio/gcc7
|
||||
- <<: *conan-linux
|
||||
env: CONAN_GCC_VERSIONS=8 CONAN_DOCKER_IMAGE=conanio/gcc8
|
||||
- <<: *conan-linux
|
||||
env: CONAN_GCC_VERSIONS=9 CONAN_DOCKER_IMAGE=conanio/gcc9
|
||||
- <<: *conan-linux
|
||||
env: CONAN_CLANG_VERSIONS=3.9 CONAN_DOCKER_IMAGE=conanio/clang39
|
||||
- <<: *conan-linux
|
||||
env: CONAN_CLANG_VERSIONS=4.0 CONAN_DOCKER_IMAGE=conanio/clang40
|
||||
- <<: *conan-linux
|
||||
env: CONAN_CLANG_VERSIONS=5.0 CONAN_DOCKER_IMAGE=conanio/clang50
|
||||
- <<: *conan-linux
|
||||
env: CONAN_CLANG_VERSIONS=6.0 CONAN_DOCKER_IMAGE=conanio/clang60
|
||||
- <<: *conan-linux
|
||||
env: CONAN_CLANG_VERSIONS=7.0 CONAN_DOCKER_IMAGE=conanio/clang7
|
||||
- <<: *conan-linux
|
||||
env: CONAN_CLANG_VERSIONS=8 CONAN_DOCKER_IMAGE=conanio/clang8
|
||||
- <<: *conan-osx
|
||||
osx_image: xcode7.3
|
||||
env: CONAN_APPLE_CLANG_VERSIONS=7.3
|
||||
- <<: *conan-osx
|
||||
osx_image: xcode8.3
|
||||
env: CONAN_APPLE_CLANG_VERSIONS=8.1
|
||||
- <<: *conan-osx
|
||||
osx_image: xcode9
|
||||
env: CONAN_APPLE_CLANG_VERSIONS=9.0
|
||||
- <<: *conan-osx
|
||||
osx_image: xcode9.4
|
||||
env: CONAN_APPLE_CLANG_VERSIONS=9.1
|
||||
- <<: *conan-osx
|
||||
osx_image: xcode10.2
|
||||
env: CONAN_APPLE_CLANG_VERSIONS=10.0
|
||||
|
||||
- language: android
|
||||
sudo: true
|
||||
dist: trusty
|
||||
android:
|
||||
components:
|
||||
- tools
|
||||
- platform-tools
|
||||
- extra-android-m2repository
|
||||
licenses:
|
||||
- 'android-sdk-preview-license-52d11cd2'
|
||||
- 'android-sdk-license-.+'
|
||||
- 'google-gdk-license-.+'
|
||||
compiler:
|
||||
- gcc
|
||||
before_install:
|
||||
- echo y | sdkmanager "platforms;android-30"
|
||||
- echo y | sdkmanager "build-tools;30.0.2"
|
||||
- echo y | sdkmanager "ndk-bundle"
|
||||
- echo y | sdkmanager "cmake;3.6.4111459"
|
||||
script:
|
||||
- cmake -DFLATBUFFERS_BUILD_TESTS=OFF -DFLATBUFFERS_BUILD_FLATLIB=OFF -DFLATBUFFERS_BUILD_FLATHASH=OFF .; make; export PATH="$PATH:${PWD}"
|
||||
- cd android; ./gradlew clean build
|
||||
|
||||
- language: generic
|
||||
if: type IN (pull_request)
|
||||
os: linux
|
||||
install:
|
||||
- bash .travis/format_install.sh
|
||||
|
||||
script:
|
||||
- bash .travis/format_check.sh
|
||||
@@ -1,45 +0,0 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Copyright 2018 Google Inc. All rights reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
set -e
|
||||
|
||||
docker build -t build_cpp_image -f tests/docker/Dockerfile.testing.cpp.debian_buster .
|
||||
# Run tests with sanitizers (--cap-add SYS_PTRACE), both GCC and Clang.
|
||||
cpp_test_args="--cap-add SYS_PTRACE build_cpp_image sh ./tests/docker/cpp_test.run.sh Debug"
|
||||
docker run --rm $cpp_test_args
|
||||
docker run --rm --env CC=/usr/bin/clang --env CXX=/usr/bin/clang++ $cpp_test_args
|
||||
# Build flatc on debian once to speed up the test loop below.
|
||||
docker run --name flatc_container build_cpp_image sh ./tests/docker/build_flatc.run.sh Debug
|
||||
# All dependent dockers refer to 'flatc_debian_stretch'.
|
||||
docker cp flatc_container:/flatbuffers/flatc flatc_debian_stretch
|
||||
|
||||
for f in $(ls tests/docker/languages | sort)
|
||||
do
|
||||
# docker pull sometimes fails for unknown reasons, probably travisci-related. this retries the pull we need a few times.
|
||||
REQUIRED_BASE_IMAGE=$(cat tests/docker/languages/${f} | head -n 1 | awk ' { print $2 } ')
|
||||
|
||||
set +e
|
||||
n=0
|
||||
until [ $n -ge 5 ]
|
||||
do
|
||||
docker pull $REQUIRED_BASE_IMAGE && break
|
||||
n=$[$n+1]
|
||||
sleep 1
|
||||
done
|
||||
set -e
|
||||
|
||||
docker build -t $(echo ${f} | cut -f 3- -d .) -f tests/docker/languages/${f} .
|
||||
echo "TEST OK: ${f}"
|
||||
done
|
||||
@@ -1,33 +0,0 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Copyright 2018 Google Inc. All rights reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
set -e
|
||||
|
||||
if [ -n "$1" ]; then
|
||||
scan_dir="$1"
|
||||
else
|
||||
scan_dir="$( pwd )"
|
||||
fi
|
||||
|
||||
py_checker="$0.py"
|
||||
|
||||
echo "scan root directory = '$scan_dir'"
|
||||
python3 --version
|
||||
# Scan recursively and search all *.cpp and *.h files using regex patterns.
|
||||
# Assume that script running from a root of Flatbuffers working dir.
|
||||
python3 $py_checker "ascii" "$scan_dir/include" "\.h$"
|
||||
python3 $py_checker "ascii" "$scan_dir/src" "\.cpp$"
|
||||
python3 $py_checker "ascii" "$scan_dir/tests" "\.h$"
|
||||
python3 $py_checker "utf-8" "$scan_dir/tests" "\.cpp$"
|
||||
@@ -1,35 +0,0 @@
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
|
||||
def check_encoding(encoding, scan_dir, regex_pattern):
|
||||
fname = None
|
||||
try:
|
||||
assert encoding in ['ascii', 'utf-8'], "unexpected encoding"
|
||||
cmp = re.compile(regex_pattern)
|
||||
for root, dirs, files in os.walk(scan_dir):
|
||||
fname = root
|
||||
cmp_list = [f for f in files if cmp.search(f) is not None]
|
||||
for f in cmp_list:
|
||||
fname = os.path.join(root, f)
|
||||
with open(fname, mode='rb') as test_file:
|
||||
btext = test_file.read()
|
||||
# check encoding
|
||||
btext.decode(encoding=encoding, errors="strict")
|
||||
if encoding == "utf-8" and btext.startswith(b'\xEF\xBB\xBF'):
|
||||
raise ValueError("unexpected BOM in file")
|
||||
# check LF line endings
|
||||
LF = btext.count(b'\n')
|
||||
CR = btext.count(b'\r')
|
||||
if CR!=0:
|
||||
raise ValueError("invalid line endings: LF({})/CR({})".format(LF, CR))
|
||||
except Exception as err:
|
||||
print("ERROR with [{}]: {}".format(fname, err))
|
||||
return -1
|
||||
else:
|
||||
return 0
|
||||
|
||||
if __name__ == "__main__":
|
||||
# python check-sources.sh.py 'ascii' '.' '.*\.(cpp|h)$'
|
||||
res = check_encoding(sys.argv[1], sys.argv[2], sys.argv[3])
|
||||
sys.exit(0 if res == 0 else -1)
|
||||
@@ -1,12 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
PROD_REPOSITORY="https://upload.pypi.org/legacy/"
|
||||
TEST_REPOSITORY="https://test.pypi.org/legacy/"
|
||||
|
||||
twine upload \
|
||||
--username "$PYPI_USERNAME" \
|
||||
--password "$PYPI_PASSWORD" \
|
||||
--repository-url "$PROD_REPOSITORY" \
|
||||
"$DIR/../python/dist/"*
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Copyright 2021 Google Inc. All rights reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
set -e
|
||||
|
||||
# HACKY solution to make nodejs work.
|
||||
source ~/.nvm/nvm.sh
|
||||
nvm alias default node
|
||||
nvm use default
|
||||
|
||||
sh scripts/clang-format-git.sh
|
||||
|
||||
# Check formatting for go lang
|
||||
|
||||
cd go
|
||||
gofmt -w .
|
||||
cd ..
|
||||
cd grpc/examples/go
|
||||
sh format.sh
|
||||
cd ../../..
|
||||
|
||||
node_modules/.bin/eslint ts/** --ext .ts --quiet --fix
|
||||
|
||||
#PYTHON IS DISABLED UNTIL WE CREATE A .pylintrc FILE FOR IT
|
||||
pylint python/** --disable=all
|
||||
|
||||
swiftformat --config swift.swiftformat .
|
||||
|
||||
|
||||
if ! git diff --quiet; then
|
||||
echo >&2
|
||||
echo "ERROR: ********************************************************" >&2
|
||||
echo "ERROR: The following differences were found after running" >&2
|
||||
echo "ERROR: .travis/format_check.sh script. Maybe you forgot to format" >&2
|
||||
echo "ERROR: the code after making changes? please check Formatters.md" >&2
|
||||
echo "ERROR: ********************************************************" >&2
|
||||
echo >&2
|
||||
git diff --binary --exit-code
|
||||
fi
|
||||
@@ -1,90 +0,0 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Copyright 2020 Google Inc. All rights reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
set -e
|
||||
set -x
|
||||
|
||||
# install devtools
|
||||
install_languages() {
|
||||
sudo apt update
|
||||
|
||||
# Install nodeJS and yarn
|
||||
wget https://raw.githubusercontent.com/creationix/nvm/v0.31.0/nvm.sh -O ~/.nvm/nvm.sh
|
||||
source ~/.nvm/nvm.sh
|
||||
nvm install node
|
||||
node --version
|
||||
curl -o- -L https://yarnpkg.com/install.sh | bash
|
||||
export PATH="$HOME/.yarn/bin:$PATH"
|
||||
yarn config set prefix ~/.yarn -g
|
||||
export PATH="$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$PATH"
|
||||
|
||||
# Install swift
|
||||
sudo apt-get install \
|
||||
binutils \
|
||||
git \
|
||||
libc6-dev \
|
||||
libcurl3 \
|
||||
libedit2 \
|
||||
libgcc-5-dev \
|
||||
libpython2.7 \
|
||||
libsqlite3-0 \
|
||||
libstdc++-5-dev \
|
||||
libxml2 \
|
||||
pkg-config \
|
||||
tzdata \
|
||||
zlib1g-dev
|
||||
|
||||
SWIFT_URL=https://swift.org/builds/swift-5.3.1-release/ubuntu1604/swift-5.3.1-RELEASE/swift-5.3.1-RELEASE-ubuntu16.04.tar.gz
|
||||
curl -fSsL "$SWIFT_URL" -o swift.tar.gz
|
||||
|
||||
mkdir ~/swiftbuild
|
||||
tar -xvzf swift.tar.gz -C ~/swiftbuild
|
||||
|
||||
export PATH="~/swiftbuild/swift-5.3.1-RELEASE-ubuntu16.04/usr/bin:$PATH"
|
||||
|
||||
|
||||
mkdir ~/gobuild
|
||||
wget -c https://golang.org/dl/go1.15.2.linux-amd64.tar.gz
|
||||
tar -xvzf go1.15.2.linux-amd64.tar.gz -C ~/gobuild
|
||||
|
||||
export PATH="~/gobuild/go/bin:$PATH"
|
||||
|
||||
swift --version
|
||||
go version
|
||||
yarn -v
|
||||
node -v
|
||||
}
|
||||
|
||||
install_formatters() {
|
||||
# installing swift formatter
|
||||
git clone --depth 1 --branch 0.47.4 https://github.com/nicklockwood/SwiftFormat.git
|
||||
cd SwiftFormat
|
||||
swift build -c release
|
||||
sudo cp .build/release/swiftformat /usr/local/bin/swiftformat
|
||||
cd ..
|
||||
|
||||
which yarn
|
||||
which node
|
||||
yarn -v
|
||||
node -v
|
||||
|
||||
yarn install
|
||||
pip install pylint
|
||||
}
|
||||
|
||||
install_languages
|
||||
export PATH="~/swift/swift/usr/bin:$PATH"
|
||||
install_formatters
|
||||
@@ -8,6 +8,7 @@ package(
|
||||
|
||||
exports_files([
|
||||
"LICENSE",
|
||||
"tsconfig.json",
|
||||
])
|
||||
|
||||
config_setting(
|
||||
@@ -40,14 +41,15 @@ filegroup(
|
||||
"include/flatbuffers/allocator.h",
|
||||
"include/flatbuffers/array.h",
|
||||
"include/flatbuffers/base.h",
|
||||
"include/flatbuffers/bfbs_generator.h",
|
||||
"include/flatbuffers/buffer.h",
|
||||
"include/flatbuffers/buffer_ref.h",
|
||||
"include/flatbuffers/code_generator.h",
|
||||
"include/flatbuffers/code_generators.h",
|
||||
"include/flatbuffers/default_allocator.h",
|
||||
"include/flatbuffers/detached_buffer.h",
|
||||
"include/flatbuffers/flatbuffer_builder.h",
|
||||
"include/flatbuffers/flatbuffers.h",
|
||||
"include/flatbuffers/flex_flat_util.h",
|
||||
"include/flatbuffers/flexbuffers.h",
|
||||
"include/flatbuffers/grpc.h",
|
||||
"include/flatbuffers/hash.h",
|
||||
@@ -79,6 +81,7 @@ cc_library(
|
||||
# Public flatc compiler.
|
||||
cc_binary(
|
||||
name = "flatc",
|
||||
data = ["//reflection:reflection_fbs_schema"],
|
||||
deps = [
|
||||
"//src:flatc",
|
||||
],
|
||||
|
||||
103
CHANGELOG.md
Normal file
103
CHANGELOG.md
Normal file
@@ -0,0 +1,103 @@
|
||||
# Flatbuffers Change Log
|
||||
|
||||
All major or breaking changes will be documented in this file, as well as any
|
||||
new features that should be highlighted. Minor fixes or improvements are not
|
||||
necessarily listed.
|
||||
|
||||
## [23.3.3 (Mar 3 2023)](https://github.com/google/flatbuffers/releases/tag/v23.3.3)
|
||||
|
||||
* Refactoring of `flatc` generators to use an interface (#7797).
|
||||
|
||||
* Removed legacy cmake support and set min to 3.8 (#7801).
|
||||
|
||||
## [23.1.21 (Jan 21 2023)](https://github.com/google/flatbuffers/releases/tag/v23.1.20)
|
||||
|
||||
* Reworked entry points for Typescript/Javascript and compatibility for single
|
||||
file build (#7510)
|
||||
|
||||
## [23.1.20 (Jan 20 2023)](https://github.com/google/flatbuffers/releases/tag/v23.1.20)
|
||||
|
||||
* Removed go.mod files after some versioning issues were being report (#7780).
|
||||
|
||||
## [23.1.4 (Jan 4 2023)](https://github.com/google/flatbuffers/releases/tag/v23.1.4)
|
||||
|
||||
* Major release! Just kidding, we are continuing the
|
||||
[versioning scheme](https://github.com/google/flatbuffers/wiki/Versioning) of
|
||||
using a date to signify releases. This results in the first release of the new
|
||||
year to bump the tradition major version field.
|
||||
|
||||
* Go minimum version is now 1.19 (#7720) with the addition of Go modules.
|
||||
|
||||
* Added CI support for Big Endian regression testing (#7707).
|
||||
|
||||
* Fixed `getFullyQualifiedName` in typescript to return name delimited by '.'
|
||||
instead of '_' (#7730).
|
||||
|
||||
* Fixed the versioning scheme to not include leading zeros which are not
|
||||
consistently handled by every package manager. Only the last release
|
||||
(12.12.06) should have suffered from this.
|
||||
|
||||
## [22.12.06 (Dec 06 2022)](https://github.com/google/flatbuffers/releases/tag/v22.12.06)
|
||||
|
||||
* Bug fixing release, no major changes.
|
||||
|
||||
## [22.10.25 (Oct 25 2022)](https://github.com/google/flatbuffers/releases/tag/v22.10.25)
|
||||
|
||||
* Added Nim language support with generator and runtime libraries (#7534).
|
||||
|
||||
## [22.9.29 (Sept 29 2022)](https://github.com/google/flatbuffers/releases/tag/v22.9.29)
|
||||
|
||||
* Rust soundness fixes to avoid the crate from bing labelled unsafe (#7518).
|
||||
|
||||
## [22.9.24 (Sept 24 2022)](https://github.com/google/flatbuffers/releases/tag/v22.9.24)
|
||||
|
||||
* 20 Major releases in a row? Nope, we switched to a new
|
||||
[versioning scheme](https://github.com/google/flatbuffers/wiki/Versioning)
|
||||
that is based on date.
|
||||
|
||||
* Python supports fixed size arrays now (#7529).
|
||||
|
||||
* Behavior change in how C++ object API uses `UnPackTo`. The original intent of
|
||||
this was to reduce allocations by reusing an existing object to pack data
|
||||
into. At some point, this logic started to merge the states of the two objects
|
||||
instead of clearing the state of the packee. This change goes back to the
|
||||
original intention, the packed object is cleared when getting data packed into
|
||||
it (#7527).
|
||||
|
||||
* Fixed a bug in C++ alignment that was using `sizeof()` instead of the intended
|
||||
`AlignOf()` for structs (#7520).
|
||||
|
||||
* C# has an
|
||||
[official Nuget package](https://www.nuget.org/packages/Google.FlatBuffers)
|
||||
now (#7496).
|
||||
|
||||
## 2.0.8 (Aug 29 2022)
|
||||
|
||||
* Fix for `--keep-prefix` the was generating the wrong include statements for
|
||||
C++ (#7469). The bug was introduced in 2.0.7.
|
||||
|
||||
* Added the `Verifier::Options` option struct to allow specifying runtime
|
||||
configuration settings for the verifier (#7489). This allows to skip verifying
|
||||
nested flatbuffers, a on-by-default change that was introduced in 2.0.7. This
|
||||
deprecates the existing `Verifier` constructor, which may be removed in a
|
||||
future version.
|
||||
|
||||
* Refactor of `tests/test.cpp` that lead to ~10% speedup in compilation of the
|
||||
entire project (#7487).
|
||||
|
||||
## 2.0.7 (Aug 22 2022)
|
||||
|
||||
* This is the first version with an explicit change log, so all the previous
|
||||
features will not be listed.
|
||||
|
||||
* Verifier now checks that buffers are at least the minimum size required to be
|
||||
a flatbuffers (12 bytes). This includes nested flatbuffers, which previously
|
||||
could be declared valid at size 0.
|
||||
|
||||
* Annotated binaries. Given a flatbuffer binary and a schema (or binary schema)
|
||||
one can generate an annotated flatbuffer (.afb) to describe each byte in the
|
||||
binary with schema metadata and value.
|
||||
|
||||
* First binary schema generator (Lua) to generate Lua code via a .bfbs file.
|
||||
This is mostly an implementation detail of flatc internals, but will be slowly
|
||||
applied to the other language generators.
|
||||
@@ -157,6 +157,10 @@ endfunction()
|
||||
# other flagc flags using the FLAGS option to change the behavior of the flatc
|
||||
# tool.
|
||||
#
|
||||
# When the target_link_libraries is done within a different directory than
|
||||
# flatbuffers_generate_headers is called, then the target should also be dependent
|
||||
# the custom generation target called GENERATE_<TARGET>.
|
||||
#
|
||||
# Arguments:
|
||||
# TARGET: The name of the target to generate.
|
||||
# SCHEMAS: The list of schema files to generate code for.
|
||||
@@ -182,6 +186,9 @@ endfunction()
|
||||
# target_link_libraries(MyExecutableTarget
|
||||
# PRIVATE my_generated_headers_target
|
||||
# )
|
||||
#
|
||||
# Optional (only needed within different directory):
|
||||
# add_dependencies(app GENERATE_my_generated_headers_target)
|
||||
function(flatbuffers_generate_headers)
|
||||
# Parse function arguments.
|
||||
set(options)
|
||||
@@ -226,6 +233,8 @@ function(flatbuffers_generate_headers)
|
||||
"--include-prefix" ${FLATBUFFERS_GENERATE_HEADERS_INCLUDE_PREFIX})
|
||||
endif()
|
||||
|
||||
set(generated_custom_commands)
|
||||
|
||||
# Create rules to generate the code for each schema.
|
||||
foreach(schema ${FLATBUFFERS_GENERATE_HEADERS_SCHEMAS})
|
||||
get_filename_component(filename ${schema} NAME_WE)
|
||||
@@ -254,6 +263,7 @@ function(flatbuffers_generate_headers)
|
||||
COMMENT "Building ${schema} flatbuffers...")
|
||||
list(APPEND all_generated_header_files ${generated_include})
|
||||
list(APPEND all_generated_source_files ${generated_source_file})
|
||||
list(APPEND generated_custom_commands "${generated_include}" "${generated_source_file}")
|
||||
|
||||
# Geneate the binary flatbuffers schemas if instructed to.
|
||||
if (NOT ${FLATBUFFERS_GENERATE_HEADERS_BINARY_SCHEMAS_DIR} STREQUAL "")
|
||||
@@ -267,10 +277,17 @@ function(flatbuffers_generate_headers)
|
||||
${schema}
|
||||
DEPENDS ${FLATC_TARGET} ${schema}
|
||||
WORKING_DIRECTORY "${working_dir}")
|
||||
list(APPEND generated_custom_commands "${binary_schema}")
|
||||
list(APPEND all_generated_binary_files ${binary_schema})
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
# Create an additional target as add_custom_command scope is only within same directory (CMakeFile.txt)
|
||||
set(generate_target GENERATE_${FLATBUFFERS_GENERATE_HEADERS_TARGET})
|
||||
add_custom_target(${generate_target} ALL
|
||||
DEPENDS ${generated_custom_commands}
|
||||
COMMENT "Generating flatbuffer target ${FLATBUFFERS_GENERATE_HEADERS_TARGET}")
|
||||
|
||||
# Set up interface library
|
||||
add_library(${FLATBUFFERS_GENERATE_HEADERS_TARGET} INTERFACE)
|
||||
target_sources(
|
||||
|
||||
@@ -1,774 +0,0 @@
|
||||
# This was the legacy <root>/CMakeLists.txt that supported cmake version 2.8.12.
|
||||
# It was originally copied on Jan 30 2022, and is conditionally included in the
|
||||
# current <root>/CMakeLists.txt if the cmake version used is older than the new
|
||||
# minimum version.
|
||||
#
|
||||
# Only add to this file to fix immediate issues or if a change cannot be made
|
||||
# <root>/CMakeList.txt in a compatible way.
|
||||
|
||||
if (POLICY CMP0048)
|
||||
cmake_policy(SET CMP0048 NEW)
|
||||
project(FlatBuffers
|
||||
DESCRIPTION "Flatbuffers serialization library"
|
||||
VERSION 2.0.0
|
||||
LANGUAGES CXX)
|
||||
else()
|
||||
project(FlatBuffers)
|
||||
endif (POLICY CMP0048)
|
||||
|
||||
include(CMake/Version.cmake)
|
||||
|
||||
# generate compile_commands.json
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
|
||||
# NOTE: Code coverage only works on Linux & OSX.
|
||||
option(FLATBUFFERS_CODE_COVERAGE "Enable the code coverage build option." OFF)
|
||||
option(FLATBUFFERS_BUILD_TESTS "Enable the build of tests and samples." ON)
|
||||
option(FLATBUFFERS_INSTALL "Enable the installation of targets." ON)
|
||||
option(FLATBUFFERS_BUILD_FLATLIB "Enable the build of the flatbuffers library"
|
||||
ON)
|
||||
option(FLATBUFFERS_BUILD_FLATC "Enable the build of the flatbuffers compiler"
|
||||
ON)
|
||||
option(FLATBUFFERS_STATIC_FLATC "Build flatbuffers compiler with -static flag"
|
||||
OFF)
|
||||
option(FLATBUFFERS_BUILD_FLATHASH "Enable the build of flathash" ON)
|
||||
option(FLATBUFFERS_BUILD_BENCHMARKS "Enable the build of flatbenchmark. \"
|
||||
Requires C++11."
|
||||
OFF)
|
||||
option(FLATBUFFERS_BUILD_GRPCTEST "Enable the build of grpctest" OFF)
|
||||
option(FLATBUFFERS_BUILD_SHAREDLIB
|
||||
"Enable the build of the flatbuffers shared library"
|
||||
OFF)
|
||||
option(FLATBUFFERS_LIBCXX_WITH_CLANG "Force libc++ when using Clang" ON)
|
||||
# NOTE: Sanitizer check only works on Linux & OSX (gcc & llvm).
|
||||
option(FLATBUFFERS_CODE_SANITIZE
|
||||
"Add '-fsanitize' flags to 'flattests' and 'flatc' targets."
|
||||
OFF)
|
||||
option(FLATBUFFERS_PACKAGE_REDHAT
|
||||
"Build an rpm using the 'package' target."
|
||||
OFF)
|
||||
option(FLATBUFFERS_PACKAGE_DEBIAN
|
||||
"Build an deb using the 'package' target."
|
||||
OFF)
|
||||
option(FLATBUFFERS_BUILD_CPP17
|
||||
"Enable the build of c++17 test target. \"
|
||||
Requirements: Clang6, GCC7, MSVC2017 (_MSC_VER >= 1914) or higher."
|
||||
OFF)
|
||||
option(FLATBUFFERS_BUILD_LEGACY
|
||||
"Run C++ code generator with '--cpp-std c++0x' switch."
|
||||
OFF)
|
||||
option(FLATBUFFERS_ENABLE_PCH
|
||||
"Enable precompile headers support for 'flatbuffers' and 'flatc'. \"
|
||||
Only work if CMake supports 'target_precompile_headers'. \"
|
||||
This can speed up compilation time."
|
||||
OFF)
|
||||
option(FLATBUFFERS_SKIP_MONSTER_EXTRA
|
||||
"Skip generating monster_extra.fbs that contains non-supported numerical\"
|
||||
types." OFF)
|
||||
option(FLATBUFFERS_OSX_BUILD_UNIVERSAL
|
||||
"Enable the build for multiple architectures on OS X (arm64, x86_64)."
|
||||
ON)
|
||||
|
||||
if(NOT FLATBUFFERS_BUILD_FLATC AND FLATBUFFERS_BUILD_TESTS)
|
||||
message(WARNING
|
||||
"Cannot build tests without building the compiler. Tests will be disabled.")
|
||||
set(FLATBUFFERS_BUILD_TESTS OFF)
|
||||
endif()
|
||||
|
||||
if(DEFINED FLATBUFFERS_MAX_PARSING_DEPTH)
|
||||
# Override the default recursion depth limit.
|
||||
add_definitions(-DFLATBUFFERS_MAX_PARSING_DEPTH=${FLATBUFFERS_MAX_PARSING_DEPTH})
|
||||
message(STATUS "FLATBUFFERS_MAX_PARSING_DEPTH: ${FLATBUFFERS_MAX_PARSING_DEPTH}")
|
||||
endif()
|
||||
|
||||
# Auto-detect locale-narrow 'strtod_l' and 'strtoull_l' functions.
|
||||
if(NOT DEFINED FLATBUFFERS_LOCALE_INDEPENDENT)
|
||||
include(CheckCXXSymbolExists)
|
||||
|
||||
set(FLATBUFFERS_LOCALE_INDEPENDENT 0)
|
||||
if(MSVC)
|
||||
check_cxx_symbol_exists(_strtof_l stdlib.h FLATBUFFERS_HAS_STRTOF_L)
|
||||
check_cxx_symbol_exists(_strtoui64_l stdlib.h FLATBUFFERS_HAS_STRTOULL_L)
|
||||
else()
|
||||
check_cxx_symbol_exists(strtof_l stdlib.h FLATBUFFERS_HAS_STRTOF_L)
|
||||
check_cxx_symbol_exists(strtoull_l stdlib.h FLATBUFFERS_HAS_STRTOULL_L)
|
||||
endif()
|
||||
if(FLATBUFFERS_HAS_STRTOF_L AND FLATBUFFERS_HAS_STRTOULL_L)
|
||||
set(FLATBUFFERS_LOCALE_INDEPENDENT 1)
|
||||
endif()
|
||||
endif()
|
||||
add_definitions(-DFLATBUFFERS_LOCALE_INDEPENDENT=$<BOOL:${FLATBUFFERS_LOCALE_INDEPENDENT}>)
|
||||
|
||||
set(FlatBuffers_Library_SRCS
|
||||
include/flatbuffers/allocator.h
|
||||
include/flatbuffers/array.h
|
||||
include/flatbuffers/base.h
|
||||
include/flatbuffers/bfbs_generator.h
|
||||
include/flatbuffers/buffer.h
|
||||
include/flatbuffers/buffer_ref.h
|
||||
include/flatbuffers/default_allocator.h
|
||||
include/flatbuffers/detached_buffer.h
|
||||
include/flatbuffers/flatbuffer_builder.h
|
||||
include/flatbuffers/flatbuffers.h
|
||||
include/flatbuffers/flexbuffers.h
|
||||
include/flatbuffers/hash.h
|
||||
include/flatbuffers/idl.h
|
||||
include/flatbuffers/minireflect.h
|
||||
include/flatbuffers/reflection.h
|
||||
include/flatbuffers/reflection_generated.h
|
||||
include/flatbuffers/registry.h
|
||||
include/flatbuffers/stl_emulation.h
|
||||
include/flatbuffers/string.h
|
||||
include/flatbuffers/struct.h
|
||||
include/flatbuffers/table.h
|
||||
include/flatbuffers/util.h
|
||||
include/flatbuffers/vector.h
|
||||
include/flatbuffers/vector_downward.h
|
||||
include/flatbuffers/verifier.h
|
||||
src/idl_parser.cpp
|
||||
src/idl_gen_text.cpp
|
||||
src/reflection.cpp
|
||||
src/util.cpp
|
||||
)
|
||||
|
||||
set(FlatBuffers_Compiler_SRCS
|
||||
${FlatBuffers_Library_SRCS}
|
||||
src/idl_gen_cpp.cpp
|
||||
src/idl_gen_csharp.cpp
|
||||
src/idl_gen_dart.cpp
|
||||
src/idl_gen_kotlin.cpp
|
||||
src/idl_gen_go.cpp
|
||||
src/idl_gen_java.cpp
|
||||
src/idl_gen_ts.cpp
|
||||
src/idl_gen_php.cpp
|
||||
src/idl_gen_python.cpp
|
||||
src/idl_gen_lobster.cpp
|
||||
src/idl_gen_lua.cpp
|
||||
src/idl_gen_rust.cpp
|
||||
src/idl_gen_fbs.cpp
|
||||
src/idl_gen_grpc.cpp
|
||||
src/idl_gen_json_schema.cpp
|
||||
src/idl_gen_swift.cpp
|
||||
src/flatc.cpp
|
||||
src/flatc_main.cpp
|
||||
src/bfbs_gen.h
|
||||
src/bfbs_gen_lua.h
|
||||
include/flatbuffers/code_generators.h
|
||||
src/bfbs_gen_lua.cpp
|
||||
src/code_generators.cpp
|
||||
grpc/src/compiler/schema_interface.h
|
||||
grpc/src/compiler/cpp_generator.h
|
||||
grpc/src/compiler/cpp_generator.cc
|
||||
grpc/src/compiler/go_generator.h
|
||||
grpc/src/compiler/go_generator.cc
|
||||
grpc/src/compiler/java_generator.h
|
||||
grpc/src/compiler/java_generator.cc
|
||||
grpc/src/compiler/python_generator.h
|
||||
grpc/src/compiler/python_generator.cc
|
||||
grpc/src/compiler/swift_generator.h
|
||||
grpc/src/compiler/swift_generator.cc
|
||||
grpc/src/compiler/ts_generator.h
|
||||
grpc/src/compiler/ts_generator.cc
|
||||
)
|
||||
|
||||
set(FlatHash_SRCS
|
||||
include/flatbuffers/hash.h
|
||||
src/flathash.cpp
|
||||
)
|
||||
|
||||
set(FlatBuffers_Tests_SRCS
|
||||
${FlatBuffers_Library_SRCS}
|
||||
src/idl_gen_fbs.cpp
|
||||
tests/test.cpp
|
||||
tests/test_assert.h
|
||||
tests/test_assert.cpp
|
||||
tests/test_builder.h
|
||||
tests/test_builder.cpp
|
||||
tests/native_type_test_impl.h
|
||||
tests/native_type_test_impl.cpp
|
||||
include/flatbuffers/code_generators.h
|
||||
src/code_generators.cpp
|
||||
# file generate by running compiler on tests/monster_test.fbs
|
||||
${CMAKE_CURRENT_BINARY_DIR}/tests/monster_test_generated.h
|
||||
# file generate by running compiler on namespace_test/namespace_test1.fbs
|
||||
${CMAKE_CURRENT_BINARY_DIR}/tests/namespace_test/namespace_test1_generated.h
|
||||
${CMAKE_CURRENT_BINARY_DIR}/tests/namespace_test/namespace_test2_generated.h
|
||||
# file generate by running compiler on union_vector/union_vector.fbs
|
||||
${CMAKE_CURRENT_BINARY_DIR}/tests/union_vector/union_vector_generated.h
|
||||
# file generate by running compiler on tests/arrays_test.fbs
|
||||
${CMAKE_CURRENT_BINARY_DIR}/tests/arrays_test_generated.h
|
||||
# file generate by running compiler on tests/native_type_test.fbs
|
||||
${CMAKE_CURRENT_BINARY_DIR}/tests/native_type_test_generated.h
|
||||
# file generate by running compiler on tests/monster_extra.fbs
|
||||
${CMAKE_CURRENT_BINARY_DIR}/tests/monster_extra_generated.h
|
||||
# file generate by running compiler on tests/monster_test.fbs
|
||||
${CMAKE_CURRENT_BINARY_DIR}/tests/monster_test_bfbs_generated.h
|
||||
# file generate by running compiler on tests/optional_scalars.fbs
|
||||
${CMAKE_CURRENT_BINARY_DIR}/tests/optional_scalars_generated.h
|
||||
)
|
||||
|
||||
set(FlatBuffers_Tests_CPP17_SRCS
|
||||
${FlatBuffers_Library_SRCS}
|
||||
tests/test_assert.h
|
||||
tests/test_assert.cpp
|
||||
tests/cpp17/test_cpp17.cpp
|
||||
# file generate by running compiler on tests/monster_test.fbs
|
||||
${CMAKE_CURRENT_BINARY_DIR}/tests/cpp17/generated_cpp17/monster_test_generated.h
|
||||
${CMAKE_CURRENT_BINARY_DIR}/tests/monster_test_generated.h
|
||||
${CMAKE_CURRENT_BINARY_DIR}/tests/cpp17/generated_cpp17/optional_scalars_generated.h
|
||||
${CMAKE_CURRENT_BINARY_DIR}/tests/optional_scalars_generated.h
|
||||
)
|
||||
|
||||
set(FlatBuffers_Sample_Binary_SRCS
|
||||
include/flatbuffers/flatbuffers.h
|
||||
samples/sample_binary.cpp
|
||||
# file generated by running compiler on samples/monster.fbs
|
||||
${CMAKE_CURRENT_BINARY_DIR}/samples/monster_generated.h
|
||||
)
|
||||
|
||||
set(FlatBuffers_Sample_Text_SRCS
|
||||
${FlatBuffers_Library_SRCS}
|
||||
samples/sample_text.cpp
|
||||
# file generated by running compiler on samples/monster.fbs
|
||||
${CMAKE_CURRENT_BINARY_DIR}/samples/monster_generated.h
|
||||
)
|
||||
|
||||
set(FlatBuffers_Sample_BFBS_SRCS
|
||||
${FlatBuffers_Library_SRCS}
|
||||
samples/sample_bfbs.cpp
|
||||
# file generated by running compiler on samples/monster.fbs
|
||||
${CMAKE_CURRENT_BINARY_DIR}/samples/monster_generated.h
|
||||
)
|
||||
|
||||
set(FlatBuffers_GRPCTest_SRCS
|
||||
include/flatbuffers/flatbuffers.h
|
||||
include/flatbuffers/grpc.h
|
||||
include/flatbuffers/util.h
|
||||
src/util.cpp
|
||||
tests/monster_test.grpc.fb.h
|
||||
tests/test_assert.h
|
||||
tests/test_builder.h
|
||||
tests/monster_test.grpc.fb.cc
|
||||
tests/test_assert.cpp
|
||||
tests/test_builder.cpp
|
||||
grpc/tests/grpctest.cpp
|
||||
grpc/tests/message_builder_test.cpp
|
||||
# file generate by running compiler on tests/monster_test.fbs
|
||||
${CMAKE_CURRENT_BINARY_DIR}/tests/monster_test_generated.h
|
||||
)
|
||||
|
||||
# source_group(Compiler FILES ${FlatBuffers_Compiler_SRCS})
|
||||
# source_group(Tests FILES ${FlatBuffers_Tests_SRCS})
|
||||
|
||||
if(EXISTS "${CMAKE_TOOLCHAIN_FILE}")
|
||||
# do not apply any global settings if the toolchain
|
||||
# is being configured externally
|
||||
message(STATUS "Using toolchain file: ${CMAKE_TOOLCHAIN_FILE}.")
|
||||
elseif(CMAKE_COMPILER_IS_GNUCXX)
|
||||
if(CYGWIN)
|
||||
set(CMAKE_CXX_FLAGS
|
||||
"${CMAKE_CXX_FLAGS} -std=gnu++11")
|
||||
else(CYGWIN)
|
||||
set(CMAKE_CXX_FLAGS
|
||||
"${CMAKE_CXX_FLAGS} -std=c++0x")
|
||||
endif(CYGWIN)
|
||||
set(CMAKE_CXX_FLAGS
|
||||
"${CMAKE_CXX_FLAGS} -Wall -pedantic -Werror -Wextra -Werror=shadow")
|
||||
set(FLATBUFFERS_PRIVATE_CXX_FLAGS "-Wold-style-cast")
|
||||
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.4)
|
||||
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 7.0)
|
||||
set(CMAKE_CXX_FLAGS
|
||||
"${CMAKE_CXX_FLAGS} -faligned-new -Werror=implicit-fallthrough=2")
|
||||
endif()
|
||||
set(CMAKE_CXX_FLAGS
|
||||
"${CMAKE_CXX_FLAGS} -Wunused-result -Werror=unused-result -Wunused-parameter -Werror=unused-parameter")
|
||||
endif()
|
||||
|
||||
# Certain platforms such as ARM do not use signed chars by default
|
||||
# which causes issues with certain bounds checks.
|
||||
set(CMAKE_CXX_FLAGS
|
||||
"${CMAKE_CXX_FLAGS} -fsigned-char")
|
||||
|
||||
# MSVC **MUST** come before the Clang check, as clang-cl is flagged by CMake as "MSVC", but it still textually
|
||||
# matches as Clang in its Compiler Id :)
|
||||
# Note: in CMake >= 3.14 we can check CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "GNU" or "MSVC" to differentiate...
|
||||
elseif(MSVC)
|
||||
# Visual Studio pedantic build settings
|
||||
# warning C4512: assignment operator could not be generated
|
||||
# warning C4316: object allocated on the heap may not be aligned
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4 /WX /wd4512 /wd4316")
|
||||
|
||||
if(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D_CRT_SECURE_NO_WARNINGS")
|
||||
endif()
|
||||
|
||||
elseif(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
|
||||
if(APPLE)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
|
||||
|
||||
if(FLATBUFFERS_OSX_BUILD_UNIVERSAL)
|
||||
set(CMAKE_OSX_ARCHITECTURES "arm64;x86_64")
|
||||
endif()
|
||||
else()
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
|
||||
endif()
|
||||
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pedantic -Werror -Wextra -Wno-unused-parameter")
|
||||
set(FLATBUFFERS_PRIVATE_CXX_FLAGS "-Wold-style-cast")
|
||||
if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.8)
|
||||
list(APPEND FLATBUFFERS_PRIVATE_CXX_FLAGS "-Wimplicit-fallthrough" "-Wextra-semi" "-Werror=unused-private-field") # enable warning
|
||||
endif()
|
||||
if(FLATBUFFERS_LIBCXX_WITH_CLANG)
|
||||
if(NOT "${CMAKE_SYSTEM_NAME}" MATCHES "Linux")
|
||||
set(CMAKE_CXX_FLAGS
|
||||
"${CMAKE_CXX_FLAGS} -stdlib=libc++")
|
||||
endif()
|
||||
if(NOT ("${CMAKE_SYSTEM_NAME}" MATCHES "FreeBSD" OR
|
||||
"${CMAKE_SYSTEM_NAME}" MATCHES "Linux"))
|
||||
set(CMAKE_EXE_LINKER_FLAGS
|
||||
"${CMAKE_EXE_LINKER_FLAGS} -lc++abi")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Certain platforms such as ARM do not use signed chars by default
|
||||
# which causes issues with certain bounds checks.
|
||||
set(CMAKE_CXX_FLAGS
|
||||
"${CMAKE_CXX_FLAGS} -fsigned-char")
|
||||
|
||||
endif()
|
||||
|
||||
# Append FLATBUFFERS_CXX_FLAGS to CMAKE_CXX_FLAGS.
|
||||
if(DEFINED FLATBUFFERS_CXX_FLAGS AND NOT EXISTS "${CMAKE_TOOLCHAIN_FILE}")
|
||||
message(STATUS "extend CXX_FLAGS with ${FLATBUFFERS_CXX_FLAGS}")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${FLATBUFFERS_CXX_FLAGS}")
|
||||
endif()
|
||||
message(STATUS "CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}")
|
||||
|
||||
if(FLATBUFFERS_CODE_COVERAGE)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -fprofile-arcs -ftest-coverage")
|
||||
set(CMAKE_EXE_LINKER_FLAGS
|
||||
"${CMAKE_EXE_LINKER_FLAGS} -fprofile-arcs -ftest-coverage")
|
||||
endif()
|
||||
|
||||
function(add_fsanitize_to_target _target _sanitizer)
|
||||
if(WIN32)
|
||||
target_compile_definitions(${_target} PRIVATE FLATBUFFERS_MEMORY_LEAK_TRACKING)
|
||||
message(STATUS "Sanitizer MSVC::_CrtDumpMemoryLeaks added to ${_target}")
|
||||
else()
|
||||
# FLATBUFFERS_CODE_SANITIZE: boolean {ON,OFF,YES,NO} or string with list of sanitizer.
|
||||
# List of sanitizer is string starts with '=': "=address,undefined,thread,memory".
|
||||
if((${CMAKE_CXX_COMPILER_ID} MATCHES "Clang") OR
|
||||
((${CMAKE_CXX_COMPILER_ID} MATCHES "GNU") AND NOT (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.9"))
|
||||
)
|
||||
set(_sanitizer_flags "=address,undefined")
|
||||
if(_sanitizer MATCHES "=.*")
|
||||
# override default by user-defined sanitizer list
|
||||
set(_sanitizer_flags ${_sanitizer})
|
||||
endif()
|
||||
target_compile_options(${_target} PRIVATE
|
||||
-g -fsigned-char -fno-omit-frame-pointer
|
||||
"-fsanitize${_sanitizer_flags}")
|
||||
target_link_libraries(${_target} PRIVATE
|
||||
"-fsanitize${_sanitizer_flags}")
|
||||
set_property(TARGET ${_target} PROPERTY POSITION_INDEPENDENT_CODE ON)
|
||||
message(STATUS "Sanitizer ${_sanitizer_flags} added to ${_target}")
|
||||
endif()
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
function(add_pch_to_target _target _pch_header)
|
||||
if(COMMAND target_precompile_headers)
|
||||
target_precompile_headers(${_target} PRIVATE ${_pch_header})
|
||||
if(NOT MSVC)
|
||||
set_source_files_properties(src/util.cpp PROPERTIES SKIP_PRECOMPILE_HEADERS ON)
|
||||
endif()
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
if(BIICODE)
|
||||
include(biicode/cmake/biicode.cmake)
|
||||
return()
|
||||
endif()
|
||||
|
||||
include_directories(include)
|
||||
include_directories(grpc)
|
||||
|
||||
if(FLATBUFFERS_BUILD_FLATLIB)
|
||||
add_library(flatbuffers STATIC ${FlatBuffers_Library_SRCS})
|
||||
# Attach header directory for when build via add_subdirectory().
|
||||
target_include_directories(flatbuffers INTERFACE
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>)
|
||||
target_compile_options(flatbuffers PRIVATE "${FLATBUFFERS_PRIVATE_CXX_FLAGS}")
|
||||
if(FLATBUFFERS_ENABLE_PCH)
|
||||
add_pch_to_target(flatbuffers include/flatbuffers/pch/pch.h)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(FLATBUFFERS_BUILD_FLATC)
|
||||
add_executable(flatc ${FlatBuffers_Compiler_SRCS})
|
||||
if(FLATBUFFERS_ENABLE_PCH)
|
||||
add_pch_to_target(flatc include/flatbuffers/pch/flatc_pch.h)
|
||||
endif()
|
||||
target_compile_options(flatc PRIVATE "${FLATBUFFERS_PRIVATE_CXX_FLAGS}")
|
||||
if(FLATBUFFERS_CODE_SANITIZE AND NOT WIN32)
|
||||
add_fsanitize_to_target(flatc ${FLATBUFFERS_CODE_SANITIZE})
|
||||
endif()
|
||||
if(NOT FLATBUFFERS_FLATC_EXECUTABLE)
|
||||
set(FLATBUFFERS_FLATC_EXECUTABLE $<TARGET_FILE:flatc>)
|
||||
endif()
|
||||
if(MSVC)
|
||||
# Make flatc.exe not depend on runtime dlls for easy distribution.
|
||||
target_compile_options(flatc PUBLIC $<$<CONFIG:Release>:/MT>)
|
||||
endif()
|
||||
if(FLATBUFFERS_STATIC_FLATC AND NOT MSVC)
|
||||
target_link_libraries(flatc PRIVATE -static)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(FLATBUFFERS_BUILD_FLATHASH)
|
||||
add_executable(flathash ${FlatHash_SRCS})
|
||||
endif()
|
||||
|
||||
if(FLATBUFFERS_BUILD_SHAREDLIB)
|
||||
add_library(flatbuffers_shared SHARED ${FlatBuffers_Library_SRCS})
|
||||
|
||||
# Shared object version: "major.minor.micro"
|
||||
# - micro updated every release when there is no API/ABI changes
|
||||
# - minor updated when there are additions in API/ABI
|
||||
# - major (ABI number) updated when there are changes in ABI (or removals)
|
||||
set(FlatBuffers_Library_SONAME_MAJOR ${VERSION_MAJOR})
|
||||
set(FlatBuffers_Library_SONAME_FULL "${FlatBuffers_Library_SONAME_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
|
||||
set_target_properties(flatbuffers_shared PROPERTIES OUTPUT_NAME flatbuffers
|
||||
SOVERSION "${FlatBuffers_Library_SONAME_MAJOR}"
|
||||
VERSION "${FlatBuffers_Library_SONAME_FULL}")
|
||||
if(FLATBUFFERS_ENABLE_PCH)
|
||||
add_pch_to_target(flatbuffers_shared include/flatbuffers/pch/pch.h)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Global list of generated files.
|
||||
# Use the global property to be independent of PARENT_SCOPE.
|
||||
set_property(GLOBAL PROPERTY FBS_GENERATED_OUTPUTS)
|
||||
|
||||
function(get_generated_output generated_files)
|
||||
get_property(tmp GLOBAL PROPERTY FBS_GENERATED_OUTPUTS)
|
||||
set(${generated_files} ${tmp} PARENT_SCOPE)
|
||||
endfunction(get_generated_output)
|
||||
|
||||
function(register_generated_output file_name)
|
||||
get_property(tmp GLOBAL PROPERTY FBS_GENERATED_OUTPUTS)
|
||||
list(APPEND tmp ${file_name})
|
||||
set_property(GLOBAL PROPERTY FBS_GENERATED_OUTPUTS ${tmp})
|
||||
endfunction(register_generated_output)
|
||||
|
||||
function(compile_flatbuffers_schema_to_cpp_opt SRC_FBS OPT)
|
||||
if(FLATBUFFERS_BUILD_LEGACY)
|
||||
set(OPT ${OPT};--cpp-std c++0x)
|
||||
else()
|
||||
# --cpp-std is defined by flatc default settings.
|
||||
endif()
|
||||
message(STATUS "`${SRC_FBS}`: add generation of C++ code with '${OPT}'")
|
||||
get_filename_component(SRC_FBS_DIR ${SRC_FBS} PATH)
|
||||
string(REGEX REPLACE "\\.fbs$" "_generated.h" GEN_HEADER ${SRC_FBS})
|
||||
add_custom_command(
|
||||
OUTPUT ${GEN_HEADER}
|
||||
COMMAND "${FLATBUFFERS_FLATC_EXECUTABLE}"
|
||||
--cpp --gen-mutable --gen-object-api --reflect-names
|
||||
--cpp-ptr-type flatbuffers::unique_ptr # Used to test with C++98 STLs
|
||||
${OPT}
|
||||
-I "${CMAKE_CURRENT_SOURCE_DIR}/tests/include_test"
|
||||
-o "${SRC_FBS_DIR}"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/${SRC_FBS}"
|
||||
DEPENDS flatc
|
||||
COMMENT "Run generation: '${GEN_HEADER}'")
|
||||
register_generated_output(${GEN_HEADER})
|
||||
endfunction()
|
||||
|
||||
function(compile_flatbuffers_schema_to_cpp SRC_FBS)
|
||||
compile_flatbuffers_schema_to_cpp_opt(${SRC_FBS} "--no-includes;--gen-compare")
|
||||
endfunction()
|
||||
|
||||
function(compile_flatbuffers_schema_to_binary SRC_FBS)
|
||||
message(STATUS "`${SRC_FBS}`: add generation of binary (.bfbs) schema")
|
||||
get_filename_component(SRC_FBS_DIR ${SRC_FBS} PATH)
|
||||
string(REGEX REPLACE "\\.fbs$" ".bfbs" GEN_BINARY_SCHEMA ${SRC_FBS})
|
||||
# For details about flags see generate_code.py
|
||||
add_custom_command(
|
||||
OUTPUT ${GEN_BINARY_SCHEMA}
|
||||
COMMAND "${FLATBUFFERS_FLATC_EXECUTABLE}"
|
||||
-b --schema --bfbs-comments --bfbs-builtins
|
||||
--bfbs-filenames ${SRC_FBS_DIR}
|
||||
-I "${CMAKE_CURRENT_SOURCE_DIR}/tests/include_test"
|
||||
-o "${SRC_FBS_DIR}"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/${SRC_FBS}"
|
||||
DEPENDS flatc
|
||||
COMMENT "Run generation: '${GEN_BINARY_SCHEMA}'")
|
||||
register_generated_output(${GEN_BINARY_SCHEMA})
|
||||
endfunction()
|
||||
|
||||
function(compile_flatbuffers_schema_to_embedded_binary SRC_FBS OPT)
|
||||
if(FLATBUFFERS_BUILD_LEGACY)
|
||||
set(OPT ${OPT};--cpp-std c++0x)
|
||||
else()
|
||||
# --cpp-std is defined by flatc default settings.
|
||||
endif()
|
||||
message(STATUS "`${SRC_FBS}`: add generation of C++ embedded binary schema code with '${OPT}'")
|
||||
get_filename_component(SRC_FBS_DIR ${SRC_FBS} PATH)
|
||||
string(REGEX REPLACE "\\.fbs$" "_bfbs_generated.h" GEN_BFBS_HEADER ${SRC_FBS})
|
||||
# For details about flags see generate_code.py
|
||||
add_custom_command(
|
||||
OUTPUT ${GEN_BFBS_HEADER}
|
||||
COMMAND "${FLATBUFFERS_FLATC_EXECUTABLE}"
|
||||
--cpp --gen-mutable --gen-object-api --reflect-names
|
||||
--cpp-ptr-type flatbuffers::unique_ptr # Used to test with C++98 STLs
|
||||
${OPT}
|
||||
--bfbs-comments --bfbs-builtins --bfbs-gen-embed
|
||||
--bfbs-filenames ${SRC_FBS_DIR}
|
||||
-I "${CMAKE_CURRENT_SOURCE_DIR}/tests/include_test"
|
||||
-o "${SRC_FBS_DIR}"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/${SRC_FBS}"
|
||||
DEPENDS flatc
|
||||
COMMENT "Run generation: '${GEN_BFBS_HEADER}'")
|
||||
register_generated_output(${GEN_BFBS_HEADER})
|
||||
endfunction()
|
||||
|
||||
# Look if we have python 3.5 installed so that we can run the generate code
|
||||
# python script after flatc is built.
|
||||
find_package(PythonInterp 3.5)
|
||||
|
||||
if(PYTHONINTERP_FOUND AND
|
||||
# Skip doing this if the MSVC version is below VS 12.
|
||||
# https://cmake.org/cmake/help/latest/variable/MSVC_VERSION.html
|
||||
(NOT MSVC OR MSVC_VERSION GREATER 1800))
|
||||
set(GENERATION_SCRIPT ${PYTHON_EXECUTABLE} scripts/generate_code.py)
|
||||
if(FLATBUFFERS_BUILD_LEGACY)
|
||||
# Need to set --cpp-std c++-0x options
|
||||
set(GENERATION_SCRIPT ${GENERATION_SCRIPT} --cpp-0x)
|
||||
endif()
|
||||
if(FLATBUFFERS_SKIP_MONSTER_EXTRA)
|
||||
set(GENERATION_SCRIPT ${GENERATION_SCRIPT} --skip-monster-extra)
|
||||
endif()
|
||||
add_custom_command(
|
||||
TARGET flatc
|
||||
POST_BUILD
|
||||
COMMAND ${GENERATION_SCRIPT} --flatc "${FLATBUFFERS_FLATC_EXECUTABLE}"
|
||||
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
COMMENT "Running ${GENERATION_SCRIPT}..."
|
||||
VERBATIM)
|
||||
else()
|
||||
message("No Python3 interpreter found! Unable to generate files automatically.")
|
||||
endif()
|
||||
|
||||
if(FLATBUFFERS_BUILD_TESTS)
|
||||
file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/tests" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}")
|
||||
file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/samples" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}")
|
||||
|
||||
# TODO Add (monster_test.fbs monsterdata_test.json)->monsterdata_test.mon
|
||||
compile_flatbuffers_schema_to_cpp(tests/monster_test.fbs)
|
||||
compile_flatbuffers_schema_to_binary(tests/monster_test.fbs)
|
||||
compile_flatbuffers_schema_to_cpp_opt(tests/namespace_test/namespace_test1.fbs "--no-includes;--gen-compare;--gen-name-strings")
|
||||
compile_flatbuffers_schema_to_cpp_opt(tests/namespace_test/namespace_test2.fbs "--no-includes;--gen-compare;--gen-name-strings")
|
||||
compile_flatbuffers_schema_to_cpp_opt(tests/union_vector/union_vector.fbs "--no-includes;--gen-compare;--gen-name-strings")
|
||||
compile_flatbuffers_schema_to_cpp(tests/optional_scalars.fbs)
|
||||
compile_flatbuffers_schema_to_cpp_opt(tests/native_type_test.fbs "")
|
||||
compile_flatbuffers_schema_to_cpp_opt(tests/arrays_test.fbs "--scoped-enums;--gen-compare")
|
||||
compile_flatbuffers_schema_to_binary(tests/arrays_test.fbs)
|
||||
compile_flatbuffers_schema_to_embedded_binary(tests/monster_test.fbs "--no-includes;--gen-compare")
|
||||
if(NOT (MSVC AND (MSVC_VERSION LESS 1900)))
|
||||
compile_flatbuffers_schema_to_cpp(tests/monster_extra.fbs) # Test floating-point NAN/INF.
|
||||
endif()
|
||||
include_directories(${CMAKE_CURRENT_BINARY_DIR}/tests)
|
||||
add_executable(flattests ${FlatBuffers_Tests_SRCS})
|
||||
add_dependencies(flattests generated_code)
|
||||
set_property(TARGET flattests
|
||||
PROPERTY COMPILE_DEFINITIONS FLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE
|
||||
FLATBUFFERS_DEBUG_VERIFICATION_FAILURE=1)
|
||||
if(FLATBUFFERS_CODE_SANITIZE)
|
||||
add_fsanitize_to_target(flattests ${FLATBUFFERS_CODE_SANITIZE})
|
||||
endif()
|
||||
|
||||
compile_flatbuffers_schema_to_cpp(samples/monster.fbs)
|
||||
compile_flatbuffers_schema_to_binary(samples/monster.fbs)
|
||||
include_directories(${CMAKE_CURRENT_BINARY_DIR}/samples)
|
||||
add_executable(flatsamplebinary ${FlatBuffers_Sample_Binary_SRCS})
|
||||
add_dependencies(flatsamplebinary generated_code)
|
||||
add_executable(flatsampletext ${FlatBuffers_Sample_Text_SRCS})
|
||||
add_dependencies(flatsampletext generated_code)
|
||||
add_executable(flatsamplebfbs ${FlatBuffers_Sample_BFBS_SRCS})
|
||||
add_dependencies(flatsamplebfbs generated_code)
|
||||
|
||||
if(FLATBUFFERS_BUILD_CPP17)
|
||||
# Don't generate header for flattests_cpp17 target.
|
||||
# This target uses "generated_cpp17/monster_test_generated.h"
|
||||
# produced by direct call of generate_code.py script.
|
||||
add_executable(flattests_cpp17 ${FlatBuffers_Tests_CPP17_SRCS})
|
||||
add_dependencies(flattests_cpp17 generated_code)
|
||||
target_compile_features(flattests_cpp17 PRIVATE cxx_std_17)
|
||||
target_compile_definitions(flattests_cpp17 PRIVATE
|
||||
FLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE
|
||||
FLATBUFFERS_DEBUG_VERIFICATION_FAILURE=1
|
||||
)
|
||||
if(FLATBUFFERS_CODE_SANITIZE)
|
||||
add_fsanitize_to_target(flattests_cpp17 ${FLATBUFFERS_CODE_SANITIZE})
|
||||
endif()
|
||||
endif(FLATBUFFERS_BUILD_CPP17)
|
||||
endif()
|
||||
|
||||
if(FLATBUFFERS_BUILD_GRPCTEST)
|
||||
if(CMAKE_COMPILER_IS_GNUCXX)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-parameter -Wno-shadow")
|
||||
endif()
|
||||
if(NOT GRPC_INSTALL_PATH)
|
||||
message(SEND_ERROR "GRPC_INSTALL_PATH variable is not defined. See grpc/README.md")
|
||||
endif()
|
||||
if(NOT PROTOBUF_DOWNLOAD_PATH)
|
||||
message(SEND_ERROR "PROTOBUF_DOWNLOAD_PATH variable is not defined. See grpc/README.md")
|
||||
endif()
|
||||
INCLUDE_DIRECTORIES(${GRPC_INSTALL_PATH}/include)
|
||||
INCLUDE_DIRECTORIES(${PROTOBUF_DOWNLOAD_PATH}/src)
|
||||
find_package(Threads REQUIRED)
|
||||
list(APPEND CMAKE_PREFIX_PATH ${GRPC_INSTALL_PATH})
|
||||
find_package(absl CONFIG REQUIRED)
|
||||
find_package(protobuf CONFIG REQUIRED)
|
||||
find_package(gRPC CONFIG REQUIRED)
|
||||
add_executable(grpctest ${FlatBuffers_GRPCTest_SRCS})
|
||||
add_dependencies(grpctest generated_code)
|
||||
target_link_libraries(grpctest PRIVATE gRPC::grpc++_unsecure gRPC::grpc_unsecure gRPC::gpr pthread dl)
|
||||
if(FLATBUFFERS_CODE_SANITIZE AND NOT WIN32)
|
||||
# GRPC test has problems with alignment and will fail under ASAN/UBSAN.
|
||||
# add_fsanitize_to_target(grpctest ${FLATBUFFERS_CODE_SANITIZE})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
if(FLATBUFFERS_INSTALL)
|
||||
include(GNUInstallDirs)
|
||||
|
||||
install(DIRECTORY include/flatbuffers DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
|
||||
|
||||
set(FB_CMAKE_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/flatbuffers")
|
||||
|
||||
configure_file(CMake/FlatbuffersConfigVersion.cmake.in FlatbuffersConfigVersion.cmake @ONLY)
|
||||
install(
|
||||
FILES "CMake/FlatbuffersConfig.cmake" "${CMAKE_CURRENT_BINARY_DIR}/FlatbuffersConfigVersion.cmake"
|
||||
DESTINATION ${FB_CMAKE_DIR}
|
||||
)
|
||||
|
||||
if(FLATBUFFERS_BUILD_FLATLIB)
|
||||
if(CMAKE_VERSION VERSION_LESS 3.0)
|
||||
install(
|
||||
TARGETS flatbuffers EXPORT FlatbuffersTargets
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
)
|
||||
else()
|
||||
install(
|
||||
TARGETS flatbuffers EXPORT FlatbuffersTargets
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
||||
)
|
||||
endif()
|
||||
|
||||
install(EXPORT FlatbuffersTargets
|
||||
FILE FlatbuffersTargets.cmake
|
||||
NAMESPACE flatbuffers::
|
||||
DESTINATION ${FB_CMAKE_DIR}
|
||||
)
|
||||
endif()
|
||||
|
||||
if(FLATBUFFERS_BUILD_FLATC)
|
||||
install(
|
||||
TARGETS flatc EXPORT FlatcTargets
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
)
|
||||
|
||||
install(
|
||||
EXPORT FlatcTargets
|
||||
FILE FlatcTargets.cmake
|
||||
NAMESPACE flatbuffers::
|
||||
DESTINATION ${FB_CMAKE_DIR}
|
||||
)
|
||||
endif()
|
||||
|
||||
if(FLATBUFFERS_BUILD_SHAREDLIB)
|
||||
if(CMAKE_VERSION VERSION_LESS 3.0)
|
||||
install(
|
||||
TARGETS flatbuffers_shared EXPORT FlatbuffersSharedTargets
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
)
|
||||
else()
|
||||
install(
|
||||
TARGETS flatbuffers_shared EXPORT FlatbuffersSharedTargets
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
||||
)
|
||||
endif()
|
||||
|
||||
install(
|
||||
EXPORT FlatbuffersSharedTargets
|
||||
FILE FlatbuffersSharedTargets.cmake
|
||||
NAMESPACE flatbuffers::
|
||||
DESTINATION ${FB_CMAKE_DIR}
|
||||
)
|
||||
endif()
|
||||
|
||||
if(FLATBUFFERS_BUILD_SHAREDLIB OR FLATBUFFERS_BUILD_FLATLIB)
|
||||
configure_file(CMake/flatbuffers.pc.in flatbuffers.pc @ONLY)
|
||||
install(
|
||||
FILES "${CMAKE_CURRENT_BINARY_DIR}/flatbuffers.pc"
|
||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(FLATBUFFERS_BUILD_TESTS)
|
||||
enable_testing()
|
||||
|
||||
add_test(NAME flattests COMMAND flattests)
|
||||
if(FLATBUFFERS_BUILD_CPP17)
|
||||
add_test(NAME flattests_cpp17 COMMAND flattests_cpp17)
|
||||
endif()
|
||||
if(FLATBUFFERS_BUILD_GRPCTEST)
|
||||
add_test(NAME grpctest COMMAND grpctest)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# This target is sync-barrier.
|
||||
# Other generate-dependent targets can depend on 'generated_code' only.
|
||||
get_generated_output(fbs_generated)
|
||||
if(fbs_generated)
|
||||
# message(STATUS "Add generated_code target with files:${fbs_generated}")
|
||||
add_custom_target(generated_code
|
||||
DEPENDS ${fbs_generated}
|
||||
COMMENT "All generated files were updated.")
|
||||
endif()
|
||||
|
||||
include(CMake/BuildFlatBuffers.cmake)
|
||||
|
||||
if(UNIX)
|
||||
# Use of CPack only supported on Linux systems.
|
||||
if(FLATBUFFERS_PACKAGE_DEBIAN)
|
||||
include(CMake/PackageDebian.cmake)
|
||||
include(CPack)
|
||||
endif()
|
||||
if (FLATBUFFERS_PACKAGE_REDHAT)
|
||||
include(CMake/PackageRedhat.cmake)
|
||||
include(CPack)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Include for running Google Benchmarks.
|
||||
if(FLATBUFFERS_BUILD_BENCHMARKS AND CMAKE_VERSION VERSION_GREATER 3.13)
|
||||
add_subdirectory(benchmarks)
|
||||
endif()
|
||||
|
||||
# Add FlatBuffers::FlatBuffers interface, needed for FetchContent_Declare
|
||||
add_library(FlatBuffers INTERFACE)
|
||||
add_library(FlatBuffers::FlatBuffers ALIAS FlatBuffers)
|
||||
target_include_directories(
|
||||
FlatBuffers
|
||||
INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/include>)
|
||||
@@ -1,4 +0,0 @@
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/FlatbuffersTargets.cmake" OPTIONAL)
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/FlatcTargets.cmake" OPTIONAL)
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/FlatbuffersSharedTargets.cmake" OPTIONAL)
|
||||
|
||||
@@ -17,23 +17,9 @@ if (UNIX)
|
||||
SET(CPACK_PACKAGE_VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}-${VERSION_COMMIT}")
|
||||
SET(CPACK_DEBIAN_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION}")
|
||||
|
||||
# Derive architecture
|
||||
IF(NOT CPACK_DEBIAN_PACKAGE_ARCHITECTURE)
|
||||
FIND_PROGRAM(DPKG_CMD dpkg)
|
||||
IF(NOT DPKG_CMD)
|
||||
MESSAGE(STATUS "Can not find dpkg in your path, default to i386.")
|
||||
SET(CPACK_DEBIAN_PACKAGE_ARCHITECTURE i386)
|
||||
ENDIF(NOT DPKG_CMD)
|
||||
EXECUTE_PROCESS(COMMAND "${DPKG_CMD}" --print-architecture
|
||||
OUTPUT_VARIABLE CPACK_DEBIAN_PACKAGE_ARCHITECTURE
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
ENDIF(NOT CPACK_DEBIAN_PACKAGE_ARCHITECTURE)
|
||||
|
||||
# Package name
|
||||
SET(CPACK_DEBIAN_PACKAGE_NAME "flatbuffers")
|
||||
SET(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_SOURCE_DIR}/LICENSE.txt)
|
||||
SET(CPACK_PACKAGE_FILE_NAME
|
||||
"${CPACK_DEBIAN_PACKAGE_NAME}_${CPACK_DEBIAN_PACKAGE_VERSION}_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}")
|
||||
SET(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_SOURCE_DIR}/LICENSE)
|
||||
set(CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT")
|
||||
|
||||
endif(UNIX)
|
||||
|
||||
@@ -15,7 +15,7 @@ if (UNIX)
|
||||
|
||||
set(CPACK_RPM_PACKAGE_NAME "flatbuffers")
|
||||
|
||||
# Assume this is not a cross complation build.
|
||||
# Assume this is not a cross compilation build.
|
||||
if(NOT CPACK_RPM_PACKAGE_ARCHITECTURE)
|
||||
set(CPACK_RPM_PACKAGE_ARCHITECTURE "${CMAKE_SYSTEM_PROCESSOR}")
|
||||
endif(NOT CPACK_RPM_PACKAGE_ARCHITECTURE)
|
||||
|
||||
@@ -1,28 +1,39 @@
|
||||
set(VERSION_MAJOR 2)
|
||||
set(VERSION_MINOR 0)
|
||||
set(VERSION_PATCH 6)
|
||||
set(VERSION_MAJOR 23)
|
||||
set(VERSION_MINOR 3)
|
||||
set(VERSION_PATCH 3)
|
||||
set(VERSION_COMMIT 0)
|
||||
|
||||
find_program(GIT git)
|
||||
if(GIT AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git")
|
||||
execute_process(
|
||||
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git")
|
||||
find_program(GIT git)
|
||||
if(GIT)
|
||||
execute_process(
|
||||
COMMAND ${GIT} describe --tags
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
OUTPUT_VARIABLE GIT_DESCRIBE_DIRTY
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
RESULT_VARIABLE GIT_DESCRIBE_RESULT
|
||||
)
|
||||
)
|
||||
|
||||
if(GIT_DESCRIBE_RESULT EQUAL 0)
|
||||
string(REGEX REPLACE "^v([0-9]+)\\..*" "\\1" VERSION_MAJOR "${GIT_DESCRIBE_DIRTY}")
|
||||
string(REGEX REPLACE "^v[0-9]+\\.([0-9]+).*" "\\1" VERSION_MINOR "${GIT_DESCRIBE_DIRTY}")
|
||||
string(REGEX REPLACE "^v[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" VERSION_PATCH "${GIT_DESCRIBE_DIRTY}")
|
||||
string(REGEX REPLACE "^v[0-9]+\\.[0-9]+\\.[0-9]+\\-([0-9]+).*" "\\1" VERSION_COMMIT "${GIT_DESCRIBE_DIRTY}")
|
||||
if(GIT_DESCRIBE_RESULT EQUAL 0)
|
||||
# Test if the most recent Git tag matches the pattern "v<major>.<minor>.<patch>*"
|
||||
if(GIT_DESCRIBE_DIRTY MATCHES "^v[0-9]+\\.[0-9]+\\.[0-9]+.*")
|
||||
string(REGEX REPLACE "^v([0-9]+)\\..*" "\\1" VERSION_MAJOR "${GIT_DESCRIBE_DIRTY}")
|
||||
string(REGEX REPLACE "^v[0-9]+\\.([0-9]+).*" "\\1" VERSION_MINOR "${GIT_DESCRIBE_DIRTY}")
|
||||
string(REGEX REPLACE "^v[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" VERSION_PATCH "${GIT_DESCRIBE_DIRTY}")
|
||||
string(REGEX REPLACE "^v[0-9]+\\.[0-9]+\\.[0-9]+\\-([0-9]+).*" "\\1" VERSION_COMMIT "${GIT_DESCRIBE_DIRTY}")
|
||||
# If the tag points to the commit, then only the tag is shown in "git describe"
|
||||
if(VERSION_COMMIT STREQUAL GIT_DESCRIBE_DIRTY)
|
||||
set(VERSION_COMMIT 0)
|
||||
endif()
|
||||
else()
|
||||
message(WARNING "\"${GIT_DESCRIBE_DIRTY}\" does not match pattern v<major>.<minor>.<patch>-<commit>")
|
||||
endif()
|
||||
else()
|
||||
message(WARNING "git describe failed with exit code: ${GIT_DESCRIBE_RESULT}")
|
||||
endif()
|
||||
else()
|
||||
message(WARNING "git describe failed with exit code: ${GIT_DESCRIBE_RESULT}")
|
||||
message(WARNING "git is not found")
|
||||
endif()
|
||||
else()
|
||||
message(WARNING "git is not found")
|
||||
endif()
|
||||
|
||||
message(STATUS "Proceeding with version: ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}.${VERSION_COMMIT}")
|
||||
|
||||
3
CMake/flatbuffers-config.cmake
Normal file
3
CMake/flatbuffers-config.cmake
Normal file
@@ -0,0 +1,3 @@
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/FlatBuffersTargets.cmake" OPTIONAL)
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/FlatcTargets.cmake" OPTIONAL)
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/FlatBuffersSharedTargets.cmake" OPTIONAL)
|
||||
441
CMakeLists.txt
441
CMakeLists.txt
@@ -1,32 +1,13 @@
|
||||
# This is the legacy minimum version flatbuffers supported for a while.
|
||||
cmake_minimum_required(VERSION 2.8.12)
|
||||
|
||||
# CMake version 3.16 is the 'de-facto' minimum version for flatbuffers. If the
|
||||
# current cmake is older than this, warn the user and include the legacy file to
|
||||
# provide some level of support.
|
||||
if(CMAKE_VERSION VERSION_LESS 3.16)
|
||||
message(WARNING "Using cmake version ${CMAKE_VERSION} which is older than "
|
||||
"our target version of 3.16. This will use the legacy CMakeLists.txt that "
|
||||
"supports version 2.8.12 and higher, but not actively maintained. Consider "
|
||||
"upgrading cmake to a newer version, as this may become a fatal error in the "
|
||||
"future.")
|
||||
# Use the legacy version of CMakeLists.txt
|
||||
include(CMake/CMakeLists_legacy.cmake.in)
|
||||
return()
|
||||
endif()
|
||||
|
||||
if (POLICY CMP0048)
|
||||
cmake_policy(SET CMP0048 NEW)
|
||||
project(FlatBuffers
|
||||
DESCRIPTION "Flatbuffers serialization library"
|
||||
VERSION 2.0.0
|
||||
LANGUAGES CXX)
|
||||
else()
|
||||
project(FlatBuffers)
|
||||
endif (POLICY CMP0048)
|
||||
cmake_minimum_required(VERSION 3.8...3.25.2)
|
||||
|
||||
# Attempt to read the current version of flatbuffers by looking at the latest tag.
|
||||
include(CMake/Version.cmake)
|
||||
|
||||
project(FlatBuffers
|
||||
VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}
|
||||
LANGUAGES CXX)
|
||||
|
||||
# generate compile_commands.json
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
|
||||
@@ -41,8 +22,7 @@ option(FLATBUFFERS_BUILD_FLATC "Enable the build of the flatbuffers compiler"
|
||||
option(FLATBUFFERS_STATIC_FLATC "Build flatbuffers compiler with -static flag"
|
||||
OFF)
|
||||
option(FLATBUFFERS_BUILD_FLATHASH "Enable the build of flathash" ON)
|
||||
option(FLATBUFFERS_BUILD_BENCHMARKS "Enable the build of flatbenchmark. \"
|
||||
Requires C++11."
|
||||
option(FLATBUFFERS_BUILD_BENCHMARKS "Enable the build of flatbenchmark."
|
||||
OFF)
|
||||
option(FLATBUFFERS_BUILD_GRPCTEST "Enable the build of grpctest" OFF)
|
||||
option(FLATBUFFERS_BUILD_SHAREDLIB
|
||||
@@ -71,12 +51,35 @@ option(FLATBUFFERS_ENABLE_PCH
|
||||
Only work if CMake supports 'target_precompile_headers'. \"
|
||||
This can speed up compilation time."
|
||||
OFF)
|
||||
option(FLATBUFFERS_SKIP_MONSTER_EXTRA
|
||||
option(FLATBUFFERS_SKIP_MONSTER_EXTRA
|
||||
"Skip generating monster_extra.fbs that contains non-supported numerical\"
|
||||
types." OFF)
|
||||
option(FLATBUFFERS_OSX_BUILD_UNIVERSAL
|
||||
"Enable the build for multiple architectures on OS X (arm64, x86_64)."
|
||||
ON)
|
||||
option(FLATBUFFERS_STRICT_MODE
|
||||
"Build flatbuffers with all warnings as errors (-Werror or /WX)."
|
||||
OFF)
|
||||
|
||||
if(NOT DEFINED FLATBUFFERS_CPP_STD)
|
||||
set(FLATBUFFERS_CPP_STD 11)
|
||||
endif()
|
||||
|
||||
set(MSVC_LIKE OFF)
|
||||
if(MSVC OR CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC")
|
||||
set(MSVC_LIKE ON)
|
||||
endif()
|
||||
|
||||
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
set(IS_CLANG ON)
|
||||
else()
|
||||
set(IS_CLANG OFF)
|
||||
endif()
|
||||
|
||||
if(DEFINED FLATBUFFERS_COMPILATION_TIMINGS)
|
||||
message("Recording Compilation Timings to ${FLATBUFFERS_COMPILATION_TIMINGS}")
|
||||
file(REMOVE ${FLATBUFFERS_COMPILATION_TIMINGS})
|
||||
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "time -f 'Wall: %E User: %U Sys: %S | %C' -q -a -o ${FLATBUFFERS_COMPILATION_TIMINGS}")
|
||||
set_property(GLOBAL PROPERTY RULE_LAUNCH_CUSTOM "time -f 'Wall: %E User: %U Sys: %S | %C' -q -a -o ${FLATBUFFERS_COMPILATION_TIMINGS}")
|
||||
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK "time -f 'Wall: %E User: %U Sys: %S | %C' -q -a -o ${FLATBUFFERS_COMPILATION_TIMINGS}")
|
||||
endif()
|
||||
|
||||
if(NOT FLATBUFFERS_BUILD_FLATC AND FLATBUFFERS_BUILD_TESTS)
|
||||
message(WARNING
|
||||
@@ -95,7 +98,7 @@ if(NOT DEFINED FLATBUFFERS_LOCALE_INDEPENDENT)
|
||||
include(CheckCXXSymbolExists)
|
||||
|
||||
set(FLATBUFFERS_LOCALE_INDEPENDENT 0)
|
||||
if(MSVC)
|
||||
if(MSVC_LIKE)
|
||||
check_cxx_symbol_exists(_strtof_l stdlib.h FLATBUFFERS_HAS_STRTOF_L)
|
||||
check_cxx_symbol_exists(_strtoui64_l stdlib.h FLATBUFFERS_HAS_STRTOULL_L)
|
||||
else()
|
||||
@@ -108,18 +111,26 @@ if(NOT DEFINED FLATBUFFERS_LOCALE_INDEPENDENT)
|
||||
endif()
|
||||
add_definitions(-DFLATBUFFERS_LOCALE_INDEPENDENT=$<BOOL:${FLATBUFFERS_LOCALE_INDEPENDENT}>)
|
||||
|
||||
if(NOT WIN32)
|
||||
check_symbol_exists(realpath "stdlib.h" HAVE_REALPATH)
|
||||
if(NOT HAVE_REALPATH)
|
||||
add_definitions(-DFLATBUFFERS_NO_ABSOLUTE_PATH_RESOLUTION)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(FlatBuffers_Library_SRCS
|
||||
include/flatbuffers/allocator.h
|
||||
include/flatbuffers/array.h
|
||||
include/flatbuffers/base.h
|
||||
include/flatbuffers/bfbs_generator.h
|
||||
include/flatbuffers/buffer.h
|
||||
include/flatbuffers/buffer_ref.h
|
||||
include/flatbuffers/default_allocator.h
|
||||
include/flatbuffers/detached_buffer.h
|
||||
include/flatbuffers/code_generator.h
|
||||
include/flatbuffers/flatbuffer_builder.h
|
||||
include/flatbuffers/flatbuffers.h
|
||||
include/flatbuffers/flexbuffers.h
|
||||
include/flatbuffers/flex_flat_util.h
|
||||
include/flatbuffers/hash.h
|
||||
include/flatbuffers/idl.h
|
||||
include/flatbuffers/minireflect.h
|
||||
@@ -142,6 +153,8 @@ set(FlatBuffers_Library_SRCS
|
||||
|
||||
set(FlatBuffers_Compiler_SRCS
|
||||
${FlatBuffers_Library_SRCS}
|
||||
src/idl_gen_binary.cpp
|
||||
src/idl_gen_text.cpp
|
||||
src/idl_gen_cpp.cpp
|
||||
src/idl_gen_csharp.cpp
|
||||
src/idl_gen_dart.cpp
|
||||
@@ -158,12 +171,21 @@ set(FlatBuffers_Compiler_SRCS
|
||||
src/idl_gen_grpc.cpp
|
||||
src/idl_gen_json_schema.cpp
|
||||
src/idl_gen_swift.cpp
|
||||
src/idl_namer.h
|
||||
src/namer.h
|
||||
src/flatc.cpp
|
||||
src/flatc_main.cpp
|
||||
src/bfbs_gen.h
|
||||
src/bfbs_gen_lua.h
|
||||
src/bfbs_gen_nim.h
|
||||
src/bfbs_namer.h
|
||||
include/flatbuffers/code_generators.h
|
||||
src/binary_annotator.h
|
||||
src/binary_annotator.cpp
|
||||
src/annotated_binary_text_gen.h
|
||||
src/annotated_binary_text_gen.cpp
|
||||
src/bfbs_gen_lua.cpp
|
||||
src/bfbs_gen_nim.cpp
|
||||
src/code_generators.cpp
|
||||
grpc/src/compiler/schema_interface.h
|
||||
grpc/src/compiler/cpp_generator.h
|
||||
@@ -188,13 +210,26 @@ set(FlatHash_SRCS
|
||||
set(FlatBuffers_Tests_SRCS
|
||||
${FlatBuffers_Library_SRCS}
|
||||
src/idl_gen_fbs.cpp
|
||||
tests/evolution_test.cpp
|
||||
tests/flexbuffers_test.cpp
|
||||
tests/fuzz_test.cpp
|
||||
tests/json_test.cpp
|
||||
tests/key_field_test.cpp
|
||||
tests/monster_test.cpp
|
||||
tests/optional_scalars_test.cpp
|
||||
tests/parser_test.cpp
|
||||
tests/proto_test.cpp
|
||||
tests/reflection_test.cpp
|
||||
tests/test.cpp
|
||||
tests/test_assert.h
|
||||
tests/test_assert.cpp
|
||||
tests/test_builder.h
|
||||
tests/test_builder.cpp
|
||||
tests/util_test.cpp
|
||||
tests/native_type_test_impl.h
|
||||
tests/native_type_test_impl.cpp
|
||||
tests/alignment_test.h
|
||||
tests/alignment_test.cpp
|
||||
include/flatbuffers/code_generators.h
|
||||
src/code_generators.cpp
|
||||
# file generate by running compiler on tests/monster_test.fbs
|
||||
@@ -214,6 +249,12 @@ set(FlatBuffers_Tests_SRCS
|
||||
${CMAKE_CURRENT_BINARY_DIR}/tests/monster_test_bfbs_generated.h
|
||||
# file generate by running compiler on tests/optional_scalars.fbs
|
||||
${CMAKE_CURRENT_BINARY_DIR}/tests/optional_scalars_generated.h
|
||||
# file generate by running compiler on tests/native_inline_table_test.fbs
|
||||
${CMAKE_CURRENT_BINARY_DIR}/tests/native_inline_table_test_generated.h
|
||||
# file generate by running compiler on tests/alignment_test.fbs
|
||||
${CMAKE_CURRENT_BINARY_DIR}/tests/alignment_test_generated.h
|
||||
# file generate by running compiler on tests/key_field/key_field_sample.fbs
|
||||
${CMAKE_CURRENT_BINARY_DIR}/tests/key_field/key_field_sample_generated.h
|
||||
)
|
||||
|
||||
set(FlatBuffers_Tests_CPP17_SRCS
|
||||
@@ -266,99 +307,15 @@ set(FlatBuffers_GRPCTest_SRCS
|
||||
${CMAKE_CURRENT_BINARY_DIR}/tests/monster_test_generated.h
|
||||
)
|
||||
|
||||
# source_group(Compiler FILES ${FlatBuffers_Compiler_SRCS})
|
||||
# source_group(Tests FILES ${FlatBuffers_Tests_SRCS})
|
||||
|
||||
if(EXISTS "${CMAKE_TOOLCHAIN_FILE}")
|
||||
# do not apply any global settings if the toolchain
|
||||
# is being configured externally
|
||||
message(STATUS "Using toolchain file: ${CMAKE_TOOLCHAIN_FILE}.")
|
||||
elseif(CMAKE_COMPILER_IS_GNUCXX)
|
||||
if(CYGWIN)
|
||||
set(CMAKE_CXX_FLAGS
|
||||
"${CMAKE_CXX_FLAGS} -std=gnu++11")
|
||||
else(CYGWIN)
|
||||
set(CMAKE_CXX_FLAGS
|
||||
"${CMAKE_CXX_FLAGS} -std=c++0x")
|
||||
endif(CYGWIN)
|
||||
set(CMAKE_CXX_FLAGS
|
||||
"${CMAKE_CXX_FLAGS} -Wall -pedantic -Werror -Wextra -Werror=shadow")
|
||||
set(FLATBUFFERS_PRIVATE_CXX_FLAGS "-Wold-style-cast")
|
||||
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.4)
|
||||
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 7.0)
|
||||
set(CMAKE_CXX_FLAGS
|
||||
"${CMAKE_CXX_FLAGS} -faligned-new -Werror=implicit-fallthrough=2")
|
||||
endif()
|
||||
set(CMAKE_CXX_FLAGS
|
||||
"${CMAKE_CXX_FLAGS} -Wunused-result -Werror=unused-result -Wunused-parameter -Werror=unused-parameter")
|
||||
endif()
|
||||
|
||||
# Certain platforms such as ARM do not use signed chars by default
|
||||
# which causes issues with certain bounds checks.
|
||||
set(CMAKE_CXX_FLAGS
|
||||
"${CMAKE_CXX_FLAGS} -fsigned-char")
|
||||
|
||||
# MSVC **MUST** come before the Clang check, as clang-cl is flagged by CMake as "MSVC", but it still textually
|
||||
# matches as Clang in its Compiler Id :)
|
||||
# Note: in CMake >= 3.14 we can check CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "GNU" or "MSVC" to differentiate...
|
||||
elseif(MSVC)
|
||||
# Visual Studio pedantic build settings
|
||||
# warning C4512: assignment operator could not be generated
|
||||
# warning C4316: object allocated on the heap may not be aligned
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4 /WX /wd4512 /wd4316")
|
||||
|
||||
if(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D_CRT_SECURE_NO_WARNINGS")
|
||||
endif()
|
||||
|
||||
elseif(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
|
||||
if(APPLE)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
|
||||
|
||||
if(FLATBUFFERS_OSX_BUILD_UNIVERSAL)
|
||||
set(CMAKE_OSX_ARCHITECTURES "arm64;x86_64")
|
||||
endif()
|
||||
else()
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
|
||||
endif()
|
||||
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pedantic -Werror -Wextra -Wno-unused-parameter")
|
||||
set(FLATBUFFERS_PRIVATE_CXX_FLAGS "-Wold-style-cast")
|
||||
if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.8)
|
||||
list(APPEND FLATBUFFERS_PRIVATE_CXX_FLAGS "-Wimplicit-fallthrough" "-Wextra-semi" "-Werror=unused-private-field") # enable warning
|
||||
endif()
|
||||
if(FLATBUFFERS_LIBCXX_WITH_CLANG)
|
||||
if(NOT "${CMAKE_SYSTEM_NAME}" MATCHES "Linux")
|
||||
set(CMAKE_CXX_FLAGS
|
||||
"${CMAKE_CXX_FLAGS} -stdlib=libc++")
|
||||
endif()
|
||||
if(NOT ("${CMAKE_SYSTEM_NAME}" MATCHES "FreeBSD" OR
|
||||
"${CMAKE_SYSTEM_NAME}" MATCHES "Linux"))
|
||||
set(CMAKE_EXE_LINKER_FLAGS
|
||||
"${CMAKE_EXE_LINKER_FLAGS} -lc++abi")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Certain platforms such as ARM do not use signed chars by default
|
||||
# which causes issues with certain bounds checks.
|
||||
set(CMAKE_CXX_FLAGS
|
||||
"${CMAKE_CXX_FLAGS} -fsigned-char")
|
||||
|
||||
endif()
|
||||
|
||||
# TODO(dbaileychess): Figure out how this would now work. I posted a question on
|
||||
# https://stackoverflow.com/questions/71772330/override-target-compile-options-via-cmake-command-line.
|
||||
# Append FLATBUFFERS_CXX_FLAGS to CMAKE_CXX_FLAGS.
|
||||
if(DEFINED FLATBUFFERS_CXX_FLAGS AND NOT EXISTS "${CMAKE_TOOLCHAIN_FILE}")
|
||||
if(DEFINED FLATBUFFERS_CXX_FLAGS)
|
||||
message(STATUS "extend CXX_FLAGS with ${FLATBUFFERS_CXX_FLAGS}")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${FLATBUFFERS_CXX_FLAGS}")
|
||||
endif()
|
||||
message(STATUS "CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}")
|
||||
|
||||
if(FLATBUFFERS_CODE_COVERAGE)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -fprofile-arcs -ftest-coverage")
|
||||
set(CMAKE_EXE_LINKER_FLAGS
|
||||
"${CMAKE_EXE_LINKER_FLAGS} -fprofile-arcs -ftest-coverage")
|
||||
endif()
|
||||
|
||||
function(add_fsanitize_to_target _target _sanitizer)
|
||||
if(WIN32)
|
||||
target_compile_definitions(${_target} PRIVATE FLATBUFFERS_MEMORY_LEAK_TRACKING)
|
||||
@@ -366,9 +323,7 @@ function(add_fsanitize_to_target _target _sanitizer)
|
||||
else()
|
||||
# FLATBUFFERS_CODE_SANITIZE: boolean {ON,OFF,YES,NO} or string with list of sanitizer.
|
||||
# List of sanitizer is string starts with '=': "=address,undefined,thread,memory".
|
||||
if((${CMAKE_CXX_COMPILER_ID} MATCHES "Clang") OR
|
||||
((${CMAKE_CXX_COMPILER_ID} MATCHES "GNU") AND NOT (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.9"))
|
||||
)
|
||||
if(IS_CLANG OR (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 4.9))
|
||||
set(_sanitizer_flags "=address,undefined")
|
||||
if(_sanitizer MATCHES "=.*")
|
||||
# override default by user-defined sanitizer list
|
||||
@@ -379,13 +334,14 @@ function(add_fsanitize_to_target _target _sanitizer)
|
||||
"-fsanitize${_sanitizer_flags}")
|
||||
target_link_libraries(${_target} PRIVATE
|
||||
"-fsanitize${_sanitizer_flags}")
|
||||
set_property(TARGET ${_target} PROPERTY POSITION_INDEPENDENT_CODE ON)
|
||||
set_target_properties(${_target} PROPERTIES POSITION_INDEPENDENT_CODE ON)
|
||||
message(STATUS "Sanitizer ${_sanitizer_flags} added to ${_target}")
|
||||
endif()
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
function(add_pch_to_target _target _pch_header)
|
||||
# the command is available since cmake 3.16
|
||||
if(COMMAND target_precompile_headers)
|
||||
target_precompile_headers(${_target} PRIVATE ${_pch_header})
|
||||
if(NOT MSVC)
|
||||
@@ -397,12 +353,121 @@ endfunction()
|
||||
include_directories(include)
|
||||
include_directories(grpc)
|
||||
|
||||
# Creates an interface library that stores the configuration settings that each
|
||||
# target links too. This is a compromise between setting configuration globally
|
||||
# with add_compile_options() and the more targetted target_compile_options().
|
||||
# This way each target in this file can share settings and override them if
|
||||
# needed.
|
||||
add_library(ProjectConfig INTERFACE)
|
||||
target_compile_features(ProjectConfig
|
||||
INTERFACE
|
||||
cxx_std_${FLATBUFFERS_CPP_STD}
|
||||
)
|
||||
|
||||
# Force the standard to be met.
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
# We shouldn't rely on any compiler-extensions to make things work.
|
||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
|
||||
if(MSVC_LIKE)
|
||||
target_compile_options(ProjectConfig
|
||||
INTERFACE
|
||||
/W4
|
||||
$<$<BOOL:${FLATBUFFERS_STRICT_MODE}>:
|
||||
/WX # Treat all compiler warnings as errors
|
||||
>
|
||||
/wd4512 # C4512: assignment operator could not be generated
|
||||
/wd4316 # C4316: object allocated on the heap may not be aligned
|
||||
/wd4456 # C4456: hides previous local declaration
|
||||
$<$<CXX_COMPILER_ID:Clang>:
|
||||
/D_CRT_SECURE_NO_WARNINGS
|
||||
>
|
||||
)
|
||||
else()
|
||||
target_compile_options(ProjectConfig
|
||||
INTERFACE
|
||||
-Wall
|
||||
$<$<BOOL:${FLATBUFFERS_STRICT_MODE}>:
|
||||
-Werror # Treat all compiler warnings as errors
|
||||
|
||||
-fno-rtti # Disable runtime type information
|
||||
|
||||
$<$<CXX_COMPILER_ID:GNU>:
|
||||
# False positive string overflow
|
||||
# https://github.com/google/flatbuffers/issues/7366
|
||||
-Wno-error=stringop-overflow
|
||||
>
|
||||
>
|
||||
-pedantic
|
||||
-Wextra
|
||||
-Wno-unused-parameter
|
||||
-Wold-style-cast
|
||||
-fsigned-char
|
||||
-Wnon-virtual-dtor
|
||||
|
||||
# This isn't working for some reason: $<$<CXX_COMPILER_ID:CLANG>:
|
||||
$<$<BOOL:${IS_CLANG}>:
|
||||
-Wnewline-eof
|
||||
-Wno-unknown-warning-option
|
||||
-Wmissing-declarations
|
||||
-Wzero-as-null-pointer-constant
|
||||
$<$<VERSION_GREATER:$<CXX_COMPILER_VERSION>,3.8>:
|
||||
-Wimplicit-fallthrough
|
||||
-Wextra-semi
|
||||
$<$<BOOL:${FLATBUFFERS_STRICT_MODE}>:
|
||||
-Werror=unused-private-field
|
||||
>
|
||||
>
|
||||
>
|
||||
|
||||
$<$<CXX_COMPILER_ID:GNU>:
|
||||
$<$<VERSION_GREATER:$<CXX_COMPILER_VERSION>,4.4>:
|
||||
-Wunused-result
|
||||
-Wunused-parameter
|
||||
-Werror=unused-parameter
|
||||
-Wmissing-declarations
|
||||
>
|
||||
$<$<VERSION_GREATER:$<CXX_COMPILER_VERSION>,4.7>:
|
||||
-Wzero-as-null-pointer-constant
|
||||
>
|
||||
$<$<VERSION_GREATER:$<CXX_COMPILER_VERSION>,7.0>:
|
||||
-faligned-new
|
||||
$<$<BOOL:${FLATBUFFERS_STRICT_MODE}>:
|
||||
-Werror=implicit-fallthrough=2
|
||||
>
|
||||
>
|
||||
$<$<VERSION_GREATER:$<CXX_COMPILER_VERSION>,8.0>:
|
||||
-Wextra-semi
|
||||
>
|
||||
>
|
||||
|
||||
$<$<BOOL:${FLATBUFFERS_CODE_COVERAGE}>:
|
||||
-g
|
||||
-fprofile-arcs
|
||||
-ftest-coverage
|
||||
>
|
||||
)
|
||||
|
||||
if(FLATBUFFERS_CODE_COVERAGE)
|
||||
target_link_options(ProjectConfig
|
||||
INTERFACE
|
||||
-fprofile-arcs
|
||||
-ftest-coverage
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(FLATBUFFERS_BUILD_FLATLIB)
|
||||
add_library(flatbuffers STATIC ${FlatBuffers_Library_SRCS})
|
||||
|
||||
# Attach header directory for when build via add_subdirectory().
|
||||
target_include_directories(flatbuffers INTERFACE
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>)
|
||||
target_compile_options(flatbuffers PRIVATE "${FLATBUFFERS_PRIVATE_CXX_FLAGS}")
|
||||
target_include_directories(flatbuffers
|
||||
INTERFACE
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||
)
|
||||
target_link_libraries(flatbuffers PRIVATE $<BUILD_INTERFACE:ProjectConfig>)
|
||||
|
||||
if(FLATBUFFERS_ENABLE_PCH)
|
||||
add_pch_to_target(flatbuffers include/flatbuffers/pch/pch.h)
|
||||
endif()
|
||||
@@ -413,17 +478,21 @@ if(FLATBUFFERS_BUILD_FLATC)
|
||||
if(FLATBUFFERS_ENABLE_PCH)
|
||||
add_pch_to_target(flatc include/flatbuffers/pch/flatc_pch.h)
|
||||
endif()
|
||||
target_compile_options(flatc PRIVATE "${FLATBUFFERS_PRIVATE_CXX_FLAGS}")
|
||||
|
||||
target_link_libraries(flatc PRIVATE $<BUILD_INTERFACE:ProjectConfig>)
|
||||
target_compile_options(flatc
|
||||
PRIVATE
|
||||
$<$<AND:$<BOOL:${MSVC_LIKE}>,$<CONFIG:Release>>:
|
||||
/MT
|
||||
>
|
||||
)
|
||||
|
||||
if(FLATBUFFERS_CODE_SANITIZE AND NOT WIN32)
|
||||
add_fsanitize_to_target(flatc ${FLATBUFFERS_CODE_SANITIZE})
|
||||
endif()
|
||||
if(NOT FLATBUFFERS_FLATC_EXECUTABLE)
|
||||
set(FLATBUFFERS_FLATC_EXECUTABLE $<TARGET_FILE:flatc>)
|
||||
endif()
|
||||
if(MSVC)
|
||||
# Make flatc.exe not depend on runtime dlls for easy distribution.
|
||||
target_compile_options(flatc PUBLIC $<$<CONFIG:Release>:/MT>)
|
||||
endif()
|
||||
if(FLATBUFFERS_STATIC_FLATC AND NOT MSVC)
|
||||
target_link_libraries(flatc PRIVATE -static)
|
||||
endif()
|
||||
@@ -431,19 +500,19 @@ endif()
|
||||
|
||||
if(FLATBUFFERS_BUILD_FLATHASH)
|
||||
add_executable(flathash ${FlatHash_SRCS})
|
||||
target_link_libraries(flathash PRIVATE $<BUILD_INTERFACE:ProjectConfig>)
|
||||
endif()
|
||||
|
||||
if(FLATBUFFERS_BUILD_SHAREDLIB)
|
||||
add_library(flatbuffers_shared SHARED ${FlatBuffers_Library_SRCS})
|
||||
|
||||
# Shared object version: "major.minor.micro"
|
||||
# - micro updated every release when there is no API/ABI changes
|
||||
# - minor updated when there are additions in API/ABI
|
||||
# - major (ABI number) updated when there are changes in ABI (or removals)
|
||||
set(FlatBuffers_Library_SONAME_MAJOR ${VERSION_MAJOR})
|
||||
set(FlatBuffers_Library_SONAME_FULL "${FlatBuffers_Library_SONAME_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
|
||||
set_target_properties(flatbuffers_shared PROPERTIES OUTPUT_NAME flatbuffers
|
||||
SOVERSION "${FlatBuffers_Library_SONAME_MAJOR}"
|
||||
target_link_libraries(flatbuffers_shared PRIVATE $<BUILD_INTERFACE:ProjectConfig>)
|
||||
# FlatBuffers use calendar-based versioning and do not provide any ABI
|
||||
# stability guarantees. Therefore, always use the full version as SOVERSION
|
||||
# in order to avoid breaking reverse dependencies on upgrades.
|
||||
set(FlatBuffers_Library_SONAME_FULL "${PROJECT_VERSION}")
|
||||
set_target_properties(flatbuffers_shared PROPERTIES
|
||||
OUTPUT_NAME flatbuffers
|
||||
SOVERSION "${FlatBuffers_Library_SONAME_FULL}"
|
||||
VERSION "${FlatBuffers_Library_SONAME_FULL}")
|
||||
if(FLATBUFFERS_ENABLE_PCH)
|
||||
add_pch_to_target(flatbuffers_shared include/flatbuffers/pch/pch.h)
|
||||
@@ -501,7 +570,7 @@ function(compile_flatbuffers_schema_to_binary SRC_FBS)
|
||||
OUTPUT ${GEN_BINARY_SCHEMA}
|
||||
COMMAND "${FLATBUFFERS_FLATC_EXECUTABLE}"
|
||||
-b --schema --bfbs-comments --bfbs-builtins
|
||||
--bfbs-filenames ${SRC_FBS_DIR}
|
||||
--bfbs-filenames "${CMAKE_CURRENT_SOURCE_DIR}/${SRC_FBS_DIR}"
|
||||
-I "${CMAKE_CURRENT_SOURCE_DIR}/tests/include_test"
|
||||
-o "${SRC_FBS_DIR}"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/${SRC_FBS}"
|
||||
@@ -536,30 +605,6 @@ function(compile_flatbuffers_schema_to_embedded_binary SRC_FBS OPT)
|
||||
register_generated_output(${GEN_BFBS_HEADER})
|
||||
endfunction()
|
||||
|
||||
# Look if we have python 3.5 installed so that we can run the generate code
|
||||
# python script after flatc is built.
|
||||
find_package(Python3 3.5 COMPONENTS Interpreter)
|
||||
|
||||
if(Python3_Interpreter_FOUND)
|
||||
set(GENERATION_OPTS --flatc "${FLATBUFFERS_FLATC_EXECUTABLE}")
|
||||
if(FLATBUFFERS_BUILD_LEGACY)
|
||||
# Need to set --cpp-std c++-0x options
|
||||
set(GENERATION_OPTS ${GENERATION_OPTS}--cpp-0x)
|
||||
endif()
|
||||
if(FLATBUFFERS_SKIP_MONSTER_EXTRA)
|
||||
set(GENERATION_OPTS ${GENERATION_OPTS} --skip-monster-extra)
|
||||
endif()
|
||||
add_custom_command(
|
||||
TARGET flatc
|
||||
POST_BUILD
|
||||
COMMAND ${Python3_EXECUTABLE} scripts/generate_code.py ${GENERATION_OPTS} --skip-gen-reflection
|
||||
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
COMMENT "Running scripts/generate_code.py..."
|
||||
VERBATIM)
|
||||
else()
|
||||
message("No Python3 interpreter found! Unable to generate files automatically.")
|
||||
endif()
|
||||
|
||||
if(FLATBUFFERS_BUILD_TESTS)
|
||||
file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/tests" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}")
|
||||
file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/samples" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}")
|
||||
@@ -569,21 +614,24 @@ if(FLATBUFFERS_BUILD_TESTS)
|
||||
compile_flatbuffers_schema_to_binary(tests/monster_test.fbs)
|
||||
compile_flatbuffers_schema_to_cpp_opt(tests/namespace_test/namespace_test1.fbs "--no-includes;--gen-compare;--gen-name-strings")
|
||||
compile_flatbuffers_schema_to_cpp_opt(tests/namespace_test/namespace_test2.fbs "--no-includes;--gen-compare;--gen-name-strings")
|
||||
compile_flatbuffers_schema_to_cpp_opt(tests/union_vector/union_vector.fbs "--no-includes;--gen-compare;--gen-name-strings")
|
||||
compile_flatbuffers_schema_to_cpp_opt(tests/union_vector/union_vector.fbs "--no-includes;--gen-compare;")
|
||||
compile_flatbuffers_schema_to_cpp(tests/optional_scalars.fbs)
|
||||
compile_flatbuffers_schema_to_cpp_opt(tests/native_type_test.fbs "")
|
||||
compile_flatbuffers_schema_to_cpp_opt(tests/arrays_test.fbs "--scoped-enums;--gen-compare")
|
||||
compile_flatbuffers_schema_to_binary(tests/arrays_test.fbs)
|
||||
compile_flatbuffers_schema_to_embedded_binary(tests/monster_test.fbs "--no-includes;--gen-compare")
|
||||
compile_flatbuffers_schema_to_cpp(tests/native_inline_table_test.fbs "--gen-compare")
|
||||
compile_flatbuffers_schema_to_cpp(tests/alignment_test.fbs "--gen-compare")
|
||||
compile_flatbuffers_schema_to_cpp(tests/key_field/key_field_sample.fbs)
|
||||
if(NOT (MSVC AND (MSVC_VERSION LESS 1900)))
|
||||
compile_flatbuffers_schema_to_cpp(tests/monster_extra.fbs) # Test floating-point NAN/INF.
|
||||
endif()
|
||||
include_directories(${CMAKE_CURRENT_BINARY_DIR}/tests)
|
||||
add_executable(flattests ${FlatBuffers_Tests_SRCS})
|
||||
target_link_libraries(flattests PRIVATE $<BUILD_INTERFACE:ProjectConfig>)
|
||||
|
||||
add_dependencies(flattests generated_code)
|
||||
set_property(TARGET flattests
|
||||
PROPERTY COMPILE_DEFINITIONS FLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE
|
||||
FLATBUFFERS_DEBUG_VERIFICATION_FAILURE=1)
|
||||
|
||||
if(FLATBUFFERS_CODE_SANITIZE)
|
||||
add_fsanitize_to_target(flattests ${FLATBUFFERS_CODE_SANITIZE})
|
||||
endif()
|
||||
@@ -591,24 +639,27 @@ if(FLATBUFFERS_BUILD_TESTS)
|
||||
compile_flatbuffers_schema_to_cpp(samples/monster.fbs)
|
||||
compile_flatbuffers_schema_to_binary(samples/monster.fbs)
|
||||
include_directories(${CMAKE_CURRENT_BINARY_DIR}/samples)
|
||||
|
||||
add_executable(flatsamplebinary ${FlatBuffers_Sample_Binary_SRCS})
|
||||
target_link_libraries(flatsamplebinary PRIVATE $<BUILD_INTERFACE:ProjectConfig>)
|
||||
add_dependencies(flatsamplebinary generated_code)
|
||||
|
||||
add_executable(flatsampletext ${FlatBuffers_Sample_Text_SRCS})
|
||||
target_link_libraries(flatsampletext PRIVATE $<BUILD_INTERFACE:ProjectConfig>)
|
||||
add_dependencies(flatsampletext generated_code)
|
||||
|
||||
add_executable(flatsamplebfbs ${FlatBuffers_Sample_BFBS_SRCS})
|
||||
target_link_libraries(flatsamplebfbs PRIVATE $<BUILD_INTERFACE:ProjectConfig>)
|
||||
add_dependencies(flatsamplebfbs generated_code)
|
||||
|
||||
if(FLATBUFFERS_BUILD_CPP17)
|
||||
# Don't generate header for flattests_cpp17 target.
|
||||
# This target uses "generated_cpp17/monster_test_generated.h"
|
||||
# produced by direct call of generate_code.py script.
|
||||
add_executable(flattests_cpp17 ${FlatBuffers_Tests_CPP17_SRCS})
|
||||
add_dependencies(flattests_cpp17 generated_code)
|
||||
target_compile_features(flattests_cpp17 PRIVATE cxx_std_17)
|
||||
target_compile_definitions(flattests_cpp17 PRIVATE
|
||||
FLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE
|
||||
FLATBUFFERS_DEBUG_VERIFICATION_FAILURE=1
|
||||
)
|
||||
target_link_libraries(flattests_cpp17 PRIVATE $<BUILD_INTERFACE:ProjectConfig>)
|
||||
target_compile_features(flattests_cpp17 PRIVATE cxx_std_17) # requires cmake 3.8
|
||||
|
||||
if(FLATBUFFERS_CODE_SANITIZE)
|
||||
add_fsanitize_to_target(flattests_cpp17 ${FLATBUFFERS_CODE_SANITIZE})
|
||||
endif()
|
||||
@@ -616,9 +667,6 @@ if(FLATBUFFERS_BUILD_TESTS)
|
||||
endif()
|
||||
|
||||
if(FLATBUFFERS_BUILD_GRPCTEST)
|
||||
if(CMAKE_COMPILER_IS_GNUCXX)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-parameter -Wno-shadow")
|
||||
endif()
|
||||
if(NOT GRPC_INSTALL_PATH)
|
||||
message(SEND_ERROR "GRPC_INSTALL_PATH variable is not defined. See grpc/README.md")
|
||||
endif()
|
||||
@@ -634,14 +682,16 @@ if(FLATBUFFERS_BUILD_GRPCTEST)
|
||||
find_package(gRPC CONFIG REQUIRED)
|
||||
add_executable(grpctest ${FlatBuffers_GRPCTest_SRCS})
|
||||
add_dependencies(grpctest generated_code)
|
||||
target_link_libraries(grpctest PRIVATE gRPC::grpc++_unsecure gRPC::grpc_unsecure gRPC::gpr pthread dl)
|
||||
if(FLATBUFFERS_CODE_SANITIZE AND NOT WIN32)
|
||||
# GRPC test has problems with alignment and will fail under ASAN/UBSAN.
|
||||
# add_fsanitize_to_target(grpctest ${FLATBUFFERS_CODE_SANITIZE})
|
||||
endif()
|
||||
target_link_libraries(grpctext
|
||||
PRIVATE
|
||||
$<BUILD_INTERFACE:ProjectConfig>
|
||||
gRPC::grpc++_unsecure
|
||||
gRPC::gpr
|
||||
pthread
|
||||
dl
|
||||
)
|
||||
endif()
|
||||
|
||||
|
||||
if(FLATBUFFERS_INSTALL)
|
||||
include(GNUInstallDirs)
|
||||
|
||||
@@ -649,21 +699,24 @@ if(FLATBUFFERS_INSTALL)
|
||||
|
||||
set(FB_CMAKE_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/flatbuffers")
|
||||
|
||||
configure_file(CMake/FlatbuffersConfigVersion.cmake.in FlatbuffersConfigVersion.cmake @ONLY)
|
||||
configure_file(CMake/flatbuffers-config-version.cmake.in flatbuffers-config-version.cmake @ONLY)
|
||||
install(
|
||||
FILES "CMake/FlatbuffersConfig.cmake" "${CMAKE_CURRENT_BINARY_DIR}/FlatbuffersConfigVersion.cmake"
|
||||
FILES
|
||||
"CMake/flatbuffers-config.cmake"
|
||||
"CMake/BuildFlatBuffers.cmake"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/flatbuffers-config-version.cmake"
|
||||
DESTINATION ${FB_CMAKE_DIR}
|
||||
)
|
||||
|
||||
if(FLATBUFFERS_BUILD_FLATLIB)
|
||||
install(
|
||||
TARGETS flatbuffers EXPORT FlatbuffersTargets
|
||||
TARGETS flatbuffers EXPORT FlatBuffersTargets
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
||||
)
|
||||
|
||||
install(EXPORT FlatbuffersTargets
|
||||
FILE FlatbuffersTargets.cmake
|
||||
install(EXPORT FlatBuffersTargets
|
||||
FILE FlatBuffersTargets.cmake
|
||||
NAMESPACE flatbuffers::
|
||||
DESTINATION ${FB_CMAKE_DIR}
|
||||
)
|
||||
@@ -685,7 +738,7 @@ if(FLATBUFFERS_INSTALL)
|
||||
|
||||
if(FLATBUFFERS_BUILD_SHAREDLIB)
|
||||
install(
|
||||
TARGETS flatbuffers_shared EXPORT FlatbuffersSharedTargets
|
||||
TARGETS flatbuffers_shared EXPORT FlatBuffersSharedTargets
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
@@ -693,8 +746,8 @@ if(FLATBUFFERS_INSTALL)
|
||||
)
|
||||
|
||||
install(
|
||||
EXPORT FlatbuffersSharedTargets
|
||||
FILE FlatbuffersSharedTargets.cmake
|
||||
EXPORT FlatBuffersSharedTargets
|
||||
FILE FlatBuffersSharedTargets.cmake
|
||||
NAMESPACE flatbuffers::
|
||||
DESTINATION ${FB_CMAKE_DIR}
|
||||
)
|
||||
@@ -756,4 +809,4 @@ add_library(FlatBuffers::FlatBuffers ALIAS FlatBuffers)
|
||||
target_include_directories(
|
||||
FlatBuffers
|
||||
INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/include>)
|
||||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/include>)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
Pod::Spec.new do |s|
|
||||
s.name = 'FlatBuffers'
|
||||
s.version = '2.0.0'
|
||||
s.version = '23.3.3'
|
||||
s.summary = 'FlatBuffers: Memory Efficient Serialization Library'
|
||||
|
||||
s.description = "FlatBuffers is a cross platform serialization library architected for
|
||||
@@ -11,11 +11,11 @@ Pod::Spec.new do |s|
|
||||
s.homepage = 'https://github.com/google/flatbuffers'
|
||||
s.license = { :type => 'Apache2.0', :file => 'LICENSE' }
|
||||
s.author = { 'mustii' => 'mustii@mmk.one' }
|
||||
s.source = { :git => 'https://github.com/mustiikhalil/flatbuffers.git', :tag => s.version.to_s, :submodules => true }
|
||||
s.source = { :git => 'https://github.com/google/flatbuffers.git', :tag => s.version.to_s, :submodules => true }
|
||||
|
||||
s.ios.deployment_target = '11.0'
|
||||
s.osx.deployment_target = '10.14'
|
||||
|
||||
s.swift_version = '5.0'
|
||||
s.source_files = 'Sources/**/*'
|
||||
s.source_files = 'swift/Sources/Flatbuffers/*.swift'
|
||||
end
|
||||
@@ -32,5 +32,6 @@ let package = Package(
|
||||
.target(
|
||||
name: "FlatBuffers",
|
||||
dependencies: [],
|
||||
path: "swift/Sources",
|
||||
exclude: ["Documentation.docc/Resources/code/swift"]),
|
||||
])
|
||||
@@ -31,6 +31,7 @@ let package = Package(
|
||||
targets: [
|
||||
.target(
|
||||
name: "FlatBuffers",
|
||||
dependencies: []),
|
||||
dependencies: [],
|
||||
path: "swift/Sources"),
|
||||
])
|
||||
|
||||
77
WORKSPACE
77
WORKSPACE
@@ -3,20 +3,47 @@ workspace(name = "com_github_google_flatbuffers")
|
||||
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
|
||||
|
||||
http_archive(
|
||||
name = "io_bazel_rules_go",
|
||||
sha256 = "d1ffd055969c8f8d431e2d439813e42326961d0942bdf734d2c95dc30c369566",
|
||||
name = "platforms",
|
||||
sha256 = "379113459b0feaf6bfbb584a91874c065078aa673222846ac765f86661c27407",
|
||||
urls = [
|
||||
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.24.5/rules_go-v0.24.5.tar.gz",
|
||||
"https://github.com/bazelbuild/rules_go/releases/download/v0.24.5/rules_go-v0.24.5.tar.gz",
|
||||
"https://mirror.bazel.build/github.com/bazelbuild/platforms/releases/download/0.0.5/platforms-0.0.5.tar.gz",
|
||||
"https://github.com/bazelbuild/platforms/releases/download/0.0.5/platforms-0.0.5.tar.gz",
|
||||
],
|
||||
)
|
||||
|
||||
load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
|
||||
http_archive(
|
||||
name = "build_bazel_rules_swift",
|
||||
sha256 = "a2fd565e527f83fb3f9eb07eb9737240e668c9242d3bc318712efa54a7deda97",
|
||||
url = "https://github.com/bazelbuild/rules_swift/releases/download/0.27.0/rules_swift.0.27.0.tar.gz",
|
||||
)
|
||||
|
||||
load(
|
||||
"@build_bazel_rules_swift//swift:repositories.bzl",
|
||||
"swift_rules_dependencies",
|
||||
)
|
||||
|
||||
swift_rules_dependencies()
|
||||
|
||||
load(
|
||||
"@build_bazel_rules_swift//swift:extras.bzl",
|
||||
"swift_rules_extra_dependencies",
|
||||
)
|
||||
|
||||
swift_rules_extra_dependencies()
|
||||
|
||||
http_archive(
|
||||
name = "io_bazel_rules_go",
|
||||
sha256 = "ae013bf35bd23234d1dea46b079f1e05ba74ac0321423830119d3e787ec73483",
|
||||
urls = [
|
||||
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.36.0/rules_go-v0.36.0.zip",
|
||||
"https://github.com/bazelbuild/rules_go/releases/download/v0.36.0/rules_go-v0.36.0.zip",
|
||||
],
|
||||
)
|
||||
|
||||
load("@io_bazel_rules_go//go:deps.bzl", "go_rules_dependencies")
|
||||
|
||||
go_rules_dependencies()
|
||||
|
||||
go_register_toolchains()
|
||||
|
||||
##### Protobuf
|
||||
_PROTOBUF_VERSION = "3.15.2"
|
||||
|
||||
@@ -29,12 +56,15 @@ http_archive(
|
||||
)
|
||||
|
||||
##### GRPC
|
||||
_GRPC_VERSION = "1.42.0"
|
||||
_GRPC_VERSION = "1.49.0" # https://github.com/grpc/grpc/releases/tag/v1.48.0
|
||||
|
||||
http_archive(
|
||||
name = "com_github_grpc_grpc",
|
||||
patch_args = ["-p1"],
|
||||
patches = ["//grpc:build_grpc_with_cxx14.patch"],
|
||||
sha256 = "15715e1847cc9e42014f02c727dbcb48e39dbdb90f79ad3d66fe4361709ff935",
|
||||
strip_prefix = "grpc-" + _GRPC_VERSION,
|
||||
urls = ["https://github.com/grpc/grpc/archive/v" + _GRPC_VERSION + ".tar.gz"],
|
||||
urls = ["https://github.com/grpc/grpc/archive/refs/tags/v" + _GRPC_VERSION + ".tar.gz"],
|
||||
)
|
||||
|
||||
load("@com_github_grpc_grpc//bazel:grpc_deps.bzl", "grpc_deps")
|
||||
@@ -44,3 +74,32 @@ grpc_deps()
|
||||
load("@com_github_grpc_grpc//bazel:grpc_extra_deps.bzl", "grpc_extra_deps")
|
||||
|
||||
grpc_extra_deps()
|
||||
|
||||
# rules_go from https://github.com/bazelbuild/rules_go/releases/tag/v0.34.0
|
||||
http_archive(
|
||||
name = "build_bazel_rules_nodejs",
|
||||
sha256 = "965ee2492a2b087cf9e0f2ca472aeaf1be2eb650e0cfbddf514b9a7d3ea4b02a",
|
||||
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/5.2.0/rules_nodejs-5.2.0.tar.gz"],
|
||||
)
|
||||
|
||||
load("@build_bazel_rules_nodejs//:repositories.bzl", "build_bazel_rules_nodejs_dependencies")
|
||||
|
||||
build_bazel_rules_nodejs_dependencies()
|
||||
|
||||
load("@build_bazel_rules_nodejs//:index.bzl", "node_repositories", "yarn_install")
|
||||
|
||||
node_repositories()
|
||||
|
||||
yarn_install(
|
||||
name = "npm",
|
||||
exports_directories_only = False,
|
||||
# Unfreeze to add/remove packages.
|
||||
frozen_lockfile = False,
|
||||
package_json = "//:package.json",
|
||||
symlink_node_modules = False,
|
||||
yarn_lock = "//:yarn.lock",
|
||||
)
|
||||
|
||||
load("@build_bazel_rules_nodejs//toolchains/esbuild:esbuild_repositories.bzl", "esbuild_repositories")
|
||||
|
||||
esbuild_repositories(npm_repository = "npm")
|
||||
|
||||
@@ -1,20 +1,22 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Copyright (c) 2014 Google, Inc.
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
-->
|
||||
<projectDescription>
|
||||
<name>FlatBufferTest</name>
|
||||
<name>FlatBufferTest</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
</natures>
|
||||
<filteredResources>
|
||||
<filter>
|
||||
<id>1677235311958</id>
|
||||
<name></name>
|
||||
<type>30</type>
|
||||
<matcher>
|
||||
<id>org.eclipse.core.resources.regexFilterMatcher</id>
|
||||
<arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
|
||||
</matcher>
|
||||
</filter>
|
||||
</filteredResources>
|
||||
</projectDescription>
|
||||
|
||||
@@ -3,10 +3,12 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.example.FlatBufferTest">
|
||||
|
||||
<uses-sdk android:minSdkVersion="14"/>
|
||||
<uses-feature android:glEsVersion="0x00020000"></uses-feature>
|
||||
|
||||
<!-- This .apk has no Java code itself, so set hasCode to false. -->
|
||||
<application android:label="@string/app_name"
|
||||
<application android:name="android.support.multidex.MultiDexApplication"
|
||||
android:label="@string/app_name"
|
||||
android:hasCode="false"
|
||||
android:allowBackup="false">
|
||||
<!-- Our activity is the built-in NativeActivity framework class.
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
apply plugin: 'com.android.application'
|
||||
apply plugin: 'kotlin-android'
|
||||
apply plugin: 'kotlin-android-extensions'
|
||||
|
||||
android {
|
||||
compileSdkVersion 30
|
||||
buildToolsVersion "30.0.2"
|
||||
compileSdk 33
|
||||
|
||||
defaultConfig {
|
||||
applicationId "com.flatbuffers.app"
|
||||
minSdkVersion 16
|
||||
targetSdkVersion 30
|
||||
minSdkVersion 26
|
||||
targetSdkVersion 33
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
|
||||
@@ -18,6 +16,18 @@ android {
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
main {
|
||||
java {
|
||||
srcDir '../../java/src/main/java/'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ndk {
|
||||
abiFilters 'arm64-v8a', 'armeabi-v7a'
|
||||
}
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
externalNativeBuild {
|
||||
cmake {
|
||||
@@ -33,7 +43,6 @@ android {
|
||||
}
|
||||
}
|
||||
|
||||
ndkVersion "21.3.6528147"
|
||||
externalNativeBuild {
|
||||
cmake {
|
||||
path "src/main/cpp/CMakeLists.txt"
|
||||
@@ -52,16 +61,17 @@ android {
|
||||
fbsFiles.forEach{
|
||||
commandLineArgs.add(it.path)
|
||||
}
|
||||
|
||||
commandLine commandLineArgs
|
||||
|
||||
doFirst {
|
||||
delete "$outputCppDir/"
|
||||
mkdir "$outputCppDir/"
|
||||
}
|
||||
|
||||
doLast {
|
||||
if (execResult.getExitValue() != 0) {
|
||||
println(standardOutput.toString())
|
||||
throw new GradleException("flatc command line failed")
|
||||
if (executionResult.get().exitValue != 0) {
|
||||
throw new GradleException("flatc failed with: ${executionResult.get().toString()}")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -74,6 +84,10 @@ android {
|
||||
|
||||
standardOutput = new ByteArrayOutputStream()
|
||||
errorOutput = new ByteArrayOutputStream()
|
||||
|
||||
setErrorOutput(errorOutput)
|
||||
setStandardOutput(standardOutput)
|
||||
|
||||
def commandLineArgs = ['flatc', '-o', outputKotlinDir, '--kotlin']
|
||||
fbsFiles.forEach{
|
||||
commandLineArgs.add(it.path)
|
||||
@@ -85,50 +99,27 @@ android {
|
||||
mkdir "$outputKotlinDir/"
|
||||
}
|
||||
doLast {
|
||||
if (execResult.getExitValue() != 0) {
|
||||
println(standardOutput.toString())
|
||||
throw new GradleException("flatc command line failed")
|
||||
if (executionResult.get().exitValue != 0) {
|
||||
throw new GradleException("flatc failed with: ${executionResult.get().toString()}")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
afterEvaluate {
|
||||
android.applicationVariants.all { variant ->
|
||||
variant.javaCompiler.dependsOn(generateFbsKotlin)
|
||||
variant.javaCompiler.dependsOn(generateFbsCpp)
|
||||
}
|
||||
}
|
||||
|
||||
flavorDimensions "stl-variant"
|
||||
productFlavors {
|
||||
gnustl {
|
||||
dimension "stl-variant"
|
||||
applicationIdSuffix ".gnustl"
|
||||
versionNameSuffix "-gnustl"
|
||||
externalNativeBuild {
|
||||
ndkBuild {
|
||||
arguments "APP_STL=gnustl_static"
|
||||
}
|
||||
}
|
||||
}
|
||||
libcpp {
|
||||
dimension "stl-variant"
|
||||
applicationIdSuffix ".libcpp"
|
||||
versionNameSuffix "-libcpp"
|
||||
externalNativeBuild {
|
||||
ndkBuild {
|
||||
arguments "APP_STL=c++_static"
|
||||
}
|
||||
}
|
||||
tasks.named("preBuild") {
|
||||
dependsOn(generateFbsKotlin)
|
||||
dependsOn(generateFbsCpp)
|
||||
}
|
||||
}
|
||||
namespace 'com.flatbuffers.app'
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation fileTree(dir: "libs", include: ["*.jar"])
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
||||
implementation 'androidx.core:core-ktx:1.3.2'
|
||||
implementation 'androidx.appcompat:appcompat:1.2.0'
|
||||
implementation 'com.google.flatbuffers:flatbuffers-java:2.0.0'
|
||||
implementation 'androidx.appcompat:appcompat:1.6.1'
|
||||
|
||||
// If you using java runtime you can add its dependency as the example below
|
||||
// implementation 'com.google.flatbuffers:flatbuffers-java:$latest_version'
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.flatbuffers.app">
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
@@ -9,7 +8,8 @@
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme">
|
||||
<activity android:name=".MainActivity">
|
||||
<activity android:name=".MainActivity"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@ set(FlatBuffers_Library_SRCS
|
||||
${FLATBUFFERS_SRC}/include/flatbuffers/allocator.h
|
||||
${FLATBUFFERS_SRC}/include/flatbuffers/array.h
|
||||
${FLATBUFFERS_SRC}/include/flatbuffers/base.h
|
||||
${FLATBUFFERS_SRC}/include/flatbuffers/bfbs_generator.h
|
||||
${FLATBUFFERS_SRC}/include/flatbuffers/buffer.h
|
||||
${FLATBUFFERS_SRC}/include/flatbuffers/buffer_ref.h
|
||||
${FLATBUFFERS_SRC}/include/flatbuffers/default_allocator.h
|
||||
@@ -26,6 +25,7 @@ set(FlatBuffers_Library_SRCS
|
||||
${FLATBUFFERS_SRC}/include/flatbuffers/flatbuffer_builder.h
|
||||
${FLATBUFFERS_SRC}/include/flatbuffers/flatbuffers.h
|
||||
${FLATBUFFERS_SRC}/include/flatbuffers/flexbuffers.h
|
||||
${FLATBUFFERS_SRC}/include/flatbuffers/flex_flat_util.h
|
||||
${FLATBUFFERS_SRC}/include/flatbuffers/hash.h
|
||||
${FLATBUFFERS_SRC}/include/flatbuffers/idl.h
|
||||
${FLATBUFFERS_SRC}/include/flatbuffers/minireflect.h
|
||||
|
||||
@@ -6,6 +6,13 @@
|
||||
|
||||
#include "flatbuffers/flatbuffers.h"
|
||||
|
||||
// Ensure the included flatbuffers.h is the same version as when this file was
|
||||
// generated, otherwise it may not be compatible.
|
||||
static_assert(FLATBUFFERS_VERSION_MAJOR == 23 &&
|
||||
FLATBUFFERS_VERSION_MINOR == 1 &&
|
||||
FLATBUFFERS_VERSION_REVISION == 21,
|
||||
"Non-compatible flatbuffers version included");
|
||||
|
||||
namespace com {
|
||||
namespace fbs {
|
||||
namespace app {
|
||||
@@ -13,62 +20,61 @@ namespace app {
|
||||
struct Animal;
|
||||
struct AnimalBuilder;
|
||||
|
||||
struct Animal FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
|
||||
struct Animal FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
||||
typedef AnimalBuilder Builder;
|
||||
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
|
||||
VT_NAME = 4,
|
||||
VT_SOUND = 6,
|
||||
VT_WEIGHT = 8
|
||||
};
|
||||
const flatbuffers::String *name() const {
|
||||
return GetPointer<const flatbuffers::String *>(VT_NAME);
|
||||
const ::flatbuffers::String *name() const {
|
||||
return GetPointer<const ::flatbuffers::String *>(VT_NAME);
|
||||
}
|
||||
const flatbuffers::String *sound() const {
|
||||
return GetPointer<const flatbuffers::String *>(VT_SOUND);
|
||||
const ::flatbuffers::String *sound() const {
|
||||
return GetPointer<const ::flatbuffers::String *>(VT_SOUND);
|
||||
}
|
||||
uint16_t weight() const {
|
||||
return GetField<uint16_t>(VT_WEIGHT, 0);
|
||||
}
|
||||
bool Verify(flatbuffers::Verifier &verifier) const {
|
||||
bool Verify(::flatbuffers::Verifier &verifier) const {
|
||||
return VerifyTableStart(verifier) &&
|
||||
VerifyOffset(verifier, VT_NAME) &&
|
||||
verifier.VerifyString(name()) &&
|
||||
VerifyOffset(verifier, VT_SOUND) &&
|
||||
verifier.VerifyString(sound()) &&
|
||||
VerifyField<uint16_t>(verifier, VT_WEIGHT) &&
|
||||
VerifyField<uint16_t>(verifier, VT_WEIGHT, 2) &&
|
||||
verifier.EndTable();
|
||||
}
|
||||
};
|
||||
|
||||
struct AnimalBuilder {
|
||||
typedef Animal Table;
|
||||
flatbuffers::FlatBufferBuilder &fbb_;
|
||||
flatbuffers::uoffset_t start_;
|
||||
void add_name(flatbuffers::Offset<flatbuffers::String> name) {
|
||||
::flatbuffers::FlatBufferBuilder &fbb_;
|
||||
::flatbuffers::uoffset_t start_;
|
||||
void add_name(::flatbuffers::Offset<::flatbuffers::String> name) {
|
||||
fbb_.AddOffset(Animal::VT_NAME, name);
|
||||
}
|
||||
void add_sound(flatbuffers::Offset<flatbuffers::String> sound) {
|
||||
void add_sound(::flatbuffers::Offset<::flatbuffers::String> sound) {
|
||||
fbb_.AddOffset(Animal::VT_SOUND, sound);
|
||||
}
|
||||
void add_weight(uint16_t weight) {
|
||||
fbb_.AddElement<uint16_t>(Animal::VT_WEIGHT, weight, 0);
|
||||
}
|
||||
explicit AnimalBuilder(flatbuffers::FlatBufferBuilder &_fbb)
|
||||
explicit AnimalBuilder(::flatbuffers::FlatBufferBuilder &_fbb)
|
||||
: fbb_(_fbb) {
|
||||
start_ = fbb_.StartTable();
|
||||
}
|
||||
AnimalBuilder &operator=(const AnimalBuilder &);
|
||||
flatbuffers::Offset<Animal> Finish() {
|
||||
::flatbuffers::Offset<Animal> Finish() {
|
||||
const auto end = fbb_.EndTable(start_);
|
||||
auto o = flatbuffers::Offset<Animal>(end);
|
||||
auto o = ::flatbuffers::Offset<Animal>(end);
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
inline flatbuffers::Offset<Animal> CreateAnimal(
|
||||
flatbuffers::FlatBufferBuilder &_fbb,
|
||||
flatbuffers::Offset<flatbuffers::String> name = 0,
|
||||
flatbuffers::Offset<flatbuffers::String> sound = 0,
|
||||
inline ::flatbuffers::Offset<Animal> CreateAnimal(
|
||||
::flatbuffers::FlatBufferBuilder &_fbb,
|
||||
::flatbuffers::Offset<::flatbuffers::String> name = 0,
|
||||
::flatbuffers::Offset<::flatbuffers::String> sound = 0,
|
||||
uint16_t weight = 0) {
|
||||
AnimalBuilder builder_(_fbb);
|
||||
builder_.add_sound(sound);
|
||||
@@ -77,8 +83,8 @@ inline flatbuffers::Offset<Animal> CreateAnimal(
|
||||
return builder_.Finish();
|
||||
}
|
||||
|
||||
inline flatbuffers::Offset<Animal> CreateAnimalDirect(
|
||||
flatbuffers::FlatBufferBuilder &_fbb,
|
||||
inline ::flatbuffers::Offset<Animal> CreateAnimalDirect(
|
||||
::flatbuffers::FlatBufferBuilder &_fbb,
|
||||
const char *name = nullptr,
|
||||
const char *sound = nullptr,
|
||||
uint16_t weight = 0) {
|
||||
@@ -92,32 +98,32 @@ inline flatbuffers::Offset<Animal> CreateAnimalDirect(
|
||||
}
|
||||
|
||||
inline const com::fbs::app::Animal *GetAnimal(const void *buf) {
|
||||
return flatbuffers::GetRoot<com::fbs::app::Animal>(buf);
|
||||
return ::flatbuffers::GetRoot<com::fbs::app::Animal>(buf);
|
||||
}
|
||||
|
||||
inline const com::fbs::app::Animal *GetSizePrefixedAnimal(const void *buf) {
|
||||
return flatbuffers::GetSizePrefixedRoot<com::fbs::app::Animal>(buf);
|
||||
return ::flatbuffers::GetSizePrefixedRoot<com::fbs::app::Animal>(buf);
|
||||
}
|
||||
|
||||
inline bool VerifyAnimalBuffer(
|
||||
flatbuffers::Verifier &verifier) {
|
||||
::flatbuffers::Verifier &verifier) {
|
||||
return verifier.VerifyBuffer<com::fbs::app::Animal>(nullptr);
|
||||
}
|
||||
|
||||
inline bool VerifySizePrefixedAnimalBuffer(
|
||||
flatbuffers::Verifier &verifier) {
|
||||
::flatbuffers::Verifier &verifier) {
|
||||
return verifier.VerifySizePrefixedBuffer<com::fbs::app::Animal>(nullptr);
|
||||
}
|
||||
|
||||
inline void FinishAnimalBuffer(
|
||||
flatbuffers::FlatBufferBuilder &fbb,
|
||||
flatbuffers::Offset<com::fbs::app::Animal> root) {
|
||||
::flatbuffers::FlatBufferBuilder &fbb,
|
||||
::flatbuffers::Offset<com::fbs::app::Animal> root) {
|
||||
fbb.Finish(root);
|
||||
}
|
||||
|
||||
inline void FinishSizePrefixedAnimalBuffer(
|
||||
flatbuffers::FlatBufferBuilder &fbb,
|
||||
flatbuffers::Offset<com::fbs::app::Animal> root) {
|
||||
::flatbuffers::FlatBufferBuilder &fbb,
|
||||
::flatbuffers::Offset<com::fbs::app::Animal> root) {
|
||||
fbb.FinishSizePrefixed(root);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,12 +2,24 @@
|
||||
|
||||
package com.fbs.app
|
||||
|
||||
import java.nio.*
|
||||
import com.google.flatbuffers.BaseVector
|
||||
import com.google.flatbuffers.BooleanVector
|
||||
import com.google.flatbuffers.ByteVector
|
||||
import com.google.flatbuffers.Constants
|
||||
import com.google.flatbuffers.DoubleVector
|
||||
import com.google.flatbuffers.FlatBufferBuilder
|
||||
import com.google.flatbuffers.FloatVector
|
||||
import com.google.flatbuffers.LongVector
|
||||
import com.google.flatbuffers.StringVector
|
||||
import com.google.flatbuffers.Struct
|
||||
import com.google.flatbuffers.Table
|
||||
import com.google.flatbuffers.UnionVector
|
||||
import java.nio.ByteBuffer
|
||||
import java.nio.ByteOrder
|
||||
import kotlin.math.sign
|
||||
import com.google.flatbuffers.*
|
||||
|
||||
@Suppress("unused")
|
||||
@ExperimentalUnsignedTypes
|
||||
@kotlin.ExperimentalUnsignedTypes
|
||||
class Animal : Table() {
|
||||
|
||||
fun __init(_i: Int, _bb: ByteBuffer) {
|
||||
@@ -20,14 +32,22 @@ class Animal : Table() {
|
||||
val name : String?
|
||||
get() {
|
||||
val o = __offset(4)
|
||||
return if (o != 0) __string(o + bb_pos) else null
|
||||
return if (o != 0) {
|
||||
__string(o + bb_pos)
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
||||
val nameAsByteBuffer : ByteBuffer get() = __vector_as_bytebuffer(4, 1)
|
||||
fun nameInByteBuffer(_bb: ByteBuffer) : ByteBuffer = __vector_in_bytebuffer(_bb, 4, 1)
|
||||
val sound : String?
|
||||
get() {
|
||||
val o = __offset(6)
|
||||
return if (o != 0) __string(o + bb_pos) else null
|
||||
return if (o != 0) {
|
||||
__string(o + bb_pos)
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
||||
val soundAsByteBuffer : ByteBuffer get() = __vector_as_bytebuffer(6, 1)
|
||||
fun soundInByteBuffer(_bb: ByteBuffer) : ByteBuffer = __vector_in_bytebuffer(_bb, 6, 1)
|
||||
@@ -37,7 +57,7 @@ class Animal : Table() {
|
||||
return if(o != 0) bb.getShort(o + bb_pos).toUShort() else 0u
|
||||
}
|
||||
companion object {
|
||||
fun validateVersion() = Constants.FLATBUFFERS_2_0_0()
|
||||
fun validateVersion() = Constants.FLATBUFFERS_23_3_3()
|
||||
fun getRootAsAnimal(_bb: ByteBuffer): Animal = getRootAsAnimal(_bb, Animal())
|
||||
fun getRootAsAnimal(_bb: ByteBuffer, obj: Animal): Animal {
|
||||
_bb.order(ByteOrder.LITTLE_ENDIAN)
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||
buildscript {
|
||||
ext.kotlin_version = "1.4.10"
|
||||
ext.kotlin_version = "1.7.21"
|
||||
repositories {
|
||||
google()
|
||||
jcenter()
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:4.1.0'
|
||||
classpath 'com.android.tools.build:gradle:7.4.1'
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
|
||||
// NOTE: Do not place your application dependencies here; they belong
|
||||
@@ -17,7 +17,7 @@ buildscript {
|
||||
allprojects {
|
||||
repositories {
|
||||
google()
|
||||
jcenter()
|
||||
mavenCentral()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,3 +19,5 @@ android.useAndroidX=true
|
||||
android.enableJetifier=true
|
||||
# Kotlin code style for this project: "official" or "obsolete":
|
||||
kotlin.code.style=official
|
||||
# Use parallel builds
|
||||
org.gradle.parallel=true
|
||||
BIN
android/gradle/wrapper/gradle-wrapper.jar
vendored
BIN
android/gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
@@ -1,6 +1,5 @@
|
||||
#Thu Oct 29 19:47:23 CET 2020
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.1-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
# Setup for running Google Benchmarks (https://github.com/google/benchmark) on
|
||||
# flatbuffers. This requires both that benchmark library and its depenency gtest
|
||||
# flatbuffers. This requires both that benchmark library and its dependency gtest
|
||||
# to build. Instead of including them here or doing a submodule, this uses
|
||||
# FetchContent (https://cmake.org/cmake/help/latest/module/FetchContent.html) to
|
||||
# grab the dependencies at config time. This requires CMake 3.14 or higher.
|
||||
|
||||
cmake_minimum_required(VERSION 3.14)
|
||||
include(FetchContent)
|
||||
|
||||
@@ -16,7 +17,7 @@ FetchContent_Declare(
|
||||
FetchContent_Declare(
|
||||
googlebenchmark
|
||||
GIT_REPOSITORY https://github.com/google/benchmark.git
|
||||
GIT_TAG f91b6b42b1b9854772a90ae9501464a161707d1e # v1.6.0
|
||||
GIT_TAG 0d98dba29d66e93259db7daa53a9327df767a415 # v1.6.1
|
||||
)
|
||||
|
||||
# For Windows: Prevent overriding the parent project's compiler/linker
|
||||
@@ -27,7 +28,7 @@ FetchContent_MakeAvailable(
|
||||
googlebenchmark
|
||||
)
|
||||
|
||||
set(CPP_BENCH_DIR cpp)
|
||||
set(CPP_BENCH_DIR ${CMAKE_CURRENT_SOURCE_DIR}/cpp)
|
||||
set(CPP_FB_BENCH_DIR ${CPP_BENCH_DIR}/flatbuffers)
|
||||
set(CPP_RAW_BENCH_DIR ${CPP_BENCH_DIR}/raw)
|
||||
set(CPP_BENCH_FBS ${CPP_FB_BENCH_DIR}/bench.fbs)
|
||||
@@ -62,8 +63,14 @@ add_custom_command(
|
||||
add_executable(flatbenchmark ${FlatBenchmark_SRCS})
|
||||
|
||||
# Benchmark requires C++11
|
||||
target_compile_features(flatbenchmark PUBLIC
|
||||
cxx_std_11
|
||||
target_compile_features(flatbenchmark PRIVATE
|
||||
cxx_std_11 # requires cmake 3.8
|
||||
)
|
||||
|
||||
target_compile_options(flatbenchmark
|
||||
PRIVATE
|
||||
-fno-aligned-new
|
||||
-Wno-deprecated-declarations
|
||||
)
|
||||
|
||||
# Set the output directory to the root binary directory
|
||||
@@ -75,7 +82,7 @@ set_target_properties(flatbenchmark
|
||||
# The includes of the benchmark files are fully qualified from flatbuffers root.
|
||||
target_include_directories(flatbenchmark PUBLIC ${CMAKE_SOURCE_DIR})
|
||||
|
||||
target_link_libraries(flatbenchmark
|
||||
target_link_libraries(flatbenchmark PRIVATE
|
||||
benchmark::benchmark_main # _main to use their entry point
|
||||
gtest # Link to gtest so we can also assert in the benchmarks
|
||||
)
|
||||
@@ -6,6 +6,13 @@
|
||||
|
||||
#include "flatbuffers/flatbuffers.h"
|
||||
|
||||
// Ensure the included flatbuffers.h is the same version as when this file was
|
||||
// generated, otherwise it may not be compatible.
|
||||
static_assert(FLATBUFFERS_VERSION_MAJOR == 2 &&
|
||||
FLATBUFFERS_VERSION_MINOR == 0 &&
|
||||
FLATBUFFERS_VERSION_REVISION == 6,
|
||||
"Non-compatible flatbuffers version included");
|
||||
|
||||
namespace benchmarks_flatbuffers {
|
||||
|
||||
struct Foo;
|
||||
@@ -157,11 +164,11 @@ struct FooBar FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
|
||||
}
|
||||
bool Verify(flatbuffers::Verifier &verifier) const {
|
||||
return VerifyTableStart(verifier) &&
|
||||
VerifyField<benchmarks_flatbuffers::Bar>(verifier, VT_SIBLING) &&
|
||||
VerifyField<benchmarks_flatbuffers::Bar>(verifier, VT_SIBLING, 8) &&
|
||||
VerifyOffset(verifier, VT_NAME) &&
|
||||
verifier.VerifyString(name()) &&
|
||||
VerifyField<double>(verifier, VT_RATING) &&
|
||||
VerifyField<uint8_t>(verifier, VT_POSTFIX) &&
|
||||
VerifyField<double>(verifier, VT_RATING, 8) &&
|
||||
VerifyField<uint8_t>(verifier, VT_POSTFIX, 1) &&
|
||||
verifier.EndTable();
|
||||
}
|
||||
};
|
||||
@@ -247,8 +254,8 @@ struct FooBarContainer FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
|
||||
VerifyOffset(verifier, VT_LIST) &&
|
||||
verifier.VerifyVector(list()) &&
|
||||
verifier.VerifyVectorOfTables(list()) &&
|
||||
VerifyField<uint8_t>(verifier, VT_INITIALIZED) &&
|
||||
VerifyField<int16_t>(verifier, VT_FRUIT) &&
|
||||
VerifyField<uint8_t>(verifier, VT_INITIALIZED, 1) &&
|
||||
VerifyField<int16_t>(verifier, VT_FRUIT, 2) &&
|
||||
VerifyOffset(verifier, VT_LOCATION) &&
|
||||
verifier.VerifyString(location()) &&
|
||||
verifier.EndTable();
|
||||
|
||||
@@ -16,7 +16,7 @@ struct FlatBufferBench : Bench {
|
||||
explicit FlatBufferBench(int64_t initial_size, Allocator *allocator)
|
||||
: fbb(initial_size, allocator, false) {}
|
||||
|
||||
uint8_t *Encode(void *, int64_t &len) {
|
||||
uint8_t *Encode(void *, int64_t &len) override {
|
||||
fbb.Clear();
|
||||
|
||||
const int kVectorLength = 3;
|
||||
@@ -40,7 +40,7 @@ struct FlatBufferBench : Bench {
|
||||
return fbb.GetBufferPointer();
|
||||
}
|
||||
|
||||
int64_t Use(void *decoded) {
|
||||
int64_t Use(void *decoded) override {
|
||||
sum = 0;
|
||||
auto foobarcontainer = GetFooBarContainer(decoded);
|
||||
sum = 0;
|
||||
@@ -65,8 +65,8 @@ struct FlatBufferBench : Bench {
|
||||
return sum;
|
||||
}
|
||||
|
||||
void *Decode(void *buffer, int64_t) { return buffer; }
|
||||
void Dealloc(void *) override{};
|
||||
void *Decode(void *buffer, int64_t) override { return buffer; }
|
||||
void Dealloc(void *) override {};
|
||||
|
||||
FlatBufferBuilder fbb;
|
||||
};
|
||||
|
||||
@@ -45,7 +45,7 @@ struct FooBarContainer {
|
||||
};
|
||||
|
||||
struct RawBench : Bench {
|
||||
uint8_t *Encode(void *buf, int64_t &len) {
|
||||
uint8_t *Encode(void *buf, int64_t &len) override {
|
||||
FooBarContainer *fbc = new (buf) FooBarContainer;
|
||||
strcpy(fbc->location, "http://google.com/flatbuffers/"); // Unsafe eek!
|
||||
fbc->location_len = (int)strlen(fbc->location);
|
||||
@@ -74,7 +74,7 @@ struct RawBench : Bench {
|
||||
return reinterpret_cast<uint8_t *>(fbc);
|
||||
};
|
||||
|
||||
int64_t Use(void *decoded) {
|
||||
int64_t Use(void *decoded) override {
|
||||
auto foobarcontainer = reinterpret_cast<FooBarContainer *>(decoded);
|
||||
sum = 0;
|
||||
Add(foobarcontainer->initialized);
|
||||
@@ -98,7 +98,7 @@ struct RawBench : Bench {
|
||||
return sum;
|
||||
}
|
||||
|
||||
void *Decode(void *buf, int64_t) { return buf; }
|
||||
void *Decode(void *buf, int64_t) override { return buf; }
|
||||
void Dealloc(void *) override{};
|
||||
};
|
||||
|
||||
|
||||
@@ -7,14 +7,23 @@ Rules for building C++ flatbuffers with Bazel.
|
||||
|
||||
load("@rules_cc//cc:defs.bzl", "cc_library")
|
||||
|
||||
flatc_path = "@com_github_google_flatbuffers//:flatc"
|
||||
TRUE_FLATC_PATH = "@com_github_google_flatbuffers//:flatc"
|
||||
|
||||
DEFAULT_INCLUDE_PATHS = [
|
||||
"./",
|
||||
"$(GENDIR)",
|
||||
"$(BINDIR)",
|
||||
"$(execpath @com_github_google_flatbuffers//:flatc).runfiles/com_github_google_flatbuffers",
|
||||
]
|
||||
|
||||
def default_include_paths(flatc_path):
|
||||
return [
|
||||
"./",
|
||||
"$(GENDIR)",
|
||||
"$(BINDIR)",
|
||||
"$(execpath %s).runfiles/com_github_google_flatbuffers" % (flatc_path),
|
||||
]
|
||||
|
||||
DEFAULT_FLATC_ARGS = [
|
||||
"--gen-object-api",
|
||||
"--gen-compare",
|
||||
@@ -31,12 +40,14 @@ def flatbuffer_library_public(
|
||||
language_flag,
|
||||
out_prefix = "",
|
||||
includes = [],
|
||||
include_paths = DEFAULT_INCLUDE_PATHS,
|
||||
include_paths = None,
|
||||
flatc_args = DEFAULT_FLATC_ARGS,
|
||||
reflection_name = "",
|
||||
reflection_visibility = None,
|
||||
compatible_with = None,
|
||||
restricted_to = None,
|
||||
target_compatible_with = None,
|
||||
flatc_path = "@com_github_google_flatbuffers//:flatc",
|
||||
output_to_bindir = False):
|
||||
"""Generates code files for reading/writing the given flatbuffers in the requested language using the public compiler.
|
||||
|
||||
@@ -58,6 +69,9 @@ def flatbuffer_library_public(
|
||||
built for, in addition to default-supported environments.
|
||||
restricted_to: Optional, The list of environments this rule can be built
|
||||
for, instead of default-supported environments.
|
||||
target_compatible_with: Optional, The list of target platform constraints
|
||||
to use.
|
||||
flatc_path: Bazel target corresponding to the flatc compiler to use.
|
||||
output_to_bindir: Passed to genrule for output to bin directory.
|
||||
|
||||
|
||||
@@ -65,6 +79,8 @@ def flatbuffer_library_public(
|
||||
optionally a Fileset([reflection_name]) with all generated reflection
|
||||
binaries.
|
||||
"""
|
||||
if include_paths == None:
|
||||
include_paths = default_include_paths(flatc_path)
|
||||
include_paths_cmd = ["-I %s" % (s) for s in include_paths]
|
||||
|
||||
# '$(@D)' when given a single source target will give the appropriate
|
||||
@@ -76,7 +92,7 @@ def flatbuffer_library_public(
|
||||
genrule_cmd = " ".join([
|
||||
"SRCS=($(SRCS));",
|
||||
"for f in $${SRCS[@]:0:%s}; do" % len(srcs),
|
||||
"$(location %s)" % (flatc_path),
|
||||
"OUTPUT_FILE=\"$(OUTS)\" $(location %s)" % (flatc_path),
|
||||
" ".join(include_paths_cmd),
|
||||
" ".join(flatc_args),
|
||||
language_flag,
|
||||
@@ -92,6 +108,7 @@ def flatbuffer_library_public(
|
||||
tools = [flatc_path],
|
||||
cmd = genrule_cmd,
|
||||
compatible_with = compatible_with,
|
||||
target_compatible_with = target_compatible_with,
|
||||
restricted_to = restricted_to,
|
||||
message = "Generating flatbuffer files for %s:" % (name),
|
||||
)
|
||||
@@ -99,7 +116,7 @@ def flatbuffer_library_public(
|
||||
reflection_genrule_cmd = " ".join([
|
||||
"SRCS=($(SRCS));",
|
||||
"for f in $${SRCS[@]:0:%s}; do" % len(srcs),
|
||||
"$(location %s)" % (flatc_path),
|
||||
"$(location %s)" % (TRUE_FLATC_PATH),
|
||||
"-b --schema",
|
||||
" ".join(flatc_args),
|
||||
" ".join(include_paths_cmd),
|
||||
@@ -117,11 +134,13 @@ def flatbuffer_library_public(
|
||||
srcs = srcs + includes,
|
||||
outs = reflection_outs,
|
||||
output_to_bindir = output_to_bindir,
|
||||
tools = [flatc_path],
|
||||
tools = [TRUE_FLATC_PATH],
|
||||
compatible_with = compatible_with,
|
||||
restricted_to = restricted_to,
|
||||
target_compatible_with = target_compatible_with,
|
||||
cmd = reflection_genrule_cmd,
|
||||
message = "Generating flatbuffer reflection binary for %s:" % (name),
|
||||
visibility = reflection_visibility,
|
||||
)
|
||||
native.filegroup(
|
||||
name = "%s_out" % reflection_name,
|
||||
@@ -136,15 +155,18 @@ def flatbuffer_cc_library(
|
||||
srcs,
|
||||
srcs_filegroup_name = "",
|
||||
out_prefix = "",
|
||||
deps = [],
|
||||
includes = [],
|
||||
include_paths = DEFAULT_INCLUDE_PATHS,
|
||||
include_paths = None,
|
||||
cc_include_paths = [],
|
||||
flatc_args = DEFAULT_FLATC_ARGS,
|
||||
visibility = None,
|
||||
compatible_with = None,
|
||||
restricted_to = None,
|
||||
target_compatible_with = None,
|
||||
srcs_filegroup_visibility = None,
|
||||
gen_reflections = False):
|
||||
'''A cc_library with the generated reader/writers for the given flatbuffer definitions.
|
||||
"""A cc_library with the generated reader/writers for the given flatbuffer definitions.
|
||||
|
||||
Args:
|
||||
name: Rule name.
|
||||
@@ -154,9 +176,12 @@ def flatbuffer_cc_library(
|
||||
flatbuffer_cc_library that depends on this one's schemas.
|
||||
out_prefix: Prepend this path to the front of all generated files. Usually
|
||||
is a directory name.
|
||||
deps: Optional, list of other flatbuffer_cc_library's to depend on. Cannot be specified
|
||||
alongside includes.
|
||||
includes: Optional, list of filegroups of schemas that the srcs depend on.
|
||||
** SEE REMARKS BELOW **
|
||||
Use of this is discouraged, and may be deprecated.
|
||||
include_paths: Optional, list of paths the includes files can be found in.
|
||||
cc_include_paths: Optional, list of paths to add to the cc_library includes attribute.
|
||||
flatc_args: Optional list of additional arguments to pass to flatc
|
||||
(e.g. --gen-mutable).
|
||||
visibility: The visibility of the generated cc_library. By default, use the
|
||||
@@ -169,6 +194,8 @@ def flatbuffer_cc_library(
|
||||
for, in addition to default-supported environments.
|
||||
restricted_to: Optional, The list of environments this rule can be built
|
||||
for, instead of default-supported environments.
|
||||
target_compatible_with: Optional, The list of target platform constraints
|
||||
to use.
|
||||
|
||||
This produces:
|
||||
filegroup([name]_srcs): all generated .h files.
|
||||
@@ -177,41 +204,17 @@ def flatbuffer_cc_library(
|
||||
parameter, if they depend on the schemas in this library.
|
||||
Fileset([name]_reflection): (Optional) all generated reflection binaries.
|
||||
cc_library([name]): library with sources and flatbuffers deps.
|
||||
|
||||
Remarks:
|
||||
** Because the genrule used to call flatc does not have any trivial way of
|
||||
computing the output list of files transitively generated by includes and
|
||||
--gen-includes (the default) being defined for flatc, the --gen-includes
|
||||
flag will not work as expected. The way around this is to add a dependency
|
||||
to the flatbuffer_cc_library defined alongside the flatc included Fileset.
|
||||
For example you might define:
|
||||
|
||||
flatbuffer_cc_library(
|
||||
name = "my_fbs",
|
||||
srcs = [ "schemas/foo.fbs" ],
|
||||
includes = [ "//third_party/bazz:bazz_fbs_includes" ],
|
||||
)
|
||||
|
||||
In which foo.fbs includes a few files from the Fileset defined at
|
||||
//third_party/bazz:bazz_fbs_includes. When compiling the library that
|
||||
includes foo_generated.h, and therefore has my_fbs as a dependency, it
|
||||
will fail to find any of the bazz *_generated.h files unless you also
|
||||
add bazz's flatbuffer_cc_library to your own dependency list, e.g.:
|
||||
|
||||
cc_library(
|
||||
name = "my_lib",
|
||||
deps = [
|
||||
":my_fbs",
|
||||
"//third_party/bazz:bazz_fbs"
|
||||
],
|
||||
)
|
||||
|
||||
Happy dependent Flatbuffering!
|
||||
'''
|
||||
"""
|
||||
output_headers = [
|
||||
(out_prefix + "%s_generated.h") % (s.replace(".fbs", "").split("/")[-1].split(":")[-1])
|
||||
for s in srcs
|
||||
]
|
||||
if deps and includes:
|
||||
# There is no inherent reason we couldn't support both, but this discourages
|
||||
# use of includes without good reason.
|
||||
fail("Cannot specify both deps and include in flatbuffer_cc_library.")
|
||||
if deps:
|
||||
includes = [d + "_includes" for d in deps]
|
||||
reflection_name = "%s_reflection" % name if gen_reflections else ""
|
||||
|
||||
srcs_lib = "%s_srcs" % (name)
|
||||
@@ -226,6 +229,7 @@ def flatbuffer_cc_library(
|
||||
flatc_args = flatc_args,
|
||||
compatible_with = compatible_with,
|
||||
restricted_to = restricted_to,
|
||||
target_compatible_with = target_compatible_with,
|
||||
reflection_name = reflection_name,
|
||||
reflection_visibility = visibility,
|
||||
)
|
||||
@@ -242,10 +246,12 @@ def flatbuffer_cc_library(
|
||||
],
|
||||
deps = [
|
||||
"@com_github_google_flatbuffers//:runtime_cc",
|
||||
],
|
||||
includes = [],
|
||||
"@com_github_google_flatbuffers//:flatbuffers",
|
||||
] + deps,
|
||||
includes = cc_include_paths,
|
||||
compatible_with = compatible_with,
|
||||
restricted_to = restricted_to,
|
||||
target_compatible_with = target_compatible_with,
|
||||
linkstatic = 1,
|
||||
visibility = visibility,
|
||||
)
|
||||
@@ -254,7 +260,7 @@ def flatbuffer_cc_library(
|
||||
# Flatbuffer set.
|
||||
native.filegroup(
|
||||
name = srcs_filegroup_name if srcs_filegroup_name else "%s_includes" % (name),
|
||||
srcs = srcs,
|
||||
srcs = srcs + includes,
|
||||
compatible_with = compatible_with,
|
||||
restricted_to = restricted_to,
|
||||
visibility = srcs_filegroup_visibility if srcs_filegroup_visibility != None else visibility,
|
||||
|
||||
@@ -5,8 +5,8 @@ message(STATUS "Conan FlatBuffers Wrapper")
|
||||
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
|
||||
conan_basic_setup()
|
||||
|
||||
if (WIN32 AND MSVC AND FLATBUFFERS_BUILD_SHAREDLIB)
|
||||
if (WIN32 AND MSVC_LIKE AND FLATBUFFERS_BUILD_SHAREDLIB)
|
||||
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
|
||||
endif(WIN32 AND MSVC AND FLATBUFFERS_BUILD_SHAREDLIB)
|
||||
endif(WIN32 AND MSVC_LIKE AND FLATBUFFERS_BUILD_SHAREDLIB)
|
||||
|
||||
include(${CMAKE_SOURCE_DIR}/CMakeListsOriginal.txt)
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
import os
|
||||
|
||||
if os.getenv("APPVEYOR_REPO_TAG") != "true":
|
||||
print("Skip build step. It's not TAG")
|
||||
else:
|
||||
os.system("python conan/build.py")
|
||||
@@ -1,8 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
import os
|
||||
|
||||
if os.getenv("APPVEYOR_REPO_TAG") != "true":
|
||||
print("Skip step. It's not TAG")
|
||||
else:
|
||||
os.system("pip install conan conan-package-tools")
|
||||
@@ -21,14 +21,6 @@ def get_branch():
|
||||
|
||||
def get_version():
|
||||
version = get_branch()
|
||||
if os.getenv("TRAVIS", False):
|
||||
version = os.getenv("TRAVIS_BRANCH")
|
||||
|
||||
if os.getenv("APPVEYOR", False):
|
||||
version = os.getenv("APPVEYOR_REPO_BRANCH")
|
||||
if os.getenv("APPVEYOR_REPO_TAG") == "true":
|
||||
version = os.getenv("APPVEYOR_REPO_TAG_NAME")
|
||||
|
||||
match = re.search(r"v(\d+\.\d+\.\d+.*)", version)
|
||||
if match:
|
||||
return match.group(1)
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
set -x
|
||||
|
||||
if [[ "$(uname -s)" == 'Darwin' ]]; then
|
||||
if which pyenv > /dev/null; then
|
||||
eval "$(pyenv init -)"
|
||||
fi
|
||||
pyenv activate conan
|
||||
fi
|
||||
|
||||
conan user
|
||||
python conan/build.py
|
||||
@@ -1,22 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
set -x
|
||||
|
||||
if [[ "$(uname -s)" == 'Darwin' ]]; then
|
||||
brew update || brew update
|
||||
brew outdated pyenv || brew upgrade pyenv
|
||||
brew install pyenv-virtualenv
|
||||
brew install cmake || true
|
||||
|
||||
if which pyenv > /dev/null; then
|
||||
eval "$(pyenv init -)"
|
||||
fi
|
||||
|
||||
pyenv install 2.7.10
|
||||
pyenv virtualenv 2.7.10 conan
|
||||
pyenv rehash
|
||||
pyenv activate conan
|
||||
fi
|
||||
|
||||
pip install -U conan_package_tools conan
|
||||
@@ -1,7 +1,3 @@
|
||||
// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'dart:collection';
|
||||
import 'dart:convert';
|
||||
import 'dart:math';
|
||||
@@ -401,6 +397,15 @@ class Builder {
|
||||
_setFloat32AtTail(_tail, value);
|
||||
}
|
||||
|
||||
/// Writes a bool to the tail of the buffer after preparing space for it.
|
||||
/// Bools are represented as a Uint8, with the value set to '1' for true, and '0' for false
|
||||
///
|
||||
/// Updates the [offset] pointer. This method is intended for use when writing structs to the buffer.
|
||||
void putBool(bool value) {
|
||||
_prepare(_sizeofUint8, 1);
|
||||
_buf.setInt8(_buf.lengthInBytes - _tail, value ? 1 : 0);
|
||||
}
|
||||
|
||||
/// Writes a Int64 to the tail of the buffer after preparing space for it.
|
||||
///
|
||||
/// Updates the [offset] pointer. This method is intended for use when writing structs to the buffer.
|
||||
|
||||
@@ -17,7 +17,7 @@ class Builder {
|
||||
final Map<double, _StackValue> _indirectDoubleCache = {};
|
||||
|
||||
/// Instantiate the builder if you intent to gradually build up the buffer by calling
|
||||
/// add... methods and calling [finish] to receive the the resulting byte array.
|
||||
/// add... methods and calling [finish] to receive the resulting byte array.
|
||||
///
|
||||
/// The default size of internal buffer is set to 2048. Provide a different value in order to avoid buffer copies.
|
||||
Builder({int size = 2048}) : _buffer = ByteData(size);
|
||||
|
||||
@@ -199,7 +199,7 @@ class Reference {
|
||||
return _MapValueIterator(this);
|
||||
}
|
||||
|
||||
/// Returns the length of the the underlying FlexBuffer value.
|
||||
/// Returns the length of the underlying FlexBuffer value.
|
||||
/// If the underlying value is [null] the length is 0.
|
||||
/// If the underlying value is a number, or a bool, the length is 1.
|
||||
/// If the underlying value is a vector, or map, the length reflects number of elements / element pairs.
|
||||
|
||||
@@ -9,7 +9,7 @@ class BitWidthUtil {
|
||||
}
|
||||
|
||||
static BitWidth width(num value) {
|
||||
if (value.toInt() == value) {
|
||||
if (value is int) {
|
||||
var v = value.toInt().abs();
|
||||
if (v >> 7 == 0) return BitWidth.width8;
|
||||
if (v >> 15 == 0) return BitWidth.width16;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
name: flat_buffers
|
||||
version: 2.0.5
|
||||
version: 23.3.3
|
||||
description: FlatBuffers reading and writing library for Dart. Based on original work by Konstantin Scheglov and Paul Berry of the Dart SDK team.
|
||||
homepage: https://github.com/google/flatbuffers
|
||||
documentation: https://google.github.io/flatbuffers/index.html
|
||||
|
||||
10
dart/test/bool_structs.fbs
Normal file
10
dart/test/bool_structs.fbs
Normal file
@@ -0,0 +1,10 @@
|
||||
// Test for #7355
|
||||
table Foo {
|
||||
my_foo : foo_properties;
|
||||
}
|
||||
|
||||
struct foo_properties
|
||||
{
|
||||
a : bool;
|
||||
b : bool;
|
||||
}
|
||||
207
dart/test/bool_structs_generated.dart
Normal file
207
dart/test/bool_structs_generated.dart
Normal file
@@ -0,0 +1,207 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
// ignore_for_file: unused_import, unused_field, unused_element, unused_local_variable
|
||||
|
||||
import 'dart:typed_data' show Uint8List;
|
||||
import 'package:flat_buffers/flat_buffers.dart' as fb;
|
||||
|
||||
|
||||
class Foo {
|
||||
Foo._(this._bc, this._bcOffset);
|
||||
factory Foo(List<int> bytes) {
|
||||
final rootRef = fb.BufferContext.fromBytes(bytes);
|
||||
return reader.read(rootRef, 0);
|
||||
}
|
||||
|
||||
static const fb.Reader<Foo> reader = _FooReader();
|
||||
|
||||
final fb.BufferContext _bc;
|
||||
final int _bcOffset;
|
||||
|
||||
FooProperties? get myFoo => FooProperties.reader.vTableGetNullable(_bc, _bcOffset, 4);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'Foo{myFoo: ${myFoo}}';
|
||||
}
|
||||
|
||||
FooT unpack() => FooT(
|
||||
myFoo: myFoo?.unpack());
|
||||
|
||||
static int pack(fb.Builder fbBuilder, FooT? object) {
|
||||
if (object == null) return 0;
|
||||
return object.pack(fbBuilder);
|
||||
}
|
||||
}
|
||||
|
||||
class FooT implements fb.Packable {
|
||||
FooPropertiesT? myFoo;
|
||||
|
||||
FooT({
|
||||
this.myFoo});
|
||||
|
||||
@override
|
||||
int pack(fb.Builder fbBuilder) {
|
||||
fbBuilder.startTable(1);
|
||||
if (myFoo != null) {
|
||||
fbBuilder.addStruct(0, myFoo!.pack(fbBuilder));
|
||||
}
|
||||
return fbBuilder.endTable();
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'FooT{myFoo: ${myFoo}}';
|
||||
}
|
||||
}
|
||||
|
||||
class _FooReader extends fb.TableReader<Foo> {
|
||||
const _FooReader();
|
||||
|
||||
@override
|
||||
Foo createObject(fb.BufferContext bc, int offset) =>
|
||||
Foo._(bc, offset);
|
||||
}
|
||||
|
||||
class FooBuilder {
|
||||
FooBuilder(this.fbBuilder);
|
||||
|
||||
final fb.Builder fbBuilder;
|
||||
|
||||
void begin() {
|
||||
fbBuilder.startTable(1);
|
||||
}
|
||||
|
||||
int addMyFoo(int offset) {
|
||||
fbBuilder.addStruct(0, offset);
|
||||
return fbBuilder.offset;
|
||||
}
|
||||
|
||||
int finish() {
|
||||
return fbBuilder.endTable();
|
||||
}
|
||||
}
|
||||
|
||||
class FooObjectBuilder extends fb.ObjectBuilder {
|
||||
final FooPropertiesObjectBuilder? _myFoo;
|
||||
|
||||
FooObjectBuilder({
|
||||
FooPropertiesObjectBuilder? myFoo,
|
||||
})
|
||||
: _myFoo = myFoo;
|
||||
|
||||
/// Finish building, and store into the [fbBuilder].
|
||||
@override
|
||||
int finish(fb.Builder fbBuilder) {
|
||||
fbBuilder.startTable(1);
|
||||
if (_myFoo != null) {
|
||||
fbBuilder.addStruct(0, _myFoo!.finish(fbBuilder));
|
||||
}
|
||||
return fbBuilder.endTable();
|
||||
}
|
||||
|
||||
/// Convenience method to serialize to byte list.
|
||||
@override
|
||||
Uint8List toBytes([String? fileIdentifier]) {
|
||||
final fbBuilder = fb.Builder(deduplicateTables: false);
|
||||
fbBuilder.finish(finish(fbBuilder), fileIdentifier);
|
||||
return fbBuilder.buffer;
|
||||
}
|
||||
}
|
||||
class FooProperties {
|
||||
FooProperties._(this._bc, this._bcOffset);
|
||||
|
||||
static const fb.Reader<FooProperties> reader = _FooPropertiesReader();
|
||||
|
||||
final fb.BufferContext _bc;
|
||||
final int _bcOffset;
|
||||
|
||||
bool get a => const fb.BoolReader().read(_bc, _bcOffset + 0);
|
||||
bool get b => const fb.BoolReader().read(_bc, _bcOffset + 1);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'FooProperties{a: ${a}, b: ${b}}';
|
||||
}
|
||||
|
||||
FooPropertiesT unpack() => FooPropertiesT(
|
||||
a: a,
|
||||
b: b);
|
||||
|
||||
static int pack(fb.Builder fbBuilder, FooPropertiesT? object) {
|
||||
if (object == null) return 0;
|
||||
return object.pack(fbBuilder);
|
||||
}
|
||||
}
|
||||
|
||||
class FooPropertiesT implements fb.Packable {
|
||||
bool a;
|
||||
bool b;
|
||||
|
||||
FooPropertiesT({
|
||||
required this.a,
|
||||
required this.b});
|
||||
|
||||
@override
|
||||
int pack(fb.Builder fbBuilder) {
|
||||
fbBuilder.putBool(b);
|
||||
fbBuilder.putBool(a);
|
||||
return fbBuilder.offset;
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'FooPropertiesT{a: ${a}, b: ${b}}';
|
||||
}
|
||||
}
|
||||
|
||||
class _FooPropertiesReader extends fb.StructReader<FooProperties> {
|
||||
const _FooPropertiesReader();
|
||||
|
||||
@override
|
||||
int get size => 2;
|
||||
|
||||
@override
|
||||
FooProperties createObject(fb.BufferContext bc, int offset) =>
|
||||
FooProperties._(bc, offset);
|
||||
}
|
||||
|
||||
class FooPropertiesBuilder {
|
||||
FooPropertiesBuilder(this.fbBuilder);
|
||||
|
||||
final fb.Builder fbBuilder;
|
||||
|
||||
int finish(bool a, bool b) {
|
||||
fbBuilder.putBool(b);
|
||||
fbBuilder.putBool(a);
|
||||
return fbBuilder.offset;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class FooPropertiesObjectBuilder extends fb.ObjectBuilder {
|
||||
final bool _a;
|
||||
final bool _b;
|
||||
|
||||
FooPropertiesObjectBuilder({
|
||||
required bool a,
|
||||
required bool b,
|
||||
})
|
||||
: _a = a,
|
||||
_b = b;
|
||||
|
||||
/// Finish building, and store into the [fbBuilder].
|
||||
@override
|
||||
int finish(fb.Builder fbBuilder) {
|
||||
fbBuilder.putBool(_b);
|
||||
fbBuilder.putBool(_a);
|
||||
return fbBuilder.offset;
|
||||
}
|
||||
|
||||
/// Convenience method to serialize to byte list.
|
||||
@override
|
||||
Uint8List toBytes([String? fileIdentifier]) {
|
||||
final fbBuilder = fb.Builder(deduplicateTables: false);
|
||||
fbBuilder.finish(finish(fbBuilder), fileIdentifier);
|
||||
return fbBuilder.buffer;
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,3 @@
|
||||
// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'dart:typed_data';
|
||||
import 'dart:io' as io;
|
||||
|
||||
@@ -13,6 +9,9 @@ import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
||||
import './monster_test_my_game.example_generated.dart' as example;
|
||||
import './monster_test_my_game.example2_generated.dart' as example2;
|
||||
import './list_of_enums_generated.dart' as example3;
|
||||
import './bool_structs_generated.dart' as example4;
|
||||
import './keyword_test_keyword_test_generated.dart' as keyword_test;
|
||||
|
||||
main() {
|
||||
defineReflectiveSuite(() {
|
||||
@@ -20,6 +19,7 @@ main() {
|
||||
defineReflectiveTests(ObjectAPITest);
|
||||
defineReflectiveTests(CheckOtherLangaugesData);
|
||||
defineReflectiveTests(GeneratorTest);
|
||||
defineReflectiveTests(ListOfEnumsTest);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -85,7 +85,12 @@ class CheckOtherLangaugesData {
|
||||
'anyUniqueType: null, anyUnique: null, anyAmbiguousType: null, '
|
||||
'anyAmbiguous: null, vectorOfEnums: null, signedEnum: Race{value: -1}, '
|
||||
'testrequirednestedflatbuffer: null, scalarKeySortedTables: null, '
|
||||
'nativeInline: null}, '
|
||||
'nativeInline: null, '
|
||||
'longEnumNonEnumDefault: LongEnum{value: 0}, '
|
||||
'longEnumNormalDefault: LongEnum{value: 2}, nanDefault: NaN, '
|
||||
'infDefault: Infinity, positiveInfDefault: Infinity, infinityDefault: '
|
||||
'Infinity, positiveInfinityDefault: Infinity, negativeInfDefault: '
|
||||
'-Infinity, negativeInfinityDefault: -Infinity, doubleInfDefault: Infinity}, '
|
||||
'test4: [Test{a: 10, b: 20}, Test{a: 30, b: 40}], '
|
||||
'testarrayofstring: [test1, test2], testarrayoftables: null, '
|
||||
'enemy: Monster{pos: null, mana: 150, hp: 100, name: Fred, '
|
||||
@@ -106,7 +111,12 @@ class CheckOtherLangaugesData {
|
||||
'anyUniqueType: null, anyUnique: null, anyAmbiguousType: null, '
|
||||
'anyAmbiguous: null, vectorOfEnums: null, signedEnum: Race{value: -1}, '
|
||||
'testrequirednestedflatbuffer: null, scalarKeySortedTables: null, '
|
||||
'nativeInline: null}, '
|
||||
'nativeInline: null, '
|
||||
'longEnumNonEnumDefault: LongEnum{value: 0}, '
|
||||
'longEnumNormalDefault: LongEnum{value: 2}, nanDefault: NaN, '
|
||||
'infDefault: Infinity, positiveInfDefault: Infinity, infinityDefault: '
|
||||
'Infinity, positiveInfinityDefault: Infinity, negativeInfDefault: '
|
||||
'-Infinity, negativeInfinityDefault: -Infinity, doubleInfDefault: Infinity}, '
|
||||
'testnestedflatbuffer: null, testempty: null, testbool: true, '
|
||||
'testhashs32Fnv1: -579221183, testhashu32Fnv1: 3715746113, '
|
||||
'testhashs64Fnv1: 7930699090847568257, '
|
||||
@@ -131,7 +141,12 @@ class CheckOtherLangaugesData {
|
||||
'anyAmbiguous: null, vectorOfEnums: null, signedEnum: Race{value: -1}, '
|
||||
'testrequirednestedflatbuffer: null, scalarKeySortedTables: [Stat{id: '
|
||||
'miss, val: 0, count: 0}, Stat{id: hit, val: 10, count: 1}], '
|
||||
'nativeInline: Test{a: 1, b: 2}}',
|
||||
'nativeInline: Test{a: 1, b: 2}, '
|
||||
'longEnumNonEnumDefault: LongEnum{value: 0}, '
|
||||
'longEnumNormalDefault: LongEnum{value: 2}, nanDefault: NaN, '
|
||||
'infDefault: Infinity, positiveInfDefault: Infinity, infinityDefault: '
|
||||
'Infinity, positiveInfinityDefault: Infinity, negativeInfDefault: '
|
||||
'-Infinity, negativeInfinityDefault: -Infinity, doubleInfDefault: Infinity}'
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -896,3 +911,32 @@ class GeneratorTest {
|
||||
same(example.AnyAmbiguousAliasesTypeId.values));
|
||||
}
|
||||
}
|
||||
|
||||
// See #6869
|
||||
@reflectiveTest
|
||||
class ListOfEnumsTest {
|
||||
void test_listOfEnums() async {
|
||||
var mytable = example3.MyTableObjectBuilder(options: [
|
||||
example3.OptionsEnum.A,
|
||||
example3.OptionsEnum.B,
|
||||
example3.OptionsEnum.C
|
||||
]);
|
||||
var bytes = mytable.toBytes();
|
||||
var mytable_read = example3.MyTable(bytes);
|
||||
expect(mytable_read.options![0].value, example3.OptionsEnum.A.value);
|
||||
expect(mytable_read.options![1].value, example3.OptionsEnum.B.value);
|
||||
expect(mytable_read.options![2].value, example3.OptionsEnum.C.value);
|
||||
}
|
||||
}
|
||||
|
||||
@reflectiveTest
|
||||
class BoolInStructTest {
|
||||
void test_boolInStruct() async {
|
||||
var mystruct = example4.FooObjectBuilder(
|
||||
myFoo: example4.FooPropertiesObjectBuilder(a: true, b: false));
|
||||
var bytes = mystruct.toBytes();
|
||||
var mystruct_read = example4.Foo(bytes);
|
||||
expect(mystruct_read.myFoo!.a, true);
|
||||
expect(mystruct_read.myFoo!.b, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,6 +40,10 @@ void main() {
|
||||
flx.addInt(-1025);
|
||||
expect(flx.finish(), [255, 251, 5, 2]);
|
||||
}
|
||||
{
|
||||
var builder = Builder()..addDouble(1.0);
|
||||
expect(builder.finish(), [0, 0, 128, 63, 14, 4]);
|
||||
}
|
||||
{
|
||||
var flx = Builder();
|
||||
flx.addDouble(0.1);
|
||||
|
||||
@@ -37,6 +37,7 @@ void main() {
|
||||
// expect(FlxValue.fromBuffer(b([255, 255, 255, 255, 255, 255, 255, 255, 11, 8])).intValue, 18446744073709551615);
|
||||
});
|
||||
test('double value', () {
|
||||
expect(Reference.fromBuffer(b([0, 0, 128, 63, 14, 4])).doubleValue, 1.0);
|
||||
expect(Reference.fromBuffer(b([0, 0, 144, 64, 14, 4])).doubleValue, 4.5);
|
||||
expect(Reference.fromBuffer(b([205, 204, 204, 61, 14, 4])).doubleValue,
|
||||
closeTo(.1, .001));
|
||||
|
||||
109
dart/test/include_test1_generated.dart
Normal file
109
dart/test/include_test1_generated.dart
Normal file
@@ -0,0 +1,109 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
// ignore_for_file: unused_import, unused_field, unused_element, unused_local_variable
|
||||
|
||||
import 'dart:typed_data' show Uint8List;
|
||||
import 'package:flat_buffers/flat_buffers.dart' as fb;
|
||||
|
||||
|
||||
import './include_test2_my_game.other_name_space_generated.dart' as my_game_other_name_space;
|
||||
|
||||
class TableA {
|
||||
TableA._(this._bc, this._bcOffset);
|
||||
factory TableA(List<int> bytes) {
|
||||
final rootRef = fb.BufferContext.fromBytes(bytes);
|
||||
return reader.read(rootRef, 0);
|
||||
}
|
||||
|
||||
static const fb.Reader<TableA> reader = _TableAReader();
|
||||
|
||||
final fb.BufferContext _bc;
|
||||
final int _bcOffset;
|
||||
|
||||
my_game_other_name_space.TableB? get b => my_game_other_name_space.TableB.reader.vTableGetNullable(_bc, _bcOffset, 4);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'TableA{b: ${b}}';
|
||||
}
|
||||
|
||||
TableAT unpack() => TableAT(
|
||||
b: b?.unpack());
|
||||
|
||||
static int pack(fb.Builder fbBuilder, TableAT? object) {
|
||||
if (object == null) return 0;
|
||||
return object.pack(fbBuilder);
|
||||
}
|
||||
}
|
||||
|
||||
class TableAT implements fb.Packable {
|
||||
my_game_other_name_space.TableBT? b;
|
||||
|
||||
TableAT({
|
||||
this.b});
|
||||
|
||||
@override
|
||||
int pack(fb.Builder fbBuilder) {
|
||||
final int? bOffset = b?.pack(fbBuilder);
|
||||
fbBuilder.startTable(1);
|
||||
fbBuilder.addOffset(0, bOffset);
|
||||
return fbBuilder.endTable();
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'TableAT{b: ${b}}';
|
||||
}
|
||||
}
|
||||
|
||||
class _TableAReader extends fb.TableReader<TableA> {
|
||||
const _TableAReader();
|
||||
|
||||
@override
|
||||
TableA createObject(fb.BufferContext bc, int offset) =>
|
||||
TableA._(bc, offset);
|
||||
}
|
||||
|
||||
class TableABuilder {
|
||||
TableABuilder(this.fbBuilder);
|
||||
|
||||
final fb.Builder fbBuilder;
|
||||
|
||||
void begin() {
|
||||
fbBuilder.startTable(1);
|
||||
}
|
||||
|
||||
int addBOffset(int? offset) {
|
||||
fbBuilder.addOffset(0, offset);
|
||||
return fbBuilder.offset;
|
||||
}
|
||||
|
||||
int finish() {
|
||||
return fbBuilder.endTable();
|
||||
}
|
||||
}
|
||||
|
||||
class TableAObjectBuilder extends fb.ObjectBuilder {
|
||||
final my_game_other_name_space.TableBObjectBuilder? _b;
|
||||
|
||||
TableAObjectBuilder({
|
||||
my_game_other_name_space.TableBObjectBuilder? b,
|
||||
})
|
||||
: _b = b;
|
||||
|
||||
/// Finish building, and store into the [fbBuilder].
|
||||
@override
|
||||
int finish(fb.Builder fbBuilder) {
|
||||
final int? bOffset = _b?.getOrCreateOffset(fbBuilder);
|
||||
fbBuilder.startTable(1);
|
||||
fbBuilder.addOffset(0, bOffset);
|
||||
return fbBuilder.endTable();
|
||||
}
|
||||
|
||||
/// Convenience method to serialize to byte list.
|
||||
@override
|
||||
Uint8List toBytes([String? fileIdentifier]) {
|
||||
final fbBuilder = fb.Builder(deduplicateTables: false);
|
||||
fbBuilder.finish(finish(fbBuilder), fileIdentifier);
|
||||
return fbBuilder.buffer;
|
||||
}
|
||||
}
|
||||
241
dart/test/include_test2_my_game.other_name_space_generated.dart
Normal file
241
dart/test/include_test2_my_game.other_name_space_generated.dart
Normal file
@@ -0,0 +1,241 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
// ignore_for_file: unused_import, unused_field, unused_element, unused_local_variable
|
||||
|
||||
library my_game.other_name_space;
|
||||
|
||||
import 'dart:typed_data' show Uint8List;
|
||||
import 'package:flat_buffers/flat_buffers.dart' as fb;
|
||||
|
||||
|
||||
import './include_test1_generated.dart';
|
||||
|
||||
class FromInclude {
|
||||
final int value;
|
||||
const FromInclude._(this.value);
|
||||
|
||||
factory FromInclude.fromValue(int value) {
|
||||
final result = values[value];
|
||||
if (result == null) {
|
||||
throw StateError('Invalid value $value for bit flag enum FromInclude');
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static FromInclude? _createOrNull(int? value) =>
|
||||
value == null ? null : FromInclude.fromValue(value);
|
||||
|
||||
static const int minValue = 0;
|
||||
static const int maxValue = 0;
|
||||
static bool containsValue(int value) => values.containsKey(value);
|
||||
|
||||
static const FromInclude IncludeVal = FromInclude._(0);
|
||||
static const Map<int, FromInclude> values = {
|
||||
0: IncludeVal};
|
||||
|
||||
static const fb.Reader<FromInclude> reader = _FromIncludeReader();
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'FromInclude{value: $value}';
|
||||
}
|
||||
}
|
||||
|
||||
class _FromIncludeReader extends fb.Reader<FromInclude> {
|
||||
const _FromIncludeReader();
|
||||
|
||||
@override
|
||||
int get size => 8;
|
||||
|
||||
@override
|
||||
FromInclude read(fb.BufferContext bc, int offset) =>
|
||||
FromInclude.fromValue(const fb.Int64Reader().read(bc, offset));
|
||||
}
|
||||
|
||||
class Unused {
|
||||
Unused._(this._bc, this._bcOffset);
|
||||
|
||||
static const fb.Reader<Unused> reader = _UnusedReader();
|
||||
|
||||
final fb.BufferContext _bc;
|
||||
final int _bcOffset;
|
||||
|
||||
int get a => const fb.Int32Reader().read(_bc, _bcOffset + 0);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'Unused{a: ${a}}';
|
||||
}
|
||||
|
||||
UnusedT unpack() => UnusedT(
|
||||
a: a);
|
||||
|
||||
static int pack(fb.Builder fbBuilder, UnusedT? object) {
|
||||
if (object == null) return 0;
|
||||
return object.pack(fbBuilder);
|
||||
}
|
||||
}
|
||||
|
||||
class UnusedT implements fb.Packable {
|
||||
int a;
|
||||
|
||||
UnusedT({
|
||||
required this.a});
|
||||
|
||||
@override
|
||||
int pack(fb.Builder fbBuilder) {
|
||||
fbBuilder.putInt32(a);
|
||||
return fbBuilder.offset;
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'UnusedT{a: ${a}}';
|
||||
}
|
||||
}
|
||||
|
||||
class _UnusedReader extends fb.StructReader<Unused> {
|
||||
const _UnusedReader();
|
||||
|
||||
@override
|
||||
int get size => 4;
|
||||
|
||||
@override
|
||||
Unused createObject(fb.BufferContext bc, int offset) =>
|
||||
Unused._(bc, offset);
|
||||
}
|
||||
|
||||
class UnusedBuilder {
|
||||
UnusedBuilder(this.fbBuilder);
|
||||
|
||||
final fb.Builder fbBuilder;
|
||||
|
||||
int finish(int a) {
|
||||
fbBuilder.putInt32(a);
|
||||
return fbBuilder.offset;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class UnusedObjectBuilder extends fb.ObjectBuilder {
|
||||
final int _a;
|
||||
|
||||
UnusedObjectBuilder({
|
||||
required int a,
|
||||
})
|
||||
: _a = a;
|
||||
|
||||
/// Finish building, and store into the [fbBuilder].
|
||||
@override
|
||||
int finish(fb.Builder fbBuilder) {
|
||||
fbBuilder.putInt32(_a);
|
||||
return fbBuilder.offset;
|
||||
}
|
||||
|
||||
/// Convenience method to serialize to byte list.
|
||||
@override
|
||||
Uint8List toBytes([String? fileIdentifier]) {
|
||||
final fbBuilder = fb.Builder(deduplicateTables: false);
|
||||
fbBuilder.finish(finish(fbBuilder), fileIdentifier);
|
||||
return fbBuilder.buffer;
|
||||
}
|
||||
}
|
||||
class TableB {
|
||||
TableB._(this._bc, this._bcOffset);
|
||||
factory TableB(List<int> bytes) {
|
||||
final rootRef = fb.BufferContext.fromBytes(bytes);
|
||||
return reader.read(rootRef, 0);
|
||||
}
|
||||
|
||||
static const fb.Reader<TableB> reader = _TableBReader();
|
||||
|
||||
final fb.BufferContext _bc;
|
||||
final int _bcOffset;
|
||||
|
||||
TableA? get a => TableA.reader.vTableGetNullable(_bc, _bcOffset, 4);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'TableB{a: ${a}}';
|
||||
}
|
||||
|
||||
TableBT unpack() => TableBT(
|
||||
a: a?.unpack());
|
||||
|
||||
static int pack(fb.Builder fbBuilder, TableBT? object) {
|
||||
if (object == null) return 0;
|
||||
return object.pack(fbBuilder);
|
||||
}
|
||||
}
|
||||
|
||||
class TableBT implements fb.Packable {
|
||||
TableAT? a;
|
||||
|
||||
TableBT({
|
||||
this.a});
|
||||
|
||||
@override
|
||||
int pack(fb.Builder fbBuilder) {
|
||||
final int? aOffset = a?.pack(fbBuilder);
|
||||
fbBuilder.startTable(1);
|
||||
fbBuilder.addOffset(0, aOffset);
|
||||
return fbBuilder.endTable();
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'TableBT{a: ${a}}';
|
||||
}
|
||||
}
|
||||
|
||||
class _TableBReader extends fb.TableReader<TableB> {
|
||||
const _TableBReader();
|
||||
|
||||
@override
|
||||
TableB createObject(fb.BufferContext bc, int offset) =>
|
||||
TableB._(bc, offset);
|
||||
}
|
||||
|
||||
class TableBBuilder {
|
||||
TableBBuilder(this.fbBuilder);
|
||||
|
||||
final fb.Builder fbBuilder;
|
||||
|
||||
void begin() {
|
||||
fbBuilder.startTable(1);
|
||||
}
|
||||
|
||||
int addAOffset(int? offset) {
|
||||
fbBuilder.addOffset(0, offset);
|
||||
return fbBuilder.offset;
|
||||
}
|
||||
|
||||
int finish() {
|
||||
return fbBuilder.endTable();
|
||||
}
|
||||
}
|
||||
|
||||
class TableBObjectBuilder extends fb.ObjectBuilder {
|
||||
final TableAObjectBuilder? _a;
|
||||
|
||||
TableBObjectBuilder({
|
||||
TableAObjectBuilder? a,
|
||||
})
|
||||
: _a = a;
|
||||
|
||||
/// Finish building, and store into the [fbBuilder].
|
||||
@override
|
||||
int finish(fb.Builder fbBuilder) {
|
||||
final int? aOffset = _a?.getOrCreateOffset(fbBuilder);
|
||||
fbBuilder.startTable(1);
|
||||
fbBuilder.addOffset(0, aOffset);
|
||||
return fbBuilder.endTable();
|
||||
}
|
||||
|
||||
/// Convenience method to serialize to byte list.
|
||||
@override
|
||||
Uint8List toBytes([String? fileIdentifier]) {
|
||||
final fbBuilder = fb.Builder(deduplicateTables: false);
|
||||
fbBuilder.finish(finish(fbBuilder), fileIdentifier);
|
||||
return fbBuilder.buffer;
|
||||
}
|
||||
}
|
||||
399
dart/test/keyword_test_keyword_test_generated.dart
Normal file
399
dart/test/keyword_test_keyword_test_generated.dart
Normal file
@@ -0,0 +1,399 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
// ignore_for_file: unused_import, unused_field, unused_element, unused_local_variable
|
||||
|
||||
library keyword_test;
|
||||
|
||||
import 'dart:typed_data' show Uint8List;
|
||||
import 'package:flat_buffers/flat_buffers.dart' as fb;
|
||||
|
||||
|
||||
class Abc {
|
||||
final int value;
|
||||
const Abc._(this.value);
|
||||
|
||||
factory Abc.fromValue(int value) {
|
||||
final result = values[value];
|
||||
if (result == null) {
|
||||
throw StateError('Invalid value $value for bit flag enum Abc');
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static Abc? _createOrNull(int? value) =>
|
||||
value == null ? null : Abc.fromValue(value);
|
||||
|
||||
static const int minValue = 0;
|
||||
static const int maxValue = 2;
|
||||
static bool containsValue(int value) => values.containsKey(value);
|
||||
|
||||
static const Abc $void = Abc._(0);
|
||||
static const Abc where = Abc._(1);
|
||||
static const Abc stackalloc = Abc._(2);
|
||||
static const Map<int, Abc> values = {
|
||||
0: $void,
|
||||
1: where,
|
||||
2: stackalloc};
|
||||
|
||||
static const fb.Reader<Abc> reader = _AbcReader();
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'Abc{value: $value}';
|
||||
}
|
||||
}
|
||||
|
||||
class _AbcReader extends fb.Reader<Abc> {
|
||||
const _AbcReader();
|
||||
|
||||
@override
|
||||
int get size => 4;
|
||||
|
||||
@override
|
||||
Abc read(fb.BufferContext bc, int offset) =>
|
||||
Abc.fromValue(const fb.Int32Reader().read(bc, offset));
|
||||
}
|
||||
|
||||
class Public {
|
||||
final int value;
|
||||
const Public._(this.value);
|
||||
|
||||
factory Public.fromValue(int value) {
|
||||
final result = values[value];
|
||||
if (result == null) {
|
||||
throw StateError('Invalid value $value for bit flag enum Public');
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static Public? _createOrNull(int? value) =>
|
||||
value == null ? null : Public.fromValue(value);
|
||||
|
||||
static const int minValue = 0;
|
||||
static const int maxValue = 0;
|
||||
static bool containsValue(int value) => values.containsKey(value);
|
||||
|
||||
static const Public NONE = Public._(0);
|
||||
static const Map<int, Public> values = {
|
||||
0: NONE};
|
||||
|
||||
static const fb.Reader<Public> reader = _PublicReader();
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'Public{value: $value}';
|
||||
}
|
||||
}
|
||||
|
||||
class _PublicReader extends fb.Reader<Public> {
|
||||
const _PublicReader();
|
||||
|
||||
@override
|
||||
int get size => 4;
|
||||
|
||||
@override
|
||||
Public read(fb.BufferContext bc, int offset) =>
|
||||
Public.fromValue(const fb.Int32Reader().read(bc, offset));
|
||||
}
|
||||
|
||||
class KeywordsInUnionTypeId {
|
||||
final int value;
|
||||
const KeywordsInUnionTypeId._(this.value);
|
||||
|
||||
factory KeywordsInUnionTypeId.fromValue(int value) {
|
||||
final result = values[value];
|
||||
if (result == null) {
|
||||
throw StateError('Invalid value $value for bit flag enum KeywordsInUnionTypeId');
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static KeywordsInUnionTypeId? _createOrNull(int? value) =>
|
||||
value == null ? null : KeywordsInUnionTypeId.fromValue(value);
|
||||
|
||||
static const int minValue = 0;
|
||||
static const int maxValue = 2;
|
||||
static bool containsValue(int value) => values.containsKey(value);
|
||||
|
||||
static const KeywordsInUnionTypeId NONE = KeywordsInUnionTypeId._(0);
|
||||
static const KeywordsInUnionTypeId $static = KeywordsInUnionTypeId._(1);
|
||||
static const KeywordsInUnionTypeId internal = KeywordsInUnionTypeId._(2);
|
||||
static const Map<int, KeywordsInUnionTypeId> values = {
|
||||
0: NONE,
|
||||
1: $static,
|
||||
2: internal};
|
||||
|
||||
static const fb.Reader<KeywordsInUnionTypeId> reader = _KeywordsInUnionTypeIdReader();
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'KeywordsInUnionTypeId{value: $value}';
|
||||
}
|
||||
}
|
||||
|
||||
class _KeywordsInUnionTypeIdReader extends fb.Reader<KeywordsInUnionTypeId> {
|
||||
const _KeywordsInUnionTypeIdReader();
|
||||
|
||||
@override
|
||||
int get size => 1;
|
||||
|
||||
@override
|
||||
KeywordsInUnionTypeId read(fb.BufferContext bc, int offset) =>
|
||||
KeywordsInUnionTypeId.fromValue(const fb.Uint8Reader().read(bc, offset));
|
||||
}
|
||||
|
||||
class KeywordsInTable {
|
||||
KeywordsInTable._(this._bc, this._bcOffset);
|
||||
factory KeywordsInTable(List<int> bytes) {
|
||||
final rootRef = fb.BufferContext.fromBytes(bytes);
|
||||
return reader.read(rootRef, 0);
|
||||
}
|
||||
|
||||
static const fb.Reader<KeywordsInTable> reader = _KeywordsInTableReader();
|
||||
|
||||
final fb.BufferContext _bc;
|
||||
final int _bcOffset;
|
||||
|
||||
Abc get $is => Abc.fromValue(const fb.Int32Reader().vTableGet(_bc, _bcOffset, 4, 0));
|
||||
Public get private => Public.fromValue(const fb.Int32Reader().vTableGet(_bc, _bcOffset, 6, 0));
|
||||
int get type => const fb.Int32Reader().vTableGet(_bc, _bcOffset, 8, 0);
|
||||
bool get $default => const fb.BoolReader().vTableGet(_bc, _bcOffset, 10, false);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'KeywordsInTable{\$is: ${$is}, private: ${private}, type: ${type}, \$default: ${$default}}';
|
||||
}
|
||||
|
||||
KeywordsInTableT unpack() => KeywordsInTableT(
|
||||
$is: $is,
|
||||
private: private,
|
||||
type: type,
|
||||
$default: $default);
|
||||
|
||||
static int pack(fb.Builder fbBuilder, KeywordsInTableT? object) {
|
||||
if (object == null) return 0;
|
||||
return object.pack(fbBuilder);
|
||||
}
|
||||
}
|
||||
|
||||
class KeywordsInTableT implements fb.Packable {
|
||||
Abc $is;
|
||||
Public private;
|
||||
int type;
|
||||
bool $default;
|
||||
|
||||
KeywordsInTableT({
|
||||
this.$is = Abc.$void,
|
||||
this.private = Public.NONE,
|
||||
this.type = 0,
|
||||
this.$default = false});
|
||||
|
||||
@override
|
||||
int pack(fb.Builder fbBuilder) {
|
||||
fbBuilder.startTable(4);
|
||||
fbBuilder.addInt32(0, $is.value);
|
||||
fbBuilder.addInt32(1, private.value);
|
||||
fbBuilder.addInt32(2, type);
|
||||
fbBuilder.addBool(3, $default);
|
||||
return fbBuilder.endTable();
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'KeywordsInTableT{\$is: ${$is}, private: ${private}, type: ${type}, \$default: ${$default}}';
|
||||
}
|
||||
}
|
||||
|
||||
class _KeywordsInTableReader extends fb.TableReader<KeywordsInTable> {
|
||||
const _KeywordsInTableReader();
|
||||
|
||||
@override
|
||||
KeywordsInTable createObject(fb.BufferContext bc, int offset) =>
|
||||
KeywordsInTable._(bc, offset);
|
||||
}
|
||||
|
||||
class KeywordsInTableBuilder {
|
||||
KeywordsInTableBuilder(this.fbBuilder);
|
||||
|
||||
final fb.Builder fbBuilder;
|
||||
|
||||
void begin() {
|
||||
fbBuilder.startTable(4);
|
||||
}
|
||||
|
||||
int addIs(Abc? $is) {
|
||||
fbBuilder.addInt32(0, $is?.value);
|
||||
return fbBuilder.offset;
|
||||
}
|
||||
int addPrivate(Public? private) {
|
||||
fbBuilder.addInt32(1, private?.value);
|
||||
return fbBuilder.offset;
|
||||
}
|
||||
int addType(int? type) {
|
||||
fbBuilder.addInt32(2, type);
|
||||
return fbBuilder.offset;
|
||||
}
|
||||
int addDefault(bool? $default) {
|
||||
fbBuilder.addBool(3, $default);
|
||||
return fbBuilder.offset;
|
||||
}
|
||||
|
||||
int finish() {
|
||||
return fbBuilder.endTable();
|
||||
}
|
||||
}
|
||||
|
||||
class KeywordsInTableObjectBuilder extends fb.ObjectBuilder {
|
||||
final Abc? _$is;
|
||||
final Public? _private;
|
||||
final int? _type;
|
||||
final bool? _$default;
|
||||
|
||||
KeywordsInTableObjectBuilder({
|
||||
Abc? $is,
|
||||
Public? private,
|
||||
int? type,
|
||||
bool? $default,
|
||||
})
|
||||
: _$is = $is,
|
||||
_private = private,
|
||||
_type = type,
|
||||
_$default = $default;
|
||||
|
||||
/// Finish building, and store into the [fbBuilder].
|
||||
@override
|
||||
int finish(fb.Builder fbBuilder) {
|
||||
fbBuilder.startTable(4);
|
||||
fbBuilder.addInt32(0, _$is?.value);
|
||||
fbBuilder.addInt32(1, _private?.value);
|
||||
fbBuilder.addInt32(2, _type);
|
||||
fbBuilder.addBool(3, _$default);
|
||||
return fbBuilder.endTable();
|
||||
}
|
||||
|
||||
/// Convenience method to serialize to byte list.
|
||||
@override
|
||||
Uint8List toBytes([String? fileIdentifier]) {
|
||||
final fbBuilder = fb.Builder(deduplicateTables: false);
|
||||
fbBuilder.finish(finish(fbBuilder), fileIdentifier);
|
||||
return fbBuilder.buffer;
|
||||
}
|
||||
}
|
||||
class Table2 {
|
||||
Table2._(this._bc, this._bcOffset);
|
||||
factory Table2(List<int> bytes) {
|
||||
final rootRef = fb.BufferContext.fromBytes(bytes);
|
||||
return reader.read(rootRef, 0);
|
||||
}
|
||||
|
||||
static const fb.Reader<Table2> reader = _Table2Reader();
|
||||
|
||||
final fb.BufferContext _bc;
|
||||
final int _bcOffset;
|
||||
|
||||
KeywordsInUnionTypeId? get typeType => KeywordsInUnionTypeId._createOrNull(const fb.Uint8Reader().vTableGetNullable(_bc, _bcOffset, 4));
|
||||
dynamic get type {
|
||||
switch (typeType?.value) {
|
||||
case 1: return KeywordsInTable.reader.vTableGetNullable(_bc, _bcOffset, 6);
|
||||
case 2: return KeywordsInTable.reader.vTableGetNullable(_bc, _bcOffset, 6);
|
||||
default: return null;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'Table2{typeType: ${typeType}, type: ${type}}';
|
||||
}
|
||||
|
||||
Table2T unpack() => Table2T(
|
||||
typeType: typeType,
|
||||
type: type);
|
||||
|
||||
static int pack(fb.Builder fbBuilder, Table2T? object) {
|
||||
if (object == null) return 0;
|
||||
return object.pack(fbBuilder);
|
||||
}
|
||||
}
|
||||
|
||||
class Table2T implements fb.Packable {
|
||||
KeywordsInUnionTypeId? typeType;
|
||||
dynamic type;
|
||||
|
||||
Table2T({
|
||||
this.typeType,
|
||||
this.type});
|
||||
|
||||
@override
|
||||
int pack(fb.Builder fbBuilder) {
|
||||
final int? typeOffset = type?.pack(fbBuilder);
|
||||
fbBuilder.startTable(2);
|
||||
fbBuilder.addUint8(0, typeType?.value);
|
||||
fbBuilder.addOffset(1, typeOffset);
|
||||
return fbBuilder.endTable();
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'Table2T{typeType: ${typeType}, type: ${type}}';
|
||||
}
|
||||
}
|
||||
|
||||
class _Table2Reader extends fb.TableReader<Table2> {
|
||||
const _Table2Reader();
|
||||
|
||||
@override
|
||||
Table2 createObject(fb.BufferContext bc, int offset) =>
|
||||
Table2._(bc, offset);
|
||||
}
|
||||
|
||||
class Table2Builder {
|
||||
Table2Builder(this.fbBuilder);
|
||||
|
||||
final fb.Builder fbBuilder;
|
||||
|
||||
void begin() {
|
||||
fbBuilder.startTable(2);
|
||||
}
|
||||
|
||||
int addTypeType(KeywordsInUnionTypeId? typeType) {
|
||||
fbBuilder.addUint8(0, typeType?.value);
|
||||
return fbBuilder.offset;
|
||||
}
|
||||
int addTypeOffset(int? offset) {
|
||||
fbBuilder.addOffset(1, offset);
|
||||
return fbBuilder.offset;
|
||||
}
|
||||
|
||||
int finish() {
|
||||
return fbBuilder.endTable();
|
||||
}
|
||||
}
|
||||
|
||||
class Table2ObjectBuilder extends fb.ObjectBuilder {
|
||||
final KeywordsInUnionTypeId? _typeType;
|
||||
final dynamic _type;
|
||||
|
||||
Table2ObjectBuilder({
|
||||
KeywordsInUnionTypeId? typeType,
|
||||
dynamic type,
|
||||
})
|
||||
: _typeType = typeType,
|
||||
_type = type;
|
||||
|
||||
/// Finish building, and store into the [fbBuilder].
|
||||
@override
|
||||
int finish(fb.Builder fbBuilder) {
|
||||
final int? typeOffset = _type?.getOrCreateOffset(fbBuilder);
|
||||
fbBuilder.startTable(2);
|
||||
fbBuilder.addUint8(0, _typeType?.value);
|
||||
fbBuilder.addOffset(1, typeOffset);
|
||||
return fbBuilder.endTable();
|
||||
}
|
||||
|
||||
/// Convenience method to serialize to byte list.
|
||||
@override
|
||||
Uint8List toBytes([String? fileIdentifier]) {
|
||||
final fbBuilder = fb.Builder(deduplicateTables: false);
|
||||
fbBuilder.finish(finish(fbBuilder), fileIdentifier);
|
||||
return fbBuilder.buffer;
|
||||
}
|
||||
}
|
||||
10
dart/test/list_of_enums.fbs
Normal file
10
dart/test/list_of_enums.fbs
Normal file
@@ -0,0 +1,10 @@
|
||||
enum OptionsEnum : uint32
|
||||
{
|
||||
A = 1,
|
||||
B = 2,
|
||||
C = 3
|
||||
}
|
||||
|
||||
table MyTable {
|
||||
options : [OptionsEnum];
|
||||
}
|
||||
155
dart/test/list_of_enums_generated.dart
Normal file
155
dart/test/list_of_enums_generated.dart
Normal file
@@ -0,0 +1,155 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
// ignore_for_file: unused_import, unused_field, unused_element, unused_local_variable
|
||||
|
||||
import 'dart:typed_data' show Uint8List;
|
||||
import 'package:flat_buffers/flat_buffers.dart' as fb;
|
||||
|
||||
|
||||
class OptionsEnum {
|
||||
final int value;
|
||||
const OptionsEnum._(this.value);
|
||||
|
||||
factory OptionsEnum.fromValue(int value) {
|
||||
final result = values[value];
|
||||
if (result == null) {
|
||||
throw StateError('Invalid value $value for bit flag enum OptionsEnum');
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static OptionsEnum? _createOrNull(int? value) =>
|
||||
value == null ? null : OptionsEnum.fromValue(value);
|
||||
|
||||
static const int minValue = 1;
|
||||
static const int maxValue = 3;
|
||||
static bool containsValue(int value) => values.containsKey(value);
|
||||
|
||||
static const OptionsEnum A = OptionsEnum._(1);
|
||||
static const OptionsEnum B = OptionsEnum._(2);
|
||||
static const OptionsEnum C = OptionsEnum._(3);
|
||||
static const Map<int, OptionsEnum> values = {
|
||||
1: A,
|
||||
2: B,
|
||||
3: C};
|
||||
|
||||
static const fb.Reader<OptionsEnum> reader = _OptionsEnumReader();
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'OptionsEnum{value: $value}';
|
||||
}
|
||||
}
|
||||
|
||||
class _OptionsEnumReader extends fb.Reader<OptionsEnum> {
|
||||
const _OptionsEnumReader();
|
||||
|
||||
@override
|
||||
int get size => 4;
|
||||
|
||||
@override
|
||||
OptionsEnum read(fb.BufferContext bc, int offset) =>
|
||||
OptionsEnum.fromValue(const fb.Uint32Reader().read(bc, offset));
|
||||
}
|
||||
|
||||
class MyTable {
|
||||
MyTable._(this._bc, this._bcOffset);
|
||||
factory MyTable(List<int> bytes) {
|
||||
final rootRef = fb.BufferContext.fromBytes(bytes);
|
||||
return reader.read(rootRef, 0);
|
||||
}
|
||||
|
||||
static const fb.Reader<MyTable> reader = _MyTableReader();
|
||||
|
||||
final fb.BufferContext _bc;
|
||||
final int _bcOffset;
|
||||
|
||||
List<OptionsEnum>? get options => const fb.ListReader<OptionsEnum>(OptionsEnum.reader).vTableGetNullable(_bc, _bcOffset, 4);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'MyTable{options: ${options}}';
|
||||
}
|
||||
|
||||
MyTableT unpack() => MyTableT(
|
||||
options: const fb.ListReader<OptionsEnum>(OptionsEnum.reader, lazy: false).vTableGetNullable(_bc, _bcOffset, 4));
|
||||
|
||||
static int pack(fb.Builder fbBuilder, MyTableT? object) {
|
||||
if (object == null) return 0;
|
||||
return object.pack(fbBuilder);
|
||||
}
|
||||
}
|
||||
|
||||
class MyTableT implements fb.Packable {
|
||||
List<OptionsEnum>? options;
|
||||
|
||||
MyTableT({
|
||||
this.options});
|
||||
|
||||
@override
|
||||
int pack(fb.Builder fbBuilder) {
|
||||
final int? optionsOffset = options == null ? null
|
||||
: fbBuilder.writeListUint32(options!.map((f) => f.value).toList());
|
||||
fbBuilder.startTable(1);
|
||||
fbBuilder.addOffset(0, optionsOffset);
|
||||
return fbBuilder.endTable();
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'MyTableT{options: ${options}}';
|
||||
}
|
||||
}
|
||||
|
||||
class _MyTableReader extends fb.TableReader<MyTable> {
|
||||
const _MyTableReader();
|
||||
|
||||
@override
|
||||
MyTable createObject(fb.BufferContext bc, int offset) =>
|
||||
MyTable._(bc, offset);
|
||||
}
|
||||
|
||||
class MyTableBuilder {
|
||||
MyTableBuilder(this.fbBuilder);
|
||||
|
||||
final fb.Builder fbBuilder;
|
||||
|
||||
void begin() {
|
||||
fbBuilder.startTable(1);
|
||||
}
|
||||
|
||||
int addOptionsOffset(int? offset) {
|
||||
fbBuilder.addOffset(0, offset);
|
||||
return fbBuilder.offset;
|
||||
}
|
||||
|
||||
int finish() {
|
||||
return fbBuilder.endTable();
|
||||
}
|
||||
}
|
||||
|
||||
class MyTableObjectBuilder extends fb.ObjectBuilder {
|
||||
final List<OptionsEnum>? _options;
|
||||
|
||||
MyTableObjectBuilder({
|
||||
List<OptionsEnum>? options,
|
||||
})
|
||||
: _options = options;
|
||||
|
||||
/// Finish building, and store into the [fbBuilder].
|
||||
@override
|
||||
int finish(fb.Builder fbBuilder) {
|
||||
final int? optionsOffset = _options == null ? null
|
||||
: fbBuilder.writeListUint32(_options!.map((f) => f.value).toList());
|
||||
fbBuilder.startTable(1);
|
||||
fbBuilder.addOffset(0, optionsOffset);
|
||||
return fbBuilder.endTable();
|
||||
}
|
||||
|
||||
/// Convenience method to serialize to byte list.
|
||||
@override
|
||||
Uint8List toBytes([String? fileIdentifier]) {
|
||||
final fbBuilder = fb.Builder(deduplicateTables: false);
|
||||
fbBuilder.finish(finish(fbBuilder), fileIdentifier);
|
||||
return fbBuilder.buffer;
|
||||
}
|
||||
}
|
||||
@@ -31,6 +31,14 @@ enum Race:byte {
|
||||
Elf,
|
||||
}
|
||||
|
||||
enum LongEnum:ulong (bit_flags) {
|
||||
LongOne = 1,
|
||||
LongTwo = 2,
|
||||
// Because this is a bitflag, 40 will be out of range of a 32-bit integer,
|
||||
// allowing us to exercise any logic special to big numbers.
|
||||
LongBig = 40,
|
||||
}
|
||||
|
||||
union Any { Monster, TestSimpleTableWithEnum, MyGame.Example2.Monster }
|
||||
|
||||
union AnyUniqueAliases { M: Monster, TS: TestSimpleTableWithEnum, M2: MyGame.Example2.Monster }
|
||||
@@ -62,6 +70,10 @@ struct StructOfStructs {
|
||||
c: Ability;
|
||||
}
|
||||
|
||||
struct StructOfStructsOfStructs {
|
||||
a: StructOfStructs;
|
||||
}
|
||||
|
||||
table Stat {
|
||||
id:string;
|
||||
val:long;
|
||||
@@ -124,6 +136,20 @@ table Monster {
|
||||
signed_enum:Race = None (id:48);
|
||||
testrequirednestedflatbuffer:[ubyte] (id:49, nested_flatbuffer: "Monster");
|
||||
scalar_key_sorted_tables:[Stat] (id: 50);
|
||||
native_inline:Test (id: 51, native_inline);
|
||||
// The default value of this enum will be a numeric zero, which isn't a valid
|
||||
// enum value.
|
||||
long_enum_non_enum_default:LongEnum (id: 52);
|
||||
long_enum_normal_default:LongEnum = LongOne (id: 53);
|
||||
// Test that default values nan and +/-inf work.
|
||||
nan_default:float = nan (id: 54);
|
||||
inf_default:float = inf (id: 55);
|
||||
positive_inf_default:float = +inf (id: 56);
|
||||
infinity_default:float = infinity (id: 57);
|
||||
positive_infinity_default:float = +infinity (id: 58);
|
||||
negative_inf_default:float = -inf (id: 59);
|
||||
negative_infinity_default:float = -infinity (id: 60);
|
||||
double_inf_default:double = inf (id: 61);
|
||||
}
|
||||
|
||||
table TypeAliases {
|
||||
|
||||
@@ -9,6 +9,8 @@ import 'package:flat_buffers/flat_buffers.dart' as fb;
|
||||
import './monster_test_my_game_generated.dart' as my_game;
|
||||
import './monster_test_my_game.example_generated.dart' as my_game_example;
|
||||
|
||||
import './include_test1_generated.dart';
|
||||
|
||||
class Monster {
|
||||
Monster._(this._bc, this._bcOffset);
|
||||
factory Monster(List<int> bytes) {
|
||||
|
||||
@@ -9,6 +9,8 @@ import 'package:flat_buffers/flat_buffers.dart' as fb;
|
||||
import './monster_test_my_game_generated.dart' as my_game;
|
||||
import './monster_test_my_game.example2_generated.dart' as my_game_example2;
|
||||
|
||||
import './include_test1_generated.dart';
|
||||
|
||||
/// Composite components of Monster color.
|
||||
class Color {
|
||||
final int value;
|
||||
@@ -17,7 +19,11 @@ class Color {
|
||||
factory Color.fromValue(int value) {
|
||||
final result = values[value];
|
||||
if (result == null) {
|
||||
throw StateError('Invalid value $value for bit flag enum Color');
|
||||
if (value == 0) {
|
||||
return Color._(0);
|
||||
} else {
|
||||
throw StateError('Invalid value $value for bit flag enum Color');
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -66,7 +72,7 @@ class Race {
|
||||
factory Race.fromValue(int value) {
|
||||
final result = values[value];
|
||||
if (result == null) {
|
||||
throw StateError('Invalid value $value for bit flag enum Race');
|
||||
throw StateError('Invalid value $value for bit flag enum Race');
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -107,6 +113,54 @@ class _RaceReader extends fb.Reader<Race> {
|
||||
Race.fromValue(const fb.Int8Reader().read(bc, offset));
|
||||
}
|
||||
|
||||
class LongEnum {
|
||||
final int value;
|
||||
const LongEnum._(this.value);
|
||||
|
||||
factory LongEnum.fromValue(int value) {
|
||||
final result = values[value];
|
||||
if (result == null) {
|
||||
if (value == 0) {
|
||||
return LongEnum._(0);
|
||||
} else {
|
||||
throw StateError('Invalid value $value for bit flag enum LongEnum');
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static LongEnum? _createOrNull(int? value) =>
|
||||
value == null ? null : LongEnum.fromValue(value);
|
||||
|
||||
static bool containsValue(int value) => values.containsKey(value);
|
||||
|
||||
static const LongEnum LongOne = LongEnum._(2);
|
||||
static const LongEnum LongTwo = LongEnum._(4);
|
||||
static const LongEnum LongBig = LongEnum._(1099511627776);
|
||||
static const Map<int, LongEnum> values = {
|
||||
2: LongOne,
|
||||
4: LongTwo,
|
||||
1099511627776: LongBig};
|
||||
|
||||
static const fb.Reader<LongEnum> reader = _LongEnumReader();
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'LongEnum{value: $value}';
|
||||
}
|
||||
}
|
||||
|
||||
class _LongEnumReader extends fb.Reader<LongEnum> {
|
||||
const _LongEnumReader();
|
||||
|
||||
@override
|
||||
int get size => 8;
|
||||
|
||||
@override
|
||||
LongEnum read(fb.BufferContext bc, int offset) =>
|
||||
LongEnum.fromValue(const fb.Uint64Reader().read(bc, offset));
|
||||
}
|
||||
|
||||
class AnyTypeId {
|
||||
final int value;
|
||||
const AnyTypeId._(this.value);
|
||||
@@ -114,7 +168,7 @@ class AnyTypeId {
|
||||
factory AnyTypeId.fromValue(int value) {
|
||||
final result = values[value];
|
||||
if (result == null) {
|
||||
throw StateError('Invalid value $value for bit flag enum AnyTypeId');
|
||||
throw StateError('Invalid value $value for bit flag enum AnyTypeId');
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -162,7 +216,7 @@ class AnyUniqueAliasesTypeId {
|
||||
factory AnyUniqueAliasesTypeId.fromValue(int value) {
|
||||
final result = values[value];
|
||||
if (result == null) {
|
||||
throw StateError('Invalid value $value for bit flag enum AnyUniqueAliasesTypeId');
|
||||
throw StateError('Invalid value $value for bit flag enum AnyUniqueAliasesTypeId');
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -210,7 +264,7 @@ class AnyAmbiguousAliasesTypeId {
|
||||
factory AnyAmbiguousAliasesTypeId.fromValue(int value) {
|
||||
final result = values[value];
|
||||
if (result == null) {
|
||||
throw StateError('Invalid value $value for bit flag enum AnyAmbiguousAliasesTypeId');
|
||||
throw StateError('Invalid value $value for bit flag enum AnyAmbiguousAliasesTypeId');
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -264,7 +318,7 @@ class Test {
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'Test{a: $a, b: $b}';
|
||||
return 'Test{a: ${a}, b: ${b}}';
|
||||
}
|
||||
|
||||
TestT unpack() => TestT(
|
||||
@@ -295,7 +349,7 @@ class TestT implements fb.Packable {
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'TestT{a: $a, b: $b}';
|
||||
return 'TestT{a: ${a}, b: ${b}}';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -368,7 +422,7 @@ class TestSimpleTableWithEnum {
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'TestSimpleTableWithEnum{color: $color}';
|
||||
return 'TestSimpleTableWithEnum{color: ${color}}';
|
||||
}
|
||||
|
||||
TestSimpleTableWithEnumT unpack() => TestSimpleTableWithEnumT(
|
||||
@@ -395,7 +449,7 @@ class TestSimpleTableWithEnumT implements fb.Packable {
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'TestSimpleTableWithEnumT{color: $color}';
|
||||
return 'TestSimpleTableWithEnumT{color: ${color}}';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -467,7 +521,7 @@ class Vec3 {
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'Vec3{x: $x, y: $y, z: $z, test1: $test1, test2: $test2, test3: $test3}';
|
||||
return 'Vec3{x: ${x}, y: ${y}, z: ${z}, test1: ${test1}, test2: ${test2}, test3: ${test3}}';
|
||||
}
|
||||
|
||||
Vec3T unpack() => Vec3T(
|
||||
@@ -516,7 +570,7 @@ class Vec3T implements fb.Packable {
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'Vec3T{x: $x, y: $y, z: $z, test1: $test1, test2: $test2, test3: $test3}';
|
||||
return 'Vec3T{x: ${x}, y: ${y}, z: ${z}, test1: ${test1}, test2: ${test2}, test3: ${test3}}';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -610,7 +664,7 @@ class Ability {
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'Ability{id: $id, distance: $distance}';
|
||||
return 'Ability{id: ${id}, distance: ${distance}}';
|
||||
}
|
||||
|
||||
AbilityT unpack() => AbilityT(
|
||||
@@ -640,7 +694,7 @@ class AbilityT implements fb.Packable {
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'AbilityT{id: $id, distance: $distance}';
|
||||
return 'AbilityT{id: ${id}, distance: ${distance}}';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -709,7 +763,7 @@ class StructOfStructs {
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'StructOfStructs{a: $a, b: $b, c: $c}';
|
||||
return 'StructOfStructs{a: ${a}, b: ${b}, c: ${c}}';
|
||||
}
|
||||
|
||||
StructOfStructsT unpack() => StructOfStructsT(
|
||||
@@ -743,7 +797,7 @@ class StructOfStructsT implements fb.Packable {
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'StructOfStructsT{a: $a, b: $b, c: $c}';
|
||||
return 'StructOfStructsT{a: ${a}, b: ${b}, c: ${c}}';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -803,6 +857,94 @@ class StructOfStructsObjectBuilder extends fb.ObjectBuilder {
|
||||
return fbBuilder.buffer;
|
||||
}
|
||||
}
|
||||
class StructOfStructsOfStructs {
|
||||
StructOfStructsOfStructs._(this._bc, this._bcOffset);
|
||||
|
||||
static const fb.Reader<StructOfStructsOfStructs> reader = _StructOfStructsOfStructsReader();
|
||||
|
||||
final fb.BufferContext _bc;
|
||||
final int _bcOffset;
|
||||
|
||||
StructOfStructs get a => StructOfStructs.reader.read(_bc, _bcOffset + 0);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'StructOfStructsOfStructs{a: ${a}}';
|
||||
}
|
||||
|
||||
StructOfStructsOfStructsT unpack() => StructOfStructsOfStructsT(
|
||||
a: a.unpack());
|
||||
|
||||
static int pack(fb.Builder fbBuilder, StructOfStructsOfStructsT? object) {
|
||||
if (object == null) return 0;
|
||||
return object.pack(fbBuilder);
|
||||
}
|
||||
}
|
||||
|
||||
class StructOfStructsOfStructsT implements fb.Packable {
|
||||
StructOfStructsT a;
|
||||
|
||||
StructOfStructsOfStructsT({
|
||||
required this.a});
|
||||
|
||||
@override
|
||||
int pack(fb.Builder fbBuilder) {
|
||||
a.pack(fbBuilder);
|
||||
return fbBuilder.offset;
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'StructOfStructsOfStructsT{a: ${a}}';
|
||||
}
|
||||
}
|
||||
|
||||
class _StructOfStructsOfStructsReader extends fb.StructReader<StructOfStructsOfStructs> {
|
||||
const _StructOfStructsOfStructsReader();
|
||||
|
||||
@override
|
||||
int get size => 20;
|
||||
|
||||
@override
|
||||
StructOfStructsOfStructs createObject(fb.BufferContext bc, int offset) =>
|
||||
StructOfStructsOfStructs._(bc, offset);
|
||||
}
|
||||
|
||||
class StructOfStructsOfStructsBuilder {
|
||||
StructOfStructsOfStructsBuilder(this.fbBuilder);
|
||||
|
||||
final fb.Builder fbBuilder;
|
||||
|
||||
int finish(fb.StructBuilder a) {
|
||||
a();
|
||||
return fbBuilder.offset;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class StructOfStructsOfStructsObjectBuilder extends fb.ObjectBuilder {
|
||||
final StructOfStructsObjectBuilder _a;
|
||||
|
||||
StructOfStructsOfStructsObjectBuilder({
|
||||
required StructOfStructsObjectBuilder a,
|
||||
})
|
||||
: _a = a;
|
||||
|
||||
/// Finish building, and store into the [fbBuilder].
|
||||
@override
|
||||
int finish(fb.Builder fbBuilder) {
|
||||
_a.finish(fbBuilder);
|
||||
return fbBuilder.offset;
|
||||
}
|
||||
|
||||
/// Convenience method to serialize to byte list.
|
||||
@override
|
||||
Uint8List toBytes([String? fileIdentifier]) {
|
||||
final fbBuilder = fb.Builder(deduplicateTables: false);
|
||||
fbBuilder.finish(finish(fbBuilder), fileIdentifier);
|
||||
return fbBuilder.buffer;
|
||||
}
|
||||
}
|
||||
class Stat {
|
||||
Stat._(this._bc, this._bcOffset);
|
||||
factory Stat(List<int> bytes) {
|
||||
@@ -821,7 +963,7 @@ class Stat {
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'Stat{id: $id, val: $val, count: $count}';
|
||||
return 'Stat{id: ${id}, val: ${val}, count: ${count}}';
|
||||
}
|
||||
|
||||
StatT unpack() => StatT(
|
||||
@@ -858,7 +1000,7 @@ class StatT implements fb.Packable {
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'StatT{id: $id, val: $val, count: $count}';
|
||||
return 'StatT{id: ${id}, val: ${val}, count: ${count}}';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -947,7 +1089,7 @@ class Referrable {
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'Referrable{id: $id}';
|
||||
return 'Referrable{id: ${id}}';
|
||||
}
|
||||
|
||||
ReferrableT unpack() => ReferrableT(
|
||||
@@ -974,7 +1116,7 @@ class ReferrableT implements fb.Packable {
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'ReferrableT{id: $id}';
|
||||
return 'ReferrableT{id: ${id}}';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1115,10 +1257,21 @@ class Monster {
|
||||
Race get signedEnum => Race.fromValue(const fb.Int8Reader().vTableGet(_bc, _bcOffset, 100, -1));
|
||||
List<int>? get testrequirednestedflatbuffer => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 102);
|
||||
List<Stat>? get scalarKeySortedTables => const fb.ListReader<Stat>(Stat.reader).vTableGetNullable(_bc, _bcOffset, 104);
|
||||
Test? get nativeInline => Test.reader.vTableGetNullable(_bc, _bcOffset, 106);
|
||||
LongEnum get longEnumNonEnumDefault => LongEnum.fromValue(const fb.Uint64Reader().vTableGet(_bc, _bcOffset, 108, 0));
|
||||
LongEnum get longEnumNormalDefault => LongEnum.fromValue(const fb.Uint64Reader().vTableGet(_bc, _bcOffset, 110, 2));
|
||||
double get nanDefault => const fb.Float32Reader().vTableGet(_bc, _bcOffset, 112, double.nan);
|
||||
double get infDefault => const fb.Float32Reader().vTableGet(_bc, _bcOffset, 114, double.infinity);
|
||||
double get positiveInfDefault => const fb.Float32Reader().vTableGet(_bc, _bcOffset, 116, double.infinity);
|
||||
double get infinityDefault => const fb.Float32Reader().vTableGet(_bc, _bcOffset, 118, double.infinity);
|
||||
double get positiveInfinityDefault => const fb.Float32Reader().vTableGet(_bc, _bcOffset, 120, double.infinity);
|
||||
double get negativeInfDefault => const fb.Float32Reader().vTableGet(_bc, _bcOffset, 122, double.negativeInfinity);
|
||||
double get negativeInfinityDefault => const fb.Float32Reader().vTableGet(_bc, _bcOffset, 124, double.negativeInfinity);
|
||||
double get doubleInfDefault => const fb.Float64Reader().vTableGet(_bc, _bcOffset, 126, double.infinity);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'Monster{pos: $pos, mana: $mana, hp: $hp, name: $name, inventory: $inventory, color: $color, testType: $testType, test: $test, test4: $test4, testarrayofstring: $testarrayofstring, testarrayoftables: $testarrayoftables, enemy: $enemy, testnestedflatbuffer: $testnestedflatbuffer, testempty: $testempty, testbool: $testbool, testhashs32Fnv1: $testhashs32Fnv1, testhashu32Fnv1: $testhashu32Fnv1, testhashs64Fnv1: $testhashs64Fnv1, testhashu64Fnv1: $testhashu64Fnv1, testhashs32Fnv1a: $testhashs32Fnv1a, testhashu32Fnv1a: $testhashu32Fnv1a, testhashs64Fnv1a: $testhashs64Fnv1a, testhashu64Fnv1a: $testhashu64Fnv1a, testarrayofbools: $testarrayofbools, testf: $testf, testf2: $testf2, testf3: $testf3, testarrayofstring2: $testarrayofstring2, testarrayofsortedstruct: $testarrayofsortedstruct, flex: $flex, test5: $test5, vectorOfLongs: $vectorOfLongs, vectorOfDoubles: $vectorOfDoubles, parentNamespaceTest: $parentNamespaceTest, vectorOfReferrables: $vectorOfReferrables, singleWeakReference: $singleWeakReference, vectorOfWeakReferences: $vectorOfWeakReferences, vectorOfStrongReferrables: $vectorOfStrongReferrables, coOwningReference: $coOwningReference, vectorOfCoOwningReferences: $vectorOfCoOwningReferences, nonOwningReference: $nonOwningReference, vectorOfNonOwningReferences: $vectorOfNonOwningReferences, anyUniqueType: $anyUniqueType, anyUnique: $anyUnique, anyAmbiguousType: $anyAmbiguousType, anyAmbiguous: $anyAmbiguous, vectorOfEnums: $vectorOfEnums, signedEnum: $signedEnum, testrequirednestedflatbuffer: $testrequirednestedflatbuffer, scalarKeySortedTables: $scalarKeySortedTables}';
|
||||
return 'Monster{pos: ${pos}, mana: ${mana}, hp: ${hp}, name: ${name}, inventory: ${inventory}, color: ${color}, testType: ${testType}, test: ${test}, test4: ${test4}, testarrayofstring: ${testarrayofstring}, testarrayoftables: ${testarrayoftables}, enemy: ${enemy}, testnestedflatbuffer: ${testnestedflatbuffer}, testempty: ${testempty}, testbool: ${testbool}, testhashs32Fnv1: ${testhashs32Fnv1}, testhashu32Fnv1: ${testhashu32Fnv1}, testhashs64Fnv1: ${testhashs64Fnv1}, testhashu64Fnv1: ${testhashu64Fnv1}, testhashs32Fnv1a: ${testhashs32Fnv1a}, testhashu32Fnv1a: ${testhashu32Fnv1a}, testhashs64Fnv1a: ${testhashs64Fnv1a}, testhashu64Fnv1a: ${testhashu64Fnv1a}, testarrayofbools: ${testarrayofbools}, testf: ${testf}, testf2: ${testf2}, testf3: ${testf3}, testarrayofstring2: ${testarrayofstring2}, testarrayofsortedstruct: ${testarrayofsortedstruct}, flex: ${flex}, test5: ${test5}, vectorOfLongs: ${vectorOfLongs}, vectorOfDoubles: ${vectorOfDoubles}, parentNamespaceTest: ${parentNamespaceTest}, vectorOfReferrables: ${vectorOfReferrables}, singleWeakReference: ${singleWeakReference}, vectorOfWeakReferences: ${vectorOfWeakReferences}, vectorOfStrongReferrables: ${vectorOfStrongReferrables}, coOwningReference: ${coOwningReference}, vectorOfCoOwningReferences: ${vectorOfCoOwningReferences}, nonOwningReference: ${nonOwningReference}, vectorOfNonOwningReferences: ${vectorOfNonOwningReferences}, anyUniqueType: ${anyUniqueType}, anyUnique: ${anyUnique}, anyAmbiguousType: ${anyAmbiguousType}, anyAmbiguous: ${anyAmbiguous}, vectorOfEnums: ${vectorOfEnums}, signedEnum: ${signedEnum}, testrequirednestedflatbuffer: ${testrequirednestedflatbuffer}, scalarKeySortedTables: ${scalarKeySortedTables}, nativeInline: ${nativeInline}, longEnumNonEnumDefault: ${longEnumNonEnumDefault}, longEnumNormalDefault: ${longEnumNormalDefault}, nanDefault: ${nanDefault}, infDefault: ${infDefault}, positiveInfDefault: ${positiveInfDefault}, infinityDefault: ${infinityDefault}, positiveInfinityDefault: ${positiveInfinityDefault}, negativeInfDefault: ${negativeInfDefault}, negativeInfinityDefault: ${negativeInfinityDefault}, doubleInfDefault: ${doubleInfDefault}}';
|
||||
}
|
||||
|
||||
MonsterT unpack() => MonsterT(
|
||||
@@ -1171,7 +1324,18 @@ class Monster {
|
||||
vectorOfEnums: const fb.ListReader<Color>(Color.reader, lazy: false).vTableGetNullable(_bc, _bcOffset, 98),
|
||||
signedEnum: signedEnum,
|
||||
testrequirednestedflatbuffer: const fb.Uint8ListReader(lazy: false).vTableGetNullable(_bc, _bcOffset, 102),
|
||||
scalarKeySortedTables: scalarKeySortedTables?.map((e) => e.unpack()).toList());
|
||||
scalarKeySortedTables: scalarKeySortedTables?.map((e) => e.unpack()).toList(),
|
||||
nativeInline: nativeInline?.unpack(),
|
||||
longEnumNonEnumDefault: longEnumNonEnumDefault,
|
||||
longEnumNormalDefault: longEnumNormalDefault,
|
||||
nanDefault: nanDefault,
|
||||
infDefault: infDefault,
|
||||
positiveInfDefault: positiveInfDefault,
|
||||
infinityDefault: infinityDefault,
|
||||
positiveInfinityDefault: positiveInfinityDefault,
|
||||
negativeInfDefault: negativeInfDefault,
|
||||
negativeInfinityDefault: negativeInfinityDefault,
|
||||
doubleInfDefault: doubleInfDefault);
|
||||
|
||||
static int pack(fb.Builder fbBuilder, MonsterT? object) {
|
||||
if (object == null) return 0;
|
||||
@@ -1233,6 +1397,17 @@ class MonsterT implements fb.Packable {
|
||||
Race signedEnum;
|
||||
List<int>? testrequirednestedflatbuffer;
|
||||
List<StatT>? scalarKeySortedTables;
|
||||
TestT? nativeInline;
|
||||
LongEnum longEnumNonEnumDefault;
|
||||
LongEnum longEnumNormalDefault;
|
||||
double nanDefault;
|
||||
double infDefault;
|
||||
double positiveInfDefault;
|
||||
double infinityDefault;
|
||||
double positiveInfinityDefault;
|
||||
double negativeInfDefault;
|
||||
double negativeInfinityDefault;
|
||||
double doubleInfDefault;
|
||||
|
||||
MonsterT({
|
||||
this.pos,
|
||||
@@ -1284,7 +1459,18 @@ class MonsterT implements fb.Packable {
|
||||
this.vectorOfEnums,
|
||||
this.signedEnum = Race.None,
|
||||
this.testrequirednestedflatbuffer,
|
||||
this.scalarKeySortedTables});
|
||||
this.scalarKeySortedTables,
|
||||
this.nativeInline,
|
||||
this.longEnumNonEnumDefault = const LongEnum._(0),
|
||||
this.longEnumNormalDefault = LongEnum.LongOne,
|
||||
this.nanDefault = double.nan,
|
||||
this.infDefault = double.infinity,
|
||||
this.positiveInfDefault = double.infinity,
|
||||
this.infinityDefault = double.infinity,
|
||||
this.positiveInfinityDefault = double.infinity,
|
||||
this.negativeInfDefault = double.negativeInfinity,
|
||||
this.negativeInfinityDefault = double.negativeInfinity,
|
||||
this.doubleInfDefault = double.infinity});
|
||||
|
||||
@override
|
||||
int pack(fb.Builder fbBuilder) {
|
||||
@@ -1345,7 +1531,7 @@ class MonsterT implements fb.Packable {
|
||||
: fbBuilder.writeListUint8(testrequirednestedflatbuffer!);
|
||||
final int? scalarKeySortedTablesOffset = scalarKeySortedTables == null ? null
|
||||
: fbBuilder.writeList(scalarKeySortedTables!.map((b) => b.pack(fbBuilder)).toList());
|
||||
fbBuilder.startTable(50);
|
||||
fbBuilder.startTable(62);
|
||||
if (pos != null) {
|
||||
fbBuilder.addStruct(0, pos!.pack(fbBuilder));
|
||||
}
|
||||
@@ -1398,12 +1584,25 @@ class MonsterT implements fb.Packable {
|
||||
fbBuilder.addInt8(48, signedEnum.value);
|
||||
fbBuilder.addOffset(49, testrequirednestedflatbufferOffset);
|
||||
fbBuilder.addOffset(50, scalarKeySortedTablesOffset);
|
||||
if (nativeInline != null) {
|
||||
fbBuilder.addStruct(51, nativeInline!.pack(fbBuilder));
|
||||
}
|
||||
fbBuilder.addUint64(52, longEnumNonEnumDefault.value);
|
||||
fbBuilder.addUint64(53, longEnumNormalDefault.value);
|
||||
fbBuilder.addFloat32(54, nanDefault);
|
||||
fbBuilder.addFloat32(55, infDefault);
|
||||
fbBuilder.addFloat32(56, positiveInfDefault);
|
||||
fbBuilder.addFloat32(57, infinityDefault);
|
||||
fbBuilder.addFloat32(58, positiveInfinityDefault);
|
||||
fbBuilder.addFloat32(59, negativeInfDefault);
|
||||
fbBuilder.addFloat32(60, negativeInfinityDefault);
|
||||
fbBuilder.addFloat64(61, doubleInfDefault);
|
||||
return fbBuilder.endTable();
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'MonsterT{pos: $pos, mana: $mana, hp: $hp, name: $name, inventory: $inventory, color: $color, testType: $testType, test: $test, test4: $test4, testarrayofstring: $testarrayofstring, testarrayoftables: $testarrayoftables, enemy: $enemy, testnestedflatbuffer: $testnestedflatbuffer, testempty: $testempty, testbool: $testbool, testhashs32Fnv1: $testhashs32Fnv1, testhashu32Fnv1: $testhashu32Fnv1, testhashs64Fnv1: $testhashs64Fnv1, testhashu64Fnv1: $testhashu64Fnv1, testhashs32Fnv1a: $testhashs32Fnv1a, testhashu32Fnv1a: $testhashu32Fnv1a, testhashs64Fnv1a: $testhashs64Fnv1a, testhashu64Fnv1a: $testhashu64Fnv1a, testarrayofbools: $testarrayofbools, testf: $testf, testf2: $testf2, testf3: $testf3, testarrayofstring2: $testarrayofstring2, testarrayofsortedstruct: $testarrayofsortedstruct, flex: $flex, test5: $test5, vectorOfLongs: $vectorOfLongs, vectorOfDoubles: $vectorOfDoubles, parentNamespaceTest: $parentNamespaceTest, vectorOfReferrables: $vectorOfReferrables, singleWeakReference: $singleWeakReference, vectorOfWeakReferences: $vectorOfWeakReferences, vectorOfStrongReferrables: $vectorOfStrongReferrables, coOwningReference: $coOwningReference, vectorOfCoOwningReferences: $vectorOfCoOwningReferences, nonOwningReference: $nonOwningReference, vectorOfNonOwningReferences: $vectorOfNonOwningReferences, anyUniqueType: $anyUniqueType, anyUnique: $anyUnique, anyAmbiguousType: $anyAmbiguousType, anyAmbiguous: $anyAmbiguous, vectorOfEnums: $vectorOfEnums, signedEnum: $signedEnum, testrequirednestedflatbuffer: $testrequirednestedflatbuffer, scalarKeySortedTables: $scalarKeySortedTables}';
|
||||
return 'MonsterT{pos: ${pos}, mana: ${mana}, hp: ${hp}, name: ${name}, inventory: ${inventory}, color: ${color}, testType: ${testType}, test: ${test}, test4: ${test4}, testarrayofstring: ${testarrayofstring}, testarrayoftables: ${testarrayoftables}, enemy: ${enemy}, testnestedflatbuffer: ${testnestedflatbuffer}, testempty: ${testempty}, testbool: ${testbool}, testhashs32Fnv1: ${testhashs32Fnv1}, testhashu32Fnv1: ${testhashu32Fnv1}, testhashs64Fnv1: ${testhashs64Fnv1}, testhashu64Fnv1: ${testhashu64Fnv1}, testhashs32Fnv1a: ${testhashs32Fnv1a}, testhashu32Fnv1a: ${testhashu32Fnv1a}, testhashs64Fnv1a: ${testhashs64Fnv1a}, testhashu64Fnv1a: ${testhashu64Fnv1a}, testarrayofbools: ${testarrayofbools}, testf: ${testf}, testf2: ${testf2}, testf3: ${testf3}, testarrayofstring2: ${testarrayofstring2}, testarrayofsortedstruct: ${testarrayofsortedstruct}, flex: ${flex}, test5: ${test5}, vectorOfLongs: ${vectorOfLongs}, vectorOfDoubles: ${vectorOfDoubles}, parentNamespaceTest: ${parentNamespaceTest}, vectorOfReferrables: ${vectorOfReferrables}, singleWeakReference: ${singleWeakReference}, vectorOfWeakReferences: ${vectorOfWeakReferences}, vectorOfStrongReferrables: ${vectorOfStrongReferrables}, coOwningReference: ${coOwningReference}, vectorOfCoOwningReferences: ${vectorOfCoOwningReferences}, nonOwningReference: ${nonOwningReference}, vectorOfNonOwningReferences: ${vectorOfNonOwningReferences}, anyUniqueType: ${anyUniqueType}, anyUnique: ${anyUnique}, anyAmbiguousType: ${anyAmbiguousType}, anyAmbiguous: ${anyAmbiguous}, vectorOfEnums: ${vectorOfEnums}, signedEnum: ${signedEnum}, testrequirednestedflatbuffer: ${testrequirednestedflatbuffer}, scalarKeySortedTables: ${scalarKeySortedTables}, nativeInline: ${nativeInline}, longEnumNonEnumDefault: ${longEnumNonEnumDefault}, longEnumNormalDefault: ${longEnumNormalDefault}, nanDefault: ${nanDefault}, infDefault: ${infDefault}, positiveInfDefault: ${positiveInfDefault}, infinityDefault: ${infinityDefault}, positiveInfinityDefault: ${positiveInfinityDefault}, negativeInfDefault: ${negativeInfDefault}, negativeInfinityDefault: ${negativeInfinityDefault}, doubleInfDefault: ${doubleInfDefault}}';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1421,7 +1620,7 @@ class MonsterBuilder {
|
||||
final fb.Builder fbBuilder;
|
||||
|
||||
void begin() {
|
||||
fbBuilder.startTable(50);
|
||||
fbBuilder.startTable(62);
|
||||
}
|
||||
|
||||
int addPos(int offset) {
|
||||
@@ -1624,6 +1823,50 @@ class MonsterBuilder {
|
||||
fbBuilder.addOffset(50, offset);
|
||||
return fbBuilder.offset;
|
||||
}
|
||||
int addNativeInline(int offset) {
|
||||
fbBuilder.addStruct(51, offset);
|
||||
return fbBuilder.offset;
|
||||
}
|
||||
int addLongEnumNonEnumDefault(LongEnum? longEnumNonEnumDefault) {
|
||||
fbBuilder.addUint64(52, longEnumNonEnumDefault?.value);
|
||||
return fbBuilder.offset;
|
||||
}
|
||||
int addLongEnumNormalDefault(LongEnum? longEnumNormalDefault) {
|
||||
fbBuilder.addUint64(53, longEnumNormalDefault?.value);
|
||||
return fbBuilder.offset;
|
||||
}
|
||||
int addNanDefault(double? nanDefault) {
|
||||
fbBuilder.addFloat32(54, nanDefault);
|
||||
return fbBuilder.offset;
|
||||
}
|
||||
int addInfDefault(double? infDefault) {
|
||||
fbBuilder.addFloat32(55, infDefault);
|
||||
return fbBuilder.offset;
|
||||
}
|
||||
int addPositiveInfDefault(double? positiveInfDefault) {
|
||||
fbBuilder.addFloat32(56, positiveInfDefault);
|
||||
return fbBuilder.offset;
|
||||
}
|
||||
int addInfinityDefault(double? infinityDefault) {
|
||||
fbBuilder.addFloat32(57, infinityDefault);
|
||||
return fbBuilder.offset;
|
||||
}
|
||||
int addPositiveInfinityDefault(double? positiveInfinityDefault) {
|
||||
fbBuilder.addFloat32(58, positiveInfinityDefault);
|
||||
return fbBuilder.offset;
|
||||
}
|
||||
int addNegativeInfDefault(double? negativeInfDefault) {
|
||||
fbBuilder.addFloat32(59, negativeInfDefault);
|
||||
return fbBuilder.offset;
|
||||
}
|
||||
int addNegativeInfinityDefault(double? negativeInfinityDefault) {
|
||||
fbBuilder.addFloat32(60, negativeInfinityDefault);
|
||||
return fbBuilder.offset;
|
||||
}
|
||||
int addDoubleInfDefault(double? doubleInfDefault) {
|
||||
fbBuilder.addFloat64(61, doubleInfDefault);
|
||||
return fbBuilder.offset;
|
||||
}
|
||||
|
||||
int finish() {
|
||||
return fbBuilder.endTable();
|
||||
@@ -1681,6 +1924,17 @@ class MonsterObjectBuilder extends fb.ObjectBuilder {
|
||||
final Race? _signedEnum;
|
||||
final List<int>? _testrequirednestedflatbuffer;
|
||||
final List<StatObjectBuilder>? _scalarKeySortedTables;
|
||||
final TestObjectBuilder? _nativeInline;
|
||||
final LongEnum? _longEnumNonEnumDefault;
|
||||
final LongEnum? _longEnumNormalDefault;
|
||||
final double? _nanDefault;
|
||||
final double? _infDefault;
|
||||
final double? _positiveInfDefault;
|
||||
final double? _infinityDefault;
|
||||
final double? _positiveInfinityDefault;
|
||||
final double? _negativeInfDefault;
|
||||
final double? _negativeInfinityDefault;
|
||||
final double? _doubleInfDefault;
|
||||
|
||||
MonsterObjectBuilder({
|
||||
Vec3ObjectBuilder? pos,
|
||||
@@ -1733,6 +1987,17 @@ class MonsterObjectBuilder extends fb.ObjectBuilder {
|
||||
Race? signedEnum,
|
||||
List<int>? testrequirednestedflatbuffer,
|
||||
List<StatObjectBuilder>? scalarKeySortedTables,
|
||||
TestObjectBuilder? nativeInline,
|
||||
LongEnum? longEnumNonEnumDefault,
|
||||
LongEnum? longEnumNormalDefault,
|
||||
double? nanDefault,
|
||||
double? infDefault,
|
||||
double? positiveInfDefault,
|
||||
double? infinityDefault,
|
||||
double? positiveInfinityDefault,
|
||||
double? negativeInfDefault,
|
||||
double? negativeInfinityDefault,
|
||||
double? doubleInfDefault,
|
||||
})
|
||||
: _pos = pos,
|
||||
_mana = mana,
|
||||
@@ -1783,7 +2048,18 @@ class MonsterObjectBuilder extends fb.ObjectBuilder {
|
||||
_vectorOfEnums = vectorOfEnums,
|
||||
_signedEnum = signedEnum,
|
||||
_testrequirednestedflatbuffer = testrequirednestedflatbuffer,
|
||||
_scalarKeySortedTables = scalarKeySortedTables;
|
||||
_scalarKeySortedTables = scalarKeySortedTables,
|
||||
_nativeInline = nativeInline,
|
||||
_longEnumNonEnumDefault = longEnumNonEnumDefault,
|
||||
_longEnumNormalDefault = longEnumNormalDefault,
|
||||
_nanDefault = nanDefault,
|
||||
_infDefault = infDefault,
|
||||
_positiveInfDefault = positiveInfDefault,
|
||||
_infinityDefault = infinityDefault,
|
||||
_positiveInfinityDefault = positiveInfinityDefault,
|
||||
_negativeInfDefault = negativeInfDefault,
|
||||
_negativeInfinityDefault = negativeInfinityDefault,
|
||||
_doubleInfDefault = doubleInfDefault;
|
||||
|
||||
/// Finish building, and store into the [fbBuilder].
|
||||
@override
|
||||
@@ -1836,7 +2112,7 @@ class MonsterObjectBuilder extends fb.ObjectBuilder {
|
||||
: fbBuilder.writeListUint8(_testrequirednestedflatbuffer!);
|
||||
final int? scalarKeySortedTablesOffset = _scalarKeySortedTables == null ? null
|
||||
: fbBuilder.writeList(_scalarKeySortedTables!.map((b) => b.getOrCreateOffset(fbBuilder)).toList());
|
||||
fbBuilder.startTable(50);
|
||||
fbBuilder.startTable(62);
|
||||
if (_pos != null) {
|
||||
fbBuilder.addStruct(0, _pos!.finish(fbBuilder));
|
||||
}
|
||||
@@ -1889,6 +2165,19 @@ class MonsterObjectBuilder extends fb.ObjectBuilder {
|
||||
fbBuilder.addInt8(48, _signedEnum?.value);
|
||||
fbBuilder.addOffset(49, testrequirednestedflatbufferOffset);
|
||||
fbBuilder.addOffset(50, scalarKeySortedTablesOffset);
|
||||
if (_nativeInline != null) {
|
||||
fbBuilder.addStruct(51, _nativeInline!.finish(fbBuilder));
|
||||
}
|
||||
fbBuilder.addUint64(52, _longEnumNonEnumDefault?.value);
|
||||
fbBuilder.addUint64(53, _longEnumNormalDefault?.value);
|
||||
fbBuilder.addFloat32(54, _nanDefault);
|
||||
fbBuilder.addFloat32(55, _infDefault);
|
||||
fbBuilder.addFloat32(56, _positiveInfDefault);
|
||||
fbBuilder.addFloat32(57, _infinityDefault);
|
||||
fbBuilder.addFloat32(58, _positiveInfinityDefault);
|
||||
fbBuilder.addFloat32(59, _negativeInfDefault);
|
||||
fbBuilder.addFloat32(60, _negativeInfinityDefault);
|
||||
fbBuilder.addFloat64(61, _doubleInfDefault);
|
||||
return fbBuilder.endTable();
|
||||
}
|
||||
|
||||
@@ -1927,7 +2216,7 @@ class TypeAliases {
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'TypeAliases{i8: $i8, u8: $u8, i16: $i16, u16: $u16, i32: $i32, u32: $u32, i64: $i64, u64: $u64, f32: $f32, f64: $f64, v8: $v8, vf64: $vf64}';
|
||||
return 'TypeAliases{i8: ${i8}, u8: ${u8}, i16: ${i16}, u16: ${u16}, i32: ${i32}, u32: ${u32}, i64: ${i64}, u64: ${u64}, f32: ${f32}, f64: ${f64}, v8: ${v8}, vf64: ${vf64}}';
|
||||
}
|
||||
|
||||
TypeAliasesT unpack() => TypeAliasesT(
|
||||
@@ -2002,7 +2291,7 @@ class TypeAliasesT implements fb.Packable {
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'TypeAliasesT{i8: $i8, u8: $u8, i16: $i16, u16: $u16, i32: $i32, u32: $u32, i64: $i64, u64: $u64, f32: $f32, f64: $f64, v8: $v8, vf64: $vf64}';
|
||||
return 'TypeAliasesT{i8: ${i8}, u8: ${u8}, i16: ${i16}, u16: ${u16}, i32: ${i32}, u32: ${u32}, i64: ${i64}, u64: ${u64}, f32: ${f32}, f64: ${f64}, v8: ${v8}, vf64: ${vf64}}';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,8 @@ import 'package:flat_buffers/flat_buffers.dart' as fb;
|
||||
import './monster_test_my_game.example_generated.dart' as my_game_example;
|
||||
import './monster_test_my_game.example2_generated.dart' as my_game_example2;
|
||||
|
||||
import './include_test1_generated.dart';
|
||||
|
||||
class InParentNamespace {
|
||||
InParentNamespace._(this._bc, this._bcOffset);
|
||||
factory InParentNamespace(List<int> bytes) {
|
||||
|
||||
Binary file not shown.
@@ -31,24 +31,22 @@ run 'flattests' or `flatsampletext`, or it will fail to load its files.*
|
||||
|
||||
### Make all warnings into errors
|
||||
|
||||
By default all Flatbuffers `cmake` targets are build with `-Werror` flag.
|
||||
With this flag (or `/WX` for MSVC) C++ compiler will treat all warnings as errors.
|
||||
Additionally `-Wall -pedantic -Wextra` (or `/W4` form MSVC) flags are set.
|
||||
These flags minimize the number of possible defects in code and keep code highly portable.
|
||||
Using these flags is considered good practice but sometimes it can break dependent projects
|
||||
if a compiler is upgraded or a toolset is changed.
|
||||
Usually, newer compiler versions add new compile-time diagnostics that were unavailable before.
|
||||
These new diagnostic warnings could stop the build process if `-Werror` flag is set.
|
||||
By default all Flatbuffers `cmake` targets are **not** built with the `-Werror`
|
||||
(or `/WX` for MSVC) flag that treats any warning as an error. This allows more
|
||||
flexibility for users of Flatbuffers to use newer compilers and toolsets that
|
||||
may add new warnings that would cause a build failure.
|
||||
|
||||
It is possible to cancel `warnings as errors` flag at `cmake` configuration stage using
|
||||
`FLATBUFFERS_CXX_FLAGS` option. Compilation flags declared in `FLATBUFFERS_CXX_FLAGS` will be
|
||||
appended to the project-level `CMAKE_CXX_FLAGS` variable.
|
||||
Examples:
|
||||
To enable a stricter build that does treat warnings as errors, set the
|
||||
`FLATBUFFERS_STRICT_MODE` `cmake` compliation flag to `ON`.
|
||||
|
||||
- GCC and Clang: `cmake . -D FLATBUFFERS_CXX_FLAGS="-Wno-error"`
|
||||
- MSVC: `cmake . -D FLATBUFFERS_CXX_FLAGS="/WX-"`
|
||||
- MSVC: `cmake . -D FLATBUFFERS_CXX_FLAGS="/Wv <compiler.version>"`
|
||||
```
|
||||
cmake . -DFLATBUFFERS_STRICT_MODE=ON
|
||||
```
|
||||
|
||||
Our CI builds run with strict mode on, ensuring the code that is committed to
|
||||
the project is as portable and warning free as possible. Thus developers
|
||||
contributing to the project should enable strict mode locally before making a
|
||||
PR.
|
||||
|
||||
## Building with VCPKG
|
||||
|
||||
@@ -63,6 +61,18 @@ You can download and install flatbuffers using the [vcpkg](https://github.com/Mi
|
||||
The flatbuffers port in vcpkg is kept up to date by Microsoft team members and community contributors.
|
||||
If the version is out of date, please [create an issue or pull request](https://github.com/Microsoft/vcpkg) on the vcpkg repository.
|
||||
|
||||
## Downloading binaries
|
||||
You can download the binaries from the
|
||||
[GitHub release page](https://github.com/google/flatbuffers/releases).
|
||||
|
||||
We generate [SLSA3 signatures](slsa.dev) using the OpenSSF's [slsa-framework/slsa-github-generator](https://github.com/slsa-framework/slsa-github-generator). To verify the binaries:
|
||||
1. Install the verification tool from [slsa-framework/slsa-verifier#installation](https://github.com/slsa-framework/slsa-verifier#installation)
|
||||
1. Download the file named `attestation.intoto.jsonl` from the GitHub release
|
||||
1. Run:
|
||||
```shell
|
||||
$ slsa-verifier -artifact-path <downloaded.zip> -provenance attestation.intoto.jsonl -source github.com/google/flatbuffers -tag <version>
|
||||
PASSED: Verified SLSA provenance
|
||||
|
||||
## Building for Android
|
||||
|
||||
There is a `flatbuffers/android` directory that contains all you need to build
|
||||
|
||||
@@ -90,7 +90,10 @@ Additional options:
|
||||
|
||||
- `--scoped-enums` : Use C++11 style scoped and strongly typed enums in
|
||||
generated C++. This also implies `--no-prefix`.
|
||||
|
||||
|
||||
- `--no-emit-min-max-enum-values` : Disable generation of MIN and MAX
|
||||
enumerated values for scoped enums and prefixed enums.
|
||||
|
||||
- `--gen-includes` : (deprecated), this is the default behavior.
|
||||
If the original behavior is required (no include
|
||||
statements) use `--no-includes.`
|
||||
|
||||
@@ -82,7 +82,7 @@ pass to the `GetRootAsMyRootType` function:
|
||||
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cs}
|
||||
using MyGame.Example;
|
||||
using FlatBuffers;
|
||||
using Google.FlatBuffers;
|
||||
|
||||
// This snippet ignores exceptions for brevity.
|
||||
byte[] data = File.ReadAllBytes("monsterdata_test.mon");
|
||||
|
||||
@@ -52,10 +52,10 @@ a `[]byte`, which you pass to the `GetRootAsMonster` function:
|
||||
example "MyGame/Example"
|
||||
flatbuffers "github.com/google/flatbuffers/go"
|
||||
|
||||
io/ioutil
|
||||
"os"
|
||||
)
|
||||
|
||||
buf, err := ioutil.ReadFile("monster.dat")
|
||||
buf, err := os.ReadFile("monster.dat")
|
||||
// handle err
|
||||
monster := example.GetRootAsMonster(buf, 0)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
@@ -10,7 +10,7 @@ include = `include` string\_constant `;`
|
||||
|
||||
namespace\_decl = `namespace` ident ( `.` ident )* `;`
|
||||
|
||||
attribute\_decl = `attribute` ident | `"`ident`"` `;`
|
||||
attribute\_decl = `attribute` ident | `"` ident `"` `;`
|
||||
|
||||
type\_decl = ( `table` | `struct` ) ident metadata `{` field\_decl+ `}`
|
||||
|
||||
@@ -31,7 +31,7 @@ type = `bool` | `byte` | `ubyte` | `short` | `ushort` | `int` | `uint` |
|
||||
`float32` | `float64` |
|
||||
`string` | `[` type `]` | ident
|
||||
|
||||
enumval\_decl = ident [ `=` integer\_constant ]
|
||||
enumval\_decl = ident [ `=` integer\_constant ] metadata
|
||||
|
||||
metadata = [ `(` commasep( ident [ `:` single\_value ] ) `)` ]
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ To generate the docs for FlatBuffers from the source files, you
|
||||
will first need to install two programs.
|
||||
|
||||
1. You will need to install `doxygen`. See
|
||||
[Download Doxygen](http://www.stack.nl/~dimitri/doxygen/download.html).
|
||||
[Download Doxygen](https://doxygen.nl/download.html).
|
||||
|
||||
2. You will need to install `doxypypy` to format python comments appropriately.
|
||||
Install it from [here](https://github.com/Feneric/doxypypy).
|
||||
|
||||
@@ -58,7 +58,7 @@ and the generated code to read or write FlatBuffers.
|
||||
|
||||
For example, here is how you would read a FlatBuffer binary file in Rust:
|
||||
First, include the library and generated code. Then read the file into
|
||||
a `u8` vector, which you pass, as a byte slice, to `get_root_as_monster()`.
|
||||
a `u8` vector, which you pass, as a byte slice, to `root_as_monster()`.
|
||||
|
||||
This full example program is available in the Rust test suite:
|
||||
[monster_example.rs](https://github.com/google/flatbuffers/blob/master/tests/rust_usage_test/bin/monster_example.rs)
|
||||
@@ -80,7 +80,7 @@ It can be run by `cd`ing to the `rust_usage_test` directory and executing: `carg
|
||||
let mut buf = Vec::new();
|
||||
f.read_to_end(&mut buf).expect("file reading failed");
|
||||
|
||||
let monster = my_game::example::get_root_as_monster(&buf[..]);
|
||||
let monster = my_game::example::root_as_monster(&buf[..]);
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
`monster` is of type `Monster`, and points to somewhere *inside* your
|
||||
@@ -108,7 +108,7 @@ the layout of things is generally not known to the user.
|
||||
For structs, layout is deterministic and guaranteed to be the same
|
||||
across platforms (scalars are aligned to their
|
||||
own size, and structs themselves to their largest member), and you
|
||||
are allowed to access this memory directly by using `safe_slice` and
|
||||
are allowed to access this memory directly by using `safe_slice`
|
||||
on the reference to a struct, or even an array of structs.
|
||||
|
||||
To compute offsets to sub-elements of a struct, make sure they
|
||||
@@ -118,9 +118,10 @@ handy for use of arrays of structs with calls like `glVertexAttribPointer`
|
||||
in OpenGL or similar APIs.
|
||||
|
||||
It is important to note is that structs are still little endian on all
|
||||
machines, so only use tricks like this if you can guarantee you're not
|
||||
shipping on a big endian machine (using an `#[cfg(target_endian = "little")]`
|
||||
attribute would be wise).
|
||||
machines, so the functions to enable tricks like this are only exposed on little
|
||||
endian machines. If you also ship on big endian machines, using an
|
||||
`#[cfg(target_endian = "little")]` attribute would be wise or your code will not
|
||||
compile.
|
||||
|
||||
The special function `safe_slice` is implemented on Vector objects that are
|
||||
represented in memory the same way as they are represented on the wire. This
|
||||
@@ -134,22 +135,22 @@ of `safe_slice`.
|
||||
|
||||
## Access of untrusted buffers
|
||||
|
||||
The safe Rust functions to interpret a slice as a table (`root`,
|
||||
`size_prefixed_root`, `root_with_opts`, and `size_prefixed_root_with_opts`)
|
||||
verify the data first. This has some performance cost, but is intended to be
|
||||
safe for use on flatbuffers from untrusted sources. There are corresponding
|
||||
`unsafe` versions with names ending in `_unchecked` which skip this
|
||||
verification, and may access arbitrary memory.
|
||||
|
||||
The generated accessor functions access fields over offsets, which is
|
||||
very quick. These offsets are used to index into Rust slices, so they are
|
||||
bounds-checked by the Rust runtime. However, our Rust implementation may
|
||||
change: we may convert access functions to use direct pointer dereferencing, to
|
||||
improve lookup speed. As a result, users should not rely on the aforementioned
|
||||
bounds-checking behavior.
|
||||
very quick. The current implementation uses these to access memory without any
|
||||
further bounds checking. All of the safe Rust APIs ensure the verifier is run
|
||||
over these flatbuffers before accessing them.
|
||||
|
||||
When you're processing large amounts of data from a source you know (e.g.
|
||||
your own generated data on disk), this is acceptable, but when reading
|
||||
data from the network that can potentially have been modified by an
|
||||
attacker, this is undesirable.
|
||||
|
||||
The C++ port provides a buffer verifier. At this time, Rust does not. Rust may
|
||||
provide a verifier in a future version. In the meantime, Rust users can access
|
||||
the buffer verifier generated by the C++ port through a foreign function
|
||||
interface (FFI).
|
||||
your own generated data on disk), the `_unchecked` versions are acceptable, but
|
||||
when reading data from the network that can potentially have been modified by an
|
||||
attacker, it is desirable to use the safe versions which use the verifier.
|
||||
|
||||
## Threading
|
||||
|
||||
@@ -165,6 +166,17 @@ manually wrap it in synchronisation primitives. There's no automatic way to
|
||||
accomplish this, by design, as we feel multithreaded construction
|
||||
of a single buffer will be rare, and synchronisation overhead would be costly.
|
||||
|
||||
Unlike most other languages, in Rust these properties are exposed to and
|
||||
enforced by the type system. `flatbuffers::Table` and the generated table types
|
||||
are `Send + Sync`, indicating they may be freely shared across threads and data
|
||||
may be accessed from any thread which receives a const (aka shared) reference.
|
||||
There are no functions which require a mutable (aka exclusive) reference, which
|
||||
means all the available functions may be called like this.
|
||||
`flatbuffers::FlatBufferBuilder` is also `Send + Sync`, but all of the mutating
|
||||
functions require a mutable (aka exclusive) reference which can only be created
|
||||
when no other references to the `FlatBufferBuilder` exist, and may not be copied
|
||||
within the same thread, let alone to a second thread.
|
||||
|
||||
## Useful tools created by others
|
||||
|
||||
* [flatc-rust](https://github.com/frol/flatc-rust) - FlatBuffers compiler
|
||||
|
||||
@@ -309,11 +309,11 @@ in the corresponding C++ code. Multiple such lines per item are allowed.
|
||||
|
||||
### Attributes
|
||||
|
||||
Attributes may be attached to a declaration, behind a field, or after
|
||||
the name of a table/struct/enum/union. These may either have a value or
|
||||
not. Some attributes like `deprecated` are understood by the compiler;
|
||||
user defined ones need to be declared with the attribute declaration
|
||||
(like `priority` in the example above), and are
|
||||
Attributes may be attached to a declaration, behind a field/enum value,
|
||||
or after the name of a table/struct/enum/union. These may either have
|
||||
a value or not. Some attributes like `deprecated` are understood by
|
||||
the compiler; user defined ones need to be declared with the attribute
|
||||
declaration (like `priority` in the example above), and are
|
||||
available to query if you parse the schema at runtime.
|
||||
This is useful if you write your own code generators/editors etc., and
|
||||
you wish to add additional information specific to your tool (such as a
|
||||
@@ -552,7 +552,7 @@ the world. If this is not practical for you, use explicit field ids, which
|
||||
should always generate a merge conflict if two people try to allocate the same
|
||||
id.
|
||||
|
||||
### Schema evolution examples
|
||||
### Schema evolution examples (tables)
|
||||
|
||||
Some examples to clarify what happens as you change a schema:
|
||||
|
||||
@@ -614,6 +614,41 @@ Occasionally ok. You've renamed fields, which will break all code (and JSON
|
||||
files!) that use this schema, but as long as the change is obvious, this is not
|
||||
incompatible with the actual binary buffers, since those only ever address
|
||||
fields by id/offset.
|
||||
|
||||
#### Schema evolution examples (unions)
|
||||
|
||||
Suppose we have the following schema:
|
||||
```
|
||||
union Foo { A, B }
|
||||
```
|
||||
We can add another variant at the end.
|
||||
```
|
||||
union Foo { A, B, another_a: A }
|
||||
```
|
||||
and this will be okay. Old code will not recognize `another_a`.
|
||||
However if we add `another_a` anywhere but the end, e.g.
|
||||
```
|
||||
union Foo { A, another_a: A, B }
|
||||
```
|
||||
this is not okay. When new code writes `another_a`, old code will
|
||||
misinterpret it as `B` (and vice versa). However you can explicitly
|
||||
set the union's "discriminant" value like so:
|
||||
```
|
||||
union Foo { A = 1, another_a: A = 3, B = 2 }
|
||||
```
|
||||
This is okay.
|
||||
|
||||
```
|
||||
union Foo { original_a: A = 1, another_a: A = 3, B = 2 }
|
||||
```
|
||||
Renaming fields will break code and any saved human readable representations,
|
||||
such as json files, but the binary buffers will be the same.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<br>
|
||||
|
||||
### Testing whether a field is present in a table
|
||||
|
||||
@@ -22,10 +22,10 @@ GitHub page](https://github.com/google/flatbuffers/tree/master/swift).
|
||||
|
||||
## Testing the FlatBuffers Swift library
|
||||
|
||||
The code to test the Swift library can be found at `flatbuffers/Flatbuffers.Test.Swift`.
|
||||
The test code itself is located in [Flatbuffers.Test.Swift](https://github.com/google/flatbuffers/blob/master/tests/FlatBuffers.Test.Swift).
|
||||
The code to test the Swift library can be found at `flatbuffers/tests/swift/tests`.
|
||||
The test code itself is located in [flatbuffers/tests/swift/tests](https://github.com/google/flatbuffers/blob/master/tests/swift/tests).
|
||||
|
||||
To run the tests, use the [SwiftTest.sh](https://github.com/google/flatbuffers/blob/master/tests/FlatBuffers.Test.Swift/SwiftTest.sh) shell script.
|
||||
To run the tests, use the [SwiftTest.sh](https://github.com/google/flatbuffers/blob/master/tests/swift/tests/SwiftTest.sh) shell script.
|
||||
|
||||
*Note: The shell script requires [Swift](https://swift.org) to
|
||||
be installed.*
|
||||
@@ -72,7 +72,10 @@ Now you can access values like this:
|
||||
In some cases it's necessary to modify values in an existing FlatBuffer in place (without creating a copy). For this reason, scalar fields of a Flatbuffer table or struct can be mutated.
|
||||
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.swift}
|
||||
let monster = Monster.getRootAsMonster(bb: ByteBuffer(data: data))
|
||||
var byteBuffer = ByteBuffer(bytes: data)
|
||||
// Get an accessor to the root object inside the buffer.
|
||||
let monster: Monster = try! getCheckedRoot(byteBuffer: &byteBuffer)
|
||||
// let monster: Monster = getRoot(byteBuffer: &byteBuffer)
|
||||
|
||||
if !monster.mutate(hp: 10) {
|
||||
fatalError("couldn't mutate")
|
||||
|
||||
@@ -321,9 +321,8 @@ Please be aware of the difference between `flatc` and `flatcc` tools.
|
||||
<div class="language-javascript">
|
||||
~~~{.sh}
|
||||
cd flatbuffers/samples
|
||||
./../flatc --ts monster.fbs
|
||||
# customize your TS -> JS transpilation
|
||||
tsc monster_generated.ts
|
||||
./../flatc --ts-flat-files --ts monster.fbs
|
||||
# produces ts/js modules and js bundle monster_generated.js
|
||||
~~~
|
||||
</div>
|
||||
<div class="language-typescript">
|
||||
@@ -415,7 +414,7 @@ The first step is to import/include the library, generated files, etc.
|
||||
</div>
|
||||
<div class="language-csharp">
|
||||
~~~{.cs}
|
||||
using FlatBuffers;
|
||||
using Google.FlatBuffers;
|
||||
using MyGame.Sample; // The `flatc` generated files. (Monster, Vec3, etc.)
|
||||
~~~
|
||||
</div>
|
||||
@@ -2200,7 +2199,7 @@ before:
|
||||
</div>
|
||||
<div class="language-csharp">
|
||||
~~~{.cs}
|
||||
using FlatBuffers;
|
||||
using Google.FlatBuffers;
|
||||
using MyGame.Sample; // The `flatc` generated files. (Monster, Vec3, etc.)
|
||||
~~~
|
||||
</div>
|
||||
@@ -2241,7 +2240,7 @@ before:
|
||||
~~~{.ts}
|
||||
// note: import flatbuffers with your desired import method
|
||||
|
||||
// note: the `./monster_generated.ts` file was previously generated by `flatc` above using the `monster.fbs` schema
|
||||
// note: the `./monster_generated.js` file was previously generated by `flatc` above using the `monster.fbs` schema
|
||||
import { MyGame } from './monster_generated';
|
||||
~~~
|
||||
</div>
|
||||
@@ -2472,10 +2471,10 @@ myGame.Monster monster = new myGame.Monster(data);
|
||||
<div class="language-swift">
|
||||
~~~{.swift}
|
||||
// create a ByteBuffer(:) from an [UInt8] or Data()
|
||||
let buf = // Get your data
|
||||
|
||||
var buf = // Get your data
|
||||
// Get an accessor to the root object inside the buffer.
|
||||
let monster = Monster.getRootAsMonster(bb: ByteBuffer(bytes: buf))
|
||||
let monster: Monster = try! getCheckedRoot(byteBuffer: &byteBuffer)
|
||||
// let monster: Monster = getRoot(byteBuffer: &byteBuffer)
|
||||
~~~
|
||||
</div>
|
||||
|
||||
@@ -3449,7 +3448,7 @@ Java supports vectors of unions, but it isn't currently documented.
|
||||
</div>
|
||||
<div class="language-csharp">
|
||||
~~~{.cs}
|
||||
using FlatBuffers;
|
||||
using Google.FlatBuffers;
|
||||
using Example.VectorOfUnions;
|
||||
|
||||
var fbb = new FlatBufferBuilder(100);
|
||||
|
||||
@@ -21,8 +21,8 @@ https://www.npmjs.com/package/flatbuffers.
|
||||
|
||||
## Testing the FlatBuffers TypeScript library
|
||||
|
||||
To run the tests, use the [TypeScriptTest.sh](https://github.com/google/
|
||||
flatbuffers/blob/master/tests/TypeScriptTest.sh) shell script.
|
||||
To run the tests, use the [TypeScriptTest.py](https://github.com/google/
|
||||
flatbuffers/blob/master/tests/TypeScriptTest.py) Python3 script.
|
||||
|
||||
*Note: The TypeScript test file requires [Node.js](https://nodejs.org/en/).*
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ through a *vtable*. Each table comes with a vtable (which may be shared
|
||||
between multiple tables with the same layout), and contains information
|
||||
where fields for this particular kind of instance of vtable are stored.
|
||||
The vtable may also indicate that the field is not present (because this
|
||||
FlatBuffer was written with an older version of the software, of simply
|
||||
FlatBuffer was written with an older version of the software, or simply
|
||||
because the information was not necessary for this instance, or deemed
|
||||
deprecated), in which case a default value is returned.
|
||||
|
||||
|
||||
27
examples/go-echo/README.md
Normal file
27
examples/go-echo/README.md
Normal file
@@ -0,0 +1,27 @@
|
||||
# Go Echo Example
|
||||
|
||||
A simple example demonstrating how to send flatbuffers over the network in Go.
|
||||
|
||||
## Generate flatbuffer code
|
||||
|
||||
```
|
||||
flatc -g --gen-object-api --go-module-name echo hero.fbs net.fbs
|
||||
```
|
||||
|
||||
## Running example
|
||||
|
||||
1. Run go mod tidy to get dependencies
|
||||
```
|
||||
go mod tidy
|
||||
```
|
||||
|
||||
2. Start a server
|
||||
```
|
||||
go run server/server.go
|
||||
```
|
||||
|
||||
3. Run the client in another terminal
|
||||
```
|
||||
go run client/client.go
|
||||
```
|
||||
|
||||
51
examples/go-echo/client/client.go
Normal file
51
examples/go-echo/client/client.go
Normal file
@@ -0,0 +1,51 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
|
||||
"echo/hero"
|
||||
"echo/net"
|
||||
|
||||
flatbuffers "github.com/google/flatbuffers/go"
|
||||
)
|
||||
|
||||
func RequestBody() *bytes.Reader {
|
||||
b := flatbuffers.NewBuilder(0)
|
||||
r := net.RequestT{Player: &hero.WarriorT{Name: "Krull", Hp: 100}}
|
||||
b.Finish(r.Pack(b))
|
||||
return bytes.NewReader(b.FinishedBytes())
|
||||
}
|
||||
|
||||
func ReadResponse(r *http.Response) {
|
||||
body, err := ioutil.ReadAll(r.Body)
|
||||
if err != nil {
|
||||
fmt.Printf("Unable to read request body: %v\n", err)
|
||||
return
|
||||
}
|
||||
|
||||
res := net.GetRootAsResponse(body, 0)
|
||||
player := res.Player(nil)
|
||||
|
||||
fmt.Printf("Got response (name: %v, hp: %v)\n", string(player.Name()), player.Hp())
|
||||
}
|
||||
|
||||
func main() {
|
||||
body := RequestBody()
|
||||
req, err := http.NewRequest("POST", "http://localhost:8080/echo", body)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
|
||||
client := http.DefaultClient
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
|
||||
ReadResponse(resp)
|
||||
}
|
||||
5
examples/go-echo/go.mod
Normal file
5
examples/go-echo/go.mod
Normal file
@@ -0,0 +1,5 @@
|
||||
module echo
|
||||
|
||||
go 1.19
|
||||
|
||||
require github.com/google/flatbuffers v22.10.26+incompatible
|
||||
6
examples/go-echo/hero.fbs
Normal file
6
examples/go-echo/hero.fbs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace hero;
|
||||
|
||||
table Warrior {
|
||||
name: string;
|
||||
hp: uint32;
|
||||
}
|
||||
93
examples/go-echo/hero/Warrior.go
Normal file
93
examples/go-echo/hero/Warrior.go
Normal file
@@ -0,0 +1,93 @@
|
||||
// Code generated by the FlatBuffers compiler. DO NOT EDIT.
|
||||
|
||||
package hero
|
||||
|
||||
import (
|
||||
flatbuffers "github.com/google/flatbuffers/go"
|
||||
)
|
||||
|
||||
type WarriorT struct {
|
||||
Name string `json:"name"`
|
||||
Hp uint32 `json:"hp"`
|
||||
}
|
||||
|
||||
func (t *WarriorT) Pack(builder *flatbuffers.Builder) flatbuffers.UOffsetT {
|
||||
if t == nil { return 0 }
|
||||
nameOffset := builder.CreateString(t.Name)
|
||||
WarriorStart(builder)
|
||||
WarriorAddName(builder, nameOffset)
|
||||
WarriorAddHp(builder, t.Hp)
|
||||
return WarriorEnd(builder)
|
||||
}
|
||||
|
||||
func (rcv *Warrior) UnPackTo(t *WarriorT) {
|
||||
t.Name = string(rcv.Name())
|
||||
t.Hp = rcv.Hp()
|
||||
}
|
||||
|
||||
func (rcv *Warrior) UnPack() *WarriorT {
|
||||
if rcv == nil { return nil }
|
||||
t := &WarriorT{}
|
||||
rcv.UnPackTo(t)
|
||||
return t
|
||||
}
|
||||
|
||||
type Warrior struct {
|
||||
_tab flatbuffers.Table
|
||||
}
|
||||
|
||||
func GetRootAsWarrior(buf []byte, offset flatbuffers.UOffsetT) *Warrior {
|
||||
n := flatbuffers.GetUOffsetT(buf[offset:])
|
||||
x := &Warrior{}
|
||||
x.Init(buf, n+offset)
|
||||
return x
|
||||
}
|
||||
|
||||
func GetSizePrefixedRootAsWarrior(buf []byte, offset flatbuffers.UOffsetT) *Warrior {
|
||||
n := flatbuffers.GetUOffsetT(buf[offset+flatbuffers.SizeUint32:])
|
||||
x := &Warrior{}
|
||||
x.Init(buf, n+offset+flatbuffers.SizeUint32)
|
||||
return x
|
||||
}
|
||||
|
||||
func (rcv *Warrior) Init(buf []byte, i flatbuffers.UOffsetT) {
|
||||
rcv._tab.Bytes = buf
|
||||
rcv._tab.Pos = i
|
||||
}
|
||||
|
||||
func (rcv *Warrior) Table() flatbuffers.Table {
|
||||
return rcv._tab
|
||||
}
|
||||
|
||||
func (rcv *Warrior) Name() []byte {
|
||||
o := flatbuffers.UOffsetT(rcv._tab.Offset(4))
|
||||
if o != 0 {
|
||||
return rcv._tab.ByteVector(o + rcv._tab.Pos)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (rcv *Warrior) Hp() uint32 {
|
||||
o := flatbuffers.UOffsetT(rcv._tab.Offset(6))
|
||||
if o != 0 {
|
||||
return rcv._tab.GetUint32(o + rcv._tab.Pos)
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (rcv *Warrior) MutateHp(n uint32) bool {
|
||||
return rcv._tab.MutateUint32Slot(6, n)
|
||||
}
|
||||
|
||||
func WarriorStart(builder *flatbuffers.Builder) {
|
||||
builder.StartObject(2)
|
||||
}
|
||||
func WarriorAddName(builder *flatbuffers.Builder, name flatbuffers.UOffsetT) {
|
||||
builder.PrependUOffsetTSlot(0, flatbuffers.UOffsetT(name), 0)
|
||||
}
|
||||
func WarriorAddHp(builder *flatbuffers.Builder, hp uint32) {
|
||||
builder.PrependUint32Slot(1, hp, 0)
|
||||
}
|
||||
func WarriorEnd(builder *flatbuffers.Builder) flatbuffers.UOffsetT {
|
||||
return builder.EndObject()
|
||||
}
|
||||
11
examples/go-echo/net.fbs
Normal file
11
examples/go-echo/net.fbs
Normal file
@@ -0,0 +1,11 @@
|
||||
include "hero.fbs";
|
||||
|
||||
namespace net;
|
||||
|
||||
table Request {
|
||||
player: hero.Warrior;
|
||||
}
|
||||
|
||||
table Response {
|
||||
player: hero.Warrior;
|
||||
}
|
||||
82
examples/go-echo/net/Request.go
Normal file
82
examples/go-echo/net/Request.go
Normal file
@@ -0,0 +1,82 @@
|
||||
// Code generated by the FlatBuffers compiler. DO NOT EDIT.
|
||||
|
||||
package net
|
||||
|
||||
import (
|
||||
flatbuffers "github.com/google/flatbuffers/go"
|
||||
|
||||
hero "echo/hero"
|
||||
)
|
||||
|
||||
type RequestT struct {
|
||||
Player *hero.WarriorT `json:"player"`
|
||||
}
|
||||
|
||||
func (t *RequestT) Pack(builder *flatbuffers.Builder) flatbuffers.UOffsetT {
|
||||
if t == nil { return 0 }
|
||||
playerOffset := t.Player.Pack(builder)
|
||||
RequestStart(builder)
|
||||
RequestAddPlayer(builder, playerOffset)
|
||||
return RequestEnd(builder)
|
||||
}
|
||||
|
||||
func (rcv *Request) UnPackTo(t *RequestT) {
|
||||
t.Player = rcv.Player(nil).UnPack()
|
||||
}
|
||||
|
||||
func (rcv *Request) UnPack() *RequestT {
|
||||
if rcv == nil { return nil }
|
||||
t := &RequestT{}
|
||||
rcv.UnPackTo(t)
|
||||
return t
|
||||
}
|
||||
|
||||
type Request struct {
|
||||
_tab flatbuffers.Table
|
||||
}
|
||||
|
||||
func GetRootAsRequest(buf []byte, offset flatbuffers.UOffsetT) *Request {
|
||||
n := flatbuffers.GetUOffsetT(buf[offset:])
|
||||
x := &Request{}
|
||||
x.Init(buf, n+offset)
|
||||
return x
|
||||
}
|
||||
|
||||
func GetSizePrefixedRootAsRequest(buf []byte, offset flatbuffers.UOffsetT) *Request {
|
||||
n := flatbuffers.GetUOffsetT(buf[offset+flatbuffers.SizeUint32:])
|
||||
x := &Request{}
|
||||
x.Init(buf, n+offset+flatbuffers.SizeUint32)
|
||||
return x
|
||||
}
|
||||
|
||||
func (rcv *Request) Init(buf []byte, i flatbuffers.UOffsetT) {
|
||||
rcv._tab.Bytes = buf
|
||||
rcv._tab.Pos = i
|
||||
}
|
||||
|
||||
func (rcv *Request) Table() flatbuffers.Table {
|
||||
return rcv._tab
|
||||
}
|
||||
|
||||
func (rcv *Request) Player(obj *hero.Warrior) *hero.Warrior {
|
||||
o := flatbuffers.UOffsetT(rcv._tab.Offset(4))
|
||||
if o != 0 {
|
||||
x := rcv._tab.Indirect(o + rcv._tab.Pos)
|
||||
if obj == nil {
|
||||
obj = new(hero.Warrior)
|
||||
}
|
||||
obj.Init(rcv._tab.Bytes, x)
|
||||
return obj
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func RequestStart(builder *flatbuffers.Builder) {
|
||||
builder.StartObject(1)
|
||||
}
|
||||
func RequestAddPlayer(builder *flatbuffers.Builder, player flatbuffers.UOffsetT) {
|
||||
builder.PrependUOffsetTSlot(0, flatbuffers.UOffsetT(player), 0)
|
||||
}
|
||||
func RequestEnd(builder *flatbuffers.Builder) flatbuffers.UOffsetT {
|
||||
return builder.EndObject()
|
||||
}
|
||||
82
examples/go-echo/net/Response.go
Normal file
82
examples/go-echo/net/Response.go
Normal file
@@ -0,0 +1,82 @@
|
||||
// Code generated by the FlatBuffers compiler. DO NOT EDIT.
|
||||
|
||||
package net
|
||||
|
||||
import (
|
||||
flatbuffers "github.com/google/flatbuffers/go"
|
||||
|
||||
hero "echo/hero"
|
||||
)
|
||||
|
||||
type ResponseT struct {
|
||||
Player *hero.WarriorT `json:"player"`
|
||||
}
|
||||
|
||||
func (t *ResponseT) Pack(builder *flatbuffers.Builder) flatbuffers.UOffsetT {
|
||||
if t == nil { return 0 }
|
||||
playerOffset := t.Player.Pack(builder)
|
||||
ResponseStart(builder)
|
||||
ResponseAddPlayer(builder, playerOffset)
|
||||
return ResponseEnd(builder)
|
||||
}
|
||||
|
||||
func (rcv *Response) UnPackTo(t *ResponseT) {
|
||||
t.Player = rcv.Player(nil).UnPack()
|
||||
}
|
||||
|
||||
func (rcv *Response) UnPack() *ResponseT {
|
||||
if rcv == nil { return nil }
|
||||
t := &ResponseT{}
|
||||
rcv.UnPackTo(t)
|
||||
return t
|
||||
}
|
||||
|
||||
type Response struct {
|
||||
_tab flatbuffers.Table
|
||||
}
|
||||
|
||||
func GetRootAsResponse(buf []byte, offset flatbuffers.UOffsetT) *Response {
|
||||
n := flatbuffers.GetUOffsetT(buf[offset:])
|
||||
x := &Response{}
|
||||
x.Init(buf, n+offset)
|
||||
return x
|
||||
}
|
||||
|
||||
func GetSizePrefixedRootAsResponse(buf []byte, offset flatbuffers.UOffsetT) *Response {
|
||||
n := flatbuffers.GetUOffsetT(buf[offset+flatbuffers.SizeUint32:])
|
||||
x := &Response{}
|
||||
x.Init(buf, n+offset+flatbuffers.SizeUint32)
|
||||
return x
|
||||
}
|
||||
|
||||
func (rcv *Response) Init(buf []byte, i flatbuffers.UOffsetT) {
|
||||
rcv._tab.Bytes = buf
|
||||
rcv._tab.Pos = i
|
||||
}
|
||||
|
||||
func (rcv *Response) Table() flatbuffers.Table {
|
||||
return rcv._tab
|
||||
}
|
||||
|
||||
func (rcv *Response) Player(obj *hero.Warrior) *hero.Warrior {
|
||||
o := flatbuffers.UOffsetT(rcv._tab.Offset(4))
|
||||
if o != 0 {
|
||||
x := rcv._tab.Indirect(o + rcv._tab.Pos)
|
||||
if obj == nil {
|
||||
obj = new(hero.Warrior)
|
||||
}
|
||||
obj.Init(rcv._tab.Bytes, x)
|
||||
return obj
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func ResponseStart(builder *flatbuffers.Builder) {
|
||||
builder.StartObject(1)
|
||||
}
|
||||
func ResponseAddPlayer(builder *flatbuffers.Builder, player flatbuffers.UOffsetT) {
|
||||
builder.PrependUOffsetTSlot(0, flatbuffers.UOffsetT(player), 0)
|
||||
}
|
||||
func ResponseEnd(builder *flatbuffers.Builder) flatbuffers.UOffsetT {
|
||||
return builder.EndObject()
|
||||
}
|
||||
29
examples/go-echo/server/server.go
Normal file
29
examples/go-echo/server/server.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"echo/net"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func echo(w http.ResponseWriter, r *http.Request) {
|
||||
body, err := ioutil.ReadAll(r.Body)
|
||||
if err != nil {
|
||||
fmt.Printf("Unable to read request body: %v\n", err)
|
||||
return
|
||||
}
|
||||
|
||||
req := net.GetRootAsRequest(body, 0)
|
||||
player := req.Player(nil)
|
||||
|
||||
fmt.Printf("Got request (name: %v, hp: %v)\n", string(player.Name()), player.Hp())
|
||||
w.Write(body)
|
||||
}
|
||||
|
||||
func main() {
|
||||
http.HandleFunc("/echo", echo)
|
||||
|
||||
fmt.Println("Listening on port :8080")
|
||||
http.ListenAndServe(":8080", nil)
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user