annotate scripts/pkg/private/configure_make.m @ 32632:2e484f9f1f18 stable

maint: update Octave Project Developers copyright for the new year
author John W. Eaton <jwe@octave.org>
date Fri, 22 Dec 2023 12:08:17 -0500
parents 597f3ee61a48
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
1 ########################################################################
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
2 ##
32632
2e484f9f1f18 maint: update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 31706
diff changeset
3 ## Copyright (C) 2005-2024 The Octave Project Developers
27918
b442ec6dda5c use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents: 27216
diff changeset
4 ##
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
5 ## See the file COPYRIGHT.md in the top-level directory of this
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
6 ## distribution or <https://octave.org/copyright/>.
14466
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
7 ##
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
8 ## This file is part of Octave.
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
9 ##
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24370
diff changeset
10 ## Octave is free software: you can redistribute it and/or modify it
14466
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
11 ## under the terms of the GNU General Public License as published by
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24370
diff changeset
12 ## the Free Software Foundation, either version 3 of the License, or
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22323
diff changeset
13 ## (at your option) any later version.
14466
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
14 ##
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
15 ## Octave is distributed in the hope that it will be useful, but
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
16 ## WITHOUT ANY WARRANTY; without even the implied warranty of
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22323
diff changeset
17 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22323
diff changeset
18 ## GNU General Public License for more details.
14466
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
19 ##
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
20 ## You should have received a copy of the GNU General Public License
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
21 ## along with Octave; see the file COPYING. If not, see
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24370
diff changeset
22 ## <https://www.gnu.org/licenses/>.
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
23 ##
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
24 ########################################################################
14466
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
25
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
26 ## -*- texinfo -*-
20852
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 20713
diff changeset
27 ## @deftypefn {} {} configure_make (@var{desc}, @var{packdir}, @var{verbose})
14466
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
28 ## Undocumented internal function.
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
29 ## @end deftypefn
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
30
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
31 function configure_make (desc, packdir, verbose)
21758
ffad2baa90f7 maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents: 21751
diff changeset
32
14466
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
33 ## Perform ./configure, make, make install in "src".
25787
3293cd2651fb prefer 'isfolder' over 'exist (..., "dir")' in Octave functions
Mike Miller <mtmiller@octave.org>
parents: 25564
diff changeset
34 if (isfolder (fullfile (packdir, "src")))
14466
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
35 src = fullfile (packdir, "src");
21434
1da428cbf401 deprecate octave_config_info
John W. Eaton <jwe@octave.org>
parents: 20955
diff changeset
36 octave_bindir = __octave_config_info__ ("bindir");
14466
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
37 ver = version ();
21434
1da428cbf401 deprecate octave_config_info
John W. Eaton <jwe@octave.org>
parents: 20955
diff changeset
38 ext = __octave_config_info__ ("EXEEXT");
19833
9fc020886ae9 maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19697
diff changeset
39 mkoctfile_program = fullfile (octave_bindir, ...
9fc020886ae9 maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19697
diff changeset
40 sprintf ("mkoctfile-%s%s", ver, ext));
9fc020886ae9 maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19697
diff changeset
41 octave_config_program = fullfile (octave_bindir, ...
9fc020886ae9 maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19697
diff changeset
42 sprintf ("octave-config-%s%s", ver, ext));
30629
2a234181057b pkg: Use octave binary on all platforms.
Markus Mützel <markus.muetzel@gmx.de>
parents: 30564
diff changeset
43 octave_binary = fullfile (octave_bindir, sprintf ("octave-%s%s", ver, ext));
16824
51bcaa55f120 pkg: display output of shell commands on real time if verbose.
Carnë Draug <carandraug+dev@gmail.com>
parents: 16724
diff changeset
44
17516
21656a949661 Add hook function to handle missing Octave components
Mike Miller <mtmiller@ieee.org>
parents: 17016
diff changeset
45 if (! exist (mkoctfile_program, "file"))
21656a949661 Add hook function to handle missing Octave components
Mike Miller <mtmiller@ieee.org>
parents: 17016
diff changeset
46 __gripe_missing_component__ ("pkg", "mkoctfile");
21656a949661 Add hook function to handle missing Octave components
Mike Miller <mtmiller@ieee.org>
parents: 17016
diff changeset
47 endif
21656a949661 Add hook function to handle missing Octave components
Mike Miller <mtmiller@ieee.org>
parents: 17016
diff changeset
48 if (! exist (octave_config_program, "file"))
21656a949661 Add hook function to handle missing Octave components
Mike Miller <mtmiller@ieee.org>
parents: 17016
diff changeset
49 __gripe_missing_component__ ("pkg", "octave-config");
21656a949661 Add hook function to handle missing Octave components
Mike Miller <mtmiller@ieee.org>
parents: 17016
diff changeset
50 endif
21656a949661 Add hook function to handle missing Octave components
Mike Miller <mtmiller@ieee.org>
parents: 17016
diff changeset
51 if (! exist (octave_binary, "file"))
21656a949661 Add hook function to handle missing Octave components
Mike Miller <mtmiller@ieee.org>
parents: 17016
diff changeset
52 __gripe_missing_component__ ("pkg", "octave");
21656a949661 Add hook function to handle missing Octave components
Mike Miller <mtmiller@ieee.org>
parents: 17016
diff changeset
53 endif
21656a949661 Add hook function to handle missing Octave components
Mike Miller <mtmiller@ieee.org>
parents: 17016
diff changeset
54
30778
e36380193f2b pkg: Allow spaces in paths to Octave binaries (bug #62090).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30700
diff changeset
55 if (ispc () && ! isunix ())
30780
1fcb3359f6a4 maint: Use Octave convention for leading comment character.
Rik <rik@octave.org>
parents: 30778
diff changeset
56 ## Replace all backslashes with forward slashes
30778
e36380193f2b pkg: Allow spaces in paths to Octave binaries (bug #62090).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30700
diff changeset
57 mkoctfile_program = strrep (mkoctfile_program, '\', '/');
e36380193f2b pkg: Allow spaces in paths to Octave binaries (bug #62090).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30700
diff changeset
58 octave_config_program = strrep (octave_config_program, '\', '/');
e36380193f2b pkg: Allow spaces in paths to Octave binaries (bug #62090).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30700
diff changeset
59 octave_binary = strrep (octave_binary, '\', '/');
e36380193f2b pkg: Allow spaces in paths to Octave binaries (bug #62090).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30700
diff changeset
60 endif
e36380193f2b pkg: Allow spaces in paths to Octave binaries (bug #62090).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30700
diff changeset
61
30780
1fcb3359f6a4 maint: Use Octave convention for leading comment character.
Rik <rik@octave.org>
parents: 30778
diff changeset
62 ## Escape spaces in file paths unless they are already escaped
30778
e36380193f2b pkg: Allow spaces in paths to Octave binaries (bug #62090).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30700
diff changeset
63 mkoctfile_program = regexprep (mkoctfile_program, '([^\\]) ', '$1\\ ');
e36380193f2b pkg: Allow spaces in paths to Octave binaries (bug #62090).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30700
diff changeset
64 octave_config_program = regexprep (octave_config_program, ...
e36380193f2b pkg: Allow spaces in paths to Octave binaries (bug #62090).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30700
diff changeset
65 '([^\\]) ', '$1\\ ');
e36380193f2b pkg: Allow spaces in paths to Octave binaries (bug #62090).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30700
diff changeset
66 octave_binary = regexprep (octave_binary, '([^\\]) ', '$1\\ ');
e36380193f2b pkg: Allow spaces in paths to Octave binaries (bug #62090).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30700
diff changeset
67
18420
c2d1869a95ee Pass --verbose option to mkoctfile when installing packages with --verbose (bug #41351).
Mike Miller <mtmiller@ieee.org>
parents: 17744
diff changeset
68 if (verbose)
c2d1869a95ee Pass --verbose option to mkoctfile when installing packages with --verbose (bug #41351).
Mike Miller <mtmiller@ieee.org>
parents: 17744
diff changeset
69 mkoctfile_program = [mkoctfile_program " --verbose"];
c2d1869a95ee Pass --verbose option to mkoctfile when installing packages with --verbose (bug #41351).
Mike Miller <mtmiller@ieee.org>
parents: 17744
diff changeset
70 endif
c2d1869a95ee Pass --verbose option to mkoctfile when installing packages with --verbose (bug #41351).
Mike Miller <mtmiller@ieee.org>
parents: 17744
diff changeset
71
c2d1869a95ee Pass --verbose option to mkoctfile when installing packages with --verbose (bug #41351).
Mike Miller <mtmiller@ieee.org>
parents: 17744
diff changeset
72 cenv = {"MKOCTFILE"; mkoctfile_program;
c2d1869a95ee Pass --verbose option to mkoctfile when installing packages with --verbose (bug #41351).
Mike Miller <mtmiller@ieee.org>
parents: 17744
diff changeset
73 "OCTAVE_CONFIG"; octave_config_program;
21519
8e5eca2c5a64 pkg install: drop INSTALLDIR and stop calling configure with --prefix.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
74 "OCTAVE"; octave_binary};
19584
e33427a854ec * configure_make.m: Single-quote environment variable values.
John W. Eaton <jwe@octave.org>
parents: 18986
diff changeset
75 scenv = sprintf ("%s='%s' ", cenv{:});
18420
c2d1869a95ee Pass --verbose option to mkoctfile when installing packages with --verbose (bug #41351).
Mike Miller <mtmiller@ieee.org>
parents: 17744
diff changeset
76
28186
c26838a3afa6 pkg: build with "V=1" for verbose build rules
Mike Miller <mtmiller@octave.org>
parents: 27923
diff changeset
77 if (verbose)
c26838a3afa6 pkg: build with "V=1" for verbose build rules
Mike Miller <mtmiller@octave.org>
parents: 27923
diff changeset
78 ## Add standard V=1 make argument for verbose build rules
c26838a3afa6 pkg: build with "V=1" for verbose build rules
Mike Miller <mtmiller@octave.org>
parents: 27923
diff changeset
79 scenv = [scenv, "V=1"];
c26838a3afa6 pkg: build with "V=1" for verbose build rules
Mike Miller <mtmiller@octave.org>
parents: 27923
diff changeset
80 endif
c26838a3afa6 pkg: build with "V=1" for verbose build rules
Mike Miller <mtmiller@octave.org>
parents: 27923
diff changeset
81
14466
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
82 ## Configure.
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
83 if (exist (fullfile (src, "configure"), "file"))
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
84 flags = "";
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
85 if (isempty (getenv ("CC")))
16994
333243133364 Use matrix concatenation for strings, rather than cstrcat(), for clarity and performance.
Rik <rik@octave.org>
parents: 16824
diff changeset
86 flags = [flags ' CC="' mkoctfile("-p", "CC") '"'];
14466
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
87 endif
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
88 if (isempty (getenv ("CXX")))
16994
333243133364 Use matrix concatenation for strings, rather than cstrcat(), for clarity and performance.
Rik <rik@octave.org>
parents: 16824
diff changeset
89 flags = [flags ' CXX="' mkoctfile("-p", "CXX") '"'];
14466
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
90 endif
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
91 if (isempty (getenv ("AR")))
17016
a3f6790df115 Fix typos from cstrcat to matrix concatenation changeset (333243133364).
Rik <rik@octave.org>
parents: 16994
diff changeset
92 flags = [flags ' AR="' mkoctfile("-p", "AR") '"'];
14466
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
93 endif
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
94 if (isempty (getenv ("RANLIB")))
17016
a3f6790df115 Fix typos from cstrcat to matrix concatenation changeset (333243133364).
Rik <rik@octave.org>
parents: 16994
diff changeset
95 flags = [flags ' RANLIB="' mkoctfile("-p", "RANLIB") '"'];
14466
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
96 endif
28200
bc6dae9cbe73 pkg: insert missing space in configure command
Mike Miller <mtmiller@octave.org>
parents: 28186
diff changeset
97 cmd = ["cd '" src "'; " scenv " ./configure " flags];
16994
333243133364 Use matrix concatenation for strings, rather than cstrcat(), for clarity and performance.
Rik <rik@octave.org>
parents: 16824
diff changeset
98 [status, output] = shell (cmd, verbose);
14466
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
99 if (status != 0)
16824
51bcaa55f120 pkg: display output of shell commands on real time if verbose.
Carnë Draug <carandraug+dev@gmail.com>
parents: 16724
diff changeset
100 disp (output);
28905
89a425f2c202 maint: Use Octave convention that error() messages don't end with a period.
Rik <rik@octave.org>
parents: 28201
diff changeset
101 error ("pkg: error running the configure script for %s", desc.name);
14466
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
102 endif
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
103 endif
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
104
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
105 ## Make.
19603
b74ae93040e8 limit number of jobs for make command to 1 under windows (bug #44053)
Avinoam Kalma
parents: 19584
diff changeset
106 if (ispc ())
b74ae93040e8 limit number of jobs for make command to 1 under windows (bug #44053)
Avinoam Kalma
parents: 19584
diff changeset
107 jobs = 1;
b74ae93040e8 limit number of jobs for make command to 1 under windows (bug #44053)
Avinoam Kalma
parents: 19584
diff changeset
108 else
19833
9fc020886ae9 maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19697
diff changeset
109 jobs = nproc ("overridable");
19603
b74ae93040e8 limit number of jobs for make command to 1 under windows (bug #44053)
Avinoam Kalma
parents: 19584
diff changeset
110 endif
b74ae93040e8 limit number of jobs for make command to 1 under windows (bug #44053)
Avinoam Kalma
parents: 19584
diff changeset
111
14466
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
112 if (exist (fullfile (src, "Makefile"), "file"))
18986
7141d9728ee0 pkg.m: run make with multiple simultaneous jobs (bug #42915)
Carnë Draug <carandraug@octave.org>
parents: 18420
diff changeset
113 [status, output] = shell (sprintf ("%s make --jobs %i --directory '%s'",
19603
b74ae93040e8 limit number of jobs for make command to 1 under windows (bug #44053)
Avinoam Kalma
parents: 19584
diff changeset
114 scenv, jobs, src), verbose);
14466
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
115 if (status != 0)
16824
51bcaa55f120 pkg: display output of shell commands on real time if verbose.
Carnë Draug <carandraug+dev@gmail.com>
parents: 16724
diff changeset
116 disp (output);
28905
89a425f2c202 maint: Use Octave convention that error() messages don't end with a period.
Rik <rik@octave.org>
parents: 28201
diff changeset
117 error ("pkg: error running 'make' for the %s package", desc.name);
14466
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
118 endif
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
119 endif
29026
64d1c7af5b18 Automatically extract BISTs during pkg install (bug #41298).
Oliver Heimlich <oheim@posteo.de>
parents: 28200
diff changeset
120
64d1c7af5b18 Automatically extract BISTs during pkg install (bug #41298).
Oliver Heimlich <oheim@posteo.de>
parents: 28200
diff changeset
121 ## Extract tests from source files which will not to be installed
64d1c7af5b18 Automatically extract BISTs during pkg install (bug #41298).
Oliver Heimlich <oheim@posteo.de>
parents: 28200
diff changeset
122 tst_files_src = [];
64d1c7af5b18 Automatically extract BISTs during pkg install (bug #41298).
Oliver Heimlich <oheim@posteo.de>
parents: 28200
diff changeset
123 for suffix = {"*.cc", "*.c", "*.C", "*.cpp", "*.cxx"}
64d1c7af5b18 Automatically extract BISTs during pkg install (bug #41298).
Oliver Heimlich <oheim@posteo.de>
parents: 28200
diff changeset
124 tst_files_src = [tst_files_src; ...
64d1c7af5b18 Automatically extract BISTs during pkg install (bug #41298).
Oliver Heimlich <oheim@posteo.de>
parents: 28200
diff changeset
125 nthargout(1, 1, @dir, fullfile (src, suffix{1}))];
64d1c7af5b18 Automatically extract BISTs during pkg install (bug #41298).
Oliver Heimlich <oheim@posteo.de>
parents: 28200
diff changeset
126 endfor
64d1c7af5b18 Automatically extract BISTs during pkg install (bug #41298).
Oliver Heimlich <oheim@posteo.de>
parents: 28200
diff changeset
127 if (! isempty (tst_files_src))
64d1c7af5b18 Automatically extract BISTs during pkg install (bug #41298).
Oliver Heimlich <oheim@posteo.de>
parents: 28200
diff changeset
128 for tst_file_src = {tst_files_src.name}
64d1c7af5b18 Automatically extract BISTs during pkg install (bug #41298).
Oliver Heimlich <oheim@posteo.de>
parents: 28200
diff changeset
129 full_tst_file_src = fullfile (src, tst_file_src{1});
64d1c7af5b18 Automatically extract BISTs during pkg install (bug #41298).
Oliver Heimlich <oheim@posteo.de>
parents: 28200
diff changeset
130 tst_code = __extract_test_code__ (full_tst_file_src);
64d1c7af5b18 Automatically extract BISTs during pkg install (bug #41298).
Oliver Heimlich <oheim@posteo.de>
parents: 28200
diff changeset
131 if (isempty (tst_code))
64d1c7af5b18 Automatically extract BISTs during pkg install (bug #41298).
Oliver Heimlich <oheim@posteo.de>
parents: 28200
diff changeset
132 continue;
64d1c7af5b18 Automatically extract BISTs during pkg install (bug #41298).
Oliver Heimlich <oheim@posteo.de>
parents: 28200
diff changeset
133 endif
64d1c7af5b18 Automatically extract BISTs during pkg install (bug #41298).
Oliver Heimlich <oheim@posteo.de>
parents: 28200
diff changeset
134 full_tst_file = strcat (full_tst_file_src, "-tst");
64d1c7af5b18 Automatically extract BISTs during pkg install (bug #41298).
Oliver Heimlich <oheim@posteo.de>
parents: 28200
diff changeset
135 if (exist (full_tst_file))
64d1c7af5b18 Automatically extract BISTs during pkg install (bug #41298).
Oliver Heimlich <oheim@posteo.de>
parents: 28200
diff changeset
136 continue;
64d1c7af5b18 Automatically extract BISTs during pkg install (bug #41298).
Oliver Heimlich <oheim@posteo.de>
parents: 28200
diff changeset
137 endif
64d1c7af5b18 Automatically extract BISTs during pkg install (bug #41298).
Oliver Heimlich <oheim@posteo.de>
parents: 28200
diff changeset
138 tst_code = ...
64d1c7af5b18 Automatically extract BISTs during pkg install (bug #41298).
Oliver Heimlich <oheim@posteo.de>
parents: 28200
diff changeset
139 ["## DO NOT EDIT!\n", ...
64d1c7af5b18 Automatically extract BISTs during pkg install (bug #41298).
Oliver Heimlich <oheim@posteo.de>
parents: 28200
diff changeset
140 "## Generated automatically from ", tst_file_src{1}, "\n", ...
64d1c7af5b18 Automatically extract BISTs during pkg install (bug #41298).
Oliver Heimlich <oheim@posteo.de>
parents: 28200
diff changeset
141 "## by ", mfilename(), ".m during package installation.\n\n", ...
64d1c7af5b18 Automatically extract BISTs during pkg install (bug #41298).
Oliver Heimlich <oheim@posteo.de>
parents: 28200
diff changeset
142 tst_code];
64d1c7af5b18 Automatically extract BISTs during pkg install (bug #41298).
Oliver Heimlich <oheim@posteo.de>
parents: 28200
diff changeset
143 [fid, output] = fopen (full_tst_file, "w");
64d1c7af5b18 Automatically extract BISTs during pkg install (bug #41298).
Oliver Heimlich <oheim@posteo.de>
parents: 28200
diff changeset
144 if (fid == -1)
64d1c7af5b18 Automatically extract BISTs during pkg install (bug #41298).
Oliver Heimlich <oheim@posteo.de>
parents: 28200
diff changeset
145 error ("Octave:pkg:extract-tests", ...
64d1c7af5b18 Automatically extract BISTs during pkg install (bug #41298).
Oliver Heimlich <oheim@posteo.de>
parents: 28200
diff changeset
146 "pkg: error writing extracted tests to 'src': %s", output);
64d1c7af5b18 Automatically extract BISTs during pkg install (bug #41298).
Oliver Heimlich <oheim@posteo.de>
parents: 28200
diff changeset
147 endif
64d1c7af5b18 Automatically extract BISTs during pkg install (bug #41298).
Oliver Heimlich <oheim@posteo.de>
parents: 28200
diff changeset
148 fputs (fid, tst_code);
64d1c7af5b18 Automatically extract BISTs during pkg install (bug #41298).
Oliver Heimlich <oheim@posteo.de>
parents: 28200
diff changeset
149 fclose (fid);
64d1c7af5b18 Automatically extract BISTs during pkg install (bug #41298).
Oliver Heimlich <oheim@posteo.de>
parents: 28200
diff changeset
150 endfor
64d1c7af5b18 Automatically extract BISTs during pkg install (bug #41298).
Oliver Heimlich <oheim@posteo.de>
parents: 28200
diff changeset
151 endif
64d1c7af5b18 Automatically extract BISTs during pkg install (bug #41298).
Oliver Heimlich <oheim@posteo.de>
parents: 28200
diff changeset
152
21758
ffad2baa90f7 maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents: 21751
diff changeset
153 endif
21519
8e5eca2c5a64 pkg install: drop INSTALLDIR and stop calling configure with --prefix.
Carnë Draug <carandraug@octave.org>
parents: 21518
diff changeset
154
14466
cfb0173fe1ca maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff changeset
155 endfunction
21615
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21519
diff changeset
156
21759
b002b4331a12 maint: Use two newlines after endfunction and start of BIST tests.
Rik <rik@octave.org>
parents: 21758
diff changeset
157 ## Executes a shell command.
b002b4331a12 maint: Use two newlines after endfunction and start of BIST tests.
Rik <rik@octave.org>
parents: 21758
diff changeset
158 ## In the end it calls system(), but in the case of MS Windows it will first
b002b4331a12 maint: Use two newlines after endfunction and start of BIST tests.
Rik <rik@octave.org>
parents: 21758
diff changeset
159 ## check if sh.exe works.
21615
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21519
diff changeset
160 ##
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21519
diff changeset
161 ## If VERBOSE is true, it will prints the output to STDOUT in real time and
21751
b571fc85953f maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents: 21615
diff changeset
162 ## the second output argument will be an empty string. Otherwise, it will
21615
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21519
diff changeset
163 ## contain the output of the execeuted command.
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21519
diff changeset
164 function [status, output] = shell (cmd, verbose)
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21519
diff changeset
165 persistent have_sh;
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21519
diff changeset
166
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21519
diff changeset
167 if (ispc () && ! isunix ())
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21519
diff changeset
168 if (isempty (have_sh))
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21519
diff changeset
169 if (system ('sh.exe -c "exit"'))
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21519
diff changeset
170 have_sh = false;
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21519
diff changeset
171 else
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21519
diff changeset
172 have_sh = true;
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21519
diff changeset
173 endif
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21519
diff changeset
174 endif
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21519
diff changeset
175 if (have_sh)
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21519
diff changeset
176 cmd = ['sh.exe -c "' cmd '"'];
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21519
diff changeset
177 else
28905
89a425f2c202 maint: Use Octave convention that error() messages don't end with a period.
Rik <rik@octave.org>
parents: 28201
diff changeset
178 error ("pkg: unable to find the command shell");
21615
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21519
diff changeset
179 endif
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21519
diff changeset
180 endif
21751
b571fc85953f maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents: 21615
diff changeset
181 ## if verbose, we want to display the output in real time. To do this, we
27216
823b4bcf79fc unless necessary for formatting or code, use ' instead of `
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
182 ## must call system with 1 output argument. But then the variable 'output'
21751
b571fc85953f maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents: 21615
diff changeset
183 ## won't exist. So we initialize it empty. If an error does occur, and we
21615
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21519
diff changeset
184 ## are verbose we will return an empty string but it's all fine since
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21519
diff changeset
185 ## the error message has already been displayed.
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21519
diff changeset
186 output = "";
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21519
diff changeset
187 if (verbose)
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21519
diff changeset
188 [status] = system (cmd);
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21519
diff changeset
189 else
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21519
diff changeset
190 [status, output] = system (cmd);
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21519
diff changeset
191 endif
21758
ffad2baa90f7 maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents: 21751
diff changeset
192
21615
9ccd64201b4d pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents: 21519
diff changeset
193 endfunction
29026
64d1c7af5b18 Automatically extract BISTs during pkg install (bug #41298).
Oliver Heimlich <oheim@posteo.de>
parents: 28200
diff changeset
194
64d1c7af5b18 Automatically extract BISTs during pkg install (bug #41298).
Oliver Heimlich <oheim@posteo.de>
parents: 28200
diff changeset
195 function body = __extract_test_code__ (nm)
30379
363fb10055df maint: Style check m-files ahead of 7.1 release.
Rik <rik@octave.org>
parents: 29359
diff changeset
196
29026
64d1c7af5b18 Automatically extract BISTs during pkg install (bug #41298).
Oliver Heimlich <oheim@posteo.de>
parents: 28200
diff changeset
197 ## Collect all BIST lines starting %! from the file named nm
64d1c7af5b18 Automatically extract BISTs during pkg install (bug #41298).
Oliver Heimlich <oheim@posteo.de>
parents: 28200
diff changeset
198 ## and return them as a single \n-delimited string.
64d1c7af5b18 Automatically extract BISTs during pkg install (bug #41298).
Oliver Heimlich <oheim@posteo.de>
parents: 28200
diff changeset
199 fid = fopen (nm, "rt");
64d1c7af5b18 Automatically extract BISTs during pkg install (bug #41298).
Oliver Heimlich <oheim@posteo.de>
parents: 28200
diff changeset
200 body = "";
64d1c7af5b18 Automatically extract BISTs during pkg install (bug #41298).
Oliver Heimlich <oheim@posteo.de>
parents: 28200
diff changeset
201 if (fid >= 0)
64d1c7af5b18 Automatically extract BISTs during pkg install (bug #41298).
Oliver Heimlich <oheim@posteo.de>
parents: 28200
diff changeset
202 while (ischar (ln = fgets (fid)))
64d1c7af5b18 Automatically extract BISTs during pkg install (bug #41298).
Oliver Heimlich <oheim@posteo.de>
parents: 28200
diff changeset
203 if (strncmp (ln, "%!", 2))
64d1c7af5b18 Automatically extract BISTs during pkg install (bug #41298).
Oliver Heimlich <oheim@posteo.de>
parents: 28200
diff changeset
204 body = [body, ln];
64d1c7af5b18 Automatically extract BISTs during pkg install (bug #41298).
Oliver Heimlich <oheim@posteo.de>
parents: 28200
diff changeset
205 endif
64d1c7af5b18 Automatically extract BISTs during pkg install (bug #41298).
Oliver Heimlich <oheim@posteo.de>
parents: 28200
diff changeset
206 endwhile
64d1c7af5b18 Automatically extract BISTs during pkg install (bug #41298).
Oliver Heimlich <oheim@posteo.de>
parents: 28200
diff changeset
207 fclose (fid);
64d1c7af5b18 Automatically extract BISTs during pkg install (bug #41298).
Oliver Heimlich <oheim@posteo.de>
parents: 28200
diff changeset
208 endif
30379
363fb10055df maint: Style check m-files ahead of 7.1 release.
Rik <rik@octave.org>
parents: 29359
diff changeset
209
29026
64d1c7af5b18 Automatically extract BISTs during pkg install (bug #41298).
Oliver Heimlich <oheim@posteo.de>
parents: 28200
diff changeset
210 endfunction