{"id":13772748,"url":"https://github.com/pezy-computing/flgen","last_synced_at":"2025-05-11T05:33:32.015Z","repository":{"id":64851562,"uuid":"578819227","full_name":"pezy-computing/flgen","owner":"pezy-computing","description":"Filelist generator","archived":false,"fork":false,"pushed_at":"2025-04-01T00:45:51.000Z","size":119,"stargazers_count":16,"open_issues_count":3,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-17T21:35:28.490Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Ruby","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/pezy-computing.png","metadata":{"files":{"readme":"README.md","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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-12-16T00:31:23.000Z","updated_at":"2025-04-01T00:45:47.000Z","dependencies_parsed_at":"2023-12-27T08:37:16.475Z","dependency_job_id":"a151d39d-b3be-40e4-aef4-af23e6b3c211","html_url":"https://github.com/pezy-computing/flgen","commit_stats":{"total_commits":28,"total_committers":2,"mean_commits":14.0,"dds":0.0714285714285714,"last_synced_commit":"2f617328db96e9758d113954f585d57c811fc7ae"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pezy-computing%2Fflgen","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pezy-computing%2Fflgen/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pezy-computing%2Fflgen/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pezy-computing%2Fflgen/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pezy-computing","download_url":"https://codeload.github.com/pezy-computing/flgen/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253523690,"owners_count":21921815,"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":[],"created_at":"2024-08-03T17:01:07.465Z","updated_at":"2025-05-11T05:33:31.641Z","avatar_url":"https://github.com/pezy-computing.png","language":"Ruby","funding_links":[],"categories":["Build Systems"],"sub_categories":[],"readme":"[![Gem Version](https://badge.fury.io/rb/flgen.svg)](https://badge.fury.io/rb/flgen)\n[![CI](https://github.com/pezy-computing/flgen/actions/workflows/ci.yml/badge.svg)](https://github.com/pezy-computing/flgen/actions/workflows/ci.yml)\n[![codecov](https://codecov.io/github/pezy-computing/flgen/branch/master/graph/badge.svg?token=P5JSMPRV3J)](https://codecov.io/github/pezy-computing/flgen)\n\n# FLGen\n\nFLGen provides a DSL to write filelists and generator tool to generate a filelist which is given to EDA tools.\n\n## Install\n\n### Ruby\n\nFLGen is written in [Ruby](https://www.ruby-lang.org) programing language and its required version is 3.0 or later. You need to install Ruby before using FLGen. See [this page](https://www.ruby-lang.org/en/documentation/installation/) for further details.\n\n### Install FLGen\n\nUse the command below to isntall FLGen.\n\n```\n$ gem install flgen\n```\n\n## Filelist\n\nFLGen prives APIs listed below to describe your filelists.\n\n* `source_file(path, from: nil)`\n    * Add the given source file to the current filelist.\n* `file_list(path, from: nil)`\n    * Load the given filelist.\n* `library_file(path, from: nil)`\n    * Add the given file to the list of library files.\n* `include_directory(path, from: nil)`\n    * Add the given directory to the list of include direcotries.\n* `library_directory(path, from: nil)`\n    * Add the given directory to the list of library directories.\n* `find_files(patterns, from: nil)`\n    * Return an array of filenames matching the given patterns strings.\n    * See [here](https://docs.ruby-lang.org/en/3.2/Dir.html#method-c-glob) for the format of a pattern string.\n* `find_file(patterns, from: nil)`\n    * Return the first filename matching the given pattern strings.\n* `file?(path, from: :current)`\n    * Return `true` if the given file exists.\n* `directory?(path, from: :current)`\n    * Return `true` if the given directory exists.\n* `define_macro(name, value = nil)`\n    * Define a text macro.\n* `undefine_macro(name)`\n    * Undefine the given macro.\n* `macro?(name)`/`macro_defined?(name)`\n    * Return `true` if the given macro is defined.\n* `macro(name)`\n    * Return the value of the given macro.\n* `env?(name)`\n    * Return `true` if the givne environment variable is defined.\n* `env(name)`\n    * Retunr the value of the given environment variable.\n* `compile_argument(argument, tool: nil)`\n    * Add the given argument to the list of compile arguments.\n    * If `tool` is specified the given argument is added only when `tool` is matched with the targe tool.\n* `runtime_argumetn(argument, tool: nil)`\n    * Add the given argument to the list of runtime arguments.\n    * If `tool` is specified the given argument is added only when `tool` is matched with the targe tool.\n* `target_tool?(tool)`\n    * Return `true` if the given tool is matched with the targe tool.\n* `default_search_path(**search_paths)`\n    * Change the default behavior when the `from` argument is not specified.\n* `reset_default_search_path(*target_types)`\n    * Reset the default behavior when the `from` argument is not specified.\n\nFLGen's filelist is designed as an inernal DSL with Ruby. Therefore you can use Ruby's syntax. For example:\n\n```ruby\nif macro? :GATE_SIM\n  source_file 'foo_top.v.gz' # synthsized netlist\nelse\n  source_file 'foo_top.sv' # RTL\nend\n```\n\n### About the `from` argument\n\nThe `from` argument is to specify how to search the given file or directory. You can specify one of three below.\n\n* a directory path\n    * Search the given file or directory from the directory path specified by the `from` argument.\n* `:cwd`\n    * Search the given file or directory from the current working directory.\n* `:current`\n    * Search the given file or directory from the directory where the current filelist is.\n* `:root`\n    * Search the given file or directory from the repository root directories where the `.git` directory is.\n    * Serch order is descending order.\n        * from upper root direcotries to local root direcoty\n* `:local_root`\n    * Search the given file or directory from the repository root directory where the current filelist belongs to.\n\nDefault behaviors when the `from` argument is not spcified are listed below:\n\n\n| API name          | Default `from` argument |\n|:------------------|:------------------------|\n| source_file       | :current                |\n| file_list         | :root                   |\n| library_file      | :current                |\n| include_directory | :current                |\n| library_directory | :current                |\n| find_files        | :current                |\n| find_file         | :current                |\n\nYou can change the above default behaviors by using the `default_search_path` API.\nIn addition, you can reset the default behaviors by using the `reset_default_search_path` API.\n\n```ruby\ndefault_search_path source_file: :root, file_list: :current\nsource_file 'foo.sv'    # FLGen will search the 'foo.sv' file from the root directories.\nfile_list 'bar.list.rb' # FLGen will eaarch the 'bar.list.rb' file from the directory where this file list is.\n\nreset_default_search_path :source_file, :file_list\nsource_file 'baz.sv'    # FLGen will search the 'baz.sv' file from the directory where this file list is.\nfile_list 'qux.list.rb' # FLGen will eaarch the 'qux.list.rb' file from  the root directories.\n```\n\n#### Example\n\nThis is an exmaple directory structure.\n\n```\nfoo_project\n+-- .git\n+-- bar_project\n|   +-- .git\n|   +-- common\n|   |   `-- common.sv\n|   `-- src\n|       + bar.list.rb\n|       ` bar.sv\n`-- common\n    `-- common.sv\n```\n\n* `source_file 'bar.sv', from: :current` @ `bar.list.rb`\n    * `foo_project/bar_project/bar.sv` is added.\n* `source_file 'common/common.sv', from: :root` @ `bar.list.rb`\n    * `foo_project/common/common.sv` is added\n* `source_file 'common/bar_common.sv', from: :local_root` @ `bar.list.rb`\n    * `foo_project/bar_project/common/common.sv` is added\n\n## Generator command\n\n`flgen` is the generator command and generate a filelist which is given to EDA tools from the given filelists. Command line options are listed below.\n\n* `--define-macro=MACRO[,MACRO]`\n    * Define the given macros\n* `--include-directory=DIR[,DIR]`\n    * Specify include directories\n* `--compile`\n    * If this option is specified the generated filelist contains source file path, arguments to define macros, arguments to specify include directories and arguments specified by `compile_argument` API.\n* `--runtime`\n    * If this option is specified the generated filelist contains arguments specified by `runtime_argumetn`\n* `--tool=TOOL`\n    * Specify the target tool.\n* `--rm-ext=EXT[,EXT]`\n    * Remove specifyed file extentions from source file path.\n* `--collect-ext=EXT[,EXT]`\n    * The generated filelist contains source file pash which has the specified file extentions.\n* `--format=FORMAT`\n    * Specify the format of the generated filelist.\n    * If no format is specified FLGen will generate a generated filelist for major EDA tools.\n    * If `vivado-tcl` is specified FLGen will generate a TCL script to load source files for Vivado synthesis.\n    * If `filelist-xsim` is specified FLGen will generate a filelist for Vivado simulator.\n* `--output=FILE`\n    * Specify the path of the generated filelist\n    * The generated fileslist is output to STDOUT if no path is specified.\n* `--[no-]print-header`\n    * Specify whether or not the output filelist includes its file header or not.\n* `--source-file-only`\n    * The generated filelist contains source file path only if this option is specified.\n\n## Example\n\nYou can find an exmpale from [here](https://github.com/pezy-computing/flgen/tree/master/sample).\n\n```\n$ flgen --output=filelist.f sample/foo.list.rb\n$ cat filelist.f\n//  flgen version 0.17.0\n//  applied arguments\n//    --output=filelist.f\n//    sample/foo.list.rb\n+define+BAR_0\n+define+BAR_1=1\n+incdir+/home/taichi/workspace/pezy/flgen/sample/bar\n+incdir+/home/taichi/workspace/pezy/flgen/sample/bar/baz\n-y /home/taichi/workspace/pezy/flgen/sample/bar/bar_lib\n-v /home/taichi/workspace/pezy/flgen/sample/foo_lib.sv\n-foo_0\n/home/taichi/workspace/pezy/flgen/sample/foo.sv\n/home/taichi/workspace/pezy/flgen/sample/bar/bar.sv\n/home/taichi/workspace/pezy/flgen/sample/bar/baz/baz.sv\n```\n\n[rggen-sample-testbench](https://github.com/rggen/rggen-sample-testbench) uses FLGen. This can be a practical example.\n\n* https://github.com/rggen/rggen-sample-testbench/blob/master/env/compile.rb\n* https://github.com/rggen/rggen-sample-testbench/blob/master/rtl/compile.rb\n\n## License\n\nFLGen is licensed under the Apache-2.0 license. See [LICNESE](LICENSE) and below for further details.\n\n```\nCopyright 2022 PEZY Computing K.K.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpezy-computing%2Fflgen","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpezy-computing%2Fflgen","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpezy-computing%2Fflgen/lists"}