Coder Social home page Coder Social logo

json2cmake's People

Contributors

abigailbuccaneer avatar arichardson avatar jfmherokiller 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

Watchers

 avatar  avatar  avatar

json2cmake's Issues

Windows paths should use forward slash

When running on Windows, we output paths like "c:\users\...", and \u is interpreted as an escape sequence. We should instead output "c:/users/..." even if the compile_commands.json uses backslashes.

TypeError: 'set' object does not support indexing

Using 13e0a6b with Python 3.7.1 on a following (redacted, simplified, but roughly the same) compile_commands.json, I get following error:

$ json2cmake      
fatal: not a git repository (or any parent up to mount point /)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
Traceback (most recent call last):
  File "/home/janisozaur/.local/bin/json2cmake", line 10, in <module>
    sys.exit(main())
  File "/home/janisozaur/.local/lib/python3.7/site-packages/json2cmake/__init__.py", line 223, in main
    database.write(args.outfile, name=args.name)
  File "/home/janisozaur/.local/lib/python3.7/site-packages/json2cmake/__init__.py", line 122, in write
    name = os.path.basename(os.path.commonprefix(files).rstrip("/_"))
  File "/usr/lib/python3.7/genericpath.py", line 76, in commonprefix
    if not isinstance(m[0], (list, tuple)):
TypeError: 'set' object does not support indexing
[
    {
        "arguments": [
            "/usr/bin/gcc",
            "-c",
            "-m64",
            "-fPIC",
            "-pipe",
            "-fno-strict-aliasing",
            "-Og",
            "-g",
            "-fno-omit-frame-pointer",
            "-I.",
            "-I../../include",
            "-o",
            "ccc.o",
            "../../../foo/bar_43/ccc.c"
        ],
        "directory": "/home/janisozaur/workspace/foo-build/bar_43",
        "file": "../../../foo/bar_43/ccc.c"
    },
    {
        "arguments": [
            "gcc",
            "-c",
            "-m64",
            "-I.",
            "-I../../include",
            "-fPIC",
            "-pipe",
            "-fno-strict-aliasing",
            "-Og",
            "-g",
            "-fno-omit-frame-pointer",
            "-o",
            "aaa.o",
            "../../../foo/bar_43/aaa.c"
        ],
        "directory": "/home/janisozaur/workspace/foo-build/bar_43",
        "file": "../../../foo/bar_43/aaa.c"
    },
    {
        "arguments": [
            "/usr/bin/gcc",
            "-c",
            "-m64",
            "-fPIC",
            "-pipe",
            "-fno-strict-aliasing",
            "-Og",
            "-g",
            "-fno-omit-frame-pointer",
            "-I.",
            "-I../../include",
            "-o",
            "bbb.o",
            "../../../foo/bar_43/bbb.c"
        ],
        "directory": "/home/janisozaur/workspace/foo-build/bar_43",
        "file": "../../../foo/bar_43/bbb.c"
    }
]

It looks like json2cmake is also looking for some git information, but in this case I built the project outside of the git clone.

Convert README.md to reStructuredText

The README is displayed on GitHub, but also set to the long_description of the package in setup.py, which causes it to be displayed on the PyPI website. The PyPI website only supports reStructuredText (and GitHub also supports it), so that's what we should use.

Python 3.7 --> TypeError: 'set' object does not support indexing

I installed the latest version of json2cmake from Git in an Python 3.7 environment. When trying to run json2cmake I get the following error:

$ python --version
Python 3.7.0
$ json2cmake
Traceback (most recent call last):
  File "/home/salo/proggin/json2cmake/venv/bin/json2cmake", line 11, in <module>
    load_entry_point('json2cmake', 'console_scripts', 'json2cmake')()
  File "/home/salo/proggin/json2cmake/json2cmake/__init__.py", line 223, in main
    database.write(args.outfile, name=args.name)
  File "/home/salo/proggin/json2cmake/json2cmake/__init__.py", line 122, in write
    name = os.path.basename(os.path.commonprefix(files).rstrip("/_"))
  File "/home/salo/proggin/json2cmake/venv/lib/python3.7/genericpath.py", line 76, in commonprefix
    if not isinstance(m[0], (list, tuple)):
TypeError: 'set' object does not support indexing

StopIteration

json2cmake failed and reported some error

fengziteng@ubuntu:~/temp$ ls
CMakeLists.txt  compile_commands.json
fengziteng@ubuntu:~/temp$ git init .
hint: Using 'master' as the name for the initial branch. This default branch name
hint: is subject to change. To configure the initial branch name to use in all
hint: of your new repositories, which will suppress this warning, call:
hint:
hint:   git config --global init.defaultBranch <name>
hint:
hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
hint: 'development'. The just-created branch can be renamed via this command:
hint:
hint:   git branch -m <name>
Initialized empty Git repository in /home/fengziteng/temp/.git/
fengziteng@ubuntu:~/temp$ json2cmake
Traceback (most recent call last):
  File "/home/fengziteng/.local/bin/json2cmake", line 8, in <module>
    sys.exit(main())
  File "/home/fengziteng/.local/lib/python3.10/site-packages/json2cmake/__init__.py", line 222, in main
    database.read(args.infile)
  File "/home/fengziteng/.local/lib/python3.10/site-packages/json2cmake/__init__.py", line 103, in read
    parsecommand(
  File "/home/fengziteng/.local/lib/python3.10/site-packages/json2cmake/__init__.py", line 32, in parsecommand
    next(words)  # remove the initial 'cc' / 'c++'
StopIteration
fengziteng@ubuntu:~/temp$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=22.04
DISTRIB_CODENAME=jammy
DISTRIB_DESCRIPTION="Ubuntu 22.04.1 LTS"
fengziteng@ubuntu:~/temp$ pip install --user json2cmake
Looking in indexes: https://repo.huaweicloud.com/repository/pypi/simple
Requirement already satisfied: json2cmake in /home/fengziteng/.local/lib/python3.10/site-packages (0.6.3)
fengziteng@ubuntu:~/temp$ uname -a
Linux ubuntu 5.15.0-52-generic #58-Ubuntu SMP Thu Oct 13 08:03:55 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

the source ccjson is uploaded as an attachment below.

compile_commands.zip

fatal: not a git repository

fengziteng@ubuntu:~/temp$ json2cmake
fatal: not a git repository (or any of the parent directories): .git

the tool may catch the exception if not a git repo

Project name should be taken from git root dir

Currently the generated CMakeLists.txt always uses a project name of autogenerated. Where possible, it should use basename $(git rev-parse --show-toplevel), the name of the git root directory.

Fix uploading bdist_wheel to PyPI

Travis is only uploading a source tarball, not the bdist_wheel tarball, to PyPI. That means when I release a version I wait for Travis to do its thing, check PyPI, sigh, and locally python setup.py sdist bdist_wheel && twine upload dist/*.whl.

Support pipe input and output

  • If not isatty(stdin), we should read from stdin instead of ./compile_commands.json.
  • If not isatty(stdout), we should write to stdout instead of ./CMakeLists.txt.

That way, it can be invoked like json2cmake <project-build/compile_commands.json >project/CMakeLists.txt

It might be worth having -i and -o parameters too.

`-arch` option not supported

Clang's -arch takes an argument after it, eg. -arch x86_64. The command-line parser doesn't understand this and outputs broken CMake files.

Miscompile with `-DFOO=`

I've just been told that -DFOO= (ie. define FOO to be replaced with no tokens) is compiled the same as -DFOO (ie. define FOO to 1), which can lead to miscompiles.

TypeError: 'set' object is not subscriptable

Ubuntu 20.04.3 LTS
Python 3.8.10

json2cmake generates the following error

Traceback (most recent call last):
File "/home/jk2/.local/bin/json2cmake", line 8, in
sys.exit(main())
File "/home/jk2/.local/lib/python3.8/site-packages/json2cmake/init.py", line 223, in main
database.write(args.outfile, name=args.name)
File "/home/jk2/.local/lib/python3.8/site-packages/json2cmake/init.py", line 122, in write
name = os.path.basename(os.path.commonprefix(files).rstrip("/_"))
File "/usr/lib/python3.8/genericpath.py", line 76, in commonprefix
if not isinstance(m[0], (list, tuple)):
TypeError: 'set' object is not subscriptable

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.