Home GnuPG

Allow in-memory maps to be registered in libphutil
10fca52d0ff6Unpublished

Unpublished Commit ยท Learn More

Repository Importing: This repository is still importing.

Description

Allow in-memory maps to be registered in libphutil

Summary:
This allows libphutil to have maps and libraries registered from an existing array. Currently when Phage runs (or any similar mechanism that bundles PHP into a single file or stream), all calls to PhutilSymbolLoader will return an empty set of classes when querying, because the appropriate maps haven't been loaded.

In my code, I'm using the following to load in the libphutil maps after concatenating all of the source files:

    // $library is the library name, $map is the map returned
    // from getLibraryMap.
    foreach ($maps as $library => $map) {
      $library_serialized = base64_encode(serialize($library));
      $map_serialized = base64_encode(serialize($map));
      $bootstrap->addText(<<<EOF

PhutilBootloader::getInstance()->registerInMemoryLibrary(
  unserialize(base64_decode("$library_serialized")),
  unserialize(base64_decode("$map_serialized")));

EOF
      );
    }

Test Plan: Tested inside Omni (the UNIX shell I'm working on) as part of it's bundling process (so that scripts can be run on systems without Omni).

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

Maniphest Tasks: T6844

Differential Revision: https://secure.phabricator.com/D11115

Details

Event Timeline

James Rhodes <jrhodes@redpointsoftware.com.au> committed rPHUTIL10fca52d0ff6: Allow in-memory maps to be registered in libphutil (authored by James Rhodes <jrhodes@redpointsoftware.com.au>).Jan 2 2015, 2:24 AM