Hello,
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.
So I've made another patch (the v1). This one adds #hugin_tempdir to
the pto file. Also according changes are done to the createMakefile().
This one doesn't need to change any function declaration. That's why I
like this one much more than the previous one. The problem is that
evidently I have not done all necessary changes because #hugin_tempdir
is always saved empty.
Can someone please point me where I should continue?
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.
The only change in makefile is that it adds:
export TMPDIR=/path/to/temporary/directory
for Linux and Mac OSX and:
set TEMP=\path\to\temporary\directory
set TMP=\path\to\temporary\directory
for windows
--~--~---------~--~----~------------~-------~--~----~
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 3626)
+++ 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 3626)
+++ 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 3626)
+++ 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 3626)
+++ 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 3626)
+++ 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 << "set TEMP=" << quoteStringShell(tmpDir) << endl
+ << "set 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 3626)
+++ 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;
};
Index: src/hugin1/base_wx/RunStitchPanel.cpp
===================================================================
--- src/hugin1/base_wx/RunStitchPanel.cpp (revision 3626)
+++ src/hugin1/base_wx/RunStitchPanel.cpp (working copy)
@@ -141,6 +141,7 @@
// get options and correct for correct makefile
PanoramaOptions opts = pano.getOptions();
opts.outputFormat = PanoramaOptions::TIFF_m;
+ opts.tempdir = (wxConfigBase::Get()->Read(wxT("tempDir"),wxT(""))).mb_str(wxConvLocal);
if (opts.enblendOptions.length() == 0) {
// no options stored in file, use default arguments in config file
Index: src/hugin1/hugin/MainFrame.cpp
===================================================================
--- src/hugin1/hugin/MainFrame.cpp (revision 3626)
+++ src/hugin1/hugin/MainFrame.cpp (working copy)
@@ -742,6 +742,7 @@
wxConfigBase* config = wxConfigBase::Get();
opts.enblendOptions = config->Read(wxT("Enblend/Args"),wxT(HUGIN_ENBLEND_ARGS)).mb_str(wxConvLocal);
opts.enfuseOptions = config->Read(wxT("Enfuse/Args"),wxT(HUGIN_ENFUSE_ARGS)).mb_str(wxConvLocal);
+ opts.tempdir = config->Read(wxT("tempDir"),wxT("")).mb_str(wxConvLocal);
pano.setOptions(opts);
wxCommandEvent dummy;
Index: src/hugin_base/panodata/Panorama.cpp
===================================================================
--- src/hugin_base/panodata/Panorama.cpp (revision 3626)
+++ src/hugin_base/panodata/Panorama.cpp (working copy)
@@ -810,6 +810,7 @@
o << "#hugin_outputJPEGQuality " << output.quality << endl;
o << "#hugin_outputImageTypeHDR " << output.outputImageTypeHDR << endl;
o << "#hugin_outputImageTypeHDRCompression " << output.outputImageTypeHDRCompression << endl;
+ o << "#hugin_tempdir " << output.tempdir << endl;
#ifdef __unix__
// reset locale
@@ -1704,6 +1705,7 @@
options.outputHDRBlended = false;
options.outputHDRLayers = false;
options.outputHDRStacks = false;
+ options.tempdir = "";
ptoVersion = 1;
@@ -2133,6 +2135,9 @@
options.outputImageTypeHDR = value;
} else if (var == "#hugin_outputImageTypeHDRCompression") {
options.outputImageTypeHDRCompression = value;
+
+ } else if (var == "#hugin_tempdir") {
+ options.tempdir = value;
}
}
}
Index: src/hugin_base/panodata/PanoramaOptions.h
===================================================================
--- src/hugin_base/panodata/PanoramaOptions.h (revision 3626)
+++ src/hugin_base/panodata/PanoramaOptions.h (working copy)
@@ -237,6 +237,8 @@
outputImageTypeHDR= "exr";
outputImageTypeHDRCompression = "";
+ tempdir = "";
+
enblendOptions = "";
enfuseOptions = "";
hdrmergeOptions = "";
@@ -391,6 +393,8 @@
std::string outputImageTypeHDR;
std::string outputImageTypeHDRCompression;
+ std::string tempdir;
+
std::string enblendOptions;
std::string enfuseOptions;
std::string hdrmergeOptions;
Index: src/hugin_base/algorithms/panorama_makefile/PanoramaMakefileExport.cpp
===================================================================
--- src/hugin_base/algorithms/panorama_makefile/PanoramaMakefileExport.cpp (revision 3626)
+++ src/hugin_base/algorithms/panorama_makefile/PanoramaMakefileExport.cpp (working copy)
@@ -173,6 +173,17 @@
o << "# makefile for panorama stitching, created by hugin " << endl
<< endl;
+ // pass settings for different temporary directory
+ if (opts.tempdir != "") {
+ o << "# set temporary directory" << endl;
+#ifdef __unix__
+ o << "export TMPDIR=" << quoteStringShell(opts.tempdir) << endl;
+#else // WINDOWS
+ o << "set TEMP=" << quoteStringShell(opts.tempdir) << endl
+ << "set TMP=" << quoteStringShell(opts.tempdir) << endl;
+#endif
+ }
+
o << endl
<< endl
<< "# Tool configuration" << endl