Giter Site home page Giter Site logo

quom's People

Contributors

maxsagebaum avatar viatorus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

quom's Issues

when source files have no newline at EOF, content of next file is concatenated right after last closing curly bracket

When one of source files has no newline at EOF, the "#include ..."s of the next file appears right after the last closing curly bracket and that causes a compilation error.
I know it's a trivial problem to resolve when compiling fails but it would be nice to ensure the content of all source files are separated by newline.

// bad.cpp
void foo(){
// there is no newline at EOF, file ends right after this closing curly bracket.
}

// b.cpp
#include <iostream>
// this include is at first line and located outside current build directory

// main.cpp

include "bad.hpp"
include "b.hpp"
...

And the source file quom produces has something like:

void foo(){
}#include <iostream> // this include comes from b.cpp

I wrote a test to demonstrate this problem. The following test will fail at current commit which is 4633b5aa.


from io import StringIO
from pathlib import Path

from quom import Quom

FILE_MAIN_CPP = """\
#include "a.hpp"
#include "b.hpp"

int main() {

  return 0;
}
"""

FILE_A_HPP = """\
#ifndef A_HPP_
#define A_HPP_

#endif //A_HPP_
"""

FILE_A_CPP = """\
#include "a.hpp"
#include "b.hpp"

int mid() {

}"""

FILE_B_HPP = """\
#ifndef B_HPP_
#define B_HPP_

#endif //B_HPP_
"""

FILE_B_CPP = """\
#include <memory>
"""

RESULT = """\
#ifndef A_HPP_
#define A_HPP_

#endif //A_HPP_

#ifndef B_HPP_
#define B_HPP_

#endif //B_HPP_

int main() {

  return 0;
}

void mid() {

}
#include <memory>
"""


def init():
    with open('main.hpp', 'w+', encoding='utf-8') as file:
        file.write(FILE_MAIN_CPP)

    with open('a.hpp', 'w+', encoding='utf-8') as file:
        file.write(FILE_A_HPP)

    with open('a.cpp', 'w+', encoding='utf-8') as file:
        file.write(FILE_A_CPP)

    with open('b.hpp', 'w+', encoding='utf-8') as file:
        file.write(FILE_B_HPP)

    with open('b.cpp', 'w+', encoding='utf-8') as file:
        file.write(FILE_B_CPP)


def test_issue_one(fs):
    init()

    dst = StringIO()
    Quom(Path('main.hpp'), dst)

    assert dst.getvalue() == RESULT

Can't expand headers within `<>`

I believe the code is designed to expand headers within "" only.
For example when I am trying to amalgamate this code primecount api,
since in #include <primecount.hpp> the header name primecount.hpp is enclosed by <> it fails to pull in the required code.
Ideally we should use a lookup table to check if a header is native c++ header or not . Dont you think so?
Please do update if you can get quom to work with the above repo.

PS: This ticket has nothing to do with my other ticket. Now I am on macOS and I dont have that issue here.

option to skip already included files

Hello and thanks for creating such awesome utility! I'm using it in my CTRE project. I noticed sometimes quom include same file multiple times.

Would be possible to add an option to ignore already included files? Based on normalised URL preferably.

Thanks! ❤️

option to remove comments

Add an option to remove comments.

This will help make clear that development is supposed to happen on the non-combined file.

You could keep comments that start with ! to maintain license information for the first file, or just keep all comments in the first file and remove all comments in other files.

quom command not found

Hello,

I've installed quom using pip3 but when I try to run the command I've:

Command 'quom' not found, did you mean:

  command 'quot' from deb quota

Try: apt install <deb name>

Python3 and pip3 versions:

python3 --version
Python 3.6.9
pip3 --version
pip 9.0.1 from /usr/lib/python3/dist-packages (python 3.6)

Ready?

Does it work yet or is it still in dev?

Issues when used in conjunctions with CMake

I have a C++ project that uses CMake. The paths are provided by CMake, meaning they aren't wholly relative. This causes quom to not work with this. Is there a way to specify a source directory to always look for files in? All of my files are organized in a tree structure so that if I could specify "look from x directory" quom would find everything it needs.

Open files with UTF-8 encoding

On Windows, Python uses ANSI encoding as its default text encoding when opening files. This is fine if you only use ASCII characters since ANSI is compatible with ASCII. But otherwise you will get errors like the following:

  File "C:\Users\Username\AppData\Roaming\Python\Python39\site-packages\quom\__main__.py", line 54, in run
    main(sys.argv[1:])
  File "C:\Users\Username\AppData\Roaming\Python\Python39\site-packages\quom\__main__.py", line 49, in main
    Quom(args.input_path, file, args.stitch, args.include_guard, args.trim, args.include_directory,
  File "C:\Users\Username\AppData\Roaming\Python\Python39\site-packages\quom\quom.py", line 49, in __init__
    self.__process_file(Path(), src_file_path, False, True)
  File "C:\Users\Username\AppData\Roaming\Python\Python39\site-packages\quom\quom.py", line 70, in __process_file
    tokens = tokenize(file.read())
UnicodeDecodeError: 'gbk' codec can't decode byte 0xbf in position 2: illegal multibyte sequence

(GBK, or CP936, is the ANSI encoding under Simplified Chinese)

My suggestion is to change to using UTF-8 encoding to open files, which is more appropriate for most programmers:

file_path.open(encoding='utf-8')

Feature request - Additional directories to search for sources

Hi, I found this package very useful, but when trying to use it - encounter with a small problem. The case when sources are located in different directory then their headers - are not supported. The common folder structure of any project can be as follows:
project/
   public/
   include/
   src/
So it would be nice if it will be possible to specify source directories relative to include directories. For instance via --relative_source_dir or -SI argument.
The most common use can be: -SI "./" -SI "../" -SI "../src"
By default the directory suffixes array is ["./'] but if at least one -SI argument provided it should be overwritten.

error while loading shared libraries: MSVCR120.dll: cannot open shared object file: No such file or directory

I am on MinGW x64 system hosted on Windows7
I installed quom via

pip install --user quom
PATH=/c/users/hp/.local/bin:$PATH
quom crt.hpp crt_gen.cpp

C:/users/hp/.local/bin/quom.exe: error while loading shared libraries: MSVCR120.dll: cannot open shared object file: No such file or directory

My understanding is MSVCR120.dll comes with Microsoft Visual studio . If anything more needs to be installed for quom that should go into documentations.

There is no issue with the usual way of running this which is like this:

$ g++ crt.cpp -o crt.exe -L/mingw64/bin -I/mingw64/include/flint -lgmp -lflint -lpthread
$ ./crt 2342

Everything is Fine

No new amalgamated file generated

I am on MinGW x64 system hosted on Windows7
I installed quom via

pip install --user quom
PATH=/c/users/hp/.local/bin:$PATH
quom crt.hpp crt_gen.cpp

It runs silently without any output or error message. No new file crt_gen.cpp generated.
I have searched not just under current folder but under / , /home, /home/hp, /c/users/hp/.local/bin as well.

There is no issue with the usual way of running this which is like this:

$ g++ crt.cpp -o crt.exe -L/mingw64/bin -I/mingw64/include/flint -lgmp -lflint -lpthread
$ ./crt 2342

Everything is Fine

Feature Request - List of symbols to export

My use-case, I have an older library that I need to keep for backwards compatibility. It has some symbols that conflict with other parts of the codebase, and I really just need a handful of functions from it. I currently use some compiler-specific flags to rename symbols.

The ask is if this could make everything static, except for a list of symbols (or something that does the inverse - takes a list of symbols and makes them static)

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.