Dear Rainer,
I worked on the consistency of paths so that they all relate to
$bp_application_path which is the top of "bolprocessor". This was not
the case and this explains a few bizarre displays you got.
Then I tried two cases, the results of which are shown on attached
pictures.
Case 1 (which is the current one):
$bp_application_path = "..".DIRECTORY_SEPARATOR;
The picture shows the production of -gr.NotReich on a BP console pop-up
window, and the output file "out.sco" on another pop-up window.
Case 2 (one of your suggestions):
$bp_application_path = dirname(getcwd()).DIRECTORY_SEPARATOR;
This makes all paths "absolute", i.e. related to the root created by MAMP.
The picture shows that the console responded (which may not be the case
in Windows), the pop-up BP console opened but the pop-up "outs.sco" did
not.
The reason is that javascript window.open() does not work if the URL
provided for filling the window is an absolute one.
It accepts:
../my_output/out.sco
But it does not accept:
/Applications/MAMP/htdocs/try/bolprocessor/my_output/out.sco
I had faced this problem some time ago and decided to avoid absolute
paths for that reason.
In the interface I have just committed I also set this:
define('SLASH',DIRECTORY_SEPARATOR);
so that you will see backslashes in your paths.
The "BP Help" and "Console help" links work on Mac in both cases.
I have difficulties following your explanation of the system-path
solution. My guess is that you may want to call the console with "bp
etc." instead of "../bp etc."
And may be replace relative links with absolute ones in the command
line? The result would be:
bp produce -gr
/Applications/MAMP/htdocs/try/bolprocessor/ctests/-gr.NotReich -se
/Applications/MAMP/htdocs/try/bolprocessor/ctests/-se.NotReich -d
--csoundout /Applications/MAMP/htdocs/try/bolprocessor/my_output/out.sco
etc.
or the same with backslashes?
It is not difficult to modify URLs according to the operating system. I
implemented a function that returns the OS platform, so it would be very
easy to make conditional changes once we know exactly which syntax fits
which system…
Regarding the Makefile, this sounds like a real mess! My guess is that
we should distribute ready-compiled versions of the console and let the
interface select the one fitting the operating system.
Bernard
Rainer Schuetz wrote on 07/10/2020 14:59:
> On 7. Oct 2020, at 07:33, Bernard Bel<ber...@gm...> wrote:
>
> Rainer Schuetz wrote on 06/10/2020 23:44:
>
>> For now I think the symbolic link approach works fine - except - bad
>> news, sorry to realise it so late - on Windows the php-frontend
>> doesn’t receive the standard-out output of bpconsole - it’s there on
>> the command-line, but php doesn’t get it… (and no, it’s not related
>> to symlinking (which doesn’t work for the binary anyways), I tried
>> all alternative ways of merging the repos).
> Dear Rainer,
>
> I am not 100% sure about what you mean…
Sorry for unclear language. I think I understand what’s going wrong now,
but symptoms first:
Currently - when I run the php-frontend - clicking “help” at the top of
the index.php (where it says "or the console’s help-output") will open
an empty browser window (well, the window contains “No message produced…”).
Likewise all links, that are supposed to display output from the console
do not display anything in the popup Window.
No the reason, for the simple console-help case first:
The link calles produce.php?instruction=help, which in turn constructs
the command "../bp --help" which is sent to the system. Unfortunately
"../bp --help" doesn't work in Windows, even if I go to the command
line, change to the php-frontend/php folder and type "../bp --help" the
vision statement (humor!) doesn't appear, instead the system returns
`'..' is not recognized as an internal or external command,
operable program or batch file.`. If I type `..\bp --help` instead, it
works as expected. So while "/" generally works as a folder-level
seperator in Windows, there seem to be corner cases, and one of them
seems to be the ".." shortcut for parent directory.
Staying with the simple "help" case for now, I see four quick fix
alternatives:
- let $application_path return a backslash on Windows (if - on Windows -
I replace `$application_path = "..".SLASH;` by `$application_path =
"..\\";` the vision statement is displayed properly. But it's not cross
platform and you'd have to do a OS-check to control that literally
yourself. No need, I think, PHP provides the means itself.
- use DIRECTORY_SEPARATOR instead, which should be crossplatform:
`$application_path = "..".DIRECTORY_SEPARATOR;` works on Windows.
- let the frontend assume, that the bp executable is available in the
system (or user) PATH (envir-var). So, if for the sake of this
experiment, I add the bolprocessor folder to the system path (which
makes bp.exe avaible to be called from anywhere), and I replace
`$application_path = "..".SLASH;` by `$application_path = "";`, bare `bp
--help` is constructed as command, and I do get output.
- make $application_path return the absolute path with the standard
syntax of the current OS. `$application_path =
dirname(getcwd()).DIRECTORY_SEPARATOR;` works on Windows and should be
cross-platform.
The system-path solution is appealing for it's simplicity and
flexibility, it allows to keep the bp-folder and the php-frontend folder
totally separate, but it requires people to add the bolprocessor folder
to the path, which might have side effects, and which might be
difficult/confusing for some. The dirname(...) solution is nice in that
it let's php decide how to expand getcwd. It would also work if there
was a supported OS that doesn't use ".." at all.
"..".DIRECTORY_SEPARATOR is midway between being totally literal and
using some PHP-smartness.
I tend to using full PHP-smartness, though at some point, I think, one
should consider more flexible ways of "adressing" a bp-executable.
So now to the complex constructed bp commands (I tried this while having
replaced your $application_path assignment with: `$application_path =
dirname(getcwd()).DIRECTORY_SEPARATOR;`):
Opening -gr.NotReich and pressing Produce item(s) constructs this command:
../bp produce -gr ../ctests/-gr.NotReich -se ../ctests/-se.NotReich-d
--csoundout ../my_output/out.sco --traceout
../temp_bolprocessor/trace_ee9b7331d6f62db3a5194abb54a84e1b.txt --seed
15524
which fails for at least the constant use of "../" So at this point the
bp-executable seems not to be addressed using $application_path any
more, and all other paths continue to use the
parent-dir-dots.forward-slash that doesn't work in Windows.
Unfortunately I don't understand that $_GET and urldecode-stuff yet, so
I can't make suggestions, but I can say that if above command is
replaced by:
..\bp produce -gr ..\ctests\-gr.NotReich -se ..\ctests\-se.NotReich -d
--csoundout ..\my_output\out.sco --traceout
..\temp_bolprocessor\trace_ee9b7331d6f62db3a5194abb54a84e1b.txt --seed
15524
on the command line in the php-folder at least it get's to:
Bol Processor console app
Version 2.999... (Oct5 2020)
This is a beta version for evaluation...
Reading grammar file ..\ctests\-gr.NotReich...
Error reading data from file.
If I do the `define('SLASH',DIRECTORY_SEPARATOR);` "trick" in
_basic_tasks.php, I get this constructed command:
command = ../bp produce -gr ..\ctests\-gr.NotReich -se -se.NotReich-d
--csoundout ../\my_output\out.sco --traceout
..\temp_bolprocessor\trace_ee9b7331d6f62db3a5194abb54a84e1b.txt --seed
15524
So it seems there seems to be some inconsistency left in path
construction...
So much from me right now, a combination of not understanding the more
complex parts of the code and lack of time require me to stop. I guess
if this path construction is cleaned up, there might be more detective
work necessary to find out if some of the complex commands on Windows
don't work at expected even though they are executed with correct paths.
Best
.r.
PS: as to "make". I think of make/Makefile as belonging gcc. That is not
actually true, but in practice it's what mostly happens (?). Make is an
executable (on MacOS it's in /usr/bin/make) that interprets a file
called "Makefile" that resides in the root-folder of the project to be
built (look it up, it's quite transparent) in order to automate all the
steps of the build. It's consdered native on Linux. I can work on MacOS,
but the "native" compiler of MacOS is Apple clang, and the native
toolchain is Xcode, using the xcodeproj-files Anthony has stored in the
BP2 folder instead of make + Makefile. On Windows the situation is more
difficult. You can't just install gcc and then use make like on MacOS
because make expects a posix environment and tools that won't work in
the Windows environment. Yes, there is mingw, which basically is a gcc
that works in Windows natively, but it cannot be used with "make",
because of said reasons. Therefore environments like msys, msys2 or
cygwin were created, that allow to run all the build (automation) tools
in Windows by emulating a unixy enviroment. msys and msys2 surpass
cygwin in that they produce executables that*once built* can run in the
native Windows environment. That is how I use bp.exe in Windows.
Now, MAMP, i.e. Apache and PHP run in the native Windows enviroment and
expect bp to behave like a native Windows app. As such, you cannot
compile bp.exe using the "make"-approach. You'd need to switch to that
dedicated, unixy "build-environment". That might actually be possible
(provided a lot of preconditions are met), but it's far from trivial,
not even easy. The bottom line, I think, is: Making compile by make part
of the php-interface isn't likely to work in more than very few
use-cases. The "normal" MacOS user will want to use Xcode, the
Windows-user will be forced to build in a "for building only", emulated
environment - in both cases make won't work the way you envision it. And
even on Linux (likely the smallest user-group) installing the toolchain
isn't something that comes natural to the majority of the users. So tbh
I am sceptical that compiling from the php-interface covers any
practical use case: the ones who can install gcc in a non-native
environment, will always also be able (and prefer!) to compile from the
command-line.
> Enclosed is the display of what you should see after clicking the
> PRODUCE ITEM(s) button on grammar "-gr.NotReich". It creates a pop-up
> window named "BP console" and displays the output.
>
> The process is the following (in produce.php):
>
> exec($command,$o);
> $n_messages = count($o);
> $no_error = FALSE;
> for($i = 0; $i < $n_messages; $i++) {
> $mssg = $o[$i];
> if(is_integer($pos=strpos($mssg,"Errors: 0")) AND $pos == 0)
> $no_error = TRUE;
> }
>
> This runs the console command displayed in red on top of BP console.
> Then it checks whether "Errors: 0" was found in one of the messages.
>
> After displaying links to output file and if necessary to the trace
> file, it displays all messages in a standard way:
>
> for($i = 0; $i < $n_messages; $i++) {
> $mssg = $o[$i];
> $mssg = clean_up_encoding(TRUE,$mssg);
> echo $mssg."<br />";
> }
>
> clean_up_encoding() is a function that replaces garbage signs with the
> correct UTF-8 ones (in _basic_tasks.php):
>
> function clean_up_encoding($convert,$text) {
> if($convert) $text = mb_convert_encoding($text, "UTF-8",
> mb_detect_encoding($text, "UTF-8, ISO-8859-1, ISO-8859-15", true));
> $text = str_replace("¥","•",$text);
> $text = str_replace("Ô","‘",$text);
> $text = str_replace("Õ","’",$text);
> $text = str_replace("Ò","“",$text);
> $text = str_replace("Ó","”",$text);
> $text = str_replace("É","…",$text);
> $text = str_replace("Â","¬",$text);
> $text = str_replace("¤","•",$text);
> $text = str_replace("â¢","•",$text);
> $text = str_replace(" . ","•",$text);
> $text = str_replace("²","≤",$text);
> $text = str_replace("³","≥",$text);
> return $text;
> }
>
> On this particular example, clean_up_encoding() does nothing and could
> be ignored.
>
> The only thing I guess might not work in a different environment is
> the pop-up window opening — which would be very, very troublesome…
>
> Let us sort out this problem, if confirmed!
>
> Bernard
>
> <Screen Shot 2020-10-07 at 07.17.17
> (2).png>_______________________________________________
> bolprocessor-devel mailing list
> bol...@li...
> https://lists.sourceforge.net/lists/listinfo/bolprocessor-devel
_______________________________________________
bolprocessor-devel mailing list
bol...@li...
https://lists.sourceforge.net/lists/listinfo/bolprocessor-devel
|