Giter Site home page Giter Site logo

usaco-bundler's Introduction

usaco-bundler

Bundles #include directives into a single output file, which is useful for contests like USACO where only a single file can be uploaded. This allows you to create useful utility functions in advance and simply #include them during the contest. This works recursively, such that the #includes in the files you include will also be bundled. Note that STL libraries will not be included in the output file, and that multiple instances of the same file will not be bundled twice.

Usage

Use your C++ compiler (clang, GCC, etc.) to compile main.cpp.

g++ main.cpp -o bundle
./bundle ../path/to/your-entry-file.cpp ./out-file.cpp

If you don't specify an output file, the contents will be sent to the standard output. This can be piped to the clipboard, your own script, etc.

On MacOS (bash):

./bundle ../cow-herding/main.cpp | pbcopy

On Windows (CMD/PowerShell):

./bundle ../cow-herding/main.cpp | clip.exe

Example

main.cpp:

#include <iostream>
#include <epic.hpp>
#include "cool.cpp"

int main() {
    std::cout << cool() << '\n';
}

epic.hpp:

#include <string>
std::string EPIC_STRING = "EPIC";

cool.cpp:

#include <string>
#include "epic.hpp"
std::string cool() {
    return EPIC_STRING;
}

Output:

#include <iostream>
#include <string>

// File: epic.cpp
std::string EPIC_STRING = "EPIC";

// File: cool.cpp
std::string cool() {
    return EPIC_STRING;
}

int main() {
    std::cout << cool() << '\n';
}

As you can see, header files and normal .cpp files work, both double-quote and angle-bracket #includes work, and duplicate #includes are ignored. All STL imports are hoisted to the top of the file.

Wait, isn't using other people's code cheating?

This script basically copy-pastes external #includes into a single file with the rest of your code, something you could do yourself but also something that you may not want to waste time doing. It's not cheating to use it. However, it IS cheating to #include other people's code, with or without this tool.

License

MIT

usaco-bundler's People

Contributors

101arrowz avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.