Giter Site home page Giter Site logo

osschar / cpp-merge Goto Github PK

View Code? Open in Web Editor NEW

This project forked from fastalien/cpp-merge

0.0 0.0 0.0 1.7 MB

Command line tool to produce single source file from multiple C/C++ files.

License: MIT License

JavaScript 1.88% C++ 4.66% C 0.26% TypeScript 93.20%

cpp-merge's Introduction

cpp-merge

Tool to produce a single source file from multiple C/C++ files. It was developed mainly to be used in programming contests that require submitting a solution as a single source file.

Install

Prerequisites

  • Node.js
  • npm
  • Yarn (optional)

Installation from npm

npm install -g cpp-merge

Installation from source

Clone git repository
git clone [email protected]:FastAlien/cpp-merge.git
Build

Go to the project directory and run the following commands.

Using npm:

npm ci
npm run build

Using Yarn:

yarn install
yarn build
Link package

Go to the project directory and run the following command:

npm -g link

Usage

This tool will produce a single source file from multiple C/C++ files. By default produced content is displayed on the standard output. To save it into a file use option -o or --output.

File passed as an argument will be processed similarly to what the preprocessor would do. It means all included local files (ex. #include "header.hpp") will be processed and added to output in place of the include directive. Program will search for include files first in the directory where the currently processed file is located and then in additional include directory, if it was specified in program arguments (option -i or --include).

Files containing #pragma once will be processed only once, so use this directive to avoid duplication of content of files in the output and to reduce its size.

After processing all included files, the program will try to find related source files for each of included local header files. If a file with the same base name and extension .c or .cpp exists, it will be appended to the output. Program will search first in the same directory where the main source file is located and then in an additional source directory, if it was specified in program arguments (option -s or --source). If the header was included using relative path ex. #include "one/two/three.hpp" the program will search for three.c or three.cpp in one/two/ or ${sourceDirectory}/one/two/. First found file will be appended to the output.

Program will detect duplication of system header includes, so output will contain only a unique set of them, ordered alphabetically. Any of the processed header and source files will not be changed.

Display the build-in help:

cpp-merge --help

Usage examples

Process main.cpp and display produced content on the standard output:

cpp-merge main.cpp

Process main.cpp and save output to file output.cpp:

cpp-merge --output output.cpp main.cpp

Specify additional include and source directory:

cpp-merge --include ../include --source ../src main.cpp

cpp-merge's People

Contributors

fastalien avatar dependabot[bot] avatar osschar 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.