Return-Path: X-Original-To: apmail-lucy-dev-archive@www.apache.org Delivered-To: apmail-lucy-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 192AD98C4 for ; Thu, 5 Apr 2012 16:36:18 +0000 (UTC) Received: (qmail 78315 invoked by uid 500); 5 Apr 2012 16:36:18 -0000 Delivered-To: apmail-lucy-dev-archive@lucy.apache.org Received: (qmail 78288 invoked by uid 500); 5 Apr 2012 16:36:18 -0000 Mailing-List: contact dev-help@lucy.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@lucy.apache.org Delivered-To: mailing list dev@lucy.apache.org Received: (qmail 78280 invoked by uid 99); 5 Apr 2012 16:36:17 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 05 Apr 2012 16:36:17 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (nike.apache.org: local policy) Received: from [209.85.213.51] (HELO mail-yw0-f51.google.com) (209.85.213.51) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 05 Apr 2012 16:36:10 +0000 Received: by yhnn12 with SMTP id n12so764352yhn.10 for ; Thu, 05 Apr 2012 09:35:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-originating-ip:in-reply-to:references:date :message-id:subject:from:to:content-type:x-gm-message-state; bh=23k/GqdYfmerpDJCko6pE7zIWeLlMh7dNxbbnTL/aHo=; b=kDMyDL2Z5med1CRfc5CJoTWlUTiaFN+s5F8d3/bAz/DbFlHAwmoWh1TvVk6DPa8g7j b/6mBzUZkI+V7Dgr42Aor/WiLymFQnKDE79ZW2Ani6I8i4Ib32l+RHwEtfOFWYQRf4g9 ha4ahu+JSWhTM7Xsonu9K7vrVTzAeUTugSs1CINF90ZexK8xrasHmliBfBDbqY+3IP8A BR+4VKnlSd50O6mdBrXXYMWfDSFoRaTROP8HhBNZ2AyeR0nAnSU498bSwqp73TUGCFpA g6bUHdXY+pvPlIoTh6wdiPnNt+/jUINwJyx8FZVTwGhl6UHMXWZYFNeSUz9JfFti91qP PHkQ== MIME-Version: 1.0 Received: by 10.50.51.137 with SMTP id k9mr2651234igo.46.1333643747385; Thu, 05 Apr 2012 09:35:47 -0700 (PDT) Received: by 10.142.115.3 with HTTP; Thu, 5 Apr 2012 09:35:47 -0700 (PDT) X-Originating-IP: [184.189.118.13] In-Reply-To: <4F7D8C9F.2030406@aevum.de> References: <4F7757EF.4030705@aevum.de> <4F7C9F07.8090500@aevum.de> <4F7D8C9F.2030406@aevum.de> Date: Thu, 5 Apr 2012 09:35:47 -0700 Message-ID: From: Marvin Humphrey To: dev@lucy.apache.org Content-Type: text/plain; charset=ISO-8859-1 X-Gm-Message-State: ALoCoQkHEcYjwqaNPPytzxWY7auHTxe9dV0/EfgWVdrBSU1xxAG9ei/9IqmYoNqzZJB6II3rfkYq Subject: Re: [lucy-dev] Build support classes for C extensions On Thu, Apr 5, 2012 at 5:14 AM, Nick Wellnhofer wrote: > I will write some POD once the implementation is stable. Currently, the > C::C::P::B API looks like this: > > C::C::P::B is a subclass of Module::Build. > > There's a new constructor argument 'clownfish_params' that takes a hashref > containing the following entries: > > * cf_include_dirs: arrayref of Clownfish include dirs containing .cfh files. > Empty by default. Extensions will typically set this to > cf_system_include_dirs (see below). > > * extra_c_sources: arrayref of extra C source dirs or files. Empty by > default. > > * autogen_header: header for autogenerated files. Defaults to a "do not > edit" text without license. > > * core_source_dir: directory containing the core Clownfish sources (.cfh and > .c files). Defaults to 'core' or '../core'. Doesn't have to be provided > normally. Could "core_source_dir" and "extra_c_sources" be consolidated into a single "source" param? And then can we leverage the standard Module::Build "c_source" param to hold directories which contain C code exclusively (i.e. no .cfh files)? I think we can just dump all of Lucy's C source directories into $clownfish_params{source} to work around the limitations of c_source in versions of M::B prior to 0.3604. The only annoying bit is that we might want to separate out any .h files lest they be vacuumed up and installed into the clownfish system include dir. On a related note, I would suggest that we rename $clownfish_params{cf_include_dirs} to $clownfish_params{include}. * The need for the "cf_" prefix is not strong because the param is nested within "clownfish_params". (Things would be different if we were adding top-level M::B params). * IMO, it would be nice to parallel the "include" and "source" attributes of CFCHierarchy by using the same names. > There's also an accessor for 'clownfish_params'. > > Then there are two class methods: > > my @dirs = C::C::P::B->cf_system_include_dirs; > > Returns the list of system-wide Clownfish include dirs in > $Config{installsitearch} and $Config{installvendorarch}. > > my $path = C::C::P::B->cf_system_library_file($module_name); > > Returns the installed library file (.so or .dll) for a module. This is > needed by extensions which have to link against the library of the module > they're extending. +1 to both, sounds good! > I can try to mirror the API we would get with > Module::Build#add_property using an inside-out class attribute. I think we might consider just using an ordinary hash param inside the Module::Build object. I seem to recall some weirdness with Module::Build object serializing and deserializing itself in all the process-spawning chaos, and I'm not sure that an inside-out attribute will survive. > Doesn't that mean that Lucy can't be loaded which sounds like the worst case > to me? I wasn't clear. Here are some things that are worse than installation failure: * Index corruption. * Security vulnerability. * Publication of a bad API which confuses users, constrains future development, etc. * A version number screwup affecting the CPAN toolchain rather than just Lucy module loading. * A bug which causes silent failure, e.g. discarding a supplied parameter. * A crashing bug which the test suite fails to catch. I don't mean that having XSLoader crash out wouldn't be a serious problem, but it is really easy to recover from with a subsequent release. The version number in question only ends up in the shared object. So, I didn't want to stand in your way, because even if you were to disregard the concern I raised, CPAN testers would ultimately force us to fix things and no irreparable damage would be done. > Is it that only that some versions of XSLoader have problems? I recall experiencing problems with XSLoader not liking version numbers that were not exactly the same -- I think it was 0.003 vs "0.003000" or something like that. It could have been a floating-point precision problem[1], but in any case, the conservative strategy is to make sure that XSLoader::load() gets fed exactly the same version number format that the shared object was built with. > It would be easy to switch to the old way of parsing the version number from > Lucy.pm. I don't think that's true any more because that code block has moved into Clownfish::CFC::Build::Perl, right? Invoking dist_version() is really the right design choice. Maybe we can adapt Lucy.pm instead, passing e.g. a literal version string instead of $Lucy::VERSION. Marvin Humphrey [1] Note to self: Don't ever design a system to use floating point version numbers because of problematic comparison semantics.