Implement flexible target specification

See commit message.
Could you also add tests for files like invalid json, RUST_TARGET_PATH, invalid specification with valid json, etc? These seems like routine errors that all shouldn't ICE and should have reasonable error messages.