Skip to content

Use hash based renaming for dependencies#3

Merged
hughsk merged 6 commits into
masterfrom
static-rename
Dec 6, 2015
Merged

Use hash based renaming for dependencies#3
hughsk merged 6 commits into
masterfrom
static-rename

Conversation

@mikolalysenko
Copy link
Copy Markdown
Contributor

This patch implements content based renaming for dependencies. So instead of giving variables names like: Light_2_3_4_..., the new naming scheme renames variables to Light_<hash> where hash is a hash of the dependency index and the arguments to the bundle. This reduces code duplication due to nested dependencies and also makes reusing structures between modules (as in the complex dependency case) easier to do.

One problem right now though is that preprocessor macros aren't renamed. I think that this is a bug in glsl-descope-tokens, but I'm not sure. @hughsk or @mattdesl: Do you know how glslify-bundle handled renaming macro tokens (like #define PI 3.14...) previously?

@hughsk
Copy link
Copy Markdown
Member

hughsk commented Nov 28, 2015

Thanks @mikolalysenko! This looks super promising. Unsure what's causing macros not to be renamed, I believe that was working previously? It would rename any macros that weren't in the entry file. I'll review over this weekend and keep you posted :)

@hughsk
Copy link
Copy Markdown
Member

hughsk commented Nov 28, 2015

631d817 made macro renaming work before :)

@mikolalysenko
Copy link
Copy Markdown
Contributor Author

@hughsk thanks, all fixed now.

@mikolalysenko
Copy link
Copy Markdown
Contributor Author

Maybe in the future it might make some sense to scope macros to individual files so that they don't leak out of a particular module. As a hack, one way we could do this is just stick a bunch of #undef's at the end of each file after it is imported.

* Use standard formatting
* Use shallow-copy instead of JSON.parse for cloning tokens
* Update test names
* Pull in murmurhash3_gc directly to save on bundle size
@hughsk hughsk merged commit ec12403 into master Dec 6, 2015
hughsk added a commit to glslify/glslify that referenced this pull request Dec 6, 2015
Most notable is glslify-bundle@4. See also:
glslify/glslify-bundle#3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants