A tool for combining many C and/or C++ files into one file.
SeaPool.new do |a|
# these files will be combined into output
a.add_input 'src/input1.cpp'
a.add_input 'src/input2.cpp'
a.add_input 'src/sub/input3.cpp'
a.add_input 'src/input4.cpp', 'src/input5.cpp', 'src/input6.cpp'
# search for files here (e.g. #include "some_file.cpp")
a.add_include 'include'
a.add_include 'src'
a.add_include 'src/sub'
a.add_include 'src/another1', 'src/another2'
# search for system files here (e.g. #include <some_file.h>)
a.add_system_include '/opt/somearch/include'
a.add_system_include '/opt/somearch2/include', '/opt/somearch3/include'
# never expand these files
a.add_ignore 'include/to_be_ignored.h'
a.add_ignore 'include/another_to_be_ignored1.h', 'include/another_to_be_ignored2.h'
# the combined output file (can only be one file)
a.set_output 'combined.cpp'
).runOr, a shorter version of the same example in the terminal:
bundle exec sea_pool --include=include --system=/opt/somearch/include --ignore=include/to_be_ignored.h --output=combined.cpp src/input1.cpp src/input2.cpp- expands
#include#include""if a file is found in theincludesearch path#include<>if a file is found in thesystem_includesearch path
- will not expand an
#includeif- no match is found in the search path
- a match is found in the exclude list
- non-exluded match has already been expanded
- comments out
#includewhich have already been expanded (also a limitation) - inserts
#fileinto output so that compile time messages can be referenced back to the original files - non-recursive and line based
- depends only on Ruby stdlib (should work with your system Ruby)
- available as standalone executable via bin/sea_pool_exporter
- does not evaluate include guards or
#pragma once - does not support including same file multiple times (workaround for the above)
- does not interpret preprocessor variables
- input files must be written in a way that makes them suitable for amalgamation
- ensure no file static name collisions
- ensure no 'using namespace' in c++
- it's a preprocessor, it won't check if your code can compile
- lines that are not UTF-8 are passed through to output without any processing
- doesn't consider if a file is a link
bundle exec sea_pool_exporter > your_executable_fileor
bundle exec sea_pool_exporter --output=your_executable_fileThis file can be kept with your project.
- might evaluate guards
- might expand other macros
- might fix file static name problems
- Don't combine C and C++ into the same file unless you want to compile C with a C++ compiler
- ensure file static preprocessor macros are
#undefat end of a file
- sometimes fewer source files can make a project easier to distribute
- sometimes fewer source files will speed up compile time (Arduino + GNU tools ported to Windows!)