mtproto 0.0.6 → 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/.env.example +4 -0
  3. data/lib/mtproto/async/middleware/base.rb +17 -0
  4. data/lib/mtproto/async/middleware/flood_wait.rb +42 -0
  5. data/lib/mtproto/async/request.rb +18 -0
  6. data/lib/mtproto/async/request_queue.rb +63 -0
  7. data/lib/mtproto/async_client.rb +201 -0
  8. data/lib/mtproto/auth_key_generator.rb +22 -12
  9. data/lib/mtproto/client/rpc.rb +165 -0
  10. data/lib/mtproto/client.rb +65 -176
  11. data/lib/mtproto/crypto/aes_ige.rb +1 -1
  12. data/lib/mtproto/crypto/factorization.rb +1 -1
  13. data/lib/mtproto/message_id.rb +13 -0
  14. data/lib/mtproto/rpc/get_config.rb +34 -0
  15. data/lib/mtproto/rpc/get_contacts.rb +29 -0
  16. data/lib/mtproto/rpc/get_updates_difference.rb +51 -0
  17. data/lib/mtproto/rpc/get_updates_state.rb +29 -0
  18. data/lib/mtproto/rpc/get_users.rb +29 -0
  19. data/lib/mtproto/rpc/ping.rb +33 -0
  20. data/lib/mtproto/rpc/send_code.rb +41 -0
  21. data/lib/mtproto/rpc/send_message.rb +47 -0
  22. data/lib/mtproto/rpc/sign_in.rb +48 -0
  23. data/lib/mtproto/type/auth_key/dh_gen_response.rb +37 -0
  24. data/lib/mtproto/type/auth_key/req_dh_params.rb +31 -0
  25. data/lib/mtproto/type/auth_key/req_pq_multi.rb +18 -0
  26. data/lib/mtproto/type/auth_key/res_pq.rb +62 -0
  27. data/lib/mtproto/type/auth_key/server_dh_params.rb +43 -0
  28. data/lib/mtproto/type/auth_key/set_client_dh_params.rb +25 -0
  29. data/lib/mtproto/{tl → type}/bad_msg_notification.rb +1 -1
  30. data/lib/mtproto/{tl → type}/client_dh_inner_data.rb +1 -1
  31. data/lib/mtproto/{tl → type}/code_settings.rb +1 -1
  32. data/lib/mtproto/{tl → type}/config.rb +1 -1
  33. data/lib/mtproto/{tl → type}/gzip_packed.rb +1 -1
  34. data/lib/mtproto/type/message.rb +38 -0
  35. data/lib/mtproto/{tl → type}/msg_container.rb +1 -1
  36. data/lib/mtproto/{tl → type}/new_session_created.rb +1 -1
  37. data/lib/mtproto/{tl/p_q_inner_data.rb → type/pq_inner_data.rb} +1 -1
  38. data/lib/mtproto/type/rpc/auth/authorization.rb +107 -0
  39. data/lib/mtproto/type/rpc/auth/send_code.rb +28 -0
  40. data/lib/mtproto/type/rpc/auth/sent_code.rb +36 -0
  41. data/lib/mtproto/type/rpc/auth/sign_in.rb +32 -0
  42. data/lib/mtproto/type/rpc/contacts/contacts.rb +155 -0
  43. data/lib/mtproto/type/rpc/contacts/get_contacts.rb +18 -0
  44. data/lib/mtproto/type/rpc/help/config.rb +35 -0
  45. data/lib/mtproto/type/rpc/help/get_config.rb +17 -0
  46. data/lib/mtproto/type/rpc/init_connection.rb +28 -0
  47. data/lib/mtproto/type/rpc/invoke_with_layer.rb +19 -0
  48. data/lib/mtproto/type/rpc/messages/send_message.rb +43 -0
  49. data/lib/mtproto/type/rpc/messages/updates.rb +87 -0
  50. data/lib/mtproto/type/rpc/ping.rb +18 -0
  51. data/lib/mtproto/type/rpc/pong.rb +46 -0
  52. data/lib/mtproto/type/rpc/updates/difference.rb +332 -0
  53. data/lib/mtproto/type/rpc/updates/get_difference.rb +42 -0
  54. data/lib/mtproto/type/rpc/updates/get_state.rb +17 -0
  55. data/lib/mtproto/type/rpc/updates/state.rb +59 -0
  56. data/lib/mtproto/type/rpc/users/get_users.rb +25 -0
  57. data/lib/mtproto/type/rpc/users/users.rb +99 -0
  58. data/lib/mtproto/{tl → type}/rpc_error.rb +1 -1
  59. data/lib/mtproto/{tl → type}/sent_code.rb +1 -1
  60. data/lib/mtproto/{tl → type}/serializer.rb +1 -1
  61. data/lib/mtproto/{tl → type}/server_dh_inner_data.rb +1 -1
  62. data/lib/mtproto/updates_poller.rb +111 -0
  63. data/lib/mtproto/version.rb +1 -1
  64. data/lib/mtproto.rb +28 -14
  65. metadata +86 -18
  66. data/ext/aes_ige/Makefile +0 -273
  67. data/ext/factorization/Makefile +0 -273
  68. data/lib/mtproto/connection.rb +0 -103
  69. data/lib/mtproto/tl/message.rb +0 -252
@@ -0,0 +1,111 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'rpc/get_updates_state'
4
+ require_relative 'rpc/get_updates_difference'
5
+
6
+ module MTProto
7
+ class UpdatesPoller
8
+ attr_reader :state, :running
9
+
10
+ def initialize(client, poll_interval: 1.0)
11
+ @client = client
12
+ @poll_interval = poll_interval
13
+ @state = nil
14
+ @running = false
15
+ @on_message_callbacks = []
16
+ @on_update_callbacks = []
17
+ @users_cache = {} # Cache user_id => access_hash
18
+ end
19
+
20
+ def on_message(&block)
21
+ @on_message_callbacks << block
22
+ end
23
+
24
+ def on_update(&block)
25
+ @on_update_callbacks << block
26
+ end
27
+
28
+ def start
29
+ raise 'Already running' if @running
30
+ raise 'Auth key not generated' unless @client.auth_key
31
+
32
+ @running = true
33
+
34
+ @state = RPC::GetUpdatesState.new(@client).call_sync
35
+
36
+ poll_loop
37
+ end
38
+
39
+ def stop
40
+ @running = false
41
+ end
42
+
43
+ private
44
+
45
+ def poll_loop
46
+ while @running
47
+ begin
48
+ difference = RPC::GetUpdatesDifference.new(@client).call_sync(
49
+ pts: @state[:pts],
50
+ date: @state[:date],
51
+ qts: @state[:qts]
52
+ )
53
+
54
+ process_difference(difference)
55
+
56
+ if difference[:state]
57
+ @state = @state.merge(difference[:state])
58
+ elsif difference[:type] == :too_long
59
+ @state = RPC::GetUpdatesState.new(@client).call_sync
60
+ elsif difference[:date]
61
+ @state[:date] = difference[:date]
62
+ end
63
+
64
+ sleep @poll_interval
65
+ rescue MTProto::RpcError => e
66
+ puts "RPC Error during polling: #{e.message}"
67
+ sleep @poll_interval
68
+ rescue StandardError => e
69
+ puts "Error during polling: #{e.class} - #{e.message}"
70
+ puts e.backtrace.first(5)
71
+ sleep @poll_interval
72
+ end
73
+ end
74
+ end
75
+
76
+ def process_difference(difference)
77
+ case difference[:type]
78
+ when :empty
79
+ nil
80
+ when :difference, :slice, :short_message
81
+ if difference[:users]
82
+ difference[:users].each do |user|
83
+ if user[:access_hash]
84
+ @users_cache[user[:id]] = user[:access_hash]
85
+ end
86
+ end
87
+ end
88
+
89
+ if difference[:new_messages] && !difference[:new_messages].empty?
90
+ difference[:new_messages].each do |message|
91
+ process_message(message)
92
+ end
93
+ end
94
+
95
+ @on_update_callbacks.each { |callback| callback.call(difference) }
96
+ when :too_long
97
+ puts "Update gap too long (pts=#{difference[:pts]}), refreshing state..."
98
+ end
99
+ end
100
+
101
+ def process_message(message)
102
+ return unless message
103
+
104
+ if message[:user_id] && @users_cache[message[:user_id]]
105
+ message[:access_hash] = @users_cache[message[:user_id]]
106
+ end
107
+
108
+ @on_message_callbacks.each { |callback| callback.call(message) }
109
+ end
110
+ end
111
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MTProto
4
- VERSION = '0.0.6'
4
+ VERSION = '0.0.8'
5
5
  end
data/lib/mtproto.rb CHANGED
@@ -4,19 +4,19 @@ require_relative 'mtproto/version'
4
4
  require_relative 'mtproto/errors'
5
5
  require_relative 'mtproto/transport/abridged_packet_codec'
6
6
  require_relative 'mtproto/transport/tcp_connection'
7
- require_relative 'mtproto/tl/message'
8
- require_relative 'mtproto/tl/serializer'
9
- require_relative 'mtproto/tl/p_q_inner_data'
10
- require_relative 'mtproto/tl/server_dh_inner_data'
11
- require_relative 'mtproto/tl/client_dh_inner_data'
12
- require_relative 'mtproto/tl/bad_msg_notification'
13
- require_relative 'mtproto/tl/msg_container'
14
- require_relative 'mtproto/tl/new_session_created'
15
- require_relative 'mtproto/tl/rpc_error'
16
- require_relative 'mtproto/tl/gzip_packed'
17
- require_relative 'mtproto/tl/config'
18
- require_relative 'mtproto/tl/code_settings'
19
- require_relative 'mtproto/tl/sent_code'
7
+ require_relative 'mtproto/type/message'
8
+ require_relative 'mtproto/type/serializer'
9
+ require_relative 'mtproto/type/pq_inner_data'
10
+ require_relative 'mtproto/type/server_dh_inner_data'
11
+ require_relative 'mtproto/type/client_dh_inner_data'
12
+ require_relative 'mtproto/type/bad_msg_notification'
13
+ require_relative 'mtproto/type/msg_container'
14
+ require_relative 'mtproto/type/new_session_created'
15
+ require_relative 'mtproto/type/rpc_error'
16
+ require_relative 'mtproto/type/gzip_packed'
17
+ require_relative 'mtproto/type/config'
18
+ require_relative 'mtproto/type/code_settings'
19
+ require_relative 'mtproto/type/sent_code'
20
20
  require_relative 'mtproto/crypto/rsa_key'
21
21
  require_relative 'mtproto/crypto/factorization'
22
22
  require_relative 'mtproto/crypto/aes_ige'
@@ -29,7 +29,21 @@ require_relative 'mtproto/auth_key_generator'
29
29
  require_relative 'mtproto/session'
30
30
  require_relative 'mtproto/encrypted_message'
31
31
  require_relative 'mtproto/client'
32
- require_relative 'mtproto/connection'
32
+ require_relative 'mtproto/rpc/ping'
33
+ require_relative 'mtproto/rpc/get_config'
34
+ require_relative 'mtproto/rpc/send_code'
35
+ require_relative 'mtproto/rpc/sign_in'
36
+ require_relative 'mtproto/rpc/get_users'
37
+ require_relative 'mtproto/rpc/send_message'
38
+ require_relative 'mtproto/rpc/get_updates_state'
39
+ require_relative 'mtproto/rpc/get_updates_difference'
40
+ require_relative 'mtproto/rpc/get_contacts'
41
+ require_relative 'mtproto/updates_poller'
42
+ require_relative 'mtproto/async/request'
43
+ require_relative 'mtproto/async/request_queue'
44
+ require_relative 'mtproto/async/middleware/base'
45
+ require_relative 'mtproto/async/middleware/flood_wait'
46
+ require_relative 'mtproto/async_client'
33
47
 
34
48
  module MTProto
35
49
  end
metadata CHANGED
@@ -1,14 +1,42 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mtproto
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Artem Levenkov
8
8
  bindir: bin
9
9
  cert_chain: []
10
10
  date: 1980-01-02 00:00:00.000000000 Z
11
- dependencies: []
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: base64
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - "~>"
17
+ - !ruby/object:Gem::Version
18
+ version: '0.2'
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - "~>"
24
+ - !ruby/object:Gem::Version
25
+ version: '0.2'
26
+ - !ruby/object:Gem::Dependency
27
+ name: concurrent-ruby
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - "~>"
31
+ - !ruby/object:Gem::Version
32
+ version: '1.3'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '1.3'
12
40
  description: A Ruby library for Telegram MTProto protocol with TCP abridged transport
13
41
  support
14
42
  email:
@@ -20,16 +48,19 @@ files:
20
48
  - ".env.example"
21
49
  - ".ruby-version"
22
50
  - Rakefile
23
- - ext/aes_ige/Makefile
24
51
  - ext/aes_ige/aes_ige.c
25
52
  - ext/aes_ige/extconf.rb
26
- - ext/factorization/Makefile
27
53
  - ext/factorization/extconf.rb
28
54
  - ext/factorization/factorization.c
29
55
  - lib/mtproto.rb
56
+ - lib/mtproto/async/middleware/base.rb
57
+ - lib/mtproto/async/middleware/flood_wait.rb
58
+ - lib/mtproto/async/request.rb
59
+ - lib/mtproto/async/request_queue.rb
60
+ - lib/mtproto/async_client.rb
30
61
  - lib/mtproto/auth_key_generator.rb
31
62
  - lib/mtproto/client.rb
32
- - lib/mtproto/connection.rb
63
+ - lib/mtproto/client/rpc.rb
33
64
  - lib/mtproto/crypto/aes_ige.rb
34
65
  - lib/mtproto/crypto/auth_key_helper.rb
35
66
  - lib/mtproto/crypto/dh_key_exchange.rb
@@ -40,22 +71,59 @@ files:
40
71
  - lib/mtproto/crypto/rsa_pad.rb
41
72
  - lib/mtproto/encrypted_message.rb
42
73
  - lib/mtproto/errors.rb
74
+ - lib/mtproto/message_id.rb
75
+ - lib/mtproto/rpc/get_config.rb
76
+ - lib/mtproto/rpc/get_contacts.rb
77
+ - lib/mtproto/rpc/get_updates_difference.rb
78
+ - lib/mtproto/rpc/get_updates_state.rb
79
+ - lib/mtproto/rpc/get_users.rb
80
+ - lib/mtproto/rpc/ping.rb
81
+ - lib/mtproto/rpc/send_code.rb
82
+ - lib/mtproto/rpc/send_message.rb
83
+ - lib/mtproto/rpc/sign_in.rb
43
84
  - lib/mtproto/session.rb
44
- - lib/mtproto/tl/bad_msg_notification.rb
45
- - lib/mtproto/tl/client_dh_inner_data.rb
46
- - lib/mtproto/tl/code_settings.rb
47
- - lib/mtproto/tl/config.rb
48
- - lib/mtproto/tl/gzip_packed.rb
49
- - lib/mtproto/tl/message.rb
50
- - lib/mtproto/tl/msg_container.rb
51
- - lib/mtproto/tl/new_session_created.rb
52
- - lib/mtproto/tl/p_q_inner_data.rb
53
- - lib/mtproto/tl/rpc_error.rb
54
- - lib/mtproto/tl/sent_code.rb
55
- - lib/mtproto/tl/serializer.rb
56
- - lib/mtproto/tl/server_dh_inner_data.rb
57
85
  - lib/mtproto/transport/abridged_packet_codec.rb
58
86
  - lib/mtproto/transport/tcp_connection.rb
87
+ - lib/mtproto/type/auth_key/dh_gen_response.rb
88
+ - lib/mtproto/type/auth_key/req_dh_params.rb
89
+ - lib/mtproto/type/auth_key/req_pq_multi.rb
90
+ - lib/mtproto/type/auth_key/res_pq.rb
91
+ - lib/mtproto/type/auth_key/server_dh_params.rb
92
+ - lib/mtproto/type/auth_key/set_client_dh_params.rb
93
+ - lib/mtproto/type/bad_msg_notification.rb
94
+ - lib/mtproto/type/client_dh_inner_data.rb
95
+ - lib/mtproto/type/code_settings.rb
96
+ - lib/mtproto/type/config.rb
97
+ - lib/mtproto/type/gzip_packed.rb
98
+ - lib/mtproto/type/message.rb
99
+ - lib/mtproto/type/msg_container.rb
100
+ - lib/mtproto/type/new_session_created.rb
101
+ - lib/mtproto/type/pq_inner_data.rb
102
+ - lib/mtproto/type/rpc/auth/authorization.rb
103
+ - lib/mtproto/type/rpc/auth/send_code.rb
104
+ - lib/mtproto/type/rpc/auth/sent_code.rb
105
+ - lib/mtproto/type/rpc/auth/sign_in.rb
106
+ - lib/mtproto/type/rpc/contacts/contacts.rb
107
+ - lib/mtproto/type/rpc/contacts/get_contacts.rb
108
+ - lib/mtproto/type/rpc/help/config.rb
109
+ - lib/mtproto/type/rpc/help/get_config.rb
110
+ - lib/mtproto/type/rpc/init_connection.rb
111
+ - lib/mtproto/type/rpc/invoke_with_layer.rb
112
+ - lib/mtproto/type/rpc/messages/send_message.rb
113
+ - lib/mtproto/type/rpc/messages/updates.rb
114
+ - lib/mtproto/type/rpc/ping.rb
115
+ - lib/mtproto/type/rpc/pong.rb
116
+ - lib/mtproto/type/rpc/updates/difference.rb
117
+ - lib/mtproto/type/rpc/updates/get_difference.rb
118
+ - lib/mtproto/type/rpc/updates/get_state.rb
119
+ - lib/mtproto/type/rpc/updates/state.rb
120
+ - lib/mtproto/type/rpc/users/get_users.rb
121
+ - lib/mtproto/type/rpc/users/users.rb
122
+ - lib/mtproto/type/rpc_error.rb
123
+ - lib/mtproto/type/sent_code.rb
124
+ - lib/mtproto/type/serializer.rb
125
+ - lib/mtproto/type/server_dh_inner_data.rb
126
+ - lib/mtproto/updates_poller.rb
59
127
  - lib/mtproto/version.rb
60
128
  - tmp/.keep
61
129
  homepage: https://github.com/alev-pro/mtproto-ruby
data/ext/aes_ige/Makefile DELETED
@@ -1,273 +0,0 @@
1
-
2
- SHELL = /bin/sh
3
-
4
- # V=0 quiet, V=1 verbose. other values don't work.
5
- V = 0
6
- V0 = $(V:0=)
7
- Q1 = $(V:1=)
8
- Q = $(Q1:0=@)
9
- ECHO1 = $(V:1=@ :)
10
- ECHO = $(ECHO1:0=@ echo)
11
- NULLCMD = :
12
-
13
- #### Start of system configuration section. ####
14
-
15
- srcdir = .
16
- topdir = /Users/alev/.rvm/rubies/ruby-3.4.4/include/ruby-3.4.0
17
- hdrdir = $(topdir)
18
- arch_hdrdir = /Users/alev/.rvm/rubies/ruby-3.4.4/include/ruby-3.4.0/arm64-darwin24
19
- PATH_SEPARATOR = :
20
- VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
21
- prefix = $(DESTDIR)/Users/alev/.rvm/rubies/ruby-3.4.4
22
- rubysitearchprefix = $(rubylibprefix)/$(sitearch)
23
- rubyarchprefix = $(rubylibprefix)/$(arch)
24
- rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
25
- exec_prefix = $(prefix)
26
- vendorarchhdrdir = $(vendorhdrdir)/$(sitearch)
27
- sitearchhdrdir = $(sitehdrdir)/$(sitearch)
28
- rubyarchhdrdir = $(rubyhdrdir)/$(arch)
29
- vendorhdrdir = $(rubyhdrdir)/vendor_ruby
30
- sitehdrdir = $(rubyhdrdir)/site_ruby
31
- rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME)
32
- vendorarchdir = $(vendorlibdir)/$(sitearch)
33
- vendorlibdir = $(vendordir)/$(ruby_version)
34
- vendordir = $(rubylibprefix)/vendor_ruby
35
- sitearchdir = $(sitelibdir)/$(sitearch)
36
- sitelibdir = $(sitedir)/$(ruby_version)
37
- sitedir = $(rubylibprefix)/site_ruby
38
- rubyarchdir = $(rubylibdir)/$(arch)
39
- rubylibdir = $(rubylibprefix)/$(ruby_version)
40
- sitearchincludedir = $(includedir)/$(sitearch)
41
- archincludedir = $(includedir)/$(arch)
42
- sitearchlibdir = $(libdir)/$(sitearch)
43
- archlibdir = $(libdir)/$(arch)
44
- ridir = $(datarootdir)/$(RI_BASE_NAME)
45
- modular_gc_dir = $(DESTDIR)
46
- mandir = $(datarootdir)/man
47
- localedir = $(datarootdir)/locale
48
- libdir = $(exec_prefix)/lib
49
- psdir = $(docdir)
50
- pdfdir = $(docdir)
51
- dvidir = $(docdir)
52
- htmldir = $(docdir)
53
- infodir = $(datarootdir)/info
54
- docdir = $(datarootdir)/doc/$(PACKAGE)
55
- oldincludedir = $(DESTDIR)/usr/include
56
- includedir = $(SDKROOT)$(prefix)/include
57
- runstatedir = $(localstatedir)/run
58
- localstatedir = $(prefix)/var
59
- sharedstatedir = $(prefix)/com
60
- sysconfdir = $(prefix)/etc
61
- datadir = $(datarootdir)
62
- datarootdir = $(prefix)/share
63
- libexecdir = $(exec_prefix)/libexec
64
- sbindir = $(exec_prefix)/sbin
65
- bindir = $(exec_prefix)/bin
66
- archdir = $(rubyarchdir)
67
-
68
-
69
- CC_WRAPPER =
70
- CC = gcc
71
- CXX = g++
72
- LIBRUBY = $(LIBRUBY_SO)
73
- LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
74
- LIBRUBYARG_SHARED = -l$(RUBY_SO_NAME)
75
- LIBRUBYARG_STATIC = -l$(RUBY_SO_NAME)-static -framework CoreFoundation $(MAINLIBS)
76
- empty =
77
- OUTFLAG = -o $(empty)
78
- COUTFLAG = -o $(empty)
79
- CSRCFLAG = $(empty)
80
-
81
- RUBY_EXTCONF_H =
82
- cflags = $(hardenflags) -fdeclspec $(optflags) $(debugflags) $(warnflags)
83
- cxxflags =
84
- optflags = -O3 -fno-fast-math
85
- debugflags = -ggdb3
86
- warnflags = -Wall -Wextra -Wextra-tokens -Wdeprecated-declarations -Wdivision-by-zero -Wdiv-by-zero -Wimplicit-function-declaration -Wimplicit-int -Wpointer-arith -Wshorten-64-to-32 -Wwrite-strings -Wold-style-definition -Wmissing-noreturn -Wno-cast-function-type -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wunused-variable -Wmisleading-indentation -Wundef
87
- cppflags =
88
- CCDLFLAGS = -fno-common
89
- CFLAGS = $(CCDLFLAGS) -O3 -I/opt/homebrew/opt/libyaml/include -I/opt/homebrew/opt/libksba/include -I/opt/homebrew/opt/readline/include -I/opt/homebrew/opt/zlib/include -I/opt/homebrew/opt/openssl@1.1/include $(cflags) -fno-common -pipe -Wno-deprecated-declarations $(ARCH_FLAG)
90
- INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir)/ruby/backward -I$(hdrdir) -I$(srcdir)
91
- DEFS =
92
- CPPFLAGS = -DHAVE_OPENSSL_AES_H -DHAVE_AES_IGE_ENCRYPT -I/opt/homebrew/opt/openssl@3/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT $(DEFS) $(cppflags)
93
- CXXFLAGS = $(CCDLFLAGS) -fdeclspec $(ARCH_FLAG)
94
- ldflags = -L. -L/opt/homebrew/opt/libyaml/lib -L/opt/homebrew/opt/libksba/lib -L/opt/homebrew/opt/readline/lib -L/opt/homebrew/opt/zlib/lib -L/opt/homebrew/opt/openssl@1.1/lib -fstack-protector-strong
95
- dldflags = -L/opt/homebrew/opt/libyaml/lib -L/opt/homebrew/opt/libksba/lib -L/opt/homebrew/opt/readline/lib -L/opt/homebrew/opt/zlib/lib -L/opt/homebrew/opt/openssl@1.1/lib -Wl,-undefined,dynamic_lookup
96
- ARCH_FLAG = -arch arm64
97
- DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
98
- LDSHARED = $(CC) -dynamic -bundle
99
- LDSHAREDXX = $(CXX) -dynamic -bundle
100
- POSTLINK = dsymutil $@ 2>/dev/null; { test -z '$(RUBY_CODESIGN)' || codesign -s '$(RUBY_CODESIGN)' $@; }
101
- AR = ar
102
- LD = ld
103
- EXEEXT =
104
-
105
- RUBY_INSTALL_NAME = $(RUBY_BASE_NAME)
106
- RUBY_SO_NAME = ruby.3.4
107
- RUBYW_INSTALL_NAME =
108
- RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
109
- RUBYW_BASE_NAME = rubyw
110
- RUBY_BASE_NAME = ruby
111
-
112
- arch = arm64-darwin24
113
- sitearch = $(arch)
114
- ruby_version = 3.4.0
115
- ruby = $(bindir)/$(RUBY_BASE_NAME)
116
- RUBY = $(ruby)
117
- BUILTRUBY = $(bindir)/$(RUBY_BASE_NAME)
118
- ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/backward.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h
119
-
120
- RM = rm -f
121
- RM_RF = rm -fr
122
- RMDIRS = rmdir -p
123
- MAKEDIRS = /opt/homebrew/opt/coreutils/bin/gmkdir -p
124
- INSTALL = /opt/homebrew/opt/coreutils/bin/ginstall -c
125
- INSTALL_PROG = $(INSTALL) -m 0755
126
- INSTALL_DATA = $(INSTALL) -m 644
127
- COPY = cp
128
- TOUCH = exit >
129
-
130
- #### End of system configuration section. ####
131
-
132
- preload =
133
- libpath = . $(libdir) /opt/homebrew/opt/openssl@3/lib
134
- LIBPATH = -L. -L$(libdir) -L/opt/homebrew/opt/openssl@3/lib
135
- DEFFILE =
136
-
137
- CLEANFILES = mkmf.log
138
- DISTCLEANFILES =
139
- DISTCLEANDIRS =
140
-
141
- extout =
142
- extout_prefix =
143
- target_prefix = /aes_ige
144
- LOCAL_LIBS =
145
- LIBS = $(LIBRUBYARG_SHARED) -lcrypto -lssl -lpthread
146
- ORIG_SRCS = aes_ige.c
147
- SRCS = $(ORIG_SRCS)
148
- OBJS = aes_ige.o
149
- HDRS =
150
- LOCAL_HDRS =
151
- TARGET = aes_ige
152
- TARGET_NAME = aes_ige
153
- TARGET_ENTRY = Init_$(TARGET_NAME)
154
- DLLIB = $(TARGET).bundle
155
- EXTSTATIC =
156
- STATIC_LIB =
157
-
158
- TIMESTAMP_DIR = .
159
- BINDIR = $(bindir)
160
- RUBYCOMMONDIR = $(sitedir)$(target_prefix)
161
- RUBYLIBDIR = $(sitelibdir)$(target_prefix)
162
- RUBYARCHDIR = $(sitearchdir)$(target_prefix)
163
- HDRDIR = $(sitehdrdir)$(target_prefix)
164
- ARCHHDRDIR = $(sitearchhdrdir)$(target_prefix)
165
- TARGET_SO_DIR =
166
- TARGET_SO = $(TARGET_SO_DIR)$(DLLIB)
167
- CLEANLIBS = $(TARGET_SO) $(TARGET_SO:=.dSYM)
168
- CLEANOBJS = $(OBJS) *.bak
169
- TARGET_SO_DIR_TIMESTAMP = $(TIMESTAMP_DIR)/.sitearchdir.-.aes_ige.time
170
-
171
- all: $(DLLIB)
172
- static: $(STATIC_LIB)
173
- .PHONY: all install static install-so install-rb
174
- .PHONY: clean clean-so clean-static clean-rb
175
-
176
- clean-static::
177
- clean-rb-default::
178
- clean-rb::
179
- clean-so::
180
- clean: clean-so clean-static clean-rb-default clean-rb
181
- -$(Q)$(RM_RF) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time
182
-
183
- distclean-rb-default::
184
- distclean-rb::
185
- distclean-so::
186
- distclean-static::
187
- distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb
188
- -$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
189
- -$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
190
- -$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
191
-
192
- realclean: distclean
193
- install: install-so install-rb
194
-
195
- install-so: $(DLLIB) $(TARGET_SO_DIR_TIMESTAMP)
196
- $(INSTALL_PROG) $(DLLIB) $(RUBYARCHDIR)
197
- clean-static::
198
- -$(Q)$(RM) $(STATIC_LIB)
199
- install-rb: pre-install-rb do-install-rb install-rb-default
200
- install-rb-default: pre-install-rb-default do-install-rb-default
201
- pre-install-rb: Makefile
202
- pre-install-rb-default: Makefile
203
- do-install-rb:
204
- do-install-rb-default:
205
- pre-install-rb-default:
206
- @$(NULLCMD)
207
- $(TARGET_SO_DIR_TIMESTAMP):
208
- $(Q) $(MAKEDIRS) $(@D) $(RUBYARCHDIR)
209
- $(Q) $(TOUCH) $@
210
-
211
- site-install: site-install-so site-install-rb
212
- site-install-so: install-so
213
- site-install-rb: install-rb
214
-
215
- .SUFFIXES: .c .m .cc .mm .cxx .cpp .o .S
216
-
217
- .cc.o:
218
- $(ECHO) compiling $(<)
219
- $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$<
220
-
221
- .cc.S:
222
- $(ECHO) translating $(<)
223
- $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$<
224
-
225
- .mm.o:
226
- $(ECHO) compiling $(<)
227
- $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$<
228
-
229
- .mm.S:
230
- $(ECHO) translating $(<)
231
- $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$<
232
-
233
- .cxx.o:
234
- $(ECHO) compiling $(<)
235
- $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$<
236
-
237
- .cxx.S:
238
- $(ECHO) translating $(<)
239
- $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$<
240
-
241
- .cpp.o:
242
- $(ECHO) compiling $(<)
243
- $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$<
244
-
245
- .cpp.S:
246
- $(ECHO) translating $(<)
247
- $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$<
248
-
249
- .c.o:
250
- $(ECHO) compiling $(<)
251
- $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$<
252
-
253
- .c.S:
254
- $(ECHO) translating $(<)
255
- $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$<
256
-
257
- .m.o:
258
- $(ECHO) compiling $(<)
259
- $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$<
260
-
261
- .m.S:
262
- $(ECHO) translating $(<)
263
- $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$<
264
-
265
- $(TARGET_SO): $(OBJS) Makefile
266
- $(ECHO) linking shared-object aes_ige/$(DLLIB)
267
- -$(Q)$(RM) $(@)
268
- $(Q) $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
269
- $(Q) $(POSTLINK)
270
-
271
-
272
-
273
- $(OBJS): $(HDRS) $(ruby_headers)