Created
April 19, 2010 11:08
-
-
Save icebreaker/370918 to your computer and use it in GitHub Desktop.
Scan and create a QT Creator project file which can be included in another project.
This file contains hidden or 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 | |
| def ScanForFiles(sources, headers, pattern) | |
| Dir[pattern].each do |f| | |
| if FileTest.directory?(f) | |
| ScanForFiles(sources, headers, "#{f}/*") | |
| else | |
| if f =~ /.h$/ | |
| headers.push(f) | |
| else | |
| if f =~ /.cpp$/ | |
| sources.push(f) | |
| end | |
| end | |
| end | |
| end | |
| end | |
| puts 'Scanning ...' | |
| sources = [] | |
| headers = [] | |
| ScanForFiles(sources, headers, '*') | |
| puts 'Writing QT Project ...' | |
| file = File.new('project.pri','w') | |
| file.write("INCLUDEPATH += $$PWD\n") | |
| file.write("DEPENDPATH += $$PWD\n\n") | |
| if sources.size > 0 | |
| file.write('SOURCES += ') | |
| sources.each do |s| | |
| if s == sources.last | |
| file.write("#{s}\n") | |
| else | |
| file.write("#{s} \\\n\t") | |
| end | |
| end | |
| end | |
| if headers.size > 0 | |
| file.write('HEADERS += ') | |
| headers.each do |h| | |
| if h == headers.last | |
| file.write("#{h}\n") | |
| else | |
| file.write("#{h} \\\n\t") | |
| end | |
| end | |
| end | |
| file.close() | |
| puts 'Done' | |
| gets |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment