2011-07-25

Mac OS X Lion Fiddly Fun Facts

X Windows Is There

At least if it was installed before. The good news is that it's using xorg-server 1.10.2, which enables a few extensions used by modern X software. So, for example, you're ssh'ing over to Linux box and use Emacs, you won't get the warnings that you used to.

It's not entirely Lion-ized, though. For example, you can only resize a window from the lower right using the old resize control.

Java Is There, and the Developer Kit Download Might Not Be Needed

After the recent Java Drama in the Leopard versions of Mac OS X, Apple started delivering the sources and native headers for Java in a separate download on {{developer.apple.com}}, which was annoying if you were compiled JNI modules.

In Mac OS X Lion, Java is not included, but, as you as you start a Java program (any Eclipse or RCP-based application, for example), you'll be offered to download it. As before, “Java” on Mac OS X really means the JDK, not just the JRE. But it also looks like the JNI headers are included in this civilian download as well, which is a welcome restoration of affairs.

The current version is the same as Snow Leopard's: 6u26. This has an escape-analysis-related JIT bug that can affect long-running applications; version 6u27 is supposed to fix this.

GCC 4.2 from Xcode 4.1 Uses The LLVM Front End

Notice:

$ gcc --version
i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)

This shouldn't break anything, unless, I suspect, you have truly pathological C or C++ code. Since the GCC 4.2 backend is still used, you can safely link with GCC-compiled libraries from the GCC front-end version of GCC 4.2

2010-03-19

Directory References In WiX

I love the way WiX gives you control over a Windows Installer project, and that it integrates with a variety of building styles (at work, I use it in conjunction with Cygwin make and Perl), but sometimes, sometimes, the documentation leaves a bit to be desired. Most of the time, I'm interested in element syntax and semantics, so I can search for WiX foo element, but it's harder to search for the finer details, like the various forms of property reference syntax beyond simple constructs like [INSTALLDIR].

In a recent effort, I was trying to construct a registry entry inside an merge module (MSM) — in this case, so that a Visual Studio .NET Add Reference dialog would recognize an assembly. The way this works is that you construct a registry key under Software\Microsoft\.NETFramework\AssemblyFolders (under the appropriate root, like HKEY_CURRENT_USER) whose default key value is a string with the path to a directory that should be scanned for assemblies.

Now, I suppose you could use [TARGETDIR] and then duplicate the directory part of the path that contains your assemblies, but [TARGETDIR] inside merge modules is a tempermental beast that oftens ends up being set to the eminently useless value of C:\. So it's better to tie the directory path to something that is more under your control, like an actual file or component that the MSM is delivering. Ideally, you should be able to change the location of the directory, and the registry element won't have to change. And that registry XML and the component XML probably will be close together, so it should be easier for future maintainers to see what's going on.

I knew about the [#file] syntax for getting the effective installed path of the file, but in this case I needed a directory path, not a file path. So I Googled and Googled and finally found this tantalizing discussion, and I was almost there. The problem was: where could I find the authoritative description of what It is better to use [$component] actually referred to? It turns out that trying to search for a literal [$ in Google or Bing brings up a lot of junk. I also tried search for bracket and dollar hoping that some piece of documentation would spell out the punctuation. No such luck (although, hey, now I've done it!).

Now, I think part of the reason for the state of WiX documentation, such as it is, has to do with the fact that's largely a civilized but largely translucent front end to the MSI runtime, which is pretty well documented in MSDN and various SDK help files. Still, developers working in WiX aren't really interested in a lot of MSI detail, except when they surface in WiX directly. So, eventually, I found this documentation on how MSI resolves property names, keys, and other strings. While I don't expect the WiX documentation to clone or rewrite this kind of documentation, and we all know that links can change (especially, ugh, on the MSDN site), the usability of WiX depends a lot on how developers can figure out how to get the MSI machinery to work for them. In particular, this level of detail is needed to make clear that, for example, in [$componentid], the string really is naming a component with its ID, not a file.

And of course, showing a useful fragment says a lot, too, so I humbly submit this:

<Component Id="ACME_DotNET_Client_AssemblyFolder" Guid='F78BCC5-41AD-4026-AEDB-060F27783697'>
    <RegistryKey Root="HKLM"
                 Key="Software\Microsoft\.NETFramework\AssemblyFolders\ACME_DotNET"
                 Action="createAndRemoveOnUninstall" >
        <RegistryValue Type="string" Value="[$Client_Files]"/> <!-- Directory reference -->
    </RegistryKey>
</Component>

<Directory Id='BinDirectory' Name='bin'>
   <Component Id='Client_Files' Guid='936AA0E-7D75-461E-8532-D0DF7829E2F9'>
       <File Id='acmeclient.dll' Name='acmeclient.dll' Source="$(sys.SOURCEFILEDIR)client\Win32\VC8\Release\acmeclient.dll" KeyPath='yes' />
   </Component>
   <Component Id='Extendo_Files' Guid='43FA5CF4-5A4D-4988-918D-34D8AA228ECC'>
       <File Id='acmeextendo.dll' Name='acmeextendo.dll' Source="$(sys.SOURCEFILEDIR)extendo\Win32\VC8\Release\acmeextendo.dll" KeyPath='yes' />
   </Component>
</Directory>

These elements would typically be nested under a Directory element. Notice how we only refer to one of the components, Client_Files, that owns an assembly file in the directory. And, of course, that the registry value is [$Client_File], and not, say [$acmeclient.dll] or maybe even [#BinDirectory].

Hope this helps (and is findable by other souls in need).

2008-08-21

Using using in C# - a little pitfall

The using clause in C# is pretty nifty. Wrap an initializer in the first part of using, and, no matter how the code in body exits, the object will be disposed of using its IDisposable interface. .NET defines a lot of such managed object classes for processes, mutexes, and so on. Well, I was stealing borrowing some code from an example that looked like: using (Process p = new Process()) { . . . p.WaitForExit(); } but I needed to return the process and wait for it somewhere else instead, outside this snipped. So I wrote: using (Process p = new Process()) { . . . return p; } As soon as the caller used WaitForExit() on the process, it blew up, because the process was disposed of before it was returned ! While I suppose there could be reasons for returning disposed objects — after all, they are still valid objects — this kind of thing is usually a braino. It would be nice if the compiler issued a warning like: Hey, bub, do you really want to return a disposed object ?

2008-05-13

PHP Goonz


PHP Goonz, originally uploaded by rpkrajewski.

No comment.

2008-04-30

Here's What JDK 6 in Mac OS X Gets You:

Finally, Apple has shipped JDK 6 for Mac OS X 10.5. It's only for Intel Macs that can run 64-bit code, like Core 2 Duos and Xeons. If you have an early Intel Mac, you're probably out of luck.

You can run pure Java programs in 64-bit mode.

But a lot of popular programs, like those based on the Eclipse Rich Client Platform, cannot run in the new JDK. That includes Eclipse and Azureus.

However, you can use Eclipse as a development environment for JDK 6-based programs. Eclipse will detect the JDK 6 runtime, and you can use it in a Java project. If you run a little program like this:

public class Main {
public static void main(String[] args) {
 System.out.print("os.arch: ");
 System.out.println(System.getProperty("os.arch"));
}
}

It will print out:

os.arch: x86_64

instead of

os.arch: i386

as it would with the default Mac OS X JVM (1.5, 32 bit).

Whoopee !