{"id":26013626,"url":"https://github.com/sfuller/devilsmachine","last_synced_at":"2026-05-26T23:02:43.229Z","repository":{"id":62567889,"uuid":"104605952","full_name":"sfuller/devilsmachine","owner":"sfuller","description":"🏭 A framework for integrating preprocessors into your projects with ease","archived":false,"fork":false,"pushed_at":"2018-12-15T04:55:11.000Z","size":26,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-08-08T21:10:28.631Z","etag":null,"topics":["cmake","cmake-modules","preprocessing","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sfuller.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-09-23T23:41:42.000Z","updated_at":"2022-06-08T17:20:49.000Z","dependencies_parsed_at":"2022-11-03T16:00:36.534Z","dependency_job_id":null,"html_url":"https://github.com/sfuller/devilsmachine","commit_stats":null,"previous_names":["galaxgames/devilsmachine"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sfuller%2Fdevilsmachine","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sfuller%2Fdevilsmachine/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sfuller%2Fdevilsmachine/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sfuller%2Fdevilsmachine/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sfuller","download_url":"https://codeload.github.com/sfuller/devilsmachine/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242133486,"owners_count":20077097,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cmake","cmake-modules","preprocessing","python"],"created_at":"2025-03-06T01:54:12.545Z","updated_at":"2026-05-26T23:02:38.210Z","avatar_url":"https://github.com/sfuller.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\ndevilsmachine\n=============\n\ndevilsmachine is a content preprocessor framework that makes integrating preprocessors easy. devilsmachine has first\nclass support for CMake and eliminates the need to write burdensome boilerplate CMake code for each proceprocesor you\nuse. Preprocessors are configured through a deadly simple config file that devilsmachine uses to do the heavy CMake\nlifting.\n\ndevilsmachine makes writing preprocessors easy too. Preprocessors are written as python modules containing a\npreprocessor class. The devilsmachine CMake module handles all of the work for configuring targets for each file a\npreprocessor touches. It's also incredibly easy to use any pip python module, as the CMake module handles setting up a\nvirtual environment and ensuring the required pip packages are installed. All you need to do is define your pip\ndependencies in the devilsmachine config file, in a subsection which is essentially just an embedded requirements.txt\nfile.\n\nIntegrating devilsmachine with your CMake Project\n=================================================\n\nFirst, you must install devilsmachine using devilsmachine's CMakeLists.txt file.\n\n.. code:: sh\n\n    git clone git@github.com:galaxgames/devilsmachine.git\n    cd devilsmachine\n    mkdir build\n    cd build\n    cmake -G \"Unix Makefiles\" ..\n    cmake --build . --target install\n\nThis will install the devilsmachine python library and CMake to your prefix. By default, this prefix is `/usr/local/`.\nIt is recommended that you use a different prefix path for each project. You can change this prefix by passing\n`-DCMAKE_INSTALL_PREFIX=/your/project/prefix/path` into the first `cmake -G` command. I also recomment you check out\ndew_ for an example of how to manage CMake dependencies (or you could just use dew if you're brave enough :wink:)\n\n.. _dew: https://github.com/sfuller/dew\n\nNext, Insert the following into your project's CMakeLists.txt file:\n\n.. code:: cmake\n\n    include(devilsmachine)\n\n    # Assemble a list of all the source files devilsmachine should evaluate and produce output for.\n    # For example, you might have a have a directory (in this example named 'content') that contains all of the files\n    # you need processed.\n    file(GLOB_RECURSE MY_PROJECT_CONTENT_SOURCE_FILES \"${CMAKE_CURRENT_SOURCE_DIR}/content/*\")\n\n    # Next, use this function to have devilsmachine work it's magic!\n    add_devilsmachine_commands(\n        \"${MY_PROJECT_CONTENT_SOURCE_FILES}\"\n        MY_PROJECT_CONTENT_GENERATED_FILES      # This variable will be set with the filenames of all the files\n                                                # that will be generated by devils machine at build time.\n        \"${CMAKE_CURRENT_SOURCE_DIR}/dmconfig\"  # See below for more info about this file\n        \"${CMAKE_CURRENT_SOURCE_DIR}/content\"   # A path to directory which contains all of of your content files.\n                                                # Used to help structure the generated output directory below\n        \"${CMAKE_CURRENT_BINARY_DIR}/content\"   # A path to a directory where all of the generated artifacts should go.\n    )\n\n    # Now create a target which depends on all of the generated files given to us from the above function.\n    # NOTE: In the future, the function above might be able to do this for you. Stay tuned :)\n    add_custom_target(\n        my_project_content\n        DEPENDS ${MY_PROJECT_CONTENT_GENERATED_FILES}\n        SOURCES ${MY_PROJECT_CONTENT_SOURCE_FILES}\n    )\n\n    # Gotta make sure our main target depends on the target we created above using devilsmachine.\n    # Otherwise the generated files your main target needs won't be generated!\n    add_dependencies(my_project my_project_content)\n\nAnd finally, we need to define a config file for devilsmachine, to specify what it should preprocess and how it should\npreprocess.\n\n.. code::\n\n    #\n    # Config file for devilsmachine content preprocessor\n    # https://github.com/galaxgames/devilsmachine\n    #\n\n    [dependencies]\n    pillow==5.2.0\n\n    [processors]\n    tga:\tdevilsmachine.stockmodules:Copy\n    glsl:\tdevilsmachine.stockmodules.glsl:CompileGLSL\n    level:  my_project_preprocessor_module:LevelPreprocessor\n    png:    my_project_preprocessor_module:PngPreprocessor\n\nIn devilsmachine, preprocessor selection is based on the source file file extension. Note that there may be more\ncomplex preprocessor determination features in the future. In this example, we dictate that all .tga files will simply\nbe copied to the output directory using the built-in Copy module. We then dictacte that all .glsl files will be\nprocessed by the built-in glsl module. This glsl module compiles the source file, and outputs the compiled .spirv file\nin the output directory. Note that devilsmachine does not actually contain a glsl compiler, but requires an external\ntool. The devilsmachine CMake module will look for automaticly, as preprocessor modules can list requirement tools to be\nfound by CMake's find_program() machinery.\n\nNext, we have some custom modules. These modules are defined by python modules which live in your project. devilsmachine\nincludes your project root in the PYTHONPATH, allowing you to specify any python modules you have living in your\nproject.\n\nThe syntax for a preprocessor configuration is:\n\n`file_extension: module_name:preprocessor_class_name`\n\nThe dependencies section of the config file defines a requirements.txt file which will be given to pip when installing\nall needed dependency libraries to the project's virtualenv. In our example, our project's PngPreprocessor uses pillow\nas a dependency to do convert png images into another format. Note: In the future, dependencies may be defined in the\nmodules, requiring less configuration for the user.\n\nAnd that's about it!\n====================\nThanks for reading my readme! If this project gets more popular I will put together more thorough documentation of\ncourse. But until then, have an *amazing* day!","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsfuller%2Fdevilsmachine","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsfuller%2Fdevilsmachine","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsfuller%2Fdevilsmachine/lists"}