[M3devel] problems with cm3.cfg and MxConfig

Randy Coleburn rcoleburn at scires.com
Mon Aug 3 17:27:44 CEST 2009


Jay:
 
No problem.  I think you are trying to make it more flexible, and that
is good.  I just ran into a problem with cm3ide.
 
The shortcut I use to launch cm3ide causes the current dir to be the
"bin" folder.  So, using your new cm3.cfg, I was always having a problem
with (path() & "/config/"), since it would be trying to find "config" at
the root of the file system when path() returned the empty string. 
Since "/config" wasn't found, none of the other parts of your include
file were ever processed, hence, BUILD_DIR would never be found.
 
I gather that path() is supposed to return the path to the cm3.cfg
file.  If this is true, then returning "" is not really a path, so the
function seems broken when cm3.cfg is in the current dir.  Returning "."
makes more sense for this case and would allow the rest of your cm3.cfg
file to work I think, provided that HOST is defined or that it is
replaced by the actual text.
 
Regards,
Randy

>>> Jay K <jay.krell at cornell.edu> 8/3/2009 5:05 AM >>>

Sorry about #1 Randy, my mistake.


Sitting in the bin directory...seems a little wierd, eh?
What source are you going to build sitting there?
I guess um some custom quake code??
Good enough if empty is instead just "."?

This falls out of the fact that cm3 actually probes all over the place
for the cm3.cfg file and the first place it looks in is the current
directory.


Another good option I think would be just to remove that probe.
It looks in way too many places.


Here is the current code. I think it is gross.
Too much probing make things quite ambiguous.


PROCEDURE FindConfig () =
  (* LL = mu *)
  VAR txt: TEXT;
  BEGIN
    IF (found) THEN RETURN END;

    (* try the current directory *)
    IF TryConfig (Filename) THEN RETURN END;

    (* try the immediate source directory *)
    IF TryConfig ("src", Filename) THEN RETURN END;

    (* try the sibling source directory *)
    IF TryConfig ("..", "src", Filename) THEN RETURN END;

    (* try the M3CONFIG environment variable *)
    txt := QMachine.GetEnv (NIL, "M3CONFIG");
    IF (txt # NIL) THEN
      IF TryConfig (txt) THEN RETURN END;
      IF TryConfig (txt, Filename) THEN RETURN END;
    END;

    (* try the directory containing the current executable *)
    txt := Pathname.Prefix (Params.Get (0));

    IF Text.Length (txt)> 0 THEN
      IF TryConfig (txt, Filename) THEN RETURN END;
    END;

    (* try the directories named by the PATH environment variable. *)
    txt := Env.Get ("PATH");
    FindConfigInPath (txt);

    IF found THEN RETURN END;

    (* try the etc directories *)
    IF TryConfig("/usr/local/cm3/etc", Filename) THEN RETURN END;
    IF TryConfig("/usr/cm3/etc", Filename) THEN RETURN END; 
    IF TryConfig("/cm3/etc", Filename) THEN RETURN END; 
    IF TryConfig("/usr/contrib/etc", Filename) THEN RETURN END; 
    IF TryConfig("/usr/local/etc", Filename) THEN RETURN END; 
    IF TryConfig("/usr/etc", Filename) THEN RETURN END; 
    IF TryConfig("/opt/etc", Filename) THEN RETURN END; 
    IF TryConfig("/sw/etc", Filename) THEN RETURN END; 
    IF TryConfig("/etc", Filename) THEN RETURN END;

    (* oh well, make sure we don't try this silly exercise again... *)
    config := NIL;
    found := TRUE;
  END FindConfig;


I propose..roughly roughly, we make it like this instead:


PROCEDURE FindConfig () =
  (* LL = mu *)
  VAR txt: TEXT;
  BEGIN
    IF (found) THEN RETURN END;

    (* try the M3CONFIG environment variable *)
    txt := QMachine.GetEnv (NIL, "M3CONFIG");
    IF (txt # NIL) THEN
      IF TryConfig (txt) THEN RETURN END;
      IF TryConfig (txt, Filename) THEN RETURN END;
    END;

    (* try the directory containing the current executable *)
    txt := Pathname.Prefix (Params.Get (0));
    IF Text.Length (txt)> 0 THEN
      IF TryConfig (txt, Filename) THEN RETURN END;
    END;

    (* oh well, make sure we don't try this silly exercise again... *)
    config := NIL;
    found := TRUE;
  END FindConfig;


or, if people really like it looking all over the place, fixing the
case of it being in the current working directory is probably like
this:


    (* try the current directory *)
<    IF TryConfig (Filename) THEN RETURN END;
>    IF TryConfig (".", Filename) THEN RETURN END;


- Jay



----------------------------------------
> From: jay.krell at cornell.edu 
> To: rcoleburn at scires.com 
> Date: Sun, 2 Aug 2009 23:42:17 -0700
> CC: m3devel at elegosoft.com 
> Subject: Re: [M3devel] problems with cm3.cfg and MxConfig
>
> Host, hm, I think probably my mistake. It is defined by cm3 but not
> all m3quake users. Path() should be the directory containing the
file
> with the call.
>
> - Jay (phone)
>
> On Aug 2, 2009, at 9:52 PM, "Randy Coleburn" 
> wrote:
>
>> I have been working on the problem of cm3ide not getting the
>> BUILD_DIR from cm3.cfg. I've run across some perplexing test
results.
>>
>> MxConfig.Get("BUILD_DIR") is returning NIL on Windows XP & Vista.
>> I've tracked it down a bit further. There seem to be two issues
>> that must be fixed to solve this problem:
>>
>> 1. HOST does not seem to be defined. In particular my "C:\cm3\bin
>> \cm3.cfg" file appears as follows (this is the file Jay
recommended):
>> INSTALL_ROOT = path() & "/.."
>> include (path() & "/config/" & HOST)
>>
>> Is HOST a variable? Or, was I supposed to replace it by "NT386"?
>> If the latter, my bad on this one--I took Jay's message literally.
>>
>> 2. path() does not appear to always yield the path to the bin
>> folder. In particular, it seems to work fine unless you invoke the
>> program when the current directory is actually set to the bin
>> folder, in which case path() seems to return the empty string.
>>
>> So, if Í%=C:\, and I run cm3ide, path() returns "C:\cm3\bin" as it
s
>> hould.
>> But, if Í%=C:\cm3\bin, and I run cm3ide, path() returns "".
>>
>> So in the latter case, the include statement winds up trying to
pull
>> a file from the wrong place, e.g. "/config/NT386" rather than "C:
>> \cm3\bin/config/NT386"
>>
>> Regards,
>> Randy Coleburn

CONFIDENTIALITY NOTICE:  This email and any attachments are intended
solely for the use of the named recipient(s). This e-mail may contain
confidential and/or proprietary information of Scientific Research
Corporation.  If you are not a named recipient, you are prohibited from
making any use of the information in the email and attachments.  If you
believe you have received this email in error, please notify the sender
immediately and permanently delete the email, any attachments, and all
copies thereof from any drives or storage media and destroy any
printouts of the email or attachments.

EXPORT COMPLIANCE NOTICE:  This email and any attachments may contain
technical data subject to U.S export restrictions under the
International Traffic in Arms Regulations (ITAR) or the Export
Administration Regulations (EAR).  Export or transfer of this technical
data and/or related information to any foreign person(s) or entity(ies),
either within the U.S. or outside of the U.S., may require export
authorization by the appropriate U.S. Government agency prior to export
or transfer.  In addition, technical data may not be exported or
transferred to certain countries or specified designated nationals
identified by U.S. embargo controls without prior export authorization. 
By accepting this email and any attachments, all recipients confirm that
they understand and will comply with all applicable ITAR, EAR and
embargo compliance requirements.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://m3lists.elegosoft.com/pipermail/m3devel/attachments/20090803/4f240e92/attachment-0002.html>


More information about the M3devel mailing list