-
Notifications
You must be signed in to change notification settings - Fork 0
Quickstart
comp4me is a build-system that tries to do most of the work for you. It is aimed at smaller projects without external dependencies (for now..).
All files your code needs (libraries, source files, non-system headers) need to be available from the root directory of your project. They may be linked there via Symlinks, but keep in mind that this makes it harder to share your code with others.
Furthermore, Source-files (.cpp, .c, .cc) may only exist once per name. Additionally it is highly recommended to never use files Source-file typical extensions (.cpp, .c, .cc) as Header-files, and use Header-files whose name only appear once in the project as well.
Enough limitations, here's how you use it:
To install it, create a symbolic link in your System's path folder (for example /bin) to comp4me.py. Then you can use this tool anywhere you like. You create symbolic links with the terminal placed in /bin using sudo ln -s *path/to/comp4me.py*.
You'll need two python libraries, you can install them via: pip install toml pip install argparser.
To run it, just call comp4me.py in your terminal, set in the root of your project. By default, all Source-files are going to be used, and a single executable created. All existing precompiled files (.o, .a, .so, .obj) will be linked as well. Include-Paths will be generated automatically, if there is ambiguity which file should be used the user will be asked to choose.
To change it's behaviour, you can set definitions in a comp.toml file placed at the root of your project.
-
ENTRYPOINT = ["path/to/srcs","...]You can list folders using relative paths from your root directory as Entrypoints. That meanscomp4mewill start out only using these files, and only take files from other folders if it is necessary. Necessary meaning, Header-files from there are needed, or a Source-files with the same name as a used Header file. This definition is inherited to sub-folders of defined folders. Files that are not in such a folder are called Neutral files. -
NEUTRALS = ["path/to/srcs","...]This overrides the definition of folders to be Neutral folders, so they contain neutral files. This is usefull if a sub-folder of an Entrypoint folder is not supposed to be an Entrypoint folder. This definition is inherited to sub-folders of defined folders. -
EXCLUDES = ["path/to/srcs","...]This sets folders, and all files contained in them, to never be used by comp4me. This definition is inherited to sub-folders of defined folders.
You can set the compiler comp4me should use. By default, comp4me first tries to use gcc for C, and g++ for g++ files, if that isn't found it tries to fall back to clang/clang++. For Linking, by default the same command as the used C++ Compiler will be used. You can override all this in comp.toml:
-
CCOMP = "compiler-command"Sets which command is to be used for the Compiler for C files. -
CPPCOMP = "compiler-command"Sets which command is to be used for the Compiler for C++ files. -
LINKER = "compiler-command"Sets which command is to link compiled files. -
AR = "compiler-command"Sets which command is to bundle libraries.
To use flags, different definitions are avaivable:
-
CFLAGS = "flags"orCFLAGS = ["flags1", "flags2"...]Sets which flags should be used to compile C files. -
CPPFLAGS = "flags"orCPPFLAGS = ["flags1", "flags2"...]Sets which flags should be used to compile C++ files. -
LINKERFLAGS = "flags"orLINKERFLAGS = ["flags1", "flags2"...]Sets which flags should be used to link compiled files.
Using the second option, a shortcut to reuse flags is made available:
CFLAGS = "-03"
CPPFLAGS = ["CFLAGS", "-verbose"]
This results in CFLAGS being used for CPPFLAGS as well. This is possible for all commands, as long as they are defined in order.
comp4me recognizes which files are used for what by their file-endings. Default file-endings are:
- C = .c, .s, .S
- CPP = .cpp, .cc
- Header = .h, .hpp
You can append those definitions in your comp.toml file, note that they of course may not overlap:
HEADER = [".hpp", ".x...]C = [".xx", ".x...]CPP = [".xx", ".x...]