kompo 0.1.2 → 0.1.4
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/README.md +20 -15
- data/lib/kompo/version.rb +1 -1
- data/lib/kompo.rb +30 -28
- metadata +5 -8
- data/sample/Gemfile +0 -8
- data/sample/Gemfile.lock +0 -48
- data/sample/hello.rb +0 -3
- data/sample/main.rb +0 -33
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 12a48f38a6abeb3b4587b542da43b0ecc1813a9c86db2104f162e706bb71a542
|
4
|
+
data.tar.gz: 5c0b5d0b3c1fdd021482c4746befa09e699569e7c2fbe63ac746adae8656a6ba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 81f9ac47065c925cfcd51807123080fa0dd2304d75070bb7b44cfeba5c885ee7dd87d9498dde962d5dd48cb045af5deb62d438747f7e41d73925fd23412cfc5e
|
7
|
+
data.tar.gz: 6d2c8f0613ce1ca07f28d364b8e37f306c7e0d0d760a5b11b88003c6198e19196f75dd807d4f413f9c39a5b5402c68d18995200a8169715eeb70c2e44e4272d5
|
data/README.md
CHANGED
@@ -1,17 +1,10 @@
|
|
1
1
|
# Kompo
|
2
|
-
|
3
|
-
TODO: Delete this and the text below, and describe your gem
|
4
|
-
|
5
|
-
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/kompo`. To experiment with that code, run `bin/console` for an interactive prompt.
|
2
|
+
A tool to pack Ruby and Ruby scripts in one binary. This tool is still under development.
|
6
3
|
|
7
4
|
## Installation
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
If bundler is not being used to manage dependencies, install the gem by executing:
|
13
|
-
|
14
|
-
$ gem install kompo
|
5
|
+
```sh
|
6
|
+
$ gem install kompo
|
7
|
+
```
|
15
8
|
|
16
9
|
## Usage
|
17
10
|
|
@@ -24,13 +17,25 @@ $ brew tap ahogappa0613/kompo-vfs https://github.com/ahogappa0613/kompo-vfs.git
|
|
24
17
|
$ brew install ahogappa0613/kompo-vfs/kompo-vfs
|
25
18
|
```
|
26
19
|
|
27
|
-
###
|
28
|
-
|
20
|
+
### Building
|
21
|
+
To build komp-vfs, you need to have cargo installation.
|
29
22
|
```sh
|
30
|
-
$ kompo
|
23
|
+
$ git clone https://github.com/ahogappa0613/kompo-vfs.git
|
24
|
+
$ cd kompo-vfs
|
25
|
+
$ cargo build --release
|
31
26
|
```
|
32
|
-
|
27
|
+
Set environment variables
|
28
|
+
```sh
|
29
|
+
$ KOMPO_CLI=/path/to/kompo-vfs/target/release/kompo-cli
|
30
|
+
$ LIB_KOMPO_DIR=/path/to/kompo-vfs/target/release
|
31
|
+
```
|
32
|
+
|
33
|
+
## examples
|
33
34
|
|
35
|
+
* hello
|
36
|
+
* simple hello world script.
|
37
|
+
* sinatra_and_sqlite
|
38
|
+
* sinatra app with sqlite3 with Gemfile.
|
34
39
|
|
35
40
|
|
36
41
|
## Development
|
data/lib/kompo/version.rb
CHANGED
data/lib/kompo.rb
CHANGED
@@ -18,7 +18,7 @@ module Kompo
|
|
18
18
|
def initialize(dir = Dir.getwd, opt = OptionParser.new)
|
19
19
|
@entrypoint = File.join(dir, 'main.rb')
|
20
20
|
@output = File.basename(dir)
|
21
|
-
@gemfile =
|
21
|
+
@gemfile = File.exist?(File.join(Dir.pwd, 'Gemfile'))
|
22
22
|
@stdlib = true
|
23
23
|
@dest_dir = dir
|
24
24
|
@ruby_src_path = nil
|
@@ -165,33 +165,35 @@ module Kompo
|
|
165
165
|
require 'erb'
|
166
166
|
|
167
167
|
exts = []
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
168
|
+
if gemfile
|
169
|
+
Dir.glob(File.join(bundle_ruby, get_semantic_ruby_version, 'gems/**/extconf.rb')).each do |makefile_dir|
|
170
|
+
dir_name = File.dirname(makefile_dir)
|
171
|
+
makefile = File.join(dir_name, 'Makefile')
|
172
|
+
if File.exist?(cargo_toml = File.join(dir_name, 'Cargo.toml'))
|
173
|
+
command = [
|
174
|
+
'cargo',
|
175
|
+
'rustc',
|
176
|
+
'--release',
|
177
|
+
'--crate-type=staticlib',
|
178
|
+
'--target-dir',
|
179
|
+
'target',
|
180
|
+
"--manifest-path=#{cargo_toml}",
|
181
|
+
].join(' ')
|
182
|
+
exec_command command, 'cargo build'
|
183
|
+
copy_targets = Dir.glob(File.join(dir_name, 'target/release/*.a'))
|
184
|
+
else
|
185
|
+
objs = File.read(makefile).scan(/OBJS = (.*\.o)/).join(' ')
|
186
|
+
command = ['make', '-C', dir_name, objs, '--always-make'].join(' ')
|
187
|
+
exec_command command, 'make'
|
188
|
+
copy_targets = objs.split(' ').map { File.join(dir_name, _1) }
|
189
|
+
end
|
190
|
+
|
191
|
+
dir = FileUtils.mkdir_p('exts/' + File.basename(dir_name)).first
|
192
|
+
FileUtils.cp(copy_targets, dir)
|
193
|
+
prefix = File.read(makefile).scan(/target_prefix = (.*)/).join.delete_prefix('/')
|
194
|
+
target_name = File.read(makefile).scan(/TARGET_NAME = (.*)/).join
|
195
|
+
exts << [File.join(prefix, "#{target_name}.so").delete_prefix('/'), "Init_#{target_name}"]
|
188
196
|
end
|
189
|
-
|
190
|
-
dir = FileUtils.mkdir_p('exts/' + File.basename(dir_name)).first
|
191
|
-
FileUtils.cp(copy_targets, dir)
|
192
|
-
prefix = File.read(makefile).scan(/target_prefix = (.*)/).join.delete_prefix('/')
|
193
|
-
target_name = File.read(makefile).scan(/TARGET_NAME = (.*)/).join
|
194
|
-
exts << [File.join(prefix, "#{target_name}.so").delete_prefix('/'), "Init_#{target_name}"]
|
195
197
|
end
|
196
198
|
|
197
199
|
File.write("main.c", ERB.new(File.read(File.join(__dir__, 'main.c.erb'))).result(binding))
|
@@ -203,7 +205,7 @@ module Kompo
|
|
203
205
|
'-O3',
|
204
206
|
'-Wall',
|
205
207
|
'main.c',
|
206
|
-
'exts/**/*.o',
|
208
|
+
Dir.glob('exts/**/*.o').join(' '),
|
207
209
|
'fs.o',
|
208
210
|
"#{lib_ruby_static_dir.nil? ? '' : '-L' + lib_ruby_static_dir}",
|
209
211
|
"#{lib_kompo_dir.nil? ? '' : '-L' + lib_kompo_dir}",
|
metadata
CHANGED
@@ -1,16 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kompo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sho Hirano
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-04-
|
11
|
+
date: 2024-04-24 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
|
-
description:
|
13
|
+
description: A tool to pack Ruby and Ruby scripts in one binary. This tool is still
|
14
|
+
under development.
|
14
15
|
email:
|
15
16
|
- ahogappa@gmail.com
|
16
17
|
executables:
|
@@ -29,10 +30,6 @@ files:
|
|
29
30
|
- lib/kompo/kompo_fs.rb
|
30
31
|
- lib/kompo/version.rb
|
31
32
|
- lib/main.c.erb
|
32
|
-
- sample/Gemfile
|
33
|
-
- sample/Gemfile.lock
|
34
|
-
- sample/hello.rb
|
35
|
-
- sample/main.rb
|
36
33
|
- sig/kompo.rbs
|
37
34
|
homepage: https://github.com/ahogappa0613/kompo
|
38
35
|
licenses: []
|
@@ -58,5 +55,5 @@ requirements: []
|
|
58
55
|
rubygems_version: 3.4.10
|
59
56
|
signing_key:
|
60
57
|
specification_version: 4
|
61
|
-
summary:
|
58
|
+
summary: A tool to pack Ruby and Ruby scripts in one binary.
|
62
59
|
test_files: []
|
data/sample/Gemfile
DELETED
data/sample/Gemfile.lock
DELETED
@@ -1,48 +0,0 @@
|
|
1
|
-
GEM
|
2
|
-
remote: https://rubygems.org/
|
3
|
-
specs:
|
4
|
-
base64 (0.2.0)
|
5
|
-
mini_portile2 (2.8.5)
|
6
|
-
mustermann (3.0.0)
|
7
|
-
ruby2_keywords (~> 0.0.1)
|
8
|
-
nio4r (2.7.0)
|
9
|
-
puma (6.4.2)
|
10
|
-
nio4r (~> 2.0)
|
11
|
-
rack (3.0.9.1)
|
12
|
-
rack-protection (4.0.0)
|
13
|
-
base64 (>= 0.1.0)
|
14
|
-
rack (>= 3.0.0, < 4)
|
15
|
-
rack-session (2.0.0)
|
16
|
-
rack (>= 3.0.0)
|
17
|
-
rackup (2.1.0)
|
18
|
-
rack (>= 3)
|
19
|
-
webrick (~> 1.8)
|
20
|
-
ruby2_keywords (0.0.5)
|
21
|
-
sinatra (4.0.0)
|
22
|
-
mustermann (~> 3.0)
|
23
|
-
rack (>= 3.0.0, < 4)
|
24
|
-
rack-protection (= 4.0.0)
|
25
|
-
rack-session (>= 2.0.0, < 3)
|
26
|
-
tilt (~> 2.0)
|
27
|
-
sqlite3 (1.7.2)
|
28
|
-
mini_portile2 (~> 2.8.0)
|
29
|
-
tilt (2.3.0)
|
30
|
-
webrick (1.8.1)
|
31
|
-
|
32
|
-
PLATFORMS
|
33
|
-
aarch64-linux
|
34
|
-
arm-linux
|
35
|
-
arm64-darwin
|
36
|
-
ruby
|
37
|
-
x86-linux
|
38
|
-
x86_64-darwin
|
39
|
-
x86_64-linux
|
40
|
-
|
41
|
-
DEPENDENCIES
|
42
|
-
puma
|
43
|
-
rackup
|
44
|
-
sinatra
|
45
|
-
sqlite3
|
46
|
-
|
47
|
-
BUNDLED WITH
|
48
|
-
2.5.3
|
data/sample/hello.rb
DELETED
data/sample/main.rb
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
require 'sqlite3'
|
2
|
-
require 'sinatra'
|
3
|
-
|
4
|
-
require_relative './hello'
|
5
|
-
|
6
|
-
File.delete("sample.db") if File.exist?("sample.db")
|
7
|
-
|
8
|
-
db = SQLite3::Database.new "sample.db"
|
9
|
-
|
10
|
-
rows = db.execute <<-SQL
|
11
|
-
create table numbers (
|
12
|
-
name varchar(30),
|
13
|
-
val int
|
14
|
-
);
|
15
|
-
SQL
|
16
|
-
|
17
|
-
{
|
18
|
-
"one" => 1,
|
19
|
-
"two" => 2,
|
20
|
-
}.each do |pair|
|
21
|
-
db.execute "insert into numbers values ( ?, ? )", pair
|
22
|
-
end
|
23
|
-
|
24
|
-
set :bind, '0.0.0.0'
|
25
|
-
|
26
|
-
get '/' do
|
27
|
-
rows = db.execute 'select * from numbers;'
|
28
|
-
rows.to_s
|
29
|
-
end
|
30
|
-
|
31
|
-
get '/hello' do
|
32
|
-
Hello::World
|
33
|
-
end
|