hotreload 0.2.1 → 0.2.2
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.
- checksums.yaml +4 -4
- data/lib/config.rb +6 -5
- data/lib/hotreload.rb +34 -20
- data/lib/main.rb +2 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ae578210693f38228edf1551ef5d4b23ee8ec56d4d548782b2bf7ec16cd578b2
|
4
|
+
data.tar.gz: ac65c0fc2a8e06f57df1797eb84ec256abf698d4ba13f92d5fda0b816b1df8b2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d658e01b6472ab3e877ed5f959b238a329fbd752657527c992eed8af9cc3011dd0148a64e6048b7255342e7665b4a6727184a156dc874b3618761a20279e2296
|
7
|
+
data.tar.gz: 9ae111e6aec259559e7bd547ed28564b34e853391a486df92caa5e89bf5ed93edc7b1a60113e1fb5c043ce8d6ff9ab502d57da8e1802a04dd5485d86f5ccfc97
|
data/lib/config.rb
CHANGED
@@ -31,11 +31,12 @@ module Command
|
|
31
31
|
|
32
32
|
HRCommandComplete = 0
|
33
33
|
HRCommandBuilding = 1
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
34
|
+
HRCommandBuildFailed = 2
|
35
|
+
HRCommandSetProject = 3
|
36
|
+
HRCommandTransferFile = 4
|
37
|
+
HRCommandTransferFileNameFinished = 5
|
38
|
+
HRCommandTransferFileSizeFinished = 6
|
39
|
+
HRCommandTransferFileFinished = 7
|
39
40
|
|
40
41
|
InjectionEOF = ~0
|
41
42
|
end
|
data/lib/hotreload.rb
CHANGED
@@ -26,6 +26,7 @@ class HotReload
|
|
26
26
|
@hot_reload_tmp_path = ""
|
27
27
|
@compile_class = Hash.new
|
28
28
|
@xcode_dev_path = "/Applications/Xcode.app/Contents/Developer"
|
29
|
+
@task_queue = Queue.new
|
29
30
|
|
30
31
|
end
|
31
32
|
|
@@ -42,11 +43,11 @@ class HotReload
|
|
42
43
|
|
43
44
|
# tell client the project being watched
|
44
45
|
@project_file = "#{@project_path}/*.xcworkspace"
|
45
|
-
files_sorted_by_time = Dir[@project_file].
|
46
|
+
files_sorted_by_time = Dir[@project_file].sort!{ |x,y| File.mtime(y) <=> File.mtime(x) }
|
46
47
|
@project_file = files_sorted_by_time[0]
|
47
48
|
if @project_file == nil
|
48
49
|
@project_file = "#{@project_path}/*.xcodeproj"
|
49
|
-
files_sorted_by_time = Dir[@project_file].
|
50
|
+
files_sorted_by_time = Dir[@project_file].sort!{ |x,y| File.mtime(y) <=> File.mtime(x) }
|
50
51
|
@project_file = files_sorted_by_time[0]
|
51
52
|
end
|
52
53
|
|
@@ -67,6 +68,8 @@ class HotReload
|
|
67
68
|
|
68
69
|
# listen_command
|
69
70
|
|
71
|
+
runTask
|
72
|
+
|
70
73
|
set_project(@project_file)
|
71
74
|
|
72
75
|
@watcher = nil
|
@@ -81,31 +84,38 @@ class HotReload
|
|
81
84
|
@server.read_message
|
82
85
|
end
|
83
86
|
|
84
|
-
def
|
87
|
+
def runTask
|
85
88
|
Thread.new do
|
86
89
|
# rebuild
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
90
|
+
while true do
|
91
|
+
source = @task_queue.pop
|
92
|
+
@server.send_command(Command::HRCommandBuilding, source)
|
93
|
+
dylib = build(source)
|
94
|
+
if !dylib
|
95
|
+
puts "build failed"
|
96
|
+
@server.send_command(Command::HRCommandBuildFailed, source)
|
97
|
+
next
|
98
|
+
end
|
93
99
|
|
94
|
-
|
100
|
+
symbol_file = get_symbol_file
|
95
101
|
|
96
|
-
|
102
|
+
@server.send_command(Command::HRCommandTransferFile, nil)
|
97
103
|
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
104
|
+
puts "start transfer file"
|
105
|
+
file_tmp = "#{@hot_reload_tmp_path}/hotreload#{@hot_reload_id}"
|
106
|
+
@server.send_file(dylib)
|
107
|
+
@server.send_file("#{file_tmp}.o")
|
108
|
+
@server.send_file(symbol_file)
|
103
109
|
|
104
|
-
|
105
|
-
|
110
|
+
puts "finish transfer file"
|
111
|
+
end
|
106
112
|
end
|
107
113
|
end
|
108
114
|
|
115
|
+
def inject(source)
|
116
|
+
@task_queue << source
|
117
|
+
end
|
118
|
+
|
109
119
|
def changeFiles(changeFiles)
|
110
120
|
now = Time.now.to_i
|
111
121
|
changeFiles.each do |file|
|
@@ -174,6 +184,7 @@ class HotReload
|
|
174
184
|
if !compile_model
|
175
185
|
puts
|
176
186
|
"Could not locate compile command for #{file} (HotReload does not work with Whole Module Optimization. There are also restrictions on characters allowed in paths. All paths are also case sensitive is another thing to check.)"
|
187
|
+
return
|
177
188
|
end
|
178
189
|
end
|
179
190
|
|
@@ -184,7 +195,8 @@ class HotReload
|
|
184
195
|
ret = system(command)
|
185
196
|
if !ret
|
186
197
|
@compile_class.delete(file)
|
187
|
-
puts "Re-compilation failed (#{
|
198
|
+
puts "Re-compilation failed (#{file_tmp}.sh)\n#{File.read(log_file)})"
|
199
|
+
return
|
188
200
|
end
|
189
201
|
|
190
202
|
# save in memory
|
@@ -218,6 +230,7 @@ class HotReload
|
|
218
230
|
ret = system(link_command)
|
219
231
|
if !ret
|
220
232
|
puts "Link failed, check #{@hot_reload_tmp_path}/command.sh \n #{log_file}"
|
233
|
+
return
|
221
234
|
end
|
222
235
|
|
223
236
|
puts "codesign dylib"
|
@@ -268,7 +281,7 @@ class HotReload
|
|
268
281
|
end
|
269
282
|
end
|
270
283
|
|
271
|
-
log_sort = build_log_array.
|
284
|
+
log_sort = build_log_array.sort!{ |x,y| File.mtime(y) <=> File.mtime(x) }
|
272
285
|
log_sort[0]
|
273
286
|
end
|
274
287
|
|
@@ -284,6 +297,7 @@ class HotReload
|
|
284
297
|
compile_command_file = "#{tmp_file}.sh"
|
285
298
|
if !File.exist?(compile_command_file)
|
286
299
|
puts "compile command parse error"
|
300
|
+
return
|
287
301
|
end
|
288
302
|
|
289
303
|
compile_command = File.read("#{tmp_file}.sh")
|
data/lib/main.rb
CHANGED
@@ -20,6 +20,5 @@ require_relative 'hotreload'
|
|
20
20
|
|
21
21
|
|
22
22
|
|
23
|
-
|
24
|
-
project_path
|
25
|
-
HotReload.new().startServer(project_path)
|
23
|
+
project_path = "/Users/***/Documents/workspace/third/HotReloadClient/Example/Pods"
|
24
|
+
# HotReload.new().startServer(project_path)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hotreload
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- shantj
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-12-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|