Fun with Autotools and XUL

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.

One thought on “Fun with Autotools and XUL

  1. James Boston

    Maybe you could try a bit of indirection. For example, starting a shell script that changes the working directory and then executes autoconf. However, I’m not sure if you can start shell scripts with nsIProcess. But there is another way.

    This method will simulate clicking double clicking a file for launching it:

    var file = Components.classes[“@mozilla.org/file/local;1”]
    .createInstance(Components.interfaces.nsILocalFile);
    file.initWithPath(“/path/to/script.sh”);
    file.launch();

    One big drawback of this method, unfortunately, is that you can’t pass arguments to the process.

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *