Field Notes from the Workshop · № 303 Development

Fun with Autotools and XUL

Joshua Doodnauth Software Engineer · Toronto
February 12, 2009 2 min read 246 words

In my quest to create a packager for XULRunner apps, I figured I should use the Autotools to package up the app and distribute it as a tarball. This will allow the developer to distribute on any flavor of Linux, and the end-user will just need to do the standard untar, configure, make, install.

For Autotools, I must use several command-line tools, autoscan, autoconf, and automake, and since im using it through my XUL app, I must reference to /usr/bin/ which is where these tools are stored.

function runAutoscan()

{

var appRootDir= Components.classes[“@mozilla.org/file/local;1”]

.createInstance(Components.interfaces.nsILocalFile);

appRootDir.initWithPath(“//”);

appRootDir.append(“usr”);

appRootDir.append(“bin”);

appRootDir.append(“autoscan”);

var process = Components.classes[“@mozilla.org/process/util;1”]

.createInstance(Components.interfaces.nsIProcess);

process.init(appRootDir);

var args = [targetPath];

process.run(true, args, args.length);

}

  1. Where ‘appRootDir’ is an instance nsILocalFile, Initalize the path as the root directory ‘//’

  2. Append the each directory and the command to the root

  3. Create an instance of nsIProcess

  4. Initalize the process with the path to the command

  5. Include any agruments in a separate variable, in this case I used the directory of where I want to package

  6. Finally just run the process

This method works perfectly if you want to run command-line utilities in the directory you are working in, or in this case where the command takes in a source. Unfortunatly, autoconf and automake don’t seem to work if you are not in the working directory.