[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [OctDev] main ported to the package system
From: |
David Bateman |
Subject: |
Re: [OctDev] main ported to the package system |
Date: |
Tue, 22 Aug 2006 10:17:18 +0200 |
User-agent: |
Mozilla Thunderbird 1.0.6-7.6.20060mdk (X11/20050322) |
Soren,
As this should be applied to the octave core pkg.m function I've cc'ed
the maintainers list. John can you look at this?
Soren Hauberg wrote:
>man, 21 08 2006 kl. 18:43 +0200, skrev David Bateman:
>
>
>>Ok, this makes sense, and I'd propose something like the attached patch
>>to address this. Though this needs further testing, it seems to work for
>>the test case I've used based on the comms toolbox. Basically, this
>>means that symbolic links should be handled by the developer either
>>embedded in the code or as a seperate PKG_ADD file that is appended to
>>the end of the PKG_ADD commands found in the source.
>>
>>
>Looks good, but there are a few details I don't understand:
>
>
>
>>+ function create_pkgadd (desc, packdir)
>>+ pkgadd = [desc.dir "/PKG_ADD"];
>>+ rm_rf(pkgadd);
>>
>>
>Why do you need to delete 'pkgadd'? 'desc.dir' should always be a newly
>created directory, so 'pkgadd' should never exist.
>
>
Ok, I'm not that familar with the package system yet.
>
>
>>+ fid = fopen(pkgadd, "wt");
>>+ if (fid >= 0)
>>+ ## Search all dot-m files for PKG_ADD commands
>>+ lst = dir ([packdir "inst"]);
>>+ for i=1:length(lst)
>>+ nm = lst(i).name;
>>+ if (length(nm) > 3 && strcmp (nm((end-1):end), ".m"))
>>+ fwrite (fid, extract_pkgadd (nm, '^[#%][#%]* *PKG_ADD: *(.*)$'));
>>+ endif
>>+ endfor
>>
>>
>Can't you simply write:
> lst = dir ([packdir "/inst/*.m"]);
> for i = 1:length(list)
> nm = list(i).name;
> fwrite (fid, extract_pkgadd (nm, '^[#%][#%]* *PKG_ADD: *(.*)$'));
> endfor
>and similar for the C++ files.
>
>
Hey, it was a first pass. Ok, I've adapted the changes you suggested.
>
>
>
>>+ ## Search all C++ source files for PKG_ADD commands
>>+ lst = dir ([packdir "src"]);
>>+ for i=1:length(lst)
>>+ nm = lst(i).name;
>>+ if (length(nm) > 4 && strcmp (nm((end-2):end), ".cc"))
>>
>>
>Should we only handle *.cc files, or should we also handle *.cpp and *.C
>(are there others?) ? Which reminds me: is MS Windows case sensitive, or
>do we also need to handle *.M, *.CPP, etc.?
>
>
The existing mkpkgadd funcion only search *.m and *.cc files. Its easy
to make it search other files, but do we want it to?
>Besides these details it looks good, and I think this should be applied
>to CVS. Assuming this gets accepted into CVS, what else is needed to aid
>package developers?
>
>
Some way of treating additional directories in the package other than
src/ and inst/, though I'll address that in a seperate mail..
I attach the PKG_ADD patch for pkg.m that I'd like to see applied
Regards
David
2006-08-22 David Bateman <address@hidden>
* pkg/pkg.m: Search inst/*.m and src/*.m files in the package for
PKG_ADD directives. Append user supplied PKG_ADD as well.
--
David Bateman address@hidden
Motorola Labs - Paris +33 1 69 35 48 04 (Ph)
Parc Les Algorithmes, Commune de St Aubin +33 6 72 01 06 33 (Mob)
91193 Gif-Sur-Yvette FRANCE +33 1 69 35 77 01 (Fax)
The information contained in this communication has been classified as:
[x] General Business Information
[ ] Motorola Internal Use Only
[ ] Motorola Confidential Proprietary
*** pkg.m.orig 2006-08-21 18:40:45.792043828 +0200
--- pkg.m 2006-08-22 10:00:57.573105603 +0200
***************
*** 249,254 ****
--- 249,255 ----
desc = descriptions{i};
pdir = packdirs{i};
copy_files(desc, pdir);
+ create_pkgadd(desc, pdir);
finish_installation (desc, pdir)
endfor
catch
***************
*** 495,500 ****
--- 496,556 ----
endif
endfunction
+ function pkgadd = extract_pkgadd (nm, pat)
+ fid = fopen (nm, "rt");
+ pkgadd = "";
+ if (fid >= 0)
+ while (! feof(fid))
+ ln = fgetl (fid);
+ if (ln > 0)
+ t = regexp(ln, pat, "tokens","dotexceptnewline");
+ if (!isempty(t))
+ pkgadd = [pkgadd, "\n", t{1}{1}];
+ endif
+ endif
+ endwhile
+ if (!isempty(pkgadd))
+ pkgadd = [pkgadd, "\n"];
+ endif
+ fclose (fid);
+ endif
+ endfunction
+
+ function create_pkgadd (desc, packdir)
+ pkgadd = [desc.dir "/PKG_ADD"];
+ fid = fopen(pkgadd, "wt");
+ if (fid >= 0)
+ ## Search all dot-m files for PKG_ADD commands
+ lst = dir ([packdir "inst/*.m"]);
+ for i=1:length(lst)
+ nm = lst(i).name;
+ fwrite (fid, extract_pkgadd (nm, '^[#%][#%]* *PKG_ADD: *(.*)$'));
+ endfor
+
+ ## Search all C++ source files for PKG_ADD commands
+ lst = dir ([packdir "src/*.cc"]);
+ for i=1:length(lst)
+ nm = lst(i).name;
+ fwrite (fid, extract_pkgadd (nm, '^//* *PKG_ADD: *(.*)$'));
+ fwrite (fid, extract_pkgadd (nm, '^/\** *PKG_ADD: *(.*) *\*/$'));
+ endfor
+
+ ## Add developer included PKG_ADD commands
+ if (exist([packdir "PKG_ADD"],"file"))
+ fid2 = fopen([packdir "PKG_ADD"],"rt");
+ if (fid2 >= 0)
+ while (! feof(fid2))
+ ln = fgets (fid2);
+ if (ln > 0)
+ fwrite(fid, ln);
+ endif
+ endwhile
+ endif
+ endif
+ fclose(fid);
+ endif
+ endfunction
+
function copy_files (desc, packdir)
## Copy the files from "inst" to installdir
[status, output] = system(["cp -R " packdir "inst/* " desc.dir]);
- Re: [OctDev] main ported to the package system,
David Bateman <=