-
-
Save antongaenko/0b69b1c1079028ae355d44883bab6539 to your computer and use it in GitHub Desktop.
Generates a naïve umbrella header by assuming every header in the working folder or any of its subfolders is public and should be included
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# Your umbrella header needs a comment in it like the below so this script | |
# knows which parts to replace | |
# | |
# /* IMPORTS BEGIN */ | |
# | |
# /* IMPORTS END */ | |
MODULE = ARGV[0] || File.basename(Dir.getwd) | |
MODULE_HEADER = "#{MODULE}.h" | |
REPLACEMENT_TAGS = /\/\* IMPORTS BEGIN \*\/.*\/\* IMPORTS END \*\//m | |
imports = Dir.glob("**/*.h").select { |f| File.basename(f) != MODULE_HEADER } | |
.map { |f| "#import <#{MODULE}/#{File.basename(f)}>" } | |
.join("\n") | |
imports = "/* IMPORTS BEGIN */\n#{imports}\n/* IMPORTS END */" | |
header = File.read(MODULE_HEADER) | |
imports = header.gsub(REPLACEMENT_TAGS, imports) | |
File.write(MODULE_HEADER, imports) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment