2009/2/6 Bruno Postle <[email protected]>:
>
> On Wed 04-Feb-2009 at 18:08 +0100, Lukáš Jirkovský wrote:
>>I've been working on bug #2036114 (pass TMPDIR to external programs)
>>and I've created two possible ways how to fix it.
>>
>>The first one (the v0 one) changes createMakefile() to add tempdir
>>parameter and then create necessary changes into generated makefile.
>>This is the most straightforward way how to do it. But I don't like
>>it. In my opinion it's ugly.
>
> I haven't tested it, but this sounds right. The process as I
> understand it is run by both hugin_stitch_project and PTBatcher:
>
> 1. Create a temporary folder and put a temporary .pto project and
> Makefile in it.
>
> 2. Then `make -f /path/to/makefile all clean` is run
>
> 3. This creates all the intermediate files in the temporary folder,
> writes the final output in a normal folder and deletes the
> intermediate files.
>
> The problem is that in (1), the temporary folder is created in the
> default system tempdir and not in the tempdir that the hugin user
> can specify in the preferences.
>
>>So I've made another patch (the v1). This one adds #hugin_tempdir to
>>the pto file.
>
> The temporary directory should definitely be a program preference
> rather than a project setting. Setting it in the .pto files means
> they are not portable between machines.
I've realized that in the yesterdays evening and I wanted to write
this today morning. It could cause problems (maybe even security, who
knows what is in the specified directory?) when project file is for
example used on another machine.
>>Anyway I need someone to test generated makefile on Mac OS X and
>>Windows (you can change it manually, see example below). I've
>>successfully tested it on GNU/Linux. There's problem that I'm not sure
>>if Mac OS uses export to set environment variables or setenv. Windows
>>version uses for setting environment variables set, but I don't know
>>if it really works as I think it works.
>
> As I understand 'export' in this case is a Makefile internal
> directive, so it would be 'export TMPDIR=/blah' for all OS's.
It seem so. I've changed patch accordingly.
>>The only change in makefile is that it adds:
>>export TMPDIR=/path/to/temporary/directory
>
> --
> Bruno
So here's the third version of the patch. It's based on the version v0
as Bruno pointed out that it's not project specific. Changes are made
to the exporting variable in makefile as suggested.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"hugin and other free panoramic software" group.
A list of frequently asked questions is available at:
http://wiki.panotools.org/Hugin_FAQ
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at http://groups.google.com/group/hugin-ptx
-~----------~----~----~----~------~----~------~--~---
Index: src/hugin1/PT/utils.h
===================================================================
--- src/hugin1/PT/utils.h (revision 3627)
+++ src/hugin1/PT/utils.h (working copy)
@@ -44,7 +44,8 @@
const PTPrograms & progs,
const std::string & includePath,
std::vector<std::string> & outputFiles
- std::ostream & o)
+ std::ostream & o,
+ std::string & tmpDir)
{
Panorama copyOfPano(pano);
HuginBase::PanoramaMakefileExport(copyOfPano, o, images, ptofile, outputPrefix, progs, includePath).run();
Index: src/hugin1/base_wx/RunStitchPanel.cpp
===================================================================
--- src/hugin1/base_wx/RunStitchPanel.cpp (revision 3627)
+++ src/hugin1/base_wx/RunStitchPanel.cpp (working copy)
@@ -199,6 +199,7 @@
makeFile.Close();
std::string resultFn(basename.mb_str(HUGIN_CONV_FILENAME));
std::string tmpPTOfnC = (const char *) m_currentPTOfn.mb_str(HUGIN_CONV_FILENAME);
+ std::string tmpDir((wxConfigBase::Get()->Read(wxT("tempDir"),wxT(""))).mb_str(HUGIN_CONV_FILENAME));
std::vector<std::string> outputFiles;
HuginBase::PanoramaMakefileExport::createMakefile(pano,
@@ -208,7 +209,8 @@
progs,
"",
outputFiles,
- makeFileStream);
+ makeFileStream,
+ tmpDir);
// cd to output directory, if one is given.
wxString oldCWD = wxFileName::GetCwd();
Index: src/hugin1/hugin/MainFrame.cpp
===================================================================
--- src/hugin1/hugin/MainFrame.cpp (revision 3627)
+++ src/hugin1/hugin/MainFrame.cpp (working copy)
@@ -547,6 +547,7 @@
wxString resultFnwx = scriptName.GetFullPath();
resultFn = resultFnwx.mb_str(HUGIN_CONV_FILENAME);
resultFn = utils::stripPath(utils::stripExtension(resultFn));
+ std::string tmpDir((wxConfigBase::Get()->Read(wxT("tempDir"),wxT(""))).mb_str(HUGIN_CONV_FILENAME));
std::vector<std::string> outputFiles;
HuginBase::PanoramaMakefileExport::createMakefile(pano,
@@ -556,7 +557,8 @@
progs,
"",
outputFiles,
- makefile);
+ makefile,
+ tmpDir);
}
}
SetStatusText(wxString::Format(_("saved project %s"), m_filename.c_str()),0);
Index: src/tools/pto2mk.cpp
===================================================================
--- src/tools/pto2mk.cpp (revision 3627)
+++ src/tools/pto2mk.cpp (working copy)
@@ -146,6 +146,7 @@
progs,
"",
outputFiles,
- makeFileStream);
+ makeFileStream,
+ "");
return 0;
}
Index: src/hugin_base/algorithms/panorama_makefile/PanoramaMakefileExport.cpp
===================================================================
--- src/hugin_base/algorithms/panorama_makefile/PanoramaMakefileExport.cpp (revision 3627)
+++ src/hugin_base/algorithms/panorama_makefile/PanoramaMakefileExport.cpp (working copy)
@@ -142,7 +142,8 @@
const PTPrograms& progs,
const std::string& includePath,
std::vector<std::string> & outputFiles,
- std::ostream& o)
+ std::ostream& o,
+ const std::string& tmpDir)
{
PanoramaOptions opts = pano.getOptions();
#ifdef __unix__
@@ -173,6 +174,17 @@
o << "# makefile for panorama stitching, created by hugin " << endl
<< endl;
+ // pass settings for different temporary directory
+ if (tmpDir != "") {
+ o << "# set temporary directory" << endl;
+#ifdef __unix__
+ o << "export TMPDIR=" << quoteStringShell(tmpDir) << endl;
+#else // WINDOWS
+ o << "export TEMP=" << quoteStringShell(tmpDir) << endl
+ << "export TMP=" << quoteStringShell(tmpDir) << endl;
+#endif
+ }
+
o << endl
<< endl
<< "# Tool configuration" << endl
Index: src/hugin_base/algorithms/panorama_makefile/PanoramaMakefileExport.h
===================================================================
--- src/hugin_base/algorithms/panorama_makefile/PanoramaMakefileExport.h (revision 3627)
+++ src/hugin_base/algorithms/panorama_makefile/PanoramaMakefileExport.h (working copy)
@@ -105,7 +105,8 @@
const PTPrograms & progs,
const std::string & includePath,
std::vector<std::string> & outputFiles,
- std::ostream & o);
+ std::ostream & o,
+ const std::string& tmpDir);
public:
@@ -118,7 +119,7 @@
{
createMakefile(o_panorama,
o_images, o_ptofile, o_outputPrefix, o_progs, o_includePath,
- o_outputFiles, o_output);
+ o_outputFiles, o_output, o_tmpDir);
return true; // let's hope so.
}
@@ -133,6 +134,7 @@
PTPrograms o_progs;
std::vector<std::string> o_outputFiles;
String o_includePath;
+ String o_tmpDir;
};