ruby_wasm 2.6.1-x64-mingw-ucrt → 2.7.0-x64-mingw-ucrt

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.
data/package.json CHANGED
@@ -5,9 +5,10 @@
5
5
  "packages/npm-packages/*"
6
6
  ],
7
7
  "devDependencies": {
8
- "@playwright/test": "^1.43.1",
8
+ "@bytecodealliance/jco": "1.4.4",
9
+ "@playwright/test": "^1.46.1",
9
10
  "@rollup/plugin-json": "^6.1.0",
10
- "rollup": "^4.17.2",
11
- "@bytecodealliance/jco": "./vendor/jco"
11
+ "rollup": "^4.22.5",
12
+ "typedoc": "^0.26.7"
12
13
  }
13
14
  }
data/rakelib/check.rake CHANGED
@@ -41,8 +41,12 @@ namespace :check do
41
41
  )
42
42
  end
43
43
 
44
+ task bindgen_ts: :install_wit_bindgen do
45
+ sh "node", "packages/npm-packages/ruby-wasm-wasi/tools/component-ts-bindgen.mjs"
46
+ end
47
+
44
48
  desc "Check wit-bindgen'ed sources are up-to-date"
45
- task bindgen: %i[bindgen_c legacy_bindgen_c legacy_bindgen_js]
49
+ task bindgen: %i[bindgen_c bindgen_ts legacy_bindgen_c legacy_bindgen_js]
46
50
 
47
51
  task :type do
48
52
  sh "bundle exec steep check"
data/rakelib/ci.rake CHANGED
@@ -62,19 +62,21 @@ def rake_task_matrix
62
62
  end
63
63
  npm_entries =
64
64
  NPM_PACKAGES.map do |pkg|
65
+ package_json =
66
+ JSON.parse(
67
+ File.read("packages/npm-packages/#{pkg[:name]}/package.json")
68
+ )
65
69
  entry = {
66
70
  task: "npm:#{pkg[:name]}",
67
71
  prerelease: "npm:configure_prerelease",
68
72
  artifact: "packages/npm-packages/#{pkg[:name]}/#{pkg[:name]}-*.tgz",
69
73
  artifact_name: "npm-#{pkg[:name]}",
74
+ # Skip publishing packages with `"private": true`
75
+ should_publish: !package_json["private"],
70
76
  builder: pkg[:target],
71
77
  rubies_cache_key: npm_pkg_rubies_cache_key(pkg)
72
78
  }
73
79
  # Run tests only if the package has 'test' script
74
- package_json =
75
- JSON.parse(
76
- File.read("packages/npm-packages/#{pkg[:name]}/package.json")
77
- )
78
80
  if package_json["scripts"] && package_json["scripts"]["test"]
79
81
  entry[:test] = "npm:#{pkg[:name]}:check"
80
82
  end
@@ -95,7 +97,10 @@ end
95
97
 
96
98
  namespace :ci do
97
99
  task :rake_task_matrix do
98
- print JSON.generate(rake_task_matrix.flat_map { |_, entries| entries })
100
+ content = JSON.generate(rake_task_matrix.flat_map { |_, entries| entries })
101
+ output = "ci_matrix.json"
102
+ File.write("#{output}", content)
103
+ puts "Created \"#{output}\""
99
104
  end
100
105
 
101
106
  task :pin_build_manifest do
@@ -139,6 +144,7 @@ namespace :ci do
139
144
  .map { |entry| "release/#{entry[:artifact_name]}/*" }
140
145
  File.open("release/note.md", "w") { |f| f.print release_note }
141
146
  matrix[:npm].each do |task|
147
+ next unless task[:should_publish]
142
148
  artifact = task[:artifact_name]
143
149
  tarball = Dir.glob("release/#{artifact}/*")
144
150
  next if tarball.empty?
data/rakelib/doc.rake CHANGED
@@ -12,18 +12,15 @@ RDoc::Task.new do |doc|
12
12
  ]
13
13
  end
14
14
 
15
- namespace :doc do
16
- desc "Update docs/api/javascript.md"
17
- task :api_js do
18
- sh "npx",
19
- "documentation",
20
- "readme",
21
- "--readme-file",
22
- "./packages/npm-packages/ruby-wasm-wasi/README.md",
23
- "--section",
24
- "API",
25
- "--markdown-toc",
26
- "false",
27
- "./packages/npm-packages/ruby-wasm-wasi/dist/esm/index.js"
28
- end
15
+ desc "Generate TypeScript documentation"
16
+ task :typedoc do
17
+ sh "npm install"
18
+ mkdir_p "html/npm/@ruby/wasm-wasi"
19
+ sh "npx typedoc packages/npm-packages/ruby-wasm-wasi/src/index.ts --sort source-order --out html/npm/@ruby/wasm-wasi"
20
+ end
21
+
22
+ desc "Generate documentation site"
23
+ task :doc do
24
+ Rake::Task["rdoc"].invoke
25
+ Rake::Task["typedoc"].invoke
29
26
  end
@@ -11,8 +11,6 @@ def npm_pkg_build_command(pkg)
11
11
  # Skip if the package does not require building ruby
12
12
  return nil unless pkg[:ruby_version] && pkg[:target]
13
13
  [
14
- "bundle",
15
- "exec",
16
14
  exe_rbwasm,
17
15
  "build",
18
16
  "--ruby-version",
@@ -25,19 +23,112 @@ def npm_pkg_build_command(pkg)
25
23
  end
26
24
 
27
25
  def npm_pkg_rubies_cache_key(pkg)
26
+ vendor_gem_cache(pkg)
27
+
28
28
  build_command = npm_pkg_build_command(pkg)
29
29
  return nil unless build_command
30
30
  require "open3"
31
31
  cmd = build_command + ["--print-ruby-cache-key"]
32
32
  chdir = pkg[:gemfile] ? File.dirname(pkg[:gemfile]) : Dir.pwd
33
- stdout, status = Open3.capture2(*cmd, chdir: chdir)
33
+ env = { "RUBY_WASM_ROOT" => LIB_ROOT }
34
+ stdout, status = Open3.capture2(env, *cmd, chdir: chdir)
34
35
  unless status.success?
35
- raise "Command failed with status (#{status.exitstatus}): #{cmd.join ""}"
36
+ raise "Command failed with status (#{status.exitstatus}): #{cmd.join " "}"
36
37
  end
37
38
  require "json"
38
39
  JSON.parse(stdout)["hexdigest"]
39
40
  end
40
41
 
42
+ def vendor_gem_cache(pkg)
43
+ return unless pkg[:gemfile]
44
+ pkg_dir = File.dirname(pkg[:gemfile])
45
+ pkg_dir = File.expand_path(pkg_dir)
46
+ vendor_cache_dir = File.join(pkg_dir, "vendor", "cache")
47
+ mkdir_p vendor_cache_dir
48
+ require_relative "../packages/gems/js/lib/js/version"
49
+ sh "gem", "-C", "packages/gems/js", "build", "-o",
50
+ File.join(vendor_cache_dir, "js-#{JS::VERSION}.gem")
51
+ JS::VERSION
52
+ end
53
+
54
+ def build_ruby(pkg, base_dir, pkg_dir, wasi_sdk, clean: false)
55
+ build_command = npm_pkg_build_command(pkg)
56
+ # Skip if the package does not require building ruby
57
+ return unless build_command
58
+
59
+ js_gem_version = vendor_gem_cache(pkg)
60
+
61
+ env = {
62
+ # Share ./build and ./rubies in the same workspace
63
+ "RUBY_WASM_ROOT" => base_dir
64
+ }
65
+ cwd = base_dir
66
+ if gemfile_path = pkg[:gemfile]
67
+ cwd = File.dirname(gemfile_path)
68
+ else
69
+ # Explicitly disable rubygems integration since Bundler finds
70
+ # Gemfile in the repo root directory.
71
+ build_command.push "--disable-gems"
72
+ end
73
+ dist_dir = File.join(pkg_dir, "dist")
74
+ mkdir_p dist_dir
75
+ if pkg[:target].start_with?("wasm32-unknown-wasi")
76
+ if pkg[:enable_component_model]
77
+ component_path = File.join(pkg_dir, "tmp", "ruby.component.wasm")
78
+ FileUtils.mkdir_p(File.dirname(component_path))
79
+
80
+ # Remove js gem from the ./bundle directory to force Bundler to re-install it
81
+ rm_rf FileList[File.join(pkg_dir, "bundle", "**", "js-#{js_gem_version}")]
82
+
83
+ Dir.chdir(cwd) do
84
+ sh env.merge("RUBY_WASM_EXPERIMENTAL_DYNAMIC_LINKING" => "1"),
85
+ *build_command, *(clean ? ["--clean"] : []),
86
+ "-o", component_path
87
+ end
88
+ sh "npx", "jco", "transpile",
89
+ "--no-wasi-shim", "--instantiation", "--valid-lifting-optimization",
90
+ component_path, "-o", File.join(dist_dir, "component")
91
+ # ./component/package.json is required to be an ES module
92
+ File.write(File.join(dist_dir, "component", "package.json"), '{ "type": "module" }')
93
+ else
94
+ Dir.chdir(cwd) do
95
+ # uninstall js gem to re-install just-built js gem
96
+ sh "gem", "uninstall", "js", "-v", js_gem_version, "--force"
97
+ # install gems including js gem
98
+ sh "bundle", "install"
99
+
100
+ sh env,
101
+ "bundle", "exec",
102
+ *build_command,
103
+ "--no-stdlib", "--remake",
104
+ *(clean ? ["--clean"] : []),
105
+ "-o",
106
+ File.join(dist_dir, "ruby.wasm")
107
+ sh env,
108
+ "bundle", "exec",
109
+ *build_command,
110
+ "-o",
111
+ File.join(dist_dir, "ruby.debug+stdlib.wasm")
112
+ end
113
+
114
+ sh wasi_sdk.wasm_opt,
115
+ "--strip-debug",
116
+ File.join(dist_dir, "ruby.wasm"),
117
+ "-o",
118
+ File.join(dist_dir, "ruby.wasm")
119
+ sh wasi_sdk.wasm_opt,
120
+ "--strip-debug",
121
+ File.join(dist_dir, "ruby.debug+stdlib.wasm"),
122
+ "-o",
123
+ File.join(dist_dir, "ruby+stdlib.wasm")
124
+ end
125
+ elsif pkg[:target] == "wasm32-unknown-emscripten"
126
+ Dir.chdir(cwd || base_dir) do
127
+ sh env, *build_command, "-o", "/dev/null"
128
+ end
129
+ end
130
+ end
131
+
41
132
  namespace :npm do
42
133
  NPM_PACKAGES.each do |pkg|
43
134
  base_dir = Dir.pwd
@@ -46,63 +137,7 @@ namespace :npm do
46
137
  namespace pkg[:name] do
47
138
  desc "Build ruby for npm package #{pkg[:name]}"
48
139
  task "ruby" do
49
- build_command = npm_pkg_build_command(pkg)
50
- # Skip if the package does not require building ruby
51
- next unless build_command
52
-
53
- env = {
54
- # Share ./build and ./rubies in the same workspace
55
- "RUBY_WASM_ROOT" => base_dir
56
- }
57
- cwd = nil
58
- if gemfile_path = pkg[:gemfile]
59
- cwd = File.dirname(gemfile_path)
60
- else
61
- # Explicitly disable rubygems integration since Bundler finds
62
- # Gemfile in the repo root directory.
63
- build_command.push "--disable-gems"
64
- end
65
- dist_dir = File.join(pkg_dir, "dist")
66
- mkdir_p dist_dir
67
- if pkg[:target].start_with?("wasm32-unknown-wasi")
68
- Dir.chdir(cwd || base_dir) do
69
- sh env,
70
- *build_command,
71
- "--no-stdlib",
72
- "-o",
73
- File.join(dist_dir, "ruby.wasm")
74
- sh env,
75
- *build_command,
76
- "-o",
77
- File.join(dist_dir, "ruby.debug+stdlib.wasm")
78
- if pkg[:enable_component_model]
79
- component_path = File.join(pkg_dir, "tmp", "ruby.component.wasm")
80
- FileUtils.mkdir_p(File.dirname(component_path))
81
-
82
- sh env.merge("RUBY_WASM_EXPERIMENTAL_COMPONENT_MODEL" => "1"),
83
- *build_command, "-o", component_path
84
- sh "npx", "jco", "transpile",
85
- "--no-wasi-shim", "--instantiation", "--valid-lifting-optimization",
86
- component_path, "-o", File.join(dist_dir, "component")
87
- # ./component/package.json is required to be an ES module
88
- File.write(File.join(dist_dir, "component", "package.json"), '{ "type": "module" }')
89
- end
90
- end
91
- sh wasi_sdk.wasm_opt,
92
- "--strip-debug",
93
- File.join(dist_dir, "ruby.wasm"),
94
- "-o",
95
- File.join(dist_dir, "ruby.wasm")
96
- sh wasi_sdk.wasm_opt,
97
- "--strip-debug",
98
- File.join(dist_dir, "ruby.debug+stdlib.wasm"),
99
- "-o",
100
- File.join(dist_dir, "ruby+stdlib.wasm")
101
- elsif pkg[:target] == "wasm32-unknown-emscripten"
102
- Dir.chdir(cwd || base_dir) do
103
- sh env, *build_command, "-o", "/dev/null"
104
- end
105
- end
140
+ build_ruby(pkg, base_dir, pkg_dir, wasi_sdk)
106
141
  end
107
142
 
108
143
  desc "Build npm package #{pkg[:name]}"
@@ -110,6 +145,11 @@ namespace :npm do
110
145
  sh tools, "npm run build", chdir: pkg_dir
111
146
  end
112
147
 
148
+ desc "Clean and build npm package #{pkg[:name]}"
149
+ task "clean-build" do
150
+ build_ruby(pkg, base_dir, pkg_dir, wasi_sdk, clean: true)
151
+ end
152
+
113
153
  desc "Check npm package #{pkg[:name]}"
114
154
  task "check" do
115
155
  sh "npm test", chdir: pkg_dir
data/rakelib/version.rake CHANGED
@@ -36,5 +36,23 @@ task :bump_version, %i[version] do |t, args|
36
36
  # Update ./package-lock.json
37
37
  sh "npm install"
38
38
  # Update Gemfile.lock
39
- sh "BUNDLE_GEMFILE=packages/npm-packages/ruby-wasm-wasi/Gemfile bundle install"
39
+ NPM_PACKAGES.each do |pkg|
40
+ next unless pkg[:gemfile]
41
+ vendor_gem_cache(pkg)
42
+ sh "BUNDLE_GEMFILE=#{pkg[:gemfile]} bundle install"
43
+ end
44
+ end
45
+
46
+ def bump_dev_version_rb(version_rb)
47
+ version_rb_content = File.read(version_rb)
48
+ version_rb_content.sub!(/VERSION = "(.+)"$/) do
49
+ dev_version = $1.end_with?(".dev") ? $1 : $1 + ".dev"
50
+ "VERSION = \"#{dev_version}\""
51
+ end
52
+ File.write(version_rb, version_rb_content)
53
+ end
54
+
55
+ task :bump_dev_version do
56
+ bump_dev_version_rb("lib/ruby_wasm/version.rb")
57
+ bump_dev_version_rb("packages/gems/js/lib/js/version.rb")
40
58
  end
data/sbom.spdx.json ADDED
@@ -0,0 +1,114 @@
1
+ {
2
+ "spdxVersion": "SPDX-2.3",
3
+ "dataLicense": "CC0-1.0",
4
+ "SPDXID": "SPDXRef-DOCUMENT",
5
+ "name": "ruby.wasm-spdx",
6
+ "documentNamespace": "http://spdx.org/spdxdocs/ruby.wasm-spdx-01906291-792d-7385-b800-45753122d052",
7
+ "creationInfo": {
8
+ "created": "2024-06-29T14:00:00Z",
9
+ "comment": "This document only covers software packages used by WebAssembly form of Ruby interpreters distributed by ruby.wasm project. It does not cover those used by the build system for now.",
10
+ "creators": [
11
+ "Person: Yuta Saito"
12
+ ]
13
+ },
14
+ "documentDescribes": [
15
+ "SPDXRef-Package-ruby.wasm"
16
+ ],
17
+ "packages": [
18
+ {
19
+ "SPDXID": "SPDXRef-Package-ruby.wasm",
20
+ "name": "ruby.wasm",
21
+ "filesAnalyzed": false,
22
+ "licenseDeclared": "MIT",
23
+ "licenseConcluded": "MIT",
24
+ "downloadLocation": "git+http://github.com/ruby/ruby.wasm.git",
25
+ "copyrightText": "Copyright (c) 2021 Yuta Saito"
26
+ },
27
+ {
28
+ "SPDXID": "SPDXRef-Package-ruby",
29
+ "name": "ruby",
30
+ "filesAnalyzed": false,
31
+ "licenseDeclared": "BSD-2-Clause OR Ruby",
32
+ "licenseConcluded": "Ruby",
33
+ "downloadLocation": "https://www.ruby-lang.org/en/",
34
+ "copyrightText": "Ruby is copyrighted free software by Yukihiro Matsumoto <matz@netlab.jp>."
35
+ },
36
+ {
37
+ "SPDXID": "SPDXRef-Package-libyaml",
38
+ "name": "libyaml",
39
+ "filesAnalyzed": false,
40
+ "licenseDeclared": "MIT",
41
+ "licenseConcluded": "MIT",
42
+ "downloadLocation": "git+https://github.com/yaml/libyaml.git",
43
+ "copyrightText": "Copyright (c) 2017-2020 Ingy döt Net\nCopyright (c) 2006-2016 Kirill Simonov"
44
+ },
45
+ {
46
+ "SPDXID": "SPDXRef-Package-zlib",
47
+ "name": "zlib",
48
+ "filesAnalyzed": false,
49
+ "downloadLocation": "git+https://github.com/madler/zlib.git",
50
+ "licenseConcluded": "Zlib",
51
+ "licenseDeclared": "Zlib",
52
+ "copyrightText": "Copyright (C) 1995-2017 Jean-loup Gailly and Mark Adler"
53
+ },
54
+ {
55
+ "SPDXID": "SPDXRef-Package-wasi-libc",
56
+ "name": "wasi-libc",
57
+ "filesAnalyzed": false,
58
+ "downloadLocation": "git+https://github.com/WebAssembly/wasi-libc.git",
59
+ "licenseConcluded": "Apache-2.0 WITH LLVM-exception OR Apache-2.0 OR MIT",
60
+ "licenseDeclared": "MIT",
61
+ "copyrightText": "NOASSERTION"
62
+ },
63
+ {
64
+ "SPDXID": "SPDXRef-Package-openssl",
65
+ "name": "openssl",
66
+ "filesAnalyzed": false,
67
+ "downloadLocation": "https://www.openssl.org",
68
+ "licenseConcluded": "Apache-2.0",
69
+ "licenseDeclared": "Apache-2.0",
70
+ "copyrightText": "Copyright 1995-2021 The OpenSSL Project Authors. All Rights Reserved."
71
+ },
72
+ {
73
+ "SPDXID": "SPDXRef-Package-wasi-vfs",
74
+ "name": "wasi-vfs",
75
+ "filesAnalyzed": false,
76
+ "downloadLocation": "git+https://github.com/kateinoigakukun/wasi-vfs.git",
77
+ "licenseConcluded": "Apache-2.0 WITH LLVM-exception",
78
+ "licenseDeclared": "Apache-2.0 WITH LLVM-exception",
79
+ "copyrightText": "NOASSERTION"
80
+ }
81
+ ],
82
+ "relationships": [
83
+ {
84
+ "spdxElementId": "SPDXRef-Package-ruby.wasm",
85
+ "relatedSpdxElement": "SPDXRef-Package-ruby",
86
+ "relationshipType": "DEPENDS_ON"
87
+ },
88
+ {
89
+ "spdxElementId": "SPDXRef-Package-ruby.wasm",
90
+ "relatedSpdxElement": "SPDXRef-Package-libyaml",
91
+ "relationshipType": "DEPENDS_ON"
92
+ },
93
+ {
94
+ "spdxElementId": "SPDXRef-Package-ruby.wasm",
95
+ "relatedSpdxElement": "SPDXRef-Package-zlib",
96
+ "relationshipType": "DEPENDS_ON"
97
+ },
98
+ {
99
+ "spdxElementId": "SPDXRef-Package-ruby.wasm",
100
+ "relatedSpdxElement": "SPDXRef-Package-wasi-libc",
101
+ "relationshipType": "DEPENDS_ON"
102
+ },
103
+ {
104
+ "spdxElementId": "SPDXRef-Package-ruby.wasm",
105
+ "relatedSpdxElement": "SPDXRef-Package-openssl",
106
+ "relationshipType": "DEPENDS_ON"
107
+ },
108
+ {
109
+ "spdxElementId": "SPDXRef-Package-ruby.wasm",
110
+ "relatedSpdxElement": "SPDXRef-Package-wasi-vfs",
111
+ "relationshipType": "DEPENDS_ON"
112
+ }
113
+ ]
114
+ }
@@ -33,6 +33,7 @@ module RubyWasm
33
33
  @source: BuildSource
34
34
 
35
35
  attr_reader toolchain: Toolchain
36
+ attr_reader baseruby: BaseRubyProduct
36
37
 
37
38
  def initialize: (
38
39
  string name,
@@ -218,6 +219,7 @@ module RubyWasm
218
219
  def extinit_c_erb: -> String
219
220
  def baseruby_path: -> String
220
221
  def configure_args: (String build_triple, Toolchain toolchain) -> Array[String]
222
+ def rbconfig_rb: -> String?
221
223
  end
222
224
 
223
225
  class WitBindgen
@@ -33,4 +33,12 @@ module RubyWasmExt
33
33
  def import_name_map: (Hash[String, String] map) -> void
34
34
  def encode: () -> bytes
35
35
  end
36
+
37
+ class WasiVirt
38
+ def initialize: () -> void
39
+ def allow_all: () -> void
40
+ def map_dir: (String guest_path, String host_path) -> void
41
+ def finish: () -> bytes
42
+ def compose: (bytes component_bytes) -> bytes
43
+ end
36
44
  end
@@ -46,7 +46,7 @@ class RubyWasm::Packager
46
46
 
47
47
  def root: () -> string
48
48
 
49
- ALL_DEFAULT_EXTS: string
49
+ ALL_DEFAULT_EXTS: String
50
50
 
51
51
  def build_options: () -> Hash[Symbol, untyped]
52
52
  def full_build_options: () -> Hash[Symbol, untyped]
@@ -77,6 +77,7 @@ class RubyWasm::Packager
77
77
  def build_gem_exts: (RubyWasm::BuildExecutor, string gem_home) -> void
78
78
  def link_gem_exts: (RubyWasm::BuildExecutor, string ruby_root, string gem_home, bytes module_bytes) -> bytes
79
79
  def wasi_exec_model: () -> String
80
+ def with_unbundled_env: () { () -> void } -> void
80
81
  end
81
82
 
82
83
  class DynamicLinking < RubyWasm::Packager::Core::BuildStrategy
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_wasm
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.6.1
4
+ version: 2.7.0
5
5
  platform: x64-mingw-ucrt
6
6
  authors:
7
7
  - Yuta Saito
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-05-22 00:00:00.000000000 Z
11
+ date: 2024-11-11 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Ruby to WebAssembly toolkit. This gem takes Ruby code and Gemfile, and
14
14
  packages them with Ruby runtime into a WebAssembly binary.
@@ -74,6 +74,7 @@ files:
74
74
  - rakelib/gem.rake
75
75
  - rakelib/packaging.rake
76
76
  - rakelib/version.rake
77
+ - sbom.spdx.json
77
78
  - sig/open_uri.rbs
78
79
  - sig/ruby_wasm/build.rbs
79
80
  - sig/ruby_wasm/cli.rbs
@@ -81,9 +82,6 @@ files:
81
82
  - sig/ruby_wasm/feature_set.rbs
82
83
  - sig/ruby_wasm/packager.rbs
83
84
  - sig/ruby_wasm/util.rbs
84
- - tools/clang-format-diff.sh
85
- - tools/exe/rbminify
86
- - tools/lib/syntax_tree/minify_ruby.rb
87
85
  homepage: https://github.com/ruby/ruby.wasm
88
86
  licenses:
89
87
  - MIT
@@ -1,18 +0,0 @@
1
- #!/bin/bash
2
-
3
- set -eo pipefail
4
-
5
- if [ -n "$1" ]; then
6
- BASE_BRANCH="$1"
7
- elif [ -n "$GITHUB_EVENT_BEFORE" ] && [ "push" = "$GITHUB_EVENT_NAME" ]; then
8
- BASE_BRANCH="$GITHUB_EVENT_BEFORE"
9
- elif [ -n "$GITHUB_BASE_REF" ]; then
10
- BASE_BRANCH="origin/$GITHUB_BASE_REF"
11
- else
12
- BASE_BRANCH="@{upstream}"
13
- fi
14
-
15
- MERGE_BASE=$(git merge-base $BASE_BRANCH HEAD)
16
-
17
- git diff -U0 --no-color $MERGE_BASE -- '*.c' '*.h' | clang-format-diff -i -p1
18
- exit $?
data/tools/exe/rbminify DELETED
@@ -1,12 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- $LOAD_PATH << File.join(File.dirname(__FILE__), "../lib")
4
-
5
- require "syntax_tree"
6
- require "syntax_tree/cli"
7
- require "syntax_tree/minify_ruby"
8
-
9
- # Override the default formatter with our own.
10
- SyntaxTree.register_handler(".rb", SyntaxTree::MinifyRuby)
11
-
12
- exit(SyntaxTree::CLI.run(ARGV))
@@ -1,63 +0,0 @@
1
- require "syntax_tree"
2
-
3
- module SyntaxTree
4
- module MinifyRuby
5
-
6
- # This is a required API for syntax tree which just delegates to SyntaxTree.parse.
7
- def self.parse(source)
8
- ::SyntaxTree.parse(source)
9
- end
10
-
11
- # This is the main entrypoint for the formatter. It parses the source,
12
- # builds a formatter, then prints the result.
13
- def self.format(source, _maxwidth = nil)
14
- formatter = Formatter.new(source)
15
- program = parse(source)
16
- CommentStrippingVisitor.new.visit(program)
17
- program.format(formatter)
18
-
19
- formatter.flush
20
- formatter.output.join
21
- end
22
-
23
- # This is a required API for syntax tree which just delegates to SyntaxTree.read.
24
- def self.read(filepath)
25
- ::SyntaxTree.read(filepath)
26
- end
27
-
28
- class CommentStrippingVisitor < SyntaxTree::Visitor
29
- def visit(node)
30
- if node and node.comments.any?
31
- node.comments.clear
32
- end
33
- super(node)
34
- end
35
-
36
- def visit_statements(node)
37
- node.body.delete_if { _1.is_a?(SyntaxTree::Comment) }
38
- super(node)
39
- end
40
- end
41
-
42
- class Formatter < SyntaxTree::Formatter
43
- def initialize(source)
44
- super(source, [], Float::INFINITY) do |n|
45
- # This block, called `genspace`, is used to generate indentation for `n` depth.
46
- ""
47
- end
48
- end
49
-
50
- def breakable(
51
- separator = " ",
52
- _width = separator.length,
53
- indent: nil,
54
- force: nil
55
- )
56
- # Don't break when already broken
57
- return if target.last.is_a?(PrettierPrint::BreakParent)
58
- return if not force and separator == ""
59
- super(separator, _width, indent: indent, force: force)
60
- end
61
- end
62
- end
63
- end