ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:81199] [Ruby trunk Feature#13570] Using mkmf for ruby/spec C API specs
       [not found] <redmine.issue-13570.20170516124746@ruby-lang.org>
@ 2017-05-16 12:47 ` eregontp
  2017-05-16 21:11 ` [ruby-core:81200] " Greg.mpls
                   ` (19 subsequent siblings)
  20 siblings, 0 replies; 21+ messages in thread
From: eregontp @ 2017-05-16 12:47 UTC (permalink / raw)
  To: ruby-core

Issue #13570 has been reported by Eregon (Benoit Daloze).

----------------------------------------
Feature #13570: Using mkmf for ruby/spec C API specs
https://bugs.ruby-lang.org/issues/13570

* Author: Eregon (Benoit Daloze)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
Hello all,

I am thinking to use mkmf to compile the C API specs.

https://github.com/ruby/ruby/blob/trunk/spec/rubyspec/optional/capi/spec_helper.rb
is getting pretty complex and hard to maintain.

I have a few questions:
* Does mkmf works well on Windows?
* What is a good way to compile a single .c file with mkmf to a given library file in another directory?

I tried this but I am not sure it's correct:

~~~ ruby
def compile_extension(name)
  objdir = object_path
  ext = "#{name}_spec"
  lib = "#{objdir}/#{ext}.#{RbConfig::CONFIG['DLEXT']}"

  require 'mkmf' # TODO: probably best to use a subprocess to avoid polluting the namespace
  Dir.chdir(objdir) do
    $srcs = ["#{extension_path}/#{ext}.c"]
    $objs = ["#{extension_path}/#{ext}.o"] # should probably be in objdir but that does not seem to work
    create_makefile(ext)
    system "make"
  end

  lib
end
~~~

Alternatively, we can copy the needed files to a temporary directory, build there and copy the shared library back.
It's a bit more work but not a big deal either.



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [ruby-core:81200] [Ruby trunk Feature#13570] Using mkmf for ruby/spec C API specs
       [not found] <redmine.issue-13570.20170516124746@ruby-lang.org>
  2017-05-16 12:47 ` [ruby-core:81199] [Ruby trunk Feature#13570] Using mkmf for ruby/spec C API specs eregontp
@ 2017-05-16 21:11 ` Greg.mpls
  2017-05-28 11:38 ` [ruby-core:81434] [Ruby trunk Feature#13570][Closed] " eregontp
                   ` (18 subsequent siblings)
  20 siblings, 0 replies; 21+ messages in thread
From: Greg.mpls @ 2017-05-16 21:11 UTC (permalink / raw)
  To: ruby-core

Issue #13570 has been updated by MSP-Greg (Greg L).


> Does mkmf works well on Windows?

I'm not a c type.  With MinGW builds, I've got 89 mkmf.log files in the build dir, and [test-all results](https://msp-greg.github.io/file.mingw_test-all.html) are consistent and reasonable low.  I'm guessing that means yes.

FYI, I ran test-spec with -j on 58760, and it matched (or very closely matched) results without -j.  test-all has the same results, but assertions and skips are different.

----------------------------------------
Feature #13570: Using mkmf for ruby/spec C API specs
https://bugs.ruby-lang.org/issues/13570#change-64855

* Author: Eregon (Benoit Daloze)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
Hello all,

I am thinking to use mkmf to compile the C API specs.

https://github.com/ruby/ruby/blob/trunk/spec/rubyspec/optional/capi/spec_helper.rb
is getting pretty complex and hard to maintain.

I have a few questions:
* Does mkmf works well on Windows?
* What is a good way to compile a single .c file with mkmf to a given library file in another directory?

I tried this but I am not sure it's correct:

~~~ ruby
def compile_extension(name)
  objdir = object_path
  ext = "#{name}_spec"
  lib = "#{objdir}/#{ext}.#{RbConfig::CONFIG['DLEXT']}"

  require 'mkmf' # TODO: probably best to use a subprocess to avoid polluting the namespace
  Dir.chdir(objdir) do
    $srcs = ["#{extension_path}/#{ext}.c"]
    $objs = ["#{extension_path}/#{ext}.o"] # should probably be in objdir but that does not seem to work
    create_makefile(ext)
    system "make"
  end

  lib
end
~~~

Alternatively, we can copy the needed files to a temporary directory, build there and copy the shared library back.
It's a bit more work but not a big deal either.



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [ruby-core:81434] [Ruby trunk Feature#13570][Closed] Using mkmf for ruby/spec C API specs
       [not found] <redmine.issue-13570.20170516124746@ruby-lang.org>
  2017-05-16 12:47 ` [ruby-core:81199] [Ruby trunk Feature#13570] Using mkmf for ruby/spec C API specs eregontp
  2017-05-16 21:11 ` [ruby-core:81200] " Greg.mpls
@ 2017-05-28 11:38 ` eregontp
  2017-05-29 15:33 ` [ruby-core:81455] [Ruby trunk Feature#13570] " eregontp
                   ` (17 subsequent siblings)
  20 siblings, 0 replies; 21+ messages in thread
From: eregontp @ 2017-05-28 11:38 UTC (permalink / raw)
  To: ruby-core

Issue #13570 has been updated by Eregon (Benoit Daloze).

Status changed from Open to Closed

I made the change in https://github.com/ruby/spec/commit/84ea66ef61424ef87d03658cbc140d4b1af17c22
which was imported in r58939.

----------------------------------------
Feature #13570: Using mkmf for ruby/spec C API specs
https://bugs.ruby-lang.org/issues/13570#change-65139

* Author: Eregon (Benoit Daloze)
* Status: Closed
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
Hello all,

I am thinking to use mkmf to compile the C API specs.

https://github.com/ruby/ruby/blob/trunk/spec/rubyspec/optional/capi/spec_helper.rb
is getting pretty complex and hard to maintain.

I have a few questions:
* Does mkmf works well on Windows?
* What is a good way to compile a single .c file with mkmf to a given library file in another directory?

I tried this but I am not sure it's correct:

~~~ ruby
def compile_extension(name)
  objdir = object_path
  ext = "#{name}_spec"
  lib = "#{objdir}/#{ext}.#{RbConfig::CONFIG['DLEXT']}"

  require 'mkmf' # TODO: probably best to use a subprocess to avoid polluting the namespace
  Dir.chdir(objdir) do
    $srcs = ["#{extension_path}/#{ext}.c"]
    $objs = ["#{extension_path}/#{ext}.o"] # should probably be in objdir but that does not seem to work
    create_makefile(ext)
    system "make"
  end

  lib
end
~~~

Alternatively, we can copy the needed files to a temporary directory, build there and copy the shared library back.
It's a bit more work but not a big deal either.



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [ruby-core:81455] [Ruby trunk Feature#13570] Using mkmf for ruby/spec C API specs
       [not found] <redmine.issue-13570.20170516124746@ruby-lang.org>
                   ` (2 preceding siblings ...)
  2017-05-28 11:38 ` [ruby-core:81434] [Ruby trunk Feature#13570][Closed] " eregontp
@ 2017-05-29 15:33 ` eregontp
  2017-05-29 15:33 ` [ruby-core:81456] [Ruby trunk Feature#13570][Assigned] " eregontp
                   ` (16 subsequent siblings)
  20 siblings, 0 replies; 21+ messages in thread
From: eregontp @ 2017-05-29 15:33 UTC (permalink / raw)
  To: ruby-core

Issue #13570 has been updated by Eregon (Benoit Daloze).

File spec_helper.rb added

I attach here the current version of the spec_helper.rb doing the compilation of extensions.
It seems to now work correctly for out-of-source builds,
and with an extra hack uses the right ruby in the Makefile
(RbConfig.ruby in ./rbconfig.rb is just incorrect for built but not installed ruby).

I found very confusing the effect that $extmf can have,
I wished MRI used a simpler mechanism to detect if ruby was installed or not.
Is it so important nowadays to be able to test without "make install"?

Could I ask some help for making this run correctly on Windows?
I would like if possible something not too hacky.
The old way to compile extensions was un-maintainable due to its complexity.

----------------------------------------
Feature #13570: Using mkmf for ruby/spec C API specs
https://bugs.ruby-lang.org/issues/13570#change-65157

* Author: Eregon (Benoit Daloze)
* Status: Closed
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
Hello all,

I am thinking to use mkmf to compile the C API specs.

https://github.com/ruby/ruby/blob/trunk/spec/rubyspec/optional/capi/spec_helper.rb
is getting pretty complex and hard to maintain.

I have a few questions:
* Does mkmf works well on Windows?
* What is a good way to compile a single .c file with mkmf to a given library file in another directory?

I tried this but I am not sure it's correct:

~~~ ruby
def compile_extension(name)
  objdir = object_path
  ext = "#{name}_spec"
  lib = "#{objdir}/#{ext}.#{RbConfig::CONFIG['DLEXT']}"

  require 'mkmf' # TODO: probably best to use a subprocess to avoid polluting the namespace
  Dir.chdir(objdir) do
    $srcs = ["#{extension_path}/#{ext}.c"]
    $objs = ["#{extension_path}/#{ext}.o"] # should probably be in objdir but that does not seem to work
    create_makefile(ext)
    system "make"
  end

  lib
end
~~~

Alternatively, we can copy the needed files to a temporary directory, build there and copy the shared library back.
It's a bit more work but not a big deal either.

---Files--------------------------------
spec_helper.rb (2.22 KB)


-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [ruby-core:81456] [Ruby trunk Feature#13570][Assigned] Using mkmf for ruby/spec C API specs
       [not found] <redmine.issue-13570.20170516124746@ruby-lang.org>
                   ` (3 preceding siblings ...)
  2017-05-29 15:33 ` [ruby-core:81455] [Ruby trunk Feature#13570] " eregontp
@ 2017-05-29 15:33 ` eregontp
  2017-05-29 16:39 ` [ruby-core:81458] [Ruby trunk Feature#13570] " Greg.mpls
                   ` (15 subsequent siblings)
  20 siblings, 0 replies; 21+ messages in thread
From: eregontp @ 2017-05-29 15:33 UTC (permalink / raw)
  To: ruby-core

Issue #13570 has been updated by Eregon (Benoit Daloze).

Status changed from Closed to Assigned
Assignee set to cruby-windows

----------------------------------------
Feature #13570: Using mkmf for ruby/spec C API specs
https://bugs.ruby-lang.org/issues/13570#change-65158

* Author: Eregon (Benoit Daloze)
* Status: Assigned
* Priority: Normal
* Assignee: cruby-windows
* Target version: 
----------------------------------------
Hello all,

I am thinking to use mkmf to compile the C API specs.

https://github.com/ruby/ruby/blob/trunk/spec/rubyspec/optional/capi/spec_helper.rb
is getting pretty complex and hard to maintain.

I have a few questions:
* Does mkmf works well on Windows?
* What is a good way to compile a single .c file with mkmf to a given library file in another directory?

I tried this but I am not sure it's correct:

~~~ ruby
def compile_extension(name)
  objdir = object_path
  ext = "#{name}_spec"
  lib = "#{objdir}/#{ext}.#{RbConfig::CONFIG['DLEXT']}"

  require 'mkmf' # TODO: probably best to use a subprocess to avoid polluting the namespace
  Dir.chdir(objdir) do
    $srcs = ["#{extension_path}/#{ext}.c"]
    $objs = ["#{extension_path}/#{ext}.o"] # should probably be in objdir but that does not seem to work
    create_makefile(ext)
    system "make"
  end

  lib
end
~~~

Alternatively, we can copy the needed files to a temporary directory, build there and copy the shared library back.
It's a bit more work but not a big deal either.

---Files--------------------------------
spec_helper.rb (2.22 KB)


-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [ruby-core:81458] [Ruby trunk Feature#13570] Using mkmf for ruby/spec C API specs
       [not found] <redmine.issue-13570.20170516124746@ruby-lang.org>
                   ` (4 preceding siblings ...)
  2017-05-29 15:33 ` [ruby-core:81456] [Ruby trunk Feature#13570][Assigned] " eregontp
@ 2017-05-29 16:39 ` Greg.mpls
  2017-05-31 22:25 ` [ruby-core:81490] " Greg.mpls
                   ` (14 subsequent siblings)
  20 siblings, 0 replies; 21+ messages in thread
From: Greg.mpls @ 2017-05-29 16:39 UTC (permalink / raw)
  To: ruby-core

Issue #13570 has been updated by MSP-Greg (Greg L).


Benoit,

Sorry, never set this to 'watch'.  I'll try a build with MinGW.

FWIW, I just got one of the spec c files to compile with only the following --

```ruby
require 'mkmf'
Dir.chdir('src/build-x86_64/spec/rubyspec/optional/capi/temp') { |d|
  append_ldflags('-L /e/GitHub/ruby-loco/src/build-x86_64')
  create_makefile("bignum_spec")
  puts `make`
  require_relative 'src/build-x86_64/spec/rubyspec/optional/capi/temp/bignum_spec.so'
  puts CApiBignumSpecs.instance_methods(false)
}
```

Output:

```
E:\GitHub\ruby-loco>ruby make_test.rb
checking for whether -L /e/GitHub/ruby-loco/src/build-x86_64 is accepted as LDFLAGS... yes
creating Makefile
generating bignum_spec-x64-mingw32.def
compiling bignum_spec.c
linking shared-object bignum_spec.so

rb_big_pack_array
rb_big_pack_length
rb_big2dbl
rb_dbl2big
rb_big2ll
rb_big2long
rb_big2str
rb_big2ulong
rb_big_cmp
rb_big_pack
```

For the test, I only copied `bignum_spec.c` to the temp folder, along with `rubyspec.h`.  I'm sure there's a setting to pick that up in `mkmf.rb`, along with several more that I'm probably missing.  Again, I'm not a c type...

----------------------------------------
Feature #13570: Using mkmf for ruby/spec C API specs
https://bugs.ruby-lang.org/issues/13570#change-65161

* Author: Eregon (Benoit Daloze)
* Status: Assigned
* Priority: Normal
* Assignee: cruby-windows
* Target version: 
----------------------------------------
Hello all,

I am thinking to use mkmf to compile the C API specs.

https://github.com/ruby/ruby/blob/trunk/spec/rubyspec/optional/capi/spec_helper.rb
is getting pretty complex and hard to maintain.

I have a few questions:
* Does mkmf works well on Windows?
* What is a good way to compile a single .c file with mkmf to a given library file in another directory?

I tried this but I am not sure it's correct:

~~~ ruby
def compile_extension(name)
  objdir = object_path
  ext = "#{name}_spec"
  lib = "#{objdir}/#{ext}.#{RbConfig::CONFIG['DLEXT']}"

  require 'mkmf' # TODO: probably best to use a subprocess to avoid polluting the namespace
  Dir.chdir(objdir) do
    $srcs = ["#{extension_path}/#{ext}.c"]
    $objs = ["#{extension_path}/#{ext}.o"] # should probably be in objdir but that does not seem to work
    create_makefile(ext)
    system "make"
  end

  lib
end
~~~

Alternatively, we can copy the needed files to a temporary directory, build there and copy the shared library back.
It's a bit more work but not a big deal either.

---Files--------------------------------
spec_helper.rb (2.22 KB)


-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [ruby-core:81490] [Ruby trunk Feature#13570] Using mkmf for ruby/spec C API specs
       [not found] <redmine.issue-13570.20170516124746@ruby-lang.org>
                   ` (5 preceding siblings ...)
  2017-05-29 16:39 ` [ruby-core:81458] [Ruby trunk Feature#13570] " Greg.mpls
@ 2017-05-31 22:25 ` Greg.mpls
  2017-06-01 16:21 ` [ruby-core:81510] " eregontp
                   ` (13 subsequent siblings)
  20 siblings, 0 replies; 21+ messages in thread
From: Greg.mpls @ 2017-05-31 22:25 UTC (permalink / raw)
  To: ruby-core

Issue #13570 has been updated by MSP-Greg (Greg L).


Benoit,

After screwing around with quite a bit of make code, I found the (simple) issue. The code in [Object.cp](https://github.com/ruby/ruby/blob/trunk/spec/mspec/lib/mspec/helpers/fs.rb#L3-L11) does not properly copy binary files on Windows.

Hence, since we know the `src` and `dest` are on the same partition/drive, I used `File.rename` in `spec_helper.rb`.  Below is a diff/patch file:

```diff
--- spec_helper_orig.rb	Mon May 29 13:34:22 2017
+++ spec_helper.rb	Wed May 31 15:47:17 2017
@@ -18,11 +18,7 @@
 
 def compile_extension(name)
   debug = false
-  run_mkmf_in_process = false
-
-  if RUBY_NAME == 'truffleruby'
-    run_mkmf_in_process = true
-  end
+  run_mkmf_in_process = RUBY_NAME == 'truffleruby'
 
   ext = "#{name}_spec"
   lib = "#{object_path}/#{ext}.#{RbConfig::CONFIG['DLEXT']}"
@@ -61,7 +57,7 @@
       raise "make failed:\n#{output}" unless $?.success?
       $stderr.puts output if debug
 
-      cp File.basename(lib), lib
+      File.rename File.basename(lib), lib
     end
   ensure
     rm_r tmpdir unless debug

```

Tests run with `-j` both via `make test-spec` and running `mspec`.  Results of both are at [Ruby MinGW Test Results](https://msp-greg.github.io/file.mingw_test-all.html#test-spec-Failure-Error-Summary).

Thanks for the work.

----------------------------------------
Feature #13570: Using mkmf for ruby/spec C API specs
https://bugs.ruby-lang.org/issues/13570#change-65198

* Author: Eregon (Benoit Daloze)
* Status: Assigned
* Priority: Normal
* Assignee: cruby-windows
* Target version: 
----------------------------------------
Hello all,

I am thinking to use mkmf to compile the C API specs.

https://github.com/ruby/ruby/blob/trunk/spec/rubyspec/optional/capi/spec_helper.rb
is getting pretty complex and hard to maintain.

I have a few questions:
* Does mkmf works well on Windows?
* What is a good way to compile a single .c file with mkmf to a given library file in another directory?

I tried this but I am not sure it's correct:

~~~ ruby
def compile_extension(name)
  objdir = object_path
  ext = "#{name}_spec"
  lib = "#{objdir}/#{ext}.#{RbConfig::CONFIG['DLEXT']}"

  require 'mkmf' # TODO: probably best to use a subprocess to avoid polluting the namespace
  Dir.chdir(objdir) do
    $srcs = ["#{extension_path}/#{ext}.c"]
    $objs = ["#{extension_path}/#{ext}.o"] # should probably be in objdir but that does not seem to work
    create_makefile(ext)
    system "make"
  end

  lib
end
~~~

Alternatively, we can copy the needed files to a temporary directory, build there and copy the shared library back.
It's a bit more work but not a big deal either.

---Files--------------------------------
spec_helper.rb (2.22 KB)


-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [ruby-core:81510] [Ruby trunk Feature#13570] Using mkmf for ruby/spec C API specs
       [not found] <redmine.issue-13570.20170516124746@ruby-lang.org>
                   ` (6 preceding siblings ...)
  2017-05-31 22:25 ` [ruby-core:81490] " Greg.mpls
@ 2017-06-01 16:21 ` eregontp
  2017-06-01 16:44 ` [ruby-core:81511] " Greg.mpls
                   ` (12 subsequent siblings)
  20 siblings, 0 replies; 21+ messages in thread
From: eregontp @ 2017-06-01 16:21 UTC (permalink / raw)
  To: ruby-core

Issue #13570 has been updated by Eregon (Benoit Daloze).


MSP-Greg (Greg L) wrote:
> Benoit,
> 
> After screwing around with quite a bit of make code, I found the (simple) issue. The code in [Object.cp](https://github.com/ruby/ruby/blob/trunk/spec/mspec/lib/mspec/helpers/fs.rb#L3-L11) does not properly copy binary files on Windows.

Oh, wow, thanks and nice find!
MSpec's #cp should use "rb"/"wb" modes obviously.
Would it work with that?

> Hence, since we know the `src` and `dest` are on the same partition/drive, I used `File.rename` in `spec_helper.rb`.  Below is a diff/patch file:

I am not sure that's always the case, but thanks for the patch, I will try it.

> Tests run with `-j` both via `make test-spec` and running `mspec`.  Results of both are at [Ruby MinGW Test Results](https://msp-greg.github.io/file.mingw_test-all.html#test-spec-Failure-Error-Summary).

Great!

----------------------------------------
Feature #13570: Using mkmf for ruby/spec C API specs
https://bugs.ruby-lang.org/issues/13570#change-65217

* Author: Eregon (Benoit Daloze)
* Status: Assigned
* Priority: Normal
* Assignee: cruby-windows
* Target version: 
----------------------------------------
Hello all,

I am thinking to use mkmf to compile the C API specs.

https://github.com/ruby/ruby/blob/trunk/spec/rubyspec/optional/capi/spec_helper.rb
is getting pretty complex and hard to maintain.

I have a few questions:
* Does mkmf works well on Windows?
* What is a good way to compile a single .c file with mkmf to a given library file in another directory?

I tried this but I am not sure it's correct:

~~~ ruby
def compile_extension(name)
  objdir = object_path
  ext = "#{name}_spec"
  lib = "#{objdir}/#{ext}.#{RbConfig::CONFIG['DLEXT']}"

  require 'mkmf' # TODO: probably best to use a subprocess to avoid polluting the namespace
  Dir.chdir(objdir) do
    $srcs = ["#{extension_path}/#{ext}.c"]
    $objs = ["#{extension_path}/#{ext}.o"] # should probably be in objdir but that does not seem to work
    create_makefile(ext)
    system "make"
  end

  lib
end
~~~

Alternatively, we can copy the needed files to a temporary directory, build there and copy the shared library back.
It's a bit more work but not a big deal either.

---Files--------------------------------
spec_helper.rb (2.22 KB)


-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [ruby-core:81511] [Ruby trunk Feature#13570] Using mkmf for ruby/spec C API specs
       [not found] <redmine.issue-13570.20170516124746@ruby-lang.org>
                   ` (7 preceding siblings ...)
  2017-06-01 16:21 ` [ruby-core:81510] " eregontp
@ 2017-06-01 16:44 ` Greg.mpls
  2017-06-01 19:08 ` [ruby-core:81513] " eregontp
                   ` (11 subsequent siblings)
  20 siblings, 0 replies; 21+ messages in thread
From: Greg.mpls @ 2017-06-01 16:44 UTC (permalink / raw)
  To: ruby-core

Issue #13570 has been updated by MSP-Greg (Greg L).


I checked on MinGW, and there is not an issue with `File.rename` with `src` and `dest` being on different drives.  Where I got that from, I don't know...

Hence, on MinGW/Windows, rename will work in all situations.

> MSpec's #cp should use "rb"/"wb" modes obviously.
Would it work with that?

Yes and haven't tried.  Seems odd to copy a file when a rename will do...

----------------------------------------
Feature #13570: Using mkmf for ruby/spec C API specs
https://bugs.ruby-lang.org/issues/13570#change-65218

* Author: Eregon (Benoit Daloze)
* Status: Assigned
* Priority: Normal
* Assignee: cruby-windows
* Target version: 
----------------------------------------
Hello all,

I am thinking to use mkmf to compile the C API specs.

https://github.com/ruby/ruby/blob/trunk/spec/rubyspec/optional/capi/spec_helper.rb
is getting pretty complex and hard to maintain.

I have a few questions:
* Does mkmf works well on Windows?
* What is a good way to compile a single .c file with mkmf to a given library file in another directory?

I tried this but I am not sure it's correct:

~~~ ruby
def compile_extension(name)
  objdir = object_path
  ext = "#{name}_spec"
  lib = "#{objdir}/#{ext}.#{RbConfig::CONFIG['DLEXT']}"

  require 'mkmf' # TODO: probably best to use a subprocess to avoid polluting the namespace
  Dir.chdir(objdir) do
    $srcs = ["#{extension_path}/#{ext}.c"]
    $objs = ["#{extension_path}/#{ext}.o"] # should probably be in objdir but that does not seem to work
    create_makefile(ext)
    system "make"
  end

  lib
end
~~~

Alternatively, we can copy the needed files to a temporary directory, build there and copy the shared library back.
It's a bit more work but not a big deal either.

---Files--------------------------------
spec_helper.rb (2.22 KB)


-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [ruby-core:81513] [Ruby trunk Feature#13570] Using mkmf for ruby/spec C API specs
       [not found] <redmine.issue-13570.20170516124746@ruby-lang.org>
                   ` (8 preceding siblings ...)
  2017-06-01 16:44 ` [ruby-core:81511] " Greg.mpls
@ 2017-06-01 19:08 ` eregontp
  2017-06-02  2:00 ` [ruby-core:81517] " nobu
                   ` (10 subsequent siblings)
  20 siblings, 0 replies; 21+ messages in thread
From: eregontp @ 2017-06-01 19:08 UTC (permalink / raw)
  To: ruby-core

Issue #13570 has been updated by Eregon (Benoit Daloze).


MSP-Greg (Greg L) wrote:
> I checked on MinGW, and there is not an issue with `File.rename` with `src` and `dest` being on different drives.  Where I got that from, I don't know...

It's the semantics of the rename(2) syscall on Linux, which throws EXDEV if oldpath and newpath are not on the same mounted filesystem. 

And indeed, on Linux:

    > File.write "foo","abc"
    > File.rename "foo", "/tmp/bla"
    Errno::EXDEV: Invalid cross-device link @ rb_file_s_rename - (foo, /tmp/bla)

So we would need some special handling to move files across filesystems on non-Windows, or use FileUtils.mv

> > MSpec's #cp should use "rb"/"wb" modes obviously.
> Would it work with that?
> 
> Yes and haven't tried.  Seems odd to copy a file when a rename will do...

Indeed, moving sounds nicer in principle.
The reason I like the copy is to help debugging, the .so is still in tmpdir used for compilation along other files.
But it's a small thing, looking for the moved file is fine as well.

----------------------------------------
Feature #13570: Using mkmf for ruby/spec C API specs
https://bugs.ruby-lang.org/issues/13570#change-65220

* Author: Eregon (Benoit Daloze)
* Status: Assigned
* Priority: Normal
* Assignee: cruby-windows
* Target version: 
----------------------------------------
Hello all,

I am thinking to use mkmf to compile the C API specs.

https://github.com/ruby/ruby/blob/trunk/spec/rubyspec/optional/capi/spec_helper.rb
is getting pretty complex and hard to maintain.

I have a few questions:
* Does mkmf works well on Windows?
* What is a good way to compile a single .c file with mkmf to a given library file in another directory?

I tried this but I am not sure it's correct:

~~~ ruby
def compile_extension(name)
  objdir = object_path
  ext = "#{name}_spec"
  lib = "#{objdir}/#{ext}.#{RbConfig::CONFIG['DLEXT']}"

  require 'mkmf' # TODO: probably best to use a subprocess to avoid polluting the namespace
  Dir.chdir(objdir) do
    $srcs = ["#{extension_path}/#{ext}.c"]
    $objs = ["#{extension_path}/#{ext}.o"] # should probably be in objdir but that does not seem to work
    create_makefile(ext)
    system "make"
  end

  lib
end
~~~

Alternatively, we can copy the needed files to a temporary directory, build there and copy the shared library back.
It's a bit more work but not a big deal either.

---Files--------------------------------
spec_helper.rb (2.22 KB)


-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [ruby-core:81517] [Ruby trunk Feature#13570] Using mkmf for ruby/spec C API specs
       [not found] <redmine.issue-13570.20170516124746@ruby-lang.org>
                   ` (9 preceding siblings ...)
  2017-06-01 19:08 ` [ruby-core:81513] " eregontp
@ 2017-06-02  2:00 ` nobu
  2017-06-02  9:09 ` [ruby-core:81520] " eregontp
                   ` (9 subsequent siblings)
  20 siblings, 0 replies; 21+ messages in thread
From: nobu @ 2017-06-02  2:00 UTC (permalink / raw)
  To: ruby-core

Issue #13570 has been updated by nobu (Nobuyoshi Nakada).


Eregon (Benoit Daloze) wrote:
> MSpec's #cp should use "rb"/"wb" modes obviously.

Why not `IO.copy_stream`?


----------------------------------------
Feature #13570: Using mkmf for ruby/spec C API specs
https://bugs.ruby-lang.org/issues/13570#change-65224

* Author: Eregon (Benoit Daloze)
* Status: Assigned
* Priority: Normal
* Assignee: cruby-windows
* Target version: 
----------------------------------------
Hello all,

I am thinking to use mkmf to compile the C API specs.

https://github.com/ruby/ruby/blob/trunk/spec/rubyspec/optional/capi/spec_helper.rb
is getting pretty complex and hard to maintain.

I have a few questions:
* Does mkmf works well on Windows?
* What is a good way to compile a single .c file with mkmf to a given library file in another directory?

I tried this but I am not sure it's correct:

~~~ ruby
def compile_extension(name)
  objdir = object_path
  ext = "#{name}_spec"
  lib = "#{objdir}/#{ext}.#{RbConfig::CONFIG['DLEXT']}"

  require 'mkmf' # TODO: probably best to use a subprocess to avoid polluting the namespace
  Dir.chdir(objdir) do
    $srcs = ["#{extension_path}/#{ext}.c"]
    $objs = ["#{extension_path}/#{ext}.o"] # should probably be in objdir but that does not seem to work
    create_makefile(ext)
    system "make"
  end

  lib
end
~~~

Alternatively, we can copy the needed files to a temporary directory, build there and copy the shared library back.
It's a bit more work but not a big deal either.

---Files--------------------------------
spec_helper.rb (2.22 KB)


-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [ruby-core:81520] [Ruby trunk Feature#13570] Using mkmf for ruby/spec C API specs
       [not found] <redmine.issue-13570.20170516124746@ruby-lang.org>
                   ` (10 preceding siblings ...)
  2017-06-02  2:00 ` [ruby-core:81517] " nobu
@ 2017-06-02  9:09 ` eregontp
  2017-06-02  9:15 ` [ruby-core:81521] " eregontp
                   ` (8 subsequent siblings)
  20 siblings, 0 replies; 21+ messages in thread
From: eregontp @ 2017-06-02  9:09 UTC (permalink / raw)
  To: ruby-core

Issue #13570 has been updated by Eregon (Benoit Daloze).


Sounds good, I did not know IO.copy_stream can be used with 2 path Strings as well. It's a bit of a strange name for "cp".
But I think I slightly prefer the current implementation, it uses only well-known basic functionality such as File.open+read/write.
I would guess early Ruby implementations don't implement IO.copy_stream.

----------------------------------------
Feature #13570: Using mkmf for ruby/spec C API specs
https://bugs.ruby-lang.org/issues/13570#change-65227

* Author: Eregon (Benoit Daloze)
* Status: Assigned
* Priority: Normal
* Assignee: cruby-windows
* Target version: 
----------------------------------------
Hello all,

I am thinking to use mkmf to compile the C API specs.

https://github.com/ruby/ruby/blob/trunk/spec/rubyspec/optional/capi/spec_helper.rb
is getting pretty complex and hard to maintain.

I have a few questions:
* Does mkmf works well on Windows?
* What is a good way to compile a single .c file with mkmf to a given library file in another directory?

I tried this but I am not sure it's correct:

~~~ ruby
def compile_extension(name)
  objdir = object_path
  ext = "#{name}_spec"
  lib = "#{objdir}/#{ext}.#{RbConfig::CONFIG['DLEXT']}"

  require 'mkmf' # TODO: probably best to use a subprocess to avoid polluting the namespace
  Dir.chdir(objdir) do
    $srcs = ["#{extension_path}/#{ext}.c"]
    $objs = ["#{extension_path}/#{ext}.o"] # should probably be in objdir but that does not seem to work
    create_makefile(ext)
    system "make"
  end

  lib
end
~~~

Alternatively, we can copy the needed files to a temporary directory, build there and copy the shared library back.
It's a bit more work but not a big deal either.

---Files--------------------------------
spec_helper.rb (2.22 KB)


-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [ruby-core:81521] [Ruby trunk Feature#13570] Using mkmf for ruby/spec C API specs
       [not found] <redmine.issue-13570.20170516124746@ruby-lang.org>
                   ` (11 preceding siblings ...)
  2017-06-02  9:09 ` [ruby-core:81520] " eregontp
@ 2017-06-02  9:15 ` eregontp
  2017-06-02 13:16 ` [ruby-core:81524] " Greg.mpls
                   ` (7 subsequent siblings)
  20 siblings, 0 replies; 21+ messages in thread
From: eregontp @ 2017-06-02  9:15 UTC (permalink / raw)
  To: ruby-core

Issue #13570 has been updated by Eregon (Benoit Daloze).

File spec_helper.rb added

Here is a version of the spec_helper.rb working on MRI 2.2 to trunk on Linux (and I would expect macOS as well).

@Greg and @nobu:
Could you test it on Windows?

Then should I commit it?
Or do we have a way to test CI (Travis + rubyci.org) before committing?

----------------------------------------
Feature #13570: Using mkmf for ruby/spec C API specs
https://bugs.ruby-lang.org/issues/13570#change-65228

* Author: Eregon (Benoit Daloze)
* Status: Assigned
* Priority: Normal
* Assignee: cruby-windows
* Target version: 
----------------------------------------
Hello all,

I am thinking to use mkmf to compile the C API specs.

https://github.com/ruby/ruby/blob/trunk/spec/rubyspec/optional/capi/spec_helper.rb
is getting pretty complex and hard to maintain.

I have a few questions:
* Does mkmf works well on Windows?
* What is a good way to compile a single .c file with mkmf to a given library file in another directory?

I tried this but I am not sure it's correct:

~~~ ruby
def compile_extension(name)
  objdir = object_path
  ext = "#{name}_spec"
  lib = "#{objdir}/#{ext}.#{RbConfig::CONFIG['DLEXT']}"

  require 'mkmf' # TODO: probably best to use a subprocess to avoid polluting the namespace
  Dir.chdir(objdir) do
    $srcs = ["#{extension_path}/#{ext}.c"]
    $objs = ["#{extension_path}/#{ext}.o"] # should probably be in objdir but that does not seem to work
    create_makefile(ext)
    system "make"
  end

  lib
end
~~~

Alternatively, we can copy the needed files to a temporary directory, build there and copy the shared library back.
It's a bit more work but not a big deal either.

---Files--------------------------------
spec_helper.rb (2.22 KB)
spec_helper.rb (2.24 KB)


-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [ruby-core:81524] [Ruby trunk Feature#13570] Using mkmf for ruby/spec C API specs
       [not found] <redmine.issue-13570.20170516124746@ruby-lang.org>
                   ` (12 preceding siblings ...)
  2017-06-02  9:15 ` [ruby-core:81521] " eregontp
@ 2017-06-02 13:16 ` Greg.mpls
  2017-06-02 14:33 ` [ruby-core:81527] " Greg.mpls
                   ` (6 subsequent siblings)
  20 siblings, 0 replies; 21+ messages in thread
From: Greg.mpls @ 2017-06-02 13:16 UTC (permalink / raw)
  To: ruby-core

Issue #13570 has been updated by MSP-Greg (Greg L).


I'll try a MinGW build shortly.

Re `IO.copy_stream`, I believe it has existed since [Ruby 1.9.3](http://ruby-doc.org/core-1.9.3/IO.html#method-c-copy_stream), which should be far enough back for current test code.  Also, I've only paid attention to the files copied for capi, but all are small enough that I'd prefer one function call to the call in fs.rb that creates two blocks in ruby, then loops (in ruby) 300+ times for the copy.

I patched both fs.rb and spec_helper.rb with `IO.copy_stream`, and both ran successfully.

I'll start the build.

----------------------------------------
Feature #13570: Using mkmf for ruby/spec C API specs
https://bugs.ruby-lang.org/issues/13570#change-65231

* Author: Eregon (Benoit Daloze)
* Status: Assigned
* Priority: Normal
* Assignee: cruby-windows
* Target version: 
----------------------------------------
Hello all,

I am thinking to use mkmf to compile the C API specs.

https://github.com/ruby/ruby/blob/trunk/spec/rubyspec/optional/capi/spec_helper.rb
is getting pretty complex and hard to maintain.

I have a few questions:
* Does mkmf works well on Windows?
* What is a good way to compile a single .c file with mkmf to a given library file in another directory?

I tried this but I am not sure it's correct:

~~~ ruby
def compile_extension(name)
  objdir = object_path
  ext = "#{name}_spec"
  lib = "#{objdir}/#{ext}.#{RbConfig::CONFIG['DLEXT']}"

  require 'mkmf' # TODO: probably best to use a subprocess to avoid polluting the namespace
  Dir.chdir(objdir) do
    $srcs = ["#{extension_path}/#{ext}.c"]
    $objs = ["#{extension_path}/#{ext}.o"] # should probably be in objdir but that does not seem to work
    create_makefile(ext)
    system "make"
  end

  lib
end
~~~

Alternatively, we can copy the needed files to a temporary directory, build there and copy the shared library back.
It's a bit more work but not a big deal either.

---Files--------------------------------
spec_helper.rb (2.22 KB)
spec_helper.rb (2.24 KB)


-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [ruby-core:81527] [Ruby trunk Feature#13570] Using mkmf for ruby/spec C API specs
       [not found] <redmine.issue-13570.20170516124746@ruby-lang.org>
                   ` (13 preceding siblings ...)
  2017-06-02 13:16 ` [ruby-core:81524] " Greg.mpls
@ 2017-06-02 14:33 ` Greg.mpls
  2017-06-02 19:26 ` [ruby-core:81538] " Greg.mpls
                   ` (5 subsequent siblings)
  20 siblings, 0 replies; 21+ messages in thread
From: Greg.mpls @ 2017-06-02 14:33 UTC (permalink / raw)
  To: ruby-core

Issue #13570 has been updated by MSP-Greg (Greg L).


Ran a MinGW build on `ruby 2.5.0dev 2017-06-02 58998`.  Ran tests three ways:

1. `make test-spec` - pkg/install bin folder in path
2. `make test-spec` - pkg/install bin folder not in path
3. `mspec` - pkg/install bin folder in path

All three ran with expected results.  Although I'd prefer that `IO.copy_stream` be used, neither `fs.rb` or `spec_helper.rb` were patched to use it.

Hence, good job and thanks...

----------------------------------------
Feature #13570: Using mkmf for ruby/spec C API specs
https://bugs.ruby-lang.org/issues/13570#change-65233

* Author: Eregon (Benoit Daloze)
* Status: Assigned
* Priority: Normal
* Assignee: cruby-windows
* Target version: 
----------------------------------------
Hello all,

I am thinking to use mkmf to compile the C API specs.

https://github.com/ruby/ruby/blob/trunk/spec/rubyspec/optional/capi/spec_helper.rb
is getting pretty complex and hard to maintain.

I have a few questions:
* Does mkmf works well on Windows?
* What is a good way to compile a single .c file with mkmf to a given library file in another directory?

I tried this but I am not sure it's correct:

~~~ ruby
def compile_extension(name)
  objdir = object_path
  ext = "#{name}_spec"
  lib = "#{objdir}/#{ext}.#{RbConfig::CONFIG['DLEXT']}"

  require 'mkmf' # TODO: probably best to use a subprocess to avoid polluting the namespace
  Dir.chdir(objdir) do
    $srcs = ["#{extension_path}/#{ext}.c"]
    $objs = ["#{extension_path}/#{ext}.o"] # should probably be in objdir but that does not seem to work
    create_makefile(ext)
    system "make"
  end

  lib
end
~~~

Alternatively, we can copy the needed files to a temporary directory, build there and copy the shared library back.
It's a bit more work but not a big deal either.

---Files--------------------------------
spec_helper.rb (2.22 KB)
spec_helper.rb (2.24 KB)


-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [ruby-core:81538] [Ruby trunk Feature#13570] Using mkmf for ruby/spec C API specs
       [not found] <redmine.issue-13570.20170516124746@ruby-lang.org>
                   ` (14 preceding siblings ...)
  2017-06-02 14:33 ` [ruby-core:81527] " Greg.mpls
@ 2017-06-02 19:26 ` Greg.mpls
  2017-06-05  6:13 ` [ruby-core:81575] " usa
                   ` (4 subsequent siblings)
  20 siblings, 0 replies; 21+ messages in thread
From: Greg.mpls @ 2017-06-02 19:26 UTC (permalink / raw)
  To: ruby-core

Issue #13570 has been updated by MSP-Greg (Greg L).


Eregon (Benoit Daloze) wrote:
> Or do we have a way to test CI (Travis + rubyci.org) before committing?

As you know, Travis will run on a PR.

A few people seem to state that trunk builds and tests fine on mswin, but Appveyor doesn't run test-all or test-spec/test-rubyspec.  I'd be interested to know why...



----------------------------------------
Feature #13570: Using mkmf for ruby/spec C API specs
https://bugs.ruby-lang.org/issues/13570#change-65241

* Author: Eregon (Benoit Daloze)
* Status: Assigned
* Priority: Normal
* Assignee: cruby-windows
* Target version: 
----------------------------------------
Hello all,

I am thinking to use mkmf to compile the C API specs.

https://github.com/ruby/ruby/blob/trunk/spec/rubyspec/optional/capi/spec_helper.rb
is getting pretty complex and hard to maintain.

I have a few questions:
* Does mkmf works well on Windows?
* What is a good way to compile a single .c file with mkmf to a given library file in another directory?

I tried this but I am not sure it's correct:

~~~ ruby
def compile_extension(name)
  objdir = object_path
  ext = "#{name}_spec"
  lib = "#{objdir}/#{ext}.#{RbConfig::CONFIG['DLEXT']}"

  require 'mkmf' # TODO: probably best to use a subprocess to avoid polluting the namespace
  Dir.chdir(objdir) do
    $srcs = ["#{extension_path}/#{ext}.c"]
    $objs = ["#{extension_path}/#{ext}.o"] # should probably be in objdir but that does not seem to work
    create_makefile(ext)
    system "make"
  end

  lib
end
~~~

Alternatively, we can copy the needed files to a temporary directory, build there and copy the shared library back.
It's a bit more work but not a big deal either.

---Files--------------------------------
spec_helper.rb (2.22 KB)
spec_helper.rb (2.24 KB)


-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [ruby-core:81575] [Ruby trunk Feature#13570] Using mkmf for ruby/spec C API specs
       [not found] <redmine.issue-13570.20170516124746@ruby-lang.org>
                   ` (15 preceding siblings ...)
  2017-06-02 19:26 ` [ruby-core:81538] " Greg.mpls
@ 2017-06-05  6:13 ` usa
  2017-06-05  8:03 ` [ruby-core:81576] " nobu
                   ` (3 subsequent siblings)
  20 siblings, 0 replies; 21+ messages in thread
From: usa @ 2017-06-05  6:13 UTC (permalink / raw)
  To: ruby-core

Issue #13570 has been updated by usa (Usaku NAKAMURA).


MSP-Greg (Greg L) wrote:
> A few people seem to state that trunk builds and tests fine on mswin, but Appveyor doesn't run test-all or test-spec/test-rubyspec.  I'd be interested to know why...

Our hero nobu is testing running test-all and test-spec on appveyor.
I've heard that there was a little problem, but I believe that he will merge it into trunk in near future.

----------------------------------------
Feature #13570: Using mkmf for ruby/spec C API specs
https://bugs.ruby-lang.org/issues/13570#change-65278

* Author: Eregon (Benoit Daloze)
* Status: Assigned
* Priority: Normal
* Assignee: cruby-windows
* Target version: 
----------------------------------------
Hello all,

I am thinking to use mkmf to compile the C API specs.

https://github.com/ruby/ruby/blob/trunk/spec/rubyspec/optional/capi/spec_helper.rb
is getting pretty complex and hard to maintain.

I have a few questions:
* Does mkmf works well on Windows?
* What is a good way to compile a single .c file with mkmf to a given library file in another directory?

I tried this but I am not sure it's correct:

~~~ ruby
def compile_extension(name)
  objdir = object_path
  ext = "#{name}_spec"
  lib = "#{objdir}/#{ext}.#{RbConfig::CONFIG['DLEXT']}"

  require 'mkmf' # TODO: probably best to use a subprocess to avoid polluting the namespace
  Dir.chdir(objdir) do
    $srcs = ["#{extension_path}/#{ext}.c"]
    $objs = ["#{extension_path}/#{ext}.o"] # should probably be in objdir but that does not seem to work
    create_makefile(ext)
    system "make"
  end

  lib
end
~~~

Alternatively, we can copy the needed files to a temporary directory, build there and copy the shared library back.
It's a bit more work but not a big deal either.

---Files--------------------------------
spec_helper.rb (2.22 KB)
spec_helper.rb (2.24 KB)


-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [ruby-core:81576] [Ruby trunk Feature#13570] Using mkmf for ruby/spec C API specs
       [not found] <redmine.issue-13570.20170516124746@ruby-lang.org>
                   ` (16 preceding siblings ...)
  2017-06-05  6:13 ` [ruby-core:81575] " usa
@ 2017-06-05  8:03 ` nobu
  2017-06-05 16:32 ` [ruby-core:81582] " Greg.mpls
                   ` (2 subsequent siblings)
  20 siblings, 0 replies; 21+ messages in thread
From: nobu @ 2017-06-05  8:03 UTC (permalink / raw)
  To: ruby-core

Issue #13570 has been updated by nobu (Nobuyoshi Nakada).


test-spec runs fine on AppVeyor, test/ruby/test_rubyoptions.rb has a failure when locale and filesystem encodings differ.
Another problem is that it consumes 15 min, vs 8 min without tests.

----------------------------------------
Feature #13570: Using mkmf for ruby/spec C API specs
https://bugs.ruby-lang.org/issues/13570#change-65279

* Author: Eregon (Benoit Daloze)
* Status: Assigned
* Priority: Normal
* Assignee: cruby-windows
* Target version: 
----------------------------------------
Hello all,

I am thinking to use mkmf to compile the C API specs.

https://github.com/ruby/ruby/blob/trunk/spec/rubyspec/optional/capi/spec_helper.rb
is getting pretty complex and hard to maintain.

I have a few questions:
* Does mkmf works well on Windows?
* What is a good way to compile a single .c file with mkmf to a given library file in another directory?

I tried this but I am not sure it's correct:

~~~ ruby
def compile_extension(name)
  objdir = object_path
  ext = "#{name}_spec"
  lib = "#{objdir}/#{ext}.#{RbConfig::CONFIG['DLEXT']}"

  require 'mkmf' # TODO: probably best to use a subprocess to avoid polluting the namespace
  Dir.chdir(objdir) do
    $srcs = ["#{extension_path}/#{ext}.c"]
    $objs = ["#{extension_path}/#{ext}.o"] # should probably be in objdir but that does not seem to work
    create_makefile(ext)
    system "make"
  end

  lib
end
~~~

Alternatively, we can copy the needed files to a temporary directory, build there and copy the shared library back.
It's a bit more work but not a big deal either.

---Files--------------------------------
spec_helper.rb (2.22 KB)
spec_helper.rb (2.24 KB)


-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [ruby-core:81582] [Ruby trunk Feature#13570] Using mkmf for ruby/spec C API specs
       [not found] <redmine.issue-13570.20170516124746@ruby-lang.org>
                   ` (17 preceding siblings ...)
  2017-06-05  8:03 ` [ruby-core:81576] " nobu
@ 2017-06-05 16:32 ` Greg.mpls
  2017-06-15 13:51 ` [ruby-core:81693] " eregontp
  2018-12-28 19:04 ` [ruby-core:90779] " eregontp
  20 siblings, 0 replies; 21+ messages in thread
From: Greg.mpls @ 2017-06-05 16:32 UTC (permalink / raw)
  To: ruby-core

Issue #13570 has been updated by MSP-Greg (Greg L).


nobu (Nobuyoshi Nakada) wrote:
> test-spec runs fine on AppVeyor, test/ruby/test_rubyoptions.rb has a failure when locale and filesystem encodings differ.
> Another problem is that it consumes 15 min, vs 8 min without tests.

Thank you for working on that (in addition to everything else you do).

MinGW has the same failure, as discussed previously.  In my test results log, failures jumped from 5 to 6.  That's when I decided to remove the chcp and RUBYOPT changes from my build code.  

Re my MinGW test-all, I guess my goals were/are:

1. It completes
2. Consistent failures/errors
3. Minimize skips
4. Consistent tests/assertions
5. WHY DOES THIS TAKE SO LONG / parallel test

I haven't gotten to 5...

----------------------------------------
Feature #13570: Using mkmf for ruby/spec C API specs
https://bugs.ruby-lang.org/issues/13570#change-65286

* Author: Eregon (Benoit Daloze)
* Status: Assigned
* Priority: Normal
* Assignee: cruby-windows
* Target version: 
----------------------------------------
Hello all,

I am thinking to use mkmf to compile the C API specs.

https://github.com/ruby/ruby/blob/trunk/spec/rubyspec/optional/capi/spec_helper.rb
is getting pretty complex and hard to maintain.

I have a few questions:
* Does mkmf works well on Windows?
* What is a good way to compile a single .c file with mkmf to a given library file in another directory?

I tried this but I am not sure it's correct:

~~~ ruby
def compile_extension(name)
  objdir = object_path
  ext = "#{name}_spec"
  lib = "#{objdir}/#{ext}.#{RbConfig::CONFIG['DLEXT']}"

  require 'mkmf' # TODO: probably best to use a subprocess to avoid polluting the namespace
  Dir.chdir(objdir) do
    $srcs = ["#{extension_path}/#{ext}.c"]
    $objs = ["#{extension_path}/#{ext}.o"] # should probably be in objdir but that does not seem to work
    create_makefile(ext)
    system "make"
  end

  lib
end
~~~

Alternatively, we can copy the needed files to a temporary directory, build there and copy the shared library back.
It's a bit more work but not a big deal either.

---Files--------------------------------
spec_helper.rb (2.22 KB)
spec_helper.rb (2.24 KB)


-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [ruby-core:81693] [Ruby trunk Feature#13570] Using mkmf for ruby/spec C API specs
       [not found] <redmine.issue-13570.20170516124746@ruby-lang.org>
                   ` (18 preceding siblings ...)
  2017-06-05 16:32 ` [ruby-core:81582] " Greg.mpls
@ 2017-06-15 13:51 ` eregontp
  2018-12-28 19:04 ` [ruby-core:90779] " eregontp
  20 siblings, 0 replies; 21+ messages in thread
From: eregontp @ 2017-06-15 13:51 UTC (permalink / raw)
  To: ruby-core

Issue #13570 has been updated by Eregon (Benoit Daloze).


I tested and adapted the spec_helper.rb so it now also works on mswin (https://github.com/ruby/ruby/pull/1649) and mingw (on the Travis of ruby/spec).
Therefore I close this with r59093.
Please fix if new failures appear when building with mkmf.

----------------------------------------
Feature #13570: Using mkmf for ruby/spec C API specs
https://bugs.ruby-lang.org/issues/13570#change-65382

* Author: Eregon (Benoit Daloze)
* Status: Assigned
* Priority: Normal
* Assignee: cruby-windows
* Target version: 
----------------------------------------
Hello all,

I am thinking to use mkmf to compile the C API specs.

https://github.com/ruby/ruby/blob/trunk/spec/rubyspec/optional/capi/spec_helper.rb
is getting pretty complex and hard to maintain.

I have a few questions:
* Does mkmf works well on Windows?
* What is a good way to compile a single .c file with mkmf to a given library file in another directory?

I tried this but I am not sure it's correct:

~~~ ruby
def compile_extension(name)
  objdir = object_path
  ext = "#{name}_spec"
  lib = "#{objdir}/#{ext}.#{RbConfig::CONFIG['DLEXT']}"

  require 'mkmf' # TODO: probably best to use a subprocess to avoid polluting the namespace
  Dir.chdir(objdir) do
    $srcs = ["#{extension_path}/#{ext}.c"]
    $objs = ["#{extension_path}/#{ext}.o"] # should probably be in objdir but that does not seem to work
    create_makefile(ext)
    system "make"
  end

  lib
end
~~~

Alternatively, we can copy the needed files to a temporary directory, build there and copy the shared library back.
It's a bit more work but not a big deal either.

---Files--------------------------------
spec_helper.rb (2.22 KB)
spec_helper.rb (2.24 KB)


-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [ruby-core:90779] [Ruby trunk Feature#13570] Using mkmf for ruby/spec C API specs
       [not found] <redmine.issue-13570.20170516124746@ruby-lang.org>
                   ` (19 preceding siblings ...)
  2017-06-15 13:51 ` [ruby-core:81693] " eregontp
@ 2018-12-28 19:04 ` eregontp
  20 siblings, 0 replies; 21+ messages in thread
From: eregontp @ 2018-12-28 19:04 UTC (permalink / raw)
  To: ruby-core

Issue #13570 has been updated by Eregon (Benoit Daloze).


@nobu cherry-picked the IO.copy_stream patch in r66147, and I now upstreamed it to ruby/mspec.
I mostly forgot about it, and it's easy enough for early Ruby implementations to shim IO.copy_stream.

----------------------------------------
Feature #13570: Using mkmf for ruby/spec C API specs
https://bugs.ruby-lang.org/issues/13570#change-75954

* Author: Eregon (Benoit Daloze)
* Status: Closed
* Priority: Normal
* Assignee: cruby-windows
* Target version: 
----------------------------------------
Hello all,

I am thinking to use mkmf to compile the C API specs.

https://github.com/ruby/ruby/blob/trunk/spec/rubyspec/optional/capi/spec_helper.rb
is getting pretty complex and hard to maintain.

I have a few questions:
* Does mkmf works well on Windows?
* What is a good way to compile a single .c file with mkmf to a given library file in another directory?

I tried this but I am not sure it's correct:

~~~ ruby
def compile_extension(name)
  objdir = object_path
  ext = "#{name}_spec"
  lib = "#{objdir}/#{ext}.#{RbConfig::CONFIG['DLEXT']}"

  require 'mkmf' # TODO: probably best to use a subprocess to avoid polluting the namespace
  Dir.chdir(objdir) do
    $srcs = ["#{extension_path}/#{ext}.c"]
    $objs = ["#{extension_path}/#{ext}.o"] # should probably be in objdir but that does not seem to work
    create_makefile(ext)
    system "make"
  end

  lib
end
~~~

Alternatively, we can copy the needed files to a temporary directory, build there and copy the shared library back.
It's a bit more work but not a big deal either.

---Files--------------------------------
spec_helper.rb (2.22 KB)
spec_helper.rb (2.24 KB)


-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2018-12-28 19:04 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <redmine.issue-13570.20170516124746@ruby-lang.org>
2017-05-16 12:47 ` [ruby-core:81199] [Ruby trunk Feature#13570] Using mkmf for ruby/spec C API specs eregontp
2017-05-16 21:11 ` [ruby-core:81200] " Greg.mpls
2017-05-28 11:38 ` [ruby-core:81434] [Ruby trunk Feature#13570][Closed] " eregontp
2017-05-29 15:33 ` [ruby-core:81455] [Ruby trunk Feature#13570] " eregontp
2017-05-29 15:33 ` [ruby-core:81456] [Ruby trunk Feature#13570][Assigned] " eregontp
2017-05-29 16:39 ` [ruby-core:81458] [Ruby trunk Feature#13570] " Greg.mpls
2017-05-31 22:25 ` [ruby-core:81490] " Greg.mpls
2017-06-01 16:21 ` [ruby-core:81510] " eregontp
2017-06-01 16:44 ` [ruby-core:81511] " Greg.mpls
2017-06-01 19:08 ` [ruby-core:81513] " eregontp
2017-06-02  2:00 ` [ruby-core:81517] " nobu
2017-06-02  9:09 ` [ruby-core:81520] " eregontp
2017-06-02  9:15 ` [ruby-core:81521] " eregontp
2017-06-02 13:16 ` [ruby-core:81524] " Greg.mpls
2017-06-02 14:33 ` [ruby-core:81527] " Greg.mpls
2017-06-02 19:26 ` [ruby-core:81538] " Greg.mpls
2017-06-05  6:13 ` [ruby-core:81575] " usa
2017-06-05  8:03 ` [ruby-core:81576] " nobu
2017-06-05 16:32 ` [ruby-core:81582] " Greg.mpls
2017-06-15 13:51 ` [ruby-core:81693] " eregontp
2018-12-28 19:04 ` [ruby-core:90779] " eregontp

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).