Build capture utility for Linux

Overview

CX-BUILD

Compilation Database alternative

Build

Prerequisite

the CXBUILD uses linux system call trace utility called strace which was customized. So If you want use the cxbuild, you have to build the custom strace(It prints whole path to recognize build commands, https://github.com/damho1104/strace.git)

mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=/usr/local ..
make -j8

When after you build 'cstrace', please copy cstrace binary into '/usr/bin' or '/bin' directory(or add $PATH environement variable) to make the cxbuild freely invokes.

Export single portable binary

Sometimes python and python module requirements is annoying. the pyinstaller can generate everything in single binary. It is really helpful in many cases.

To do this, Required Python 3.x(we tested 3.6.9) and above version. when you ready to build the cxbuild binary, at the source root directory, type below:

python3 -mvenv python
source python/bin/activate
pip install wheel
pip install -r requirements.txt

pip install pyinstaller
pyinstaller build.spec
chmod +x dist/cxbuild
cp dist/cxbuild /usr/local/bin

or Just use cxbuild with python interpreter like this:

source env/bin/activate
pip install -r requirements.txt
python cxbuild.py capture make -j 8

Usage

Capture command

When you ready build your repository, you can use 'capture' command, to make compilation database

cxbuild capture [build command here]

If succeed, "[pwd]/.xdb/compile-commands.json" file will be generated(some intermediate file exist).

Captured command

You can run post process only after build capture completed, It only required when debug something.

The 'captured' command assumes that there exists trace files(full_trace.log) in .xdb directory. and This command run only post process phase, It will generate compile_commands.json file from full_trace.log.

cxbuild captured

Try it

Assumes that 'cstrace' and 'cxbuild' exist in $PATH environment

/bin/cstrace
/bin/cxbuild

gzip

Prepare source build (in Ubuntu OS, apt source command will serve source files to build):

$ apt source gzip
$ls -al
total 1084
drwxr-xr-x  3 minhyuk minhyuk    4096 Nov  1 10:51 .
drwxr-xr-x 12 minhyuk minhyuk    4096 Nov  1 10:51 ..
drwxr-xr-x 11 minhyuk minhyuk    4096 Nov  1 10:52 gzip-1.6
-rw-r--r--  1 minhyuk minhyuk   15604 Jul  8 01:53 gzip_1.6-5ubuntu1.1.debian.tar.xz
-rw-r--r--  1 minhyuk minhyuk    2060 Jul  8 01:53 gzip_1.6-5ubuntu1.1.dsc
-rw-r--r--  1 minhyuk minhyuk 1074924 Aug 21  2013 gzip_1.6.orig.tar.gz

then prepare build tools

$ cd gzip-1.6
$ ./configure

actual build will with cxbuild just type like this:

Making all in tests make[2]: Entering directory '/home/minhyuk/cx/tests/gzip-1.6/tests' make[2]: Nothing to be done for 'all'. make[2]: Leaving directory '/home/minhyuk/cx/tests/gzip-1.6/tests' make[1]: Leaving directory '/home/minhyuk/cx/tests/gzip-1.6' -- [Analyzing build Activities] /home/minhyuk/cx/tests/gzip-1.6/.xdb/xtrace_tree.json > Finished(00:00:09) ">
$ cxbuild capture make -j 8
> eXtension of Compilation Database
-- [Build]
make -j 8
cstrace -s 65535 -e trace=open,openat,execve -v -y -f -o "/home/minhyuk/cx/tests/gzip-1.6/.xdb/full_cstrace.log" -- make -j 8
  GEN      version.c
  GEN      version.h
make  all-recursive
make[1]: Entering directory '/home/minhyuk/cx/tests/gzip-1.6'
Making all in lib
make[2]: Entering directory '/home/minhyuk/cx/tests/gzip-1.6/lib'
  GEN      alloca.h
  GEN      configmake.h
  GEN      c++defs.h
  GEN      arg-nonnull.h
  GEN      warn-on-use.h
  GEN      unused-parameter.h
<...skipped...>
Making all in tests
make[2]: Entering directory '/home/minhyuk/cx/tests/gzip-1.6/tests'
make[2]: Nothing to be done for 'all'.
make[2]: Leaving directory '/home/minhyuk/cx/tests/gzip-1.6/tests'
make[1]: Leaving directory '/home/minhyuk/cx/tests/gzip-1.6'
-- [Analyzing build Activities]
/home/minhyuk/cx/tests/gzip-1.6/.xdb/xtrace_tree.json
> Finished(00:00:09)

Check compile_commands.json:

] ">
$ cat .xdb/compile_commands.json
[
   {
       "directory": "/home/minhyuk/cx/tests/gzip-1.6/lib",
       "command": "gcc -D HAVE_CONFIG_H -I /home/minhyuk/cx/tests/gzip-1.6/lib -g -O2 -MT /home/minhyuk/cx/tests/gzip-1.6/lib/c-strcasecmp.o -MD -MP -MF .deps/c-strcasecmp.Tpo -c -o /home/minhyuk/cx/tests/gzip-1.6/lib/c-strcasecmp.o /home/minhyuk/cx/tests/gzip-1.6/lib/c-strcasecmp.c",
       "file": "c-strcasecmp.c"
   },
   {
       "directory": "/home/minhyuk/cx/tests/gzip-1.6/lib",
       "command": "gcc -D HAVE_CONFIG_H -I /home/minhyuk/cx/tests/gzip-1.6/lib -g -O2 -MT /home/minhyuk/cx/tests/gzip-1.6/lib/c-ctype.o -MD -MP -MF .deps/c-ctype.Tpo -c -o /home/minhyuk/cx/tests/gzip-1.6/lib/c-ctype.o /home/minhyuk/cx/tests/gzip-1.6/lib/c-ctype.c",
       "file": "c-ctype.c"
   },
   {
       "directory": "/home/minhyuk/cx/tests/gzip-1.6/lib",
       "command": "gcc -D HAVE_CONFIG_H -I /home/minhyuk/cx/tests/gzip-1.6/lib -g -O2 -MT /home/minhyuk/cx/tests/gzip-1.6/lib/cloexec.o -MD -MP -MF .deps/cloexec.Tpo -c -o /home/minhyuk/cx/tests/gzip-1.6/lib/cloexec.o /home/minhyuk/cx/tests/gzip-1.6/lib/cloexec.c",
       "file": "cloexec.c"
   },
   {
       "directory": "/home/minhyuk/cx/tests/gzip-1.6/lib",
       "command": "gcc -D HAVE_CONFIG_H -I /home/minhyuk/cx/tests/gzip-1.6/lib -g -O2 -MT /home/minhyuk/cx/tests/gzip-1.6/lib/c-strncasecmp.o -MD -MP -MF .deps/c-strncasecmp.Tpo -c -o /home/minhyuk/cx/tests/gzip-1.6/lib/c-strncasecmp.o /home/minhyuk/cx/tests/gzip-1.6/lib/c-strncasecmp.c",
       "file": "c-strncasecmp.c"
   },
   <...skipped...>
]
You might also like...
MongoDB utility to inflate the contents of small collection to a new larger collection

MongoDB Data Inflater ("data-inflater") The data-inflater tool is a MongoDB utility to automate the creation of a new large database collection using

A utility tool to create .env files

A utility tool to create .env files dump-env takes an .env.template file and some optional environmental variables to create a new .env file from thes

Yet another retry utility in Python

Yet another retry utility in Python, avereno being the Malagasy word for retry.

The git for the Python Story Utility Package library.

SUP The git for the Python Story Utility Package library. Installation: Install SUP by simply running pip install psup in your terminal. Check out our

A utility that makes it easy to work with Python projects containing lots of packages, of which you only want to develop some.

Mixed development source packages on top of stable constraints using pip mxdev [mɪks dɛv] is a utility that makes it easy to work with Python projects

A collection of utility functions to prototype geometry processing research in python

gpytoolbox This repo is a work in progress and contains general utility functions I have needed to code while trying to work on geometry process resea

A morse code encoder and decoder utility.

morsedecode A morse code encoder and decoder utility. Installation Install it via pip: pip install morsedecode Alternatively, you can use pipx to run

Utility to add/remove licenses to/from source files
Utility to add/remove licenses to/from source files

Utility to add/remove licenses to/from source files. Supports processing any combination of globs, files, and directories (recurse). Pruning options allow skipping non-licensing files.

EVE-NG tools, A Utility to make operations with EVE-NG more friendly.
EVE-NG tools, A Utility to make operations with EVE-NG more friendly.

EVE-NG tools, A Utility to make operations with EVE-NG more friendly. Also it support different snapshot operations with same style as Libvirt/KVM

Comments
  • __test_dummy_source__.o is generated at cwd

    __test_dummy_source__.o is generated at cwd

    When you capture a program, __test_dummy_source__.o is generated at cwd.

    $ cxbuild capture gcc -o test test.c
    
    $ ls
    __test_dummy_source__.o test test.c
    
    

    This is not intended behavior. This should be fixed.

    bug 
    opened by HansolChoe 0
  • bug: compile_commands.json may have duplicate data

    bug: compile_commands.json may have duplicate data

    compile_commands.json may have duplicate data(not entirely duplicated because command is slightly different, but compilation target file is same) like below:

    [
        {
            "directory": "/home/workspace/src",
            "command": "gcc -D HAVE_CONFIG_H -I /home/workspace/src -g -O2 -std=gnu99 -Wall -Wextra -Wdeclaration-after-statement -Wpointer-arith -funsigned-char -D _FORTIFY_SOURCE=2 -Wcast-align -Wcast-qual -Wshadow -Wbad-function-cast -Wwrite-strings -Wundef -Wuninitialized -Winit-self -Wnested-externs -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Waggregate-return -pipe -MT /home/workspace/src/g72x.lo -MD -MP -MF .deps/g72x.Tpo -c -fPIC -D PIC -o /home/workspace/src/.libs/g72x.o -I /usr/lib/gcc/x86_64-linux-gnu/7/include -I /usr/local/include -I /usr/lib/gcc/x86_64-linux-gnu/7/include-fixed -I /usr/include/x86_64-linux-gnu -I /usr/include /home/workspace/src/g72x.c",
            "file": "/home/workspace/src/g72x.c"
        },
       ...
        {
            "directory": "/home/workspace/src",
            "command": "gcc -D HAVE_CONFIG_H -I /home/workspace/src -g -O2 -std=gnu99 -Wall -Wextra -Wdeclaration-after-statement -Wpointer-arith -funsigned-char -D _FORTIFY_SOURCE=2 -Wcast-align -Wcast-qual -Wshadow -Wbad-function-cast -Wwrite-strings -Wundef -Wuninitialized -Winit-self -Wnested-externs -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Waggregate-return -pipe -MT /home/workspace/src/g72x.lo -MD -MP -MF .deps/g72x.Tpo -c -o /home/workspace/src/g72x.o -I /usr/lib/gcc/x86_64-linux-gnu/7/include -I /usr/local/include -I /usr/lib/gcc/x86_64-linux-gnu/7/include-fixed -I /usr/include/x86_64-linux-gnu -I /usr/include /home/workspace/src/g72x.c",
            "file": "/home/workspace/src/g72x.c"
        },
      ...
    ]
    

    The command below does not have -fPIC -D PIC but other data are same. This is confusing.

    This symptom can be reproduced by cxbuild captured command at root of this file(fixed.1.zip). It is normal that .xdb/artifacts.zip is empty.

    bug 
    opened by HansolChoe 0
  • Some paths are not captured properly (not absoulte path)

    Some paths are not captured properly (not absoulte path)

    In some cases, paths in projects.json are not recorded in absolute path.

    If you capture the build information of gzip-1.11, you may see logs like below:

    $ ./configure && cxbuild capture make -j10
    ...
    > eXtension of Compilation Database
    -- [Analyzing build Activities]
    -- [Build trace preprocessed]
    -- [project.json written [/home/vagrant/workspace/gzip-1.11/.xdb/project.json]]
    -- [compile_commands.json written [/home/vagrant/workspace/gzip-1.11/.xdb/compile_commands.json]]
      > All dependency should start with '//'. Ignore 'threadlib.c'.
      > All dependency should start with '//'. Ignore 'lock.c'.
    -- [artifacts.zip written [/home/vagrant/workspace/gzip-1.11/.xdb/artifacts.zip]]
    

    threadlib.c and lock.c are not absolute path. In this case, cxbuild is not killed, but it prints warning messages and ignores the two files.

    These files may be okay to ignore, but we need to know when these things happen.

    bug 
    opened by HansolChoe 1
Releases(dpp)
  • dpp(Nov 3, 2022)

    Commits

    • clang-11 no such compiler error (vulcan-action)
    • artifact.zip except for library(.so etc) file (vulcan-action)
    • 6c466f1: Fix get_system_include_list and get_predefined_macro (HansolChoe)
    • 48bf810: Fix _ArtifactBuilder to use the function in cslib (HansolChoe)
    • f7ef04f: Fix _gnu_compiler_tool's compiler setting and pytest (HansolChoe)
    • b975946: Remove is_debug_mode call csutil (HansolChoe)
    • 1e0b592: Fixed _ArtifactBuilder to collect source or header file (Yeongcheol Kim)
    • 51a75a5: Revised to not remove artifacts directory (Yeongcheol Kim)
    • 1eb568b: Revised to check CXBUILD_OUTPUT_DIR environment variable and set as working_dir (Yeongcheol Kim)
    • afd9e0b: cc를 compiler로 인식하도록 패턴 추가 (HansolChoe)
    • 72f8b8e: cc를 command로 인식하도록 추가 (HansolChoe)
    Source code(tar.gz)
    Source code(zip)
    Release-cxbuild-Ubuntu-18.04.tar.gz(10.29 MB)
Owner
GLaDOS (G? L? Automatic Debug Operation System)
GLaDOS (G? L? Automatic Debug Operation System)
ZX Spectrum Utilities: (zx-spectrum-utils)

Here are a few utility programs that can be used with the zx spectrum. The ZX Spectrum is one of the first home computers from the early 1980s.

Graham Oakes 4 Mar 07, 2022
A Tool that provides automatic kerning for ligature based OpenType fonts in Microsoft Volt

Kerning A Tool that provides automatic kerning for ligature based OpenType fonts in Microsoft Volt There are three stages of the algorithm. The first

Sayed Zeeshan Asghar 6 Aug 01, 2022
Modeling Category-Selective Cortical Regions with Topographic Variational Autoencoders

Modeling Category-Selective Cortical Regions with Topographic Variational Autoencoders Getting Started Install requirements with Anaconda: conda env c

T. Andy Keller 4 Aug 22, 2022
API Rate Limit Decorator

ratelimit APIs are a very common way to interact with web services. As the need to consume data grows, so does the number of API calls necessary to re

Tomas Basham 575 Jan 05, 2023
Multipurpose Growtopia Server tools, can be used for newbie to learn things.

Information Multipurpose Growtopia Server tools, can be used for newbie to learn things. Requirements - Python 3.x - Operating System (Recommended : W

Morphias 2 Oct 29, 2021
Color getter (including method to get random color or complementary color) made out of Python

python-color-getter Color getter (including method to get random color or complementary color) made out of Python Setup pip3 install git+https://githu

Jung Gyu Yoon 2 Sep 17, 2022
Application for easy configuration of swap file and swappiness priority in slackware and others linux distributions.

Swap File Program created with the objective of assisting in the configuration of swap file in Distributions such as Slackware. Required packages: pyt

Mauricio Ferrari 3 Aug 06, 2022
Python program for analyzing the output files of phonopy.

PhononTools Description Python program to analyze the results generated by phonopy. Using the .yaml and .dat files that phonopy generates one can plot

Harry LaBollita 8 Nov 27, 2022
Find unused resource keys in properties files in a Salesforce Commerce Cloud project and get rid of them.

Find Unused Resource Keys Find unused resource keys in properties files in a Salesforce Commerce Cloud project and get rid of them. It looks through a

Noël 5 Jan 08, 2022
A python module to update the console without flashing.

A python module to update the console without flashing.

Matthias 112 Dec 19, 2022
A thing to simplify listening for PG notifications with asyncpg

A thing to simplify listening for PG notifications with asyncpg

ANNA 18 Dec 23, 2022
✨ Un générateur de mot de passe aléatoire totalement fait en Python par moi, et en français.

Password Generator ❗ Un générateur de mot de passe aléatoire totalement fait en Python par moi, et en français. 🔮 Grâce a une au module random et str

MrGabin 3 Jul 29, 2021
Protect your eyes from eye strain using this simple and beautiful, yet extensible break reminder

Protect your eyes from eye strain using this simple and beautiful, yet extensible break reminder

Gobinath 1.2k Jan 01, 2023
A simple and easy to use Spam Bot made in Python!

This is a simple spam bot made in python. You can use to to spam anyone with anything on any platform.

7 Sep 08, 2022
A collection of custom scripts for working with Quake assets.

Custom Quake Tools A collection of custom scripts for working with Quake assets. Features Script to list all BSP files in a Quake mod

Jason Brownlee 3 Jul 05, 2022
We provide useful util functions. When adding a util function, please add a description of the util function.

Utils Collection Motivation When we implement codes, we often search for util functions that are already implemented. Here, we are going to share util

6 Sep 09, 2021
A random cats photos python module

A random cats photos python module

Fayas Noushad 6 Dec 01, 2021
A simple example for calling C++ functions in Python by `ctypes`.

ctypes-example A simple example for calling C++ functions in Python by ctypes. Features call C++ function int bar(int* value, char* msg) with argumene

Yusu Pan 3 Nov 23, 2022
Group imports from Windows binaries

importsort This is a tool that I use to group imports from Windows binaries. Sometimes, you have a gigantic folder full of executables, and you want t

【☆ ゆう ☆ 】 15 Aug 27, 2022
jsoooooooon derulo - Make sure your 'jason derulo' is featured as the first part of your json data

jsonderulo Make sure your 'jason derulo' is featured as the first part of your json data Install: # python pip install jsonderulo poetry add jsonderul

jesse 3 Sep 13, 2021