From 8d8f0bd0b4e1cd53a275be8e98740803656aea1c Mon Sep 17 00:00:00 2001 From: Stan Lo Date: Fri, 10 Jan 2025 17:39:27 +0000 Subject: [PATCH] WIP --- .github/workflows/ci.yml | 3 - WORKSPACE | 2 - third_party/externals.bzl | 5 +- third_party/prism.BUILD | 55 +------------------ third_party/ruby_root.bzl | 20 ------- .../scripts/verify_prism_regression_tests.sh | 2 +- 6 files changed, 5 insertions(+), 82 deletions(-) delete mode 100644 third_party/ruby_root.bzl diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e04bf201e0e..b40721b9b63 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,9 +5,6 @@ on: branches: [prism] pull_request: branches: [prism] -env: - RUBY_ROOT: '/opt/hostedtoolcache/Ruby/3.3.0/x64' - jobs: tests: runs-on: ubuntu-latest diff --git a/WORKSPACE b/WORKSPACE index 1dd284d7600..f6fde1468d9 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -2,10 +2,8 @@ workspace(name = "com_stripe_ruby_typer") load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") load("//third_party:externals.bzl", "register_sorbet_dependencies") -load("//third_party:ruby_root.bzl", "ruby_root") register_sorbet_dependencies() -ruby_root(name = "ruby_root") load("@rules_foreign_cc//foreign_cc:repositories.bzl", "rules_foreign_cc_dependencies") diff --git a/third_party/externals.bzl b/third_party/externals.bzl index 92f99c6c0a5..956c313ce98 100644 --- a/third_party/externals.bzl +++ b/third_party/externals.bzl @@ -12,9 +12,8 @@ def register_sorbet_dependencies(): http_archive( name = "prism", - url = "https://github.com/ruby/prism/archive/v1.2.0.zip", - sha256 = "f398cdb0ed9e5f9b8f7127a8c180ed6a8a611ad4612dcdae8a91ebfc5ee0ed7c", - strip_prefix = "prism-1.2.0", + url = "https://github.com/Shopify/sorbet/releases/download/test-release-artifacts/prism-release-artifacts-new.tar.gz", + sha256 = "58d93c7fd7dc5fa5a3adc4df4ea714a8982e720c10abce5f5e1d561860a3ba7f", build_file = "@com_stripe_ruby_typer//third_party:prism.BUILD", ) diff --git a/third_party/prism.BUILD b/third_party/prism.BUILD index 82e22273ae3..f213a730524 100644 --- a/third_party/prism.BUILD +++ b/third_party/prism.BUILD @@ -1,58 +1,7 @@ -load("@ruby_root//:ruby_root.bzl", "RUBY_ROOT") # Get the RUBY_ROOT environment variable - -GENERATED_SRCS = [ - "src/diagnostic.c", - "src/node.c", - "src/prettyprint.c", - "src/serialize.c", - "src/token_type.c", -] - -GENERATED_HDRS = [ - "include/prism/ast.h", - "include/prism/diagnostic.h", -] - -genrule( - name = "generate_templates", - srcs = [ - "templates/template.rb", - "prism.gemspec", - "Gemfile", - "Gemfile.lock", - "config.yml", # Contains the data to populate the ERB templates. - ] + \ - ["templates/{c_file}.erb".format(c_file = c_file) for c_file in GENERATED_SRCS] + \ - ["templates/{h_file}.erb".format(h_file = h_file) for h_file in GENERATED_HDRS], - outs = GENERATED_HDRS + GENERATED_SRCS, - cmd = """ - # set -o xtrace # Uncomment this to debug the execution of this script. - # echo "PWD: $$PWD" - # echo "RULEDIR: $(RULEDIR)" - - export PATH="{ruby_root}/bin:$$PATH" - - gemfile="$(location Gemfile)" - script="$(location templates/template.rb)" - - bundle install --gemfile="$$gemfile" - - {template_render_commands} - - """.format( - ruby_root = RUBY_ROOT, - template_render_commands = "\n ".join([ - """ - bundle exec --gemfile="$$gemfile" ruby "$$script" {f} "$(location {f})" - """.format(f=f) for f in (GENERATED_SRCS + GENERATED_HDRS) - ]) - ), -) - cc_library( name = "prism", - srcs = glob(["src/**/*.c"], exclude=GENERATED_SRCS) + [":generate_templates"], - hdrs = glob(["include/**/*.h"], exclude=GENERATED_HDRS) + [":generate_templates"], + srcs = glob(["src/**/*.c"]), + hdrs = glob(["include/**/*.h"]), visibility = ["//visibility:public"], includes = ["include"], copts = ["-Wno-implicit-fallthrough"], diff --git a/third_party/ruby_root.bzl b/third_party/ruby_root.bzl deleted file mode 100644 index f6bfc66fbd1..00000000000 --- a/third_party/ruby_root.bzl +++ /dev/null @@ -1,20 +0,0 @@ -# This rule is used to get the RUBY_ROOT environment variable from the -# user's local environment and make it available to the build system. -def _ruby_root_impl(repository_ctx): - # Retrieve the RUBY_ROOT environment variable - ruby_root = repository_ctx.os.environ.get("RUBY_ROOT") - - if not ruby_root: - fail("RUBY_ROOT environment variable is not set.") - - # Create a file to store the RUBY_ROOT value - content = 'RUBY_ROOT = "{}"\n'.format(ruby_root) - repository_ctx.file("ruby_root.bzl", content=content) - - # Create an empty BUILD file to make the directory a valid Bazel repository - repository_ctx.file("BUILD", content="") - -ruby_root = repository_rule( - implementation = _ruby_root_impl, - attrs = {}, -) diff --git a/tools/scripts/verify_prism_regression_tests.sh b/tools/scripts/verify_prism_regression_tests.sh index fdf0db41730..b85b82a1c92 100755 --- a/tools/scripts/verify_prism_regression_tests.sh +++ b/tools/scripts/verify_prism_regression_tests.sh @@ -2,7 +2,7 @@ set -euo pipefail echo "Building Sorbet..." -./bazel build //main:sorbet --config=dbg --define RUBY_PATH=$RUBY_ROOT +./bazel build //main:sorbet --config=dbg echo "Verifying parse trees..."