Load a Jamfile at the given directory. Returns nothing.
        Will attempt to load the file as indicated by the JAMFILE patterns.
        Effect of calling this rule twice with the same 'dir' is underfined.

def load_jamfile(self, dir, jamfile_module):
        """Load a Jamfile at the given directory. Returns nothing.
        Will attempt to load the file as indicated by the JAMFILE patterns.
        Effect of calling this rule twice with the same 'dir' is underfined."""
        assert isinstance(dir, basestring)
        assert isinstance(jamfile_module, basestring)

        # See if the Jamfile is where it should be.
        is_jamroot = False
        jamfile_to_load = b2.util.path.glob([dir], self.JAMROOT)
        if jamfile_to_load:
            if len(jamfile_to_load) > 1:
                get_manager().errors()(
                    "Multiple Jamfiles found at '{}'\n"
                    "Filenames are: {}"
                    .format(dir, ' '.join(os.path.basename(j) for j in jamfile_to_load))
                )
            is_jamroot = True
            jamfile_to_load = jamfile_to_load[0]
        else:
            jamfile_to_load = self.find_jamfile(dir)

        dir = os.path.dirname(jamfile_to_load)
        if not dir:
            dir = "."

        self.used_projects[jamfile_module] = []

        # Now load the Jamfile in it's own context.
        # The call to 'initialize' may load parent Jamfile, which might have
        # 'use-project' statement that causes a second attempt to load the
        # same project we're loading now.  Checking inside .jamfile-modules
        # prevents that second attempt from messing up.
        if not jamfile_module in self.jamfile_modules:
            previous_project = self.current_project
            # Initialize the jamfile module before loading.
            self.initialize(jamfile_module, dir, os.path.basename(jamfile_to_load))

            if not jamfile_module in self.jamfile_modules:
                saved_project = self.current_project
                self.jamfile_modules[jamfile_module] = True

                bjam.call("load", jamfile_module, jamfile_to_load)

                if is_jamroot:
                    jamfile = self.find_jamfile(dir, no_errors=True)
                    if jamfile:
                        bjam.call("load", jamfile_module, jamfile)

                # Now do some checks
                if self.current_project != saved_project:
                    from textwrap import dedent
                    self.manager.errors()(dedent(
                        """
                        The value of the .current-project variable has magically changed
                        after loading a Jamfile. This means some of the targets might be
                        defined a the wrong project.
                        after loading %s
                        expected value %s
                        actual value %s
                        """
                        % (jamfile_module, saved_project, self.current_project)
                    ))

                self.end_load(previous_project)

                if self.global_build_dir:
                    id = self.attributeDefault(jamfile_module, "id", None)
                    project_root = self.attribute(jamfile_module, "project-root")
                    location = self.attribute(jamfile_module, "location")

                    if location and project_root == dir:
                        # This is Jamroot
                        if not id:
                            # FIXME: go via errors module, so that contexts are
                            # shown?
                            print "warning: the --build-dir option was specified"
                            print "warning: but Jamroot at '%s'" % dir
                            print "warning: specified no project id"
                            print "warning: the --build-dir option will be ignored"