kompo 0.1.2 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 530a1741287a0f2ef4705f078d5dcce97879b84b9cc222f5c005741a5a0b05e1
4
- data.tar.gz: 9fdd81108938288b9908ca3c34af707e24d3a0f1fb2bf31fae33fba22d34381d
3
+ metadata.gz: 12a48f38a6abeb3b4587b542da43b0ecc1813a9c86db2104f162e706bb71a542
4
+ data.tar.gz: 5c0b5d0b3c1fdd021482c4746befa09e699569e7c2fbe63ac746adae8656a6ba
5
5
  SHA512:
6
- metadata.gz: 514af116c063da5503567dd8e2f6e94d64e9f7075264cb56a2d829e954eec36c225dec8c194f806c62daf1b76a2eddfaaf7a2087f4c3d7b5de8801f2046e5692
7
- data.tar.gz: 25880f8208dc8df0f82c815375804ad34c558945a3ae7d037cdc35f621312fffcd95ebd22361d7f84ffba14825df32d6250cb236cca1b652a83b83ded90bb423
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
- Install the gem and add to the application's Gemfile by executing:
9
-
10
- $ bundle add kompo
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
- ### Quick Start
28
- If you want to try it out, `cd` to the `sample/` directory and execute the following:
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
- This will read the Gemfile in the directory and create an executable file with `main.rb` as the entry point in the same directory as `./sample` in the same directory.
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Kompo
4
- VERSION = "0.1.2"
4
+ VERSION = "0.1.4"
5
5
  end
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 = true
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
- Dir.glob(File.join(bundle_ruby, get_semantic_ruby_version, 'gems/**/extconf.rb')).each do |makefile_dir|
169
- dir_name = File.dirname(makefile_dir)
170
- makefile = File.join(dir_name, 'Makefile')
171
- if File.exist?(cargo_toml = File.join(dir_name, 'Cargo.toml'))
172
- command = [
173
- 'cargo',
174
- 'rustc',
175
- '--release',
176
- '--crate-type=staticlib',
177
- '--target-dir',
178
- 'target',
179
- "--manifest-path=#{cargo_toml}",
180
- ].join(' ')
181
- exec_command command, 'cargo build'
182
- copy_targets = Dir.glob(File.join(dir_name, 'target/release/*.a'))
183
- else
184
- objs = File.read(makefile).scan(/OBJS = (.*\.o)/).join(' ')
185
- command = ['make', '-C', dir_name, objs, '--always-make'].join(' ')
186
- exec_command command, 'make'
187
- copy_targets = objs.split(' ').map { File.join(dir_name, _1) }
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.2
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-03 00:00:00.000000000 Z
11
+ date: 2024-04-24 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description: Write a longer description or delete this line.
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: Write a short summary, because RubyGems requires one.
58
+ summary: A tool to pack Ruby and Ruby scripts in one binary.
62
59
  test_files: []
data/sample/Gemfile DELETED
@@ -1,8 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- source "https://rubygems.org"
4
-
5
- gem 'sinatra'
6
- gem 'sqlite3', force_ruby_platform: true
7
- gem 'puma'
8
- gem 'rackup'
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
@@ -1,3 +0,0 @@
1
- module Hello
2
- World = "Hello, World!"
3
- end
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