Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Directories in configure_args #7076

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jan 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,14 @@ jobs:
run: |
echo "MAKEFLAGS=-j$((1 + $(sysctl -n hw.activecpu)))" >> $GITHUB_ENV
echo "PATH="/usr/local/opt/bison/bin:$PATH"" >> $GITHUB_ENV
for lib in [email protected] readline; do
CONFIGURE_ARGS="${CONFIGURE_ARGS:+$CONFIGURE_ARGS }--with-${lib%@*}-dir=$(brew --prefix $lib)"
done
echo CONFIGURE_ARGS="${CONFIGURE_ARGS}" >> $GITHUB_ENV
- run: ./autogen.sh
working-directory: src
- name: Run configure
run: ../src/configure -C --disable-install-doc --with-openssl-dir=$(brew --prefix [email protected]) --with-readline-dir=$(brew --prefix readline)
run: ../src/configure -C --disable-install-doc
- run: make incs
- run: make prepare-gems
if: ${{ matrix.test_task == 'test-bundled-gems' }}
Expand Down
41 changes: 19 additions & 22 deletions doc/contributing/building_ruby.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,59 +20,56 @@
* libexecinfo (FreeBSD)
* rustc - 1.58.0 or later (if you wish to build [YJIT](/doc/yjit/yjit.md))

If you installed the libraries needed for extensions (openssl, readline, libyaml, zlib) into other than the OS default place,
typically using Homebrew on macOS, add `--with-EXTLIB-dir` options to `CONFIGURE_ARGS` environment variable.

``` shell
export CONFIGURE_ARGS=""
for ext in openssl readline libyaml zlib; do
CONFIGURE_ARGS="${CONFIGURE_ARGS} --with-$ext-dir=$(brew --prefix $ext)"
done
```

3. Checkout the CRuby source code:

```
``` shell
git clone https://github.com/ruby/ruby.git
```

4. Generate the configure file:

```
``` shell
./autogen.sh
```

5. Create a `build` directory outside of the source directory:

```
``` shell
mkdir build && cd build
```

While it's not necessary to build in a separate directory, it's good practice to do so.

6. We'll install Ruby in `~/.rubies/ruby-master`, so create the directory:

```
``` shell
mkdir ~/.rubies
```

7. Run configure:

```
``` shell
../configure --prefix="${HOME}/.rubies/ruby-master"
```

- If you are frequently building Ruby, add the `--disable-install-doc` flag to not build documentation which will speed up the build process.

8. Build Ruby:

```
``` shell
make install
```

- If you're on macOS and installed \OpenSSL through Homebrew, you may encounter failure to build \OpenSSL that look like this:

```
openssl:
Could not be configured. It will not be installed.
ruby/ext/openssl/extconf.rb: OpenSSL library could not be found. You might want to use --with-openssl-dir=<dir> option to specify the prefix where OpenSSL is installed.
Check ext/openssl/mkmf.log for more details.
```

Adding `--with-openssl-dir=$(brew --prefix openssl)` to the list of options passed to configure may solve the issue.

Remember to delete your `build` directory and start again from the configure step.

9. [Run tests](testing_ruby.md) to confirm your build succeeded.

### Unexplainable Build Errors
Expand All @@ -89,7 +86,7 @@ about Ruby's build to help out.
In GNU make and BSD make implementations, to run a specific make script in parallel, pass the flag `-j<number of processes>`. For instance,
to run tests on 8 processes, use:

```
``` shell
make test-all -j8
```

Expand Down Expand Up @@ -117,7 +114,7 @@ Miniruby is a version of Ruby which has no external dependencies and lacks certa
It can be useful in Ruby development because it allows for faster build times. Miniruby is
built before Ruby. A functional Miniruby is required to build Ruby. To build Miniruby:

```
``` shell
make miniruby
```

Expand Down Expand Up @@ -151,7 +148,7 @@ On Linux it is important to specify `-O0` when debugging. This is especially tru

You need to be able to use gcc (gcov) and lcov visualizer.

```
``` shell
./autogen.sh
./configure --enable-gcov
make
Expand Down
22 changes: 6 additions & 16 deletions lib/mkmf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,26 +89,16 @@ module MakeMakefile

unless defined? $configure_args
$configure_args = {}
args = CONFIG["configure_args"]
if ENV["CONFIGURE_ARGS"]
args << " " << ENV["CONFIGURE_ARGS"]
args = CONFIG["configure_args"].shellsplit
if arg = ENV["CONFIGURE_ARGS"]
args.push(*arg.shellsplit)
end
for arg in Shellwords::shellwords(args)
args.delete_if {|a| /\A--(?:top(?:src)?|src|cur)dir(?=\z|=)/ =~ a}
for arg in args.concat(ARGV)
arg, val = arg.split('=', 2)
next unless arg
arg.tr!('_', '-')
if arg.sub!(/^(?!--)/, '--')
val or next
arg.downcase!
end
next if /^--(?:top|topsrc|src|cur)dir$/ =~ arg
$configure_args[arg] = val || true
end
for arg in ARGV
arg, val = arg.split('=', 2)
next unless arg
arg.tr!('_', '-')
if arg.sub!(/^(?!--)/, '--')
if arg.sub!(/\A(?!--)/, '--')
val or next
arg.downcase!
end
Expand Down