From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS4713 221.184.0.0/13 X-Spam-Status: No, score=-3.0 required=3.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_MED,SPF_PASS,T_DKIM_INVALID, T_RP_MATCHES_RCVD shortcircuit=no autolearn=ham autolearn_force=no version=3.4.0 Received: from neon.ruby-lang.org (neon.ruby-lang.org [221.186.184.75]) by dcvr.yhbt.net (Postfix) with ESMTP id 44CDD20D0A for ; Mon, 29 May 2017 16:39:12 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id A69061207AE; Tue, 30 May 2017 01:39:09 +0900 (JST) Received: from o1678916x28.outbound-mail.sendgrid.net (o1678916x28.outbound-mail.sendgrid.net [167.89.16.28]) by neon.ruby-lang.org (Postfix) with ESMTPS id 540C01207A3 for ; Tue, 30 May 2017 01:39:08 +0900 (JST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=sendgrid.me; h=from:to:references:subject:mime-version:content-type:content-transfer-encoding:list-id; s=smtpapi; bh=nSAxIogGvpkFCCSA8xA7fIVffLw=; b=RKN4fDrmj8jHWgQy/k 9ChWphmcKk34655+D6gbJLp5tlpGFjaIm2p+IXrJE9/706eluRAKt2mNh+sJip4R 0EV7s70mT2c28UUR7CwQNJiWOccOxp7HtGbI16FBGwbCFHswwQMvwAwC5W2AINj1 pI6mvCptNu8ns9flb9QIa9Kd8= Received: by filter1123p1mdw1.sendgrid.net with SMTP id filter1123p1mdw1-30116-592C4EA7-30 2017-05-29 16:39:03.740621678 +0000 UTC Received: from herokuapp.com (ec2-54-167-29-171.compute-1.amazonaws.com [54.167.29.171]) by ismtpd0004p1iad1.sendgrid.net (SG) with ESMTP id v_cf0fioRUOtcFawZZwjoA Mon, 29 May 2017 16:39:03.763 +0000 (UTC) Date: Mon, 29 May 2017 16:39:03 +0000 From: Greg.mpls@gmail.com To: ruby-core@ruby-lang.org Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 56484 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 13570 X-Redmine-Issue-Author: Eregon X-Redmine-Issue-Assignee: X-Redmine-Sender: MSP-Greg X-Mailer: Redmine X-Redmine-Host: bugs.ruby-lang.org X-Redmine-Site: Ruby Issue Tracking System X-Auto-Response-Suppress: All Auto-Submitted: auto-generated X-SG-EID: ync6xU2WACa70kv/Ymy4QrNMhiuLXJG8OTL2vJD1yS54H14UnXWmqDivuj/gw3gcD+Ofn+hnipY3Af BzdLj3RCOlLMXUTlKj5WGuPgIcIilF3VhvcfCe3t2gbialotfe7lZ2/P2SAQAOuzu5DMT1oARMEeWn jlITs9XmL98BaPdMU4GtgOqFE2PXu271AtsJDRaJVbk4L2S7aKiTBw1Abg== X-ML-Name: ruby-core X-Mail-Count: 81458 Subject: [ruby-core:81458] [Ruby trunk Feature#13570] Using mkmf for ruby/spec C API specs X-BeenThere: ruby-core@ruby-lang.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: Ruby developers List-Id: Ruby developers List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ruby-core-bounces@ruby-lang.org Sender: "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/