{"id":19271103,"url":"https://github.com/mgood7123/kpp","last_synced_at":"2025-04-21T21:30:37.696Z","repository":{"id":119195722,"uuid":"177743009","full_name":"mgood7123/kpp","owner":"mgood7123","description":"kotlin pre-processor, written in kotlin for kotlin - all updates will now come from https://github.com/mgood7123/kpp-Native","archived":false,"fork":false,"pushed_at":"2019-04-10T05:03:15.000Z","size":988,"stargazers_count":6,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-01T16:11:18.996Z","etag":null,"topics":["kotlin","pre","pre-processor","prepreprocessor","processor"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mgood7123.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-03-26T08:14:59.000Z","updated_at":"2025-02-14T02:40:36.000Z","dependencies_parsed_at":null,"dependency_job_id":"7b54637b-1b10-45ef-851b-4109b887c7de","html_url":"https://github.com/mgood7123/kpp","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mgood7123%2Fkpp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mgood7123%2Fkpp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mgood7123%2Fkpp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mgood7123%2Fkpp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mgood7123","download_url":"https://codeload.github.com/mgood7123/kpp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250136614,"owners_count":21380866,"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":["kotlin","pre","pre-processor","prepreprocessor","processor"],"created_at":"2024-11-09T20:29:09.678Z","updated_at":"2025-04-21T21:30:37.675Z","avatar_url":"https://github.com/mgood7123.png","language":"Kotlin","readme":"# KPP\nKPP is a kotlin pre-processor developed in Kotlin DSL (kotlin build script) for android studio and the kotlin language\n\nit is currently in beta as it is not fully functional yet\n\n# UNDER CONSTRUCTION\n\n## TODO\n* improve documentation\n* publish plugin\n* figure out how to include this in other projects\n* improve installation and usage information\n* figure out how to hook gradle syntax analysis to provide autocompletion for directives and macros\n\n## what works?\n* #define is fully functional\n\n## what does not work?\n* `#undef`\n* stringilization :  `#define tostring(x) #x`\n* token concation :  `#define cat(a,b) a##b`\n* predefined macros : `__FILE__, __LINE__, and others`\n* `#ifdef`\n* `#endif`\n* `#if`\n* `#else`\n* `#fi`\n* any other directives i may have missed\n\n\n\n\n\n\n\n\n\n\n\n# old README.md\n\n# how do i use kpp?\nin project root\n```\ngit clone https://github.com/mgood7123/kpp\n```\n\nby default, kpp's install directory is hardcoded to ProjectRoot/kpp, eg `/home/superlock/AndroidStudioProjects/AudioEvolved/kpp` where `AudioEvolved` is the ProjectRoot\n\nin module you wish kpp to operate on\n\nfor example, if i want KPP to process all files in `/home/superlock/AndroidStudioProjects/AudioEvolved/app`, i would append\n```\napply from: '../kpp/build.gradle.kts'\n\npreBuild.dependsOn KOTLIN_PRE_PROCESSOR\n```\n\nto `/home/superlock/AndroidStudioProjects/AudioEvolved/app/build.gradle`\n\n# how it works\nthe internals of kpp are simple\n\nfirst, it operates on the following rules:\n\n```\nin order to explain we need to assume something first\n\nsrc = /home/superlock/AndroidStudioProjects/AudioEvolved/app/src/main/java/start_of_email/smallville7123/at/gmail/com/end_of_email/apps/audioevolved/UI.kt\n\ndest = /home/superlock/AndroidStudioProjects/AudioEvolved/kpp/src/main/java/start_of_email/smallville7123/at/gmail/com/end_of_email/apps/audioevolved/UI.kt\n\nwhen src is about to be scanned, it first checks for the existence of dest\n\nif dest exist, kpp will process dest\n\nif dest does not exist, it will scan src\n    if src contains any pre-processing information such as #defines, kpp will move src to dest, overwriting it if it exists\n    if src does not contain pre-processing info, kpp will leave src alone\n\nif dest no longer contains pre-processing info, kpp will copy dest back to src, overwriting src\n```\n\nafter it has found files with pre-processing information, those files are kept in kpp's internal folder and any changes to the src will no longer be effective, this is explained after\n\nwhen kpp processes files in its internal folder, any changes made to any file are automatically applied to the original src of that file\n\nfor example:\n```\nif you have a\n\n#define a b\n\nin src, kpp will copy src to dest, process dest to dest.preprocessed.kt, then copy dest.preprocessed.kt to src, overwriting src\n\nif you delete the contents of src, but not src itself, the contents of src is restored when kpp processes dest\n\nif you modify dest, src will also be modified accordingly\n\nif dest no longer contains\n\n#define a b\n\ndest will be moved to src, and its files removed from the kpp folder\n\nif you delete the contents of dest, the src will also have its contents deleted, and dest will be deleted as it has no pre-processing information such as #define due to the fact dest is now empty\n```\n\ngiven this, the verbose log of KPP is maintained in the Build tabs console view, and depending on your build file, is the very first task executed\n\nones build might look like this\n\n```\nsync failed\t19 s 923 ms\nRun build\t19 s 279 ms\n    Load build\t161 ms\n        Run init scripts\t145 ms\n        Evaluate settings\t16 ms\n    Configure build\t19 s 49 ms\n        Load projects\t14 ms\n        Configure project :\t711 ms\n            Register task :init\n            Register task :wrapper\t1 ms\n        Configure project :app\t18 s 302 ms\n\n\u003e Configure project :app\nstarting KOTLIN_PRE_PROCESSOR\nusing preprocessing examples.kt in kpp/src\nregistered macro definition for preprocessing examples.kt at index 1\nprocessing preprocessing examples.kt -\u003e preprocessing examples.kt.preprocessed.kt\npreprocessing examples.kt: preprocessor directive: define\npreprocessing examples.kt: preprocessor line: #define foob(X,                 y                 ,               Z             )              bar X y Z\ntext : (X,                 y                 ,               Z             )\nextracting arguments for X,                 y                 ,               Z\nArguments List = [X, y, Z]\nexpanding line '             bar X y Z'\ntokens to ignore : [ , (, ), ., ,, -, \u003e]\ntokenization : [ ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  , bar,  , X,  , y,  , Z]\nexpanded string :              bar X y Z\nType       = function\nToken      = foob\nArguments  = [X, y, Z]\nValue      =              bar X y Z\nLISTING MACROS\n[0].FullMacro  = #define foob(X,                 y                 ,               Z             )              bar X y Z\n[0].Type       = function\n[0].Token      = foob\n[0].Arguments  = [X, y, Z]\n[0].Value      =              bar X y Z\nLISTED MACROS\nexpanding line 'foob a(1,2,3) // object'\ntokens to ignore : [ , (, ), ., ,, -, \u003e]\ntokenization : [foob,  , a, (, 1, ,, 2, ,, 3, ),  , //,  , object]\nfoob of type matches foob\ntoken list     = foob\ndetermining if foob is a function or an object\nfoob is an object\nfoob of type function has value              bar X y Z\nfoob of type function does not match a\nfoob of type function does not match 1\nfoob of type function does not match 2\nfoob of type function does not match 3\nfoob of type function does not match //\nfoob of type function does not match object\nexpanded string :              bar X y Z a(1,2,3) // object\nexpanding line 'foob (1,2,3) // function'\ntokens to ignore : [ , (, ), ., ,, -, \u003e]\ntokenization : [foob,  , (, 1, ,, 2, ,, 3, ),  , //,  , function]\nfoob of type matches foob\ntoken list     = foob\ndetermining if foob is a function or an object\nfoob is a function\ntoken list [2] = (\nfoob of type function has value              bar X y Z\nfoob of type function does not match 1\nfoob of type function does not match 2\nfoob of type function does not match 3\nfoob of type function does not match //\nfoob of type function does not match function\nexpanded string : foob (1,2,3) // function\nexpanding line 'foob(1,2,3) // function'\ntokens to ignore : [ , (, ), ., ,, -, \u003e]\ntokenization : [foob, (, 1, ,, 2, ,, 3, ),  , //,  , function]\nfoob of type matches foob\ntoken list     = foob\ndetermining if foob is a function or an object\nfoob is a function\ntoken list [1] = (\nfoob of type function has value              bar X y Z\nfoob of type function does not match 1\nfoob of type function does not match 2\nfoob of type function does not match 3\nfoob of type function does not match //\nfoob of type function does not match function\nexpanded string : foob(1,2,3) // function\nexpanding line ''\ntokens to ignore : [ , (, ), ., ,, -, \u003e]\ntokenization : []\nexpanded string :\npreprocessing examples.kt.preprocessed.kt (in kpp/src) copied back to original source\nKOTLIN_PRE_PROCESSOR finished\n\nFAILURE: Build failed with an exception.\n\n* Where:\nBuild file '/home/superlock/AndroidStudioProjects/AudioEvolved/app/build.gradle' line: 39\n\n* What went wrong:\nA problem occurred evaluating project ':app'.\n\u003e Could not create task ':app:KOTLIN_PRE_PROCESSOR'.\n   \u003e Aborted\n\n* Try:\nRun with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.\n\n* Get more help at https://help.gradle.org\n\nCONFIGURE FAILED in 19s\nAborted\nOpen File\n```\n\nthis is taken at the time of this documents writing, and at the current state of KPP\n\nthe Aborted here is intentional as i am only focussing on KPP, and need not actually build the project untill i actually get kpp to be stable, in which i will start implementing kotlin specific pre-processor directives\n\njava is also going to be supported, but for now i am focusing on kotlin\n\n# implemented\n`#define`   ( define directive fully supports object like macros, and function like macros )\n\n# yet to be implemented\n`#undef`\n\nstringilization :  `#define tostring(x) #x`\n\ntoken concation :  `#define cat(a,b) a##b`\n\npredefined macros : `__FILE__, __LINE__, and others`\n\n`#ifdef`\n\n`#endif`\n\n`#if`\n\n`#else`\n\n`#fi`\n\nany other directives i may have missed\n\n# why not just use cpp\n\ncpp is intended for `C`, `C#`, and `C++` and as such produces unwanted text in its output, such as `#line` directives, aswell as not properly supporting the kotlin language (using cpp on anything other than the C language set is considered abuse of the preprocessor, and may result in unintended side effects\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmgood7123%2Fkpp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmgood7123%2Fkpp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmgood7123%2Fkpp/lists"}