Package: smake-buildtools
Copyright (c) 2019Permission is hereby granted, free of charge, to any person obtaining a copyof this software and associated documentation files (the "Software"), to dealin the Software without restriction, including without limitation the rightsto use, copy, modify, merge, publish, distribute, sublicense, and/or sellcopies of the Software, and to permit persons to whom the Software isfurnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included in allcopies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ORIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THEAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHERLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THESOFTWARE.Description: # SMakeSimple Make replacement for lazy developers that like Python.## What is it for?You think that Makefiles are confusing or unreadable?You're too lazy to go through CMake or Autotools? If so, SMake is for you.It's simply a Python module that used in .py file links and compiles your C/C++ project.## Requirements- [Python](http://python.org) 3.6+- Click (optional)## Supported compilers+ gcc+ g+++ clang# Example codeExample for Hello world example:`src/hello.c`:```C#include <stdio.h>int main() {printf("Hello, SMakefile!\n");return 0;}````Smakefile.py`:```pythonimport smake_buildtoolsimport clicksm = smake_buildtools.Smake()sm.name = 'hello'sm.obj_dir = 'obj'sm.bin_dir = 'build'@click.group()def cli():pass@cli.command()def install():sm.gcc.sources = ['src/hello.c']sm.gcc.compiler_flags.append('pedantic')sm.gcc.warning_flags.append('all')sm.gcc.link()sm.gcc.compile()@cli.command()def clean():sm.remove_dir(sm.obj_dir)sm.remove_dir(sm.bin_dir)if __name__ == "__main__":cli()```## Running the script`$ python ./SMakefile.py install`# How to installUsing pip:`$ pip install smake_buildtools`# Okay, how to use it?First you need to import SMake:```pythonimport smake_buildtools```## Defining projectThen define your SMake project:```pythonsm = smake_buildtools.Smake()sm.name = 'app'sm.obj_dir = 'obj'sm.bin_dir = 'build'```## Adding source filesYou need to add some source files for compiler.For example, we have sources in `src/` and `src/module` directories.For this we can use two SMake methods: `Smake.wildcard` and `Smake.merge`.```pythonsm.gcc_cpp.sources = sm.merge(sm.wildcard('src/*.cpp'),sm.wildcard('src/module/*.cpp'))```## Compiler flagsThen add some flags (here we can use some SFML libs):```pythonsm.gcc_cpp.compiler_flags = ['pedantic', 'static']sm.gcc_cpp.warning_flags = ['all']# SFML 2sm.gcc_cpp.linker_flags.append('sfml-graphics')sm.gcc_cpp.linker_flags.append('sfml-window')sm.gcc_cpp.linker_flags.append('sfml-system')sm.gcc_cpp.linker_flags.append('sfml-audio')```## Platform checkingFor Linux it's easy to install libraries via the package manager.But what if you want specifically for Windows to add SFML `include/` and `lib/` directories?With help comes `Smake.get_platform()`:```python# SFML 2if sm.get_platform().startswith('win'): # win32, win64sm.gcc_cpp.include_dirs.append('C:\\SFML2\\include')sm.gcc_cpp.library_dirs.append('C:\\SFML2\\lib')```## Compiling and linkingNow the easiest ones are left: compiling and linking.For this you use `Smake.compile()` and `Smake.link()` method, respectively.```pythonsm.gcc_cpp.compile()sm.gcc_cpp.link()```## SummaryAs you can see, for normal user every line is very clear.If someone wants to compile your code it's easy for them to see what values are used for what.Example code:```pythonimport smake_buildtoolsimport clicksm = smake_buildtools.Smake()sm.name = 'app'sm.obj_dir = 'obj'sm.bin_dir = 'build'@click.group()def cli():pass@cli.command()def install():sm.gcc_cpp.sources = sm.merge(sm.wildcard('src/*.cpp'),sm.wildcard('src/module/*.cpp'))sm.gcc_cpp.compiler_flags = ['pedantic', 'static']sm.gcc_cpp.warning_flags = ['all']# SFML 2sm.gcc_cpp.linker_flags.append('sfml-graphics')sm.gcc_cpp.linker_flags.append('sfml-window')sm.gcc_cpp.linker_flags.append('sfml-system')sm.gcc_cpp.linker_flags.append('sfml-audio')if sm.get_platform().startswith('win'): # win32, win64sm.gcc_cpp.include_dirs.append('C:\\SFML2\\include')sm.gcc_cpp.library_dirs.append('C:\\SFML2\\lib')sm.gcc_cpp.compile()sm.gcc_cpp.link()# post-linking stuffif sm.get_platform().startswith('linux') or sm.get_platform() == 'darwin':target_path = sm.make_path('usr', 'bin', sm.name)sm.copy_executable_to(target_path)@cli.command()def clean():sm.remove_dir(sm.obj_dir)sm.remove_dir(sm.bin_dir)if __name__ == '__main__':cli()```Save this as SMakefile.py in project root directory and run:`$ python ./SMakefile.py install`Keywords: packages,import,downloader,package-managementPlatform: UNKNOWN