Coder Social home page Coder Social logo

yakshalang / yakshaccodepackager Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 947 KB

Tool / DSL to prefix and package C source code

CMake 0.04% Python 0.63% C 91.68% C++ 2.56% Objective-C 5.09%
c99 domain-specific-language dsl python single-header single-header-library

yakshaccodepackager's Introduction

Yaksha C Code Packager

What does this do?

  • Convert C libraries to header only libraries with prefixed names/identifiers/macros.

Why?

  • Avoid name clash in libraries.
  • Easy auto completion.
  • Planned to be used in Yaksha programming language.

How it works?

  • Provides a small python DSL to modify C code.
  • DSL Functions
    • use_source(path: str) - use this source directory (copy it to temp) and chdir
    • patch(patch_filename: str) - apply a .patch file in current temp directory
    • rename(filename: str, renames: Iterable[Tuple[str, str]]) - perform given regex renames
    • remove_comments(filename: str) - remove comments from given file
    • prefix(filename: str, prefix_: str, renames: Iterable[str]) - rename given identifiers with prefix
    • preprocess(filename: str, target: str, is_temp=True, args=("-M",)) - run preprocessor
    • extract_ids(filename: str) -> Set[str] - extract all identifiers (non keyword and larger than 1 char)
    • pack(intro_files: str = "", macro: str = None, private: str = "", public: str = "", target: str = None, is_temp=True) - package files to a single header file
    • PREFIX default prefix
    • PREFIX_U default prefix upper case
  • 3rd party dependencies
    • See in 3rd folder.
    • I needed to patch fcpp with fcpp.patch so it worked for me in Windows.
      • This needs to be compiled
    • libs - Apoorva Joshi's single header packer (used in pack function above)
      • Apply libs.patch
    • python-patch - techtonik's patch script
  • Tools
    • cids - extract c identifiers (ignores preprocessor)
      • Ensure this is compiled first before you run packer.py
      • This is used by extract_ids
  • Main Program
    • packer.py this executes all packing scripts in instructions folder and create single file header files.

yakshaccodepackager's People

Contributors

jadogg avatar

Stargazers

 avatar

Watchers

 avatar

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.