Skip to content

Commit

Permalink
Made libyaml into a submodule and now builds from that.
Browse files Browse the repository at this point in the history
Also attempts to fix the Github-specific CI configuration for this
rgem.
  • Loading branch information
suetanvil committed May 10, 2021
1 parent 0606652 commit 64930c7
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 9 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ name: ubuntu
on: [push, pull_request]
jobs:
gcc:
env:
# 'set-env' has been disabled by default because it's a
# potential security issue. See https://github.blog/changelog/2020-10-01-github-actions-deprecating-set-env-and-add-path-commands/.
# We re-enable it here for now because the problem does not
# appear to affect us.
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
runs-on: ubuntu-latest
steps:
- name: Install libraries
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "third_party/libyaml"]
path = third_party/libyaml
url = https://github.com/yaml/libyaml.git
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ else
end
```

### Getting libyaml

If you have a compiled version of `libyaml` available on your system, you can use it by setting the environment variable `MRUBY_YAML_USE_SYSTEM_LIBRARY` to a non-empty value and ensuring your compiler can find the library.

Otherwise, Rake will attempt to compile it from sources obtained from the offical `libyaml` GitHub repository. This requires that you have `autoconf` installed.


### Documentation

#### `YAML.load(yaml_str)`
Expand Down
22 changes: 13 additions & 9 deletions mrbgem.rake
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,22 @@ MRuby::Gem::Specification.new('mruby-yaml') do |spec|
use_system_library = ENV.fetch('MRUBY_YAML_USE_SYSTEM_LIBRARY', '') != ''

unless use_system_library
yaml_version = "0.2.2"
yaml_dir = "#{build_dir}/yaml-#{yaml_version}"
yaml_base_dir = "libyaml"
yaml_dir = File.join(build_dir, yaml_base_dir)

FileUtils.mkdir_p build_dir

if ! File.exists? yaml_dir
Dir.chdir(build_dir) do
e = {}
tar_zxf = (RUBY_PLATFORM.match(/solaris/) ? 'gzip -d | tar xf -' : 'tar zxf -')
run_command e, "curl -L https://pyyaml.org/download/libyaml/yaml-#{yaml_version}.tar.gz | #{tar_zxf}"
run_command e, "mkdir #{yaml_dir}/build"
end
# We build libyaml in the gem's build directory, which means
# copying the sources from the repo.
if ! File.exists? "#{yaml_dir}"

# But first, we generate the configure script. This requires GNU
# autoconf to be installed.
Dir.chdir(File.join(spec.dir, 'third_party', yaml_base_dir)) {
run_command({}, "./bootstrap")
}

FileUtils.cp_r File.join(spec.dir, 'third_party', yaml_base_dir), build_dir
end

if ! File.exists? "#{yaml_dir}/build/lib/libyaml.a"
Expand Down
1 change: 1 addition & 0 deletions third_party/libyaml
Submodule libyaml added at 690a78

0 comments on commit 64930c7

Please sign in to comment.