Running CMD line tools during UCB pre process

I’m using a 3rd party tool (ImageMagick) to process a series of .PNG files that are output into the project folder and ultimately built into the final player.

Inside the repository I have a static distributable version of the ImageMagick tool. A couple of the initial commits were spent resolving the tool dependencies which the UCB now no longer complains about. The process now however, while not throwing out any dependency issues, doesn’t produce any result and exits with code 132 (not sure what this is yet).

Should it at all possible to run a command line tool during the UCB pre process phase or is this behaviour restricted?

The behavior isn’t restricted. How are you running the tools?

The code snippet looks like:

public static bool ResizeUnity(string inputPath, string outputPath, int width, int height)
        {
            string toolHome = Application.dataPath + "/ImageProcessing/Editor";
            string magickHome = toolHome + "/imagemagick/6.9.6-3";

            string[] libs =
            {
                 toolHome + "/libpng/1.6.26/lib",
                 toolHome + "/libtiff/4.0.6_3/lib",
                 toolHome + "/jpeg/8d/lib",
                 toolHome + "/freetype/2.7/lib",
                 toolHome + "/xz/5.2.2/lib",
                 toolHome + "/libtool/2.4.6_1/lib",
            };

            string textToolPath = magickHome + "/bin/convert";

            ProcessStartInfo startInfo = new ProcessStartInfo
            {
                FileName = textToolPath,
                Arguments = string.Format("'{0}' -resize {2}x{3} '{1}'", inputPath, outputPath, width, height),
                UseShellExecute = false,
                RedirectStandardOutput = true,
                RedirectStandardError = true   
            };

            startInfo.EnvironmentVariables.Add("MAGICK_HOME", magickHome);
            startInfo.EnvironmentVariables.Add("DYLD_LIBRARY_PATH", string.Join(":", libs));
            startInfo.EnvironmentVariables.Add("MAGICK_DEBUG", "exception,trace");

            Process p = new Process
            {
                StartInfo = startInfo
            };

            try
            {
                if (!p.Start())
                {
                    Debug.LogError("ImageProcessing: Failed to start process.");
                }
                else
                {
                    string error = p.StandardError.ReadToEnd();

                    if (!string.IsNullOrEmpty(error))
                    {
                        Debug.LogError("ImageProcessing ERROR: " + error);
                    }

                    string output = p.StandardOutput.ReadToEnd();

                    if (!string.IsNullOrEmpty(output))
                    {
                        Debug.LogError("ImageProcessing OUTPUT: " + output);
                    }

                    p.WaitForExit();

                    if (p.ExitCode != 0)
                    {
                        Debug.LogError(string.Format("ImageProcessing: Non-zero exit code {0}.", p.ExitCode));
                    }

                }
            }
            catch (Exception e)
            {
                Debug.LogError("ImageProcessing EXCEPTION: " + e);
            }

            return true;
        }

The build processing works on my local box but it could be simply that I have some libraries setup that aren’t present on UCB. When I was setting up the first couple of dependencies I would get output from p.StandardError.ReadToEnd() that would point me to what it was looking for, now I get nothing. The only information I have is that the process is terminating with exit code 132. I couldn’t find any google material for the exit codes but I guess if CMD tools should be working then that is the next thing I’ll look into.

What platform are the tools compiled for? All of our builders are running OSX so those binaries will need to be compatible.

The binaries are built for OS X 64 bit. I am running macOS Sierra. I have had someone else pull the project onto their OS X install (Sierra 10.12.1) and, after adding an unresolved library dependency in the project, had the build process work on their machine.

Hmm I’m not sure what else it might be. Can you PM me your project info and where I can get a copy of these tools so I can run some local tests?