Skip to content

Commit

Permalink
Don't put CompUnitRepo folders outside the build dir during build
Browse files Browse the repository at this point in the history
CompUnitRepo generates a folder structure in the PERL6_HOME folder. That
folder does not exist yet during the build. So the normal logic to
auto determine the PERL6_HOME folder thinks it's
`build_dir/../share/perl6`. Thus CompUnitRepo puts some folders there.
This is not wanted. As a temporary solution to prevent pollution of the
users directories, we just explicitly set PERL6_HOME to
`build_dir/gen/dummy_p6_home` then CompUnitRepo can litter it's folders
there and all is well.
  • Loading branch information
PatZim committed Oct 25, 2019
1 parent f3dda96 commit cbd1dc2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
7 changes: 6 additions & 1 deletion tools/templates/moar/perl6-m-build.c.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <string.h>
#include <errno.h>
#include <unistd.h>
extern char **environ;

int main(int argc, char *argv[])
{
Expand Down Expand Up @@ -35,7 +36,11 @@ int main(int argc, char *argv[])

exec_argv[exec_argc - 1] = NULL;

execv(moar, exec_argv);
// Hack: Explicitly set a dummy PERL6_HOME, so the autogenerated CompUnitRepo
// folder structure does not end up in the build directories parent folder.
setenv("PERL6_HOME", "@c_escape(@nfp(@base_dir@/gen/dummy_p6_home)@)@", 1);

execve(moar, exec_argv, environ);

// execv doesn't return on successful exec.
fprintf(stderr, "ERROR: Failed to execute moar. Error code: %i\n", errno);
Expand Down
4 changes: 4 additions & 0 deletions tools/templates/moar/perl6-m-build.c.windows
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ int wmain(int argc, wchar_t *argv[]) {
}
cmd_line[cmd_line_size - 1] = 0;

// Hack: Explicitly set a dummy PERL6_HOME, so the autogenerated CompUnitRepo
// folder structure does not end up in the build directories parent folder.
_wputenv_s(L"PERL6_HOME", L"@c_escape(@nfp(@base_dir@/gen/dummy_p6_home)@)@");

// Execute the command and wait for it to finish.
ZeroMemory(&si, sizeof(si));
si.cb = sizeof(si);
Expand Down

0 comments on commit cbd1dc2

Please sign in to comment.