ruble 0.0.3.alpha

Sign up to get free protection for your applications and to get access to all the features.
Files changed (92) hide show
  1. checksums.yaml +7 -0
  2. data/.gdbinit +21 -0
  3. data/.gitignore +18 -0
  4. data/.rubocop.yml +96 -0
  5. data/.ruby-version +1 -0
  6. data/CHANGELOG.md +6 -0
  7. data/CMakeLists.txt +4 -0
  8. data/CODE_OF_CONDUCT.md +84 -0
  9. data/Gemfile +21 -0
  10. data/Gemfile.lock +98 -0
  11. data/LICENSE.txt +21 -0
  12. data/README.md +63 -0
  13. data/Rakefile +41 -0
  14. data/ext/ruble/.gitignore +5 -0
  15. data/ext/ruble/CMakeLists.txt +157 -0
  16. data/ext/ruble/RuBLEHelpers.cmake +240 -0
  17. data/ext/ruble/bindings/Adapter.cpp +193 -0
  18. data/ext/ruble/bindings/Adapter.hpp +85 -0
  19. data/ext/ruble/bindings/Characteristic.cpp +171 -0
  20. data/ext/ruble/bindings/Characteristic.hpp +132 -0
  21. data/ext/ruble/bindings/Descriptor.cpp +34 -0
  22. data/ext/ruble/bindings/Descriptor.hpp +69 -0
  23. data/ext/ruble/bindings/Peripheral.cpp +212 -0
  24. data/ext/ruble/bindings/Peripheral.hpp +108 -0
  25. data/ext/ruble/bindings/RuBLE.cpp +115 -0
  26. data/ext/ruble/bindings/Service.cpp +112 -0
  27. data/ext/ruble/bindings/Service.hpp +61 -0
  28. data/ext/ruble/bindings/common.hpp +48 -0
  29. data/ext/ruble/bindings/globals.cpp +43 -0
  30. data/ext/ruble/cmake.mk +62 -0
  31. data/ext/ruble/concerns/CharacteristicValueTracker.cpp +18 -0
  32. data/ext/ruble/concerns/CharacteristicValueTracker.hpp +40 -0
  33. data/ext/ruble/concerns/Rubyable.cpp +4 -0
  34. data/ext/ruble/concerns/Rubyable.hpp +46 -0
  35. data/ext/ruble/config.h.in +25 -0
  36. data/ext/ruble/containers/ByteArray.cpp +64 -0
  37. data/ext/ruble/containers/ByteArray.hpp +161 -0
  38. data/ext/ruble/containers/Callback.hpp +52 -0
  39. data/ext/ruble/containers/NamedBitSet.hpp +140 -0
  40. data/ext/ruble/containers/NamedBitSet.ipp +71 -0
  41. data/ext/ruble/extconf.rb +30 -0
  42. data/ext/ruble/management/Registry.cpp +63 -0
  43. data/ext/ruble/management/Registry.hpp +170 -0
  44. data/ext/ruble/management/RegistryFactory.hpp +113 -0
  45. data/ext/ruble/management/RubyQueue.cpp +152 -0
  46. data/ext/ruble/management/RubyQueue.hpp +69 -0
  47. data/ext/ruble/modularize.diff +28 -0
  48. data/ext/ruble/types/SimpleBLE.hpp +21 -0
  49. data/ext/ruble/types/declarations.hpp +91 -0
  50. data/ext/ruble/types/helpers.hpp +12 -0
  51. data/ext/ruble/types/ruby.hpp +36 -0
  52. data/ext/ruble/types/stl.hpp +41 -0
  53. data/ext/ruble/utils/RubyCallbackTraits.cpp +28 -0
  54. data/ext/ruble/utils/RubyCallbackTraits.hpp +48 -0
  55. data/ext/ruble/utils/async.cpp +10 -0
  56. data/ext/ruble/utils/async.hpp +76 -0
  57. data/ext/ruble/utils/containers.hpp +41 -0
  58. data/ext/ruble/utils/exception_handling.cpp +50 -0
  59. data/ext/ruble/utils/exception_handling.hpp +53 -0
  60. data/ext/ruble/utils/garbage_collection.cpp +82 -0
  61. data/ext/ruble/utils/garbage_collection.hpp +22 -0
  62. data/ext/ruble/utils/hash.cpp +83 -0
  63. data/ext/ruble/utils/hash.hpp +52 -0
  64. data/ext/ruble/utils/hexadecimal.hpp +116 -0
  65. data/ext/ruble/utils/human_type_names.hpp +38 -0
  66. data/ext/ruble/utils/inspection.cpp +24 -0
  67. data/ext/ruble/utils/inspection.hpp +108 -0
  68. data/ext/ruble/utils/ruby.hpp +103 -0
  69. data/ext/ruble/utils/ruby_context.hpp +73 -0
  70. data/lib/ruble/build/.rubocop.yml +19 -0
  71. data/lib/ruble/build/boost.rb +34 -0
  72. data/lib/ruble/build/cmake.rb +134 -0
  73. data/lib/ruble/build/core_ext.rb +5 -0
  74. data/lib/ruble/build/data/bundler.rb +24 -0
  75. data/lib/ruble/build/data/extension.rb +101 -0
  76. data/lib/ruble/build/data/os.rb +21 -0
  77. data/lib/ruble/build/data/rice.rb +24 -0
  78. data/lib/ruble/build/data.rb +22 -0
  79. data/lib/ruble/build/extconf.rb +76 -0
  80. data/lib/ruble/build/github_repo.rb +129 -0
  81. data/lib/ruble/build/simpleble.rb +56 -0
  82. data/lib/ruble/build.rb +28 -0
  83. data/lib/ruble/version.rb +7 -0
  84. data/lib/ruble.rb +46 -0
  85. data/lib/tasks/dev/dev_tasks.rb +130 -0
  86. data/lib/tasks/dev/pager.rb +218 -0
  87. data/lib/tasks/dev/paths.rb +30 -0
  88. data/lib/tasks/dev/state_hash.rb +65 -0
  89. data/lib/tasks/dev.rake +41 -0
  90. data/lib/tasks/simpleble.rake +29 -0
  91. data/sig/rubble.rbs +4 -0
  92. metadata +263 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: cd5703f6d730f4085c5ee2762dfddca91f3e585d4a319bdee4938cb6bb754c9c
4
+ data.tar.gz: 470adfb29c75ac8e913c990e30a931ecdae6f328588d5e1c5dbf5e698446af7d
5
+ SHA512:
6
+ metadata.gz: 23fe549308d6ae3eaed0e729420d97ee30d61ae1c62167437a8cbc47e622789fa3d1527a2373ff550431f2a250e7588b499a79ff7d325b7e792f749415a91acd
7
+ data.tar.gz: dee972e44da78e86e72d43c57420248bb8222cc4dc58854c9584272067c19a1cdb4a4e668e38b5829b84bff00bbbe3c55869873041cd3ced8c91bc8c52137c50
data/.gdbinit ADDED
@@ -0,0 +1,21 @@
1
+ #set environment RUBY_GC_DISABLE 1
2
+ #set environment RUBY_GC_STRESS 1
3
+
4
+ # (Failed) attempt to disable some CPU math extensions so gdb reverse debugging would work
5
+ #set environment LC_ALL C
6
+ #set environment GLIBC_TUNABLES glibc.cpu.hwcaps=-AVX,-AVX2,-AVX512F,-AVX512DQ,-AVX512_IFMA,-AVX512PF,-AVX512ER,-AVX512CD,-AVX512BW,-AVX512VL,-AVX512_VBMI,-AVX512_VBMI2,-AVX512_VNNI,-AVX512_BITALG,-AVX512_VPOPCNTDQ,-AVX512_4VNNIW,-AVX512_4FMAPS,-AVX512_VP2INTERSECT,-AVX512_FP16,-AVX_VNNI,-AVX512_BF16,-BMI1,-BMI2,-LZCNT,-MOVBE,-RTM:glibc.cpu.hwcap_mask=0
7
+ # custom libc without AVX extensions
8
+ #set environment LD_PRELOAD /usr/local/src/glibc-2.37/build/libc.so
9
+
10
+ # To debug issue with code hanging
11
+ set record full insn-number-max 20
12
+ #set disable-randomization on
13
+ #set record full insn-number-max 200000
14
+ source contrib/gdb-cpp-frame-filters.py
15
+ add-symbol-file lib/ruble/ruble.so
16
+ catch throw
17
+ #b c_debug
18
+ #b rb_check_typeddata
19
+
20
+
21
+ #b rb_exc_raise
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /checksums/
8
+ /spec/reports/
9
+ tmp/
10
+ *.o
11
+ *.so
12
+ *.log
13
+ Makefile
14
+ tmp/
15
+ .gdb_history
16
+ *.patch
17
+ mkmf.log
18
+ cmake-build*
data/.rubocop.yml ADDED
@@ -0,0 +1,96 @@
1
+ require: rubocop-rake
2
+
3
+ AllCops:
4
+ AllowSymlinksInCacheRootDirectory: true
5
+ TargetRubyVersion: 3.2
6
+ Exclude:
7
+ - "**/bin/**/*"
8
+ - "**/node_modules/**/*"
9
+ - "**/.git/**/*"
10
+ AutoCorrect: true
11
+ NewCops: enable
12
+ StyleGuideBaseURL: https://rubystyle.guide
13
+ #Rails:
14
+ # StyleGuideBaseURL: https://rails.rubystyle.guide
15
+
16
+ # TODO: enable Gemspec/DevelopmentDependencies and pick an `EnforcedStyle`
17
+ Gemspec/DevelopmentDependencies:
18
+ Enabled: false
19
+
20
+ Layout/AccessModifierIndentation:
21
+ EnforcedStyle: outdent
22
+ Layout/EmptyLinesAroundAccessModifier:
23
+ EnforcedStyle: only_before
24
+ Layout/EmptyLinesAroundAttributeAccessor:
25
+ Enabled: false
26
+ Layout/EndAlignment:
27
+ EnforcedStyleAlignWith: start_of_line
28
+ #Layout/ExtraSpacing:
29
+ # Enabled: false # Disabled pending resoulution of #5657
30
+ Layout/FirstHashElementIndentation:
31
+ EnforcedStyle: consistent
32
+ Layout/HashAlignment:
33
+ EnforcedColonStyle: table
34
+ EnforcedHashRocketStyle: table
35
+ Layout/LineLength:
36
+ Enabled: false
37
+ #Layout/SpaceAroundOperators:
38
+ # Enabled: false # Disabled pending resoulution of #5657
39
+ Layout/SpaceInsideArrayLiteralBrackets:
40
+ EnforcedStyle: space
41
+
42
+ Lint/AmbiguousOperator:
43
+ Enabled: false
44
+
45
+ Metrics/AbcSize:
46
+ Enabled: false
47
+ Metrics/BlockLength:
48
+ IgnoredMethods:
49
+ - aasm
50
+ - included
51
+ - class_methods
52
+ - namespace
53
+ - task
54
+ Metrics/MethodLength:
55
+ Max: 25
56
+ Metrics/ParameterLists:
57
+ Enabled: false
58
+
59
+ Naming/MethodParameterName:
60
+ AllowedNames:
61
+ - as
62
+ - to
63
+ - io
64
+ - id
65
+
66
+ Style/AccessorGrouping:
67
+ Enabled: false
68
+ Style/Alias:
69
+ EnforcedStyle: prefer_alias_method
70
+ Style/ClassAndModuleChildren:
71
+ Enabled: false
72
+ Style/CommentedKeyword:
73
+ Enabled: false
74
+ Style/Documentation:
75
+ Enabled: false
76
+ Style/DoubleNegation:
77
+ Enabled: false
78
+ Style/EmptyMethod:
79
+ EnforcedStyle: expanded
80
+ Style/FrozenStringLiteralComment:
81
+ EnforcedStyle: always_true
82
+ SafeAutoCorrect: true
83
+ Style/HashSyntax:
84
+ EnforcedStyle: no_mixed_keys
85
+ Style/Lambda:
86
+ EnforcedStyle: literal
87
+ Style/MultilineBlockChain:
88
+ Enabled: false
89
+ Style/MultilineIfModifier:
90
+ Enabled: false
91
+ Style/SpecialGlobalVars:
92
+ EnforcedStyle: use_perl_names
93
+ Style/SymbolArray:
94
+ MinSize: 1
95
+ Style/TrailingCommaInHashLiteral:
96
+ EnforcedStyleForMultiline: comma
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 3.2.2
data/CHANGELOG.md ADDED
@@ -0,0 +1,6 @@
1
+ ## [Unreleased]
2
+
3
+ ## 0.0.3-alpha - 2023-11-03
4
+
5
+ - Initial release
6
+ - Theoretically working, but missing important components (incl packaging)
data/CMakeLists.txt ADDED
@@ -0,0 +1,4 @@
1
+ cmake_minimum_required(VERSION 3.25.1)
2
+ project(RuBLE LANGUAGES CXX)
3
+
4
+ add_subdirectory(ext/ruble)
@@ -0,0 +1,84 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment for our community include:
12
+
13
+ * Demonstrating empathy and kindness toward other people
14
+ * Being respectful of differing opinions, viewpoints, and experiences
15
+ * Giving and gracefully accepting constructive feedback
16
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ * Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ * The use of sexualized language or imagery, and sexual attention or
22
+ advances of any kind
23
+ * Trolling, insulting or derogatory comments, and personal or political attacks
24
+ * Public or private harassment
25
+ * Publishing others' private information, such as a physical or email
26
+ address, without their explicit permission
27
+ * Other conduct which could reasonably be considered inappropriate in a
28
+ professional setting
29
+
30
+ ## Enforcement Responsibilities
31
+
32
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
+
34
+ Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
+
36
+ ## Scope
37
+
38
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
+
40
+ ## Enforcement
41
+
42
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at mike@vasto.la. All complaints will be reviewed and investigated promptly and fairly.
43
+
44
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
+
46
+ ## Enforcement Guidelines
47
+
48
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
+
50
+ ### 1. Correction
51
+
52
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
+
54
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
+
56
+ ### 2. Warning
57
+
58
+ **Community Impact**: A violation through a single incident or series of actions.
59
+
60
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
+
62
+ ### 3. Temporary Ban
63
+
64
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
+
66
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
+
68
+ ### 4. Permanent Ban
69
+
70
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
+
72
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
73
+
74
+ ## Attribution
75
+
76
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
+ available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
+
79
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
+
81
+ [homepage]: https://www.contributor-covenant.org
82
+
83
+ For answers to common questions about this code of conduct, see the FAQ at
84
+ https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/Gemfile ADDED
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ ruby '3.2.2'
6
+ gemspec development_group: :build
7
+
8
+ gem 'bundler', '~> 2.4.21'
9
+
10
+ group :build do
11
+ gem 'rainbow', '~> 3.1' # TODO: use this more
12
+ gem 'terrapin', '~> 0.6.0' # TODO: switch to this
13
+ end
14
+
15
+ gem 'rake', '~> 13.0'
16
+
17
+ group :dev do
18
+ gem 'debug'
19
+ gem 'rubocop', require: false
20
+ gem 'rubocop-rake', require: false
21
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,98 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ ruble (0.0.3.alpha)
5
+ zeitwerk (~> 2.6.12)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ ast (2.4.2)
11
+ base64 (0.2.0)
12
+ climate_control (0.2.0)
13
+ concurrent-ruby (1.2.2)
14
+ debug (1.8.0)
15
+ irb (>= 1.5.0)
16
+ reline (>= 0.3.1)
17
+ faraday (2.7.11)
18
+ base64
19
+ faraday-net_http (>= 2.0, < 3.1)
20
+ ruby2_keywords (>= 0.0.4)
21
+ faraday-follow_redirects (0.3.0)
22
+ faraday (>= 1, < 3)
23
+ faraday-net_http (3.0.2)
24
+ faraday-retry (2.2.0)
25
+ faraday (~> 2.0)
26
+ io-console (0.6.0)
27
+ irb (1.9.0)
28
+ rdoc
29
+ reline (>= 0.3.8)
30
+ json (2.6.3)
31
+ language_server-protocol (3.17.0.3)
32
+ memery (1.5.0)
33
+ ruby2_keywords (~> 0.0.2)
34
+ os (1.1.4)
35
+ parallel (1.23.0)
36
+ parser (3.2.2.4)
37
+ ast (~> 2.4.1)
38
+ racc
39
+ psych (5.1.1.1)
40
+ stringio
41
+ racc (1.7.3)
42
+ rainbow (3.1.1)
43
+ rake (13.1.0)
44
+ rdoc (6.6.0)
45
+ psych (>= 4.0.0)
46
+ regexp_parser (2.8.2)
47
+ reline (0.4.0)
48
+ io-console (~> 0.5)
49
+ rexml (3.2.6)
50
+ rice (4.1.0)
51
+ rubocop (1.57.2)
52
+ json (~> 2.3)
53
+ language_server-protocol (>= 3.17.0)
54
+ parallel (~> 1.10)
55
+ parser (>= 3.2.2.4)
56
+ rainbow (>= 2.2.2, < 4.0)
57
+ regexp_parser (>= 1.8, < 3.0)
58
+ rexml (>= 3.2.5, < 4.0)
59
+ rubocop-ast (>= 1.28.1, < 2.0)
60
+ ruby-progressbar (~> 1.7)
61
+ unicode-display_width (>= 2.4.0, < 3.0)
62
+ rubocop-ast (1.30.0)
63
+ parser (>= 3.2.1.0)
64
+ rubocop-rake (0.6.0)
65
+ rubocop (~> 1.0)
66
+ ruby-progressbar (1.13.0)
67
+ ruby2_keywords (0.0.5)
68
+ stringio (3.0.9)
69
+ terrapin (0.6.0)
70
+ climate_control (>= 0.0.3, < 1.0)
71
+ unicode-display_width (2.5.0)
72
+ zeitwerk (2.6.12)
73
+
74
+ PLATFORMS
75
+ x86_64-linux
76
+
77
+ DEPENDENCIES
78
+ bundler (~> 2.4.21)
79
+ concurrent-ruby (~> 1.2.2)
80
+ debug
81
+ faraday (~> 2.7.11)
82
+ faraday-follow_redirects (~> 0.3.0)
83
+ faraday-retry (~> 2.2.0)
84
+ memery (~> 1.5)
85
+ os (~> 1.1)
86
+ rainbow (~> 3.1)
87
+ rake (~> 13.0)
88
+ rice (~> 4.1)
89
+ ruble!
90
+ rubocop
91
+ rubocop-rake
92
+ terrapin (~> 0.6.0)
93
+
94
+ RUBY VERSION
95
+ ruby 3.2.2p53
96
+
97
+ BUNDLED WITH
98
+ 2.4.21
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2023 Mike Vastola
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,63 @@
1
+ # RuBLE (Pre-Alpa)
2
+
3
+ Preliminary attempt to implement an interface to the easy-to-use [SimpleBLE](https://github.com/OpenBluetoothToolbox/SimpleBLE) (Bluetooth Low Energy) library in Ruby using the very nifty [rice](https://github.com/jasonroelofs/rice) gem.
4
+
5
+ I'm reasonably far along now (actually, theoretically, this is fully-functional) and I'm only aware of one bug (which I'm pretty sure is in SimpleBLE). It's definitely not tested though, and I'm not happy yet with the code quality, nor confident in the feature set. I should publish it soon though to get feedback.
6
+
7
+ ## TODOs
8
+
9
+ - See [Known Issues](#known-issues) just below
10
+ - Make tests (/ figure out how to mock bluetooth devices!)
11
+ - Create gem on rubygems, and automate building/packaging for different OSes
12
+ - Implement `rake-compiler`-compatible rake tasks for compiling gem
13
+ - Forward all relevant configuration options to cmake somehow
14
+ - See lots of tiny todos in the comments throughout my code (`grep -rIn TODO` should flag them all)
15
+ - Documentation
16
+ - RBS file
17
+
18
+ ## Known Issues
19
+ - For some reason, if ruby crashes (e.g. segfaults) while a device is connected, the device seems to be invisible to ruby once restarting, until one disconnects the bluetooth adapter from the device through other means
20
+ - This won't package correctly if you try to turn it into a gem. Namely, you'll have to build the extension manually by doing the following (starting in the base directory):
21
+
22
+ ```bash
23
+ $ bundle install
24
+ $ cd ext/ruble
25
+ $ bundle exec ruby extconf.rb
26
+ $ mkdir build
27
+ $ cd build
28
+ $ cmake ..
29
+ $ make
30
+ $ make install
31
+ ```
32
+
33
+ ## Installation
34
+
35
+ Install the gem and add to the application's Gemfile by executing:
36
+
37
+ $ bundle add RuBLE
38
+
39
+ If bundler is not being used to manage dependencies, install the gem by executing:
40
+
41
+ $ gem install RuBLE
42
+
43
+ ## Usage
44
+
45
+ TODO: Write usage instructions here
46
+
47
+ ## Development
48
+
49
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
50
+
51
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
52
+
53
+ ## Contributing
54
+
55
+ Bug reports and pull requests are welcome on GitHub at https://github.com/mvastola/RuBLE. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/mvastola/RuBLE/blob/master/CODE_OF_CONDUCT.md).
56
+
57
+ ## License
58
+
59
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
60
+
61
+ ## Code of Conduct
62
+
63
+ Everyone interacting in the RuBLE project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/mvastola/RuBLE/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ # TODO: see if I can bypass needing to prefix rake commands with `bundle exec` via this:
4
+
5
+ # ENV["BUNDLE_GEMFILE"] ||= File.expand_path("./Gemfile", __dir__)
6
+ require "bundler/setup" # Set up gems listed in the Gemfile.
7
+ Bundler.require(*%i[dev build])
8
+
9
+ require "bundler/gem_tasks"
10
+ require "rubygems/package_task"
11
+
12
+ # noinspection RubyMismatchedArgumentType
13
+ ROOT_DIR = Pathname.new(__dir__)
14
+ ROOT_DIR.glob('lib/tasks/*.rake').each { |r| import r }
15
+
16
+ GEMSPECS = ROOT_DIR.glob('*.gemspec')
17
+
18
+ GEMSPECS.each do |gemspec|
19
+ spec = Bundler.load_gemspec(gemspec.to_s)
20
+ Gem::PackageTask.new(spec).define
21
+ end
22
+
23
+ begin
24
+ require "rubocop/rake_task"
25
+ RuboCop::RakeTask.new do |task|
26
+ task.requires << 'rubocop-rake'
27
+ end
28
+ task default: :rubocop
29
+ rescue LoadError
30
+ STDERR.puts "Rubocop not installed. Skipping associated tasks."
31
+ end
32
+
33
+ #require 'rake/extensiontask'
34
+ # TODO: figure out how to build/install the gem with precompiled binaries
35
+ # ...or at least debug why systemwide installation can be finnicky
36
+ #Rake::ExtensionTask.new(EXTENSION_NAME) do |ext|
37
+ # ext.lib_dir = "lib/#{EXTENSION_NAME}"
38
+ #end
39
+
40
+
41
+
@@ -0,0 +1,5 @@
1
+ .state_hash
2
+ /extconf.h
3
+ /build
4
+ /build-config.cmake
5
+ /config.h
@@ -0,0 +1,157 @@
1
+ cmake_minimum_required(VERSION 3.25.1) # TODO: see if this can/should be lowered
2
+ project(RuBLE LANGUAGES CXX)
3
+
4
+ set(CMAKE_CXX_STANDARD 23) # TODO: see if this will compile with C++20 (I think it will)
5
+ set(CMAKE_CXX_STANDARD_REQUIRED ON)
6
+ set(CMAKE_SHARED_LIBRARY_PREFIX "") # So target file isn't libruble.so
7
+ set(CMAKE_POSITION_INDEPENDENT_CODE ON)
8
+ set(CMAKE_TLS_VERIFY ON)
9
+
10
+ # relies on extconf.rb having been run
11
+ cmake_path(SET INSTALL_DIR NORMALIZE "${CMAKE_SOURCE_DIR}/../../lib/ruble")
12
+
13
+ include(${CMAKE_CURRENT_SOURCE_DIR}/build-config.cmake)
14
+ set(RUBY_ARCH ${rb_target_cpu}-${rb_target_os})
15
+ set(RICE_INCLUDE_PATH ${rice_include_dir})
16
+ set(RICE_VERSION ${rice_version})
17
+ set(EXTENSION_NAME ${extconf_name})
18
+ set(EXTENSION_VERSION ${extconf_version})
19
+ set(DEBUG_MODE ${extconf_debug_build})
20
+ #set(SIMPLEBLE_EXTRACT_DIR ${rb_simpleble_install_location})
21
+
22
+ cmake_host_system_information(RESULT NPROC QUERY NUMBER_OF_PHYSICAL_CORES)
23
+
24
+ include(RuBLEHelpers.cmake)
25
+
26
+ # I was having trouble with this not finding my personal rvm. we could use build-config.json here
27
+ find_path(VALGRIND_HEADER_DIR valgrind/valgrind.h)
28
+ set(HAVE_VALGRIND ${VALGRIND_HEADER_DIR})
29
+
30
+
31
+ include_directories(.)
32
+ # For config.h
33
+ include_directories("${CMAKE_CURRENT_BINARY_DIR}")
34
+
35
+ add_library(ruble SHARED)
36
+
37
+ target_compile_options(ruble PUBLIC
38
+ -ggdb3 # TODO: strip debug info into separate file (don't necessarily need to package it with distributable version)
39
+ -fthreadsafe-statics
40
+ )
41
+
42
+ target_link_options(ruble PUBLIC
43
+ LINKER:-z,defs
44
+ LINKER:-fPIC
45
+ LINKER:--dynamic-list-cpp-typeinfo
46
+ LINKER:--export-dynamic
47
+ LINKER:--demangle
48
+ )
49
+
50
+ # TODO: should this be debug only? (need to figure out what normal install paths are and where they come from)
51
+ cmake_path(SET CMAKE_INSTALL_PREFIX NORMALIZE "${CMAKE_SOURCE_DIR}/../../lib/ruble")
52
+
53
+ if(CMAKE_BUILD_TYPE STREQUAL "Debug" OR DEBUG_MODE)
54
+ set(RUBLE_DEBUG true)
55
+ # set(CMAKE_VERBOSE_MAKEFILE ON)
56
+ target_compile_options(ruble PUBLIC
57
+ -ggdb3
58
+ -O0
59
+ -fdiagnostics-color=always
60
+ -fno-eliminate-unused-debug-symbols
61
+ -fno-eliminate-unused-debug-types
62
+ -femit-class-debug-always
63
+ -fno-indirect-inlining
64
+ -fno-partial-inlining
65
+ -fno-omit-frame-pointer
66
+ -ggnu-pubnames
67
+ -ginline-points
68
+ -gstatement-frontiers
69
+ -gvariable-location-views
70
+ -fdiagnostics-color=always
71
+ -fconcepts-diagnostics-depth=1
72
+ )
73
+ target_link_options(ruble PUBLIC
74
+ LINKER:--no-strip-discarded
75
+ LINKER:--discard-none
76
+ LINKER:--ld-generated-unwind-info
77
+ LINKER:--gc-keep-exported
78
+ LINKER:--no-gc-sections
79
+ LINKER:--no-copy-dt-needed-entries
80
+ LINKER:--unresolved-symbols=report-all
81
+ LINKER:--enable-new-dtags
82
+ LINKER:-O0
83
+ LINKER:--ctf-variables
84
+ )
85
+ endif()
86
+
87
+ setup_ruby(ruble)
88
+ setup_boost(ruble)
89
+ setup_simpleble(ruble)
90
+ configure_file(config.h.in config.h)
91
+
92
+ target_precompile_headers(ruble PRIVATE
93
+ ${CMAKE_BINARY_DIR}/config.h
94
+ ./management/RegistryFactory.hpp
95
+ ./management/Registry.hpp
96
+ ./management/RubyQueue.hpp
97
+ ./bindings/Characteristic.hpp
98
+ ./bindings/common.hpp
99
+ ./bindings/Service.hpp
100
+ ./bindings/Adapter.hpp
101
+ ./bindings/Descriptor.hpp
102
+ ./bindings/Peripheral.hpp
103
+ ./utils/containers.hpp
104
+ ./utils/hexadecimal.hpp
105
+ ./utils/RubyCallbackTraits.hpp
106
+ ./utils/ruby_context.hpp
107
+ ./utils/ruby.hpp
108
+ ./utils/human_type_names.hpp
109
+ ./utils/inspection.hpp
110
+ ./utils/hash.hpp
111
+ ./utils/garbage_collection.hpp
112
+ ./utils/async.hpp
113
+ ./utils/exception_handling.hpp
114
+ ./containers/ByteArray.hpp
115
+ ./containers/NamedBitSet.hpp
116
+ ./containers/NamedBitSet.ipp
117
+ ./containers/Callback.hpp
118
+ ./types/SimpleBLE.hpp
119
+ ./types/ruby.hpp
120
+ ./types/helpers.hpp
121
+ ./types/stl.hpp
122
+ ./types/declarations.hpp
123
+ ./concerns/CharacteristicValueTracker.hpp
124
+ ./concerns/Rubyable.hpp
125
+ )
126
+ target_sources(ruble PRIVATE
127
+ ./management/RubyQueue.cpp
128
+ ./management/Registry.cpp
129
+ ./bindings/Service.cpp
130
+ ./bindings/globals.cpp
131
+ ./bindings/Descriptor.cpp
132
+ ./bindings/Adapter.cpp
133
+ ./bindings/Peripheral.cpp
134
+ ./bindings/Characteristic.cpp
135
+ ./utils/hash.cpp
136
+ ./utils/exception_handling.cpp
137
+ ./utils/inspection.cpp
138
+ ./utils/RubyCallbackTraits.cpp
139
+ ./utils/garbage_collection.cpp
140
+ ./utils/async.cpp
141
+ ./containers/ByteArray.cpp
142
+ ./concerns/CharacteristicValueTracker.cpp
143
+ ./concerns/Rubyable.cpp
144
+ )
145
+
146
+ # TODO: does PUBLIC vs PRIVATE in target_sources actually do anything here?
147
+ target_sources(ruble PUBLIC
148
+ ./bindings/RuBLE.cpp # The only source file that defines exported functions
149
+ )
150
+
151
+ # TODO: `install(EXPORT...` to generate .cmake files for import
152
+ install(TARGETS ruble DESTINATION "${INSTALL_DIR}" CONFIGURATIONS Debug RENAME ruble.so)
153
+
154
+ #print_target_properties(ruble)
155
+ #print_target_properties(Boost::exception)
156
+ #print_target_properties(simpleble::simpleble)
157
+ #dump_variables()