Skip to content

Commit 8600b06

Browse files
committed
Rename librubyparser to libprism
librubyparser was an artifact of the prototype that was initially named ruby-parser. Instead, this renames it to libprism to be consistent with the actual name.
1 parent 2dc5320 commit 8600b06

File tree

10 files changed

+53
-52
lines changed

10 files changed

+53
-52
lines changed

Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ STATIC_OBJECTS := $(subst src/,build/static/,$(SOURCES:.c=.o))
2222

2323
all: shared static
2424

25-
shared: build/librubyparser.$(SOEXT)
26-
static: build/librubyparser.a
25+
shared: build/libprism.$(SOEXT)
26+
static: build/libprism.a
2727
wasm: javascript/src/prism.wasm
2828

29-
build/librubyparser.$(SOEXT): $(SHARED_OBJECTS)
29+
build/libprism.$(SOEXT): $(SHARED_OBJECTS)
3030
$(ECHO) "linking $@"
3131
$(Q) $(CC) $(DEBUG_FLAGS) $(CFLAGS) -shared -o $@ $(SHARED_OBJECTS)
3232

33-
build/librubyparser.a: $(STATIC_OBJECTS)
33+
build/libprism.a: $(STATIC_OBJECTS)
3434
$(ECHO) "building $@"
3535
$(Q) $(AR) $(ARFLAGS) $@ $(STATIC_OBJECTS) $(Q1:0=>/dev/null)
3636

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ This is a parser for the Ruby programming language. It is designed to be portabl
77

88
## Overview
99

10-
The repository contains the infrastructure for both a shared library (librubyparser) and a native CRuby extension. The shared library has no bindings to CRuby itself, and so can be used by other projects. The native CRuby extension links against `ruby.h`, and so is suitable in the context of CRuby.
10+
The repository contains the infrastructure for both a shared library (libprism) and a native CRuby extension. The shared library has no bindings to CRuby itself, and so can be used by other projects. The native CRuby extension links against `ruby.h`, and so is suitable in the context of CRuby.
1111

1212
```
1313
.
@@ -21,7 +21,7 @@ The repository contains the infrastructure for both a shared library (librubypar
2121
├── ext
2222
│   └── prism
2323
│   ├── extconf.rb configuration to generate the Makefile for the native extension
24-
│   └── extension.c the native extension that interacts with librubyparser
24+
│   └── extension.c the native extension that interacts with libprism
2525
├── fuzz files related to fuzz testing
2626
├── include
2727
│   ├── prism header files for the shared library

docs/build_system.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ The main solution for the second point seems a Makefile, otherwise many of the u
1616
## General Design
1717

1818
1. Templates are generated by `templates/template.rb`
19-
4. The `Makefile` compiles both `librubyparser.a` and `librubyparser.{so,dylib,dll}` from the `src/**/*.c` and `include/**/*.h` files
19+
4. The `Makefile` compiles both `libprism.a` and `libprism.{so,dylib,dll}` from the `src/**/*.c` and `include/**/*.h` files
2020
5. The `Rakefile` `:compile` task ensures the above prerequisites are done, then calls `make`,
21-
and uses `Rake::ExtensionTask` to compile the C extension (using its `extconf.rb`), which uses `librubyparser.a`
21+
and uses `Rake::ExtensionTask` to compile the C extension (using its `extconf.rb`), which uses `libprism.a`
2222

2323
This way there is minimal duplication, and each layer builds on the previous one and has its own responsibilities.
2424

2525
The static library exports no symbols, to avoid any conflict.
26-
The shared library exports some symbols, and this is fine since there should only be one librubyparser shared library
26+
The shared library exports some symbols, and this is fine since there should only be one libprism shared library
2727
loaded per process (i.e., at most one version of the prism *gem* loaded in a process, only the gem uses the shared library).
2828

2929
## The various ways to build prism
@@ -36,11 +36,11 @@ loaded per process (i.e., at most one version of the prism *gem* loaded in a pro
3636

3737
The gem contains the pre-generated templates.
3838
When installing the gem, `extconf.rb` is used and that:
39-
* runs `make build/librubyparser.a`
39+
* runs `make build/libprism.a`
4040
* compiles the C extension with mkmf
4141

4242
When installing the gem on JRuby and TruffleRuby, no C extension is built, so instead of the last step,
43-
there is Ruby code using FFI which uses `librubyparser.{so,dylib,dll}`
43+
there is Ruby code using FFI which uses `libprism.{so,dylib,dll}`
4444
to implement the same methods as the C extension, but using serialization instead of many native calls/accesses
4545
(JRuby does not support C extensions, serialization is faster on TruffleRuby than the C extension).
4646

@@ -67,7 +67,7 @@ The script generates the templates when importing.
6767
Then when `mx build` builds TruffleRuby and the `prism` mx project inside, it runs `make`.
6868

6969
Then the `prism bindings` mx project is built, which contains the [bindings](https://github.com/oracle/truffleruby/blob/master/src/main/c/prism_bindings/src/prism_bindings.c)
70-
and links to `librubyparser.a` (to avoid exporting symbols, so no conflict when installing the prism gem).
70+
and links to `libprism.a` (to avoid exporting symbols, so no conflict when installing the prism gem).
7171

7272
### Building prism as part of JRuby
7373

ext/prism/extconf.rb

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,25 @@ module ExtConf
77
class << self
88
def configure
99
unless RUBY_ENGINE == "ruby"
10-
# On non-CRuby we only need the shared library, so build only that and not the C extension.
11-
# We also avoid `require "mkmf"` as that prepends the LLVM toolchain to PATH on TruffleRuby,
12-
# but we want to use the native toolchain here since librubyparser is run natively.
13-
build_shared_rubyparser
10+
# On non-CRuby we only need the shared library, so build only that and
11+
# not the C extension. We also avoid `require "mkmf"` as that prepends
12+
# the LLVM toolchain to PATH on TruffleRuby, but we want to use the
13+
# native toolchain here since libprism is run natively.
14+
build_shared_prism
1415
File.write("Makefile", "all install clean:\n\t@#{RbConfig::CONFIG["NULLCMD"]}\n")
1516
return
1617
end
1718

1819
require "mkmf"
1920
configure_c_extension
20-
configure_rubyparser
21+
configure_libprism
2122

2223
create_makefile("prism/prism")
2324

2425
if static_link?
2526
File.open('Makefile', 'a') do |mf|
2627
mf.puts
27-
mf.puts '# Automatically rebuild the extension if librubyparser.a changed'
28+
mf.puts '# Automatically rebuild the extension if libprism.a changed'
2829
mf.puts '$(TARGET_SO): $(LOCAL_LIBS)'
2930
end
3031
end
@@ -35,19 +36,19 @@ def configure_c_extension
3536
append_cflags("-fvisibility=hidden")
3637
end
3738

38-
def configure_rubyparser
39+
def configure_libprism
3940
if static_link?
40-
static_archive_path = File.join(build_dir, "librubyparser.a")
41+
static_archive_path = File.join(build_dir, "libprism.a")
4142
unless File.exist?(static_archive_path)
42-
build_static_rubyparser
43+
build_static_prism
4344
end
4445
$LOCAL_LIBS << " #{static_archive_path}"
4546
else
46-
shared_library_path = File.join(build_dir, "librubyparser.#{RbConfig::CONFIG["SOEXT"]}")
47+
shared_library_path = File.join(build_dir, "libprism.#{RbConfig::CONFIG["SOEXT"]}")
4748
unless File.exist?(shared_library_path)
48-
build_shared_rubyparser
49+
build_shared_prism
4950
end
50-
unless find_library("rubyparser", "pm_parser_init", build_dir)
51+
unless find_library("prism", "pm_parser_init", build_dir)
5152
raise "could not link against #{File.basename(shared_library_path)}"
5253
end
5354
end
@@ -60,15 +61,15 @@ def configure_rubyparser
6061
find_header("prism/extension.h", File.join(__dir__, "..")) or raise "prism/extension.h is required"
6162
end
6263

63-
def build_shared_rubyparser
64-
build_target_rubyparser "build/librubyparser.#{RbConfig::CONFIG["SOEXT"]}"
64+
def build_shared_prism
65+
build_target_prism "build/libprism.#{RbConfig::CONFIG["SOEXT"]}"
6566
end
6667

67-
def build_static_rubyparser
68-
build_target_rubyparser "build/librubyparser.a"
68+
def build_static_prism
69+
build_target_prism "build/libprism.a"
6970
end
7071

71-
def build_target_rubyparser(target)
72+
def build_target_prism(target)
7273
Dir.chdir(root_dir) do
7374
if !File.exist?("include/prism/ast.h") && Dir.exist?(".git")
7475
# this block only exists to support building the gem from a "git" source,
@@ -99,7 +100,7 @@ def print_help
99100
100101
--enable-static
101102
--disable-static
102-
Enable or disable static linking against librubyparser.
103+
Enable or disable static linking against libprism.
103104
The default is to statically link.
104105
105106
--enable-debug-mode-build

ext/prism/extension.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#include "prism/extension.h"
22

33
// NOTE: this file should contain only bindings. All non-trivial logic should be
4-
// in librubyparser so it can be shared its the various callers.
4+
// in libprism so it can be shared its the various callers.
55

66
VALUE rb_cPrism;
77
VALUE rb_cPrismNode;

lib/prism/ffi.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ module LibRubyParser # :nodoc:
1414

1515
# Define the library that we will be pulling functions from. Note that this
1616
# must align with the build shared library from make/rake.
17-
ffi_lib File.expand_path("../../build/librubyparser.#{RbConfig::CONFIG["SOEXT"]}", __dir__)
17+
ffi_lib File.expand_path("../../build/libprism.#{RbConfig::CONFIG["SOEXT"]}", __dir__)
1818

1919
# Convert a native C type declaration into a symbol that FFI understands.
2020
# For example:

rust/prism-sys/build/main.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ fn main() {
1010
let ruby_build_path = prism_lib_path();
1111
let ruby_include_path = prism_include_path();
1212

13-
// Tell cargo/rustc that we want to link against `librubyparser.a`.
14-
println!("cargo:rustc-link-lib=static=rubyparser");
13+
// Tell cargo/rustc that we want to link against `libprism.a`.
14+
println!("cargo:rustc-link-lib=static=prism");
1515

16-
// Add `[root]/build/` to the search paths, so it can find `librubyparser.a`.
16+
// Add `[root]/build/` to the search paths, so it can find `libprism.a`.
1717
println!("cargo:rustc-link-search=native={}", ruby_build_path.to_str().unwrap());
1818

1919
// This is where the magic happens.
@@ -23,7 +23,7 @@ fn main() {
2323
write_bindings(&bindings);
2424
}
2525

26-
/// Gets the path to project files (`librubyparser*`) at `[root]/build/`.
26+
/// Gets the path to project files (`libprism*`) at `[root]/build/`.
2727
///
2828
fn prism_lib_path() -> PathBuf {
2929
if let Ok(lib_dir) = std::env::var("PRISM_LIB_DIR") {

rust/prism-sys/build/vendored.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ pub fn build() -> Result<(), Box<dyn std::error::Error>> {
6262

6363
build.files(source_files(src_dir()));
6464
build.out_dir(&out_dir);
65-
build.try_compile("rubyparser")?;
65+
build.try_compile("prism")?;
6666

6767
std::env::set_var("PRISM_INCLUDE_DIR", include_dir());
6868
std::env::set_var("PRISM_LIB_DIR", out_dir);

rust/prism-sys/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
#[allow(non_upper_case_globals)]
2828
mod bindings {
2929
// In `build.rs`, we use `bindgen` to generate bindings based on C headers
30-
// and `librubyparser`. Here is where we pull in those bindings and make
30+
// and `libprism`. Here is where we pull in those bindings and make
3131
// them part of our library.
3232
include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
3333
}

test/prism/library_symbols_test.rb

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ class LibrarySymbolsTest < TestCase
1313
def setup
1414
super
1515

16-
@librubyparser_a = File.expand_path("../../build/librubyparser.a", __dir__)
17-
@librubyparser_so = File.expand_path("../../build/librubyparser.so", __dir__)
16+
@libprism_a = File.expand_path("../../build/libprism.a", __dir__)
17+
@libprism_so = File.expand_path("../../build/libprism.so", __dir__)
1818
@prism_so = File.expand_path("../../lib/prism/prism.so", __dir__)
1919
end
2020

@@ -56,34 +56,34 @@ def names(symbol_lines)
5656
end
5757

5858
#
59-
# static archive - librubyparser.a
59+
# static archive - libprism.a
6060
#
61-
def test_librubyparser_a_contains_nothing_globally_visible
62-
omit("librubyparser.a is not built") unless File.exist?(@librubyparser_a)
61+
def test_libprism_a_contains_nothing_globally_visible
62+
omit("libprism.a is not built") unless File.exist?(@libprism_a)
6363

64-
assert_empty(names(visible_global_objdump_symbols(@librubyparser_a)))
64+
assert_empty(names(visible_global_objdump_symbols(@libprism_a)))
6565
end
6666

67-
def test_librubyparser_a_contains_hidden_pm_symbols
68-
omit("librubyparser.a is not built") unless File.exist?(@librubyparser_a)
67+
def test_libprism_a_contains_hidden_pm_symbols
68+
omit("libprism.a is not built") unless File.exist?(@libprism_a)
6969

70-
names(hidden_global_objdump_symbols(@librubyparser_a)).tap do |symbols|
70+
names(hidden_global_objdump_symbols(@libprism_a)).tap do |symbols|
7171
assert_includes(symbols, "pm_parse")
7272
assert_includes(symbols, "pm_version")
7373
end
7474
end
7575

7676
#
77-
# shared object - librubyparser.so
77+
# shared object - libprism.so
7878
#
79-
def test_librubyparser_so_exports_only_the_necessary_functions
80-
omit("librubyparser.so is not built") unless File.exist?(@librubyparser_so)
79+
def test_libprism_so_exports_only_the_necessary_functions
80+
omit("libprism.so is not built") unless File.exist?(@libprism_so)
8181

82-
names(global_nm_symbols(@librubyparser_so)).tap do |symbols|
82+
names(global_nm_symbols(@libprism_so)).tap do |symbols|
8383
assert_includes(symbols, "pm_parse")
8484
assert_includes(symbols, "pm_version")
8585
end
86-
names(local_nm_symbols(@librubyparser_so)).tap do |symbols|
86+
names(local_nm_symbols(@libprism_so)).tap do |symbols|
8787
assert_includes(symbols, "pm_encoding_shift_jis_isupper_char")
8888
end
8989
# TODO: someone who uses this library needs to finish this test

0 commit comments

Comments
 (0)